@orion-js/core 3.11.14 → 4.0.0-next.1
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/build/compile.d.ts +3 -0
- package/dist/build/getOptions.d.ts +7 -0
- package/dist/build/index.d.ts +3 -0
- package/dist/create/index.d.ts +4 -0
- package/dist/fsevents-hj42pnne.node +0 -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/getModulesToWatch.d.ts +1 -0
- package/dist/helpers/isPortInUse.d.ts +1 -0
- package/dist/helpers/runOnce.d.ts +1 -0
- package/dist/helpers/sleep.d.ts +2 -0
- package/dist/helpers/writeFile.d.ts +1 -0
- package/dist/index.cjs +196340 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +196332 -0
- package/dist/start/copyCursorRule/index.d.ts +1 -0
- package/dist/start/copyMCP/consts.d.ts +2 -0
- package/dist/start/copyMCP/index.d.ts +1 -0
- package/dist/start/copyMCP/isValidMCPRepo.d.ts +5 -0
- package/dist/start/index.d.ts +2 -0
- package/dist/start/runner/getArgs.d.ts +5 -0
- package/dist/start/runner/index.d.ts +12 -0
- package/dist/start/runner/startProcess.d.ts +1 -0
- package/dist/start/watchAndCompile/cleanDirectory.d.ts +1 -0
- package/dist/start/watchAndCompile/ensureConfigComplies.d.ts +1 -0
- package/dist/start/watchAndCompile/getConfigPath.d.ts +1 -0
- package/dist/start/watchAndCompile/getHost.d.ts +3 -0
- package/dist/start/watchAndCompile/index.d.ts +2 -0
- package/dist/start/watchAndCompile/reports.d.ts +2 -0
- package/dist/start/watchAndCompile/watchDeletes.d.ts +1 -0
- package/dist/start/watchAndCompile/writeEnvFile.d.ts +2 -0
- package/dist/start/watchAndCompile/writeIndex/index.d.ts +3 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/version.d.ts +2 -0
- package/package.json +22 -10
- package/LICENSE +0 -21
- package/lib/build/compile.js +0 -28
- package/lib/build/getOptions.js +0 -36
- package/lib/build/index.js +0 -21
- package/lib/create/index.js +0 -20
- package/lib/handleErrors.js +0 -20
- package/lib/helpers/ensureDirectory.js +0 -15
- package/lib/helpers/execute.js +0 -16
- package/lib/helpers/getFileContents.js +0 -12
- package/lib/helpers/getModulesToWatch.js +0 -39
- package/lib/helpers/isPortInUse.js +0 -26
- package/lib/helpers/runOnce.js +0 -14
- package/lib/helpers/sleep.js +0 -3
- package/lib/helpers/writeFile.js +0 -12
- package/lib/index.js +0 -52
- package/lib/start/copyCursorRule/index.js +0 -66
- package/lib/start/copyMCP/consts.js +0 -6
- package/lib/start/copyMCP/index.js +0 -87
- package/lib/start/copyMCP/isValidMCPRepo.js +0 -56
- package/lib/start/index.js +0 -25
- package/lib/start/runner/getArgs.js +0 -19
- package/lib/start/runner/index.js +0 -42
- package/lib/start/runner/startProcess.js +0 -18
- package/lib/start/watchAndCompile/cleanDirectory.js +0 -34
- package/lib/start/watchAndCompile/ensureConfigComplies.js +0 -31
- package/lib/start/watchAndCompile/getConfigPath.js +0 -19
- package/lib/start/watchAndCompile/getHost.js +0 -38
- package/lib/start/watchAndCompile/index.js +0 -18
- package/lib/start/watchAndCompile/reports.js +0 -16
- package/lib/start/watchAndCompile/watchDeletes.js +0 -29
- package/lib/start/watchAndCompile/writeEnvFile.js +0 -22
- package/lib/start/watchAndCompile/writeIndex/index.js +0 -28
- package/lib/test/index.js +0 -12
- package/lib/version.js +0 -3
- package/moduleAlias.js.txt +0 -224
- package/tsconfig.json +0 -15
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.copyMCP = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
-
const execute_1 = __importDefault(require("../../helpers/execute"));
|
|
10
|
-
const safe_1 = __importDefault(require("colors/safe"));
|
|
11
|
-
const isValidMCPRepo_1 = require("./isValidMCPRepo");
|
|
12
|
-
const consts_1 = require("./consts");
|
|
13
|
-
async function copyMCP() {
|
|
14
|
-
const repoUrl = 'https://github.com/orionjs/mcp-docs';
|
|
15
|
-
const targetDir = path_1.default.join(process.cwd(), '.orion', 'mcp');
|
|
16
|
-
try {
|
|
17
|
-
// Ensure parent directory exists
|
|
18
|
-
await promises_1.default.mkdir(path_1.default.join(process.cwd(), '.orion'), { recursive: true });
|
|
19
|
-
// Check if the repository is already properly installed with current version
|
|
20
|
-
if (await (0, isValidMCPRepo_1.isValidMCPRepository)(targetDir)) {
|
|
21
|
-
console.log(safe_1.default.bold(`=> ✨ MCP documentation already installed`));
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
// Check if the directory already exists but is not a valid repository or has outdated version
|
|
25
|
-
try {
|
|
26
|
-
const stats = await promises_1.default.stat(targetDir);
|
|
27
|
-
if (stats.isDirectory()) {
|
|
28
|
-
// Directory exists, remove it first to ensure fresh clone
|
|
29
|
-
await promises_1.default.rm(targetDir, { recursive: true, force: true });
|
|
30
|
-
console.log(safe_1.default.bold(`=> ✨ Removed existing .orion/mcp directory (invalid, incomplete, or outdated)`));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
// Directory doesn't exist, which is fine
|
|
35
|
-
}
|
|
36
|
-
// Clone the repository
|
|
37
|
-
console.log(safe_1.default.bold(`=> ✨ Downloading MCP documentation ${consts_1.MCP_VERSION}...`));
|
|
38
|
-
await (0, execute_1.default)(`git clone ${repoUrl} ${targetDir}`);
|
|
39
|
-
// Remove git directory to avoid confusion
|
|
40
|
-
await (0, execute_1.default)(`rm -rf ${path_1.default.join(targetDir, '.git')}`);
|
|
41
|
-
// Create version file
|
|
42
|
-
await promises_1.default.writeFile(path_1.default.join(targetDir, consts_1.VERSION_FILE), consts_1.MCP_VERSION, 'utf-8');
|
|
43
|
-
console.log(safe_1.default.bold(`=> ✨ Successfully downloaded MCP documentation v${consts_1.MCP_VERSION} to .orion/mcp`));
|
|
44
|
-
// Install dependencies in the MCP directory
|
|
45
|
-
console.log(safe_1.default.bold(`=> ✨ Installing MCP dependencies...`));
|
|
46
|
-
await (0, execute_1.default)(`cd ${targetDir} && npm install`);
|
|
47
|
-
console.log(safe_1.default.bold(`=> ✨ Successfully installed MCP dependencies`));
|
|
48
|
-
const mcpServerConfig = {
|
|
49
|
-
"mcpServers": {
|
|
50
|
-
"Orionjs documentation search": {
|
|
51
|
-
"command": "node",
|
|
52
|
-
"args": [
|
|
53
|
-
path_1.default.join(targetDir, 'src', 'index.js')
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const configPath = path_1.default.join(process.cwd(), '.cursor', 'mcp.json');
|
|
59
|
-
// Check if the config file exists
|
|
60
|
-
try {
|
|
61
|
-
// Try to read existing config file
|
|
62
|
-
const existingConfig = await promises_1.default.readFile(configPath, 'utf-8');
|
|
63
|
-
const parsedConfig = JSON.parse(existingConfig);
|
|
64
|
-
// Update the mcpServers section while preserving other settings
|
|
65
|
-
parsedConfig.mcpServers = {
|
|
66
|
-
...parsedConfig.mcpServers,
|
|
67
|
-
...mcpServerConfig.mcpServers
|
|
68
|
-
};
|
|
69
|
-
// Write the updated config back
|
|
70
|
-
await promises_1.default.writeFile(configPath, JSON.stringify(parsedConfig, null, 2), 'utf-8');
|
|
71
|
-
console.log(safe_1.default.bold(`=> ✨ Updated MCP server configuration in .cursor/mcp.json`));
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
// If file doesn't exist or can't be parsed, create a new one
|
|
75
|
-
// Ensure the .cursor directory exists
|
|
76
|
-
await promises_1.default.mkdir(path_1.default.dirname(configPath), { recursive: true });
|
|
77
|
-
// Write the new config file
|
|
78
|
-
await promises_1.default.writeFile(configPath, JSON.stringify(mcpServerConfig, null, 2), 'utf-8');
|
|
79
|
-
console.log(safe_1.default.bold(`=> ✨ Created new MCP server configuration in .cursor/mcp.json`));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error(safe_1.default.red('=> ✨ Error copying MCP documentation:'), error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.copyMCP = copyMCP;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isValidMCPRepository = void 0;
|
|
7
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const safe_1 = __importDefault(require("colors/safe"));
|
|
10
|
-
const consts_1 = require("./consts");
|
|
11
|
-
/**
|
|
12
|
-
* Checks if the MCP repository appears to be already installed correctly
|
|
13
|
-
* and has the current version
|
|
14
|
-
*/
|
|
15
|
-
async function isValidMCPRepository(directoryPath) {
|
|
16
|
-
try {
|
|
17
|
-
// Check if directory exists
|
|
18
|
-
const stats = await promises_1.default.stat(directoryPath);
|
|
19
|
-
if (!stats.isDirectory())
|
|
20
|
-
return false;
|
|
21
|
-
// Check for some key files/directories that should exist in the repository
|
|
22
|
-
// This helps verify it's a valid repository and not just an empty or corrupted directory
|
|
23
|
-
const expectedFiles = ['settings.js', 'package.json'];
|
|
24
|
-
for (const file of expectedFiles) {
|
|
25
|
-
try {
|
|
26
|
-
await promises_1.default.access(path_1.default.join(directoryPath, file));
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// If any expected file doesn't exist, consider the repository invalid
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
// Check if version file exists and has the correct version
|
|
34
|
-
try {
|
|
35
|
-
const versionPath = path_1.default.join(directoryPath, consts_1.VERSION_FILE);
|
|
36
|
-
const versionContent = await promises_1.default.readFile(versionPath, 'utf-8');
|
|
37
|
-
// If the version in the file doesn't match the current version,
|
|
38
|
-
// consider the repository outdated
|
|
39
|
-
if (versionContent.trim() !== consts_1.MCP_VERSION) {
|
|
40
|
-
console.log(safe_1.default.yellow(`=> ✨ MCP version mismatch: installed=${versionContent.trim()}, required=${consts_1.MCP_VERSION}`));
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
// Version file doesn't exist or can't be read
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
// All checks passed, consider it a valid and current repository
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
// Any error means directory doesn't exist or can't be accessed
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.isValidMCPRepository = isValidMCPRepository;
|
package/lib/start/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const safe_1 = __importDefault(require("colors/safe"));
|
|
7
|
-
const runner_1 = require("./runner");
|
|
8
|
-
const watchAndCompile_1 = __importDefault(require("./watchAndCompile"));
|
|
9
|
-
const copyCursorRule_1 = require("./copyCursorRule");
|
|
10
|
-
const copyMCP_1 = require("./copyMCP");
|
|
11
|
-
async function default_1(options) {
|
|
12
|
-
console.log(safe_1.default.bold('\nOrionjs App ' + safe_1.default.green(safe_1.default.bold('V3\n'))));
|
|
13
|
-
if (!options.omitCursorRule) {
|
|
14
|
-
await ((0, copyCursorRule_1.copyCursorRule)().catch(console.error));
|
|
15
|
-
}
|
|
16
|
-
if (!options.omitMcpServer) {
|
|
17
|
-
await ((0, copyMCP_1.copyMCP)().catch(console.error));
|
|
18
|
-
}
|
|
19
|
-
if (!options.omitMcpServer && !options.omitCursorRule) {
|
|
20
|
-
console.log(safe_1.default.bold(`=> ✨ Orionjs AI is ready\n`));
|
|
21
|
-
}
|
|
22
|
-
const runner = (0, runner_1.getRunner)(options);
|
|
23
|
-
(0, watchAndCompile_1.default)(runner);
|
|
24
|
-
}
|
|
25
|
-
exports.default = default_1;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getArgs = void 0;
|
|
4
|
-
function getArgs(options) {
|
|
5
|
-
let startCommand = process.env.START_COMMAND || 'node';
|
|
6
|
-
const args = [];
|
|
7
|
-
if (process.env.START_COMMAND) {
|
|
8
|
-
const [first, ...otherArgs] = process.env.START_COMMAND.split(' ');
|
|
9
|
-
startCommand = first;
|
|
10
|
-
args.push(...otherArgs);
|
|
11
|
-
console.log('Using custom command: ' + [startCommand, ...args].join(' '));
|
|
12
|
-
}
|
|
13
|
-
else if (options.shell) {
|
|
14
|
-
args.push('--inspect');
|
|
15
|
-
}
|
|
16
|
-
args.push('.orion/build/index.js');
|
|
17
|
-
return { startCommand, args };
|
|
18
|
-
}
|
|
19
|
-
exports.getArgs = getArgs;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getRunner = void 0;
|
|
7
|
-
const safe_1 = __importDefault(require("colors/safe"));
|
|
8
|
-
const writeFile_1 = __importDefault(require("../../helpers/writeFile"));
|
|
9
|
-
const startProcess_1 = require("./startProcess");
|
|
10
|
-
function getRunner(options) {
|
|
11
|
-
let appProcess = null;
|
|
12
|
-
if (options.clean) {
|
|
13
|
-
console.log(safe_1.default.bold('=> Cleaning directory...\n'));
|
|
14
|
-
}
|
|
15
|
-
const start = () => {
|
|
16
|
-
console.log(safe_1.default.bold('=> Starting app...\n'));
|
|
17
|
-
appProcess = (0, startProcess_1.startProcess)(options);
|
|
18
|
-
appProcess.on('exit', function (code, signal) {
|
|
19
|
-
if (!code || code === 143 || code === 0 || signal === 'SIGTERM' || signal === 'SIGINT') {
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
console.log(safe_1.default.bold(`=> Error running app. Exit code: ${code}`));
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
(0, writeFile_1.default)('.orion/process', `${appProcess.pid}`);
|
|
26
|
-
};
|
|
27
|
-
const stop = () => {
|
|
28
|
-
if (appProcess) {
|
|
29
|
-
appProcess.kill();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const restart = () => {
|
|
33
|
-
stop();
|
|
34
|
-
start();
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
restart,
|
|
38
|
-
stop,
|
|
39
|
-
basePath: `${process.cwd()}/.orion/build`
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.getRunner = getRunner;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startProcess = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
const getArgs_1 = require("./getArgs");
|
|
6
|
-
function startProcess(options) {
|
|
7
|
-
const { startCommand, args } = (0, getArgs_1.getArgs)(options);
|
|
8
|
-
return (0, child_process_1.spawn)(startCommand, args, {
|
|
9
|
-
env: {
|
|
10
|
-
ORION_DEV: 'local',
|
|
11
|
-
...process.env
|
|
12
|
-
},
|
|
13
|
-
cwd: process.cwd(),
|
|
14
|
-
stdio: 'inherit',
|
|
15
|
-
detached: false
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
exports.startProcess = startProcess;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
/**
|
|
9
|
-
* Remove directory recursively
|
|
10
|
-
* @param {string} dir_path
|
|
11
|
-
* @see https://stackoverflow.com/a/42505874/3027390
|
|
12
|
-
*/
|
|
13
|
-
function rimraf(dir_path) {
|
|
14
|
-
if (fs_1.default.existsSync(dir_path)) {
|
|
15
|
-
fs_1.default.readdirSync(dir_path).forEach(function (entry) {
|
|
16
|
-
var entry_path = path_1.default.join(dir_path, entry);
|
|
17
|
-
if (fs_1.default.lstatSync(entry_path).isDirectory()) {
|
|
18
|
-
rimraf(entry_path);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
fs_1.default.unlinkSync(entry_path);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
fs_1.default.rmdirSync(dir_path);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function cleanDirectory() {
|
|
28
|
-
try {
|
|
29
|
-
const path = `${process.cwd()}/.orion/build`;
|
|
30
|
-
rimraf(path);
|
|
31
|
-
}
|
|
32
|
-
catch { }
|
|
33
|
-
}
|
|
34
|
-
exports.default = cleanDirectory;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ensureConfigComplies = void 0;
|
|
7
|
-
const getFileContents_1 = __importDefault(require("../../helpers/getFileContents"));
|
|
8
|
-
const writeFile_1 = __importDefault(require("../../helpers/writeFile"));
|
|
9
|
-
const comment_json_1 = require("comment-json");
|
|
10
|
-
function ensureConfigComplies(configPath) {
|
|
11
|
-
try {
|
|
12
|
-
const configJSON = (0, getFileContents_1.default)(configPath);
|
|
13
|
-
const config = (0, comment_json_1.parse)(configJSON);
|
|
14
|
-
const newConfig = {
|
|
15
|
-
...config,
|
|
16
|
-
compilerOptions: {
|
|
17
|
-
...config.compilerOptions,
|
|
18
|
-
outDir: `./.orion/build/app`,
|
|
19
|
-
baseUrl: `./`
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
if (!config.compilerOptions?.rootDir && !config.compilerOptions?.rootDirs) {
|
|
23
|
-
newConfig.compilerOptions.rootDir = `./app`;
|
|
24
|
-
}
|
|
25
|
-
(0, writeFile_1.default)(configPath, (0, comment_json_1.stringify)(newConfig, null, 2));
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.log(`Error reading tsconfig ${error.message}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.ensureConfigComplies = ensureConfigComplies;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getConfigPath = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
const ensureConfigComplies_1 = require("./ensureConfigComplies");
|
|
9
|
-
function getConfigPath() {
|
|
10
|
-
const appBasePath = process.cwd();
|
|
11
|
-
const configPath = typescript_1.default.findConfigFile(appBasePath, typescript_1.default.sys.fileExists, 'tsconfig.server.json') ||
|
|
12
|
-
typescript_1.default.findConfigFile(appBasePath, typescript_1.default.sys.fileExists, 'tsconfig.json');
|
|
13
|
-
if (!configPath) {
|
|
14
|
-
throw new Error("Could not find a valid 'tsconfig.json'.");
|
|
15
|
-
}
|
|
16
|
-
(0, ensureConfigComplies_1.ensureConfigComplies)(configPath);
|
|
17
|
-
return configPath;
|
|
18
|
-
}
|
|
19
|
-
exports.getConfigPath = getConfigPath;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getHost = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
const getConfigPath_1 = require("./getConfigPath");
|
|
9
|
-
const reports_1 = require("./reports");
|
|
10
|
-
const safe_1 = __importDefault(require("colors/safe"));
|
|
11
|
-
const writeIndex_1 = __importDefault(require("./writeIndex"));
|
|
12
|
-
function getHost(runner) {
|
|
13
|
-
const reportWatchStatusChanged = (diagnostic) => {
|
|
14
|
-
if (diagnostic.category !== 3)
|
|
15
|
-
return;
|
|
16
|
-
if (diagnostic.code === 6032 || diagnostic.code === 6031) {
|
|
17
|
-
runner.stop();
|
|
18
|
-
}
|
|
19
|
-
console.log(safe_1.default.bold(`=> ${diagnostic.messageText}`));
|
|
20
|
-
if (diagnostic.code === 6194) {
|
|
21
|
-
/**
|
|
22
|
-
* Sometimes diagnostic code is 6194 even with errors
|
|
23
|
-
*/
|
|
24
|
-
if (/^Found .+ errors?/.test(diagnostic.messageText.toString())) {
|
|
25
|
-
if (!diagnostic.messageText.toString().includes('Found 0 errors.')) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
(0, writeIndex_1.default)({ basePath: runner.basePath });
|
|
30
|
-
runner.restart();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const configPath = (0, getConfigPath_1.getConfigPath)();
|
|
34
|
-
const createProgram = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram;
|
|
35
|
-
const host = typescript_1.default.createWatchCompilerHost(configPath, {}, typescript_1.default.sys, createProgram, reports_1.reportDiagnostic, reportWatchStatusChanged);
|
|
36
|
-
return host;
|
|
37
|
-
}
|
|
38
|
-
exports.getHost = getHost;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
7
|
-
const cleanDirectory_1 = __importDefault(require("./cleanDirectory"));
|
|
8
|
-
const getHost_1 = require("./getHost");
|
|
9
|
-
const watchDeletes_1 = require("./watchDeletes");
|
|
10
|
-
const writeEnvFile_1 = require("./writeEnvFile");
|
|
11
|
-
async function watchAndCompile(runner) {
|
|
12
|
-
await (0, cleanDirectory_1.default)();
|
|
13
|
-
const host = (0, getHost_1.getHost)(runner);
|
|
14
|
-
typescript_1.default.createWatchProgram(host);
|
|
15
|
-
(0, watchDeletes_1.watchDeletes)();
|
|
16
|
-
(0, writeEnvFile_1.watchEnvFile)(runner);
|
|
17
|
-
}
|
|
18
|
-
exports.default = watchAndCompile;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.reportDiagnostic = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
const format = {
|
|
9
|
-
getCanonicalFileName: fileName => fileName,
|
|
10
|
-
getCurrentDirectory: () => process.cwd(),
|
|
11
|
-
getNewLine: () => typescript_1.default.sys.newLine
|
|
12
|
-
};
|
|
13
|
-
function reportDiagnostic(diagnostic) {
|
|
14
|
-
console.log(typescript_1.default.formatDiagnosticsWithColorAndContext([diagnostic], format));
|
|
15
|
-
}
|
|
16
|
-
exports.reportDiagnostic = reportDiagnostic;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.watchDeletes = void 0;
|
|
7
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
async function watchDeletes() {
|
|
11
|
-
const projectPath = path_1.default.resolve('./app');
|
|
12
|
-
const watcher = chokidar_1.default.watch(projectPath, {
|
|
13
|
-
ignoreInitial: true
|
|
14
|
-
});
|
|
15
|
-
watcher.on('unlink', async (filepath) => {
|
|
16
|
-
if (!filepath.endsWith('.ts'))
|
|
17
|
-
return;
|
|
18
|
-
const relative = path_1.default.relative(process.cwd(), filepath);
|
|
19
|
-
const atBuildPath = path_1.default.resolve('.orion/build', relative.replace(/.ts$/, ''));
|
|
20
|
-
try {
|
|
21
|
-
fs_1.default.unlinkSync(`${atBuildPath}.js`);
|
|
22
|
-
fs_1.default.unlinkSync(`${atBuildPath}.d.ts`);
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.log(`Error cleaning ${atBuildPath}. Restar project is suggested. Error: ${error.message}`);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
exports.watchDeletes = watchDeletes;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.watchEnvFile = void 0;
|
|
7
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
|
-
const safe_1 = __importDefault(require("colors/safe"));
|
|
9
|
-
const env_1 = require("@orion-js/env");
|
|
10
|
-
const envFilePath = process.env.ORION_ENV_FILE_PATH;
|
|
11
|
-
const dtsFilePath = './app/env.d.ts';
|
|
12
|
-
const watchEnvFile = async (runner) => {
|
|
13
|
-
if (!envFilePath)
|
|
14
|
-
return;
|
|
15
|
-
(0, env_1.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
|
|
16
|
-
chokidar_1.default.watch(envFilePath, { ignoreInitial: true }).on('change', async () => {
|
|
17
|
-
console.log(safe_1.default.bold(`=> Environment file changed. Restarting...`));
|
|
18
|
-
(0, env_1.writeDtsFileFromConfigFile)(envFilePath, dtsFilePath);
|
|
19
|
-
runner.restart();
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
exports.watchEnvFile = watchEnvFile;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const writeFile_1 = __importDefault(require("../../../helpers/writeFile"));
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
function default_1({ basePath }) {
|
|
10
|
-
const libPath = `${basePath}/moduleAliasLib.js`;
|
|
11
|
-
const libContentPath = path_1.default.resolve(__dirname, '../../../../moduleAlias.js.txt');
|
|
12
|
-
const libContent = fs_1.default.readFileSync(libContentPath).toString();
|
|
13
|
-
(0, writeFile_1.default)(libPath, libContent);
|
|
14
|
-
const aliasPath = `${basePath}/moduleAlias.js`;
|
|
15
|
-
(0, writeFile_1.default)(aliasPath, `"use strict";
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
const moduleAlias = require('./moduleAliasLib')
|
|
18
|
-
const path = __dirname + '/app'
|
|
19
|
-
moduleAlias.addAlias('app', path)
|
|
20
|
-
`);
|
|
21
|
-
const indexPath = `${basePath}/index.js`;
|
|
22
|
-
(0, writeFile_1.default)(indexPath, `"use strict";
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
require("./moduleAlias");
|
|
25
|
-
require("./app");
|
|
26
|
-
`);
|
|
27
|
-
}
|
|
28
|
-
exports.default = default_1;
|
package/lib/test/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const safe_1 = __importDefault(require("colors/safe"));
|
|
7
|
-
function default_1() {
|
|
8
|
-
console.log(safe_1.default.bold(`To run tests run the following command`));
|
|
9
|
-
console.log(safe_1.default.bold(`ORION_DEV=LOCAL ORION_TEST=1 jest`));
|
|
10
|
-
process.exit(1);
|
|
11
|
-
}
|
|
12
|
-
exports.default = default_1;
|
package/lib/version.js
DELETED