@confect/cli 1.0.0-next.1 → 1.0.0-next.2
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 +10 -0
- package/dist/FunctionPaths.mjs +3 -3
- package/dist/FunctionPaths.mjs.map +1 -1
- package/dist/cliApp.mjs +1 -1
- package/dist/confect/dev.mjs.map +1 -1
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +1 -1
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/services/ProjectRoot.mjs +2 -2
- package/dist/services/ProjectRoot.mjs.map +1 -1
- package/dist/utils.mjs +7 -7
- package/dist/utils.mjs.map +1 -1
- package/package.json +21 -18
- package/dist/_virtual/rolldown_runtime.mjs +0 -28
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeCommandExecutor.mjs +0 -12
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeCommandExecutor.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeFileSystem.mjs +0 -15
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeFileSystem.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodePath.mjs +0 -25
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodePath.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeRuntime.mjs +0 -12
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeRuntime.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeTerminal.mjs +0 -17
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeTerminal.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/commandExecutor.mjs +0 -129
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/commandExecutor.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/error.mjs +0 -43
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/error.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/fileSystem.mjs +0 -329
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/fileSystem.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/path.mjs +0 -51
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/path.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/runtime.mjs +0 -31
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/runtime.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/sink.mjs +0 -24
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/sink.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/stream.mjs +0 -91
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/stream.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/terminal.mjs +0 -75
- package/dist/node_modules/.pnpm/@effect_platform-node-shared@0.53.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/internal/terminal.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeContext.mjs +0 -21
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeContext.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeFileSystem.mjs +0 -15
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeFileSystem.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeRuntime.mjs +0 -15
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeRuntime.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeWorker.mjs +0 -27
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeWorker.mjs.map +0 -1
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/internal/worker.mjs +0 -71
- package/dist/node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/internal/worker.mjs.map +0 -1
- package/dist/packages/cli/package.mjs +0 -6
- package/dist/packages/cli/package.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @confect/cli
|
|
2
2
|
|
|
3
|
+
## 1.0.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 071b6ed: Upgrade deps
|
|
8
|
+
- Updated dependencies [071b6ed]
|
|
9
|
+
- Updated dependencies [afc9fb4]
|
|
10
|
+
- @confect/server@1.0.0-next.2
|
|
11
|
+
- @confect/core@1.0.0-next.2
|
|
12
|
+
|
|
3
13
|
## 1.0.0-next.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/FunctionPaths.mjs
CHANGED
|
@@ -7,15 +7,15 @@ import { HashSet, Option, Record, Schema, pipe } from "effect";
|
|
|
7
7
|
const FunctionPaths = Schema.HashSetFromSelf(FunctionPath).pipe(Schema.brand("@confect/cli/FunctionPaths"));
|
|
8
8
|
const make = (spec) => makeHelper(spec.groups, Option.none(), FunctionPaths.make(HashSet.empty()));
|
|
9
9
|
const makeHelper = (groups, currentGroupPath, apiPaths) => Record.reduce(groups, apiPaths, (acc, group, groupName) => {
|
|
10
|
-
const groupPath
|
|
10
|
+
const groupPath = Option.match(currentGroupPath, {
|
|
11
11
|
onNone: () => make$1([groupName]),
|
|
12
12
|
onSome: (path) => append(path, groupName)
|
|
13
13
|
});
|
|
14
14
|
const accWithFunctions = Record.reduce(group.functions, acc, (acc_, _fn, functionName) => FunctionPaths.make(HashSet.add(acc_, FunctionPath.make({
|
|
15
|
-
groupPath
|
|
15
|
+
groupPath,
|
|
16
16
|
name: functionName
|
|
17
17
|
}))));
|
|
18
|
-
return makeHelper(group.groups, Option.some(groupPath
|
|
18
|
+
return makeHelper(group.groups, Option.some(groupPath), accWithFunctions);
|
|
19
19
|
});
|
|
20
20
|
const groupPaths = (functionPaths) => pipe(functionPaths, HashSet.map(groupPath), GroupPaths.make);
|
|
21
21
|
const diff = (previousFunctions, currentFunctions) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionPaths.mjs","names":["FunctionPath.FunctionPath","
|
|
1
|
+
{"version":3,"file":"FunctionPaths.mjs","names":["FunctionPath.FunctionPath","GroupPath.make","GroupPath.append","FunctionPath.groupPath"],"sources":["../src/FunctionPaths.ts"],"sourcesContent":["import type { GroupSpec, Spec } from \"@confect/core\";\nimport { HashSet, Option, pipe, Record, Schema } from \"effect\";\nimport * as FunctionPath from \"./FunctionPath\";\nimport * as GroupPath from \"./GroupPath\";\nimport * as GroupPaths from \"./GroupPaths\";\n\nexport const FunctionPaths = Schema.HashSetFromSelf(\n FunctionPath.FunctionPath,\n).pipe(Schema.brand(\"@confect/cli/FunctionPaths\"));\nexport type FunctionPaths = typeof FunctionPaths.Type;\n\nexport const make = (spec: Spec.AnyWithProps): FunctionPaths =>\n makeHelper(spec.groups, Option.none(), FunctionPaths.make(HashSet.empty()));\n\nconst makeHelper = (\n groups: {\n [key: string]: GroupSpec.AnyWithProps;\n },\n currentGroupPath: Option.Option<GroupPath.GroupPath>,\n apiPaths: FunctionPaths,\n): FunctionPaths =>\n Record.reduce(groups, apiPaths, (acc, group, groupName) => {\n const groupPath = Option.match(currentGroupPath, {\n onNone: () => GroupPath.make([groupName]),\n onSome: (path) => GroupPath.append(path, groupName),\n });\n\n const accWithFunctions = Record.reduce(\n group.functions,\n acc,\n (acc_, _fn, functionName) =>\n FunctionPaths.make(\n HashSet.add(\n acc_,\n FunctionPath.FunctionPath.make({\n groupPath,\n name: functionName,\n }),\n ),\n ),\n );\n\n return makeHelper(group.groups, Option.some(groupPath), accWithFunctions);\n });\n\nexport const groupPaths = (\n functionPaths: FunctionPaths,\n): GroupPaths.GroupPaths =>\n pipe(\n functionPaths,\n HashSet.map(FunctionPath.groupPath),\n GroupPaths.GroupPaths.make,\n );\n\nexport const diff = (\n previousFunctions: FunctionPaths,\n currentFunctions: FunctionPaths,\n): {\n functionsAdded: FunctionPaths;\n functionsRemoved: FunctionPaths;\n groupsRemoved: GroupPaths.GroupPaths;\n groupsAdded: GroupPaths.GroupPaths;\n groupsChanged: GroupPaths.GroupPaths;\n} => {\n const currentGroups = groupPaths(currentFunctions);\n const previousGroups = groupPaths(previousFunctions);\n\n const groupsAdded = GroupPaths.GroupPaths.make(\n HashSet.difference(currentGroups, previousGroups),\n );\n const groupsRemoved = GroupPaths.GroupPaths.make(\n HashSet.difference(previousGroups, currentGroups),\n );\n\n const functionsAdded = FunctionPaths.make(\n HashSet.difference(currentFunctions, previousFunctions),\n );\n const existingGroupsToWhichFunctionsWereAdded = GroupPaths.GroupPaths.make(\n HashSet.intersection(currentGroups, groupPaths(functionsAdded)),\n );\n\n const functionsRemoved = FunctionPaths.make(\n HashSet.difference(previousFunctions, currentFunctions),\n );\n const existingGroupsToWhichFunctionsWereRemoved = GroupPaths.GroupPaths.make(\n HashSet.intersection(previousGroups, groupPaths(functionsRemoved)),\n );\n\n const groupsChanged = pipe(\n existingGroupsToWhichFunctionsWereAdded,\n HashSet.union(existingGroupsToWhichFunctionsWereRemoved),\n HashSet.difference(HashSet.union(groupsAdded, groupsRemoved)),\n GroupPaths.GroupPaths.make,\n );\n\n return {\n functionsAdded,\n functionsRemoved,\n groupsRemoved,\n groupsAdded,\n groupsChanged,\n };\n};\n"],"mappings":";;;;;;AAMA,MAAa,gBAAgB,OAAO,gBAClCA,aACD,CAAC,KAAK,OAAO,MAAM,6BAA6B,CAAC;AAGlD,MAAa,QAAQ,SACnB,WAAW,KAAK,QAAQ,OAAO,MAAM,EAAE,cAAc,KAAK,QAAQ,OAAO,CAAC,CAAC;AAE7E,MAAM,cACJ,QAGA,kBACA,aAEA,OAAO,OAAO,QAAQ,WAAW,KAAK,OAAO,cAAc;CACzD,MAAM,YAAY,OAAO,MAAM,kBAAkB;EAC/C,cAAcC,OAAe,CAAC,UAAU,CAAC;EACzC,SAAS,SAASC,OAAiB,MAAM,UAAU;EACpD,CAAC;CAEF,MAAM,mBAAmB,OAAO,OAC9B,MAAM,WACN,MACC,MAAM,KAAK,iBACV,cAAc,KACZ,QAAQ,IACN,mBAC0B,KAAK;EAC7B;EACA,MAAM;EACP,CAAC,CACH,CACF,CACJ;AAED,QAAO,WAAW,MAAM,QAAQ,OAAO,KAAK,UAAU,EAAE,iBAAiB;EACzE;AAEJ,MAAa,cACX,kBAEA,KACE,eACA,QAAQ,IAAIC,UAAuB,aACb,KACvB;AAEH,MAAa,QACX,mBACA,qBAOG;CACH,MAAM,gBAAgB,WAAW,iBAAiB;CAClD,MAAM,iBAAiB,WAAW,kBAAkB;CAEpD,MAAM,yBAAoC,KACxC,QAAQ,WAAW,eAAe,eAAe,CAClD;CACD,MAAM,2BAAsC,KAC1C,QAAQ,WAAW,gBAAgB,cAAc,CAClD;CAED,MAAM,iBAAiB,cAAc,KACnC,QAAQ,WAAW,kBAAkB,kBAAkB,CACxD;CACD,MAAM,qDAAgE,KACpE,QAAQ,aAAa,eAAe,WAAW,eAAe,CAAC,CAChE;CAED,MAAM,mBAAmB,cAAc,KACrC,QAAQ,WAAW,mBAAmB,iBAAiB,CACxD;CACD,MAAM,uDAAkE,KACtE,QAAQ,aAAa,gBAAgB,WAAW,iBAAiB,CAAC,CACnE;AASD,QAAO;EACL;EACA;EACA;EACA;EACA,eAZoB,KACpB,yCACA,QAAQ,MAAM,0CAA0C,EACxD,QAAQ,WAAW,QAAQ,MAAM,aAAa,cAAc,CAAC,aACvC,KACvB;EAQA"}
|
package/dist/cliApp.mjs
CHANGED
package/dist/confect/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.mjs","names":["pendingInit: Pending","GroupPath.toString","specResult: Option.Option<ReadonlyArray<FileChange>>","FunctionPaths.make","FunctionPaths.diff","GroupPath.modulePath","optionalChanges: ReadonlyArray<FileChange>","optionalConfectFiles: ReadonlyRecord<string, keyof Pending>"],"sources":["../../src/confect/dev.ts"],"sourcesContent":["import { Spec } from \"@confect/core\";\nimport { Command } from \"@effect/cli\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport { Ansi, AnsiDoc } from \"@effect/printer-ansi\";\nimport {\n Array,\n Console,\n Data,\n Duration,\n Effect,\n Equal,\n HashSet,\n Match,\n Option,\n pipe,\n Queue,\n Ref,\n Schema,\n Stream,\n String,\n} from \"effect\";\nimport type { ReadonlyRecord } from \"effect/Record\";\nimport * as esbuild from \"esbuild\";\nimport * as tsx from \"tsx/esm/api\";\nimport type * as FunctionPath from \"../FunctionPath\";\nimport * as FunctionPaths from \"../FunctionPaths\";\nimport * as GroupPath from \"../GroupPath\";\nimport { logCompleted, logFailed } from \"../log\";\nimport { ConfectDirectory } from \"../services/ConfectDirectory\";\nimport { ConvexDirectory } from \"../services/ConvexDirectory\";\nimport { ProjectRoot } from \"../services/ProjectRoot\";\nimport {\n generateAuthConfig,\n generateConvexConfig,\n generateCrons,\n generateHttp,\n removeGroups,\n writeGroups,\n} from \"../utils\";\nimport { codegenHandler } from \"./codegen\";\n\ntype Pending = {\n readonly specDirty: boolean;\n readonly httpDirty: boolean;\n readonly appDirty: boolean;\n readonly cronsDirty: boolean;\n readonly authDirty: boolean;\n};\n\nconst pendingInit: Pending = {\n specDirty: false,\n httpDirty: false,\n appDirty: false,\n cronsDirty: false,\n authDirty: false,\n};\n\ntype FileChange = Data.TaggedEnum<{\n OptionalFile: {\n readonly change: \"Added\" | \"Removed\" | \"Modified\";\n readonly filePath: string;\n };\n GroupModule: {\n readonly change: \"Added\" | \"Removed\" | \"Modified\";\n readonly filePath: string;\n readonly functionsAdded: ReadonlyArray<FunctionPath.FunctionPath>;\n readonly functionsRemoved: ReadonlyArray<FunctionPath.FunctionPath>;\n };\n}>;\n\nconst FileChange = Data.taggedEnum<FileChange>();\n\nconst logChangeReport = (changes: ReadonlyArray<FileChange>) =>\n Effect.gen(function* () {\n yield* logCompleted(\"Generated files are up-to-date\");\n\n yield* Effect.when(\n Effect.forEach(changes, (change) =>\n FileChange.$match(change, {\n OptionalFile: ({ change: c, filePath }) =>\n logFileChangeIndented(c, filePath),\n GroupModule: ({\n change: c,\n filePath,\n functionsAdded,\n functionsRemoved,\n }) =>\n Effect.gen(function* () {\n yield* logFileChangeIndented(c, filePath);\n yield* Effect.forEach(functionsAdded, logFunctionAddedIndented);\n yield* Effect.forEach(\n functionsRemoved,\n logFunctionRemovedIndented,\n );\n }),\n }),\n ),\n () => Array.isNonEmptyReadonlyArray(changes),\n );\n });\n\nconst changeChar = (change: \"Added\" | \"Removed\" | \"Modified\") =>\n Match.value(change).pipe(\n Match.when(\"Added\", () => ({ char: \"+\", color: Ansi.green })),\n Match.when(\"Removed\", () => ({ char: \"-\", color: Ansi.red })),\n Match.when(\"Modified\", () => ({ char: \"~\", color: Ansi.yellow })),\n Match.exhaustive,\n );\n\nconst logFileChangeIndented = (\n change: \"Added\" | \"Removed\" | \"Modified\",\n fullPath: string,\n) =>\n Effect.gen(function* () {\n const projectRoot = yield* ProjectRoot.get;\n const path = yield* Path.Path;\n\n const prefix = projectRoot + path.sep;\n const suffix = pipe(fullPath, String.startsWith(prefix))\n ? pipe(fullPath, String.slice(prefix.length))\n : fullPath;\n\n const { char, color } = changeChar(change);\n\n yield* Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(char), AnsiDoc.annotate(color))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(AnsiDoc.text(prefix), AnsiDoc.annotate(Ansi.blackBright)),\n pipe(AnsiDoc.text(suffix), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n });\n\nconst logFunctionAddedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"+\"), AnsiDoc.annotate(Ansi.green))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.green)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nconst logFunctionRemovedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"-\"), AnsiDoc.annotate(Ansi.red))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.red)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const dev = Command.make(\"dev\", {}, () =>\n Effect.gen(function* () {\n const initialFunctionPaths = yield* codegenHandler;\n\n const pendingRef = yield* Ref.make<Pending>(pendingInit);\n const signal = yield* Queue.sliding<void>(1);\n\n yield* Effect.all(\n [\n specFileWatcher(signal, pendingRef),\n confectDirectoryWatcher(signal, pendingRef),\n syncLoop(signal, pendingRef, initialFunctionPaths),\n ],\n { concurrency: \"unbounded\" },\n );\n }),\n).pipe(Command.withDescription(\"Start the Confect development server\"));\n\nconst syncLoop = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n initialFunctionPaths: FunctionPaths.FunctionPaths,\n) =>\n Effect.gen(function* () {\n const functionPathsRef = yield* Ref.make(initialFunctionPaths);\n const changesRef = yield* Ref.make<ReadonlyArray<FileChange>>([]);\n\n return yield* Effect.forever(\n Effect.gen(function* () {\n yield* Effect.logDebug(\"Running sync loop...\");\n yield* Queue.take(signal);\n\n const pending = yield* Ref.getAndSet(pendingRef, pendingInit);\n\n const specResult: Option.Option<ReadonlyArray<FileChange>> =\n yield* Effect.if(pending.specDirty, {\n onTrue: () =>\n loadSpec.pipe(\n Effect.andThen(\n Effect.fn(function* (spec) {\n yield* Effect.logDebug(\"Spec loaded\");\n\n const previous = yield* Ref.get(functionPathsRef);\n\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const current = FunctionPaths.make(spec);\n const {\n functionsAdded,\n functionsRemoved,\n groupsRemoved,\n groupsAdded,\n groupsChanged,\n } = FunctionPaths.diff(previous, current);\n\n // Removed groups\n yield* removeGroups(groupsRemoved);\n const removedChanges = yield* Effect.forEach(\n groupsRemoved,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Removed\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: [],\n functionsRemoved: Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n });\n }),\n );\n\n // Added groups\n yield* writeGroups(spec, groupsAdded);\n const addedChanges = yield* Effect.forEach(\n groupsAdded,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Added\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n functionsRemoved: [],\n });\n }),\n );\n\n // Changed groups\n yield* writeGroups(spec, groupsChanged);\n const changedChanges = yield* Effect.forEach(\n groupsChanged,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Modified\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n functionsRemoved: Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n });\n }),\n );\n\n yield* Ref.set(functionPathsRef, current);\n\n return Option.some([\n ...removedChanges,\n ...addedChanges,\n ...changedChanges,\n ]);\n }),\n ),\n Effect.catchTag(\"SpecImportFailedError\", () =>\n logFailed(\"Spec import failed\").pipe(\n Effect.as(Option.none()),\n ),\n ),\n Effect.catchTag(\"SpecFileDoesNotExportSpecError\", () =>\n logFailed(\"Spec file does not default export a spec\").pipe(\n Effect.as(Option.none()),\n ),\n ),\n ),\n onFalse: () => Effect.succeed(Option.some([])),\n });\n\n const specChanges = Option.getOrElse(specResult, () => []);\n\n const dirtyOptionalFiles = [\n ...(pending.httpDirty\n ? [syncOptionalFile(generateHttp, \"http.ts\")]\n : []),\n ...(pending.appDirty\n ? [syncOptionalFile(generateConvexConfig, \"convex.config.ts\")]\n : []),\n ...(pending.cronsDirty\n ? [syncOptionalFile(generateCrons, \"crons.ts\")]\n : []),\n ...(pending.authDirty\n ? [syncOptionalFile(generateAuthConfig, \"auth.config.ts\")]\n : []),\n ];\n\n const optionalChanges: ReadonlyArray<FileChange> =\n Array.isNonEmptyReadonlyArray(dirtyOptionalFiles)\n ? yield* pipe(\n Effect.all(dirtyOptionalFiles, {\n concurrency: \"unbounded\",\n }),\n Effect.map(Array.getSomes),\n )\n : [];\n\n yield* Ref.update(changesRef, (prev) => [\n ...prev,\n ...specChanges,\n ...optionalChanges,\n ]);\n\n yield* Option.match(specResult, {\n onSome: () =>\n Effect.gen(function* () {\n const pendingSize = yield* Queue.size(signal);\n yield* Effect.when(\n Effect.gen(function* () {\n const allChanges = yield* Ref.getAndSet(changesRef, []);\n yield* logChangeReport(allChanges);\n }),\n () => pendingSize === 0,\n );\n }),\n onNone: () => Ref.set(changesRef, []),\n });\n }),\n );\n });\n\nconst loadSpec = Effect.gen(function* () {\n const path = yield* Path.Path;\n const specPathUrl = yield* path.toFileUrl(yield* getSpecPath);\n const specModule = yield* Effect.tryPromise({\n try: () => tsx.tsImport(specPathUrl.href, import.meta.url),\n catch: (error) => new SpecImportFailedError({ error }),\n });\n const spec = specModule.default;\n\n if (Spec.isSpec(spec)) {\n return spec;\n } else {\n return yield* Effect.fail(new SpecFileDoesNotExportSpecError());\n }\n});\n\nconst getSpecPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n return path.join(confectDirectory, \"spec.ts\");\n});\n\nconst specFileWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n) =>\n Effect.gen(function* () {\n const specPath = yield* getSpecPath;\n\n const specChanges: Stream.Stream<void> = Stream.asyncPush(\n (emit) =>\n Effect.acquireRelease(\n Effect.promise(async () => {\n const ctx = await esbuild.context({\n entryPoints: [specPath],\n bundle: true,\n write: false,\n metafile: true,\n platform: \"node\",\n format: \"esm\",\n logLevel: \"silent\",\n external: [\n \"@confect/core\",\n \"@confect/server\",\n \"effect\",\n \"@effect/*\",\n ],\n plugins: [\n {\n name: \"notify-rebuild\",\n setup(build) {\n build.onEnd((result) => {\n if (result.errors.length === 0) {\n emit.single();\n } else {\n Effect.runPromise(\n Effect.gen(function* () {\n yield* logFailed(\"Build errors\");\n const formattedMessages = yield* Effect.promise(\n () =>\n esbuild.formatMessages(result.errors, {\n kind: \"error\",\n color: true,\n terminalWidth: 80,\n }),\n );\n const output = formatBuildErrors(\n result.errors,\n formattedMessages,\n );\n yield* Console.error(\"\\n\" + output + \"\\n\");\n }),\n );\n }\n });\n },\n },\n ],\n });\n\n await ctx.watch();\n\n return ctx;\n }),\n (ctx) =>\n Effect.promise(() => ctx.dispose()).pipe(\n Effect.tap(() => Effect.logDebug(\"esbuild watcher disposed\")),\n ),\n ),\n { bufferSize: 1, strategy: \"sliding\" },\n );\n\n yield* pipe(\n specChanges,\n Stream.debounce(Duration.millis(200)),\n Stream.runForEach(() =>\n Ref.update(pendingRef, (pending) => ({\n ...pending,\n specDirty: true,\n })).pipe(Effect.andThen(Queue.offer(signal, undefined))),\n ),\n );\n });\n\nconst formatBuildError = (\n error: esbuild.Message | undefined,\n formattedMessage: string,\n): string => {\n const lines = String.split(formattedMessage, \"\\n\");\n const redErrorText = pipe(\n AnsiDoc.text(error?.text ?? \"\"),\n AnsiDoc.annotate(Ansi.red),\n AnsiDoc.render({ style: \"pretty\" }),\n );\n const replaced = pipe(\n Array.findFirstIndex(lines, (l) => pipe(l, String.trim, String.isNonEmpty)),\n Option.match({\n onNone: () => lines,\n onSome: (idx) => Array.modify(lines, idx, () => redErrorText),\n }),\n );\n return pipe(\n replaced,\n Array.map((l) => (pipe(l, String.trim, String.isNonEmpty) ? ` ${l}` : l)),\n Array.join(\"\\n\"),\n );\n};\n\nconst formatBuildErrors = (\n errors: readonly esbuild.Message[],\n formattedMessages: readonly string[],\n): string =>\n pipe(\n formattedMessages,\n Array.map((message, i) => formatBuildError(errors[i], message)),\n Array.join(\"\"),\n String.trimEnd,\n );\n\nexport class SpecFileDoesNotExportSpecError extends Schema.TaggedError<SpecFileDoesNotExportSpecError>(\n \"SpecFileDoesNotExportSpecError\",\n)(\"SpecFileDoesNotExportSpecError\", {}) {}\n\nexport class SpecImportFailedError extends Schema.TaggedError<SpecImportFailedError>(\n \"SpecImportFailedError\",\n)(\"SpecImportFailedError\", {\n error: Schema.Unknown,\n}) {}\n\nconst syncOptionalFile = (generate: typeof generateHttp, convexFile: string) =>\n pipe(\n generate,\n Effect.andThen(\n Option.match({\n onSome: ({ change, convexFilePath }) =>\n Match.value(change).pipe(\n Match.when(\"Unchanged\", () => Effect.succeed(Option.none())),\n Match.whenOr(\"Added\", \"Modified\", (addedOrModified) =>\n Effect.succeed(\n Option.some(\n FileChange.OptionalFile({\n change: addedOrModified,\n filePath: convexFilePath,\n }),\n ),\n ),\n ),\n Match.exhaustive,\n ),\n onNone: () =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const convexFilePath = path.join(convexDirectory, convexFile);\n\n if (yield* fs.exists(convexFilePath)) {\n yield* fs.remove(convexFilePath);\n\n return Option.some(\n FileChange.OptionalFile({\n change: \"Removed\",\n filePath: convexFilePath,\n }),\n );\n } else {\n return Option.none();\n }\n }),\n }),\n ),\n );\n\nconst optionalConfectFiles: ReadonlyRecord<string, keyof Pending> = {\n \"http.ts\": \"httpDirty\",\n \"app.ts\": \"appDirty\",\n \"crons.ts\": \"cronsDirty\",\n \"auth.ts\": \"authDirty\",\n};\n\nconst confectDirectoryWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* pipe(\n fs.watch(confectDirectory),\n Stream.runForEach((event) =>\n pipe(\n Option.fromNullable(optionalConfectFiles[event.path]),\n Option.match({\n onNone: () => Effect.void,\n onSome: (pendingKey) =>\n pipe(\n pendingRef,\n Ref.update((pending) => ({\n ...pending,\n [pendingKey]: true,\n })),\n Effect.andThen(Queue.offer(signal, undefined)),\n ),\n }),\n ),\n ),\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;AAiDA,MAAMA,cAAuB;CAC3B,WAAW;CACX,WAAW;CACX,UAAU;CACV,YAAY;CACZ,WAAW;CACZ;AAeD,MAAM,aAAa,KAAK,YAAwB;AAEhD,MAAM,mBAAmB,YACvB,OAAO,IAAI,aAAa;AACtB,QAAO,aAAa,iCAAiC;AAErD,QAAO,OAAO,KACZ,OAAO,QAAQ,UAAU,WACvB,WAAW,OAAO,QAAQ;EACxB,eAAe,EAAE,QAAQ,GAAG,eAC1B,sBAAsB,GAAG,SAAS;EACpC,cAAc,EACZ,QAAQ,GACR,UACA,gBACA,uBAEA,OAAO,IAAI,aAAa;AACtB,UAAO,sBAAsB,GAAG,SAAS;AACzC,UAAO,OAAO,QAAQ,gBAAgB,yBAAyB;AAC/D,UAAO,OAAO,QACZ,kBACA,2BACD;IACD;EACL,CAAC,CACH,QACK,MAAM,wBAAwB,QAAQ,CAC7C;EACD;AAEJ,MAAM,cAAc,WAClB,MAAM,MAAM,OAAO,C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AAa;GACvB,GAAG;IACF,aAAa;GACf,EAAE,EACH,OAAO,QAAQ,MAAM,MAAM,QAAQ,OAAU,CAAC,CAC/C;EACJ,CAAC,CACH,CACF,CACF;EACD"}
|
|
1
|
+
{"version":3,"file":"dev.mjs","names":["GroupPath.toString","FunctionPaths.make","FunctionPaths.diff","GroupPath.modulePath"],"sources":["../../src/confect/dev.ts"],"sourcesContent":["import { Spec } from \"@confect/core\";\nimport { Command } from \"@effect/cli\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport { Ansi, AnsiDoc } from \"@effect/printer-ansi\";\nimport {\n Array,\n Console,\n Data,\n Duration,\n Effect,\n Equal,\n HashSet,\n Match,\n Option,\n pipe,\n Queue,\n Ref,\n Schema,\n Stream,\n String,\n} from \"effect\";\nimport type { ReadonlyRecord } from \"effect/Record\";\nimport * as esbuild from \"esbuild\";\nimport * as tsx from \"tsx/esm/api\";\nimport type * as FunctionPath from \"../FunctionPath\";\nimport * as FunctionPaths from \"../FunctionPaths\";\nimport * as GroupPath from \"../GroupPath\";\nimport { logCompleted, logFailed } from \"../log\";\nimport { ConfectDirectory } from \"../services/ConfectDirectory\";\nimport { ConvexDirectory } from \"../services/ConvexDirectory\";\nimport { ProjectRoot } from \"../services/ProjectRoot\";\nimport {\n generateAuthConfig,\n generateConvexConfig,\n generateCrons,\n generateHttp,\n removeGroups,\n writeGroups,\n} from \"../utils\";\nimport { codegenHandler } from \"./codegen\";\n\ntype Pending = {\n readonly specDirty: boolean;\n readonly httpDirty: boolean;\n readonly appDirty: boolean;\n readonly cronsDirty: boolean;\n readonly authDirty: boolean;\n};\n\nconst pendingInit: Pending = {\n specDirty: false,\n httpDirty: false,\n appDirty: false,\n cronsDirty: false,\n authDirty: false,\n};\n\ntype FileChange = Data.TaggedEnum<{\n OptionalFile: {\n readonly change: \"Added\" | \"Removed\" | \"Modified\";\n readonly filePath: string;\n };\n GroupModule: {\n readonly change: \"Added\" | \"Removed\" | \"Modified\";\n readonly filePath: string;\n readonly functionsAdded: ReadonlyArray<FunctionPath.FunctionPath>;\n readonly functionsRemoved: ReadonlyArray<FunctionPath.FunctionPath>;\n };\n}>;\n\nconst FileChange = Data.taggedEnum<FileChange>();\n\nconst logChangeReport = (changes: ReadonlyArray<FileChange>) =>\n Effect.gen(function* () {\n yield* logCompleted(\"Generated files are up-to-date\");\n\n yield* Effect.when(\n Effect.forEach(changes, (change) =>\n FileChange.$match(change, {\n OptionalFile: ({ change: c, filePath }) =>\n logFileChangeIndented(c, filePath),\n GroupModule: ({\n change: c,\n filePath,\n functionsAdded,\n functionsRemoved,\n }) =>\n Effect.gen(function* () {\n yield* logFileChangeIndented(c, filePath);\n yield* Effect.forEach(functionsAdded, logFunctionAddedIndented);\n yield* Effect.forEach(\n functionsRemoved,\n logFunctionRemovedIndented,\n );\n }),\n }),\n ),\n () => Array.isNonEmptyReadonlyArray(changes),\n );\n });\n\nconst changeChar = (change: \"Added\" | \"Removed\" | \"Modified\") =>\n Match.value(change).pipe(\n Match.when(\"Added\", () => ({ char: \"+\", color: Ansi.green })),\n Match.when(\"Removed\", () => ({ char: \"-\", color: Ansi.red })),\n Match.when(\"Modified\", () => ({ char: \"~\", color: Ansi.yellow })),\n Match.exhaustive,\n );\n\nconst logFileChangeIndented = (\n change: \"Added\" | \"Removed\" | \"Modified\",\n fullPath: string,\n) =>\n Effect.gen(function* () {\n const projectRoot = yield* ProjectRoot.get;\n const path = yield* Path.Path;\n\n const prefix = projectRoot + path.sep;\n const suffix = pipe(fullPath, String.startsWith(prefix))\n ? pipe(fullPath, String.slice(prefix.length))\n : fullPath;\n\n const { char, color } = changeChar(change);\n\n yield* Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(char), AnsiDoc.annotate(color))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(AnsiDoc.text(prefix), AnsiDoc.annotate(Ansi.blackBright)),\n pipe(AnsiDoc.text(suffix), AnsiDoc.annotate(color)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n });\n\nconst logFunctionAddedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"+\"), AnsiDoc.annotate(Ansi.green))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.green)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nconst logFunctionRemovedIndented = (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n pipe(\n AnsiDoc.text(\" \"),\n AnsiDoc.cat(pipe(AnsiDoc.char(\"-\"), AnsiDoc.annotate(Ansi.red))),\n AnsiDoc.catWithSpace(\n AnsiDoc.hcat([\n pipe(\n AnsiDoc.text(GroupPath.toString(functionPath.groupPath) + \".\"),\n AnsiDoc.annotate(Ansi.blackBright),\n ),\n pipe(AnsiDoc.text(functionPath.name), AnsiDoc.annotate(Ansi.red)),\n ]),\n ),\n AnsiDoc.render({ style: \"pretty\" }),\n ),\n );\n\nexport const dev = Command.make(\"dev\", {}, () =>\n Effect.gen(function* () {\n const initialFunctionPaths = yield* codegenHandler;\n\n const pendingRef = yield* Ref.make<Pending>(pendingInit);\n const signal = yield* Queue.sliding<void>(1);\n\n yield* Effect.all(\n [\n specFileWatcher(signal, pendingRef),\n confectDirectoryWatcher(signal, pendingRef),\n syncLoop(signal, pendingRef, initialFunctionPaths),\n ],\n { concurrency: \"unbounded\" },\n );\n }),\n).pipe(Command.withDescription(\"Start the Confect development server\"));\n\nconst syncLoop = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n initialFunctionPaths: FunctionPaths.FunctionPaths,\n) =>\n Effect.gen(function* () {\n const functionPathsRef = yield* Ref.make(initialFunctionPaths);\n const changesRef = yield* Ref.make<ReadonlyArray<FileChange>>([]);\n\n return yield* Effect.forever(\n Effect.gen(function* () {\n yield* Effect.logDebug(\"Running sync loop...\");\n yield* Queue.take(signal);\n\n const pending = yield* Ref.getAndSet(pendingRef, pendingInit);\n\n const specResult: Option.Option<ReadonlyArray<FileChange>> =\n yield* Effect.if(pending.specDirty, {\n onTrue: () =>\n loadSpec.pipe(\n Effect.andThen(\n Effect.fn(function* (spec) {\n yield* Effect.logDebug(\"Spec loaded\");\n\n const previous = yield* Ref.get(functionPathsRef);\n\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const current = FunctionPaths.make(spec);\n const {\n functionsAdded,\n functionsRemoved,\n groupsRemoved,\n groupsAdded,\n groupsChanged,\n } = FunctionPaths.diff(previous, current);\n\n // Removed groups\n yield* removeGroups(groupsRemoved);\n const removedChanges = yield* Effect.forEach(\n groupsRemoved,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Removed\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: [],\n functionsRemoved: Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n });\n }),\n );\n\n // Added groups\n yield* writeGroups(spec, groupsAdded);\n const addedChanges = yield* Effect.forEach(\n groupsAdded,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Added\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n functionsRemoved: [],\n });\n }),\n );\n\n // Changed groups\n yield* writeGroups(spec, groupsChanged);\n const changedChanges = yield* Effect.forEach(\n groupsChanged,\n (gp) =>\n Effect.gen(function* () {\n const relativeModulePath =\n yield* GroupPath.modulePath(gp);\n return FileChange.GroupModule({\n change: \"Modified\",\n filePath: path.join(\n convexDirectory,\n relativeModulePath,\n ),\n functionsAdded: Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n functionsRemoved: Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n });\n }),\n );\n\n yield* Ref.set(functionPathsRef, current);\n\n return Option.some([\n ...removedChanges,\n ...addedChanges,\n ...changedChanges,\n ]);\n }),\n ),\n Effect.catchTag(\"SpecImportFailedError\", () =>\n logFailed(\"Spec import failed\").pipe(\n Effect.as(Option.none()),\n ),\n ),\n Effect.catchTag(\"SpecFileDoesNotExportSpecError\", () =>\n logFailed(\"Spec file does not default export a spec\").pipe(\n Effect.as(Option.none()),\n ),\n ),\n ),\n onFalse: () => Effect.succeed(Option.some([])),\n });\n\n const specChanges = Option.getOrElse(specResult, () => []);\n\n const dirtyOptionalFiles = [\n ...(pending.httpDirty\n ? [syncOptionalFile(generateHttp, \"http.ts\")]\n : []),\n ...(pending.appDirty\n ? [syncOptionalFile(generateConvexConfig, \"convex.config.ts\")]\n : []),\n ...(pending.cronsDirty\n ? [syncOptionalFile(generateCrons, \"crons.ts\")]\n : []),\n ...(pending.authDirty\n ? [syncOptionalFile(generateAuthConfig, \"auth.config.ts\")]\n : []),\n ];\n\n const optionalChanges: ReadonlyArray<FileChange> =\n Array.isNonEmptyReadonlyArray(dirtyOptionalFiles)\n ? yield* pipe(\n Effect.all(dirtyOptionalFiles, {\n concurrency: \"unbounded\",\n }),\n Effect.map(Array.getSomes),\n )\n : [];\n\n yield* Ref.update(changesRef, (prev) => [\n ...prev,\n ...specChanges,\n ...optionalChanges,\n ]);\n\n yield* Option.match(specResult, {\n onSome: () =>\n Effect.gen(function* () {\n const pendingSize = yield* Queue.size(signal);\n yield* Effect.when(\n Effect.gen(function* () {\n const allChanges = yield* Ref.getAndSet(changesRef, []);\n yield* logChangeReport(allChanges);\n }),\n () => pendingSize === 0,\n );\n }),\n onNone: () => Ref.set(changesRef, []),\n });\n }),\n );\n });\n\nconst loadSpec = Effect.gen(function* () {\n const path = yield* Path.Path;\n const specPathUrl = yield* path.toFileUrl(yield* getSpecPath);\n const specModule = yield* Effect.tryPromise({\n try: () => tsx.tsImport(specPathUrl.href, import.meta.url),\n catch: (error) => new SpecImportFailedError({ error }),\n });\n const spec = specModule.default;\n\n if (Spec.isSpec(spec)) {\n return spec;\n } else {\n return yield* Effect.fail(new SpecFileDoesNotExportSpecError());\n }\n});\n\nconst getSpecPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n return path.join(confectDirectory, \"spec.ts\");\n});\n\nconst specFileWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n) =>\n Effect.gen(function* () {\n const specPath = yield* getSpecPath;\n\n const specChanges: Stream.Stream<void> = Stream.asyncPush(\n (emit) =>\n Effect.acquireRelease(\n Effect.promise(async () => {\n const ctx = await esbuild.context({\n entryPoints: [specPath],\n bundle: true,\n write: false,\n metafile: true,\n platform: \"node\",\n format: \"esm\",\n logLevel: \"silent\",\n external: [\n \"@confect/core\",\n \"@confect/server\",\n \"effect\",\n \"@effect/*\",\n ],\n plugins: [\n {\n name: \"notify-rebuild\",\n setup(build) {\n build.onEnd((result) => {\n if (result.errors.length === 0) {\n emit.single();\n } else {\n Effect.runPromise(\n Effect.gen(function* () {\n yield* logFailed(\"Build errors\");\n const formattedMessages = yield* Effect.promise(\n () =>\n esbuild.formatMessages(result.errors, {\n kind: \"error\",\n color: true,\n terminalWidth: 80,\n }),\n );\n const output = formatBuildErrors(\n result.errors,\n formattedMessages,\n );\n yield* Console.error(\"\\n\" + output + \"\\n\");\n }),\n );\n }\n });\n },\n },\n ],\n });\n\n await ctx.watch();\n\n return ctx;\n }),\n (ctx) =>\n Effect.promise(() => ctx.dispose()).pipe(\n Effect.tap(() => Effect.logDebug(\"esbuild watcher disposed\")),\n ),\n ),\n { bufferSize: 1, strategy: \"sliding\" },\n );\n\n yield* pipe(\n specChanges,\n Stream.debounce(Duration.millis(200)),\n Stream.runForEach(() =>\n Ref.update(pendingRef, (pending) => ({\n ...pending,\n specDirty: true,\n })).pipe(Effect.andThen(Queue.offer(signal, undefined))),\n ),\n );\n });\n\nconst formatBuildError = (\n error: esbuild.Message | undefined,\n formattedMessage: string,\n): string => {\n const lines = String.split(formattedMessage, \"\\n\");\n const redErrorText = pipe(\n AnsiDoc.text(error?.text ?? \"\"),\n AnsiDoc.annotate(Ansi.red),\n AnsiDoc.render({ style: \"pretty\" }),\n );\n const replaced = pipe(\n Array.findFirstIndex(lines, (l) => pipe(l, String.trim, String.isNonEmpty)),\n Option.match({\n onNone: () => lines,\n onSome: (idx) => Array.modify(lines, idx, () => redErrorText),\n }),\n );\n return pipe(\n replaced,\n Array.map((l) => (pipe(l, String.trim, String.isNonEmpty) ? ` ${l}` : l)),\n Array.join(\"\\n\"),\n );\n};\n\nconst formatBuildErrors = (\n errors: readonly esbuild.Message[],\n formattedMessages: readonly string[],\n): string =>\n pipe(\n formattedMessages,\n Array.map((message, i) => formatBuildError(errors[i], message)),\n Array.join(\"\"),\n String.trimEnd,\n );\n\nexport class SpecFileDoesNotExportSpecError extends Schema.TaggedError<SpecFileDoesNotExportSpecError>(\n \"SpecFileDoesNotExportSpecError\",\n)(\"SpecFileDoesNotExportSpecError\", {}) {}\n\nexport class SpecImportFailedError extends Schema.TaggedError<SpecImportFailedError>(\n \"SpecImportFailedError\",\n)(\"SpecImportFailedError\", {\n error: Schema.Unknown,\n}) {}\n\nconst syncOptionalFile = (generate: typeof generateHttp, convexFile: string) =>\n pipe(\n generate,\n Effect.andThen(\n Option.match({\n onSome: ({ change, convexFilePath }) =>\n Match.value(change).pipe(\n Match.when(\"Unchanged\", () => Effect.succeed(Option.none())),\n Match.whenOr(\"Added\", \"Modified\", (addedOrModified) =>\n Effect.succeed(\n Option.some(\n FileChange.OptionalFile({\n change: addedOrModified,\n filePath: convexFilePath,\n }),\n ),\n ),\n ),\n Match.exhaustive,\n ),\n onNone: () =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const convexFilePath = path.join(convexDirectory, convexFile);\n\n if (yield* fs.exists(convexFilePath)) {\n yield* fs.remove(convexFilePath);\n\n return Option.some(\n FileChange.OptionalFile({\n change: \"Removed\",\n filePath: convexFilePath,\n }),\n );\n } else {\n return Option.none();\n }\n }),\n }),\n ),\n );\n\nconst optionalConfectFiles: ReadonlyRecord<string, keyof Pending> = {\n \"http.ts\": \"httpDirty\",\n \"app.ts\": \"appDirty\",\n \"crons.ts\": \"cronsDirty\",\n \"auth.ts\": \"authDirty\",\n};\n\nconst confectDirectoryWatcher = (\n signal: Queue.Queue<void>,\n pendingRef: Ref.Ref<Pending>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const confectDirectory = yield* ConfectDirectory.get;\n\n yield* pipe(\n fs.watch(confectDirectory),\n Stream.runForEach((event) =>\n pipe(\n Option.fromNullable(optionalConfectFiles[event.path]),\n Option.match({\n onNone: () => Effect.void,\n onSome: (pendingKey) =>\n pipe(\n pendingRef,\n Ref.update((pending) => ({\n ...pending,\n [pendingKey]: true,\n })),\n Effect.andThen(Queue.offer(signal, undefined)),\n ),\n }),\n ),\n ),\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;AAiDA,MAAM,cAAuB;CAC3B,WAAW;CACX,WAAW;CACX,UAAU;CACV,YAAY;CACZ,WAAW;CACZ;AAeD,MAAM,aAAa,KAAK,YAAwB;AAEhD,MAAM,mBAAmB,YACvB,OAAO,IAAI,aAAa;AACtB,QAAO,aAAa,iCAAiC;AAErD,QAAO,OAAO,KACZ,OAAO,QAAQ,UAAU,WACvB,WAAW,OAAO,QAAQ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ClE,WAAW;CACX,UAAU;CACV,YAAY;CACZ,WAAW;CACZ;AAED,MAAM,2BACJ,QACA,eAEA,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,mBAAmB,OAAO,iBAAiB;AAEjD,QAAO,KACL,GAAG,MAAM,iBAAiB,EAC1B,OAAO,YAAY,UACjB,KACE,OAAO,aAAa,qBAAqB,MAAM,MAAM,EACrD,OAAO,MAAM;EACX,cAAc,OAAO;EACrB,SAAS,eACP,KACE,YACA,IAAI,QAAQ,aAAa;GACvB,GAAG;IACF,aAAa;GACf,EAAE,EACH,OAAO,QAAQ,MAAM,MAAM,QAAQ,OAAU,CAAC,CAC/C;EACJ,CAAC,CACH,CACF,CACF;EACD"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { layer } from "./node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeContext.mjs";
|
|
3
|
-
import { runMain } from "./node_modules/.pnpm/@effect_platform-node@0.100.0_@effect_cluster@0.52.9_@effect_platform@0.93.2_effect@3.1_a15ca1802d939cd85cc564105ef862ac/node_modules/@effect/platform-node/dist/esm/NodeRuntime.mjs";
|
|
4
2
|
import { cliApp } from "./cliApp.mjs";
|
|
3
|
+
import { NodeContext, NodeRuntime } from "@effect/platform-node";
|
|
5
4
|
import { Effect } from "effect";
|
|
6
5
|
|
|
7
6
|
//#region src/index.ts
|
|
@@ -12,7 +11,7 @@ process.prependListener("SIGINT", () => {
|
|
|
12
11
|
process.on("exit", () => {
|
|
13
12
|
if (interrupted) process.kill(process.pid, "SIGINT");
|
|
14
13
|
});
|
|
15
|
-
cliApp(process.argv).pipe(Effect.provide(layer), runMain);
|
|
14
|
+
cliApp(process.argv).pipe(Effect.provide(NodeContext.layer), NodeRuntime.runMain);
|
|
16
15
|
|
|
17
16
|
//#endregion
|
|
18
17
|
export { };
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { NodeContext, NodeRuntime } from \"@effect/platform-node\";\nimport { Effect } from \"effect\";\nimport { cliApp } from \"./cliApp\";\n\n// Track if we received SIGINT so we can re-raise it after cleanup.\n// This ensures proper terminal state restoration when run via e.g. `pnpm`.\nlet interrupted = false;\nprocess.prependListener(\"SIGINT\", () => {\n interrupted = true;\n});\nprocess.on(\"exit\", () => {\n if (interrupted) {\n process.kill(process.pid, \"SIGINT\");\n }\n});\n\ncliApp(process.argv).pipe(\n Effect.provide(NodeContext.layer),\n NodeRuntime.runMain,\n);\n"],"mappings":";;;;;;AAQA,IAAI,cAAc;AAClB,QAAQ,gBAAgB,gBAAgB;AACtC,eAAc;EACd;AACF,QAAQ,GAAG,cAAc;AACvB,KAAI,YACF,SAAQ,KAAK,QAAQ,KAAK,SAAS;EAErC;AAEF,OAAO,QAAQ,KAAK,CAAC,KACnB,OAAO,QAAQ,YAAY,MAAM,EACjC,YAAY,QACb"}
|
package/dist/package.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodeFileSystem } from "@effect/platform-node";
|
|
2
2
|
import { Array, Effect, Option, Ref, Schema } from "effect";
|
|
3
3
|
import { FileSystem, Path } from "@effect/platform";
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ var ProjectRoot = class extends Effect.Service()("@confect/cli/services/ProjectR
|
|
|
9
9
|
const ref = yield* Ref.make(projectRoot);
|
|
10
10
|
return { get: Ref.get(ref) };
|
|
11
11
|
}),
|
|
12
|
-
dependencies: [layer],
|
|
12
|
+
dependencies: [NodeFileSystem.layer],
|
|
13
13
|
accessors: true
|
|
14
14
|
}) {};
|
|
15
15
|
const findProjectRoot = Effect.gen(function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectRoot.mjs","names":[
|
|
1
|
+
{"version":3,"file":"ProjectRoot.mjs","names":[],"sources":["../../src/services/ProjectRoot.ts"],"sourcesContent":["import { FileSystem, Path } from \"@effect/platform\";\nimport { NodeFileSystem } from \"@effect/platform-node\";\nimport { Array, Effect, Option, Ref, Schema } from \"effect\";\n\nexport class ProjectRoot extends Effect.Service<ProjectRoot>()(\n \"@confect/cli/services/ProjectRoot\",\n {\n effect: Effect.gen(function* () {\n const projectRoot = yield* findProjectRoot;\n\n const ref = yield* Ref.make<string>(projectRoot);\n\n return { get: Ref.get(ref) } as const;\n }),\n dependencies: [NodeFileSystem.layer],\n accessors: true,\n },\n) {}\n\nexport const findProjectRoot = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const startDir = path.resolve(\".\");\n const root = path.parse(startDir).root;\n\n const directories = Array.unfold(startDir, (dir) =>\n dir === root\n ? Option.none()\n : Option.some([dir, path.dirname(dir)] as const),\n );\n\n const projectRoot = yield* Effect.findFirst(directories, (dir) =>\n fs.exists(path.join(dir, \"package.json\")),\n );\n\n return yield* Option.match(projectRoot, {\n onNone: () => Effect.fail(new ProjectRootNotFoundError()),\n onSome: Effect.succeed,\n });\n});\n\nexport class ProjectRootNotFoundError extends Schema.TaggedError<ProjectRootNotFoundError>(\n \"ProjectRootNotFoundError\",\n)(\"ProjectRootNotFoundError\", {}) {\n override get message(): string {\n return \"Could not find project root (no 'package.json' found)\";\n }\n}\n"],"mappings":";;;;;AAIA,IAAa,cAAb,cAAiC,OAAO,SAAsB,CAC5D,qCACA;CACE,QAAQ,OAAO,IAAI,aAAa;EAC9B,MAAM,cAAc,OAAO;EAE3B,MAAM,MAAM,OAAO,IAAI,KAAa,YAAY;AAEhD,SAAO,EAAE,KAAK,IAAI,IAAI,IAAI,EAAE;GAC5B;CACF,cAAc,CAAC,eAAe,MAAM;CACpC,WAAW;CACZ,CACF,CAAC;AAEF,MAAa,kBAAkB,OAAO,IAAI,aAAa;CACrD,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CAEzB,MAAM,WAAW,KAAK,QAAQ,IAAI;CAClC,MAAM,OAAO,KAAK,MAAM,SAAS,CAAC;CAElC,MAAM,cAAc,MAAM,OAAO,WAAW,QAC1C,QAAQ,OACJ,OAAO,MAAM,GACb,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAU,CACnD;CAED,MAAM,cAAc,OAAO,OAAO,UAAU,cAAc,QACxD,GAAG,OAAO,KAAK,KAAK,KAAK,eAAe,CAAC,CAC1C;AAED,QAAO,OAAO,OAAO,MAAM,aAAa;EACtC,cAAc,OAAO,KAAK,IAAI,0BAA0B,CAAC;EACzD,QAAQ,OAAO;EAChB,CAAC;EACF;AAEF,IAAa,2BAAb,cAA8C,OAAO,YACnD,2BACD,CAAC,4BAA4B,EAAE,CAAC,CAAC;CAChC,IAAa,UAAkB;AAC7B,SAAO"}
|
package/dist/utils.mjs
CHANGED
|
@@ -72,10 +72,10 @@ const generateGroupModule = ({ groupPath, functionNames }) => Effect.gen(functio
|
|
|
72
72
|
}
|
|
73
73
|
return "Unchanged";
|
|
74
74
|
});
|
|
75
|
-
const logGroupPaths = (groupPaths
|
|
75
|
+
const logGroupPaths = (groupPaths, logFn) => Effect.gen(function* () {
|
|
76
76
|
const path = yield* Path.Path;
|
|
77
77
|
const convexDirectory = yield* ConvexDirectory.get;
|
|
78
|
-
yield* Effect.forEach(groupPaths
|
|
78
|
+
yield* Effect.forEach(groupPaths, (gp) => Effect.gen(function* () {
|
|
79
79
|
const relativeModulePath = yield* modulePath(gp);
|
|
80
80
|
yield* logFn(path.join(convexDirectory, relativeModulePath));
|
|
81
81
|
}));
|
|
@@ -117,19 +117,19 @@ const getGroupPathsFromFs = Effect.gen(function* () {
|
|
|
117
117
|
]);
|
|
118
118
|
return pipe(yield* pipe(yield* fs.readDirectory(convexDirectory, { recursive: true }), Array.filter((convexPath) => path.extname(convexPath) === ".ts" && !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)) && path.basename(path.dirname(convexPath)) !== "_generated"), Effect.forEach((groupModulePath) => fromGroupModulePath(groupModulePath))), HashSet.fromIterable, GroupPaths.make);
|
|
119
119
|
});
|
|
120
|
-
const removeGroups = (groupPaths
|
|
120
|
+
const removeGroups = (groupPaths) => Effect.gen(function* () {
|
|
121
121
|
const fs = yield* FileSystem.FileSystem;
|
|
122
122
|
const path = yield* Path.Path;
|
|
123
123
|
const convexDirectory = yield* ConvexDirectory.get;
|
|
124
|
-
yield* Effect.all(HashSet.map(groupPaths
|
|
124
|
+
yield* Effect.all(HashSet.map(groupPaths, (groupPath) => Effect.gen(function* () {
|
|
125
125
|
const relativeModulePath = yield* modulePath(groupPath);
|
|
126
|
-
const modulePath$
|
|
126
|
+
const modulePath$2 = path.join(convexDirectory, relativeModulePath);
|
|
127
127
|
yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);
|
|
128
|
-
yield* fs.remove(modulePath$
|
|
128
|
+
yield* fs.remove(modulePath$2);
|
|
129
129
|
yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);
|
|
130
130
|
})), { concurrency: "unbounded" });
|
|
131
131
|
});
|
|
132
|
-
const writeGroups = (spec, groupPaths
|
|
132
|
+
const writeGroups = (spec, groupPaths) => Effect.forEach(groupPaths, (groupPath) => Effect.gen(function* () {
|
|
133
133
|
const functionNames = pipe((yield* getGroupSpec(spec, groupPath)).functions, Record.values, Array.sortBy(Order.mapInput(Order.string, (fn) => fn.name)), Array.map((fn) => fn.name));
|
|
134
134
|
yield* Effect.logDebug(`Generating group ${groupPath}...`);
|
|
135
135
|
yield* generateGroupModule({
|
package/dist/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":["GroupPath.modulePath","modulePath","templates.functions","groupPaths","FunctionPaths.make","FunctionPaths.groupPaths","GroupPath.getGroupSpec","GroupPath.fromGroupModulePath","templates.http","templates.convexConfig","templates.crons","templates.authConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import type { FunctionSpec, Spec } from \"@confect/core\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport type { PlatformError } from \"@effect/platform/Error\";\nimport {\n Array,\n Effect,\n HashSet,\n Option,\n Order,\n pipe,\n Record,\n String,\n} from \"effect\";\nimport * as FunctionPaths from \"./FunctionPaths\";\nimport * as GroupPath from \"./GroupPath\";\nimport * as GroupPaths from \"./GroupPaths\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log\";\nimport { ConfectDirectory } from \"./services/ConfectDirectory\";\nimport { ConvexDirectory } from \"./services/ConvexDirectory\";\nimport * as templates from \"./templates\";\n\nexport const removePathExtension = (pathStr: string) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n\n return String.slice(0, -path.extname(pathStr).length)(pathStr);\n });\n\nexport const writeFileStringAndLog = (filePath: string, contents: string) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileAdded(filePath);\n return;\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileModified(filePath);\n }\n });\n\nexport const findProjectRoot = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const startDir = path.resolve(\".\");\n const root = path.parse(startDir).root;\n\n const directories = Array.unfold(startDir, (dir) =>\n dir === root\n ? Option.none()\n : Option.some([dir, path.dirname(dir)] as const),\n );\n\n const projectRoot = yield* Effect.findFirst(directories, (dir) =>\n fs.exists(path.join(dir, \"package.json\")),\n );\n\n return Option.getOrElse(projectRoot, () => startDir);\n});\n\nexport type WriteChange = \"Added\" | \"Modified\" | \"Unchanged\";\n\nexport const writeFileString = (\n filePath: string,\n contents: string,\n): Effect.Effect<WriteChange, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n return \"Added\";\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n return \"Modified\";\n }\n return \"Unchanged\";\n });\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: string[];\n}) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n const directoryPath = path.dirname(modulePath);\n if (!(yield* fs.exists(directoryPath))) {\n yield* fs.makeDirectory(directoryPath, { recursive: true });\n }\n\n const registeredFunctionsPath = path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions.ts\",\n );\n const registeredFunctionsImportPath = yield* removePathExtension(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n\n const functionsContentsString = yield* templates.functions({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n });\n\n if (!(yield* fs.exists(modulePath))) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Added\" as const;\n }\n const existing = yield* fs.readFileString(modulePath);\n if (existing !== functionsContentsString) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Modified\" as const;\n }\n return \"Unchanged\" as const;\n });\n\nconst logGroupPaths = <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(groupPaths, (gp) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n });\n\nexport const generateFunctions = (spec: Spec.AnyWithProps) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n const functionPaths = FunctionPaths.make(spec);\n const groupPathsFromSpec = FunctionPaths.groupPaths(functionPaths);\n\n const overlappingGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.intersection(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* Effect.forEach(overlappingGroupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n const result = yield* generateGroupModule({ groupPath, functionNames });\n if (result === \"Modified\") {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n yield* logFileModified(\n path.join(convexDirectory, relativeModulePath),\n );\n }\n }),\n );\n\n const extinctGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* removeGroups(extinctGroupPaths);\n yield* logGroupPaths(extinctGroupPaths, logFileRemoved);\n\n const newGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromSpec, groupPathsFromFs),\n );\n yield* writeGroups(spec, newGroupPaths);\n yield* logGroupPaths(newGroupPaths, logFileAdded);\n\n return functionPaths;\n });\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n ]);\n\n const allConvexPaths = yield* fs.readDirectory(convexDirectory, {\n recursive: true,\n });\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)) &&\n path.basename(path.dirname(convexPath)) !== \"_generated\",\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return pipe(groupPathArray, HashSet.fromIterable, GroupPaths.GroupPaths.make);\n});\n\nexport const removeGroups = (groupPaths: GroupPaths.GroupPaths) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.all(\n HashSet.map(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);\n\n yield* fs.remove(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n });\n\nexport const writeGroups = (\n spec: Spec.AnyWithProps,\n groupPaths: GroupPaths.GroupPaths,\n) =>\n Effect.forEach(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n\n yield* Effect.logDebug(`Generating group ${groupPath}...`);\n yield* generateGroupModule({\n groupPath,\n functionNames,\n });\n yield* Effect.logDebug(`Group ${groupPath} generated`);\n }),\n );\n\nconst generateOptionalFile = (\n confectFile: string,\n convexFile: string,\n generateContents: (importPath: string) => Effect.Effect<string>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const confectFilePath = path.join(confectDirectory, confectFile);\n\n if (!(yield* fs.exists(confectFilePath))) {\n return Option.none();\n }\n\n const convexFilePath = path.join(convexDirectory, convexFile);\n const relativeImportPath = path.relative(\n path.dirname(convexFilePath),\n confectFilePath,\n );\n const importPathWithoutExt = yield* removePathExtension(relativeImportPath);\n const contents = yield* generateContents(importPathWithoutExt);\n const change = yield* writeFileString(convexFilePath, contents);\n return Option.some({ change, convexFilePath });\n });\n\nexport const generateHttp = generateOptionalFile(\n \"http.ts\",\n \"http.ts\",\n (importPath) => templates.http({ httpImportPath: importPath }),\n);\n\nexport const generateConvexConfig = generateOptionalFile(\n \"app.ts\",\n \"convex.config.ts\",\n (importPath) => templates.convexConfig({ appImportPath: importPath }),\n);\n\nexport const generateCrons = generateOptionalFile(\n \"crons.ts\",\n \"crons.ts\",\n (importPath) => templates.crons({ cronsImportPath: importPath }),\n);\n\nexport const generateAuthConfig = generateOptionalFile(\n \"auth.ts\",\n \"auth.config.ts\",\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n);\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,uBAAuB,YAClC,OAAO,IAAI,aAAa;CACtB,MAAM,OAAO,OAAO,KAAK;AAEzB,QAAO,OAAO,MAAM,GAAG,CAAC,KAAK,QAAQ,QAAQ,CAAC,OAAO,CAAC,QAAQ;EAC9D;AAEJ,MAAa,yBAAyB,UAAkB,aACtD,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;AAC7B,KAAI,EAAE,OAAO,GAAG,OAAO,SAAS,GAAG;AACjC,SAAO,GAAG,gBAAgB,UAAU,SAAS;AAC7C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C,eAAeE,KAAe,EAAE,gBAAgB,YAAY,CAAC,CAC/D;AAED,MAAa,uBAAuB,qBAClC,UACA,qBACC,eAAeC,aAAuB,EAAE,eAAe,YAAY,CAAC,CACtE;AAED,MAAa,gBAAgB,qBAC3B,YACA,aACC,eAAeC,MAAgB,EAAE,iBAAiB,YAAY,CAAC,CACjE;AAED,MAAa,qBAAqB,qBAChC,WACA,mBACC,eAAeC,WAAqB,EAAE,gBAAgB,YAAY,CAAC,CACrE"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["GroupPath.modulePath","modulePath","templates.functions","FunctionPaths.make","FunctionPaths.groupPaths","GroupPath.getGroupSpec","GroupPath.fromGroupModulePath","templates.http","templates.convexConfig","templates.crons","templates.authConfig"],"sources":["../src/utils.ts"],"sourcesContent":["import type { FunctionSpec, Spec } from \"@confect/core\";\nimport { FileSystem, Path } from \"@effect/platform\";\nimport type { PlatformError } from \"@effect/platform/Error\";\nimport {\n Array,\n Effect,\n HashSet,\n Option,\n Order,\n pipe,\n Record,\n String,\n} from \"effect\";\nimport * as FunctionPaths from \"./FunctionPaths\";\nimport * as GroupPath from \"./GroupPath\";\nimport * as GroupPaths from \"./GroupPaths\";\nimport { logFileAdded, logFileModified, logFileRemoved } from \"./log\";\nimport { ConfectDirectory } from \"./services/ConfectDirectory\";\nimport { ConvexDirectory } from \"./services/ConvexDirectory\";\nimport * as templates from \"./templates\";\n\nexport const removePathExtension = (pathStr: string) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n\n return String.slice(0, -path.extname(pathStr).length)(pathStr);\n });\n\nexport const writeFileStringAndLog = (filePath: string, contents: string) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileAdded(filePath);\n return;\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n yield* logFileModified(filePath);\n }\n });\n\nexport const findProjectRoot = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n\n const startDir = path.resolve(\".\");\n const root = path.parse(startDir).root;\n\n const directories = Array.unfold(startDir, (dir) =>\n dir === root\n ? Option.none()\n : Option.some([dir, path.dirname(dir)] as const),\n );\n\n const projectRoot = yield* Effect.findFirst(directories, (dir) =>\n fs.exists(path.join(dir, \"package.json\")),\n );\n\n return Option.getOrElse(projectRoot, () => startDir);\n});\n\nexport type WriteChange = \"Added\" | \"Modified\" | \"Unchanged\";\n\nexport const writeFileString = (\n filePath: string,\n contents: string,\n): Effect.Effect<WriteChange, PlatformError, FileSystem.FileSystem> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n\n if (!(yield* fs.exists(filePath))) {\n yield* fs.writeFileString(filePath, contents);\n return \"Added\";\n }\n const existing = yield* fs.readFileString(filePath);\n if (existing !== contents) {\n yield* fs.writeFileString(filePath, contents);\n return \"Modified\";\n }\n return \"Unchanged\";\n });\n\nexport const generateGroupModule = ({\n groupPath,\n functionNames,\n}: {\n groupPath: GroupPath.GroupPath;\n functionNames: string[];\n}) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n const directoryPath = path.dirname(modulePath);\n if (!(yield* fs.exists(directoryPath))) {\n yield* fs.makeDirectory(directoryPath, { recursive: true });\n }\n\n const registeredFunctionsPath = path.join(\n confectDirectory,\n \"_generated\",\n \"registeredFunctions.ts\",\n );\n const registeredFunctionsImportPath = yield* removePathExtension(\n path.relative(path.dirname(modulePath), registeredFunctionsPath),\n );\n\n const functionsContentsString = yield* templates.functions({\n groupPath,\n functionNames,\n registeredFunctionsImportPath,\n });\n\n if (!(yield* fs.exists(modulePath))) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Added\" as const;\n }\n const existing = yield* fs.readFileString(modulePath);\n if (existing !== functionsContentsString) {\n yield* fs.writeFileString(modulePath, functionsContentsString);\n return \"Modified\" as const;\n }\n return \"Unchanged\" as const;\n });\n\nconst logGroupPaths = <R>(\n groupPaths: GroupPaths.GroupPaths,\n logFn: (fullPath: string) => Effect.Effect<void, never, R>,\n) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.forEach(groupPaths, (gp) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(gp);\n yield* logFn(path.join(convexDirectory, relativeModulePath));\n }),\n );\n });\n\nexport const generateFunctions = (spec: Spec.AnyWithProps) =>\n Effect.gen(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const groupPathsFromFs = yield* getGroupPathsFromFs;\n const functionPaths = FunctionPaths.make(spec);\n const groupPathsFromSpec = FunctionPaths.groupPaths(functionPaths);\n\n const overlappingGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.intersection(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* Effect.forEach(overlappingGroupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n const result = yield* generateGroupModule({ groupPath, functionNames });\n if (result === \"Modified\") {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n yield* logFileModified(\n path.join(convexDirectory, relativeModulePath),\n );\n }\n }),\n );\n\n const extinctGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromFs, groupPathsFromSpec),\n );\n yield* removeGroups(extinctGroupPaths);\n yield* logGroupPaths(extinctGroupPaths, logFileRemoved);\n\n const newGroupPaths = GroupPaths.GroupPaths.make(\n HashSet.difference(groupPathsFromSpec, groupPathsFromFs),\n );\n yield* writeGroups(spec, newGroupPaths);\n yield* logGroupPaths(newGroupPaths, logFileAdded);\n\n return functionPaths;\n });\n\nconst getGroupPathsFromFs = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const RESERVED_CONVEX_TS_FILE_NAMES = new Set([\n \"schema.ts\",\n \"http.ts\",\n \"crons.ts\",\n \"auth.config.ts\",\n \"convex.config.ts\",\n ]);\n\n const allConvexPaths = yield* fs.readDirectory(convexDirectory, {\n recursive: true,\n });\n const groupPathArray = yield* pipe(\n allConvexPaths,\n Array.filter(\n (convexPath) =>\n path.extname(convexPath) === \".ts\" &&\n !RESERVED_CONVEX_TS_FILE_NAMES.has(path.basename(convexPath)) &&\n path.basename(path.dirname(convexPath)) !== \"_generated\",\n ),\n Effect.forEach((groupModulePath) =>\n GroupPath.fromGroupModulePath(groupModulePath),\n ),\n );\n return pipe(groupPathArray, HashSet.fromIterable, GroupPaths.GroupPaths.make);\n});\n\nexport const removeGroups = (groupPaths: GroupPaths.GroupPaths) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n\n yield* Effect.all(\n HashSet.map(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const relativeModulePath = yield* GroupPath.modulePath(groupPath);\n const modulePath = path.join(convexDirectory, relativeModulePath);\n\n yield* Effect.logDebug(`Removing group '${relativeModulePath}'...`);\n\n yield* fs.remove(modulePath);\n yield* Effect.logDebug(`Group '${relativeModulePath}' removed`);\n }),\n ),\n { concurrency: \"unbounded\" },\n );\n });\n\nexport const writeGroups = (\n spec: Spec.AnyWithProps,\n groupPaths: GroupPaths.GroupPaths,\n) =>\n Effect.forEach(groupPaths, (groupPath) =>\n Effect.gen(function* () {\n const group = yield* GroupPath.getGroupSpec(spec, groupPath);\n\n const functionNames = pipe(\n group.functions,\n Record.values,\n Array.sortBy(\n Order.mapInput(\n Order.string,\n (fn: FunctionSpec.AnyWithProps) => fn.name,\n ),\n ),\n Array.map((fn) => fn.name),\n );\n\n yield* Effect.logDebug(`Generating group ${groupPath}...`);\n yield* generateGroupModule({\n groupPath,\n functionNames,\n });\n yield* Effect.logDebug(`Group ${groupPath} generated`);\n }),\n );\n\nconst generateOptionalFile = (\n confectFile: string,\n convexFile: string,\n generateContents: (importPath: string) => Effect.Effect<string>,\n) =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const convexDirectory = yield* ConvexDirectory.get;\n\n const confectFilePath = path.join(confectDirectory, confectFile);\n\n if (!(yield* fs.exists(confectFilePath))) {\n return Option.none();\n }\n\n const convexFilePath = path.join(convexDirectory, convexFile);\n const relativeImportPath = path.relative(\n path.dirname(convexFilePath),\n confectFilePath,\n );\n const importPathWithoutExt = yield* removePathExtension(relativeImportPath);\n const contents = yield* generateContents(importPathWithoutExt);\n const change = yield* writeFileString(convexFilePath, contents);\n return Option.some({ change, convexFilePath });\n });\n\nexport const generateHttp = generateOptionalFile(\n \"http.ts\",\n \"http.ts\",\n (importPath) => templates.http({ httpImportPath: importPath }),\n);\n\nexport const generateConvexConfig = generateOptionalFile(\n \"app.ts\",\n \"convex.config.ts\",\n (importPath) => templates.convexConfig({ appImportPath: importPath }),\n);\n\nexport const generateCrons = generateOptionalFile(\n \"crons.ts\",\n \"crons.ts\",\n (importPath) => templates.crons({ cronsImportPath: importPath }),\n);\n\nexport const generateAuthConfig = generateOptionalFile(\n \"auth.ts\",\n \"auth.config.ts\",\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n);\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,uBAAuB,YAClC,OAAO,IAAI,aAAa;CACtB,MAAM,OAAO,OAAO,KAAK;AAEzB,QAAO,OAAO,MAAM,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iBAAiB,WAAW;CAO7D,MAAM,SAAS,OAAO,gBAAgB,gBADrB,OAAO,iBADK,OAAO,oBAJT,KAAK,SAC9B,KAAK,QAAQ,eAAe,EAC5B,gBACD,CAC0E,CACb,CACC;AAC/D,QAAO,OAAO,KAAK;EAAE;EAAQ;EAAgB,CAAC;EAC9C;AAEJ,MAAa,eAAe,qBAC1B,WACA,YACC,eAAeE,KAAe,EAAE,gBAAgB,YAAY,CAAC,CAC/D;AAED,MAAa,uBAAuB,qBAClC,UACA,qBACC,eAAeC,aAAuB,EAAE,eAAe,YAAY,CAAC,CACtE;AAED,MAAa,gBAAgB,qBAC3B,YACA,aACC,eAAeC,MAAgB,EAAE,iBAAiB,YAAY,CAAC,CACjE;AAED,MAAa,qBAAqB,qBAChC,WACA,mBACC,eAAeC,WAAqB,EAAE,gBAAgB,YAAY,CAAC,CACrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/cli",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.2",
|
|
4
4
|
"description": "Developer tooling for codegen and sync",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,34 +38,37 @@
|
|
|
38
38
|
"author": "RJ Dellecese",
|
|
39
39
|
"license": "ISC",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@effect/cli": "^0.
|
|
41
|
+
"@effect/cli": "^0.73.2",
|
|
42
|
+
"@effect/platform-node": "0.104.1",
|
|
43
|
+
"@effect/platform-node-shared": "0.57.1",
|
|
42
44
|
"@effect/printer": "^0.47.0",
|
|
43
45
|
"@effect/printer-ansi": "^0.47.0",
|
|
44
46
|
"code-block-writer": "^13.0.3",
|
|
45
|
-
"esbuild": "^0.
|
|
46
|
-
"tsx": "^4.
|
|
47
|
+
"esbuild": "^0.27.3",
|
|
48
|
+
"tsx": "^4.21.0"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
|
-
"@effect/language-service": "0.
|
|
50
|
-
"@effect/platform
|
|
51
|
+
"@effect/language-service": "0.73.1",
|
|
52
|
+
"@effect/platform": "0.94.4",
|
|
51
53
|
"@effect/vitest": "0.27.0",
|
|
52
|
-
"@eslint/js": "9.39.
|
|
53
|
-
"@types/node": "
|
|
54
|
+
"@eslint/js": "9.39.2",
|
|
55
|
+
"@types/node": "25.2.3",
|
|
54
56
|
"@vitest/coverage-v8": "3.2.4",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
57
|
+
"effect": "3.19.16",
|
|
58
|
+
"eslint": "9.39.2",
|
|
59
|
+
"prettier": "3.8.1",
|
|
60
|
+
"tsdown": "0.20.3",
|
|
58
61
|
"typescript": "5.9.3",
|
|
59
|
-
"typescript-eslint": "8.
|
|
60
|
-
"vite": "7.
|
|
61
|
-
"vite-tsconfig-paths": "
|
|
62
|
+
"typescript-eslint": "8.55.0",
|
|
63
|
+
"vite": "7.3.1",
|
|
64
|
+
"vite-tsconfig-paths": "6.1.1",
|
|
62
65
|
"vitest": "3.2.4"
|
|
63
66
|
},
|
|
64
67
|
"peerDependencies": {
|
|
65
|
-
"@effect/platform": "^0.
|
|
66
|
-
"effect": "^3.19.
|
|
67
|
-
"@confect/core": "1.0.0-next.
|
|
68
|
-
"@confect/server": "1.0.0-next.
|
|
68
|
+
"@effect/platform": "^0.94.4",
|
|
69
|
+
"effect": "^3.19.16",
|
|
70
|
+
"@confect/core": "1.0.0-next.2",
|
|
71
|
+
"@confect/server": "1.0.0-next.2"
|
|
69
72
|
},
|
|
70
73
|
"engines": {
|
|
71
74
|
"node": ">=22",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
-
key = keys[i];
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
export { };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { layer as layer$1 } from "./internal/commandExecutor.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeCommandExecutor.js
|
|
4
|
-
/**
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
* @category layer
|
|
7
|
-
*/
|
|
8
|
-
const layer = layer$1;
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { layer };
|
|
12
|
-
//# sourceMappingURL=NodeCommandExecutor.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeCommandExecutor.mjs","names":["internal.layer"],"sources":["../../../../../../../../../../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeCommandExecutor.js"],"sourcesContent":["import * as internal from \"./internal/commandExecutor.js\";\n/**\n * @since 1.0.0\n * @category layer\n */\nexport const layer = internal.layer;\n//# sourceMappingURL=NodeCommandExecutor.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;AAKA,MAAa,QAAQA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { layer as layer$1 } from "./internal/fileSystem.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeFileSystem.js
|
|
4
|
-
/**
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @since 1.0.0
|
|
9
|
-
* @category layer
|
|
10
|
-
*/
|
|
11
|
-
const layer = layer$1;
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { layer };
|
|
15
|
-
//# sourceMappingURL=NodeFileSystem.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeFileSystem.mjs","names":["internal.layer"],"sources":["../../../../../../../../../../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeFileSystem.js"],"sourcesContent":["/**\n * @since 1.0.0\n */\nimport * as internal from \"./internal/fileSystem.js\";\n/**\n * @since 1.0.0\n * @category layer\n */\nexport const layer = internal.layer;\n//# sourceMappingURL=NodeFileSystem.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;AAQA,MAAa,QAAQA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { layer as layer$1, layerPosix as layerPosix$1, layerWin32 as layerWin32$1 } from "./internal/path.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodePath.js
|
|
4
|
-
/**
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @since 1.0.0
|
|
9
|
-
* @category layer
|
|
10
|
-
*/
|
|
11
|
-
const layer = layer$1;
|
|
12
|
-
/**
|
|
13
|
-
* @since 1.0.0
|
|
14
|
-
* @category layer
|
|
15
|
-
*/
|
|
16
|
-
const layerPosix = layerPosix$1;
|
|
17
|
-
/**
|
|
18
|
-
* @since 1.0.0
|
|
19
|
-
* @category layer
|
|
20
|
-
*/
|
|
21
|
-
const layerWin32 = layerWin32$1;
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { layer };
|
|
25
|
-
//# sourceMappingURL=NodePath.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodePath.mjs","names":["internal.layer","internal.layerPosix","internal.layerWin32"],"sources":["../../../../../../../../../../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodePath.js"],"sourcesContent":["/**\n * @since 1.0.0\n */\nimport * as internal from \"./internal/path.js\";\n/**\n * @since 1.0.0\n * @category layer\n */\nexport const layer = internal.layer;\n/**\n * @since 1.0.0\n * @category layer\n */\nexport const layerPosix = internal.layerPosix;\n/**\n * @since 1.0.0\n * @category layer\n */\nexport const layerWin32 = internal.layerWin32;\n//# sourceMappingURL=NodePath.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;AAQA,MAAa,QAAQA;;;;;AAKrB,MAAa,aAAaC;;;;;AAK1B,MAAa,aAAaC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { runMain as runMain$1 } from "./internal/runtime.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeRuntime.js
|
|
4
|
-
/**
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
* @category runtime
|
|
7
|
-
*/
|
|
8
|
-
const runMain = runMain$1;
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { runMain };
|
|
12
|
-
//# sourceMappingURL=NodeRuntime.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeRuntime.mjs","names":["internal.runMain"],"sources":["../../../../../../../../../../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeRuntime.js"],"sourcesContent":["import * as internal from \"./internal/runtime.js\";\n/**\n * @since 1.0.0\n * @category runtime\n */\nexport const runMain = internal.runMain;\n//# sourceMappingURL=NodeRuntime.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;AAKA,MAAa,UAAUA"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { layer as layer$1, make as make$1 } from "./internal/terminal.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@effect+platform-node-shared@0.53.0_@effect+cluster@0.52.9_@effect+platform@0.93.2_effe_e0eeb3aae5ffec3060feb87d17ffb17c/node_modules/@effect/platform-node-shared/dist/esm/NodeTerminal.js
|
|
4
|
-
/**
|
|
5
|
-
* @since 1.0.0
|
|
6
|
-
* @category constructors
|
|
7
|
-
*/
|
|
8
|
-
const make = make$1;
|
|
9
|
-
/**
|
|
10
|
-
* @since 1.0.0
|
|
11
|
-
* @category layer
|
|
12
|
-
*/
|
|
13
|
-
const layer = layer$1;
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { layer };
|
|
17
|
-
//# sourceMappingURL=NodeTerminal.mjs.map
|