@art-work/cli 0.1.2 → 0.1.3

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 (31) hide show
  1. package/dist/cjs/commands/checkouts/runCheckoutsRun.d.ts +1 -1
  2. package/dist/cjs/commands/checkouts/runCheckoutsRun.d.ts.map +1 -1
  3. package/dist/cjs/index.js +9 -8
  4. package/dist/cjs/index.js.map +2 -2
  5. package/dist/cjs/private/commands/checkouts/doCheckoutRun.d.ts +1 -1
  6. package/dist/cjs/private/commands/checkouts/doCheckoutRun.d.ts.map +1 -1
  7. package/dist/cjs/private/exec/runCommandInDirectory.d.ts +1 -1
  8. package/dist/cjs/private/exec/runCommandInDirectory.d.ts.map +1 -1
  9. package/dist/commands/checkouts/runCheckoutsRun.d.ts +1 -1
  10. package/dist/commands/checkouts/runCheckoutsRun.d.ts.map +1 -1
  11. package/dist/esm/commands/checkouts/runCheckoutRun.test.mjs +6 -17
  12. package/dist/esm/commands/checkouts/runCheckoutRun.test.mjs.map +2 -2
  13. package/dist/esm/commands/checkouts/runCheckoutsRun.d.ts +1 -1
  14. package/dist/esm/commands/checkouts/runCheckoutsRun.d.ts.map +1 -1
  15. package/dist/esm/commands/checkouts/runCheckoutsRun.mjs +1 -1
  16. package/dist/esm/commands/checkouts/runCheckoutsRun.mjs.map +2 -2
  17. package/dist/esm/index.mjs +1 -1
  18. package/dist/esm/index.mjs.map +2 -2
  19. package/dist/esm/private/commands/checkouts/doCheckoutRun.d.ts +1 -1
  20. package/dist/esm/private/commands/checkouts/doCheckoutRun.d.ts.map +1 -1
  21. package/dist/esm/private/commands/checkouts/doCheckoutRun.mjs +6 -4
  22. package/dist/esm/private/commands/checkouts/doCheckoutRun.mjs.map +2 -2
  23. package/dist/esm/private/exec/runCommandInDirectory.d.ts +1 -1
  24. package/dist/esm/private/exec/runCommandInDirectory.d.ts.map +1 -1
  25. package/dist/esm/private/exec/runCommandInDirectory.mjs +1 -2
  26. package/dist/esm/private/exec/runCommandInDirectory.mjs.map +2 -2
  27. package/dist/private/commands/checkouts/doCheckoutRun.d.ts +1 -1
  28. package/dist/private/commands/checkouts/doCheckoutRun.d.ts.map +1 -1
  29. package/dist/private/exec/runCommandInDirectory.d.ts +1 -1
  30. package/dist/private/exec/runCommandInDirectory.d.ts.map +1 -1
  31. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { WorkspaceContext } from '../../private/context/createWorkspaceContext';
2
2
  export declare function runCheckoutsRun(ctx: WorkspaceContext, options: {
3
- command: string[];
3
+ command: string;
4
4
  checkouts?: string[];
5
5
  all?: boolean;
6
6
  }): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"runCheckoutsRun.d.ts","sourceRoot":"","sources":["../../../../src/commands/checkouts/runCheckoutsRun.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AASrF,wBAAsB,eAAe,CACpC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
1
+ {"version":3,"file":"runCheckoutsRun.d.ts","sourceRoot":"","sources":["../../../../src/commands/checkouts/runCheckoutsRun.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AASrF,wBAAsB,eAAe,CACpC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/D,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
package/dist/cjs/index.js CHANGED
@@ -792,8 +792,7 @@ async function runBranch(ctx, options) {
792
792
  var import_node_child_process = require("node:child_process");
793
793
  function runCommandInDirectory(dir, command) {
794
794
  return new Promise((resolve) => {
795
- const [cmd, ...args] = command.length === 1 ? command[0].split(/\s+/) : command;
796
- const child = (0, import_node_child_process.spawn)(cmd, args, { cwd: dir });
795
+ const child = (0, import_node_child_process.spawn)(command, { cwd: dir, shell: true });
797
796
  let output = "";
798
797
  let error = "";
799
798
  child.stdout?.on("data", (chunk) => output += chunk);
@@ -822,16 +821,15 @@ function createCheckoutRunOperation(checkout, command) {
822
821
 
823
822
  // src/private/commands/checkouts/doCheckoutRun.ts
824
823
  async function doCheckoutRun(ctx, checkout, command) {
825
- const commandLine = command.join(" ");
826
824
  if (!checkout.scan?.state("exists").exists) {
827
825
  const op = createOperationFailure(
828
- createCheckoutRunOperation(checkout, commandLine),
826
+ createCheckoutRunOperation(checkout, command),
829
827
  new Error("checkout not cloned")
830
828
  );
831
829
  ctx.log.log(op);
832
830
  return null;
833
831
  }
834
- const pending = createCheckoutRunOperation(checkout, commandLine);
832
+ const pending = createCheckoutRunOperation(checkout, command);
835
833
  try {
836
834
  ctx.log.log(pending);
837
835
  const runOutcome = await runCommandInDirectory(checkout.path, command);
@@ -849,7 +847,10 @@ async function doCheckoutRun(ctx, checkout, command) {
849
847
  console.info("");
850
848
  }
851
849
  if (runOutcome.error) {
852
- console.error("\n--- Error:\n");
850
+ const maybeErrorLabel = runOutcome.code === 0 ? "" : " Error:";
851
+ console.error(`
852
+ ---${maybeErrorLabel}
853
+ `);
853
854
  console.error(runOutcome.error);
854
855
  console.error("");
855
856
  }
@@ -867,7 +868,6 @@ async function runCheckoutsRun(ctx, options) {
867
868
  const records = await loadCheckoutRecords(ctx, repos);
868
869
  hydrateStoreFromRecords(ctx.config, ctx.store, records);
869
870
  ctx.log.log(createGenericOperation("command", ["checkouts", "run", options.command]));
870
- await scanAllCheckoutsStates(ctx);
871
871
  if (!options.all && (!options.checkouts || options.checkouts.length === 0)) {
872
872
  console.error("No checkouts matched.");
873
873
  console.error(
@@ -875,6 +875,7 @@ async function runCheckoutsRun(ctx, options) {
875
875
  );
876
876
  return;
877
877
  }
878
+ await scanAllCheckoutsStates(ctx);
878
879
  const checkouts = options.all ? ctx.store.getAllCheckouts() : ctx.store.getCheckoutsByPattern(options.checkouts ?? []);
879
880
  await runWithConcurrency(checkouts, 4, async (checkout) => {
880
881
  await doCheckoutRun(ctx, checkout, options.command);
@@ -2077,7 +2078,7 @@ program.command("sync").description("Pull and push clean checkouts").option(
2077
2078
  const ctx = createWorkspaceContext(config, store, log);
2078
2079
  await runSync(ctx, { checkouts: options.checkouts, all: options.all });
2079
2080
  });
2080
- program.command("checkouts").description("Checkout operations").command("run").description("Run a command in selected checkouts").argument("<command...>", "command to run").option(
2081
+ program.command("checkouts").description("Checkout operations").command("run").description("Run a command in selected checkouts").argument("<command>", "command to run").option(
2081
2082
  "-c, --checkouts <PATTERN...>",
2082
2083
  'One or more. Matches checkout name and location. Wildcard asterisk * supported. Example: -c "* @ refactor" "lib-*"'
2083
2084
  ).option("-A, --all", "Apply to all checkouts").action(async (command, options) => {