-
Notifications
You must be signed in to change notification settings - Fork 8
feat(gastown): configurable merge strategy (direct/PR) #701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules | ||
| .wrangler |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Generated by scripts/prepare-container.mjs for Docker builds. | ||
| # pnpm needs the workspace yaml and lockfile to resolve catalog: references. | ||
| pnpm-workspace.yaml | ||
| pnpm-lock.yaml | ||
| package.prod.json |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /** | ||
| * Copy the root pnpm-workspace.yaml (catalog only) and pnpm-lock.yaml | ||
| * into the container build context so pnpm can resolve catalog: references. | ||
| * | ||
| * The packages: section and other non-catalog sections are stripped because | ||
| * those workspace paths don't exist inside the container and would cause | ||
| * pnpm to error on workspace: references. | ||
| */ | ||
|
|
||
| import { readFileSync, writeFileSync, copyFileSync } from 'node:fs'; | ||
| import { resolve, dirname } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const gastownRoot = resolve(__dirname, '..'); | ||
| const repoRoot = resolve(gastownRoot, '..'); | ||
| const containerDir = resolve(gastownRoot, 'container'); | ||
|
|
||
| // Read root workspace yaml and extract only the catalog: section. | ||
| // Parse line-by-line: keep lines from `catalog:` until the next | ||
| // top-level key (a line starting with a non-space, non-comment char). | ||
| const lines = readFileSync(resolve(repoRoot, 'pnpm-workspace.yaml'), 'utf8').split('\n'); | ||
| const catalogLines = []; | ||
| let inCatalog = false; | ||
|
|
||
| for (const line of lines) { | ||
| if (line.startsWith('catalog:')) { | ||
| inCatalog = true; | ||
| catalogLines.push(line); | ||
| continue; | ||
| } | ||
| if (inCatalog) { | ||
| // Still in catalog if line is indented, empty, or a comment | ||
| if (line === '' || line.startsWith(' ') || line.startsWith('\t') || line.startsWith('#')) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [SUGGESTION]: Empty lines at the end of the If |
||
| catalogLines.push(line); | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| writeFileSync(resolve(containerDir, 'pnpm-workspace.yaml'), catalogLines.join('\n') + '\n'); | ||
|
|
||
| // Create a production-only package.json that strips workspace: references | ||
| // (they can't be resolved outside the monorepo). | ||
| const pkg = JSON.parse(readFileSync(resolve(containerDir, 'package.json'), 'utf8')); | ||
| if (pkg.devDependencies) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [SUGGESTION]: Only strips If a production dependency in Consider also stripping for (const section of ['dependencies', 'devDependencies']) {
if (pkg[section]) {
for (const [name, version] of Object.entries(pkg[section])) {
if (typeof version === 'string' && version.startsWith('workspace:')) {
delete pkg[section][name];
}
}
}
} |
||
| for (const [name, version] of Object.entries(pkg.devDependencies)) { | ||
| if (typeof version === 'string' && version.startsWith('workspace:')) { | ||
| delete pkg.devDependencies[name]; | ||
| } | ||
| } | ||
| } | ||
| writeFileSync(resolve(containerDir, 'package.prod.json'), JSON.stringify(pkg, null, 2) + '\n'); | ||
|
|
||
| // Copy the lockfile as-is | ||
| copyFileSync(resolve(repoRoot, 'pnpm-lock.yaml'), resolve(containerDir, 'pnpm-lock.yaml')); | ||
|
|
||
| console.log( | ||
| 'Prepared container build context with pnpm-workspace.yaml (catalog only) and pnpm-lock.yaml' | ||
| ); | ||
Uh oh!
There was an error while loading. Please reload this page.