lincd-cli 0.1.24 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,9 +22,9 @@
22
22
  "web3"
23
23
  ],
24
24
  "dependencies": {
25
- "lincd": "^0.3.6"
25
+ "lincd": "^0.4"
26
26
  },
27
27
  "devDependencies": {
28
- "lincd-cli": "^0.1"
28
+ "lincd-cli": "^0.2"
29
29
  }
30
30
  }
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ frontend/build
3
+ modules/**/dist
4
+ modules/**/lib
@@ -37,7 +37,7 @@
37
37
  "@babel/preset-react": "^7.18.6",
38
38
  "@babel/preset-typescript": "^7.18.6",
39
39
  "@babel/register": "^7.18.9",
40
- "lincd": "^0.3.6",
40
+ "lincd": "^0.4",
41
41
  "lincd-jsonld": "^0.1.5",
42
42
  "lincd-server": "^0.1",
43
43
  "react": "^18.2",
@@ -49,8 +49,7 @@
49
49
  "@types/react": "^18.0.17",
50
50
  "@types/react-dom": "^18.0.6",
51
51
  "env-cmd": "^10.1.0",
52
- "lincd-cli": "^0.1",
53
- "nodemon": "^2.0.6",
54
- "ts-loader": "^9.4.1"
52
+ "lincd-cli": "^0.2",
53
+ "nodemon": "^2.0.6"
55
54
  }
56
55
  }
File without changes
@@ -1,5 +1,5 @@
1
1
  var buildTools = require('lincd-cli');
2
- module.exports = buildTools.generateGruntConfig('${module_name}', {
2
+ module.exports = buildTools.generateGruntConfig('${package_name}', {
3
3
  externals: {
4
4
  react: 'React',
5
5
  'react-dom': 'ReactDOM',
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "${module_name}",
2
+ "name": "${package_name}",
3
3
  "description": "",
4
4
  "author": {
5
5
  "name": "",
@@ -29,10 +29,10 @@
29
29
  "web3"
30
30
  ],
31
31
  "dependencies": {
32
- "lincd": "^0.3.6",
32
+ "lincd": "^0.4",
33
33
  "lincd-jsonld": "^0.1"
34
34
  },
35
35
  "devDependencies": {
36
- "lincd-cli": "^0.1"
36
+ "lincd-cli": "^0.2"
37
37
  }
38
38
  }
File without changes
@@ -1,4 +1,4 @@
1
1
  import {linkedPackage} from 'lincd/lib/utils/Module';
2
2
 
3
3
  export const {linkedComponent, linkedComponentClass, linkedShape, linkedUtil, linkedOntology, registerPackageModule, registerPackageExport, packageExports} =
4
- linkedPackage('${module_name}');
4
+ linkedPackage('${package_name}');
File without changes
File without changes
package/lib/cli.js CHANGED
@@ -81,9 +81,9 @@ program
81
81
  .description('Creates a new folder with all the required files for a LINCD app')
82
82
  .argument('<name>', 'the name of your LINCD app. To use spaces, wrap the name in double quotes.');
83
83
  program
84
- .command('create-module')
84
+ .command('create-package')
85
85
  .action(function (name, uriBase) {
86
- return createModule(name, uriBase);
86
+ return createPackage(name, uriBase);
87
87
  })
88
88
  .description('Create a new folder with all the required files for a new LINCD package')
89
89
  .argument('<name>', 'The name of the package. Will be used as package name in package.json')
@@ -131,7 +131,7 @@ program
131
131
  })
132
132
  .description("Log the version of this tool and the path that it's running from");
133
133
  program.command('build [target] [target2]', { isDefault: true }).action(function (target, target2) {
134
- buildModule(target, target2);
134
+ buildPackage(target, target2);
135
135
  });
136
136
  program.command('publish-updated').action(function () {
137
137
  return publishUpdated();
@@ -153,16 +153,16 @@ program.command('build-all [target] [target2]').action(function (target, target2
153
153
  buildAll(target, target2);
154
154
  });
155
155
  program.command('all [action] [filter] [filter-value]').action(function (command, filter, filterValue) {
156
- executeCommandForEachModule(getLincdModules(), command, filter, filterValue);
156
+ executeCommandForEachPackage(getLincdPackages(), command, filter, filterValue);
157
157
  });
158
158
  // program.command('all-except [excludedSpaces] [action]').action((excludedSpaces, command) => {
159
159
  // executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);
160
160
  // });
161
161
  program.command('dev [target] [mode]').action(function (target, mode) {
162
- developModule(target, mode);
162
+ developPackage(target, mode);
163
163
  });
164
164
  program
165
- .command('module|m|package|p')
165
+ .command('package')
166
166
  .action(function (name, command, args) {
167
167
  var fullCommand = command
168
168
  ? command +
@@ -173,9 +173,12 @@ program
173
173
  .filter(function (a) { return a && true; })
174
174
  .join(' ')
175
175
  : null;
176
- executeCommandForModule(name, fullCommand);
176
+ executeCommandForPackage(name, fullCommand);
177
177
  })
178
+ .alias('p')
179
+ .alias('pkg')
178
180
  .alias('m')
181
+ .alias('module')
179
182
  .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
183
  .argument('<name>', 'the name of the package. Can be a part of the name.')
181
184
  .argument('[command]', 'the lincd command you want to execute. Like dev or build')
@@ -229,7 +232,7 @@ function warn() {
229
232
  // console.log(chalk.red(message));
230
233
  });
231
234
  }
232
- function developModule(target, mode) {
235
+ function developPackage(target, mode) {
233
236
  if (!target)
234
237
  target = 'es6';
235
238
  if (mode !== 'production')
@@ -261,29 +264,28 @@ function checkWorkspaces(rootPath, workspaces, res) {
261
264
  var folders = fs.readdirSync(workspacePath);
262
265
  folders.forEach(function (folder) {
263
266
  if (folder !== './' && folder !== '../') {
264
- checkModulePath(rootPath, path.join(workspacePath, folder), res);
267
+ checkPackagePath(rootPath, path.join(workspacePath, folder), res);
265
268
  }
266
269
  });
267
270
  }
268
271
  }
269
272
  else {
270
- checkModulePath(rootPath, workspacePath, res);
273
+ checkPackagePath(rootPath, workspacePath, res);
271
274
  }
272
275
  });
273
276
  }
274
- function checkModulePath(rootPath, modulePath, res) {
275
- var packagePath = path.join(modulePath, 'package.json');
277
+ function checkPackagePath(rootPath, packagePath, res) {
278
+ var packageJsonPath = path.join(packagePath, 'package.json');
276
279
  // console.log('checking '+packagePath);
277
- if (fs.existsSync(packagePath)) {
278
- var pack = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
280
+ if (fs.existsSync(packageJsonPath)) {
281
+ var pack = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
279
282
  //some packages are not true lincd packages, but we still want them to be re-built automatically. This is what lincd_util is for
280
283
  if (pack && pack.workspaces) {
281
- checkWorkspaces(modulePath, pack.workspaces, res);
284
+ checkWorkspaces(packagePath, pack.workspaces, res);
282
285
  }
283
286
  else if (pack && pack.lincd === true) {
284
287
  res.push({
285
- path: modulePath,
286
- moduleName: pack.name,
288
+ path: packagePath,
287
289
  packageName: pack.name
288
290
  });
289
291
  }
@@ -293,28 +295,28 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
293
295
  var _this = this;
294
296
  var dependencies = new Map();
295
297
  //get dependencies of each package
296
- var leastDependentModule;
298
+ var leastDependentPackage;
297
299
  lincdPackages.forEach(function (pkg) {
298
300
  var pack = (0, utils_1.getPackageJSON)(pkg.path);
299
301
  if (pack) {
300
302
  //get lincd related dependencies and get the actual package details from the package map by removing '@dacore/' from the package name
301
- var moduleDependencies = Object.keys(pack.dependencies)
303
+ var packageDependencies = Object.keys(pack.dependencies)
302
304
  .filter(function (dependency) { return lincdPackages.has(dependency); })
303
305
  .map(function (dependency) {
304
306
  return lincdPackages.has(dependency) ? lincdPackages.get(dependency) : dependency;
305
307
  });
306
- // console.log(package.moduleName,moduleDependencies.map())
307
- dependencies.set(pkg, moduleDependencies);
308
+ // console.log(package.packageName,packageDependencies.map())
309
+ dependencies.set(pkg, packageDependencies);
308
310
  }
309
311
  });
310
- dependencies.forEach(function (moduleDependencies, pkg) {
311
- if (!moduleDependencies.some(function (dependency) {
312
- return typeof dependency !== 'string' && lincdPackages.has(dependency.moduleName);
312
+ dependencies.forEach(function (PackageDependencies, pkg) {
313
+ if (!PackageDependencies.some(function (dependency) {
314
+ return typeof dependency !== 'string' && lincdPackages.has(dependency.packageName);
313
315
  })) {
314
- leastDependentModule = pkg;
316
+ leastDependentPackage = pkg;
315
317
  }
316
318
  });
317
- var startStack = [leastDependentModule];
319
+ var startStack = [leastDependentPackage];
318
320
  var done = new Set();
319
321
  var results = [];
320
322
  var runStack = function (stack) { return __awaiter(_this, void 0, void 0, function () {
@@ -327,8 +329,8 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
327
329
  // p = p.then(() => {
328
330
  return runFunction(pck)["catch"](function (_a) {
329
331
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
330
- warn('Uncaught exception whilst running parallel function on ' + pck.moduleName, error.message);
331
- // warn(chalk.red(pck.moduleName+' failed:'));
332
+ warn('Uncaught exception whilst running parallel function on ' + pck.packageName, error.message);
333
+ // warn(chalk.red(pck.packageName+' failed:'));
332
334
  // console.log(stdout);
333
335
  })
334
336
  .then(function (res) {
@@ -349,7 +351,7 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
349
351
  //but every dependency is now done OR was not something we can build (some @dacore dependencies may not be local)
350
352
  if (!done.has(pkg) &&
351
353
  deps.every(function (dependency) {
352
- return typeof dependency !== 'string' && (done.has(dependency) || !lincdPackages.has(dependency.moduleName));
354
+ return typeof dependency !== 'string' && (done.has(dependency) || !lincdPackages.has(dependency.packageName));
353
355
  })) {
354
356
  stack.push(pkg);
355
357
  }
@@ -376,7 +378,7 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
376
378
  function buildAll(target, target2) {
377
379
  var _this = this;
378
380
  console.log('Building all LINCD packages of this repository in order of dependencies');
379
- var lincdPackages = getLocalLincdModuleMap();
381
+ var lincdPackages = getLocalLincdPackageMap();
380
382
  var startFrom;
381
383
  //by default start building
382
384
  var building = true;
@@ -396,61 +398,61 @@ function buildAll(target, target2) {
396
398
  var done = new Set();
397
399
  var failedModules = [];
398
400
  progressUpdate(lincdPackages.size + ' packages left');
399
- var modulesLeft = lincdPackages.size;
400
- // let modulesLeft = lincdPackages.size - done.size;
401
+ var packagesLeft = lincdPackages.size;
402
+ // let packagesLeft = lincdPackages.size - done.size;
401
403
  runOnPackagesGroupedByDependencies(lincdPackages, function (packageGroup, dependencies) {
402
404
  if (done.size > 0) {
403
405
  debugInfo(chalk.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
404
406
  // log(stack);
405
407
  }
406
- debugInfo('Now building: ' + chalk.blue(packageGroup.map(function (i) { return i.moduleName; })));
408
+ debugInfo('Now building: ' + chalk.blue(packageGroup.map(function (i) { return i.packageName; })));
407
409
  return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
408
410
  var command;
409
411
  return __generator(this, function (_a) {
410
412
  //if we're skipping builds until a certain package
411
413
  if (!building) {
412
414
  //if the package name matches the package we're supposed to start from then start building packages
413
- if (pkg.moduleName == startFrom || pkg.packageName == startFrom) {
415
+ if (pkg.packageName == startFrom || pkg.packageName == startFrom) {
414
416
  building = true;
415
417
  }
416
418
  //else still waiting for the package
417
419
  else {
418
- log(chalk.blue('skipping ' + pkg.moduleName));
420
+ log(chalk.blue('skipping ' + pkg.packageName));
419
421
  command = Promise.resolve(true);
420
422
  }
421
423
  }
422
424
  //unless told otherwise, build the package
423
425
  if (!command) {
424
426
  command = execPromise('cd ' + pkg.path + ' && yarn lincd build' + (target ? ' ' + target : '') + (target2 ? ' ' + target2 : ''), false, false, {}, false);
425
- debugInfo(chalk.cyan('Building ' + pkg.moduleName));
427
+ debugInfo(chalk.cyan('Building ' + pkg.packageName));
426
428
  }
427
429
  return [2 /*return*/, command["catch"](function (_a) {
428
430
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
429
431
  //this prints out the webpack output, including the build errors
430
- warn('Failed to build ' + pkg.moduleName);
432
+ warn('Failed to build ' + pkg.packageName);
431
433
  console.log(stdout);
432
- failedModules.push(pkg.moduleName);
434
+ failedModules.push(pkg.packageName);
433
435
  var dependentModules = getDependentPackages(dependencies, pkg);
434
436
  if (dependentModules.length > 0) {
435
437
  printBuildResults(failedModules, done);
436
438
  console.log(chalk.magenta('Stopping build process because an error occurred whilst building ' +
437
- pkg.moduleName +
439
+ pkg.packageName +
438
440
  ', which ' +
439
441
  dependentModules.length +
440
- ' other packages depend on.')); //"+dependentModules.map(d => d.moduleName).join(", ")));
442
+ ' other packages depend on.')); //"+dependentModules.map(d => d.packageName).join(", ")));
441
443
  console.log(chalk.cyanBright('tip ') +
442
444
  'Run ' +
443
- chalk.green("lincd build-all from ".concat(pkg.moduleName)) +
444
- ' to build only the remaining packages'); //"+dependentModules.map(d => d.moduleName).join(", ")));
445
+ chalk.green("lincd build-all from ".concat(pkg.packageName)) +
446
+ ' to build only the remaining packages'); //"+dependentModules.map(d => d.packageName).join(", ")));
445
447
  process.exit(1);
446
448
  }
447
449
  })
448
450
  .then(function (res) {
449
451
  done.add(pkg);
450
- modulesLeft--;
451
- // log(chalk.magenta(modulesLeft + ' packages left'));
452
- process.stdout.write(modulesLeft + ' packages left\r');
453
- if (modulesLeft == 0) {
452
+ packagesLeft--;
453
+ // log(chalk.magenta(packagesLeft + ' packages left'));
454
+ process.stdout.write(packagesLeft + ' packages left\r');
455
+ if (packagesLeft == 0) {
454
456
  printBuildResults(failedModules, done);
455
457
  }
456
458
  return res;
@@ -473,14 +475,14 @@ function buildAll(target, target2) {
473
475
  first_1 = false;
474
476
  }
475
477
  //print the cyclical dependencies
476
- console.log(chalk.red(pkg.moduleName) +
478
+ console.log(chalk.red(pkg.packageName) +
477
479
  ' depends on ' +
478
480
  deps
479
481
  .filter(function (dependency) {
480
482
  return typeof dependency !== 'string';
481
483
  })
482
484
  .map(function (d) {
483
- return done.has(d) ? d.moduleName : chalk.red(d.moduleName);
485
+ return done.has(d) ? d.packageName : chalk.red(d.packageName);
484
486
  })
485
487
  .join(', '));
486
488
  //also print some information why these packages have not been moved into the stack
@@ -508,24 +510,24 @@ function getDependentPackages(dependencies, pkg) {
508
510
  * Returns a map of the packages that this repository manages (so no packages found through the workspaces who's path contains ../ )
509
511
  * @param rootPath
510
512
  */
511
- function getLocalLincdModuleMap(rootPath) {
513
+ function getLocalLincdPackageMap(rootPath) {
512
514
  if (rootPath === void 0) { rootPath = './'; }
513
515
  var map = new Map();
514
- getLincdModules(rootPath).forEach(function (pkg) {
516
+ getLincdPackages(rootPath).forEach(function (pkg) {
515
517
  if (pkg.path.indexOf('../') === -1 && pkg.path.indexOf('..\\') === -1) {
516
518
  // console.log(package.path);
517
- map.set(pkg.moduleName, pkg);
519
+ map.set(pkg.packageName, pkg);
518
520
  }
519
521
  });
520
522
  return map;
521
523
  }
522
524
  function getLocalLincdModules(rootPath) {
523
525
  if (rootPath === void 0) { rootPath = './'; }
524
- return getLincdModules(rootPath).filter(function (pkg) {
526
+ return getLincdPackages(rootPath).filter(function (pkg) {
525
527
  return pkg.path.indexOf('..\\') === -1;
526
528
  });
527
529
  }
528
- function getLincdModules(rootPath) {
530
+ function getLincdPackages(rootPath) {
529
531
  if (rootPath === void 0) { rootPath = process.cwd(); }
530
532
  var pack = (0, utils_1.getPackageJSON)();
531
533
  if (!pack || !pack.workspaces) {
@@ -686,11 +688,11 @@ var createOntology = function (prefix, uriBase, basePath) {
686
688
  //copy ontology accessor file
687
689
  log("Creating files for ontology '" + prefix + "'");
688
690
  targetFile = path.join(targetFolder, hyphenName + '.ts');
689
- fs.copySync(path.join(__dirname, '..', 'defaults', 'module', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
691
+ fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
690
692
  targetDataFile = path.join(targetFolder, '..', 'data', hyphenName + '.json');
691
693
  targetDataFile2 = path.join(targetFolder, '..', 'data', hyphenName + '.json.d.ts');
692
- fs.copySync(path.join(__dirname, '..', 'defaults', 'module', 'src', 'data', 'example-ontology.json'), targetDataFile);
693
- fs.copySync(path.join(__dirname, '..', 'defaults', 'module', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
694
+ fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json'), targetDataFile);
695
+ fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
694
696
  return [4 /*yield*/, replaceVariablesInFiles(targetFile, targetDataFile, targetDataFile2)];
695
697
  case 1:
696
698
  _b.sent();
@@ -781,7 +783,7 @@ var ensureFolderExists = function () {
781
783
  fs.mkdirSync(targetFolder);
782
784
  } else {
783
785
  warn(
784
- `Please run this command from the root of your module. This command expects ${parentDirectory.toString()} to exists from that folder`,
786
+ `Please run this command from the root of your package. This command expects ${parentDirectory.toString()} to exists from that folder`,
785
787
  );
786
788
  }
787
789
  }
@@ -789,7 +791,7 @@ var ensureFolderExists = function () {
789
791
  };
790
792
  var setNameVariables = function (name) {
791
793
  var hyphenName = name.replace(/[-_\s]+/g, '-');
792
- var camelCaseName = camelCase(name); //some-module --> someModule
794
+ var camelCaseName = camelCase(name); //some-package --> someModule
793
795
  var underscoreName = name.replace(/[-\s]+/g, '_');
794
796
  //longer similar variables names should come before the shorter ones
795
797
  setVariable('underscore_name', underscoreName);
@@ -850,7 +852,7 @@ var createComponent = function (name, basePath) {
850
852
  });
851
853
  });
852
854
  };
853
- var createModule = function (name, uriBase, basePath) {
855
+ var createPackage = function (name, uriBase, basePath) {
854
856
  if (basePath === void 0) { basePath = process.cwd(); }
855
857
  return __awaiter(void 0, void 0, void 0, function () {
856
858
  var _a, packageName, scope, cleanPackageName, targetFolder, _b, hyphenName, camelCaseName, underscoreName, version, installCommand;
@@ -859,8 +861,8 @@ var createModule = function (name, uriBase, basePath) {
859
861
  case 0:
860
862
  //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)
861
863
  //so we manually find a packages folder, if it exists we go into that.
862
- if (fs.existsSync(path.join(basePath, 'modules'))) {
863
- basePath = path.join(basePath, 'modules');
864
+ if (fs.existsSync(path.join(basePath, 'packages'))) {
865
+ basePath = path.join(basePath, 'packages');
864
866
  }
865
867
  if (!name) {
866
868
  console.warn('Please provide a name as the first argument');
@@ -877,13 +879,13 @@ var createModule = function (name, uriBase, basePath) {
877
879
  // --> match[0] = @dacore/some-mod
878
880
  // --> match[1] = @dacore
879
881
  // --> match[2] = some-mod
880
- //but save full scoped package name under ${module_name}
881
- setVariable('module_name', name);
882
+ //but save full scoped package name under ${package_name}
883
+ setVariable('package_name', name);
882
884
  //extra variable for clarity (will be same as 'name')
883
885
  setVariable('output_file_name', name);
884
886
  _b = setNameVariables(cleanPackageName), hyphenName = _b.hyphenName, camelCaseName = _b.camelCaseName, underscoreName = _b.underscoreName;
885
887
  log("Creating new LINCD package '" + name + "'");
886
- fs.copySync(path.join(__dirname, '..', 'defaults', 'module'), targetFolder);
888
+ fs.copySync(path.join(__dirname, '..', 'defaults', 'package'), targetFolder);
887
889
  //replace variables in some of the copied files
888
890
  return [4 /*yield*/, Promise.all([
889
891
  'src/index.ts',
@@ -997,7 +999,7 @@ var buildFailed = function (output) {
997
999
  var pack = JSON.parse(
998
1000
  fs.readFileSync(process.cwd() + '/package.json', 'utf8'),
999
1001
  );
1000
- let moduleName = pack.name;
1002
+ let packageName = pack.name;
1001
1003
 
1002
1004
  //just making sure the library is loaded in correct order because circular references are currently happening when importing BlankNode before NamedNode for example
1003
1005
  // require('lincd');
@@ -1008,7 +1010,7 @@ var buildFailed = function (output) {
1008
1010
  let shapeJSONLD = await getShapesJSONLD(indexExports.packageExports);
1009
1011
  console.log(indexExports.packageExports);
1010
1012
  console.log(shapeJSONLD);
1011
- console.log(chalk.bold(chalk.green(moduleName+'/dist/shapes.json')));
1013
+ console.log(chalk.bold(chalk.green(packageName+'/dist/shapes.json')));
1012
1014
  return fs.writeFile(path.join('dist', 'shapes.json'), shapeJSONLD);
1013
1015
  }
1014
1016
  else
@@ -1024,7 +1026,7 @@ var register = function (registryURL) {
1024
1026
  if (fs.existsSync(process.cwd() + '/package.json')) {
1025
1027
  var pack = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
1026
1028
  var version = pack.version;
1027
- var moduleName = pack.name;
1029
+ var packageName = pack.name;
1028
1030
  // let author = pack.author;
1029
1031
  // let description = pack.description;
1030
1032
  //
@@ -1032,14 +1034,14 @@ var register = function (registryURL) {
1032
1034
  // if (pack.author.name) {
1033
1035
  // authorName = pack.author.name;
1034
1036
  // }
1035
- console.log(chalk.cyan('registering package ' + moduleName + ' ' + version + ' in the LINCD registry'));
1037
+ console.log(chalk.cyan('registering package ' + packageName + ' ' + version + ' in the LINCD registry'));
1036
1038
  return fetch(registryURL + '/register', {
1037
1039
  method: 'POST',
1038
1040
  headers: {
1039
1041
  Accept: 'application/json, text/plain, */*',
1040
1042
  'Content-Type': 'application/json'
1041
1043
  },
1042
- body: JSON.stringify({ package: moduleName, version: version })
1044
+ body: JSON.stringify({ package: packageName, version: version })
1043
1045
  })
1044
1046
  .then(function (res) { return res.json(); })
1045
1047
  .then(function (json) {
@@ -1060,12 +1062,12 @@ var register = function (registryURL) {
1060
1062
  console.warn(chalk.red('Warning:') + ' not found: ' + process.cwd() + '/package.json');
1061
1063
  }
1062
1064
  };
1063
- var buildModule = function (target, target2, modulePath, logResults) {
1064
- if (modulePath === void 0) { modulePath = process.cwd(); }
1065
+ var buildPackage = function (target, target2, packagePath, logResults) {
1066
+ if (packagePath === void 0) { packagePath = process.cwd(); }
1065
1067
  if (logResults === void 0) { logResults = true; }
1066
1068
  if (target == 'production' || target == 'es5' || target == 'es6' || !target) {
1067
- if (!fs.existsSync(path.join(modulePath, 'Gruntfile.js'))) {
1068
- console.warn("No Gruntfile found at ".concat(modulePath, "\\Gruntfile.js. Cannot build."));
1069
+ if (!fs.existsSync(path.join(packagePath, 'Gruntfile.js'))) {
1070
+ console.warn("No Gruntfile found at ".concat(packagePath, "\\Gruntfile.js. Cannot build."));
1069
1071
  return;
1070
1072
  }
1071
1073
  var nodeEnv = '';
@@ -1093,7 +1095,7 @@ var buildModule = function (target, target2, modulePath, logResults) {
1093
1095
  ' --color');
1094
1096
  var method = logResults ? execp : execPromise;
1095
1097
  //execute the command to build the method, and provide the current work directory as option
1096
- return method(nodeEnv + 'grunt build' + (target ? '-' + target : '') + (target2 ? '-' + target2 : '') + ' --color', false, false, { cwd: modulePath })["catch"](function (err) {
1098
+ return method(nodeEnv + 'grunt build' + (target ? '-' + target : '') + (target2 ? '-' + target2 : '') + ' --color', false, false, { cwd: packagePath })["catch"](function (err) {
1097
1099
  process.exit(1);
1098
1100
  });
1099
1101
  }
@@ -1101,21 +1103,21 @@ var buildModule = function (target, target2, modulePath, logResults) {
1101
1103
  console.warn('unknown build target. Use es5, es6 or production.');
1102
1104
  }
1103
1105
  };
1104
- var getLastBuildTime = function (modulePath) {
1105
- return getLastModifiedFile(modulePath + '/@(builds|lib|dist)/**/*.js');
1106
+ var getLastBuildTime = function (packagePath) {
1107
+ return getLastModifiedFile(packagePath + '/@(builds|lib|dist)/**/*.js');
1106
1108
  };
1107
- var getLastModifiedSourceTime = function (modulePath) {
1108
- return getLastModifiedFile(modulePath + '/@(src|data|scss)/**/*', {
1109
- ignore: [modulePath + '/**/*.scss.json', modulePath + '/**/*.d.ts']
1109
+ var getLastModifiedSourceTime = function (packagePath) {
1110
+ return getLastModifiedFile(packagePath + '/@(src|data|scss)/**/*', {
1111
+ ignore: [packagePath + '/**/*.scss.json', packagePath + '/**/*.d.ts']
1110
1112
  });
1111
1113
  };
1112
- var getLastCommitTime = function (modulePath) {
1113
- // console.log(`git log -1 --format=%ci -- ${modulePath}`);
1114
+ var getLastCommitTime = function (packagePath) {
1115
+ // console.log(`git log -1 --format=%ci -- ${packagePath}`);
1114
1116
  // process.exit();
1115
- return execPromise("git log -1 --format=%ci -- ".concat(modulePath))
1117
+ return execPromise("git log -1 --format=%ci -- ".concat(packagePath))
1116
1118
  .then(function (result) {
1117
1119
  var lastCommit = new Date(result);
1118
- // console.log(modulePath,result,lastCommit);
1120
+ // console.log(packagePath,result,lastCommit);
1119
1121
  return lastCommit;
1120
1122
  })["catch"](function (_a) {
1121
1123
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
@@ -1156,8 +1158,8 @@ var publishUpdated = function (test) {
1156
1158
  console.log('Checking which packages need to be published by comparing last published date with last git commit');
1157
1159
  packages.forEach(function (pckg) {
1158
1160
  p = p.then(function (previousResult) {
1159
- progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.moduleName);
1160
- debugInfo('# Checking package ' + pckg.moduleName);
1161
+ progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.packageName);
1162
+ debugInfo('# Checking package ' + pckg.packageName);
1161
1163
  // log('# Requesting ' + 'yarn info '+pkg.packageName+' --json');
1162
1164
  // return execPromise('yarn info '+pkg.packageName+' --json').then((output:string) => {
1163
1165
  // console.log("Will be requesting npm view from this current working directory:\n"+process.cwd());
@@ -1168,7 +1170,7 @@ var publishUpdated = function (test) {
1168
1170
  if (pack.private) {
1169
1171
  shouldPublish = false;
1170
1172
  debugInfo(chalk.blue('--> is private, skipping'));
1171
- return previousResult + ' ' + chalk.gray(pckg.moduleName + ' is private\n');
1173
+ return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
1172
1174
  }
1173
1175
  return execPromise('yarn info ' + pckg.packageName + ' --json')
1174
1176
  .then(function (output) { return __awaiter(_this, void 0, void 0, function () {
@@ -1188,13 +1190,13 @@ var publishUpdated = function (test) {
1188
1190
  else {
1189
1191
  info = JSON.parse(output);
1190
1192
  }
1191
- // var stats = fs.statSync(path.join(moduleDirectory));
1192
- // var files = fs.readdirSync(path.join(moduleDirectory,'src'));
1193
+ // var stats = fs.statSync(path.join(packageDirectory));
1194
+ // var files = fs.readdirSync(path.join(packageDirectory,'src'));
1193
1195
  }
1194
1196
  catch (err) {
1195
- chalk.red(pckg.moduleName + ' failed: ' + err.message + '\n');
1197
+ chalk.red(pckg.packageName + ' failed: ' + err.message + '\n');
1196
1198
  console.warn('Returned JSON from npm: ' + output);
1197
- return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.moduleName + ' failed: ' + err.message + '\n')];
1199
+ return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.packageName + ' failed: ' + err.message + '\n')];
1198
1200
  }
1199
1201
  if (!info) return [3 /*break*/, 2];
1200
1202
  lastPublish = info.data.time[info.data.version];
@@ -1205,7 +1207,7 @@ var publishUpdated = function (test) {
1205
1207
  if (!lastCommit) {
1206
1208
  shouldPublish = false;
1207
1209
  debugInfo('Could not determine last git commit');
1208
- return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.moduleName + ' - could not determine last commit\n')];
1210
+ return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n')];
1209
1211
  }
1210
1212
  else {
1211
1213
  //NOTE: removed lastModified, because switching branches will say that the file was modified and cause everything to publish
@@ -1224,12 +1226,12 @@ var publishUpdated = function (test) {
1224
1226
  case 2:
1225
1227
  if (shouldPublish) {
1226
1228
  res = publishPackage(pckg, previousResult, test, info, version);
1227
- if (pckg.moduleName == 'browser-core') {
1229
+ if (pckg.packageName == 'browser-core') {
1228
1230
  browserCoreBuilt = true;
1229
1231
  }
1230
1232
  //when publishing core, also make sure to publish browser-core
1231
- if (pckg.moduleName == 'core' && !browserCoreBuilt) {
1232
- browserModule = packages.find(function (m) { return m.moduleName == 'browser-core'; });
1233
+ if (pckg.packageName == 'core' && !browserCoreBuilt) {
1234
+ browserModule = packages.find(function (m) { return m.packageName == 'browser-core'; });
1233
1235
  return [2 /*return*/, Promise.resolve(res).then(function (previousResult) {
1234
1236
  log('# Automatically also publishing package browser-core');
1235
1237
  return publishPackage(browserModule, previousResult, test);
@@ -1243,7 +1245,7 @@ var publishUpdated = function (test) {
1243
1245
  }); })["catch"](function (_a) {
1244
1246
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
1245
1247
  console.log(error.message);
1246
- return previousResult + ' ' + chalk.red(pckg.moduleName + ' failed\n');
1248
+ return previousResult + ' ' + chalk.red(pckg.packageName + ' failed\n');
1247
1249
  });
1248
1250
  });
1249
1251
  });
@@ -1261,10 +1263,10 @@ var publishPackage = function (pkg, previousResult, test, info, publishVersion)
1261
1263
  publishVersion = info ? getNextVersion(info.data.version) : '';
1262
1264
  }
1263
1265
  if (test) {
1264
- debugInfo('should publish ' + pkg.moduleName + ' ' + publishVersion);
1266
+ debugInfo('should publish ' + pkg.packageName + ' ' + publishVersion);
1265
1267
  }
1266
1268
  else {
1267
- console.log(chalk.blue('publishing ' + pkg.moduleName + ' ' + publishVersion));
1269
+ console.log(chalk.blue('publishing ' + pkg.packageName + ' ' + publishVersion));
1268
1270
  }
1269
1271
  if (!test) {
1270
1272
  return execPromise("cd ".concat(pkg.path, " && yarn publish").concat(publishVersion ? ' --new-version ' + publishVersion : ''), true, false, {}, true)
@@ -1273,19 +1275,19 @@ var publishPackage = function (pkg, previousResult, test, info, publishVersion)
1273
1275
  res.indexOf('Could not publish') !== -1 ||
1274
1276
  res.indexOf("Couldn't publish") !== -1) {
1275
1277
  console.log(res);
1276
- return previousResult + ' ' + chalk.red(pkg.moduleName + ' failed\n');
1278
+ return previousResult + ' ' + chalk.red(pkg.packageName + ' failed\n');
1277
1279
  }
1278
1280
  console.log(chalk.green('Successfully published ' + pkg.path + ' ' + publishVersion));
1279
- return previousResult + ' ' + chalk.green(pkg.moduleName + ' published ' + publishVersion + '\n');
1281
+ return previousResult + ' ' + chalk.green(pkg.packageName + ' published ' + publishVersion + '\n');
1280
1282
  })["catch"](function (_a) {
1281
1283
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
1282
1284
  console.log(chalk.red('Failed to publish: ' + error.message));
1283
- return previousResult + ' ' + chalk.red(pkg.moduleName + ' failed to publish\n');
1285
+ return previousResult + ' ' + chalk.red(pkg.packageName + ' failed to publish\n');
1284
1286
  });
1285
1287
  }
1286
1288
  else {
1287
1289
  //when testing what needs to be published
1288
- return previousResult + ' ' + chalk.blue(pkg.moduleName + ' should publish\n');
1290
+ return previousResult + ' ' + chalk.blue(pkg.packageName + ' should publish\n');
1289
1291
  }
1290
1292
  };
1291
1293
  var buildUpdated = function (back, target, target2, test) {
@@ -1298,7 +1300,7 @@ var buildUpdated = function (back, target, target2, test) {
1298
1300
  case 0:
1299
1301
  previousResult = '';
1300
1302
  log(test ? 'Checking which packages need to be rebuild' : 'Building updated packages');
1301
- packages = getLocalLincdModuleMap();
1303
+ packages = getLocalLincdPackageMap();
1302
1304
  jsonldPkgUpdated = needsRebuilding(packages.get('lincd-jsonld'));
1303
1305
  cliPkgUpdated = needsRebuilding(packages.get('lincd-cli'));
1304
1306
  if (!(jsonldPkgUpdated || cliPkgUpdated)) return [3 /*break*/, 2];
@@ -1310,46 +1312,46 @@ var buildUpdated = function (back, target, target2, test) {
1310
1312
  rebuildAllModules = false;
1311
1313
  if (cliPkgUpdated) {
1312
1314
  rebuildAllModules = true;
1313
- log(chalk.magenta('Rebuilding all modules because the build tools (lincd-cli) got updated'));
1315
+ log(chalk.magenta('Rebuilding all packages because the build tools (lincd-cli) got updated'));
1314
1316
  }
1315
1317
  packagesLeft = packages.size;
1316
1318
  runOnPackagesGroupedByDependencies(packages, function (packageGroup, dependencies) {
1317
- // console.log('Now checking: ' + chalk.blue(packageGroup.map((i) => i.moduleName)));
1319
+ // console.log('Now checking: ' + chalk.blue(packageGroup.map((i) => i.packageName)));
1318
1320
  // console.log((packagesLeft) + " packages left.");
1319
1321
  packagesLeft = packagesLeft - packageGroup.length;
1320
1322
  return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
1321
1323
  var needRebuild;
1322
1324
  return __generator(this, function (_a) {
1323
- debugInfo('# Checking package ' + pkg.moduleName);
1325
+ debugInfo('# Checking package ' + pkg.packageName);
1324
1326
  needRebuild = needsRebuilding(pkg, true);
1325
- if (pkg.moduleName === 'lincd-jsonld' && jsonldPkgUpdated) {
1327
+ if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated) {
1326
1328
  needRebuild = true;
1327
1329
  }
1328
1330
  // console.log(pkg.path,lastModifiedSource.lastModifiedTime,lastModifiedBundle.lastModifiedTime);
1329
1331
  // console.log(pkg.path,new Date(lastModifiedSource.lastModified).toString(),new Date(lastModifiedBundle.lastModified).toString());
1330
1332
  if (needRebuild || rebuildAllModules) {
1331
1333
  //TODO: when building a pkg, also rebuild all packages that depend on this package.. and iteratively build packages that depend on those packages..
1332
- // log(moduleName+' modified since last commit on '+now.toString());
1334
+ // log(packageName+' modified since last commit on '+now.toString());
1333
1335
  if (test) {
1334
- debugInfo('Need to build ' + pkg.moduleName);
1335
- return [2 /*return*/, chalk.blue(pkg.moduleName + ' should be build')];
1336
+ debugInfo('Need to build ' + pkg.packageName);
1337
+ return [2 /*return*/, chalk.blue(pkg.packageName + ' should be build')];
1336
1338
  }
1337
- log('Building ' + pkg.moduleName);
1339
+ log('Building ' + pkg.packageName);
1338
1340
  return [2 /*return*/, execPromise('cd ' + pkg.path + ' && yarn build' + (target ? ' ' + target : '') + (target2 ? ' ' + target2 : ''))
1339
1341
  .then(function (res) {
1340
- debugInfo(chalk.green(pkg.moduleName + ' successfully built'));
1341
- return chalk.green(pkg.moduleName + ' built');
1342
+ debugInfo(chalk.green(pkg.packageName + ' successfully built'));
1343
+ return chalk.green(pkg.packageName + ' built');
1342
1344
  })["catch"](function (_a) {
1343
1345
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
1344
- warn('Failed to build ' + pkg.moduleName);
1346
+ warn('Failed to build ' + pkg.packageName);
1345
1347
  console.log(stdout);
1346
1348
  var dependentModules = getDependentPackages(dependencies, pkg);
1347
1349
  if (dependentModules.length > 0) {
1348
1350
  // printBuildResults(failedModules, done);
1349
- warn(chalk.red(pkg.moduleName + ' build failed'));
1351
+ warn(chalk.red(pkg.packageName + ' build failed'));
1350
1352
  warn('Stopping build-updated process because ' +
1351
1353
  dependentModules.length +
1352
- ' other packages depend on this module.\n'); //"+dependentModules.map(d => d.moduleName).join(", ")));
1354
+ ' other packages depend on this package.\n'); //"+dependentModules.map(d => d.packageName).join(", ")));
1353
1355
  process.exit(1);
1354
1356
  }
1355
1357
  })];
@@ -1389,18 +1391,18 @@ var needsRebuilding = function (pkg, logDetailsIfTrue) {
1389
1391
  return result;
1390
1392
  };
1391
1393
  var printBuildResults = function (failed, done) {
1392
- log('Successfully built: ' + chalk.green(__spreadArray([], __read(done), false).map(function (m) { return m.moduleName; }).join(', ')) + '\n');
1394
+ log('Successfully built: ' + chalk.green(__spreadArray([], __read(done), false).map(function (m) { return m.packageName; }).join(', ')) + '\n');
1393
1395
  if (failed.length > 0) {
1394
1396
  warn('Failed to build: ' + chalk.red(failed.join(', ')) + '\n');
1395
1397
  }
1396
1398
  };
1397
- var executeCommandForEachModule = function (packages, command, filterMethod, filterValue) {
1399
+ var executeCommandForEachPackage = function (packages, command, filterMethod, filterValue) {
1398
1400
  //if a specific set of packages is given
1399
1401
  if (filterMethod == 'exclude') {
1400
1402
  //filter packages, so that we only execute on the packages as provided in the command
1401
1403
  log('Excluding ' + filterValue);
1402
1404
  filterValue = filterValue.split(',');
1403
- packages = packages.filter(function (pkg) { return filterValue.indexOf(pkg.moduleName) === -1; });
1405
+ packages = packages.filter(function (pkg) { return filterValue.indexOf(pkg.packageName) === -1; });
1404
1406
  }
1405
1407
  var startFrom;
1406
1408
  //by default start executing, unless 'from' is given
@@ -1413,7 +1415,7 @@ var executeCommandForEachModule = function (packages, command, filterMethod, fil
1413
1415
  }
1414
1416
  var seen_1 = false;
1415
1417
  packages = packages.filter(function (pkg) {
1416
- if (!seen_1 && (pkg.moduleName == startFrom || pkg.packageName == startFrom)) {
1418
+ if (!seen_1 && (pkg.packageName == startFrom || pkg.packageName == startFrom)) {
1417
1419
  seen_1 = true;
1418
1420
  }
1419
1421
  return seen_1;
@@ -1422,26 +1424,26 @@ var executeCommandForEachModule = function (packages, command, filterMethod, fil
1422
1424
  log("Executing '" +
1423
1425
  chalk.blueBright(command) +
1424
1426
  "' on packages " +
1425
- chalk.magenta(packages.map(function (m) { return m.moduleName; }).join(', ')));
1427
+ chalk.magenta(packages.map(function (m) { return m.packageName; }).join(', ')));
1426
1428
  var p = Promise.resolve(true);
1427
1429
  packages.forEach(function (pkg) {
1428
1430
  p = p.then(function () {
1429
- log('# Package ' + chalk.magenta(pkg.moduleName));
1431
+ log('# Package ' + chalk.magenta(pkg.packageName));
1430
1432
  return execp('cd ' + pkg.path + ' && ' + command);
1431
1433
  });
1432
1434
  });
1433
1435
  return p;
1434
1436
  };
1435
- var executeCommandForModule = function (moduleName, command) {
1436
- var moduleDetails = getLincdModules().find(function (modDetails) {
1437
- return modDetails.packageName.indexOf(moduleName) !== -1 || modDetails.moduleName.indexOf(moduleName) !== -1;
1437
+ var executeCommandForPackage = function (packageName, command) {
1438
+ var packageDetails = getLincdPackages().find(function (modDetails) {
1439
+ return modDetails.packageName.indexOf(packageName) !== -1 || modDetails.packageName.indexOf(packageName) !== -1;
1438
1440
  });
1439
- if (moduleDetails) {
1440
- log("Executing 'cd " + moduleDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + "'");
1441
- return execp('cd ' + moduleDetails.path + ' && yarn lincd' + (command ? ' ' + command : ''));
1441
+ if (packageDetails) {
1442
+ log("Executing 'cd " + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + "'");
1443
+ return execp('cd ' + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : ''));
1442
1444
  }
1443
1445
  else {
1444
- warn("Could not find a pkg who's name (partially) matched " + chalk.cyan(moduleName));
1446
+ warn("Could not find a pkg who's name (partially) matched " + chalk.cyan(packageName));
1445
1447
  }
1446
1448
  };
1447
1449
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.1.24",
3
+ "version": "0.2.1",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -54,7 +54,7 @@
54
54
  "grunt-ts": "^6.0.0-beta.22",
55
55
  "grunt-webpack": "^5.0.0",
56
56
  "license-info-webpack-plugin": "^3.0.0",
57
- "lincd": "^0.3.6",
57
+ "lincd": "^0.4",
58
58
  "lincd-jsonld": "^0.1.8",
59
59
  "load-grunt-tasks": "^5.1.0",
60
60
  "mini-css-extract-plugin": "^2.6.1",