@couch-kit/cli 0.3.6 → 0.3.8

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 +27 -16
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2463,38 +2463,49 @@ var require2 = createRequire2(import.meta.url);
2463
2463
  var { version } = require2("../package.json");
2464
2464
  var program2 = new Command;
2465
2465
  program2.name("couch-kit").description("CLI for Couch Kit").version(version);
2466
- program2.command("bundle").description("Bundles the web controller into the Android assets directory").option("-s, --source <path>", "Source directory of web controller", "./web-controller").option("-o, --output <path>", "Android assets directory", "./android/app/src/main/assets/www").option("--no-build", "Skip build step (just copy)").option("-m, --manifest <path>", "Also write manifest to this path for import in app source").action(async (options) => {
2466
+ program2.command("bundle").description("Bundles the web controller into the Android assets directory").option("-s, --source <path>", "Source directory of web controller", "./web-controller").option("-o, --output <path>", "Android assets directory", "./android/app/src/main/assets/www").option("--no-build", "Skip build step (just copy)").option("-m, --manifest <path>", "Also write manifest to this path for import in app source").action(async (_options, command) => {
2467
2467
  const { bundleCommand: bundleCommand2 } = await Promise.resolve().then(() => (init_bundle(), exports_bundle));
2468
- await bundleCommand2.parseAsync(["bundle", ...reconstructArgs(options)], {
2468
+ await bundleCommand2.parseAsync(reconstructArgs(command), {
2469
2469
  from: "user"
2470
2470
  });
2471
2471
  });
2472
- program2.command("simulate").description("Spawns headless bots to simulate players").option("-n, --count <number>", "Number of bots", "4").option("-u, --url <url>", "WebSocket URL of host", "ws://localhost:8082").option("-i, --interval <ms>", "Action interval in ms", "1000").action(async (options) => {
2472
+ program2.command("simulate").description("Spawns headless bots to simulate players").option("-n, --count <number>", "Number of bots", "4").option("-u, --url <url>", "WebSocket URL of host", "ws://localhost:8082").option("-i, --interval <ms>", "Action interval in ms", "1000").action(async (_options, command) => {
2473
2473
  const { simulateCommand: simulateCommand2 } = await Promise.resolve().then(() => (init_simulate(), exports_simulate));
2474
- await simulateCommand2.parseAsync(["simulate", ...reconstructArgs(options)], { from: "user" });
2474
+ await simulateCommand2.parseAsync(reconstructArgs(command), {
2475
+ from: "user"
2476
+ });
2475
2477
  });
2476
2478
  program2.command("init").description("Scaffolds a new web controller project").argument("[name]", "Project name", "web-controller").action(async (name) => {
2477
2479
  const { initCommand: initCommand2 } = await Promise.resolve().then(() => (init_init(), exports_init));
2478
- await initCommand2.parseAsync(["init", name], { from: "user" });
2480
+ await initCommand2.parseAsync([name], { from: "user" });
2479
2481
  });
2480
- program2.command("replay").description("Replay a recorded game session against a reducer").argument("<recording>", "Path to recording JSON file").argument("<reducer>", "Path to reducer module").option("--snapshots", "Output intermediate state snapshots").option("--json", "Output as formatted JSON").action(async (recording, reducer2, options) => {
2482
+ program2.command("replay").description("Replay a recorded game session against a reducer").argument("<recording>", "Path to recording JSON file").argument("<reducer>", "Path to reducer module").option("--snapshots", "Output intermediate state snapshots").option("--json", "Output as formatted JSON").action(async (recording, reducer2, _options, command) => {
2481
2483
  const { replay: replay3 } = await Promise.resolve().then(() => (init_replay(), exports_replay));
2482
- await replay3.parseAsync(["replay", recording, reducer2, ...reconstructArgs(options)], { from: "user" });
2484
+ await replay3.parseAsync([recording, reducer2, ...reconstructArgs(command)], {
2485
+ from: "user"
2486
+ });
2483
2487
  });
2484
- program2.command("dev").description("Start development server with LAN access").option("-p, --port <port>", "Port number", "5173").option("--host", "Expose to LAN").option("--open", "Open browser automatically").action(async (options) => {
2488
+ program2.command("dev").description("Start development server with LAN access").option("-p, --port <port>", "Port number", "5173").option("--host", "Expose to LAN").option("--open", "Open browser automatically").action(async (_options, command) => {
2485
2489
  const { dev: dev2 } = await Promise.resolve().then(() => (init_dev(), exports_dev));
2486
- await dev2.parseAsync(["dev", ...reconstructArgs(options)], {
2490
+ await dev2.parseAsync(reconstructArgs(command), {
2487
2491
  from: "user"
2488
2492
  });
2489
2493
  });
2490
- function reconstructArgs(options) {
2494
+ function reconstructArgs(command) {
2491
2495
  const args = [];
2492
- for (const [key, value] of Object.entries(options)) {
2493
- if (typeof value === "boolean") {
2494
- if (!value)
2495
- args.push(`--no-${key}`);
2496
- } else if (value !== undefined) {
2497
- args.push(`--${key}`, String(value));
2496
+ const opts = command.opts();
2497
+ for (const option of command.options) {
2498
+ const value = opts[option.attributeName()];
2499
+ if (value === undefined)
2500
+ continue;
2501
+ if (option.negate) {
2502
+ if (value === false)
2503
+ args.push(option.long ?? option.short ?? "");
2504
+ } else if (option.isBoolean()) {
2505
+ if (value === true)
2506
+ args.push(option.long ?? option.short ?? "");
2507
+ } else {
2508
+ args.push(option.long ?? option.short ?? "", String(value));
2498
2509
  }
2499
2510
  }
2500
2511
  return args;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@couch-kit/cli",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -39,7 +39,7 @@
39
39
  "clean": "rm -rf dist"
40
40
  },
41
41
  "dependencies": {
42
- "@couch-kit/core": "0.9.1",
42
+ "@couch-kit/core": "0.9.2",
43
43
  "commander": "^12.0.0"
44
44
  },
45
45
  "devDependencies": {