@lithia-js/cli 1.0.0-canary.3 → 1.0.0-canary.30

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/README.md CHANGED
@@ -2,59 +2,32 @@
2
2
  <a href="https://github.com/lithia-framework/lithia">
3
3
  <img alt="Lithia logo" src="https://raw.githubusercontent.com/lithia-framework/lithia/canary/.github/assets/logo.svg" height="128">
4
4
  </a>
5
- <h1>Lithia</h1>
6
- <p><strong>The Node.js framework that makes API development feel like magic</strong></p>
5
+ <h1>@lithia-js/cli</h1>
6
+ <p><strong>The `lithia` command-line interface.</strong></p>
7
7
 
8
- <a href="https://www.npmjs.com/package/lithia"><img alt="NPM version" src="https://img.shields.io/npm/v/lithia.svg?style=for-the-badge&labelColor=000000"></a>
9
- <a href="https://github.com/lithia-framework/lithia/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/lithia.svg?style=for-the-badge&labelColor=000000"></a>
8
+ <p>Development server, production build flow, and host orchestration for Lithia apps.</p>
9
+
10
+ <a href="https://www.npmjs.com/package/@lithia-js/cli"><img alt="NPM version" src="https://img.shields.io/npm/v/@lithia-js/cli.svg?style=for-the-badge&labelColor=000000"></a>
11
+ <a href="https://github.com/lithia-framework/lithia/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@lithia-js/cli.svg?style=for-the-badge&labelColor=000000"></a>
10
12
  <a href="https://opencollective.com/lithiajs"><img alt="Support Lithia" src="https://img.shields.io/badge/Support%20Lithia-blueviolet.svg?style=for-the-badge&logo=OpenCollective&labelColor=000000&logoWidth=20"></a>
11
13
 
12
14
  </div>
13
15
 
14
- ## Getting Started
15
-
16
- Lithia is a next-generation Node.js framework that enables you to build powerful APIs with file-based routing, built-in WebSocket support, and a beautiful development interface.
17
-
18
- - Visit our [Learn Lithia](https://lithiajs.com/docs) guide to get started.
19
- - Check out the [Examples](https://github.com/lithia-framework/lithia/tree/main/examples) to see Lithia in action.
20
-
21
- ## Documentation
22
-
23
- Visit [https://lithiajs.com/docs](https://lithiajs.com/docs) to view the full documentation.
24
-
25
- ## Community
26
-
27
- The Lithia community can be found on [GitHub Discussions](https://github.com/lithia-framework/lithia/discussions) where you can ask questions, voice ideas, and share your projects with other people.
16
+ ## Commands
28
17
 
29
- ## Contributing
18
+ ### `lithia dev`
30
19
 
31
- Contributions to Lithia are welcome and highly appreciated. However, before you jump right into it, we would like you to review our [Contribution Guidelines](CONTRIBUTING.md) to make sure you have a smooth experience contributing to Lithia.
20
+ Starts the development server, watches source/config/env changes, rebuilds the
21
+ app, and swaps the app worker when reloads succeed.
32
22
 
33
- ---
23
+ ### `lithia build`
34
24
 
35
- ## Support the Project
25
+ Builds the application into the configured `outDir`, generates manifests, and
26
+ prints the discovered routes, events, and async tasks.
36
27
 
37
- If Lithia makes your life easier, consider supporting it:
28
+ ## Notes
38
29
 
39
- - **Star** this repository
40
- - **Share** on social media
41
- - **Sponsor** via [OpenCollective](https://opencollective.com/lithiajs)
42
- - **Report bugs** and suggest improvements
43
-
44
- ---
45
-
46
- ## License
47
-
48
- Lithia is [MIT licensed](LICENSE). Free for personal and commercial use.
49
-
50
- ---
51
-
52
- <div align="center">
53
- <p><strong>Built with ❤️ by the Lithia community</strong></p>
54
- <p>
55
- <a href="https://github.com/lithia-framework/lithia">GitHub</a> •
56
- <a href="https://lithiajs.com">Documentation</a> •
57
- <a href="https://opencollective.com/lithiajs">OpenCollective</a> •
58
- <a href="https://github.com/lithia-framework/lithia/discussions">Discussions</a>
59
- </p>
60
- </div>
30
+ - The CLI is designed around the worker-based Lithia runtime.
31
+ - It uses `@lithia-js/core/_` internally for host orchestration.
32
+ - Templates are scaffolded by `create-lithia`, while repo-local examples live
33
+ under `examples/`.
@@ -0,0 +1,25 @@
1
+ #! /usr/bin/env node
2
+ import { CFG_GLOBAL_KEY, HostSupervisor } from '@lithia-js/core/_';
3
+
4
+ async function bootstrap() {
5
+ globalThis[CFG_GLOBAL_KEY] = __CONFIG__;
6
+ const lithia = new HostSupervisor({ environment: "production" });
7
+ await lithia.setup();
8
+ try {
9
+ await lithia.start();
10
+ } catch {
11
+ }
12
+ const shutdown = async () => {
13
+ try {
14
+ await lithia.stop();
15
+ } catch {
16
+ } finally {
17
+ process.exit(0);
18
+ }
19
+ };
20
+ process.once("SIGINT", shutdown);
21
+ process.once("SIGTERM", shutdown);
22
+ }
23
+ await bootstrap().catch(() => process.exit(1));
24
+ //# sourceMappingURL=_entrypoint.mjs.map
25
+ //# sourceMappingURL=_entrypoint.mjs.map
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,306 @@
1
+ #! /usr/bin/env node
2
+ import { defineCommand, runMain } from 'citty';
3
+ import { readFile, writeFile, chmod } from 'fs/promises';
4
+ import { join, resolve } from 'path';
5
+ import { HostSupervisor } from '@lithia-js/core/_';
6
+ import { logger } from '@lithia-js/utils';
7
+ import chokidar from 'chokidar';
8
+
9
+ var build = defineCommand({
10
+ meta: {
11
+ name: "build",
12
+ description: "Compile the project for production deployment"
13
+ },
14
+ /**
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.
23
+ */
24
+ async run() {
25
+ const lithia = new HostSupervisor({ environment: "build" });
26
+ await lithia.setup();
27
+ logger.info("Initializing production build sequence...");
28
+ try {
29
+ await lithia.build();
30
+ } catch {
31
+ process.exit(1);
32
+ }
33
+ const { config } = lithia;
34
+ const workingDirectory = process.cwd();
35
+ const entryPath = join(workingDirectory, config.outDir, "server.js");
36
+ const templatePath = resolve(import.meta.dirname, "_entrypoint.mjs");
37
+ try {
38
+ const rawTemplate = await readFile(templatePath, "utf-8");
39
+ const processedContent = rawTemplate.replace(
40
+ "__CONFIG__",
41
+ JSON.stringify(config)
42
+ );
43
+ await writeFile(entryPath, processedContent, "utf-8");
44
+ await lithia.loadRoutes();
45
+ await lithia.loadEvents();
46
+ await lithia.loadTasks();
47
+ await chmod(entryPath, 493);
48
+ logger.success("Production build completed successfully.");
49
+ } catch (error) {
50
+ logger.error("Failed to finalize the build entry point.");
51
+ logger.debug(error);
52
+ }
53
+ lithia.printRouteTree();
54
+ lithia.printEventTree();
55
+ lithia.printTaskTree();
56
+ }
57
+ });
58
+ var build_default = build;
59
+
60
+ // src/cmd/dev-scheduler.ts
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
+ */
72
+ constructor(onBatch, debounceMs = 180, onError = () => {
73
+ }) {
74
+ this.onBatch = onBatch;
75
+ this.debounceMs = debounceMs;
76
+ this.onError = onError;
77
+ }
78
+ pending = {
79
+ source: false,
80
+ config: false,
81
+ env: false
82
+ };
83
+ timer = null;
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
+ */
91
+ enqueue(kind) {
92
+ this.pending[kind] = true;
93
+ if (this.running) return;
94
+ if (this.timer) clearTimeout(this.timer);
95
+ this.timer = setTimeout(() => {
96
+ this.timer = null;
97
+ void this.flush();
98
+ }, this.debounceMs);
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
+ */
106
+ async flush() {
107
+ if (this.running) return;
108
+ this.running = true;
109
+ try {
110
+ while (this.hasPendingChanges()) {
111
+ await this.onBatch(this.consumePending());
112
+ }
113
+ } catch (error) {
114
+ this.onError(error);
115
+ } finally {
116
+ this.running = false;
117
+ if (this.hasPendingChanges() && !this.timer) {
118
+ this.timer = setTimeout(() => {
119
+ this.timer = null;
120
+ void this.flush();
121
+ }, this.debounceMs);
122
+ }
123
+ }
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
+ */
130
+ hasPendingChanges() {
131
+ return this.pending.source || this.pending.config || this.pending.env;
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
+ */
139
+ consumePending() {
140
+ const batch = { ...this.pending };
141
+ this.pending.source = false;
142
+ this.pending.config = false;
143
+ this.pending.env = false;
144
+ return batch;
145
+ }
146
+ };
147
+
148
+ // src/cmd/dev.ts
149
+ var dev = defineCommand({
150
+ meta: {
151
+ name: "dev",
152
+ description: "Start the development server with hot-reload capabilities"
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
+ */
160
+ async run() {
161
+ const cwd = process.cwd();
162
+ const lithia = new HostSupervisor({ environment: "development" });
163
+ await lithia.setup();
164
+ const initialBuildSucceeded = await lithia.build();
165
+ const lifecycleState = {
166
+ hasReloadableArtifacts: initialBuildSucceeded
167
+ };
168
+ if (initialBuildSucceeded) {
169
+ try {
170
+ await lithia.start();
171
+ } catch {
172
+ logger.error("Failed to start the development server.");
173
+ }
174
+ } else {
175
+ logger.warn(
176
+ "Initial build failed. Waiting for file changes while continuing to serve nothing."
177
+ );
178
+ }
179
+ const scheduler = new DevLifecycleScheduler(
180
+ async (batch) => {
181
+ await processDevBatch(lithia, batch, lifecycleState);
182
+ },
183
+ 180,
184
+ (error) => {
185
+ logger.error("Dev lifecycle failed:", error);
186
+ }
187
+ );
188
+ const srcWatcher = chokidar.watch(join(cwd, "src"), {
189
+ ignored: [/(^|[/\\])\../, "**/node_modules/**"],
190
+ persistent: true,
191
+ ignoreInitial: true
192
+ });
193
+ srcWatcher.on("all", (event) => {
194
+ if (["add", "change", "unlink"].includes(event)) {
195
+ scheduler.enqueue("source");
196
+ }
197
+ });
198
+ const extensions = [".js", ".mjs", ".ts", ".mts", ".json"];
199
+ const configFiles = [
200
+ ...lithia.config.envFiles,
201
+ ...extensions.map((ext) => join(cwd, `lithia.config${ext}`))
202
+ ];
203
+ const configWatcher = chokidar.watch(configFiles, {
204
+ cwd,
205
+ ignoreInitial: true
206
+ });
207
+ configWatcher.on("all", (event, filePath) => {
208
+ if (["change", "add"].includes(event)) {
209
+ if (filePath.includes("lithia.config")) {
210
+ scheduler.enqueue("config");
211
+ } else {
212
+ scheduler.enqueue("env");
213
+ }
214
+ }
215
+ });
216
+ const shutdown = async () => {
217
+ logger.info("Shutting down development server...");
218
+ await Promise.allSettled([
219
+ srcWatcher.close(),
220
+ configWatcher.close(),
221
+ lithia.stop()
222
+ ]);
223
+ process.exit(0);
224
+ };
225
+ process.once("SIGINT", shutdown);
226
+ process.once("SIGTERM", shutdown);
227
+ }
228
+ });
229
+ var dev_default = dev;
230
+ async function processDevBatch(lithia, batch, state) {
231
+ if (batch.config) {
232
+ const previousConfig = structuredClone(lithia.config);
233
+ const previousEnv = lithia.getEnvSnapshot();
234
+ try {
235
+ await lithia.loadConfig();
236
+ await lithia.loadEnv();
237
+ const buildSucceeded = await lithia.build();
238
+ if (!buildSucceeded) {
239
+ state.hasReloadableArtifacts = state.hasReloadableArtifacts || lithia.isAppReady;
240
+ lithia.replaceConfig(previousConfig);
241
+ lithia.replaceEnv(previousEnv);
242
+ logger.warn(
243
+ "Reload skipped due to build failure. Rolled back config/env and kept serving the previous app."
244
+ );
245
+ return;
246
+ }
247
+ await lithia.reload();
248
+ state.hasReloadableArtifacts = true;
249
+ return;
250
+ } catch (error) {
251
+ lithia.replaceConfig(previousConfig);
252
+ lithia.replaceEnv(previousEnv);
253
+ throw error;
254
+ }
255
+ }
256
+ if (batch.source) {
257
+ const buildSucceeded = await lithia.build();
258
+ if (!buildSucceeded) {
259
+ state.hasReloadableArtifacts = state.hasReloadableArtifacts || lithia.isAppReady;
260
+ logger.warn(
261
+ "Reload skipped due to build failure. Continuing to serve previous app."
262
+ );
263
+ return;
264
+ }
265
+ state.hasReloadableArtifacts = true;
266
+ }
267
+ if (batch.env) {
268
+ if (!state.hasReloadableArtifacts) {
269
+ logger.warn(
270
+ "Reload skipped because the latest build artifacts are unavailable. Fix the build and save again."
271
+ );
272
+ return;
273
+ }
274
+ await lithia.loadEnv();
275
+ }
276
+ if (batch.source || batch.env) {
277
+ await lithia.reload();
278
+ state.hasReloadableArtifacts = true;
279
+ if (batch.env && !batch.source) {
280
+ logger.success("Applied environment changes.");
281
+ }
282
+ }
283
+ }
284
+
285
+ // package.json
286
+ var package_default = {
287
+ version: "1.0.0-canary.30"};
288
+
289
+ // src/meta.ts
290
+ var version = package_default.version;
291
+
292
+ // src/index.ts
293
+ var main = defineCommand({
294
+ meta: {
295
+ name: "lithia",
296
+ description: "Lithia CLI",
297
+ version
298
+ },
299
+ subCommands: {
300
+ dev: dev_default,
301
+ build: build_default
302
+ }
303
+ });
304
+ runMain(main).then();
305
+ //# sourceMappingURL=index.mjs.map
306
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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":";;;;;;;;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,M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AO;AACpB,IAAA,KAAA,CAAM,sBAAA,GAAyB,IAAA;AAE/B,IAAA,IAAI,KAAA,CAAM,GAAA,IAAO,CAAC,KAAA,CAAM,MAAA,EAAQ;AAC/B,MAAAA,MAAAA,CAAO,QAAQ,8BAA8B,CAAA;AAAA,IAC9C;AAAA,EACD;AACD;;;ACxMA,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\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\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\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\tawait lithia.loadEnv();\n\t}\n\n\tif (batch.source || batch.env) {\n\t\tawait lithia.reload();\n\t\tstate.hasReloadableArtifacts = true;\n\n\t\tif (batch.env && !batch.source) {\n\t\t\tlogger.success(\"Applied environment changes.\");\n\t\t}\n\t}\n}\n","{\n\t\"name\": \"@lithia-js/cli\",\n\t\"version\": \"1.0.0-canary.30\",\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.30\",\n\t\t\"@lithia-js/utils\": \"workspace:1.0.0-canary.30\",\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,35 +1,53 @@
1
1
  {
2
2
  "name": "@lithia-js/cli",
3
- "version": "1.0.0-canary.3",
4
- "private": false,
5
- "bin": {
6
- "lithia": "dist/main.js"
7
- },
3
+ "version": "1.0.0-canary.30",
4
+ "description": "Command-line interface for developing and building Lithia.js applications.",
5
+ "keywords": [
6
+ "lithia",
7
+ "lithia-js",
8
+ "cli",
9
+ "framework",
10
+ "backend",
11
+ "create-app",
12
+ "build-tool",
13
+ "dev-server"
14
+ ],
8
15
  "author": "Lucas Arch <luketsx@icloud.com>",
9
- "homepage": "https://lithiajs.com",
10
16
  "license": "MIT",
17
+ "homepage": "https://lithiajs.org",
11
18
  "repository": {
12
19
  "type": "git",
13
- "url": "git+https://github.com/lithia-framework/lithia.git"
20
+ "url": "git+https://github.com/lithia-framework/lithia.git",
21
+ "directory": "packages/cli"
14
22
  },
15
23
  "bugs": {
16
24
  "url": "https://github.com/lithia-framework/lithia/issues"
17
25
  },
18
- "dependencies": {
19
- "citty": "^0.2.0",
20
- "chokidar": "^5.0.0",
21
- "@lithia-js/core": "1.0.0-canary.3",
22
- "@lithia-js/utils": "1.0.0-canary.3"
26
+ "type": "module",
27
+ "bin": {
28
+ "lithia": "./dist/index.mjs"
23
29
  },
30
+ "main": "./dist/index.mjs",
31
+ "files": [
32
+ "dist",
33
+ "templates"
34
+ ],
24
35
  "engines": {
25
36
  "node": ">=20"
26
37
  },
38
+ "dependencies": {
39
+ "@lithia-js/core": "1.0.0-canary.30",
40
+ "@lithia-js/utils": "1.0.0-canary.30",
41
+ "citty": "^0.2.0",
42
+ "chokidar": "^5.0.0"
43
+ },
27
44
  "publishConfig": {
28
45
  "registry": "https://registry.npmjs.org/",
29
46
  "access": "public",
30
47
  "provenance": true
31
48
  },
32
49
  "scripts": {
33
- "build": "tsc -p tsconfig.build.json"
50
+ "build": "tsup --config tsup.config.ts",
51
+ "test": "vitest --run"
34
52
  }
35
53
  }
package/CHANGELOG.md DELETED
@@ -1,40 +0,0 @@
1
- # @lithia-js/cli
2
-
3
- ## 1.0.0-canary.3
4
-
5
- ### Patch Changes
6
-
7
- - d536a2f: Fixed exports from @lithia-js/native
8
- - Updated dependencies [d536a2f]
9
- - @lithia-js/core@1.0.0-canary.3
10
- - @lithia-js/utils@1.0.0-canary.3
11
-
12
- ## 1.0.0-canary.2
13
-
14
- ### Patch Changes
15
-
16
- - .npmignore update
17
- - Updated dependencies
18
- - @lithia-js/core@1.0.0-canary.2
19
- - @lithia-js/utils@1.0.0-canary.2
20
-
21
- ## 1.0.0-canary.1
22
-
23
- ### Patch Changes
24
-
25
- - 2992e91: Manifest update for workflow compatibility
26
- - Updated dependencies [2992e91]
27
- - @lithia-js/utils@1.0.0-canary.1
28
- - @lithia-js/core@1.0.0-canary.1
29
-
30
- ## 1.0.0-canary.0
31
-
32
- ### Major Changes
33
-
34
- - e9a0904: Lithia v1 canary release. Now with separated modules and napi bindings for build performance
35
-
36
- ### Patch Changes
37
-
38
- - Updated dependencies [e9a0904]
39
- - @lithia-js/core@1.0.0-canary.0
40
- - @lithia-js/utils@1.0.0-canary.0
@@ -1,2 +0,0 @@
1
- declare const build: import("citty").CommandDef<import("citty").ArgsDef>;
2
- export default build;
package/dist/cmd/build.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_path_1 = __importDefault(require("node:path"));
7
- const core_1 = require("@lithia-js/core");
8
- const utils_1 = require("@lithia-js/utils");
9
- const citty_1 = require("citty");
10
- const build = (0, citty_1.defineCommand)({
11
- meta: {
12
- name: "build",
13
- description: "Start the build process",
14
- },
15
- async run() {
16
- const tsConfig = (0, utils_1.parseTsConfig)();
17
- const sourceRoot = node_path_1.default.join(process.cwd(), "src");
18
- const outRoot = node_path_1.default.join(process.cwd(), tsConfig.outDir);
19
- const lithia = await core_1.Lithia.create({
20
- environment: "production",
21
- sourceRoot,
22
- outRoot,
23
- });
24
- lithia.build();
25
- },
26
- });
27
- exports.default = build;
28
- //# sourceMappingURL=build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/cmd/build.ts"],"names":[],"mappings":";;;;;AAAA,0DAA6B;AAC7B,0CAAyC;AACzC,4CAAiD;AACjD,iCAAsC;AAEtC,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC;IAC3B,IAAI,EAAE;QACL,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yBAAyB;KACtC;IACD,KAAK,CAAC,GAAG;QACR,MAAM,QAAQ,GAAG,IAAA,qBAAa,GAAE,CAAC;QACjC,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAE1D,MAAM,MAAM,GAAG,MAAM,aAAM,CAAC,MAAM,CAAC;YAClC,WAAW,EAAE,YAAY;YACzB,UAAU;YACV,OAAO;SACP,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;CACD,CAAC,CAAC;AAEH,kBAAe,KAAK,CAAC"}
package/dist/cmd/dev.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const dev: import("citty").CommandDef<import("citty").ArgsDef>;
2
- export default dev;
package/dist/cmd/dev.js DELETED
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_path_1 = __importDefault(require("node:path"));
7
- const core_1 = require("@lithia-js/core");
8
- const utils_1 = require("@lithia-js/utils");
9
- const chokidar_1 = __importDefault(require("chokidar"));
10
- const citty_1 = require("citty");
11
- const dev = (0, citty_1.defineCommand)({
12
- meta: {
13
- name: "dev",
14
- description: "Start the development server",
15
- },
16
- async run() {
17
- const cwd = process.cwd();
18
- // Load environment variables initially
19
- (0, core_1.loadEnv)(cwd);
20
- const tsConfig = (0, utils_1.parseTsConfig)();
21
- const sourceRoot = node_path_1.default.join(cwd, "src");
22
- const outRoot = node_path_1.default.join(cwd, tsConfig.outDir);
23
- const lithia = await core_1.Lithia.create({
24
- environment: "development",
25
- sourceRoot,
26
- outRoot,
27
- });
28
- // Initial build
29
- lithia.build();
30
- // Start the HTTP server after initial build
31
- try {
32
- await lithia.start();
33
- }
34
- catch {
35
- // let Lithia's emitter handle the error
36
- }
37
- // Debounced rebuild helper
38
- let timer = null;
39
- const debounce = (fn, ms = 150) => {
40
- if (timer)
41
- clearTimeout(timer);
42
- timer = setTimeout(() => {
43
- timer = null;
44
- fn();
45
- }, ms);
46
- };
47
- // Watch source files
48
- const watchPath = sourceRoot;
49
- const sourceWatcher = chokidar_1.default.watch(watchPath, {
50
- ignored: /(^|[/\\])\../, // ignore dotfiles
51
- persistent: true,
52
- ignoreInitial: true,
53
- });
54
- sourceWatcher.on("all", (event, changedPath) => {
55
- // only trigger on relevant events
56
- if (event === "add" || event === "change" || event === "unlink") {
57
- const filename = node_path_1.default.basename(changedPath);
58
- if (filename === "_server.ts") {
59
- core_1.logger.warn(`Detected change in ${(0, utils_1.green)(filename)} file. Please restart the dev server to apply changes.`);
60
- }
61
- // notify Lithia about the changed file so core can react
62
- try {
63
- lithia.emit("file:changed", { event, path: changedPath });
64
- }
65
- catch {
66
- // ignore if emitter not available for some reason
67
- }
68
- debounce(() => {
69
- lithia.build();
70
- });
71
- }
72
- });
73
- // Watch env files for changes
74
- const envWatcher = chokidar_1.default.watch([".env", ".env.local"], {
75
- cwd: cwd,
76
- ignoreInitial: true,
77
- });
78
- envWatcher.on("all", (event, path) => {
79
- if (event === "change" || event === "add") {
80
- // Reload env vars
81
- (0, core_1.loadEnv)(cwd);
82
- // Restart server to pick up new env vars if needed
83
- // For now we just reload, but some configs might depend on env vars
84
- // so a full restart might be safer, but let's stick to hot reloading what we can
85
- // Usually env var changes require process restart in Node, but
86
- // since we are just setting process.env, subsequent accesses will see new values.
87
- // However, if code read process.env at startup, it won't suffice.
88
- // For a dev server, maybe logging that env changed is enough?
89
- // Or fully restarting the Lithia instance?
90
- // Given the request "recarregamento automático de .env", we should try to support it.
91
- // But Node.js process.env changes don't affect already started modules if they cached it.
92
- // Let's at least reload the env vars.
93
- // A full restart would require tearing down Lithia and recreating it.
94
- core_1.logger.event(`Environment file changed (${path}). Reloading...`);
95
- }
96
- });
97
- // Graceful shutdown: stop watchers and server
98
- const shutdown = async () => {
99
- try {
100
- await sourceWatcher.close();
101
- await envWatcher.close();
102
- }
103
- catch (_) { }
104
- try {
105
- await lithia.stop();
106
- }
107
- catch (_) { }
108
- process.exit(0);
109
- };
110
- process.on("SIGINT", shutdown);
111
- process.on("SIGTERM", shutdown);
112
- // Process remains alive while the HTTP server and watcher run
113
- },
114
- });
115
- exports.default = dev;
116
- //# sourceMappingURL=dev.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/cmd/dev.ts"],"names":[],"mappings":";;;;;AAAA,0DAA6B;AAC7B,0CAA0D;AAC1D,4CAAwD;AACxD,wDAAgC;AAChC,iCAAsC;AAEtC,MAAM,GAAG,GAAG,IAAA,qBAAa,EAAC;IACzB,IAAI,EAAE;QACL,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,8BAA8B;KAC3C;IACD,KAAK,CAAC,GAAG;QACR,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAE1B,uCAAuC;QACvC,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC;QAEb,MAAM,QAAQ,GAAG,IAAA,qBAAa,GAAE,CAAC;QACjC,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,MAAM,aAAM,CAAC,MAAM,CAAC;YAClC,WAAW,EAAE,aAAa;YAC1B,UAAU;YACV,OAAO;SACP,CAAC,CAAC;QAEH,gBAAgB;QAChB,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,4CAA4C;QAC5C,IAAI,CAAC;YACJ,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;QAAC,MAAM,CAAC;YACR,wCAAwC;QACzC,CAAC;QAED,2BAA2B;QAC3B,IAAI,KAAK,GAA0B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;CACD,CAAC,CAAC;AAEH,kBAAe,GAAG,CAAC"}
@@ -1,2 +0,0 @@
1
- declare const start: import("citty").CommandDef<import("citty").ArgsDef>;
2
- export default start;
package/dist/cmd/start.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_path_1 = __importDefault(require("node:path"));
7
- const core_1 = require("@lithia-js/core");
8
- const utils_1 = require("@lithia-js/utils");
9
- const citty_1 = require("citty");
10
- const start = (0, citty_1.defineCommand)({
11
- meta: {
12
- name: "start",
13
- description: "Start the production server",
14
- },
15
- async run() {
16
- const cwd = process.cwd();
17
- // Load environment variables
18
- (0, core_1.loadEnv)(cwd);
19
- const tsConfig = (0, utils_1.parseTsConfig)();
20
- const sourceRoot = node_path_1.default.join(cwd, "src");
21
- const outRoot = node_path_1.default.join(cwd, tsConfig.outDir);
22
- const lithia = await core_1.Lithia.create({
23
- environment: "production",
24
- sourceRoot,
25
- outRoot,
26
- });
27
- lithia.loadRoutes();
28
- try {
29
- await lithia.start();
30
- }
31
- catch {
32
- // let Lithia's emitter handle the error
33
- }
34
- const shutdown = async () => {
35
- try {
36
- await lithia.stop();
37
- }
38
- catch { }
39
- process.exit(0);
40
- };
41
- process.on("SIGINT", shutdown);
42
- process.on("SIGTERM", shutdown);
43
- },
44
- });
45
- exports.default = start;
46
- //# sourceMappingURL=start.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/cmd/start.ts"],"names":[],"mappings":";;;;;AAAA,0DAA6B;AAC7B,0CAAkD;AAClD,4CAAiD;AACjD,iCAAsC;AAEtC,MAAM,KAAK,GAAG,IAAA,qBAAa,EAAC;IAC3B,IAAI,EAAE;QACL,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,6BAA6B;KAC1C;IACD,KAAK,CAAC,GAAG;QACR,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAE1B,6BAA6B;QAC7B,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC;QAEb,MAAM,QAAQ,GAAG,IAAA,qBAAa,GAAE,CAAC;QACjC,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEhD,MAAM,MAAM,GAAG,MAAM,aAAM,CAAC,MAAM,CAAC;YAClC,WAAW,EAAE,YAAY;YACzB,UAAU;YACV,OAAO;SACP,CAAC,CAAC;QAEH,MAAM,CAAC,UAAU,EAAE,CAAC;QAEpB,IAAI,CAAC;YACJ,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;QAAC,MAAM,CAAC;YACR,wCAAwC;QACzC,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;YAC3B,IAAI,CAAC;gBACJ,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD,CAAC,CAAC;AAEH,kBAAe,KAAK,CAAC"}
package/dist/main.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
package/dist/main.js DELETED
@@ -1,25 +0,0 @@
1
- #! /usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const citty_1 = require("citty");
8
- const build_1 = __importDefault(require("./cmd/build"));
9
- const dev_1 = __importDefault(require("./cmd/dev"));
10
- const start_1 = __importDefault(require("./cmd/start"));
11
- const meta_1 = require("./meta");
12
- const main = (0, citty_1.defineCommand)({
13
- meta: {
14
- name: "lithia",
15
- description: "Lithia CLI",
16
- version: meta_1.version,
17
- },
18
- subCommands: {
19
- dev: dev_1.default,
20
- build: build_1.default,
21
- start: start_1.default,
22
- },
23
- });
24
- (0, citty_1.runMain)(main).then();
25
- //# sourceMappingURL=main.js.map
package/dist/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;AAEA,iCAA+C;AAC/C,wDAAgC;AAChC,oDAA4B;AAC5B,wDAAgC;AAChC,iCAAiC;AAEjC,MAAM,IAAI,GAAG,IAAA,qBAAa,EAAC;IAC1B,IAAI,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,YAAY;QACzB,OAAO,EAAP,cAAO;KACP;IACD,WAAW,EAAE;QACZ,GAAG,EAAH,aAAG;QACH,KAAK,EAAL,eAAK;QACL,KAAK,EAAL,eAAK;KACL;CACD,CAAC,CAAC;AAEH,IAAA,eAAO,EAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC"}
package/dist/meta.d.ts DELETED
@@ -1 +0,0 @@
1
- export { version } from "../package.json";
package/dist/meta.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = void 0;
4
- var package_json_1 = require("../package.json");
5
- Object.defineProperty(exports, "version", { enumerable: true, get: function () { return package_json_1.version; } });
6
- //# sourceMappingURL=meta.js.map
package/dist/meta.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.js","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":";;;AAAA,gDAA0C;AAAjC,uGAAA,OAAO,OAAA"}
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist"
6
- },
7
- "include": ["src/**/*"]
8
- }