@orion-js/core 4.0.0-next.3 → 4.0.0-next.5
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.cjs +325 -384
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +333 -392
- package/dist/index.js.map +1 -1
- package/package.json +6 -10
package/dist/index.cjs
CHANGED
|
@@ -23,143 +23,68 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
|
|
25
25
|
// src/index.ts
|
|
26
|
-
var
|
|
26
|
+
var import_chalk11 = __toESM(require("chalk"), 1);
|
|
27
27
|
var import_commander = require("commander");
|
|
28
28
|
|
|
29
|
-
// src/
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
// src/start/runner/index.ts
|
|
33
|
-
var import_safe = __toESM(require("colors/safe"), 1);
|
|
34
|
-
|
|
35
|
-
// src/helpers/writeFile.ts
|
|
36
|
-
var import_fs2 = __toESM(require("fs"), 1);
|
|
37
|
-
|
|
38
|
-
// src/helpers/ensureDirectory.ts
|
|
39
|
-
var import_fs = __toESM(require("fs"), 1);
|
|
40
|
-
var import_path = __toESM(require("path"), 1);
|
|
41
|
-
var ensureDirectory = function(filePath) {
|
|
42
|
-
const dirname = import_path.default.dirname(filePath);
|
|
43
|
-
if (import_fs.default.existsSync(dirname)) return true;
|
|
44
|
-
ensureDirectory(dirname);
|
|
45
|
-
import_fs.default.mkdirSync(dirname);
|
|
46
|
-
};
|
|
47
|
-
var ensureDirectory_default = ensureDirectory;
|
|
48
|
-
|
|
49
|
-
// src/helpers/writeFile.ts
|
|
50
|
-
async function writeFile_default(path9, content) {
|
|
51
|
-
ensureDirectory_default(path9);
|
|
52
|
-
import_fs2.default.writeFileSync(path9, content);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// src/start/runner/startProcess.ts
|
|
56
|
-
var import_child_process = require("child_process");
|
|
57
|
-
|
|
58
|
-
// src/start/runner/getArgs.ts
|
|
59
|
-
function getArgs(options) {
|
|
60
|
-
let startCommand = process.env.START_COMMAND || "node";
|
|
61
|
-
const args = [];
|
|
62
|
-
if (process.env.START_COMMAND) {
|
|
63
|
-
const [first, ...otherArgs] = process.env.START_COMMAND.split(" ");
|
|
64
|
-
startCommand = first;
|
|
65
|
-
args.push(...otherArgs);
|
|
66
|
-
console.log("Using custom command: " + [startCommand, ...args].join(" "));
|
|
67
|
-
} else if (options.shell) {
|
|
68
|
-
args.push("--inspect");
|
|
69
|
-
}
|
|
70
|
-
args.push(".orion/build/index.js");
|
|
71
|
-
return { startCommand, args };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/start/runner/startProcess.ts
|
|
75
|
-
function startProcess(options) {
|
|
76
|
-
const { startCommand, args } = getArgs(options);
|
|
77
|
-
return (0, import_child_process.spawn)(startCommand, args, {
|
|
78
|
-
env: {
|
|
79
|
-
ORION_DEV: "local",
|
|
80
|
-
...process.env
|
|
81
|
-
},
|
|
82
|
-
cwd: process.cwd(),
|
|
83
|
-
stdio: "inherit",
|
|
84
|
-
detached: false
|
|
85
|
-
});
|
|
86
|
-
}
|
|
29
|
+
// src/build/index.ts
|
|
30
|
+
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
87
31
|
|
|
88
|
-
// src/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
console.log(import_safe.default.bold("=> Starting app...\n"));
|
|
96
|
-
appProcess = startProcess(options);
|
|
97
|
-
appProcess.on("exit", function(code, signal) {
|
|
98
|
-
if (!code || code === 143 || code === 0 || signal === "SIGTERM" || signal === "SIGINT") {
|
|
32
|
+
// src/helpers/execute.ts
|
|
33
|
+
var import_node_child_process = require("child_process");
|
|
34
|
+
async function execute_default(command) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
(0, import_node_child_process.exec)(command, (error, stdout, stderr) => {
|
|
37
|
+
if (error) {
|
|
38
|
+
reject(error);
|
|
99
39
|
} else {
|
|
100
|
-
|
|
40
|
+
resolve({ stdout, stderr });
|
|
101
41
|
}
|
|
102
42
|
});
|
|
103
|
-
|
|
104
|
-
};
|
|
105
|
-
const stop = () => {
|
|
106
|
-
if (appProcess) {
|
|
107
|
-
appProcess.kill();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const restart = () => {
|
|
111
|
-
stop();
|
|
112
|
-
start();
|
|
113
|
-
};
|
|
114
|
-
return {
|
|
115
|
-
restart,
|
|
116
|
-
stop,
|
|
117
|
-
basePath: `${process.cwd()}/.orion/build`
|
|
118
|
-
};
|
|
43
|
+
});
|
|
119
44
|
}
|
|
120
45
|
|
|
121
|
-
// src/
|
|
46
|
+
// src/build/compile.ts
|
|
47
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
122
48
|
var import_typescript4 = __toESM(require("typescript"), 1);
|
|
123
49
|
|
|
124
|
-
// src/
|
|
125
|
-
var
|
|
126
|
-
var import_path2 = __toESM(require("path"), 1);
|
|
127
|
-
function rimraf(dir_path) {
|
|
128
|
-
if (import_fs3.default.existsSync(dir_path)) {
|
|
129
|
-
import_fs3.default.readdirSync(dir_path).forEach(function(entry) {
|
|
130
|
-
var entry_path = import_path2.default.join(dir_path, entry);
|
|
131
|
-
if (import_fs3.default.lstatSync(entry_path).isDirectory()) {
|
|
132
|
-
rimraf(entry_path);
|
|
133
|
-
} else {
|
|
134
|
-
import_fs3.default.unlinkSync(entry_path);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
import_fs3.default.rmdirSync(dir_path);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async function cleanDirectory() {
|
|
141
|
-
try {
|
|
142
|
-
const path9 = `${process.cwd()}/.orion/build`;
|
|
143
|
-
rimraf(path9);
|
|
144
|
-
} catch {
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// src/start/watchAndCompile/getHost.ts
|
|
50
|
+
// src/build/getOptions.ts
|
|
51
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
149
52
|
var import_typescript3 = __toESM(require("typescript"), 1);
|
|
150
53
|
|
|
151
54
|
// src/start/watchAndCompile/getConfigPath.ts
|
|
152
55
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
153
56
|
|
|
57
|
+
// src/start/watchAndCompile/ensureConfigComplies.ts
|
|
58
|
+
var import_comment_json = require("comment-json");
|
|
59
|
+
|
|
154
60
|
// src/helpers/getFileContents.ts
|
|
155
|
-
var
|
|
61
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
156
62
|
function readFile(filePath) {
|
|
157
|
-
if (!
|
|
158
|
-
return
|
|
63
|
+
if (!import_node_fs.default.existsSync(filePath)) return null;
|
|
64
|
+
return import_node_fs.default.readFileSync(filePath).toString();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/helpers/writeFile.ts
|
|
68
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
69
|
+
|
|
70
|
+
// src/helpers/ensureDirectory.ts
|
|
71
|
+
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
72
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
73
|
+
var ensureDirectory = (filePath) => {
|
|
74
|
+
const dirname = import_node_path.default.dirname(filePath);
|
|
75
|
+
if (import_node_fs2.default.existsSync(dirname)) return true;
|
|
76
|
+
ensureDirectory(dirname);
|
|
77
|
+
import_node_fs2.default.mkdirSync(dirname);
|
|
78
|
+
};
|
|
79
|
+
var ensureDirectory_default = ensureDirectory;
|
|
80
|
+
|
|
81
|
+
// src/helpers/writeFile.ts
|
|
82
|
+
async function writeFile_default(path8, content) {
|
|
83
|
+
ensureDirectory_default(path8);
|
|
84
|
+
import_node_fs3.default.writeFileSync(path8, content);
|
|
159
85
|
}
|
|
160
86
|
|
|
161
87
|
// src/start/watchAndCompile/ensureConfigComplies.ts
|
|
162
|
-
var import_comment_json = require("comment-json");
|
|
163
88
|
function ensureConfigComplies(configPath) {
|
|
164
89
|
var _a, _b;
|
|
165
90
|
try {
|
|
@@ -169,16 +94,16 @@ function ensureConfigComplies(configPath) {
|
|
|
169
94
|
...config,
|
|
170
95
|
compilerOptions: {
|
|
171
96
|
...config.compilerOptions,
|
|
172
|
-
outDir:
|
|
173
|
-
baseUrl:
|
|
97
|
+
outDir: "./.orion/build/app",
|
|
98
|
+
baseUrl: "./"
|
|
174
99
|
}
|
|
175
100
|
};
|
|
176
101
|
if (!((_a = config.compilerOptions) == null ? void 0 : _a.rootDir) && !((_b = config.compilerOptions) == null ? void 0 : _b.rootDirs)) {
|
|
177
|
-
newConfig.compilerOptions.rootDir =
|
|
102
|
+
newConfig.compilerOptions.rootDir = "./app";
|
|
178
103
|
}
|
|
179
104
|
writeFile_default(configPath, (0, import_comment_json.stringify)(newConfig, null, 2));
|
|
180
105
|
} catch (error) {
|
|
181
|
-
console.log(`Error reading tsconfig ${error.message}`);
|
|
106
|
+
console.log(`Error reading tsconfig: ${error.message}`);
|
|
182
107
|
}
|
|
183
108
|
}
|
|
184
109
|
|
|
@@ -193,7 +118,7 @@ function getConfigPath() {
|
|
|
193
118
|
return configPath;
|
|
194
119
|
}
|
|
195
120
|
|
|
196
|
-
// src/
|
|
121
|
+
// src/build/reports.ts
|
|
197
122
|
var import_typescript2 = __toESM(require("typescript"), 1);
|
|
198
123
|
var format = {
|
|
199
124
|
getCanonicalFileName: (fileName) => fileName,
|
|
@@ -204,123 +129,86 @@ function reportDiagnostic(diagnostic) {
|
|
|
204
129
|
console.log(import_typescript2.default.formatDiagnosticsWithColorAndContext([diagnostic], format));
|
|
205
130
|
}
|
|
206
131
|
|
|
207
|
-
// src/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const aliasPath = `${basePath}/moduleAlias.js`;
|
|
219
|
-
writeFile_default(
|
|
220
|
-
aliasPath,
|
|
221
|
-
`"use strict";
|
|
222
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
223
|
-
const moduleAlias = require('./moduleAliasLib')
|
|
224
|
-
const path = __dirname + '/app'
|
|
225
|
-
moduleAlias.addAlias('app', path)
|
|
226
|
-
`
|
|
227
|
-
);
|
|
228
|
-
const indexPath = `${basePath}/index.js`;
|
|
229
|
-
writeFile_default(
|
|
230
|
-
indexPath,
|
|
231
|
-
`"use strict";
|
|
232
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
233
|
-
require("./moduleAlias");
|
|
234
|
-
require("./app");
|
|
235
|
-
`
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// src/start/watchAndCompile/getHost.ts
|
|
240
|
-
function getHost(runner) {
|
|
241
|
-
const reportWatchStatusChanged = (diagnostic) => {
|
|
242
|
-
if (diagnostic.category !== 3) return;
|
|
243
|
-
if (diagnostic.code === 6032 || diagnostic.code === 6031) {
|
|
244
|
-
runner.stop();
|
|
245
|
-
}
|
|
246
|
-
console.log(import_safe2.default.bold(`=> ${diagnostic.messageText}`));
|
|
247
|
-
if (diagnostic.code === 6194) {
|
|
248
|
-
if (/^Found .+ errors?/.test(diagnostic.messageText.toString())) {
|
|
249
|
-
if (!diagnostic.messageText.toString().includes("Found 0 errors.")) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
writeIndex_default({ basePath: runner.basePath });
|
|
254
|
-
runner.restart();
|
|
255
|
-
}
|
|
132
|
+
// src/build/getOptions.ts
|
|
133
|
+
function getCompilerOptionsJSONFollowExtends(filename) {
|
|
134
|
+
let compopts = {};
|
|
135
|
+
const config = import_typescript3.default.readConfigFile(filename, import_typescript3.default.sys.readFile).config;
|
|
136
|
+
if (config.extends) {
|
|
137
|
+
const rqrpath = require.resolve(config.extends);
|
|
138
|
+
compopts = getCompilerOptionsJSONFollowExtends(rqrpath);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
...compopts,
|
|
142
|
+
...config.compilerOptions
|
|
256
143
|
};
|
|
144
|
+
}
|
|
145
|
+
function getOptions({ output }) {
|
|
257
146
|
const configPath = getConfigPath();
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return host;
|
|
147
|
+
const config = getCompilerOptionsJSONFollowExtends(configPath);
|
|
148
|
+
config.outDir = `${output}/app`;
|
|
149
|
+
config.incremental = false;
|
|
150
|
+
const { options, errors } = import_typescript3.default.convertCompilerOptionsFromJson(config, import_node_path2.default.dirname(configPath));
|
|
151
|
+
if (errors.length) {
|
|
152
|
+
errors.forEach(reportDiagnostic);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
return options;
|
|
268
156
|
}
|
|
269
157
|
|
|
270
|
-
// src/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
console.log(
|
|
288
|
-
`Error cleaning ${atBuildPath}. Restar project is suggested. Error: ${error.message}`
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
});
|
|
158
|
+
// src/build/compile.ts
|
|
159
|
+
function compile({ output }) {
|
|
160
|
+
const options = getOptions({ output });
|
|
161
|
+
const program2 = import_typescript4.default.createProgram(["./app/index.ts"], options);
|
|
162
|
+
const preEmitDiagnostics = import_typescript4.default.getPreEmitDiagnostics(program2);
|
|
163
|
+
if (preEmitDiagnostics.length > 0) {
|
|
164
|
+
console.log(import_chalk.default.red("\n==> Error builing Orion app\n"));
|
|
165
|
+
}
|
|
166
|
+
preEmitDiagnostics.forEach(reportDiagnostic);
|
|
167
|
+
if (preEmitDiagnostics.length > 0) {
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
const emitResult = program2.emit();
|
|
171
|
+
emitResult.diagnostics.forEach(reportDiagnostic);
|
|
172
|
+
if (emitResult.emitSkipped) {
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
292
175
|
}
|
|
293
176
|
|
|
294
|
-
// src/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
(0, import_env.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
|
|
306
|
-
runner.restart();
|
|
307
|
-
});
|
|
308
|
-
};
|
|
177
|
+
// src/build/index.ts
|
|
178
|
+
async function build_default({ output }) {
|
|
179
|
+
if (!output) {
|
|
180
|
+
output = "./build";
|
|
181
|
+
}
|
|
182
|
+
console.log(import_chalk2.default.bold(`Cleaning directory ${output}...`));
|
|
183
|
+
await execute_default(`rm -rf ${output}`);
|
|
184
|
+
console.log(import_chalk2.default.bold("Compiling your app..."));
|
|
185
|
+
compile({ output });
|
|
186
|
+
console.log(import_chalk2.default.bold("Build created"));
|
|
187
|
+
}
|
|
309
188
|
|
|
310
|
-
// src/
|
|
311
|
-
async function
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
189
|
+
// src/create/index.ts
|
|
190
|
+
async function create_default({ name, kit }) {
|
|
191
|
+
if (!name) {
|
|
192
|
+
throw new Error("Please set the name of the app");
|
|
193
|
+
}
|
|
194
|
+
if (!kit) {
|
|
195
|
+
throw new Error("Please select which kit to use");
|
|
196
|
+
}
|
|
197
|
+
const repo = `https://github.com/siturra/boilerplate-orionjs-${kit}`;
|
|
198
|
+
console.log("Downloading starter kit...");
|
|
199
|
+
await execute_default(`git clone ${repo} ${name}`);
|
|
200
|
+
await execute_default(`cd ${name} && rm -rf .git`);
|
|
201
|
+
console.log("Your starter kit is ready");
|
|
317
202
|
}
|
|
318
203
|
|
|
204
|
+
// src/start/index.ts
|
|
205
|
+
var import_chalk8 = __toESM(require("chalk"), 1);
|
|
206
|
+
|
|
319
207
|
// src/start/copyCursorRule/index.ts
|
|
320
|
-
var import_path5 = __toESM(require("path"), 1);
|
|
321
208
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
322
|
-
var
|
|
323
|
-
var
|
|
209
|
+
var import_node_https = __toESM(require("https"), 1);
|
|
210
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
211
|
+
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
324
212
|
var rules = [
|
|
325
213
|
"orionjs.mdx",
|
|
326
214
|
"orionjs-component.mdx",
|
|
@@ -331,7 +219,7 @@ var rules = [
|
|
|
331
219
|
];
|
|
332
220
|
var downloadFile = (url) => {
|
|
333
221
|
return new Promise((resolve, reject) => {
|
|
334
|
-
|
|
222
|
+
import_node_https.default.get(url, (response) => {
|
|
335
223
|
if (response.statusCode !== 200) {
|
|
336
224
|
reject(new Error(`Failed to download, status code: ${response.statusCode}`));
|
|
337
225
|
return;
|
|
@@ -350,55 +238,37 @@ var downloadFile = (url) => {
|
|
|
350
238
|
});
|
|
351
239
|
};
|
|
352
240
|
async function copyCursorRule() {
|
|
353
|
-
const baseUrl =
|
|
241
|
+
const baseUrl = "https://raw.githubusercontent.com/orionjs/orionjs/refs/heads/master/mdc";
|
|
354
242
|
try {
|
|
355
|
-
const targetDir =
|
|
243
|
+
const targetDir = import_node_path3.default.join(process.cwd(), ".cursor", "rules");
|
|
356
244
|
await import_promises.default.mkdir(targetDir, { recursive: true });
|
|
357
245
|
for (const rule of rules) {
|
|
358
246
|
const targetFileName = rule.replace(".mdx", ".mdc");
|
|
359
|
-
const targetFile =
|
|
247
|
+
const targetFile = import_node_path3.default.join(targetDir, targetFileName);
|
|
360
248
|
const sourceUrl = `${baseUrl}/${rule}`;
|
|
361
249
|
const content = await downloadFile(sourceUrl);
|
|
362
250
|
await import_promises.default.writeFile(targetFile, content, "utf8");
|
|
363
|
-
console.log(
|
|
251
|
+
console.log(import_chalk3.default.bold(`=> \u2728 Successfully downloaded ${import_chalk3.default.cyan(targetFileName)}`));
|
|
364
252
|
}
|
|
365
|
-
console.log(
|
|
253
|
+
console.log(import_chalk3.default.bold("=> \u2728 All rule files have been successfully copied"));
|
|
366
254
|
} catch (error) {
|
|
367
|
-
console.error(
|
|
255
|
+
console.error(import_chalk3.default.red(`Error copying rule files: ${error.message}`));
|
|
368
256
|
}
|
|
369
257
|
}
|
|
370
258
|
|
|
371
259
|
// src/start/copyMCP/index.ts
|
|
372
|
-
var import_path7 = __toESM(require("path"), 1);
|
|
373
260
|
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
var import_child_process2 = require("child_process");
|
|
377
|
-
async function execute_default(command) {
|
|
378
|
-
return new Promise(function(resolve, reject) {
|
|
379
|
-
(0, import_child_process2.exec)(command, (error, stdout, stderr) => {
|
|
380
|
-
if (error) {
|
|
381
|
-
reject(error);
|
|
382
|
-
} else {
|
|
383
|
-
resolve({ stdout, stderr });
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// src/start/copyMCP/index.ts
|
|
390
|
-
var import_safe6 = __toESM(require("colors/safe"), 1);
|
|
391
|
-
|
|
392
|
-
// src/start/copyMCP/isValidMCPRepo.ts
|
|
393
|
-
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
394
|
-
var import_path6 = __toESM(require("path"), 1);
|
|
395
|
-
var import_safe5 = __toESM(require("colors/safe"), 1);
|
|
261
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
262
|
+
var import_chalk5 = __toESM(require("chalk"), 1);
|
|
396
263
|
|
|
397
264
|
// src/start/copyMCP/consts.ts
|
|
398
265
|
var MCP_VERSION = "v1";
|
|
399
266
|
var VERSION_FILE = "version.txt";
|
|
400
267
|
|
|
401
268
|
// src/start/copyMCP/isValidMCPRepo.ts
|
|
269
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
270
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
271
|
+
var import_chalk4 = __toESM(require("chalk"), 1);
|
|
402
272
|
async function isValidMCPRepository(directoryPath) {
|
|
403
273
|
try {
|
|
404
274
|
const stats = await import_promises2.default.stat(directoryPath);
|
|
@@ -406,16 +276,20 @@ async function isValidMCPRepository(directoryPath) {
|
|
|
406
276
|
const expectedFiles = ["settings.js", "package.json"];
|
|
407
277
|
for (const file of expectedFiles) {
|
|
408
278
|
try {
|
|
409
|
-
await import_promises2.default.access(
|
|
279
|
+
await import_promises2.default.access(import_node_path4.default.join(directoryPath, file));
|
|
410
280
|
} catch {
|
|
411
281
|
return false;
|
|
412
282
|
}
|
|
413
283
|
}
|
|
414
284
|
try {
|
|
415
|
-
const versionPath =
|
|
285
|
+
const versionPath = import_node_path4.default.join(directoryPath, VERSION_FILE);
|
|
416
286
|
const versionContent = await import_promises2.default.readFile(versionPath, "utf-8");
|
|
417
287
|
if (versionContent.trim() !== MCP_VERSION) {
|
|
418
|
-
console.log(
|
|
288
|
+
console.log(
|
|
289
|
+
import_chalk4.default.yellow(
|
|
290
|
+
`=> \u2728 MCP version mismatch: installed=${versionContent.trim()}, required=${MCP_VERSION}`
|
|
291
|
+
)
|
|
292
|
+
);
|
|
419
293
|
return false;
|
|
420
294
|
}
|
|
421
295
|
} catch {
|
|
@@ -430,40 +304,44 @@ async function isValidMCPRepository(directoryPath) {
|
|
|
430
304
|
// src/start/copyMCP/index.ts
|
|
431
305
|
async function copyMCP() {
|
|
432
306
|
const repoUrl = "https://github.com/orionjs/mcp-docs";
|
|
433
|
-
const targetDir =
|
|
307
|
+
const targetDir = import_node_path5.default.join(process.cwd(), ".orion", "mcp");
|
|
434
308
|
try {
|
|
435
|
-
await import_promises3.default.mkdir(
|
|
309
|
+
await import_promises3.default.mkdir(import_node_path5.default.join(process.cwd(), ".orion"), { recursive: true });
|
|
436
310
|
if (await isValidMCPRepository(targetDir)) {
|
|
437
|
-
console.log(
|
|
311
|
+
console.log(import_chalk5.default.bold("=> \u2728 MCP documentation already installed"));
|
|
438
312
|
return;
|
|
439
313
|
}
|
|
440
314
|
try {
|
|
441
315
|
const stats = await import_promises3.default.stat(targetDir);
|
|
442
316
|
if (stats.isDirectory()) {
|
|
443
317
|
await import_promises3.default.rm(targetDir, { recursive: true, force: true });
|
|
444
|
-
console.log(
|
|
318
|
+
console.log(
|
|
319
|
+
import_chalk5.default.bold(
|
|
320
|
+
"=> \u2728 Removed existing .orion/mcp directory (invalid, incomplete, or outdated)"
|
|
321
|
+
)
|
|
322
|
+
);
|
|
445
323
|
}
|
|
446
|
-
} catch (
|
|
324
|
+
} catch (_) {
|
|
447
325
|
}
|
|
448
|
-
console.log(
|
|
326
|
+
console.log(import_chalk5.default.bold(`=> \u2728 Downloading MCP documentation ${MCP_VERSION}...`));
|
|
449
327
|
await execute_default(`git clone ${repoUrl} ${targetDir}`);
|
|
450
|
-
await execute_default(`rm -rf ${
|
|
451
|
-
await import_promises3.default.writeFile(
|
|
452
|
-
console.log(
|
|
453
|
-
|
|
328
|
+
await execute_default(`rm -rf ${import_node_path5.default.join(targetDir, ".git")}`);
|
|
329
|
+
await import_promises3.default.writeFile(import_node_path5.default.join(targetDir, VERSION_FILE), MCP_VERSION, "utf-8");
|
|
330
|
+
console.log(
|
|
331
|
+
import_chalk5.default.bold(`=> \u2728 Successfully downloaded MCP documentation v${MCP_VERSION} to .orion/mcp`)
|
|
332
|
+
);
|
|
333
|
+
console.log(import_chalk5.default.bold("=> \u2728 Installing MCP dependencies..."));
|
|
454
334
|
await execute_default(`cd ${targetDir} && npm install`);
|
|
455
|
-
console.log(
|
|
335
|
+
console.log(import_chalk5.default.bold("=> \u2728 Successfully installed MCP dependencies"));
|
|
456
336
|
const mcpServerConfig = {
|
|
457
|
-
|
|
337
|
+
mcpServers: {
|
|
458
338
|
"Orionjs documentation search": {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
import_path7.default.join(targetDir, "src", "index.js")
|
|
462
|
-
]
|
|
339
|
+
command: "node",
|
|
340
|
+
args: [import_node_path5.default.join(targetDir, "src", "index.js")]
|
|
463
341
|
}
|
|
464
342
|
}
|
|
465
343
|
};
|
|
466
|
-
const configPath =
|
|
344
|
+
const configPath = import_node_path5.default.join(process.cwd(), ".cursor", "mcp.json");
|
|
467
345
|
try {
|
|
468
346
|
const existingConfig = await import_promises3.default.readFile(configPath, "utf-8");
|
|
469
347
|
const parsedConfig = JSON.parse(existingConfig);
|
|
@@ -472,158 +350,221 @@ async function copyMCP() {
|
|
|
472
350
|
...mcpServerConfig.mcpServers
|
|
473
351
|
};
|
|
474
352
|
await import_promises3.default.writeFile(configPath, JSON.stringify(parsedConfig, null, 2), "utf-8");
|
|
475
|
-
console.log(
|
|
476
|
-
} catch (
|
|
477
|
-
await import_promises3.default.mkdir(
|
|
353
|
+
console.log(import_chalk5.default.bold("=> \u2728 Updated MCP server configuration in .cursor/mcp.json"));
|
|
354
|
+
} catch (_) {
|
|
355
|
+
await import_promises3.default.mkdir(import_node_path5.default.dirname(configPath), { recursive: true });
|
|
478
356
|
await import_promises3.default.writeFile(configPath, JSON.stringify(mcpServerConfig, null, 2), "utf-8");
|
|
479
|
-
console.log(
|
|
357
|
+
console.log(import_chalk5.default.bold("=> \u2728 Created new MCP server configuration in .cursor/mcp.json"));
|
|
480
358
|
}
|
|
481
359
|
} catch (error) {
|
|
482
|
-
console.error(
|
|
360
|
+
console.error(import_chalk5.default.red("=> \u2728 Error copying MCP documentation:"), error);
|
|
483
361
|
throw error;
|
|
484
362
|
}
|
|
485
363
|
}
|
|
486
364
|
|
|
487
|
-
// src/start/index.ts
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
365
|
+
// src/start/runner/index.ts
|
|
366
|
+
var import_chalk6 = __toESM(require("chalk"), 1);
|
|
367
|
+
|
|
368
|
+
// src/start/runner/startProcess.ts
|
|
369
|
+
var import_node_child_process2 = require("child_process");
|
|
370
|
+
|
|
371
|
+
// src/start/runner/getArgs.ts
|
|
372
|
+
function getArgs(options) {
|
|
373
|
+
let startCommand = process.env.START_COMMAND || "node";
|
|
374
|
+
const args = [];
|
|
375
|
+
if (process.env.START_COMMAND) {
|
|
376
|
+
const [first, ...otherArgs] = process.env.START_COMMAND.split(" ");
|
|
377
|
+
startCommand = first;
|
|
378
|
+
args.push(...otherArgs);
|
|
379
|
+
console.log(`Using custom command: ${[startCommand, ...args].join(" ")}`);
|
|
380
|
+
} else if (options.shell) {
|
|
381
|
+
args.push("--inspect");
|
|
499
382
|
}
|
|
500
|
-
|
|
501
|
-
|
|
383
|
+
args.push(".orion/build/index.js");
|
|
384
|
+
return { startCommand, args };
|
|
502
385
|
}
|
|
503
386
|
|
|
504
|
-
// src/
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
387
|
+
// src/start/runner/startProcess.ts
|
|
388
|
+
function startProcess(options) {
|
|
389
|
+
const { startCommand, args } = getArgs(options);
|
|
390
|
+
return (0, import_node_child_process2.spawn)(startCommand, args, {
|
|
391
|
+
env: {
|
|
392
|
+
ORION_DEV: "local",
|
|
393
|
+
...process.env
|
|
394
|
+
},
|
|
395
|
+
cwd: process.cwd(),
|
|
396
|
+
stdio: "inherit",
|
|
397
|
+
detached: false
|
|
398
|
+
});
|
|
399
|
+
}
|
|
509
400
|
|
|
510
|
-
// src/
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
const config = import_typescript5.default.readConfigFile(filename, import_typescript5.default.sys.readFile).config;
|
|
516
|
-
if (config.extends) {
|
|
517
|
-
const rqrpath = require.resolve(config.extends);
|
|
518
|
-
compopts = getCompilerOptionsJSONFollowExtends(rqrpath);
|
|
401
|
+
// src/start/runner/index.ts
|
|
402
|
+
function getRunner(options) {
|
|
403
|
+
let appProcess = null;
|
|
404
|
+
if (options.clean) {
|
|
405
|
+
console.log(import_chalk6.default.bold("=> Cleaning directory...\n"));
|
|
519
406
|
}
|
|
407
|
+
const start = () => {
|
|
408
|
+
console.log(import_chalk6.default.bold("=> Starting app...\n"));
|
|
409
|
+
appProcess = startProcess(options);
|
|
410
|
+
appProcess.on("exit", (code, signal) => {
|
|
411
|
+
if (!code || code === 143 || code === 0 || signal === "SIGTERM" || signal === "SIGINT") {
|
|
412
|
+
} else {
|
|
413
|
+
console.log(import_chalk6.default.bold(`=> Error running app. Exit code: ${code}`));
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
writeFile_default(".orion/process", `${appProcess.pid}`);
|
|
417
|
+
};
|
|
418
|
+
const stop = () => {
|
|
419
|
+
if (appProcess) {
|
|
420
|
+
appProcess.kill();
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
const restart = () => {
|
|
424
|
+
stop();
|
|
425
|
+
start();
|
|
426
|
+
};
|
|
520
427
|
return {
|
|
521
|
-
|
|
522
|
-
|
|
428
|
+
restart,
|
|
429
|
+
stop,
|
|
430
|
+
basePath: `${process.cwd()}/.orion/build`
|
|
523
431
|
};
|
|
524
432
|
}
|
|
525
|
-
function getOptions({ output }) {
|
|
526
|
-
const configPath = getConfigPath();
|
|
527
|
-
const config = getCompilerOptionsJSONFollowExtends(configPath);
|
|
528
|
-
config.outDir = `${output}/app`;
|
|
529
|
-
config.incremental = false;
|
|
530
|
-
const { options, errors } = import_typescript5.default.convertCompilerOptionsFromJson(config, import_path8.default.dirname(configPath));
|
|
531
|
-
if (errors.length) {
|
|
532
|
-
errors.forEach(reportDiagnostic);
|
|
533
|
-
process.exit(1);
|
|
534
|
-
}
|
|
535
|
-
return options;
|
|
536
|
-
}
|
|
537
433
|
|
|
538
|
-
// src/
|
|
539
|
-
var
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
434
|
+
// src/start/watchAndCompile/index.ts
|
|
435
|
+
var import_node_child_process3 = require("child_process");
|
|
436
|
+
|
|
437
|
+
// src/start/watchAndCompile/cleanDirectory.ts
|
|
438
|
+
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
439
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
440
|
+
function rimraf(dir_path) {
|
|
441
|
+
if (import_node_fs4.default.existsSync(dir_path)) {
|
|
442
|
+
import_node_fs4.default.readdirSync(dir_path).forEach((entry) => {
|
|
443
|
+
const entry_path = import_node_path6.default.join(dir_path, entry);
|
|
444
|
+
if (import_node_fs4.default.lstatSync(entry_path).isDirectory()) {
|
|
445
|
+
rimraf(entry_path);
|
|
446
|
+
} else {
|
|
447
|
+
import_node_fs4.default.unlinkSync(entry_path);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
import_node_fs4.default.rmdirSync(dir_path);
|
|
552
451
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
process.
|
|
452
|
+
}
|
|
453
|
+
async function cleanDirectory() {
|
|
454
|
+
try {
|
|
455
|
+
const dirPath = import_node_path6.default.join(process.cwd(), ".orion", "build");
|
|
456
|
+
rimraf(dirPath);
|
|
457
|
+
} catch (_) {
|
|
557
458
|
}
|
|
558
459
|
}
|
|
559
460
|
|
|
560
|
-
// src/
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
461
|
+
// src/start/watchAndCompile/watchDeletes.ts
|
|
462
|
+
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
463
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
464
|
+
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
465
|
+
async function watchDeletes() {
|
|
466
|
+
const projectPath = import_node_path7.default.resolve("./app");
|
|
467
|
+
const watcher = import_chokidar.default.watch(projectPath, {
|
|
468
|
+
ignoreInitial: true
|
|
469
|
+
});
|
|
470
|
+
watcher.on("unlink", async (filepath) => {
|
|
471
|
+
if (!filepath.endsWith(".ts")) return;
|
|
472
|
+
const relative = import_node_path7.default.relative(process.cwd(), filepath);
|
|
473
|
+
const atBuildPath = import_node_path7.default.resolve(".orion/build", relative.replace(/.ts$/, ""));
|
|
474
|
+
try {
|
|
475
|
+
import_node_fs5.default.unlinkSync(`${atBuildPath}.js`);
|
|
476
|
+
import_node_fs5.default.unlinkSync(`${atBuildPath}.d.ts`);
|
|
477
|
+
} catch (error) {
|
|
478
|
+
console.log(
|
|
479
|
+
`Error cleaning ${atBuildPath}. Restar project is suggested. Error: ${error.message}`
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
571
483
|
}
|
|
572
484
|
|
|
573
|
-
// src/
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
485
|
+
// src/start/watchAndCompile/writeEnvFile.ts
|
|
486
|
+
var import_env = require("@orion-js/env");
|
|
487
|
+
var import_chalk7 = __toESM(require("chalk"), 1);
|
|
488
|
+
var import_chokidar2 = __toESM(require("chokidar"), 1);
|
|
489
|
+
var envFilePath = process.env.ORION_ENV_FILE_PATH;
|
|
490
|
+
var dtsFilePath = "./app/env.d.ts";
|
|
491
|
+
var watchEnvFile = async (runner) => {
|
|
492
|
+
if (!envFilePath) return;
|
|
493
|
+
(0, import_env.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
|
|
494
|
+
import_chokidar2.default.watch(envFilePath, { ignoreInitial: true }).on("change", async () => {
|
|
495
|
+
console.log(import_chalk7.default.bold("=> Environment file changed. Restarting..."));
|
|
496
|
+
(0, import_env.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
|
|
497
|
+
runner.restart();
|
|
498
|
+
});
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// src/start/watchAndCompile/index.ts
|
|
502
|
+
async function watchAndCompile(runner) {
|
|
503
|
+
const configPath = getConfigPath();
|
|
504
|
+
ensureConfigComplies(configPath);
|
|
505
|
+
await cleanDirectory();
|
|
506
|
+
watchDeletes();
|
|
507
|
+
watchEnvFile(runner);
|
|
508
|
+
(0, import_node_child_process3.spawn)("tsx", ["watch", "app/index.ts"], {
|
|
509
|
+
cwd: process.cwd(),
|
|
510
|
+
env: process.env,
|
|
511
|
+
gid: process.getgid(),
|
|
512
|
+
uid: process.getuid(),
|
|
513
|
+
stdio: "inherit"
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// src/start/index.ts
|
|
518
|
+
async function start_default(options) {
|
|
519
|
+
console.log(import_chalk8.default.bold(`
|
|
520
|
+
Orionjs App ${import_chalk8.default.green(import_chalk8.default.bold("V4\n"))}`));
|
|
521
|
+
if (!options.omitCursorRule) {
|
|
522
|
+
await copyCursorRule().catch(console.error);
|
|
577
523
|
}
|
|
578
|
-
if (!
|
|
579
|
-
|
|
524
|
+
if (!options.omitMcpServer) {
|
|
525
|
+
await copyMCP().catch(console.error);
|
|
580
526
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
527
|
+
if (!options.omitMcpServer && !options.omitCursorRule) {
|
|
528
|
+
console.log(import_chalk8.default.bold("=> \u2728 Orionjs AI is ready\n"));
|
|
529
|
+
}
|
|
530
|
+
const runner = getRunner(options);
|
|
531
|
+
watchAndCompile(runner);
|
|
586
532
|
}
|
|
587
533
|
|
|
588
|
-
// src/index.ts
|
|
589
|
-
var import_safe11 = __toESM(require("colors/safe"), 1);
|
|
590
|
-
|
|
591
534
|
// src/test/index.ts
|
|
592
|
-
var
|
|
535
|
+
var import_chalk9 = __toESM(require("chalk"), 1);
|
|
593
536
|
function test_default() {
|
|
594
|
-
console.log(
|
|
595
|
-
console.log(
|
|
537
|
+
console.log(import_chalk9.default.bold("To run tests run the following command"));
|
|
538
|
+
console.log(import_chalk9.default.bold("ORION_DEV=LOCAL ORION_TEST=1 jest"));
|
|
596
539
|
process.exit(1);
|
|
597
540
|
}
|
|
598
541
|
|
|
599
542
|
// src/handleErrors.ts
|
|
600
|
-
var
|
|
543
|
+
var import_chalk10 = __toESM(require("chalk"), 1);
|
|
601
544
|
process.on("unhandledRejection", (error) => {
|
|
602
545
|
if (error.codeFrame) {
|
|
603
|
-
console.error(
|
|
546
|
+
console.error(import_chalk10.default.red(error.message));
|
|
604
547
|
console.log(error.codeFrame);
|
|
605
548
|
} else {
|
|
606
|
-
console.error(
|
|
549
|
+
console.error(import_chalk10.default.red(error.message), import_chalk10.default.red("Unhandled promise rejection"));
|
|
607
550
|
}
|
|
608
551
|
}).on("uncaughtException", (error) => {
|
|
609
|
-
console.error(
|
|
552
|
+
console.error(import_chalk10.default.red(error.message));
|
|
610
553
|
process.exit(1);
|
|
611
554
|
});
|
|
612
555
|
|
|
613
556
|
// src/version.ts
|
|
614
|
-
var version_default =
|
|
557
|
+
var version_default = "3.0";
|
|
615
558
|
|
|
616
559
|
// src/index.ts
|
|
617
560
|
var import_config = require("dotenv/config");
|
|
618
561
|
var program = new import_commander.Command();
|
|
619
|
-
var run =
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
};
|
|
562
|
+
var run = (action) => async (...args) => {
|
|
563
|
+
try {
|
|
564
|
+
await action(...args);
|
|
565
|
+
} catch (e) {
|
|
566
|
+
console.error(import_chalk11.default.red(`Error: ${e.message}`));
|
|
567
|
+
}
|
|
627
568
|
};
|
|
628
569
|
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));
|
|
629
570
|
program.command("test").allowUnknownOption().description("Deprecated command").action(run(test_default));
|