lincd-cli 1.2.2 → 1.2.4
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/package/src/backend.ts +2 -1
- package/defaults/package/src/types.ts +0 -5
- package/lib/cjs/cli-methods.d.ts.map +1 -0
- package/lib/cjs/cli-methods.js +283 -123
- package/lib/cjs/cli-methods.js.map +1 -1
- package/lib/cjs/cli.d.ts.map +1 -0
- package/lib/cjs/config-grunt.cjs +1 -1
- package/lib/cjs/config-grunt.cjs.map +1 -1
- package/lib/cjs/config-grunt.d.cts +3 -0
- package/lib/cjs/config-grunt.d.cts.map +1 -0
- package/lib/cjs/config-webpack-app.d.ts.map +1 -0
- package/lib/cjs/config-webpack-app.js +154 -257
- package/lib/cjs/config-webpack-app.js.map +1 -1
- package/lib/cjs/config-webpack.d.ts.map +1 -0
- package/lib/cjs/config-webpack.js +46 -82
- package/lib/cjs/config-webpack.js.map +1 -1
- package/lib/cjs/defineConfig.d.ts.map +1 -0
- package/lib/cjs/defineConfig.js +13 -0
- package/lib/cjs/defineConfig.js.map +1 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces.d.ts.map +1 -0
- package/lib/cjs/loaders/css-loader.d.mts +2 -0
- package/lib/cjs/loaders/css-loader.d.mts.map +1 -0
- package/lib/cjs/loaders/css-loader.mjs +22 -15
- package/lib/cjs/loaders/css-loader.mjs.map +1 -1
- package/lib/cjs/loaders/register-css-only.d.ts.map +1 -0
- package/lib/cjs/loaders/register-css-only.js +11 -0
- package/lib/cjs/loaders/register-css-only.js.map +1 -0
- package/lib/cjs/loaders/register.d.ts.map +1 -0
- package/lib/cjs/metadata.d.ts.map +1 -0
- package/lib/cjs/package.json +4 -5
- package/lib/cjs/plugins/check-imports.d.ts.map +1 -0
- 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.d.ts.map +1 -0
- package/lib/cjs/plugins/declaration-plugin.js +7 -17
- package/lib/cjs/plugins/declaration-plugin.js.map +1 -1
- package/lib/cjs/plugins/externalise-modules.d.ts.map +1 -0
- package/lib/cjs/plugins/lincd-tailwind-sources.d.ts.map +1 -0
- package/lib/cjs/plugins/watch-run.d.ts.map +1 -0
- package/lib/cjs/preflight.css +137 -0
- package/lib/cjs/tailwind.config.d.ts.map +1 -0
- package/lib/cjs/tailwind.config.js +3 -4
- package/lib/cjs/tailwind.config.js.map +1 -1
- package/lib/cjs/utils.d.ts.map +1 -0
- package/lib/cjs/utils.js +41 -38
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/cli-methods.d.ts.map +1 -0
- package/lib/esm/cli-methods.js +281 -107
- package/lib/esm/cli-methods.js.map +1 -1
- package/lib/esm/cli.d.ts.map +1 -0
- package/lib/esm/config-grunt.cjs +24 -27
- package/lib/esm/config-grunt.cjs.map +1 -1
- package/lib/esm/config-grunt.d.cts +3 -0
- package/lib/esm/config-grunt.d.cts.map +1 -0
- package/lib/esm/config-webpack-app.d.ts.map +1 -0
- package/lib/esm/config-webpack-app.js +148 -241
- package/lib/esm/config-webpack-app.js.map +1 -1
- package/lib/esm/config-webpack.d.ts.map +1 -0
- package/lib/esm/config-webpack.js +38 -65
- package/lib/esm/config-webpack.js.map +1 -1
- package/lib/esm/defineConfig.d.ts.map +1 -0
- package/lib/esm/defineConfig.js +9 -0
- package/lib/esm/defineConfig.js.map +1 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces.d.ts.map +1 -0
- package/lib/esm/loaders/css-loader.d.mts +2 -0
- package/lib/esm/loaders/css-loader.d.mts.map +1 -0
- package/lib/esm/loaders/css-loader.mjs +10 -10
- package/lib/esm/loaders/css-loader.mjs.map +1 -1
- package/lib/esm/loaders/register-css-only.d.ts.map +1 -0
- package/lib/esm/loaders/register-css-only.js +9 -0
- package/lib/esm/loaders/register-css-only.js.map +1 -0
- package/lib/esm/loaders/register.d.ts.map +1 -0
- package/lib/esm/metadata.d.ts.map +1 -0
- package/lib/esm/package.json +4 -5
- package/lib/esm/plugins/check-imports.d.ts.map +1 -0
- package/lib/esm/plugins/declaration-plugin.d.ts.map +1 -0
- package/lib/esm/plugins/externalise-modules.d.ts.map +1 -0
- package/lib/esm/plugins/lincd-tailwind-sources.d.ts.map +1 -0
- package/lib/esm/plugins/watch-run.d.ts.map +1 -0
- package/lib/esm/preflight.css +137 -0
- package/lib/esm/tailwind.config.d.ts.map +1 -0
- package/lib/esm/tailwind.config.js +3 -4
- package/lib/esm/tailwind.config.js.map +1 -1
- package/lib/esm/utils.d.ts.map +1 -0
- package/lib/esm/utils.js +21 -9
- package/lib/esm/utils.js.map +1 -1
- package/package.json +10 -5
- package/preflight.css +137 -0
package/lib/cjs/cli-methods.js
CHANGED
|
@@ -15,33 +15,18 @@ 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) ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
})();
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
35
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
27
|
};
|
|
38
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
29
|
+
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.getLincdPackages = exports.buildAll = exports.runOnPackagesGroupedByDependencies = exports.developPackage = exports.logError = exports.warn = exports.createApp = void 0;
|
|
45
30
|
const chalk_1 = __importDefault(require("chalk"));
|
|
46
31
|
const child_process_1 = require("child_process");
|
|
47
32
|
const depcheck_1 = __importDefault(require("depcheck"));
|
|
@@ -49,19 +34,21 @@ const get_env_vars_js_1 = require("env-cmd/dist/get-env-vars.js");
|
|
|
49
34
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
50
35
|
const path_1 = __importStar(require("path"));
|
|
51
36
|
const utils_js_1 = require("./utils.js");
|
|
52
|
-
const
|
|
37
|
+
const child_process_2 = require("child_process");
|
|
53
38
|
const find_nearest_package_json_1 = require("find-nearest-package-json");
|
|
39
|
+
const fs_1 = require("fs");
|
|
54
40
|
const LinkedFileStorage_1 = require("lincd/utils/LinkedFileStorage");
|
|
55
|
-
const child_process_2 = require("child_process");
|
|
56
41
|
// import pkg from 'lincd/utils/LinkedFileStorage';
|
|
57
42
|
// const { LinkedFileStorage } = pkg;
|
|
58
43
|
// const config = require('lincd-server/site.webpack.config');
|
|
59
44
|
const glob_1 = require("glob");
|
|
60
45
|
const webpack_1 = __importDefault(require("webpack"));
|
|
61
|
-
const staged_git_files_1 = __importDefault(require("staged-git-files"));
|
|
62
46
|
const ora_1 = __importDefault(require("ora"));
|
|
63
|
-
|
|
64
|
-
let dirname__ = typeof __dirname !== 'undefined'
|
|
47
|
+
const staged_git_files_1 = __importDefault(require("staged-git-files"));
|
|
48
|
+
let dirname__ = typeof __dirname !== 'undefined'
|
|
49
|
+
? __dirname
|
|
50
|
+
: //@ts-ignore
|
|
51
|
+
(0, path_1.dirname)(import.meta.url).replace('file:/', '');
|
|
65
52
|
var variables = {};
|
|
66
53
|
const createApp = async (name, basePath = process.cwd()) => {
|
|
67
54
|
if (!name) {
|
|
@@ -81,7 +68,7 @@ const createApp = async (name, basePath = process.cwd()) => {
|
|
|
81
68
|
fs_extra_1.default.renameSync(path_1.default.join(targetFolder, 'gitignore.template'), path_1.default.join(targetFolder, '.gitignore'));
|
|
82
69
|
fs_extra_1.default.renameSync(path_1.default.join(targetFolder, 'yarnrc.yml.template'), path_1.default.join(targetFolder, '.yarnrc.yml'));
|
|
83
70
|
// fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
|
|
84
|
-
log(
|
|
71
|
+
log("Creating new LINCD application '" + name + "'");
|
|
85
72
|
//replace variables in some copied files
|
|
86
73
|
await replaceVariablesInFolder(targetFolder);
|
|
87
74
|
let hasYarn = await hasYarnInstalled();
|
|
@@ -108,10 +95,17 @@ function progressUpdate(message) {
|
|
|
108
95
|
}
|
|
109
96
|
function warn(...messages) {
|
|
110
97
|
messages.forEach((message) => {
|
|
111
|
-
console.
|
|
98
|
+
console.warn(chalk_1.default.redBright('Warning: ') + message);
|
|
112
99
|
// console.log(chalk.red(message));
|
|
113
100
|
});
|
|
114
101
|
}
|
|
102
|
+
exports.warn = warn;
|
|
103
|
+
function logError(...messages) {
|
|
104
|
+
messages.forEach((message) => {
|
|
105
|
+
console.error(chalk_1.default.redBright('Error: ') + message);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
exports.logError = logError;
|
|
115
109
|
function developPackage(target, mode) {
|
|
116
110
|
if (!target)
|
|
117
111
|
target = 'es6';
|
|
@@ -137,6 +131,7 @@ function developPackage(target, mode) {
|
|
|
137
131
|
console.warn('unknown build target. Use es5 or es6');
|
|
138
132
|
}
|
|
139
133
|
}
|
|
134
|
+
exports.developPackage = developPackage;
|
|
140
135
|
function checkWorkspaces(rootPath, workspaces, res) {
|
|
141
136
|
// console.log('checking workspaces at '+rootPath+": "+workspaces.toString());
|
|
142
137
|
if (workspaces.packages) {
|
|
@@ -328,6 +323,7 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
|
|
|
328
323
|
//starts the process
|
|
329
324
|
runStack(startStack);
|
|
330
325
|
}
|
|
326
|
+
exports.runOnPackagesGroupedByDependencies = runOnPackagesGroupedByDependencies;
|
|
331
327
|
function hasDependency(pkg, childPkg, dependencies, depth = 1) {
|
|
332
328
|
console.log('Does ' + pkg.packageName + ' have dep ' + childPkg.packageName + ' ?');
|
|
333
329
|
let deps = dependencies.get(pkg);
|
|
@@ -345,9 +341,121 @@ function hasDependency(pkg, childPkg, dependencies, depth = 1) {
|
|
|
345
341
|
console.log('going up');
|
|
346
342
|
return false;
|
|
347
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* Finds the topmost package.json that could be an APP_ROOT
|
|
346
|
+
* Returns null if no app root is found (standalone repo case)
|
|
347
|
+
*/
|
|
348
|
+
function findAppRoot(startPath = process.cwd()) {
|
|
349
|
+
let currentPath = startPath;
|
|
350
|
+
let candidateRoots = [];
|
|
351
|
+
// Walk up the directory tree
|
|
352
|
+
for (let i = 0; i < 10; i++) {
|
|
353
|
+
const packageJsonPath = path_1.default.join(currentPath, 'package.json');
|
|
354
|
+
if (fs_extra_1.default.existsSync(packageJsonPath)) {
|
|
355
|
+
const packageJson = JSON.parse(fs_extra_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
356
|
+
candidateRoots.push({
|
|
357
|
+
path: currentPath,
|
|
358
|
+
hasWorkspaces: !!packageJson.workspaces,
|
|
359
|
+
isLincd: packageJson.lincd === true,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
const parentPath = path_1.default.join(currentPath, '..');
|
|
363
|
+
// If we've reached the root or haven't moved up
|
|
364
|
+
if (parentPath === currentPath) {
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
currentPath = parentPath;
|
|
368
|
+
}
|
|
369
|
+
// Find the topmost package.json that has workspaces
|
|
370
|
+
// Prefer non-lincd packages (app roots) over lincd packages
|
|
371
|
+
let appRoot = null;
|
|
372
|
+
for (let i = candidateRoots.length - 1; i >= 0; i--) {
|
|
373
|
+
const candidate = candidateRoots[i];
|
|
374
|
+
if (candidate.hasWorkspaces && !candidate.isLincd) {
|
|
375
|
+
appRoot = candidate.path;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// If no non-lincd workspace found, use the topmost workspace
|
|
380
|
+
if (!appRoot) {
|
|
381
|
+
for (let i = candidateRoots.length - 1; i >= 0; i--) {
|
|
382
|
+
if (candidateRoots[i].hasWorkspaces) {
|
|
383
|
+
appRoot = candidateRoots[i].path;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return appRoot;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Filters packages to only include those in the dependency tree of the app root
|
|
392
|
+
*/
|
|
393
|
+
function filterPackagesByDependencyTree(allPackages, appRootPath) {
|
|
394
|
+
const appPackageJson = (0, utils_js_1.getPackageJSON)(appRootPath);
|
|
395
|
+
if (!appPackageJson) {
|
|
396
|
+
return allPackages;
|
|
397
|
+
}
|
|
398
|
+
const relevantPackages = new Map();
|
|
399
|
+
const packagesToCheck = new Set();
|
|
400
|
+
// Start with direct dependencies from app root
|
|
401
|
+
if (appPackageJson.dependencies) {
|
|
402
|
+
Object.keys(appPackageJson.dependencies).forEach((dep) => {
|
|
403
|
+
if (allPackages.has(dep)) {
|
|
404
|
+
packagesToCheck.add(dep);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
// Recursively add dependencies
|
|
409
|
+
const processedPackages = new Set();
|
|
410
|
+
while (packagesToCheck.size > 0) {
|
|
411
|
+
const packageName = Array.from(packagesToCheck)[0];
|
|
412
|
+
packagesToCheck.delete(packageName);
|
|
413
|
+
if (processedPackages.has(packageName)) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
processedPackages.add(packageName);
|
|
417
|
+
const packageDetails = allPackages.get(packageName);
|
|
418
|
+
if (packageDetails) {
|
|
419
|
+
relevantPackages.set(packageName, packageDetails);
|
|
420
|
+
// Get this package's dependencies
|
|
421
|
+
const packageJson = (0, utils_js_1.getPackageJSON)(packageDetails.path);
|
|
422
|
+
if (packageJson && packageJson.dependencies) {
|
|
423
|
+
Object.keys(packageJson.dependencies).forEach((dep) => {
|
|
424
|
+
if (allPackages.has(dep) && !processedPackages.has(dep)) {
|
|
425
|
+
packagesToCheck.add(dep);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return relevantPackages;
|
|
432
|
+
}
|
|
348
433
|
function buildAll(options) {
|
|
349
434
|
console.log('Building all LINCD packages of this repository in order of dependencies');
|
|
350
435
|
let lincdPackages = getLocalLincdPackageMap();
|
|
436
|
+
const originalPackageCount = lincdPackages.size;
|
|
437
|
+
// Check if we're in an app context and filter packages accordingly
|
|
438
|
+
const appRoot = findAppRoot();
|
|
439
|
+
if (appRoot) {
|
|
440
|
+
const appPackageJson = (0, utils_js_1.getPackageJSON)(appRoot);
|
|
441
|
+
// Check if this is an app (not a lincd package itself) with lincd dependencies
|
|
442
|
+
const isAppWithLincdDeps = appPackageJson &&
|
|
443
|
+
appPackageJson.lincd !== true &&
|
|
444
|
+
appPackageJson.dependencies &&
|
|
445
|
+
Object.keys(appPackageJson.dependencies).some((dep) => lincdPackages.has(dep));
|
|
446
|
+
if (isAppWithLincdDeps) {
|
|
447
|
+
(0, utils_js_1.debugInfo)(chalk_1.default.blue(`Found app root at: ${appRoot}`));
|
|
448
|
+
const filteredPackages = filterPackagesByDependencyTree(lincdPackages, appRoot);
|
|
449
|
+
console.log(chalk_1.default.magenta(`Found ${originalPackageCount} total LINCD packages, building only ${filteredPackages.size} that are relevant to this app`));
|
|
450
|
+
lincdPackages = filteredPackages;
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
(0, utils_js_1.debugInfo)(chalk_1.default.blue(`Building all ${originalPackageCount} packages from workspace`));
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
(0, utils_js_1.debugInfo)(chalk_1.default.blue(`No workspace root found, building all ${originalPackageCount} packages`));
|
|
458
|
+
}
|
|
351
459
|
let startFrom;
|
|
352
460
|
//by default start building
|
|
353
461
|
let building = true;
|
|
@@ -421,7 +529,8 @@ function buildAll(options) {
|
|
|
421
529
|
log(chalk_1.default.cyan('Building ' + pkg.packageName));
|
|
422
530
|
process.stdout.write(packagesLeft + ' packages left\r');
|
|
423
531
|
}
|
|
424
|
-
return command
|
|
532
|
+
return command
|
|
533
|
+
.then((res) => {
|
|
425
534
|
//empty string or true is success
|
|
426
535
|
//false is success with warnings
|
|
427
536
|
//any other string is the build error text
|
|
@@ -445,7 +554,8 @@ function buildAll(options) {
|
|
|
445
554
|
}
|
|
446
555
|
else {
|
|
447
556
|
if (!skipping) {
|
|
448
|
-
log(chalk_1.default.green('Built ' + pkg.packageName) +
|
|
557
|
+
log(chalk_1.default.green('Built ' + pkg.packageName) +
|
|
558
|
+
(res === false ? chalk_1.default.redBright(' (with warnings)') : ''));
|
|
449
559
|
}
|
|
450
560
|
done.add(pkg);
|
|
451
561
|
packagesLeft--;
|
|
@@ -461,7 +571,7 @@ function buildAll(options) {
|
|
|
461
571
|
}
|
|
462
572
|
})
|
|
463
573
|
.catch(({ error, stdout, stderr }) => {
|
|
464
|
-
|
|
574
|
+
logError(chalk_1.default.red('Failed to build ' + pkg.packageName));
|
|
465
575
|
console.log(stdout);
|
|
466
576
|
process.exit(1);
|
|
467
577
|
// let dependentModules = getDependentP
|
|
@@ -562,6 +672,7 @@ function buildAll(options) {
|
|
|
562
672
|
}
|
|
563
673
|
}, sync);
|
|
564
674
|
}
|
|
675
|
+
exports.buildAll = buildAll;
|
|
565
676
|
function getDependentPackages(dependencies, pkg) {
|
|
566
677
|
let dependentModules = [];
|
|
567
678
|
dependencies.forEach((dModuleDependencies, dModule) => {
|
|
@@ -612,6 +723,7 @@ function getLincdPackages(rootPath = process.cwd()) {
|
|
|
612
723
|
checkWorkspaces(rootPath, pack.workspaces, res);
|
|
613
724
|
return res;
|
|
614
725
|
}
|
|
726
|
+
exports.getLincdPackages = getLincdPackages;
|
|
615
727
|
function setVariable(name, replacement) {
|
|
616
728
|
//prepare name for regexp
|
|
617
729
|
name = name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
@@ -657,7 +769,7 @@ const createOntology = async (prefix, uriBase, basePath = process.cwd()) => {
|
|
|
657
769
|
setVariable('uri_base', uriBase);
|
|
658
770
|
let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(prefix);
|
|
659
771
|
//copy ontology accessor file
|
|
660
|
-
log(
|
|
772
|
+
log("Creating files for ontology '" + prefix + "'");
|
|
661
773
|
let targetFile = path_1.default.join(targetFolder, hyphenName + '.ts');
|
|
662
774
|
fs_extra_1.default.copySync(path_1.default.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
|
|
663
775
|
//copy data files
|
|
@@ -829,7 +941,7 @@ const createSetComponent = async (name, basePath = process.cwd()) => {
|
|
|
829
941
|
let targetFolder = ensureFolderExists(basePath, 'src', 'components');
|
|
830
942
|
let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(name);
|
|
831
943
|
//copy default shape file
|
|
832
|
-
log(
|
|
944
|
+
log("Creating files for set component '" + name + "'");
|
|
833
945
|
let targetFile = path_1.default.join(targetFolder, hyphenName + '.tsx');
|
|
834
946
|
fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'set-component.tsx'), targetFile);
|
|
835
947
|
let targetFile2 = path_1.default.join(targetFolder, hyphenName + '.scss');
|
|
@@ -845,7 +957,7 @@ const createComponent = async (name, basePath = process.cwd()) => {
|
|
|
845
957
|
let targetFolder = ensureFolderExists(sourceFolder, 'components');
|
|
846
958
|
let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(name);
|
|
847
959
|
//copy default shape file
|
|
848
|
-
log(
|
|
960
|
+
log("Creating files for component '" + name + "'");
|
|
849
961
|
let targetFile = path_1.default.join(targetFolder, hyphenName + '.tsx');
|
|
850
962
|
fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', 'defaults', 'component.tsx'), targetFile);
|
|
851
963
|
let targetFile2 = path_1.default.join(targetFolder, hyphenName + '.scss');
|
|
@@ -923,15 +1035,17 @@ invalidImports = new Map()) => {
|
|
|
923
1035
|
invalidImports.forEach((value, key) => {
|
|
924
1036
|
// res += '- '+chalk.blueBright(key.split('/').pop()) + ':\n';
|
|
925
1037
|
value.forEach(({ type, importPath }) => {
|
|
926
|
-
let message = key.split('/').pop() +
|
|
1038
|
+
let message = key.split('/').pop() + " imports from '" + importPath + "'";
|
|
927
1039
|
if (type === 'outside_package') {
|
|
928
1040
|
message += ' which is outside the package source root';
|
|
929
1041
|
}
|
|
930
1042
|
if (type === 'lincd') {
|
|
931
|
-
message +=
|
|
1043
|
+
message +=
|
|
1044
|
+
' which should not contain /src/ or /lib/ in the import path';
|
|
932
1045
|
}
|
|
933
1046
|
if (type === 'missing_extension') {
|
|
934
|
-
message +=
|
|
1047
|
+
message +=
|
|
1048
|
+
' which should end with a file extension. Like .js or .scss';
|
|
935
1049
|
}
|
|
936
1050
|
res += chalk_1.default.red(message + '\n');
|
|
937
1051
|
});
|
|
@@ -988,13 +1102,16 @@ const depCheck = async (packagePath = process.cwd()) => {
|
|
|
988
1102
|
if (missingLincdPackages.length > 0) {
|
|
989
1103
|
reject(chalk_1.default.red(packagePath.split('/').pop() +
|
|
990
1104
|
'\n[ERROR] These LINCD packages are imported but they are not listed in package.json:\n- ' +
|
|
991
|
-
missingLincdPackages
|
|
1105
|
+
missingLincdPackages
|
|
1106
|
+
.map((missedKey) => {
|
|
992
1107
|
const files = results.missing[missedKey];
|
|
993
1108
|
return `${missedKey} (${files.length} files: ${files.join(', ')})`;
|
|
994
|
-
})
|
|
1109
|
+
})
|
|
1110
|
+
.join(',\n- ')));
|
|
995
1111
|
}
|
|
996
1112
|
else if (missing.length > 0) {
|
|
997
|
-
resolve(chalk_1.default.redBright('warning: ' +
|
|
1113
|
+
resolve(chalk_1.default.redBright('warning: ' +
|
|
1114
|
+
packagePath.split('/').pop() +
|
|
998
1115
|
' is missing dependencies:\n - ' +
|
|
999
1116
|
missing.join('\n - ')));
|
|
1000
1117
|
}
|
|
@@ -1064,13 +1181,22 @@ const runMethod = async (packageName, method, options) => {
|
|
|
1064
1181
|
await (0, exports.ensureEnvironmentLoaded)();
|
|
1065
1182
|
if (options.spawn) {
|
|
1066
1183
|
let lincdConfig = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lincd.config.js')}`).then(s => __importStar(require(s)))).default;
|
|
1184
|
+
// Set default loadAppComponent if not provided
|
|
1185
|
+
if (!lincdConfig.server) {
|
|
1186
|
+
lincdConfig.server = {};
|
|
1187
|
+
}
|
|
1188
|
+
if (!lincdConfig.server.loadAppComponent) {
|
|
1189
|
+
lincdConfig.server.loadAppComponent = async () => (await Promise.resolve(`${path_1.default.join(process.cwd(), 'src', 'App')}`).then(s => __importStar(require(s)))).default;
|
|
1190
|
+
}
|
|
1191
|
+
// Set default loadRoutes if not provided
|
|
1192
|
+
if (!lincdConfig.server.loadRoutes) {
|
|
1193
|
+
lincdConfig.server.loadRoutes = async () => await Promise.resolve(`${path_1.default.join(process.cwd(), 'src', 'routes.tsx')}`).then(s => __importStar(require(s)));
|
|
1194
|
+
}
|
|
1067
1195
|
//@ts-ignore
|
|
1068
|
-
const ServerClass = (await Promise.resolve().then(() => __importStar(require('lincd-server/shapes/LincdServer'))))
|
|
1196
|
+
const ServerClass = (await Promise.resolve().then(() => __importStar(require('lincd-server/shapes/LincdServer'))))
|
|
1197
|
+
.LincdServer;
|
|
1069
1198
|
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
|
-
});
|
|
1199
|
+
let server = new ServerClass(lincdConfig);
|
|
1074
1200
|
//init the server
|
|
1075
1201
|
console.log('Initializing server...');
|
|
1076
1202
|
server.initOnly().then(() => {
|
|
@@ -1098,7 +1224,9 @@ const runMethod = async (packageName, method, options) => {
|
|
|
1098
1224
|
},
|
|
1099
1225
|
};
|
|
1100
1226
|
//TODO; allow sending args
|
|
1101
|
-
server
|
|
1227
|
+
server
|
|
1228
|
+
.callBackendMethod(packageName, method, [], request, response)
|
|
1229
|
+
.then(() => {
|
|
1102
1230
|
console.log('Done');
|
|
1103
1231
|
process.exit();
|
|
1104
1232
|
});
|
|
@@ -1113,17 +1241,21 @@ const runMethod = async (packageName, method, options) => {
|
|
|
1113
1241
|
headers: {
|
|
1114
1242
|
'Content-Type': 'application/json',
|
|
1115
1243
|
},
|
|
1116
|
-
})
|
|
1244
|
+
})
|
|
1245
|
+
.then((response) => {
|
|
1117
1246
|
if (!response.ok) {
|
|
1118
1247
|
throw new Error('Network response was not ok');
|
|
1119
1248
|
}
|
|
1120
1249
|
return response.json();
|
|
1121
|
-
})
|
|
1250
|
+
})
|
|
1251
|
+
.then((data) => {
|
|
1122
1252
|
console.log('Response data:', data);
|
|
1123
1253
|
process.exit();
|
|
1124
|
-
})
|
|
1254
|
+
})
|
|
1255
|
+
.catch((error) => {
|
|
1125
1256
|
var _a;
|
|
1126
|
-
if (error.code === 'ECONNREFUSED' ||
|
|
1257
|
+
if (error.code === 'ECONNREFUSED' ||
|
|
1258
|
+
((_a = error.cause) === null || _a === void 0 ? void 0 : _a.code) === 'ECONNREFUSED') {
|
|
1127
1259
|
console.error(chalk_1.default.red('Could not connect to the backend server. Is it running?'));
|
|
1128
1260
|
console.error(`Make sure you ${chalk_1.default.magenta('run "yarn start" in a separate process')} before calling this method.`);
|
|
1129
1261
|
}
|
|
@@ -1137,7 +1269,8 @@ const runMethod = async (packageName, method, options) => {
|
|
|
1137
1269
|
exports.runMethod = runMethod;
|
|
1138
1270
|
const startServer = async (initOnly = false, ServerClass = null) => {
|
|
1139
1271
|
await (0, exports.ensureEnvironmentLoaded)();
|
|
1140
|
-
let lincdConfig = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lincd.config.js')}`).then(s => __importStar(require(s))))
|
|
1272
|
+
let lincdConfig = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lincd.config.js')}`).then(s => __importStar(require(s))))
|
|
1273
|
+
.default;
|
|
1141
1274
|
// function scssLoadcall(source, filename) {
|
|
1142
1275
|
// return 'console.log("SCSS CALL: ' + filename + '");\n' + source;
|
|
1143
1276
|
// process.exit();
|
|
@@ -1153,18 +1286,36 @@ const startServer = async (initOnly = false, ServerClass = null) => {
|
|
|
1153
1286
|
ServerClass = (await Promise.resolve().then(() => __importStar(require('lincd-server/shapes/LincdServer')))).LincdServer;
|
|
1154
1287
|
}
|
|
1155
1288
|
await Promise.resolve(`${path_1.default.join(process.cwd(), 'scripts', 'storage-config.js')}`).then(s => __importStar(require(s)));
|
|
1156
|
-
|
|
1157
|
-
if (
|
|
1158
|
-
|
|
1289
|
+
// Set default loadAppComponent if not provided
|
|
1290
|
+
if (!lincdConfig.server) {
|
|
1291
|
+
lincdConfig.server = {};
|
|
1292
|
+
}
|
|
1293
|
+
if (!lincdConfig.server.loadAppComponent) {
|
|
1294
|
+
let appPromise;
|
|
1295
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
1296
|
+
appPromise = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'lib', 'App.js')}`).then(s => __importStar(require(s))))
|
|
1297
|
+
.default;
|
|
1298
|
+
}
|
|
1299
|
+
else {
|
|
1300
|
+
appPromise = (await Promise.resolve(`${path_1.default.join(process.cwd(), 'src', 'App.tsx')}`).then(s => __importStar(require(s))))
|
|
1301
|
+
.default;
|
|
1302
|
+
}
|
|
1303
|
+
lincdConfig.server.loadAppComponent = async () => {
|
|
1304
|
+
return appPromise;
|
|
1305
|
+
};
|
|
1159
1306
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1307
|
+
// Set default loadRoutes if not provided
|
|
1308
|
+
if (!lincdConfig.server.loadRoutes) {
|
|
1309
|
+
lincdConfig.server.loadRoutes = async () => {
|
|
1310
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
1311
|
+
return await Promise.resolve(`${path_1.default.join(process.cwd(), 'lib', 'routes.js')}`).then(s => __importStar(require(s)));
|
|
1312
|
+
}
|
|
1313
|
+
else {
|
|
1314
|
+
return await Promise.resolve(`${path_1.default.join(process.cwd(), 'src', 'routes.tsx')}`).then(s => __importStar(require(s)));
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1162
1317
|
}
|
|
1163
|
-
let server = new ServerClass(
|
|
1164
|
-
loadAppComponent: async () => {
|
|
1165
|
-
return appPromise;
|
|
1166
|
-
}, ...lincdConfig,
|
|
1167
|
-
});
|
|
1318
|
+
let server = new ServerClass(lincdConfig);
|
|
1168
1319
|
//Important to use slice, because when using clusers, child processes need to be able to read the same arguments
|
|
1169
1320
|
let args = process.argv.slice(2);
|
|
1170
1321
|
//if --initOnly is passed, only initialize the server and don't start it
|
|
@@ -1180,6 +1331,7 @@ const buildApp = async () => {
|
|
|
1180
1331
|
await (0, exports.buildFrontend)();
|
|
1181
1332
|
await (0, exports.buildBackend)();
|
|
1182
1333
|
console.log(chalk_1.default.magenta(`✅ ${process.env.NODE_ENV} app build finished`));
|
|
1334
|
+
process.exit(0);
|
|
1183
1335
|
};
|
|
1184
1336
|
exports.buildApp = buildApp;
|
|
1185
1337
|
const buildFrontend = async () => {
|
|
@@ -1222,7 +1374,8 @@ const buildFrontend = async () => {
|
|
|
1222
1374
|
}).then(async () => {
|
|
1223
1375
|
// make sure environment is not development for storage config
|
|
1224
1376
|
// and if we want to upload to storage, we need set S3_BUCKET_ENDPOINT
|
|
1225
|
-
if (process.env.NODE_ENV === 'development' ||
|
|
1377
|
+
if (process.env.NODE_ENV === 'development' ||
|
|
1378
|
+
!process.env.S3_BUCKET_ENDPOINT) {
|
|
1226
1379
|
console.warn('Upload build to storage skip in development environment or S3_BUCKET_ENDPOINT is not set');
|
|
1227
1380
|
return;
|
|
1228
1381
|
// process.exit();
|
|
@@ -1259,9 +1412,11 @@ const buildFrontend = async () => {
|
|
|
1259
1412
|
// example: /Users/username/project/www/index.html -> /project/www/index.html
|
|
1260
1413
|
const pathname = filePath.replace(pathDir, `/${rootDirectory}`);
|
|
1261
1414
|
// upload file to storage
|
|
1262
|
-
await LinkedFileStorage_1.LinkedFileStorage.saveFile(pathname, fileContent)
|
|
1415
|
+
await LinkedFileStorage_1.LinkedFileStorage.saveFile(pathname, fileContent)
|
|
1416
|
+
.then(() => {
|
|
1263
1417
|
clearSpinner.text = `${counter++}/${files.length}: - Published ${pathname} `;
|
|
1264
|
-
})
|
|
1418
|
+
})
|
|
1419
|
+
.catch(console.error);
|
|
1265
1420
|
});
|
|
1266
1421
|
const urls = await Promise.all(uploads);
|
|
1267
1422
|
clearSpinner.succeed(`${urls.length} files uploaded to storage`);
|
|
@@ -1339,7 +1494,9 @@ const upgradePackages = async () => {
|
|
|
1339
1494
|
const tsConfigCJS = path_1.default.join(dirname, '../../defaults/package', 'tsconfig-cjs.json');
|
|
1340
1495
|
const tsConfigESM = path_1.default.join(dirname, '../../defaults/package', 'tsconfig-esm.json');
|
|
1341
1496
|
const typesFile = path_1.default.join(dirname, '../../defaults/package/src', 'types.d.ts');
|
|
1342
|
-
const tsConfigTemplate = await fs_extra_1.default
|
|
1497
|
+
const tsConfigTemplate = await fs_extra_1.default
|
|
1498
|
+
.readJson(path_1.default.join(dirname, '../../defaults/package', 'tsconfig.json'))
|
|
1499
|
+
.catch((err) => {
|
|
1343
1500
|
console.log(err);
|
|
1344
1501
|
});
|
|
1345
1502
|
runOnPackagesGroupedByDependencies(packages, (packageGroup, dependencies) => {
|
|
@@ -1454,7 +1611,9 @@ const upgradePackages = async () => {
|
|
|
1454
1611
|
// }
|
|
1455
1612
|
// })
|
|
1456
1613
|
// });
|
|
1457
|
-
files
|
|
1614
|
+
files
|
|
1615
|
+
.filter((f) => f.match(/\.(scss\.json|css\.json)$/))
|
|
1616
|
+
.forEach((cssJsonFile) => {
|
|
1458
1617
|
console.log('Removing ' + cssJsonFile);
|
|
1459
1618
|
fs_extra_1.default.unlinkSync(cssJsonFile);
|
|
1460
1619
|
});
|
|
@@ -1504,7 +1663,7 @@ const createPackage = async (name, uriBase, basePath = process.cwd()) => {
|
|
|
1504
1663
|
//extra variable for clarity (will be same as 'name')
|
|
1505
1664
|
setVariable('output_file_name', name);
|
|
1506
1665
|
let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(cleanPackageName);
|
|
1507
|
-
log(
|
|
1666
|
+
log("Creating new LINCD package '" + name + "'");
|
|
1508
1667
|
fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'package'), targetFolder);
|
|
1509
1668
|
//replace variables in some of the copied files
|
|
1510
1669
|
await Promise.all([
|
|
@@ -1627,7 +1786,7 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1627
1786
|
spinner.text = step.name;
|
|
1628
1787
|
spinner.start();
|
|
1629
1788
|
}
|
|
1630
|
-
return step.apply().then(stepResult => {
|
|
1789
|
+
return step.apply().then((stepResult) => {
|
|
1631
1790
|
//if a build step returns a string,
|
|
1632
1791
|
//a warning is shown but the build is still successful with warnings
|
|
1633
1792
|
if (typeof stepResult === 'string') {
|
|
@@ -1676,26 +1835,29 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1676
1835
|
name: 'Copying files to lib folder',
|
|
1677
1836
|
apply: async () => {
|
|
1678
1837
|
const files = await (0, glob_1.glob)(packagePath + '/src/**/*.{json,d.ts,css,scss}');
|
|
1679
|
-
return Promise.all(files.map(
|
|
1838
|
+
return Promise.all(files.map(async (file) => {
|
|
1680
1839
|
try {
|
|
1681
|
-
await fs_extra_1.default.copy(file, packagePath +
|
|
1682
|
-
|
|
1840
|
+
await fs_extra_1.default.copy(file, packagePath +
|
|
1841
|
+
'/lib/esm/' +
|
|
1842
|
+
file.replace(packagePath + '/src/', ''));
|
|
1843
|
+
await fs_extra_1.default.copy(file, packagePath +
|
|
1844
|
+
'/lib/cjs/' +
|
|
1845
|
+
file.replace(packagePath + '/src/', ''));
|
|
1683
1846
|
return true;
|
|
1684
1847
|
}
|
|
1685
1848
|
catch (err) {
|
|
1686
1849
|
console.warn(err);
|
|
1687
1850
|
return false;
|
|
1688
1851
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
return allResults.every(r => r === true);
|
|
1852
|
+
})).then((allResults) => {
|
|
1853
|
+
return allResults.every((r) => r === true);
|
|
1692
1854
|
});
|
|
1693
1855
|
},
|
|
1694
1856
|
});
|
|
1695
1857
|
buildStep({
|
|
1696
1858
|
name: 'Dual package support',
|
|
1697
1859
|
apply: () => {
|
|
1698
|
-
return (0, utils_js_1.execPromise)('yarn tsconfig-to-dual-package ./tsconfig-cjs.json ./tsconfig-esm.json', false, false, { cwd: packagePath }).then(res => {
|
|
1860
|
+
return (0, utils_js_1.execPromise)('yarn tsconfig-to-dual-package ./tsconfig-cjs.json ./tsconfig-esm.json', false, false, { cwd: packagePath }).then((res) => {
|
|
1699
1861
|
return res === '';
|
|
1700
1862
|
});
|
|
1701
1863
|
},
|
|
@@ -1710,8 +1872,12 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1710
1872
|
name: 'Checking dependencies',
|
|
1711
1873
|
apply: () => (0, exports.depCheck)(packagePath),
|
|
1712
1874
|
});
|
|
1713
|
-
let success = await buildProcess.catch(err => {
|
|
1714
|
-
let msg = typeof err === 'string' || err instanceof Error
|
|
1875
|
+
let success = await buildProcess.catch((err) => {
|
|
1876
|
+
let msg = typeof err === 'string' || err instanceof Error
|
|
1877
|
+
? err.toString()
|
|
1878
|
+
: err.error && !err.error.toString().includes('Command failed:')
|
|
1879
|
+
? err.error
|
|
1880
|
+
: err.stdout + '\n' + err.stderr;
|
|
1715
1881
|
if (logResults) {
|
|
1716
1882
|
spinner.stopAndPersist({
|
|
1717
1883
|
symbol: chalk_1.default.red('✖'),
|
|
@@ -1729,15 +1895,19 @@ const buildPackage = async (target, target2, packagePath = process.cwd(), logRes
|
|
|
1729
1895
|
if (logResults) {
|
|
1730
1896
|
spinner.stopAndPersist({
|
|
1731
1897
|
symbol: chalk_1.default.greenBright('✔'),
|
|
1732
|
-
text: success === true
|
|
1898
|
+
text: success === true
|
|
1899
|
+
? 'Build successful'
|
|
1900
|
+
: 'Build successful with warnings',
|
|
1733
1901
|
});
|
|
1734
1902
|
}
|
|
1735
1903
|
}
|
|
1736
1904
|
else {
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1905
|
+
if (logResults) {
|
|
1906
|
+
spinner.stopAndPersist({
|
|
1907
|
+
symbol: chalk_1.default.red('✖'),
|
|
1908
|
+
text: 'Build failed',
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1741
1911
|
}
|
|
1742
1912
|
return success;
|
|
1743
1913
|
};
|
|
@@ -1772,16 +1942,18 @@ exports.compilePackage = compilePackage;
|
|
|
1772
1942
|
const compilePackageESM = async (packagePath = process.cwd()) => {
|
|
1773
1943
|
//echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
|
|
1774
1944
|
let compileCommand = `yarn exec tsc -p tsconfig-esm.json`;
|
|
1775
|
-
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath }).then(res => {
|
|
1945
|
+
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath }).then((res) => {
|
|
1776
1946
|
return res === '';
|
|
1777
1947
|
});
|
|
1778
1948
|
};
|
|
1779
1949
|
exports.compilePackageESM = compilePackageESM;
|
|
1780
1950
|
const compilePackageCJS = async (packagePath = process.cwd()) => {
|
|
1781
1951
|
let compileCommand = `yarn exec tsc -p tsconfig-cjs.json`;
|
|
1782
|
-
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath })
|
|
1952
|
+
return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath })
|
|
1953
|
+
.then((res) => {
|
|
1783
1954
|
return res === '';
|
|
1784
|
-
})
|
|
1955
|
+
})
|
|
1956
|
+
.catch((err) => {
|
|
1785
1957
|
return {
|
|
1786
1958
|
error: err.stdout,
|
|
1787
1959
|
};
|
|
@@ -1899,7 +2071,7 @@ var publishUpdated = function (test = false) {
|
|
|
1899
2071
|
})
|
|
1900
2072
|
.catch(({ error, stdout, stderr }) => {
|
|
1901
2073
|
if (error) {
|
|
1902
|
-
console.
|
|
2074
|
+
console.error(error.message);
|
|
1903
2075
|
}
|
|
1904
2076
|
if (stdout) {
|
|
1905
2077
|
console.log(stderr);
|
|
@@ -1975,7 +2147,7 @@ var publishPackage = async function (pkg, test, info, publishVersion) {
|
|
|
1975
2147
|
.then((res) => {
|
|
1976
2148
|
if (res.indexOf('Aborted due to warnings') !== -1 ||
|
|
1977
2149
|
res.indexOf('Could not publish') !== -1 ||
|
|
1978
|
-
res.indexOf(
|
|
2150
|
+
res.indexOf("Couldn't publish") !== -1) {
|
|
1979
2151
|
console.log(res);
|
|
1980
2152
|
return chalk_1.default.red(pkg.packageName + ' failed\n');
|
|
1981
2153
|
}
|
|
@@ -1988,7 +2160,7 @@ var publishPackage = async function (pkg, test, info, publishVersion) {
|
|
|
1988
2160
|
chalk_1.default.magenta(publishVersion));
|
|
1989
2161
|
})
|
|
1990
2162
|
.catch(({ error, stdout, stderr }) => {
|
|
1991
|
-
|
|
2163
|
+
logError('Failed to publish: ' + error.message);
|
|
1992
2164
|
return chalk_1.default.red(pkg.packageName + ' failed to publish');
|
|
1993
2165
|
});
|
|
1994
2166
|
};
|
|
@@ -2049,42 +2221,31 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
|
|
|
2049
2221
|
return chalk_1.default.blue(pkg.packageName + ' should be build');
|
|
2050
2222
|
}
|
|
2051
2223
|
log('Building ' + pkg.packageName);
|
|
2052
|
-
|
|
2053
|
-
return (0, utils_js_1.execPromise)('cd ' +
|
|
2054
|
-
pkg.path +
|
|
2055
|
-
' && yarn build' +
|
|
2056
|
-
(target ? ' ' + target : '') +
|
|
2057
|
-
(target2 ? ' ' + target2 : ''))
|
|
2224
|
+
return (0, exports.buildPackage)(null, null, path_1.default.join(process.cwd(), pkg.path), false)
|
|
2058
2225
|
.then((res) => {
|
|
2059
|
-
|
|
2226
|
+
//empty string or true is success
|
|
2227
|
+
//false is success with warnings
|
|
2228
|
+
//any other string is the build error text
|
|
2229
|
+
//undefined result means it failed
|
|
2230
|
+
if (typeof res === 'undefined') {
|
|
2231
|
+
logError('Failed to build ' + pkg.packageName);
|
|
2232
|
+
process.exit(1);
|
|
2233
|
+
}
|
|
2234
|
+
else {
|
|
2060
2235
|
(0, utils_js_1.debugInfo)(chalk_1.default.green(pkg.packageName + ' successfully built'));
|
|
2061
2236
|
return chalk_1.default.green(pkg.packageName + ' built');
|
|
2062
2237
|
}
|
|
2063
|
-
else if (typeof res === 'string') {
|
|
2064
|
-
warn(chalk_1.default.red('Failed to build ' + pkg.packageName));
|
|
2065
|
-
console.log(res);
|
|
2066
|
-
process.exit(1);
|
|
2067
|
-
}
|
|
2068
2238
|
})
|
|
2069
|
-
.catch((
|
|
2070
|
-
|
|
2071
|
-
console.
|
|
2239
|
+
.catch((err) => {
|
|
2240
|
+
logError('Failed to build ' + pkg.packageName);
|
|
2241
|
+
console.error(err);
|
|
2072
2242
|
process.exit(1);
|
|
2073
|
-
// let dependentModules = getDependentPackages(dependencies, pkg);
|
|
2074
|
-
// if (dependentModules.length > 0) {
|
|
2075
|
-
// // printBuildResults(failedModules, done);
|
|
2076
|
-
// warn(chalk.red(pkg.packageName + ' build failed'));
|
|
2077
|
-
// warn(
|
|
2078
|
-
// 'Stopping build-updated process because ' +
|
|
2079
|
-
// dependentModules.length +
|
|
2080
|
-
// ' other packages depend on this package.\n',
|
|
2081
|
-
// ); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
2082
|
-
// }
|
|
2083
2243
|
});
|
|
2084
2244
|
}
|
|
2085
2245
|
};
|
|
2086
|
-
}, (results) => {
|
|
2246
|
+
}, (dependencies, results) => {
|
|
2087
2247
|
if (results.length) {
|
|
2248
|
+
log(chalk_1.default.green('Changed packages have been rebuilt'));
|
|
2088
2249
|
log('Summary:');
|
|
2089
2250
|
log(results.join('\n'));
|
|
2090
2251
|
}
|
|
@@ -2124,16 +2285,15 @@ var executeCommandForEachPackage = function (packages, command, filterMethod, fi
|
|
|
2124
2285
|
}
|
|
2125
2286
|
let seen = false;
|
|
2126
2287
|
packages = packages.filter((pkg) => {
|
|
2127
|
-
if (!seen &&
|
|
2128
|
-
pkg.packageName.includes(startFrom)) {
|
|
2288
|
+
if (!seen && pkg.packageName.includes(startFrom)) {
|
|
2129
2289
|
seen = true;
|
|
2130
2290
|
}
|
|
2131
2291
|
return seen;
|
|
2132
2292
|
});
|
|
2133
2293
|
}
|
|
2134
|
-
log(
|
|
2294
|
+
log("Executing '" +
|
|
2135
2295
|
chalk_1.default.blueBright(command) +
|
|
2136
|
-
'
|
|
2296
|
+
"' on packages " +
|
|
2137
2297
|
chalk_1.default.magenta(packages.map((m) => m.packageName).join(', ')));
|
|
2138
2298
|
var p = Promise.resolve(true);
|
|
2139
2299
|
packages.forEach((pkg) => {
|
|
@@ -2217,11 +2377,11 @@ var executeCommandForPackage = function (packageName, command) {
|
|
|
2217
2377
|
let packageDetails = getLincdPackages().find((modDetails) => modDetails.packageName.indexOf(packageName) !== -1 ||
|
|
2218
2378
|
modDetails.packageName.indexOf(packageName) !== -1);
|
|
2219
2379
|
if (packageDetails) {
|
|
2220
|
-
log(
|
|
2380
|
+
log("Executing 'cd " +
|
|
2221
2381
|
packageDetails.path +
|
|
2222
2382
|
' && yarn lincd' +
|
|
2223
2383
|
(command ? ' ' + command : '') +
|
|
2224
|
-
'
|
|
2384
|
+
"'");
|
|
2225
2385
|
(0, child_process_2.spawn)(process.platform === 'win32' ? 'yarn.cmd' : 'yarn', // Windows quirk
|
|
2226
2386
|
['lincd', command || null], {
|
|
2227
2387
|
cwd: packageDetails.path,
|
|
@@ -2229,7 +2389,7 @@ var executeCommandForPackage = function (packageName, command) {
|
|
|
2229
2389
|
});
|
|
2230
2390
|
}
|
|
2231
2391
|
else {
|
|
2232
|
-
warn(
|
|
2392
|
+
warn("Could not find a pkg who's name (partially) matched " +
|
|
2233
2393
|
chalk_1.default.cyan(packageName));
|
|
2234
2394
|
}
|
|
2235
2395
|
};
|