lincd-cli 0.1.23 → 0.2.0
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/package.json +1 -1
- package/defaults/app-with-backend/.gitignore +4 -0
- package/defaults/app-with-backend/package.json +4 -4
- package/defaults/{module → package}/.npmignore +0 -0
- package/defaults/{module → package}/Gruntfile.js +1 -1
- package/defaults/{module → package}/package.json +3 -3
- package/defaults/{module → package}/src/components/ExampleComponent.tsx +0 -0
- package/defaults/{module → package}/src/data/example-ontology.json +0 -0
- package/defaults/{module → package}/src/data/example-ontology.json.d.ts +0 -0
- package/defaults/{module → package}/src/index.ts +0 -0
- package/defaults/{module → package}/src/ontologies/example-ontology.ts +0 -0
- package/defaults/{module → package}/src/package.ts +1 -1
- package/defaults/{module → package}/src/shapes/ExampleShapeClass.ts +0 -0
- package/defaults/{module → package}/tsconfig-es5.json +0 -0
- package/defaults/{module → package}/tsconfig.json +0 -0
- package/lib/cli.js +493 -355
- package/lib/config-webpack.js +4 -3
- package/lib/utils.js +23 -7
- package/package.json +4 -3
package/lib/cli.js
CHANGED
|
@@ -72,6 +72,7 @@ var path = require('path');
|
|
|
72
72
|
var glob = require('glob');
|
|
73
73
|
var variables = {};
|
|
74
74
|
var open = require('open');
|
|
75
|
+
var gruntConfig;
|
|
75
76
|
program
|
|
76
77
|
.command('create-app')
|
|
77
78
|
.action(function (name) {
|
|
@@ -80,19 +81,19 @@ program
|
|
|
80
81
|
.description('Creates a new folder with all the required files for a LINCD app')
|
|
81
82
|
.argument('<name>', 'the name of your LINCD app. To use spaces, wrap the name in double quotes.');
|
|
82
83
|
program
|
|
83
|
-
.command('create-
|
|
84
|
+
.command('create-package')
|
|
84
85
|
.action(function (name, uriBase) {
|
|
85
|
-
return
|
|
86
|
+
return createPackage(name, uriBase);
|
|
86
87
|
})
|
|
87
|
-
.description('Create a new folder with all the required files for a new LINCD
|
|
88
|
-
.argument('<name>', 'The name of the
|
|
89
|
-
.argument('[uri_base]', 'The base URL used for data of this
|
|
88
|
+
.description('Create a new folder with all the required files for a new LINCD package')
|
|
89
|
+
.argument('<name>', 'The name of the package. Will be used as package name in package.json')
|
|
90
|
+
.argument('[uri_base]', 'The base URL used for data of this package. Leave blank to use the URL of your package on lincd.org after you register it');
|
|
90
91
|
program
|
|
91
92
|
.command('create-shape')
|
|
92
93
|
.action(function (name, uriBase) {
|
|
93
94
|
return createShape(name);
|
|
94
95
|
})
|
|
95
|
-
.description('Creates a new ShapeClass file for your
|
|
96
|
+
.description('Creates a new ShapeClass file for your package. Execute this from your package folder.')
|
|
96
97
|
.argument('<name>', 'The name of the shape. Will be used for the file name and the class name');
|
|
97
98
|
program
|
|
98
99
|
.command('create-component')
|
|
@@ -106,9 +107,9 @@ program
|
|
|
106
107
|
.action(function (prefix, uriBase) {
|
|
107
108
|
return createOntology(prefix, uriBase);
|
|
108
109
|
})
|
|
109
|
-
.description('Creates a new ontology file for your
|
|
110
|
+
.description('Creates a new ontology file for your package. Execute this from your package folder.')
|
|
110
111
|
.argument('<suggested-prefix>', 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object')
|
|
111
|
-
.argument('[uribase]', "Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this
|
|
112
|
+
.argument('[uribase]', "Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this package");
|
|
112
113
|
program.command('register-local', { hidden: true }).action(function () {
|
|
113
114
|
register('http://localhost:4101');
|
|
114
115
|
});
|
|
@@ -120,7 +121,7 @@ program
|
|
|
120
121
|
.action(function () {
|
|
121
122
|
register('https://registry.lincd.org');
|
|
122
123
|
})
|
|
123
|
-
.description('Register (a new version of) this
|
|
124
|
+
.description('Register (a new version of) this package to the LINCD registry. If successful your package will appear on www.lincd.org');
|
|
124
125
|
program
|
|
125
126
|
.command('info')
|
|
126
127
|
.action(function () {
|
|
@@ -130,13 +131,15 @@ program
|
|
|
130
131
|
})
|
|
131
132
|
.description("Log the version of this tool and the path that it's running from");
|
|
132
133
|
program.command('build [target] [target2]', { isDefault: true }).action(function (target, target2) {
|
|
133
|
-
|
|
134
|
+
buildPackage(target, target2);
|
|
134
135
|
});
|
|
135
136
|
program.command('publish-updated').action(function () {
|
|
136
137
|
return publishUpdated();
|
|
137
138
|
});
|
|
138
139
|
program.command('status').action(function () {
|
|
140
|
+
//log which packages need to be published
|
|
139
141
|
return publishUpdated(true).then(function () {
|
|
142
|
+
//log which packages need to be build
|
|
140
143
|
return buildUpdated(undefined, '', '', true);
|
|
141
144
|
});
|
|
142
145
|
});
|
|
@@ -149,17 +152,17 @@ program.command('build-updated-since [num-commits-back] [target] [target2]').act
|
|
|
149
152
|
program.command('build-all [target] [target2]').action(function (target, target2) {
|
|
150
153
|
buildAll(target, target2);
|
|
151
154
|
});
|
|
152
|
-
program.command('
|
|
153
|
-
|
|
155
|
+
program.command('all [action] [filter] [filter-value]').action(function (command, filter, filterValue) {
|
|
156
|
+
executeCommandForEachPackage(getLincdPackages(), command, filter, filterValue);
|
|
154
157
|
});
|
|
155
|
-
// program.command('
|
|
158
|
+
// program.command('all-except [excludedSpaces] [action]').action((excludedSpaces, command) => {
|
|
156
159
|
// executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);
|
|
157
160
|
// });
|
|
158
161
|
program.command('dev [target] [mode]').action(function (target, mode) {
|
|
159
|
-
|
|
162
|
+
developPackage(target, mode);
|
|
160
163
|
});
|
|
161
164
|
program
|
|
162
|
-
.command('module|m')
|
|
165
|
+
.command('module|m|package|p|pkg')
|
|
163
166
|
.action(function (name, command, args) {
|
|
164
167
|
var fullCommand = command
|
|
165
168
|
? command +
|
|
@@ -170,11 +173,11 @@ program
|
|
|
170
173
|
.filter(function (a) { return a && true; })
|
|
171
174
|
.join(' ')
|
|
172
175
|
: null;
|
|
173
|
-
|
|
176
|
+
executeCommandForPackage(name, fullCommand);
|
|
174
177
|
})
|
|
175
178
|
.alias('m')
|
|
176
|
-
.description(
|
|
177
|
-
.argument('<name>', 'the name of the
|
|
179
|
+
.description('Searches for a package in this workspace with a partially matching name and executes a command for that package (without needing to execute it from the folder of the package)')
|
|
180
|
+
.argument('<name>', 'the name of the package. Can be a part of the name.')
|
|
178
181
|
.argument('[command]', 'the lincd command you want to execute. Like dev or build')
|
|
179
182
|
.argument('[args...]', 'the additional arguments of that command');
|
|
180
183
|
function logHelp() {
|
|
@@ -189,6 +192,33 @@ function log() {
|
|
|
189
192
|
console.log(chalk.cyan('Info: ') + message);
|
|
190
193
|
});
|
|
191
194
|
}
|
|
195
|
+
function progressUpdate(message) {
|
|
196
|
+
process.stdout.write(' \r');
|
|
197
|
+
process.stdout.write(message + '\r');
|
|
198
|
+
}
|
|
199
|
+
function debugInfo() {
|
|
200
|
+
var messages = [];
|
|
201
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
202
|
+
messages[_i] = arguments[_i];
|
|
203
|
+
}
|
|
204
|
+
// messages.forEach((message) => {
|
|
205
|
+
// console.log(chalk.cyan('Info: ') + message);
|
|
206
|
+
// });
|
|
207
|
+
//@TODO: let packages also use lincd.config.json? instead of gruntfile...
|
|
208
|
+
// that way we can read "analyse" here and see if we need to log debug info
|
|
209
|
+
// if(!gruntConfig)
|
|
210
|
+
// {
|
|
211
|
+
// gruntConfig = getGruntConfig();
|
|
212
|
+
// console.log(gruntConfig);
|
|
213
|
+
// process.exit();
|
|
214
|
+
// }
|
|
215
|
+
// if(gruntConfig.analyse === true)
|
|
216
|
+
// {
|
|
217
|
+
// messages.forEach((message) => {
|
|
218
|
+
// console.log(chalk.cyan('Info: ') + message);
|
|
219
|
+
// });
|
|
220
|
+
// }
|
|
221
|
+
}
|
|
192
222
|
function warn() {
|
|
193
223
|
var messages = [];
|
|
194
224
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -199,7 +229,7 @@ function warn() {
|
|
|
199
229
|
// console.log(chalk.red(message));
|
|
200
230
|
});
|
|
201
231
|
}
|
|
202
|
-
function
|
|
232
|
+
function developPackage(target, mode) {
|
|
203
233
|
if (!target)
|
|
204
234
|
target = 'es6';
|
|
205
235
|
if (mode !== 'production')
|
|
@@ -231,252 +261,270 @@ function checkWorkspaces(rootPath, workspaces, res) {
|
|
|
231
261
|
var folders = fs.readdirSync(workspacePath);
|
|
232
262
|
folders.forEach(function (folder) {
|
|
233
263
|
if (folder !== './' && folder !== '../') {
|
|
234
|
-
|
|
264
|
+
checkPackagePath(rootPath, path.join(workspacePath, folder), res);
|
|
235
265
|
}
|
|
236
266
|
});
|
|
237
267
|
}
|
|
238
268
|
}
|
|
239
269
|
else {
|
|
240
|
-
|
|
270
|
+
checkPackagePath(rootPath, workspacePath, res);
|
|
241
271
|
}
|
|
242
272
|
});
|
|
243
273
|
}
|
|
244
|
-
function
|
|
245
|
-
var
|
|
274
|
+
function checkPackagePath(rootPath, packagePath, res) {
|
|
275
|
+
var packageJsonPath = path.join(packagePath, 'package.json');
|
|
246
276
|
// console.log('checking '+packagePath);
|
|
247
|
-
if (fs.existsSync(
|
|
248
|
-
var pack = JSON.parse(fs.readFileSync(
|
|
249
|
-
//some packages are not true lincd
|
|
277
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
278
|
+
var pack = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
279
|
+
//some packages are not true lincd packages, but we still want them to be re-built automatically. This is what lincd_util is for
|
|
250
280
|
if (pack && pack.workspaces) {
|
|
251
|
-
checkWorkspaces(
|
|
281
|
+
checkWorkspaces(packagePath, pack.workspaces, res);
|
|
252
282
|
}
|
|
253
283
|
else if (pack && pack.lincd === true) {
|
|
254
284
|
res.push({
|
|
255
|
-
path:
|
|
256
|
-
moduleName: pack.name,
|
|
285
|
+
path: packagePath,
|
|
257
286
|
packageName: pack.name
|
|
258
287
|
});
|
|
259
288
|
}
|
|
260
289
|
}
|
|
261
290
|
}
|
|
262
|
-
function
|
|
291
|
+
function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStackEnd) {
|
|
263
292
|
var _this = this;
|
|
264
293
|
var dependencies = new Map();
|
|
265
|
-
|
|
266
|
-
var
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
modules.forEach(function (module) {
|
|
270
|
-
var pack = (0, utils_1.getPackageJSON)(module.path);
|
|
294
|
+
//get dependencies of each package
|
|
295
|
+
var leastDependentPackage;
|
|
296
|
+
lincdPackages.forEach(function (pkg) {
|
|
297
|
+
var pack = (0, utils_1.getPackageJSON)(pkg.path);
|
|
271
298
|
if (pack) {
|
|
272
|
-
//get lincd related dependencies and get the actual
|
|
273
|
-
var
|
|
274
|
-
.filter(function (dependency) { return
|
|
299
|
+
//get lincd related dependencies and get the actual package details from the package map by removing '@dacore/' from the package name
|
|
300
|
+
var packageDependencies = Object.keys(pack.dependencies)
|
|
301
|
+
.filter(function (dependency) { return lincdPackages.has(dependency); })
|
|
275
302
|
.map(function (dependency) {
|
|
276
|
-
return
|
|
303
|
+
return lincdPackages.has(dependency) ? lincdPackages.get(dependency) : dependency;
|
|
277
304
|
});
|
|
278
|
-
// console.log(
|
|
279
|
-
dependencies.set(
|
|
305
|
+
// console.log(package.packageName,packageDependencies.map())
|
|
306
|
+
dependencies.set(pkg, packageDependencies);
|
|
280
307
|
}
|
|
281
308
|
});
|
|
282
|
-
dependencies.forEach(function (
|
|
283
|
-
if (!
|
|
284
|
-
return typeof dependency !== 'string' &&
|
|
309
|
+
dependencies.forEach(function (PackageDependencies, pkg) {
|
|
310
|
+
if (!PackageDependencies.some(function (dependency) {
|
|
311
|
+
return typeof dependency !== 'string' && lincdPackages.has(dependency.packageName);
|
|
285
312
|
})) {
|
|
286
|
-
|
|
313
|
+
leastDependentPackage = pkg;
|
|
287
314
|
}
|
|
288
315
|
});
|
|
289
|
-
var
|
|
290
|
-
//by default start building
|
|
291
|
-
var building = true;
|
|
292
|
-
//option to start from a specific module in the stack
|
|
293
|
-
if (target == 'from') {
|
|
294
|
-
startFrom = target2;
|
|
295
|
-
//if we have a startFrom, then we havnt started the build process yet
|
|
296
|
-
building = startFrom ? false : true;
|
|
297
|
-
//clear targets
|
|
298
|
-
target = '';
|
|
299
|
-
target2 = '';
|
|
300
|
-
console.log(chalk.blue('Will skip builds until ' + startFrom));
|
|
301
|
-
}
|
|
302
|
-
var stack = [leastDependentModule];
|
|
316
|
+
var startStack = [leastDependentPackage];
|
|
303
317
|
var done = new Set();
|
|
304
|
-
var
|
|
305
|
-
var runStack = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
306
|
-
var
|
|
318
|
+
var results = [];
|
|
319
|
+
var runStack = function (stack) { return __awaiter(_this, void 0, void 0, function () {
|
|
320
|
+
var runFunction, stackPromise, stackResults;
|
|
307
321
|
return __generator(this, function (_a) {
|
|
308
322
|
switch (_a.label) {
|
|
309
323
|
case 0:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
console.log(chalk.magenta('\n-------\nThese modules are next, since all their dependencies have now been build:'));
|
|
313
|
-
console.log(chalk.magenta(stack.map(function (i) { return i.moduleName; })));
|
|
314
|
-
// log(stack);
|
|
315
|
-
}
|
|
316
|
-
failedModules = [];
|
|
317
|
-
stackPromise = Promise.all(stack.map(function (module) {
|
|
324
|
+
runFunction = onBuildStack(stack, dependencies);
|
|
325
|
+
stackPromise = Promise.all(stack.map(function (pck) {
|
|
318
326
|
// p = p.then(() => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
//
|
|
323
|
-
|
|
324
|
-
building = true;
|
|
325
|
-
}
|
|
326
|
-
//else still waiting for the module
|
|
327
|
-
else {
|
|
328
|
-
log(chalk.blue('skipping ' + module.moduleName));
|
|
329
|
-
command = Promise.resolve(true);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
//unless told otherwise, build the module
|
|
333
|
-
if (!command) {
|
|
334
|
-
command = execp('cd ' +
|
|
335
|
-
module.path +
|
|
336
|
-
' && yarn lincd build' +
|
|
337
|
-
(target ? ' ' + target : '') +
|
|
338
|
-
(target2 ? ' ' + target2 : ''));
|
|
339
|
-
log(chalk.cyan('Building ' + module.moduleName));
|
|
340
|
-
}
|
|
341
|
-
return command["catch"](function (err) {
|
|
342
|
-
var dependentModules = [];
|
|
343
|
-
dependencies.forEach(function (dModuleDependencies, dModule) {
|
|
344
|
-
if (dModuleDependencies.indexOf(module) !== -1) {
|
|
345
|
-
dependentModules.push(dModule);
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
if (dependentModules.length > 0) {
|
|
349
|
-
failedModules.push(module.moduleName);
|
|
350
|
-
printBuildResults(failedModules, done);
|
|
351
|
-
console.log(chalk.magenta('Stopping build process because an error occurred whilst building ' +
|
|
352
|
-
module.moduleName +
|
|
353
|
-
', which ' +
|
|
354
|
-
dependentModules.length +
|
|
355
|
-
' other modules depend on.')); //"+dependentModules.map(d => d.moduleName).join(", ")));
|
|
356
|
-
console.log(chalk.cyanBright('tip ') +
|
|
357
|
-
'Run ' +
|
|
358
|
-
chalk.green("lincd build-all from ".concat(module.moduleName)) +
|
|
359
|
-
' to build only the remaining modules'); //"+dependentModules.map(d => d.moduleName).join(", ")));
|
|
360
|
-
process.exit(1);
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
failedModules.push(module.moduleName);
|
|
364
|
-
}
|
|
327
|
+
return runFunction(pck)["catch"](function (_a) {
|
|
328
|
+
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
329
|
+
warn('Uncaught exception whilst running parallel function on ' + pck.packageName, error.message);
|
|
330
|
+
// warn(chalk.red(pck.packageName+' failed:'));
|
|
331
|
+
// console.log(stdout);
|
|
365
332
|
})
|
|
366
333
|
.then(function (res) {
|
|
367
|
-
|
|
368
|
-
// if(res && res.includes("Aborted due to warnings"))
|
|
369
|
-
// {
|
|
370
|
-
// failedModules.push(module.moduleName);
|
|
371
|
-
// }
|
|
372
|
-
// else
|
|
373
|
-
// {
|
|
374
|
-
done.add(module);
|
|
375
|
-
// }
|
|
376
|
-
modulesLeft--;
|
|
377
|
-
log(chalk.magenta(modulesLeft + ' modules left'));
|
|
378
|
-
if (modulesLeft == 0) {
|
|
379
|
-
printBuildResults(failedModules, done);
|
|
380
|
-
}
|
|
334
|
+
done.add(pck);
|
|
381
335
|
return res;
|
|
382
336
|
});
|
|
383
|
-
// });
|
|
384
|
-
// done.add(module);
|
|
385
337
|
}));
|
|
386
|
-
//wait till stack is completed
|
|
387
338
|
return [4 /*yield*/, stackPromise];
|
|
388
339
|
case 1:
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
// await p;
|
|
340
|
+
stackResults = _a.sent();
|
|
341
|
+
results = results.concat(stackResults);
|
|
392
342
|
//clear stack for next round
|
|
393
343
|
stack = [];
|
|
394
|
-
//find those
|
|
395
|
-
|
|
396
|
-
var deps = dependencies.get(
|
|
397
|
-
//if the
|
|
344
|
+
//find those packages who have all their dependencies already built and add them to the stack
|
|
345
|
+
lincdPackages.forEach(function (pkg) {
|
|
346
|
+
var deps = dependencies.get(pkg);
|
|
347
|
+
//if the package is not done yet
|
|
398
348
|
//but every dependency is now done OR was not something we can build (some @dacore dependencies may not be local)
|
|
399
|
-
if (!done.has(
|
|
349
|
+
if (!done.has(pkg) &&
|
|
400
350
|
deps.every(function (dependency) {
|
|
401
|
-
return typeof dependency !== 'string' && (done.has(dependency) || !
|
|
351
|
+
return typeof dependency !== 'string' && (done.has(dependency) || !lincdPackages.has(dependency.packageName));
|
|
402
352
|
})) {
|
|
403
|
-
stack.push(
|
|
353
|
+
stack.push(pkg);
|
|
404
354
|
}
|
|
405
|
-
// else if(!done.has(
|
|
355
|
+
// else if(!done.has(package))
|
|
406
356
|
// {
|
|
407
|
-
// console.log(chalk.red(
|
|
357
|
+
// console.log(chalk.red(package+' not yet'))
|
|
408
358
|
// console.log('UNMET DEPS: '+deps.filter(dependency => !done.has(dependency)).join(" "))
|
|
409
359
|
// }
|
|
410
360
|
});
|
|
411
361
|
//if more to be built, iterate
|
|
412
362
|
if (stack.length > 0) {
|
|
413
|
-
return [2 /*return*/, runStack()];
|
|
363
|
+
return [2 /*return*/, runStack(stack)];
|
|
414
364
|
}
|
|
415
365
|
else {
|
|
416
|
-
|
|
417
|
-
if (!building) {
|
|
418
|
-
console.log(chalk.red('Could not find the module to start from. Please provide a correct package name or module name to build from'));
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
first_1 = true;
|
|
422
|
-
modules.forEach(function (module) {
|
|
423
|
-
if (!done.has(module)) {
|
|
424
|
-
var deps = dependencies.get(module);
|
|
425
|
-
if (first_1) {
|
|
426
|
-
console.log(chalk.red('CYCLICAL DEPENDENCIES? - could not build some modules because they depend on each other.'));
|
|
427
|
-
first_1 = false;
|
|
428
|
-
}
|
|
429
|
-
//print the cyclical dependencies
|
|
430
|
-
console.log(chalk.red(module.moduleName) +
|
|
431
|
-
' depends on ' +
|
|
432
|
-
deps
|
|
433
|
-
.filter(function (dependency) {
|
|
434
|
-
return typeof dependency !== 'string';
|
|
435
|
-
})
|
|
436
|
-
.map(function (d) {
|
|
437
|
-
return done.has(d) ? d.moduleName : chalk.red(d.moduleName);
|
|
438
|
-
})
|
|
439
|
-
.join(', '));
|
|
440
|
-
//also print some information why these modules have not been moved into the stack
|
|
441
|
-
var stringDependencies = deps.filter(function (d) { return typeof d === 'string'; });
|
|
442
|
-
if (stringDependencies.length > 0) {
|
|
443
|
-
console.log(chalk.red('And it depends on these module(s) - which seem not to be proper modules :' +
|
|
444
|
-
stringDependencies.join(', ')));
|
|
445
|
-
console.log(chalk.red('Could you remove this from dependencies? Should it be a devDependency?'));
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
}
|
|
366
|
+
onStackEnd(results.filter(Boolean));
|
|
450
367
|
}
|
|
451
368
|
return [2 /*return*/];
|
|
452
369
|
}
|
|
453
370
|
});
|
|
454
371
|
}); };
|
|
455
372
|
//starts the process
|
|
456
|
-
runStack();
|
|
373
|
+
runStack(startStack);
|
|
374
|
+
}
|
|
375
|
+
function buildAll(target, target2) {
|
|
376
|
+
var _this = this;
|
|
377
|
+
console.log('Building all LINCD packages of this repository in order of dependencies');
|
|
378
|
+
var lincdPackages = getLocalLincdPackageMap();
|
|
379
|
+
var startFrom;
|
|
380
|
+
//by default start building
|
|
381
|
+
var building = true;
|
|
382
|
+
//option to start from a specific package in the stack
|
|
383
|
+
if (target == 'from') {
|
|
384
|
+
startFrom = target2;
|
|
385
|
+
//if we have a startFrom, then we havnt started the build process yet
|
|
386
|
+
building = startFrom ? false : true;
|
|
387
|
+
//clear targets
|
|
388
|
+
target = '';
|
|
389
|
+
target2 = '';
|
|
390
|
+
console.log(chalk.blue('Will skip builds until ' + startFrom));
|
|
391
|
+
return function (pkg) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
392
|
+
return [2 /*return*/];
|
|
393
|
+
}); }); };
|
|
394
|
+
}
|
|
395
|
+
var done = new Set();
|
|
396
|
+
var failedModules = [];
|
|
397
|
+
progressUpdate(lincdPackages.size + ' packages left');
|
|
398
|
+
var packagesLeft = lincdPackages.size;
|
|
399
|
+
// let packagesLeft = lincdPackages.size - done.size;
|
|
400
|
+
runOnPackagesGroupedByDependencies(lincdPackages, function (packageGroup, dependencies) {
|
|
401
|
+
if (done.size > 0) {
|
|
402
|
+
debugInfo(chalk.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
|
|
403
|
+
// log(stack);
|
|
404
|
+
}
|
|
405
|
+
debugInfo('Now building: ' + chalk.blue(packageGroup.map(function (i) { return i.packageName; })));
|
|
406
|
+
return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
|
|
407
|
+
var command;
|
|
408
|
+
return __generator(this, function (_a) {
|
|
409
|
+
//if we're skipping builds until a certain package
|
|
410
|
+
if (!building) {
|
|
411
|
+
//if the package name matches the package we're supposed to start from then start building packages
|
|
412
|
+
if (pkg.packageName == startFrom || pkg.packageName == startFrom) {
|
|
413
|
+
building = true;
|
|
414
|
+
}
|
|
415
|
+
//else still waiting for the package
|
|
416
|
+
else {
|
|
417
|
+
log(chalk.blue('skipping ' + pkg.packageName));
|
|
418
|
+
command = Promise.resolve(true);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
//unless told otherwise, build the package
|
|
422
|
+
if (!command) {
|
|
423
|
+
command = execPromise('cd ' + pkg.path + ' && yarn lincd build' + (target ? ' ' + target : '') + (target2 ? ' ' + target2 : ''), false, false, {}, false);
|
|
424
|
+
debugInfo(chalk.cyan('Building ' + pkg.packageName));
|
|
425
|
+
}
|
|
426
|
+
return [2 /*return*/, command["catch"](function (_a) {
|
|
427
|
+
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
428
|
+
//this prints out the webpack output, including the build errors
|
|
429
|
+
warn('Failed to build ' + pkg.packageName);
|
|
430
|
+
console.log(stdout);
|
|
431
|
+
failedModules.push(pkg.packageName);
|
|
432
|
+
var dependentModules = getDependentPackages(dependencies, pkg);
|
|
433
|
+
if (dependentModules.length > 0) {
|
|
434
|
+
printBuildResults(failedModules, done);
|
|
435
|
+
console.log(chalk.magenta('Stopping build process because an error occurred whilst building ' +
|
|
436
|
+
pkg.packageName +
|
|
437
|
+
', which ' +
|
|
438
|
+
dependentModules.length +
|
|
439
|
+
' other packages depend on.')); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
440
|
+
console.log(chalk.cyanBright('tip ') +
|
|
441
|
+
'Run ' +
|
|
442
|
+
chalk.green("lincd build-all from ".concat(pkg.packageName)) +
|
|
443
|
+
' to build only the remaining packages'); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}
|
|
446
|
+
})
|
|
447
|
+
.then(function (res) {
|
|
448
|
+
done.add(pkg);
|
|
449
|
+
packagesLeft--;
|
|
450
|
+
// log(chalk.magenta(packagesLeft + ' packages left'));
|
|
451
|
+
process.stdout.write(packagesLeft + ' packages left\r');
|
|
452
|
+
if (packagesLeft == 0) {
|
|
453
|
+
printBuildResults(failedModules, done);
|
|
454
|
+
}
|
|
455
|
+
return res;
|
|
456
|
+
})];
|
|
457
|
+
});
|
|
458
|
+
}); };
|
|
459
|
+
}, function (dependencies) {
|
|
460
|
+
//if no more packages to build but we never started building...
|
|
461
|
+
if (!building) {
|
|
462
|
+
console.log(chalk.red('Could not find the package to start from. Please provide a correct package name or package name to build from'));
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
//Detecting cyclical dependencies that caused some packages not to be build
|
|
466
|
+
var first_1 = true;
|
|
467
|
+
lincdPackages.forEach(function (pkg) {
|
|
468
|
+
if (!done.has(pkg)) {
|
|
469
|
+
var deps = dependencies.get(pkg);
|
|
470
|
+
if (first_1) {
|
|
471
|
+
console.log(chalk.red('CYCLICAL DEPENDENCIES? - could not build some packages because they depend on each other.'));
|
|
472
|
+
first_1 = false;
|
|
473
|
+
}
|
|
474
|
+
//print the cyclical dependencies
|
|
475
|
+
console.log(chalk.red(pkg.packageName) +
|
|
476
|
+
' depends on ' +
|
|
477
|
+
deps
|
|
478
|
+
.filter(function (dependency) {
|
|
479
|
+
return typeof dependency !== 'string';
|
|
480
|
+
})
|
|
481
|
+
.map(function (d) {
|
|
482
|
+
return done.has(d) ? d.packageName : chalk.red(d.packageName);
|
|
483
|
+
})
|
|
484
|
+
.join(', '));
|
|
485
|
+
//also print some information why these packages have not been moved into the stack
|
|
486
|
+
var stringDependencies = deps.filter(function (d) { return typeof d === 'string'; });
|
|
487
|
+
if (stringDependencies.length > 0) {
|
|
488
|
+
console.log(chalk.red('And it depends on these package(s) - which seem not to be proper packages :' +
|
|
489
|
+
stringDependencies.join(', ')));
|
|
490
|
+
console.log(chalk.red('Could you remove this from dependencies? Should it be a devDependency?'));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
function getDependentPackages(dependencies, pkg) {
|
|
498
|
+
var dependentModules = [];
|
|
499
|
+
dependencies.forEach(function (dModuleDependencies, dModule) {
|
|
500
|
+
if (dModuleDependencies.indexOf(pkg) !== -1) {
|
|
501
|
+
dependentModules.push(dModule);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
return dependentModules;
|
|
457
505
|
}
|
|
458
506
|
/**
|
|
459
|
-
* Returns a map of the
|
|
507
|
+
* Returns a map of the packages that this repository manages (so no packages found through the workspaces who's path contains ../ )
|
|
460
508
|
* @param rootPath
|
|
461
509
|
*/
|
|
462
|
-
function
|
|
510
|
+
function getLocalLincdPackageMap(rootPath) {
|
|
463
511
|
if (rootPath === void 0) { rootPath = './'; }
|
|
464
512
|
var map = new Map();
|
|
465
|
-
|
|
466
|
-
if (
|
|
467
|
-
// console.log(
|
|
468
|
-
map.set(
|
|
513
|
+
getLincdPackages(rootPath).forEach(function (pkg) {
|
|
514
|
+
if (pkg.path.indexOf('../') === -1 && pkg.path.indexOf('..\\') === -1) {
|
|
515
|
+
// console.log(package.path);
|
|
516
|
+
map.set(pkg.packageName, pkg);
|
|
469
517
|
}
|
|
470
518
|
});
|
|
471
519
|
return map;
|
|
472
520
|
}
|
|
473
521
|
function getLocalLincdModules(rootPath) {
|
|
474
522
|
if (rootPath === void 0) { rootPath = './'; }
|
|
475
|
-
return
|
|
476
|
-
return
|
|
523
|
+
return getLincdPackages(rootPath).filter(function (pkg) {
|
|
524
|
+
return pkg.path.indexOf('..\\') === -1;
|
|
477
525
|
});
|
|
478
526
|
}
|
|
479
|
-
function
|
|
527
|
+
function getLincdPackages(rootPath) {
|
|
480
528
|
if (rootPath === void 0) { rootPath = process.cwd(); }
|
|
481
529
|
var pack = (0, utils_1.getPackageJSON)();
|
|
482
530
|
if (!pack || !pack.workspaces) {
|
|
@@ -558,16 +606,17 @@ function execp(cmd, log, allowError, options) {
|
|
|
558
606
|
});
|
|
559
607
|
});
|
|
560
608
|
}
|
|
561
|
-
function execPromise(command, log, allowError, options) {
|
|
609
|
+
function execPromise(command, log, allowError, options, pipeOutput) {
|
|
562
610
|
if (log === void 0) { log = false; }
|
|
563
611
|
if (allowError === void 0) { allowError = false; }
|
|
612
|
+
if (pipeOutput === void 0) { pipeOutput = false; }
|
|
564
613
|
return new Promise(function (resolve, reject) {
|
|
565
614
|
if (log)
|
|
566
615
|
console.log(chalk.cyan(command));
|
|
567
|
-
exec(command, options, function (error, stdout, stderr) {
|
|
616
|
+
var child = exec(command, options, function (error, stdout, stderr) {
|
|
568
617
|
if (error) {
|
|
569
618
|
if (!allowError) {
|
|
570
|
-
reject(error
|
|
619
|
+
reject({ error: error, stdout: stdout, stderr: stderr });
|
|
571
620
|
return;
|
|
572
621
|
}
|
|
573
622
|
else if (log) {
|
|
@@ -583,6 +632,10 @@ function execPromise(command, log, allowError, options) {
|
|
|
583
632
|
}
|
|
584
633
|
resolve(result);
|
|
585
634
|
});
|
|
635
|
+
if (pipeOutput) {
|
|
636
|
+
child.stdout.pipe(process.stdout);
|
|
637
|
+
child.stderr.pipe(process.stderr);
|
|
638
|
+
}
|
|
586
639
|
});
|
|
587
640
|
}
|
|
588
641
|
var replaceVariablesInFile = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -606,9 +659,7 @@ var replaceCurlyVariables = function (string) {
|
|
|
606
659
|
};
|
|
607
660
|
var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1); };
|
|
608
661
|
var camelCase = function (str) {
|
|
609
|
-
var string = str
|
|
610
|
-
.replace(/[^A-Za-z0-9]/g, ' ')
|
|
611
|
-
.split(' ');
|
|
662
|
+
var string = str.replace(/[^A-Za-z0-9]/g, ' ').split(' ');
|
|
612
663
|
if (string.length > 1) {
|
|
613
664
|
return string.reduce(function (result, word) { return result + capitalize(word); });
|
|
614
665
|
}
|
|
@@ -634,11 +685,11 @@ var createOntology = function (prefix, uriBase, basePath) {
|
|
|
634
685
|
//copy ontology accessor file
|
|
635
686
|
log("Creating files for ontology '" + prefix + "'");
|
|
636
687
|
targetFile = path.join(targetFolder, hyphenName + '.ts');
|
|
637
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', '
|
|
688
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
|
|
638
689
|
targetDataFile = path.join(targetFolder, '..', 'data', hyphenName + '.json');
|
|
639
690
|
targetDataFile2 = path.join(targetFolder, '..', 'data', hyphenName + '.json.d.ts');
|
|
640
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', '
|
|
641
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', '
|
|
691
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json'), targetDataFile);
|
|
692
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
|
|
642
693
|
return [4 /*yield*/, replaceVariablesInFiles(targetFile, targetDataFile, targetDataFile2)];
|
|
643
694
|
case 1:
|
|
644
695
|
_b.sent();
|
|
@@ -729,7 +780,7 @@ var ensureFolderExists = function () {
|
|
|
729
780
|
fs.mkdirSync(targetFolder);
|
|
730
781
|
} else {
|
|
731
782
|
warn(
|
|
732
|
-
`Please run this command from the root of your
|
|
783
|
+
`Please run this command from the root of your package. This command expects ${parentDirectory.toString()} to exists from that folder`,
|
|
733
784
|
);
|
|
734
785
|
}
|
|
735
786
|
}
|
|
@@ -737,7 +788,7 @@ var ensureFolderExists = function () {
|
|
|
737
788
|
};
|
|
738
789
|
var setNameVariables = function (name) {
|
|
739
790
|
var hyphenName = name.replace(/[-_\s]+/g, '-');
|
|
740
|
-
var camelCaseName = camelCase(name); //some-
|
|
791
|
+
var camelCaseName = camelCase(name); //some-package --> someModule
|
|
741
792
|
var underscoreName = name.replace(/[-\s]+/g, '_');
|
|
742
793
|
//longer similar variables names should come before the shorter ones
|
|
743
794
|
setVariable('underscore_name', underscoreName);
|
|
@@ -798,7 +849,7 @@ var createComponent = function (name, basePath) {
|
|
|
798
849
|
});
|
|
799
850
|
});
|
|
800
851
|
};
|
|
801
|
-
var
|
|
852
|
+
var createPackage = function (name, uriBase, basePath) {
|
|
802
853
|
if (basePath === void 0) { basePath = process.cwd(); }
|
|
803
854
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
804
855
|
var _a, packageName, scope, cleanPackageName, targetFolder, _b, hyphenName, camelCaseName, underscoreName, version, installCommand;
|
|
@@ -806,9 +857,9 @@ var createModule = function (name, uriBase, basePath) {
|
|
|
806
857
|
switch (_c.label) {
|
|
807
858
|
case 0:
|
|
808
859
|
//if ran with npx, basePath will be the root directory of the repository, even if we're executing from a sub folder (the root directory is where node_modules lives and package.json with workspaces)
|
|
809
|
-
//so we manually find a
|
|
810
|
-
if (fs.existsSync(path.join(basePath, '
|
|
811
|
-
basePath = path.join(basePath, '
|
|
860
|
+
//so we manually find a packages folder, if it exists we go into that.
|
|
861
|
+
if (fs.existsSync(path.join(basePath, 'packages'))) {
|
|
862
|
+
basePath = path.join(basePath, 'packages');
|
|
812
863
|
}
|
|
813
864
|
if (!name) {
|
|
814
865
|
console.warn('Please provide a name as the first argument');
|
|
@@ -825,13 +876,13 @@ var createModule = function (name, uriBase, basePath) {
|
|
|
825
876
|
// --> match[0] = @dacore/some-mod
|
|
826
877
|
// --> match[1] = @dacore
|
|
827
878
|
// --> match[2] = some-mod
|
|
828
|
-
//but save full scoped
|
|
829
|
-
setVariable('
|
|
879
|
+
//but save full scoped package name under ${package_name}
|
|
880
|
+
setVariable('package_name', name);
|
|
830
881
|
//extra variable for clarity (will be same as 'name')
|
|
831
882
|
setVariable('output_file_name', name);
|
|
832
883
|
_b = setNameVariables(cleanPackageName), hyphenName = _b.hyphenName, camelCaseName = _b.camelCaseName, underscoreName = _b.underscoreName;
|
|
833
|
-
log("Creating new LINCD
|
|
834
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', '
|
|
884
|
+
log("Creating new LINCD package '" + name + "'");
|
|
885
|
+
fs.copySync(path.join(__dirname, '..', 'defaults', 'package'), targetFolder);
|
|
835
886
|
//replace variables in some of the copied files
|
|
836
887
|
return [4 /*yield*/, Promise.all([
|
|
837
888
|
'src/index.ts',
|
|
@@ -849,7 +900,7 @@ var createModule = function (name, uriBase, basePath) {
|
|
|
849
900
|
case 1:
|
|
850
901
|
//replace variables in some of the copied files
|
|
851
902
|
_c.sent();
|
|
852
|
-
//rename these to a file name similar to the
|
|
903
|
+
//rename these to a file name similar to the pkg name
|
|
853
904
|
[
|
|
854
905
|
'src/ontologies/example-ontology.ts',
|
|
855
906
|
'src/data/example-ontology.json',
|
|
@@ -874,7 +925,7 @@ var createModule = function (name, uriBase, basePath) {
|
|
|
874
925
|
})];
|
|
875
926
|
case 3:
|
|
876
927
|
_c.sent();
|
|
877
|
-
log("Prepared a new LINCD
|
|
928
|
+
log("Prepared a new LINCD package in ".concat(chalk.magenta(targetFolder)), "Run ".concat(chalk.blueBright('yarn build'), " from this directory to build once"), "Or ".concat(chalk.blueBright('yarn dev'), " to continuously rebuild on file changes"));
|
|
878
929
|
return [2 /*return*/];
|
|
879
930
|
}
|
|
880
931
|
});
|
|
@@ -945,7 +996,7 @@ var buildFailed = function (output) {
|
|
|
945
996
|
var pack = JSON.parse(
|
|
946
997
|
fs.readFileSync(process.cwd() + '/package.json', 'utf8'),
|
|
947
998
|
);
|
|
948
|
-
let
|
|
999
|
+
let packageName = pack.name;
|
|
949
1000
|
|
|
950
1001
|
//just making sure the library is loaded in correct order because circular references are currently happening when importing BlankNode before NamedNode for example
|
|
951
1002
|
// require('lincd');
|
|
@@ -956,12 +1007,12 @@ var buildFailed = function (output) {
|
|
|
956
1007
|
let shapeJSONLD = await getShapesJSONLD(indexExports.packageExports);
|
|
957
1008
|
console.log(indexExports.packageExports);
|
|
958
1009
|
console.log(shapeJSONLD);
|
|
959
|
-
console.log(chalk.bold(chalk.green(
|
|
1010
|
+
console.log(chalk.bold(chalk.green(packageName+'/dist/shapes.json')));
|
|
960
1011
|
return fs.writeFile(path.join('dist', 'shapes.json'), shapeJSONLD);
|
|
961
1012
|
}
|
|
962
1013
|
else
|
|
963
1014
|
{
|
|
964
|
-
console.warn("Invalid LINCD
|
|
1015
|
+
console.warn("Invalid LINCD package. Index file should export a packageExports object. See examples.")
|
|
965
1016
|
}
|
|
966
1017
|
|
|
967
1018
|
} else {
|
|
@@ -972,7 +1023,7 @@ var register = function (registryURL) {
|
|
|
972
1023
|
if (fs.existsSync(process.cwd() + '/package.json')) {
|
|
973
1024
|
var pack = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
|
|
974
1025
|
var version = pack.version;
|
|
975
|
-
var
|
|
1026
|
+
var packageName = pack.name;
|
|
976
1027
|
// let author = pack.author;
|
|
977
1028
|
// let description = pack.description;
|
|
978
1029
|
//
|
|
@@ -980,14 +1031,14 @@ var register = function (registryURL) {
|
|
|
980
1031
|
// if (pack.author.name) {
|
|
981
1032
|
// authorName = pack.author.name;
|
|
982
1033
|
// }
|
|
983
|
-
console.log(chalk.cyan('registering package ' +
|
|
1034
|
+
console.log(chalk.cyan('registering package ' + packageName + ' ' + version + ' in the LINCD registry'));
|
|
984
1035
|
return fetch(registryURL + '/register', {
|
|
985
1036
|
method: 'POST',
|
|
986
1037
|
headers: {
|
|
987
1038
|
Accept: 'application/json, text/plain, */*',
|
|
988
1039
|
'Content-Type': 'application/json'
|
|
989
1040
|
},
|
|
990
|
-
body: JSON.stringify({ package:
|
|
1041
|
+
body: JSON.stringify({ package: packageName, version: version })
|
|
991
1042
|
})
|
|
992
1043
|
.then(function (res) { return res.json(); })
|
|
993
1044
|
.then(function (json) {
|
|
@@ -1008,12 +1059,12 @@ var register = function (registryURL) {
|
|
|
1008
1059
|
console.warn(chalk.red('Warning:') + ' not found: ' + process.cwd() + '/package.json');
|
|
1009
1060
|
}
|
|
1010
1061
|
};
|
|
1011
|
-
var
|
|
1012
|
-
if (
|
|
1062
|
+
var buildPackage = function (target, target2, packagePath, logResults) {
|
|
1063
|
+
if (packagePath === void 0) { packagePath = process.cwd(); }
|
|
1013
1064
|
if (logResults === void 0) { logResults = true; }
|
|
1014
1065
|
if (target == 'production' || target == 'es5' || target == 'es6' || !target) {
|
|
1015
|
-
if (!fs.existsSync(path.join(
|
|
1016
|
-
console.warn("No Gruntfile found at ".concat(
|
|
1066
|
+
if (!fs.existsSync(path.join(packagePath, 'Gruntfile.js'))) {
|
|
1067
|
+
console.warn("No Gruntfile found at ".concat(packagePath, "\\Gruntfile.js. Cannot build."));
|
|
1017
1068
|
return;
|
|
1018
1069
|
}
|
|
1019
1070
|
var nodeEnv = '';
|
|
@@ -1041,7 +1092,7 @@ var buildModule = function (target, target2, modulePath, logResults) {
|
|
|
1041
1092
|
' --color');
|
|
1042
1093
|
var method = logResults ? execp : execPromise;
|
|
1043
1094
|
//execute the command to build the method, and provide the current work directory as option
|
|
1044
|
-
return method(nodeEnv + 'grunt build' + (target ? '-' + target : '') + (target2 ? '-' + target2 : '') + ' --color', false, false, { cwd:
|
|
1095
|
+
return method(nodeEnv + 'grunt build' + (target ? '-' + target : '') + (target2 ? '-' + target2 : '') + ' --color', false, false, { cwd: packagePath })["catch"](function (err) {
|
|
1045
1096
|
process.exit(1);
|
|
1046
1097
|
});
|
|
1047
1098
|
}
|
|
@@ -1049,21 +1100,26 @@ var buildModule = function (target, target2, modulePath, logResults) {
|
|
|
1049
1100
|
console.warn('unknown build target. Use es5, es6 or production.');
|
|
1050
1101
|
}
|
|
1051
1102
|
};
|
|
1052
|
-
var getLastBuildTime = function (
|
|
1053
|
-
return getLastModifiedFile(
|
|
1103
|
+
var getLastBuildTime = function (packagePath) {
|
|
1104
|
+
return getLastModifiedFile(packagePath + '/@(builds|lib|dist)/**/*.js');
|
|
1054
1105
|
};
|
|
1055
|
-
var getLastModifiedSourceTime = function (
|
|
1056
|
-
return getLastModifiedFile(
|
|
1057
|
-
ignore: [
|
|
1106
|
+
var getLastModifiedSourceTime = function (packagePath) {
|
|
1107
|
+
return getLastModifiedFile(packagePath + '/@(src|data|scss)/**/*', {
|
|
1108
|
+
ignore: [packagePath + '/**/*.scss.json', packagePath + '/**/*.d.ts']
|
|
1058
1109
|
});
|
|
1059
1110
|
};
|
|
1060
|
-
var getLastCommitTime = function (
|
|
1061
|
-
// console.log(`git log -1 --format=%ci -- ${
|
|
1111
|
+
var getLastCommitTime = function (packagePath) {
|
|
1112
|
+
// console.log(`git log -1 --format=%ci -- ${packagePath}`);
|
|
1062
1113
|
// process.exit();
|
|
1063
|
-
return execPromise("git log -1 --format=%ci -- ".concat(
|
|
1114
|
+
return execPromise("git log -1 --format=%ci -- ".concat(packagePath))
|
|
1115
|
+
.then(function (result) {
|
|
1064
1116
|
var lastCommit = new Date(result);
|
|
1065
|
-
// console.log(
|
|
1117
|
+
// console.log(packagePath,result,lastCommit);
|
|
1066
1118
|
return lastCommit;
|
|
1119
|
+
})["catch"](function (_a) {
|
|
1120
|
+
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1121
|
+
debugInfo(chalk.red('Git error: ') + error.message.toString());
|
|
1122
|
+
return null;
|
|
1067
1123
|
});
|
|
1068
1124
|
};
|
|
1069
1125
|
var getLastModifiedFile = function (filePath, config) {
|
|
@@ -1092,60 +1148,90 @@ var getLastModifiedFile = function (filePath, config) {
|
|
|
1092
1148
|
var publishUpdated = function (test) {
|
|
1093
1149
|
var _this = this;
|
|
1094
1150
|
if (test === void 0) { test = false; }
|
|
1095
|
-
var
|
|
1151
|
+
var packages = getLocalLincdModules();
|
|
1096
1152
|
var browserCoreBuilt = false;
|
|
1097
1153
|
var p = Promise.resolve('');
|
|
1098
|
-
|
|
1154
|
+
var packagesLeft = packages.length;
|
|
1155
|
+
console.log('Checking which packages need to be published by comparing last published date with last git commit');
|
|
1156
|
+
packages.forEach(function (pckg) {
|
|
1099
1157
|
p = p.then(function (previousResult) {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
//
|
|
1158
|
+
progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.packageName);
|
|
1159
|
+
debugInfo('# Checking package ' + pckg.packageName);
|
|
1160
|
+
// log('# Requesting ' + 'yarn info '+pkg.packageName+' --json');
|
|
1161
|
+
// return execPromise('yarn info '+pkg.packageName+' --json').then((output:string) => {
|
|
1103
1162
|
// console.log("Will be requesting npm view from this current working directory:\n"+process.cwd());
|
|
1104
|
-
// return execPromise('npm view '+
|
|
1105
|
-
|
|
1163
|
+
// return execPromise('npm view '+pkg.packageName+' --json').then((output:string) => {
|
|
1164
|
+
var shouldPublish;
|
|
1165
|
+
var pack = (0, utils_1.getPackageJSON)(pckg.path);
|
|
1166
|
+
var version = getNextVersion(pack.version);
|
|
1167
|
+
if (pack.private) {
|
|
1168
|
+
shouldPublish = false;
|
|
1169
|
+
debugInfo(chalk.blue('--> is private, skipping'));
|
|
1170
|
+
return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
|
|
1171
|
+
}
|
|
1172
|
+
return execPromise('yarn info ' + pckg.packageName + ' --json')
|
|
1106
1173
|
.then(function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
1107
|
-
var info, lastPublish, lastPublishDate,
|
|
1108
|
-
return __generator(this, function (
|
|
1109
|
-
switch (
|
|
1174
|
+
var info, lastPublish, lastPublishDate, lastCommit, res, browserModule;
|
|
1175
|
+
return __generator(this, function (_a) {
|
|
1176
|
+
switch (_a.label) {
|
|
1110
1177
|
case 0:
|
|
1111
1178
|
try {
|
|
1112
1179
|
if (output == '') {
|
|
1113
|
-
|
|
1114
|
-
throw new Error('Empty response from `
|
|
1115
|
-
|
|
1180
|
+
debugInfo('No response (empty) from `yarn info`. This package was probably not published before');
|
|
1181
|
+
// throw new Error('Empty response from `yarn info`. This pkg was probably not published before');
|
|
1182
|
+
// return;
|
|
1183
|
+
shouldPublish = true;
|
|
1184
|
+
//don't patch the version number (default, see above), use the current version
|
|
1185
|
+
version = pack.version;
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
info = JSON.parse(output);
|
|
1116
1189
|
}
|
|
1117
|
-
|
|
1118
|
-
// var
|
|
1119
|
-
// var files = fs.readdirSync(path.join(moduleDirectory,'src'));
|
|
1190
|
+
// var stats = fs.statSync(path.join(packageDirectory));
|
|
1191
|
+
// var files = fs.readdirSync(path.join(packageDirectory,'src'));
|
|
1120
1192
|
}
|
|
1121
1193
|
catch (err) {
|
|
1122
|
-
chalk.red(
|
|
1194
|
+
chalk.red(pckg.packageName + ' failed: ' + err.message + '\n');
|
|
1123
1195
|
console.warn('Returned JSON from npm: ' + output);
|
|
1124
|
-
return [2 /*return*/, previousResult + ' ' + chalk.red(
|
|
1196
|
+
return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.packageName + ' failed: ' + err.message + '\n')];
|
|
1125
1197
|
}
|
|
1198
|
+
if (!info) return [3 /*break*/, 2];
|
|
1126
1199
|
lastPublish = info.data.time[info.data.version];
|
|
1127
1200
|
lastPublishDate = new Date(lastPublish);
|
|
1128
|
-
|
|
1129
|
-
return [4 /*yield*/, getLastCommitTime(module.path)];
|
|
1201
|
+
return [4 /*yield*/, getLastCommitTime(pckg.path)];
|
|
1130
1202
|
case 1:
|
|
1131
|
-
lastCommit =
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1203
|
+
lastCommit = _a.sent();
|
|
1204
|
+
if (!lastCommit) {
|
|
1205
|
+
shouldPublish = false;
|
|
1206
|
+
debugInfo('Could not determine last git commit');
|
|
1207
|
+
return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n')];
|
|
1208
|
+
}
|
|
1209
|
+
else {
|
|
1210
|
+
//NOTE: removed lastModified, because switching branches will say that the file was modified and cause everything to publish
|
|
1211
|
+
//SO: now you NEED TO commit before it picks up that you should publish
|
|
1212
|
+
shouldPublish = lastPublishDate.getTime() < lastCommit.getTime();
|
|
1213
|
+
if (shouldPublish) {
|
|
1214
|
+
debugInfo(lastPublishDate.toDateString() +
|
|
1215
|
+
' ' +
|
|
1216
|
+
lastPublishDate.toTimeString() +
|
|
1217
|
+
' published ' +
|
|
1218
|
+
info.data.version);
|
|
1219
|
+
debugInfo(lastCommit.toDateString() + ' ' + new Date(lastCommit).toTimeString() + ' source last committed');
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
_a.label = 2;
|
|
1223
|
+
case 2:
|
|
1224
|
+
if (shouldPublish) {
|
|
1225
|
+
res = publishPackage(pckg, previousResult, test, info, version);
|
|
1226
|
+
if (pckg.packageName == 'browser-core') {
|
|
1141
1227
|
browserCoreBuilt = true;
|
|
1142
1228
|
}
|
|
1143
1229
|
//when publishing core, also make sure to publish browser-core
|
|
1144
|
-
if (
|
|
1145
|
-
browserModule =
|
|
1230
|
+
if (pckg.packageName == 'core' && !browserCoreBuilt) {
|
|
1231
|
+
browserModule = packages.find(function (m) { return m.packageName == 'browser-core'; });
|
|
1146
1232
|
return [2 /*return*/, Promise.resolve(res).then(function (previousResult) {
|
|
1147
|
-
log('# Automatically also publishing
|
|
1148
|
-
return
|
|
1233
|
+
log('# Automatically also publishing package browser-core');
|
|
1234
|
+
return publishPackage(browserModule, previousResult, test);
|
|
1149
1235
|
})];
|
|
1150
1236
|
}
|
|
1151
1237
|
return [2 /*return*/, res];
|
|
@@ -1153,156 +1239,208 @@ var publishUpdated = function (test) {
|
|
|
1153
1239
|
return [2 /*return*/, previousResult];
|
|
1154
1240
|
}
|
|
1155
1241
|
});
|
|
1156
|
-
}); })["catch"](function (
|
|
1157
|
-
|
|
1158
|
-
|
|
1242
|
+
}); })["catch"](function (_a) {
|
|
1243
|
+
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1244
|
+
console.log(error.message);
|
|
1245
|
+
return previousResult + ' ' + chalk.red(pckg.packageName + ' failed\n');
|
|
1159
1246
|
});
|
|
1160
1247
|
});
|
|
1161
1248
|
});
|
|
1162
1249
|
return p.then(function (messages) {
|
|
1163
1250
|
if (messages == '') {
|
|
1164
|
-
console.log('All published
|
|
1251
|
+
console.log('All published packages are already up-to-date.');
|
|
1165
1252
|
}
|
|
1166
1253
|
else {
|
|
1167
1254
|
console.log('Summary: \n' + messages);
|
|
1168
1255
|
}
|
|
1169
1256
|
});
|
|
1170
1257
|
};
|
|
1171
|
-
var
|
|
1172
|
-
|
|
1173
|
-
|
|
1258
|
+
var publishPackage = function (pkg, previousResult, test, info, publishVersion) {
|
|
1259
|
+
if (!publishVersion) {
|
|
1260
|
+
publishVersion = info ? getNextVersion(info.data.version) : '';
|
|
1261
|
+
}
|
|
1262
|
+
if (test) {
|
|
1263
|
+
debugInfo('should publish ' + pkg.packageName + ' ' + publishVersion);
|
|
1264
|
+
}
|
|
1265
|
+
else {
|
|
1266
|
+
console.log(chalk.blue('publishing ' + pkg.packageName + ' ' + publishVersion));
|
|
1267
|
+
}
|
|
1174
1268
|
if (!test) {
|
|
1175
|
-
return execPromise(
|
|
1269
|
+
return execPromise("cd ".concat(pkg.path, " && yarn publish").concat(publishVersion ? ' --new-version ' + publishVersion : ''), true, false, {}, true)
|
|
1176
1270
|
.then(function (res) {
|
|
1177
1271
|
if (res.indexOf('Aborted due to warnings') !== -1 ||
|
|
1178
1272
|
res.indexOf('Could not publish') !== -1 ||
|
|
1179
1273
|
res.indexOf("Couldn't publish") !== -1) {
|
|
1180
1274
|
console.log(res);
|
|
1181
|
-
return previousResult + ' ' + chalk.red(
|
|
1275
|
+
return previousResult + ' ' + chalk.red(pkg.packageName + ' failed\n');
|
|
1182
1276
|
}
|
|
1183
|
-
console.log(chalk.green('Successfully published ' +
|
|
1184
|
-
return previousResult + ' ' + chalk.green(
|
|
1185
|
-
})["catch"](function (
|
|
1186
|
-
|
|
1187
|
-
|
|
1277
|
+
console.log(chalk.green('Successfully published ' + pkg.path + ' ' + publishVersion));
|
|
1278
|
+
return previousResult + ' ' + chalk.green(pkg.packageName + ' published ' + publishVersion + '\n');
|
|
1279
|
+
})["catch"](function (_a) {
|
|
1280
|
+
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1281
|
+
console.log(chalk.red('Failed to publish: ' + error.message));
|
|
1282
|
+
return previousResult + ' ' + chalk.red(pkg.packageName + ' failed to publish\n');
|
|
1188
1283
|
});
|
|
1189
1284
|
}
|
|
1190
1285
|
else {
|
|
1191
1286
|
//when testing what needs to be published
|
|
1192
|
-
return previousResult + ' ' + chalk.blue(
|
|
1287
|
+
return previousResult + ' ' + chalk.blue(pkg.packageName + ' should publish\n');
|
|
1193
1288
|
}
|
|
1194
1289
|
};
|
|
1195
1290
|
var buildUpdated = function (back, target, target2, test) {
|
|
1196
1291
|
if (test === void 0) { test = false; }
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1292
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1293
|
+
var previousResult, packages, jsonldPkgUpdated, cliPkgUpdated, rebuildAllModules, packagesLeft, p;
|
|
1294
|
+
var _this = this;
|
|
1295
|
+
return __generator(this, function (_a) {
|
|
1296
|
+
switch (_a.label) {
|
|
1297
|
+
case 0:
|
|
1298
|
+
previousResult = '';
|
|
1299
|
+
log(test ? 'Checking which packages need to be rebuild' : 'Building updated packages');
|
|
1300
|
+
packages = getLocalLincdPackageMap();
|
|
1301
|
+
jsonldPkgUpdated = needsRebuilding(packages.get('lincd-jsonld'));
|
|
1302
|
+
cliPkgUpdated = needsRebuilding(packages.get('lincd-cli'));
|
|
1303
|
+
if (!(jsonldPkgUpdated || cliPkgUpdated)) return [3 /*break*/, 2];
|
|
1304
|
+
return [4 /*yield*/, execPromise('yarn build-core', false, false, {}, true)];
|
|
1305
|
+
case 1:
|
|
1306
|
+
_a.sent();
|
|
1307
|
+
_a.label = 2;
|
|
1308
|
+
case 2:
|
|
1309
|
+
rebuildAllModules = false;
|
|
1310
|
+
if (cliPkgUpdated) {
|
|
1311
|
+
rebuildAllModules = true;
|
|
1312
|
+
log(chalk.magenta('Rebuilding all packages because the build tools (lincd-cli) got updated'));
|
|
1313
|
+
}
|
|
1314
|
+
packagesLeft = packages.size;
|
|
1315
|
+
runOnPackagesGroupedByDependencies(packages, function (packageGroup, dependencies) {
|
|
1316
|
+
// console.log('Now checking: ' + chalk.blue(packageGroup.map((i) => i.packageName)));
|
|
1317
|
+
// console.log((packagesLeft) + " packages left.");
|
|
1318
|
+
packagesLeft = packagesLeft - packageGroup.length;
|
|
1319
|
+
return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
|
|
1320
|
+
var needRebuild;
|
|
1321
|
+
return __generator(this, function (_a) {
|
|
1322
|
+
debugInfo('# Checking package ' + pkg.packageName);
|
|
1323
|
+
needRebuild = needsRebuilding(pkg, true);
|
|
1324
|
+
if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated) {
|
|
1325
|
+
needRebuild = true;
|
|
1326
|
+
}
|
|
1327
|
+
// console.log(pkg.path,lastModifiedSource.lastModifiedTime,lastModifiedBundle.lastModifiedTime);
|
|
1328
|
+
// console.log(pkg.path,new Date(lastModifiedSource.lastModified).toString(),new Date(lastModifiedBundle.lastModified).toString());
|
|
1329
|
+
if (needRebuild || rebuildAllModules) {
|
|
1330
|
+
//TODO: when building a pkg, also rebuild all packages that depend on this package.. and iteratively build packages that depend on those packages..
|
|
1331
|
+
// log(packageName+' modified since last commit on '+now.toString());
|
|
1332
|
+
if (test) {
|
|
1333
|
+
debugInfo('Need to build ' + pkg.packageName);
|
|
1334
|
+
return [2 /*return*/, chalk.blue(pkg.packageName + ' should be build')];
|
|
1335
|
+
}
|
|
1336
|
+
log('Building ' + pkg.packageName);
|
|
1337
|
+
return [2 /*return*/, execPromise('cd ' + pkg.path + ' && yarn build' + (target ? ' ' + target : '') + (target2 ? ' ' + target2 : ''))
|
|
1338
|
+
.then(function (res) {
|
|
1339
|
+
debugInfo(chalk.green(pkg.packageName + ' successfully built'));
|
|
1340
|
+
return chalk.green(pkg.packageName + ' built');
|
|
1341
|
+
})["catch"](function (_a) {
|
|
1342
|
+
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1343
|
+
warn('Failed to build ' + pkg.packageName);
|
|
1344
|
+
console.log(stdout);
|
|
1345
|
+
var dependentModules = getDependentPackages(dependencies, pkg);
|
|
1346
|
+
if (dependentModules.length > 0) {
|
|
1347
|
+
// printBuildResults(failedModules, done);
|
|
1348
|
+
warn(chalk.red(pkg.packageName + ' build failed'));
|
|
1349
|
+
warn('Stopping build-updated process because ' +
|
|
1350
|
+
dependentModules.length +
|
|
1351
|
+
' other packages depend on this package.\n'); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
1352
|
+
process.exit(1);
|
|
1353
|
+
}
|
|
1354
|
+
})];
|
|
1355
|
+
}
|
|
1356
|
+
return [2 /*return*/];
|
|
1357
|
+
});
|
|
1358
|
+
}); };
|
|
1359
|
+
}, function (results) {
|
|
1360
|
+
if (results.length) {
|
|
1361
|
+
log('Summary:');
|
|
1362
|
+
log(results.join('\n'));
|
|
1363
|
+
}
|
|
1364
|
+
else {
|
|
1365
|
+
log(chalk.green('Nothing to rebuild'));
|
|
1232
1366
|
}
|
|
1233
|
-
console.log(chalk.green(moduleName + ' bundles successfully built'));
|
|
1234
|
-
return previousResult + ' ' + chalk.green(moduleName + ' built\n');
|
|
1235
1367
|
});
|
|
1236
|
-
|
|
1237
|
-
return previousResult + ' ' + chalk.blue(moduleName + ' should be build\n');
|
|
1368
|
+
return [2 /*return*/];
|
|
1238
1369
|
}
|
|
1239
|
-
return previousResult;
|
|
1240
|
-
})["catch"](function (err) {
|
|
1241
|
-
console.log(err);
|
|
1242
|
-
return previousResult + ' ' + chalk.red(moduleName + ' failed\n');
|
|
1243
1370
|
});
|
|
1244
1371
|
});
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1372
|
+
};
|
|
1373
|
+
var needsRebuilding = function (pkg, logDetailsIfTrue) {
|
|
1374
|
+
if (logDetailsIfTrue === void 0) { logDetailsIfTrue = false; }
|
|
1375
|
+
var lastModifiedSource = getLastModifiedSourceTime(pkg.path);
|
|
1376
|
+
var lastModifiedBundle = getLastBuildTime(pkg.path);
|
|
1377
|
+
var result = lastModifiedSource.lastModifiedTime > lastModifiedBundle.lastModifiedTime;
|
|
1378
|
+
if (logDetailsIfTrue) {
|
|
1379
|
+
debugInfo(chalk.cyan('Last modified source: ' +
|
|
1380
|
+
lastModifiedSource.lastModifiedName +
|
|
1381
|
+
' on ' +
|
|
1382
|
+
lastModifiedSource.lastModified.toString()));
|
|
1383
|
+
debugInfo(chalk.cyan('Last build: ' +
|
|
1384
|
+
(lastModifiedBundle && typeof lastModifiedBundle.lastModified !== 'undefined'
|
|
1385
|
+
? lastModifiedBundle.lastModified.toString()
|
|
1386
|
+
: 'never')));
|
|
1387
|
+
}
|
|
1388
|
+
return result;
|
|
1254
1389
|
};
|
|
1255
1390
|
var printBuildResults = function (failed, done) {
|
|
1256
|
-
log('
|
|
1257
|
-
|
|
1258
|
-
(
|
|
1259
|
-
|
|
1391
|
+
log('Successfully built: ' + chalk.green(__spreadArray([], __read(done), false).map(function (m) { return m.packageName; }).join(', ')) + '\n');
|
|
1392
|
+
if (failed.length > 0) {
|
|
1393
|
+
warn('Failed to build: ' + chalk.red(failed.join(', ')) + '\n');
|
|
1394
|
+
}
|
|
1260
1395
|
};
|
|
1261
|
-
var
|
|
1262
|
-
//if a specific set of
|
|
1396
|
+
var executeCommandForEachPackage = function (packages, command, filterMethod, filterValue) {
|
|
1397
|
+
//if a specific set of packages is given
|
|
1263
1398
|
if (filterMethod == 'exclude') {
|
|
1264
|
-
//filter
|
|
1399
|
+
//filter packages, so that we only execute on the packages as provided in the command
|
|
1265
1400
|
log('Excluding ' + filterValue);
|
|
1266
1401
|
filterValue = filterValue.split(',');
|
|
1267
|
-
|
|
1402
|
+
packages = packages.filter(function (pkg) { return filterValue.indexOf(pkg.packageName) === -1; });
|
|
1268
1403
|
}
|
|
1269
1404
|
var startFrom;
|
|
1270
1405
|
//by default start executing, unless 'from' is given
|
|
1271
1406
|
var executing = true;
|
|
1272
|
-
//option to start from a specific
|
|
1407
|
+
//option to start from a specific pkg in the stack
|
|
1273
1408
|
if (filterMethod == 'from') {
|
|
1274
1409
|
startFrom = filterValue;
|
|
1275
1410
|
if (startFrom) {
|
|
1276
1411
|
console.log(chalk.blue('Will skip ahead to ' + startFrom));
|
|
1277
1412
|
}
|
|
1278
1413
|
var seen_1 = false;
|
|
1279
|
-
|
|
1280
|
-
if (!seen_1 && (
|
|
1414
|
+
packages = packages.filter(function (pkg) {
|
|
1415
|
+
if (!seen_1 && (pkg.packageName == startFrom || pkg.packageName == startFrom)) {
|
|
1281
1416
|
seen_1 = true;
|
|
1282
1417
|
}
|
|
1283
1418
|
return seen_1;
|
|
1284
1419
|
});
|
|
1285
1420
|
}
|
|
1286
|
-
log("Executing '" +
|
|
1421
|
+
log("Executing '" +
|
|
1422
|
+
chalk.blueBright(command) +
|
|
1423
|
+
"' on packages " +
|
|
1424
|
+
chalk.magenta(packages.map(function (m) { return m.packageName; }).join(', ')));
|
|
1287
1425
|
var p = Promise.resolve(true);
|
|
1288
|
-
|
|
1426
|
+
packages.forEach(function (pkg) {
|
|
1289
1427
|
p = p.then(function () {
|
|
1290
|
-
log('# Package ' + chalk.magenta(
|
|
1291
|
-
return execp('cd ' +
|
|
1428
|
+
log('# Package ' + chalk.magenta(pkg.packageName));
|
|
1429
|
+
return execp('cd ' + pkg.path + ' && ' + command);
|
|
1292
1430
|
});
|
|
1293
1431
|
});
|
|
1294
1432
|
return p;
|
|
1295
1433
|
};
|
|
1296
|
-
var
|
|
1297
|
-
var
|
|
1298
|
-
return modDetails.packageName.indexOf(
|
|
1434
|
+
var executeCommandForPackage = function (packageName, command) {
|
|
1435
|
+
var packageDetails = getLincdPackages().find(function (modDetails) {
|
|
1436
|
+
return modDetails.packageName.indexOf(packageName) !== -1 || modDetails.packageName.indexOf(packageName) !== -1;
|
|
1299
1437
|
});
|
|
1300
|
-
if (
|
|
1301
|
-
log("Executing 'cd " +
|
|
1302
|
-
return execp('cd ' +
|
|
1438
|
+
if (packageDetails) {
|
|
1439
|
+
log("Executing 'cd " + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + "'");
|
|
1440
|
+
return execp('cd ' + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : ''));
|
|
1303
1441
|
}
|
|
1304
1442
|
else {
|
|
1305
|
-
warn("Could not find a
|
|
1443
|
+
warn("Could not find a pkg who's name (partially) matched " + chalk.cyan(packageName));
|
|
1306
1444
|
}
|
|
1307
1445
|
};
|
|
1308
1446
|
program.parse(process.argv);
|