@devbie/newbie-cli 0.1.0-stage.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.
Files changed (139) hide show
  1. package/dist/assemble/assets.d.ts +9 -0
  2. package/dist/assemble/assets.js +49 -0
  3. package/dist/assemble/assets.js.map +1 -0
  4. package/dist/assemble/dependencies.d.ts +10 -0
  5. package/dist/assemble/dependencies.js +36 -0
  6. package/dist/assemble/dependencies.js.map +1 -0
  7. package/dist/assemble/env.d.ts +15 -0
  8. package/dist/assemble/env.js +79 -0
  9. package/dist/assemble/env.js.map +1 -0
  10. package/dist/assemble/modules-copy.d.ts +13 -0
  11. package/dist/assemble/modules-copy.js +36 -0
  12. package/dist/assemble/modules-copy.js.map +1 -0
  13. package/dist/assemble/modules.d.ts +8 -0
  14. package/dist/assemble/modules.js +86 -0
  15. package/dist/assemble/modules.js.map +1 -0
  16. package/dist/assemble/pipeline.d.ts +17 -0
  17. package/dist/assemble/pipeline.js +143 -0
  18. package/dist/assemble/pipeline.js.map +1 -0
  19. package/dist/assemble/schema.d.ts +10 -0
  20. package/dist/assemble/schema.js +64 -0
  21. package/dist/assemble/schema.js.map +1 -0
  22. package/dist/assemble/types.d.ts +18 -0
  23. package/dist/assemble/types.js +3 -0
  24. package/dist/assemble/types.js.map +1 -0
  25. package/dist/commands/agent.d.ts +1 -0
  26. package/dist/commands/agent.js +16 -0
  27. package/dist/commands/agent.js.map +1 -0
  28. package/dist/commands/apply.d.ts +6 -0
  29. package/dist/commands/apply.js +52 -0
  30. package/dist/commands/apply.js.map +1 -0
  31. package/dist/commands/check.d.ts +2 -0
  32. package/dist/commands/check.js +37 -0
  33. package/dist/commands/check.js.map +1 -0
  34. package/dist/commands/config.d.ts +7 -0
  35. package/dist/commands/config.js +82 -0
  36. package/dist/commands/config.js.map +1 -0
  37. package/dist/commands/create.d.ts +16 -0
  38. package/dist/commands/create.js +89 -0
  39. package/dist/commands/create.js.map +1 -0
  40. package/dist/commands/default.d.ts +2 -0
  41. package/dist/commands/default.js +69 -0
  42. package/dist/commands/default.js.map +1 -0
  43. package/dist/commands/doctor.d.ts +2 -0
  44. package/dist/commands/doctor.js +145 -0
  45. package/dist/commands/doctor.js.map +1 -0
  46. package/dist/commands/env.d.ts +7 -0
  47. package/dist/commands/env.js +324 -0
  48. package/dist/commands/env.js.map +1 -0
  49. package/dist/commands/install.d.ts +4 -0
  50. package/dist/commands/install.js +45 -0
  51. package/dist/commands/install.js.map +1 -0
  52. package/dist/commands/shared.d.ts +19 -0
  53. package/dist/commands/shared.js +54 -0
  54. package/dist/commands/shared.js.map +1 -0
  55. package/dist/commands/status.d.ts +4 -0
  56. package/dist/commands/status.js +62 -0
  57. package/dist/commands/status.js.map +1 -0
  58. package/dist/commands/update-template.d.ts +6 -0
  59. package/dist/commands/update-template.js +83 -0
  60. package/dist/commands/update-template.js.map +1 -0
  61. package/dist/commands/update.d.ts +6 -0
  62. package/dist/commands/update.js +129 -0
  63. package/dist/commands/update.js.map +1 -0
  64. package/dist/constants/paths.d.ts +12 -0
  65. package/dist/constants/paths.js +19 -0
  66. package/dist/constants/paths.js.map +1 -0
  67. package/dist/core/assets.d.ts +8 -0
  68. package/dist/core/assets.js +30 -0
  69. package/dist/core/assets.js.map +1 -0
  70. package/dist/core/dependency-plan.d.ts +12 -0
  71. package/dist/core/dependency-plan.js +42 -0
  72. package/dist/core/dependency-plan.js.map +1 -0
  73. package/dist/core/drift.d.ts +9 -0
  74. package/dist/core/drift.js +34 -0
  75. package/dist/core/drift.js.map +1 -0
  76. package/dist/core/env-file.d.ts +19 -0
  77. package/dist/core/env-file.js +184 -0
  78. package/dist/core/env-file.js.map +1 -0
  79. package/dist/core/module-manifest.d.ts +19 -0
  80. package/dist/core/module-manifest.js +48 -0
  81. package/dist/core/module-manifest.js.map +1 -0
  82. package/dist/core/modules-state.d.ts +24 -0
  83. package/dist/core/modules-state.js +81 -0
  84. package/dist/core/modules-state.js.map +1 -0
  85. package/dist/core/prisma-schema.d.ts +3 -0
  86. package/dist/core/prisma-schema.js +38 -0
  87. package/dist/core/prisma-schema.js.map +1 -0
  88. package/dist/core/semver.d.ts +9 -0
  89. package/dist/core/semver.js +32 -0
  90. package/dist/core/semver.js.map +1 -0
  91. package/dist/core/template-sync.d.ts +19 -0
  92. package/dist/core/template-sync.js +97 -0
  93. package/dist/core/template-sync.js.map +1 -0
  94. package/dist/core/unified-diff.d.ts +1 -0
  95. package/dist/core/unified-diff.js +103 -0
  96. package/dist/core/unified-diff.js.map +1 -0
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.js +202 -0
  99. package/dist/index.js.map +1 -0
  100. package/dist/lib/check.d.ts +1 -0
  101. package/dist/lib/check.js +31 -0
  102. package/dist/lib/check.js.map +1 -0
  103. package/dist/lib/drift.d.ts +5 -0
  104. package/dist/lib/drift.js +142 -0
  105. package/dist/lib/drift.js.map +1 -0
  106. package/dist/lib/env-tool-config.d.ts +17 -0
  107. package/dist/lib/env-tool-config.js +32 -0
  108. package/dist/lib/env-tool-config.js.map +1 -0
  109. package/dist/lib/errors.d.ts +5 -0
  110. package/dist/lib/errors.js +20 -0
  111. package/dist/lib/errors.js.map +1 -0
  112. package/dist/lib/exec.d.ts +13 -0
  113. package/dist/lib/exec.js +40 -0
  114. package/dist/lib/exec.js.map +1 -0
  115. package/dist/lib/fs-util.d.ts +1 -0
  116. package/dist/lib/fs-util.js +18 -0
  117. package/dist/lib/fs-util.js.map +1 -0
  118. package/dist/lib/issues.d.ts +8 -0
  119. package/dist/lib/issues.js +31 -0
  120. package/dist/lib/issues.js.map +1 -0
  121. package/dist/lib/loading.d.ts +1 -0
  122. package/dist/lib/loading.js +31 -0
  123. package/dist/lib/loading.js.map +1 -0
  124. package/dist/lib/module-install.d.ts +5 -0
  125. package/dist/lib/module-install.js +54 -0
  126. package/dist/lib/module-install.js.map +1 -0
  127. package/dist/lib/modules-state.d.ts +6 -0
  128. package/dist/lib/modules-state.js +51 -0
  129. package/dist/lib/modules-state.js.map +1 -0
  130. package/dist/lib/registry.d.ts +23 -0
  131. package/dist/lib/registry.js +182 -0
  132. package/dist/lib/registry.js.map +1 -0
  133. package/dist/lib/sink.d.ts +10 -0
  134. package/dist/lib/sink.js +56 -0
  135. package/dist/lib/sink.js.map +1 -0
  136. package/dist/lib/version.d.ts +1 -0
  137. package/dist/lib/version.js +19 -0
  138. package/dist/lib/version.js.map +1 -0
  139. package/package.json +39 -0
@@ -0,0 +1,24 @@
1
+ export interface ModuleRecord {
2
+ key: string;
3
+ version: string | null;
4
+ sourceCommit: string | null;
5
+ localPatches: string[];
6
+ }
7
+ export interface ModulesState {
8
+ registry: {
9
+ url?: string;
10
+ ref?: string | null;
11
+ sourceCommit?: string | null;
12
+ } | null;
13
+ modules: ModuleRecord[];
14
+ [key: string]: unknown;
15
+ }
16
+ export declare function createEmptyModulesState(): ModulesState;
17
+ export declare function normalizeModulesState(raw: unknown): ModulesState;
18
+ export declare function moduleKeys(state: ModulesState): string[];
19
+ export interface EnabledDiff {
20
+ added: string[];
21
+ removed: string[];
22
+ }
23
+ export declare function diffModuleKeys(current: string[], next: string[]): EnabledDiff;
24
+ export declare function withModuleKeys(state: ModulesState, nextKeys: string[]): ModulesState;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEmptyModulesState = createEmptyModulesState;
4
+ exports.normalizeModulesState = normalizeModulesState;
5
+ exports.moduleKeys = moduleKeys;
6
+ exports.diffModuleKeys = diffModuleKeys;
7
+ exports.withModuleKeys = withModuleKeys;
8
+ function createEmptyModulesState() {
9
+ return { registry: null, modules: [] };
10
+ }
11
+ function normalizeRecord(raw) {
12
+ if (!raw || typeof raw !== "object")
13
+ return null;
14
+ const record = raw;
15
+ if (typeof record.key !== "string" || record.key.length === 0)
16
+ return null;
17
+ const sourceCommit = typeof record.sourceCommit === "string" ? record.sourceCommit : null;
18
+ const version = typeof record.version === "string" ? record.version : null;
19
+ const localPatches = Array.isArray(record.localPatches)
20
+ ? record.localPatches.filter((patch) => typeof patch === "string")
21
+ : [];
22
+ return { key: record.key, version, sourceCommit, localPatches };
23
+ }
24
+ function normalizeModulesState(raw) {
25
+ const data = (raw && typeof raw === "object"
26
+ ? raw
27
+ : {});
28
+ const registryData = data.registry && typeof data.registry === "object" ? data.registry : null;
29
+ const registry = registryData
30
+ ? {
31
+ url: typeof registryData.url === "string" ? registryData.url : undefined,
32
+ ref: typeof registryData.ref === "string" ? registryData.ref : null,
33
+ sourceCommit: typeof registryData.sourceCommit === "string"
34
+ ? registryData.sourceCommit
35
+ : null,
36
+ }
37
+ : null;
38
+ const records = Array.isArray(data.modules)
39
+ ? data.modules
40
+ .map(normalizeRecord)
41
+ .filter((record) => record !== null)
42
+ : [];
43
+ const seen = new Set();
44
+ const modules = [];
45
+ for (const record of records) {
46
+ if (seen.has(record.key))
47
+ continue;
48
+ seen.add(record.key);
49
+ modules.push(record);
50
+ }
51
+ return { ...data, registry, modules };
52
+ }
53
+ function moduleKeys(state) {
54
+ return state.modules.map((record) => record.key);
55
+ }
56
+ function diffModuleKeys(current, next) {
57
+ const currentSet = new Set(current);
58
+ const nextSet = new Set(next);
59
+ return {
60
+ added: next.filter((key) => !currentSet.has(key)),
61
+ removed: current.filter((key) => !nextSet.has(key)),
62
+ };
63
+ }
64
+ function withModuleKeys(state, nextKeys) {
65
+ const byKey = new Map(state.modules.map((record) => [record.key, record]));
66
+ const seen = new Set();
67
+ const modules = [];
68
+ for (const key of nextKeys) {
69
+ if (seen.has(key))
70
+ continue;
71
+ seen.add(key);
72
+ modules.push(byKey.get(key) ?? {
73
+ key,
74
+ version: null,
75
+ sourceCommit: null,
76
+ localPatches: [],
77
+ });
78
+ }
79
+ return { ...state, modules };
80
+ }
81
+ //# sourceMappingURL=modules-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules-state.js","sourceRoot":"","sources":["../../src/core/modules-state.ts"],"names":[],"mappings":";;AAoCA,0DAEC;AA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AC/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function updateDatasourceSchemas(content: string, addedPaths: string[], removedPaths: string[]): string;
2
+ export declare function moduleSchemaNamespace(key: string): string;
3
+ export declare function readDatasourceSchemas(content: string): string[] | null;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateDatasourceSchemas = updateDatasourceSchemas;
4
+ exports.moduleSchemaNamespace = moduleSchemaNamespace;
5
+ exports.readDatasourceSchemas = readDatasourceSchemas;
6
+ const DATASOURCE_SCHEMAS_RE = /(datasource\s+db\s*\{(?:.|\n|\r)*schemas\s*=\s*)(\[.*?\])/;
7
+ function updateDatasourceSchemas(content, addedPaths, removedPaths) {
8
+ return content.replace(DATASOURCE_SCHEMAS_RE, (_whole, prefix, arrayLiteral) => {
9
+ let current = [];
10
+ try {
11
+ current = JSON.parse(`{"val": ${arrayLiteral}}`).val;
12
+ }
13
+ catch {
14
+ throw new Error("[Error] Cannot parse schemas array in prisma/schema.prisma");
15
+ }
16
+ const removed = new Set(removedPaths);
17
+ const next = Array.from(new Set([
18
+ ...current.filter((entry) => !removed.has(entry)),
19
+ ...addedPaths,
20
+ ]));
21
+ return `${prefix}${JSON.stringify(next).replace(/,/g, ", ")}`;
22
+ });
23
+ }
24
+ function moduleSchemaNamespace(key) {
25
+ return `module/${key}`;
26
+ }
27
+ function readDatasourceSchemas(content) {
28
+ const match = content.match(DATASOURCE_SCHEMAS_RE);
29
+ if (!match)
30
+ return null;
31
+ try {
32
+ return JSON.parse(`{"val": ${match[2]}}`).val;
33
+ }
34
+ catch {
35
+ return null;
36
+ }
37
+ }
38
+ //# sourceMappingURL=prisma-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prisma-schema.js","sourceRoot":"","sources":["../../src/core/prisma-schema.ts"],"names":[],"mappings":";;AASA,0DA2BC;AAGD,sDAEC;AAGD,sDAQC;AA9CD,MAAM,qBAAqB,GACzB,2DAA2D,C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d,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface SemverTag {
2
+ tag: string;
3
+ major: number;
4
+ minor: number;
5
+ patch: number;
6
+ }
7
+ export declare function parseSemverTag(tag: string): SemverTag | null;
8
+ export declare function compareSemverTags(a: SemverTag, b: SemverTag): number;
9
+ export declare function pickLatestSemverTag(tags: string[]): string | null;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseSemverTag = parseSemverTag;
4
+ exports.compareSemverTags = compareSemverTags;
5
+ exports.pickLatestSemverTag = pickLatestSemverTag;
6
+ function parseSemverTag(tag) {
7
+ const match = tag.trim().match(/^v?(\d+)\.(\d+)\.(\d+)$/);
8
+ if (!match)
9
+ return null;
10
+ return {
11
+ tag: match[0].startsWith("v") ? match[0] : match[0],
12
+ major: Number(match[1]),
13
+ minor: Number(match[2]),
14
+ patch: Number(match[3]),
15
+ };
16
+ }
17
+ function compareSemverTags(a, b) {
18
+ if (a.major !== b.major)
19
+ return a.major - b.major;
20
+ if (a.minor !== b.minor)
21
+ return a.minor - b.minor;
22
+ return a.patch - b.patch;
23
+ }
24
+ function pickLatestSemverTag(tags) {
25
+ const parsed = tags
26
+ .map((tag) => parseSemverTag(tag))
27
+ .filter((tag) => tag !== null);
28
+ if (parsed.length === 0)
29
+ return null;
30
+ return parsed.sort(compareSemverTags).pop().tag;
31
+ }
32
+ //# sourceMappingURL=semver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semver.js","sourceRoot":"","sources":["../../src/core/semver.ts"],"names":[],"mappings":";;AASA,wCAUC;AAGD,8CAIC;AAGD,kDAMC;AA1BD,SAAgB,cAAc,CAAC,GAAW;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,OAAO;QACL,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACnD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACxB,CAAC;AACJ,CAAC;AAGD,SAAgB,iBAAiB,CAAC,CAAY,EAAE,CAAY;IAC1D,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAClD,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAClD,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;AAC3B,CAAC;AAGD,SAAgB,mBAAmB,CAAC,IAAc;IAChD,MAAM,MAAM,GAAG,IAAI;SAChB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;SACjC,MAAM,CAAC,CAAC,GAAG,EAAoB,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,GAAG,EAAG,CAAC,GAAG,CAAC;AACnD,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare const MARKER_START = "// @@newbie-framework-start";
2
+ export declare const MARKER_END = "// @@newbie-framework-end";
3
+ export type SkeletonStrategy = "whole-file" | "marker-block";
4
+ export interface SkeletonFile {
5
+ path: string;
6
+ strategy: SkeletonStrategy;
7
+ }
8
+ export declare const SKELETON_FILES: readonly SkeletonFile[];
9
+ export declare function extractMarkerBlock(content: string): string | null;
10
+ export declare function replaceMarkerBlock(content: string, block: string): string | null;
11
+ export type SkeletonChangeKind = "create" | "update" | "missing-markers";
12
+ export interface SkeletonChange {
13
+ file: SkeletonFile;
14
+ kind: SkeletonChangeKind;
15
+ nextContent: string | null;
16
+ currentComparable: string | null;
17
+ templateComparable: string | null;
18
+ }
19
+ export declare function planTemplateSync(projectFiles: ReadonlyMap<string, string | null>, templateFiles: ReadonlyMap<string, string | null>): SkeletonChange[];
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SKELETON_FILES = exports.MARKER_END = exports.MARKER_START = void 0;
4
+ exports.extractMarkerBlock = extractMarkerBlock;
5
+ exports.replaceMarkerBlock = replaceMarkerBlock;
6
+ exports.planTemplateSync = planTemplateSync;
7
+ exports.MARKER_START = "// @@newbie-framework-start";
8
+ exports.MARKER_END = "// @@newbie-framework-end";
9
+ exports.SKELETON_FILES = [
10
+ { path: "src/main.ts", strategy: "whole-file" },
11
+ { path: "tsconfig.json", strategy: "whole-file" },
12
+ { path: "tsconfig.build.json", strategy: "whole-file" },
13
+ { path: "nest-cli.json", strategy: "whole-file" },
14
+ { path: "prisma.config.ts", strategy: "whole-file" },
15
+ { path: "prisma/schema.prisma", strategy: "marker-block" },
16
+ ];
17
+ function extractMarkerBlock(content) {
18
+ const start = content.indexOf(exports.MARKER_START);
19
+ const end = content.indexOf(exports.MARKER_END);
20
+ if (start === -1 || end === -1 || end < start)
21
+ return null;
22
+ return content.slice(start, end + exports.MARKER_END.length);
23
+ }
24
+ function replaceMarkerBlock(content, block) {
25
+ const current = extractMarkerBlock(content);
26
+ if (current === null)
27
+ return null;
28
+ return content.replace(current, block);
29
+ }
30
+ function planTemplateSync(projectFiles, templateFiles) {
31
+ const changes = [];
32
+ for (const file of exports.SKELETON_FILES) {
33
+ const templateContent = templateFiles.get(file.path);
34
+ if (templateContent == null)
35
+ continue;
36
+ const projectContent = projectFiles.get(file.path);
37
+ if (file.strategy === "whole-file") {
38
+ if (projectContent == null) {
39
+ changes.push({
40
+ file,
41
+ kind: "create",
42
+ nextContent: templateContent,
43
+ currentComparable: null,
44
+ templateComparable: templateContent,
45
+ });
46
+ }
47
+ else if (projectContent !== templateContent) {
48
+ changes.push({
49
+ file,
50
+ kind: "update",
51
+ nextContent: templateContent,
52
+ currentComparable: projectContent,
53
+ templateComparable: templateContent,
54
+ });
55
+ }
56
+ continue;
57
+ }
58
+ const templateBlock = extractMarkerBlock(templateContent);
59
+ if (templateBlock === null) {
60
+ throw new Error(`Template ${file.path} is missing the framework block ` +
61
+ `(${exports.MARKER_START} / ${exports.MARKER_END}).`);
62
+ }
63
+ if (projectContent == null) {
64
+ changes.push({
65
+ file,
66
+ kind: "create",
67
+ nextContent: templateContent,
68
+ currentComparable: null,
69
+ templateComparable: templateBlock,
70
+ });
71
+ continue;
72
+ }
73
+ const projectBlock = extractMarkerBlock(projectContent);
74
+ if (projectBlock === null) {
75
+ changes.push({
76
+ file,
77
+ kind: "missing-markers",
78
+ nextContent: null,
79
+ currentComparable: null,
80
+ templateComparable: templateBlock,
81
+ });
82
+ continue;
83
+ }
84
+ if (projectBlock !== templateBlock) {
85
+ const nextContent = replaceMarkerBlock(projectContent, templateBlock);
86
+ changes.push({
87
+ file,
88
+ kind: "update",
89
+ nextContent,
90
+ currentComparable: projectBlock,
91
+ templateComparable: templateBlock,
92
+ });
93
+ }
94
+ }
95
+ return changes;
96
+ }
97
+ //# sourceMappingURL=template-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-sync.js","sourceRoot":"","sources":["../../src/core/template-sync.ts"],"names":[],"mappings":";;;AAgCA,gDAKC;AAMD,gDAOC;AAyBD,4CA8EC;AA/IY,QAAA,YAAY,GAAG,6BAA6B,CAAC;AAC7C,QAAA,UAAU,GAAG,2BAA2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C;YAC1B,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI;gBACJ,IAAI,EAAE,iBAAiB;gBACvB,WAAW,EAAE,IAAI;gBACjB,iBAAiB,EAAE,IAAI;gBACvB,kBAAkB,EAAE,aAAa;aAClC,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;YACnC,MAAM,WAAW,GAAG,kBAAkB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;YACtE,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW;gBACX,iBAAiB,EAAE,YAAY;gBAC/B,kBAAkB,EAAE,aAAa;aAClC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function unifiedDiff(aText: string, bText: string, aLabel: string, bLabel: string, context?: number): string;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unifiedDiff = unifiedDiff;
4
+ function lcsDiff(a, b) {
5
+ const m = a.length;
6
+ const n = b.length;
7
+ const dp = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
8
+ for (let i = 1; i <= m; i++) {
9
+ for (let j = 1; j <= n; j++) {
10
+ dp[i][j] =
11
+ a[i - 1] === b[j - 1]
12
+ ? dp[i - 1][j - 1] + 1
13
+ : Math.max(dp[i - 1][j], dp[i][j - 1]);
14
+ }
15
+ }
16
+ const ops = [];
17
+ let i = m;
18
+ let j = n;
19
+ while (i > 0 || j > 0) {
20
+ if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
21
+ ops.unshift({ type: "same", line: a[i - 1] });
22
+ i--;
23
+ j--;
24
+ }
25
+ else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
26
+ ops.unshift({ type: "add", line: b[j - 1] });
27
+ j--;
28
+ }
29
+ else {
30
+ ops.unshift({ type: "del", line: a[i - 1] });
31
+ i--;
32
+ }
33
+ }
34
+ return ops;
35
+ }
36
+ function buildHunks(ops, context) {
37
+ const changed = ops.map((op) => op.type !== "same");
38
+ const aPos = [];
39
+ const bPos = [];
40
+ let a = 1;
41
+ let b = 1;
42
+ for (const op of ops) {
43
+ aPos.push(a);
44
+ bPos.push(b);
45
+ if (op.type !== "add")
46
+ a++;
47
+ if (op.type !== "del")
48
+ b++;
49
+ }
50
+ const hunks = [];
51
+ let i = 0;
52
+ while (i < ops.length) {
53
+ if (!changed[i]) {
54
+ i++;
55
+ continue;
56
+ }
57
+ const start = Math.max(0, i - context);
58
+ let end = Math.min(ops.length - 1, i + context);
59
+ for (;;) {
60
+ const next = changed.indexOf(true, end + 1);
61
+ if (next === -1 || next - end > context * 2 + 1)
62
+ break;
63
+ end = Math.min(ops.length - 1, next + context);
64
+ }
65
+ const hunk = { aStart: aPos[start], bStart: bPos[start], lines: [] };
66
+ for (let k = start; k <= end; k++) {
67
+ hunk.lines.push({ type: ops[k].type, text: ops[k].line });
68
+ }
69
+ hunks.push(hunk);
70
+ i = end + 1;
71
+ }
72
+ return hunks;
73
+ }
74
+ function hunkHeader(hunk) {
75
+ const aCount = hunk.lines.filter((l) => l.type !== "add").length;
76
+ const bCount = hunk.lines.filter((l) => l.type !== "del").length;
77
+ const aStart = aCount === 0 ? hunk.aStart - 1 : hunk.aStart;
78
+ const bStart = bCount === 0 ? hunk.bStart - 1 : hunk.bStart;
79
+ const aPart = aCount === 1 ? `${aStart}` : `${aStart},${aCount}`;
80
+ const bPart = bCount === 1 ? `${bStart}` : `${bStart},${bCount}`;
81
+ return `@@ -${aPart} +${bPart} @@`;
82
+ }
83
+ function unifiedDiff(aText, bText, aLabel, bLabel, context = 3) {
84
+ const a = aText.split("\n");
85
+ const b = bText.split("\n");
86
+ if (a.length > 0 && a[a.length - 1] === "")
87
+ a.pop();
88
+ if (b.length > 0 && b[b.length - 1] === "")
89
+ b.pop();
90
+ const ops = lcsDiff(a, b);
91
+ if (ops.every((op) => op.type === "same"))
92
+ return "";
93
+ const out = [`--- ${aLabel}`, `+++ ${bLabel}`];
94
+ for (const hunk of buildHunks(ops, context)) {
95
+ out.push(hunkHeader(hunk));
96
+ for (const line of hunk.lines) {
97
+ const prefix = line.type === "same" ? " " : line.type === "del" ? "-" : "+";
98
+ out.push(`${prefix}${line.text}`);
99
+ }
100
+ }
101
+ return `${out.join("\n")}\n`;
102
+ }
103
+ //# sourceMappingURL=unified-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified-diff.js","sourceRoot":"","sources":["../../src/core/unified-diff.ts"],"names":[],"mappings":";;AA8GA,kCA0BC;AAjID,SAAS,OAAO,CAAC,CAAW,EAAE,CAAW;IACvC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,MAAM,EAAE,GAAe,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,CACxD,IAAI,KAAK,CAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACjC,CAAC;IACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACN,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;oBACnB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;oBACtB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,C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AC5C,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,MAAM,MAAM,GACV,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAC/D,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export declare const VERSION: string;
package/dist/index.js ADDED
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.VERSION = void 0;
5
+ const commander_1 = require("commander");
6
+ const colorette_1 = require("colorette");
7
+ const agent_1 = require("./commands/agent");
8
+ const apply_1 = require("./commands/apply");
9
+ const check_1 = require("./commands/check");
10
+ const config_1 = require("./commands/config");
11
+ const create_1 = require("./commands/create");
12
+ const doctor_1 = require("./commands/doctor");
13
+ const env_1 = require("./commands/env");
14
+ const install_1 = require("./commands/install");
15
+ const status_1 = require("./commands/status");
16
+ const update_1 = require("./commands/update");
17
+ const update_template_1 = require("./commands/update-template");
18
+ const default_1 = require("./commands/default");
19
+ const errors_1 = require("./lib/errors");
20
+ exports.VERSION = require("../package.json")
21
+ .version;
22
+ const program = new commander_1.Command();
23
+ program
24
+ .name("newbie")
25
+ .description("Newbie framework CLI: install modules from the newbie-modules registry and sync project files")
26
+ .version(exports.VERSION)
27
+ .option("-C, --cwd <dir>", "project root directory", process.cwd())
28
+ .option("--dry-run", "print planned changes without writing files or running mutating commands", false)
29
+ .option("--skip-prisma-generate", "skip `npx prisma generate` after schema changes", false);
30
+ function collectOptions(command) {
31
+ const globals = command.optsWithGlobals();
32
+ return {
33
+ cwd: globals.cwd ?? process.cwd(),
34
+ dryRun: Boolean(globals.dryRun),
35
+ skipPrismaGenerate: Boolean(globals.skipPrismaGenerate),
36
+ };
37
+ }
38
+ async function run(action) {
39
+ try {
40
+ await action();
41
+ }
42
+ catch (error) {
43
+ if ((0, errors_1.isUserCancellation)(error)) {
44
+ console.info("\nOperation cancelled\n");
45
+ process.exit(0);
46
+ }
47
+ if (error instanceof errors_1.CliError) {
48
+ console.error((0, colorette_1.red)(`\n${error.message}\n`));
49
+ process.exit(1);
50
+ }
51
+ console.error((0, colorette_1.red)(`\n${error.message}\n`));
52
+ if (process.env.NEWBIE_DEBUG && error.stack) {
53
+ console.error(error.stack);
54
+ }
55
+ process.exit(1);
56
+ }
57
+ }
58
+ program
59
+ .command("install")
60
+ .description("Reconcile the project with modules.json (copy missing modules / remove extra ones and regenerate wiring)")
61
+ .option("-y, --yes", "skip confirmation prompts", false)
62
+ .action(function () {
63
+ const options = { ...collectOptions(this), yes: Boolean(this.opts().yes) };
64
+ return run(() => (0, install_1.runInstall)(options));
65
+ });
66
+ program
67
+ .command("config")
68
+ .description("View or edit the enabled-module list in modules.json without touching project files")
69
+ .option("--add <modules...>", "enable module(s), space or comma separated")
70
+ .option("--remove <modules...>", "disable module(s), space or comma separated")
71
+ .option("--list", "print current configuration", false)
72
+ .action(function () {
73
+ const flags = this.opts();
74
+ return run(() => (0, config_1.runConfig)({
75
+ ...collectOptions(this),
76
+ add: flags.add,
77
+ remove: flags.remove,
78
+ list: Boolean(flags.list),
79
+ }));
80
+ });
81
+ program
82
+ .command("check")
83
+ .description("Check that every env variable required by enabled modules is present in .env")
84
+ .action(function () {
85
+ return run(() => (0, check_1.runCheck)(collectOptions(this)));
86
+ });
87
+ program
88
+ .command("update")
89
+ .description("Update enabled module copies to the registry HEAD commit (blocks on local drift unless --force)")
90
+ .option("--all", "select every module with an available update", false)
91
+ .option("-y, --yes", "skip confirmation prompts", false)
92
+ .option("--force", "overwrite locally drifted module copies", false)
93
+ .action(function () {
94
+ const flags = this.opts();
95
+ return run(() => (0, update_1.runUpdate)({
96
+ ...collectOptions(this),
97
+ all: Boolean(flags.all),
98
+ yes: Boolean(flags.yes),
99
+ force: Boolean(flags.force),
100
+ }));
101
+ });
102
+ program
103
+ .command("apply")
104
+ .description('Non-interactively sync the module set declared in a JSON spec ({"modules": [...]})')
105
+ .requiredOption("--config <file>", "path to the declarative apply spec JSON")
106
+ .option("--ci", "CI mode marker (apply is always non-interactive)", false)
107
+ .action(function () {
108
+ const flags = this.opts();
109
+ return run(() => (0, apply_1.runApply)({
110
+ ...collectOptions(this),
111
+ config: flags.config,
112
+ ci: Boolean(flags.ci),
113
+ }));
114
+ });
115
+ program
116
+ .command("doctor")
117
+ .description("Audit the installation: registry pins, copied modules, drift, env and prisma wiring")
118
+ .action(function () {
119
+ return run(() => (0, doctor_1.runDoctor)(collectOptions(this)));
120
+ });
121
+ program
122
+ .command("status")
123
+ .description("Print machine-readable project state as JSON")
124
+ .option("--drift", "include content drift against pinned pristine copies", false)
125
+ .action(function () {
126
+ const flags = this.opts();
127
+ return run(() => (0, status_1.runStatus)({ ...collectOptions(this), drift: Boolean(flags.drift) }));
128
+ });
129
+ program
130
+ .command("create <name>")
131
+ .description("Scaffold a new project from the basic template")
132
+ .option("--template-path <dir>", "use a local template directory instead of cloning the newbie repository")
133
+ .option("--template-ref <ref>", "git ref of the newbie repository to clone the template from")
134
+ .option("--no-git-init", "skip 'git init' in the new project", undefined)
135
+ .action(function (name) {
136
+ const flags = this.opts();
137
+ return run(() => (0, create_1.runCreate)({
138
+ ...collectOptions(this),
139
+ name,
140
+ templatePath: flags.templatePath,
141
+ templateRef: flags.templateRef,
142
+ gitInit: flags.gitInit,
143
+ }));
144
+ });
145
+ program
146
+ .command("update-template")
147
+ .description("Diff framework-managed skeleton files (main.ts, tsconfig*, prisma framework block) against the template; business files are skipped")
148
+ .option("--template-path <dir>", "use a local template directory instead of cloning the newbie repository")
149
+ .option("--template-ref <ref>", "git ref (e.g. a template tag) of the newbie repository to sync from")
150
+ .option("--write", "apply the template version of differing skeleton files", false)
151
+ .action(function () {
152
+ const flags = this.opts();
153
+ return run(() => (0, update_template_1.runUpdateTemplate)({
154
+ ...collectOptions(this),
155
+ templatePath: flags.templatePath,
156
+ templateRef: flags.templateRef,
157
+ write: Boolean(flags.write),
158
+ }));
159
+ });
160
+ program
161
+ .command("agent")
162
+ .description("Reserved entrypoint for the module-hub remote agent protocol")
163
+ .action(function () {
164
+ return run(() => (0, agent_1.runAgent)());
165
+ });
166
+ const env = program
167
+ .command("env")
168
+ .description("Sync .env with AWS Secrets Manager");
169
+ env
170
+ .command("pull")
171
+ .description("Pull environment variables from AWS Secrets Manager into .env")
172
+ .option("-e, --environment <name>", "environment name from the env-tool config (skips the prompt)")
173
+ .option("-y, --yes", "write .env without prompting (conflicting local values are kept)", false)
174
+ .action(function () {
175
+ const flags = this.opts();
176
+ return run(() => (0, env_1.runEnvPull)({
177
+ ...collectOptions(this),
178
+ environment: flags.environment,
179
+ yes: Boolean(flags.yes),
180
+ }));
181
+ });
182
+ env
183
+ .command("push")
184
+ .description("Push environment variables from .env to AWS Secrets Manager")
185
+ .option("-e, --environment <name>", "environment name from the env-tool config (skips the prompt)")
186
+ .option("-y, --yes", "create/update secrets without prompting", false)
187
+ .action(function () {
188
+ const flags = this.opts();
189
+ return run(() => (0, env_1.runEnvPush)({
190
+ ...collectOptions(this),
191
+ environment: flags.environment,
192
+ yes: Boolean(flags.yes),
193
+ }));
194
+ });
195
+ program
196
+ .command("interactive", { isDefault: true, hidden: true })
197
+ .description("Interactive module enable/disable flow (default)")
198
+ .action(function () {
199
+ return run(() => (0, default_1.runInteractive)(collectOptions(this)));
200
+ });
201
+ program.parseAsync(process.argv);
202
+ //# sourceMappingURL=index.js.map