@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/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.
package/dist/index.cjs CHANGED
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
8
  var __copyProps = (to, from, except, desc) => {
10
9
  if (from && typeof from === "object" || typeof from === "function") {
11
10
  for (let key of __getOwnPropNames(from))
@@ -39,12 +38,12 @@ var import_fs2 = __toESM(require("fs"), 1);
39
38
  // src/helpers/ensureDirectory.ts
40
39
  var import_fs = __toESM(require("fs"), 1);
41
40
  var import_path = __toESM(require("path"), 1);
42
- var ensureDirectory = /* @__PURE__ */ __name(function(filePath) {
41
+ var ensureDirectory = function(filePath) {
43
42
  const dirname = import_path.default.dirname(filePath);
44
43
  if (import_fs.default.existsSync(dirname)) return true;
45
44
  ensureDirectory(dirname);
46
45
  import_fs.default.mkdirSync(dirname);
47
- }, "ensureDirectory");
46
+ };
48
47
  var ensureDirectory_default = ensureDirectory;
49
48
 
50
49
  // src/helpers/writeFile.ts
@@ -52,7 +51,6 @@ async function writeFile_default(path9, content) {
52
51
  ensureDirectory_default(path9);
53
52
  import_fs2.default.writeFileSync(path9, content);
54
53
  }
55
- __name(writeFile_default, "default");
56
54
 
57
55
  // src/start/runner/startProcess.ts
58
56
  var import_child_process = require("child_process");
@@ -65,20 +63,13 @@ function getArgs(options) {
65
63
  const [first, ...otherArgs] = process.env.START_COMMAND.split(" ");
66
64
  startCommand = first;
67
65
  args.push(...otherArgs);
68
- console.log("Using custom command: " + [
69
- startCommand,
70
- ...args
71
- ].join(" "));
66
+ console.log("Using custom command: " + [startCommand, ...args].join(" "));
72
67
  } else if (options.shell) {
73
68
  args.push("--inspect");
74
69
  }
75
70
  args.push(".orion/build/index.js");
76
- return {
77
- startCommand,
78
- args
79
- };
71
+ return { startCommand, args };
80
72
  }
81
- __name(getArgs, "getArgs");
82
73
 
83
74
  // src/start/runner/startProcess.ts
84
75
  function startProcess(options) {
@@ -93,7 +84,6 @@ function startProcess(options) {
93
84
  detached: false
94
85
  });
95
86
  }
96
- __name(startProcess, "startProcess");
97
87
 
98
88
  // src/start/runner/index.ts
99
89
  function getRunner(options) {
@@ -101,7 +91,7 @@ function getRunner(options) {
101
91
  if (options.clean) {
102
92
  console.log(import_safe.default.bold("=> Cleaning directory...\n"));
103
93
  }
104
- const start = /* @__PURE__ */ __name(() => {
94
+ const start = () => {
105
95
  console.log(import_safe.default.bold("=> Starting app...\n"));
106
96
  appProcess = startProcess(options);
107
97
  appProcess.on("exit", function(code, signal) {
@@ -111,23 +101,22 @@ function getRunner(options) {
111
101
  }
112
102
  });
113
103
  writeFile_default(".orion/process", `${appProcess.pid}`);
114
- }, "start");
115
- const stop = /* @__PURE__ */ __name(() => {
104
+ };
105
+ const stop = () => {
116
106
  if (appProcess) {
117
107
  appProcess.kill();
118
108
  }
119
- }, "stop");
120
- const restart = /* @__PURE__ */ __name(() => {
109
+ };
110
+ const restart = () => {
121
111
  stop();
122
112
  start();
123
- }, "restart");
113
+ };
124
114
  return {
125
115
  restart,
126
116
  stop,
127
117
  basePath: `${process.cwd()}/.orion/build`
128
118
  };
129
119
  }
130
- __name(getRunner, "getRunner");
131
120
 
132
121
  // src/start/watchAndCompile/index.ts
133
122
  var import_typescript4 = __toESM(require("typescript"), 1);
@@ -148,7 +137,6 @@ function rimraf(dir_path) {
148
137
  import_fs3.default.rmdirSync(dir_path);
149
138
  }
150
139
  }
151
- __name(rimraf, "rimraf");
152
140
  async function cleanDirectory() {
153
141
  try {
154
142
  const path9 = `${process.cwd()}/.orion/build`;
@@ -156,7 +144,6 @@ async function cleanDirectory() {
156
144
  } catch {
157
145
  }
158
146
  }
159
- __name(cleanDirectory, "cleanDirectory");
160
147
 
161
148
  // src/start/watchAndCompile/getHost.ts
162
149
  var import_typescript3 = __toESM(require("typescript"), 1);
@@ -170,7 +157,6 @@ function readFile(filePath) {
170
157
  if (!import_fs4.default.existsSync(filePath)) return null;
171
158
  return import_fs4.default.readFileSync(filePath).toString();
172
159
  }
173
- __name(readFile, "readFile");
174
160
 
175
161
  // src/start/watchAndCompile/ensureConfigComplies.ts
176
162
  var import_comment_json = require("comment-json");
@@ -195,7 +181,6 @@ function ensureConfigComplies(configPath) {
195
181
  console.log(`Error reading tsconfig ${error.message}`);
196
182
  }
197
183
  }
198
- __name(ensureConfigComplies, "ensureConfigComplies");
199
184
 
200
185
  // src/start/watchAndCompile/getConfigPath.ts
201
186
  function getConfigPath() {
@@ -207,21 +192,17 @@ function getConfigPath() {
207
192
  ensureConfigComplies(configPath);
208
193
  return configPath;
209
194
  }
210
- __name(getConfigPath, "getConfigPath");
211
195
 
212
196
  // src/start/watchAndCompile/reports.ts
213
197
  var import_typescript2 = __toESM(require("typescript"), 1);
214
198
  var format = {
215
- getCanonicalFileName: /* @__PURE__ */ __name((fileName) => fileName, "getCanonicalFileName"),
216
- getCurrentDirectory: /* @__PURE__ */ __name(() => process.cwd(), "getCurrentDirectory"),
217
- getNewLine: /* @__PURE__ */ __name(() => import_typescript2.default.sys.newLine, "getNewLine")
199
+ getCanonicalFileName: (fileName) => fileName,
200
+ getCurrentDirectory: () => process.cwd(),
201
+ getNewLine: () => import_typescript2.default.sys.newLine
218
202
  };
219
203
  function reportDiagnostic(diagnostic) {
220
- console.log(import_typescript2.default.formatDiagnosticsWithColorAndContext([
221
- diagnostic
222
- ], format));
204
+ console.log(import_typescript2.default.formatDiagnosticsWithColorAndContext([diagnostic], format));
223
205
  }
224
- __name(reportDiagnostic, "reportDiagnostic");
225
206
 
226
207
  // src/start/watchAndCompile/getHost.ts
227
208
  var import_safe2 = __toESM(require("colors/safe"), 1);
@@ -235,24 +216,29 @@ function writeIndex_default({ basePath }) {
235
216
  const libContent = import_fs5.default.readFileSync(libContentPath).toString();
236
217
  writeFile_default(libPath, libContent);
237
218
  const aliasPath = `${basePath}/moduleAlias.js`;
238
- writeFile_default(aliasPath, `"use strict";
219
+ writeFile_default(
220
+ aliasPath,
221
+ `"use strict";
239
222
  Object.defineProperty(exports, "__esModule", { value: true });
240
223
  const moduleAlias = require('./moduleAliasLib')
241
224
  const path = __dirname + '/app'
242
225
  moduleAlias.addAlias('app', path)
243
- `);
226
+ `
227
+ );
244
228
  const indexPath = `${basePath}/index.js`;
245
- writeFile_default(indexPath, `"use strict";
229
+ writeFile_default(
230
+ indexPath,
231
+ `"use strict";
246
232
  Object.defineProperty(exports, "__esModule", { value: true });
247
233
  require("./moduleAlias");
248
234
  require("./app");
249
- `);
235
+ `
236
+ );
250
237
  }
251
- __name(writeIndex_default, "default");
252
238
 
253
239
  // src/start/watchAndCompile/getHost.ts
254
240
  function getHost(runner) {
255
- const reportWatchStatusChanged = /* @__PURE__ */ __name((diagnostic) => {
241
+ const reportWatchStatusChanged = (diagnostic) => {
256
242
  if (diagnostic.category !== 3) return;
257
243
  if (diagnostic.code === 6032 || diagnostic.code === 6031) {
258
244
  runner.stop();
@@ -264,18 +250,22 @@ function getHost(runner) {
264
250
  return;
265
251
  }
266
252
  }
267
- writeIndex_default({
268
- basePath: runner.basePath
269
- });
253
+ writeIndex_default({ basePath: runner.basePath });
270
254
  runner.restart();
271
255
  }
272
- }, "reportWatchStatusChanged");
256
+ };
273
257
  const configPath = getConfigPath();
274
258
  const createProgram = import_typescript3.default.createEmitAndSemanticDiagnosticsBuilderProgram;
275
- const host = import_typescript3.default.createWatchCompilerHost(configPath, {}, import_typescript3.default.sys, createProgram, reportDiagnostic, reportWatchStatusChanged);
259
+ const host = import_typescript3.default.createWatchCompilerHost(
260
+ configPath,
261
+ {},
262
+ import_typescript3.default.sys,
263
+ createProgram,
264
+ reportDiagnostic,
265
+ reportWatchStatusChanged
266
+ );
276
267
  return host;
277
268
  }
278
- __name(getHost, "getHost");
279
269
 
280
270
  // src/start/watchAndCompile/watchDeletes.ts
281
271
  var import_chokidar = __toESM(require("chokidar"), 1);
@@ -294,11 +284,12 @@ async function watchDeletes() {
294
284
  import_fs6.default.unlinkSync(`${atBuildPath}.js`);
295
285
  import_fs6.default.unlinkSync(`${atBuildPath}.d.ts`);
296
286
  } catch (error) {
297
- console.log(`Error cleaning ${atBuildPath}. Restar project is suggested. Error: ${error.message}`);
287
+ console.log(
288
+ `Error cleaning ${atBuildPath}. Restar project is suggested. Error: ${error.message}`
289
+ );
298
290
  }
299
291
  });
300
292
  }
301
- __name(watchDeletes, "watchDeletes");
302
293
 
303
294
  // src/start/watchAndCompile/writeEnvFile.ts
304
295
  var import_chokidar2 = __toESM(require("chokidar"), 1);
@@ -306,17 +297,15 @@ var import_safe3 = __toESM(require("colors/safe"), 1);
306
297
  var import_env = require("@orion-js/env");
307
298
  var envFilePath = process.env.ORION_ENV_FILE_PATH;
308
299
  var dtsFilePath = "./app/env.d.ts";
309
- var watchEnvFile = /* @__PURE__ */ __name(async (runner) => {
300
+ var watchEnvFile = async (runner) => {
310
301
  if (!envFilePath) return;
311
302
  (0, import_env.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
312
- import_chokidar2.default.watch(envFilePath, {
313
- ignoreInitial: true
314
- }).on("change", async () => {
303
+ import_chokidar2.default.watch(envFilePath, { ignoreInitial: true }).on("change", async () => {
315
304
  console.log(import_safe3.default.bold(`=> Environment file changed. Restarting...`));
316
305
  (0, import_env.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
317
306
  runner.restart();
318
307
  });
319
- }, "watchEnvFile");
308
+ };
320
309
 
321
310
  // src/start/watchAndCompile/index.ts
322
311
  async function watchAndCompile(runner) {
@@ -326,7 +315,6 @@ async function watchAndCompile(runner) {
326
315
  watchDeletes();
327
316
  watchEnvFile(runner);
328
317
  }
329
- __name(watchAndCompile, "watchAndCompile");
330
318
 
331
319
  // src/start/copyCursorRule/index.ts
332
320
  var import_path5 = __toESM(require("path"), 1);
@@ -341,7 +329,7 @@ var rules = [
341
329
  "orionjs-services.mdx",
342
330
  "orionjs-resolvers.mdx"
343
331
  ];
344
- var downloadFile = /* @__PURE__ */ __name((url) => {
332
+ var downloadFile = (url) => {
345
333
  return new Promise((resolve, reject) => {
346
334
  import_https.default.get(url, (response) => {
347
335
  if (response.statusCode !== 200) {
@@ -360,14 +348,12 @@ var downloadFile = /* @__PURE__ */ __name((url) => {
360
348
  });
361
349
  });
362
350
  });
363
- }, "downloadFile");
351
+ };
364
352
  async function copyCursorRule() {
365
353
  const baseUrl = `https://raw.githubusercontent.com/orionjs/orionjs/refs/heads/master/mdc`;
366
354
  try {
367
355
  const targetDir = import_path5.default.join(process.cwd(), ".cursor", "rules");
368
- await import_promises.default.mkdir(targetDir, {
369
- recursive: true
370
- });
356
+ await import_promises.default.mkdir(targetDir, { recursive: true });
371
357
  for (const rule of rules) {
372
358
  const targetFileName = rule.replace(".mdx", ".mdc");
373
359
  const targetFile = import_path5.default.join(targetDir, targetFileName);
@@ -381,7 +367,6 @@ async function copyCursorRule() {
381
367
  console.error(import_safe4.default.red(`Error copying rule files: ${error.message}`));
382
368
  }
383
369
  }
384
- __name(copyCursorRule, "copyCursorRule");
385
370
 
386
371
  // src/start/copyMCP/index.ts
387
372
  var import_path7 = __toESM(require("path"), 1);
@@ -395,15 +380,11 @@ async function execute_default(command) {
395
380
  if (error) {
396
381
  reject(error);
397
382
  } else {
398
- resolve({
399
- stdout,
400
- stderr
401
- });
383
+ resolve({ stdout, stderr });
402
384
  }
403
385
  });
404
386
  });
405
387
  }
406
- __name(execute_default, "default");
407
388
 
408
389
  // src/start/copyMCP/index.ts
409
390
  var import_safe6 = __toESM(require("colors/safe"), 1);
@@ -422,10 +403,7 @@ async function isValidMCPRepository(directoryPath) {
422
403
  try {
423
404
  const stats = await import_promises2.default.stat(directoryPath);
424
405
  if (!stats.isDirectory()) return false;
425
- const expectedFiles = [
426
- "settings.js",
427
- "package.json"
428
- ];
406
+ const expectedFiles = ["settings.js", "package.json"];
429
407
  for (const file of expectedFiles) {
430
408
  try {
431
409
  await import_promises2.default.access(import_path6.default.join(directoryPath, file));
@@ -448,16 +426,13 @@ async function isValidMCPRepository(directoryPath) {
448
426
  return false;
449
427
  }
450
428
  }
451
- __name(isValidMCPRepository, "isValidMCPRepository");
452
429
 
453
430
  // src/start/copyMCP/index.ts
454
431
  async function copyMCP() {
455
432
  const repoUrl = "https://github.com/orionjs/mcp-docs";
456
433
  const targetDir = import_path7.default.join(process.cwd(), ".orion", "mcp");
457
434
  try {
458
- await import_promises3.default.mkdir(import_path7.default.join(process.cwd(), ".orion"), {
459
- recursive: true
460
- });
435
+ await import_promises3.default.mkdir(import_path7.default.join(process.cwd(), ".orion"), { recursive: true });
461
436
  if (await isValidMCPRepository(targetDir)) {
462
437
  console.log(import_safe6.default.bold(`=> \u2728 MCP documentation already installed`));
463
438
  return;
@@ -465,10 +440,7 @@ async function copyMCP() {
465
440
  try {
466
441
  const stats = await import_promises3.default.stat(targetDir);
467
442
  if (stats.isDirectory()) {
468
- await import_promises3.default.rm(targetDir, {
469
- recursive: true,
470
- force: true
471
- });
443
+ await import_promises3.default.rm(targetDir, { recursive: true, force: true });
472
444
  console.log(import_safe6.default.bold(`=> \u2728 Removed existing .orion/mcp directory (invalid, incomplete, or outdated)`));
473
445
  }
474
446
  } catch (error) {
@@ -502,9 +474,7 @@ async function copyMCP() {
502
474
  await import_promises3.default.writeFile(configPath, JSON.stringify(parsedConfig, null, 2), "utf-8");
503
475
  console.log(import_safe6.default.bold(`=> \u2728 Updated MCP server configuration in .cursor/mcp.json`));
504
476
  } catch (error) {
505
- await import_promises3.default.mkdir(import_path7.default.dirname(configPath), {
506
- recursive: true
507
- });
477
+ await import_promises3.default.mkdir(import_path7.default.dirname(configPath), { recursive: true });
508
478
  await import_promises3.default.writeFile(configPath, JSON.stringify(mcpServerConfig, null, 2), "utf-8");
509
479
  console.log(import_safe6.default.bold(`=> \u2728 Created new MCP server configuration in .cursor/mcp.json`));
510
480
  }
@@ -513,7 +483,6 @@ async function copyMCP() {
513
483
  throw error;
514
484
  }
515
485
  }
516
- __name(copyMCP, "copyMCP");
517
486
 
518
487
  // src/start/index.ts
519
488
  async function start_default(options) {
@@ -531,7 +500,6 @@ async function start_default(options) {
531
500
  const runner = getRunner(options);
532
501
  watchAndCompile(runner);
533
502
  }
534
- __name(start_default, "default");
535
503
 
536
504
  // src/build/index.ts
537
505
  var import_safe9 = __toESM(require("colors/safe"), 1);
@@ -554,7 +522,6 @@ function getCompilerOptionsJSONFollowExtends(filename) {
554
522
  ...config.compilerOptions
555
523
  };
556
524
  }
557
- __name(getCompilerOptionsJSONFollowExtends, "getCompilerOptionsJSONFollowExtends");
558
525
  function getOptions({ output }) {
559
526
  const configPath = getConfigPath();
560
527
  const config = getCompilerOptionsJSONFollowExtends(configPath);
@@ -567,17 +534,12 @@ function getOptions({ output }) {
567
534
  }
568
535
  return options;
569
536
  }
570
- __name(getOptions, "getOptions");
571
537
 
572
538
  // src/build/compile.ts
573
539
  var import_safe8 = __toESM(require("colors/safe"), 1);
574
540
  function compile({ output }) {
575
- const options = getOptions({
576
- output
577
- });
578
- const program2 = import_typescript6.default.createProgram([
579
- "./app/index.ts"
580
- ], options);
541
+ const options = getOptions({ output });
542
+ const program2 = import_typescript6.default.createProgram(["./app/index.ts"], options);
581
543
  const preEmitDiagnostics = import_typescript6.default.getPreEmitDiagnostics(program2);
582
544
  if (preEmitDiagnostics.length > 0) {
583
545
  console.log(import_safe8.default.red(`
@@ -594,7 +556,6 @@ function compile({ output }) {
594
556
  process.exit(1);
595
557
  }
596
558
  }
597
- __name(compile, "compile");
598
559
 
599
560
  // src/build/index.ts
600
561
  async function build_default({ output }) {
@@ -604,15 +565,10 @@ async function build_default({ output }) {
604
565
  console.log(import_safe9.default.bold(`Cleaning directory ${output}...`));
605
566
  await execute_default(`rm -rf ${output}`);
606
567
  console.log(import_safe9.default.bold("Compiling your app..."));
607
- compile({
608
- output
609
- });
610
- writeIndex_default({
611
- basePath: output
612
- });
568
+ compile({ output });
569
+ writeIndex_default({ basePath: output });
613
570
  console.log(import_safe9.default.bold("Build created"));
614
571
  }
615
- __name(build_default, "default");
616
572
 
617
573
  // src/create/index.ts
618
574
  async function create_default({ name, kit }) {
@@ -628,7 +584,6 @@ async function create_default({ name, kit }) {
628
584
  await execute_default(`cd ${name} && rm -rf .git`);
629
585
  console.log("Your starter kit is ready");
630
586
  }
631
- __name(create_default, "default");
632
587
 
633
588
  // src/index.ts
634
589
  var import_safe11 = __toESM(require("colors/safe"), 1);
@@ -640,7 +595,6 @@ function test_default() {
640
595
  console.log(import_safe10.default.bold(`ORION_DEV=LOCAL ORION_TEST=1 jest`));
641
596
  process.exit(1);
642
597
  }
643
- __name(test_default, "default");
644
598
 
645
599
  // src/handleErrors.ts
646
600
  var import_colors = __toESM(require("colors"), 1);
@@ -662,7 +616,7 @@ var version_default = `3.0`;
662
616
  // src/index.ts
663
617
  var import_config = require("dotenv/config");
664
618
  var program = new import_commander.Command();
665
- var run = /* @__PURE__ */ __name(function(action) {
619
+ var run = function(action) {
666
620
  return async function(...args) {
667
621
  try {
668
622
  await action(...args);
@@ -670,7 +624,7 @@ var run = /* @__PURE__ */ __name(function(action) {
670
624
  console.error(import_safe11.default.red("Error: " + e.message));
671
625
  }
672
626
  };
673
- }, "run");
627
+ };
674
628
  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));
675
629
  program.command("test").allowUnknownOption().description("Deprecated command").action(run(test_default));
676
630
  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));