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/esm/cli-methods.js
CHANGED
|
@@ -14,19 +14,21 @@ import { getEnvFile } from 'env-cmd/dist/get-env-vars.js';
|
|
|
14
14
|
import fs from 'fs-extra';
|
|
15
15
|
import path, { dirname } from 'path';
|
|
16
16
|
import { debugInfo, execp, execPromise, getFileImports, getFiles, getLastCommitTime, getPackageJSON, isImportOutsideOfPackage, isImportWithMissingExtension, isInvalidLINCDImport, needsRebuilding, } from './utils.js';
|
|
17
|
-
import {
|
|
17
|
+
import { spawn as spawnChild } from 'child_process';
|
|
18
18
|
import { findNearestPackageJson } from 'find-nearest-package-json';
|
|
19
|
+
import { statSync } from 'fs';
|
|
19
20
|
import { LinkedFileStorage } from 'lincd/utils/LinkedFileStorage';
|
|
20
|
-
import { spawn as spawnChild } from 'child_process';
|
|
21
21
|
// import pkg from 'lincd/utils/LinkedFileStorage';
|
|
22
22
|
// const { LinkedFileStorage } = pkg;
|
|
23
23
|
// const config = require('lincd-server/site.webpack.config');
|
|
24
24
|
import { glob } from 'glob';
|
|
25
25
|
import webpack from 'webpack';
|
|
26
|
-
import stagedGitFiles from 'staged-git-files';
|
|
27
26
|
import ora from 'ora';
|
|
28
|
-
|
|
29
|
-
let dirname__ = typeof __dirname !== 'undefined'
|
|
27
|
+
import stagedGitFiles from 'staged-git-files';
|
|
28
|
+
let dirname__ = typeof __dirname !== 'undefined'
|
|
29
|
+
? __dirname
|
|
30
|
+
: //@ts-ignore
|
|
31
|
+
dirname(import.meta.url).replace('file:/', '');
|
|
30
32
|
var variables = {};
|
|
31
33
|
export const createApp = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...args_1], void 0, function* (name, basePath = process.cwd()) {
|
|
32
34
|
if (!name) {
|
|
@@ -46,7 +48,7 @@ export const createApp = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...ar
|
|
|
46
48
|
fs.renameSync(path.join(targetFolder, 'gitignore.template'), path.join(targetFolder, '.gitignore'));
|
|
47
49
|
fs.renameSync(path.join(targetFolder, 'yarnrc.yml.template'), path.join(targetFolder, '.yarnrc.yml'));
|
|
48
50
|
// fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
|
|
49
|
-
log(
|
|
51
|
+
log("Creating new LINCD application '" + name + "'");
|
|
50
52
|
//replace variables in some copied files
|
|
51
53
|
yield replaceVariablesInFolder(targetFolder);
|
|
52
54
|
let hasYarn = yield hasYarnInstalled();
|
|
@@ -72,10 +74,15 @@ function progressUpdate(message) {
|
|
|
72
74
|
}
|
|
73
75
|
export function warn(...messages) {
|
|
74
76
|
messages.forEach((message) => {
|
|
75
|
-
console.
|
|
77
|
+
console.warn(chalk.redBright('Warning: ') + message);
|
|
76
78
|
// console.log(chalk.red(message));
|
|
77
79
|
});
|
|
78
80
|
}
|
|
81
|
+
export function logError(...messages) {
|
|
82
|
+
messages.forEach((message) => {
|
|
83
|
+
console.error(chalk.redBright('Error: ') + message);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
79
86
|
export function developPackage(target, mode) {
|
|
80
87
|
if (!target)
|
|
81
88
|
target = 'es6';
|
|
@@ -309,9 +316,121 @@ function hasDependency(pkg, childPkg, dependencies, depth = 1) {
|
|
|
309
316
|
console.log('going up');
|
|
310
317
|
return false;
|
|
311
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Finds the topmost package.json that could be an APP_ROOT
|
|
321
|
+
* Returns null if no app root is found (standalone repo case)
|
|
322
|
+
*/
|
|
323
|
+
function findAppRoot(startPath = process.cwd()) {
|
|
324
|
+
let currentPath = startPath;
|
|
325
|
+
let candidateRoots = [];
|
|
326
|
+
// Walk up the directory tree
|
|
327
|
+
for (let i = 0; i < 10; i++) {
|
|
328
|
+
const packageJsonPath = path.join(currentPath, 'package.json');
|
|
329
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
330
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
331
|
+
candidateRoots.push({
|
|
332
|
+
path: currentPath,
|
|
333
|
+
hasWorkspaces: !!packageJson.workspaces,
|
|
334
|
+
isLincd: packageJson.lincd === true,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
const parentPath = path.join(currentPath, '..');
|
|
338
|
+
// If we've reached the root or haven't moved up
|
|
339
|
+
if (parentPath === currentPath) {
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
currentPath = parentPath;
|
|
343
|
+
}
|
|
344
|
+
// Find the topmost package.json that has workspaces
|
|
345
|
+
// Prefer non-lincd packages (app roots) over lincd packages
|
|
346
|
+
let appRoot = null;
|
|
347
|
+
for (let i = candidateRoots.length - 1; i >= 0; i--) {
|
|
348
|
+
const candidate = candidateRoots[i];
|
|
349
|
+
if (candidate.hasWorkspaces && !candidate.isLincd) {
|
|
350
|
+
appRoot = candidate.path;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// If no non-lincd workspace found, use the topmost workspace
|
|
355
|
+
if (!appRoot) {
|
|
356
|
+
for (let i = candidateRoots.length - 1; i >= 0; i--) {
|
|
357
|
+
if (candidateRoots[i].hasWorkspaces) {
|
|
358
|
+
appRoot = candidateRoots[i].path;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return appRoot;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Filters packages to only include those in the dependency tree of the app root
|
|
367
|
+
*/
|
|
368
|
+
function filterPackagesByDependencyTree(allPackages, appRootPath) {
|
|
369
|
+
const appPackageJson = getPackageJSON(appRootPath);
|
|
370
|
+
if (!appPackageJson) {
|
|
371
|
+
return allPackages;
|
|
372
|
+
}
|
|
373
|
+
const relevantPackages = new Map();
|
|
374
|
+
const packagesToCheck = new Set();
|
|
375
|
+
// Start with direct dependencies from app root
|
|
376
|
+
if (appPackageJson.dependencies) {
|
|
377
|
+
Object.keys(appPackageJson.dependencies).forEach((dep) => {
|
|
378
|
+
if (allPackages.has(dep)) {
|
|
379
|
+
packagesToCheck.add(dep);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
// Recursively add dependencies
|
|
384
|
+
const processedPackages = new Set();
|
|
385
|
+
while (packagesToCheck.size > 0) {
|
|
386
|
+
const packageName = Array.from(packagesToCheck)[0];
|
|
387
|
+
packagesToCheck.delete(packageName);
|
|
388
|
+
if (processedPackages.has(packageName)) {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
processedPackages.add(packageName);
|
|
392
|
+
const packageDetails = allPackages.get(packageName);
|
|
393
|
+
if (packageDetails) {
|
|
394
|
+
relevantPackages.set(packageName, packageDetails);
|
|
395
|
+
// Get this package's dependencies
|
|
396
|
+
const packageJson = getPackageJSON(packageDetails.path);
|
|
397
|
+
if (packageJson && packageJson.dependencies) {
|
|
398
|
+
Object.keys(packageJson.dependencies).forEach((dep) => {
|
|
399
|
+
if (allPackages.has(dep) && !processedPackages.has(dep)) {
|
|
400
|
+
packagesToCheck.add(dep);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return relevantPackages;
|
|
407
|
+
}
|
|
312
408
|
export function buildAll(options) {
|
|
313
409
|
console.log('Building all LINCD packages of this repository in order of dependencies');
|
|
314
410
|
let lincdPackages = getLocalLincdPackageMap();
|
|
411
|
+
const originalPackageCount = lincdPackages.size;
|
|
412
|
+
// Check if we're in an app context and filter packages accordingly
|
|
413
|
+
const appRoot = findAppRoot();
|
|
414
|
+
if (appRoot) {
|
|
415
|
+
const appPackageJson = getPackageJSON(appRoot);
|
|
416
|
+
// Check if this is an app (not a lincd package itself) with lincd dependencies
|
|
417
|
+
const isAppWithLincdDeps = appPackageJson &&
|
|
418
|
+
appPackageJson.lincd !== true &&
|
|
419
|
+
appPackageJson.dependencies &&
|
|
420
|
+
Object.keys(appPackageJson.dependencies).some((dep) => lincdPackages.has(dep));
|
|
421
|
+
if (isAppWithLincdDeps) {
|
|
422
|
+
debugInfo(chalk.blue(`Found app root at: ${appRoot}`));
|
|
423
|
+
const filteredPackages = filterPackagesByDependencyTree(lincdPackages, appRoot);
|
|
424
|
+
console.log(chalk.magenta(`Found ${originalPackageCount} total LINCD packages, building only ${filteredPackages.size} that are relevant to this app`));
|
|
425
|
+
lincdPackages = filteredPackages;
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
debugInfo(chalk.blue(`Building all ${originalPackageCount} packages from workspace`));
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
debugInfo(chalk.blue(`No workspace root found, building all ${originalPackageCount} packages`));
|
|
433
|
+
}
|
|
315
434
|
let startFrom;
|
|
316
435
|
//by default start building
|
|
317
436
|
let building = true;
|
|
@@ -385,7 +504,8 @@ export function buildAll(options) {
|
|
|
385
504
|
log(chalk.cyan('Building ' + pkg.packageName));
|
|
386
505
|
process.stdout.write(packagesLeft + ' packages left\r');
|
|
387
506
|
}
|
|
388
|
-
return command
|
|
507
|
+
return command
|
|
508
|
+
.then((res) => {
|
|
389
509
|
//empty string or true is success
|
|
390
510
|
//false is success with warnings
|
|
391
511
|
//any other string is the build error text
|
|
@@ -409,7 +529,8 @@ export function buildAll(options) {
|
|
|
409
529
|
}
|
|
410
530
|
else {
|
|
411
531
|
if (!skipping) {
|
|
412
|
-
log(chalk.green('Built ' + pkg.packageName) +
|
|
532
|
+
log(chalk.green('Built ' + pkg.packageName) +
|
|
533
|
+
(res === false ? chalk.redBright(' (with warnings)') : ''));
|
|
413
534
|
}
|
|
414
535
|
done.add(pkg);
|
|
415
536
|
packagesLeft--;
|
|
@@ -425,7 +546,7 @@ export function buildAll(options) {
|
|
|
425
546
|
}
|
|
426
547
|
})
|
|
427
548
|
.catch(({ error, stdout, stderr }) => {
|
|
428
|
-
|
|
549
|
+
logError(chalk.red('Failed to build ' + pkg.packageName));
|
|
429
550
|
console.log(stdout);
|
|
430
551
|
process.exit(1);
|
|
431
552
|
// let dependentModules = getDependentP
|
|
@@ -608,7 +729,7 @@ const camelCase = (str) => {
|
|
|
608
729
|
}
|
|
609
730
|
return str;
|
|
610
731
|
};
|
|
611
|
-
export const createOntology = (prefix_1, uriBase_1, ...
|
|
732
|
+
export const createOntology = (prefix_1, uriBase_1, ...args_2) => __awaiter(void 0, [prefix_1, uriBase_1, ...args_2], void 0, function* (prefix, uriBase, basePath = process.cwd()) {
|
|
612
733
|
if (!prefix) {
|
|
613
734
|
console.warn('Please provide a suggested prefix as the first argument');
|
|
614
735
|
return;
|
|
@@ -621,7 +742,7 @@ export const createOntology = (prefix_1, uriBase_1, ...args_1) => __awaiter(void
|
|
|
621
742
|
setVariable('uri_base', uriBase);
|
|
622
743
|
let { hyphenName, camelCaseName, underscoreName } = setNameVariables(prefix);
|
|
623
744
|
//copy ontology accessor file
|
|
624
|
-
log(
|
|
745
|
+
log("Creating files for ontology '" + prefix + "'");
|
|
625
746
|
let targetFile = path.join(targetFolder, hyphenName + '.ts');
|
|
626
747
|
fs.copySync(path.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
|
|
627
748
|
//copy data files
|
|
@@ -771,7 +892,7 @@ export const getScriptDir = () => {
|
|
|
771
892
|
// return dirname(import.meta.url).replace('file:/','');
|
|
772
893
|
// }
|
|
773
894
|
};
|
|
774
|
-
export const createShape = (
|
|
895
|
+
export const createShape = (name_2, ...args_3) => __awaiter(void 0, [name_2, ...args_3], void 0, function* (name, basePath = process.cwd()) {
|
|
775
896
|
let sourceFolder = getSourceFolder(basePath);
|
|
776
897
|
let targetFolder = ensureFolderExists(sourceFolder, 'shapes');
|
|
777
898
|
let { hyphenName, camelCaseName, underscoreName } = setNameVariables(name);
|
|
@@ -789,11 +910,11 @@ export const createShape = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...
|
|
|
789
910
|
log(`Added an import of this file from ${chalk.magenta(indexPath)}`);
|
|
790
911
|
}
|
|
791
912
|
});
|
|
792
|
-
export const createSetComponent = (
|
|
913
|
+
export const createSetComponent = (name_3, ...args_4) => __awaiter(void 0, [name_3, ...args_4], void 0, function* (name, basePath = process.cwd()) {
|
|
793
914
|
let targetFolder = ensureFolderExists(basePath, 'src', 'components');
|
|
794
915
|
let { hyphenName, camelCaseName, underscoreName } = setNameVariables(name);
|
|
795
916
|
//copy default shape file
|
|
796
|
-
log(
|
|
917
|
+
log("Creating files for set component '" + name + "'");
|
|
797
918
|
let targetFile = path.join(targetFolder, hyphenName + '.tsx');
|
|
798
919
|
fs.copySync(path.join(getScriptDir(), '..', '..', 'defaults', 'set-component.tsx'), targetFile);
|
|
799
920
|
let targetFile2 = path.join(targetFolder, hyphenName + '.scss');
|
|
@@ -803,12 +924,12 @@ export const createSetComponent = (name_1, ...args_1) => __awaiter(void 0, [name
|
|
|
803
924
|
let indexPath = addLineToIndex(`import './components/${hyphenName}.js';`, 'components');
|
|
804
925
|
log(`Created a new set component in ${chalk.magenta(targetFile.replace(basePath, ''))}`, `Created a new stylesheet in ${chalk.magenta(targetFile2.replace(basePath, ''))}`, `Added an import of this file from ${chalk.magenta(indexPath)}`);
|
|
805
926
|
});
|
|
806
|
-
export const createComponent = (
|
|
927
|
+
export const createComponent = (name_4, ...args_5) => __awaiter(void 0, [name_4, ...args_5], void 0, function* (name, basePath = process.cwd()) {
|
|
807
928
|
let sourceFolder = getSourceFolder(basePath);
|
|
808
929
|
let targetFolder = ensureFolderExists(sourceFolder, 'components');
|
|
809
930
|
let { hyphenName, camelCaseName, underscoreName } = setNameVariables(name);
|
|
810
931
|
//copy default shape file
|
|
811
|
-
log(
|
|
932
|
+
log("Creating files for component '" + name + "'");
|
|
812
933
|
let targetFile = path.join(targetFolder, hyphenName + '.tsx');
|
|
813
934
|
fs.copySync(path.join(getScriptDir(), '..', 'defaults', 'component.tsx'), targetFile);
|
|
814
935
|
let targetFile2 = path.join(targetFolder, hyphenName + '.scss');
|
|
@@ -826,7 +947,7 @@ export const createComponent = (name_1, ...args_1) => __awaiter(void 0, [name_1,
|
|
|
826
947
|
//read the source of all ts/tsx files in the src folder
|
|
827
948
|
//if there is an import that imports a lincd package with /src/ in it, then warn
|
|
828
949
|
//if there is an import that imports something from outside the src folder, then warn
|
|
829
|
-
export const checkImports = (...
|
|
950
|
+
export const checkImports = (...args_6) => __awaiter(void 0, [...args_6], void 0, function* (sourceFolder = getSourceFolder(), depth = 0, // Used to check if the import is outside the src folder
|
|
830
951
|
invalidImports = new Map()) {
|
|
831
952
|
const dir = fs.readdirSync(sourceFolder);
|
|
832
953
|
// Start checking each file in the source folder
|
|
@@ -885,15 +1006,17 @@ invalidImports = new Map()) {
|
|
|
885
1006
|
invalidImports.forEach((value, key) => {
|
|
886
1007
|
// res += '- '+chalk.blueBright(key.split('/').pop()) + ':\n';
|
|
887
1008
|
value.forEach(({ type, importPath }) => {
|
|
888
|
-
let message = key.split('/').pop() +
|
|
1009
|
+
let message = key.split('/').pop() + " imports from '" + importPath + "'";
|
|
889
1010
|
if (type === 'outside_package') {
|
|
890
1011
|
message += ' which is outside the package source root';
|
|
891
1012
|
}
|
|
892
1013
|
if (type === 'lincd') {
|
|
893
|
-
message +=
|
|
1014
|
+
message +=
|
|
1015
|
+
' which should not contain /src/ or /lib/ in the import path';
|
|
894
1016
|
}
|
|
895
1017
|
if (type === 'missing_extension') {
|
|
896
|
-
message +=
|
|
1018
|
+
message +=
|
|
1019
|
+
' which should end with a file extension. Like .js or .scss';
|
|
897
1020
|
}
|
|
898
1021
|
res += chalk.red(message + '\n');
|
|
899
1022
|
});
|
|
@@ -930,7 +1053,7 @@ export const depCheckStaged = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
930
1053
|
});
|
|
931
1054
|
});
|
|
932
1055
|
});
|
|
933
|
-
export const depCheck = (...
|
|
1056
|
+
export const depCheck = (...args_7) => __awaiter(void 0, [...args_7], void 0, function* (packagePath = process.cwd()) {
|
|
934
1057
|
return new Promise((resolve, reject) => {
|
|
935
1058
|
depcheck(packagePath, {}, (results) => {
|
|
936
1059
|
if (results.missing) {
|
|
@@ -950,13 +1073,16 @@ export const depCheck = (...args_1) => __awaiter(void 0, [...args_1], void 0, fu
|
|
|
950
1073
|
if (missingLincdPackages.length > 0) {
|
|
951
1074
|
reject(chalk.red(packagePath.split('/').pop() +
|
|
952
1075
|
'\n[ERROR] These LINCD packages are imported but they are not listed in package.json:\n- ' +
|
|
953
|
-
missingLincdPackages
|
|
1076
|
+
missingLincdPackages
|
|
1077
|
+
.map((missedKey) => {
|
|
954
1078
|
const files = results.missing[missedKey];
|
|
955
1079
|
return `${missedKey} (${files.length} files: ${files.join(', ')})`;
|
|
956
|
-
})
|
|
1080
|
+
})
|
|
1081
|
+
.join(',\n- ')));
|
|
957
1082
|
}
|
|
958
1083
|
else if (missing.length > 0) {
|
|
959
|
-
resolve(chalk.redBright('warning: ' +
|
|
1084
|
+
resolve(chalk.redBright('warning: ' +
|
|
1085
|
+
packagePath.split('/').pop() +
|
|
960
1086
|
' is missing dependencies:\n - ' +
|
|
961
1087
|
missing.join('\n - ')));
|
|
962
1088
|
}
|
|
@@ -1024,10 +1150,22 @@ export const runMethod = (packageName, method, options) => __awaiter(void 0, voi
|
|
|
1024
1150
|
yield ensureEnvironmentLoaded();
|
|
1025
1151
|
if (options.spawn) {
|
|
1026
1152
|
let lincdConfig = (yield import(path.join(process.cwd(), 'lincd.config.js'))).default;
|
|
1153
|
+
// Set default loadAppComponent if not provided
|
|
1154
|
+
if (!lincdConfig.server) {
|
|
1155
|
+
lincdConfig.server = {};
|
|
1156
|
+
}
|
|
1157
|
+
if (!lincdConfig.server.loadAppComponent) {
|
|
1158
|
+
lincdConfig.server.loadAppComponent = () => __awaiter(void 0, void 0, void 0, function* () { return (yield import(path.join(process.cwd(), 'src', 'App'))).default; });
|
|
1159
|
+
}
|
|
1160
|
+
// Set default loadRoutes if not provided
|
|
1161
|
+
if (!lincdConfig.server.loadRoutes) {
|
|
1162
|
+
lincdConfig.server.loadRoutes = () => __awaiter(void 0, void 0, void 0, function* () { return yield import(path.join(process.cwd(), 'src', 'routes.tsx')); });
|
|
1163
|
+
}
|
|
1027
1164
|
//@ts-ignore
|
|
1028
|
-
const ServerClass = (yield import('lincd-server/shapes/LincdServer'))
|
|
1165
|
+
const ServerClass = (yield import('lincd-server/shapes/LincdServer'))
|
|
1166
|
+
.LincdServer;
|
|
1029
1167
|
yield import(path.join(process.cwd(), 'scripts', 'storage-config.js'));
|
|
1030
|
-
let server = new ServerClass(
|
|
1168
|
+
let server = new ServerClass(lincdConfig);
|
|
1031
1169
|
//init the server
|
|
1032
1170
|
console.log('Initializing server...');
|
|
1033
1171
|
server.initOnly().then(() => {
|
|
@@ -1055,7 +1193,9 @@ export const runMethod = (packageName, method, options) => __awaiter(void 0, voi
|
|
|
1055
1193
|
},
|
|
1056
1194
|
};
|
|
1057
1195
|
//TODO; allow sending args
|
|
1058
|
-
server
|
|
1196
|
+
server
|
|
1197
|
+
.callBackendMethod(packageName, method, [], request, response)
|
|
1198
|
+
.then(() => {
|
|
1059
1199
|
console.log('Done');
|
|
1060
1200
|
process.exit();
|
|
1061
1201
|
});
|
|
@@ -1070,17 +1210,21 @@ export const runMethod = (packageName, method, options) => __awaiter(void 0, voi
|
|
|
1070
1210
|
headers: {
|
|
1071
1211
|
'Content-Type': 'application/json',
|
|
1072
1212
|
},
|
|
1073
|
-
})
|
|
1213
|
+
})
|
|
1214
|
+
.then((response) => {
|
|
1074
1215
|
if (!response.ok) {
|
|
1075
1216
|
throw new Error('Network response was not ok');
|
|
1076
1217
|
}
|
|
1077
1218
|
return response.json();
|
|
1078
|
-
})
|
|
1219
|
+
})
|
|
1220
|
+
.then((data) => {
|
|
1079
1221
|
console.log('Response data:', data);
|
|
1080
1222
|
process.exit();
|
|
1081
|
-
})
|
|
1223
|
+
})
|
|
1224
|
+
.catch((error) => {
|
|
1082
1225
|
var _a;
|
|
1083
|
-
if (error.code === 'ECONNREFUSED' ||
|
|
1226
|
+
if (error.code === 'ECONNREFUSED' ||
|
|
1227
|
+
((_a = error.cause) === null || _a === void 0 ? void 0 : _a.code) === 'ECONNREFUSED') {
|
|
1084
1228
|
console.error(chalk.red('Could not connect to the backend server. Is it running?'));
|
|
1085
1229
|
console.error(`Make sure you ${chalk.magenta('run "yarn start" in a separate process')} before calling this method.`);
|
|
1086
1230
|
}
|
|
@@ -1091,9 +1235,10 @@ export const runMethod = (packageName, method, options) => __awaiter(void 0, voi
|
|
|
1091
1235
|
});
|
|
1092
1236
|
}
|
|
1093
1237
|
});
|
|
1094
|
-
export const startServer = (...
|
|
1238
|
+
export const startServer = (...args_8) => __awaiter(void 0, [...args_8], void 0, function* (initOnly = false, ServerClass = null) {
|
|
1095
1239
|
yield ensureEnvironmentLoaded();
|
|
1096
|
-
let lincdConfig = (yield import(path.join(process.cwd(), 'lincd.config.js')))
|
|
1240
|
+
let lincdConfig = (yield import(path.join(process.cwd(), 'lincd.config.js')))
|
|
1241
|
+
.default;
|
|
1097
1242
|
// function scssLoadcall(source, filename) {
|
|
1098
1243
|
// return 'console.log("SCSS CALL: ' + filename + '");\n' + source;
|
|
1099
1244
|
// process.exit();
|
|
@@ -1109,16 +1254,36 @@ export const startServer = (...args_1) => __awaiter(void 0, [...args_1], void 0,
|
|
|
1109
1254
|
ServerClass = (yield import('lincd-server/shapes/LincdServer')).LincdServer;
|
|
1110
1255
|
}
|
|
1111
1256
|
yield import(path.join(process.cwd(), 'scripts', 'storage-config.js'));
|
|
1112
|
-
|
|
1113
|
-
if (
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
else {
|
|
1117
|
-
appPromise = (yield import(path.join(process.cwd(), 'src', 'App.js'))).default;
|
|
1257
|
+
// Set default loadAppComponent if not provided
|
|
1258
|
+
if (!lincdConfig.server) {
|
|
1259
|
+
lincdConfig.server = {};
|
|
1118
1260
|
}
|
|
1119
|
-
|
|
1261
|
+
if (!lincdConfig.server.loadAppComponent) {
|
|
1262
|
+
let appPromise;
|
|
1263
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
1264
|
+
appPromise = (yield import(path.join(process.cwd(), 'lib', 'App.js')))
|
|
1265
|
+
.default;
|
|
1266
|
+
}
|
|
1267
|
+
else {
|
|
1268
|
+
appPromise = (yield import(path.join(process.cwd(), 'src', 'App.tsx')))
|
|
1269
|
+
.default;
|
|
1270
|
+
}
|
|
1271
|
+
lincdConfig.server.loadAppComponent = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1120
1272
|
return appPromise;
|
|
1121
|
-
})
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
// Set default loadRoutes if not provided
|
|
1276
|
+
if (!lincdConfig.server.loadRoutes) {
|
|
1277
|
+
lincdConfig.server.loadRoutes = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1278
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
1279
|
+
return yield import(path.join(process.cwd(), 'lib', 'routes.js'));
|
|
1280
|
+
}
|
|
1281
|
+
else {
|
|
1282
|
+
return yield import(path.join(process.cwd(), 'src', 'routes.tsx'));
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
let server = new ServerClass(lincdConfig);
|
|
1122
1287
|
//Important to use slice, because when using clusers, child processes need to be able to read the same arguments
|
|
1123
1288
|
let args = process.argv.slice(2);
|
|
1124
1289
|
//if --initOnly is passed, only initialize the server and don't start it
|
|
@@ -1133,6 +1298,7 @@ export const buildApp = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
1133
1298
|
yield buildFrontend();
|
|
1134
1299
|
yield buildBackend();
|
|
1135
1300
|
console.log(chalk.magenta(`✅ ${process.env.NODE_ENV} app build finished`));
|
|
1301
|
+
process.exit(0);
|
|
1136
1302
|
});
|
|
1137
1303
|
export const buildFrontend = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1138
1304
|
yield ensureEnvironmentLoaded();
|
|
@@ -1174,7 +1340,8 @@ export const buildFrontend = () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
1174
1340
|
}).then(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
1175
1341
|
// make sure environment is not development for storage config
|
|
1176
1342
|
// and if we want to upload to storage, we need set S3_BUCKET_ENDPOINT
|
|
1177
|
-
if (process.env.NODE_ENV === 'development' ||
|
|
1343
|
+
if (process.env.NODE_ENV === 'development' ||
|
|
1344
|
+
!process.env.S3_BUCKET_ENDPOINT) {
|
|
1178
1345
|
console.warn('Upload build to storage skip in development environment or S3_BUCKET_ENDPOINT is not set');
|
|
1179
1346
|
return;
|
|
1180
1347
|
// process.exit();
|
|
@@ -1211,9 +1378,11 @@ export const buildFrontend = () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
1211
1378
|
// example: /Users/username/project/www/index.html -> /project/www/index.html
|
|
1212
1379
|
const pathname = filePath.replace(pathDir, `/${rootDirectory}`);
|
|
1213
1380
|
// upload file to storage
|
|
1214
|
-
yield LinkedFileStorage.saveFile(pathname, fileContent)
|
|
1381
|
+
yield LinkedFileStorage.saveFile(pathname, fileContent)
|
|
1382
|
+
.then(() => {
|
|
1215
1383
|
clearSpinner.text = `${counter++}/${files.length}: - Published ${pathname} `;
|
|
1216
|
-
})
|
|
1384
|
+
})
|
|
1385
|
+
.catch(console.error);
|
|
1217
1386
|
}));
|
|
1218
1387
|
const urls = yield Promise.all(uploads);
|
|
1219
1388
|
clearSpinner.succeed(`${urls.length} files uploaded to storage`);
|
|
@@ -1289,7 +1458,9 @@ export const upgradePackages = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
1289
1458
|
const tsConfigCJS = path.join(dirname, '../../defaults/package', 'tsconfig-cjs.json');
|
|
1290
1459
|
const tsConfigESM = path.join(dirname, '../../defaults/package', 'tsconfig-esm.json');
|
|
1291
1460
|
const typesFile = path.join(dirname, '../../defaults/package/src', 'types.d.ts');
|
|
1292
|
-
const tsConfigTemplate = yield fs
|
|
1461
|
+
const tsConfigTemplate = yield fs
|
|
1462
|
+
.readJson(path.join(dirname, '../../defaults/package', 'tsconfig.json'))
|
|
1463
|
+
.catch((err) => {
|
|
1293
1464
|
console.log(err);
|
|
1294
1465
|
});
|
|
1295
1466
|
runOnPackagesGroupedByDependencies(packages, (packageGroup, dependencies) => {
|
|
@@ -1404,7 +1575,9 @@ export const upgradePackages = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
1404
1575
|
// }
|
|
1405
1576
|
// })
|
|
1406
1577
|
// });
|
|
1407
|
-
files
|
|
1578
|
+
files
|
|
1579
|
+
.filter((f) => f.match(/\.(scss\.json|css\.json)$/))
|
|
1580
|
+
.forEach((cssJsonFile) => {
|
|
1408
1581
|
console.log('Removing ' + cssJsonFile);
|
|
1409
1582
|
fs.unlinkSync(cssJsonFile);
|
|
1410
1583
|
});
|
|
@@ -1422,7 +1595,7 @@ export const upgradePackages = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
1422
1595
|
// })
|
|
1423
1596
|
// });
|
|
1424
1597
|
});
|
|
1425
|
-
export const createPackage = (
|
|
1598
|
+
export const createPackage = (name_5, uriBase_2, ...args_9) => __awaiter(void 0, [name_5, uriBase_2, ...args_9], void 0, function* (name, uriBase, basePath = process.cwd()) {
|
|
1426
1599
|
if (!name) {
|
|
1427
1600
|
console.warn('Please provide a name as the first argument');
|
|
1428
1601
|
return;
|
|
@@ -1453,7 +1626,7 @@ export const createPackage = (name_1, uriBase_1, ...args_1) => __awaiter(void 0,
|
|
|
1453
1626
|
//extra variable for clarity (will be same as 'name')
|
|
1454
1627
|
setVariable('output_file_name', name);
|
|
1455
1628
|
let { hyphenName, camelCaseName, underscoreName } = setNameVariables(cleanPackageName);
|
|
1456
|
-
log(
|
|
1629
|
+
log("Creating new LINCD package '" + name + "'");
|
|
1457
1630
|
fs.copySync(path.join(getScriptDir(), '..', '..', 'defaults', 'package'), targetFolder);
|
|
1458
1631
|
//replace variables in some of the copied files
|
|
1459
1632
|
yield Promise.all([
|
|
@@ -1555,7 +1728,7 @@ export const register = function (registryURL) {
|
|
|
1555
1728
|
console.warn(chalk.red('Warning:') + ' not found: ' + process.cwd() + '/package.json');
|
|
1556
1729
|
}
|
|
1557
1730
|
};
|
|
1558
|
-
export const buildPackage = (target_1, target2_1, ...
|
|
1731
|
+
export const buildPackage = (target_1, target2_1, ...args_10) => __awaiter(void 0, [target_1, target2_1, ...args_10], void 0, function* (target, target2, packagePath = process.cwd(), logResults = true) {
|
|
1559
1732
|
let spinner;
|
|
1560
1733
|
if (logResults) {
|
|
1561
1734
|
//TODO: replace with listr so we can show multiple processes at once
|
|
@@ -1574,7 +1747,7 @@ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0
|
|
|
1574
1747
|
spinner.text = step.name;
|
|
1575
1748
|
spinner.start();
|
|
1576
1749
|
}
|
|
1577
|
-
return step.apply().then(stepResult => {
|
|
1750
|
+
return step.apply().then((stepResult) => {
|
|
1578
1751
|
//if a build step returns a string,
|
|
1579
1752
|
//a warning is shown but the build is still successful with warnings
|
|
1580
1753
|
if (typeof stepResult === 'string') {
|
|
@@ -1623,26 +1796,29 @@ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0
|
|
|
1623
1796
|
name: 'Copying files to lib folder',
|
|
1624
1797
|
apply: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1625
1798
|
const files = yield glob(packagePath + '/src/**/*.{json,d.ts,css,scss}');
|
|
1626
|
-
return Promise.all(files.map((
|
|
1799
|
+
return Promise.all(files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1627
1800
|
try {
|
|
1628
|
-
yield fs.copy(file, packagePath +
|
|
1629
|
-
|
|
1801
|
+
yield fs.copy(file, packagePath +
|
|
1802
|
+
'/lib/esm/' +
|
|
1803
|
+
file.replace(packagePath + '/src/', ''));
|
|
1804
|
+
yield fs.copy(file, packagePath +
|
|
1805
|
+
'/lib/cjs/' +
|
|
1806
|
+
file.replace(packagePath + '/src/', ''));
|
|
1630
1807
|
return true;
|
|
1631
1808
|
}
|
|
1632
1809
|
catch (err) {
|
|
1633
1810
|
console.warn(err);
|
|
1634
1811
|
return false;
|
|
1635
1812
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
return allResults.every(r => r === true);
|
|
1813
|
+
}))).then((allResults) => {
|
|
1814
|
+
return allResults.every((r) => r === true);
|
|
1639
1815
|
});
|
|
1640
1816
|
}),
|
|
1641
1817
|
});
|
|
1642
1818
|
buildStep({
|
|
1643
1819
|
name: 'Dual package support',
|
|
1644
1820
|
apply: () => {
|
|
1645
|
-
return execPromise('yarn tsconfig-to-dual-package ./tsconfig-cjs.json ./tsconfig-esm.json', false, false, { cwd: packagePath }).then(res => {
|
|
1821
|
+
return execPromise('yarn tsconfig-to-dual-package ./tsconfig-cjs.json ./tsconfig-esm.json', false, false, { cwd: packagePath }).then((res) => {
|
|
1646
1822
|
return res === '';
|
|
1647
1823
|
});
|
|
1648
1824
|
},
|
|
@@ -1657,8 +1833,12 @@ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0
|
|
|
1657
1833
|
name: 'Checking dependencies',
|
|
1658
1834
|
apply: () => depCheck(packagePath),
|
|
1659
1835
|
});
|
|
1660
|
-
let success = yield buildProcess.catch(err => {
|
|
1661
|
-
let msg = typeof err === 'string' || err instanceof Error
|
|
1836
|
+
let success = yield buildProcess.catch((err) => {
|
|
1837
|
+
let msg = typeof err === 'string' || err instanceof Error
|
|
1838
|
+
? err.toString()
|
|
1839
|
+
: err.error && !err.error.toString().includes('Command failed:')
|
|
1840
|
+
? err.error
|
|
1841
|
+
: err.stdout + '\n' + err.stderr;
|
|
1662
1842
|
if (logResults) {
|
|
1663
1843
|
spinner.stopAndPersist({
|
|
1664
1844
|
symbol: chalk.red('✖'),
|
|
@@ -1676,19 +1856,23 @@ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0
|
|
|
1676
1856
|
if (logResults) {
|
|
1677
1857
|
spinner.stopAndPersist({
|
|
1678
1858
|
symbol: chalk.greenBright('✔'),
|
|
1679
|
-
text: success === true
|
|
1859
|
+
text: success === true
|
|
1860
|
+
? 'Build successful'
|
|
1861
|
+
: 'Build successful with warnings',
|
|
1680
1862
|
});
|
|
1681
1863
|
}
|
|
1682
1864
|
}
|
|
1683
1865
|
else {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1866
|
+
if (logResults) {
|
|
1867
|
+
spinner.stopAndPersist({
|
|
1868
|
+
symbol: chalk.red('✖'),
|
|
1869
|
+
text: 'Build failed',
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1688
1872
|
}
|
|
1689
1873
|
return success;
|
|
1690
1874
|
});
|
|
1691
|
-
export const compilePackage = (...
|
|
1875
|
+
export const compilePackage = (...args_11) => __awaiter(void 0, [...args_11], void 0, function* (packagePath = process.cwd()) {
|
|
1692
1876
|
//echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
|
|
1693
1877
|
// let cjsConfig = fs.existsSync(path.join(packagePath,'tsconfig-cjs.json'));
|
|
1694
1878
|
// let esmConfig = fs.existsSync(path.join(packagePath,'tsconfig-esm.json'));
|
|
@@ -1714,18 +1898,20 @@ export const compilePackage = (...args_1) => __awaiter(void 0, [...args_1], void
|
|
|
1714
1898
|
yield compilePackageESM(packagePath);
|
|
1715
1899
|
yield compilePackageCJS(packagePath);
|
|
1716
1900
|
});
|
|
1717
|
-
export const compilePackageESM = (...
|
|
1901
|
+
export const compilePackageESM = (...args_12) => __awaiter(void 0, [...args_12], void 0, function* (packagePath = process.cwd()) {
|
|
1718
1902
|
//echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
|
|
1719
1903
|
let compileCommand = `yarn exec tsc -p tsconfig-esm.json`;
|
|
1720
|
-
return execPromise(compileCommand, false, false, { cwd: packagePath }).then(res => {
|
|
1904
|
+
return execPromise(compileCommand, false, false, { cwd: packagePath }).then((res) => {
|
|
1721
1905
|
return res === '';
|
|
1722
1906
|
});
|
|
1723
1907
|
});
|
|
1724
|
-
export const compilePackageCJS = (...
|
|
1908
|
+
export const compilePackageCJS = (...args_13) => __awaiter(void 0, [...args_13], void 0, function* (packagePath = process.cwd()) {
|
|
1725
1909
|
let compileCommand = `yarn exec tsc -p tsconfig-cjs.json`;
|
|
1726
|
-
return execPromise(compileCommand, false, false, { cwd: packagePath })
|
|
1910
|
+
return execPromise(compileCommand, false, false, { cwd: packagePath })
|
|
1911
|
+
.then((res) => {
|
|
1727
1912
|
return res === '';
|
|
1728
|
-
})
|
|
1913
|
+
})
|
|
1914
|
+
.catch((err) => {
|
|
1729
1915
|
return {
|
|
1730
1916
|
error: err.stdout,
|
|
1731
1917
|
};
|
|
@@ -1842,7 +2028,7 @@ export var publishUpdated = function (test = false) {
|
|
|
1842
2028
|
}))
|
|
1843
2029
|
.catch(({ error, stdout, stderr }) => {
|
|
1844
2030
|
if (error) {
|
|
1845
|
-
console.
|
|
2031
|
+
console.error(error.message);
|
|
1846
2032
|
}
|
|
1847
2033
|
if (stdout) {
|
|
1848
2034
|
console.log(stderr);
|
|
@@ -1920,7 +2106,7 @@ export var publishPackage = function (pkg, test, info, publishVersion) {
|
|
|
1920
2106
|
.then((res) => {
|
|
1921
2107
|
if (res.indexOf('Aborted due to warnings') !== -1 ||
|
|
1922
2108
|
res.indexOf('Could not publish') !== -1 ||
|
|
1923
|
-
res.indexOf(
|
|
2109
|
+
res.indexOf("Couldn't publish") !== -1) {
|
|
1924
2110
|
console.log(res);
|
|
1925
2111
|
return chalk.red(pkg.packageName + ' failed\n');
|
|
1926
2112
|
}
|
|
@@ -1933,7 +2119,7 @@ export var publishPackage = function (pkg, test, info, publishVersion) {
|
|
|
1933
2119
|
chalk.magenta(publishVersion));
|
|
1934
2120
|
})
|
|
1935
2121
|
.catch(({ error, stdout, stderr }) => {
|
|
1936
|
-
|
|
2122
|
+
logError('Failed to publish: ' + error.message);
|
|
1937
2123
|
return chalk.red(pkg.packageName + ' failed to publish');
|
|
1938
2124
|
});
|
|
1939
2125
|
});
|
|
@@ -1995,42 +2181,31 @@ export var buildUpdated = function (back_1, target_1, target2_1) {
|
|
|
1995
2181
|
return chalk.blue(pkg.packageName + ' should be build');
|
|
1996
2182
|
}
|
|
1997
2183
|
log('Building ' + pkg.packageName);
|
|
1998
|
-
|
|
1999
|
-
return execPromise('cd ' +
|
|
2000
|
-
pkg.path +
|
|
2001
|
-
' && yarn build' +
|
|
2002
|
-
(target ? ' ' + target : '') +
|
|
2003
|
-
(target2 ? ' ' + target2 : ''))
|
|
2184
|
+
return buildPackage(null, null, path.join(process.cwd(), pkg.path), false)
|
|
2004
2185
|
.then((res) => {
|
|
2005
|
-
|
|
2186
|
+
//empty string or true is success
|
|
2187
|
+
//false is success with warnings
|
|
2188
|
+
//any other string is the build error text
|
|
2189
|
+
//undefined result means it failed
|
|
2190
|
+
if (typeof res === 'undefined') {
|
|
2191
|
+
logError('Failed to build ' + pkg.packageName);
|
|
2192
|
+
process.exit(1);
|
|
2193
|
+
}
|
|
2194
|
+
else {
|
|
2006
2195
|
debugInfo(chalk.green(pkg.packageName + ' successfully built'));
|
|
2007
2196
|
return chalk.green(pkg.packageName + ' built');
|
|
2008
2197
|
}
|
|
2009
|
-
else if (typeof res === 'string') {
|
|
2010
|
-
warn(chalk.red('Failed to build ' + pkg.packageName));
|
|
2011
|
-
console.log(res);
|
|
2012
|
-
process.exit(1);
|
|
2013
|
-
}
|
|
2014
2198
|
})
|
|
2015
|
-
.catch((
|
|
2016
|
-
|
|
2017
|
-
console.
|
|
2199
|
+
.catch((err) => {
|
|
2200
|
+
logError('Failed to build ' + pkg.packageName);
|
|
2201
|
+
console.error(err);
|
|
2018
2202
|
process.exit(1);
|
|
2019
|
-
// let dependentModules = getDependentPackages(dependencies, pkg);
|
|
2020
|
-
// if (dependentModules.length > 0) {
|
|
2021
|
-
// // printBuildResults(failedModules, done);
|
|
2022
|
-
// warn(chalk.red(pkg.packageName + ' build failed'));
|
|
2023
|
-
// warn(
|
|
2024
|
-
// 'Stopping build-updated process because ' +
|
|
2025
|
-
// dependentModules.length +
|
|
2026
|
-
// ' other packages depend on this package.\n',
|
|
2027
|
-
// ); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
2028
|
-
// }
|
|
2029
2203
|
});
|
|
2030
2204
|
}
|
|
2031
2205
|
});
|
|
2032
|
-
}, (results) => {
|
|
2206
|
+
}, (dependencies, results) => {
|
|
2033
2207
|
if (results.length) {
|
|
2208
|
+
log(chalk.green('Changed packages have been rebuilt'));
|
|
2034
2209
|
log('Summary:');
|
|
2035
2210
|
log(results.join('\n'));
|
|
2036
2211
|
}
|
|
@@ -2070,16 +2245,15 @@ export var executeCommandForEachPackage = function (packages, command, filterMet
|
|
|
2070
2245
|
}
|
|
2071
2246
|
let seen = false;
|
|
2072
2247
|
packages = packages.filter((pkg) => {
|
|
2073
|
-
if (!seen &&
|
|
2074
|
-
pkg.packageName.includes(startFrom)) {
|
|
2248
|
+
if (!seen && pkg.packageName.includes(startFrom)) {
|
|
2075
2249
|
seen = true;
|
|
2076
2250
|
}
|
|
2077
2251
|
return seen;
|
|
2078
2252
|
});
|
|
2079
2253
|
}
|
|
2080
|
-
log(
|
|
2254
|
+
log("Executing '" +
|
|
2081
2255
|
chalk.blueBright(command) +
|
|
2082
|
-
'
|
|
2256
|
+
"' on packages " +
|
|
2083
2257
|
chalk.magenta(packages.map((m) => m.packageName).join(', ')));
|
|
2084
2258
|
var p = Promise.resolve(true);
|
|
2085
2259
|
packages.forEach((pkg) => {
|
|
@@ -2162,11 +2336,11 @@ export var executeCommandForPackage = function (packageName, command) {
|
|
|
2162
2336
|
let packageDetails = getLincdPackages().find((modDetails) => modDetails.packageName.indexOf(packageName) !== -1 ||
|
|
2163
2337
|
modDetails.packageName.indexOf(packageName) !== -1);
|
|
2164
2338
|
if (packageDetails) {
|
|
2165
|
-
log(
|
|
2339
|
+
log("Executing 'cd " +
|
|
2166
2340
|
packageDetails.path +
|
|
2167
2341
|
' && yarn lincd' +
|
|
2168
2342
|
(command ? ' ' + command : '') +
|
|
2169
|
-
'
|
|
2343
|
+
"'");
|
|
2170
2344
|
spawnChild(process.platform === 'win32' ? 'yarn.cmd' : 'yarn', // Windows quirk
|
|
2171
2345
|
['lincd', command || null], {
|
|
2172
2346
|
cwd: packageDetails.path,
|
|
@@ -2174,7 +2348,7 @@ export var executeCommandForPackage = function (packageName, command) {
|
|
|
2174
2348
|
});
|
|
2175
2349
|
}
|
|
2176
2350
|
else {
|
|
2177
|
-
warn(
|
|
2351
|
+
warn("Could not find a pkg who's name (partially) matched " +
|
|
2178
2352
|
chalk.cyan(packageName));
|
|
2179
2353
|
}
|
|
2180
2354
|
};
|