@orion-js/core 4.3.2 → 4.4.0
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/LICENSE +21 -0
- package/dist/build/build.d.ts +3 -0
- package/dist/build/checkTs.d.ts +1 -0
- package/dist/build/index.d.ts +3 -0
- package/dist/check/checkTs.d.ts +1 -0
- package/dist/check/index.d.ts +1 -0
- package/dist/create/index.d.ts +4 -0
- package/dist/dev/index.d.ts +2 -0
- package/dist/dev/runner/getArgs.d.ts +5 -0
- package/dist/dev/runner/index.d.ts +12 -0
- package/dist/dev/runner/startProcess.d.ts +2 -0
- package/dist/dev/watchAndCompile/cleanDirectory.d.ts +1 -0
- package/dist/dev/watchAndCompile/ensureConfigComplies.d.ts +1 -0
- package/dist/dev/watchAndCompile/getConfigPath.d.ts +1 -0
- package/dist/dev/watchAndCompile/getHost.d.ts +2 -0
- package/dist/dev/watchAndCompile/index.d.ts +2 -0
- package/dist/dev/watchAndCompile/writeEnvFile.d.ts +2 -0
- package/dist/handleErrors.d.ts +1 -0
- package/dist/helpers/ensureDirectory.d.ts +2 -0
- package/dist/helpers/execute.d.ts +1 -0
- package/dist/helpers/getFileContents.d.ts +1 -0
- package/dist/helpers/writeFile.d.ts +1 -0
- package/dist/index.cjs +104 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +91 -101
- package/dist/index.js.map +1 -1
- package/dist/info.d.ts +1 -0
- package/dist/prod/index.d.ts +5 -0
- package/dist/prod/runProd.d.ts +2 -0
- package/dist/repl/index.d.ts +5 -0
- package/dist/version.d.ts +2 -0
- package/package.json +12 -13
- package/dist/index.d.cts +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Orionjs Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkTs(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function checkTs(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface RunnerOptions {
|
|
2
|
+
shell: boolean;
|
|
3
|
+
clean: boolean;
|
|
4
|
+
node: boolean;
|
|
5
|
+
repl: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface Runner {
|
|
8
|
+
start: () => void;
|
|
9
|
+
restart: () => void;
|
|
10
|
+
stop: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function getRunner(options: RunnerOptions, command: any): Runner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function cleanDirectory(directory?: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ensureConfigComplies(configPath: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getConfigPath(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (command: any): Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function readFile(filePath: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (path: string, content: string): Promise<void>;
|
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
|
|
25
25
|
// src/index.ts
|
|
26
|
-
var
|
|
26
|
+
var import_chalk14 = __toESM(require("chalk"), 1);
|
|
27
27
|
var import_commander = require("commander");
|
|
28
28
|
|
|
29
29
|
// src/helpers/execute.ts
|
|
@@ -56,7 +56,7 @@ async function create_default({ name, kit }) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// src/dev/index.ts
|
|
59
|
-
var
|
|
59
|
+
var import_chalk4 = __toESM(require("chalk"), 1);
|
|
60
60
|
|
|
61
61
|
// src/dev/runner/index.ts
|
|
62
62
|
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
@@ -68,10 +68,10 @@ var import_node_fs2 = __toESM(require("fs"), 1);
|
|
|
68
68
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
69
69
|
var import_node_path = __toESM(require("path"), 1);
|
|
70
70
|
var ensureDirectory = (filePath) => {
|
|
71
|
-
const
|
|
72
|
-
if (import_node_fs.default.existsSync(
|
|
73
|
-
ensureDirectory(
|
|
74
|
-
import_node_fs.default.mkdirSync(
|
|
71
|
+
const dirname3 = import_node_path.default.dirname(filePath);
|
|
72
|
+
if (import_node_fs.default.existsSync(dirname3)) return true;
|
|
73
|
+
ensureDirectory(dirname3);
|
|
74
|
+
import_node_fs.default.mkdirSync(dirname3);
|
|
75
75
|
};
|
|
76
76
|
var ensureDirectory_default = ensureDirectory;
|
|
77
77
|
|
|
@@ -154,9 +154,6 @@ function getRunner(options, command) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
// src/dev/watchAndCompile/index.ts
|
|
158
|
-
var import_typescript4 = __toESM(require("typescript"), 1);
|
|
159
|
-
|
|
160
157
|
// src/dev/watchAndCompile/cleanDirectory.ts
|
|
161
158
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
162
159
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
@@ -182,10 +179,12 @@ async function cleanDirectory(directory) {
|
|
|
182
179
|
}
|
|
183
180
|
|
|
184
181
|
// src/dev/watchAndCompile/getHost.ts
|
|
185
|
-
var
|
|
182
|
+
var import_node_child_process3 = require("child_process");
|
|
183
|
+
var import_node_readline = require("readline");
|
|
186
184
|
|
|
187
185
|
// src/dev/watchAndCompile/getConfigPath.ts
|
|
188
|
-
var
|
|
186
|
+
var import_node_fs5 = require("fs");
|
|
187
|
+
var import_node_path3 = require("path");
|
|
189
188
|
|
|
190
189
|
// src/dev/watchAndCompile/ensureConfigComplies.ts
|
|
191
190
|
var import_comment_json = require("comment-json");
|
|
@@ -203,11 +202,15 @@ function ensureConfigComplies(configPath) {
|
|
|
203
202
|
try {
|
|
204
203
|
const configJSON = readFile(configPath);
|
|
205
204
|
const config = (0, import_comment_json.parse)(configJSON);
|
|
205
|
+
const { baseUrl: _baseUrl, ...compilerOptions } = config.compilerOptions ?? {};
|
|
206
206
|
const newConfig = {
|
|
207
207
|
...config,
|
|
208
208
|
compilerOptions: {
|
|
209
|
-
...
|
|
210
|
-
|
|
209
|
+
...compilerOptions,
|
|
210
|
+
paths: {
|
|
211
|
+
"*": ["./*"],
|
|
212
|
+
...compilerOptions.paths
|
|
213
|
+
},
|
|
211
214
|
noEmit: true
|
|
212
215
|
}
|
|
213
216
|
};
|
|
@@ -224,9 +227,19 @@ function ensureConfigComplies(configPath) {
|
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
// src/dev/watchAndCompile/getConfigPath.ts
|
|
230
|
+
function findConfigFile(startDirectory, fileName) {
|
|
231
|
+
let directory = startDirectory;
|
|
232
|
+
while (true) {
|
|
233
|
+
const candidate = (0, import_node_path3.join)(directory, fileName);
|
|
234
|
+
if ((0, import_node_fs5.existsSync)(candidate)) return candidate;
|
|
235
|
+
const parent = (0, import_node_path3.dirname)(directory);
|
|
236
|
+
if (parent === directory) return void 0;
|
|
237
|
+
directory = parent;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
227
240
|
function getConfigPath() {
|
|
228
241
|
const appBasePath = process.cwd();
|
|
229
|
-
const configPath =
|
|
242
|
+
const configPath = findConfigFile(appBasePath, "tsconfig.server.json") || findConfigFile(appBasePath, "tsconfig.json");
|
|
230
243
|
if (!configPath) {
|
|
231
244
|
throw new Error("Could not find a valid 'tsconfig.json'.");
|
|
232
245
|
}
|
|
@@ -234,63 +247,40 @@ function getConfigPath() {
|
|
|
234
247
|
return configPath;
|
|
235
248
|
}
|
|
236
249
|
|
|
237
|
-
// src/dev/watchAndCompile/reports.ts
|
|
238
|
-
var import_typescript2 = __toESM(require("typescript"), 1);
|
|
239
|
-
var format = {
|
|
240
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
241
|
-
getCurrentDirectory: () => process.cwd(),
|
|
242
|
-
getNewLine: () => import_typescript2.default.sys.newLine
|
|
243
|
-
};
|
|
244
|
-
function reportDiagnostic(diagnostic) {
|
|
245
|
-
console.log(import_typescript2.default.formatDiagnosticsWithColorAndContext([diagnostic], format));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
250
|
// src/dev/watchAndCompile/getHost.ts
|
|
249
|
-
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
250
251
|
function getHost(runner) {
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
const configPath = getConfigPath();
|
|
253
|
+
const watcher = (0, import_node_child_process3.spawn)("tsc", ["--watch", "--noEmit", "--project", configPath], {
|
|
254
|
+
env: process.env,
|
|
255
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
256
|
+
});
|
|
257
|
+
const output = (0, import_node_readline.createInterface)({ input: watcher.stdout });
|
|
258
|
+
output.on("line", (line) => {
|
|
259
|
+
console.log(line);
|
|
260
|
+
if (line.includes("Starting compilation") || line.includes("File change detected")) {
|
|
258
261
|
runner.stop();
|
|
259
|
-
isStopped = true;
|
|
260
262
|
return;
|
|
261
263
|
}
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
if (!diagnostic.messageText.toString().includes("Found 0 errors.")) {
|
|
265
|
-
runner.stop();
|
|
266
|
-
isStopped = true;
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (isStopped) {
|
|
271
|
-
isStopped = false;
|
|
272
|
-
runner.start();
|
|
273
|
-
}
|
|
264
|
+
if (line.includes("Found 0 errors.")) {
|
|
265
|
+
runner.start();
|
|
274
266
|
return;
|
|
275
267
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
);
|
|
288
|
-
return host;
|
|
268
|
+
if (/Found [1-9]\d* errors?\./.test(line)) {
|
|
269
|
+
runner.stop();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
const errors = (0, import_node_readline.createInterface)({ input: watcher.stderr });
|
|
273
|
+
errors.on("line", (line) => console.error(line));
|
|
274
|
+
watcher.on("error", (error) => {
|
|
275
|
+
runner.stop();
|
|
276
|
+
console.error(`Unable to start TypeScript: ${error.message}`);
|
|
277
|
+
});
|
|
278
|
+
return watcher;
|
|
289
279
|
}
|
|
290
280
|
|
|
291
281
|
// src/dev/watchAndCompile/writeEnvFile.ts
|
|
292
282
|
var import_env = require("@orion-js/env");
|
|
293
|
-
var
|
|
283
|
+
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
294
284
|
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
295
285
|
var envFilePath = process.env.ORION_ENV_FILE_PATH;
|
|
296
286
|
var dtsFilePath = "./app/env.d.ts";
|
|
@@ -298,7 +288,7 @@ var watchEnvFile = async (runner) => {
|
|
|
298
288
|
if (!envFilePath) return;
|
|
299
289
|
(0, import_env.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
|
|
300
290
|
import_chokidar.default.watch(envFilePath, { ignoreInitial: true }).on("change", async () => {
|
|
301
|
-
console.log(
|
|
291
|
+
console.log(import_chalk3.default.bold("=> Environment file changed. Restarting..."));
|
|
302
292
|
(0, import_env.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
|
|
303
293
|
runner.restart();
|
|
304
294
|
});
|
|
@@ -307,28 +297,27 @@ var watchEnvFile = async (runner) => {
|
|
|
307
297
|
// src/dev/watchAndCompile/index.ts
|
|
308
298
|
async function watchAndCompile(runner) {
|
|
309
299
|
await cleanDirectory();
|
|
310
|
-
|
|
311
|
-
import_typescript4.default.createWatchProgram(host);
|
|
300
|
+
getHost(runner);
|
|
312
301
|
watchEnvFile(runner);
|
|
313
302
|
}
|
|
314
303
|
|
|
315
304
|
// src/dev/index.ts
|
|
316
305
|
async function dev_default(options, command) {
|
|
317
|
-
console.log(
|
|
318
|
-
Orionjs App ${
|
|
306
|
+
console.log(import_chalk4.default.bold(`
|
|
307
|
+
Orionjs App ${import_chalk4.default.green(import_chalk4.default.bold("V4"))} Dev mode
|
|
319
308
|
`));
|
|
320
309
|
const runner = getRunner(options, command);
|
|
321
310
|
watchAndCompile(runner);
|
|
322
311
|
}
|
|
323
312
|
|
|
324
313
|
// src/prod/index.ts
|
|
325
|
-
var
|
|
314
|
+
var import_chalk8 = __toESM(require("chalk"), 1);
|
|
326
315
|
|
|
327
316
|
// src/build/index.ts
|
|
328
|
-
var
|
|
317
|
+
var import_chalk7 = __toESM(require("chalk"), 1);
|
|
329
318
|
|
|
330
319
|
// src/build/build.ts
|
|
331
|
-
var
|
|
320
|
+
var import_chalk5 = __toESM(require("chalk"), 1);
|
|
332
321
|
var esbuild = __toESM(require("esbuild"), 1);
|
|
333
322
|
async function build2(options) {
|
|
334
323
|
const { output } = options;
|
|
@@ -346,14 +335,14 @@ async function build2(options) {
|
|
|
346
335
|
minify: true,
|
|
347
336
|
packages: "external"
|
|
348
337
|
});
|
|
349
|
-
console.log(
|
|
338
|
+
console.log(import_chalk5.default.green.bold("Build successful"));
|
|
350
339
|
}
|
|
351
340
|
|
|
352
341
|
// src/build/checkTs.ts
|
|
353
|
-
var
|
|
354
|
-
var
|
|
342
|
+
var import_chalk6 = __toESM(require("chalk"), 1);
|
|
343
|
+
var import_node_child_process4 = require("child_process");
|
|
355
344
|
var import_node_util = require("util");
|
|
356
|
-
var execPromise = (0, import_node_util.promisify)(
|
|
345
|
+
var execPromise = (0, import_node_util.promisify)(import_node_child_process4.exec);
|
|
357
346
|
async function checkTs() {
|
|
358
347
|
try {
|
|
359
348
|
console.log("Checking TypeScript...");
|
|
@@ -365,9 +354,9 @@ async function checkTs() {
|
|
|
365
354
|
gid: process.getgid(),
|
|
366
355
|
uid: process.getuid()
|
|
367
356
|
});
|
|
368
|
-
console.log(
|
|
357
|
+
console.log(import_chalk6.default.green.bold("TypeScript check passed"));
|
|
369
358
|
} catch (error) {
|
|
370
|
-
console.log(
|
|
359
|
+
console.log(import_chalk6.default.red.bold("TypeScript compilation failed"));
|
|
371
360
|
console.log(error.stderr || error.stdout || error.message);
|
|
372
361
|
process.exit(1);
|
|
373
362
|
}
|
|
@@ -375,23 +364,23 @@ async function checkTs() {
|
|
|
375
364
|
|
|
376
365
|
// src/build/index.ts
|
|
377
366
|
async function build_default(options) {
|
|
378
|
-
console.log(
|
|
367
|
+
console.log(import_chalk7.default.bold(`Building Orionjs App ${import_chalk7.default.green(import_chalk7.default.bold("V4"))}...`));
|
|
379
368
|
if (!options.output) {
|
|
380
369
|
options.output = "./build";
|
|
381
370
|
}
|
|
382
371
|
await cleanDirectory(options.output);
|
|
383
372
|
await checkTs();
|
|
384
373
|
await build2(options);
|
|
385
|
-
console.log(
|
|
374
|
+
console.log(import_chalk7.default.bold("Build completed"));
|
|
386
375
|
}
|
|
387
376
|
|
|
388
377
|
// src/prod/runProd.ts
|
|
389
|
-
var
|
|
378
|
+
var import_node_child_process5 = require("child_process");
|
|
390
379
|
function runProd(options, command) {
|
|
391
380
|
if (options.node) {
|
|
392
381
|
const indexPath = `${options.path}/index.js`;
|
|
393
382
|
const args2 = ["--import=tsx", ...command.args, indexPath];
|
|
394
|
-
(0,
|
|
383
|
+
(0, import_node_child_process5.spawn)("node", args2, {
|
|
395
384
|
env: {
|
|
396
385
|
NODE_ENV: "production",
|
|
397
386
|
...process.env
|
|
@@ -405,7 +394,7 @@ function runProd(options, command) {
|
|
|
405
394
|
return;
|
|
406
395
|
}
|
|
407
396
|
const args = [...command.args, "./app/index.ts"];
|
|
408
|
-
(0,
|
|
397
|
+
(0, import_node_child_process5.spawn)("bun", args, {
|
|
409
398
|
env: {
|
|
410
399
|
NODE_ENV: "production",
|
|
411
400
|
...process.env
|
|
@@ -420,8 +409,8 @@ function runProd(options, command) {
|
|
|
420
409
|
|
|
421
410
|
// src/prod/index.ts
|
|
422
411
|
async function prod_default(options, command) {
|
|
423
|
-
console.log(
|
|
424
|
-
Orionjs App ${
|
|
412
|
+
console.log(import_chalk8.default.bold(`
|
|
413
|
+
Orionjs App ${import_chalk8.default.green(import_chalk8.default.bold("V4"))} Prod mode
|
|
425
414
|
`));
|
|
426
415
|
if (options.node) {
|
|
427
416
|
if (!options.path) {
|
|
@@ -433,29 +422,29 @@ Orionjs App ${import_chalk9.default.green(import_chalk9.default.bold("V4"))} Pro
|
|
|
433
422
|
}
|
|
434
423
|
|
|
435
424
|
// src/handleErrors.ts
|
|
436
|
-
var
|
|
425
|
+
var import_chalk9 = __toESM(require("chalk"), 1);
|
|
437
426
|
process.on("unhandledRejection", (error) => {
|
|
438
427
|
if (error.codeFrame) {
|
|
439
|
-
console.error(
|
|
428
|
+
console.error(import_chalk9.default.red(error.message));
|
|
440
429
|
console.log(error.codeFrame);
|
|
441
430
|
} else {
|
|
442
|
-
console.error(
|
|
431
|
+
console.error(import_chalk9.default.red(error.message), import_chalk9.default.red("Unhandled promise rejection"));
|
|
443
432
|
}
|
|
444
433
|
}).on("uncaughtException", (error) => {
|
|
445
|
-
console.error(
|
|
434
|
+
console.error(import_chalk9.default.red(error.message));
|
|
446
435
|
process.exit(1);
|
|
447
436
|
});
|
|
448
437
|
|
|
449
438
|
// src/version.ts
|
|
450
|
-
var
|
|
451
|
-
var
|
|
439
|
+
var import_node_fs6 = require("fs");
|
|
440
|
+
var import_node_path4 = require("path");
|
|
452
441
|
var import_node_url = require("url");
|
|
453
442
|
var import_meta = {};
|
|
454
443
|
function getVersion() {
|
|
455
444
|
try {
|
|
456
|
-
const dir = (0,
|
|
457
|
-
const pkgPath = (0,
|
|
458
|
-
const pkg = JSON.parse((0,
|
|
445
|
+
const dir = (0, import_node_path4.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
446
|
+
const pkgPath = (0, import_node_path4.resolve)(dir, "..", "package.json");
|
|
447
|
+
const pkg = JSON.parse((0, import_node_fs6.readFileSync)(pkgPath, "utf-8"));
|
|
459
448
|
return pkg.version;
|
|
460
449
|
} catch {
|
|
461
450
|
return "unknown";
|
|
@@ -467,14 +456,14 @@ var version_default = getVersion();
|
|
|
467
456
|
var import_config = require("dotenv/config");
|
|
468
457
|
|
|
469
458
|
// src/check/index.ts
|
|
470
|
-
var
|
|
459
|
+
var import_chalk11 = __toESM(require("chalk"), 1);
|
|
471
460
|
|
|
472
461
|
// src/check/checkTs.ts
|
|
473
|
-
var
|
|
474
|
-
var
|
|
462
|
+
var import_chalk10 = __toESM(require("chalk"), 1);
|
|
463
|
+
var import_node_child_process6 = require("child_process");
|
|
475
464
|
function checkTs2() {
|
|
476
465
|
try {
|
|
477
|
-
(0,
|
|
466
|
+
(0, import_node_child_process6.execSync)("tsc --noEmit", {
|
|
478
467
|
cwd: process.cwd(),
|
|
479
468
|
env: {
|
|
480
469
|
...process.env
|
|
@@ -484,27 +473,27 @@ function checkTs2() {
|
|
|
484
473
|
stdio: "inherit"
|
|
485
474
|
});
|
|
486
475
|
} catch {
|
|
487
|
-
console.log(
|
|
476
|
+
console.log(import_chalk10.default.red.bold("TypeScript compilation failed"));
|
|
488
477
|
process.exit(1);
|
|
489
478
|
}
|
|
490
479
|
}
|
|
491
480
|
|
|
492
481
|
// src/check/index.ts
|
|
493
482
|
async function check_default() {
|
|
494
|
-
console.log(
|
|
483
|
+
console.log(import_chalk11.default.bold(`Orionjs App ${import_chalk11.default.green(import_chalk11.default.bold("V4"))}
|
|
495
484
|
`));
|
|
496
485
|
console.log("Checking typescript...");
|
|
497
486
|
checkTs2();
|
|
498
|
-
console.log(
|
|
487
|
+
console.log(import_chalk11.default.bold.green("Check passed\n"));
|
|
499
488
|
}
|
|
500
489
|
|
|
501
490
|
// src/info.ts
|
|
502
|
-
var
|
|
503
|
-
var
|
|
491
|
+
var import_chalk12 = __toESM(require("chalk"), 1);
|
|
492
|
+
var import_node_child_process7 = require("child_process");
|
|
504
493
|
function detectRuntime() {
|
|
505
494
|
const runtimes = [];
|
|
506
495
|
try {
|
|
507
|
-
const bunVersion = (0,
|
|
496
|
+
const bunVersion = (0, import_node_child_process7.execSync)("bun --version", { encoding: "utf-8" }).trim();
|
|
508
497
|
runtimes.push(`Bun ${bunVersion}`);
|
|
509
498
|
} catch {
|
|
510
499
|
}
|
|
@@ -512,21 +501,21 @@ function detectRuntime() {
|
|
|
512
501
|
return runtimes.join(", ");
|
|
513
502
|
}
|
|
514
503
|
function info() {
|
|
515
|
-
console.log(`Orion CLI v${version_default} \u2014 Available runtimes: ${
|
|
516
|
-
console.log(`Default runtime: ${
|
|
504
|
+
console.log(`Orion CLI v${version_default} \u2014 Available runtimes: ${import_chalk12.default.bold(detectRuntime())}`);
|
|
505
|
+
console.log(`Default runtime: ${import_chalk12.default.bold("Bun")} (use --node flag to switch to Node.js)`);
|
|
517
506
|
}
|
|
518
507
|
|
|
519
508
|
// src/repl/index.ts
|
|
520
|
-
var
|
|
521
|
-
var
|
|
522
|
-
var
|
|
509
|
+
var import_node_fs7 = require("fs");
|
|
510
|
+
var import_node_path5 = require("path");
|
|
511
|
+
var import_chalk13 = __toESM(require("chalk"), 1);
|
|
523
512
|
function resolvePort(options) {
|
|
524
513
|
if (options.port) {
|
|
525
514
|
return Number(options.port);
|
|
526
515
|
}
|
|
527
516
|
try {
|
|
528
|
-
const portFile = (0,
|
|
529
|
-
const port = (0,
|
|
517
|
+
const portFile = (0, import_node_path5.resolve)(process.cwd(), ".orion/port");
|
|
518
|
+
const port = (0, import_node_fs7.readFileSync)(portFile, "utf-8").trim();
|
|
530
519
|
return Number(port);
|
|
531
520
|
} catch {
|
|
532
521
|
}
|
|
@@ -539,7 +528,7 @@ async function repl(options) {
|
|
|
539
528
|
var _a;
|
|
540
529
|
const expression = options.expression;
|
|
541
530
|
if (!expression) {
|
|
542
|
-
console.error(
|
|
531
|
+
console.error(import_chalk13.default.red('Error: expression is required. Use -e "<expression>"'));
|
|
543
532
|
process.exit(1);
|
|
544
533
|
}
|
|
545
534
|
const port = resolvePort(options);
|
|
@@ -551,9 +540,9 @@ async function repl(options) {
|
|
|
551
540
|
});
|
|
552
541
|
const data = await response.json();
|
|
553
542
|
if (!data.success) {
|
|
554
|
-
console.error(
|
|
543
|
+
console.error(import_chalk13.default.red(`Error: ${data.error}`));
|
|
555
544
|
if (data.stack) {
|
|
556
|
-
console.error(
|
|
545
|
+
console.error(import_chalk13.default.dim(data.stack));
|
|
557
546
|
}
|
|
558
547
|
process.exit(1);
|
|
559
548
|
}
|
|
@@ -563,14 +552,15 @@ async function repl(options) {
|
|
|
563
552
|
);
|
|
564
553
|
}
|
|
565
554
|
} catch (error) {
|
|
566
|
-
|
|
555
|
+
const nodeError = error;
|
|
556
|
+
if (nodeError.code === "ECONNREFUSED" || ((_a = nodeError.cause) == null ? void 0 : _a.code) === "ECONNREFUSED") {
|
|
567
557
|
console.error(
|
|
568
|
-
|
|
558
|
+
import_chalk13.default.red(
|
|
569
559
|
`Could not connect to dev server on port ${port}. Make sure "orion dev --repl" is running.`
|
|
570
560
|
)
|
|
571
561
|
);
|
|
572
562
|
} else {
|
|
573
|
-
console.error(
|
|
563
|
+
console.error(import_chalk13.default.red(`Error: ${nodeError.message}`));
|
|
574
564
|
}
|
|
575
565
|
process.exit(1);
|
|
576
566
|
}
|
|
@@ -582,7 +572,7 @@ var run = (action) => async (...args) => {
|
|
|
582
572
|
try {
|
|
583
573
|
await action(...args);
|
|
584
574
|
} catch (e) {
|
|
585
|
-
console.error(
|
|
575
|
+
console.error(import_chalk14.default.red(`Error: ${e.message}`));
|
|
586
576
|
}
|
|
587
577
|
};
|
|
588
578
|
program.command("dev").description("Run the Orionjs app in development mode").option("--node", "Use Node.js runtime instead of Bun").option("--repl", "Enable REPL endpoint for orion repl").allowUnknownOption().action(run(dev_default));
|