@_linked/cli 1.42.0 → 1.43.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.43.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#225](https://github.com/linked-fw/cli/pull/225) [`1b8e157`](https://github.com/linked-fw/cli/commit/1b8e157a3d28e232f7fe4df4db6ac6a248f41f44) Thanks [@flyon](https://github.com/flyon)! - Packages created with `create-package` now publish only the files consumers need: the template's `package.json` has `"files": ["lib", "CHANGELOG.md"]`, so their tarballs no longer include `.github/`, `.changeset/`, tests or tsconfig files.
8
+
9
+ ## 1.43.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#224](https://github.com/linked-fw/cli/pull/224) [`51d38d1`](https://github.com/linked-fw/cli/commit/51d38d1392afd212e6c5b656d343a8f581cc42bf) Thanks [@flyon](https://github.com/flyon)! - `linked setup-publish` now also sets up what every linked-cm package needed by hand:
14
+
15
+ - an `.npmrc` with `allow-remote=all` (npm 12 otherwise fails `npm install` with EALLOWREMOTE on bundled tarballs), plus `legacy-peer-deps=true` in linked-cm, whose CI installs that way. Keys the repo already sets are kept.
16
+ - a `renovate.json` stub extending `<org>/renovate-config`, unless the repo already has a Renovate config.
17
+ - `@changesets/cli` ^3 and `@changesets/changelog-github` ^1, the versions the fleet runs.
18
+
19
+ The lockfile step now keeps the existing lockfile's resolutions and resolves under the repo's `.npmrc`, instead of re-resolving from scratch with `--legacy-peer-deps` everywhere.
20
+
3
21
  ## 1.42.0
4
22
 
5
23
  ### Minor Changes
@@ -18,6 +18,10 @@
18
18
  "//types": "Correct as written, do not 'fix' it: typesVersions below is applied to the types field too, so \"index.d.ts\" resolves to lib/esm/index.d.ts. Writing that literal path applies the mapping twice (lib/esm/lib/esm/index.d.ts) and breaks node10 resolution. Verify with ts.resolveModuleName under node10 AND bundler, not by looking for the file on disk.",
19
19
  "types": "index.d.ts",
20
20
  "license": "ISC",
21
+ "files": [
22
+ "lib",
23
+ "CHANGELOG.md"
24
+ ],
21
25
  "scripts": {
22
26
  "start": "linked dev",
23
27
  "build": "rimraf ./lib && npm run build-esm && npm run copy-to-lib",
@@ -56,7 +56,10 @@ export type SetupPublishOptions = {
56
56
  * - .gitignore entries for node_modules, lib, yarn.lock, src-compiled-artifacts
57
57
  * - package.json: @changesets/cli + @changesets/changelog-github devDeps,
58
58
  * publishConfig: {access: public}
59
- * - package-lock.json generated via npm install --package-lock-only
59
+ * - .npmrc: allow-remote=all, plus legacy-peer-deps=true in linked-cm (see npmrcSettings);
60
+ * keys the repo already sets are left alone
61
+ * - renovate.json extending <org>/renovate-config, unless the repo has a Renovate config
62
+ * - package-lock.json refreshed via npm install --package-lock-only, keeping existing resolutions
60
63
  *
61
64
  * With --configure-github: if `gh` CLI is available and authenticated, also applies the uniform
62
65
  * branch-protection profile on main and enables auto-merge.
@@ -75,6 +78,28 @@ export type WorkflowVars = {
75
78
  requireTests: boolean;
76
79
  };
77
80
  export declare function renderWorkflow(template: string, vars: WorkflowVars): string;
81
+ /**
82
+ * The `.npmrc` settings a package repo needs so that a local `npm install` resolves the same tree
83
+ * as its org's shared workflows and Renovate.
84
+ *
85
+ * - `allow-remote=all`: npm 12 defaults `allow-remote` to `none` and then refuses the registry
86
+ * tarball of a bundled dependency (`@tailwindcss/oxide-wasm32-wasi` is in most of the fleet),
87
+ * failing `npm install` with EALLOWREMOTE. npm 11, which CI runs, accepts the setting.
88
+ * - `legacy-peer-deps=true`, linked-cm only: its workflows install with
89
+ * `npm ci --legacy-peer-deps`. linked-fw's install strictly, and its Renovate policy requires
90
+ * locks to be resolved under CI's peer rules — so writing it there would be the mismatch.
91
+ */
92
+ export declare function npmrcSettings(workflowOrg: string): string[];
93
+ /**
94
+ * Appends each setting whose key the existing `.npmrc` does not set. A key that is already set
95
+ * keeps its value: the repo may have a reason, and silently flipping it would change installs.
96
+ */
97
+ export declare function mergeNpmrc(existing: string, settings: string[]): string;
98
+ /**
99
+ * The three-line stub every package repo carries: the policy itself lives in the org's
100
+ * `renovate-config` repo, so one edit there reaches the whole fleet.
101
+ */
102
+ export declare function renovateStub(workflowOrg: string): string;
78
103
  /** Mutates `pkgJson` in place; returns whether anything changed. Pure enough to test. */
79
104
  export declare function applyPackageJsonPatches(pkgJson: any, repoSlug: string): boolean;
80
105
  //# sourceMappingURL=setup-publish.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-publish.d.ts","sourceRoot":"","sources":["../../../src/commands/setup-publish.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,cAAc,oCAAqC,CAAC;AAEjE;;;;;;GAMG;AACH,wBAAgB,4BAA4B;;;;;;;;;;;;;;EAkB3C;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyFhF;AAwBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAC,GAAG,OAAO,CAGnF;AAED,MAAM,MAAM,YAAY,GAAG;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAC,CAAC;AAExE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,CAI3E;AAiGD,yFAAyF;AACzF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,GAAG,EAAE,Q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O,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAkD/E"}
@@ -65,7 +65,10 @@ export function buildBranchProtectionPayload() {
65
65
  * - .gitignore entries for node_modules, lib, yarn.lock, src-compiled-artifacts
66
66
  * - package.json: @changesets/cli + @changesets/changelog-github devDeps,
67
67
  * publishConfig: {access: public}
68
- * - package-lock.json generated via npm install --package-lock-only
68
+ * - .npmrc: allow-remote=all, plus legacy-peer-deps=true in linked-cm (see npmrcSettings);
69
+ * keys the repo already sets are left alone
70
+ * - renovate.json extending <org>/renovate-config, unless the repo has a Renovate config
71
+ * - package-lock.json refreshed via npm install --package-lock-only, keeping existing resolutions
69
72
  *
70
73
  * With --configure-github: if `gh` CLI is available and authenticated, also applies the uniform
71
74
  * branch-protection profile on main and enables auto-merge.
@@ -119,13 +122,17 @@ export function setupPublish() {
119
122
  yield updateGitignore(cwd);
120
123
  // 5. package.json patches
121
124
  yield patchPackageJson(pkgJsonPath, pkgJson, repoSlug);
122
- // 6. npm install --package-lock-only to generate lockfile (if not present)
125
+ // 6. .npmrc — before the lockfile step, which must resolve under the same settings as CI
126
+ yield updateNpmrc(cwd, workflowOrg);
127
+ // 7. renovate.json stub extending the org's shared policy
128
+ yield writeRenovateConfig(cwd, workflowOrg);
129
+ // 8. npm install --package-lock-only to generate lockfile (if not present)
123
130
  yield ensureLockfile(cwd);
124
- // 7. Optional: configure GitHub branch protection
131
+ // 9. Optional: configure GitHub branch protection
125
132
  if (opts.configureGithub) {
126
133
  yield configureGithub(repoSlug);
127
134
  }
128
- // 8. Optional: grant a GitHub team push access
135
+ // 10. Optional: grant a GitHub team push access
129
136
  if (opts.grantTeam) {
130
137
  yield grantTeamAccess(repoSlug, opts.grantTeam);
131
138
  }
@@ -258,6 +265,91 @@ function updateGitignore(cwd) {
258
265
  console.log(chalk.green(' ✓') + ' .gitignore');
259
266
  });
260
267
  }
268
+ /**
269
+ * The `.npmrc` settings a package repo needs so that a local `npm install` resolves the same tree
270
+ * as its org's shared workflows and Renovate.
271
+ *
272
+ * - `allow-remote=all`: npm 12 defaults `allow-remote` to `none` and then refuses the registry
273
+ * tarball of a bundled dependency (`@tailwindcss/oxide-wasm32-wasi` is in most of the fleet),
274
+ * failing `npm install` with EALLOWREMOTE. npm 11, which CI runs, accepts the setting.
275
+ * - `legacy-peer-deps=true`, linked-cm only: its workflows install with
276
+ * `npm ci --legacy-peer-deps`. linked-fw's install strictly, and its Renovate policy requires
277
+ * locks to be resolved under CI's peer rules — so writing it there would be the mismatch.
278
+ */
279
+ export function npmrcSettings(workflowOrg) {
280
+ const settings = ['allow-remote=all'];
281
+ if (workflowOrg === 'linked-cm')
282
+ settings.push('legacy-peer-deps=true');
283
+ return settings;
284
+ }
285
+ /**
286
+ * Appends each setting whose key the existing `.npmrc` does not set. A key that is already set
287
+ * keeps its value: the repo may have a reason, and silently flipping it would change installs.
288
+ */
289
+ export function mergeNpmrc(existing, settings) {
290
+ const keyOf = (line) => line.split('=')[0].trim();
291
+ const present = new Set(existing
292
+ .split('\n')
293
+ .map((line) => line.trim())
294
+ .filter((line) => line && !line.startsWith('#') && !line.startsWith(';'))
295
+ .map(keyOf));
296
+ const missing = settings.filter((setting) => !present.has(keyOf(setting)));
297
+ if (missing.length === 0)
298
+ return existing;
299
+ const base = existing === '' || existing.endsWith('\n') ? existing : existing + '\n';
300
+ return base + missing.join('\n') + '\n';
301
+ }
302
+ function updateNpmrc(cwd, workflowOrg) {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ const npmrcPath = path.join(cwd, '.npmrc');
305
+ const existing = fs.existsSync(npmrcPath) ? fs.readFileSync(npmrcPath, 'utf8') : '';
306
+ const next = mergeNpmrc(existing, npmrcSettings(workflowOrg));
307
+ if (next === existing) {
308
+ console.log(chalk.gray(' · .npmrc already has the required settings'));
309
+ return;
310
+ }
311
+ fs.writeFileSync(npmrcPath, next);
312
+ console.log(chalk.green(' ✓') + ' .npmrc');
313
+ });
314
+ }
315
+ // Every location Renovate reads a repo config from. If any exists, the repo has a config of its
316
+ // own and setup-publish leaves it alone.
317
+ const RENOVATE_CONFIG_FILES = [
318
+ 'renovate.json',
319
+ 'renovate.json5',
320
+ '.github/renovate.json',
321
+ '.github/renovate.json5',
322
+ '.gitlab/renovate.json',
323
+ '.gitlab/renovate.json5',
324
+ '.renovaterc',
325
+ '.renovaterc.json',
326
+ '.renovaterc.json5',
327
+ ];
328
+ /**
329
+ * The three-line stub every package repo carries: the policy itself lives in the org's
330
+ * `renovate-config` repo, so one edit there reaches the whole fleet.
331
+ */
332
+ export function renovateStub(workflowOrg) {
333
+ return (JSON.stringify({
334
+ $schema: 'https://docs.renovatebot.com/renovate-schema.json',
335
+ extends: [`local>${workflowOrg}/renovate-config`],
336
+ }, null, 2) + '\n');
337
+ }
338
+ function writeRenovateConfig(cwd, workflowOrg) {
339
+ return __awaiter(this, void 0, void 0, function* () {
340
+ if (workflowOrg === 'OWNER') {
341
+ console.warn(chalk.yellow(' ⚠ Skipped renovate.json: the repo org is unknown.'));
342
+ return;
343
+ }
344
+ const existing = RENOVATE_CONFIG_FILES.find((file) => fs.existsSync(path.join(cwd, file)));
345
+ if (existing) {
346
+ console.log(chalk.gray(` · ${existing} exists — left as is`));
347
+ return;
348
+ }
349
+ fs.writeFileSync(path.join(cwd, 'renovate.json'), renovateStub(workflowOrg));
350
+ console.log(chalk.green(' ✓') + ` renovate.json (extends ${workflowOrg}/renovate-config)`);
351
+ });
352
+ }
261
353
  function patchPackageJson(pkgJsonPath, pkgJson, repoSlug) {
262
354
  return __awaiter(this, void 0, void 0, function* () {
263
355
  if (applyPackageJsonPatches(pkgJson, repoSlug)) {
@@ -309,11 +401,11 @@ export function applyPackageJsonPatches(pkgJson, repoSlug) {
309
401
  }
310
402
  pkgJson.devDependencies = pkgJson.devDependencies || {};
311
403
  if (!pkgJson.devDependencies['@changesets/cli']) {
312
- pkgJson.devDependencies['@changesets/cli'] = '^2.29.8';
404
+ pkgJson.devDependencies['@changesets/cli'] = '^3.0.0';
313
405
  modified = true;
314
406
  }
315
407
  if (!pkgJson.devDependencies['@changesets/changelog-github']) {
316
- pkgJson.devDependencies['@changesets/changelog-github'] = '^0.5.2';
408
+ pkgJson.devDependencies['@changesets/changelog-github'] = '^1.0.0';
317
409
  modified = true;
318
410
  }
319
411
  return modified;
@@ -331,9 +423,15 @@ function ensureLockfile(cwd) {
331
423
  const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), 'linked-setup-'));
332
424
  const cacheDir = fs.mkdtempSync(path.join(os.tmpdir(), 'linked-setup-cache-'));
333
425
  try {
334
- const pkgJsonPath = path.join(cwd, 'package.json');
335
- fs.copyFileSync(pkgJsonPath, path.join(tmpBase, 'package.json'));
336
- yield execp(`npm install --legacy-peer-deps --package-lock-only --cache ${cacheDir}`, false, true, { cwd: tmpBase });
426
+ // The existing lockfile comes along so its resolutions are kept (only what package.json just
427
+ // gained is resolved), and .npmrc so the lock is resolved under the repo's own settings —
428
+ // allow-remote for npm 12, and legacy-peer-deps exactly where the org's CI installs that way.
429
+ for (const file of ['package.json', 'package-lock.json', '.npmrc']) {
430
+ const src = path.join(cwd, file);
431
+ if (fs.existsSync(src))
432
+ fs.copyFileSync(src, path.join(tmpBase, file));
433
+ }
434
+ yield execp(`npm install --package-lock-only --ignore-scripts --cache ${cacheDir}`, false, true, { cwd: tmpBase });
337
435
  const lockPath = path.join(tmpBase, 'package-lock.json');
338
436
  if (fs.existsSync(lockPath)) {
339
437
  fs.copyFileSync(lockPath, path.join(cwd, 'package-lock.json'));
@@ -1 +1 @@
1
- {"version":3,"file":"setup-publish.js","sourceRoot":"","sources":["../../../src/commands/setup-publish.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,EAAE,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AACnC,OAAO,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,aAAa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F,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,IAAI,CAAC,yCAAyC,CAAC,8BAA8B,CAAC,CAAC;QACjH,OAAO,CAAC,GAAG,CAAC,2CAA2C,QAAQ,sBAAsB,CAAC,CAAC;QACvF,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACpH,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path, {dirname} from 'path';\nimport {execp, execPromise} from '../utils.js';\n\nconst dirname__ =\n typeof __dirname !== 'undefined'\n ? __dirname\n : //@ts-ignore\n dirname(import.meta.url).replace('file:/', '');\n\n// defaults/setup-publish/ lives at packages/cli/defaults/setup-publish/\n// This file compiles to lib/{esm,cjs}/commands/setup-publish.js — go up three\n// levels to reach the package root, then into defaults/setup-publish.\nconst TEMPLATE_ROOT = path.resolve(dirname__, '..', '..', '..', 'defaults', 'setup-publish');\n\n// Both are callers of the shared reusable workflows. `publish.yml` in particular cannot be\n// renamed: npm's trusted-publisher check validates the calling workflow's filename, and a\n// mismatch only shows up as releases quietly needing manual approval again.\nexport const WORKFLOW_FILES = ['pr.yml', 'publish.yml'] as const;\n\n/**\n * The uniform branch-protection profile every `@_linked` repo runs on `main`.\n *\n * The required check is `checks / Build & Test`, not `Build & Test`: GitHub reports a job invoked\n * through `workflow_call` as `<caller-job-id> / <job name>`, and the caller job in pr.yml is\n * `checks`. A repo pinning the bare name waits forever on a check that never reports.\n */\nexport function buildBranchProtectionPayload() {\n return {\n required_status_checks: {strict: false, contexts: ['checks / Build & Test']},\n // Admins included: the point of the gate is that no release skips the build, and the people\n // most likely to push straight to main are the admins.\n enforce_admins: true,\n // Reviews enabled but zero approvals required. The publish workflow direct-merges the version\n // PR (GitHub's auto-merge queue does not honor review-bypass allowances), so a non-zero count\n // would stall every release; the block itself still has to exist for the profile to match.\n required_pull_request_reviews: {\n required_approving_review_count: 0,\n dismiss_stale_reviews: false,\n require_code_owner_reviews: false,\n },\n restrictions: null,\n allow_force_pushes: false,\n allow_deletions: false,\n };\n}\n\nexport type SetupPublishOptions = {\n configureGithub?: boolean;\n /**\n * @deprecated The npm secret is `NPM_AUTH_TOKEN` in every org, holding a token for that\n * org's own npm scope — there is no longer a second name to select between. Kept as an\n * accepted no-op for the same reason as `dualBranch`: commander aborts the whole command\n * on an unknown option, so a stale script would fail to set the repo up at all rather\n * than setting it up correctly.\n */\n scope?: string;\n /**\n * @deprecated The dual-branch (`main` + `dev`) flow and its `@next` prereleases are retired —\n * every package repo is `main`-only. Kept as an accepted no-op rather than removed because\n * commander aborts the whole command on an unknown option, so a stale script or copied\n * command line would fail to set the repo up at all instead of setting it up correctly.\n */\n dualBranch?: boolean;\n grantTeam?: string; // GitHub team slug to grant push access on the repo\n};\n\n/**\n * Set up the changesets publish pipeline in the current package repo.\n *\n * The workflows are thin callers of the shared reusable workflows in the repo's OWN org\n * `.github` repo (pinned `@v1`, a deliberately moving tag) — one edit there changes every\n * package's pipeline in that org, which is why nothing about the build or publish steps is\n * scaffolded per repo any more. Each org keeps its own copy so that community gates can be\n * stricter than first-party ones without a cross-org `workflow_call`.\n *\n * Installs:\n * - .github/workflows/{pr,publish}.yml — caller stubs, nothing else\n * - .changeset/config.json + README.md\n * - .changeset/initial-release.md\n * - .gitignore entries for node_modules, lib, yarn.lock, src-compiled-artifacts\n * - package.json: @changesets/cli + @changesets/changelog-github devDeps,\n * publishConfig: {access: public}\n * - package-lock.json generated via npm install --package-lock-only\n *\n * With --configure-github: if `gh` CLI is available and authenticated, also applies the uniform\n * branch-protection profile on main and enables auto-merge.\n */\nexport async function setupPublish(opts: SetupPublishOptions = {}): Promise<void> {\n const cwd = process.cwd();\n // One secret NAME across every org. The orgs are separate, so each holds its own value —\n // a token scoped to that org's npm scope. (There used to be an `NPM_AUTH_TOKEN_CM` for\n // `@linked.cm`; that dates from before first-party and community repos were split into two\n // orgs and one org therefore had to hold both tokens at once.)\n const npmSecretName = 'NPM_AUTH_TOKEN';\n\n console.log(chalk.magenta('Setting up the publish pipeline (main only)...'));\n if (opts.scope) {\n console.log(\n chalk.yellow(\n ' ⚠ --scope is deprecated and ignored: every org uses NPM_AUTH_TOKEN, holding that\\n' +\n \" org's own token. The NPM_AUTH_TOKEN_CM name is retired.\",\n ),\n );\n }\n if (opts.dualBranch) {\n console.log(\n chalk.yellow(\n ' ⚠ --dual-branch is deprecated and ignored: the main + dev flow and its @next prereleases are retired.',\n ),\n );\n }\n console.log(` target: ${cwd}`);\n console.log(` npm secret: ${npmSecretName}`);\n\n const pkgJsonPath = path.join(cwd, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n console.error(chalk.red('No package.json found in current directory. Run from the repo root.'));\n process.exit(1);\n }\n\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));\n const repoSlug = await resolveRepoSlug(cwd, pkgJson);\n\n console.log(` repo: ${repoSlug}`);\n console.log('');\n\n // 1. Workflow files. The caller stubs point at the shared workflows in this repo's own org,\n // so a repo in linked-cm never reaches into linked-fw for its CI.\n const workflowOrg = repoSlug.split('/')[0];\n if (workflowOrg === 'OWNER') {\n console.warn(\n chalk.yellow(\n ' ⚠ The repo slug is unknown, so the workflow stubs will call OWNER/.github — which does\\n' +\n ' not exist. Set the git remote (or package.json repository) and rerun, or fix the\\n' +\n ' `uses:` line in .github/workflows/{pr,publish}.yml by hand.',\n ),\n );\n }\n const requireTests = hasTestScript(pkgJson);\n if (!requireTests) {\n console.warn(\n chalk.yellow(\n ' ⚠ package.json has no `test` script, so pr.yml is written with require-tests: false.\\n' +\n ' Set it to true in .github/workflows/pr.yml once the package has a test suite.',\n ),\n );\n }\n await copyWorkflows(cwd, {workflowOrg, requireTests});\n\n // 2. Changesets config + README\n await copyChangesetConfig(cwd, repoSlug);\n\n // 3. Initial changeset\n await writeInitialChangeset(cwd, pkgJson.name);\n\n // 4. .gitignore\n await updateGitignore(cwd);\n\n // 5. package.json patches\n await patchPackageJson(pkgJsonPath, pkgJson, repoSlug);\n\n // 6. npm install --package-lock-only to generate lockfile (if not present)\n await ensureLockfile(cwd);\n\n // 7. Optional: configure GitHub branch protection\n if (opts.configureGithub) {\n await configureGithub(repoSlug);\n }\n\n // 8. Optional: grant a GitHub team push access\n if (opts.grantTeam) {\n await grantTeamAccess(repoSlug, opts.grantTeam);\n }\n\n // Summary + manual steps\n printNextSteps(repoSlug, npmSecretName, opts.configureGithub, opts.grantTeam);\n}\n\nasync function resolveRepoSlug(cwd: string, pkgJson: any): Promise<string> {\n // Try git remote first\n try {\n const remoteUrl = await execPromise('git config --get remote.origin.url', false, false, {cwd});\n const m = typeof remoteUrl === 'string' ? remoteUrl.match(/[:/]([^/:]+\\/[^/]+?)(?:\\.git)?\\s*$/) : null;\n if (m) return m[1];\n } catch {\n // fall through\n }\n // Fallback: parse package.json repository\n const repoField = pkgJson.repository;\n if (typeof repoField === 'string') {\n const m = repoField.match(/github\\.com[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n if (m) return m[1];\n } else if (repoField?.url) {\n const m = repoField.url.match(/github\\.com[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n if (m) return m[1];\n }\n console.warn(chalk.yellow('Could not determine repo slug. Using placeholder \"OWNER/REPO\" — update .changeset/config.json manually.'));\n return 'OWNER/REPO';\n}\n\n/**\n * Whether the package has a `test` script for the PR check to run. `require-tests: true` turns a\n * missing script into a failure, so it is only safe to write once one exists — and a fresh\n * `create-package` scaffold has none.\n */\nexport function hasTestScript(pkgJson: {scripts?: Record<string, unknown>}): boolean {\n const test = pkgJson.scripts?.test;\n return typeof test === 'string' && test.trim() !== '';\n}\n\nexport type WorkflowVars = {workflowOrg: string; requireTests: boolean};\n\nexport function renderWorkflow(template: string, vars: WorkflowVars): string {\n return template\n .replace(/\\{\\{WORKFLOW_ORG\\}\\}/g, vars.workflowOrg)\n .replace(/\\{\\{REQUIRE_TESTS\\}\\}/g, String(vars.requireTests));\n}\n\nasync function copyWorkflows(cwd: string, vars: WorkflowVars): Promise<void> {\n const srcDir = path.join(TEMPLATE_ROOT, 'github', 'workflows');\n const dstDir = path.join(cwd, '.github', 'workflows');\n fs.mkdirpSync(dstDir);\n\n for (const file of WORKFLOW_FILES) {\n const content = renderWorkflow(fs.readFileSync(path.join(srcDir, file), 'utf8'), vars);\n fs.writeFileSync(path.join(dstDir, file), content);\n console.log(chalk.green(' ✓') + ` .github/workflows/${file}`);\n }\n\n // ci.yml and changeset-check.yml became the two jobs of the shared pr.yml. Left behind on a\n // repo that was set up before the consolidation they keep running, so the old bare\n // `Build & Test` check reports alongside `checks / Build & Test` and re-setting a repo up\n // looks like it worked while the duplicate gate quietly stays.\n for (const stale of ['ci.yml', 'changeset-check.yml']) {\n const stalePath = path.join(dstDir, stale);\n if (fs.existsSync(stalePath)) {\n fs.removeSync(stalePath);\n console.log(chalk.green(' ✓') + ` removed superseded .github/workflows/${stale}`);\n }\n }\n}\n\nasync function copyChangesetConfig(cwd: string, repoSlug: string): Promise<void> {\n const srcDir = path.join(TEMPLATE_ROOT, 'changeset');\n const dstDir = path.join(cwd, '.changeset');\n fs.mkdirpSync(dstDir);\n\n let configContent = fs.readFileSync(path.join(srcDir, 'config.json'), 'utf8');\n configContent = configContent.replace(/\\{\\{REPO_SLUG\\}\\}/g, repoSlug);\n fs.writeFileSync(path.join(dstDir, 'config.json'), configContent);\n console.log(chalk.green(' ✓') + ' .changeset/config.json');\n\n fs.copyFileSync(path.join(srcDir, 'README.md'), path.join(dstDir, 'README.md'));\n console.log(chalk.green(' ✓') + ' .changeset/README.md');\n}\n\nasync function writeInitialChangeset(cwd: string, pkgName: string): Promise<void> {\n const changelogPath = path.join(cwd, 'CHANGELOG.md');\n if (fs.existsSync(changelogPath)) {\n console.log(chalk.gray(' · CHANGELOG.md exists — skipping initial changeset'));\n return;\n }\n const initial = path.join(cwd, '.changeset', 'initial-release.md');\n const body = `---\\n'${pkgName}': patch\\n---\\n\\nInitial release under the new publishing setup.\\n`;\n fs.writeFileSync(initial, body);\n console.log(chalk.green(' ✓') + ' .changeset/initial-release.md');\n}\n\nasync function updateGitignore(cwd: string): Promise<void> {\n const gitignorePath = path.join(cwd, '.gitignore');\n const entries = [\n 'node_modules/',\n 'lib/',\n 'yarn.lock',\n '*.log',\n '.DS_Store',\n '',\n '# tsc sourcemap output — always in lib/, never src/.',\n '# (.d.ts not ignored — hand-written type declarations like colors.d.ts',\n '# are legit src files.)',\n 'src/**/*.js.map',\n ];\n const existing = fs.existsSync(gitignorePath)\n ? fs.readFileSync(gitignorePath, 'utf8').split('\\n')\n : [];\n const existingSet = new Set(existing.map((l) => l.trim()));\n const toAdd = entries.filter((e) => e && !existingSet.has(e.trim()));\n if (toAdd.length === 0) {\n console.log(chalk.gray(' · .gitignore already has all entries'));\n return;\n }\n const merged = [\n ...existing.filter((l) => l.trim() !== ''),\n '',\n ...entries,\n ].join('\\n');\n fs.writeFileSync(gitignorePath, merged + '\\n');\n console.log(chalk.green(' ✓') + ' .gitignore');\n}\n\nasync function patchPackageJson(\n pkgJsonPath: string,\n pkgJson: any,\n repoSlug: string,\n): Promise<void> {\n if (applyPackageJsonPatches(pkgJson, repoSlug)) {\n fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\\n');\n console.log(chalk.green(' ✓') + ' package.json (publishConfig + changesets devDeps)');\n } else {\n console.log(chalk.gray(' · package.json already configured'));\n }\n}\n\n/** Mutates `pkgJson` in place; returns whether anything changed. Pure enough to test. */\nexport function applyPackageJsonPatches(pkgJson: any, repoSlug: string): boolean {\n let modified = false;\n\n // `repository.url` must be set, and must match the repo the workflow builds in.\n //\n // `create-package` scaffolds it EMPTY, and npm rejects a provenance-signed publish whose\n // attestation cannot be matched against it:\n //\n // 422 Error verifying sigstore provenance bundle: Failed to validate repository\n // information: package.json \"repository.url\" is \"\", expected to match <repo>\n //\n // The slug is already resolved from `git remote` above, so there is no reason to leave a\n // package to discover this at its first release.\n if (repoSlug !== 'OWNER/REPO') {\n const url = `git+https://github.com/${repoSlug}.git`;\n const current =\n typeof pkgJson.repository === 'string'\n ? pkgJson.repository\n : pkgJson.repository?.url;\n if (!current) {\n pkgJson.repository = {type: 'git', url};\n modified = true;\n }\n }\n\n if (!pkgJson.publishConfig) {\n pkgJson.publishConfig = {access: 'public'};\n modified = true;\n } else {\n if (pkgJson.publishConfig.access !== 'public') {\n pkgJson.publishConfig.access = 'public';\n modified = true;\n }\n // `provenance` is deliberately left alone. It used to be stripped because publishing went\n // through NPM_AUTH_TOKEN only; the shared workflow now publishes with OIDC trusted publishing\n // first (`npm publish --provenance`, id-token: write on both caller and reusable workflow) and\n // falls back to the staged token release, so provenance is wanted, not a conflict.\n }\n\n pkgJson.devDependencies = pkgJson.devDependencies || {};\n if (!pkgJson.devDependencies['@changesets/cli']) {\n pkgJson.devDependencies['@changesets/cli'] = '^2.29.8';\n modified = true;\n }\n if (!pkgJson.devDependencies['@changesets/changelog-github']) {\n pkgJson.devDependencies['@changesets/changelog-github'] = '^0.5.2';\n modified = true;\n }\n\n return modified;\n}\n\nasync function ensureLockfile(cwd: string): Promise<void> {\n // Always regenerate — package.json has just been patched (new devDeps etc.),\n // so any existing lockfile is stale.\n console.log(chalk.magenta(' Running npm install --package-lock-only...'));\n\n // When running inside a yarn workspace (e.g. CN's packages/* layout), npm\n // climbs up, detects the parent workspace, and writes the lockfile at the\n // wrong level. Work around by copying the package to a tmpdir, generating\n // the lockfile in isolation, and copying it back.\n const os = await import('os');\n const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), 'linked-setup-'));\n const cacheDir = fs.mkdtempSync(path.join(os.tmpdir(), 'linked-setup-cache-'));\n try {\n const pkgJsonPath = path.join(cwd, 'package.json');\n fs.copyFileSync(pkgJsonPath, path.join(tmpBase, 'package.json'));\n await execp(\n `npm install --legacy-peer-deps --package-lock-only --cache ${cacheDir}`,\n false,\n true,\n {cwd: tmpBase},\n );\n const lockPath = path.join(tmpBase, 'package-lock.json');\n if (fs.existsSync(lockPath)) {\n fs.copyFileSync(lockPath, path.join(cwd, 'package-lock.json'));\n console.log(chalk.green(' ✓') + ' package-lock.json');\n } else {\n console.warn(chalk.yellow(' ⚠ npm install did not produce a package-lock.json — likely because a dependency is not yet published on npm.'));\n console.warn(chalk.yellow(' Regenerate manually once all deps are published: `npm install --package-lock-only`.'));\n }\n } catch (err) {\n console.warn(chalk.yellow(' ⚠ Failed to generate package-lock.json — likely because a dependency is not yet published on npm.'));\n console.warn(chalk.yellow(' Regenerate manually once all deps are published: `npm install --package-lock-only`.'));\n } finally {\n fs.removeSync(tmpBase);\n fs.removeSync(cacheDir);\n }\n}\n\nasync function configureGithub(repoSlug: string): Promise<void> {\n console.log('');\n console.log(chalk.magenta('Configuring GitHub (branch protection)...'));\n\n // Check gh CLI available\n try {\n await execPromise('gh --version', false, false);\n } catch {\n console.warn(chalk.yellow(' ⚠ `gh` CLI not found. Install from https://cli.github.com/ and retry with --configure-github,'));\n console.warn(chalk.yellow(' or set branch protection manually at https://github.com/' + repoSlug + '/settings/branches'));\n return;\n }\n\n // Check gh CLI authenticated\n try {\n await execPromise('gh auth status', false, false);\n } catch {\n console.warn(chalk.yellow(' ⚠ `gh` CLI is not authenticated. Run `gh auth login` and retry.'));\n return;\n }\n\n const payload = JSON.stringify(buildBranchProtectionPayload());\n\n try {\n // Use --input - to pass the JSON payload via stdin\n await execPromise(\n `echo '${payload.replace(/'/g, \"'\\\\''\")}' | gh api -X PUT /repos/${repoSlug}/branches/main/protection --input -`,\n false,\n false,\n );\n console.log(chalk.green(' ✓') + ` branch protection enabled on ${repoSlug}/main`);\n // A repo can pin a required check in a *ruleset* as well as in classic branch protection, and\n // the two are stored separately — this call only writes the classic one, so a leftover ruleset\n // keeps blocking merges on a check name that no longer reports.\n console.log(\n chalk.gray(` · check for a competing ruleset: gh api /repos/${repoSlug}/rulesets`),\n );\n } catch (err) {\n console.warn(chalk.yellow(' ⚠ Failed to set branch protection. Do it manually:'));\n console.warn(chalk.yellow(` https://github.com/${repoSlug}/settings/branches`));\n }\n\n // Enable \"Allow auto-merge\" so a PR can be queued to merge itself once checks pass. The publish\n // workflow authors the Release PR via the org App token (org secrets RELEASE_APP_ID /\n // RELEASE_APP_PRIVATE_KEY) so its CI runs without a manual approval gate.\n try {\n await execPromise(\n `gh api -X PATCH /repos/${repoSlug} -F allow_auto_merge=true`,\n false,\n false,\n );\n console.log(chalk.green(' ✓') + ` auto-merge enabled on ${repoSlug}`);\n } catch (err) {\n console.warn(chalk.yellow(' ⚠ Failed to enable auto-merge. Enable it manually:'));\n console.warn(chalk.yellow(` https://github.com/${repoSlug}/settings (General → Allow auto-merge)`));\n }\n}\n\nasync function grantTeamAccess(repoSlug: string, teamSlug: string): Promise<void> {\n console.log('');\n console.log(chalk.magenta(`Granting '${teamSlug}' team push access to ${repoSlug}...`));\n\n try {\n await execPromise('gh --version', false, false);\n } catch {\n console.warn(chalk.yellow(\" ⚠ `gh` CLI not found. Install from https://cli.github.com/ and retry with --grant-team,\"));\n console.warn(chalk.yellow(` or add the team manually at https://github.com/${repoSlug}/settings/access`));\n return;\n }\n\n const [owner, repo] = repoSlug.split('/');\n try {\n await execPromise(\n `gh api -X PUT /orgs/${owner}/teams/${teamSlug}/repos/${owner}/${repo} -f permission=push`,\n false,\n false,\n );\n console.log(chalk.green(' ✓') + ` team '${teamSlug}' granted push access on ${repoSlug}`);\n } catch (err: any) {\n const msg = err?.stderr || err?.stdout || String(err);\n console.warn(chalk.yellow(` ⚠ Failed to grant team access: ${msg.slice(0, 200)}`));\n console.warn(chalk.yellow(` Team may not exist in org '${owner}', or you may lack admin rights.`));\n console.warn(chalk.yellow(` Manual: https://github.com/${repoSlug}/settings/access`));\n }\n}\n\nfunction printNextSteps(\n repoSlug: string,\n npmSecretName: string,\n configuredGithub: boolean | undefined,\n grantedTeam: string | undefined,\n): void {\n console.log('');\n console.log(chalk.green('Done.'));\n console.log('');\n console.log(chalk.bold('Next steps:'));\n console.log('');\n const [owner, repo] = repoSlug.split('/');\n\n console.log(` 1. Review the generated files, adjust as needed.`);\n console.log(` 2. Commit:`);\n console.log(chalk.cyan(' git add . && git commit -m \"set up the publish pipeline\"'));\n console.log(` 3. Push to main — the publish workflow will trigger.`);\n console.log('');\n console.log(chalk.bold('Register the trusted publisher on npmjs.com (before the first release):'));\n console.log('');\n console.log(` package → Settings → Trusted Publisher, matching the caller workflow exactly:`);\n console.log(` organization: ${chalk.cyan(owner)} repository: ${chalk.cyan(repo)}`);\n console.log(` workflow filename: ${chalk.cyan('publish.yml')} environment: ${chalk.cyan('(empty)')}`);\n console.log(` \"Allow npm publish\": ${chalk.cyan('ticked')}`);\n console.log('');\n console.log(chalk.gray(` Without it the release still ships — the workflow falls back to a staged`));\n console.log(chalk.gray(` npm release that a maintainer approves with 2FA. A typo in the organization`));\n console.log(chalk.gray(` field looks exactly the same, so check that field first if a package that`));\n console.log(chalk.gray(` should publish directly keeps staging instead.`));\n console.log('');\n // No per-repo secret grant step: NPM_AUTH_TOKEN, RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are\n // \"All repositories\" org secrets, which is the whole reason first-party and community packages\n // live in separate orgs. Only mention what is genuinely still one-time-per-org.\n console.log(chalk.bold(`One-time org-level setup (already done on linked-fw and linked-cm):`));\n console.log('');\n console.log(` a. Org secrets ${chalk.cyan(npmSecretName)}, ${chalk.cyan('RELEASE_APP_ID')} and ${chalk.cyan('RELEASE_APP_PRIVATE_KEY')},`);\n console.log(` visible to ${chalk.cyan('All repositories')} — there is no per-repo grant step.`);\n console.log(` → https://github.com/organizations/${owner}/settings/secrets/actions`);\n console.log('');\n console.log(` b. Enable \"Allow GitHub Actions to create and approve pull requests\":`);\n console.log(` → https://github.com/organizations/${owner}/settings/actions`);\n\n if (!configuredGithub) {\n console.log('');\n console.log(chalk.bold('Branch protection:'));\n console.log(` Rerun with ${chalk.cyan('linked setup-publish --configure-github')} to configure automatically,`);\n console.log(` or set manually at https://github.com/${repoSlug}/settings/branches —`);\n console.log(` the required check is ${chalk.cyan('checks / Build & Test')}, not ${chalk.cyan('Build & Test')}.`);\n }\n console.log('');\n}\n"]}
1
+ {"version":3,"file":"setup-publish.js","sourceRoot":"","sources":["../../../src/commands/setup-publish.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,EAAE,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AACnC,OAAO,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAE/C,MAAM,SAAS,GACb,OAAO,SAAS,KAAK,WAAW;IAC9B,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,YAAY;QACZ,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAErD,wEAAwE;AACxE,8EAA8E;AAC9E,sEAAsE;AACtE,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AAE7F,2FAA2F;AAC3F,0FAA0F;AAC1F,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAU,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B;IAC1C,OAAO;QACL,sBAAsB,EAAE,EAAC,MAAM,EAAE,KAAK,EAAE,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AQ,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC;IAC5I,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,CAAC;IACpG,OAAO,CAAC,GAAG,CAAC,2CAA2C,KAAK,2BAA2B,CAAC,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,yEAAyE,CAAC,CAAC;IACvF,OAAO,CAAC,GAAG,CAAC,2CAA2C,KAAK,mBAAmB,CAAC,CAAC;IAEjF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,IAAI,CAAC,yCAAyC,CAAC,8BAA8B,CAAC,CAAC;QACjH,OAAO,CAAC,GAAG,CAAC,2CAA2C,QAAQ,sBAAsB,CAAC,CAAC;QACvF,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACpH,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import chalk from 'chalk';\nimport fs from 'fs-extra';\nimport path, {dirname} from 'path';\nimport {execp, execPromise} from '../utils.js';\n\nconst dirname__ =\n typeof __dirname !== 'undefined'\n ? __dirname\n : //@ts-ignore\n dirname(import.meta.url).replace('file:/', '');\n\n// defaults/setup-publish/ lives at packages/cli/defaults/setup-publish/\n// This file compiles to lib/{esm,cjs}/commands/setup-publish.js — go up three\n// levels to reach the package root, then into defaults/setup-publish.\nconst TEMPLATE_ROOT = path.resolve(dirname__, '..', '..', '..', 'defaults', 'setup-publish');\n\n// Both are callers of the shared reusable workflows. `publish.yml` in particular cannot be\n// renamed: npm's trusted-publisher check validates the calling workflow's filename, and a\n// mismatch only shows up as releases quietly needing manual approval again.\nexport const WORKFLOW_FILES = ['pr.yml', 'publish.yml'] as const;\n\n/**\n * The uniform branch-protection profile every `@_linked` repo runs on `main`.\n *\n * The required check is `checks / Build & Test`, not `Build & Test`: GitHub reports a job invoked\n * through `workflow_call` as `<caller-job-id> / <job name>`, and the caller job in pr.yml is\n * `checks`. A repo pinning the bare name waits forever on a check that never reports.\n */\nexport function buildBranchProtectionPayload() {\n return {\n required_status_checks: {strict: false, contexts: ['checks / Build & Test']},\n // Admins included: the point of the gate is that no release skips the build, and the people\n // most likely to push straight to main are the admins.\n enforce_admins: true,\n // Reviews enabled but zero approvals required. The publish workflow direct-merges the version\n // PR (GitHub's auto-merge queue does not honor review-bypass allowances), so a non-zero count\n // would stall every release; the block itself still has to exist for the profile to match.\n required_pull_request_reviews: {\n required_approving_review_count: 0,\n dismiss_stale_reviews: false,\n require_code_owner_reviews: false,\n },\n restrictions: null,\n allow_force_pushes: false,\n allow_deletions: false,\n };\n}\n\nexport type SetupPublishOptions = {\n configureGithub?: boolean;\n /**\n * @deprecated The npm secret is `NPM_AUTH_TOKEN` in every org, holding a token for that\n * org's own npm scope — there is no longer a second name to select between. Kept as an\n * accepted no-op for the same reason as `dualBranch`: commander aborts the whole command\n * on an unknown option, so a stale script would fail to set the repo up at all rather\n * than setting it up correctly.\n */\n scope?: string;\n /**\n * @deprecated The dual-branch (`main` + `dev`) flow and its `@next` prereleases are retired —\n * every package repo is `main`-only. Kept as an accepted no-op rather than removed because\n * commander aborts the whole command on an unknown option, so a stale script or copied\n * command line would fail to set the repo up at all instead of setting it up correctly.\n */\n dualBranch?: boolean;\n grantTeam?: string; // GitHub team slug to grant push access on the repo\n};\n\n/**\n * Set up the changesets publish pipeline in the current package repo.\n *\n * The workflows are thin callers of the shared reusable workflows in the repo's OWN org\n * `.github` repo (pinned `@v1`, a deliberately moving tag) — one edit there changes every\n * package's pipeline in that org, which is why nothing about the build or publish steps is\n * scaffolded per repo any more. Each org keeps its own copy so that community gates can be\n * stricter than first-party ones without a cross-org `workflow_call`.\n *\n * Installs:\n * - .github/workflows/{pr,publish}.yml — caller stubs, nothing else\n * - .changeset/config.json + README.md\n * - .changeset/initial-release.md\n * - .gitignore entries for node_modules, lib, yarn.lock, src-compiled-artifacts\n * - package.json: @changesets/cli + @changesets/changelog-github devDeps,\n * publishConfig: {access: public}\n * - .npmrc: allow-remote=all, plus legacy-peer-deps=true in linked-cm (see npmrcSettings);\n * keys the repo already sets are left alone\n * - renovate.json extending <org>/renovate-config, unless the repo has a Renovate config\n * - package-lock.json refreshed via npm install --package-lock-only, keeping existing resolutions\n *\n * With --configure-github: if `gh` CLI is available and authenticated, also applies the uniform\n * branch-protection profile on main and enables auto-merge.\n */\nexport async function setupPublish(opts: SetupPublishOptions = {}): Promise<void> {\n const cwd = process.cwd();\n // One secret NAME across every org. The orgs are separate, so each holds its own value —\n // a token scoped to that org's npm scope. (There used to be an `NPM_AUTH_TOKEN_CM` for\n // `@linked.cm`; that dates from before first-party and community repos were split into two\n // orgs and one org therefore had to hold both tokens at once.)\n const npmSecretName = 'NPM_AUTH_TOKEN';\n\n console.log(chalk.magenta('Setting up the publish pipeline (main only)...'));\n if (opts.scope) {\n console.log(\n chalk.yellow(\n ' ⚠ --scope is deprecated and ignored: every org uses NPM_AUTH_TOKEN, holding that\\n' +\n \" org's own token. The NPM_AUTH_TOKEN_CM name is retired.\",\n ),\n );\n }\n if (opts.dualBranch) {\n console.log(\n chalk.yellow(\n ' ⚠ --dual-branch is deprecated and ignored: the main + dev flow and its @next prereleases are retired.',\n ),\n );\n }\n console.log(` target: ${cwd}`);\n console.log(` npm secret: ${npmSecretName}`);\n\n const pkgJsonPath = path.join(cwd, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n console.error(chalk.red('No package.json found in current directory. Run from the repo root.'));\n process.exit(1);\n }\n\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));\n const repoSlug = await resolveRepoSlug(cwd, pkgJson);\n\n console.log(` repo: ${repoSlug}`);\n console.log('');\n\n // 1. Workflow files. The caller stubs point at the shared workflows in this repo's own org,\n // so a repo in linked-cm never reaches into linked-fw for its CI.\n const workflowOrg = repoSlug.split('/')[0];\n if (workflowOrg === 'OWNER') {\n console.warn(\n chalk.yellow(\n ' ⚠ The repo slug is unknown, so the workflow stubs will call OWNER/.github — which does\\n' +\n ' not exist. Set the git remote (or package.json repository) and rerun, or fix the\\n' +\n ' `uses:` line in .github/workflows/{pr,publish}.yml by hand.',\n ),\n );\n }\n const requireTests = hasTestScript(pkgJson);\n if (!requireTests) {\n console.warn(\n chalk.yellow(\n ' ⚠ package.json has no `test` script, so pr.yml is written with require-tests: false.\\n' +\n ' Set it to true in .github/workflows/pr.yml once the package has a test suite.',\n ),\n );\n }\n await copyWorkflows(cwd, {workflowOrg, requireTests});\n\n // 2. Changesets config + README\n await copyChangesetConfig(cwd, repoSlug);\n\n // 3. Initial changeset\n await writeInitialChangeset(cwd, pkgJson.name);\n\n // 4. .gitignore\n await updateGitignore(cwd);\n\n // 5. package.json patches\n await patchPackageJson(pkgJsonPath, pkgJson, repoSlug);\n\n // 6. .npmrc — before the lockfile step, which must resolve under the same settings as CI\n await updateNpmrc(cwd, workflowOrg);\n\n // 7. renovate.json stub extending the org's shared policy\n await writeRenovateConfig(cwd, workflowOrg);\n\n // 8. npm install --package-lock-only to generate lockfile (if not present)\n await ensureLockfile(cwd);\n\n // 9. Optional: configure GitHub branch protection\n if (opts.configureGithub) {\n await configureGithub(repoSlug);\n }\n\n // 10. Optional: grant a GitHub team push access\n if (opts.grantTeam) {\n await grantTeamAccess(repoSlug, opts.grantTeam);\n }\n\n // Summary + manual steps\n printNextSteps(repoSlug, npmSecretName, opts.configureGithub, opts.grantTeam);\n}\n\nasync function resolveRepoSlug(cwd: string, pkgJson: any): Promise<string> {\n // Try git remote first\n try {\n const remoteUrl = await execPromise('git config --get remote.origin.url', false, false, {cwd});\n const m = typeof remoteUrl === 'string' ? remoteUrl.match(/[:/]([^/:]+\\/[^/]+?)(?:\\.git)?\\s*$/) : null;\n if (m) return m[1];\n } catch {\n // fall through\n }\n // Fallback: parse package.json repository\n const repoField = pkgJson.repository;\n if (typeof repoField === 'string') {\n const m = repoField.match(/github\\.com[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n if (m) return m[1];\n } else if (repoField?.url) {\n const m = repoField.url.match(/github\\.com[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/);\n if (m) return m[1];\n }\n console.warn(chalk.yellow('Could not determine repo slug. Using placeholder \"OWNER/REPO\" — update .changeset/config.json manually.'));\n return 'OWNER/REPO';\n}\n\n/**\n * Whether the package has a `test` script for the PR check to run. `require-tests: true` turns a\n * missing script into a failure, so it is only safe to write once one exists — and a fresh\n * `create-package` scaffold has none.\n */\nexport function hasTestScript(pkgJson: {scripts?: Record<string, unknown>}): boolean {\n const test = pkgJson.scripts?.test;\n return typeof test === 'string' && test.trim() !== '';\n}\n\nexport type WorkflowVars = {workflowOrg: string; requireTests: boolean};\n\nexport function renderWorkflow(template: string, vars: WorkflowVars): string {\n return template\n .replace(/\\{\\{WORKFLOW_ORG\\}\\}/g, vars.workflowOrg)\n .replace(/\\{\\{REQUIRE_TESTS\\}\\}/g, String(vars.requireTests));\n}\n\nasync function copyWorkflows(cwd: string, vars: WorkflowVars): Promise<void> {\n const srcDir = path.join(TEMPLATE_ROOT, 'github', 'workflows');\n const dstDir = path.join(cwd, '.github', 'workflows');\n fs.mkdirpSync(dstDir);\n\n for (const file of WORKFLOW_FILES) {\n const content = renderWorkflow(fs.readFileSync(path.join(srcDir, file), 'utf8'), vars);\n fs.writeFileSync(path.join(dstDir, file), content);\n console.log(chalk.green(' ✓') + ` .github/workflows/${file}`);\n }\n\n // ci.yml and changeset-check.yml became the two jobs of the shared pr.yml. Left behind on a\n // repo that was set up before the consolidation they keep running, so the old bare\n // `Build & Test` check reports alongside `checks / Build & Test` and re-setting a repo up\n // looks like it worked while the duplicate gate quietly stays.\n for (const stale of ['ci.yml', 'changeset-check.yml']) {\n const stalePath = path.join(dstDir, stale);\n if (fs.existsSync(stalePath)) {\n fs.removeSync(stalePath);\n console.log(chalk.green(' ✓') + ` removed superseded .github/workflows/${stale}`);\n }\n }\n}\n\nasync function copyChangesetConfig(cwd: string, repoSlug: string): Promise<void> {\n const srcDir = path.join(TEMPLATE_ROOT, 'changeset');\n const dstDir = path.join(cwd, '.changeset');\n fs.mkdirpSync(dstDir);\n\n let configContent = fs.readFileSync(path.join(srcDir, 'config.json'), 'utf8');\n configContent = configContent.replace(/\\{\\{REPO_SLUG\\}\\}/g, repoSlug);\n fs.writeFileSync(path.join(dstDir, 'config.json'), configContent);\n console.log(chalk.green(' ✓') + ' .changeset/config.json');\n\n fs.copyFileSync(path.join(srcDir, 'README.md'), path.join(dstDir, 'README.md'));\n console.log(chalk.green(' ✓') + ' .changeset/README.md');\n}\n\nasync function writeInitialChangeset(cwd: string, pkgName: string): Promise<void> {\n const changelogPath = path.join(cwd, 'CHANGELOG.md');\n if (fs.existsSync(changelogPath)) {\n console.log(chalk.gray(' · CHANGELOG.md exists — skipping initial changeset'));\n return;\n }\n const initial = path.join(cwd, '.changeset', 'initial-release.md');\n const body = `---\\n'${pkgName}': patch\\n---\\n\\nInitial release under the new publishing setup.\\n`;\n fs.writeFileSync(initial, body);\n console.log(chalk.green(' ✓') + ' .changeset/initial-release.md');\n}\n\nasync function updateGitignore(cwd: string): Promise<void> {\n const gitignorePath = path.join(cwd, '.gitignore');\n const entries = [\n 'node_modules/',\n 'lib/',\n 'yarn.lock',\n '*.log',\n '.DS_Store',\n '',\n '# tsc sourcemap output — always in lib/, never src/.',\n '# (.d.ts not ignored — hand-written type declarations like colors.d.ts',\n '# are legit src files.)',\n 'src/**/*.js.map',\n ];\n const existing = fs.existsSync(gitignorePath)\n ? fs.readFileSync(gitignorePath, 'utf8').split('\\n')\n : [];\n const existingSet = new Set(existing.map((l) => l.trim()));\n const toAdd = entries.filter((e) => e && !existingSet.has(e.trim()));\n if (toAdd.length === 0) {\n console.log(chalk.gray(' · .gitignore already has all entries'));\n return;\n }\n const merged = [\n ...existing.filter((l) => l.trim() !== ''),\n '',\n ...entries,\n ].join('\\n');\n fs.writeFileSync(gitignorePath, merged + '\\n');\n console.log(chalk.green(' ✓') + ' .gitignore');\n}\n\n/**\n * The `.npmrc` settings a package repo needs so that a local `npm install` resolves the same tree\n * as its org's shared workflows and Renovate.\n *\n * - `allow-remote=all`: npm 12 defaults `allow-remote` to `none` and then refuses the registry\n * tarball of a bundled dependency (`@tailwindcss/oxide-wasm32-wasi` is in most of the fleet),\n * failing `npm install` with EALLOWREMOTE. npm 11, which CI runs, accepts the setting.\n * - `legacy-peer-deps=true`, linked-cm only: its workflows install with\n * `npm ci --legacy-peer-deps`. linked-fw's install strictly, and its Renovate policy requires\n * locks to be resolved under CI's peer rules — so writing it there would be the mismatch.\n */\nexport function npmrcSettings(workflowOrg: string): string[] {\n const settings = ['allow-remote=all'];\n if (workflowOrg === 'linked-cm') settings.push('legacy-peer-deps=true');\n return settings;\n}\n\n/**\n * Appends each setting whose key the existing `.npmrc` does not set. A key that is already set\n * keeps its value: the repo may have a reason, and silently flipping it would change installs.\n */\nexport function mergeNpmrc(existing: string, settings: string[]): string {\n const keyOf = (line: string) => line.split('=')[0].trim();\n const present = new Set(\n existing\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.startsWith('#') && !line.startsWith(';'))\n .map(keyOf),\n );\n const missing = settings.filter((setting) => !present.has(keyOf(setting)));\n if (missing.length === 0) return existing;\n const base = existing === '' || existing.endsWith('\\n') ? existing : existing + '\\n';\n return base + missing.join('\\n') + '\\n';\n}\n\nasync function updateNpmrc(cwd: string, workflowOrg: string): Promise<void> {\n const npmrcPath = path.join(cwd, '.npmrc');\n const existing = fs.existsSync(npmrcPath) ? fs.readFileSync(npmrcPath, 'utf8') : '';\n const next = mergeNpmrc(existing, npmrcSettings(workflowOrg));\n if (next === existing) {\n console.log(chalk.gray(' · .npmrc already has the required settings'));\n return;\n }\n fs.writeFileSync(npmrcPath, next);\n console.log(chalk.green(' ✓') + ' .npmrc');\n}\n\n// Every location Renovate reads a repo config from. If any exists, the repo has a config of its\n// own and setup-publish leaves it alone.\nconst RENOVATE_CONFIG_FILES = [\n 'renovate.json',\n 'renovate.json5',\n '.github/renovate.json',\n '.github/renovate.json5',\n '.gitlab/renovate.json',\n '.gitlab/renovate.json5',\n '.renovaterc',\n '.renovaterc.json',\n '.renovaterc.json5',\n];\n\n/**\n * The three-line stub every package repo carries: the policy itself lives in the org's\n * `renovate-config` repo, so one edit there reaches the whole fleet.\n */\nexport function renovateStub(workflowOrg: string): string {\n return (\n JSON.stringify(\n {\n $schema: 'https://docs.renovatebot.com/renovate-schema.json',\n extends: [`local>${workflowOrg}/renovate-config`],\n },\n null,\n 2,\n ) + '\\n'\n );\n}\n\nasync function writeRenovateConfig(cwd: string, workflowOrg: string): Promise<void> {\n if (workflowOrg === 'OWNER') {\n console.warn(chalk.yellow(' ⚠ Skipped renovate.json: the repo org is unknown.'));\n return;\n }\n const existing = RENOVATE_CONFIG_FILES.find((file) => fs.existsSync(path.join(cwd, file)));\n if (existing) {\n console.log(chalk.gray(` · ${existing} exists — left as is`));\n return;\n }\n fs.writeFileSync(path.join(cwd, 'renovate.json'), renovateStub(workflowOrg));\n console.log(chalk.green(' ✓') + ` renovate.json (extends ${workflowOrg}/renovate-config)`);\n}\n\nasync function patchPackageJson(\n pkgJsonPath: string,\n pkgJson: any,\n repoSlug: string,\n): Promise<void> {\n if (applyPackageJsonPatches(pkgJson, repoSlug)) {\n fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\\n');\n console.log(chalk.green(' ✓') + ' package.json (publishConfig + changesets devDeps)');\n } else {\n console.log(chalk.gray(' · package.json already configured'));\n }\n}\n\n/** Mutates `pkgJson` in place; returns whether anything changed. Pure enough to test. */\nexport function applyPackageJsonPatches(pkgJson: any, repoSlug: string): boolean {\n let modified = false;\n\n // `repository.url` must be set, and must match the repo the workflow builds in.\n //\n // `create-package` scaffolds it EMPTY, and npm rejects a provenance-signed publish whose\n // attestation cannot be matched against it:\n //\n // 422 Error verifying sigstore provenance bundle: Failed to validate repository\n // information: package.json \"repository.url\" is \"\", expected to match <repo>\n //\n // The slug is already resolved from `git remote` above, so there is no reason to leave a\n // package to discover this at its first release.\n if (repoSlug !== 'OWNER/REPO') {\n const url = `git+https://github.com/${repoSlug}.git`;\n const current =\n typeof pkgJson.repository === 'string'\n ? pkgJson.repository\n : pkgJson.repository?.url;\n if (!current) {\n pkgJson.repository = {type: 'git', url};\n modified = true;\n }\n }\n\n if (!pkgJson.publishConfig) {\n pkgJson.publishConfig = {access: 'public'};\n modified = true;\n } else {\n if (pkgJson.publishConfig.access !== 'public') {\n pkgJson.publishConfig.access = 'public';\n modified = true;\n }\n // `provenance` is deliberately left alone. It used to be stripped because publishing went\n // through NPM_AUTH_TOKEN only; the shared workflow now publishes with OIDC trusted publishing\n // first (`npm publish --provenance`, id-token: write on both caller and reusable workflow) and\n // falls back to the staged token release, so provenance is wanted, not a conflict.\n }\n\n pkgJson.devDependencies = pkgJson.devDependencies || {};\n if (!pkgJson.devDependencies['@changesets/cli']) {\n pkgJson.devDependencies['@changesets/cli'] = '^3.0.0';\n modified = true;\n }\n if (!pkgJson.devDependencies['@changesets/changelog-github']) {\n pkgJson.devDependencies['@changesets/changelog-github'] = '^1.0.0';\n modified = true;\n }\n\n return modified;\n}\n\nasync function ensureLockfile(cwd: string): Promise<void> {\n // Always regenerate — package.json has just been patched (new devDeps etc.),\n // so any existing lockfile is stale.\n console.log(chalk.magenta(' Running npm install --package-lock-only...'));\n\n // When running inside a yarn workspace (e.g. CN's packages/* layout), npm\n // climbs up, detects the parent workspace, and writes the lockfile at the\n // wrong level. Work around by copying the package to a tmpdir, generating\n // the lockfile in isolation, and copying it back.\n const os = await import('os');\n const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), 'linked-setup-'));\n const cacheDir = fs.mkdtempSync(path.join(os.tmpdir(), 'linked-setup-cache-'));\n try {\n // The existing lockfile comes along so its resolutions are kept (only what package.json just\n // gained is resolved), and .npmrc so the lock is resolved under the repo's own settings —\n // allow-remote for npm 12, and legacy-peer-deps exactly where the org's CI installs that way.\n for (const file of ['package.json', 'package-lock.json', '.npmrc']) {\n const src = path.join(cwd, file);\n if (fs.existsSync(src)) fs.copyFileSync(src, path.join(tmpBase, file));\n }\n await execp(\n `npm install --package-lock-only --ignore-scripts --cache ${cacheDir}`,\n false,\n true,\n {cwd: tmpBase},\n );\n const lockPath = path.join(tmpBase, 'package-lock.json');\n if (fs.existsSync(lockPath)) {\n fs.copyFileSync(lockPath, path.join(cwd, 'package-lock.json'));\n console.log(chalk.green(' ✓') + ' package-lock.json');\n } else {\n console.warn(chalk.yellow(' ⚠ npm install did not produce a package-lock.json — likely because a dependency is not yet published on npm.'));\n console.warn(chalk.yellow(' Regenerate manually once all deps are published: `npm install --package-lock-only`.'));\n }\n } catch (err) {\n console.warn(chalk.yellow(' ⚠ Failed to generate package-lock.json — likely because a dependency is not yet published on npm.'));\n console.warn(chalk.yellow(' Regenerate manually once all deps are published: `npm install --package-lock-only`.'));\n } finally {\n fs.removeSync(tmpBase);\n fs.removeSync(cacheDir);\n }\n}\n\nasync function configureGithub(repoSlug: string): Promise<void> {\n console.log('');\n console.log(chalk.magenta('Configuring GitHub (branch protection)...'));\n\n // Check gh CLI available\n try {\n await execPromise('gh --version', false, false);\n } catch {\n console.warn(chalk.yellow(' ⚠ `gh` CLI not found. Install from https://cli.github.com/ and retry with --configure-github,'));\n console.warn(chalk.yellow(' or set branch protection manually at https://github.com/' + repoSlug + '/settings/branches'));\n return;\n }\n\n // Check gh CLI authenticated\n try {\n await execPromise('gh auth status', false, false);\n } catch {\n console.warn(chalk.yellow(' ⚠ `gh` CLI is not authenticated. Run `gh auth login` and retry.'));\n return;\n }\n\n const payload = JSON.stringify(buildBranchProtectionPayload());\n\n try {\n // Use --input - to pass the JSON payload via stdin\n await execPromise(\n `echo '${payload.replace(/'/g, \"'\\\\''\")}' | gh api -X PUT /repos/${repoSlug}/branches/main/protection --input -`,\n false,\n false,\n );\n console.log(chalk.green(' ✓') + ` branch protection enabled on ${repoSlug}/main`);\n // A repo can pin a required check in a *ruleset* as well as in classic branch protection, and\n // the two are stored separately — this call only writes the classic one, so a leftover ruleset\n // keeps blocking merges on a check name that no longer reports.\n console.log(\n chalk.gray(` · check for a competing ruleset: gh api /repos/${repoSlug}/rulesets`),\n );\n } catch (err) {\n console.warn(chalk.yellow(' ⚠ Failed to set branch protection. Do it manually:'));\n console.warn(chalk.yellow(` https://github.com/${repoSlug}/settings/branches`));\n }\n\n // Enable \"Allow auto-merge\" so a PR can be queued to merge itself once checks pass. The publish\n // workflow authors the Release PR via the org App token (org secrets RELEASE_APP_ID /\n // RELEASE_APP_PRIVATE_KEY) so its CI runs without a manual approval gate.\n try {\n await execPromise(\n `gh api -X PATCH /repos/${repoSlug} -F allow_auto_merge=true`,\n false,\n false,\n );\n console.log(chalk.green(' ✓') + ` auto-merge enabled on ${repoSlug}`);\n } catch (err) {\n console.warn(chalk.yellow(' ⚠ Failed to enable auto-merge. Enable it manually:'));\n console.warn(chalk.yellow(` https://github.com/${repoSlug}/settings (General → Allow auto-merge)`));\n }\n}\n\nasync function grantTeamAccess(repoSlug: string, teamSlug: string): Promise<void> {\n console.log('');\n console.log(chalk.magenta(`Granting '${teamSlug}' team push access to ${repoSlug}...`));\n\n try {\n await execPromise('gh --version', false, false);\n } catch {\n console.warn(chalk.yellow(\" ⚠ `gh` CLI not found. Install from https://cli.github.com/ and retry with --grant-team,\"));\n console.warn(chalk.yellow(` or add the team manually at https://github.com/${repoSlug}/settings/access`));\n return;\n }\n\n const [owner, repo] = repoSlug.split('/');\n try {\n await execPromise(\n `gh api -X PUT /orgs/${owner}/teams/${teamSlug}/repos/${owner}/${repo} -f permission=push`,\n false,\n false,\n );\n console.log(chalk.green(' ✓') + ` team '${teamSlug}' granted push access on ${repoSlug}`);\n } catch (err: any) {\n const msg = err?.stderr || err?.stdout || String(err);\n console.warn(chalk.yellow(` ⚠ Failed to grant team access: ${msg.slice(0, 200)}`));\n console.warn(chalk.yellow(` Team may not exist in org '${owner}', or you may lack admin rights.`));\n console.warn(chalk.yellow(` Manual: https://github.com/${repoSlug}/settings/access`));\n }\n}\n\nfunction printNextSteps(\n repoSlug: string,\n npmSecretName: string,\n configuredGithub: boolean | undefined,\n grantedTeam: string | undefined,\n): void {\n console.log('');\n console.log(chalk.green('Done.'));\n console.log('');\n console.log(chalk.bold('Next steps:'));\n console.log('');\n const [owner, repo] = repoSlug.split('/');\n\n console.log(` 1. Review the generated files, adjust as needed.`);\n console.log(` 2. Commit:`);\n console.log(chalk.cyan(' git add . && git commit -m \"set up the publish pipeline\"'));\n console.log(` 3. Push to main — the publish workflow will trigger.`);\n console.log('');\n console.log(chalk.bold('Register the trusted publisher on npmjs.com (before the first release):'));\n console.log('');\n console.log(` package → Settings → Trusted Publisher, matching the caller workflow exactly:`);\n console.log(` organization: ${chalk.cyan(owner)} repository: ${chalk.cyan(repo)}`);\n console.log(` workflow filename: ${chalk.cyan('publish.yml')} environment: ${chalk.cyan('(empty)')}`);\n console.log(` \"Allow npm publish\": ${chalk.cyan('ticked')}`);\n console.log('');\n console.log(chalk.gray(` Without it the release still ships — the workflow falls back to a staged`));\n console.log(chalk.gray(` npm release that a maintainer approves with 2FA. A typo in the organization`));\n console.log(chalk.gray(` field looks exactly the same, so check that field first if a package that`));\n console.log(chalk.gray(` should publish directly keeps staging instead.`));\n console.log('');\n // No per-repo secret grant step: NPM_AUTH_TOKEN, RELEASE_APP_ID and RELEASE_APP_PRIVATE_KEY are\n // \"All repositories\" org secrets, which is the whole reason first-party and community packages\n // live in separate orgs. Only mention what is genuinely still one-time-per-org.\n console.log(chalk.bold(`One-time org-level setup (already done on linked-fw and linked-cm):`));\n console.log('');\n console.log(` a. Org secrets ${chalk.cyan(npmSecretName)}, ${chalk.cyan('RELEASE_APP_ID')} and ${chalk.cyan('RELEASE_APP_PRIVATE_KEY')},`);\n console.log(` visible to ${chalk.cyan('All repositories')} — there is no per-repo grant step.`);\n console.log(` → https://github.com/organizations/${owner}/settings/secrets/actions`);\n console.log('');\n console.log(` b. Enable \"Allow GitHub Actions to create and approve pull requests\":`);\n console.log(` → https://github.com/organizations/${owner}/settings/actions`);\n\n if (!configuredGithub) {\n console.log('');\n console.log(chalk.bold('Branch protection:'));\n console.log(` Rerun with ${chalk.cyan('linked setup-publish --configure-github')} to configure automatically,`);\n console.log(` or set manually at https://github.com/${repoSlug}/settings/branches —`);\n console.log(` the required check is ${chalk.cyan('checks / Build & Test')}, not ${chalk.cyan('Build & Test')}.`);\n }\n console.log('');\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_linked/cli",
3
- "version": "1.42.0",
3
+ "version": "1.43.1",
4
4
  "packageManager": "npm@11.21.0",
5
5
  "description": "Command line tools for the @_linked/* packages and apps",
6
6
  "main": "lib/esm/index.js",