Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
save-exact=true
save-exact=true
# Link internal @parallax/* packages from the workspace by version (they are
# unpublished and only bundled into parallax-cli), so package.json can pin
# concrete versions instead of the workspace:* protocol.
link-workspace-packages=true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lint:fix": "pnpm --filter './packages/*' -r lint:fix && pnpm exec eslint eslint.config.js --fix",
"parallax": "NODE_ENV=dev pnpm --filter parallax-cli start",
"clean": "rm -rf packages/orchestrator/parallax.db packages/orchestrator/workspaces",
"version:set": "node scripts/set-version.mjs",
"release:pack": "pnpm --filter parallax-cli pack:tarball",
"release:publish": "pnpm --dir packages/cli publish:package"
},
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
"dependencies": {
"@clack/prompts": "1.4.0",
"@fastify/cors": "11.2.0",
"@parallax/common": "workspace:*",
"@parallax/orchestrator": "workspace:*",
"@parallax/slack": "workspace:*",
"@parallax/ui": "workspace:*",
"@parallax/common": "0.1.0",
"@parallax/orchestrator": "0.1.0",
"@parallax/slack": "0.1.0",
"@parallax/ui": "0.1.0",
"@slack/bolt": "^4.0.0",
"@slack/web-api": "^7.0.0",
"chalk": "4",
"fastify": "5.7.4",
"log-update": "7.1.0",
Expand Down
22 changes: 21 additions & 1 deletion packages/cli/scripts/prepare-package.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'node:fs/promises'
import { lstatSync, readlinkSync } from 'node:fs'
import { lstatSync, readlinkSync, readFileSync } from 'node:fs'
import path from 'node:path'
import { execFileSync } from 'node:child_process'
import { fileURLToPath } from 'node:url'
Expand Down Expand Up @@ -51,8 +51,27 @@ const bundledPackages = [
type: 'module',
},
},
{
name: '@parallax/slack',
sourceDir: path.join(workspaceRoot, 'packages/slack'),
packageJson: {
name: '@parallax/slack',
version: '0.0.4',
type: 'module',
},
},
]

// Pin each bundled package to its real workspace version so the published
// package.json, the flattened bundled package.json, and the rewritten cli
// dependency ranges all stay consistent across releases.
for (const metadata of bundledPackages) {
const { version } = JSON.parse(
readFileSync(path.join(metadata.sourceDir, 'package.json'), 'utf8')
)
metadata.packageJson.version = version
}

function runPnpm(args) {
execFileSync('pnpm', ['--dir', workspaceRoot, ...args], {
stdio: 'inherit',
Expand Down Expand Up @@ -120,6 +139,7 @@ async function main() {
'@parallax/common': bundledPackages[0].packageJson.version,
'@parallax/orchestrator': bundledPackages[1].packageJson.version,
'@parallax/ui': bundledPackages[2].packageJson.version,
'@parallax/slack': bundledPackages[3].packageJson.version,
},
}
await fs.writeFile(cliPackageJsonPath, JSON.stringify(rewrittenCliPackageJson, null, 2) + '\n')
Expand Down
14 changes: 10 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions scripts/set-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

// Sets a single version across the whole workspace: the root package, every
// package under packages/*, and the internal @parallax/* dependency pins in the
// published cli package. Keeping these in lockstep is required because the
// @parallax/* packages are unpublished — the cli links them from the workspace
// by version (link-workspace-packages=true), so a stale pin would fall back to
// the npm registry and fail to resolve.
//
// Usage: node scripts/set-version.mjs <version>

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const workspaceRoot = path.resolve(__dirname, '..')

const version = process.argv[2]
if (!version || !/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(version)) {
console.error(`Usage: node scripts/set-version.mjs <version>\nGot: ${version ?? '(none)'}`)
process.exit(1)
}

const packagesDir = path.join(workspaceRoot, 'packages')
const packageJsonPaths = [
path.join(workspaceRoot, 'package.json'),
...fs
.readdirSync(packagesDir)
.map((name) => path.join(packagesDir, name, 'package.json'))
.filter((p) => fs.existsSync(p)),
]

const internalPrefix = '@parallax/'

for (const pkgPath of packageJsonPaths) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
pkg.version = version

// Re-pin any non-workspace internal dependency ranges to the new version.
for (const field of ['dependencies', 'devDependencies', 'peerDependencies']) {
const deps = pkg[field]
if (!deps) continue
for (const name of Object.keys(deps)) {
if (name.startsWith(internalPrefix) && !deps[name].startsWith('workspace:')) {
deps[name] = version
}
}
}

fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
console.log(`${path.relative(workspaceRoot, pkgPath)} -> ${version}`)
}
Loading