@gaganref/confect-cli 10.3.1-fork.52 → 10.3.1-fork.53
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/dist/SectionFiles.mjs +17 -5
- package/dist/SectionFiles.mjs.map +1 -1
- package/package.json +3 -3
package/dist/SectionFiles.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { fromBundlerError } from "./BuildError.mjs";
|
|
2
|
+
import { logFileRemoved } from "./log.mjs";
|
|
2
3
|
import { bundle } from "./Bundler.mjs";
|
|
3
4
|
import { InvalidManifestSectionError, logCodegenError } from "./CodegenError.mjs";
|
|
4
5
|
import { ConfectDirectory } from "./ConfectDirectory.mjs";
|
|
5
|
-
import { toPosixPath, writeFileStringAndLog } from "./utils.mjs";
|
|
6
|
+
import { removePathIfExists, toPosixPath, writeFileStringAndLog } from "./utils.mjs";
|
|
6
7
|
import * as Effect from "effect/Effect";
|
|
7
8
|
import * as FileSystem from "effect/FileSystem";
|
|
8
9
|
import * as Path from "effect/Path";
|
|
@@ -16,7 +17,8 @@ import * as Schema from "effect/Schema";
|
|
|
16
17
|
const builtIn = new Set(`spec schema convexSchema id components component refs docs services manifest
|
|
17
18
|
auth.providers testing api nodeApi impl nodeImpl nodeSpec registeredFunctions
|
|
18
19
|
nodeRegisteredFunctions`.split(/\s+/).map((name) => `${name}.ts`));
|
|
19
|
-
const
|
|
20
|
+
const PREFIX = "// Generated by `confect codegen` from the manifest section ";
|
|
21
|
+
const header = (key) => `${PREFIX}${JSON.stringify(key)}. Do not edit.`;
|
|
20
22
|
const encodeSources = Schema.encodeSync(Schema.fromJsonString(Schema.Array(Schema.String)));
|
|
21
23
|
const visit = (leaves, each) => {
|
|
22
24
|
const walk = (group, path, source) => {
|
|
@@ -92,10 +94,12 @@ const render = Effect.fnUntraced(function* ({ key, generate }, input, files) {
|
|
|
92
94
|
});
|
|
93
95
|
/**
|
|
94
96
|
* Write each claimed file into `confect/_generated` once every section has
|
|
95
|
-
* rendered
|
|
96
|
-
*
|
|
97
|
+
* rendered, and remove a file a section wrote that no section claims any more.
|
|
98
|
+
* Every section renders before codegen fails with the first error after logging
|
|
99
|
+
* the rest. Returns the claimed file names.
|
|
97
100
|
*/
|
|
98
101
|
const sync = Effect.fnUntraced(function* (leaves, mounts) {
|
|
102
|
+
const fs = yield* FileSystem.FileSystem;
|
|
99
103
|
const path = yield* Path.Path;
|
|
100
104
|
const generated = path.join(yield* ConfectDirectory.get, "_generated");
|
|
101
105
|
const claimed = yield* Effect.fromResult(claims(leaves));
|
|
@@ -116,7 +120,15 @@ const sync = Effect.fnUntraced(function* (leaves, mounts) {
|
|
|
116
120
|
for (const other of more) yield* logCodegenError(other);
|
|
117
121
|
if (error !== void 0) return yield* error;
|
|
118
122
|
for (const { file, contents } of rendered) yield* writeFileStringAndLog(path.join(generated, file), contents);
|
|
119
|
-
|
|
123
|
+
const names = rendered.map(({ file }) => file);
|
|
124
|
+
for (const file of yield* fs.readDirectory(generated)) {
|
|
125
|
+
const absolutePath = path.join(generated, file);
|
|
126
|
+
if (file.endsWith(".ts") && !names.includes(file) && (yield* fs.readFileString(absolutePath)).startsWith(PREFIX)) {
|
|
127
|
+
yield* removePathIfExists(absolutePath);
|
|
128
|
+
yield* logFileRemoved(absolutePath);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return names;
|
|
120
132
|
});
|
|
121
133
|
//#endregion
|
|
122
134
|
export { builtIn, claims, sync };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionFiles.mjs","names":["Bundler.bundle"],"sources":["../src/SectionFiles.ts"],"sourcesContent":["import type { FunctionSpec, GroupSpec, ManifestSection } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"./BuildError.js\";\nimport * as Bundler from \"./Bundler.js\";\nimport {\n InvalidManifestSectionError,\n logCodegenError,\n} from \"./CodegenError.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport type { LoadedLeafModule } from \"./LeafModule.js\";\nimport { toPosixPath, writeFileStringAndLog } from \"./utils.js\";\n\ntype Leaf = Pick<LoadedLeafModule, \"spec\" | \"pathSegments\" | \"relativePath\">;\n\n/**\n * The files codegen writes directly in `confect/_generated`, current and\n * legacy, which no section may claim.\n */\nexport const builtIn: ReadonlySet<string> = new Set(\n `spec schema convexSchema id components component refs docs services manifest\n auth.providers testing api nodeApi impl nodeImpl nodeSpec registeredFunctions\n nodeRegisteredFunctions`\n .split(/\\s+/)\n .map((name) => `${name}.ts`),\n);\n\nconst header = (key: string) =>\n `// Generated by \\`confect codegen\\` from the manifest section ${JSON.stringify(key)}. Do not edit.`;\nconst encodeSources = Schema.encodeSync(\n Schema.fromJsonString(Schema.Array(Schema.String)),\n);\n\ninterface Claim {\n readonly key: string;\n readonly generate: ManifestSection.Generate;\n}\n\nconst visit = (\n leaves: ReadonlyArray<Leaf>,\n each: (spec: FunctionSpec.AnyWithProps, path: string, source: string) => void,\n) => {\n const walk = (\n group: GroupSpec.AnyWithProps,\n path: string,\n source: string,\n ) => {\n for (const spec of Object.values(group.functions))\n each(spec, `${path}:${spec.name}`, source);\n for (const [name, child] of Object.entries(group.groups))\n walk(child, `${path}/${name}`, source);\n };\n for (const leaf of leaves)\n walk(leaf.spec, leaf.pathSegments.join(\"/\"), leaf.relativePath);\n};\n\n/**\n * One claim per section key that generates a file, ordered by file. A name that\n * is built in, not a `.ts` file directly in `_generated`, or claimed by two\n * keys is refused.\n */\nexport const claims = (leaves: ReadonlyArray<Leaf>) =>\n Result.gen(function* () {\n const byKey = new Map<string, ManifestSection.Generate>();\n visit(leaves, (spec) => {\n for (const { key, section } of spec.manifestSections ?? [])\n if (section.generate !== undefined && !byKey.has(key))\n byKey.set(key, section.generate);\n });\n const byFile = new Map<string, string>();\n for (const [key, { file }] of byKey) {\n const other = byFile.get(file);\n const refusal = builtIn.has(file)\n ? `claims confect/_generated/${file}, which codegen writes itself.`\n : !/^[\\w-]+\\.ts$/.test(file)\n ? `claims ${JSON.stringify(file)}; name a .ts file directly inside confect/_generated.`\n : other !== undefined\n ? `claims confect/_generated/${file}, which the manifest section ${JSON.stringify(other)} also claims.`\n : undefined;\n if (refusal !== undefined)\n return yield* Result.fail(\n new InvalidManifestSectionError({ sectionKey: key, reason: refusal }),\n );\n byFile.set(file, key);\n }\n return [...byKey]\n .map(([key, generate]) => ({ key, generate }))\n .sort((a, b) => a.generate.file.localeCompare(b.generate.file));\n });\n\nconst sourceFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n return (yield* fs.readDirectory(confectDirectory, { recursive: true }))\n .map((file) => toPosixPath(path, file))\n .filter(\n (file) =>\n file.endsWith(\".ts\") &&\n !file.endsWith(\".d.ts\") &&\n !file.split(\"/\").includes(\"_generated\"),\n )\n .sort();\n});\n\nconst render = Effect.fnUntraced(function* (\n { key, generate }: Claim,\n input: Omit<ManifestSection.GenerateInput, \"modules\">,\n files: ReadonlyArray<string>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const failed = (cause: unknown) =>\n new InvalidManifestSectionError({\n sectionKey: key,\n reason: `generate failed: ${String(cause)}`,\n });\n const matched = yield* Effect.try({\n try: () => files.filter((file) => generate.match(file)),\n catch: failed,\n });\n const modules = yield* Effect.forEach(matched, (relativePath) =>\n Bundler.bundle(path.join(confectDirectory, relativePath)).pipe(\n Effect.map(({ module }) => ({ relativePath, exports: module })),\n Effect.mapError((error) =>\n fromBundlerError(`confect/${relativePath}`, error),\n ),\n ),\n );\n const { contents, errors } = yield* Effect.try({\n try: () => generate.render({ ...input, modules }),\n catch: failed,\n });\n const [error, ...more] = errors.map(\n (reason) => new InvalidManifestSectionError({ sectionKey: key, reason }),\n );\n for (const other of more) yield* logCodegenError(other);\n if (error !== undefined) return yield* error;\n return [header(key), `// Sources: ${encodeSources(matched)}`, contents].join(\n \"\\n\",\n );\n});\n\n/**\n * Write each claimed file into `confect/_generated` once every section has\n * rendered. Every section renders before codegen fails with the first error\n * after logging the rest. Returns the claimed file names.\n */\nexport const sync = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<Leaf>,\n mounts: ManifestSection.GenerateInput[\"mounts\"],\n) {\n const path = yield* Path.Path;\n const generated = path.join(yield* ConfectDirectory.get, \"_generated\");\n const claimed = yield* Effect.fromResult(claims(leaves));\n const functions: Array<{ path: string; source: string }> = [];\n visit(leaves, (_, functionPath, source) =>\n functions.push({ path: functionPath, source }),\n );\n const files = claimed.length === 0 ? [] : yield* sourceFiles;\n const [rendered, failures] = yield* Effect.partition(claimed, (claim) =>\n render(claim, { functions, mounts }, files).pipe(\n Effect.map((contents) => ({ file: claim.generate.file, contents })),\n ),\n );\n const [error, ...more] = failures;\n for (const other of more) yield* logCodegenError(other);\n if (error !== undefined) return yield* error;\n for (const { file, contents } of rendered)\n yield* writeFileStringAndLog(path.join(generated, file), contents);\n return rendered.map(({ file }) => file);\n});\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAa,UAA+B,IAAI,IAC9C;;2BAGG,MAAM,KAAK,CAAC,CACZ,KAAK,SAAS,GAAG,KAAK,IAAI,CAC/B;AAEA,MAAM,UAAU,QACd,iEAAiE,KAAK,UAAU,GAAG,EAAE;AACvF,MAAM,gBAAgB,OAAO,WAC3B,OAAO,eAAe,OAAO,MAAM,OAAO,MAAM,CAAC,CACnD;AAOA,MAAM,SACJ,QACA,SACG;CACH,MAAM,QACJ,OACA,MACA,WACG;EACH,KAAK,MAAM,QAAQ,OAAO,OAAO,MAAM,SAAS,GAC9C,KAAK,MAAM,GAAG,KAAK,GAAG,KAAK,QAAQ,MAAM;EAC3C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,MAAM,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F;AACF,CAAC;;;;;;AAOD,MAAa,OAAO,OAAO,WAAW,WACpC,QACA,QACA;CACA,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,YAAY,KAAK,KAAK,OAAO,iBAAiB,KAAK,YAAY;CACrE,MAAM,UAAU,OAAO,OAAO,WAAW,OAAO,MAAM,CAAC;CACvD,MAAM,YAAqD,CAAC;CAC5D,MAAM,SAAS,GAAG,cAAc,WAC9B,UAAU,KAAK;EAAE,MAAM;EAAc;CAAO,CAAC,CAC/C;CACA,MAAM,QAAQ,QAAQ,WAAW,IAAI,CAAC,IAAI,OAAO;CACjD,MAAM,CAAC,UAAU,YAAY,OAAO,OAAO,UAAU,UAAU,UAC7D,OAAO,OAAO;EAAE;EAAW;CAAO,GAAG,KAAK,CAAC,CAAC,KAC1C,OAAO,KAAK,cAAc;EAAE,MAAM,MAAM,SAAS;EAAM;CAAS,EAAE,CACpE,CACF;CACA,MAAM,CAAC,OAAO,GAAG,QAAQ;CACzB,KAAK,MAAM,SAAS,MAAM,OAAO,gBAAgB,KAAK;CACtD,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO;CACvC,KAAK,MAAM,EAAE,MAAM,cAAc,UAC/B,OAAO,sBAAsB,KAAK,KAAK,WAAW,IAAI,GAAG,QAAQ;CACnE,OAAO,SAAS,KAAK,EAAE,WAAW,IAAI;AACxC,CAAC"}
|
|
1
|
+
{"version":3,"file":"SectionFiles.mjs","names":["Bundler.bundle"],"sources":["../src/SectionFiles.ts"],"sourcesContent":["import type { FunctionSpec, GroupSpec, ManifestSection } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"./BuildError.js\";\nimport * as Bundler from \"./Bundler.js\";\nimport {\n InvalidManifestSectionError,\n logCodegenError,\n} from \"./CodegenError.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport type { LoadedLeafModule } from \"./LeafModule.js\";\nimport { logFileRemoved } from \"./log.js\";\nimport {\n removePathIfExists,\n toPosixPath,\n writeFileStringAndLog,\n} from \"./utils.js\";\n\ntype Leaf = Pick<LoadedLeafModule, \"spec\" | \"pathSegments\" | \"relativePath\">;\n\n/**\n * The files codegen writes directly in `confect/_generated`, current and\n * legacy, which no section may claim.\n */\nexport const builtIn: ReadonlySet<string> = new Set(\n `spec schema convexSchema id components component refs docs services manifest\n auth.providers testing api nodeApi impl nodeImpl nodeSpec registeredFunctions\n nodeRegisteredFunctions`\n .split(/\\s+/)\n .map((name) => `${name}.ts`),\n);\n\nconst PREFIX = \"// Generated by `confect codegen` from the manifest section \";\nconst header = (key: string) => `${PREFIX}${JSON.stringify(key)}. Do not edit.`;\nconst encodeSources = Schema.encodeSync(\n Schema.fromJsonString(Schema.Array(Schema.String)),\n);\n\ninterface Claim {\n readonly key: string;\n readonly generate: ManifestSection.Generate;\n}\n\nconst visit = (\n leaves: ReadonlyArray<Leaf>,\n each: (spec: FunctionSpec.AnyWithProps, path: string, source: string) => void,\n) => {\n const walk = (\n group: GroupSpec.AnyWithProps,\n path: string,\n source: string,\n ) => {\n for (const spec of Object.values(group.functions))\n each(spec, `${path}:${spec.name}`, source);\n for (const [name, child] of Object.entries(group.groups))\n walk(child, `${path}/${name}`, source);\n };\n for (const leaf of leaves)\n walk(leaf.spec, leaf.pathSegments.join(\"/\"), leaf.relativePath);\n};\n\n/**\n * One claim per section key that generates a file, ordered by file. A name that\n * is built in, not a `.ts` file directly in `_generated`, or claimed by two\n * keys is refused.\n */\nexport const claims = (leaves: ReadonlyArray<Leaf>) =>\n Result.gen(function* () {\n const byKey = new Map<string, ManifestSection.Generate>();\n visit(leaves, (spec) => {\n for (const { key, section } of spec.manifestSections ?? [])\n if (section.generate !== undefined && !byKey.has(key))\n byKey.set(key, section.generate);\n });\n const byFile = new Map<string, string>();\n for (const [key, { file }] of byKey) {\n const other = byFile.get(file);\n const refusal = builtIn.has(file)\n ? `claims confect/_generated/${file}, which codegen writes itself.`\n : !/^[\\w-]+\\.ts$/.test(file)\n ? `claims ${JSON.stringify(file)}; name a .ts file directly inside confect/_generated.`\n : other !== undefined\n ? `claims confect/_generated/${file}, which the manifest section ${JSON.stringify(other)} also claims.`\n : undefined;\n if (refusal !== undefined)\n return yield* Result.fail(\n new InvalidManifestSectionError({ sectionKey: key, reason: refusal }),\n );\n byFile.set(file, key);\n }\n return [...byKey]\n .map(([key, generate]) => ({ key, generate }))\n .sort((a, b) => a.generate.file.localeCompare(b.generate.file));\n });\n\nconst sourceFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n return (yield* fs.readDirectory(confectDirectory, { recursive: true }))\n .map((file) => toPosixPath(path, file))\n .filter(\n (file) =>\n file.endsWith(\".ts\") &&\n !file.endsWith(\".d.ts\") &&\n !file.split(\"/\").includes(\"_generated\"),\n )\n .sort();\n});\n\nconst render = Effect.fnUntraced(function* (\n { key, generate }: Claim,\n input: Omit<ManifestSection.GenerateInput, \"modules\">,\n files: ReadonlyArray<string>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const failed = (cause: unknown) =>\n new InvalidManifestSectionError({\n sectionKey: key,\n reason: `generate failed: ${String(cause)}`,\n });\n const matched = yield* Effect.try({\n try: () => files.filter((file) => generate.match(file)),\n catch: failed,\n });\n const modules = yield* Effect.forEach(matched, (relativePath) =>\n Bundler.bundle(path.join(confectDirectory, relativePath)).pipe(\n Effect.map(({ module }) => ({ relativePath, exports: module })),\n Effect.mapError((error) =>\n fromBundlerError(`confect/${relativePath}`, error),\n ),\n ),\n );\n const { contents, errors } = yield* Effect.try({\n try: () => generate.render({ ...input, modules }),\n catch: failed,\n });\n const [error, ...more] = errors.map(\n (reason) => new InvalidManifestSectionError({ sectionKey: key, reason }),\n );\n for (const other of more) yield* logCodegenError(other);\n if (error !== undefined) return yield* error;\n return [header(key), `// Sources: ${encodeSources(matched)}`, contents].join(\n \"\\n\",\n );\n});\n\n/**\n * Write each claimed file into `confect/_generated` once every section has\n * rendered, and remove a file a section wrote that no section claims any more.\n * Every section renders before codegen fails with the first error after logging\n * the rest. Returns the claimed file names.\n */\nexport const sync = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<Leaf>,\n mounts: ManifestSection.GenerateInput[\"mounts\"],\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const generated = path.join(yield* ConfectDirectory.get, \"_generated\");\n const claimed = yield* Effect.fromResult(claims(leaves));\n const functions: Array<{ path: string; source: string }> = [];\n visit(leaves, (_, functionPath, source) =>\n functions.push({ path: functionPath, source }),\n );\n const files = claimed.length === 0 ? [] : yield* sourceFiles;\n const [rendered, failures] = yield* Effect.partition(claimed, (claim) =>\n render(claim, { functions, mounts }, files).pipe(\n Effect.map((contents) => ({ file: claim.generate.file, contents })),\n ),\n );\n const [error, ...more] = failures;\n for (const other of more) yield* logCodegenError(other);\n if (error !== undefined) return yield* error;\n for (const { file, contents } of rendered)\n yield* writeFileStringAndLog(path.join(generated, file), contents);\n const names = rendered.map(({ file }) => file);\n for (const file of yield* fs.readDirectory(generated)) {\n const absolutePath = path.join(generated, file);\n if (\n file.endsWith(\".ts\") &&\n !names.includes(file) &&\n (yield* fs.readFileString(absolutePath)).startsWith(PREFIX)\n ) {\n yield* removePathIfExists(absolutePath);\n yield* logFileRemoved(absolutePath);\n }\n }\n return names;\n});\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAa,UAA+B,IAAI,IAC9C;;2BAGG,MAAM,KAAK,CAAC,CACZ,KAAK,SAAS,GAAG,KAAK,IAAI,CAC/B;AAEA,MAAM,SAAS;AACf,MAAM,UAAU,QAAgB,GAAG,SAAS,KAAK,UAAU,GAAG,EAAE;AAChE,MAAM,gBAAgB,OAAO,WAC3B,OAAO,eAAe,OAAO,MAAM,OAAO,MAAM,CAA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AK,KACnB,CAAC,MAAM,SAAS,IAAI,MACnB,OAAO,GAAG,eAAe,YAAY,EAAA,CAAG,WAAW,MAAM,GAC1D;GACA,OAAO,mBAAmB,YAAY;GACtC,OAAO,eAAe,YAAY;EACpC;CACF;CACA,OAAO;AACT,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaganref/confect-cli",
|
|
3
|
-
"version": "10.3.1-fork.
|
|
3
|
+
"version": "10.3.1-fork.53",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@effect/platform-node": ">=4.0.4 <4.1.0",
|
|
6
6
|
"bundle-require": "^5.1.0",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"exsolve": "^1.1.3"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.
|
|
13
|
-
"@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.
|
|
12
|
+
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.53",
|
|
13
|
+
"@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.53",
|
|
14
14
|
"@effect/platform-node-shared": ">=4.0.4 <4.1.0",
|
|
15
15
|
"effect": ">=4.0.4 <4.1.0"
|
|
16
16
|
},
|