lincd-cli 0.1.2 → 0.1.6

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.
Files changed (48) hide show
  1. package/LICENSE +373 -373
  2. package/README.md +2 -1
  3. package/defaults/defaultModule/Index.tsx +1 -1
  4. package/defaults/defaultModule/index.ts +11 -11
  5. package/defaults/defaultModule/ontology.ts +15 -15
  6. package/defaults/gitignorefile +3 -3
  7. package/defaults/index.ts +12 -12
  8. package/defaults/module/package.json +30 -0
  9. package/defaults/module/src/components/ExampleComponent.tsx +22 -0
  10. package/defaults/module/src/data/example-ontology.json +20 -0
  11. package/defaults/module/src/data/example-ontology.json.d.ts +1 -0
  12. package/defaults/module/src/index.ts +7 -0
  13. package/defaults/module/src/module.ts +9 -0
  14. package/defaults/module/src/ontologies/example-ontology.ts +33 -0
  15. package/defaults/module/src/shapes/ExampleShapeClass.ts +30 -0
  16. package/defaults/ontology.ts +15 -15
  17. package/defaults/package.json +26 -22
  18. package/defaults/site/package.json +40 -0
  19. package/defaults/site/storage/filestores/settings-production-template.jsonld +129 -0
  20. package/defaults/site/web/.htaccess +19 -0
  21. package/defaults/site/web/favicon.png +0 -0
  22. package/defaults/site/web/img/placeholder.jpg +0 -0
  23. package/lib/cli.js +1070 -0
  24. package/lib/config-grunt.js +244 -0
  25. package/lib/config-webpack.js +267 -0
  26. package/{index.js → lib/index.js} +8 -4
  27. package/lib/interfaces.js +2 -0
  28. package/lib/plugins/declaration-plugin.js +206 -0
  29. package/lib/plugins/externalise-modules.js +175 -0
  30. package/{plugins → lib/plugins}/watch-run.js +0 -0
  31. package/lib/utils.js +127 -0
  32. package/package.json +28 -23
  33. package/{cli.js → src/cli.js} +54 -93
  34. package/src/config-grunt.js +263 -0
  35. package/src/config-webpack.js +281 -0
  36. package/src/index.js +22 -0
  37. package/src/interfaces.js +2 -0
  38. package/{plugins → src/plugins}/declaration-plugin.js +3 -3
  39. package/{plugins → src/plugins}/externalise-modules.js +8 -6
  40. package/src/plugins/shapes-plugin.js +69 -0
  41. package/src/plugins/watch-run.js +47 -0
  42. package/src/utils.js +127 -0
  43. package/config-generator.js +0 -545
  44. package/defaults/.npmignore +0 -11
  45. package/defaults/Gruntfile.js +0 -16
  46. package/defaults/tsconfig-es5.json +0 -19
  47. package/defaults/tsconfig.json +0 -21
  48. package/utils.js +0 -17
package/lib/cli.js ADDED
@@ -0,0 +1,1070 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (_) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ exports.__esModule = true;
40
+ var utils_1 = require("./utils");
41
+ require('require-extensions');
42
+ var program = require('commander');
43
+ var exec = require('child_process').exec;
44
+ var chalk = require('chalk');
45
+ var fs = require('fs-extra');
46
+ var path = require('path');
47
+ var glob = require('glob');
48
+ var variables = {};
49
+ function log() {
50
+ var messages = [];
51
+ for (var _i = 0; _i < arguments.length; _i++) {
52
+ messages[_i] = arguments[_i];
53
+ }
54
+ messages.forEach(function (message) {
55
+ console.log(chalk.cyan('Info: ') + message);
56
+ });
57
+ }
58
+ function warn() {
59
+ var messages = [];
60
+ for (var _i = 0; _i < arguments.length; _i++) {
61
+ messages[_i] = arguments[_i];
62
+ }
63
+ messages.forEach(function (message) {
64
+ console.log(chalk.magenta('Warning: ') + message);
65
+ // console.log(chalk.red(message));
66
+ });
67
+ }
68
+ function checkWorkspaces(rootPath, workspaces, res) {
69
+ // console.log('checking workspaces at '+rootPath+": "+workspaces.toString());
70
+ workspaces.forEach(function (workspace) {
71
+ var workspacePath = path.join(rootPath, workspace.replace('/*', ''));
72
+ if (workspace.indexOf('/*') !== -1) {
73
+ // console.log(workspacePath);
74
+ if (fs.existsSync(workspacePath)) {
75
+ var folders = fs.readdirSync(workspacePath);
76
+ folders.forEach(function (folder) {
77
+ if (folder !== './' && folder !== '../') {
78
+ checkModulePath(rootPath, path.join(workspacePath, folder), res);
79
+ }
80
+ });
81
+ }
82
+ }
83
+ else {
84
+ checkModulePath(rootPath, workspacePath, res);
85
+ }
86
+ });
87
+ }
88
+ function checkModulePath(rootPath, modulePath, res) {
89
+ var packagePath = path.join(modulePath, 'package.json');
90
+ // console.log('checking '+packagePath);
91
+ if (fs.existsSync(packagePath)) {
92
+ var pack = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
93
+ //some packages are not true lincd modules, but we still want them to be re-built automatically. This is what lincd_util is for
94
+ if (pack && pack.workspaces) {
95
+ checkWorkspaces(modulePath, pack.workspaces, res);
96
+ }
97
+ else if ((pack && pack.lincd === true) || pack.lincd_util === true) {
98
+ res.push({
99
+ path: modulePath,
100
+ moduleName: pack.name,
101
+ packageName: pack.name
102
+ });
103
+ }
104
+ }
105
+ }
106
+ /**
107
+ * Returns a map of the modules that this repository manages (so no modules found through the workspaces who's path contains ../ )
108
+ * @param rootPath
109
+ */
110
+ function getLocalLincdModuleMap(rootPath) {
111
+ if (rootPath === void 0) { rootPath = './'; }
112
+ var map = new Map();
113
+ getLincdModules(rootPath).forEach(function (module) {
114
+ if (module.path.indexOf('../') === -1 && module.path.indexOf('..\\') === -1) {
115
+ // console.log(module.path);
116
+ map.set(module.moduleName, module);
117
+ }
118
+ });
119
+ return map;
120
+ }
121
+ function getLocalLincdModules(rootPath) {
122
+ if (rootPath === void 0) { rootPath = './'; }
123
+ return getLincdModules(rootPath).filter(function (module) {
124
+ return module.path.indexOf('..\\') === -1;
125
+ });
126
+ }
127
+ function getLincdModules(rootPath) {
128
+ if (rootPath === void 0) { rootPath = './'; }
129
+ //TODO: read from package.json what the workspaces are. for each, follow up all the folders inside that path
130
+ //TODO: then return an array with objects that have both the module name + the path. And then use that path across this whenever this function is called
131
+ //TODO: this way it will work with websites as well, instead of just from the main LINCD repository
132
+ var pack = utils_1.getPackageJSON();
133
+ var res = [];
134
+ if (!pack.workspaces) {
135
+ warn(chalk.red('Could not find package workspaces. Make sure you run this command from a yarn workspace.'));
136
+ logHelp();
137
+ process.exit();
138
+ }
139
+ //TODO: filter with package.lincd = true?
140
+ checkWorkspaces(rootPath, pack.workspaces, res);
141
+ // console.log(res);
142
+ return res;
143
+ }
144
+ function setVariable(name, replacement) {
145
+ //prepare name for regexp
146
+ name = name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
147
+ variables[name] = replacement;
148
+ }
149
+ function execp(cmd, log, allowError, options) {
150
+ if (log === void 0) { log = false; }
151
+ if (allowError === void 0) { allowError = false; }
152
+ if (options === void 0) { options = {}; }
153
+ // opts || (opts = {});
154
+ if (log)
155
+ console.log(chalk.cyan(cmd));
156
+ return new Promise(function (resolve, reject) {
157
+ var child = exec(cmd, options);
158
+ child.stdout.pipe(process.stdout);
159
+ child.stderr.pipe(process.stderr);
160
+ // process.stdin.pipe(child.stdin);
161
+ child.on('close', function (code) {
162
+ if (code === 0) {
163
+ resolve(null);
164
+ }
165
+ else {
166
+ reject();
167
+ }
168
+ // console.log('killing child');
169
+ // child.kill('SIGHUP');
170
+ // resolve(code);
171
+ });
172
+ // child.on('data', function (result) {
173
+ // // if (log)
174
+ // // {
175
+ // // console.log(result);
176
+ // // }
177
+ // resolve(result);
178
+ // console.log('resolve data');
179
+ //
180
+ // });
181
+ child.on('error', function (err) {
182
+ if (!allowError) {
183
+ // console.log('reject err');
184
+ reject(err);
185
+ return;
186
+ }
187
+ else if (log) {
188
+ console.warn(err);
189
+ }
190
+ // console.log('resolve err');
191
+ resolve(null);
192
+ });
193
+ child.on('exit', function (code, signal) {
194
+ if (code !== 0) {
195
+ reject('Child process exited with error code ' + code);
196
+ return;
197
+ }
198
+ // console.log('resolve exit');
199
+ resolve(null);
200
+ });
201
+ });
202
+ }
203
+ function replaceVariables(string) {
204
+ for (var key in variables) {
205
+ string = string.replace(new RegExp(key, 'g'), variables[key]);
206
+ }
207
+ return string;
208
+ }
209
+ function execPromise(command, log, allowError, options) {
210
+ if (log === void 0) { log = false; }
211
+ if (allowError === void 0) { allowError = false; }
212
+ return new Promise(function (resolve, reject) {
213
+ if (log)
214
+ console.log(chalk.cyan(command));
215
+ exec(command, options, function (error, stdout, stderr) {
216
+ if (error) {
217
+ if (!allowError) {
218
+ reject(error.message);
219
+ return;
220
+ }
221
+ else if (log) {
222
+ console.warn(error);
223
+ }
224
+ }
225
+ var result = stdout.trim();
226
+ if (log) {
227
+ // console.log(chalk"RESOLVING "+command);
228
+ console.log(result);
229
+ // console.log('ERRORS:'+(result.indexOf('Aborted due to warnings') !== -1));
230
+ // console.log('stderr:'+stderr);
231
+ }
232
+ resolve(result);
233
+ });
234
+ });
235
+ }
236
+ var replaceVariablesInFile = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
237
+ var fileContent, newContent;
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0: return [4 /*yield*/, fs.readFile(filePath, 'utf8')];
241
+ case 1:
242
+ fileContent = _a.sent();
243
+ newContent = replaceCurlyVariables(fileContent);
244
+ return [2 /*return*/, fs.writeFile(filePath, newContent)];
245
+ }
246
+ });
247
+ }); };
248
+ var replaceCurlyVariables = function (string) {
249
+ // var reg = new RegExp('\\$\\{'+key+'\\}','g');
250
+ for (var key in variables) {
251
+ string = string.replace(new RegExp('\\$\\{' + key + '\\}', 'g'), variables[key]);
252
+ }
253
+ return string;
254
+ };
255
+ var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1); };
256
+ var camelCase = function (str) {
257
+ var string = str
258
+ .toLowerCase()
259
+ .replace(/[^A-Za-z0-9]/g, ' ')
260
+ .split(' ')
261
+ .reduce(function (result, word) { return result + capitalize(word.toLowerCase()); });
262
+ return string.charAt(0).toLowerCase() + string.slice(1);
263
+ };
264
+ program.command('init [name] [uribase]').action(function (name, uriBase) {
265
+ return initModule(name, uriBase);
266
+ });
267
+ var initModule = function (name, uriBase, basePath) {
268
+ if (basePath === void 0) { basePath = process.cwd(); }
269
+ if (!uriBase) {
270
+ uriBase = '[INSERT_URI_BASE]';
271
+ }
272
+ if (!name) {
273
+ if (fs.existsSync(path.join(basePath, 'package.json'))) {
274
+ var pack = require(path.join(basePath, 'package.json'));
275
+ //find @scope and the next part between 2 slashes after
276
+ //so @dacore/some-mod/lib/file.js
277
+ // --> match[0] = @dacore/some-mod
278
+ // --> match[1] = @dacore
279
+ // --> match[2] = some-mod
280
+ var _a = pack.name.match(/(@[\w\-]+\/)?([\w\-]+)/), packageName = _a[0], scope = _a[1], cleanPackageName = _a[2];
281
+ name = cleanPackageName;
282
+ }
283
+ else {
284
+ name = path.basename(process.cwd());
285
+ }
286
+ }
287
+ // console.log(
288
+ // 'Copying ' +
289
+ // path.join(__dirname, '..', 'defaults', 'module') +
290
+ // '\nto ' +
291
+ // basePath,
292
+ // );
293
+ fs.copySync(path.join(__dirname, '..', 'defaults', 'module'), basePath);
294
+ var camelCaseModuleName = camelCase(name); //some-module --> someModule
295
+ var underscoreModuleName = name.replace(/[-\s]+/g, '_');
296
+ setVariable('uri_base', uriBase);
297
+ //longer similar variables names should come before the shorter ones
298
+ setVariable('camel_module_name', camelCaseModuleName);
299
+ setVariable('underscore_module_name', underscoreModuleName);
300
+ setVariable('module_name', name);
301
+ log("Creating new lincd module '" + name + "'");
302
+ //replace variables in some of the copied files
303
+ ['package.json', 'Gruntfile.js', 'src/module.ts']
304
+ .map(function (f) { return path.join(basePath, f); })
305
+ .forEach(function (file) {
306
+ replaceVariablesInFile(file);
307
+ });
308
+ log("Prepared all files.", "Run " + chalk.blueBright('yarn') + " or " + chalk.blueBright('npm install') + " to install the dependencies.", "Then run " + chalk.blueBright('yarn build') + " to build once or " + chalk.blueBright('yarn dev') + " to continuously rebuild on file changes");
309
+ };
310
+ var getNextVersion = function (version) {
311
+ var parts = version.split('.');
312
+ return parts[0] + '.' + parts[1] + '.' + (parseInt(parts[2]) + 1).toString();
313
+ };
314
+ var getNextMajorVersion = function (version) {
315
+ var parts = version.split('.');
316
+ return (parseInt(parts[0]) + 1).toString() + '.0.0';
317
+ };
318
+ var getNextMinorVersion = function (version) {
319
+ var parts = version.split('.');
320
+ return parts[0] + '.' + (parseInt(parts[1]) + 1).toString() + '.0';
321
+ };
322
+ var buildFailed = function (output) {
323
+ return output.indexOf('Aborted due to warnings') !== -1 && output.indexOf('Command failed') !== -1;
324
+ };
325
+ /*program.command('shapes').action(async () => {
326
+ //we've imported require-extensions from npm so that we can use this
327
+ //we want to avoid nodejs tripping up over @import commands in css files
328
+ require.extensions['.scss'] = function (sourcecode, filename) {
329
+ return {};
330
+ };
331
+ require.extensions['.css'] = function (sourcecode, filename) {
332
+ return {};
333
+ };
334
+
335
+ if (fs.existsSync(process.cwd() + '/package.json')) {
336
+ var pack = JSON.parse(
337
+ fs.readFileSync(process.cwd() + '/package.json', 'utf8'),
338
+ );
339
+ let moduleName = pack.name;
340
+
341
+ //just making sure the library is loaded in correct order because circular references are currently happening when importing BlankNode before NamedNode for example
342
+ // require('lincd');
343
+ //TODO: replace with actual index file from package.json, or tsconfig
344
+ let indexExports = require(process.cwd() + '/lib/index.js');
345
+ if(indexExports.moduleExports)
346
+ {
347
+ let shapeJSONLD = await getShapesJSONLD(indexExports.moduleExports);
348
+ console.log(indexExports.moduleExports);
349
+ console.log(shapeJSONLD);
350
+ console.log(chalk.bold(chalk.green(moduleName+'/dist/shapes.json')));
351
+ return fs.writeFile(path.join('dist', 'shapes.json'), shapeJSONLD);
352
+ }
353
+ else
354
+ {
355
+ console.warn("Invalid LINCD module. Index file should export a moduleExports object. See examples.")
356
+ }
357
+
358
+ } else {
359
+ console.warn('Not a project');
360
+ }
361
+ });*/
362
+ program.command('register [version]').action(function (newVersion) {
363
+ if (fs.existsSync(process.cwd() + '/package.json')) {
364
+ var pack = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
365
+ var version = pack.version;
366
+ var moduleName = pack.name;
367
+ var author = pack.author;
368
+ // let displayName = pack.displayName;
369
+ console.log(chalk.cyan('registering ' + author + "'s module, " + moduleName + ' ' + version + ' in the LINCD registry'));
370
+ //temporary test code
371
+ return fetch('http://localhost:4001/register', {
372
+ method: 'POST',
373
+ headers: {
374
+ Accept: 'application/json, text/plain, */*',
375
+ 'Content-Type': 'application/json'
376
+ },
377
+ body: JSON.stringify({ package: moduleName, version: version })
378
+ })
379
+ .then(function (res) { return res.json(); })
380
+ .then(function (json) {
381
+ if (json.error) {
382
+ console.log(chalk.red('Response: ' + json.error));
383
+ }
384
+ else if (json.result) {
385
+ console.log(chalk.cyan('Response: ') + json.result);
386
+ }
387
+ })["catch"](function (err) {
388
+ console.warn('Could not connect to LINCD registry');
389
+ });
390
+ /*console.log(chalk.cyan('building production bundles'));
391
+ return execPromise('yarn lincd build production', false, true)
392
+ .then((output: string) => {
393
+ if (buildFailed(output)) {
394
+ // console.warn("Build failed:");
395
+ console.log(output);
396
+ throw new Error('build failed');
397
+ }
398
+ pack.version = newVersion;
399
+ //save package.json
400
+ return fs.writeFileSync(
401
+ path.join(process.cwd(), 'package.json'),
402
+ JSON.stringify(pack, null, 2),
403
+ );
404
+ })
405
+ .then((version) => {
406
+ console.log(chalk.cyan('Committing to git'));
407
+ //we have just changed package.json, so there will be things "uncommitted"
408
+ //to make sure this module does not automatically come up as "needing to be published" we need to commit this change here straight away
409
+ //so: add all files not added yet in the folder of this module
410
+ //then commit all changes (including new version number in package.json)
411
+ //then add a version commit git flag
412
+ return execPromise(
413
+ `git add -- ./ & git commit -m "publishing ${moduleName} ${newVersion}" -- ./ & git tag ${moduleName}@${newVersion}"`,
414
+ );
415
+ })
416
+ .then((version) => {
417
+ console.log(chalk.cyan('Publishing ' + moduleName + ' ' + newVersion));
418
+
419
+ // let tag = moduleName+'@'+version;
420
+ return execPromise('yarn publish --new-version ' + newVersion, true);
421
+ })
422
+ .then((res) => {
423
+ if (
424
+ res.indexOf('Aborted due to warnings') !== -1 ||
425
+ res.indexOf('Could not publish') !== -1 ||
426
+ res.indexOf("Couldn't publish") !== -1
427
+ ) {
428
+ console.log(chalk.red('Failed to publish'));
429
+ return false;
430
+ } else {
431
+ var pack = JSON.parse(
432
+ fs.readFileSync(process.cwd() + '/package.json', 'utf8'),
433
+ );
434
+ version = pack.version;
435
+ console.log(chalk.green('Published ' + version));
436
+ return true;
437
+ }
438
+ })
439
+ .catch((err) => {
440
+ console.warn(chalk.red('Could not publish: ' + err));
441
+ });*/
442
+ }
443
+ else {
444
+ console.warn('not found: ' + process.cwd() + '/package.json');
445
+ }
446
+ });
447
+ // program.command('create [action] [value]').action((action, prefixedUri) => {
448
+ //
449
+ // let [ontology,label] = typeof prefixedUri !== 'undefined' ? prefixedUri.split(":") : [];
450
+ // if(!ontology || !label)
451
+ // {
452
+ // return console.warn("Please provide a prefixed URI of the "+action+" to create");
453
+ // }
454
+ // if(action == 'viewtype')
455
+ // {
456
+ // //add to ontology file
457
+ // let contents = fs.readFileSync(path.join('src','ontologies',ontology),'utf8');
458
+ //
459
+ //
460
+ // //create view file
461
+ // //add view file to index
462
+ // }
463
+ // });
464
+ program.command('info').action(function () {
465
+ var ownPackage = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
466
+ console.log(ownPackage.version);
467
+ console.log('Running from: ' + __dirname);
468
+ });
469
+ var ensurePath = function () {
470
+ var folders = [];
471
+ for (var _i = 0; _i < arguments.length; _i++) {
472
+ folders[_i] = arguments[_i];
473
+ }
474
+ // let target = path.join(folders.shift());
475
+ var target;
476
+ folders.forEach(function (folder) {
477
+ target = target ? path.join(target, folder) : path.join(folder);
478
+ if (!fs.existsSync(target)) {
479
+ fs.mkdirSync(target);
480
+ }
481
+ });
482
+ return target;
483
+ };
484
+ program.command('test-build').action(function (target, target2) {
485
+ execPromise('yarn lincd build', true)
486
+ .then(function (result) {
487
+ console.log('success');
488
+ })["catch"](function (err) {
489
+ console.log('failed');
490
+ });
491
+ });
492
+ program.command('build [target] [target2]').action(function (target, target2) {
493
+ buildModule(target, target2);
494
+ });
495
+ var buildModule = function (target, target2, modulePath, logResults) {
496
+ if (modulePath === void 0) { modulePath = process.cwd(); }
497
+ if (logResults === void 0) { logResults = true; }
498
+ if (target == 'production' || target == 'es5' || target == 'es6' || !target) {
499
+ if (!fs.existsSync(path.join(modulePath, 'Gruntfile.js'))) {
500
+ console.warn("No Gruntfile found at " + modulePath + "\\Gruntfile.js. Cannot build.");
501
+ return;
502
+ }
503
+ var nodeEnv = '';
504
+ if (target == 'production') {
505
+ if (!(target2 == 'es5' || target2 == 'es6' || typeof target2 == 'undefined')) {
506
+ console.warn('unknown second build target. Use es5 or es6', target2);
507
+ return;
508
+ }
509
+ var isWindows = /^win/.test(process.platform);
510
+ if (isWindows) {
511
+ nodeEnv = 'SET NODE_ENV=production&& ';
512
+ }
513
+ else {
514
+ nodeEnv = "NODE_ENV='production' ";
515
+ }
516
+ }
517
+ if (!target) {
518
+ target = 'es6';
519
+ }
520
+ log('building once: ' +
521
+ nodeEnv +
522
+ 'grunt build' +
523
+ (target ? '-' + target : '') +
524
+ (target2 ? '-' + target2 : '') +
525
+ ' --color');
526
+ var method = logResults ? execp : execPromise;
527
+ //execute the command to build the method, and provide the current work directory as option
528
+ return method(nodeEnv + 'grunt build' + (target ? '-' + target : '') + (target2 ? '-' + target2 : '') + ' --color', false, false, { cwd: modulePath })["catch"](function (err) {
529
+ process.exit(1);
530
+ });
531
+ }
532
+ else {
533
+ console.warn('unknown build target. Use es5, es6 or production.');
534
+ }
535
+ };
536
+ // program.command('css').action((message) => {
537
+ // return execp('grunt babel:css-module-transforms');
538
+ // });
539
+ var getLastBuildTime = function (modulePath) {
540
+ return getLastModifiedFile(modulePath + '/@(builds|lib)/**/*.js');
541
+ };
542
+ var getLastModifiedSourceTime = function (modulePath) {
543
+ return getLastModifiedFile(modulePath + '/@(src|data|scss)/**/*', {
544
+ ignore: [modulePath + '/**/*.scss.json', modulePath + '/**/*.d.ts']
545
+ });
546
+ };
547
+ var getLastCommitTime = function (modulePath) {
548
+ // console.log(`git log -1 --format=%ci -- ${modulePath}`);
549
+ // process.exit();
550
+ return execPromise("git log -1 --format=%ci -- " + modulePath).then(function (result) {
551
+ var lastCommit = new Date(result);
552
+ // console.log(modulePath,result,lastCommit);
553
+ return lastCommit;
554
+ });
555
+ };
556
+ var getLastModifiedFile = function (filePath, config) {
557
+ if (config === void 0) { config = {}; }
558
+ var files = glob.sync(filePath, config);
559
+ // console.log(files.join(" - "));
560
+ var lastModifiedName;
561
+ var lastModified;
562
+ var lastModifiedTime = 0;
563
+ files.forEach(function (fileName) {
564
+ if (fs.lstatSync(fileName).isDirectory()) {
565
+ // console.log("skipping directory "+fileName);
566
+ return;
567
+ }
568
+ //not counting things that are generated during build process when determining last modified source-code time
569
+ // if(fileName.indexOf(".d.ts") !== -1 || fileName.indexOf(".css.json") !== -1)
570
+ // {
571
+ // // console.log("not counting "+fileName);
572
+ // return;
573
+ // }
574
+ var mtime = fs.statSync(path.join(fileName)).mtime;
575
+ var modifiedTime = mtime.getTime();
576
+ if (modifiedTime > lastModifiedTime) {
577
+ // console.log(fileName,mtime);
578
+ lastModifiedName = fileName;
579
+ lastModified = mtime;
580
+ lastModifiedTime = modifiedTime;
581
+ }
582
+ });
583
+ return { lastModified: lastModified, lastModifiedName: lastModifiedName, lastModifiedTime: lastModifiedTime };
584
+ };
585
+ program.command('publish-updated').action(function () {
586
+ return publishUpdated();
587
+ });
588
+ program.command('status').action(function () {
589
+ return publishUpdated(true).then(function () {
590
+ return buildUpdated(undefined, '', '', true);
591
+ });
592
+ });
593
+ var publishUpdated = function (test) {
594
+ var _this = this;
595
+ if (test === void 0) { test = false; }
596
+ var modules = getLocalLincdModules();
597
+ var browserCoreBuilt = false;
598
+ var p = Promise.resolve('');
599
+ modules.forEach(function (module) {
600
+ p = p.then(function (previousResult) {
601
+ log('# Checking module ' + module.moduleName);
602
+ // log('# Requesting ' + 'yarn info '+module.packageName+' --json');
603
+ // return execPromise('yarn info '+module.packageName+' --json').then((output:string) => {
604
+ // console.log("Will be requesting npm view from this current working directory:\n"+process.cwd());
605
+ // return execPromise('npm view '+module.packageName+' --json').then((output:string) => {
606
+ return execPromise('yarn info ' + module.packageName + ' --json')
607
+ .then(function (output) { return __awaiter(_this, void 0, void 0, function () {
608
+ var info, lastPublish, lastPublishDate, _a, lastModifiedTime, lastModifiedName, lastModified, lastCommit, res, browserModule;
609
+ return __generator(this, function (_b) {
610
+ switch (_b.label) {
611
+ case 0:
612
+ try {
613
+ if (output == '') {
614
+ // console.warn("No response (empty) from `yarn info`");
615
+ throw new Error('Empty response from `npm view`');
616
+ return [2 /*return*/];
617
+ }
618
+ info = JSON.parse(output);
619
+ // var stats = fs.statSync(path.join(moduleDirectory));
620
+ // var files = fs.readdirSync(path.join(moduleDirectory,'src'));
621
+ }
622
+ catch (err) {
623
+ chalk.red(module.moduleName + ' failed: ' + err.message + '\n');
624
+ console.warn('Returned JSON from npm: ' + output);
625
+ return [2 /*return*/, previousResult + ' ' + chalk.red(module.moduleName + ' failed: ' + err.message + '\n')];
626
+ }
627
+ lastPublish = info.data.time[info.data.version];
628
+ lastPublishDate = new Date(lastPublish);
629
+ _a = getLastModifiedSourceTime(module.path), lastModifiedTime = _a.lastModifiedTime, lastModifiedName = _a.lastModifiedName, lastModified = _a.lastModified;
630
+ return [4 /*yield*/, getLastCommitTime(module.path)];
631
+ case 1:
632
+ lastCommit = _b.sent();
633
+ console.log(lastPublishDate.toDateString() + ' ' + lastPublishDate.toTimeString() + ' published ' + info.data.version);
634
+ console.log(lastCommit.toDateString() + ' ' + new Date(lastCommit).toTimeString() + ' source last committed');
635
+ // console.log(lastModified.toDateString() + ' ' + new Date(lastModified).toTimeString() + ' source ' + lastModifiedName + ' last edited');
636
+ //NOTE: removed lastModified, because switching branches will say that the file was modified and cause everything to publish
637
+ //SO: now you NEED TO commit before it picks up that you should publish
638
+ //|| lastPublishDate.getTime() < lastModified.getTime()
639
+ if (lastPublishDate.getTime() < lastCommit.getTime()) {
640
+ res = executeSingleBuild(module, previousResult, test, info);
641
+ if (module.moduleName == 'browser-core') {
642
+ browserCoreBuilt = true;
643
+ }
644
+ //when publishing core, also make sure to publish browser-core
645
+ if (module.moduleName == 'core' && !browserCoreBuilt) {
646
+ browserModule = modules.find(function (m) { return m.moduleName == 'browser-core'; });
647
+ return [2 /*return*/, Promise.resolve(res).then(function (previousResult) {
648
+ log('# Automatically also publishing module browser-core');
649
+ return executeSingleBuild(browserModule, previousResult, test);
650
+ })];
651
+ }
652
+ return [2 /*return*/, res];
653
+ }
654
+ return [2 /*return*/, previousResult];
655
+ }
656
+ });
657
+ }); })["catch"](function (err) {
658
+ console.log(err);
659
+ return previousResult + ' ' + chalk.red(module.moduleName + ' failed\n');
660
+ });
661
+ });
662
+ });
663
+ return p.then(function (messages) {
664
+ if (messages == '') {
665
+ console.log('All published modules are already up-to-date.');
666
+ }
667
+ else {
668
+ console.log('Summary: \n' + messages);
669
+ }
670
+ });
671
+ };
672
+ var executeSingleBuild = function (module, previousResult, test, info) {
673
+ var nextVersion = info ? getNextVersion(info.data.version) : '';
674
+ console.log(chalk.blue('--> ' + (test ? 'should publish' : 'publishing') + ' ' + module.moduleName + ' ' + nextVersion));
675
+ if (!test) {
676
+ return execPromise('cd ' + module.path + ' && yarn lincd register', true)
677
+ .then(function (res) {
678
+ if (res.indexOf('Aborted due to warnings') !== -1 ||
679
+ res.indexOf('Could not publish') !== -1 ||
680
+ res.indexOf("Couldn't publish") !== -1) {
681
+ console.log(res);
682
+ return previousResult + ' ' + chalk.red(module.moduleName + ' failed\n');
683
+ }
684
+ console.log(chalk.green('Successfully published ' + nextVersion));
685
+ return previousResult + ' ' + chalk.green(module.moduleName + ' published ' + nextVersion + '\n');
686
+ })["catch"](function (err) {
687
+ console.log(chalk.red('Failed to publish: ' + err));
688
+ return chalk.red('Failed to publish: ' + err);
689
+ });
690
+ }
691
+ else {
692
+ //when testing what needs to be published
693
+ return previousResult + ' ' + chalk.blue(module.moduleName + ' should publish\n');
694
+ }
695
+ };
696
+ program.command('build-updated [target] [target2]').action(function (target, target2) {
697
+ return buildUpdated(1, target, target2);
698
+ });
699
+ program.command('build-updated-since [num-commits-back] [target] [target2]').action(function (back, target, target2) {
700
+ return buildUpdated(back, target, target2);
701
+ });
702
+ var buildUpdated = function (back, target, target2, test) {
703
+ if (test === void 0) { test = false; }
704
+ // back = back || 1;
705
+ // return execPromise(`git log -${back} --format=%ci`).then((result) => {
706
+ // let now = new Date();
707
+ var previousResult = '';
708
+ log((test ? 'Checking which modules' : 'Building all modules that') + ' have been changed since their last built ');
709
+ var modules = getLocalLincdModules();
710
+ //TODO: sort all these modules in the order of their dependencies.
711
+ // To do so, see build-all command and put some of the functionality (like getting modules that depend on a module) in reusable functions
712
+ var p = Promise.resolve('');
713
+ modules.forEach(function (module) {
714
+ var moduleName = module.moduleName;
715
+ p = p
716
+ .then(function (previousResult) {
717
+ var lastModifiedSource = getLastModifiedSourceTime(module.path);
718
+ var lastModifiedBundle = getLastBuildTime(module.path);
719
+ // console.log(module.path,lastModifiedSource.lastModifiedTime,lastModifiedBundle.lastModifiedTime);
720
+ // console.log(module.path,new Date(lastModifiedSource.lastModified).toString(),new Date(lastModifiedBundle.lastModified).toString());
721
+ console.log('# Checking module ' + moduleName);
722
+ if (lastModifiedSource.lastModifiedTime > lastModifiedBundle.lastModifiedTime) {
723
+ //TODO: when building a module, also rebuild all modules that depend on this module.. and iteratively build modules that depend on those modules..
724
+ // log(moduleName+' modified since last commit on '+now.toString());
725
+ console.log(chalk.cyan('Last modified source: ' +
726
+ lastModifiedSource.lastModifiedName +
727
+ ' on ' +
728
+ lastModifiedSource.lastModified.toString()));
729
+ console.log(chalk.cyan('Last build: ' +
730
+ (lastModifiedBundle && typeof lastModifiedBundle.lastModified !== 'undefined'
731
+ ? lastModifiedBundle.lastModified.toString()
732
+ : 'never')));
733
+ log('--> ' + (test ? 'need to build ' : 'building ') + moduleName);
734
+ if (!test) {
735
+ return execPromise('cd ' + module.path + ' && yarn build' + (target ? ' ' + target : '') + (target2 ? ' ' + target2 : '')).then(function (res) {
736
+ if (res.indexOf('Aborted due to warnings') !== -1 || res.indexOf('Fatal error') !== -1) {
737
+ console.log(res);
738
+ return previousResult + ' ' + chalk.red(moduleName + ' failed\n');
739
+ }
740
+ console.log(chalk.green(moduleName + ' bundles successfully built'));
741
+ return previousResult + ' ' + chalk.green(moduleName + ' built\n');
742
+ });
743
+ }
744
+ return previousResult + ' ' + chalk.blue(moduleName + ' should be build\n');
745
+ }
746
+ return previousResult;
747
+ })["catch"](function (err) {
748
+ console.log(err);
749
+ return previousResult + ' ' + chalk.red(moduleName + ' failed\n');
750
+ });
751
+ });
752
+ return p.then(function (messages) {
753
+ if (messages == '') {
754
+ console.log(chalk.green('Nothing to rebuild.'));
755
+ }
756
+ else {
757
+ console.log('Summary: \n' + messages);
758
+ }
759
+ });
760
+ // });
761
+ };
762
+ program.command('build-all [target] [target2]').action(function (target, target2) {
763
+ var dependencies = new Map();
764
+ console.log('Building all modules of this repository in order of dependencies');
765
+ var modules = getLocalLincdModuleMap();
766
+ //get dependencies of each module
767
+ var leastDependentModule;
768
+ modules.forEach(function (module) {
769
+ var pack = utils_1.getPackageJSON(module.path);
770
+ if (pack) {
771
+ //get lincd related dependencies and get the actual module details from the module map by removing '@dacore/' from the package name
772
+ var moduleDependencies = Object.keys(pack.dependencies)
773
+ .filter(function (dependency) { return modules.has(dependency); })
774
+ .map(function (dependency) {
775
+ return modules.has(dependency) ? modules.get(dependency) : dependency;
776
+ });
777
+ // console.log(module.moduleName,moduleDependencies.map())
778
+ dependencies.set(module, moduleDependencies);
779
+ }
780
+ });
781
+ dependencies.forEach(function (moduleDependencies, module) {
782
+ if (!moduleDependencies.some(function (dependency) {
783
+ return typeof dependency !== 'string' && modules.has(dependency.moduleName);
784
+ })) {
785
+ leastDependentModule = module;
786
+ }
787
+ });
788
+ var startFrom;
789
+ //by default start building
790
+ var building = true;
791
+ //option to start from a specific module in the stack
792
+ if (target == 'from') {
793
+ startFrom = target2;
794
+ //if we have a startFrom, then we havnt started the build process yet
795
+ building = startFrom ? false : true;
796
+ //clear targets
797
+ target = '';
798
+ target2 = '';
799
+ console.log(chalk.blue('Will skip builds until ' + startFrom));
800
+ }
801
+ var stack = [leastDependentModule];
802
+ var done = new Set();
803
+ var p = Promise.resolve();
804
+ var runStack = function () { return __awaiter(void 0, void 0, void 0, function () {
805
+ var modulesLeft, stackPromise, first_1;
806
+ return __generator(this, function (_a) {
807
+ switch (_a.label) {
808
+ case 0:
809
+ modulesLeft = modules.size - done.size;
810
+ if (done.size > 0) {
811
+ console.log(chalk.magenta('\n-------\nThese modules are next, since all their dependencies have now been build:'));
812
+ console.log(chalk.magenta(stack.map(function (i) { return i.moduleName; })));
813
+ // log(stack);
814
+ }
815
+ stackPromise = Promise.all(stack.map(function (module) {
816
+ // p = p.then(() => {
817
+ var command;
818
+ //if we're skipping builds until a certain module
819
+ if (!building) {
820
+ //if the module name matches the module we're supposed to start from then start building modules
821
+ if (module.moduleName == startFrom || module.packageName == startFrom) {
822
+ building = true;
823
+ }
824
+ //else still waiting for the module
825
+ else {
826
+ log(chalk.blue('skipping ' + module.moduleName));
827
+ command = Promise.resolve(true);
828
+ }
829
+ }
830
+ //unless told otherwise, build the module
831
+ if (!command) {
832
+ command = execp('cd ' +
833
+ module.path +
834
+ ' && yarn lincd build' +
835
+ (target ? ' ' + target : '') +
836
+ (target2 ? ' ' + target2 : ''));
837
+ log(chalk.cyan('Building ' + module.moduleName));
838
+ }
839
+ return command["catch"](function (err) {
840
+ var dependentModules = [];
841
+ dependencies.forEach(function (dModuleDependencies, dModule) {
842
+ if (dModuleDependencies.indexOf(module) !== -1) {
843
+ dependentModules.push(dModule);
844
+ }
845
+ });
846
+ if (dependentModules.length > 0) {
847
+ console.log(chalk.magenta('Stopping build process because an error occurred whilst building ' +
848
+ module.moduleName +
849
+ ', which ' +
850
+ dependentModules.length +
851
+ ' other modules depend on.')); //"+dependentModules.map(d => d.moduleName).join(", ")));
852
+ console.log(chalk.cyanBright('tip ') +
853
+ 'Run ' +
854
+ chalk.green("lincd build-all from " + module.moduleName) +
855
+ ' to build only the remaining modules'); //"+dependentModules.map(d => d.moduleName).join(", ")));
856
+ process.exit(1);
857
+ }
858
+ })
859
+ .then(function (res) {
860
+ done.add(module);
861
+ modulesLeft--;
862
+ log(chalk.magenta(modulesLeft + ' modules left'));
863
+ return res;
864
+ });
865
+ // });
866
+ // done.add(module);
867
+ }));
868
+ //wait till stack is completed
869
+ return [4 /*yield*/, stackPromise];
870
+ case 1:
871
+ //wait till stack is completed
872
+ _a.sent();
873
+ // await p;
874
+ //clear stack for next round
875
+ stack = [];
876
+ //find those modules who have all their dependencies already built and add them to the stack
877
+ modules.forEach(function (module) {
878
+ var deps = dependencies.get(module);
879
+ //if the module is not done yet
880
+ //but every dependency is now done OR was not something we can build (some @dacore dependencies may not be local)
881
+ if (!done.has(module) &&
882
+ deps.every(function (dependency) {
883
+ return typeof dependency !== 'string' && (done.has(dependency) || !modules.has(dependency.moduleName));
884
+ })) {
885
+ stack.push(module);
886
+ }
887
+ // else if(!done.has(module))
888
+ // {
889
+ // console.log(chalk.red(module+' not yet'))
890
+ // console.log('UNMET DEPS: '+deps.filter(dependency => !done.has(dependency)).join(" "))
891
+ // }
892
+ });
893
+ //if more to be built, iterate
894
+ if (stack.length > 0) {
895
+ return [2 /*return*/, runStack()];
896
+ }
897
+ else {
898
+ //if no more modules to build but we never started building...
899
+ if (!building) {
900
+ console.log(chalk.red('Could not find the module to start from. Please provide a correct package name or module name to build from'));
901
+ }
902
+ else {
903
+ first_1 = true;
904
+ modules.forEach(function (module) {
905
+ if (!done.has(module)) {
906
+ var deps = dependencies.get(module);
907
+ if (first_1) {
908
+ console.log(chalk.red('CYCLICAL DEPENDENCIES? - could not build some modules because they depend on each other.'));
909
+ first_1 = false;
910
+ }
911
+ //print the cyclical dependencies
912
+ console.log(chalk.red(module.moduleName) +
913
+ ' depends on ' +
914
+ deps
915
+ .filter(function (dependency) {
916
+ return typeof dependency !== 'string';
917
+ })
918
+ .map(function (d) {
919
+ return done.has(d) ? d.moduleName : chalk.red(d.moduleName);
920
+ })
921
+ .join(', '));
922
+ //also print some information why these modules have not been moved into the stack
923
+ var stringDependencies = deps.filter(function (d) { return typeof d === 'string'; });
924
+ if (stringDependencies.length > 0) {
925
+ console.log(chalk.red('And it depends on these module(s) - which seem not to be proper modules :' +
926
+ stringDependencies.join(', ')));
927
+ console.log(chalk.red('Could you remove this from dependencies? Should it be a devDependency?'));
928
+ }
929
+ }
930
+ });
931
+ }
932
+ }
933
+ return [2 /*return*/];
934
+ }
935
+ });
936
+ }); };
937
+ //starts the process
938
+ runStack();
939
+ });
940
+ program.command('modules [action] [includedSpaces]').action(function (command, includedSpaces) {
941
+ executeCommandForEachModule(getLincdModules(), command, includedSpaces);
942
+ });
943
+ program.command('modules-except [excludedSpaces] [action]').action(function (excludedSpaces, command) {
944
+ executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);
945
+ });
946
+ program
947
+ .command('module|mod [module] [a1] [a2] [a3] [a4]')
948
+ .action(function (module) {
949
+ var args = [];
950
+ for (var _i = 1; _i < arguments.length; _i++) {
951
+ args[_i - 1] = arguments[_i];
952
+ }
953
+ var command = args
954
+ .slice(0, 3)
955
+ .filter(function (a) { return a && true; })
956
+ .join(' ');
957
+ executeCommandForModule(module, command);
958
+ })
959
+ .alias('mod')
960
+ .alias('m');
961
+ var executeCommandForEachModule = function (modules, command, includedSpaces, excludedSpaces) {
962
+ //if a specific set of modules is given
963
+ if (includedSpaces) {
964
+ //filter modules, so that we only execute on the modules as provided in the command
965
+ includedSpaces = includedSpaces.split(',');
966
+ modules = modules.filter(function (module) { return includedSpaces.indexOf(module.moduleName) !== -1; });
967
+ log('Applying to included spaces');
968
+ }
969
+ //if a specific set of modules is given
970
+ if (excludedSpaces) {
971
+ //filter modules, so that we only execute on the modules as provided in the command
972
+ excludedSpaces = excludedSpaces.split(',');
973
+ modules = modules.filter(function (module) { return excludedSpaces.indexOf(module.moduleName) === -1; });
974
+ log('Filtering excluded spaces');
975
+ }
976
+ log("Executing '" + command + "' on modules " + modules.map(function (m) { return m.moduleName; }).join(', '));
977
+ var p = Promise.resolve(true);
978
+ modules.forEach(function (module) {
979
+ p = p.then(function () {
980
+ log('# Module ' + module.moduleName + ' - ' + module.path);
981
+ return execp('cd ' + module.path + ' && ' + command);
982
+ });
983
+ });
984
+ return p;
985
+ };
986
+ var executeCommandForModule = function (module, command) {
987
+ var moduleDetails = getLincdModules().find(function (modDetails) {
988
+ return modDetails.packageName.indexOf(module) !== -1 || modDetails.moduleName.indexOf(module) !== -1;
989
+ });
990
+ if (moduleDetails) {
991
+ log("Executing 'cd " + moduleDetails.path + ' && lincd ' + command + "'");
992
+ return execp('cd ' + moduleDetails.path + ' && lincd ' + command);
993
+ }
994
+ };
995
+ program.command('dev [target] [mode]').action(function (target, mode) {
996
+ if (!target)
997
+ target = 'es6';
998
+ if (mode !== 'production')
999
+ mode = '';
1000
+ else if (target !== 'es6')
1001
+ log('target must be es6 when developing for production');
1002
+ if (target == 'es5' || target == 'es6') {
1003
+ // log('> Starting continuous development build for '+target+' target')
1004
+ log('starting continuous development build');
1005
+ log('grunt dev' + (target ? '-' + target : '') + (mode ? '-' + mode : '') + ' --color');
1006
+ var command = exec('grunt dev' + (target ? '-' + target : '') + (mode ? '-' + mode : '') + ' --color');
1007
+ command.stdout.pipe(process.stdout);
1008
+ command.stderr.pipe(process.stderr);
1009
+ }
1010
+ else {
1011
+ console.warn('unknown build target. Use es5 or es6');
1012
+ }
1013
+ });
1014
+ program.command('help').action(function (command) {
1015
+ logHelp();
1016
+ });
1017
+ program.command('*').action(function (command) {
1018
+ console.warn(chalk.red('unknown command: ' + command.args.join(' ')));
1019
+ logHelp();
1020
+ });
1021
+ function logHelp() {
1022
+ var ownPackage = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
1023
+ console.log('lincd-cli ' + ownPackage.version);
1024
+ console.log(chalk.green('\nAvailable commands from a module:'));
1025
+ console.log(chalk.blue('- build [es5|es6|production] [es5|es6] ') +
1026
+ chalk.cyan('- creates bundles & compiles source files each target environment'));
1027
+ console.log(chalk.blue('- dev [es5|es6] [production] ') +
1028
+ chalk.cyan('- continuously build bundles & compile source on file changes'));
1029
+ // console.log(
1030
+ // chalk.blue('- init [name] [uribase] ') +
1031
+ // chalk.cyan(
1032
+ // '- sets up a new module, sets up initial files and installs dependencies',
1033
+ // ),
1034
+ // );
1035
+ console.log(chalk.blue('- publish [version|minor|major|patch] ') +
1036
+ chalk.cyan('- publish new version to the npm registry AND to the LINCD.org registry'));
1037
+ //TODO: these all need to be tested to see if they work with the new LINCD setup
1038
+ console.log(chalk.green('\nAvailable commands from a yarn workspace:'));
1039
+ console.log(chalk.blue('- modules|mod|m module-name ...command') +
1040
+ chalk.cyan('- execute a lincd command for a specific module in this workspace. Use can use partial packageNames. So `lincd m xsd build` will trigger `lincd build` for the module lincd-xsd'));
1041
+ console.log(chalk.blue('- build-all [from] [module-name]') +
1042
+ chalk.cyan('- build all modules in order of dependencies. To continue later from a specific module, add `from {modulename}`'));
1043
+ console.log(chalk.blue('- build-updated') +
1044
+ chalk.cyan('- build only those modules that have updated their source since their last local built'));
1045
+ /*
1046
+ console.log(
1047
+ chalk.blue('- build-updated [n] ') +
1048
+ chalk.cyan(
1049
+ '- build only those modules that have updated their source since the last local commit (or optionally n commits back',
1050
+ ),
1051
+ );
1052
+ console.log(
1053
+ chalk.blue('- modules [action]') +
1054
+ chalk.cyan('- execute a command for all modules'),
1055
+ );
1056
+ console.log(
1057
+ chalk.blue('- publish-updated [message] ') +
1058
+ chalk.cyan(
1059
+ "- publish all modules who's source changes have been committed to git since the last published version.",
1060
+ ),
1061
+ );
1062
+ console.log(
1063
+ chalk.blue('- status') +
1064
+ chalk.cyan('- see which modules need to be published or build'),
1065
+ );*/
1066
+ console.log(chalk.green('\nOther commands:'));
1067
+ console.log(chalk.blue('- info ') + chalk.cyan('- print the version of this tool and where it runs from'));
1068
+ console.log(chalk.blue('- help ') + chalk.cyan('- print this message'));
1069
+ }
1070
+ program.parse(process.argv);