@orion-js/core 3.0.0-alpha.1 → 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.
Files changed (33) hide show
  1. package/{dist → lib}/build/compile.js +0 -0
  2. package/{dist → lib}/build/copyFiles.js +0 -0
  3. package/{dist → lib}/build/createPackageJSON.js +0 -0
  4. package/{dist → lib}/build/index.js +0 -0
  5. package/{dist → lib}/create/index.js +0 -0
  6. package/{dist → lib}/handleErrors.js +0 -0
  7. package/{dist → lib}/helpers/ensureDirectory.js +0 -0
  8. package/{dist → lib}/helpers/execute.js +0 -0
  9. package/{dist → lib}/helpers/getFileContents.js +0 -0
  10. package/{dist → lib}/helpers/getModulesToWatch.js +0 -0
  11. package/{dist → lib}/helpers/isPortInUse.js +0 -0
  12. package/{dist → lib}/helpers/runOnce.js +0 -0
  13. package/{dist → lib}/helpers/sleep.js +0 -0
  14. package/{dist → lib}/helpers/writeFile.js +0 -0
  15. package/{dist → lib}/index.js +1 -8
  16. package/{dist → lib}/start/index.js +0 -0
  17. package/{dist → lib}/start/runner/getArgs.js +0 -0
  18. package/{dist → lib}/start/runner/index.js +11 -5
  19. package/{dist → lib}/start/runner/startProcess.js +0 -0
  20. package/{dist → lib}/start/watchAndCompile/cleanDirectory.js +0 -0
  21. package/{dist → lib}/start/watchAndCompile/ensureConfigComplies.js +0 -0
  22. package/{dist → lib}/start/watchAndCompile/getConfigPath.js +0 -0
  23. package/lib/start/watchAndCompile/getHost.js +38 -0
  24. package/lib/start/watchAndCompile/index.js +14 -0
  25. package/lib/start/watchAndCompile/reports.js +16 -0
  26. package/{dist → lib}/start/watchAndCompile/writeIndex/index.js +2 -3
  27. package/{dist → lib}/test/index.js +0 -0
  28. package/{dist → lib}/version.js +0 -0
  29. package/package.json +3 -3
  30. package/tsconfig.json +1 -1
  31. package/dist/start/watchAndCompile/getHost.js +0 -18
  32. package/dist/start/watchAndCompile/index.js +0 -27
  33. package/dist/start/watchAndCompile/reports.js +0 -22
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node --experimental-specifier-resolution=node --no-warnings
1
+ #!/usr/bin/env node
2
2
  "use strict";
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -8,7 +8,6 @@ const commander_1 = __importDefault(require("commander"));
8
8
  const start_1 = __importDefault(require("./start"));
9
9
  const build_1 = __importDefault(require("./build"));
10
10
  const safe_1 = __importDefault(require("colors/safe"));
11
- const create_1 = __importDefault(require("./create"));
12
11
  const test_1 = __importDefault(require("./test"));
13
12
  require("./handleErrors");
14
13
  const version_1 = __importDefault(require("./version"));
@@ -33,12 +32,6 @@ commander_1.default
33
32
  .description('Compiles an Orionjs app and exports it to a simple nodejs app')
34
33
  .option('-o, --output [output]', 'Output directory')
35
34
  .action(run(build_1.default));
36
- commander_1.default
37
- .command('create')
38
- .description('Creates a new Orionjs project')
39
- .option('--name [name]', 'Name of the project')
40
- .option('--kit [kit]', 'Which starter kit to use')
41
- .action(run(create_1.default));
42
35
  commander_1.default.version(version_1.default, '-v --version');
43
36
  commander_1.default.parse(process.argv);
44
37
  if (!process.argv.slice(2).length) {
File without changes
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 restart = () => {
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
- return { restart };
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;
File without changes
@@ -0,0 +1,38 @@
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)();
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;
@@ -0,0 +1,14 @@
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 getHost_1 = require("./getHost");
8
+ const cleanDirectory_1 = __importDefault(require("./cleanDirectory"));
9
+ async function watchAndCompile(runner) {
10
+ await (0, cleanDirectory_1.default)();
11
+ const host = (0, getHost_1.getHost)(runner);
12
+ typescript_1.default.createWatchProgram(host);
13
+ }
14
+ exports.default = watchAndCompile;
@@ -0,0 +1,16 @@
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;
@@ -6,18 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const writeFile_1 = __importDefault(require("../../../helpers/writeFile"));
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const libPath = path_1.default.resolve(__dirname, '../../../../moduleAlias.js.txt');
10
- const libContent = fs_1.default.readFileSync(libPath).toString();
11
9
  function default_1() {
12
10
  const basePath = `${process.cwd()}/.orion/build`;
13
11
  const libPath = `${basePath}/moduleAliasLib.js`;
12
+ const libContentPath = path_1.default.resolve(__dirname, '../../../../moduleAlias.js.txt');
13
+ const libContent = fs_1.default.readFileSync(libContentPath).toString();
14
14
  (0, writeFile_1.default)(libPath, libContent);
15
15
  const aliasPath = `${basePath}/moduleAlias.js`;
16
16
  (0, writeFile_1.default)(aliasPath, `"use strict";
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const moduleAlias = require('./moduleAliasLib')
19
19
  const path = __dirname + '/app'
20
- console.log('registering alias', path)
21
20
  moduleAlias.addAlias('app', path)
22
21
  `);
23
22
  const indexPath = `${basePath}/index.js`;
File without changes
File without changes
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@orion-js/core",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.5",
4
4
  "main": "index.js",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
7
7
  "bin": {
8
- "orion": "./dist/index.js"
8
+ "orion": "./lib/index.js"
9
9
  },
10
10
  "scripts": {
11
11
  "test": "exit 0",
@@ -32,5 +32,5 @@
32
32
  "engines": {
33
33
  "node": ">=14.0.0"
34
34
  },
35
- "gitHead": "e5f09ad60d33a2f5d860dbc8f54a2efa7971b3e7"
35
+ "gitHead": "3c2d957f111c94a1dc271feb6ae04f42eb7aed76"
36
36
  }
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "strict": false,
4
- "outDir": "./dist",
4
+ "outDir": "./lib",
5
5
  "rootDir": "./src",
6
6
  "module": "commonjs",
7
7
  "target": "es2020",
@@ -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
- exports.getHost = void 0;
7
- const typescript_1 = __importDefault(require("typescript"));
8
- const getConfigPath_1 = require("./getConfigPath");
9
- const reports_1 = require("./reports");
10
- function getHost() {
11
- const configPath = (0, getConfigPath_1.getConfigPath)();
12
- const createProgram = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram;
13
- // Note that there is another overload for `createWatchCompilerHost` that takes
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);
16
- return host;
17
- }
18
- exports.getHost = getHost;
@@ -1,27 +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 getHost_1 = require("./getHost");
8
- const cleanDirectory_1 = __importDefault(require("./cleanDirectory"));
9
- const writeIndex_1 = __importDefault(require("./writeIndex"));
10
- async function watchAndCompile(runner) {
11
- 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.
25
- typescript_1.default.createWatchProgram(host);
26
- }
27
- exports.default = watchAndCompile;
@@ -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.reportWatchStatusChanged = exports.reportDiagnostic = void 0;
7
- const typescript_1 = __importDefault(require("typescript"));
8
- const formatHost = {
9
- getCanonicalFileName: path => path,
10
- getCurrentDirectory: typescript_1.default.sys.getCurrentDirectory,
11
- getNewLine: () => typescript_1.default.sys.newLine
12
- };
13
- function reportDiagnostic(diagnostic) {
14
- console.error('Error', diagnostic.code, ':', typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()));
15
- }
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;