@orion-js/core 3.0.0-alpha.4 → 3.0.0-alpha.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/lib/index.js
CHANGED
|
File without changes
|
|
@@ -9,10 +9,7 @@ const writeFile_1 = __importDefault(require("../../helpers/writeFile"));
|
|
|
9
9
|
const startProcess_1 = require("./startProcess");
|
|
10
10
|
function getRunner(options) {
|
|
11
11
|
let appProcess = null;
|
|
12
|
-
const
|
|
13
|
-
if (appProcess) {
|
|
14
|
-
appProcess.kill();
|
|
15
|
-
}
|
|
12
|
+
const start = () => {
|
|
16
13
|
console.log(safe_1.default.bold('=> Starting app...\n'));
|
|
17
14
|
appProcess = (0, startProcess_1.startProcess)(options);
|
|
18
15
|
appProcess.on('exit', function (code, signal) {
|
|
@@ -24,6 +21,15 @@ function getRunner(options) {
|
|
|
24
21
|
});
|
|
25
22
|
(0, writeFile_1.default)('.orion/process', `${appProcess.pid}`);
|
|
26
23
|
};
|
|
27
|
-
|
|
24
|
+
const stop = () => {
|
|
25
|
+
if (appProcess) {
|
|
26
|
+
appProcess.kill();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const restart = () => {
|
|
30
|
+
stop();
|
|
31
|
+
start();
|
|
32
|
+
};
|
|
33
|
+
return { restart, stop };
|
|
28
34
|
}
|
|
29
35
|
exports.getRunner = getRunner;
|
|
@@ -7,12 +7,32 @@ exports.getHost = void 0;
|
|
|
7
7
|
const typescript_1 = __importDefault(require("typescript"));
|
|
8
8
|
const getConfigPath_1 = require("./getConfigPath");
|
|
9
9
|
const reports_1 = require("./reports");
|
|
10
|
-
|
|
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)();
|
|
30
|
+
runner.restart();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
11
33
|
const configPath = (0, getConfigPath_1.getConfigPath)();
|
|
12
34
|
const createProgram = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram;
|
|
13
|
-
|
|
14
|
-
// a set of root files.
|
|
15
|
-
const host = typescript_1.default.createWatchCompilerHost(configPath, {}, typescript_1.default.sys, createProgram, reports_1.reportDiagnostic, reports_1.reportWatchStatusChanged);
|
|
35
|
+
const host = typescript_1.default.createWatchCompilerHost(configPath, {}, typescript_1.default.sys, createProgram, reports_1.reportDiagnostic, reportWatchStatusChanged);
|
|
16
36
|
return host;
|
|
17
37
|
}
|
|
18
38
|
exports.getHost = getHost;
|
|
@@ -6,22 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const typescript_1 = __importDefault(require("typescript"));
|
|
7
7
|
const getHost_1 = require("./getHost");
|
|
8
8
|
const cleanDirectory_1 = __importDefault(require("./cleanDirectory"));
|
|
9
|
-
const writeIndex_1 = __importDefault(require("./writeIndex"));
|
|
10
9
|
async function watchAndCompile(runner) {
|
|
11
10
|
await (0, cleanDirectory_1.default)();
|
|
12
|
-
const host = (0, getHost_1.getHost)();
|
|
13
|
-
const origCreateProgram = host.createProgram;
|
|
14
|
-
host.createProgram = (rootNames, options, host, oldProgram) => {
|
|
15
|
-
return origCreateProgram(rootNames, options, host, oldProgram);
|
|
16
|
-
};
|
|
17
|
-
const origPostProgramCreate = host.afterProgramCreate;
|
|
18
|
-
host.afterProgramCreate = program => {
|
|
19
|
-
origPostProgramCreate(program);
|
|
20
|
-
(0, writeIndex_1.default)();
|
|
21
|
-
runner.restart();
|
|
22
|
-
};
|
|
23
|
-
// `createWatchProgram` creates an initial program, watches files, and updates
|
|
24
|
-
// the program over time.
|
|
11
|
+
const host = (0, getHost_1.getHost)(runner);
|
|
25
12
|
typescript_1.default.createWatchProgram(host);
|
|
26
13
|
}
|
|
27
14
|
exports.default = watchAndCompile;
|
|
@@ -3,20 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.reportDiagnostic = void 0;
|
|
7
7
|
const typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
const
|
|
9
|
-
getCanonicalFileName:
|
|
10
|
-
getCurrentDirectory:
|
|
8
|
+
const format = {
|
|
9
|
+
getCanonicalFileName: fileName => fileName,
|
|
10
|
+
getCurrentDirectory: () => process.cwd(),
|
|
11
11
|
getNewLine: () => typescript_1.default.sys.newLine
|
|
12
12
|
};
|
|
13
13
|
function reportDiagnostic(diagnostic) {
|
|
14
|
-
console.
|
|
14
|
+
console.log(typescript_1.default.formatDiagnosticsWithColorAndContext([diagnostic], format));
|
|
15
15
|
}
|
|
16
16
|
exports.reportDiagnostic = reportDiagnostic;
|
|
17
|
-
/**
|
|
18
|
-
* Prints a diagnostic every time the watch status changes.
|
|
19
|
-
* This is mainly for messages like "Starting compilation" or "Compilation completed".
|
|
20
|
-
*/
|
|
21
|
-
function reportWatchStatusChanged(diagnostic) { }
|
|
22
|
-
exports.reportWatchStatusChanged = reportWatchStatusChanged;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=14.0.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "3c2d957f111c94a1dc271feb6ae04f42eb7aed76"
|
|
36
36
|
}
|