@bensandee/tooling 0.29.0 → 0.30.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/bin.mjs +31 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -62,7 +62,7 @@ The generated `ci:check` script defaults to `pnpm check --skip 'docker:*'` since
62
62
 
63
63
  | Command | Description |
64
64
  | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
65
- | `tooling release:changesets` | Changesets version/publish for Forgejo CI. Flag: `--dry-run`. Env: `FORGEJO_SERVER_URL`, `FORGEJO_REPOSITORY`, `FORGEJO_TOKEN`. |
65
+ | `tooling release:changesets` | Changesets version/publish for Forgejo CI. Flag: `--dry-run`. Env: `FORGEJO_SERVER_URL`, `FORGEJO_REPOSITORY`, `RELEASE_TOKEN`. |
66
66
  | `tooling release:simple` | Streamlined release using commit-and-tag-version. |
67
67
  | `tooling release:trigger` | Trigger a release workflow. |
68
68
  | `tooling forgejo:create-release` | Create a Forgejo release from a tag. |
package/dist/bin.mjs CHANGED
@@ -1579,7 +1579,7 @@ function getAddedDevDepNames(config) {
1579
1579
  const deps = { ...ROOT_DEV_DEPS };
1580
1580
  if (config.structure !== "monorepo") Object.assign(deps, PER_PACKAGE_DEV_DEPS);
1581
1581
  deps["@bensandee/config"] = "0.9.1";
1582
- deps["@bensandee/tooling"] = "0.29.0";
1582
+ deps["@bensandee/tooling"] = "0.30.0";
1583
1583
  if (config.formatter === "oxfmt") deps["oxfmt"] = {
1584
1584
  "@changesets/cli": "2.30.0",
1585
1585
  "@release-it/bumper": "7.0.5",
@@ -1634,7 +1634,7 @@ async function generatePackageJson(ctx) {
1634
1634
  const devDeps = { ...ROOT_DEV_DEPS };
1635
1635
  if (!isMonorepo) Object.assign(devDeps, PER_PACKAGE_DEV_DEPS);
1636
1636
  devDeps["@bensandee/config"] = isWorkspacePackage(ctx, "@bensandee/config") ? "workspace:*" : "0.9.1";
1637
- devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.29.0";
1637
+ devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.30.0";
1638
1638
  if (ctx.config.useEslintPlugin) devDeps["@bensandee/eslint-plugin"] = isWorkspacePackage(ctx, "@bensandee/eslint-plugin") ? "workspace:*" : "0.9.2";
1639
1639
  if (ctx.config.formatter === "oxfmt") devDeps["oxfmt"] = {
1640
1640
  "@changesets/cli": "2.30.0",
@@ -2779,7 +2779,7 @@ function releaseItWorkflow(ci, nodeVersionYaml, publishesNpm) {
2779
2779
  permissions:
2780
2780
  contents: write
2781
2781
  ` : "";
2782
- const tokenEnv = isGitHub ? `GITHUB_TOKEN: \${{ github.token }}` : `FORGEJO_TOKEN: \${{ secrets.FORGEJO_TOKEN }}`;
2782
+ const tokenEnv = isGitHub ? `GITHUB_TOKEN: \${{ github.token }}` : `RELEASE_TOKEN: \${{ secrets.RELEASE_TOKEN }}`;
2783
2783
  const npmEnv = publishesNpm ? `\n NODE_AUTH_TOKEN: \${{ secrets.NPM_TOKEN }}` : "";
2784
2784
  return `${workflowSchemaComment(ci)}name: Release
2785
2785
  on:
@@ -2815,7 +2815,7 @@ permissions:
2815
2815
  env:
2816
2816
  FORGEJO_SERVER_URL: \${{ github.server_url }}
2817
2817
  FORGEJO_REPOSITORY: \${{ github.repository }}
2818
- FORGEJO_TOKEN: \${{ secrets.FORGEJO_TOKEN }}
2818
+ RELEASE_TOKEN: \${{ secrets.RELEASE_TOKEN }}
2819
2819
  run: pnpm exec bst release:simple`;
2820
2820
  return `${workflowSchemaComment(ci)}name: Release
2821
2821
  on:
@@ -2853,7 +2853,7 @@ function changesetsReleaseStep(ci, publishesNpm) {
2853
2853
  env: {
2854
2854
  FORGEJO_SERVER_URL: actionsExpr("github.server_url"),
2855
2855
  FORGEJO_REPOSITORY: actionsExpr("github.repository"),
2856
- FORGEJO_TOKEN: actionsExpr("secrets.FORGEJO_TOKEN"),
2856
+ RELEASE_TOKEN: actionsExpr("secrets.RELEASE_TOKEN"),
2857
2857
  ...publishesNpm && { NODE_AUTH_TOKEN: actionsExpr("secrets.NPM_TOKEN") }
2858
2858
  },
2859
2859
  run: "pnpm exec bst release:changesets"
@@ -3319,7 +3319,7 @@ function generateMigratePrompt(results, config, detected) {
3319
3319
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
3320
3320
  sections.push("# Migration Prompt");
3321
3321
  sections.push("");
3322
- sections.push(`_Generated by \`@bensandee/tooling@0.29.0 repo:sync\` on ${timestamp}_`);
3322
+ sections.push(`_Generated by \`@bensandee/tooling@0.30.0 repo:sync\` on ${timestamp}_`);
3323
3323
  sections.push("");
3324
3324
  sections.push("The following prompt was generated by `@bensandee/tooling repo:sync`. Paste it into Claude Code or another AI assistant to finish migrating this repository.");
3325
3325
  sections.push("");
@@ -4181,16 +4181,17 @@ const RepositorySchema = z.union([z.string(), z.object({ url: z.string() })]);
4181
4181
  * Resolve the hosting platform and connection details.
4182
4182
  *
4183
4183
  * Priority:
4184
- * 1. Environment variables (FORGEJO_SERVER_URL, FORGEJO_REPOSITORY, FORGEJO_TOKEN)
4184
+ * 1. Environment variables (FORGEJO_SERVER_URL, FORGEJO_REPOSITORY, RELEASE_TOKEN)
4185
4185
  * 2. `repository` field in package.json (server URL and owner/repo parsed from the URL)
4186
4186
  *
4187
- * For Forgejo, FORGEJO_TOKEN is always required (either from env or explicitly).
4187
+ * For Forgejo, a token is always required. Accepts RELEASE_TOKEN (preferred) or
4188
+ * FORGEJO_TOKEN (legacy, but conflicts with Forgejo Actions' internal auth).
4188
4189
  * If the repository URL hostname is `github.com`, returns `{ type: "github" }`.
4189
4190
  */
4190
4191
  function resolveConnection(cwd) {
4191
4192
  const serverUrl = process.env["FORGEJO_SERVER_URL"];
4192
4193
  const repository = process.env["FORGEJO_REPOSITORY"];
4193
- const token = process.env["FORGEJO_TOKEN"];
4194
+ const token = process.env["RELEASE_TOKEN"] ?? process.env["FORGEJO_TOKEN"];
4194
4195
  if (serverUrl && repository && token) return {
4195
4196
  type: "forgejo",
4196
4197
  conn: {
@@ -4203,13 +4204,13 @@ function resolveConnection(cwd) {
4203
4204
  if (parsed === null) {
4204
4205
  if (serverUrl) {
4205
4206
  if (!repository) throw new FatalError("FORGEJO_REPOSITORY environment variable is required");
4206
- if (!token) throw new FatalError("FORGEJO_TOKEN environment variable is required");
4207
+ if (!token) throw new FatalError("RELEASE_TOKEN environment variable is required");
4207
4208
  }
4208
4209
  return { type: "github" };
4209
4210
  }
4210
4211
  if (parsed.hostname === "github.com") return { type: "github" };
4211
4212
  const resolvedToken = token;
4212
- if (!resolvedToken) throw new FatalError("FORGEJO_TOKEN environment variable is required (server URL and repository were resolved from package.json)");
4213
+ if (!resolvedToken) throw new FatalError("RELEASE_TOKEN environment variable is required (server URL and repository were resolved from package.json)");
4213
4214
  return {
4214
4215
  type: "forgejo",
4215
4216
  conn: {
@@ -4247,6 +4248,18 @@ function parseGitUrl(urlStr) {
4247
4248
  return null;
4248
4249
  }
4249
4250
  }
4251
+ /**
4252
+ * Configure the git remote origin to use a Forgejo token for push auth.
4253
+ *
4254
+ * This is necessary because `actions/checkout` configures git with the automatic
4255
+ * GITHUB_TOKEN, which may not have push permissions. Using RELEASE_TOKEN ensures
4256
+ * pushes use the explicitly provided token.
4257
+ */
4258
+ function configureGitAuth(executor, conn, cwd) {
4259
+ const host = conn.serverUrl.replace(/^https?:\/\//, "");
4260
+ const authUrl = `https://x-access-token:${conn.token}@${host}/${conn.repository}`;
4261
+ executor.exec(`git remote set-url origin ${authUrl}`, { cwd });
4262
+ }
4250
4263
  //#endregion
4251
4264
  //#region src/commands/release-changesets.ts
4252
4265
  const releaseForgejoCommand = defineCommand({
@@ -4297,6 +4310,7 @@ async function runRelease(config, executor) {
4297
4310
  }
4298
4311
  executor.exec("git config user.name \"forgejo-actions[bot]\"", { cwd: config.cwd });
4299
4312
  executor.exec("git config user.email \"forgejo-actions[bot]@noreply.localhost\"", { cwd: config.cwd });
4313
+ configureGitAuth(executor, config, config.cwd);
4300
4314
  const changesetFiles = executor.listChangesetFiles(config.cwd);
4301
4315
  debug(config, `Changeset files found: ${changesetFiles.length > 0 ? changesetFiles.join(", ") : "(none)"}`);
4302
4316
  if (changesetFiles.length > 0) {
@@ -4470,6 +4484,10 @@ async function runSimpleRelease(executor, config) {
4470
4484
  }
4471
4485
  let pushed = false;
4472
4486
  if (!config.noPush) {
4487
+ if (config.platform?.type === "forgejo") {
4488
+ configureGitAuth(executor, config.platform.conn, config.cwd);
4489
+ debug(config, "Configured git remote with RELEASE_TOKEN auth");
4490
+ }
4473
4491
  const branch = executor.exec("git rev-parse --abbrev-ref HEAD", { cwd: config.cwd }).stdout.trim() || "main";
4474
4492
  debug(config, `Pushing to origin/${branch}`);
4475
4493
  const pushResult = executor.exec(`git push --follow-tags origin ${branch}`, { cwd: config.cwd });
@@ -5109,7 +5127,7 @@ const dockerCheckCommand = defineCommand({
5109
5127
  const main = defineCommand({
5110
5128
  meta: {
5111
5129
  name: "bst",
5112
- version: "0.29.0",
5130
+ version: "0.30.0",
5113
5131
  description: "Bootstrap and maintain standardized TypeScript project tooling"
5114
5132
  },
5115
5133
  subCommands: {
@@ -5125,7 +5143,7 @@ const main = defineCommand({
5125
5143
  "docker:check": dockerCheckCommand
5126
5144
  }
5127
5145
  });
5128
- console.log(`@bensandee/tooling v0.29.0`);
5146
+ console.log(`@bensandee/tooling v0.30.0`);
5129
5147
  async function run() {
5130
5148
  await runMain(main);
5131
5149
  process.exit(process.exitCode ?? 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bensandee/tooling",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
5
5
  "bin": {
6
6
  "bst": "./dist/bin.mjs"