@orion-js/core 4.0.0-next.2 → 4.0.0-next.3

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/index.js CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env node
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
2
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
3
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
4
  }) : x)(function(x) {
@@ -24,12 +22,12 @@ import fs2 from "fs";
24
22
  // src/helpers/ensureDirectory.ts
25
23
  import fs from "fs";
26
24
  import path from "path";
27
- var ensureDirectory = /* @__PURE__ */ __name(function(filePath) {
25
+ var ensureDirectory = function(filePath) {
28
26
  const dirname = path.dirname(filePath);
29
27
  if (fs.existsSync(dirname)) return true;
30
28
  ensureDirectory(dirname);
31
29
  fs.mkdirSync(dirname);
32
- }, "ensureDirectory");
30
+ };
33
31
  var ensureDirectory_default = ensureDirectory;
34
32
 
35
33
  // src/helpers/writeFile.ts
@@ -37,7 +35,6 @@ async function writeFile_default(path9, content) {
37
35
  ensureDirectory_default(path9);
38
36
  fs2.writeFileSync(path9, content);
39
37
  }
40
- __name(writeFile_default, "default");
41
38
 
42
39
  // src/start/runner/startProcess.ts
43
40
  import { spawn } from "child_process";
@@ -50,20 +47,13 @@ function getArgs(options) {
50
47
  const [first, ...otherArgs] = process.env.START_COMMAND.split(" ");
51
48
  startCommand = first;
52
49
  args.push(...otherArgs);
53
- console.log("Using custom command: " + [
54
- startCommand,
55
- ...args
56
- ].join(" "));
50
+ console.log("Using custom command: " + [startCommand, ...args].join(" "));
57
51
  } else if (options.shell) {
58
52
  args.push("--inspect");
59
53
  }
60
54
  args.push(".orion/build/index.js");
61
- return {
62
- startCommand,
63
- args
64
- };
55
+ return { startCommand, args };
65
56
  }
66
- __name(getArgs, "getArgs");
67
57
 
68
58
  // src/start/runner/startProcess.ts
69
59
  function startProcess(options) {
@@ -78,7 +68,6 @@ function startProcess(options) {
78
68
  detached: false
79
69
  });
80
70
  }
81
- __name(startProcess, "startProcess");
82
71
 
83
72
  // src/start/runner/index.ts
84
73
  function getRunner(options) {
@@ -86,7 +75,7 @@ function getRunner(options) {
86
75
  if (options.clean) {
87
76
  console.log(colors.bold("=> Cleaning directory...\n"));
88
77
  }
89
- const start = /* @__PURE__ */ __name(() => {
78
+ const start = () => {
90
79
  console.log(colors.bold("=> Starting app...\n"));
91
80
  appProcess = startProcess(options);
92
81
  appProcess.on("exit", function(code, signal) {
@@ -96,23 +85,22 @@ function getRunner(options) {
96
85
  }
97
86
  });
98
87
  writeFile_default(".orion/process", `${appProcess.pid}`);
99
- }, "start");
100
- const stop = /* @__PURE__ */ __name(() => {
88
+ };
89
+ const stop = () => {
101
90
  if (appProcess) {
102
91
  appProcess.kill();
103
92
  }
104
- }, "stop");
105
- const restart = /* @__PURE__ */ __name(() => {
93
+ };
94
+ const restart = () => {
106
95
  stop();
107
96
  start();
108
- }, "restart");
97
+ };
109
98
  return {
110
99
  restart,
111
100
  stop,
112
101
  basePath: `${process.cwd()}/.orion/build`
113
102
  };
114
103
  }
115
- __name(getRunner, "getRunner");
116
104
 
117
105
  // src/start/watchAndCompile/index.ts
118
106
  import ts4 from "typescript";
@@ -133,7 +121,6 @@ function rimraf(dir_path) {
133
121
  fs3.rmdirSync(dir_path);
134
122
  }
135
123
  }
136
- __name(rimraf, "rimraf");
137
124
  async function cleanDirectory() {
138
125
  try {
139
126
  const path9 = `${process.cwd()}/.orion/build`;
@@ -141,7 +128,6 @@ async function cleanDirectory() {
141
128
  } catch {
142
129
  }
143
130
  }
144
- __name(cleanDirectory, "cleanDirectory");
145
131
 
146
132
  // src/start/watchAndCompile/getHost.ts
147
133
  import ts3 from "typescript";
@@ -155,7 +141,6 @@ function readFile(filePath) {
155
141
  if (!fs4.existsSync(filePath)) return null;
156
142
  return fs4.readFileSync(filePath).toString();
157
143
  }
158
- __name(readFile, "readFile");
159
144
 
160
145
  // src/start/watchAndCompile/ensureConfigComplies.ts
161
146
  import { parse, stringify } from "comment-json";
@@ -180,7 +165,6 @@ function ensureConfigComplies(configPath) {
180
165
  console.log(`Error reading tsconfig ${error.message}`);
181
166
  }
182
167
  }
183
- __name(ensureConfigComplies, "ensureConfigComplies");
184
168
 
185
169
  // src/start/watchAndCompile/getConfigPath.ts
186
170
  function getConfigPath() {
@@ -192,21 +176,17 @@ function getConfigPath() {
192
176
  ensureConfigComplies(configPath);
193
177
  return configPath;
194
178
  }
195
- __name(getConfigPath, "getConfigPath");
196
179
 
197
180
  // src/start/watchAndCompile/reports.ts
198
181
  import ts2 from "typescript";
199
182
  var format = {
200
- getCanonicalFileName: /* @__PURE__ */ __name((fileName) => fileName, "getCanonicalFileName"),
201
- getCurrentDirectory: /* @__PURE__ */ __name(() => process.cwd(), "getCurrentDirectory"),
202
- getNewLine: /* @__PURE__ */ __name(() => ts2.sys.newLine, "getNewLine")
183
+ getCanonicalFileName: (fileName) => fileName,
184
+ getCurrentDirectory: () => process.cwd(),
185
+ getNewLine: () => ts2.sys.newLine
203
186
  };
204
187
  function reportDiagnostic(diagnostic) {
205
- console.log(ts2.formatDiagnosticsWithColorAndContext([
206
- diagnostic
207
- ], format));
188
+ console.log(ts2.formatDiagnosticsWithColorAndContext([diagnostic], format));
208
189
  }
209
- __name(reportDiagnostic, "reportDiagnostic");
210
190
 
211
191
  // src/start/watchAndCompile/getHost.ts
212
192
  import colors2 from "colors/safe";
@@ -220,24 +200,29 @@ function writeIndex_default({ basePath }) {
220
200
  const libContent = fs5.readFileSync(libContentPath).toString();
221
201
  writeFile_default(libPath, libContent);
222
202
  const aliasPath = `${basePath}/moduleAlias.js`;
223
- writeFile_default(aliasPath, `"use strict";
203
+ writeFile_default(
204
+ aliasPath,
205
+ `"use strict";
224
206
  Object.defineProperty(exports, "__esModule", { value: true });
225
207
  const moduleAlias = require('./moduleAliasLib')
226
208
  const path = __dirname + '/app'
227
209
  moduleAlias.addAlias('app', path)
228
- `);
210
+ `
211
+ );
229
212
  const indexPath = `${basePath}/index.js`;
230
- writeFile_default(indexPath, `"use strict";
213
+ writeFile_default(
214
+ indexPath,
215
+ `"use strict";
231
216
  Object.defineProperty(exports, "__esModule", { value: true });
232
217
  require("./moduleAlias");
233
218
  require("./app");
234
- `);
219
+ `
220
+ );
235
221
  }
236
- __name(writeIndex_default, "default");
237
222
 
238
223
  // src/start/watchAndCompile/getHost.ts
239
224
  function getHost(runner) {
240
- const reportWatchStatusChanged = /* @__PURE__ */ __name((diagnostic) => {
225
+ const reportWatchStatusChanged = (diagnostic) => {
241
226
  if (diagnostic.category !== 3) return;
242
227
  if (diagnostic.code === 6032 || diagnostic.code === 6031) {
243
228
  runner.stop();
@@ -249,18 +234,22 @@ function getHost(runner) {
249
234
  return;
250
235
  }
251
236
  }
252
- writeIndex_default({
253
- basePath: runner.basePath
254
- });
237
+ writeIndex_default({ basePath: runner.basePath });
255
238
  runner.restart();
256
239
  }
257
- }, "reportWatchStatusChanged");
240
+ };
258
241
  const configPath = getConfigPath();
259
242
  const createProgram = ts3.createEmitAndSemanticDiagnosticsBuilderProgram;
260
- const host = ts3.createWatchCompilerHost(configPath, {}, ts3.sys, createProgram, reportDiagnostic, reportWatchStatusChanged);
243
+ const host = ts3.createWatchCompilerHost(
244
+ configPath,
245
+ {},
246
+ ts3.sys,
247
+ createProgram,
248
+ reportDiagnostic,
249
+ reportWatchStatusChanged
250
+ );
261
251
  return host;
262
252
  }
263
- __name(getHost, "getHost");
264
253
 
265
254
  // src/start/watchAndCompile/watchDeletes.ts
266
255
  import chokidar from "chokidar";
@@ -279,11 +268,12 @@ async function watchDeletes() {
279
268
  fs6.unlinkSync(`${atBuildPath}.js`);
280
269
  fs6.unlinkSync(`${atBuildPath}.d.ts`);
281
270
  } catch (error) {
282
- console.log(`Error cleaning ${atBuildPath}. Restar project is suggested. Error: ${error.message}`);
271
+ console.log(
272
+ `Error cleaning ${atBuildPath}. Restar project is suggested. Error: ${error.message}`
273
+ );
283
274
  }
284
275
  });
285
276
  }
286
- __name(watchDeletes, "watchDeletes");
287
277
 
288
278
  // src/start/watchAndCompile/writeEnvFile.ts
289
279
  import chokidar2 from "chokidar";
@@ -291,17 +281,15 @@ import colors3 from "colors/safe";
291
281
  import { writeDtsFileFromConfigFile } from "@orion-js/env";
292
282
  var envFilePath = process.env.ORION_ENV_FILE_PATH;
293
283
  var dtsFilePath = "./app/env.d.ts";
294
- var watchEnvFile = /* @__PURE__ */ __name(async (runner) => {
284
+ var watchEnvFile = async (runner) => {
295
285
  if (!envFilePath) return;
296
286
  writeDtsFileFromConfigFile(envFilePath, dtsFilePath);
297
- chokidar2.watch(envFilePath, {
298
- ignoreInitial: true
299
- }).on("change", async () => {
287
+ chokidar2.watch(envFilePath, { ignoreInitial: true }).on("change", async () => {
300
288
  console.log(colors3.bold(`=> Environment file changed. Restarting...`));
301
289
  writeDtsFileFromConfigFile(envFilePath, dtsFilePath);
302
290
  runner.restart();
303
291
  });
304
- }, "watchEnvFile");
292
+ };
305
293
 
306
294
  // src/start/watchAndCompile/index.ts
307
295
  async function watchAndCompile(runner) {
@@ -311,7 +299,6 @@ async function watchAndCompile(runner) {
311
299
  watchDeletes();
312
300
  watchEnvFile(runner);
313
301
  }
314
- __name(watchAndCompile, "watchAndCompile");
315
302
 
316
303
  // src/start/copyCursorRule/index.ts
317
304
  import path5 from "path";
@@ -326,7 +313,7 @@ var rules = [
326
313
  "orionjs-services.mdx",
327
314
  "orionjs-resolvers.mdx"
328
315
  ];
329
- var downloadFile = /* @__PURE__ */ __name((url) => {
316
+ var downloadFile = (url) => {
330
317
  return new Promise((resolve, reject) => {
331
318
  https.get(url, (response) => {
332
319
  if (response.statusCode !== 200) {
@@ -345,14 +332,12 @@ var downloadFile = /* @__PURE__ */ __name((url) => {
345
332
  });
346
333
  });
347
334
  });
348
- }, "downloadFile");
335
+ };
349
336
  async function copyCursorRule() {
350
337
  const baseUrl = `https://raw.githubusercontent.com/orionjs/orionjs/refs/heads/master/mdc`;
351
338
  try {
352
339
  const targetDir = path5.join(process.cwd(), ".cursor", "rules");
353
- await fs7.mkdir(targetDir, {
354
- recursive: true
355
- });
340
+ await fs7.mkdir(targetDir, { recursive: true });
356
341
  for (const rule of rules) {
357
342
  const targetFileName = rule.replace(".mdx", ".mdc");
358
343
  const targetFile = path5.join(targetDir, targetFileName);
@@ -366,7 +351,6 @@ async function copyCursorRule() {
366
351
  console.error(colors4.red(`Error copying rule files: ${error.message}`));
367
352
  }
368
353
  }
369
- __name(copyCursorRule, "copyCursorRule");
370
354
 
371
355
  // src/start/copyMCP/index.ts
372
356
  import path7 from "path";
@@ -380,15 +364,11 @@ async function execute_default(command) {
380
364
  if (error) {
381
365
  reject(error);
382
366
  } else {
383
- resolve({
384
- stdout,
385
- stderr
386
- });
367
+ resolve({ stdout, stderr });
387
368
  }
388
369
  });
389
370
  });
390
371
  }
391
- __name(execute_default, "default");
392
372
 
393
373
  // src/start/copyMCP/index.ts
394
374
  import colors6 from "colors/safe";
@@ -407,10 +387,7 @@ async function isValidMCPRepository(directoryPath) {
407
387
  try {
408
388
  const stats = await fs8.stat(directoryPath);
409
389
  if (!stats.isDirectory()) return false;
410
- const expectedFiles = [
411
- "settings.js",
412
- "package.json"
413
- ];
390
+ const expectedFiles = ["settings.js", "package.json"];
414
391
  for (const file of expectedFiles) {
415
392
  try {
416
393
  await fs8.access(path6.join(directoryPath, file));
@@ -433,16 +410,13 @@ async function isValidMCPRepository(directoryPath) {
433
410
  return false;
434
411
  }
435
412
  }
436
- __name(isValidMCPRepository, "isValidMCPRepository");
437
413
 
438
414
  // src/start/copyMCP/index.ts
439
415
  async function copyMCP() {
440
416
  const repoUrl = "https://github.com/orionjs/mcp-docs";
441
417
  const targetDir = path7.join(process.cwd(), ".orion", "mcp");
442
418
  try {
443
- await fs9.mkdir(path7.join(process.cwd(), ".orion"), {
444
- recursive: true
445
- });
419
+ await fs9.mkdir(path7.join(process.cwd(), ".orion"), { recursive: true });
446
420
  if (await isValidMCPRepository(targetDir)) {
447
421
  console.log(colors6.bold(`=> \u2728 MCP documentation already installed`));
448
422
  return;
@@ -450,10 +424,7 @@ async function copyMCP() {
450
424
  try {
451
425
  const stats = await fs9.stat(targetDir);
452
426
  if (stats.isDirectory()) {
453
- await fs9.rm(targetDir, {
454
- recursive: true,
455
- force: true
456
- });
427
+ await fs9.rm(targetDir, { recursive: true, force: true });
457
428
  console.log(colors6.bold(`=> \u2728 Removed existing .orion/mcp directory (invalid, incomplete, or outdated)`));
458
429
  }
459
430
  } catch (error) {
@@ -487,9 +458,7 @@ async function copyMCP() {
487
458
  await fs9.writeFile(configPath, JSON.stringify(parsedConfig, null, 2), "utf-8");
488
459
  console.log(colors6.bold(`=> \u2728 Updated MCP server configuration in .cursor/mcp.json`));
489
460
  } catch (error) {
490
- await fs9.mkdir(path7.dirname(configPath), {
491
- recursive: true
492
- });
461
+ await fs9.mkdir(path7.dirname(configPath), { recursive: true });
493
462
  await fs9.writeFile(configPath, JSON.stringify(mcpServerConfig, null, 2), "utf-8");
494
463
  console.log(colors6.bold(`=> \u2728 Created new MCP server configuration in .cursor/mcp.json`));
495
464
  }
@@ -498,7 +467,6 @@ async function copyMCP() {
498
467
  throw error;
499
468
  }
500
469
  }
501
- __name(copyMCP, "copyMCP");
502
470
 
503
471
  // src/start/index.ts
504
472
  async function start_default(options) {
@@ -516,7 +484,6 @@ async function start_default(options) {
516
484
  const runner = getRunner(options);
517
485
  watchAndCompile(runner);
518
486
  }
519
- __name(start_default, "default");
520
487
 
521
488
  // src/build/index.ts
522
489
  import colors9 from "colors/safe";
@@ -539,7 +506,6 @@ function getCompilerOptionsJSONFollowExtends(filename) {
539
506
  ...config.compilerOptions
540
507
  };
541
508
  }
542
- __name(getCompilerOptionsJSONFollowExtends, "getCompilerOptionsJSONFollowExtends");
543
509
  function getOptions({ output }) {
544
510
  const configPath = getConfigPath();
545
511
  const config = getCompilerOptionsJSONFollowExtends(configPath);
@@ -552,17 +518,12 @@ function getOptions({ output }) {
552
518
  }
553
519
  return options;
554
520
  }
555
- __name(getOptions, "getOptions");
556
521
 
557
522
  // src/build/compile.ts
558
523
  import colors8 from "colors/safe";
559
524
  function compile({ output }) {
560
- const options = getOptions({
561
- output
562
- });
563
- const program2 = ts6.createProgram([
564
- "./app/index.ts"
565
- ], options);
525
+ const options = getOptions({ output });
526
+ const program2 = ts6.createProgram(["./app/index.ts"], options);
566
527
  const preEmitDiagnostics = ts6.getPreEmitDiagnostics(program2);
567
528
  if (preEmitDiagnostics.length > 0) {
568
529
  console.log(colors8.red(`
@@ -579,7 +540,6 @@ function compile({ output }) {
579
540
  process.exit(1);
580
541
  }
581
542
  }
582
- __name(compile, "compile");
583
543
 
584
544
  // src/build/index.ts
585
545
  async function build_default({ output }) {
@@ -589,15 +549,10 @@ async function build_default({ output }) {
589
549
  console.log(colors9.bold(`Cleaning directory ${output}...`));
590
550
  await execute_default(`rm -rf ${output}`);
591
551
  console.log(colors9.bold("Compiling your app..."));
592
- compile({
593
- output
594
- });
595
- writeIndex_default({
596
- basePath: output
597
- });
552
+ compile({ output });
553
+ writeIndex_default({ basePath: output });
598
554
  console.log(colors9.bold("Build created"));
599
555
  }
600
- __name(build_default, "default");
601
556
 
602
557
  // src/create/index.ts
603
558
  async function create_default({ name, kit }) {
@@ -613,7 +568,6 @@ async function create_default({ name, kit }) {
613
568
  await execute_default(`cd ${name} && rm -rf .git`);
614
569
  console.log("Your starter kit is ready");
615
570
  }
616
- __name(create_default, "default");
617
571
 
618
572
  // src/index.ts
619
573
  import colors12 from "colors/safe";
@@ -625,7 +579,6 @@ function test_default() {
625
579
  console.log(colors10.bold(`ORION_DEV=LOCAL ORION_TEST=1 jest`));
626
580
  process.exit(1);
627
581
  }
628
- __name(test_default, "default");
629
582
 
630
583
  // src/handleErrors.ts
631
584
  import colors11 from "colors";
@@ -647,7 +600,7 @@ var version_default = `3.0`;
647
600
  // src/index.ts
648
601
  import "dotenv/config";
649
602
  var program = new Command();
650
- var run = /* @__PURE__ */ __name(function(action) {
603
+ var run = function(action) {
651
604
  return async function(...args) {
652
605
  try {
653
606
  await action(...args);
@@ -655,7 +608,7 @@ var run = /* @__PURE__ */ __name(function(action) {
655
608
  console.error(colors12.red("Error: " + e.message));
656
609
  }
657
610
  };
658
- }, "run");
611
+ };
659
612
  program.command("start").description("Run the Orionjs app").option("--shell", "Opens a shell in Chrome developer tools").option("--clean", "Build the typescript project from scratch").option("--omit-cursor-rule", "Omit the creation of the Orionjs Cursor rule").option("--omit-mcp-server", "Omit the creation of the Orionjs MCP server").action(run(start_default));
660
613
  program.command("test").allowUnknownOption().description("Deprecated command").action(run(test_default));
661
614
  program.command("build").description("Compiles an Orionjs app and exports it to a simple nodejs app").option("-o, --output [output]", "Output directory").action(run(build_default));