mano-coding 0.1.18 → 0.1.19

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/bin.js CHANGED
@@ -31879,6 +31879,13 @@ var init_execute = __esm({
31879
31879
 
31880
31880
  // packages/core/src/execute/task-runner.ts
31881
31881
  import { spawn } from "node:child_process";
31882
+ function filterTasksByHook(items, hook) {
31883
+ return items.filter((item) => {
31884
+ const task = "task" in item ? item.task : item;
31885
+ const hooks = task.on && task.on.length > 0 ? task.on : ["after:create"];
31886
+ return hooks.includes(hook);
31887
+ });
31888
+ }
31882
31889
  function parseSetInputs(rawSetFlags = []) {
31883
31890
  const values = {};
31884
31891
  const warnings = [];
@@ -33477,6 +33484,7 @@ __export(src_exports, {
33477
33484
  executeRollbackActions: () => executeRollbackActions,
33478
33485
  executeTasks: () => executeTasks,
33479
33486
  extractRequiredInputs: () => extractRequiredInputs,
33487
+ filterTasksByHook: () => filterTasksByHook,
33480
33488
  findInstallationForLauncher: () => findInstallationForLauncher,
33481
33489
  generateLauncherConfig: () => generateLauncherConfig,
33482
33490
  generateOperationId: () => generateOperationId,
@@ -39139,6 +39147,47 @@ ${taskValidation.missingInputs.map((k2) => `--set ${k2}=<value>`).join("\n")}`,
39139
39147
  }
39140
39148
  return ExitCode.Success;
39141
39149
  }
39150
+ const allTasksWithContext = allResolutions.flatMap((resolution) => {
39151
+ const tTasks = resolution.manifest.tasks ?? [];
39152
+ return tTasks.map((task) => ({
39153
+ task,
39154
+ templateDir: service.getPackageRoot(resolution) ?? service.projectRoot
39155
+ }));
39156
+ });
39157
+ const beforeCreateTasks = allTasksWithContext.filter(({ task }) => {
39158
+ const hooks = task.on && task.on.length > 0 ? task.on : ["after:create"];
39159
+ return hooks.includes("before:create");
39160
+ });
39161
+ if (beforeCreateTasks.length > 0) {
39162
+ const { basename: basename4, dirname: dirname15 } = await import("node:path");
39163
+ for (let i = 0; i < beforeCreateTasks.length; i++) {
39164
+ const { task, templateDir } = beforeCreateTasks[i];
39165
+ const taskContext = {
39166
+ projectName: basename4(service.projectRoot),
39167
+ projectDir: service.projectRoot,
39168
+ projectParentDir: dirname15(service.projectRoot),
39169
+ templateDir,
39170
+ inputs: inputValues
39171
+ };
39172
+ if (!output.json && i === 0) {
39173
+ writeHumanOutput("\n\u6B63\u5728\u6267\u884C\u524D\u7F6E\u521B\u5EFA\u4EFB\u52A1 (before:create):\n");
39174
+ }
39175
+ try {
39176
+ await executeTasks2([task], taskContext, {
39177
+ onProgress: (msg) => {
39178
+ if (!output.json) writeHumanOutput(`> ${msg}
39179
+ `);
39180
+ },
39181
+ stdio: output.json ? "ignore" : "inherit"
39182
+ });
39183
+ } catch (err) {
39184
+ if (err instanceof Error) {
39185
+ throw new CliError(err.message, ExitCode.ExecuteFailed, "TASK_EXECUTION_FAILED");
39186
+ }
39187
+ throw err;
39188
+ }
39189
+ }
39190
+ }
39142
39191
  const executor = service.getExecutor();
39143
39192
  const executeStartedAt = Date.now();
39144
39193
  if (!output.json) writeHumanOutput(t("create.writingResources", intents.length));
@@ -39219,17 +39268,14 @@ ${taskValidation.missingInputs.map((k2) => `--set ${k2}=<value>`).join("\n")}`,
39219
39268
  await finishJournal(journal);
39220
39269
  });
39221
39270
  events.report("record", "success", Date.now() - recordStartedAt, { planDigest: planResult.plan.planDigest });
39222
- const allTasksWithContext = allResolutions.flatMap((resolution) => {
39223
- const tTasks = resolution.manifest.tasks ?? [];
39224
- return tTasks.map((task) => ({
39225
- task,
39226
- templateDir: service.getPackageRoot(resolution) ?? service.projectRoot
39227
- }));
39271
+ const afterCreateTasks = allTasksWithContext.filter(({ task }) => {
39272
+ const hooks = task.on && task.on.length > 0 ? task.on : ["after:create"];
39273
+ return hooks.includes("after:create");
39228
39274
  });
39229
- if (allTasksWithContext.length > 0) {
39275
+ if (afterCreateTasks.length > 0) {
39230
39276
  const { basename: basename4, dirname: dirname15 } = await import("node:path");
39231
- for (let i = 0; i < allTasksWithContext.length; i++) {
39232
- const { task, templateDir } = allTasksWithContext[i];
39277
+ for (let i = 0; i < afterCreateTasks.length; i++) {
39278
+ const { task, templateDir } = afterCreateTasks[i];
39233
39279
  const taskContext = {
39234
39280
  projectName: basename4(service.projectRoot),
39235
39281
  projectDir: service.projectRoot,
@@ -39238,7 +39284,7 @@ ${taskValidation.missingInputs.map((k2) => `--set ${k2}=<value>`).join("\n")}`,
39238
39284
  inputs: inputValues
39239
39285
  };
39240
39286
  if (!output.json && i === 0) {
39241
- writeHumanOutput("\n\u5C06\u6309\u987A\u5E8F\u6267\u884C\u5DE5\u7A0B\u521D\u59CB\u5316\u4EFB\u52A1:\n");
39287
+ writeHumanOutput("\n\u6B63\u5728\u6267\u884C\u540E\u7F6E\u521D\u59CB\u5316\u4EFB\u52A1 (after:create):\n");
39242
39288
  }
39243
39289
  try {
39244
39290
  await executeTasks2([task], taskContext, {
@@ -39527,6 +39573,47 @@ async function executeApply(packageSpec, options, cliVersion, events) {
39527
39573
  }
39528
39574
  return ExitCode.Success;
39529
39575
  }
39576
+ const allTasksWithContext = allResolutions.flatMap((resolution) => {
39577
+ const tTasks = resolution.manifest.tasks ?? [];
39578
+ return tTasks.map((task) => ({
39579
+ task,
39580
+ templateDir: service.getPackageRoot(resolution) ?? service.projectRoot
39581
+ }));
39582
+ });
39583
+ const beforeApplyTasks = allTasksWithContext.filter(({ task }) => {
39584
+ const hooks = task.on && task.on.length > 0 ? task.on : ["after:create"];
39585
+ return hooks.includes("before:apply");
39586
+ });
39587
+ if (beforeApplyTasks.length > 0) {
39588
+ const { basename: basename4, dirname: dirname15 } = await import("node:path");
39589
+ for (let i = 0; i < beforeApplyTasks.length; i++) {
39590
+ const { task, templateDir } = beforeApplyTasks[i];
39591
+ const taskContext = {
39592
+ projectName: basename4(service.projectRoot),
39593
+ projectDir: service.projectRoot,
39594
+ projectParentDir: dirname15(service.projectRoot),
39595
+ templateDir,
39596
+ inputs: inputValues
39597
+ };
39598
+ if (!output.json && i === 0) {
39599
+ writeHumanOutput("\n\u6B63\u5728\u6267\u884C\u524D\u7F6E\u5E94\u7528\u4EFB\u52A1 (before:apply):\n");
39600
+ }
39601
+ try {
39602
+ await executeTasks([task], taskContext, {
39603
+ onProgress: (msg) => {
39604
+ if (!output.json) writeHumanOutput(`> ${msg}
39605
+ `);
39606
+ },
39607
+ stdio: output.json ? "ignore" : "inherit"
39608
+ });
39609
+ } catch (err) {
39610
+ if (err instanceof Error) {
39611
+ throw new CliError(err.message, ExitCode.ExecuteFailed, "TASK_EXECUTION_FAILED");
39612
+ }
39613
+ throw err;
39614
+ }
39615
+ }
39616
+ }
39530
39617
  const executor = service.getExecutor();
39531
39618
  const executeStartedAt = Date.now();
39532
39619
  const { journal, result: executeResult } = await withJournalTransaction(service, async (journal2) => {
@@ -39582,6 +39669,40 @@ async function executeApply(packageSpec, options, cliVersion, events) {
39582
39669
  await finishJournal(journal);
39583
39670
  });
39584
39671
  events.report("record", "success", Date.now() - recordStartedAt, { planDigest: planResult.plan.planDigest });
39672
+ const afterApplyTasks = allTasksWithContext.filter(({ task }) => {
39673
+ const hooks = task.on && task.on.length > 0 ? task.on : ["after:create"];
39674
+ return hooks.includes("after:apply");
39675
+ });
39676
+ if (afterApplyTasks.length > 0) {
39677
+ const { basename: basename4, dirname: dirname15 } = await import("node:path");
39678
+ for (let i = 0; i < afterApplyTasks.length; i++) {
39679
+ const { task, templateDir } = afterApplyTasks[i];
39680
+ const taskContext = {
39681
+ projectName: basename4(service.projectRoot),
39682
+ projectDir: service.projectRoot,
39683
+ projectParentDir: dirname15(service.projectRoot),
39684
+ templateDir,
39685
+ inputs: inputValues
39686
+ };
39687
+ if (!output.json && i === 0) {
39688
+ writeHumanOutput("\n\u6B63\u5728\u6267\u884C\u540E\u7F6E\u5E94\u7528\u4EFB\u52A1 (after:apply):\n");
39689
+ }
39690
+ try {
39691
+ await executeTasks([task], taskContext, {
39692
+ onProgress: (msg) => {
39693
+ if (!output.json) writeHumanOutput(`> ${msg}
39694
+ `);
39695
+ },
39696
+ stdio: output.json ? "ignore" : "inherit"
39697
+ });
39698
+ } catch (err) {
39699
+ if (err instanceof Error) {
39700
+ throw new CliError(err.message, ExitCode.ExecuteFailed, "TASK_EXECUTION_FAILED");
39701
+ }
39702
+ throw err;
39703
+ }
39704
+ }
39705
+ }
39585
39706
  const summary = summarizePlan(planResult.plan);
39586
39707
  if (output.json) {
39587
39708
  emitSuccessJson("apply", { dryRun: false, ...summary, lockPath: lockRepo.path, operationId: journal.operationId }, [], [], jsonEvents());
@@ -41857,7 +41978,7 @@ import { createRequire as createRequire2 } from "node:module";
41857
41978
  import { readFileSync as readFileSync4 } from "node:fs";
41858
41979
  import { fileURLToPath as fileURLToPath5 } from "node:url";
41859
41980
  function resolveVersion() {
41860
- if (true) return "0.1.18";
41981
+ if (true) return "0.1.19";
41861
41982
  const candidates = [
41862
41983
  new URL("../package.json", import.meta.url),
41863
41984
  new URL("../../package.json", import.meta.url),
@@ -55,6 +55,13 @@
55
55
  "additionalProperties": {
56
56
  "type": "string"
57
57
  }
58
+ },
59
+ "on": {
60
+ "type": "array",
61
+ "items": {
62
+ "enum": ["before:create", "after:create", "before:apply", "after:apply"]
63
+ },
64
+ "uniqueItems": true
58
65
  }
59
66
  },
60
67
  "additionalProperties": false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mano-coding",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Mano Coding CLI and toolchain",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -55,6 +55,13 @@
55
55
  "additionalProperties": {
56
56
  "type": "string"
57
57
  }
58
+ },
59
+ "on": {
60
+ "type": "array",
61
+ "items": {
62
+ "enum": ["before:create", "after:create", "before:apply", "after:apply"]
63
+ },
64
+ "uniqueItems": true
58
65
  }
59
66
  },
60
67
  "additionalProperties": false