@fenglimg/fabric-cli 1.1.0 → 1.3.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.
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ installMcpClients
4
+ } from "./chunk-TO5RUB4R.js";
5
+ import "./chunk-VMYPJPKV.js";
6
+ import {
7
+ installHooks
8
+ } from "./chunk-YDZJRLHL.js";
9
+ import {
10
+ paint
11
+ } from "./chunk-WWNXR34K.js";
12
+ import {
13
+ resolveDevModeTarget
14
+ } from "./chunk-AEOYCVBG.js";
15
+ import {
16
+ t
17
+ } from "./chunk-6ICJICVU.js";
18
+
19
+ // src/commands/update.ts
20
+ import { defineCommand } from "citty";
21
+ function writeStderr(message) {
22
+ process.stderr.write(`${message}
23
+ `);
24
+ }
25
+ function completedLabel() {
26
+ return paint.success(t("cli.init.stages.completed"));
27
+ }
28
+ function skippedLabel() {
29
+ return paint.muted(t("cli.init.stages.skipped"));
30
+ }
31
+ function failedLabel() {
32
+ return paint.error(t("cli.init.stages.failed"));
33
+ }
34
+ function formatStageResult(stage, status, installedCount, skippedCount, note) {
35
+ const label = status === "completed" ? completedLabel() : skippedLabel();
36
+ const counts = `installed=${installedCount} skipped=${skippedCount}`;
37
+ const suffix = note ? ` ${paint.muted(`(${note})`)}` : "";
38
+ return `${label} ${stage}: ${counts}${suffix}`;
39
+ }
40
+ function formatStageFailure(stage, error) {
41
+ const message = error instanceof Error ? error.message : String(error);
42
+ return `${failedLabel()} ${stage}: ${message}`;
43
+ }
44
+ function printStageSummary(stageResults) {
45
+ const ran = stageResults.filter((s) => s.disposition === "ran").map((s) => s.name);
46
+ const skipped = stageResults.filter((s) => s.disposition === "skipped").map((s) => s.name);
47
+ const failed = stageResults.filter((s) => s.disposition === "failed").map((s) => s.name);
48
+ console.log(`${paint.success(t("cli.init.stages.summary.ran"))}: ${ran.length > 0 ? ran.join(", ") : t("cli.shared.none")}`);
49
+ console.log(`${paint.muted(t("cli.init.stages.summary.skipped"))}: ${skipped.length > 0 ? skipped.join(", ") : t("cli.shared.none")}`);
50
+ console.log(`${paint.error(t("cli.init.stages.summary.failed"))}: ${failed.length > 0 ? failed.join(", ") : t("cli.shared.none")}`);
51
+ }
52
+ var updateCommand = defineCommand({
53
+ meta: {
54
+ name: "update",
55
+ description: t("cli.update.description")
56
+ },
57
+ args: {
58
+ target: {
59
+ type: "string",
60
+ description: t("cli.update.args.target.description")
61
+ },
62
+ mcp: {
63
+ type: "boolean",
64
+ default: true,
65
+ negativeDescription: t("cli.update.args.no-mcp.description")
66
+ },
67
+ hooks: {
68
+ type: "boolean",
69
+ default: true,
70
+ negativeDescription: t("cli.update.args.no-hooks.description")
71
+ }
72
+ },
73
+ async run({ args }) {
74
+ const target = resolveDevModeTarget(args.target);
75
+ const skipMcp = args.mcp === false;
76
+ const skipHooks = args.hooks === false;
77
+ const stageResults = [];
78
+ if (skipMcp) {
79
+ stageResults.push({ name: "mcp", disposition: "skipped" });
80
+ } else {
81
+ console.log(`${paint.ai(t("cli.shared.next"))} ${paint.muted(t("cli.init.stages.mcp"))}`);
82
+ try {
83
+ const result = await installMcpClients(target);
84
+ if (result.details.length === 0) {
85
+ console.log(formatStageResult("mcp", "skipped", 0, 0, t("cli.config.install.no-configs")));
86
+ stageResults.push({ name: "mcp", disposition: "skipped" });
87
+ } else {
88
+ console.log(formatStageResult("mcp", "completed", result.installed.length, result.skipped.length));
89
+ stageResults.push({ name: "mcp", disposition: "ran" });
90
+ }
91
+ } catch (error) {
92
+ writeStderr(formatStageFailure("mcp", error));
93
+ stageResults.push({ name: "mcp", disposition: "failed" });
94
+ }
95
+ }
96
+ if (skipHooks) {
97
+ stageResults.push({ name: "hooks", disposition: "skipped" });
98
+ } else {
99
+ console.log(`${paint.ai(t("cli.shared.next"))} ${paint.muted(t("cli.init.stages.hooks"))}`);
100
+ try {
101
+ const result = await installHooks(target);
102
+ console.log(formatStageResult("hooks", "completed", result.installed.length, result.skipped.length));
103
+ stageResults.push({ name: "hooks", disposition: "ran" });
104
+ } catch (error) {
105
+ writeStderr(formatStageFailure("hooks", error));
106
+ stageResults.push({ name: "hooks", disposition: "failed" });
107
+ }
108
+ }
109
+ printStageSummary(stageResults);
110
+ }
111
+ });
112
+ var update_default = updateCommand;
113
+ export {
114
+ update_default as default,
115
+ updateCommand
116
+ };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@fenglimg/fabric-cli",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "bin": {
6
- "fab": "dist/index.js"
6
+ "fab": "dist/index.js",
7
+ "fabric": "dist/index.js"
7
8
  },
8
9
  "main": "./dist/index.js",
9
10
  "types": "./dist/index.d.ts",
@@ -14,10 +15,11 @@
14
15
  "dependencies": {
15
16
  "@iarna/toml": "^2.2.5",
16
17
  "citty": "^0.2.2",
18
+ "minimatch": "^10.0.1",
17
19
  "picocolors": "^1.1.1",
18
20
  "string-width": "^7.2.0",
19
- "@fenglimg/fabric-shared": "1.1.0",
20
- "@fenglimg/fabric-server": "1.1.0"
21
+ "@fenglimg/fabric-server": "1.3.0",
22
+ "@fenglimg/fabric-shared": "1.3.0"
21
23
  },
22
24
  "devDependencies": {
23
25
  "@types/iarna__toml": "^2.0.5",
@@ -1,124 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- t
4
- } from "./chunk-6ICJICVU.js";
5
-
6
- // src/commands/hooks.ts
7
- import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
8
- import { dirname, isAbsolute, join, parse, resolve } from "path";
9
- import { fileURLToPath } from "url";
10
- import { defineCommand } from "citty";
11
- var hooksCommand = defineCommand({
12
- meta: {
13
- name: "hooks",
14
- description: t("cli.hooks.description")
15
- },
16
- subCommands: {
17
- install: defineCommand({
18
- meta: {
19
- name: "install",
20
- description: t("cli.hooks.install.description")
21
- },
22
- args: {
23
- target: {
24
- type: "string",
25
- description: t("cli.hooks.install.args.target.description"),
26
- default: process.cwd()
27
- }
28
- },
29
- async run({ args }) {
30
- const target = normalizeTarget(args.target);
31
- assertExistingDirectory(target);
32
- const huskyDir = join(target, ".husky");
33
- const hookPath = join(huskyDir, "pre-commit");
34
- const packageJsonPath = join(target, "package.json");
35
- if (!existsSync(packageJsonPath)) {
36
- throw new Error(t("cli.hooks.errors.package-json-required", { path: packageJsonPath }));
37
- }
38
- mkdirSync(huskyDir, { recursive: true });
39
- const templateContent = readFileSync(findTemplatePath("templates/husky/pre-commit"), "utf8");
40
- let hookAction;
41
- if (existsSync(hookPath)) {
42
- const existing = readFileSync(hookPath, "utf8");
43
- if (existing.includes("FAB_BIN=")) {
44
- hookAction = "skipped";
45
- } else {
46
- const fabricBlock = templateContent.replace(/^#!\/bin\/sh\n/, "");
47
- const separator = existing.endsWith("\n") ? "\n" : "\n\n";
48
- writeFileSync(hookPath, `${existing}${separator}# --- Fabric ---
49
- ${fabricBlock}`, "utf8");
50
- hookAction = "appended";
51
- }
52
- } else {
53
- writeFileSync(hookPath, templateContent, "utf8");
54
- hookAction = "created";
55
- }
56
- chmodSync(hookPath, 493);
57
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
58
- const scripts = packageJson.scripts && typeof packageJson.scripts === "object" && !Array.isArray(packageJson.scripts) ? packageJson.scripts : {};
59
- const hadPrepare = typeof scripts.prepare === "string" && scripts.prepare.trim().length > 0;
60
- if (!hadPrepare) {
61
- scripts.prepare = "husky install";
62
- packageJson.scripts = scripts;
63
- writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
64
- `, "utf8");
65
- }
66
- if (hookAction === "skipped") {
67
- writeStderr(t("cli.hooks.install.hook-skipped", { path: hookPath }));
68
- } else if (hookAction === "appended") {
69
- writeStderr(t("cli.hooks.install.hook-appended", { path: hookPath }));
70
- } else {
71
- writeStderr(t("cli.hooks.install.hook-created", { path: hookPath }));
72
- }
73
- if (hadPrepare) {
74
- writeStderr(t("cli.hooks.install.prepare-left", { path: packageJsonPath }));
75
- } else {
76
- writeStderr(t("cli.hooks.install.prepare-added", { path: packageJsonPath }));
77
- }
78
- }
79
- })
80
- }
81
- });
82
- var hooks_default = hooksCommand;
83
- function normalizeTarget(targetInput) {
84
- return isAbsolute(targetInput) ? targetInput : resolve(process.cwd(), targetInput);
85
- }
86
- function assertExistingDirectory(target) {
87
- if (!existsSync(target) || !statSync(target).isDirectory()) {
88
- throw new Error(t("cli.shared.target-invalid", { target }));
89
- }
90
- }
91
- function findTemplatePath(relativePath) {
92
- const currentModuleDir = dirname(fileURLToPath(import.meta.url));
93
- const candidates = [
94
- ...templateCandidatesFrom(process.cwd(), relativePath),
95
- ...templateCandidatesFrom(currentModuleDir, relativePath)
96
- ];
97
- for (const candidate of candidates) {
98
- if (existsSync(candidate)) {
99
- return candidate;
100
- }
101
- }
102
- throw new Error(t("cli.shared.template-not-found", { path: relativePath }));
103
- }
104
- function templateCandidatesFrom(start, relativePath) {
105
- const candidates = [];
106
- let current = resolve(start);
107
- while (true) {
108
- candidates.push(join(current, ...relativePath.split("/")));
109
- const parent = dirname(current);
110
- if (parent === current || parse(current).root === current) {
111
- break;
112
- }
113
- current = parent;
114
- }
115
- return candidates.reverse();
116
- }
117
- function writeStderr(message) {
118
- process.stderr.write(`${message}
119
- `);
120
- }
121
- export {
122
- hooks_default as default,
123
- hooksCommand
124
- };
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- ledger_append_default
4
- } from "./chunk-F2BXHPM5.js";
5
- import {
6
- resolveDevModeTarget
7
- } from "./chunk-AEOYCVBG.js";
8
- import {
9
- sync_meta_default
10
- } from "./chunk-6UUPKSDE.js";
11
- import {
12
- human_lint_default
13
- } from "./chunk-L43IGJ6X.js";
14
- import "./chunk-WWNXR34K.js";
15
- import {
16
- t
17
- } from "./chunk-6ICJICVU.js";
18
-
19
- // src/commands/pre-commit.ts
20
- import { defineCommand } from "citty";
21
- import process from "process";
22
- async function runOrFail(name, cmd, args) {
23
- try {
24
- await cmd.run?.({ args });
25
- } catch (err) {
26
- process.stderr.write(
27
- `${t("cli.pre-commit.run-failed", { name, message: err.message })}
28
- `
29
- );
30
- process.exit(1);
31
- }
32
- }
33
- var pre_commit_default = defineCommand({
34
- meta: {
35
- name: "pre-commit",
36
- description: t("cli.pre-commit.description")
37
- },
38
- args: {
39
- target: {
40
- type: "string",
41
- description: t("cli.pre-commit.args.target.description")
42
- }
43
- },
44
- async run({ args }) {
45
- const target = resolveDevModeTarget(args.target);
46
- await runOrFail("sync-meta --check-only", sync_meta_default, {
47
- target,
48
- "check-only": true
49
- });
50
- await runOrFail("human-lint", human_lint_default, { target });
51
- await runOrFail("ledger-append --staged", ledger_append_default, {
52
- target,
53
- staged: true
54
- });
55
- }
56
- });
57
- export {
58
- pre_commit_default as default
59
- };
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- createDebugLogger,
4
- readFabricConfig,
5
- resolveDevMode
6
- } from "./chunk-AEOYCVBG.js";
7
2
  import {
8
3
  displayWidth,
9
4
  padEnd,
10
5
  paint,
11
6
  symbol
12
7
  } from "./chunk-WWNXR34K.js";
8
+ import {
9
+ createDebugLogger,
10
+ readFabricConfig,
11
+ resolveDevMode
12
+ } from "./chunk-AEOYCVBG.js";
13
13
  import {
14
14
  t
15
15
  } from "./chunk-6ICJICVU.js";
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- resolveDevMode
4
- } from "./chunk-AEOYCVBG.js";
5
2
  import {
6
3
  padEnd,
7
4
  paint,
8
5
  symbol
9
6
  } from "./chunk-WWNXR34K.js";
7
+ import {
8
+ resolveDevMode
9
+ } from "./chunk-AEOYCVBG.js";
10
10
  import {
11
11
  t
12
12
  } from "./chunk-6ICJICVU.js";
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- createDebugLogger,
4
- resolveDevMode
5
- } from "./chunk-AEOYCVBG.js";
6
2
  import {
7
3
  paint,
8
4
  symbol
9
5
  } from "./chunk-WWNXR34K.js";
6
+ import {
7
+ createDebugLogger,
8
+ resolveDevMode
9
+ } from "./chunk-AEOYCVBG.js";
10
10
  import {
11
11
  t
12
12
  } from "./chunk-6ICJICVU.js";