Skip to content

Commit

Permalink
Update workspace dependencies to use current version
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Feb 23, 2024
1 parent 8be1c6e commit cbd2e1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions packages/create/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { fileURLToPath } from 'url'
import { exit } from 'node:process'

const BRANCH = 'rc'
const CURRENT_VERSION = '>=2.0.0-rc.1'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const pkg = readJSONFileSync(resolve(__dirname, '../../package.json'))
Expand Down Expand Up @@ -63,14 +64,14 @@ program
appPkg.name = appName
const targetPackages = []
for (const key in appPkg.dependencies) {
if (pkg.version && appPkg.dependencies[key] === 'workspace:^') {
appPkg.dependencies[key] = `^${pkg.version}`
if (appPkg.dependencies[key] === 'workspace:^') {
appPkg.dependencies[key] = CURRENT_VERSION
}
targetPackages.push(key)
}
for (const key in appPkg.devDependencies) {
if (pkg.version && appPkg.devDependencies[key] === 'workspace:^') {
appPkg.devDependencies[key] = `^${pkg.version}`
if (appPkg.devDependencies[key] === 'workspace:^') {
appPkg.devDependencies[key] = CURRENT_VERSION
}
targetPackages.push(key)
}
Expand Down
6 changes: 5 additions & 1 deletion packages/create/tests/new/test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { execSync } from 'node:child_process'
import { rm } from 'css-shared/utils/fs'
import { join } from 'node:path'
import { existsSync } from 'node:fs'
import { existsSync, readFileSync } from 'node:fs'

it('creates a new app', () => {
rm(join(__dirname, 'my-app'))
execSync('tsx ../../src/bin my-app', { cwd: __dirname })
expect(existsSync(join(__dirname, 'my-app/package.json'))).toBe(true)
})

it('should install the remote dependencies', () => {
expect(readFileSync(join(__dirname, 'my-app/package.json')).toString()).not.toContain('workspace:^')
})

0 comments on commit cbd2e1c

Please sign in to comment.