@gaganref/confect-cli 0.0.0-stage → 10.3.1-fork.10
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 +1824 -0
- package/LICENSE +7 -0
- package/README.md +16 -2
- package/bin/confect.mjs +26 -0
- package/dist/Ansi.mjs +18 -0
- package/dist/Ansi.mjs.map +1 -0
- package/dist/BuildError.mjs +30 -0
- package/dist/BuildError.mjs.map +1 -0
- package/dist/Bundler.mjs +426 -0
- package/dist/Bundler.mjs.map +1 -0
- package/dist/CodeBlockWriter.mjs +55 -0
- package/dist/CodeBlockWriter.mjs.map +1 -0
- package/dist/CodegenError.mjs +194 -0
- package/dist/CodegenError.mjs.map +1 -0
- package/dist/ConfectDirectory.mjs +35 -0
- package/dist/ConfectDirectory.mjs.map +1 -0
- package/dist/ConvexConfig.mjs +198 -0
- package/dist/ConvexConfig.mjs.map +1 -0
- package/dist/ConvexDirectory.mjs +54 -0
- package/dist/ConvexDirectory.mjs.map +1 -0
- package/dist/Declaration.mjs +258 -0
- package/dist/Declaration.mjs.map +1 -0
- package/dist/DirectoryOptions.mjs +42 -0
- package/dist/DirectoryOptions.mjs.map +1 -0
- package/dist/DocName.mjs +25 -0
- package/dist/DocName.mjs.map +1 -0
- package/dist/EntryPoint.mjs +111 -0
- package/dist/EntryPoint.mjs.map +1 -0
- package/dist/Evaluation.mjs +117 -0
- package/dist/Evaluation.mjs.map +1 -0
- package/dist/EvaluationWorker.mjs +46 -0
- package/dist/EvaluationWorker.mjs.map +1 -0
- package/dist/FunctionModule.mjs +137 -0
- package/dist/FunctionModule.mjs.map +1 -0
- package/dist/FunctionPath.mjs +18 -0
- package/dist/FunctionPath.mjs.map +1 -0
- package/dist/FunctionPaths.mjs +45 -0
- package/dist/FunctionPaths.mjs.map +1 -0
- package/dist/GenerationSnapshot.mjs +183 -0
- package/dist/GenerationSnapshot.mjs.map +1 -0
- package/dist/GroupPath.mjs +51 -0
- package/dist/GroupPath.mjs.map +1 -0
- package/dist/GroupPaths.mjs +8 -0
- package/dist/GroupPaths.mjs.map +1 -0
- package/dist/ImplModulePath.mjs +8 -0
- package/dist/ImplModulePath.mjs.map +1 -0
- package/dist/LeafModule.mjs +285 -0
- package/dist/LeafModule.mjs.map +1 -0
- package/dist/ProjectRoot.mjs +38 -0
- package/dist/ProjectRoot.mjs.map +1 -0
- package/dist/RelativeModulePath.mjs +13 -0
- package/dist/RelativeModulePath.mjs.map +1 -0
- package/dist/Remove.mjs +24 -0
- package/dist/Remove.mjs.map +1 -0
- package/dist/RestoreWatcher.mjs +31 -0
- package/dist/RestoreWatcher.mjs.map +1 -0
- package/dist/Rollback.mjs +50 -0
- package/dist/Rollback.mjs.map +1 -0
- package/dist/SnapshotError.mjs +21 -0
- package/dist/SnapshotError.mjs.map +1 -0
- package/dist/SpecAssemblyNode.mjs +91 -0
- package/dist/SpecAssemblyNode.mjs.map +1 -0
- package/dist/SpecModulePath.mjs +10 -0
- package/dist/SpecModulePath.mjs.map +1 -0
- package/dist/SyncState.mjs +122 -0
- package/dist/SyncState.mjs.map +1 -0
- package/dist/TableModule.mjs +97 -0
- package/dist/TableModule.mjs.map +1 -0
- package/dist/TableModulePath.mjs +8 -0
- package/dist/TableModulePath.mjs.map +1 -0
- package/dist/WatchBuild.mjs +190 -0
- package/dist/WatchBuild.mjs.map +1 -0
- package/dist/WatchGraph.mjs +35 -0
- package/dist/WatchGraph.mjs.map +1 -0
- package/dist/WatchTopology.mjs +55 -0
- package/dist/WatchTopology.mjs.map +1 -0
- package/dist/Watcher.mjs +377 -0
- package/dist/Watcher.mjs.map +1 -0
- package/dist/cliApp.mjs +9 -0
- package/dist/cliApp.mjs.map +1 -0
- package/dist/confect/codegen.mjs +570 -0
- package/dist/confect/codegen.mjs.map +1 -0
- package/dist/confect/declaration.mjs +219 -0
- package/dist/confect/declaration.mjs.map +1 -0
- package/dist/confect/dev.mjs +182 -0
- package/dist/confect/dev.mjs.map +1 -0
- package/dist/confect.mjs +9 -0
- package/dist/confect.mjs.map +1 -0
- package/dist/index.mjs +19 -0
- package/dist/index.mjs.map +1 -0
- package/dist/log.mjs +107 -0
- package/dist/log.mjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/templates.mjs +448 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/utils.mjs +105 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +51 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.mjs","names":["Ansi.green","Ansi.red","Ansi.magenta","Ansi.blackBright","FunctionPaths.diff","Evaluation.loadPreviousFunctionPaths","Watcher.make","DirectoryOptions.flags","DirectoryOptions.layer","SyncState.isDirty","SyncState.forBackend","SyncState.plan","GenerationSnapshot.functionPaths","Evaluation.catchAndLog","Watcher.isRefreshSuccessful","Evaluation.EvaluationError","validate","Evaluation.validate","Evaluation.generateSnapshot","Evaluation.updateDeclarations","SyncState.transition","SyncState.shouldRetry","SyncState.needsDeploymentNotification"],"sources":["../../src/confect/dev.ts"],"sourcesContent":["import * as Command from \"effect/cli/Command\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Console from \"effect/Console\";\nimport * as Effect from \"effect/Effect\";\nimport * as Equal from \"effect/Equal\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Order from \"effect/Order\";\nimport * as Ref from \"effect/Ref\";\nimport * as Result from \"effect/Result\";\nimport * as String from \"effect/String\";\nimport type * as esbuild from \"esbuild\";\nimport * as Ansi from \"../Ansi.js\";\nimport { renderCodegenError } from \"../CodegenError.js\";\nimport * as SyncState from \"../SyncState.js\";\nimport type { OptionalFile } from \"../EntryPoint.js\";\nimport * as Watcher from \"../Watcher.js\";\nimport * as Evaluation from \"../Evaluation.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as DirectoryOptions from \"../DirectoryOptions.js\";\nimport * as FunctionPaths from \"../FunctionPaths.js\";\nimport * as GenerationSnapshot from \"../GenerationSnapshot.js\";\nimport type { ImplModulePath } from \"../ImplModulePath.js\";\nimport type * as GroupPath from \"../GroupPath.js\";\nimport type * as GroupPaths from \"../GroupPaths.js\";\nimport {\n logCoalescedBuildErrors,\n logCoalescedBuildWarnings,\n logFunctionAdded,\n logFunctionRemoved,\n logPending,\n logSuccess,\n} from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport { preserveComponentOutput } from \"../Rollback.js\";\nimport {\n generateAuthConfig,\n generateCrons,\n generateHttp,\n touchConvexSchema,\n} from \"../utils.js\";\nimport { isDeclared } from \"./declaration.js\";\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.magenta })),\n Match.exhaustive,\n );\n\nconst logFileChangeIndented = Effect.fnUntraced(function* (\n change: \"Added\" | \"Removed\" | \"Modified\",\n fullPath: string,\n) {\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 `${color(char)} ${Ansi.blackBright(prefix)}${color(suffix)}`,\n );\n});\n\nconst logFunctionPathDiff = Effect.fnUntraced(function* (\n previous: FunctionPaths.FunctionPaths,\n current: FunctionPaths.FunctionPaths,\n) {\n const {\n functionsAdded,\n functionsRemoved,\n groupsRemoved,\n groupsAdded,\n groupsChanged,\n } = FunctionPaths.diff(previous, current);\n\n const logForGroups = (\n groupPaths: GroupPaths.GroupPaths,\n fnPaths: FunctionPaths.FunctionPaths,\n logFn: typeof logFunctionAdded,\n ) =>\n Effect.forEach(groupPaths, (gp) =>\n Effect.forEach(\n Array.fromIterable(\n HashSet.filter(fnPaths, (fp) => Equal.equals(fp.groupPath, gp)),\n ),\n logFn,\n ),\n );\n\n yield* logForGroups(groupsRemoved, functionsRemoved, logFunctionRemoved);\n yield* logForGroups(groupsAdded, functionsAdded, logFunctionAdded);\n yield* Effect.forEach(\n groupsChanged,\n Effect.fnUntraced(function* (gp: GroupPath.GroupPath) {\n yield* Effect.forEach(\n Array.fromIterable(\n HashSet.filter(functionsAdded, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n logFunctionAdded,\n );\n yield* Effect.forEach(\n Array.fromIterable(\n HashSet.filter(functionsRemoved, (fp) =>\n Equal.equals(fp.groupPath, gp),\n ),\n ),\n logFunctionRemoved,\n );\n }),\n );\n});\n\nexport const devHandler = Effect.gen(function* () {\n yield* logPending(\"Performing initial sync…\");\n const previousFunctionPaths = yield* Evaluation.loadPreviousFunctionPaths;\n\n const watcher = yield* Watcher.make();\n\n yield* Effect.all([watcher.run, syncLoop(previousFunctionPaths, watcher)], {\n concurrency: \"unbounded\",\n });\n});\n\nexport const dev = Command.make(\n \"dev\",\n DirectoryOptions.flags,\n () => devHandler,\n).pipe(\n Command.withDescription(\"Start the Confect development server\"),\n Command.provide(DirectoryOptions.layer),\n);\n\nconst esbuildMessageKey = (m: esbuild.Message): string =>\n `${m.location?.file ?? \"\"}:${m.location?.line ?? \"\"}:${m.location?.column ?? \"\"}:${m.text}`;\n\nconst dedupeWatcherMessages = (\n messages: ReadonlyArray<esbuild.Message>,\n): ReadonlyArray<esbuild.Message> =>\n pipe(\n messages,\n Array.dedupeWith(\n (messageA, messageB) =>\n esbuildMessageKey(messageA) === esbuildMessageKey(messageB),\n ),\n );\n\nconst watcherMessagesSignature = (\n messages: ReadonlyArray<esbuild.Message>,\n): string =>\n pipe(\n messages,\n Array.map(esbuildMessageKey),\n Array.dedupe,\n Array.sort(Order.String),\n Array.join(\"\\n\"),\n );\n\n/**\n * Log any watcher messages (errors or warnings) that haven't already been\n * logged at their current signature. Suppresses the per-watcher fanout that\n * happens when one root cause (e.g. a missing import) breaks every entry\n * point's build at the same source location.\n */\nconst logChangedWatcherMessages = Effect.fnUntraced(function* (\n messages: ReadonlyArray<esbuild.Message>,\n lastLoggedSignatureRef: Ref.Ref<string>,\n log: (messages: ReadonlyArray<esbuild.Message>) => Effect.Effect<void>,\n) {\n const signature = watcherMessagesSignature(messages);\n const previous = yield* Ref.get(lastLoggedSignatureRef);\n if (signature === previous) return;\n yield* Ref.set(lastLoggedSignatureRef, signature);\n if (messages.length === 0) return;\n yield* log(dedupeWatcherMessages(messages));\n});\n\nconst syncLoop = Effect.fnUntraced(function* (\n initialFunctionPaths: FunctionPaths.FunctionPaths,\n watcher: Watcher.Watcher,\n) {\n const functionPathsRef = yield* Ref.make(initialFunctionPaths);\n const lastLoggedErrorsRef = yield* Ref.make<string>(\"\");\n const lastLoggedWarningsRef = yield* Ref.make<string>(\"\");\n const phaseRef = yield* Ref.make<SyncState.Phase>(\n SyncState.Phase.Bootstrapping(),\n );\n const optionalPendingRef = yield* Ref.make(HashSet.empty<OptionalFile>());\n const logMessages = Effect.gen(function* () {\n const { errors, warnings } = yield* watcher.diagnostics;\n yield* logChangedWatcherMessages(\n errors,\n lastLoggedErrorsRef,\n logCoalescedBuildErrors,\n );\n yield* logChangedWatcherMessages(\n warnings,\n lastLoggedWarningsRef,\n logCoalescedBuildWarnings,\n );\n });\n\n return yield* Effect.forever(\n Effect.gen(function* () {\n yield* Effect.logDebug(\"Running sync loop…\");\n const taken = yield* watcher.next;\n\n const phase = yield* Ref.get(phaseRef);\n const firstSync = SyncState.Phase.$is(\"Bootstrapping\")(phase);\n if (!firstSync) yield* logMessages;\n\n if (!SyncState.isDirty(taken)) return;\n\n const declared = yield* isDeclared;\n const pending = SyncState.forBackend(\n {\n ...taken,\n optional: yield* Ref.updateAndGet(\n optionalPendingRef,\n HashSet.union(taken.optional),\n ),\n },\n {\n declared,\n component: (yield* ConvexDirectory.target).kind === \"component\",\n },\n );\n const optional = pending.optional;\n const operation = SyncState.plan(phase, pending);\n yield* Effect.logDebug(\"Planned development sync\").pipe(\n Effect.annotateLogs({\n phase: phase._tag,\n work: pending.work._tag,\n operation: operation._tag,\n }),\n );\n if (\n !firstSync &&\n !(\n SyncState.Operation.$is(\"Validate\")(operation) &&\n operation.paths.length === 0\n )\n )\n yield* logPending(\"Dependencies may have changed, reloading…\");\n\n const regenerate = <R>(\n generation: Effect.Effect<\n GenerationSnapshot.GenerationSnapshot,\n Effect.Error<typeof Evaluation.generateSnapshot>,\n R\n >,\n ) =>\n Effect.gen(function* () {\n const current = yield* generation.pipe(\n Effect.tap((snapshot) =>\n Effect.gen(function* () {\n const nextFunctionPaths =\n GenerationSnapshot.functionPaths(snapshot);\n const previous = yield* Ref.get(functionPathsRef);\n yield* logFunctionPathDiff(previous, nextFunctionPaths);\n yield* Ref.set(functionPathsRef, nextFunctionPaths);\n }),\n ),\n Evaluation.catchAndLog,\n );\n if (Option.isNone(current)) {\n return SyncState.Outcome.GenerationFailed();\n }\n const refreshed = yield* watcher.refresh.pipe(Effect.result);\n if (Result.isFailure(refreshed)) {\n yield* Console.error(\n `Dependency watcher could not ${refreshed.failure.operation}: ${globalThis.String(refreshed.failure.cause)}`,\n );\n return SyncState.Outcome.ReconciliationFailed();\n }\n if (!Watcher.isRefreshSuccessful(refreshed.success)) {\n yield* logMessages;\n return SyncState.Outcome.ReconciliationFailed();\n }\n return SyncState.Outcome.Succeeded({ snapshot: current.value });\n });\n const preserved = <R>(\n generation: Effect.Effect<\n GenerationSnapshot.GenerationSnapshot,\n Effect.Error<typeof Evaluation.generateSnapshot>,\n R\n >,\n ) =>\n preserveComponentOutput(generation, watcher.duringRestore).pipe(\n Effect.tapErrorTag(\n \"ComponentNodeGroupError\",\n () => watcher.discardRestoreEchoes,\n ),\n Effect.catchTags({\n RemoveBusyError: (error) =>\n Effect.fail(\n new Evaluation.EvaluationError({\n diagnostic: renderCodegenError(error),\n }),\n ),\n // Output that cannot be restored leaves nothing to serve.\n PlatformError: Effect.die,\n }),\n );\n const validate = (\n paths: ReadonlyArray<ImplModulePath>,\n snapshot: GenerationSnapshot.GenerationSnapshot,\n ) =>\n Effect.gen(function* () {\n if (Array.isReadonlyArrayNonEmpty(paths)) {\n const validated = yield* Evaluation.validate(paths).pipe(\n Evaluation.catchAndLog,\n );\n if (Option.isNone(validated)) {\n return SyncState.Outcome.ValidationFailed({ paths, snapshot });\n }\n }\n return SyncState.Outcome.Succeeded({ snapshot });\n });\n const outcome = yield* SyncState.Operation.$match(operation, {\n Generate: () => regenerate(preserved(Evaluation.generateSnapshot)),\n Validate: ({ paths, snapshot }) => validate(paths, snapshot),\n Update: ({ snapshot, declarations, paths }) =>\n regenerate(\n preserved(\n Evaluation.updateDeclarations(snapshot, declarations, paths),\n ),\n ),\n });\n yield* Ref.set(phaseRef, SyncState.transition(outcome));\n if (SyncState.shouldRetry(phase, outcome)) {\n yield* watcher.requestRetry;\n }\n if (!SyncState.Outcome.$is(\"Succeeded\")(outcome)) return;\n\n const dirtyOptionalFiles = [\n ...(HashSet.has(optional, \"Http\")\n ? [syncOptionalFile(generateHttp, \"http.ts\")]\n : []),\n ...(HashSet.has(optional, \"Crons\")\n ? [syncOptionalFile(generateCrons, \"crons.ts\")]\n : []),\n ...(HashSet.has(optional, \"Auth\")\n ? [syncOptionalFile(generateAuthConfig, \"auth.config.ts\")]\n : []),\n ];\n\n yield* Array.isReadonlyArrayNonEmpty(dirtyOptionalFiles)\n ? Effect.all(dirtyOptionalFiles, { concurrency: \"unbounded\" })\n : Effect.void;\n yield* Ref.set(optionalPendingRef, HashSet.empty());\n\n if (SyncState.needsDeploymentNotification(phase))\n yield* touchConvexSchema;\n\n if (!SyncState.isDirty(yield* watcher.pending)) {\n yield* logSuccess(\"Generated files are up-to-date\");\n }\n }),\n );\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.void),\n Match.whenOr(\"Added\", \"Modified\", (addedOrModified) =>\n logFileChangeIndented(addedOrModified, convexFilePath),\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 yield* logFileChangeIndented(\"Removed\", convexFilePath);\n }\n }),\n }),\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,cAAc,WAClB,MAAM,MAAM,MAAM,CAAC,CAAC,KAClB,MAAM,KAAK,gBAAgB;CAAE,MAAM;CAAK,OAAOA;AAAW,EAAE,GAC5D,MAAM,KAAK,kBAAkB;CAAE,MAAM;CAAK,OAAOC;AAAS,EAAE,GAC5D,MAAM,KAAK,mBAAmB;CAAE,MAAM;CAAK,OAAOC;AAAa,EAAE,GACjE,MAAM,UACR;AAEF,MAAM,wBAAwB,OAAO,WAAW,WAC9C,QACA,UACA;CAIA,MAAM,UAAS,OAHY,YAAY,QAGV,OAFT,KAAK,KAAA,CAES;CAClC,MAAM,SAAS,KAAK,UAAU,OAAO,WAAW,MAAM,CAAC,IACnD,KAAK,UAAU,OAAO,MAAM,OAAO,MAAM,CAAC,IAC1C;CAEJ,MAAM,EAAE,MAAM,UAAU,WAAW,MAAM;CAEzC,OAAO,QAAQ,IACb,GAAG,MAAM,IAAI,EAAE,GAAGC,YAAiB,MAAM,IAAI,MAAM,MAAM,GAC3D;AACF,CAAC;AAED,MAAM,sBAAsB,OAAO,WAAW,WAC5C,UACA,SACA;CACA,MAAM,EACJ,gBACA,kBACA,e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AoB,QAAQ,MAAM,CAAC;EAElD,IAAIC,4BAAsC,KAAK,GAC7C,OAAO;EAET,IAAI,CAACb,QAAkB,OAAO,QAAQ,OAAO,GAC3C,OAAO,WAAW,gCAAgC;CAEtD,CAAC,CACH;AACF,CAAC;AAED,MAAM,oBAAoB,UAA+B,eACvD,KACE,UACA,OAAO,QACL,OAAO,MAAM;CACX,SAAS,EAAE,QAAQ,qBACjB,MAAM,MAAM,MAAM,CAAC,CAAC,KAClB,MAAM,KAAK,mBAAmB,OAAO,IAAI,GACzC,MAAM,OAAO,SAAS,aAAa,oBACjC,sBAAsB,iBAAiB,cAAc,CACvD,GACA,MAAM,UACR;CACF,cACE,OAAO,IAAI,aAAa;EACtB,MAAM,KAAK,OAAO,WAAW;EAC7B,MAAM,OAAO,OAAO,KAAK;EACzB,MAAM,kBAAkB,OAAO,gBAAgB;EAC/C,MAAM,iBAAiB,KAAK,KAAK,iBAAiB,UAAU;EAE5D,IAAI,OAAO,GAAG,OAAO,cAAc,GAAG;GACpC,OAAO,GAAG,OAAO,cAAc;GAC/B,OAAO,sBAAsB,WAAW,cAAc;EACxD;CACF,CAAC;AACL,CAAC,CACH,CACF"}
|
package/dist/confect.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { codegen } from "./confect/codegen.mjs";
|
|
2
|
+
import { dev } from "./confect/dev.mjs";
|
|
3
|
+
import * as Command from "effect/cli/Command";
|
|
4
|
+
//#region src/confect.ts
|
|
5
|
+
const confect = Command.make("confect").pipe(Command.withDescription("Generate and sync Confect files with Convex"), Command.withSubcommands([codegen, dev]));
|
|
6
|
+
//#endregion
|
|
7
|
+
export { confect };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=confect.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confect.mjs","names":[],"sources":["../src/confect.ts"],"sourcesContent":["import * as Command from \"effect/cli/Command\";\nimport { codegen } from \"./confect/codegen.js\";\nimport { dev } from \"./confect/dev.js\";\n\nexport const confect = Command.make(\"confect\").pipe(\n Command.withDescription(\"Generate and sync Confect files with Convex\"),\n Command.withSubcommands([codegen, dev]),\n);\n"],"mappings":";;;;AAIA,MAAa,UAAU,QAAQ,KAAK,SAAS,CAAC,CAAC,KAC7C,QAAQ,gBAAgB,6CAA6C,GACrE,QAAQ,gBAAgB,CAAC,SAAS,GAAG,CAAC,CACxC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cliApp } from "./cliApp.mjs";
|
|
3
|
+
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
4
|
+
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
const canReRaiseSignals = process.platform !== "win32";
|
|
8
|
+
let interrupted = false;
|
|
9
|
+
process.prependListener("SIGINT", () => {
|
|
10
|
+
interrupted = true;
|
|
11
|
+
});
|
|
12
|
+
process.on("exit", () => {
|
|
13
|
+
if (interrupted && canReRaiseSignals) process.kill(process.pid, "SIGINT");
|
|
14
|
+
});
|
|
15
|
+
cliApp.pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);
|
|
16
|
+
//#endregion
|
|
17
|
+
export {};
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as NodeServices from \"@effect/platform-node/NodeServices\";\nimport * as NodeRuntime from \"@effect/platform-node/NodeRuntime\";\nimport * as Effect from \"effect/Effect\";\nimport { cliApp } from \"./cliApp.js\";\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`.\nconst canReRaiseSignals = process.platform !== \"win32\";\n\nlet interrupted = false;\nprocess.prependListener(\"SIGINT\", () => {\n interrupted = true;\n});\nprocess.on(\"exit\", () => {\n if (interrupted && canReRaiseSignals) {\n process.kill(process.pid, \"SIGINT\");\n }\n});\n\ncliApp.pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);\n"],"mappings":";;;;;;AASA,MAAM,oBAAoB,QAAQ,aAAa;AAE/C,IAAI,cAAc;AAClB,QAAQ,gBAAgB,gBAAgB;CACtC,cAAc;AAChB,CAAC;AACD,QAAQ,GAAG,cAAc;CACvB,IAAI,eAAe,mBACjB,QAAQ,KAAK,QAAQ,KAAK,QAAQ;AAEtC,CAAC;AAED,OAAO,KAAK,OAAO,QAAQ,aAAa,KAAK,GAAG,YAAY,OAAO"}
|
package/dist/log.mjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { blackBright, green, red, yellow } from "./Ansi.mjs";
|
|
2
|
+
import { toString } from "./GroupPath.mjs";
|
|
3
|
+
import { ProjectRoot } from "./ProjectRoot.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Path from "effect/Path";
|
|
6
|
+
import * as Array from "effect/Array";
|
|
7
|
+
import { pipe } from "effect/Function";
|
|
8
|
+
import * as Match from "effect/Match";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as String from "effect/String";
|
|
11
|
+
import * as esbuild from "esbuild";
|
|
12
|
+
import * as Console from "effect/Console";
|
|
13
|
+
import * as Predicate from "effect/Predicate";
|
|
14
|
+
//#region src/log.ts
|
|
15
|
+
/**
|
|
16
|
+
* Render a relative path with the directory portion dimmed (`Ansi.blackBright`)
|
|
17
|
+
* and the file leaf rendered in the default terminal color.
|
|
18
|
+
*/
|
|
19
|
+
const formatPath = (relativePath) => {
|
|
20
|
+
const lastSep = Math.max(relativePath.lastIndexOf("/"), relativePath.lastIndexOf("\\"));
|
|
21
|
+
const dir = lastSep < 0 ? "" : relativePath.slice(0, lastSep + 1);
|
|
22
|
+
const leaf = lastSep < 0 ? relativePath : relativePath.slice(lastSep + 1);
|
|
23
|
+
return blackBright(dir) + leaf;
|
|
24
|
+
};
|
|
25
|
+
const logFile = (char, color) => Effect.fnUntraced(function* (fullPath) {
|
|
26
|
+
const prefix = (yield* ProjectRoot.get) + (yield* Path.Path).sep;
|
|
27
|
+
const suffix = pipe(fullPath, String.startsWith(prefix)) ? pipe(fullPath, String.slice(prefix.length)) : fullPath;
|
|
28
|
+
yield* Console.log(`${color(char)} ${blackBright(prefix)}${color(suffix)}`);
|
|
29
|
+
});
|
|
30
|
+
const logFileAdded = logFile("+", green);
|
|
31
|
+
const logFileRemoved = logFile("-", red);
|
|
32
|
+
const logFileModified = logFile("~", yellow);
|
|
33
|
+
const logFunction = (char, color) => (functionPath) => Console.log(` ${color(char)} ${blackBright(toString(functionPath.groupPath) + ".")}${color(functionPath.name)}`);
|
|
34
|
+
const logFunctionAdded = logFunction("+", green);
|
|
35
|
+
const logFunctionRemoved = logFunction("-", red);
|
|
36
|
+
const logStatus = (char, charColor) => (message) => Console.log(`${charColor(char)} ${message}`);
|
|
37
|
+
const logSuccess = logStatus("✔︎", green);
|
|
38
|
+
const logPending = logStatus("⭘", yellow);
|
|
39
|
+
const logWarn = logStatus("⚠", yellow);
|
|
40
|
+
const cross = red("✘");
|
|
41
|
+
const warningSign = yellow("⚠");
|
|
42
|
+
const gutter = (color) => color("│");
|
|
43
|
+
const errorGutter = gutter(red);
|
|
44
|
+
const withGutterBlock = (gutterChar) => (output) => pipe(String.split(output, "\n"), Array.map((line) => pipe(line, String.trim) === "" ? gutterChar : `${gutterChar} ${line}`), Array.join("\n"), (guttered) => `${gutterChar}\n${guttered}\n${gutterChar}`);
|
|
45
|
+
const withErrorGutterBlock = withGutterBlock(errorGutter);
|
|
46
|
+
const formatBuildMessage = (error, formattedMessage) => {
|
|
47
|
+
const lines = String.split(formattedMessage, "\n");
|
|
48
|
+
const redErrorText = red(error?.text ?? "");
|
|
49
|
+
const replaced = pipe(Array.findFirstIndex(lines, (l) => pipe(l, String.trim, String.isNonEmpty)), Option.flatMap((index) => Array.modify(lines, index, () => redErrorText)), Option.getOrElse(() => lines));
|
|
50
|
+
return pipe(replaced, Array.join("\n"));
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Render a list of esbuild messages into a styled, gutter-prefixed block.
|
|
54
|
+
*/
|
|
55
|
+
const formatEsbuildMessages = (errors, formattedMessages) => pipe(formattedMessages, Array.map((message, i) => formatBuildMessage(errors[i], message)), Array.join(""), String.trimEnd, withErrorGutterBlock);
|
|
56
|
+
const renderImportFailedError = (error) => {
|
|
57
|
+
const causeMessage = Predicate.isError(error.cause) ? error.cause.message : Predicate.isString(error.cause) ? error.cause : globalThis.String(error.cause);
|
|
58
|
+
const oneLineCause = pipe(String.split(causeMessage, "\n"), Array.findFirst((line) => pipe(line, String.trim, String.isNonEmpty)), Option.map(String.trim), Option.getOrElse(() => "unknown error"));
|
|
59
|
+
return `${cross} Failed to load bundled module ${formatPath(error.file)}: ${oneLineCause}; check the file's top-level imports and side effects.`;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Render a {@link BundleFailedError} as a multi-line, ANSI-styled string: a
|
|
63
|
+
* one-line `✘ <file>: build errors` header followed by the gutter-prefixed
|
|
64
|
+
* esbuild diagnostic block. Multi-line is appropriate here because a single
|
|
65
|
+
* `BundleFailedError` carries an array of distinct esbuild messages.
|
|
66
|
+
*/
|
|
67
|
+
const renderBundleFailedError = (error) => {
|
|
68
|
+
const messages = error.errors;
|
|
69
|
+
const formatted = esbuild.formatMessagesSync(messages, {
|
|
70
|
+
kind: "error",
|
|
71
|
+
color: true,
|
|
72
|
+
terminalWidth: 80
|
|
73
|
+
});
|
|
74
|
+
return `${`${cross} ${formatPath(error.file)}: build errors`}\n${formatEsbuildMessages(messages, formatted)}`;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Render any {@link BuildError} into a styled, ready-to-print string.
|
|
78
|
+
* `ImportFailedError` collapses to a single line; `BundleFailedError` expands
|
|
79
|
+
* to a header plus one diagnostic block per esbuild message.
|
|
80
|
+
*/
|
|
81
|
+
const renderBuildError = (error) => Match.value(error).pipe(Match.tag("BundleFailedError", renderBundleFailedError), Match.tag("ImportFailedError", renderImportFailedError), Match.exhaustive);
|
|
82
|
+
/**
|
|
83
|
+
* Render a flat list of esbuild messages as a single error block with a generic
|
|
84
|
+
* `✘ Build errors` header.
|
|
85
|
+
*/
|
|
86
|
+
const renderCoalescedBuildErrors = (messages) => {
|
|
87
|
+
const formatted = esbuild.formatMessagesSync(messages, {
|
|
88
|
+
kind: "error",
|
|
89
|
+
color: true,
|
|
90
|
+
terminalWidth: 80
|
|
91
|
+
});
|
|
92
|
+
return `${`${cross} Build errors`}\n${formatEsbuildMessages(messages, formatted)}`;
|
|
93
|
+
};
|
|
94
|
+
const logCoalescedBuildErrors = (messages) => messages.length === 0 ? Effect.void : Console.error(renderCoalescedBuildErrors(messages));
|
|
95
|
+
const renderCoalescedBuildWarnings = (messages) => {
|
|
96
|
+
const formatted = esbuild.formatMessagesSync(messages, {
|
|
97
|
+
kind: "warning",
|
|
98
|
+
color: true,
|
|
99
|
+
terminalWidth: 80
|
|
100
|
+
});
|
|
101
|
+
return `${`${warningSign} Build warnings`}\n${pipe(formatted, Array.join(""), String.trimEnd, withGutterBlock(gutter(yellow)))}`;
|
|
102
|
+
};
|
|
103
|
+
const logCoalescedBuildWarnings = (messages) => messages.length === 0 ? Effect.void : Console.error(renderCoalescedBuildWarnings(messages));
|
|
104
|
+
//#endregion
|
|
105
|
+
export { formatEsbuildMessages, formatPath, logCoalescedBuildErrors, logCoalescedBuildWarnings, logFileAdded, logFileModified, logFileRemoved, logFunctionAdded, logFunctionRemoved, logPending, logSuccess, logWarn, renderBuildError };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=log.mjs.map
|
package/dist/log.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.mjs","names":["Ansi.blackBright","Ansi.green","Ansi.red","Ansi.yellow","GroupPath.toString"],"sources":["../src/log.ts"],"sourcesContent":["import { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Console from \"effect/Console\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as String from \"effect/String\";\nimport * as esbuild from \"esbuild\";\nimport type {\n BuildError,\n BundleFailedError,\n ImportFailedError,\n} from \"./BuildError.js\";\nimport * as Ansi from \"./Ansi.js\";\nimport type * as FunctionPath from \"./FunctionPath.js\";\nimport * as GroupPath from \"./GroupPath.js\";\nimport { ProjectRoot } from \"./ProjectRoot.js\";\n\n// --- Path styling ---\n\n/**\n * Render a relative path with the directory portion dimmed (`Ansi.blackBright`)\n * and the file leaf rendered in the default terminal color.\n */\nexport const formatPath = (relativePath: string): string => {\n const lastSep = Math.max(\n relativePath.lastIndexOf(\"/\"),\n relativePath.lastIndexOf(\"\\\\\"),\n );\n const dir = lastSep < 0 ? \"\" : relativePath.slice(0, lastSep + 1);\n const leaf = lastSep < 0 ? relativePath : relativePath.slice(lastSep + 1);\n return Ansi.blackBright(dir) + leaf;\n};\n\n// --- File operation logs ---\n\nconst logFile = (char: string, color: Ansi.Style) =>\n Effect.fnUntraced(function* (fullPath: string) {\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 yield* Console.log(\n `${color(char)} ${Ansi.blackBright(prefix)}${color(suffix)}`,\n );\n });\n\nexport const logFileAdded = logFile(\"+\", Ansi.green);\n\nexport const logFileRemoved = logFile(\"-\", Ansi.red);\n\nexport const logFileModified = logFile(\"~\", Ansi.yellow);\n\n// --- Function subline logs ---\n\nconst logFunction =\n (char: string, color: Ansi.Style) =>\n (functionPath: FunctionPath.FunctionPath) =>\n Console.log(\n ` ${color(char)} ${Ansi.blackBright(\n GroupPath.toString(functionPath.groupPath) + \".\",\n )}${color(functionPath.name)}`,\n );\n\nexport const logFunctionAdded = logFunction(\"+\", Ansi.green);\n\nexport const logFunctionRemoved = logFunction(\"-\", Ansi.red);\n\n// --- Process status logs ---\n\nconst logStatus = (char: string, charColor: Ansi.Style) => (message: string) =>\n Console.log(`${charColor(char)} ${message}`);\n\nexport const logSuccess = logStatus(\"✔︎\", Ansi.green);\n\nexport const logFailure = logStatus(\"✘\", Ansi.red);\n\nexport const logPending = logStatus(\"⭘\", Ansi.yellow);\n\nexport const logWarn = logStatus(\"⚠\", Ansi.yellow);\n\n// --- Build message rendering ---\n\nconst cross = Ansi.red(\"✘\");\n\nconst warningSign = Ansi.yellow(\"⚠\");\n\nconst gutter = (color: Ansi.Style): string => color(\"│\");\n\nconst errorGutter = gutter(Ansi.red);\n\nconst withGutterBlock =\n (gutterChar: string) =>\n (output: string): string =>\n pipe(\n String.split(output, \"\\n\"),\n Array.map((line) =>\n pipe(line, String.trim) === \"\" ? gutterChar : `${gutterChar} ${line}`,\n ),\n Array.join(\"\\n\"),\n (guttered) => `${gutterChar}\\n${guttered}\\n${gutterChar}`,\n );\n\nconst withErrorGutterBlock = withGutterBlock(errorGutter);\n\nconst formatBuildMessage = (\n error: esbuild.Message | undefined,\n formattedMessage: string,\n): string => {\n const lines = String.split(formattedMessage, \"\\n\");\n const redErrorText = Ansi.red(error?.text ?? \"\");\n const replaced = pipe(\n Array.findFirstIndex(lines, (l) => pipe(l, String.trim, String.isNonEmpty)),\n Option.flatMap((index) => Array.modify(lines, index, () => redErrorText)),\n Option.getOrElse(() => lines),\n );\n return pipe(replaced, Array.join(\"\\n\"));\n};\n\n/**\n * Render a list of esbuild messages into a styled, gutter-prefixed block.\n */\nexport const formatEsbuildMessages = (\n errors: readonly esbuild.Message[],\n formattedMessages: readonly string[],\n): string =>\n pipe(\n formattedMessages,\n Array.map((message, i) => formatBuildMessage(errors[i], message)),\n Array.join(\"\"),\n String.trimEnd,\n withErrorGutterBlock,\n );\n\nconst renderImportFailedError = (error: ImportFailedError): string => {\n const causeMessage = Predicate.isError(error.cause)\n ? error.cause.message\n : Predicate.isString(error.cause)\n ? error.cause\n : globalThis.String(error.cause);\n const oneLineCause = pipe(\n String.split(causeMessage, \"\\n\"),\n Array.findFirst((line) => pipe(line, String.trim, String.isNonEmpty)),\n Option.map(String.trim),\n Option.getOrElse(() => \"unknown error\"),\n );\n return `${cross} Failed to load bundled module ${formatPath(\n error.file,\n )}: ${oneLineCause}; check the file's top-level imports and side effects.`;\n};\n\n/**\n * Render a {@link BundleFailedError} as a multi-line, ANSI-styled string: a\n * one-line `✘ <file>: build errors` header followed by the gutter-prefixed\n * esbuild diagnostic block. Multi-line is appropriate here because a single\n * `BundleFailedError` carries an array of distinct esbuild messages.\n */\nconst renderBundleFailedError = (error: BundleFailedError): string => {\n const messages = error.errors as readonly esbuild.Message[];\n const formatted = esbuild.formatMessagesSync(messages as esbuild.Message[], {\n kind: \"error\",\n color: true,\n terminalWidth: 80,\n });\n const header = `${cross} ${formatPath(error.file)}: build errors`;\n return `${header}\\n${formatEsbuildMessages(messages, formatted)}`;\n};\n\n/**\n * Render any {@link BuildError} into a styled, ready-to-print string.\n * `ImportFailedError` collapses to a single line; `BundleFailedError` expands\n * to a header plus one diagnostic block per esbuild message.\n */\nexport const renderBuildError = (error: BuildError): string =>\n Match.value(error).pipe(\n Match.tag(\"BundleFailedError\", renderBundleFailedError),\n Match.tag(\"ImportFailedError\", renderImportFailedError),\n Match.exhaustive,\n );\n\nexport const logBuildError = (error: BuildError) =>\n Console.error(renderBuildError(error));\n\n/**\n * Render a flat list of esbuild messages as a single error block with a generic\n * `✘ Build errors` header.\n */\nconst renderCoalescedBuildErrors = (\n messages: readonly esbuild.Message[],\n): string => {\n const formatted = esbuild.formatMessagesSync(messages as esbuild.Message[], {\n kind: \"error\",\n color: true,\n terminalWidth: 80,\n });\n const header = `${cross} Build errors`;\n return `${header}\\n${formatEsbuildMessages(messages, formatted)}`;\n};\n\nexport const logCoalescedBuildErrors = (\n messages: readonly esbuild.Message[],\n) =>\n messages.length === 0\n ? Effect.void\n : Console.error(renderCoalescedBuildErrors(messages));\n\nconst renderCoalescedBuildWarnings = (\n messages: readonly esbuild.Message[],\n): string => {\n const formatted = esbuild.formatMessagesSync(messages as esbuild.Message[], {\n kind: \"warning\",\n color: true,\n terminalWidth: 80,\n });\n const header = `${warningSign} Build warnings`;\n const body = pipe(\n formatted,\n Array.join(\"\"),\n String.trimEnd,\n withGutterBlock(gutter(Ansi.yellow)),\n );\n return `${header}\\n${body}`;\n};\n\nexport const logCoalescedBuildWarnings = (\n messages: readonly esbuild.Message[],\n) =>\n messages.length === 0\n ? Effect.void\n : Console.error(renderCoalescedBuildWarnings(messages));\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,MAAa,cAAc,iBAAiC;CAC1D,MAAM,UAAU,KAAK,IACnB,aAAa,YAAY,GAAG,GAC5B,aAAa,YAAY,IAAI,CAC/B;CACA,MAAM,MAAM,UAAU,IAAI,KAAK,aAAa,MAAM,GAAG,UAAU,CAAC;CAChE,MAAM,OAAO,UAAU,IAAI,eAAe,aAAa,MAAM,UAAU,CAAC;CACxE,OAAOA,YAAiB,GAAG,IAAI;AACjC;AAIA,MAAM,WAAW,MAAc,UAC7B,OAAO,WAAW,WAAW,UAAkB;CAI7C,MAAM,UAAS,OAHY,YAAY,QAGV,OAFT,KAAK,KAAA,CAES;CAClC,MAAM,SAAS,KAAK,UAAU,OAAO,WAAW,MAAM,CAAC,IACnD,KAAK,UAAU,OAAO,MAAM,OAAO,MAAM,CAAC,IAC1C;CAEJ,OAAO,QAAQ,IACb,GAAG,MAAM,IAAI,EAAE,GAAGA,YAAiB,MAAM,IAAI,MAAM,MAAM,GAC3D;AACF,CAAC;AAEH,MAAa,eAAe,QAAQ,KAAKC,KAAU;AAEnD,MAAa,iBAAiB,QAAQ,K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AAC;AAExD,MAAM,gCACJ,aACW;CACX,MAAM,YAAY,QAAQ,mBAAmB,UAA+B;EAC1E,MAAM;EACN,OAAO;EACP,eAAe;CACjB,CAAC;CAQD,OAAO,GAAG,GAPQ,YAAY,iBAOb,IANJ,KACX,WACA,MAAM,KAAK,EAAE,GACb,OAAO,SACP,gBAAgB,OAAOC,MAAW,CAAC,CAEb;AAC1B;AAEA,MAAa,6BACX,aAEA,SAAS,WAAW,IAChB,OAAO,OACP,QAAQ,MAAM,6BAA6B,QAAQ,CAAC"}
|
package/dist/package.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.mjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|