@lithia-js/cli 1.0.0-canary.20 → 1.0.0-canary.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_entrypoint.mjs.map +1 -1
- package/dist/index.mjs +48 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/_entrypoint.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/_entrypoint.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/_entrypoint.ts"],"names":[],"mappings":";;;AAqCA,eAAe,SAAA,GAA2B;AAEzC,EAAA,UAAA,CAAW,cAAc,CAAA,GAAI,UAAA;AAE7B,EAAA,MAAM,SAAS,IAAI,cAAA,CAAe,EAAE,WAAA,EAAa,cAAc,CAAA;AAE/D,EAAA,MAAM,OAAO,KAAA,EAAM;AAEnB,EAAA,IAAI;AACH,IAAA,MAAM,OAAO,KAAA,EAAM;AAAA,EACpB,CAAA,CAAA,MAAQ;AAAA,EAER;AASA,EAAA,MAAM,WAAW,YAA2B;AAC3C,IAAA,IAAI;AACH,MAAA,MAAM,OAAO,IAAA,EAAK;AAAA,IACnB,CAAA,CAAA,MAAQ;AAAA,IAER,CAAA,SAAE;AACD,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IACf;AAAA,EACD,CAAA;AAGA,EAAA,OAAA,CAAQ,IAAA,CAAK,UAAU,QAAQ,CAAA;AAC/B,EAAA,OAAA,CAAQ,IAAA,CAAK,WAAW,QAAQ,CAAA;AACjC;AAGA,MAAM,WAAU,CAAE,KAAA,CAAM,MAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA","file":"_entrypoint.mjs","sourcesContent":["#! /usr/bin/env node\n/**\n * -----------------------------------------------------------------------------\n * LITHIA FRAMEWORK - PRODUCTION ENTRY POINT\n * -----------------------------------------------------------------------------\n * * WARNING: THIS IS A GENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n * * This file is automatically generated by the Lithia CLI during the build\n * process. Any manual modifications will be lost when the project is rebuilt.\n * * For configuration changes, please modify your 'lithia.config' file or\n * environment variables.\n * * @generated\n * -----------------------------------------------------------------------------\n */\n\nimport type { LithiaConfig } from \"@lithia-js/core\";\nimport { CFG_GLOBAL_KEY, HostSupervisor } from \"@lithia-js/core/_\";\n\ndeclare global {\n\tvar __lithia_host_config_v1: LithiaConfig;\n}\n\n/**\n * The __CONFIG__ constant is a placeholder injected during the build step.\n * It contains the resolved application configuration for production.\n */\ndeclare const __CONFIG__: LithiaConfig;\n\n/**\n * Bootstraps the production environment and manages the host lifecycle.\n *\n * The generated entrypoint publishes the injected config into the global\n * config slot expected by the runtime, creates a production host supervisor,\n * starts it, and registers signal handlers that stop the host before exiting.\n *\n * @returns {Promise<void>} Resolves after the host has been started or startup\n * failure handling has completed.\n */\nasync function bootstrap(): Promise<void> {\n\t// Initialize the global configuration context\n\tglobalThis[CFG_GLOBAL_KEY] = __CONFIG__;\n\n\tconst lithia = new HostSupervisor({ environment: \"production\" });\n\n\tawait lithia.setup();\n\n\ttry {\n\t\tawait lithia.start();\n\t} catch {\n\t\t// Initialization failure handled by the host internally\n\t}\n\n\t/**\n\t * Orchestrates a graceful shutdown by stopping the host\n\t * and releasing process resources.\n\t *\n\t * @returns {Promise<void>} Resolves only long enough to await `lithia.stop()`\n\t * before forcing process exit.\n\t */\n\tconst shutdown = async (): Promise<void> => {\n\t\ttry {\n\t\t\tawait lithia.stop();\n\t\t} catch {\n\t\t\t// Ensure the process exits even if the stop sequence encounters an error\n\t\t} finally {\n\t\t\tprocess.exit(0);\n\t\t}\n\t};\n\n\t// Register process signal listeners for clean termination\n\tprocess.once(\"SIGINT\", shutdown);\n\tprocess.once(\"SIGTERM\", shutdown);\n}\n\n// Execute the bootstrap sequence and handle unhandled rejections\nawait bootstrap().catch(() => process.exit(1));\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -12,8 +12,14 @@ var build = defineCommand({
|
|
|
12
12
|
description: "Compile the project for production deployment"
|
|
13
13
|
},
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Runs the production build lifecycle for the current project.
|
|
16
|
+
*
|
|
17
|
+
* The command exits the process with status `1` when the core build step
|
|
18
|
+
* fails. Errors that happen later during entrypoint finalization are logged
|
|
19
|
+
* but do not currently rethrow.
|
|
20
|
+
*
|
|
21
|
+
* @returns {Promise<void>} Resolves after the build flow and tree printing
|
|
22
|
+
* finish.
|
|
17
23
|
*/
|
|
18
24
|
async run() {
|
|
19
25
|
const lithia = new HostSupervisor({ environment: "build" });
|
|
@@ -53,6 +59,16 @@ var build_default = build;
|
|
|
53
59
|
|
|
54
60
|
// src/cmd/dev-scheduler.ts
|
|
55
61
|
var DevLifecycleScheduler = class {
|
|
62
|
+
/**
|
|
63
|
+
* Creates a scheduler for coalesced dev lifecycle processing.
|
|
64
|
+
*
|
|
65
|
+
* @param {(batch: DevChangeBatch) => Promise<void>} onBatch - Async callback
|
|
66
|
+
* invoked with each consumed batch of pending changes.
|
|
67
|
+
* @param {number} [debounceMs=180] - Debounce window used before a pending
|
|
68
|
+
* batch is flushed.
|
|
69
|
+
* @param {(error: unknown) => void} [onError=() => {}] - Error callback
|
|
70
|
+
* invoked when batch processing fails.
|
|
71
|
+
*/
|
|
56
72
|
constructor(onBatch, debounceMs = 180, onError = () => {
|
|
57
73
|
}) {
|
|
58
74
|
this.onBatch = onBatch;
|
|
@@ -66,6 +82,12 @@ var DevLifecycleScheduler = class {
|
|
|
66
82
|
};
|
|
67
83
|
timer = null;
|
|
68
84
|
running = false;
|
|
85
|
+
/**
|
|
86
|
+
* Marks a change category as pending and schedules a future flush.
|
|
87
|
+
*
|
|
88
|
+
* @param {DevChangeKind} kind - Change category that was observed by a
|
|
89
|
+
* filesystem watcher.
|
|
90
|
+
*/
|
|
69
91
|
enqueue(kind) {
|
|
70
92
|
this.pending[kind] = true;
|
|
71
93
|
if (this.running) return;
|
|
@@ -75,6 +97,12 @@ var DevLifecycleScheduler = class {
|
|
|
75
97
|
void this.flush();
|
|
76
98
|
}, this.debounceMs);
|
|
77
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Flushes pending changes in serialized batches.
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise<void>} Resolves after all currently pending changes have
|
|
104
|
+
* been consumed or the error callback has been invoked.
|
|
105
|
+
*/
|
|
78
106
|
async flush() {
|
|
79
107
|
if (this.running) return;
|
|
80
108
|
this.running = true;
|
|
@@ -94,9 +122,20 @@ var DevLifecycleScheduler = class {
|
|
|
94
122
|
}
|
|
95
123
|
}
|
|
96
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns whether any change category is currently pending.
|
|
127
|
+
*
|
|
128
|
+
* @returns {boolean} `true` when a flush still has work to process.
|
|
129
|
+
*/
|
|
97
130
|
hasPendingChanges() {
|
|
98
131
|
return this.pending.source || this.pending.config || this.pending.env;
|
|
99
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the current pending batch and clears the internal flags.
|
|
135
|
+
*
|
|
136
|
+
* @returns {DevChangeBatch} Snapshot of the pending change flags that should
|
|
137
|
+
* be processed next.
|
|
138
|
+
*/
|
|
100
139
|
consumePending() {
|
|
101
140
|
const batch = { ...this.pending };
|
|
102
141
|
this.pending.source = false;
|
|
@@ -112,6 +151,12 @@ var dev = defineCommand({
|
|
|
112
151
|
name: "dev",
|
|
113
152
|
description: "Start the development server with hot-reload capabilities"
|
|
114
153
|
},
|
|
154
|
+
/**
|
|
155
|
+
* Runs the development server lifecycle for the current project.
|
|
156
|
+
*
|
|
157
|
+
* @returns {Promise<void>} Resolves after watchers and shutdown handlers have
|
|
158
|
+
* been registered.
|
|
159
|
+
*/
|
|
115
160
|
async run() {
|
|
116
161
|
const cwd = process.cwd();
|
|
117
162
|
const lithia = new HostSupervisor({ environment: "development" });
|
|
@@ -241,7 +286,7 @@ async function processDevBatch(lithia, batch, state) {
|
|
|
241
286
|
|
|
242
287
|
// package.json
|
|
243
288
|
var package_default = {
|
|
244
|
-
version: "1.0.0-canary.
|
|
289
|
+
version: "1.0.0-canary.22"};
|
|
245
290
|
|
|
246
291
|
// src/meta.ts
|
|
247
292
|
var version = package_default.version;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cmd/build.ts","../src/cmd/dev-scheduler.ts","../src/cmd/dev.ts","../package.json","../src/meta.ts","../src/index.ts"],"names":["defineCommand","HostSupervisor","logger","join"],"mappings":";;;;;;;;AAgBA,IAAM,QAAQ,aAAA,CAAc;AAAA,EAC3B,IAAA,EAAM;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,WAAA,EAAa;AAAA,GACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,GAAA,GAAM;AACX,IAAA,MAAM,SAAS,IAAI,cAAA,CAAe,EAAE,WAAA,EAAa,SAAS,CAAA;AAG1D,IAAA,MAAM,OAAO,KAAA,EAAM;AAEnB,IAAA,MAAA,CAAO,KAAK,2CAA2C,CAAA;AAGvD,IAAA,IAAI;AACH,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACpB,CAAA,CAAA,MAAQ;AACP,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IACf;AAEA,IAAA,MAAM,EAAE,QAAO,GAAI,MAAA;AACnB,IAAA,MAAM,gBAAA,GAAmB,QAAQ,GAAA,EAAI;AAGrC,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,gBAAA,EAAkB,MAAA,CAAO,QAAQ,WAAW,CAAA;AACnE,IAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,MAAA,CAAA,IAAA,CAAY,OAAA,EAAS,iBAAiB,CAAA;AAGnE,IAAA,IAAI;AACH,MAAA,MAAM,WAAA,GAAc,MAAM,QAAA,CAAS,YAAA,EAAc,OAAO,CAAA;AACxD,MAAA,MAAM,mBAAmB,WAAA,CAAY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IACb;AAAA,GACD;AAAA,EACA,WAAA,EAAa;AAAA,IACZ,GAAA,EAAA,WAAA;AAAA,IACA,KAAA,EAAA;AAAA;AAEF,CAAC,CAAA;AAED,OAAA,CAAQ,IAAI,EAAE,IAAA,EAAK","file":"index.mjs","sourcesContent":["/**\n * @fileoverview Build command implementation for the Lithia CLI.\n * Handles project compilation, entry point generation, and environment preparation.\n */\n\nimport { chmod, readFile, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { HostSupervisor } from \"@lithia-js/core/_\";\nimport { logger } from \"@lithia-js/utils\";\nimport { defineCommand } from \"citty\";\n\n/**\n * The 'build' command compiles the application for production environments.\n * It initializes the Lithia host, generates the server entry point,\n * and configures file permissions.\n */\nconst build = defineCommand({\n\tmeta: {\n\t\tname: \"build\",\n\t\tdescription: \"Compile the project for production deployment\",\n\t},\n\n\t/**\n\t * Primary execution logic for the build command.\n\t * @throws {Error} If build processes or file operations fail.\n\t */\n\tasync run() {\n\t\tconst lithia = new HostSupervisor({ environment: \"build\" });\n\n\t\t// Initialize the host environment\n\t\tawait lithia.setup();\n\n\t\tlogger.info(\"Initializing production build sequence...\");\n\n\t\t// Trigger the core build process\n\t\ttry {\n\t\t\tawait lithia.build();\n\t\t} catch {\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst { config } = lithia;\n\t\tconst workingDirectory = process.cwd();\n\n\t\t// Path resolution for entry point generation\n\t\tconst entryPath = join(workingDirectory, config.outDir, \"server.js\");\n\t\tconst templatePath = resolve(import.meta.dirname, \"_entrypoint.mjs\");\n\n\t\t// Generate production entry point by injecting runtime configuration\n\t\ttry {\n\t\t\tconst rawTemplate = await readFile(templatePath, \"utf-8\");\n\t\t\tconst processedContent = rawTemplate.replace(\n\t\t\t\t\"__CONFIG__\",\n\t\t\t\tJSON.stringify(config),\n\t\t\t);\n\n\t\t\tawait writeFile(entryPath, processedContent, \"utf-8\");\n\n\t\t\t// Post-write operations: Loading metadata and setting permissions\n\t\t\tawait lithia.loadRoutes();\n\t\t\tawait lithia.loadEvents();\n\t\t\tawait lithia.loadTasks();\n\n\t\t\t// Ensure the entry point is executable (0o755: rwxr-xr-x)\n\t\t\tawait chmod(entryPath, 0o755);\n\n\t\t\tlogger.success(\"Production build completed successfully.\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to finalize the build entry point.\");\n\t\t\tlogger.debug(error);\n\t\t\t// Silent catch maintained as per original implementation,\n\t\t\t// but logged for visibility.\n\t\t}\n\n\t\t// Output visual representation of the application structure\n\t\tlithia.printRouteTree();\n\t\tlithia.printEventTree();\n\t\tlithia.printTaskTree();\n\t},\n});\n\nexport default build;\n","export type DevChangeKind = \"source\" | \"config\" | \"env\";\n\nexport interface DevChangeBatch {\n\tsource: boolean;\n\tconfig: boolean;\n\tenv: boolean;\n}\n\nexport class DevLifecycleScheduler {\n\tprivate readonly pending: DevChangeBatch = {\n\t\tsource: false,\n\t\tconfig: false,\n\t\tenv: false,\n\t};\n\n\tprivate timer: NodeJS.Timeout | null = null;\n\tprivate running = false;\n\n\tconstructor(\n\t\tprivate readonly onBatch: (batch: DevChangeBatch) => Promise<void>,\n\t\tprivate readonly debounceMs: number = 180,\n\t\tprivate readonly onError: (error: unknown) => void = () => {},\n\t) {}\n\n\tpublic enqueue(kind: DevChangeKind): void {\n\t\tthis.pending[kind] = true;\n\t\tif (this.running) return;\n\n\t\tif (this.timer) clearTimeout(this.timer);\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.timer = null;\n\t\t\tvoid this.flush();\n\t\t}, this.debounceMs);\n\t}\n\n\tprivate async flush(): Promise<void> {\n\t\tif (this.running) return;\n\t\tthis.running = true;\n\n\t\ttry {\n\t\t\twhile (this.hasPendingChanges()) {\n\t\t\t\tawait this.onBatch(this.consumePending());\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.onError(error);\n\t\t} finally {\n\t\t\tthis.running = false;\n\t\t\tif (this.hasPendingChanges() && !this.timer) {\n\t\t\t\tthis.timer = setTimeout(() => {\n\t\t\t\t\tthis.timer = null;\n\t\t\t\t\tvoid this.flush();\n\t\t\t\t}, this.debounceMs);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate hasPendingChanges(): boolean {\n\t\treturn this.pending.source || this.pending.config || this.pending.env;\n\t}\n\n\tprivate consumePending(): DevChangeBatch {\n\t\tconst batch = { ...this.pending };\n\t\tthis.pending.source = false;\n\t\tthis.pending.config = false;\n\t\tthis.pending.env = false;\n\t\treturn batch;\n\t}\n}\n","/**\n * @fileoverview Development command for the Lithia CLI.\n * Provides Hot Module Replacement (HMR) capabilities via file system watchers,\n * automatic configuration reloading, and environment synchronization.\n */\n\nimport { join } from \"node:path\";\nimport { HostSupervisor } from \"@lithia-js/core/_\";\nimport { logger } from \"@lithia-js/utils\";\nimport chokidar from \"chokidar\";\nimport { defineCommand } from \"citty\";\nimport { type DevChangeBatch, DevLifecycleScheduler } from \"./dev-scheduler\";\n\nconst dev = defineCommand({\n\tmeta: {\n\t\tname: \"dev\",\n\t\tdescription: \"Start the development server with hot-reload capabilities\",\n\t},\n\n\tasync run() {\n\t\tconst cwd = process.cwd();\n\t\tconst lithia = new HostSupervisor({ environment: \"development\" });\n\n\t\t// 1. Initial Host Setup\n\t\tawait lithia.setup();\n\t\tconst initialBuildSucceeded = await lithia.build();\n\t\tconst lifecycleState = {\n\t\t\thasReloadableArtifacts: initialBuildSucceeded,\n\t\t};\n\n\t\tif (initialBuildSucceeded) {\n\t\t\ttry {\n\t\t\t\tawait lithia.start();\n\t\t\t} catch {\n\t\t\t\tlogger.error(\"Failed to start the development server.\");\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.warn(\n\t\t\t\t\"Initial build failed. Waiting for file changes while continuing to serve nothing.\",\n\t\t\t);\n\t\t}\n\n\t\t// 2. Define the serialized dev lifecycle\n\t\tconst scheduler = new DevLifecycleScheduler(\n\t\t\tasync (batch) => {\n\t\t\t\tawait processDevBatch(lithia, batch, lifecycleState);\n\t\t\t},\n\t\t\t180,\n\t\t\t(error) => {\n\t\t\t\tlogger.error(\"Dev lifecycle failed:\", error);\n\t\t\t},\n\t\t);\n\n\t\t// 3. Source Code Watcher\n\t\tconst srcWatcher = chokidar.watch(join(cwd, \"src\"), {\n\t\t\tignored: [/(^|[/\\\\])\\../, \"**/node_modules/**\"],\n\t\t\tpersistent: true,\n\t\t\tignoreInitial: true,\n\t\t});\n\n\t\tsrcWatcher.on(\"all\", (event) => {\n\t\t\tif ([\"add\", \"change\", \"unlink\"].includes(event)) {\n\t\t\t\tscheduler.enqueue(\"source\");\n\t\t\t}\n\t\t});\n\n\t\t// 4. Configuration and Environment Watcher\n\t\tconst extensions = [\".js\", \".mjs\", \".ts\", \".mts\", \".json\"];\n\t\tconst configFiles = [\n\t\t\t...lithia.config.envFiles,\n\t\t\t...extensions.map((ext) => join(cwd, `lithia.config${ext}`)),\n\t\t];\n\n\t\tconst configWatcher = chokidar.watch(configFiles, {\n\t\t\tcwd,\n\t\t\tignoreInitial: true,\n\t\t});\n\n\t\tconfigWatcher.on(\"all\", (event, filePath) => {\n\t\t\tif ([\"change\", \"add\"].includes(event)) {\n\t\t\t\tif (filePath.includes(\"lithia.config\")) {\n\t\t\t\t\tscheduler.enqueue(\"config\");\n\t\t\t\t} else {\n\t\t\t\t\tscheduler.enqueue(\"env\");\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// 5. Graceful Shutdown Orchestration\n\t\tconst shutdown = async () => {\n\t\t\tlogger.info(\"Shutting down development server...\");\n\t\t\tawait Promise.allSettled([\n\t\t\t\tsrcWatcher.close(),\n\t\t\t\tconfigWatcher.close(),\n\t\t\t\tlithia.stop(),\n\t\t\t]);\n\t\t\tprocess.exit(0);\n\t\t};\n\n\t\t// Correctly bind signal handlers to the shutdown sequence\n\t\tprocess.once(\"SIGINT\", shutdown);\n\t\tprocess.once(\"SIGTERM\", shutdown);\n\t},\n});\n\nexport default dev;\n\nexport async function processDevBatch(\n\tlithia: HostSupervisor,\n\tbatch: DevChangeBatch,\n\tstate: { hasReloadableArtifacts: boolean },\n): Promise<void> {\n\tif (batch.config) {\n\t\tlogger.info(\"Configuration updated. Rebuilding and reloading host...\");\n\n\t\tconst previousConfig = structuredClone(lithia.config);\n\t\tconst previousEnv = lithia.getEnvSnapshot();\n\n\t\ttry {\n\t\t\tawait lithia.loadConfig();\n\t\t\tawait lithia.loadEnv();\n\n\t\t\tconst buildSucceeded = await lithia.build();\n\t\t\tif (!buildSucceeded) {\n\t\t\t\tstate.hasReloadableArtifacts =\n\t\t\t\t\tstate.hasReloadableArtifacts || lithia.isAppReady;\n\t\t\t\tlithia.replaceConfig(previousConfig);\n\t\t\t\tlithia.replaceEnv(previousEnv);\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"Reload skipped due to build failure. Rolled back config/env and kept serving the previous app.\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait lithia.reload();\n\t\t\tstate.hasReloadableArtifacts = true;\n\t\t\tlogger.success(\"Reload complete.\");\n\t\t\treturn;\n\t\t} catch (error) {\n\t\t\tlithia.replaceConfig(previousConfig);\n\t\t\tlithia.replaceEnv(previousEnv);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tif (batch.source) {\n\t\tlogger.info(\"Source updated. Building host...\");\n\t\tconst buildSucceeded = await lithia.build();\n\n\t\tif (!buildSucceeded) {\n\t\t\tstate.hasReloadableArtifacts =\n\t\t\t\tstate.hasReloadableArtifacts || lithia.isAppReady;\n\t\t\tlogger.warn(\n\t\t\t\t\"Reload skipped due to build failure. Continuing to serve previous app.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tstate.hasReloadableArtifacts = true;\n\t}\n\n\tif (batch.env) {\n\t\tif (!state.hasReloadableArtifacts) {\n\t\t\tlogger.warn(\n\t\t\t\t\"Reload skipped because the latest build artifacts are unavailable. Fix the build and save again.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tlogger.info(\"Environment updated. Reloading host...\");\n\t\tawait lithia.loadEnv();\n\t}\n\n\tif (batch.source || batch.env) {\n\t\tawait lithia.reload();\n\t\tstate.hasReloadableArtifacts = true;\n\t\tlogger.success(\"Reload complete.\");\n\t}\n}\n","{\n\t\"name\": \"@lithia-js/cli\",\n\t\"version\": \"1.0.0-canary.20\",\n\t\"description\": \"Command-line interface for developing and building Lithia.js applications.\",\n\t\"keywords\": [\n\t\t\"lithia\",\n\t\t\"lithia-js\",\n\t\t\"cli\",\n\t\t\"framework\",\n\t\t\"backend\",\n\t\t\"create-app\",\n\t\t\"build-tool\",\n\t\t\"dev-server\"\n\t],\n\t\"author\": \"Lucas Arch <luketsx@icloud.com>\",\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://lithiajs.org\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/lithia-framework/lithia.git\",\n\t\t\"directory\": \"packages/cli\"\n\t},\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/lithia-framework/lithia/issues\"\n\t},\n\t\"type\": \"module\",\n\t\"bin\": {\n\t\t\"lithia\": \"./dist/index.mjs\"\n\t},\n\t\"main\": \"./dist/index.mjs\",\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=20\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsup --config tsup.config.ts\",\n\t\t\"test\": \"vitest --run\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lithia-js/core\": \"workspace:1.0.0-canary.20\",\n\t\t\"@lithia-js/utils\": \"workspace:1.0.0-canary.20\",\n\t\t\"citty\": \"^0.2.0\",\n\t\t\"chokidar\": \"^5.0.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"registry\": \"https://registry.npmjs.org/\",\n\t\t\"access\": \"public\",\n\t\t\"provenance\": true\n\t}\n}\n","import pJson from \"../package.json\" with { type: \"json\" };\nexport const version = pJson.version;\n","#! /usr/bin/env node\n\nimport { defineCommand, runMain } from \"citty\";\nimport build from \"./cmd/build\";\nimport dev from \"./cmd/dev\";\nimport { version } from \"./meta\";\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: \"lithia\",\n\t\tdescription: \"Lithia CLI\",\n\t\tversion,\n\t},\n\tsubCommands: {\n\t\tdev,\n\t\tbuild,\n\t},\n});\n\nrunMain(main).then();\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/cmd/build.ts","../src/cmd/dev-scheduler.ts","../src/cmd/dev.ts","../package.json","../src/meta.ts","../src/index.ts"],"names":["defineCommand","HostSupervisor","logger","join"],"mappings":";;;;;;;;AAcA,IAAM,QAAQ,aAAA,CAAc;AAAA,EAC3B,IAAA,EAAM;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,WAAA,EAAa;AAAA,GACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAM,GAAA,GAAM;AACX,IAAA,MAAM,SAAS,IAAI,cAAA,CAAe,EAAE,WAAA,EAAa,SAAS,CAAA;AAG1D,IAAA,MAAM,OAAO,KAAA,EAAM;AAEnB,IAAA,MAAA,CAAO,KAAK,2CAA2C,CAAA;AAGvD,IAAA,IAAI;AACH,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACpB,CAAA,CAAA,MAAQ;AACP,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IACf;AAEA,IAAA,MAAM,EAAE,QAAO,GAAI,MAAA;AACnB,IAAA,MAAM,gBAAA,GAAmB,QAAQ,GAAA,EAAI;AAGrC,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,gBAAA,EAAkB,MAAA,CAAO,QAAQ,WAAW,CAAA;AACnE,IAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,MAAA,CAAA,IAAA,CAAY,OAAA,EAAS,iBAAiB,CAAA;AAGnE,IAAA,IAAI;AACH,MAAA,MAAM,WAAA,GAAc,MAAM,QAAA,CAAS,YAAA,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C/B,IAAAA,MAAAA,CAAO,QAAQ,kBAAkB,CAAA;AAAA,EAClC;AACD;;;AC1MA,IAAA,eAAA,GAAA;AAAA,EAEC,OAAA,EAAW,iBAkDZ,CAAA;;;ACnDO,IAAM,UAAU,eAAA,CAAM,OAAA;;;ACM7B,IAAM,OAAOF,aAAAA,CAAc;AAAA,EAC1B,IAAA,EAAM;AAAA,IACL,IAAA,EAAM,QAAA;AAAA,IACN,WAAA,EAAa,YAAA;AAAA,IACb;AAAA,GACD;AAAA,EACA,WAAA,EAAa;AAAA,IACZ,GAAA,EAAA,WAAA;AAAA,IACA,KAAA,EAAA;AAAA;AAEF,CAAC,CAAA;AAED,OAAA,CAAQ,IAAI,EAAE,IAAA,EAAK","file":"index.mjs","sourcesContent":["import { chmod, readFile, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { HostSupervisor } from \"@lithia-js/core/_\";\nimport { logger } from \"@lithia-js/utils\";\nimport { defineCommand } from \"citty\";\n\n/**\n * CLI command that builds a Lithia application for production execution.\n *\n * The command initializes a host supervisor in build mode, compiles the app,\n * generates the production `server.js` entrypoint from the template file, loads\n * the generated manifests so the route/event/task trees can be printed, and\n * marks the entrypoint as executable.\n */\nconst build = defineCommand({\n\tmeta: {\n\t\tname: \"build\",\n\t\tdescription: \"Compile the project for production deployment\",\n\t},\n\n\t/**\n\t * Runs the production build lifecycle for the current project.\n\t *\n\t * The command exits the process with status `1` when the core build step\n\t * fails. Errors that happen later during entrypoint finalization are logged\n\t * but do not currently rethrow.\n\t *\n\t * @returns {Promise<void>} Resolves after the build flow and tree printing\n\t * finish.\n\t */\n\tasync run() {\n\t\tconst lithia = new HostSupervisor({ environment: \"build\" });\n\n\t\t// Initialize the host environment\n\t\tawait lithia.setup();\n\n\t\tlogger.info(\"Initializing production build sequence...\");\n\n\t\t// Trigger the core build process\n\t\ttry {\n\t\t\tawait lithia.build();\n\t\t} catch {\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tconst { config } = lithia;\n\t\tconst workingDirectory = process.cwd();\n\n\t\t// Path resolution for entry point generation\n\t\tconst entryPath = join(workingDirectory, config.outDir, \"server.js\");\n\t\tconst templatePath = resolve(import.meta.dirname, \"_entrypoint.mjs\");\n\n\t\t// Generate production entry point by injecting runtime configuration\n\t\ttry {\n\t\t\tconst rawTemplate = await readFile(templatePath, \"utf-8\");\n\t\t\tconst processedContent = rawTemplate.replace(\n\t\t\t\t\"__CONFIG__\",\n\t\t\t\tJSON.stringify(config),\n\t\t\t);\n\n\t\t\tawait writeFile(entryPath, processedContent, \"utf-8\");\n\n\t\t\t// Post-write operations: Loading metadata and setting permissions\n\t\t\tawait lithia.loadRoutes();\n\t\t\tawait lithia.loadEvents();\n\t\t\tawait lithia.loadTasks();\n\n\t\t\t// Ensure the entry point is executable (0o755: rwxr-xr-x)\n\t\t\tawait chmod(entryPath, 0o755);\n\n\t\t\tlogger.success(\"Production build completed successfully.\");\n\t\t} catch (error) {\n\t\t\tlogger.error(\"Failed to finalize the build entry point.\");\n\t\t\tlogger.debug(error);\n\t\t\t// Silent catch maintained as per original implementation,\n\t\t\t// but logged for visibility.\n\t\t}\n\n\t\t// Output visual representation of the application structure\n\t\tlithia.printRouteTree();\n\t\tlithia.printEventTree();\n\t\tlithia.printTaskTree();\n\t},\n});\n\nexport default build;\n","/**\n * Change category tracked by the development lifecycle scheduler.\n */\nexport type DevChangeKind = \"source\" | \"config\" | \"env\";\n\n/**\n * Coalesced batch of pending development changes.\n *\n * Each flag indicates whether at least one change of that category occurred\n * since the previous flushed batch.\n */\nexport interface DevChangeBatch {\n\tsource: boolean;\n\tconfig: boolean;\n\tenv: boolean;\n}\n\n/**\n * Debounces and serializes development lifecycle work.\n *\n * The scheduler accumulates file-change categories into a single pending batch,\n * ensures only one batch is processed at a time, and automatically schedules a\n * follow-up flush when more changes arrive while a batch is running.\n */\nexport class DevLifecycleScheduler {\n\tprivate readonly pending: DevChangeBatch = {\n\t\tsource: false,\n\t\tconfig: false,\n\t\tenv: false,\n\t};\n\n\tprivate timer: NodeJS.Timeout | null = null;\n\tprivate running = false;\n\n\t/**\n\t * Creates a scheduler for coalesced dev lifecycle processing.\n\t *\n\t * @param {(batch: DevChangeBatch) => Promise<void>} onBatch - Async callback\n\t * invoked with each consumed batch of pending changes.\n\t * @param {number} [debounceMs=180] - Debounce window used before a pending\n\t * batch is flushed.\n\t * @param {(error: unknown) => void} [onError=() => {}] - Error callback\n\t * invoked when batch processing fails.\n\t */\n\tconstructor(\n\t\tprivate readonly onBatch: (batch: DevChangeBatch) => Promise<void>,\n\t\tprivate readonly debounceMs: number = 180,\n\t\tprivate readonly onError: (error: unknown) => void = () => {},\n\t) {}\n\n\t/**\n\t * Marks a change category as pending and schedules a future flush.\n\t *\n\t * @param {DevChangeKind} kind - Change category that was observed by a\n\t * filesystem watcher.\n\t */\n\tpublic enqueue(kind: DevChangeKind): void {\n\t\tthis.pending[kind] = true;\n\t\tif (this.running) return;\n\n\t\tif (this.timer) clearTimeout(this.timer);\n\t\tthis.timer = setTimeout(() => {\n\t\t\tthis.timer = null;\n\t\t\tvoid this.flush();\n\t\t}, this.debounceMs);\n\t}\n\n\t/**\n\t * Flushes pending changes in serialized batches.\n\t *\n\t * @returns {Promise<void>} Resolves after all currently pending changes have\n\t * been consumed or the error callback has been invoked.\n\t */\n\tprivate async flush(): Promise<void> {\n\t\tif (this.running) return;\n\t\tthis.running = true;\n\n\t\ttry {\n\t\t\twhile (this.hasPendingChanges()) {\n\t\t\t\tawait this.onBatch(this.consumePending());\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthis.onError(error);\n\t\t} finally {\n\t\t\tthis.running = false;\n\t\t\tif (this.hasPendingChanges() && !this.timer) {\n\t\t\t\tthis.timer = setTimeout(() => {\n\t\t\t\t\tthis.timer = null;\n\t\t\t\t\tvoid this.flush();\n\t\t\t\t}, this.debounceMs);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether any change category is currently pending.\n\t *\n\t * @returns {boolean} `true` when a flush still has work to process.\n\t */\n\tprivate hasPendingChanges(): boolean {\n\t\treturn this.pending.source || this.pending.config || this.pending.env;\n\t}\n\n\t/**\n\t * Returns the current pending batch and clears the internal flags.\n\t *\n\t * @returns {DevChangeBatch} Snapshot of the pending change flags that should\n\t * be processed next.\n\t */\n\tprivate consumePending(): DevChangeBatch {\n\t\tconst batch = { ...this.pending };\n\t\tthis.pending.source = false;\n\t\tthis.pending.config = false;\n\t\tthis.pending.env = false;\n\t\treturn batch;\n\t}\n}\n","import { join } from \"node:path\";\nimport { HostSupervisor } from \"@lithia-js/core/_\";\nimport { logger } from \"@lithia-js/utils\";\nimport chokidar from \"chokidar\";\nimport { defineCommand } from \"citty\";\nimport { type DevChangeBatch, DevLifecycleScheduler } from \"./dev-scheduler\";\n\n/**\n * CLI command that runs the Lithia development server with incremental rebuild\n * and reload behavior.\n *\n * The command boots a development host supervisor, starts filesystem watchers\n * for source, config, and environment files, and serializes reload work\n * through `DevLifecycleScheduler` so overlapping file changes do not race.\n */\nconst dev = defineCommand({\n\tmeta: {\n\t\tname: \"dev\",\n\t\tdescription: \"Start the development server with hot-reload capabilities\",\n\t},\n\n\t/**\n\t * Runs the development server lifecycle for the current project.\n\t *\n\t * @returns {Promise<void>} Resolves after watchers and shutdown handlers have\n\t * been registered.\n\t */\n\tasync run() {\n\t\tconst cwd = process.cwd();\n\t\tconst lithia = new HostSupervisor({ environment: \"development\" });\n\n\t\t// 1. Initial Host Setup\n\t\tawait lithia.setup();\n\t\tconst initialBuildSucceeded = await lithia.build();\n\t\tconst lifecycleState = {\n\t\t\thasReloadableArtifacts: initialBuildSucceeded,\n\t\t};\n\n\t\tif (initialBuildSucceeded) {\n\t\t\ttry {\n\t\t\t\tawait lithia.start();\n\t\t\t} catch {\n\t\t\t\tlogger.error(\"Failed to start the development server.\");\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.warn(\n\t\t\t\t\"Initial build failed. Waiting for file changes while continuing to serve nothing.\",\n\t\t\t);\n\t\t}\n\n\t\t// 2. Define the serialized dev lifecycle\n\t\tconst scheduler = new DevLifecycleScheduler(\n\t\t\tasync (batch) => {\n\t\t\t\tawait processDevBatch(lithia, batch, lifecycleState);\n\t\t\t},\n\t\t\t180,\n\t\t\t(error) => {\n\t\t\t\tlogger.error(\"Dev lifecycle failed:\", error);\n\t\t\t},\n\t\t);\n\n\t\t// 3. Source Code Watcher\n\t\tconst srcWatcher = chokidar.watch(join(cwd, \"src\"), {\n\t\t\tignored: [/(^|[/\\\\])\\../, \"**/node_modules/**\"],\n\t\t\tpersistent: true,\n\t\t\tignoreInitial: true,\n\t\t});\n\n\t\tsrcWatcher.on(\"all\", (event) => {\n\t\t\tif ([\"add\", \"change\", \"unlink\"].includes(event)) {\n\t\t\t\tscheduler.enqueue(\"source\");\n\t\t\t}\n\t\t});\n\n\t\t// 4. Configuration and Environment Watcher\n\t\tconst extensions = [\".js\", \".mjs\", \".ts\", \".mts\", \".json\"];\n\t\tconst configFiles = [\n\t\t\t...lithia.config.envFiles,\n\t\t\t...extensions.map((ext) => join(cwd, `lithia.config${ext}`)),\n\t\t];\n\n\t\tconst configWatcher = chokidar.watch(configFiles, {\n\t\t\tcwd,\n\t\t\tignoreInitial: true,\n\t\t});\n\n\t\tconfigWatcher.on(\"all\", (event, filePath) => {\n\t\t\tif ([\"change\", \"add\"].includes(event)) {\n\t\t\t\tif (filePath.includes(\"lithia.config\")) {\n\t\t\t\t\tscheduler.enqueue(\"config\");\n\t\t\t\t} else {\n\t\t\t\t\tscheduler.enqueue(\"env\");\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// 5. Graceful Shutdown Orchestration\n\t\tconst shutdown = async () => {\n\t\t\tlogger.info(\"Shutting down development server...\");\n\t\t\tawait Promise.allSettled([\n\t\t\t\tsrcWatcher.close(),\n\t\t\t\tconfigWatcher.close(),\n\t\t\t\tlithia.stop(),\n\t\t\t]);\n\t\t\tprocess.exit(0);\n\t\t};\n\n\t\t// Correctly bind signal handlers to the shutdown sequence\n\t\tprocess.once(\"SIGINT\", shutdown);\n\t\tprocess.once(\"SIGTERM\", shutdown);\n\t},\n});\n\nexport default dev;\n\n/**\n * Processes a coalesced development change batch against the host supervisor.\n *\n * Config changes reload config and env first, rebuild the project, and roll\n * back to the previous config/env snapshot when the rebuild fails. Source-only\n * changes rebuild the project before reloading, while env-only changes reload\n * the host only when usable build artifacts are already available.\n *\n * @param {HostSupervisor} lithia - Development host supervisor that owns build\n * and reload behavior.\n * @param {DevChangeBatch} batch - Coalesced set of pending source/config/env\n * changes.\n * @param {{ hasReloadableArtifacts: boolean }} state - Mutable lifecycle state\n * used to remember whether reloadable build artifacts currently exist.\n * @returns {Promise<void>} Resolves after the requested dev lifecycle work\n * completes.\n */\nexport async function processDevBatch(\n\tlithia: HostSupervisor,\n\tbatch: DevChangeBatch,\n\tstate: { hasReloadableArtifacts: boolean },\n): Promise<void> {\n\tif (batch.config) {\n\t\tlogger.info(\"Configuration updated. Rebuilding and reloading host...\");\n\n\t\tconst previousConfig = structuredClone(lithia.config);\n\t\tconst previousEnv = lithia.getEnvSnapshot();\n\n\t\ttry {\n\t\t\tawait lithia.loadConfig();\n\t\t\tawait lithia.loadEnv();\n\n\t\t\tconst buildSucceeded = await lithia.build();\n\t\t\tif (!buildSucceeded) {\n\t\t\t\tstate.hasReloadableArtifacts =\n\t\t\t\t\tstate.hasReloadableArtifacts || lithia.isAppReady;\n\t\t\t\tlithia.replaceConfig(previousConfig);\n\t\t\t\tlithia.replaceEnv(previousEnv);\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"Reload skipped due to build failure. Rolled back config/env and kept serving the previous app.\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait lithia.reload();\n\t\t\tstate.hasReloadableArtifacts = true;\n\t\t\tlogger.success(\"Reload complete.\");\n\t\t\treturn;\n\t\t} catch (error) {\n\t\t\tlithia.replaceConfig(previousConfig);\n\t\t\tlithia.replaceEnv(previousEnv);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tif (batch.source) {\n\t\tlogger.info(\"Source updated. Building host...\");\n\t\tconst buildSucceeded = await lithia.build();\n\n\t\tif (!buildSucceeded) {\n\t\t\tstate.hasReloadableArtifacts =\n\t\t\t\tstate.hasReloadableArtifacts || lithia.isAppReady;\n\t\t\tlogger.warn(\n\t\t\t\t\"Reload skipped due to build failure. Continuing to serve previous app.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tstate.hasReloadableArtifacts = true;\n\t}\n\n\tif (batch.env) {\n\t\tif (!state.hasReloadableArtifacts) {\n\t\t\tlogger.warn(\n\t\t\t\t\"Reload skipped because the latest build artifacts are unavailable. Fix the build and save again.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tlogger.info(\"Environment updated. Reloading host...\");\n\t\tawait lithia.loadEnv();\n\t}\n\n\tif (batch.source || batch.env) {\n\t\tawait lithia.reload();\n\t\tstate.hasReloadableArtifacts = true;\n\t\tlogger.success(\"Reload complete.\");\n\t}\n}\n","{\n\t\"name\": \"@lithia-js/cli\",\n\t\"version\": \"1.0.0-canary.22\",\n\t\"description\": \"Command-line interface for developing and building Lithia.js applications.\",\n\t\"keywords\": [\n\t\t\"lithia\",\n\t\t\"lithia-js\",\n\t\t\"cli\",\n\t\t\"framework\",\n\t\t\"backend\",\n\t\t\"create-app\",\n\t\t\"build-tool\",\n\t\t\"dev-server\"\n\t],\n\t\"author\": \"Lucas Arch <luketsx@icloud.com>\",\n\t\"license\": \"MIT\",\n\t\"homepage\": \"https://lithiajs.org\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/lithia-framework/lithia.git\",\n\t\t\"directory\": \"packages/cli\"\n\t},\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/lithia-framework/lithia/issues\"\n\t},\n\t\"type\": \"module\",\n\t\"bin\": {\n\t\t\"lithia\": \"./dist/index.mjs\"\n\t},\n\t\"main\": \"./dist/index.mjs\",\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"templates\"\n\t],\n\t\"engines\": {\n\t\t\"node\": \">=20\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"tsup --config tsup.config.ts\",\n\t\t\"test\": \"vitest --run\"\n\t},\n\t\"dependencies\": {\n\t\t\"@lithia-js/core\": \"workspace:1.0.0-canary.22\",\n\t\t\"@lithia-js/utils\": \"workspace:1.0.0-canary.22\",\n\t\t\"citty\": \"^0.2.0\",\n\t\t\"chokidar\": \"^5.0.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"registry\": \"https://registry.npmjs.org/\",\n\t\t\"access\": \"public\",\n\t\t\"provenance\": true\n\t}\n}\n","import pJson from \"../package.json\" with { type: \"json\" };\nexport const version = pJson.version;\n","#! /usr/bin/env node\n\nimport { defineCommand, runMain } from \"citty\";\nimport build from \"./cmd/build\";\nimport dev from \"./cmd/dev\";\nimport { version } from \"./meta\";\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: \"lithia\",\n\t\tdescription: \"Lithia CLI\",\n\t\tversion,\n\t},\n\tsubCommands: {\n\t\tdev,\n\t\tbuild,\n\t},\n});\n\nrunMain(main).then();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lithia-js/cli",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.22",
|
|
4
4
|
"description": "Command-line interface for developing and building Lithia.js applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lithia",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"node": ">=20"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@lithia-js/core": "1.0.0-canary.
|
|
40
|
-
"@lithia-js/utils": "1.0.0-canary.
|
|
39
|
+
"@lithia-js/core": "1.0.0-canary.22",
|
|
40
|
+
"@lithia-js/utils": "1.0.0-canary.22",
|
|
41
41
|
"citty": "^0.2.0",
|
|
42
42
|
"chokidar": "^5.0.0"
|
|
43
43
|
},
|