trustci 0.3.0 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +45 -3
  2. package/dist/cli.js +27 -7
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -10,7 +10,7 @@ Setting up trusted publishing one package at a time is tedious in a monorepo.
10
10
 
11
11
  ## Requirements
12
12
 
13
- - **npm** 11.5.1 or later (for `npm trust`)
13
+ - **npm** 11.15.0 or later (for `npm trust` with `--allow-publish` / `--allow-stage-publish`)
14
14
  - **Node** 22.14.0 or later
15
15
 
16
16
  ## Usage
@@ -32,7 +32,7 @@ npx trustci list
32
32
  | ---------- | ---------------------------------------------------------------------------------------------- | --------------- |
33
33
  | `github` | `--repo <owner/repo>` `--file <workflow>` | `--env <name>` |
34
34
  | `gitlab` | `--project <group/project>` (or `--repo`) `--file <workflow>` | `--env <name>` |
35
- | `circleci` | Either all of `--org-id` `--project-id` `--pipeline-definition-id`, or a CircleCI token | `--vcs-origin <host/owner/repo>`, `--circle-token`, `--file`, `--context-id` (repeatable) |
35
+ | `circleci` | A CircleCI token, or all of `--org-id` `--project-id` `--pipeline-definition-id` | `--vcs-origin <host/owner/repo>` (inferred), `--circle-token`, `--file`, `--context-id` (repeatable) |
36
36
 
37
37
  At least one of `--allow-publish` / `--allow-stage-publish` is required.
38
38
 
@@ -40,7 +40,12 @@ At least one of `--allow-publish` / `--allow-stage-publish` is required.
40
40
  # GitLab
41
41
  npx trustci --provider gitlab --project me/repo --file .gitlab-ci.yml --allow-publish -y
42
42
 
43
- # CircleCI (vcs-origin is host/owner/repo; a leading https:// is stripped automatically)
43
+ # CircleCI — minimal form: UUIDs are resolved via the API and --vcs-origin
44
+ # is inferred, so a token (here via the environment) is all you need to add
45
+ CIRCLE_TOKEN=... npx trustci --provider circleci --allow-publish
46
+
47
+ # CircleCI — fully explicit form
48
+ # (vcs-origin is host/owner/repo; a leading https:// is stripped automatically)
44
49
  npx trustci --provider circleci \
45
50
  --org-id <uuid> --project-id <uuid> --pipeline-definition-id <uuid> \
46
51
  --vcs-origin github.com/me/repo \
@@ -73,6 +78,22 @@ prints which one it used (never the token itself):
73
78
  The OS keychain, where circleci CLI v1 and chunk store tokens by default, is not read.
74
79
  When all three UUIDs are given, no token is looked up.
75
80
 
81
+ #### CircleCI pipeline definitions and `--file`
82
+
83
+ A missing `--pipeline-definition-id` is resolved by listing the project's
84
+ pipeline definitions. When there is exactly one, it is used automatically.
85
+ When the project has several — e.g. a config sourced from another repository
86
+ alongside `.circleci/config.yml` — pass `--file` with either the definition's
87
+ config file path or its name; the error message lists the candidates:
88
+
89
+ ```bash
90
+ npx trustci --provider circleci --allow-publish \
91
+ --file workflows/publish/npm-polyrepo-bun-semantic-release.yaml
92
+ ```
93
+
94
+ `--file` is only used for this lookup — it is not passed to `npm trust`, and
95
+ it has no effect when `--pipeline-definition-id` is given explicitly.
96
+
76
97
  ### Common options
77
98
 
78
99
  | Flag | Description |
@@ -95,6 +116,18 @@ Patterns are read from the first of:
95
116
  Packages marked `"private": true` are always excluded. On a real (non-dry) run,
96
117
  packages not yet published to the registry are skipped with a warning.
97
118
 
119
+ ## Agent skill
120
+
121
+ The repository ships an [Agent Skill](https://agentskills.io/) at
122
+ [`skills/trustci/SKILL.md`](https://github.com/hideokamoto/trustci/blob/main/skills/trustci/SKILL.md)
123
+ that teaches coding agents (Claude Code, Codex, Cursor, …) to run trustci safely:
124
+ dry-run first, then a real run only after you confirm. Install it with the
125
+ [`skills`](https://github.com/vercel-labs/skills) CLI:
126
+
127
+ ```bash
128
+ npx skills add hideokamoto/trustci
129
+ ```
130
+
98
131
  ## Development
99
132
 
100
133
  Built with [Bun](https://bun.sh), ships zero runtime dependencies, and the
@@ -107,6 +140,15 @@ bun run typecheck
107
140
  bun run build # -> dist/cli.js (npx entry point), via `bun build --target node`
108
141
  ```
109
142
 
143
+ The documentation site lives in `docs/` ([Astro Starlight](https://starlight.astro.build/)):
144
+
145
+ ```bash
146
+ cd docs
147
+ bun install
148
+ bun run dev # local preview
149
+ bun run build # -> docs/dist
150
+ ```
151
+
110
152
  `bun install` also enables a husky `commit-msg` hook that runs
111
153
  [commitlint](https://commitlint.js.org/) with `@commitlint/config-conventional`,
112
154
  so every commit must be a [Conventional Commit](https://www.conventionalcommits.org/).
package/dist/cli.js CHANGED
@@ -438,7 +438,7 @@ async function resolveCircleciOptions(parsed, deps = defaultResolveDeps) {
438
438
 
439
439
  // src/npm.ts
440
440
  var MIN_NODE = "22.14.0";
441
- var MIN_NPM = "11.5.1";
441
+ var MIN_NPM = "11.15.0";
442
442
  function cmpVersion(a, b) {
443
443
  const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
444
444
  const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
@@ -723,6 +723,9 @@ function discoverPackages(root) {
723
723
  const dirs = expandPatterns(root, patterns);
724
724
  const all = [];
725
725
  const seen = new Set;
726
+ if (existsSync(path2.join(root, "pnpm-workspace.yaml"))) {
727
+ dirs.unshift(path2.resolve(root));
728
+ }
726
729
  for (const dir of dirs) {
727
730
  const pkg = readPkg(dir);
728
731
  if (pkg && !seen.has(pkg.name)) {
@@ -750,7 +753,7 @@ function filterPackages(all, only, exclude) {
750
753
  });
751
754
  }
752
755
  // package.json
753
- var version = "0.3.0";
756
+ var version = "0.3.1";
754
757
 
755
758
  // src/cli.ts
756
759
  var VERSION = version;
@@ -760,6 +763,11 @@ Usage:
760
763
  trustci [trust] --provider <github|gitlab|circleci> [provider flags] [options]
761
764
  trustci list [package] [--dry-run]
762
765
 
766
+ Commands:
767
+ trust register a trusted publisher for every public workspace package
768
+ (the default; "trust" may be omitted)
769
+ list run \`npm trust list\` for <package>, or for every public workspace package
770
+
763
771
  Providers:
764
772
  github --repo <owner/repo> --file <workflow> [--env <name>]
765
773
  gitlab --project <group/project> --file <workflow> [--env <name>]
@@ -769,34 +777,43 @@ Providers:
769
777
  [--context-id <uuid> ...]
770
778
  --vcs-origin defaults to the root package.json "repository", then
771
779
  \`git remote get-url origin\`.
772
- Missing UUIDs are resolved via CircleCI API v2 using a token from
773
- --circle-token, $CIRCLE_TOKEN, $CIRCLECI_TOKEN, $CIRCLE_CLI_TOKEN,
774
- $CIRCLECI_CLI_TOKEN, or ~/.circleci/cli.yml (in that order).
780
+ Missing UUIDs are resolved via CircleCI API v2 (also under --dry-run)
781
+ using a token from --circle-token, $CIRCLE_TOKEN, $CIRCLECI_TOKEN,
782
+ $CIRCLE_CLI_TOKEN, $CIRCLECI_CLI_TOKEN, or ~/.circleci/cli.yml (in that order).
775
783
  Explicit UUIDs override auto-resolution; with all three, no token is needed.
784
+ --file selects the pipeline definition by config path or name (needed
785
+ when the project has more than one); it is not passed to npm trust.
776
786
 
777
787
  Permissions (at least one required):
778
788
  --allow-publish allow npm publish
779
789
  --allow-stage-publish allow npm stage publish
780
790
 
781
791
  Options:
782
- --dry-run print the npm trust commands without executing them
792
+ --dry-run print the npm commands without executing them
783
793
  --only <name-glob> only include packages matching (repeatable)
784
794
  --exclude <name-glob> exclude packages matching (repeatable)
785
- -y, --yes skip the confirmation prompt (and npm's)
795
+ globs match the whole name; * also matches "/"
796
+ -y, --yes skip the confirmation prompt (and npm's);
797
+ required when stdin is not a terminal
786
798
  -h, --help show this help
787
799
  -v, --version show the trustci version
788
800
 
789
801
  Workspaces are detected from pnpm-workspace.yaml, package.json "workspaces",
790
802
  or lerna.json. If no workspace config is found, the root package.json is used
791
803
  as a single-package fallback. Private packages ("private": true) are always excluded.
804
+ On a real run, packages not yet published to the registry are skipped.
792
805
 
793
806
  Examples:
794
807
  trustci --dry-run --provider github --repo me/repo --file release.yml --allow-publish
795
808
  trustci --provider gitlab --project me/repo --file .gitlab-ci.yml --allow-publish -y
796
809
  CIRCLE_TOKEN=... trustci --provider circleci --allow-publish
810
+ trustci --provider circleci --file .circleci/config.yml --allow-publish
797
811
  trustci --provider circleci --org-id <uuid> --project-id <uuid> \\
798
812
  --pipeline-definition-id <uuid> --vcs-origin github.com/me/repo --allow-publish
799
813
  trustci list
814
+
815
+ Requires npm >= 11.15.0 and Node >= 22.14.0.
816
+ Documentation: https://trustci.hidetaka.dev
800
817
  `;
801
818
  async function confirm(question) {
802
819
  const rl = createInterface({ input: process2.stdin, output: process2.stderr });
@@ -844,6 +861,9 @@ async function runTrust(parsed) {
844
861
  const candidates = filterPackages(all, parsed.only, parsed.exclude);
845
862
  if (candidates.length === 0) {
846
863
  console.error(`No public packages matched (out of ${all.length} discovered via ${source}).`);
864
+ for (const pkg of all) {
865
+ console.error(` - ${pkg.name}${pkg.private ? " (private)" : ""}`);
866
+ }
847
867
  return 1;
848
868
  }
849
869
  console.error(`Detected ${all.length} package(s) via ${source}; ${candidates.length} public after filters.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trustci",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Bulk-register npm Trusted Publishers (npm trust) across all public packages in a monorepo. Supports GitHub, GitLab and CircleCI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "engines": {
13
13
  "node": ">=22.14.0",
14
- "npm": ">=11.5.1"
14
+ "npm": ">=11.15.0"
15
15
  },
16
16
  "scripts": {
17
17
  "build": "bun build src/cli.ts --target node --outfile dist/cli.js",