lincd-cli 0.1.1 → 0.1.2

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/README.md CHANGED
@@ -1,13 +1,23 @@
1
- # Setup a new dacore module
1
+ #LINCD CLI
2
+ Command Line Interface for the [lincd.js](https://www.lincd.org) library
2
3
 
3
- `npm install lincd-cli`
4
+ ### Installation
5
+
6
+ ```
7
+ npm install lincd-cli
8
+ ```
4
9
 
5
10
  or
6
11
 
7
- `yarn add lincd-cli`
12
+ ```
13
+ yarn add lincd-cli
14
+ ```
8
15
 
9
- Then type
16
+ ### Usage
17
+ type
10
18
 
11
- `npm exec lincd help`
19
+ ```
20
+ npm exec lincd help
21
+ ```
12
22
 
13
23
  for available commands
package/cli.js CHANGED
@@ -39,6 +39,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
39
39
  exports.__esModule = true;
40
40
  var lib_1 = require("lincd/lib");
41
41
  var JSONLDWriter_1 = require("lincd-jsonld/lib/JSONLDWriter");
42
+ var utils_1 = require("./utils");
42
43
  var program = require('commander');
43
44
  var exec = require('child_process').exec;
44
45
  var chalk = require('chalk');
@@ -105,7 +106,7 @@ function getLincdModules(rootPath) {
105
106
  //TODO: read from package.json what the workspaces are. for each, follow up all the folders inside that path
106
107
  //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
107
108
  //TODO: this way it will work with websites as well, instead of just from the main LINCD repository
108
- var pack = getPackageJSON();
109
+ var pack = utils_1.getPackageJSON();
109
110
  var res = [];
110
111
  if (!pack.workspaces) {
111
112
  warn(chalk.red('Could not find package workspaces. Make sure you run this command from a yarn workspace.'));
@@ -501,29 +502,37 @@ program.command('shapes').action(function () { return __awaiter(void 0, void 0,
501
502
  program.command('publish [version]').action(function (newVersion) {
502
503
  if (fs.existsSync(process.cwd() + '/package.json')) {
503
504
  var pack = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
504
- var version_1 = pack.version;
505
- var moduleName_1 = pack.name;
506
- if (newVersion == 'same') {
507
- newVersion = version_1;
508
- }
509
- else if (newVersion == 'minor') {
510
- newVersion = getNextMinorVersion(version_1);
511
- console.log(chalk.cyan('Increasing version number for minor release: ' + newVersion));
512
- }
513
- else if (newVersion == 'major') {
514
- newVersion = getNextMajorVersion(version_1);
515
- console.log(chalk.cyan('Increasing version number for major release: ' + newVersion));
516
- }
517
- else if (!newVersion || newVersion == 'patch') {
518
- newVersion = getNextVersion(version_1);
519
- console.log(chalk.cyan('Increasing version number for patch release: ' + newVersion));
520
- }
521
- else {
522
- newVersion = version_1;
505
+ var version = pack.version;
506
+ var moduleName = pack.name;
507
+ /*if (newVersion == 'same') {
508
+ newVersion = version;
509
+ } else if (newVersion == 'minor') {
510
+ newVersion = getNextMinorVersion(version);
511
+ console.log(
512
+ chalk.cyan(
513
+ 'Increasing version number for minor release: ' + newVersion,
514
+ ),
515
+ );
516
+ } else if (newVersion == 'major') {
517
+ newVersion = getNextMajorVersion(version);
518
+ console.log(
519
+ chalk.cyan(
520
+ 'Increasing version number for major release: ' + newVersion,
521
+ ),
522
+ );
523
+ } else if (!newVersion || newVersion == 'patch') {
524
+ newVersion = getNextVersion(version);
525
+ console.log(
526
+ chalk.cyan(
527
+ 'Increasing version number for patch release: ' + newVersion,
528
+ ),
529
+ );
530
+ } else {
531
+ newVersion = version;
523
532
  console.log(chalk.cyan('using given version as is: ' + newVersion));
524
- }
533
+ }*/
525
534
  // message = "%s " + message;
526
- console.log(chalk.cyan('preparing to publish ' + moduleName_1 + ' ' + newVersion));
535
+ console.log(chalk.cyan('publishing ' + moduleName + ' ' + version + ' to LINCD registry'));
527
536
  //temporary test code
528
537
  return fetch('http://localhost:3000/publish', {
529
538
  method: 'POST',
@@ -531,70 +540,71 @@ program.command('publish [version]').action(function (newVersion) {
531
540
  Accept: 'application/json, text/plain, */*',
532
541
  'Content-Type': 'application/json'
533
542
  },
534
- body: JSON.stringify({ package: moduleName_1 })
543
+ body: JSON.stringify({ package: moduleName })
535
544
  })
536
545
  .then(function (res) { return res.text(); })
537
546
  .then(function (text) {
538
547
  console.log(text);
539
- });
540
- console.log(chalk.cyan('building production bundles'));
541
- return execPromise('yarn lincd build production', false, true)
542
- .then(function (output) {
543
- if (buildFailed(output)) {
544
- // console.warn("Build failed:");
545
- console.log(output);
546
- throw new Error('build failed');
547
- }
548
- pack.version = newVersion;
549
- //save package.json
550
- return fs.writeFileSync(path.join(process.cwd(), 'package.json'), JSON.stringify(pack, null, 2));
551
- })
552
- .then(function (version) {
553
- console.log(chalk.cyan('Committing to git'));
554
- //we have just changed package.json, so there will be things "uncommitted"
555
- //to make sure this module does not automatically come up as "needing to be published" we need to commit this change here straight away
556
- //so: add all files not added yet in the folder of this module
557
- //then commit all changes (including new version number in package.json)
558
- //then add a version commit git flag
559
- return execPromise("git add -- ./ & git commit -m \"publishing ".concat(moduleName_1, " ").concat(newVersion, "\" -- ./ & git tag ").concat(moduleName_1, "@").concat(newVersion, "\""));
560
- })
561
- .then(function (version) {
562
- console.log(chalk.cyan('Publishing ' + moduleName_1 + ' ' + newVersion));
563
- // let tag = moduleName+'@'+version;
564
- return execPromise('yarn publish --new-version ' + newVersion, true);
565
- })
566
- .then(function (res) {
567
- if (res.indexOf('Aborted due to warnings') !== -1 ||
568
- res.indexOf('Could not publish') !== -1 ||
569
- res.indexOf("Couldn't publish") !== -1) {
570
- console.log(chalk.red('Failed to publish'));
571
- return false;
572
- }
573
- else {
574
- var pack = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
575
- version_1 = pack.version;
576
- console.log(chalk.green('Published ' + version_1));
577
- return true;
578
- }
579
548
  })["catch"](function (err) {
580
- console.warn(chalk.red('Could not publish: ' + err));
549
+ console.warn("Could not connect to LINCD registry");
581
550
  });
551
+ /*console.log(chalk.cyan('building production bundles'));
552
+ return execPromise('yarn lincd build production', false, true)
553
+ .then((output: string) => {
554
+ if (buildFailed(output)) {
555
+ // console.warn("Build failed:");
556
+ console.log(output);
557
+ throw new Error('build failed');
558
+ }
559
+ pack.version = newVersion;
560
+ //save package.json
561
+ return fs.writeFileSync(
562
+ path.join(process.cwd(), 'package.json'),
563
+ JSON.stringify(pack, null, 2),
564
+ );
565
+ })
566
+ .then((version) => {
567
+ console.log(chalk.cyan('Committing to git'));
568
+ //we have just changed package.json, so there will be things "uncommitted"
569
+ //to make sure this module does not automatically come up as "needing to be published" we need to commit this change here straight away
570
+ //so: add all files not added yet in the folder of this module
571
+ //then commit all changes (including new version number in package.json)
572
+ //then add a version commit git flag
573
+ return execPromise(
574
+ `git add -- ./ & git commit -m "publishing ${moduleName} ${newVersion}" -- ./ & git tag ${moduleName}@${newVersion}"`,
575
+ );
576
+ })
577
+ .then((version) => {
578
+ console.log(chalk.cyan('Publishing ' + moduleName + ' ' + newVersion));
579
+
580
+ // let tag = moduleName+'@'+version;
581
+ return execPromise('yarn publish --new-version ' + newVersion, true);
582
+ })
583
+ .then((res) => {
584
+ if (
585
+ res.indexOf('Aborted due to warnings') !== -1 ||
586
+ res.indexOf('Could not publish') !== -1 ||
587
+ res.indexOf("Couldn't publish") !== -1
588
+ ) {
589
+ console.log(chalk.red('Failed to publish'));
590
+ return false;
591
+ } else {
592
+ var pack = JSON.parse(
593
+ fs.readFileSync(process.cwd() + '/package.json', 'utf8'),
594
+ );
595
+ version = pack.version;
596
+ console.log(chalk.green('Published ' + version));
597
+ return true;
598
+ }
599
+ })
600
+ .catch((err) => {
601
+ console.warn(chalk.red('Could not publish: ' + err));
602
+ });*/
582
603
  }
583
604
  else {
584
605
  console.warn('not found: ' + process.cwd() + '/package.json');
585
606
  }
586
607
  });
587
- var getPackageJSON = function (root) {
588
- if (root === void 0) { root = process.cwd(); }
589
- var packagePath = path.join(root, 'package.json');
590
- if (fs.existsSync(packagePath)) {
591
- return JSON.parse(fs.readFileSync(packagePath, 'utf8'));
592
- }
593
- else if (root === process.cwd()) {
594
- console.warn('Could not find package.json. Make sure you run this command from the root of a lincd module or a lincd yarn workspace');
595
- process.exit();
596
- }
597
- };
598
608
  // program.command('create [action] [value]').action((action, prefixedUri) => {
599
609
  //
600
610
  // let [ontology,label] = typeof prefixedUri !== 'undefined' ? prefixedUri.split(":") : [];
@@ -651,7 +661,7 @@ var buildModule = function (target, target2, modulePath, logResults) {
651
661
  target == 'es6' ||
652
662
  !target) {
653
663
  if (!fs.existsSync(path.join(modulePath, 'Gruntfile.js'))) {
654
- console.warn("No Gruntfile found at ".concat(modulePath, "\\Gruntfile.js. Cannot build."));
664
+ console.warn("No Gruntfile found at " + modulePath + "\\Gruntfile.js. Cannot build.");
655
665
  return;
656
666
  }
657
667
  var nodeEnv = '';
@@ -705,7 +715,7 @@ var getLastModifiedSourceTime = function (modulePath) {
705
715
  var getLastCommitTime = function (modulePath) {
706
716
  // console.log(`git log -1 --format=%ci -- ${modulePath}`);
707
717
  // process.exit();
708
- return execPromise("git log -1 --format=%ci -- ".concat(modulePath)).then(function (result) {
718
+ return execPromise("git log -1 --format=%ci -- " + modulePath).then(function (result) {
709
719
  var lastCommit = new Date(result);
710
720
  // console.log(modulePath,result,lastCommit);
711
721
  return lastCommit;
@@ -880,7 +890,7 @@ program
880
890
  var buildUpdated = function (back, target, target2, test) {
881
891
  if (test === void 0) { test = false; }
882
892
  back = back || 1;
883
- return execPromise("git log -".concat(back, " --format=%ci")).then(function (result) {
893
+ return execPromise("git log -" + back + " --format=%ci").then(function (result) {
884
894
  var lastCommit = new Date(result);
885
895
  var previousResult = '';
886
896
  log((test ? 'Checking which modules' : 'Building all modules that') +
@@ -948,7 +958,7 @@ program.command('build-all [target] [target2]').action(function (target, target2
948
958
  //get dependencies of each module
949
959
  var leastDependentModule;
950
960
  modules.forEach(function (module) {
951
- var pack = getPackageJSON(module.path);
961
+ var pack = utils_1.getPackageJSON(module.path);
952
962
  if (pack) {
953
963
  //get lincd related dependencies and get the actual module details from the module map by removing '@dacore/' from the package name
954
964
  var moduleDependencies = Object.keys(pack.dependencies)
@@ -1,12 +1,8 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
+ to[j] = from[i];
5
+ return to;
10
6
  };
11
7
  exports.__esModule = true;
12
8
  exports.generateWebpackConfig = exports.setupGrunt = void 0;
@@ -14,12 +10,14 @@ var declaration_plugin_1 = require("./plugins/declaration-plugin");
14
10
  var externalise_modules_1 = require("./plugins/externalise-modules");
15
11
  var watch_run_1 = require("./plugins/watch-run");
16
12
  var colors = require("colors");
13
+ var utils_1 = require("./utils");
17
14
  var fs = require('fs');
18
15
  var MiniCssExtractPlugin = require('mini-css-extract-plugin');
19
16
  var chalk = require('chalk');
20
17
  var webpack = require('webpack');
21
18
  var path = require('path');
22
19
  var ExtractTextPlugin = require('extract-text-webpack-plugin');
20
+ var WebpackLicencePlugin = require('webpack-license-plugin');
23
21
  var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
24
22
  var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
25
23
  var TerserPlugin = require('terser-webpack-plugin');
@@ -132,7 +130,7 @@ function setupGrunt(grunt, moduleName, config) {
132
130
  if (buildFrontend) {
133
131
  grunt.registerTask('build-frontend', __spreadArray([
134
132
  'prepare-build'
135
- ], targets.map(function (target) { return 'webpack:build-' + target; }), true));
133
+ ], targets.map(function (target) { return 'webpack:build-' + target; })));
136
134
  }
137
135
  grunt.registerTask('build-production', flatten([
138
136
  'clean:lib',
@@ -309,7 +307,7 @@ function setupGrunt(grunt, moduleName, config) {
309
307
  grunt.task.loadTasks(nestedWorkspacePath);
310
308
  }
311
309
  else {
312
- warn("Could not load grunt task module ".concat(taskName, "\nCould not find task at any of these paths:\n").concat(localPath, "\n").concat(localPath2, "\n").concat(workspacePath, "\n").concat(nestedWorkspacePath));
310
+ warn("Could not load grunt task module " + taskName + "\nCould not find task at any of these paths:\n" + localPath + "\n" + localPath2 + "\n" + workspacePath + "\n" + nestedWorkspacePath);
313
311
  }
314
312
  });
315
313
  }
@@ -335,6 +333,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
335
333
  warn('Cannot find ' + configFile);
336
334
  process.exit();
337
335
  }
336
+ var pack = utils_1.getPackageJSON();
338
337
  var plugins = [
339
338
  new webpack.DefinePlugin({
340
339
  'process.env.BROWSER': JSON.stringify(true),
@@ -350,6 +349,14 @@ function generateWebpackConfig(buildName, moduleName, config) {
350
349
  ? config.cssFileName
351
350
  : libraryName + '.' + moduleName + '.css'
352
351
  }),
352
+ new WebpackLicencePlugin(
353
+ //output sometimes includes things like webpack, which seems not needed? this doesn't work though
354
+ // {
355
+ // excludedPackageTest:((packageName, packageVersion) => {
356
+ // return pack.devDependencies && packageName in pack.devDependencies;
357
+ // })
358
+ // }
359
+ ),
353
360
  ];
354
361
  if (config.debug) {
355
362
  plugins.push(new watch_run_1["default"]());
@@ -508,7 +515,14 @@ function generateWebpackConfig(buildName, moduleName, config) {
508
515
  },
509
516
  optimization: {
510
517
  minimize: productionMode,
511
- minimizer: [new TerserPlugin()]
518
+ minimizer: [new TerserPlugin({
519
+ extractComments: {
520
+ condition: /^\**!|@preserve|@license|@cc_on/i,
521
+ banner: function (licenseFile) {
522
+ return "License information can be found in " + licenseFile + " and oss-licences.json";
523
+ }
524
+ }
525
+ })]
512
526
  },
513
527
  watch: watch,
514
528
  module: {
@@ -516,7 +530,7 @@ function generateWebpackConfig(buildName, moduleName, config) {
516
530
  },
517
531
  //See plugins/externalise-modules.ts We're passing in a function here that determines what to exclude from the bundle and what not
518
532
  //See also https://webpack.js.org/configuration/externals/
519
- externals: (0, externalise_modules_1["default"])(config, es5),
533
+ externals: externalise_modules_1["default"](config, es5),
520
534
  plugins: plugins,
521
535
  stats: {
522
536
  errorDetails: config.debug,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "publish-build-tools": "tsc && npm version patch && npm publish",
7
+ "prepare": "tsc",
8
8
  "build": "tsc"
9
9
  },
10
10
  "keywords": [
@@ -38,8 +38,9 @@
38
38
  "grunt-exec": "^3.0.0",
39
39
  "grunt-ts": "^6.0.0-beta.17",
40
40
  "grunt-webpack": "^4.0.2",
41
+ "license-info-webpack-plugin": "^3.0.0",
41
42
  "lincd": "*",
42
- "lincd-cli": "*",
43
+ "lincd-jsonld": "*",
43
44
  "load-grunt-tasks": "^5.1.0",
44
45
  "mini-css-extract-plugin": "^1.3.3",
45
46
  "postcss": "^8.2.1",
@@ -59,7 +60,8 @@
59
60
  "tsconfig-paths-webpack-plugin": "^3.3.0",
60
61
  "typescript": "4.2.2",
61
62
  "webpack": "^4.0.0",
62
- "webpack-bundle-analyzer": "^3.0.0"
63
+ "webpack-bundle-analyzer": "^3.0.0",
64
+ "webpack-license-plugin": "^4.2.1"
63
65
  },
64
66
  "devDependencies": {
65
67
  "optimize-css-assets-webpack-plugin": "^5.0.4"
@@ -12,7 +12,7 @@ var WatchRunPlugin = /** @class */ (function () {
12
12
  compiler.hooks.watchRun.tap('WatchRun', function (comp) {
13
13
  var changedTimes = comp.watchFileSystem.watcher.mtimes;
14
14
  var changedFiles = Object.keys(changedTimes)
15
- .map(function (file) { return "\n ".concat(file); })
15
+ .map(function (file) { return "\n " + file; })
16
16
  .join('');
17
17
  if (changedFiles.length) {
18
18
  console.log('====================================');
package/utils.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.getPackageJSON = void 0;
4
+ var fs = require("fs");
5
+ var path = require("path");
6
+ var getPackageJSON = function (root) {
7
+ if (root === void 0) { root = process.cwd(); }
8
+ var packagePath = path.join(root, 'package.json');
9
+ if (fs.existsSync(packagePath)) {
10
+ return JSON.parse(fs.readFileSync(packagePath, 'utf8'));
11
+ }
12
+ else if (root === process.cwd()) {
13
+ console.warn('Could not find package.json. Make sure you run this command from the root of a lincd module or a lincd yarn workspace');
14
+ process.exit();
15
+ }
16
+ };
17
+ exports.getPackageJSON = getPackageJSON;