@procedures/cue 0.6.0 → 0.8.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.
- package/CHANGELOG.md +31 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +12 -0
- package/dist/module.js.map +1 -1
- package/dist/procedures/cue/generate.d.ts +4 -2
- package/dist/procedures/cue/generate.d.ts.map +1 -1
- package/dist/procedures/cue/generate.js +7 -5
- package/dist/procedures/cue/generate.js.map +1 -1
- package/dist/procedures/cue/validate.d.ts.map +1 -1
- package/dist/procedures/cue/validate.js +6 -4
- package/dist/procedures/cue/validate.js.map +1 -1
- package/dist/shared.d.ts +9 -2
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +40 -4
- package/dist/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/module.ts +14 -1
- package/src/procedures/cue/generate.ts +7 -4
- package/src/procedures/cue/validate.ts +6 -4
- package/src/shared.ts +39 -4
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA+D,KAAK,eAAe,EAAuC,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AA4IpL;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,eAMR,CAAC;eAEF,SAAS;AAExB;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,iBAAsC,GAAG,IAAI,CAE5F"}
|
package/dist/module.js
CHANGED
|
@@ -14,6 +14,13 @@ import { cueRemove } from "./procedures/cue/remove.js";
|
|
|
14
14
|
import { cueGenerate } from "./procedures/cue/generate.js";
|
|
15
15
|
import { cueValidate } from "./procedures/cue/validate.js";
|
|
16
16
|
import { CueInitInputSchema, CueAddInputSchema, CueRemoveInputSchema, CueGenerateInputSchema, CueValidateInputSchema, CueInitOutputSchema, CueAddOutputSchema, CueRemoveOutputSchema, CueGenerateOutputSchema, CueValidateOutputSchema, } from "./types.js";
|
|
17
|
+
/**
|
|
18
|
+
* The rule of each cue procedure under a root of the files (roadmap R33): the folder of the
|
|
19
|
+
* project (`cwd`) must be in the root, and without `cwd` it is the root. The files of the project
|
|
20
|
+
* go through `fs.*`, so the root confines them too. The files of the installed cue package are
|
|
21
|
+
* not paths of the call.
|
|
22
|
+
*/
|
|
23
|
+
const CUE_IN_A_ROOT = { cwd: "cwd" };
|
|
17
24
|
// =============================================================================
|
|
18
25
|
// Procedure Definitions
|
|
19
26
|
// =============================================================================
|
|
@@ -26,6 +33,7 @@ const cueInitProcedure = createProcedure()
|
|
|
26
33
|
calls: ["fs.exists", "fs.read", "fs.write", "fs.mkdir"],
|
|
27
34
|
// With `force`, it overwrites dependencies.json. A second call writes the same preset again.
|
|
28
35
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
36
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
29
37
|
args: [],
|
|
30
38
|
shorts: { preset: "p", force: "f", cwd: "C" },
|
|
31
39
|
output: "json",
|
|
@@ -43,6 +51,7 @@ const cueAddProcedure = createProcedure()
|
|
|
43
51
|
calls: ["fs.exists", "fs.read", "fs.write"],
|
|
44
52
|
// It writes dependencies.json again with only `$schema` and `dependencies`. Other fields go.
|
|
45
53
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
54
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
46
55
|
args: ["feature"],
|
|
47
56
|
shorts: { cwd: "C" },
|
|
48
57
|
output: "json",
|
|
@@ -59,6 +68,7 @@ const cueRemoveProcedure = createProcedure()
|
|
|
59
68
|
description: "Remove a feature from dependencies.json",
|
|
60
69
|
calls: ["fs.exists", "fs.read", "fs.write"],
|
|
61
70
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
71
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
62
72
|
args: ["feature"],
|
|
63
73
|
shorts: { cwd: "C" },
|
|
64
74
|
output: "json",
|
|
@@ -77,6 +87,7 @@ const cueGenerateProcedure = createProcedure()
|
|
|
77
87
|
// The cue program evaluates the CUE files of @mark1russell7/cue, not code of the project.
|
|
78
88
|
// The procedure rewrites package.json, tsconfig.json and .gitignore.
|
|
79
89
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
90
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
80
91
|
args: [],
|
|
81
92
|
shorts: { cwd: "C" },
|
|
82
93
|
output: "json",
|
|
@@ -93,6 +104,7 @@ const cueValidateProcedure = createProcedure()
|
|
|
93
104
|
description: "Validate dependencies.json",
|
|
94
105
|
calls: ["fs.exists", "fs.read"],
|
|
95
106
|
effects: { reads: ["fs"], writes: [] },
|
|
107
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
96
108
|
args: [],
|
|
97
109
|
shorts: { cwd: "C" },
|
|
98
110
|
output: "json",
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAA0C,kBAAkB,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AACpL,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACj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AA4B;IACzC,KAAK,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;IAC/B,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;IACtC,MAAM,EAAE,aAAa;IACrB,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;IACpB,MAAM,EAAE,MAAM;CACf,CAAC;KACD,OAAO,CAAC,KAAK,EAAE,KAAuB,EAAE,GAAG,EAA8B,EAAE;IAC1E,OAAO,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoB,YAAY,CAAC,iBAAiB,EAAE;IACtE,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,oBAAoB;IACpB,oBAAoB;CACrB,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEjB,eAAe,SAAS,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAQ,GAAsB,kBAAkB;IACpF,eAAe,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* cue.generate procedure
|
|
3
3
|
*
|
|
4
4
|
* Generate config files (package.json, tsconfig.json, .gitignore).
|
|
5
|
-
* Uses ctx.client.call() for
|
|
6
|
-
* Runs the cue program through runCommand of client-shell (async, no shell)
|
|
5
|
+
* Uses ctx.client.call() for the files of the project (dogfooding).
|
|
6
|
+
* Runs the cue program through runCommand of client-shell (async, no shell), in a folder of the
|
|
7
|
+
* installed cue package, with the CUE files of that package only. The program reads no path of
|
|
8
|
+
* the call, so a root of the host (roadmap R33) confines only the folder of the project.
|
|
7
9
|
*/
|
|
8
10
|
import type { ProcedureContext } from "@procedures/client";
|
|
9
11
|
import type { CueGenerateInput, CueGenerateOutput } from "../../types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/generate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AA2I1E;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CA0F5B"}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* cue.generate procedure
|
|
3
3
|
*
|
|
4
4
|
* Generate config files (package.json, tsconfig.json, .gitignore).
|
|
5
|
-
* Uses ctx.client.call() for
|
|
6
|
-
* Runs the cue program through runCommand of client-shell (async, no shell)
|
|
5
|
+
* Uses ctx.client.call() for the files of the project (dogfooding).
|
|
6
|
+
* Runs the cue program through runCommand of client-shell (async, no shell), in a folder of the
|
|
7
|
+
* installed cue package, with the CUE files of that package only. The program reads no path of
|
|
8
|
+
* the call, so a root of the host (roadmap R33) confines only the folder of the project.
|
|
7
9
|
*/
|
|
8
10
|
import { resolve } from "node:path";
|
|
9
|
-
import { loadFeatures, loadDependencies, resolveFeatures, checkCue, runCue, determineTsconfig, featureToFieldName, packageRoot, fileExists, readJson, writeJson, writeFile, mkdir, } from "../../shared.js";
|
|
11
|
+
import { loadFeatures, loadDependencies, resolveFeatures, checkCue, runCue, determineTsconfig, featureToFieldName, packageRoot, fileExists, installedFileExists, readJson, writeJson, writeFile, mkdir, } from "../../shared.js";
|
|
10
12
|
/**
|
|
11
13
|
* Keys that describe a package's own entry points. The package owns them: a generated value
|
|
12
14
|
* is only a default for a package that has none. (BUGS-2026-07 H33: generate replaced a
|
|
@@ -24,7 +26,7 @@ async function generatePackageJson(resolvedFeatures, existingPkg, ctx) {
|
|
|
24
26
|
for (const feature of resolvedFeatures) {
|
|
25
27
|
const fieldName = featureToFieldName(feature);
|
|
26
28
|
const cuePath = resolve(configDir, `${fieldName}.cue`);
|
|
27
|
-
if (await
|
|
29
|
+
if (await installedFileExists(cuePath)) {
|
|
28
30
|
files.push(`${fieldName}.cue`);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
@@ -76,7 +78,7 @@ async function generateGitignore(resolvedFeatures, ctx) {
|
|
|
76
78
|
const files = ["base.cue"];
|
|
77
79
|
for (const feature of resolvedFeatures) {
|
|
78
80
|
const cuePath = resolve(configDir, `${feature}.cue`);
|
|
79
|
-
if (await
|
|
81
|
+
if (await installedFileExists(cuePath)) {
|
|
80
82
|
files.push(`${feature}.cue`);
|
|
81
83
|
}
|
|
82
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/procedures/cue/generate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/procedures/cue/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,QAAQ,EACR,SAAS,EACT,SAAS,EACT,KAAK,GACN,MAAM,iBAAiB,CAAC;AASzB;;;;;GAKG;AACH,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,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C;YAC3E,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;QAED,0CAA0C;QAC1C,IAAI,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,MAAM,WAAW,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;YACpC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,gBAAgB;YAChB,SAAS;YACT,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,gBAAgB;QAChB,SAAS;QACT,OAAO,EAAE,aAAa,SAAS,CAAC,MAAM,QAAQ;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAU1E;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/procedures/cue/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAU1E;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAwE5B"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Validate dependencies.json against schema.
|
|
5
5
|
* Uses ctx.client.call() for file system operations (dogfooding).
|
|
6
6
|
*/
|
|
7
|
-
import { resolve } from "node:path";
|
|
8
|
-
import { loadFeatures, loadDependencies, checkCue, runCue, packageRoot,
|
|
7
|
+
import { dirname, resolve } from "node:path";
|
|
8
|
+
import { loadFeatures, loadDependencies, checkCue, runCue, packageRoot, installedFileExists, } from "../../shared.js";
|
|
9
9
|
/**
|
|
10
10
|
* Validate dependencies.json
|
|
11
11
|
*/
|
|
@@ -50,9 +50,11 @@ export async function cueValidate(input, ctx) {
|
|
|
50
50
|
// If CUE is available, validate against schema
|
|
51
51
|
if (await checkCue(ctx.signal)) {
|
|
52
52
|
const schemaPath = resolve(packageRoot, "dependencies/schema.cue");
|
|
53
|
-
if (await
|
|
53
|
+
if (await installedFileExists(schemaPath)) {
|
|
54
54
|
const depsPath = resolve(projectPath, "dependencies.json");
|
|
55
|
-
|
|
55
|
+
// cue runs in the folder of the schema: a folder of the installed cue package, not the
|
|
56
|
+
// working folder of the host (roadmap R33)
|
|
57
|
+
const result = await runCue(["vet", "-d", "#Dependencies", schemaPath, depsPath], { cwd: dirname(schemaPath), signal: ctx.signal });
|
|
56
58
|
if (!result.success) {
|
|
57
59
|
errors.push(`CUE schema validation failed: ${result.stderr || result.stdout}`);
|
|
58
60
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/procedures/cue/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../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shared utilities for cue procedures
|
|
3
3
|
*
|
|
4
|
-
* Uses ctx.client.call() for
|
|
4
|
+
* Uses ctx.client.call() for the files of the project (dogfooding). The files of the installed
|
|
5
|
+
* cue package are read with `node:fs` (see `loadFeatures`).
|
|
5
6
|
*
|
|
6
7
|
* A file operation that fails is an error of the call. Only a missing file is a normal result.
|
|
7
8
|
* (Before, each helper turned every error into "missing": with no fs.* procedures in the host,
|
|
@@ -20,7 +21,13 @@ export declare function mkdir(path: string, ctx: ProcedureContext): Promise<bool
|
|
|
20
21
|
/** The JSON content of a file, or null when the file does not exist. Text that is not JSON throws. */
|
|
21
22
|
export declare function readJson<T>(path: string, ctx: ProcedureContext): Promise<T | null>;
|
|
22
23
|
export declare function writeJson<T>(path: string, data: T, ctx: ProcedureContext): Promise<boolean>;
|
|
23
|
-
|
|
24
|
+
/** True when a file of the installed cue package exists. */
|
|
25
|
+
export declare function installedFileExists(path: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* The feature manifest of the installed cue package, or null when it is missing. Text that is not
|
|
28
|
+
* JSON throws. `root` is the folder of the package: a test gives another folder.
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadFeatures(_ctx?: ProcedureContext, root?: string): Promise<FeaturesManifest | null>;
|
|
24
31
|
export declare function loadDependencies(projectPath: string, ctx: ProcedureContext): Promise<string[] | null>;
|
|
25
32
|
export declare function saveDependencies(deps: string[], projectPath: string, ctx: ProcedureContext): Promise<boolean>;
|
|
26
33
|
export declare function resolveFeatures(requested: string[], manifest: FeaturesManifest): string[];
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAA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,CAAC,CAcxH;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAe1B;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EAAE,EACd,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC,OAAO,CAAC,CAMlB;AAGD,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAqBzF;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG1D;AAMD;;;GAGG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;CAAO,GAC3E,OAAO,CAAC,aAAa,CAAC,CAExB;AAED,8CAA8C;AAC9C,wBAAsB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAErE;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,MAAM,CAQpE"}
|
package/dist/shared.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared utilities for cue procedures
|
|
3
3
|
*
|
|
4
|
-
* Uses ctx.client.call() for
|
|
4
|
+
* Uses ctx.client.call() for the files of the project (dogfooding). The files of the installed
|
|
5
|
+
* cue package are read with `node:fs` (see `loadFeatures`).
|
|
5
6
|
*
|
|
6
7
|
* A file operation that fails is an error of the call. Only a missing file is a normal result.
|
|
7
8
|
* (Before, each helper turned every error into "missing": with no fs.* procedures in the host,
|
|
8
9
|
* cue.validate answered "No dependencies.json found", deep dive WRP-3.)
|
|
9
10
|
*/
|
|
11
|
+
import { access, readFile as readInstalledFile } from "node:fs/promises";
|
|
10
12
|
import { createRequire } from "node:module";
|
|
11
13
|
import { dirname, resolve } from "node:path";
|
|
12
14
|
import { runCommand } from "@procedures/shell/command";
|
|
@@ -72,9 +74,43 @@ export async function writeJson(path, data, ctx) {
|
|
|
72
74
|
// =============================================================================
|
|
73
75
|
// Core Functions
|
|
74
76
|
// =============================================================================
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
// =============================================================================
|
|
78
|
+
// The files of the installed cue package
|
|
79
|
+
// =============================================================================
|
|
80
|
+
// The files of `@mark1russell7/cue` (features.json and its CUE files) are a part of the
|
|
81
|
+
// procedures, as their code is. The procedures read them with `node:fs`, not through `fs.*`. A
|
|
82
|
+
// root of the host (roadmap R33) confines the paths of the project, and these files are outside it.
|
|
83
|
+
/** True when a file of the installed cue package exists. */
|
|
84
|
+
export async function installedFileExists(path) {
|
|
85
|
+
try {
|
|
86
|
+
await access(path);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The feature manifest of the installed cue package, or null when it is missing. Text that is not
|
|
95
|
+
* JSON throws. `root` is the folder of the package: a test gives another folder.
|
|
96
|
+
*/
|
|
97
|
+
export async function loadFeatures(_ctx, root = packageRoot) {
|
|
98
|
+
const featuresPath = resolve(root, "features.json");
|
|
99
|
+
let content;
|
|
100
|
+
try {
|
|
101
|
+
content = await readInstalledFile(featuresPath, "utf8");
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (error.code === "ENOENT")
|
|
105
|
+
return null;
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
return JSON.parse(content);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw new Error(`${featuresPath} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
113
|
+
}
|
|
78
114
|
}
|
|
79
115
|
export async function loadDependencies(projectPath, ctx) {
|
|
80
116
|
const depsPath = resolve(projectPath, "dependencies.json");
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAsB,MAAM,2BAA2B,CAAC;AAG3E,YAAY;AACZ,0FAA0F;AAC1F,6EAA6E;AAC7E,oFAAoF;AACpF,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,WAAW,GAAW,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC,CAAC;AAEhG,0EAA0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AA0BzG,gFAAgF;AAChF,8CAA8C;AAC9C,gFAAgF;AAEhF,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,GAAqB;IAClE,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAClC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAChB,EAAE,IAAI,EAAE,CACT,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAED,yF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AQ,CAAC,MAAoB;IACjD,OAAO,CAAC,MAAM,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,gBAA0B;IAC1D,IAAI,QAAQ,GAAG,IAAI,CAAC;IACpB,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACxC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACvC,QAAQ,GAAG,OAAO,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/cue",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "cue-config as procedures: generate package.json, tsconfig.json and .gitignore from CUE feature presets, add and remove features, and validate projects.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cue",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"procedures": "./dist/register.js"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@procedures/client": "0.
|
|
66
|
-
"@procedures/fs": "0.
|
|
67
|
-
"@procedures/shell": "0.
|
|
65
|
+
"@procedures/client": "0.8.0",
|
|
66
|
+
"@procedures/fs": "0.8.0",
|
|
67
|
+
"@procedures/shell": "0.8.0",
|
|
68
68
|
"@mark1russell7/cue": "^1.0.0",
|
|
69
69
|
"zod": "^4.6.5"
|
|
70
70
|
},
|
package/src/module.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* This file is referenced by package.json's client.procedures field.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { createProcedure, zodAdapter, defineModule, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
|
|
10
|
+
import { createProcedure, zodAdapter, defineModule, type FsRootRules, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
|
|
11
11
|
import fsModule from "@procedures/fs/module";
|
|
12
12
|
import { cueInit } from "./procedures/cue/init.js";
|
|
13
13
|
import { cueAdd } from "./procedures/cue/add.js";
|
|
@@ -37,6 +37,14 @@ import {
|
|
|
37
37
|
CueValidateOutputSchema,
|
|
38
38
|
} from "./types.js";
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The rule of each cue procedure under a root of the files (roadmap R33): the folder of the
|
|
42
|
+
* project (`cwd`) must be in the root, and without `cwd` it is the root. The files of the project
|
|
43
|
+
* go through `fs.*`, so the root confines them too. The files of the installed cue package are
|
|
44
|
+
* not paths of the call.
|
|
45
|
+
*/
|
|
46
|
+
const CUE_IN_A_ROOT: FsRootRules = { cwd: "cwd" };
|
|
47
|
+
|
|
40
48
|
// =============================================================================
|
|
41
49
|
// Procedure Definitions
|
|
42
50
|
// =============================================================================
|
|
@@ -50,6 +58,7 @@ const cueInitProcedure = createProcedure()
|
|
|
50
58
|
calls: ["fs.exists", "fs.read", "fs.write", "fs.mkdir"],
|
|
51
59
|
// With `force`, it overwrites dependencies.json. A second call writes the same preset again.
|
|
52
60
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
61
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
53
62
|
args: [],
|
|
54
63
|
shorts: { preset: "p", force: "f", cwd: "C" },
|
|
55
64
|
output: "json",
|
|
@@ -68,6 +77,7 @@ const cueAddProcedure = createProcedure()
|
|
|
68
77
|
calls: ["fs.exists", "fs.read", "fs.write"],
|
|
69
78
|
// It writes dependencies.json again with only `$schema` and `dependencies`. Other fields go.
|
|
70
79
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
80
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
71
81
|
args: ["feature"],
|
|
72
82
|
shorts: { cwd: "C" },
|
|
73
83
|
output: "json",
|
|
@@ -85,6 +95,7 @@ const cueRemoveProcedure = createProcedure()
|
|
|
85
95
|
description: "Remove a feature from dependencies.json",
|
|
86
96
|
calls: ["fs.exists", "fs.read", "fs.write"],
|
|
87
97
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
98
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
88
99
|
args: ["feature"],
|
|
89
100
|
shorts: { cwd: "C" },
|
|
90
101
|
output: "json",
|
|
@@ -104,6 +115,7 @@ const cueGenerateProcedure = createProcedure()
|
|
|
104
115
|
// The cue program evaluates the CUE files of @mark1russell7/cue, not code of the project.
|
|
105
116
|
// The procedure rewrites package.json, tsconfig.json and .gitignore.
|
|
106
117
|
effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
|
|
118
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
107
119
|
args: [],
|
|
108
120
|
shorts: { cwd: "C" },
|
|
109
121
|
output: "json",
|
|
@@ -121,6 +133,7 @@ const cueValidateProcedure = createProcedure()
|
|
|
121
133
|
description: "Validate dependencies.json",
|
|
122
134
|
calls: ["fs.exists", "fs.read"],
|
|
123
135
|
effects: { reads: ["fs"], writes: [] },
|
|
136
|
+
fsRoot: CUE_IN_A_ROOT,
|
|
124
137
|
args: [],
|
|
125
138
|
shorts: { cwd: "C" },
|
|
126
139
|
output: "json",
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* cue.generate procedure
|
|
3
3
|
*
|
|
4
4
|
* Generate config files (package.json, tsconfig.json, .gitignore).
|
|
5
|
-
* Uses ctx.client.call() for
|
|
6
|
-
* Runs the cue program through runCommand of client-shell (async, no shell)
|
|
5
|
+
* Uses ctx.client.call() for the files of the project (dogfooding).
|
|
6
|
+
* Runs the cue program through runCommand of client-shell (async, no shell), in a folder of the
|
|
7
|
+
* installed cue package, with the CUE files of that package only. The program reads no path of
|
|
8
|
+
* the call, so a root of the host (roadmap R33) confines only the folder of the project.
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
import { resolve } from "node:path";
|
|
@@ -19,6 +21,7 @@ import {
|
|
|
19
21
|
featureToFieldName,
|
|
20
22
|
packageRoot,
|
|
21
23
|
fileExists,
|
|
24
|
+
installedFileExists,
|
|
22
25
|
readJson,
|
|
23
26
|
writeJson,
|
|
24
27
|
writeFile,
|
|
@@ -55,7 +58,7 @@ async function generatePackageJson(
|
|
|
55
58
|
for (const feature of resolvedFeatures) {
|
|
56
59
|
const fieldName = featureToFieldName(feature);
|
|
57
60
|
const cuePath = resolve(configDir, `${fieldName}.cue`);
|
|
58
|
-
if (await
|
|
61
|
+
if (await installedFileExists(cuePath)) {
|
|
59
62
|
files.push(`${fieldName}.cue`);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
@@ -111,7 +114,7 @@ async function generateGitignore(
|
|
|
111
114
|
const files: string[] = ["base.cue"];
|
|
112
115
|
for (const feature of resolvedFeatures) {
|
|
113
116
|
const cuePath = resolve(configDir, `${feature}.cue`);
|
|
114
|
-
if (await
|
|
117
|
+
if (await installedFileExists(cuePath)) {
|
|
115
118
|
files.push(`${feature}.cue`);
|
|
116
119
|
}
|
|
117
120
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Uses ctx.client.call() for file system operations (dogfooding).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { resolve } from "node:path";
|
|
8
|
+
import { dirname, resolve } from "node:path";
|
|
9
9
|
import type { ProcedureContext } from "@procedures/client";
|
|
10
10
|
import type { CueValidateInput, CueValidateOutput } from "../../types.js";
|
|
11
11
|
import {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
checkCue,
|
|
15
15
|
runCue,
|
|
16
16
|
packageRoot,
|
|
17
|
-
|
|
17
|
+
installedFileExists,
|
|
18
18
|
} from "../../shared.js";
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -69,9 +69,11 @@ export async function cueValidate(
|
|
|
69
69
|
// If CUE is available, validate against schema
|
|
70
70
|
if (await checkCue(ctx.signal)) {
|
|
71
71
|
const schemaPath = resolve(packageRoot, "dependencies/schema.cue");
|
|
72
|
-
if (await
|
|
72
|
+
if (await installedFileExists(schemaPath)) {
|
|
73
73
|
const depsPath = resolve(projectPath, "dependencies.json");
|
|
74
|
-
|
|
74
|
+
// cue runs in the folder of the schema: a folder of the installed cue package, not the
|
|
75
|
+
// working folder of the host (roadmap R33)
|
|
76
|
+
const result = await runCue(["vet", "-d", "#Dependencies", schemaPath, depsPath], { cwd: dirname(schemaPath), signal: ctx.signal });
|
|
75
77
|
|
|
76
78
|
if (!result.success) {
|
|
77
79
|
errors.push(`CUE schema validation failed: ${result.stderr || result.stdout}`);
|
package/src/shared.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared utilities for cue procedures
|
|
3
3
|
*
|
|
4
|
-
* Uses ctx.client.call() for
|
|
4
|
+
* Uses ctx.client.call() for the files of the project (dogfooding). The files of the installed
|
|
5
|
+
* cue package are read with `node:fs` (see `loadFeatures`).
|
|
5
6
|
*
|
|
6
7
|
* A file operation that fails is an error of the call. Only a missing file is a normal result.
|
|
7
8
|
* (Before, each helper turned every error into "missing": with no fs.* procedures in the host,
|
|
8
9
|
* cue.validate answered "No dependencies.json found", deep dive WRP-3.)
|
|
9
10
|
*/
|
|
10
11
|
|
|
12
|
+
import { access, readFile as readInstalledFile } from "node:fs/promises";
|
|
11
13
|
import { createRequire } from "node:module";
|
|
12
14
|
import { dirname, resolve } from "node:path";
|
|
13
15
|
import type { ProcedureContext } from "@procedures/client";
|
|
@@ -118,9 +120,42 @@ export async function writeJson<T>(path: string, data: T, ctx: ProcedureContext)
|
|
|
118
120
|
// Core Functions
|
|
119
121
|
// =============================================================================
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
// =============================================================================
|
|
124
|
+
// The files of the installed cue package
|
|
125
|
+
// =============================================================================
|
|
126
|
+
|
|
127
|
+
// The files of `@mark1russell7/cue` (features.json and its CUE files) are a part of the
|
|
128
|
+
// procedures, as their code is. The procedures read them with `node:fs`, not through `fs.*`. A
|
|
129
|
+
// root of the host (roadmap R33) confines the paths of the project, and these files are outside it.
|
|
130
|
+
|
|
131
|
+
/** True when a file of the installed cue package exists. */
|
|
132
|
+
export async function installedFileExists(path: string): Promise<boolean> {
|
|
133
|
+
try {
|
|
134
|
+
await access(path);
|
|
135
|
+
return true;
|
|
136
|
+
} catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The feature manifest of the installed cue package, or null when it is missing. Text that is not
|
|
143
|
+
* JSON throws. `root` is the folder of the package: a test gives another folder.
|
|
144
|
+
*/
|
|
145
|
+
export async function loadFeatures(_ctx?: ProcedureContext, root: string = packageRoot): Promise<FeaturesManifest | null> {
|
|
146
|
+
const featuresPath = resolve(root, "features.json");
|
|
147
|
+
let content: string;
|
|
148
|
+
try {
|
|
149
|
+
content = await readInstalledFile(featuresPath, "utf8");
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return null;
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
return JSON.parse(content) as FeaturesManifest;
|
|
156
|
+
} catch (error) {
|
|
157
|
+
throw new Error(`${featuresPath} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
158
|
+
}
|
|
124
159
|
}
|
|
125
160
|
|
|
126
161
|
export async function loadDependencies(
|