@staff0rd/assist 0.782.0 → 0.784.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.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.782.0",
9
+ version: "0.784.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -1181,6 +1181,8 @@ function buildRunEntry(name, command, args, options2) {
1181
1181
  const entry = { name, command: effectiveCommand };
1182
1182
  if (effectiveArgs.length > 0) entry.args = effectiveArgs;
1183
1183
  if (options2?.cwd) entry.cwd = options2.cwd;
1184
+ if (options2?.server !== void 0) entry.server = options2.server;
1185
+ if (options2?.port !== void 0) entry.port = options2.port;
1184
1186
  return entry;
1185
1187
  }
1186
1188
 
@@ -13076,7 +13078,7 @@ var rootConfigHelp = {
13076
13078
  var runConfigHelp = [
13077
13079
  {
13078
13080
  key: "run",
13079
- setter: "assist run add <name> <command>",
13081
+ setter: "assist run add <name> <command> [--server [group]] [--repo]",
13080
13082
  note: "configured commands runnable via assist run <name>"
13081
13083
  }
13082
13084
  ];
@@ -41286,6 +41288,27 @@ async function run3(name, args) {
41286
41288
  import { mkdirSync as mkdirSync34, writeFileSync as writeFileSync54 } from "fs";
41287
41289
  import { join as join100 } from "path";
41288
41290
 
41291
+ // src/commands/run/ensureNoDuplicateRun.ts
41292
+ function ensureNoDuplicateRun(configs, name) {
41293
+ if (configs.some((r) => "name" in r && r.name === name)) {
41294
+ console.error(`Run configuration with name "${name}" already exists`);
41295
+ process.exit(1);
41296
+ }
41297
+ }
41298
+
41299
+ // src/commands/run/addRepoRunConfig.ts
41300
+ async function addRepoRunConfig(entry, repoName, cwd = process.cwd()) {
41301
+ const orm = await getDb();
41302
+ const { label: label2, block } = await resolveSharedRepoBlock(orm, repoName, cwd);
41303
+ const runList = block.run ?? [];
41304
+ ensureNoDuplicateRun(runList, entry.name);
41305
+ const updated2 = { ...block, run: [...runList, entry] };
41306
+ const validation = validateConfig(updated2, "run", repoConfigSchema);
41307
+ if (!validation.ok) exitWithConfigErrors(validation.errors);
41308
+ await saveSharedRepoBlock(orm, label2, updated2);
41309
+ return label2;
41310
+ }
41311
+
41289
41312
  // src/commands/run/extractOption.ts
41290
41313
  function extractOption(args, flag) {
41291
41314
  const index2 = args.indexOf(flag);
@@ -41296,52 +41319,73 @@ function extractOption(args, flag) {
41296
41319
  };
41297
41320
  }
41298
41321
 
41299
- // src/commands/run/add.ts
41322
+ // src/commands/run/extractOptionalValueFlag.ts
41323
+ function extractOptionalValueFlag(args, flag) {
41324
+ const index2 = args.indexOf(flag);
41325
+ if (index2 === -1) return { value: void 0, remaining: args };
41326
+ const next3 = args[index2 + 1];
41327
+ const hasValue = next3 !== void 0 && !next3.startsWith("-");
41328
+ return {
41329
+ value: hasValue ? next3 : true,
41330
+ remaining: [
41331
+ ...args.slice(0, index2),
41332
+ ...args.slice(index2 + (hasValue ? 2 : 1))
41333
+ ]
41334
+ };
41335
+ }
41336
+
41337
+ // src/commands/run/requireParsedArgs.ts
41300
41338
  function findAddIndex() {
41301
41339
  const addIndex = process.argv.indexOf("add");
41302
41340
  if (addIndex === -1 || addIndex + 2 >= process.argv.length) return -1;
41303
41341
  return addIndex;
41304
41342
  }
41343
+ function parsePort(raw) {
41344
+ if (raw === void 0) return void 0;
41345
+ const port = Number(raw);
41346
+ if (!Number.isInteger(port) || port <= 0) {
41347
+ console.error(`--port must be a positive integer, got "${raw}"`);
41348
+ process.exit(1);
41349
+ }
41350
+ return port;
41351
+ }
41305
41352
  function extractAddArgs(addIndex) {
41306
41353
  const rawArgs = process.argv.slice(addIndex + 3);
41307
- const { value: cwd, remaining: args } = extractOption(rawArgs, "--cwd");
41354
+ const cwd = extractOption(rawArgs, "--cwd");
41355
+ const port = extractOption(cwd.remaining, "--port");
41356
+ const server = extractOptionalValueFlag(port.remaining, "--server");
41357
+ const repo = extractOptionalValueFlag(server.remaining, "--repo");
41308
41358
  return {
41309
41359
  name: process.argv[addIndex + 1],
41310
41360
  command: process.argv[addIndex + 2],
41311
- args,
41312
- cwd
41361
+ args: repo.remaining,
41362
+ options: {
41363
+ cwd: cwd.value,
41364
+ server: server.value,
41365
+ port: parsePort(port.value)
41366
+ },
41367
+ repo: repo.value
41313
41368
  };
41314
41369
  }
41315
- function parseAddArguments() {
41370
+ function requireParsedArgs() {
41316
41371
  const addIndex = findAddIndex();
41317
- return addIndex === -1 ? null : extractAddArgs(addIndex);
41318
- }
41319
- function ensureNoDuplicate(configs, name) {
41320
- if (configs.find((r) => r.name === name)) {
41321
- console.error(`Run configuration with name "${name}" already exists`);
41372
+ if (addIndex === -1) {
41373
+ console.error("Usage: assist run add <name> <command> [args...]");
41322
41374
  process.exit(1);
41323
41375
  }
41376
+ return extractAddArgs(addIndex);
41324
41377
  }
41378
+
41379
+ // src/commands/run/add.ts
41325
41380
  function formatDisplay(command, args) {
41326
41381
  return args.length > 0 ? `${command} ${args.join(" ")}` : command;
41327
41382
  }
41328
- function requireParsedArgs() {
41329
- const parsed = parseAddArguments();
41330
- if (!parsed) {
41331
- console.error("Usage: assist run add <name> <command> [args...]");
41332
- process.exit(1);
41333
- }
41334
- return parsed;
41335
- }
41336
- function getOrInitRunList() {
41383
+ function saveProjectRunConfig(entry) {
41337
41384
  const config = loadProjectConfig();
41338
41385
  if (!config.run) config.run = [];
41339
- return { config, runList: config.run };
41340
- }
41341
- function saveNewRunConfig(name, command, args, cwd) {
41342
- const { config, runList } = getOrInitRunList();
41343
- ensureNoDuplicate(runList, name);
41344
- runList.push(buildRunEntry(name, command, args, { cwd }));
41386
+ const runList = config.run;
41387
+ ensureNoDuplicateRun(runList, entry.name);
41388
+ runList.push(entry);
41345
41389
  saveConfig(config);
41346
41390
  }
41347
41391
  function createCommandFile(name) {
@@ -41357,15 +41401,25 @@ Run \`assist run ${name} $ARGUMENTS 2>&1\`.
41357
41401
  writeFileSync54(filePath, content);
41358
41402
  console.log(`Created command file: ${filePath}`);
41359
41403
  }
41360
- function add4() {
41361
- const { name, command, args, cwd } = requireParsedArgs();
41362
- saveNewRunConfig(name, command, args, cwd);
41404
+ async function add4() {
41405
+ const { name, command, args, options: options2, repo } = requireParsedArgs();
41406
+ const entry = buildRunEntry(name, command, args, options2);
41407
+ const display = formatDisplay(command, args);
41408
+ if (repo !== void 0) {
41409
+ const label2 = await addRepoRunConfig(
41410
+ entry,
41411
+ typeof repo === "string" ? repo : void 0
41412
+ );
41413
+ console.log(
41414
+ `Added run configuration: ${name} -> ${display} (repo: ${label2})`
41415
+ );
41416
+ return;
41417
+ }
41418
+ saveProjectRunConfig(entry);
41363
41419
  if (!name.startsWith("verify:")) {
41364
41420
  createCommandFile(name);
41365
41421
  }
41366
- console.log(
41367
- `Added run configuration: ${name} -> ${formatDisplay(command, args)}`
41368
- );
41422
+ console.log(`Added run configuration: ${name} -> ${display}`);
41369
41423
  }
41370
41424
 
41371
41425
  // src/commands/run/link.ts
@@ -41448,12 +41502,20 @@ function remove() {
41448
41502
  // src/commands/run/registerRunSubcommands.ts
41449
41503
  function registerRunSubcommands(runCommand) {
41450
41504
  runCommand.command("list").description("List configured run commands").option("-v, --verbose", "Show full command details").action((opts) => listRunConfigs(!!opts.verbose));
41451
- runCommand.command("add").description("Add a new run configuration to assist.yml").argument("<name>", "Name for the run configuration").argument("<command>", "Command to execute").argument("[args...]", "Static args to pass to the command").option(
41505
+ runCommand.command("add").description(
41506
+ "Add a new run configuration to assist.yml, or with --repo to the shared db"
41507
+ ).argument("<name>", "Name for the run configuration").argument("<command>", "Command to execute").argument("[args...]", "Static args to pass to the command").option(
41452
41508
  "--cwd <dir>",
41453
41509
  "Working directory (resolved relative to the config file)"
41510
+ ).option(
41511
+ "--server [group]",
41512
+ "Mark as a singleton dev server, optionally in a named group (default group: default)"
41513
+ ).option("--port <port>", "Display-only port shown on the serving card").option(
41514
+ "--repo [name]",
41515
+ "Write to a repo's override in the shared db, seen by every node, instead of assist.yml (defaults to the current repo; no command file is created)"
41454
41516
  ).addHelpText(
41455
41517
  "after",
41456
- '\nPositional params can be added to the config manually:\n params:\n - name: env # assist run deploy prod \u2192 appends "prod"\n required: true\n - name: tag\n default: latest'
41518
+ '\nOptions go after <command>. --server and --repo take the next argument as their value unless it starts with "-", so put them last or before another option:\n assist run add dev npm run dev --server --port 3000 --repo\n\nPositional params can be added to the config manually:\n params:\n - name: env # assist run deploy prod \u2192 appends "prod"\n required: true\n - name: tag\n default: latest'
41457
41519
  ).allowUnknownOption().allowExcessArguments().action(() => add4());
41458
41520
  runCommand.command("link").description("Link run configurations from another project's assist.yml").argument("<path>", "Relative path to the linked project").requiredOption("--prefix <prefix>", "Namespace prefix for linked commands").allowUnknownOption().action(() => link2());
41459
41521
  runCommand.command("remove").description("Remove a run configuration from assist.yml").argument("<name>", "Name of the run configuration to remove").action(() => remove());
@@ -48533,7 +48595,7 @@ async function tailscaleLinkUrl(host, port, resolveSuffix = localTailnetSuffix)
48533
48595
  }
48534
48596
 
48535
48597
  // src/commands/sessions/nodes/parsePort.ts
48536
- function parsePort(flag, value) {
48598
+ function parsePort2(flag, value) {
48537
48599
  const port = Number(value);
48538
48600
  if (!Number.isInteger(port) || port < 1 || port > 65535)
48539
48601
  throw new Error(`${flag} must be a port number, got ${value}`);
@@ -48557,7 +48619,7 @@ async function buildLink(name, url, options2, resolveTailnetSuffix) {
48557
48619
  throw new Error(
48558
48620
  "pass the peer's <url> or --tailscale <host> --port <port>"
48559
48621
  );
48560
- const port = parsePort("--port", options2.port);
48622
+ const port = parsePort2("--port", options2.port);
48561
48623
  return {
48562
48624
  name,
48563
48625
  url: await tailscaleLinkUrl(options2.tailscale, port, resolveTailnetSuffix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.782.0",
3
+ "version": "0.784.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {