@metaobjectsdev/cli 0.19.1 → 0.19.2-rc.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-drift.d.ts","sourceRoot":"","sources":["../../../src/lib/codegen-drift.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codegen-drift.d.ts","sourceRoot":"","sources":["../../../src/lib/codegen-drift.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMzD,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,KAAK,EAAE,OAAO,CAAC;IACf,8EAA8E;IAC9E,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,uDAAuD;IACvD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkCD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA2G7B"}
|
|
@@ -12,19 +12,24 @@
|
|
|
12
12
|
// to the committed output, each outDir is remapped into the temp tree at the
|
|
13
13
|
// SAME path it has relative to the project root — preserving the inter-target
|
|
14
14
|
// layout. `importBase` (a stable string, not a path) is untouched.
|
|
15
|
-
import { mkdtempSync, rmSync, existsSync, readFileSync, readdirSync, statSync, } from "node:fs";
|
|
15
|
+
import { mkdtempSync, rmSync, existsSync, readFileSync, readdirSync, statSync, cpSync, } from "node:fs";
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
17
|
import { join, relative, resolve, isAbsolute } from "node:path";
|
|
18
18
|
import { runGen } from "@metaobjectsdev/codegen-ts";
|
|
19
|
-
/** Collect the committed outDirs declared by the config (default + per-target)
|
|
20
|
-
|
|
19
|
+
/** Collect the committed outDirs declared by the config (default + per-target),
|
|
20
|
+
* resolved against `projectRoot` — a relative outDir (the common, portable,
|
|
21
|
+
* `meta init`-scaffolded shape) must resolve against the project the CLI's
|
|
22
|
+
* `--cwd` flag says to run as, not the ambient process.cwd() (which differs
|
|
23
|
+
* whenever `verify --codegen` runs from outside the target project, e.g. a
|
|
24
|
+
* test suite or a CI job invoking the CLI against another directory). */
|
|
25
|
+
function committedOutDirs(config, projectRoot) {
|
|
21
26
|
const dirs = new Set();
|
|
22
27
|
if (typeof config.outDir === "string" && config.outDir.length > 0) {
|
|
23
|
-
dirs.add(resolve(config.outDir));
|
|
28
|
+
dirs.add(resolve(projectRoot, config.outDir));
|
|
24
29
|
}
|
|
25
30
|
for (const t of Object.values(config.targets ?? {})) {
|
|
26
31
|
if (t.outDir && t.outDir.length > 0)
|
|
27
|
-
dirs.add(resolve(t.outDir));
|
|
32
|
+
dirs.add(resolve(projectRoot, t.outDir));
|
|
28
33
|
}
|
|
29
34
|
return [...dirs];
|
|
30
35
|
}
|
|
@@ -54,7 +59,7 @@ function listFiles(dir) {
|
|
|
54
59
|
*/
|
|
55
60
|
export async function computeCodegenDrift(config, metadata, projectRoot) {
|
|
56
61
|
const root = isAbsolute(projectRoot) ? projectRoot : resolve(projectRoot);
|
|
57
|
-
const committedDirs = committedOutDirs(config);
|
|
62
|
+
const committedDirs = committedOutDirs(config, root);
|
|
58
63
|
if (committedDirs.length === 0) {
|
|
59
64
|
return {
|
|
60
65
|
clean: false,
|
|
@@ -81,16 +86,32 @@ export async function computeCodegenDrift(config, metadata, projectRoot) {
|
|
|
81
86
|
return join(tempRoot, safeRel);
|
|
82
87
|
};
|
|
83
88
|
// Remap the config so runGen writes into the temp mirror instead of the
|
|
84
|
-
// committed output. Default outDir + each named target's outDir are
|
|
89
|
+
// committed output. Default outDir + each named target's outDir are
|
|
90
|
+
// rewritten — resolved against `root` (see committedOutDirs above), not
|
|
91
|
+
// the ambient process.cwd(), so this stays correct under `--cwd`.
|
|
85
92
|
const remappedTargets = {};
|
|
86
93
|
for (const [name, t] of Object.entries(config.targets ?? {})) {
|
|
87
|
-
remappedTargets[name] = { ...t, outDir: tempFor(resolve(t.outDir)) };
|
|
94
|
+
remappedTargets[name] = { ...t, outDir: tempFor(resolve(root, t.outDir)) };
|
|
88
95
|
}
|
|
89
96
|
const tempConfig = {
|
|
90
97
|
...config,
|
|
91
|
-
outDir: tempFor(resolve(config.outDir)),
|
|
98
|
+
outDir: tempFor(resolve(root, config.outDir)),
|
|
92
99
|
...(config.targets !== undefined ? { targets: remappedTargets } : {}),
|
|
93
100
|
};
|
|
101
|
+
// runGen is called with `projectRoot: tempRoot` below (so relative outDir
|
|
102
|
+
// remapping stays correct — see the module doc). Some generators resolve
|
|
103
|
+
// ancillary project-relative input at generation time rather than through
|
|
104
|
+
// `config` — namely the template-output codegen family (e.g. render-helper,
|
|
105
|
+
// via codegen-ts's `projectProvider(ctx.projectRoot)`), which reads a
|
|
106
|
+
// `<projectRoot>/templates/` dir to build-time-verify each referenced
|
|
107
|
+
// mustache. Mirror it into the temp root so that lookup succeeds the same
|
|
108
|
+
// way it does for `meta gen` against the real project root — otherwise
|
|
109
|
+
// every project using those generators would spuriously fail `--codegen`
|
|
110
|
+
// with an "unresolved" template error that has nothing to do with drift.
|
|
111
|
+
const projectTemplatesDir = join(root, "templates");
|
|
112
|
+
if (existsSync(projectTemplatesDir)) {
|
|
113
|
+
cpSync(projectTemplatesDir, join(tempRoot, "templates"), { recursive: true });
|
|
114
|
+
}
|
|
94
115
|
// Generate fresh into the temp tree. "overwrite" + "fresh" + a temp
|
|
95
116
|
// gen-state dir guarantees every file is written (no merge/skip), so the
|
|
96
117
|
// temp tree is the canonical "what gen would produce right now".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen-drift.js","sourceRoot":"","sources":["../../../src/lib/codegen-drift.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,mEAAmE;AAEnE,OAAO,EACL,WAAW,EACX,MAAM,EACN,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,
|
|
1
|
+
{"version":3,"file":"codegen-drift.js","sourceRoot":"","sources":["../../../src/lib/codegen-drift.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,gFAAgF;AAChF,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,mEAAmE;AAEnE,OAAO,EACL,WAAW,EACX,MAAM,EACN,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,MAAM,GACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAmBpD;;;;;0EAK0E;AAC1E,SAAS,gBAAgB,CAAC,MAA4B,EAAE,WAAmB;IACzE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IACD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QACxC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACrE,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metaobjectsdev/cli",
|
|
3
|
-
"version": "0.19.1",
|
|
3
|
+
"version": "0.19.2-rc.1",
|
|
4
4
|
"description": "CLI for MetaObjects: scaffold, codegen, migrate, and drift-detection commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@libsql/kysely-libsql": "^0.4.0",
|
|
52
|
-
"@metaobjectsdev/codegen-ts": "0.19.1",
|
|
53
|
-
"@metaobjectsdev/codegen-ts-react": "0.19.1",
|
|
54
|
-
"@metaobjectsdev/codegen-ts-tanstack": "0.19.1",
|
|
55
|
-
"@metaobjectsdev/docs-site": "0.19.1",
|
|
56
|
-
"@metaobjectsdev/metadata": "0.19.1",
|
|
57
|
-
"@metaobjectsdev/migrate-ts": "0.19.1",
|
|
58
|
-
"@metaobjectsdev/render": "0.19.1",
|
|
59
|
-
"@metaobjectsdev/runtime-ts": "0.19.1",
|
|
60
|
-
"@metaobjectsdev/sdk": "0.19.1",
|
|
52
|
+
"@metaobjectsdev/codegen-ts": "0.19.2-rc.1",
|
|
53
|
+
"@metaobjectsdev/codegen-ts-react": "0.19.2-rc.1",
|
|
54
|
+
"@metaobjectsdev/codegen-ts-tanstack": "0.19.2-rc.1",
|
|
55
|
+
"@metaobjectsdev/docs-site": "0.19.2-rc.1",
|
|
56
|
+
"@metaobjectsdev/metadata": "0.19.2-rc.1",
|
|
57
|
+
"@metaobjectsdev/migrate-ts": "0.19.2-rc.1",
|
|
58
|
+
"@metaobjectsdev/render": "0.19.2-rc.1",
|
|
59
|
+
"@metaobjectsdev/runtime-ts": "0.19.2-rc.1",
|
|
60
|
+
"@metaobjectsdev/sdk": "0.19.2-rc.1",
|
|
61
61
|
"@toon-format/toon": "^2.3.0",
|
|
62
62
|
"jiti": "^2.4.0"
|
|
63
63
|
},
|
package/src/lib/codegen-drift.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
readFileSync,
|
|
21
21
|
readdirSync,
|
|
22
22
|
statSync,
|
|
23
|
+
cpSync,
|
|
23
24
|
} from "node:fs";
|
|
24
25
|
import { tmpdir } from "node:os";
|
|
25
26
|
import { join, relative, resolve, isAbsolute } from "node:path";
|
|
@@ -42,14 +43,19 @@ export interface CodegenDriftResult {
|
|
|
42
43
|
error?: string;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
/** Collect the committed outDirs declared by the config (default + per-target)
|
|
46
|
-
|
|
46
|
+
/** Collect the committed outDirs declared by the config (default + per-target),
|
|
47
|
+
* resolved against `projectRoot` — a relative outDir (the common, portable,
|
|
48
|
+
* `meta init`-scaffolded shape) must resolve against the project the CLI's
|
|
49
|
+
* `--cwd` flag says to run as, not the ambient process.cwd() (which differs
|
|
50
|
+
* whenever `verify --codegen` runs from outside the target project, e.g. a
|
|
51
|
+
* test suite or a CI job invoking the CLI against another directory). */
|
|
52
|
+
function committedOutDirs(config: MetaobjectsGenConfig, projectRoot: string): string[] {
|
|
47
53
|
const dirs = new Set<string>();
|
|
48
54
|
if (typeof config.outDir === "string" && config.outDir.length > 0) {
|
|
49
|
-
dirs.add(resolve(config.outDir));
|
|
55
|
+
dirs.add(resolve(projectRoot, config.outDir));
|
|
50
56
|
}
|
|
51
57
|
for (const t of Object.values(config.targets ?? {})) {
|
|
52
|
-
if (t.outDir && t.outDir.length > 0) dirs.add(resolve(t.outDir));
|
|
58
|
+
if (t.outDir && t.outDir.length > 0) dirs.add(resolve(projectRoot, t.outDir));
|
|
53
59
|
}
|
|
54
60
|
return [...dirs];
|
|
55
61
|
}
|
|
@@ -83,7 +89,7 @@ export async function computeCodegenDrift(
|
|
|
83
89
|
): Promise<CodegenDriftResult> {
|
|
84
90
|
const root = isAbsolute(projectRoot) ? projectRoot : resolve(projectRoot);
|
|
85
91
|
|
|
86
|
-
const committedDirs = committedOutDirs(config);
|
|
92
|
+
const committedDirs = committedOutDirs(config, root);
|
|
87
93
|
if (committedDirs.length === 0) {
|
|
88
94
|
return {
|
|
89
95
|
clean: false,
|
|
@@ -113,17 +119,34 @@ export async function computeCodegenDrift(
|
|
|
113
119
|
};
|
|
114
120
|
|
|
115
121
|
// Remap the config so runGen writes into the temp mirror instead of the
|
|
116
|
-
// committed output. Default outDir + each named target's outDir are
|
|
122
|
+
// committed output. Default outDir + each named target's outDir are
|
|
123
|
+
// rewritten — resolved against `root` (see committedOutDirs above), not
|
|
124
|
+
// the ambient process.cwd(), so this stays correct under `--cwd`.
|
|
117
125
|
const remappedTargets: Record<string, TargetConfig> = {};
|
|
118
126
|
for (const [name, t] of Object.entries(config.targets ?? {})) {
|
|
119
|
-
remappedTargets[name] = { ...t, outDir: tempFor(resolve(t.outDir)) };
|
|
127
|
+
remappedTargets[name] = { ...t, outDir: tempFor(resolve(root, t.outDir)) };
|
|
120
128
|
}
|
|
121
129
|
const tempConfig: MetaobjectsGenConfig = {
|
|
122
130
|
...config,
|
|
123
|
-
outDir: tempFor(resolve(config.outDir)),
|
|
131
|
+
outDir: tempFor(resolve(root, config.outDir)),
|
|
124
132
|
...(config.targets !== undefined ? { targets: remappedTargets } : {}),
|
|
125
133
|
};
|
|
126
134
|
|
|
135
|
+
// runGen is called with `projectRoot: tempRoot` below (so relative outDir
|
|
136
|
+
// remapping stays correct — see the module doc). Some generators resolve
|
|
137
|
+
// ancillary project-relative input at generation time rather than through
|
|
138
|
+
// `config` — namely the template-output codegen family (e.g. render-helper,
|
|
139
|
+
// via codegen-ts's `projectProvider(ctx.projectRoot)`), which reads a
|
|
140
|
+
// `<projectRoot>/templates/` dir to build-time-verify each referenced
|
|
141
|
+
// mustache. Mirror it into the temp root so that lookup succeeds the same
|
|
142
|
+
// way it does for `meta gen` against the real project root — otherwise
|
|
143
|
+
// every project using those generators would spuriously fail `--codegen`
|
|
144
|
+
// with an "unresolved" template error that has nothing to do with drift.
|
|
145
|
+
const projectTemplatesDir = join(root, "templates");
|
|
146
|
+
if (existsSync(projectTemplatesDir)) {
|
|
147
|
+
cpSync(projectTemplatesDir, join(tempRoot, "templates"), { recursive: true });
|
|
148
|
+
}
|
|
149
|
+
|
|
127
150
|
// Generate fresh into the temp tree. "overwrite" + "fresh" + a temp
|
|
128
151
|
// gen-state dir guarantees every file is written (no merge/skip), so the
|
|
129
152
|
// temp tree is the canonical "what gen would produce right now".
|