@warpgogol/repo-extract 1.4.0 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/extract.js +23 -7
- package/dist/fs/transform.d.ts +3 -1
- package/dist/fs/transform.d.ts.map +1 -1
- package/dist/fs/transform.js +14 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
package/dist/extract.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</CHANGE_SUMMARY>
|
|
18
18
|
*/
|
|
19
19
|
import { stat, cp, mkdir, writeFile, readFile } from "node:fs/promises";
|
|
20
|
-
import { readFileSync } from "node:fs";
|
|
20
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
21
21
|
import { execFileSync } from "node:child_process";
|
|
22
22
|
import * as path from "node:path";
|
|
23
23
|
import { SecretScanError, PackageManagerError, GitOperationError } from "./errors.js";
|
|
@@ -352,7 +352,13 @@ async function exportMonorepo(root, dest, config, logger, emit) {
|
|
|
352
352
|
// 13. Generate lockfile
|
|
353
353
|
logger.log(`Generating ${pm} lockfile...`);
|
|
354
354
|
const installBin = pm === "pnpm" ? "pnpm" : pm === "yarn" ? "yarn" : "npm";
|
|
355
|
-
|
|
355
|
+
// --ignore-workspace: when the dest dir sits inside another pnpm workspace
|
|
356
|
+
// (e.g. pipelines self-export under packages/packages/), plain `install`
|
|
357
|
+
// resolves the ancestor workspace root and writes the lockfile THERE —
|
|
358
|
+
// dest ships without a lockfile and CI's --frozen-lockfile fails.
|
|
359
|
+
const installArgs = pm === "pnpm"
|
|
360
|
+
? ["install", "--ignore-workspace", "--config.dangerouslyAllowAllBuilds=true"]
|
|
361
|
+
: ["install"];
|
|
356
362
|
try {
|
|
357
363
|
execFileSync(installBin, installArgs, { cwd: dest, stdio: "pipe" });
|
|
358
364
|
logger.log(` generated ${pm} lockfile`);
|
|
@@ -366,11 +372,14 @@ async function exportMonorepo(root, dest, config, logger, emit) {
|
|
|
366
372
|
// 14. Cleanup stray artifacts
|
|
367
373
|
logger.log("Cleaning stray artifacts...");
|
|
368
374
|
await cleanStrayArtifacts(dest);
|
|
369
|
-
// 14b. Generate CI workflow
|
|
375
|
+
// 14b. Generate CI workflow — lockfile presence decides frozen-install/cache
|
|
370
376
|
logger.log("Generating CI workflow...");
|
|
371
377
|
const ciDir = path.join(dest, ".github", "workflows");
|
|
372
378
|
await mkdir(ciDir, { recursive: true });
|
|
373
|
-
const
|
|
379
|
+
const lockfileName = pm === "pnpm" ? "pnpm-lock.yaml" : pm === "yarn" ? "yarn.lock" : "package-lock.json";
|
|
380
|
+
const ciContent = generateCiWorkflow(pm, config.ci, {
|
|
381
|
+
lockfileShips: existsSync(path.join(dest, lockfileName)),
|
|
382
|
+
});
|
|
374
383
|
if (ciContent) {
|
|
375
384
|
await writeFile(path.join(ciDir, "ci.yml"), ciContent);
|
|
376
385
|
logger.log(" generated .github/workflows/ci.yml");
|
|
@@ -483,7 +492,11 @@ async function exportStandalonePackage(root, dest, config, logger, emit) {
|
|
|
483
492
|
// 4d. Generate lockfile
|
|
484
493
|
logger.log(`Generating ${pm} lockfile...`);
|
|
485
494
|
const installBin = pm === "pnpm" ? "pnpm" : pm === "yarn" ? "yarn" : "npm";
|
|
486
|
-
|
|
495
|
+
// --ignore-workspace: see step 13 above — dest inside an ancestor workspace
|
|
496
|
+
// would otherwise route the install to the root and ship no lockfile.
|
|
497
|
+
const installArgs = pm === "pnpm"
|
|
498
|
+
? ["install", "--ignore-workspace", "--config.dangerouslyAllowAllBuilds=true"]
|
|
499
|
+
: ["install"];
|
|
487
500
|
try {
|
|
488
501
|
execFileSync(installBin, installArgs, { cwd: dest, stdio: "pipe" });
|
|
489
502
|
logger.log(` generated ${pm} lockfile`);
|
|
@@ -516,11 +529,14 @@ async function exportStandalonePackage(root, dest, config, logger, emit) {
|
|
|
516
529
|
const ctx = { root, dest, config, packageDirs: [] };
|
|
517
530
|
await runPostProcess(ctx, config.postProcess, emit, logger);
|
|
518
531
|
}
|
|
519
|
-
// 5b. Generate CI workflow
|
|
532
|
+
// 5b. Generate CI workflow — lockfile presence decides frozen-install/cache
|
|
520
533
|
logger.log("Generating CI workflow...");
|
|
521
534
|
const ciDir = path.join(dest, ".github", "workflows");
|
|
522
535
|
await mkdir(ciDir, { recursive: true });
|
|
523
|
-
const
|
|
536
|
+
const lockfileName = pm === "pnpm" ? "pnpm-lock.yaml" : pm === "yarn" ? "yarn.lock" : "package-lock.json";
|
|
537
|
+
const ciContent = generateCiWorkflow(pm, config.ci, {
|
|
538
|
+
lockfileShips: existsSync(path.join(dest, lockfileName)),
|
|
539
|
+
});
|
|
524
540
|
if (ciContent) {
|
|
525
541
|
await writeFile(path.join(ciDir, "ci.yml"), ciContent);
|
|
526
542
|
logger.log(" generated .github/workflows/ci.yml");
|
package/dist/fs/transform.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ export declare function buildGitignore(extraLines?: string[], config?: ExtractCo
|
|
|
10
10
|
export declare function buildRootPackageJson(destName: string, config: ExtractConfig, pm: PackageManager, root?: string): object;
|
|
11
11
|
export declare function generateRootFiles(dest: string, root: string, config: ExtractConfig, packageDirs: string[], appDirs: string[], pm: PackageManager, logger?: Logger): Promise<void>;
|
|
12
12
|
export declare function cleanStrayArtifacts(dest: string): Promise<void>;
|
|
13
|
-
export declare function generateCiWorkflow(pm: PackageManager, ci?: CiConfig
|
|
13
|
+
export declare function generateCiWorkflow(pm: PackageManager, ci?: CiConfig, opts?: {
|
|
14
|
+
lockfileShips?: boolean;
|
|
15
|
+
}): string | null;
|
|
14
16
|
export declare function bumpSourceVersion(root: string, config: ExtractConfig, logger?: Logger): Promise<void>;
|
|
15
17
|
export declare function fixStandalonePackageJson(dest: string, config: ExtractConfig, pm: PackageManager, root?: string, logger?: Logger): Promise<void>;
|
|
16
18
|
export declare function fixStandaloneVitestConfig(dest: string, logger?: Logger): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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AM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe5F"}
|
package/dist/fs/transform.js
CHANGED
|
@@ -418,19 +418,27 @@ export async function cleanStrayArtifacts(dest) {
|
|
|
418
418
|
}
|
|
419
419
|
await cleanDeep(dest);
|
|
420
420
|
}
|
|
421
|
-
export function generateCiWorkflow(pm, ci) {
|
|
421
|
+
export function generateCiWorkflow(pm, ci, opts) {
|
|
422
422
|
if (ci?.provider === "none")
|
|
423
423
|
return null;
|
|
424
424
|
const nodeVersion = ci?.nodeVersion ?? 22;
|
|
425
425
|
const publish = ci?.publish ?? true;
|
|
426
|
+
// Lockfile may be excluded from the export (e.g. it embeds a local `link:`
|
|
427
|
+
// dep that cannot resolve on CI). Emitting `cache: <pm>`/`--frozen-lockfile`
|
|
428
|
+
// for a lockfile-less repo fails before install even starts.
|
|
429
|
+
const lockfileShips = opts?.lockfileShips ?? true;
|
|
426
430
|
const installCmd = pm === "pnpm"
|
|
427
|
-
?
|
|
431
|
+
? `pnpm install ${lockfileShips ? "--frozen-lockfile " : "--no-frozen-lockfile "}--config.dangerouslyAllowAllBuilds=true`
|
|
428
432
|
: pm === "yarn"
|
|
429
|
-
?
|
|
430
|
-
:
|
|
433
|
+
? `yarn install${lockfileShips ? " --frozen-lockfile" : ""}`
|
|
434
|
+
: lockfileShips
|
|
435
|
+
? "npm ci"
|
|
436
|
+
: "npm install";
|
|
431
437
|
const runPrefix = pm === "pnpm" ? "pnpm run" : pm === "yarn" ? "yarn" : "npm run";
|
|
432
438
|
const testCmd = pm === "pnpm" ? "pnpm test" : pm === "yarn" ? "yarn test" : "npm test";
|
|
433
439
|
const cacheKey = pm === "pnpm" ? "pnpm" : pm === "yarn" ? "yarn" : "npm";
|
|
440
|
+
// setup-node's cache needs a committed lockfile — skip it when none ships.
|
|
441
|
+
const cacheLines = lockfileShips ? [` cache: ${cacheKey}`] : [];
|
|
434
442
|
const pnpmSetup = pm === "pnpm" ? [" - uses: pnpm/action-setup@v6"] : [];
|
|
435
443
|
const ciSetupSteps = [
|
|
436
444
|
" - uses: actions/checkout@v5",
|
|
@@ -438,7 +446,7 @@ export function generateCiWorkflow(pm, ci) {
|
|
|
438
446
|
" - uses: actions/setup-node@v5",
|
|
439
447
|
" with:",
|
|
440
448
|
` node-version: ${nodeVersion}`,
|
|
441
|
-
|
|
449
|
+
...cacheLines,
|
|
442
450
|
` - run: ${installCmd}`,
|
|
443
451
|
];
|
|
444
452
|
const buildSteps = [];
|
|
@@ -467,7 +475,7 @@ export function generateCiWorkflow(pm, ci) {
|
|
|
467
475
|
...buildSteps,
|
|
468
476
|
];
|
|
469
477
|
if (publish) {
|
|
470
|
-
lines.push("", " publish:", " needs: ci", " if: github.event_name == 'push'", " runs-on: ubuntu-latest", " timeout-minutes: 10", " permissions:", " contents: write", " id-token: write", " steps:", " - uses: actions/checkout@v5", ...pnpmSetup, " - uses: actions/setup-node@v5", " with:", ` node-version: ${nodeVersion}`,
|
|
478
|
+
lines.push("", " publish:", " needs: ci", " if: github.event_name == 'push'", " runs-on: ubuntu-latest", " timeout-minutes: 10", " permissions:", " contents: write", " id-token: write", " steps:", " - uses: actions/checkout@v5", ...pnpmSetup, " - uses: actions/setup-node@v5", " with:", ` node-version: ${nodeVersion}`, ...cacheLines, " registry-url: https://registry.npmjs.org", ` - run: ${installCmd}`, ` - run: ${runPrefix} build`, " - run: npm publish --provenance --access public", " env:", " NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}", " - name: Create GitHub Release", " if: github.ref == 'refs/heads/main' && github.event_name == 'push'", " run: |", " VERSION=$(node -p \"require('./package.json').version\")", ' gh release create "v${VERSION}" \\', ' --title "v${VERSION}" \\', " --generate-notes \\", " --latest || true", " env:", " GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}");
|
|
471
479
|
}
|
|
472
480
|
if (ci?.deploy?.provider === "cloudflare-pages") {
|
|
473
481
|
const d = ci.deploy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warpgogol/repo-extract",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Extract apps and packages from a TurboRepo monorepo into standalone public repositories",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Andrii Syrokomskyi <andrii@syrokomskyi.com> (https://syrokomskyi.com)",
|