@warpgogol/repo-extract 1.4.5 → 1.5.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,aAAa,EAEb,cAAc,EACd,aAAa,EAGd,MAAM,YAAY,CAAC;AA0CpB,wBAAsB,cAAc,CAClC,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAkJxB"}
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,aAAa,EAEb,cAAc,EACd,aAAa,EAGd,MAAM,YAAY,CAAC;AA2CpB,wBAAsB,cAAc,CAClC,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAkJxB"}
package/dist/extract.js CHANGED
@@ -26,7 +26,7 @@ import { getMonorepoConfigFiles, copyBatchSample, copyFiltered, copyStandalonePa
26
26
  import { buildGitignore, cleanStrayArtifacts, findAppTsconfigs, findPackageJsonFiles, fixAppTsconfigs, fixPackageTsconfigs, fixStandalonePackageJson, fixStandaloneVitestConfig, generateCiWorkflow, generateRootFiles, bumpSourceVersion, regenerateTsconfigBase, transformPackageJson, } from "./fs/transform.js";
27
27
  import { discoverPackageDeps } from "./fs/discover.js";
28
28
  import { runPostProcess } from "./postprocess/index.js";
29
- import { assertCleanSource, commitExport, materializeHeadWorktree, transferGitHistory, } from "./fs/git.js";
29
+ import { assertCleanSource, commitExport, ensureNpmTokenSecret, materializeHeadWorktree, transferGitHistory, } from "./fs/git.js";
30
30
  import { tryGenerateChangelog } from "./changelog.js";
31
31
  import { scanForSecrets } from "./scan.js";
32
32
  import { detectPackageManager } from "./package-manager.js";
@@ -416,6 +416,11 @@ async function exportMonorepo(root, dest, config, logger, emit) {
416
416
  else {
417
417
  logger.log("Skipping git history transfer (git.history: false)");
418
418
  }
419
+ // 15d. Publish-secret bootstrap — before the first push, so generated CI's
420
+ // publish job finds NPM_TOKEN on a fresh repo (RFC-0132, best-effort).
421
+ if (config.git?.autoPush && config.git?.remote && (config.ci?.publish ?? true)) {
422
+ ensureNpmTokenSecret(config.git.remote, logger);
423
+ }
419
424
  // 16. Git commit + push
420
425
  emit({ phase: "gitCommit", message: changelogCommitMessage });
421
426
  const gitResult = await commitExport(dest, changelogCommitMessage, config.git, logger);
@@ -564,6 +569,10 @@ async function exportStandalonePackage(root, dest, config, logger, emit) {
564
569
  const pathPrefixes = [config.projectDir];
565
570
  emit({ phase: "gitHistory", pathPrefixes });
566
571
  await transferGitHistory(root, dest, pathPrefixes, logger);
572
+ // 6d. Publish-secret bootstrap — before the first push (RFC-0132).
573
+ if (config.git?.autoPush && config.git?.remote && (config.ci?.publish ?? true)) {
574
+ ensureNpmTokenSecret(config.git.remote, logger);
575
+ }
567
576
  // 7. Git commit + push
568
577
  emit({ phase: "gitCommit", message: changelogCommitMessage });
569
578
  const gitResult = await commitExport(dest, changelogCommitMessage, config.git, logger);
package/dist/fs/git.d.ts CHANGED
@@ -25,6 +25,14 @@ export declare function materializeHeadWorktree(root: string, ref: string, logge
25
25
  dir: string;
26
26
  cleanup: () => Promise<void>;
27
27
  }>;
28
+ /**
29
+ * RFC-0132: fresh extract repos ship no secrets, so the generated workflow's
30
+ * first `npm publish` fails ENEEDAUTH. When the remote is a GitHub repo and
31
+ * `gh` is available, ensure an NPM_TOKEN secret exists — sourced from the
32
+ * operator's own ~/.npmrc authToken. Fully best-effort: every failure mode
33
+ * degrades to a logged hint, never a failed export.
34
+ */
35
+ export declare function ensureNpmTokenSecret(remote: string | undefined, logger?: Logger): void;
28
36
  export declare function getLastExportDate(dest: string): string | null;
29
37
  export declare function transferGitHistory(root: string, dest: string, pathPrefixes: string[], logger?: Logger): Promise<boolean>;
30
38
  export declare function diffSummary(dest: string): string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/fs/git.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,SAAS,EACrB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CA0KlD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAsBrF;AAID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAiBrF;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAkCxD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW7D;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EAAE,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAsGlB;AAED,wB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IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EAAE,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAsGlB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoCvD"}
package/dist/fs/git.js CHANGED
@@ -11,9 +11,10 @@
11
11
  <item>RFC-0074: Wrapped execFileSync calls with GitOperationError. Changed commitExport return to { committed, pushed }.</item>
12
12
  <item>RFC-0075: Added Windows multi-prefix guard in transferGitHistory().</item>
13
13
  <item>RFC-0131: Added assertCleanSource (dirty preflight), materializeHeadWorktree (--from-head), and git.autoReconcile ours-merge retry in commitExport.</item>
14
+ <item>RFC-0132: Added ensureNpmTokenSecret — best-effort NPM_TOKEN bootstrap on the extract repo before first push, sourced from ~/.npmrc.</item>
14
15
  </CHANGE_SUMMARY>
15
16
  */
16
- import { existsSync, rmSync } from "node:fs";
17
+ import { existsSync, rmSync, readFileSync } from "node:fs";
17
18
  import { cp, mkdtemp, rm } from "node:fs/promises";
18
19
  import * as path from "node:path";
19
20
  import * as os from "node:os";
@@ -274,6 +275,67 @@ export async function materializeHeadWorktree(root, ref, logger) {
274
275
  },
275
276
  };
276
277
  }
278
+ /**
279
+ * RFC-0132: fresh extract repos ship no secrets, so the generated workflow's
280
+ * first `npm publish` fails ENEEDAUTH. When the remote is a GitHub repo and
281
+ * `gh` is available, ensure an NPM_TOKEN secret exists — sourced from the
282
+ * operator's own ~/.npmrc authToken. Fully best-effort: every failure mode
283
+ * degrades to a logged hint, never a failed export.
284
+ */
285
+ export function ensureNpmTokenSecret(remote, logger) {
286
+ const log = logger?.log ?? console.log;
287
+ const error = logger?.error ?? console.error;
288
+ const slug = remote?.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/) ??
289
+ remote?.match(/^https?:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/);
290
+ if (!remote || !slug) {
291
+ if (remote)
292
+ log(` npm-token: non-GitHub remote "${remote}" — set NPM_TOKEN manually`);
293
+ return;
294
+ }
295
+ const repo = `${slug[1]}/${slug[2]}`;
296
+ try {
297
+ execFileSync("gh", ["--version"], { stdio: "pipe" });
298
+ }
299
+ catch {
300
+ log(` npm-token: gh CLI not available — set NPM_TOKEN on ${repo} manually before first publish`);
301
+ return;
302
+ }
303
+ try {
304
+ const out = execFileSync("gh", ["secret", "list", "--repo", repo], {
305
+ stdio: "pipe",
306
+ }).toString();
307
+ if (/\bNPM_TOKEN\b/.test(out)) {
308
+ log(` npm-token: NPM_TOKEN already set on ${repo}`);
309
+ return;
310
+ }
311
+ }
312
+ catch (err) {
313
+ error(` npm-token: cannot list secrets on ${repo} (${err instanceof Error ? err.message.slice(0, 120) : err}) — set NPM_TOKEN manually`);
314
+ return;
315
+ }
316
+ let token;
317
+ try {
318
+ const npmrc = readFileSync(path.join(os.homedir(), ".npmrc"), "utf-8");
319
+ token = npmrc.match(/^\/\/registry\.npmjs\.org\/:_authToken=(\S+)/m)?.[1];
320
+ }
321
+ catch {
322
+ /* no readable npmrc */
323
+ }
324
+ if (!token) {
325
+ log(` npm-token: no authToken in ~/.npmrc — set NPM_TOKEN on ${repo} manually`);
326
+ return;
327
+ }
328
+ try {
329
+ execFileSync("gh", ["secret", "set", "NPM_TOKEN", "--repo", repo], {
330
+ input: token,
331
+ stdio: ["pipe", "pipe", "pipe"],
332
+ });
333
+ log(` npm-token: NPM_TOKEN set on ${repo} from ~/.npmrc`);
334
+ }
335
+ catch (err) {
336
+ error(` npm-token: gh secret set failed on ${repo} (${err instanceof Error ? err.message.slice(0, 120) : err}) — set NPM_TOKEN manually`);
337
+ }
338
+ }
277
339
  export function getLastExportDate(dest) {
278
340
  try {
279
341
  const dateStr = execFileSync("git", ["log", "-1", "--format=%ad", "--date=format:%Y-%m-%d"], {
@@ -15,5 +15,39 @@ export declare function generateCiWorkflow(pm: PackageManager, ci?: CiConfig, op
15
15
  }): string | null;
16
16
  export declare function bumpSourceVersion(root: string, config: ExtractConfig, logger?: Logger): Promise<void>;
17
17
  export declare function fixStandalonePackageJson(dest: string, config: ExtractConfig, pm: PackageManager, root?: string, logger?: Logger): Promise<void>;
18
+ /**
19
+ * RFC-0132: generated CI always runs `<pm> run typecheck`. When the source
20
+ * manifest has no typecheck script but builds via a single `tsc -p <file>`
21
+ * invocation, synthesize `typecheck` as the same command plus `--noEmit`.
22
+ * Only a single tsc invocation is rewritten — composed builds (`a && b`)
23
+ * would append the flag to the wrong segment and stay a human fix.
24
+ */
25
+ export declare function ensureTypecheckScript(pkg: {
26
+ scripts?: Record<string, string>;
27
+ }, logger?: Logger): boolean;
28
+ /**
29
+ * RFC-0132: `npm publish --provenance` verifies package.json repository.url
30
+ * against the Actions repo slug. Synthesize the field from git.remote when
31
+ * absent — accepting `git@host:owner/repo(.git)` and
32
+ * `https://host/owner/repo(.git)`. A declared-but-mismatched repository is
33
+ * left untouched: wrong data is a human decision, not a healing target.
34
+ */
35
+ export declare function ensureRepositoryField(pkg: {
36
+ repository?: unknown;
37
+ }, remote: string | undefined, logger?: Logger): boolean;
38
+ /**
39
+ * RFC-0132: scan the exported tree for test files. Exclusion rules can strip
40
+ * a package's whole test surface; the answer decides whether the test script
41
+ * needs --passWithNoTests.
42
+ */
43
+ export declare function hasAnyTestFiles(dir: string): boolean;
44
+ /**
45
+ * RFC-0132: vitest exits 1 on an empty suite, and generated CI always runs
46
+ * the test step. When the export ships no test files, make the script
47
+ * tolerate it — shipping a later test file restores real coverage.
48
+ */
49
+ export declare function ensureTestScriptTolerant(pkg: {
50
+ scripts?: Record<string, string>;
51
+ }, logger?: Logger): boolean;
18
52
  export declare function fixStandaloneVitestConfig(dest: string, logger?: Logger): Promise<void>;
19
53
  //# sourceMappingURL=transform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/fs/transform.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE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-url for NODE_AUTH_TOKEN.</item>
14
14
  <item>ADR-0082: preservePackages workspace:* deps now pin to ^&lt;sourceVersion&gt; instead of * — extracted lockfiles resolve the just-published sibling under pnpm minimumReleaseAge.</item>
15
15
  <item>RFC-1081: Added gh release create step after npm publish with --generate-notes and || true for tag collision. Updated publish job permissions to contents: write. (Ported back from standalone repo — was committed there directly on 2026-09-13.)</item>
16
+ <item>RFC-0132: standalone manifest self-healing — ensureTypecheckScript (build+--noEmit), ensureRepositoryField (from git.remote), ensureTestScriptTolerant (--passWithNoTests when no test files ship).</item>
16
17
  </CHANGE_SUMMARY>
17
18
  */
18
19
  import { readFile, writeFile, rm, access, readdir } from "node:fs/promises";
19
- import { readFileSync } from "node:fs";
20
+ import { readFileSync, readdirSync } from "node:fs";
20
21
  import * as path from "node:path";
21
22
  import { isIgnored } from "./copy.js";
22
23
  import { resolveSourceVersion } from "./discover.js";
@@ -438,10 +439,13 @@ export function generateCiWorkflow(pm, ci, opts) {
438
439
  const testCmd = pm === "pnpm" ? "pnpm test" : pm === "yarn" ? "yarn test" : "npm test";
439
440
  const cacheKey = pm === "pnpm" ? "pnpm" : pm === "yarn" ? "yarn" : "npm";
440
441
  // setup-node's cache needs a committed lockfile — skip it when none ships.
441
- const cacheLines = lockfileShips ? [` cache: ${cacheKey}`] : [];
442
- // pnpm/action-setup@v6's `cache` input defaults true and injects
443
- // `package-manager-cache: true` into setup-node, which then hard-fails on a
444
- // missing lockfile — disable it too when no lockfile ships.
442
+ // pnpm/action-setup@v6's `cache` (default true) also injects
443
+ // `package-manager-cache: true` into setup-node's resolved inputs, which
444
+ // hard-fails on a missing lockfile — the override must land on setup-node
445
+ // itself; action-setup's own `cache: false` does not retract the injection.
446
+ const cacheLines = lockfileShips
447
+ ? [` cache: ${cacheKey}`]
448
+ : [" package-manager-cache: false"];
445
449
  const pnpmSetup = pm === "pnpm"
446
450
  ? lockfileShips
447
451
  ? [" - uses: pnpm/action-setup@v6"]
@@ -586,11 +590,101 @@ export async function fixStandalonePackageJson(dest, config, pm, root, logger) {
586
590
  changed = true;
587
591
  }
588
592
  }
593
+ // RFC-0132: heal the manifest against the generated-CI and npm-provenance
594
+ // contracts — see ensureTypecheckScript / ensureRepositoryField /
595
+ // ensureTestScriptTolerant for the exact shapes.
596
+ if (ensureTypecheckScript(pkg, logger))
597
+ changed = true;
598
+ if (ensureRepositoryField(pkg, config.git?.remote, logger))
599
+ changed = true;
600
+ if (!hasAnyTestFiles(dest) && ensureTestScriptTolerant(pkg, logger))
601
+ changed = true;
589
602
  if (changed) {
590
603
  await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
591
604
  (logger?.log ?? console.log)(" fixed standalone package.json (test script, workspace deps, packageManager)");
592
605
  }
593
606
  }
607
+ /**
608
+ * RFC-0132: generated CI always runs `<pm> run typecheck`. When the source
609
+ * manifest has no typecheck script but builds via a single `tsc -p <file>`
610
+ * invocation, synthesize `typecheck` as the same command plus `--noEmit`.
611
+ * Only a single tsc invocation is rewritten — composed builds (`a && b`)
612
+ * would append the flag to the wrong segment and stay a human fix.
613
+ */
614
+ export function ensureTypecheckScript(pkg, logger) {
615
+ const scripts = pkg.scripts;
616
+ if (!scripts || typeof scripts.typecheck === "string" || typeof scripts.build !== "string") {
617
+ return false;
618
+ }
619
+ const build = scripts.build.trim();
620
+ if (/&&|\|\||;/.test(build) || !/(pnpm exec )?tsc -p \S+/.test(build))
621
+ return false;
622
+ scripts.typecheck = `${build} --noEmit`;
623
+ (logger?.log ?? console.log)(` healed scripts.typecheck: "${scripts.typecheck}"`);
624
+ return true;
625
+ }
626
+ /**
627
+ * RFC-0132: `npm publish --provenance` verifies package.json repository.url
628
+ * against the Actions repo slug. Synthesize the field from git.remote when
629
+ * absent — accepting `git@host:owner/repo(.git)` and
630
+ * `https://host/owner/repo(.git)`. A declared-but-mismatched repository is
631
+ * left untouched: wrong data is a human decision, not a healing target.
632
+ */
633
+ export function ensureRepositoryField(pkg, remote, logger) {
634
+ if (!remote || pkg.repository !== undefined)
635
+ return false;
636
+ const m = remote.match(/^[a-z]+@([^:/]+):([^/]+)\/(.+?)(?:\.git)?$/) ??
637
+ remote.match(/^https?:\/\/([^/]+)\/([^/]+)\/(.+?)(?:\.git)?$/);
638
+ if (!m)
639
+ return false;
640
+ const [, host, owner, repo] = m;
641
+ pkg.repository = { type: "git", url: `git+https://${host}/${owner}/${repo}.git` };
642
+ (logger?.log ?? console.log)(` healed repository: git+https://${host}/${owner}/${repo}.git`);
643
+ return true;
644
+ }
645
+ const TEST_FILE_RE = /\.(test|spec)\.(ts|tsx|js|jsx|mjs|cjs)$/;
646
+ /**
647
+ * RFC-0132: scan the exported tree for test files. Exclusion rules can strip
648
+ * a package's whole test surface; the answer decides whether the test script
649
+ * needs --passWithNoTests.
650
+ */
651
+ export function hasAnyTestFiles(dir) {
652
+ let entries;
653
+ try {
654
+ entries = readdirSync(dir, { withFileTypes: true });
655
+ }
656
+ catch {
657
+ return false;
658
+ }
659
+ for (const e of entries) {
660
+ if (e.name === "node_modules" || e.name === ".git")
661
+ continue;
662
+ const full = path.join(dir, e.name);
663
+ if (e.isDirectory()) {
664
+ if (hasAnyTestFiles(full))
665
+ return true;
666
+ }
667
+ else if (TEST_FILE_RE.test(e.name)) {
668
+ return true;
669
+ }
670
+ }
671
+ return false;
672
+ }
673
+ /**
674
+ * RFC-0132: vitest exits 1 on an empty suite, and generated CI always runs
675
+ * the test step. When the export ships no test files, make the script
676
+ * tolerate it — shipping a later test file restores real coverage.
677
+ */
678
+ export function ensureTestScriptTolerant(pkg, logger) {
679
+ const test = pkg.scripts?.test;
680
+ if (typeof test !== "string" || test.includes("passWithNoTests"))
681
+ return false;
682
+ if (!/vitest|jest/.test(test))
683
+ return false;
684
+ pkg.scripts.test = `${test} --passWithNoTests`;
685
+ (logger?.log ?? console.log)(` healed scripts.test: "${pkg.scripts.test}" (no test files in export)`);
686
+ return true;
687
+ }
594
688
  async function rewriteWorkspaceSpecifier(depName, preservePackages, root, logger) {
595
689
  if (!root || !preservePackages.includes(depName))
596
690
  return "*";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpgogol/repo-extract",
3
- "version": "1.4.5",
3
+ "version": "1.5.0",
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)",