@confect/cli 9.0.0-next.7 → 9.0.0-next.9
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 +60 -0
- package/dist/BuildError.mjs +9 -2
- package/dist/BuildError.mjs.map +1 -1
- package/dist/Bundler.mjs +5 -2
- package/dist/Bundler.mjs.map +1 -1
- package/dist/CodeBlockWriter.mjs +1 -1
- package/dist/CodeBlockWriter.mjs.map +1 -1
- package/dist/CodegenError.mjs +10 -15
- package/dist/CodegenError.mjs.map +1 -1
- package/dist/ConfectDirectory.mjs +5 -2
- package/dist/ConfectDirectory.mjs.map +1 -1
- package/dist/ConvexDirectory.mjs +6 -2
- package/dist/ConvexDirectory.mjs.map +1 -1
- package/dist/FunctionPath.mjs +1 -1
- package/dist/FunctionPath.mjs.map +1 -1
- package/dist/FunctionPaths.mjs +5 -1
- package/dist/FunctionPaths.mjs.map +1 -1
- package/dist/GroupPath.mjs +9 -2
- package/dist/GroupPath.mjs.map +1 -1
- package/dist/GroupPaths.mjs +1 -1
- package/dist/GroupPaths.mjs.map +1 -1
- package/dist/LeafModule.mjs +17 -24
- package/dist/LeafModule.mjs.map +1 -1
- package/dist/ProjectRoot.mjs +8 -3
- package/dist/ProjectRoot.mjs.map +1 -1
- package/dist/SpecAssemblyNode.mjs +6 -9
- package/dist/SpecAssemblyNode.mjs.map +1 -1
- package/dist/TableModule.mjs +6 -2
- package/dist/TableModule.mjs.map +1 -1
- package/dist/cliApp.mjs +1 -1
- package/dist/cliApp.mjs.map +1 -1
- package/dist/confect/codegen.mjs +36 -72
- package/dist/confect/codegen.mjs.map +1 -1
- package/dist/confect/dev.mjs +24 -7
- package/dist/confect/dev.mjs.map +1 -1
- package/dist/confect.mjs +2 -2
- package/dist/confect.mjs.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/log.mjs +7 -3
- package/dist/log.mjs.map +1 -1
- package/dist/package.mjs +1 -1
- package/dist/templates.mjs +8 -15
- package/dist/templates.mjs.map +1 -1
- package/dist/utils.mjs +42 -22
- package/dist/utils.mjs.map +1 -1
- package/package.json +3 -3
- package/src/BuildError.ts +9 -2
- package/src/Bundler.ts +5 -2
- package/src/CodeBlockWriter.ts +1 -1
- package/src/CodegenError.ts +7 -38
- package/src/ConfectDirectory.ts +5 -2
- package/src/ConvexDirectory.ts +6 -2
- package/src/FunctionPath.ts +1 -1
- package/src/FunctionPaths.ts +5 -1
- package/src/GroupPath.ts +9 -11
- package/src/GroupPaths.ts +1 -1
- package/src/LeafModule.ts +24 -36
- package/src/ProjectRoot.ts +8 -3
- package/src/SpecAssemblyNode.ts +5 -14
- package/src/TableModule.ts +6 -2
- package/src/cliApp.ts +1 -1
- package/src/confect/codegen.ts +54 -108
- package/src/confect/dev.ts +24 -29
- package/src/confect.ts +2 -2
- package/src/index.ts +3 -2
- package/src/log.ts +7 -3
- package/src/templates.ts +11 -28
- package/src/utils.ts +47 -41
package/src/utils.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import type { FunctionSpec, Spec } from "@confect/core";
|
|
2
|
-
import
|
|
2
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
3
|
+
import * as Path from "@effect/platform/Path";
|
|
3
4
|
import type { PlatformError } from "@effect/platform/Error";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
String,
|
|
15
|
-
} from "effect";
|
|
5
|
+
import { pipe } from "effect/Function";
|
|
6
|
+
import * as Array from "effect/Array";
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as HashSet from "effect/HashSet";
|
|
10
|
+
import * as Option from "effect/Option";
|
|
11
|
+
import * as Order from "effect/Order";
|
|
12
|
+
import * as Record from "effect/Record";
|
|
13
|
+
import * as Ref from "effect/Ref";
|
|
14
|
+
import * as String from "effect/String";
|
|
16
15
|
import * as FunctionPaths from "./FunctionPaths";
|
|
17
16
|
import * as GroupPath from "./GroupPath";
|
|
18
17
|
import * as GroupPaths from "./GroupPaths";
|
|
@@ -197,6 +196,35 @@ export const generateGroupModule = ({
|
|
|
197
196
|
return "Unchanged" as const;
|
|
198
197
|
});
|
|
199
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Compute the module import specifier (relative to `modulePath`) for a group's
|
|
201
|
+
* registry file under `confect/_generated/registeredFunctions/`. The registry
|
|
202
|
+
* path mirrors the group's path one-to-one (see `registeredFunctionsRelativePath`
|
|
203
|
+
* in `LeafModule.ts`) for both Convex and Node groups. Centralizing this here
|
|
204
|
+
* keeps the "overlapping" and "new" group branches of `generateFunctions` from
|
|
205
|
+
* drifting apart.
|
|
206
|
+
*/
|
|
207
|
+
const registeredFunctionsImportPathForGroup = (
|
|
208
|
+
groupPath: GroupPath.GroupPath,
|
|
209
|
+
modulePath: string,
|
|
210
|
+
) =>
|
|
211
|
+
Effect.gen(function* () {
|
|
212
|
+
const path = yield* Path.Path;
|
|
213
|
+
const confectDirectory = yield* ConfectDirectory.get;
|
|
214
|
+
|
|
215
|
+
const registeredFunctionsPath =
|
|
216
|
+
path.join(
|
|
217
|
+
confectDirectory,
|
|
218
|
+
"_generated",
|
|
219
|
+
"registeredFunctions",
|
|
220
|
+
...groupPath.pathSegments,
|
|
221
|
+
) + ".ts";
|
|
222
|
+
|
|
223
|
+
return yield* toModuleImportPath(
|
|
224
|
+
path.relative(path.dirname(modulePath), registeredFunctionsPath),
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
|
|
200
228
|
const logGroupPaths = <R>(
|
|
201
229
|
groupPaths: GroupPaths.GroupPaths,
|
|
202
230
|
logFn: (fullPath: string) => Effect.Effect<void, never, R>,
|
|
@@ -217,7 +245,6 @@ export const generateFunctions = (spec: Spec.AnyWithProps) =>
|
|
|
217
245
|
Effect.gen(function* () {
|
|
218
246
|
const path = yield* Path.Path;
|
|
219
247
|
const convexDirectory = yield* ConvexDirectory.get;
|
|
220
|
-
const confectDirectory = yield* ConfectDirectory.get;
|
|
221
248
|
|
|
222
249
|
const groupPathsFromFs = yield* getGroupPathsFromFs;
|
|
223
250
|
const functionPaths = FunctionPaths.make(spec);
|
|
@@ -242,25 +269,13 @@ export const generateFunctions = (spec: Spec.AnyWithProps) =>
|
|
|
242
269
|
);
|
|
243
270
|
const relativeModulePath = yield* GroupPath.modulePath(groupPath);
|
|
244
271
|
const modulePath = path.join(convexDirectory, relativeModulePath);
|
|
245
|
-
const
|
|
246
|
-
groupPath
|
|
247
|
-
? groupPath.pathSegments.slice(1)
|
|
248
|
-
: groupPath.pathSegments;
|
|
249
|
-
const registeredFunctionsPath =
|
|
250
|
-
path.join(
|
|
251
|
-
confectDirectory,
|
|
252
|
-
"_generated",
|
|
253
|
-
"registeredFunctions",
|
|
254
|
-
...registrySegments,
|
|
255
|
-
) + ".ts";
|
|
256
|
-
const registeredFunctionsImportPath = yield* toModuleImportPath(
|
|
257
|
-
path.relative(path.dirname(modulePath), registeredFunctionsPath),
|
|
258
|
-
);
|
|
272
|
+
const registeredFunctionsImportPath =
|
|
273
|
+
yield* registeredFunctionsImportPathForGroup(groupPath, modulePath);
|
|
259
274
|
const result = yield* generateGroupModule({
|
|
260
275
|
groupPath,
|
|
261
276
|
functionNames,
|
|
262
277
|
registeredFunctionsImportPath,
|
|
263
|
-
useNode:
|
|
278
|
+
useNode: group.runtime === "Node",
|
|
264
279
|
});
|
|
265
280
|
if (result === "Modified") {
|
|
266
281
|
yield* logFileModified(modulePath);
|
|
@@ -343,7 +358,6 @@ export const writeGroups = (
|
|
|
343
358
|
Effect.gen(function* () {
|
|
344
359
|
const path = yield* Path.Path;
|
|
345
360
|
const convexDirectory = yield* ConvexDirectory.get;
|
|
346
|
-
const confectDirectory = yield* ConfectDirectory.get;
|
|
347
361
|
const group = yield* GroupPath.getGroupSpec(spec, groupPath);
|
|
348
362
|
|
|
349
363
|
const functionNames = pipe(
|
|
@@ -360,23 +374,15 @@ export const writeGroups = (
|
|
|
360
374
|
|
|
361
375
|
const relativeModulePath = yield* GroupPath.modulePath(groupPath);
|
|
362
376
|
const modulePath = path.join(convexDirectory, relativeModulePath);
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
confectDirectory,
|
|
366
|
-
"_generated",
|
|
367
|
-
"registeredFunctions",
|
|
368
|
-
...groupPath.pathSegments,
|
|
369
|
-
) + ".ts";
|
|
370
|
-
const registeredFunctionsImportPath = yield* toModuleImportPath(
|
|
371
|
-
path.relative(path.dirname(modulePath), registeredFunctionsPath),
|
|
372
|
-
);
|
|
377
|
+
const registeredFunctionsImportPath =
|
|
378
|
+
yield* registeredFunctionsImportPathForGroup(groupPath, modulePath);
|
|
373
379
|
|
|
374
380
|
yield* Effect.logDebug(`Generating group ${groupPath}...`);
|
|
375
381
|
yield* generateGroupModule({
|
|
376
382
|
groupPath,
|
|
377
383
|
functionNames,
|
|
378
384
|
registeredFunctionsImportPath,
|
|
379
|
-
useNode:
|
|
385
|
+
useNode: group.runtime === "Node",
|
|
380
386
|
});
|
|
381
387
|
yield* Effect.logDebug(`Group ${groupPath} generated`);
|
|
382
388
|
}),
|