lincd-cli 1.2.0 → 1.2.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/defaults/app-with-backend/.eslintignore +3 -1
- package/defaults/app-with-backend/lincd.config.js +1 -3
- package/defaults/app-with-backend/package.json +6 -15
- 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 +1 -0
- 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 +2 -3
- package/defaults/app-with-backend/src/routes.tsx +8 -7
- package/defaults/app-with-backend/src/theme.css +100 -0
- package/defaults/app-with-backend/tsconfig.json +8 -5
- package/defaults/package/src/ontologies/example-ontology.ts +1 -1
- package/lib/cjs/cli-methods.js +174 -85
- package/lib/cjs/cli-methods.js.map +1 -1
- package/lib/cjs/cli.js +6 -0
- 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 +250 -108
- package/lib/cjs/config-webpack-app.js.map +1 -1
- package/lib/cjs/config-webpack.js +29 -21
- 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 +11 -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 +91 -36
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/cli-methods.js +164 -85
- package/lib/esm/cli-methods.js.map +1 -1
- package/lib/esm/cli.js +6 -0
- 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 +232 -98
- package/lib/esm/config-webpack-app.js.map +1 -1
- package/lib/esm/config-webpack.js +11 -12
- 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 +11 -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 +61 -19
- 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 +14 -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/lib/cjs/cli-methods.js
CHANGED
|
@@ -15,18 +15,32 @@ 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.buildApp = exports.startServer = exports.ensureEnvironmentLoaded = exports.depCheck = exports.depCheckStaged = exports.checkImports = exports.createComponent = exports.createSetComponent = exports.createShape = exports.getScriptDir = exports.setNameVariables = exports.createOntology = 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.buildApp = exports.startServer = 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.buildAll = buildAll;
|
|
43
|
+
exports.getLincdPackages = getLincdPackages;
|
|
30
44
|
const chalk_1 = __importDefault(require("chalk"));
|
|
31
45
|
const child_process_1 = require("child_process");
|
|
32
46
|
const depcheck_1 = __importDefault(require("depcheck"));
|
|
@@ -44,6 +58,8 @@ const glob_1 = require("glob");
|
|
|
44
58
|
const webpack_1 = __importDefault(require("webpack"));
|
|
45
59
|
const staged_git_files_1 = __importDefault(require("staged-git-files"));
|
|
46
60
|
const ora_1 = __importDefault(require("ora"));
|
|
61
|
+
//@ts-ignore
|
|
62
|
+
let dirname__ = typeof __dirname !== 'undefined' ? __dirname : (0, path_1.dirname)(import.meta.url).replace('file:/', '');
|
|
47
63
|
var variables = {};
|
|
48
64
|
const createApp = async (name, basePath = process.cwd()) => {
|
|
49
65
|
if (!name) {
|
|
@@ -54,7 +70,7 @@ const createApp = async (name, basePath = process.cwd()) => {
|
|
|
54
70
|
if (!fs_extra_1.default.existsSync(targetFolder)) {
|
|
55
71
|
fs_extra_1.default.mkdirSync(targetFolder);
|
|
56
72
|
}
|
|
57
|
-
fs_extra_1.default.copySync(path_1.default.join(
|
|
73
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'app-with-backend'), targetFolder);
|
|
58
74
|
//make sure the data folder exists (even though its empty).. copying empty folders does not work with fs.copySync
|
|
59
75
|
fs_extra_1.default.mkdirSync(path_1.default.join(targetFolder, 'data'), { recursive: true });
|
|
60
76
|
fs_extra_1.default.mkdirSync(path_1.default.join(targetFolder, 'data/uploads/resized'), {
|
|
@@ -94,7 +110,6 @@ function warn(...messages) {
|
|
|
94
110
|
// console.log(chalk.red(message));
|
|
95
111
|
});
|
|
96
112
|
}
|
|
97
|
-
exports.warn = warn;
|
|
98
113
|
function developPackage(target, mode) {
|
|
99
114
|
if (!target)
|
|
100
115
|
target = 'es6';
|
|
@@ -120,7 +135,6 @@ function developPackage(target, mode) {
|
|
|
120
135
|
console.warn('unknown build target. Use es5 or es6');
|
|
121
136
|
}
|
|
122
137
|
}
|
|
123
|
-
exports.developPackage = developPackage;
|
|
124
138
|
function checkWorkspaces(rootPath, workspaces, res) {
|
|
125
139
|
// console.log('checking workspaces at '+rootPath+": "+workspaces.toString());
|
|
126
140
|
if (workspaces.packages) {
|
|
@@ -546,7 +560,6 @@ function buildAll(options) {
|
|
|
546
560
|
}
|
|
547
561
|
}, sync);
|
|
548
562
|
}
|
|
549
|
-
exports.buildAll = buildAll;
|
|
550
563
|
function getDependentPackages(dependencies, pkg) {
|
|
551
564
|
let dependentModules = [];
|
|
552
565
|
dependencies.forEach((dModuleDependencies, dModule) => {
|
|
@@ -597,7 +610,6 @@ function getLincdPackages(rootPath = process.cwd()) {
|
|
|
597
610
|
checkWorkspaces(rootPath, pack.workspaces, res);
|
|
598
611
|
return res;
|
|
599
612
|
}
|
|
600
|
-
exports.getLincdPackages = getLincdPackages;
|
|
601
613
|
function setVariable(name, replacement) {
|
|
602
614
|
//prepare name for regexp
|
|
603
615
|
name = name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
@@ -645,18 +657,18 @@ const createOntology = async (prefix, uriBase, basePath = process.cwd()) => {
|
|
|
645
657
|
//copy ontology accessor file
|
|
646
658
|
log('Creating files for ontology \'' + prefix + '\'');
|
|
647
659
|
let targetFile = path_1.default.join(targetFolder, hyphenName + '.ts');
|
|
648
|
-
fs_extra_1.default.copySync(path_1.default.join(
|
|
660
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
|
|
649
661
|
//copy data files
|
|
650
662
|
let targetDataFile = path_1.default.join(targetFolder, '..', 'data', hyphenName + '.json');
|
|
651
663
|
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(
|
|
664
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json'), targetDataFile);
|
|
665
|
+
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
|
|
654
666
|
await replaceVariablesInFiles(targetFile, targetDataFile, targetDataFile2);
|
|
655
667
|
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
668
|
//if this is not a lincd app (but a lincd package instead)
|
|
657
669
|
if (!sourceFolder.includes('frontend')) {
|
|
658
670
|
//then also add an import to index
|
|
659
|
-
let indexPath = addLineToIndex(`import './ontologies/${hyphenName}';`, 'ontologies');
|
|
671
|
+
let indexPath = addLineToIndex(`import './ontologies/${hyphenName}.js';`, 'ontologies');
|
|
660
672
|
log(`Added an import of this file from ${chalk_1.default.magenta(indexPath)}`);
|
|
661
673
|
}
|
|
662
674
|
};
|
|
@@ -778,15 +790,18 @@ function getSourceFolder(basePath = process.cwd()) {
|
|
|
778
790
|
* get __dirname for either ESM/CJS
|
|
779
791
|
*/
|
|
780
792
|
const getScriptDir = () => {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
793
|
+
return dirname__;
|
|
794
|
+
// // @ts-ignore
|
|
795
|
+
// if (typeof __dirname !== 'undefined')
|
|
796
|
+
// {
|
|
797
|
+
// // @ts-ignore
|
|
798
|
+
// return __dirname;
|
|
799
|
+
// }
|
|
800
|
+
// else
|
|
801
|
+
// {
|
|
802
|
+
// // @ts-ignore
|
|
803
|
+
// return dirname(import.meta.url).replace('file:/','');
|
|
804
|
+
// }
|
|
790
805
|
};
|
|
791
806
|
exports.getScriptDir = getScriptDir;
|
|
792
807
|
const createShape = async (name, basePath = process.cwd()) => {
|
|
@@ -803,7 +818,7 @@ const createShape = async (name, basePath = process.cwd()) => {
|
|
|
803
818
|
//if this is NOT a lincd app (but a lincd package)
|
|
804
819
|
let indexPath;
|
|
805
820
|
if (!sourceFolder.includes('frontend')) {
|
|
806
|
-
indexPath = addLineToIndex(`import './shapes/${hyphenName}';`, 'shapes');
|
|
821
|
+
indexPath = addLineToIndex(`import './shapes/${hyphenName}.js';`, 'shapes');
|
|
807
822
|
log(`Added an import of this file from ${chalk_1.default.magenta(indexPath)}`);
|
|
808
823
|
}
|
|
809
824
|
};
|
|
@@ -819,7 +834,7 @@ const createSetComponent = async (name, basePath = process.cwd()) => {
|
|
|
819
834
|
fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'component.scss'), targetFile2);
|
|
820
835
|
//replace variables in some of the copied files
|
|
821
836
|
await replaceVariablesInFiles(targetFile, targetFile2);
|
|
822
|
-
let indexPath = addLineToIndex(`import './components/${hyphenName}';`, 'components');
|
|
837
|
+
let indexPath = addLineToIndex(`import './components/${hyphenName}.js';`, 'components');
|
|
823
838
|
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
839
|
};
|
|
825
840
|
exports.createSetComponent = createSetComponent;
|
|
@@ -839,15 +854,15 @@ const createComponent = async (name, basePath = process.cwd()) => {
|
|
|
839
854
|
//if this is not a lincd app (but a lincd package instead)
|
|
840
855
|
if (!sourceFolder.includes('frontend')) {
|
|
841
856
|
//then also add an import to index
|
|
842
|
-
let indexPath = addLineToIndex(`import './components/${hyphenName}';`, 'components');
|
|
857
|
+
let indexPath = addLineToIndex(`import './components/${hyphenName}.js';`, 'components');
|
|
843
858
|
log(`Added an import of this file from ${chalk_1.default.magenta(indexPath)}`);
|
|
844
859
|
}
|
|
845
860
|
};
|
|
846
861
|
exports.createComponent = createComponent;
|
|
847
862
|
//read the source of all ts/tsx files in the src folder
|
|
848
863
|
//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
|
|
864
|
+
//if there is an import that imports something from outside the src folder, then warn
|
|
865
|
+
const checkImports = async (sourceFolder = getSourceFolder(), depth = 0, // Used to check if the import is outside the src folder
|
|
851
866
|
invalidImports = new Map()) => {
|
|
852
867
|
const dir = fs_extra_1.default.readdirSync(sourceFolder);
|
|
853
868
|
// Start checking each file in the source folder
|
|
@@ -857,40 +872,66 @@ invalidImports = new Map()) => {
|
|
|
857
872
|
// INFO: For future use - if this part fails, it could be due to user permissions
|
|
858
873
|
// i.e. the program not having access to check the file metadata
|
|
859
874
|
if (!filename.match(/\.tsx?$/)) {
|
|
860
|
-
|
|
861
|
-
|
|
875
|
+
try {
|
|
876
|
+
if ((0, fs_1.statSync)(filename).isDirectory()) {
|
|
877
|
+
await (0, exports.checkImports)(filename, depth + 1, invalidImports);
|
|
878
|
+
}
|
|
879
|
+
else {
|
|
880
|
+
// Ignore all files that aren't one of the following:
|
|
881
|
+
// - .ts
|
|
882
|
+
// - .tsx
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
catch (e) {
|
|
887
|
+
console.log(e);
|
|
862
888
|
}
|
|
863
|
-
// Ignore all files that aren't one of the following:
|
|
864
|
-
// - .ts
|
|
865
|
-
// - .tsx
|
|
866
|
-
continue;
|
|
867
889
|
}
|
|
868
890
|
const allImports = await (0, utils_js_1.getFileImports)(filename);
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
891
|
+
if (!invalidImports.has(filename)) {
|
|
892
|
+
invalidImports.set(filename, []);
|
|
893
|
+
}
|
|
894
|
+
allImports.forEach((i) => {
|
|
895
|
+
if ((0, utils_js_1.isImportOutsideOfPackage)(i, depth)) {
|
|
896
|
+
invalidImports.get(filename).push({
|
|
897
|
+
type: 'outside_package',
|
|
898
|
+
importPath: i
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
if ((0, utils_js_1.isInvalidLINCDImport)(i, depth)) {
|
|
902
|
+
invalidImports.get(filename).push({
|
|
903
|
+
type: 'lincd',
|
|
904
|
+
importPath: i
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
if ((0, utils_js_1.isImportWithMissingExtension)(i)) {
|
|
908
|
+
invalidImports.get(filename).push({
|
|
909
|
+
type: 'missing_extension',
|
|
910
|
+
importPath: i
|
|
911
|
+
});
|
|
876
912
|
}
|
|
877
913
|
});
|
|
878
914
|
}
|
|
879
915
|
let res = '';
|
|
916
|
+
//check if invalidImports has any
|
|
917
|
+
let flat = [...invalidImports.values()].flat();
|
|
880
918
|
// All recursion must have finished, display any errors
|
|
881
|
-
if (depth === 0 &&
|
|
919
|
+
if (depth === 0 && flat.length > 0) {
|
|
882
920
|
res += chalk_1.default.red('Invalid imports found.\n');
|
|
883
921
|
invalidImports.forEach((value, key) => {
|
|
884
922
|
// res += '- '+chalk.blueBright(key.split('/').pop()) + ':\n';
|
|
885
|
-
value.forEach((
|
|
886
|
-
|
|
887
|
-
if (
|
|
888
|
-
|
|
889
|
-
'To fix: import from the NPM package directly.\n';
|
|
923
|
+
value.forEach(({ type, importPath }) => {
|
|
924
|
+
let message = key.split('/').pop() + ' imports from \'' + importPath + '\'';
|
|
925
|
+
if (type === 'outside_package') {
|
|
926
|
+
message += ' which is outside the package source root';
|
|
890
927
|
}
|
|
891
|
-
|
|
892
|
-
|
|
928
|
+
if (type === 'lincd') {
|
|
929
|
+
message += ' which should not contain /src/ or /lib/ in the import path';
|
|
893
930
|
}
|
|
931
|
+
if (type === 'missing_extension') {
|
|
932
|
+
message += ' which should end with a file extension. Like .js or .scss';
|
|
933
|
+
}
|
|
934
|
+
res += chalk_1.default.red(message + '\n');
|
|
894
935
|
});
|
|
895
936
|
});
|
|
896
937
|
throw res;
|
|
@@ -1015,9 +1056,8 @@ const ensureEnvironmentLoaded = async () => {
|
|
|
1015
1056
|
};
|
|
1016
1057
|
exports.ensureEnvironmentLoaded = ensureEnvironmentLoaded;
|
|
1017
1058
|
const startServer = async (initOnly = false, ServerClass = null) => {
|
|
1018
|
-
var _a, _b;
|
|
1019
1059
|
await (0, exports.ensureEnvironmentLoaded)();
|
|
1020
|
-
let lincdConfig = await (
|
|
1060
|
+
let lincdConfig = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lincd.config.js')}`).then(s => __importStar(require(s)))).default;
|
|
1021
1061
|
// function scssLoadcall(source, filename) {
|
|
1022
1062
|
// return 'console.log("SCSS CALL: ' + filename + '");\n' + source;
|
|
1023
1063
|
// process.exit();
|
|
@@ -1032,9 +1072,9 @@ const startServer = async (initOnly = false, ServerClass = null) => {
|
|
|
1032
1072
|
//@ts-ignore
|
|
1033
1073
|
ServerClass = (await Promise.resolve().then(() => __importStar(require('lincd-server/shapes/LincdServer')))).LincdServer;
|
|
1034
1074
|
}
|
|
1035
|
-
await (
|
|
1075
|
+
await Promise.resolve(`${path_1.default.join(process.cwd(), 'scripts', 'storage-config.js')}`).then(s => __importStar(require(s)));
|
|
1036
1076
|
let server = new ServerClass({
|
|
1037
|
-
loadAppComponent: async () =>
|
|
1077
|
+
loadAppComponent: async () => (await Promise.resolve(`${path_1.default.join(process.cwd(), 'src', 'App')}`).then(s => __importStar(require(s)))).default,
|
|
1038
1078
|
...lincdConfig,
|
|
1039
1079
|
});
|
|
1040
1080
|
//Important to use slice, because when using clusers, child processes need to be able to read the same arguments
|
|
@@ -1086,7 +1126,6 @@ const buildApp = async () => {
|
|
|
1086
1126
|
// process.exit();
|
|
1087
1127
|
});
|
|
1088
1128
|
}).then(async () => {
|
|
1089
|
-
var _a;
|
|
1090
1129
|
// make sure environment is not development for storage config
|
|
1091
1130
|
// and if we want to upload to storage, we need set S3_BUCKET_ENDPOINT
|
|
1092
1131
|
if (process.env.NODE_ENV === 'development' || !process.env.S3_BUCKET_ENDPOINT) {
|
|
@@ -1098,7 +1137,7 @@ const buildApp = async () => {
|
|
|
1098
1137
|
process.exit();
|
|
1099
1138
|
}
|
|
1100
1139
|
// load the storage config
|
|
1101
|
-
const storageConfig = await (
|
|
1140
|
+
const storageConfig = await Promise.resolve(`${path_1.default.join(process.cwd(), 'scripts', 'storage-config.js')}`).then(s => __importStar(require(s)));
|
|
1102
1141
|
// check if LincdFileStorage has a default FileStore
|
|
1103
1142
|
// if yes: copy all the files in the build folder over with LincdFileStorage
|
|
1104
1143
|
if (LinkedFileStorage_1.LinkedFileStorage.getDefaultStore()) {
|
|
@@ -1411,25 +1450,30 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1411
1450
|
//TODO: replace with listr so we can show multiple processes at once
|
|
1412
1451
|
spinner = (0, ora_1.default)({
|
|
1413
1452
|
discardStdin: true,
|
|
1414
|
-
text: 'Compiling
|
|
1453
|
+
text: 'Compiling ESM',
|
|
1415
1454
|
}).start();
|
|
1416
1455
|
}
|
|
1417
1456
|
let buildProcess = Promise.resolve(true);
|
|
1418
1457
|
let buildStep = (step) => {
|
|
1419
1458
|
buildProcess = buildProcess.then((previousResult) => {
|
|
1459
|
+
if (!previousResult) {
|
|
1460
|
+
return false;
|
|
1461
|
+
}
|
|
1420
1462
|
if (logResults) {
|
|
1421
1463
|
spinner.text = step.name;
|
|
1422
1464
|
spinner.start();
|
|
1423
1465
|
}
|
|
1424
1466
|
return step.apply().then(stepResult => {
|
|
1467
|
+
//if a build step returns a string,
|
|
1468
|
+
//a warning is shown but the build is still successful with warnings
|
|
1425
1469
|
if (typeof stepResult === 'string') {
|
|
1426
1470
|
// spinner.text = step.name + ' - ' + stepResult;
|
|
1427
1471
|
if (logResults) {
|
|
1428
1472
|
spinner.warn(step.name + ' - ' + stepResult);
|
|
1429
1473
|
spinner.stop();
|
|
1430
1474
|
}
|
|
1431
|
-
//
|
|
1432
|
-
return
|
|
1475
|
+
//can still continue
|
|
1476
|
+
return true;
|
|
1433
1477
|
}
|
|
1434
1478
|
else if (stepResult === true || typeof stepResult === 'undefined') {
|
|
1435
1479
|
if (logResults) {
|
|
@@ -1437,13 +1481,27 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1437
1481
|
}
|
|
1438
1482
|
return previousResult && true;
|
|
1439
1483
|
}
|
|
1484
|
+
else if (typeof stepResult === 'object' && stepResult.error) {
|
|
1485
|
+
if (logResults) {
|
|
1486
|
+
spinner.fail(step.name + ' - ' + stepResult.error);
|
|
1487
|
+
spinner.stop();
|
|
1488
|
+
}
|
|
1489
|
+
//failed and should stop
|
|
1490
|
+
return false;
|
|
1491
|
+
}
|
|
1440
1492
|
});
|
|
1441
1493
|
});
|
|
1442
1494
|
};
|
|
1443
1495
|
buildStep({
|
|
1444
|
-
name: 'Compiling
|
|
1496
|
+
name: 'Compiling ESM',
|
|
1497
|
+
apply: async () => {
|
|
1498
|
+
return (0, exports.compilePackageESM)(packagePath);
|
|
1499
|
+
},
|
|
1500
|
+
});
|
|
1501
|
+
buildStep({
|
|
1502
|
+
name: 'Compiling CJS',
|
|
1445
1503
|
apply: async () => {
|
|
1446
|
-
return (0, exports.
|
|
1504
|
+
return (0, exports.compilePackageCJS)(packagePath);
|
|
1447
1505
|
},
|
|
1448
1506
|
});
|
|
1449
1507
|
buildStep({
|
|
@@ -1489,20 +1547,21 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1489
1547
|
apply: () => (0, exports.depCheck)(packagePath),
|
|
1490
1548
|
});
|
|
1491
1549
|
let success = await buildProcess.catch(err => {
|
|
1492
|
-
let msg = err.error ? err.error : err.stdout + '\n' + err.stderr;
|
|
1550
|
+
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
1551
|
if (logResults) {
|
|
1494
1552
|
spinner.stopAndPersist({
|
|
1495
1553
|
symbol: chalk_1.default.red('✖'),
|
|
1496
|
-
text: 'Build failed',
|
|
1554
|
+
// text: 'Build failed',
|
|
1497
1555
|
});
|
|
1498
1556
|
}
|
|
1499
1557
|
else {
|
|
1500
1558
|
console.log(chalk_1.default.red(packagePath.split('/').pop(), ' - Build failed:'));
|
|
1559
|
+
console.log(err);
|
|
1501
1560
|
}
|
|
1502
1561
|
console.log(msg);
|
|
1503
1562
|
});
|
|
1504
1563
|
//will be undefined if there was an error
|
|
1505
|
-
if (typeof success !== 'undefined') {
|
|
1564
|
+
if (typeof success !== 'undefined' && success !== false) {
|
|
1506
1565
|
if (logResults) {
|
|
1507
1566
|
spinner.stopAndPersist({
|
|
1508
1567
|
symbol: chalk_1.default.greenBright('✔'),
|
|
@@ -1510,33 +1569,61 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1510
1569
|
});
|
|
1511
1570
|
}
|
|
1512
1571
|
}
|
|
1572
|
+
else {
|
|
1573
|
+
spinner.stopAndPersist({
|
|
1574
|
+
symbol: chalk_1.default.red('✖'),
|
|
1575
|
+
text: 'Build failed',
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1513
1578
|
return success;
|
|
1514
1579
|
};
|
|
1515
1580
|
exports.buildPackage = buildPackage;
|
|
1516
1581
|
const compilePackage = async (packagePath = process.cwd()) => {
|
|
1517
1582
|
//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
|
-
}
|
|
1583
|
+
// let cjsConfig = fs.existsSync(path.join(packagePath,'tsconfig-cjs.json'));
|
|
1584
|
+
// let esmConfig = fs.existsSync(path.join(packagePath,'tsconfig-esm.json'));
|
|
1585
|
+
// let compileCJS = `yarn exec tsc -p tsconfig-cjs.json`;
|
|
1586
|
+
// let compileESM = `yarn exec tsc -p tsconfig-esm.json`;
|
|
1587
|
+
// let compileCommand;
|
|
1588
|
+
// if (cjsConfig && esmConfig)
|
|
1589
|
+
// {
|
|
1590
|
+
// compileCommand = `${compileCJS} && ${compileESM}`;
|
|
1591
|
+
// }
|
|
1592
|
+
// else if (cjsConfig)
|
|
1593
|
+
// {
|
|
1594
|
+
// compileCommand = compileCJS;
|
|
1595
|
+
// }
|
|
1596
|
+
// else if (esmConfig)
|
|
1597
|
+
// {
|
|
1598
|
+
// compileCommand = compileESM;
|
|
1599
|
+
// }
|
|
1600
|
+
// else
|
|
1601
|
+
// {
|
|
1602
|
+
// compileCommand = `yarn exec tsc`;
|
|
1603
|
+
// }
|
|
1604
|
+
await (0, exports.compilePackageESM)(packagePath);
|
|
1605
|
+
await (0, exports.compilePackageCJS)(packagePath);
|
|
1606
|
+
};
|
|
1607
|
+
exports.compilePackage = compilePackage;
|
|
1608
|
+
const compilePackageESM = async (packagePath = process.cwd()) => {
|
|
1609
|
+
//echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
|
|
1610
|
+
let compileCommand = `yarn exec tsc -p tsconfig-esm.json`;
|
|
1535
1611
|
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath }).then(res => {
|
|
1536
1612
|
return res === '';
|
|
1537
1613
|
});
|
|
1538
1614
|
};
|
|
1539
|
-
exports.
|
|
1615
|
+
exports.compilePackageESM = compilePackageESM;
|
|
1616
|
+
const compilePackageCJS = async (packagePath = process.cwd()) => {
|
|
1617
|
+
let compileCommand = `yarn exec tsc -p tsconfig-cjs.json`;
|
|
1618
|
+
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath }).then(res => {
|
|
1619
|
+
return res === '';
|
|
1620
|
+
}).catch(err => {
|
|
1621
|
+
return {
|
|
1622
|
+
error: err.stdout
|
|
1623
|
+
};
|
|
1624
|
+
});
|
|
1625
|
+
};
|
|
1626
|
+
exports.compilePackageCJS = compilePackageCJS;
|
|
1540
1627
|
var publishUpdated = function (test = false) {
|
|
1541
1628
|
let packages = getLocalLincdModules();
|
|
1542
1629
|
var p = Promise.resolve('');
|
|
@@ -1800,7 +1887,7 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
|
|
|
1800
1887
|
}
|
|
1801
1888
|
else if (typeof res === 'string') {
|
|
1802
1889
|
warn(chalk_1.default.red('Failed to build ' + pkg.packageName));
|
|
1803
|
-
console.log(res);
|
|
1890
|
+
// console.log(res);
|
|
1804
1891
|
process.exit(1);
|
|
1805
1892
|
}
|
|
1806
1893
|
})
|
|
@@ -1960,6 +2047,8 @@ var executeCommandForPackage = function (packageName, command) {
|
|
|
1960
2047
|
' && yarn exec lincd' +
|
|
1961
2048
|
(command ? ' ' + command : '') +
|
|
1962
2049
|
'\'');
|
|
2050
|
+
//TODO : replace with spawn("path to executable", ["params"], {stdio: "inherit"});
|
|
2051
|
+
// maybe make spawnPromise that returns a promise
|
|
1963
2052
|
return (0, utils_js_1.execp)('cd ' +
|
|
1964
2053
|
packageDetails.path +
|
|
1965
2054
|
' && yarn exec lincd' +
|