lincd-cli 1.2.0 → 1.2.2
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/defaults/app-with-backend/.eslintignore +3 -1
- package/defaults/app-with-backend/lincd.config.js +4 -6
- package/defaults/app-with-backend/package.json +8 -16
- package/defaults/app-with-backend/scripts/storage-config.js +5 -5
- package/defaults/app-with-backend/src/App.module.css +17 -0
- package/defaults/app-with-backend/src/App.tsx +11 -15
- package/defaults/app-with-backend/src/backend.ts +8 -0
- package/defaults/app-with-backend/src/components/Error.tsx +2 -5
- package/defaults/app-with-backend/src/components/Spinner.tsx +3 -3
- package/defaults/app-with-backend/src/config-frontend.ts +6 -6
- package/defaults/app-with-backend/src/index.tsx +4 -3
- package/defaults/app-with-backend/src/layout/DefaultLayout.module.css +12 -0
- package/defaults/app-with-backend/src/layout/DefaultLayout.tsx +3 -4
- package/defaults/app-with-backend/src/layout/Header.module.css +25 -0
- package/defaults/app-with-backend/src/layout/Header.tsx +10 -6
- package/defaults/app-with-backend/src/package.ts +0 -1
- package/defaults/app-with-backend/src/pages/Home.tsx +3 -3
- package/defaults/app-with-backend/src/pages/PageNotFound.tsx +2 -1
- package/defaults/app-with-backend/src/routes.tsx +8 -7
- package/defaults/app-with-backend/src/theme.css +95 -0
- package/defaults/app-with-backend/src/types.ts +14 -0
- package/defaults/app-with-backend/tsconfig.json +9 -6
- package/defaults/package/package.json +30 -3
- package/defaults/package/src/index.ts +1 -1
- package/defaults/package/src/ontologies/example-ontology.ts +4 -4
- package/defaults/package/src/package.ts +2 -1
- package/defaults/shape.ts +1 -1
- package/lib/cjs/cli-methods.js +376 -113
- package/lib/cjs/cli-methods.js.map +1 -1
- package/lib/cjs/cli.js +15 -1
- package/lib/cjs/cli.js.map +1 -1
- package/lib/cjs/config-grunt.cjs +3 -3
- package/lib/cjs/config-grunt.cjs.map +1 -1
- package/lib/cjs/config-webpack-app.js +277 -133
- package/lib/cjs/config-webpack-app.js.map +1 -1
- package/lib/cjs/config-webpack.js +30 -22
- package/lib/cjs/config-webpack.js.map +1 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/loaders/css-loader.mjs +28 -24
- package/lib/cjs/loaders/css-loader.mjs.map +1 -1
- package/lib/cjs/loaders/register.js +5 -0
- package/lib/cjs/loaders/register.js.map +1 -1
- package/lib/cjs/package.json +12 -10
- package/lib/cjs/plugins/check-imports.js +1 -1
- package/lib/cjs/plugins/check-imports.js.map +1 -1
- package/lib/cjs/plugins/declaration-plugin.js +17 -7
- package/lib/cjs/plugins/declaration-plugin.js.map +1 -1
- package/lib/cjs/plugins/externalise-modules.js.map +1 -1
- package/lib/cjs/plugins/lincd-tailwind-sources.js +32 -0
- package/lib/cjs/plugins/lincd-tailwind-sources.js.map +1 -0
- package/lib/cjs/plugins/watch-run.js.map +1 -1
- package/lib/cjs/tailwind.config.js +18 -0
- package/lib/cjs/tailwind.config.js.map +1 -0
- package/lib/cjs/utils.js +103 -41
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/cli-methods.js +360 -113
- package/lib/esm/cli-methods.js.map +1 -1
- package/lib/esm/cli.js +16 -2
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/config-grunt.cjs +29 -26
- package/lib/esm/config-grunt.cjs.map +1 -1
- package/lib/esm/config-webpack-app.js +259 -123
- package/lib/esm/config-webpack-app.js.map +1 -1
- package/lib/esm/config-webpack.js +12 -13
- package/lib/esm/config-webpack.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/loaders/css-loader.mjs +23 -12
- package/lib/esm/loaders/css-loader.mjs.map +1 -1
- package/lib/esm/loaders/register.js +5 -0
- package/lib/esm/loaders/register.js.map +1 -1
- package/lib/esm/package.json +12 -10
- package/lib/esm/plugins/check-imports.js.map +1 -1
- package/lib/esm/plugins/declaration-plugin.js.map +1 -1
- package/lib/esm/plugins/externalise-modules.js.map +1 -1
- package/lib/esm/plugins/lincd-tailwind-sources.js +27 -0
- package/lib/esm/plugins/lincd-tailwind-sources.js.map +1 -0
- package/lib/esm/plugins/watch-run.js.map +1 -1
- package/lib/esm/tailwind.config.js +13 -0
- package/lib/esm/tailwind.config.js.map +1 -0
- package/lib/esm/utils.js +73 -24
- package/lib/esm/utils.js.map +1 -1
- package/lib-template/cjs/package.json +3 -0
- package/lib-template/esm/package.json +3 -0
- package/package.json +15 -12
- package/defaults/app-with-backend/babel.config.js +0 -4
- package/defaults/app-with-backend/src/App.scss +0 -6
- package/defaults/app-with-backend/src/App.scss.json +0 -1
- package/defaults/app-with-backend/src/components/Error.scss.json +0 -1
- package/defaults/app-with-backend/src/components/Spinner.scss.json +0 -1
- package/defaults/app-with-backend/src/layout/DefaultLayout.scss +0 -6
- package/defaults/app-with-backend/src/layout/DefaultLayout.scss.json +0 -1
- package/defaults/app-with-backend/src/layout/Header.scss +0 -10
- package/defaults/app-with-backend/src/layout/Header.scss.json +0 -1
- package/defaults/app-with-backend/src/pages/Home.scss.json +0 -1
- package/defaults/app-with-backend/src/scss/global-overwrites.scss +0 -11
- package/defaults/app-with-backend/src/scss/variables.scss +0 -23
- /package/defaults/app-with-backend/{web → public}/favicon-144x144.png +0 -0
- /package/defaults/app-with-backend/{web → public}/favicon-57x57.png +0 -0
- /package/defaults/app-with-backend/{web → public}/favicon-72x72.png +0 -0
- /package/defaults/app-with-backend/{web → public}/favicon.ico +0 -0
- /package/defaults/app-with-backend/src/components/{Error.scss → Error.module.css} +0 -0
- /package/defaults/app-with-backend/src/components/{Spinner.scss → Spinner.module.css} +0 -0
- /package/defaults/app-with-backend/src/pages/{Home.scss → Home.module.css} +0 -0
- /package/defaults/package/src/{types.d.ts → types.ts} +0 -0
package/lib/cjs/cli-methods.js
CHANGED
|
@@ -15,18 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.removeOldFiles = exports.executeCommandForPackage = exports.addCapacitor = exports.addLinesToFile = exports.executeCommandForEachPackage = exports.buildUpdated = exports.publishPackage = exports.publishUpdated = exports.compilePackage = exports.buildPackage = exports.register = exports.createPackage = exports.upgradePackages = exports.
|
|
39
|
+
exports.removeOldFiles = exports.executeCommandForPackage = exports.addCapacitor = exports.addLinesToFile = exports.executeCommandForEachPackage = exports.buildUpdated = exports.publishPackage = exports.publishUpdated = exports.compilePackageCJS = exports.compilePackageESM = exports.compilePackage = exports.buildPackage = exports.register = exports.createPackage = exports.upgradePackages = exports.buildBackend = exports.buildFrontend = exports.buildApp = exports.startServer = exports.runMethod = exports.ensureEnvironmentLoaded = exports.depCheck = exports.depCheckStaged = exports.checkImports = exports.createComponent = exports.createSetComponent = exports.createShape = exports.getScriptDir = exports.setNameVariables = exports.createOntology = exports.createApp = void 0;
|
|
40
|
+
exports.warn = warn;
|
|
41
|
+
exports.developPackage = developPackage;
|
|
42
|
+
exports.runOnPackagesGroupedByDependencies = runOnPackagesGroupedByDependencies;
|
|
43
|
+
exports.buildAll = buildAll;
|
|
44
|
+
exports.getLincdPackages = getLincdPackages;
|
|
30
45
|
const chalk_1 = __importDefault(require("chalk"));
|
|
31
46
|
const child_process_1 = require("child_process");
|
|
32
47
|
const depcheck_1 = __importDefault(require("depcheck"));
|
|
@@ -37,6 +52,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
37
52
|
const fs_1 = require("fs");
|
|
38
53
|
const find_nearest_package_json_1 = require("find-nearest-package-json");
|
|
39
54
|
const LinkedFileStorage_1 = require("lincd/utils/LinkedFileStorage");
|
|
55
|
+
const child_process_2 = require("child_process");
|
|
40
56
|
// import pkg from 'lincd/utils/LinkedFileStorage';
|
|
41
57
|
// const { LinkedFileStorage } = pkg;
|
|
42
58
|
// const config = require('lincd-server/site.webpack.config');
|
|
@@ -44,6 +60,8 @@ const glob_1 = require("glob");
|
|
|
44
60
|
const webpack_1 = __importDefault(require("webpack"));
|
|
45
61
|
const staged_git_files_1 = __importDefault(require("staged-git-files"));
|
|
46
62
|
const ora_1 = __importDefault(require("ora"));
|
|
63
|
+
//@ts-ignore
|
|
64
|
+
let dirname__ = typeof __dirname !== 'undefined' ? __dirname : (0, path_1.dirname)(import.meta.url).replace('file:/', '');
|
|
47
65
|
var variables = {};
|
|
48
66
|
const createApp = async (name, basePath = process.cwd()) => {
|
|
49
67
|
if (!name) {
|
|
@@ -54,7 +72,7 @@ const createApp = async (name, basePath = process.cwd()) => {
|
|
|
54
72
|
if (!fs_extra_1.default.existsSync(targetFolder)) {
|
|
55
73
|
fs_extra_1.default.mkdirSync(targetFolder);
|
|
56
74
|
}
|
|
57
|
-
fs_extra_1.default.copySync(path_1.default.join(
|
|
75
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'app-with-backend'), targetFolder);
|
|
58
76
|
//make sure the data folder exists (even though its empty).. copying empty folders does not work with fs.copySync
|
|
59
77
|
fs_extra_1.default.mkdirSync(path_1.default.join(targetFolder, 'data'), { recursive: true });
|
|
60
78
|
fs_extra_1.default.mkdirSync(path_1.default.join(targetFolder, 'data/uploads/resized'), {
|
|
@@ -94,7 +112,6 @@ function warn(...messages) {
|
|
|
94
112
|
// console.log(chalk.red(message));
|
|
95
113
|
});
|
|
96
114
|
}
|
|
97
|
-
exports.warn = warn;
|
|
98
115
|
function developPackage(target, mode) {
|
|
99
116
|
if (!target)
|
|
100
117
|
target = 'es6';
|
|
@@ -120,7 +137,6 @@ function developPackage(target, mode) {
|
|
|
120
137
|
console.warn('unknown build target. Use es5 or es6');
|
|
121
138
|
}
|
|
122
139
|
}
|
|
123
|
-
exports.developPackage = developPackage;
|
|
124
140
|
function checkWorkspaces(rootPath, workspaces, res) {
|
|
125
141
|
// console.log('checking workspaces at '+rootPath+": "+workspaces.toString());
|
|
126
142
|
if (workspaces.packages) {
|
|
@@ -546,7 +562,6 @@ function buildAll(options) {
|
|
|
546
562
|
}
|
|
547
563
|
}, sync);
|
|
548
564
|
}
|
|
549
|
-
exports.buildAll = buildAll;
|
|
550
565
|
function getDependentPackages(dependencies, pkg) {
|
|
551
566
|
let dependentModules = [];
|
|
552
567
|
dependencies.forEach((dModuleDependencies, dModule) => {
|
|
@@ -597,7 +612,6 @@ function getLincdPackages(rootPath = process.cwd()) {
|
|
|
597
612
|
checkWorkspaces(rootPath, pack.workspaces, res);
|
|
598
613
|
return res;
|
|
599
614
|
}
|
|
600
|
-
exports.getLincdPackages = getLincdPackages;
|
|
601
615
|
function setVariable(name, replacement) {
|
|
602
616
|
//prepare name for regexp
|
|
603
617
|
name = name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
@@ -645,18 +659,18 @@ const createOntology = async (prefix, uriBase, basePath = process.cwd()) => {
|
|
|
645
659
|
//copy ontology accessor file
|
|
646
660
|
log('Creating files for ontology \'' + prefix + '\'');
|
|
647
661
|
let targetFile = path_1.default.join(targetFolder, hyphenName + '.ts');
|
|
648
|
-
fs_extra_1.default.copySync(path_1.default.join(
|
|
662
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
|
|
649
663
|
//copy data files
|
|
650
664
|
let targetDataFile = path_1.default.join(targetFolder, '..', 'data', hyphenName + '.json');
|
|
651
665
|
let targetDataFile2 = path_1.default.join(targetFolder, '..', 'data', hyphenName + '.json.d.ts');
|
|
652
|
-
fs_extra_1.default.copySync(path_1.default.join(
|
|
653
|
-
fs_extra_1.default.copySync(path_1.default.join(
|
|
666
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json'), targetDataFile);
|
|
667
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
|
|
654
668
|
await replaceVariablesInFiles(targetFile, targetDataFile, targetDataFile2);
|
|
655
669
|
log(`Prepared a new ontology data files in ${chalk_1.default.magenta(targetDataFile.replace(basePath, ''))}`, `And an ontology accessor file in ${chalk_1.default.magenta(targetFile.replace(basePath, ''))}`);
|
|
656
670
|
//if this is not a lincd app (but a lincd package instead)
|
|
657
671
|
if (!sourceFolder.includes('frontend')) {
|
|
658
672
|
//then also add an import to index
|
|
659
|
-
let indexPath = addLineToIndex(`import './ontologies/${hyphenName}';`, 'ontologies');
|
|
673
|
+
let indexPath = addLineToIndex(`import './ontologies/${hyphenName}.js';`, 'ontologies');
|
|
660
674
|
log(`Added an import of this file from ${chalk_1.default.magenta(indexPath)}`);
|
|
661
675
|
}
|
|
662
676
|
};
|
|
@@ -778,15 +792,18 @@ function getSourceFolder(basePath = process.cwd()) {
|
|
|
778
792
|
* get __dirname for either ESM/CJS
|
|
779
793
|
*/
|
|
780
794
|
const getScriptDir = () => {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
795
|
+
return dirname__;
|
|
796
|
+
// // @ts-ignore
|
|
797
|
+
// if (typeof __dirname !== 'undefined')
|
|
798
|
+
// {
|
|
799
|
+
// // @ts-ignore
|
|
800
|
+
// return __dirname;
|
|
801
|
+
// }
|
|
802
|
+
// else
|
|
803
|
+
// {
|
|
804
|
+
// // @ts-ignore
|
|
805
|
+
// return dirname(import.meta.url).replace('file:/','');
|
|
806
|
+
// }
|
|
790
807
|
};
|
|
791
808
|
exports.getScriptDir = getScriptDir;
|
|
792
809
|
const createShape = async (name, basePath = process.cwd()) => {
|
|
@@ -803,7 +820,7 @@ const createShape = async (name, basePath = process.cwd()) => {
|
|
|
803
820
|
//if this is NOT a lincd app (but a lincd package)
|
|
804
821
|
let indexPath;
|
|
805
822
|
if (!sourceFolder.includes('frontend')) {
|
|
806
|
-
indexPath = addLineToIndex(`import './shapes/${hyphenName}';`, 'shapes');
|
|
823
|
+
indexPath = addLineToIndex(`import './shapes/${hyphenName}.js';`, 'shapes');
|
|
807
824
|
log(`Added an import of this file from ${chalk_1.default.magenta(indexPath)}`);
|
|
808
825
|
}
|
|
809
826
|
};
|
|
@@ -819,7 +836,7 @@ const createSetComponent = async (name, basePath = process.cwd()) => {
|
|
|
819
836
|
fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'component.scss'), targetFile2);
|
|
820
837
|
//replace variables in some of the copied files
|
|
821
838
|
await replaceVariablesInFiles(targetFile, targetFile2);
|
|
822
|
-
let indexPath = addLineToIndex(`import './components/${hyphenName}';`, 'components');
|
|
839
|
+
let indexPath = addLineToIndex(`import './components/${hyphenName}.js';`, 'components');
|
|
823
840
|
log(`Created a new set component in ${chalk_1.default.magenta(targetFile.replace(basePath, ''))}`, `Created a new stylesheet in ${chalk_1.default.magenta(targetFile2.replace(basePath, ''))}`, `Added an import of this file from ${chalk_1.default.magenta(indexPath)}`);
|
|
824
841
|
};
|
|
825
842
|
exports.createSetComponent = createSetComponent;
|
|
@@ -839,15 +856,15 @@ const createComponent = async (name, basePath = process.cwd()) => {
|
|
|
839
856
|
//if this is not a lincd app (but a lincd package instead)
|
|
840
857
|
if (!sourceFolder.includes('frontend')) {
|
|
841
858
|
//then also add an import to index
|
|
842
|
-
let indexPath = addLineToIndex(`import './components/${hyphenName}';`, 'components');
|
|
859
|
+
let indexPath = addLineToIndex(`import './components/${hyphenName}.js';`, 'components');
|
|
843
860
|
log(`Added an import of this file from ${chalk_1.default.magenta(indexPath)}`);
|
|
844
861
|
}
|
|
845
862
|
};
|
|
846
863
|
exports.createComponent = createComponent;
|
|
847
864
|
//read the source of all ts/tsx files in the src folder
|
|
848
865
|
//if there is an import that imports a lincd package with /src/ in it, then warn
|
|
849
|
-
//if there is an import that imports outside
|
|
850
|
-
const checkImports = async (sourceFolder = getSourceFolder(), depth = 0, // Used to check if the import is outside
|
|
866
|
+
//if there is an import that imports something from outside the src folder, then warn
|
|
867
|
+
const checkImports = async (sourceFolder = getSourceFolder(), depth = 0, // Used to check if the import is outside the src folder
|
|
851
868
|
invalidImports = new Map()) => {
|
|
852
869
|
const dir = fs_extra_1.default.readdirSync(sourceFolder);
|
|
853
870
|
// Start checking each file in the source folder
|
|
@@ -857,40 +874,66 @@ invalidImports = new Map()) => {
|
|
|
857
874
|
// INFO: For future use - if this part fails, it could be due to user permissions
|
|
858
875
|
// i.e. the program not having access to check the file metadata
|
|
859
876
|
if (!filename.match(/\.tsx?$/)) {
|
|
860
|
-
|
|
861
|
-
|
|
877
|
+
try {
|
|
878
|
+
if ((0, fs_1.statSync)(filename).isDirectory()) {
|
|
879
|
+
await (0, exports.checkImports)(filename, depth + 1, invalidImports);
|
|
880
|
+
}
|
|
881
|
+
else {
|
|
882
|
+
// Ignore all files that aren't one of the following:
|
|
883
|
+
// - .ts
|
|
884
|
+
// - .tsx
|
|
885
|
+
continue;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
catch (e) {
|
|
889
|
+
console.log(e);
|
|
862
890
|
}
|
|
863
|
-
// Ignore all files that aren't one of the following:
|
|
864
|
-
// - .ts
|
|
865
|
-
// - .tsx
|
|
866
|
-
continue;
|
|
867
891
|
}
|
|
868
892
|
const allImports = await (0, utils_js_1.getFileImports)(filename);
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
893
|
+
if (!invalidImports.has(filename)) {
|
|
894
|
+
invalidImports.set(filename, []);
|
|
895
|
+
}
|
|
896
|
+
allImports.forEach((i) => {
|
|
897
|
+
if ((0, utils_js_1.isImportOutsideOfPackage)(i, depth)) {
|
|
898
|
+
invalidImports.get(filename).push({
|
|
899
|
+
type: 'outside_package',
|
|
900
|
+
importPath: i,
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
if ((0, utils_js_1.isInvalidLINCDImport)(i, depth)) {
|
|
904
|
+
invalidImports.get(filename).push({
|
|
905
|
+
type: 'lincd',
|
|
906
|
+
importPath: i,
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
if ((0, utils_js_1.isImportWithMissingExtension)(i)) {
|
|
910
|
+
invalidImports.get(filename).push({
|
|
911
|
+
type: 'missing_extension',
|
|
912
|
+
importPath: i,
|
|
913
|
+
});
|
|
876
914
|
}
|
|
877
915
|
});
|
|
878
916
|
}
|
|
879
917
|
let res = '';
|
|
918
|
+
//check if invalidImports has any
|
|
919
|
+
let flat = [...invalidImports.values()].flat();
|
|
880
920
|
// All recursion must have finished, display any errors
|
|
881
|
-
if (depth === 0 &&
|
|
921
|
+
if (depth === 0 && flat.length > 0) {
|
|
882
922
|
res += chalk_1.default.red('Invalid imports found.\n');
|
|
883
923
|
invalidImports.forEach((value, key) => {
|
|
884
924
|
// res += '- '+chalk.blueBright(key.split('/').pop()) + ':\n';
|
|
885
|
-
value.forEach((
|
|
886
|
-
|
|
887
|
-
if (
|
|
888
|
-
|
|
889
|
-
'To fix: import from the NPM package directly.\n';
|
|
925
|
+
value.forEach(({ type, importPath }) => {
|
|
926
|
+
let message = key.split('/').pop() + ' imports from \'' + importPath + '\'';
|
|
927
|
+
if (type === 'outside_package') {
|
|
928
|
+
message += ' which is outside the package source root';
|
|
890
929
|
}
|
|
891
|
-
|
|
892
|
-
|
|
930
|
+
if (type === 'lincd') {
|
|
931
|
+
message += ' which should not contain /src/ or /lib/ in the import path';
|
|
893
932
|
}
|
|
933
|
+
if (type === 'missing_extension') {
|
|
934
|
+
message += ' which should end with a file extension. Like .js or .scss';
|
|
935
|
+
}
|
|
936
|
+
res += chalk_1.default.red(message + '\n');
|
|
894
937
|
});
|
|
895
938
|
});
|
|
896
939
|
throw res;
|
|
@@ -945,7 +988,10 @@ const depCheck = async (packagePath = process.cwd()) => {
|
|
|
945
988
|
if (missingLincdPackages.length > 0) {
|
|
946
989
|
reject(chalk_1.default.red(packagePath.split('/').pop() +
|
|
947
990
|
'\n[ERROR] These LINCD packages are imported but they are not listed in package.json:\n- ' +
|
|
948
|
-
missingLincdPackages.
|
|
991
|
+
missingLincdPackages.map(missedKey => {
|
|
992
|
+
const files = results.missing[missedKey];
|
|
993
|
+
return `${missedKey} (${files.length} files: ${files.join(', ')})`;
|
|
994
|
+
}).join(',\n- ')));
|
|
949
995
|
}
|
|
950
996
|
else if (missing.length > 0) {
|
|
951
997
|
resolve(chalk_1.default.redBright('warning: ' + packagePath.split('/').pop() +
|
|
@@ -1014,10 +1060,84 @@ const ensureEnvironmentLoaded = async () => {
|
|
|
1014
1060
|
}
|
|
1015
1061
|
};
|
|
1016
1062
|
exports.ensureEnvironmentLoaded = ensureEnvironmentLoaded;
|
|
1063
|
+
const runMethod = async (packageName, method, options) => {
|
|
1064
|
+
await (0, exports.ensureEnvironmentLoaded)();
|
|
1065
|
+
if (options.spawn) {
|
|
1066
|
+
let lincdConfig = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lincd.config.js')}`).then(s => __importStar(require(s)))).default;
|
|
1067
|
+
//@ts-ignore
|
|
1068
|
+
const ServerClass = (await Promise.resolve().then(() => __importStar(require('lincd-server/shapes/LincdServer')))).LincdServer;
|
|
1069
|
+
await Promise.resolve(`${path_1.default.join(process.cwd(), 'scripts', 'storage-config.js')}`).then(s => __importStar(require(s)));
|
|
1070
|
+
let server = new ServerClass({
|
|
1071
|
+
loadAppComponent: async () => (await Promise.resolve(`${path_1.default.join(process.cwd(), 'src', 'App')}`).then(s => __importStar(require(s)))).default,
|
|
1072
|
+
...lincdConfig,
|
|
1073
|
+
});
|
|
1074
|
+
//init the server
|
|
1075
|
+
console.log('Initializing server...');
|
|
1076
|
+
server.initOnly().then(() => {
|
|
1077
|
+
//process the backend method call
|
|
1078
|
+
console.log('Running method ' + method);
|
|
1079
|
+
//mock the request and response objects
|
|
1080
|
+
let request = {
|
|
1081
|
+
body: {},
|
|
1082
|
+
query: {},
|
|
1083
|
+
params: {},
|
|
1084
|
+
headers: {},
|
|
1085
|
+
method: 'POST',
|
|
1086
|
+
url: '/' + packageName + '/' + method,
|
|
1087
|
+
};
|
|
1088
|
+
let response = {
|
|
1089
|
+
status: (statusCode) => {
|
|
1090
|
+
console.log('Response status code:', statusCode);
|
|
1091
|
+
return response;
|
|
1092
|
+
},
|
|
1093
|
+
json: (data) => {
|
|
1094
|
+
console.log('Response data:', data);
|
|
1095
|
+
},
|
|
1096
|
+
send: (data) => {
|
|
1097
|
+
console.log('Response data:', data);
|
|
1098
|
+
},
|
|
1099
|
+
};
|
|
1100
|
+
//TODO; allow sending args
|
|
1101
|
+
server.callBackendMethod(packageName, method, [], request, response).then(() => {
|
|
1102
|
+
console.log('Done');
|
|
1103
|
+
process.exit();
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
else {
|
|
1108
|
+
//reuse the existing running LincdServer instance.
|
|
1109
|
+
//make a HTTP call
|
|
1110
|
+
//'/call/:pkg/:method',
|
|
1111
|
+
fetch(process.env.SITE_ROOT + '/call/' + packageName + '/' + method, {
|
|
1112
|
+
method: 'POST',
|
|
1113
|
+
headers: {
|
|
1114
|
+
'Content-Type': 'application/json',
|
|
1115
|
+
},
|
|
1116
|
+
}).then((response) => {
|
|
1117
|
+
if (!response.ok) {
|
|
1118
|
+
throw new Error('Network response was not ok');
|
|
1119
|
+
}
|
|
1120
|
+
return response.json();
|
|
1121
|
+
}).then((data) => {
|
|
1122
|
+
console.log('Response data:', data);
|
|
1123
|
+
process.exit();
|
|
1124
|
+
}).catch((error) => {
|
|
1125
|
+
var _a;
|
|
1126
|
+
if (error.code === 'ECONNREFUSED' || ((_a = error.cause) === null || _a === void 0 ? void 0 : _a.code) === 'ECONNREFUSED') {
|
|
1127
|
+
console.error(chalk_1.default.red('Could not connect to the backend server. Is it running?'));
|
|
1128
|
+
console.error(`Make sure you ${chalk_1.default.magenta('run "yarn start" in a separate process')} before calling this method.`);
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
console.error('Error during backend call:', error);
|
|
1132
|
+
}
|
|
1133
|
+
process.exit(1);
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
exports.runMethod = runMethod;
|
|
1017
1138
|
const startServer = async (initOnly = false, ServerClass = null) => {
|
|
1018
|
-
var _a, _b;
|
|
1019
1139
|
await (0, exports.ensureEnvironmentLoaded)();
|
|
1020
|
-
let lincdConfig = await (
|
|
1140
|
+
let lincdConfig = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lincd.config.js')}`).then(s => __importStar(require(s)))).default;
|
|
1021
1141
|
// function scssLoadcall(source, filename) {
|
|
1022
1142
|
// return 'console.log("SCSS CALL: ' + filename + '");\n' + source;
|
|
1023
1143
|
// process.exit();
|
|
@@ -1032,10 +1152,18 @@ const startServer = async (initOnly = false, ServerClass = null) => {
|
|
|
1032
1152
|
//@ts-ignore
|
|
1033
1153
|
ServerClass = (await Promise.resolve().then(() => __importStar(require('lincd-server/shapes/LincdServer')))).LincdServer;
|
|
1034
1154
|
}
|
|
1035
|
-
await (
|
|
1155
|
+
await Promise.resolve(`${path_1.default.join(process.cwd(), 'scripts', 'storage-config.js')}`).then(s => __importStar(require(s)));
|
|
1156
|
+
let appPromise;
|
|
1157
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
1158
|
+
appPromise = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lib', 'App.js')}`).then(s => __importStar(require(s)))).default;
|
|
1159
|
+
}
|
|
1160
|
+
else {
|
|
1161
|
+
appPromise = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'src', 'App.js')}`).then(s => __importStar(require(s)))).default;
|
|
1162
|
+
}
|
|
1036
1163
|
let server = new ServerClass({
|
|
1037
|
-
loadAppComponent: async () => {
|
|
1038
|
-
|
|
1164
|
+
loadAppComponent: async () => {
|
|
1165
|
+
return appPromise;
|
|
1166
|
+
}, ...lincdConfig,
|
|
1039
1167
|
});
|
|
1040
1168
|
//Important to use slice, because when using clusers, child processes need to be able to read the same arguments
|
|
1041
1169
|
let args = process.argv.slice(2);
|
|
@@ -1049,10 +1177,16 @@ const startServer = async (initOnly = false, ServerClass = null) => {
|
|
|
1049
1177
|
};
|
|
1050
1178
|
exports.startServer = startServer;
|
|
1051
1179
|
const buildApp = async () => {
|
|
1180
|
+
await (0, exports.buildFrontend)();
|
|
1181
|
+
await (0, exports.buildBackend)();
|
|
1182
|
+
console.log(chalk_1.default.magenta(`✅ ${process.env.NODE_ENV} app build finished`));
|
|
1183
|
+
};
|
|
1184
|
+
exports.buildApp = buildApp;
|
|
1185
|
+
const buildFrontend = async () => {
|
|
1052
1186
|
await (0, exports.ensureEnvironmentLoaded)();
|
|
1053
1187
|
const webpackAppConfig = await (await Promise.resolve().then(() => __importStar(require('./config-webpack-app.js')))).getWebpackAppConfig();
|
|
1054
|
-
console.log(chalk_1.default.magenta(
|
|
1055
|
-
|
|
1188
|
+
console.log(chalk_1.default.magenta(`🛠 Building ${process.env.NODE_ENV} frontend bundles`));
|
|
1189
|
+
await new Promise((resolve, reject) => {
|
|
1056
1190
|
(0, webpack_1.default)(webpackAppConfig, async (err, stats) => {
|
|
1057
1191
|
if (err) {
|
|
1058
1192
|
console.error(err.stack || err);
|
|
@@ -1086,19 +1220,20 @@ const buildApp = async () => {
|
|
|
1086
1220
|
// process.exit();
|
|
1087
1221
|
});
|
|
1088
1222
|
}).then(async () => {
|
|
1089
|
-
var _a;
|
|
1090
1223
|
// make sure environment is not development for storage config
|
|
1091
1224
|
// and if we want to upload to storage, we need set S3_BUCKET_ENDPOINT
|
|
1092
1225
|
if (process.env.NODE_ENV === 'development' || !process.env.S3_BUCKET_ENDPOINT) {
|
|
1093
1226
|
console.warn('Upload build to storage skip in development environment or S3_BUCKET_ENDPOINT is not set');
|
|
1094
|
-
|
|
1227
|
+
return;
|
|
1228
|
+
// process.exit();
|
|
1095
1229
|
}
|
|
1096
1230
|
if (process.env.APP_ENV) {
|
|
1097
1231
|
console.warn('Not uploading to CDN for app builds');
|
|
1098
|
-
|
|
1232
|
+
return;
|
|
1233
|
+
// process.exit();
|
|
1099
1234
|
}
|
|
1100
1235
|
// load the storage config
|
|
1101
|
-
const storageConfig = await (
|
|
1236
|
+
const storageConfig = await Promise.resolve(`${path_1.default.join(process.cwd(), 'scripts', 'storage-config.js')}`).then(s => __importStar(require(s)));
|
|
1102
1237
|
// check if LincdFileStorage has a default FileStore
|
|
1103
1238
|
// if yes: copy all the files in the build folder over with LincdFileStorage
|
|
1104
1239
|
if (LinkedFileStorage_1.LinkedFileStorage.getDefaultStore()) {
|
|
@@ -1111,6 +1246,12 @@ const buildApp = async () => {
|
|
|
1111
1246
|
}
|
|
1112
1247
|
// get all files in the web directory and then upload them to the storage
|
|
1113
1248
|
const files = await (0, utils_js_1.getFiles)(pathDir);
|
|
1249
|
+
console.log(chalk_1.default.magenta(`🕊 Publishing ${files.length} public files to linked file storage`));
|
|
1250
|
+
const clearSpinner = (0, ora_1.default)({
|
|
1251
|
+
discardStdin: true,
|
|
1252
|
+
text: `Publishing ${files.length} public files`,
|
|
1253
|
+
}).start();
|
|
1254
|
+
let counter = 0;
|
|
1114
1255
|
const uploads = files.map(async (filePath) => {
|
|
1115
1256
|
// read file content
|
|
1116
1257
|
const fileContent = await fs_extra_1.default.promises.readFile(filePath);
|
|
@@ -1118,15 +1259,77 @@ const buildApp = async () => {
|
|
|
1118
1259
|
// example: /Users/username/project/www/index.html -> /project/www/index.html
|
|
1119
1260
|
const pathname = filePath.replace(pathDir, `/${rootDirectory}`);
|
|
1120
1261
|
// upload file to storage
|
|
1121
|
-
|
|
1262
|
+
await LinkedFileStorage_1.LinkedFileStorage.saveFile(pathname, fileContent).then(() => {
|
|
1263
|
+
clearSpinner.text = `${counter++}/${files.length}: - Published ${pathname} `;
|
|
1264
|
+
}).catch(console.error);
|
|
1122
1265
|
});
|
|
1123
1266
|
const urls = await Promise.all(uploads);
|
|
1124
|
-
|
|
1125
|
-
process.exit();
|
|
1267
|
+
clearSpinner.succeed(`${urls.length} files uploaded to storage`);
|
|
1126
1268
|
}
|
|
1127
1269
|
});
|
|
1128
1270
|
};
|
|
1129
|
-
exports.
|
|
1271
|
+
exports.buildFrontend = buildFrontend;
|
|
1272
|
+
const buildBackend = async () => {
|
|
1273
|
+
console.log(chalk_1.default.magenta(`🛠 Preparing ${process.env.NODE_ENV} backend`));
|
|
1274
|
+
//run tsc in the backend folder
|
|
1275
|
+
await (0, exports.ensureEnvironmentLoaded)();
|
|
1276
|
+
const sourceFolder = path_1.default.join(process.cwd(), 'src');
|
|
1277
|
+
const targetFolder = path_1.default.join(process.cwd(), 'lib');
|
|
1278
|
+
// Step 1: Clear lib folder
|
|
1279
|
+
const clearSpinner = (0, ora_1.default)({
|
|
1280
|
+
discardStdin: true,
|
|
1281
|
+
text: 'Clearing lib folder',
|
|
1282
|
+
}).start();
|
|
1283
|
+
try {
|
|
1284
|
+
if (fs_extra_1.default.existsSync(targetFolder)) {
|
|
1285
|
+
await fs_extra_1.default.remove(targetFolder);
|
|
1286
|
+
}
|
|
1287
|
+
clearSpinner.succeed('Lib folder cleared');
|
|
1288
|
+
}
|
|
1289
|
+
catch (e) {
|
|
1290
|
+
console.error(e);
|
|
1291
|
+
clearSpinner.fail('Failed to clear lib folder');
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
// Step 2: Compile TS files
|
|
1295
|
+
const compileSpinner = (0, ora_1.default)({
|
|
1296
|
+
discardStdin: true,
|
|
1297
|
+
text: 'Compiling backend TS files',
|
|
1298
|
+
}).start();
|
|
1299
|
+
try {
|
|
1300
|
+
await (0, utils_js_1.execPromise)(`yarn exec tsc`);
|
|
1301
|
+
compileSpinner.succeed('Backend TS files compiled');
|
|
1302
|
+
}
|
|
1303
|
+
catch (e) {
|
|
1304
|
+
console.error(e);
|
|
1305
|
+
compileSpinner.fail('Failed to compile backend TS files');
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
// Step 3: Copy CSS files
|
|
1309
|
+
const copySpinner = (0, ora_1.default)({
|
|
1310
|
+
discardStdin: true,
|
|
1311
|
+
text: 'Copying CSS files',
|
|
1312
|
+
}).start();
|
|
1313
|
+
try {
|
|
1314
|
+
const cssFiles = await (0, utils_js_1.getFiles)(sourceFolder, '.css');
|
|
1315
|
+
await Promise.all(cssFiles.map((file) => {
|
|
1316
|
+
const targetFile = file.replace(sourceFolder, targetFolder);
|
|
1317
|
+
//ensure the target folder exists
|
|
1318
|
+
const targetDir = path_1.default.dirname(targetFile);
|
|
1319
|
+
if (!fs_extra_1.default.existsSync(targetDir)) {
|
|
1320
|
+
fs_extra_1.default.mkdirSync(targetDir, { recursive: true });
|
|
1321
|
+
}
|
|
1322
|
+
return fs_extra_1.default.copyFile(file, targetFile);
|
|
1323
|
+
}));
|
|
1324
|
+
copySpinner.succeed(`${cssFiles.length} CSS files copied`);
|
|
1325
|
+
}
|
|
1326
|
+
catch (e) {
|
|
1327
|
+
console.error(e);
|
|
1328
|
+
copySpinner.fail('Failed to copy CSS files');
|
|
1329
|
+
}
|
|
1330
|
+
return true;
|
|
1331
|
+
};
|
|
1332
|
+
exports.buildBackend = buildBackend;
|
|
1130
1333
|
const upgradePackages = async () => {
|
|
1131
1334
|
await (0, exports.ensureEnvironmentLoaded)();
|
|
1132
1335
|
// let packages = getLincdPackages();
|
|
@@ -1411,25 +1614,30 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1411
1614
|
//TODO: replace with listr so we can show multiple processes at once
|
|
1412
1615
|
spinner = (0, ora_1.default)({
|
|
1413
1616
|
discardStdin: true,
|
|
1414
|
-
text: 'Compiling
|
|
1617
|
+
text: 'Compiling ESM',
|
|
1415
1618
|
}).start();
|
|
1416
1619
|
}
|
|
1417
1620
|
let buildProcess = Promise.resolve(true);
|
|
1418
1621
|
let buildStep = (step) => {
|
|
1419
1622
|
buildProcess = buildProcess.then((previousResult) => {
|
|
1623
|
+
if (!previousResult) {
|
|
1624
|
+
return false;
|
|
1625
|
+
}
|
|
1420
1626
|
if (logResults) {
|
|
1421
1627
|
spinner.text = step.name;
|
|
1422
1628
|
spinner.start();
|
|
1423
1629
|
}
|
|
1424
1630
|
return step.apply().then(stepResult => {
|
|
1631
|
+
//if a build step returns a string,
|
|
1632
|
+
//a warning is shown but the build is still successful with warnings
|
|
1425
1633
|
if (typeof stepResult === 'string') {
|
|
1426
1634
|
// spinner.text = step.name + ' - ' + stepResult;
|
|
1427
1635
|
if (logResults) {
|
|
1428
1636
|
spinner.warn(step.name + ' - ' + stepResult);
|
|
1429
1637
|
spinner.stop();
|
|
1430
1638
|
}
|
|
1431
|
-
//
|
|
1432
|
-
return
|
|
1639
|
+
//can still continue
|
|
1640
|
+
return true;
|
|
1433
1641
|
}
|
|
1434
1642
|
else if (stepResult === true || typeof stepResult === 'undefined') {
|
|
1435
1643
|
if (logResults) {
|
|
@@ -1437,13 +1645,31 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1437
1645
|
}
|
|
1438
1646
|
return previousResult && true;
|
|
1439
1647
|
}
|
|
1648
|
+
else if (typeof stepResult === 'object' && stepResult.error) {
|
|
1649
|
+
if (logResults) {
|
|
1650
|
+
spinner.fail(step.name + ' - ' + stepResult.error);
|
|
1651
|
+
spinner.stop();
|
|
1652
|
+
}
|
|
1653
|
+
//failed and should stop
|
|
1654
|
+
return false;
|
|
1655
|
+
}
|
|
1440
1656
|
});
|
|
1441
1657
|
});
|
|
1442
1658
|
};
|
|
1443
1659
|
buildStep({
|
|
1444
|
-
name: '
|
|
1660
|
+
name: 'Checking imports',
|
|
1661
|
+
apply: () => (0, exports.checkImports)(packagePath + '/src'),
|
|
1662
|
+
});
|
|
1663
|
+
buildStep({
|
|
1664
|
+
name: 'Compiling ESM',
|
|
1445
1665
|
apply: async () => {
|
|
1446
|
-
return (0, exports.
|
|
1666
|
+
return (0, exports.compilePackageESM)(packagePath);
|
|
1667
|
+
},
|
|
1668
|
+
});
|
|
1669
|
+
buildStep({
|
|
1670
|
+
name: 'Compiling CJS',
|
|
1671
|
+
apply: async () => {
|
|
1672
|
+
return (0, exports.compilePackageCJS)(packagePath);
|
|
1447
1673
|
},
|
|
1448
1674
|
});
|
|
1449
1675
|
buildStep({
|
|
@@ -1480,29 +1706,26 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1480
1706
|
return (0, exports.removeOldFiles)(packagePath);
|
|
1481
1707
|
},
|
|
1482
1708
|
});
|
|
1483
|
-
buildStep({
|
|
1484
|
-
name: 'Checking imports',
|
|
1485
|
-
apply: () => (0, exports.checkImports)(packagePath),
|
|
1486
|
-
});
|
|
1487
1709
|
buildStep({
|
|
1488
1710
|
name: 'Checking dependencies',
|
|
1489
1711
|
apply: () => (0, exports.depCheck)(packagePath),
|
|
1490
1712
|
});
|
|
1491
1713
|
let success = await buildProcess.catch(err => {
|
|
1492
|
-
let msg = err.error ? err.error : err.stdout + '\n' + err.stderr;
|
|
1714
|
+
let msg = typeof err === 'string' || err instanceof Error ? err.toString() : (err.error && !err.error.toString().includes('Command failed:') ? err.error : err.stdout + '\n' + err.stderr);
|
|
1493
1715
|
if (logResults) {
|
|
1494
1716
|
spinner.stopAndPersist({
|
|
1495
1717
|
symbol: chalk_1.default.red('✖'),
|
|
1496
|
-
text: 'Build failed',
|
|
1718
|
+
// text: 'Build failed',
|
|
1497
1719
|
});
|
|
1498
1720
|
}
|
|
1499
1721
|
else {
|
|
1500
1722
|
console.log(chalk_1.default.red(packagePath.split('/').pop(), ' - Build failed:'));
|
|
1723
|
+
console.log(err);
|
|
1501
1724
|
}
|
|
1502
1725
|
console.log(msg);
|
|
1503
1726
|
});
|
|
1504
1727
|
//will be undefined if there was an error
|
|
1505
|
-
if (typeof success !== 'undefined') {
|
|
1728
|
+
if (typeof success !== 'undefined' && success !== false) {
|
|
1506
1729
|
if (logResults) {
|
|
1507
1730
|
spinner.stopAndPersist({
|
|
1508
1731
|
symbol: chalk_1.default.greenBright('✔'),
|
|
@@ -1510,33 +1733,61 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1510
1733
|
});
|
|
1511
1734
|
}
|
|
1512
1735
|
}
|
|
1736
|
+
else {
|
|
1737
|
+
spinner.stopAndPersist({
|
|
1738
|
+
symbol: chalk_1.default.red('✖'),
|
|
1739
|
+
text: 'Build failed',
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1513
1742
|
return success;
|
|
1514
1743
|
};
|
|
1515
1744
|
exports.buildPackage = buildPackage;
|
|
1516
1745
|
const compilePackage = async (packagePath = process.cwd()) => {
|
|
1517
1746
|
//echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
|
|
1518
|
-
let cjsConfig =
|
|
1519
|
-
let esmConfig =
|
|
1520
|
-
let compileCJS = `yarn exec tsc -p tsconfig-cjs.json`;
|
|
1521
|
-
let compileESM = `yarn exec tsc -p tsconfig-esm.json`;
|
|
1522
|
-
let compileCommand;
|
|
1523
|
-
if (cjsConfig && esmConfig)
|
|
1524
|
-
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
}
|
|
1747
|
+
// let cjsConfig = fs.existsSync(path.join(packagePath,'tsconfig-cjs.json'));
|
|
1748
|
+
// let esmConfig = fs.existsSync(path.join(packagePath,'tsconfig-esm.json'));
|
|
1749
|
+
// let compileCJS = `yarn exec tsc -p tsconfig-cjs.json`;
|
|
1750
|
+
// let compileESM = `yarn exec tsc -p tsconfig-esm.json`;
|
|
1751
|
+
// let compileCommand;
|
|
1752
|
+
// if (cjsConfig && esmConfig)
|
|
1753
|
+
// {
|
|
1754
|
+
// compileCommand = `${compileCJS} && ${compileESM}`;
|
|
1755
|
+
// }
|
|
1756
|
+
// else if (cjsConfig)
|
|
1757
|
+
// {
|
|
1758
|
+
// compileCommand = compileCJS;
|
|
1759
|
+
// }
|
|
1760
|
+
// else if (esmConfig)
|
|
1761
|
+
// {
|
|
1762
|
+
// compileCommand = compileESM;
|
|
1763
|
+
// }
|
|
1764
|
+
// else
|
|
1765
|
+
// {
|
|
1766
|
+
// compileCommand = `yarn exec tsc`;
|
|
1767
|
+
// }
|
|
1768
|
+
await (0, exports.compilePackageESM)(packagePath);
|
|
1769
|
+
await (0, exports.compilePackageCJS)(packagePath);
|
|
1770
|
+
};
|
|
1771
|
+
exports.compilePackage = compilePackage;
|
|
1772
|
+
const compilePackageESM = async (packagePath = process.cwd()) => {
|
|
1773
|
+
//echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
|
|
1774
|
+
let compileCommand = `yarn exec tsc -p tsconfig-esm.json`;
|
|
1535
1775
|
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath }).then(res => {
|
|
1536
1776
|
return res === '';
|
|
1537
1777
|
});
|
|
1538
1778
|
};
|
|
1539
|
-
exports.
|
|
1779
|
+
exports.compilePackageESM = compilePackageESM;
|
|
1780
|
+
const compilePackageCJS = async (packagePath = process.cwd()) => {
|
|
1781
|
+
let compileCommand = `yarn exec tsc -p tsconfig-cjs.json`;
|
|
1782
|
+
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath }).then(res => {
|
|
1783
|
+
return res === '';
|
|
1784
|
+
}).catch(err => {
|
|
1785
|
+
return {
|
|
1786
|
+
error: err.stdout,
|
|
1787
|
+
};
|
|
1788
|
+
});
|
|
1789
|
+
};
|
|
1790
|
+
exports.compilePackageCJS = compilePackageCJS;
|
|
1540
1791
|
var publishUpdated = function (test = false) {
|
|
1541
1792
|
let packages = getLocalLincdModules();
|
|
1542
1793
|
var p = Promise.resolve('');
|
|
@@ -1753,16 +2004,26 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
|
|
|
1753
2004
|
// let packages = getLocalLincdModules();
|
|
1754
2005
|
let packages = getLocalLincdPackageMap();
|
|
1755
2006
|
// console.log(packages);
|
|
1756
|
-
let jsonldPkgUpdated = await
|
|
2007
|
+
// let jsonldPkgUpdated = await needsRebuilding(
|
|
2008
|
+
// packages.get('lincd-jsonld'),
|
|
2009
|
+
// useGitForLastModified,
|
|
2010
|
+
// );
|
|
1757
2011
|
// let cliPkgUpdated = await needsRebuilding(packages.get('lincd-cli'), useGitForLastModified);
|
|
1758
2012
|
//if either cli or jsonldPkg needs to be rebuilt
|
|
1759
2013
|
// if (jsonldPkgUpdated || cliPkgUpdated) {
|
|
1760
|
-
if (jsonldPkgUpdated)
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
2014
|
+
// if (jsonldPkgUpdated)
|
|
2015
|
+
// {
|
|
2016
|
+
// await execPromise(
|
|
2017
|
+
// 'yarn exec tsc && echo "compiled lincd-jsonld"',
|
|
2018
|
+
// false,
|
|
2019
|
+
// false,
|
|
2020
|
+
// {
|
|
2021
|
+
// cwd: packages.get('lincd-jsonld').path,
|
|
2022
|
+
// },
|
|
2023
|
+
// true,
|
|
2024
|
+
// );
|
|
2025
|
+
// // await execPromise('yarn build-core', false, false, {}, true);
|
|
2026
|
+
// }
|
|
1766
2027
|
let rebuildAllModules = false;
|
|
1767
2028
|
// if (cliPkgUpdated) {
|
|
1768
2029
|
// rebuildAllModules = true;
|
|
@@ -1776,9 +2037,10 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
|
|
|
1776
2037
|
return async (pkg) => {
|
|
1777
2038
|
// debugInfo('# Checking package ' + pkg.packageName);
|
|
1778
2039
|
let needRebuild = await (0, utils_js_1.needsRebuilding)(pkg, useGitForLastModified);
|
|
1779
|
-
if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated)
|
|
1780
|
-
|
|
1781
|
-
|
|
2040
|
+
// if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated)
|
|
2041
|
+
// {
|
|
2042
|
+
// needRebuild = true;
|
|
2043
|
+
// }
|
|
1782
2044
|
if (needRebuild || rebuildAllModules) {
|
|
1783
2045
|
//TODO: when building a pkg, also rebuild all packages that depend on this package.. and iteratively build packages that depend on those packages..
|
|
1784
2046
|
// log(packageName+' modified since last commit on '+now.toString());
|
|
@@ -1957,13 +2219,14 @@ var executeCommandForPackage = function (packageName, command) {
|
|
|
1957
2219
|
if (packageDetails) {
|
|
1958
2220
|
log('Executing \'cd ' +
|
|
1959
2221
|
packageDetails.path +
|
|
1960
|
-
' && yarn
|
|
2222
|
+
' && yarn lincd' +
|
|
1961
2223
|
(command ? ' ' + command : '') +
|
|
1962
2224
|
'\'');
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
2225
|
+
(0, child_process_2.spawn)(process.platform === 'win32' ? 'yarn.cmd' : 'yarn', // Windows quirk
|
|
2226
|
+
['lincd', command || null], {
|
|
2227
|
+
cwd: packageDetails.path,
|
|
2228
|
+
stdio: 'inherit',
|
|
2229
|
+
});
|
|
1967
2230
|
}
|
|
1968
2231
|
else {
|
|
1969
2232
|
warn('Could not find a pkg who\'s name (partially) matched ' +
|