@biffo/cli 0.167.1 → 0.168.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 (2) hide show
  1. package/dist/index.js +52 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6519,12 +6519,26 @@ async function promptForConfig(awsAccountId, awsRegion, awsProfile) {
6519
6519
  import { Command as Command20 } from "commander";
6520
6520
 
6521
6521
  // src/commands/plugin-create.ts
6522
- import { existsSync as existsSync23, readFileSync as readFileSync17 } from "fs";
6522
+ import { existsSync as existsSync23, readFileSync as readFileSync17, writeFileSync as writeFileSync9 } from "fs";
6523
6523
  import { dirname as dirname8, join as join23, resolve as resolve11 } from "path";
6524
6524
  import { fileURLToPath as fileURLToPath5 } from "url";
6525
6525
  import chalk13 from "chalk";
6526
6526
  import { Command as Command13 } from "commander";
6527
6527
 
6528
+ // src/lib/registry-sources.ts
6529
+ function manifestUrlFor(repoUrl, branch = "dev") {
6530
+ const slug = repoUrl.replace(/^https:\/\/github\.com\//, "").replace(/\.git$/, "");
6531
+ return `https://raw.githubusercontent.com/${slug}/${branch}/biffo.plugin.json`;
6532
+ }
6533
+ function addSource(file, source) {
6534
+ if (file.sources.some((s) => s.name === source.name)) return null;
6535
+ return { ...file, sources: [...file.sources, source] };
6536
+ }
6537
+ function serialiseSources(file) {
6538
+ return `${JSON.stringify(file, null, 2)}
6539
+ `;
6540
+ }
6541
+
6528
6542
  // src/lib/workflow-check-contexts.ts
6529
6543
  function unquote(value) {
6530
6544
  const trimmed = value.trim();
@@ -6933,7 +6947,7 @@ var pluginCreateCommand = new Command13("create").description("Scaffold a new pl
6933
6947
  ).option(
6934
6948
  "--runner-label <label>",
6935
6949
  "With --org, the RUNNER_LABEL the new repo\u2019s CI should run on (defaults to mirroring this checkout\u2019s)"
6936
- ).option(
6950
+ ).option("--no-register", "With --org, skip adding the plugin to the registry\u2019s sources.json").option(
6937
6951
  "--skeleton <path>",
6938
6952
  "Path to the plugin skeleton (defaults to _skeletons/plugin-template)"
6939
6953
  ).option("--dry-run", "Print planned changes without modifying the repo").option("--no-commit", "Scaffold the files but leave them uncommitted").option("--cwd <path>", "Project root to scaffold into (defaults to the current directory)").action(
@@ -6947,6 +6961,7 @@ var pluginCreateCommand = new Command13("create").description("Scaffold a new pl
6947
6961
  standalone: options.standalone ?? false,
6948
6962
  ...options.org ? { org: options.org } : {},
6949
6963
  ...options.runnerLabel ? { runnerLabel: options.runnerLabel } : {},
6964
+ register: options.register !== false,
6950
6965
  ...options.skeleton ? { skeletonRoot: resolve11(options.skeleton) } : {},
6951
6966
  dryRun: options.dryRun ?? false,
6952
6967
  commit: options.commit !== false,
@@ -7101,8 +7116,41 @@ async function createAndPushStandaloneRepo(org, names, destDir, options, deps) {
7101
7116
  } else {
7102
7117
  await github.protectSingleBranch(org, names.dist, "dev", contexts);
7103
7118
  }
7119
+ if (options.register !== false) {
7120
+ await registerInRegistrySources(names, cloneUrl, token, deps);
7121
+ }
7104
7122
  printStandaloneRemoteNextSteps(names, org);
7105
7123
  }
7124
+ var REGISTRY_REPO = "https://github.com/keiranholloway/biffo-plugins-registry";
7125
+ async function registerInRegistrySources(names, cloneUrl, token, deps) {
7126
+ let dir;
7127
+ try {
7128
+ dir = await deps.git.cloneForEditing(REGISTRY_REPO, "biffo-registry", token);
7129
+ const path = join23(dir, "sources.json");
7130
+ const file = JSON.parse(readFileSync17(path, "utf8"));
7131
+ const next = addSource(file, {
7132
+ name: names.slug,
7133
+ repo: cloneUrl.replace(/\.git$/, ""),
7134
+ manifest: manifestUrlFor(cloneUrl),
7135
+ tags: []
7136
+ });
7137
+ if (next === null) {
7138
+ log.info(`${names.slug} is already listed in the registry's sources.json`);
7139
+ return;
7140
+ }
7141
+ writeFileSync9(path, serialiseSources(next));
7142
+ await deps.git.add(dir, ["sources.json"]);
7143
+ await deps.git.commit(dir, `feat(registry): track ${names.slug} in sources.json`);
7144
+ await deps.git.push(dir, "main", { token });
7145
+ log.success(`Registered ${names.slug} in the plugin registry's sources.json`);
7146
+ } catch (err) {
7147
+ log.warn(
7148
+ `Could not add ${names.slug} to the registry's sources.json: ${err.message}. Until it is listed there (or REGISTRY_PUBLISH_TOKEN is set on the new repo), the plugin will not appear in the portal's plugin store.`
7149
+ );
7150
+ } finally {
7151
+ if (dir !== void 0) deps.git.cleanup(dir);
7152
+ }
7153
+ }
7106
7154
  async function propagateRunnerLabel(org, repo, options, deps, github) {
7107
7155
  try {
7108
7156
  let label = options.runnerLabel?.trim();
@@ -7411,7 +7459,7 @@ var PluginMigrationsAdapter = class {
7411
7459
  };
7412
7460
 
7413
7461
  // src/lib/plugin-workspace-sources.ts
7414
- import { existsSync as existsSync24, readdirSync as readdirSync12, readFileSync as readFileSync18, writeFileSync as writeFileSync9 } from "fs";
7462
+ import { existsSync as existsSync24, readdirSync as readdirSync12, readFileSync as readFileSync18, writeFileSync as writeFileSync10 } from "fs";
7415
7463
  import { join as join25 } from "path";
7416
7464
  function readTomlStringArray(text, key) {
7417
7465
  const open = new RegExp(`^${key}\\s*=\\s*\\[`, "m").exec(text);
@@ -7515,7 +7563,7 @@ ${lines.join("\n")}${text.slice(insertAt)}`;
7515
7563
  ${lines.join("\n")}
7516
7564
  `;
7517
7565
  }
7518
- writeFileSync9(pluginPyprojectPath, updated);
7566
+ writeFileSync10(pluginPyprojectPath, updated);
7519
7567
  return toAdd;
7520
7568
  }
7521
7569
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.167.1",
3
+ "version": "0.168.0",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",