@devbie/newbie-cli 1.9.1 → 1.10.1
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/README.md +79 -103
- package/dist/assemble/modules-copy.js +1 -1
- package/dist/assemble/modules-copy.js.map +1 -1
- package/dist/assemble/modules.js +13 -4
- package/dist/assemble/modules.js.map +1 -1
- package/dist/assemble/schema.js +1 -1
- package/dist/commands/create.js +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/doctor.d.ts +4 -1
- package/dist/commands/doctor.js +36 -16
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/modules/default.d.ts +5 -0
- package/dist/commands/{default.js → modules/default.js} +64 -13
- package/dist/commands/modules/default.js.map +1 -0
- package/dist/commands/modules/install.d.ts +7 -0
- package/dist/commands/modules/install.js +121 -0
- package/dist/commands/modules/install.js.map +1 -0
- package/dist/commands/modules/lint.d.ts +3 -0
- package/dist/commands/{dev → modules}/lint.js +12 -11
- package/dist/commands/modules/lint.js.map +1 -0
- package/dist/commands/modules/remove.d.ts +6 -0
- package/dist/commands/modules/remove.js +47 -0
- package/dist/commands/modules/remove.js.map +1 -0
- package/dist/commands/modules/update.d.ts +8 -0
- package/dist/commands/{update.js → modules/update.js} +68 -27
- package/dist/commands/modules/update.js.map +1 -0
- package/dist/commands/modules/watch.d.ts +6 -0
- package/dist/commands/{watch.js → modules/watch.js} +16 -8
- package/dist/commands/modules/watch.js.map +1 -0
- package/dist/commands/shared.d.ts +1 -0
- package/dist/commands/shared.js +1 -1
- package/dist/commands/shared.js.map +1 -1
- package/dist/commands/template/sync.d.ts +7 -0
- package/dist/commands/{sync-template.js → template/sync.js} +10 -19
- package/dist/commands/template/sync.js.map +1 -0
- package/dist/core/deploy-compose.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -179
- package/dist/index.js.map +1 -1
- package/dist/lib/module-selector.d.ts +1 -0
- package/dist/lib/module-selector.js +13 -0
- package/dist/lib/module-selector.js.map +1 -0
- package/dist/lib/sink.d.ts +10 -1
- package/dist/lib/sink.js +42 -3
- package/dist/lib/sink.js.map +1 -1
- package/dist/program.d.ts +3 -0
- package/dist/program.js +166 -0
- package/dist/program.js.map +1 -0
- package/package.json +2 -1
- package/dist/commands/agent.d.ts +0 -5
- package/dist/commands/agent.js +0 -223
- package/dist/commands/agent.js.map +0 -1
- package/dist/commands/apply.d.ts +0 -7
- package/dist/commands/apply.js +0 -61
- package/dist/commands/apply.js.map +0 -1
- package/dist/commands/assemble.d.ts +0 -5
- package/dist/commands/assemble.js +0 -66
- package/dist/commands/assemble.js.map +0 -1
- package/dist/commands/config.d.ts +0 -7
- package/dist/commands/config.js +0 -120
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/default.d.ts +0 -2
- package/dist/commands/default.js.map +0 -1
- package/dist/commands/dev/lint.d.ts +0 -3
- package/dist/commands/dev/lint.js.map +0 -1
- package/dist/commands/install.d.ts +0 -4
- package/dist/commands/install.js +0 -48
- package/dist/commands/install.js.map +0 -1
- package/dist/commands/sync-template.d.ts +0 -8
- package/dist/commands/sync-template.js.map +0 -1
- package/dist/commands/update.d.ts +0 -8
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/watch.d.ts +0 -5
- package/dist/commands/watch.js.map +0 -1
|
@@ -11,6 +11,7 @@ export declare function printBanner(): void;
|
|
|
11
11
|
export interface ContextOptions {
|
|
12
12
|
ensureConfig?: boolean;
|
|
13
13
|
fetch?: boolean;
|
|
14
|
+
check?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export declare function createContext(options: GlobalOptions, opts?: ContextOptions): Promise<{
|
|
16
17
|
ctx: PipelineContext;
|
package/dist/commands/shared.js
CHANGED
|
@@ -34,7 +34,7 @@ function printBanner() {
|
|
|
34
34
|
}
|
|
35
35
|
async function createContext(options, opts = {}) {
|
|
36
36
|
const cwd = node_path_1.default.resolve(options.cwd);
|
|
37
|
-
const sink = (0, sink_1.createSink)(cwd, options.dryRun);
|
|
37
|
+
const sink = (0, sink_1.createSink)(cwd, options.dryRun, { check: opts.check });
|
|
38
38
|
const issues = new issues_1.IssueBag();
|
|
39
39
|
if (opts.ensureConfig) {
|
|
40
40
|
await (0, modules_state_1.ensureModulesState)(cwd, sink);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":";;;;;AAmBA,gCAOC;AAED,kCAUC;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":";;;;;AAmBA,gCAOC;AAED,kCAUC;AAeD,sCA6BC;AAlFD,gEAAkC;AAClC,0DAA6B;AAC7B,oDAA4B;AAC5B,yCAAiC;AAEjC,+CAAuD;AACvD,8CAA8C;AAE9C,0CAAyC;AACzC,wDAA4E;AAC5E,8CAAoE;AACpE,sCAA+C;AAQxC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,mBAAI,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;QACnE,OAAO,IAAA,oBAAS,EAAC,IAAA,mBAAQ,EAAC,GAAG,CAAC,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAgB,WAAW;IACzB,OAAO,CAAC,IAAI,CACV,IAAA,gBAAI,EACF,gBAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;QACxB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,GAAG;QACV,eAAe,EAAE,IAAI;KACtB,CAAC,CACH,CACF,CAAC;AACJ,CAAC;AAeM,KAAK,UAAU,aAAa,CACjC,OAAsB,EACtB,OAAuB,EAAE;IAMzB,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAC;IAE9B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,MAAM,IAAA,kCAAkB,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,IAAA,gCAAgB,EAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAe,EAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAE9D,MAAM,GAAG,GAAoB;QAC3B,GAAG;QACH,IAAI;QACJ,MAAM;QACN,KAAK;QACL,QAAQ;QACR,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;KAC/C,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GlobalOptions } from "../shared";
|
|
2
|
+
import { TemplateReference } from "../create";
|
|
3
|
+
export interface TemplateSyncOptions extends GlobalOptions, TemplateReference {
|
|
4
|
+
check?: boolean;
|
|
5
|
+
paths?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function runTemplateSync(options: TemplateSyncOptions): Promise<void>;
|
|
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.runTemplateSync = runTemplateSync;
|
|
7
7
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const colorette_1 = require("colorette");
|
|
10
|
-
const template_sync_1 = require("
|
|
11
|
-
const unified_diff_1 = require("
|
|
12
|
-
const errors_1 = require("
|
|
13
|
-
const sink_1 = require("
|
|
14
|
-
const create_1 = require("
|
|
10
|
+
const template_sync_1 = require("../../core/template-sync");
|
|
11
|
+
const unified_diff_1 = require("../../core/unified-diff");
|
|
12
|
+
const errors_1 = require("../../lib/errors");
|
|
13
|
+
const sink_1 = require("../../lib/sink");
|
|
14
|
+
const create_1 = require("../create");
|
|
15
15
|
function matchesPathFilter(filePath, filter) {
|
|
16
16
|
const normalized = filter.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
17
17
|
if (normalized === "")
|
|
@@ -85,10 +85,7 @@ function printChangeDiff(change) {
|
|
|
85
85
|
const diff = (0, unified_diff_1.unifiedDiff)(change.currentComparable ?? "", change.templateComparable ?? "", aLabel, `b/${label}`);
|
|
86
86
|
process.stdout.write(diff);
|
|
87
87
|
}
|
|
88
|
-
async function
|
|
89
|
-
if (options.check && options.write) {
|
|
90
|
-
throw new errors_1.CliError("--check and --write are mutually exclusive.");
|
|
91
|
-
}
|
|
88
|
+
async function runTemplateSync(options) {
|
|
92
89
|
const cwd = node_path_1.default.resolve(options.cwd);
|
|
93
90
|
const sink = (0, sink_1.createSink)(cwd, options.dryRun);
|
|
94
91
|
const templateFiles = filterTemplateFiles(options.paths);
|
|
@@ -123,17 +120,11 @@ async function runSyncTemplate(options) {
|
|
|
123
120
|
}
|
|
124
121
|
console.info(`\n${actionable.length} template file(s) to sync: ` +
|
|
125
122
|
actionable.map((c) => `${c.file.path} (${c.kind})`).join(", "));
|
|
126
|
-
const writeCommand = scope ? `newbie sync-template --write ${scope}` : "newbie sync-template --write";
|
|
127
123
|
if (options.check) {
|
|
124
|
+
const command = scope ? `newbie template sync ${scope}` : "newbie template sync";
|
|
128
125
|
throw new errors_1.CliError(`${changes.length} template file(s) drift from the template ` +
|
|
129
126
|
`(${actionable.length} auto-fixable). ` +
|
|
130
|
-
`Run \`${
|
|
131
|
-
}
|
|
132
|
-
if (!options.write) {
|
|
133
|
-
console.info("\nNext steps:");
|
|
134
|
-
console.info(` ${writeCommand} # apply these changes (supports --dry-run)`);
|
|
135
|
-
console.info(" git checkout -b chore/template-sync # then review `git diff` and open a PR");
|
|
136
|
-
return;
|
|
127
|
+
`Run \`${command}\` to apply the template version.`);
|
|
137
128
|
}
|
|
138
129
|
for (const change of actionable) {
|
|
139
130
|
if (change.nextContent !== null) {
|
|
@@ -148,4 +139,4 @@ async function runSyncTemplate(options) {
|
|
|
148
139
|
console.info("Review with `git diff`, then commit on a branch and open a PR.");
|
|
149
140
|
}
|
|
150
141
|
}
|
|
151
|
-
//# sourceMappingURL=sync
|
|
142
|
+
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/template/sync.ts"],"names":[],"mappings":";;;;;AA4HA,0CAgEC;AA5LD,gEAAkC;AAClC,0DAA6B;AAC7B,yCAAsD;AAEtD,4DAWkC;AAClC,0DAAsD;AACtD,6CAA4C;AAC5C,yCAA4C;AAE5C,sCAA+D;AAc/D,SAAS,iBAAiB,CAAC,QAAgB,EAAE,MAAc;IACzD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnE,IAAI,UAAU,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,QAAQ,KAAK,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,mBAAmB,CAAC,KAA2B;IACtD,MAAM,QAAQ,GAAG,8BAAc,CAAC,MAAM,CAAC,sCAAsB,CAAC,CAAC;IAC/D,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,M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C;IACD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,IAAA,iBAAK,EAAC,IAAA,gBAAI,EAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;IACjF,CAAC;AACH,CAAC"}
|
|
@@ -4,7 +4,7 @@ exports.buildComposeModulesYaml = buildComposeModulesYaml;
|
|
|
4
4
|
const env_file_1 = require("./env-file");
|
|
5
5
|
const datastore_registry_1 = require("./datastore-registry");
|
|
6
6
|
const HEADER = `# THIS FILE IS GENERATED BY @devbie/newbie-cli. DO NOT EDIT.
|
|
7
|
-
# Regenerate with \`newbie
|
|
7
|
+
# Regenerate with \`newbie modules install\` (it also runs as part of modules update).
|
|
8
8
|
|
|
9
9
|
`;
|
|
10
10
|
const EMPTY_YAML = `${HEADER}services: {}\n`;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,45 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
4
|
exports.VERSION = void 0;
|
|
8
|
-
const commander_1 = require("commander");
|
|
9
5
|
const colorette_1 = require("colorette");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const apply_1 = require("./commands/apply");
|
|
13
|
-
const assemble_1 = require("./commands/assemble");
|
|
14
|
-
const config_1 = require("./commands/config");
|
|
15
|
-
const create_1 = require("./commands/create");
|
|
16
|
-
const lint_1 = require("./commands/dev/lint");
|
|
17
|
-
const doctor_1 = require("./commands/doctor");
|
|
18
|
-
const install_1 = require("./commands/install");
|
|
19
|
-
const status_1 = require("./commands/status");
|
|
20
|
-
const update_1 = require("./commands/update");
|
|
21
|
-
const sync_template_1 = require("./commands/sync-template");
|
|
22
|
-
const watch_1 = require("./commands/watch");
|
|
23
|
-
const default_1 = require("./commands/default");
|
|
6
|
+
const program_1 = require("./program");
|
|
7
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return program_1.VERSION; } });
|
|
24
8
|
const module_cli_1 = require("./lib/module-cli");
|
|
25
|
-
const cli_runner_1 = require("./lib/cli-runner");
|
|
26
|
-
exports.VERSION = package_json_1.default.version;
|
|
27
|
-
const program = new commander_1.Command();
|
|
28
|
-
program
|
|
29
|
-
.name("newbie")
|
|
30
|
-
.description("Newbie framework CLI: install modules from the newbie-modules registry and sync project files")
|
|
31
|
-
.version(exports.VERSION)
|
|
32
|
-
.option("-C, --cwd <dir>", "project root directory", process.cwd())
|
|
33
|
-
.option("--dry-run", "print planned changes without writing files or running mutating commands", false)
|
|
34
|
-
.option("--skip-prisma-generate", "skip `npx prisma generate` after schema changes", false);
|
|
35
|
-
function collectOptions(command) {
|
|
36
|
-
const globals = command.optsWithGlobals();
|
|
37
|
-
return {
|
|
38
|
-
cwd: globals.cwd ?? process.cwd(),
|
|
39
|
-
dryRun: Boolean(globals.dryRun),
|
|
40
|
-
skipPrismaGenerate: Boolean(globals.skipPrismaGenerate),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
9
|
function findCwdInArgv() {
|
|
44
10
|
const argv = process.argv;
|
|
45
11
|
for (let i = 2; i < argv.length; i++) {
|
|
@@ -61,149 +27,7 @@ function findCwdInArgv() {
|
|
|
61
27
|
}
|
|
62
28
|
return process.cwd();
|
|
63
29
|
}
|
|
64
|
-
program
|
|
65
|
-
.command("install")
|
|
66
|
-
.description("Reconcile the project with modules.json (copy missing modules / remove extra ones and regenerate wiring)")
|
|
67
|
-
.option("-y, --yes", "skip confirmation prompts", false)
|
|
68
|
-
.action(function () {
|
|
69
|
-
const options = { ...collectOptions(this), yes: Boolean(this.opts().yes) };
|
|
70
|
-
return (0, cli_runner_1.run)(() => (0, install_1.runInstall)(options));
|
|
71
|
-
});
|
|
72
|
-
program
|
|
73
|
-
.command("assemble")
|
|
74
|
-
.description("Regenerate module-derived deploy assets (deploy/compose.modules.yml, Caddyfile module route block) from the installed module set")
|
|
75
|
-
.option("--check", "CI gate: print the diff and exit non-zero when the generated deploy assets drift", false)
|
|
76
|
-
.action(function () {
|
|
77
|
-
const flags = this.opts();
|
|
78
|
-
return (0, cli_runner_1.run)(() => (0, assemble_1.runAssemble)({ ...collectOptions(this), check: Boolean(flags.check) }));
|
|
79
|
-
});
|
|
80
|
-
program
|
|
81
|
-
.command("config")
|
|
82
|
-
.description("View or edit the enabled-module list in modules.json without touching project files")
|
|
83
|
-
.option("--add <modules...>", "enable module(s), space or comma separated")
|
|
84
|
-
.option("--remove <modules...>", "disable module(s), space or comma separated")
|
|
85
|
-
.option("--list", "print current configuration", false)
|
|
86
|
-
.action(function () {
|
|
87
|
-
const flags = this.opts();
|
|
88
|
-
return (0, cli_runner_1.run)(() => (0, config_1.runConfig)({
|
|
89
|
-
...collectOptions(this),
|
|
90
|
-
add: flags.add,
|
|
91
|
-
remove: flags.remove,
|
|
92
|
-
list: Boolean(flags.list),
|
|
93
|
-
}));
|
|
94
|
-
});
|
|
95
|
-
program
|
|
96
|
-
.command("update")
|
|
97
|
-
.description("Update enabled module copies to the registry HEAD commit (blocks on local drift unless --force)")
|
|
98
|
-
.option("--all", "select every module with an available update", false)
|
|
99
|
-
.option("-y, --yes", "skip confirmation prompts", false)
|
|
100
|
-
.option("--force", "overwrite locally drifted module copies", false)
|
|
101
|
-
.option("--keys <moduleKeys...>", "non-interactive module selector (comma or space separated)")
|
|
102
|
-
.action(function () {
|
|
103
|
-
const flags = this.opts();
|
|
104
|
-
return (0, cli_runner_1.run)(() => (0, update_1.runUpdate)({
|
|
105
|
-
...collectOptions(this),
|
|
106
|
-
all: Boolean(flags.all),
|
|
107
|
-
yes: Boolean(flags.yes),
|
|
108
|
-
force: Boolean(flags.force),
|
|
109
|
-
keys: (0, update_1.parseKeysFlag)(flags.keys),
|
|
110
|
-
}));
|
|
111
|
-
});
|
|
112
|
-
program
|
|
113
|
-
.command("apply")
|
|
114
|
-
.description('Non-interactively sync the module set declared in a JSON spec ({"modules": [...]})')
|
|
115
|
-
.requiredOption("--config <file>", "path to the declarative apply spec JSON")
|
|
116
|
-
.option("--ci", "CI mode marker (apply is always non-interactive)", false)
|
|
117
|
-
.action(function () {
|
|
118
|
-
const flags = this.opts();
|
|
119
|
-
return (0, cli_runner_1.run)(() => (0, apply_1.runApply)({
|
|
120
|
-
...collectOptions(this),
|
|
121
|
-
config: flags.config,
|
|
122
|
-
ci: Boolean(flags.ci),
|
|
123
|
-
}));
|
|
124
|
-
});
|
|
125
|
-
program
|
|
126
|
-
.command("doctor")
|
|
127
|
-
.description("Audit the installation: registry pins, copied modules, drift, env and prisma wiring")
|
|
128
|
-
.action(function () {
|
|
129
|
-
return (0, cli_runner_1.run)(() => (0, doctor_1.runDoctor)(collectOptions(this)));
|
|
130
|
-
});
|
|
131
|
-
program
|
|
132
|
-
.command("status")
|
|
133
|
-
.description("Print machine-readable project state as JSON")
|
|
134
|
-
.option("--drift", "include content drift against pinned pristine copies", false)
|
|
135
|
-
.action(function () {
|
|
136
|
-
const flags = this.opts();
|
|
137
|
-
return (0, cli_runner_1.run)(() => (0, status_1.runStatus)({ ...collectOptions(this), drift: Boolean(flags.drift) }));
|
|
138
|
-
});
|
|
139
|
-
program
|
|
140
|
-
.command("create <name>")
|
|
141
|
-
.description("Scaffold a new project from the basic template")
|
|
142
|
-
.option("--template-path <dir>", "use a local template directory instead of cloning newbie-starter")
|
|
143
|
-
.option("--template-ref <ref>", "git ref of newbie-starter to clone the template from")
|
|
144
|
-
.option("--no-git-init", "skip 'git init' in the new project", undefined)
|
|
145
|
-
.action(function (name) {
|
|
146
|
-
const flags = this.opts();
|
|
147
|
-
return (0, cli_runner_1.run)(() => (0, create_1.runCreate)({
|
|
148
|
-
...collectOptions(this),
|
|
149
|
-
name,
|
|
150
|
-
templatePath: flags.templatePath,
|
|
151
|
-
templateRef: flags.templateRef,
|
|
152
|
-
gitInit: flags.gitInit,
|
|
153
|
-
}));
|
|
154
|
-
});
|
|
155
|
-
program
|
|
156
|
-
.command("sync-template [paths...]")
|
|
157
|
-
.description("Diff framework-owned template files (ADR-009 ownership registry: main.ts, tsconfig*, nest-cli.json, prisma.config.ts, prisma framework block, .env.example/.gitignore framework blocks, deploy/*) against the template; generated and host-owned files are skipped. Pass path prefixes (e.g. deploy/) to restrict the scope")
|
|
158
|
-
.option("--template-path <dir>", "use a local template directory instead of cloning newbie-starter")
|
|
159
|
-
.option("--template-ref <ref>", "git ref (e.g. a template tag) of newbie-starter to sync from")
|
|
160
|
-
.option("--write", "apply the template version of differing skeleton files", false)
|
|
161
|
-
.option("--check", "CI gate: print the diff and exit non-zero when skeleton files drift", false)
|
|
162
|
-
.action(function (paths) {
|
|
163
|
-
const flags = this.opts();
|
|
164
|
-
return (0, cli_runner_1.run)(() => (0, sync_template_1.runSyncTemplate)({
|
|
165
|
-
...collectOptions(this),
|
|
166
|
-
templatePath: flags.templatePath,
|
|
167
|
-
templateRef: flags.templateRef,
|
|
168
|
-
write: Boolean(flags.write),
|
|
169
|
-
check: Boolean(flags.check),
|
|
170
|
-
paths,
|
|
171
|
-
}));
|
|
172
|
-
});
|
|
173
|
-
program
|
|
174
|
-
.command("agent")
|
|
175
|
-
.description("Run the module-hub agent: poll the hub with `newbie status`, execute dispatched changes (apply/update), report receipts (requires hub v2; v1 hubs expose no agent-poll route)")
|
|
176
|
-
.option("--once", "single pass: drain pending changes, deliver receipts, then exit (CI/cron friendly)", false)
|
|
177
|
-
.action(function () {
|
|
178
|
-
const flags = this.opts();
|
|
179
|
-
return (0, cli_runner_1.run)(() => (0, agent_1.runAgent)({ ...collectOptions(this), once: Boolean(flags.once) }));
|
|
180
|
-
});
|
|
181
|
-
program
|
|
182
|
-
.command("watch [keys...]")
|
|
183
|
-
.description("Watch the local newbie-modules registry and sync installed module sources into the project on change")
|
|
184
|
-
.option("--all", "watch every registry module instead of only installed ones", false)
|
|
185
|
-
.action(function (_keys) {
|
|
186
|
-
const flags = this.opts();
|
|
187
|
-
return (0, cli_runner_1.run)(() => (0, watch_1.runWatch)({
|
|
188
|
-
...collectOptions(this),
|
|
189
|
-
all: Boolean(flags.all),
|
|
190
|
-
}));
|
|
191
|
-
});
|
|
192
|
-
const dev = program
|
|
193
|
-
.command("dev")
|
|
194
|
-
.description("Registry development commands (run inside the newbie-modules repo, not a consuming project)");
|
|
195
|
-
dev
|
|
196
|
-
.command("lint")
|
|
197
|
-
.description("Enforce the module layering rules (feature -> capability -> infrastructure -> datastore) across registry sources")
|
|
198
|
-
.action(function () {
|
|
199
|
-
return (0, cli_runner_1.run)(() => (0, lint_1.runDevLint)(collectOptions(this)));
|
|
200
|
-
});
|
|
201
|
-
program
|
|
202
|
-
.command("interactive", { isDefault: true, hidden: true })
|
|
203
|
-
.description("Interactive module enable/disable flow (default)")
|
|
204
|
-
.action(function () {
|
|
205
|
-
return (0, cli_runner_1.run)(() => (0, default_1.runInteractive)(collectOptions(this)));
|
|
206
|
-
});
|
|
30
|
+
const program = (0, program_1.buildProgram)();
|
|
207
31
|
void (async () => {
|
|
208
32
|
try {
|
|
209
33
|
await (0, module_cli_1.registerModuleCommands)(program, {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,yCAAgC;AAEhC,uCAAkD;AAGzC,wFAHc,iBAAO,OAGd;AAFhB,iDAA0D;AAS1D,SAAS,aAAa;IACpB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,KAAK,IAAI,CAA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,YAAY,IAAK,KAAe,CAAC,KAAK,EAAE,CAAC;YACvD,OAAO,CAAC,KAAK,CAAE,KAAe,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseModuleSelector(input: readonly string[] | undefined): string[] | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseModuleSelector = parseModuleSelector;
|
|
4
|
+
function parseModuleSelector(input) {
|
|
5
|
+
if (!input || input.length === 0)
|
|
6
|
+
return undefined;
|
|
7
|
+
const keys = input
|
|
8
|
+
.flatMap((chunk) => chunk.split(","))
|
|
9
|
+
.map((key) => key.trim())
|
|
10
|
+
.filter((key) => key.length > 0);
|
|
11
|
+
return [...new Set(keys)];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=module-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-selector.js","sourceRoot":"","sources":["../../src/lib/module-selector.ts"],"names":[],"mappings":";;AAKA,kDAOC;AAPD,SAAgB,mBAAmB,CAAC,KAAoC;IACtE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,IAAI,GAAG,KAAK;SACf,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACxB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/lib/sink.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
export interface SinkFinding {
|
|
2
|
+
path: string;
|
|
3
|
+
kind: "missing" | "differs" | "action";
|
|
4
|
+
detail?: string;
|
|
5
|
+
}
|
|
1
6
|
export interface Sink {
|
|
2
7
|
readonly cwd: string;
|
|
3
8
|
readonly dryRun: boolean;
|
|
9
|
+
readonly check: boolean;
|
|
10
|
+
readonly findings: SinkFinding[];
|
|
4
11
|
writeText(file: string, content: string): Promise<void>;
|
|
5
12
|
writeJson(file: string, value: unknown): Promise<void>;
|
|
6
13
|
remove(fileOrDir: string): Promise<void>;
|
|
7
14
|
copy(fromAbsolute: string, toRelative: string): Promise<void>;
|
|
8
15
|
run(command: string, args: string[], label?: string): Promise<void>;
|
|
9
16
|
}
|
|
10
|
-
export declare function createSink(cwd: string, dryRun: boolean
|
|
17
|
+
export declare function createSink(cwd: string, dryRun: boolean, options?: {
|
|
18
|
+
check?: boolean;
|
|
19
|
+
}): Sink;
|
package/dist/lib/sink.js
CHANGED
|
@@ -7,15 +7,37 @@ exports.createSink = createSink;
|
|
|
7
7
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const exec_1 = require("./exec");
|
|
10
|
-
function
|
|
10
|
+
async function readOrNull(absolutePath) {
|
|
11
|
+
try {
|
|
12
|
+
return await promises_1.default.readFile(absolutePath, "utf8");
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function createSink(cwd, dryRun, options = {}) {
|
|
11
19
|
const resolve = (file) => node_path_1.default.resolve(cwd, file);
|
|
20
|
+
const check = Boolean(options.check);
|
|
21
|
+
const findings = [];
|
|
12
22
|
const plan = (message) => {
|
|
13
23
|
console.info(`[dry-run] ${message}`);
|
|
14
24
|
};
|
|
25
|
+
const recordAction = (target, detail) => {
|
|
26
|
+
findings.push({ path: target, kind: "action", detail });
|
|
27
|
+
};
|
|
15
28
|
return {
|
|
16
29
|
cwd,
|
|
17
|
-
dryRun,
|
|
30
|
+
dryRun: dryRun || check,
|
|
31
|
+
check,
|
|
32
|
+
findings,
|
|
18
33
|
async writeText(file, content) {
|
|
34
|
+
if (check) {
|
|
35
|
+
const current = await readOrNull(resolve(file));
|
|
36
|
+
if (current !== content) {
|
|
37
|
+
findings.push({ path: file, kind: current === null ? "missing" : "differs" });
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
19
41
|
if (dryRun) {
|
|
20
42
|
plan(`write ${file} (${content.length} bytes)`);
|
|
21
43
|
return;
|
|
@@ -28,6 +50,15 @@ function createSink(cwd, dryRun) {
|
|
|
28
50
|
await this.writeText(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
29
51
|
},
|
|
30
52
|
async remove(fileOrDir) {
|
|
53
|
+
if (check) {
|
|
54
|
+
try {
|
|
55
|
+
await promises_1.default.stat(resolve(fileOrDir));
|
|
56
|
+
recordAction(fileOrDir, `remove ${fileOrDir}`);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
31
62
|
if (dryRun) {
|
|
32
63
|
plan(`remove ${fileOrDir}`);
|
|
33
64
|
return;
|
|
@@ -35,6 +66,10 @@ function createSink(cwd, dryRun) {
|
|
|
35
66
|
await promises_1.default.rm(resolve(fileOrDir), { recursive: true, force: true });
|
|
36
67
|
},
|
|
37
68
|
async copy(fromAbsolute, toRelative) {
|
|
69
|
+
if (check) {
|
|
70
|
+
recordAction(toRelative, `copy ${node_path_1.default.basename(fromAbsolute)} -> ${toRelative}`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
38
73
|
if (dryRun) {
|
|
39
74
|
plan(`copy ${node_path_1.default.basename(fromAbsolute)} -> ${toRelative}`);
|
|
40
75
|
return;
|
|
@@ -44,7 +79,11 @@ function createSink(cwd, dryRun) {
|
|
|
44
79
|
await promises_1.default.mkdir(node_path_1.default.dirname(target), { recursive: true });
|
|
45
80
|
await promises_1.default.cp(fromAbsolute, target, { recursive: true });
|
|
46
81
|
},
|
|
47
|
-
async run(command, args,
|
|
82
|
+
async run(command, args, label) {
|
|
83
|
+
if (check) {
|
|
84
|
+
recordAction(label ?? `${command} ${args.join(" ")}`.trim(), label ?? `${command} ${args.join(" ")}`.trim());
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
48
87
|
if (dryRun) {
|
|
49
88
|
plan(`${command} ${args.join(" ")}`.trim());
|
|
50
89
|
return;
|
package/dist/lib/sink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.js","sourceRoot":"","sources":["../../src/lib/sink.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"sink.js","sourceRoot":"","sources":["../../src/lib/sink.ts"],"names":[],"mappings":";;;;;AA0CA,gCAqFC;AA/HD,gEAAkC;AAClC,0DAA6B;AAE7B,iCAAkC;AA+BlC,KAAK,UAAU,UAAU,CAAC,YAAoB;IAC5C,IAAI,CAAC;QACH,OAAO,MAAM,kBAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,GAAW,EAAE,MAAe,EAAE,UAA+B,EAAE;IACxF,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,mBAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAkB,EAAE,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