lincd-cli 0.2.6 → 0.2.8

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.
@@ -0,0 +1 @@
1
+ nodeLinker: "node-modules"
package/lib/cli.js CHANGED
@@ -116,7 +116,7 @@ program
116
116
  })
117
117
  .description('Creates a new ontology file for your package. Execute this from your package folder.')
118
118
  .argument('<suggested-prefix>', 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object')
119
- .argument('[uribase]', "Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this package");
119
+ .argument('[uribase]', 'Optional argument to set the URI base for the URI\'s of all entities in your ontology. Leave blank to use the URI\'s provided by lincd.org once you register this package');
120
120
  program.command('register-local', { hidden: true }).action(function () {
121
121
  register('http://localhost:4101');
122
122
  });
@@ -136,7 +136,7 @@ program
136
136
  console.log(ownPackage.version);
137
137
  console.log('Running from: ' + __dirname);
138
138
  })
139
- .description("Log the version of this tool and the path that it's running from");
139
+ .description('Log the version of this tool and the path that it\'s running from');
140
140
  program.command('build [target] [target2]', { isDefault: true }).action(function (target, target2) {
141
141
  buildPackage(target, target2);
142
142
  });
@@ -225,12 +225,11 @@ function debugInfo() {
225
225
  // console.log(gruntConfig);
226
226
  // process.exit();
227
227
  // }
228
- // if(gruntConfig.analyse === true)
229
- // {
230
- // messages.forEach((message) => {
231
- // console.log(chalk.cyan('Info: ') + message);
232
- // });
233
- // }
228
+ if (gruntConfig && gruntConfig.analyse === true) {
229
+ messages.forEach(function (message) {
230
+ console.log(chalk.cyan('Info: ') + message);
231
+ });
232
+ }
234
233
  }
235
234
  function warn() {
236
235
  var messages = [];
@@ -705,7 +704,7 @@ var createOntology = function (prefix, uriBase, basePath) {
705
704
  setVariable('uri_base', uriBase);
706
705
  _a = setNameVariables(prefix), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
707
706
  //copy ontology accessor file
708
- log("Creating files for ontology '" + prefix + "'");
707
+ log('Creating files for ontology \'' + prefix + '\'');
709
708
  targetFile = path.join(targetFolder, hyphenName + '.ts');
710
709
  fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
711
710
  targetDataFile = path.join(targetFolder, '..', 'data', hyphenName + '.json');
@@ -829,7 +828,7 @@ var createShape = function (name, basePath) {
829
828
  targetFolder = ensureFolderExists(basePath, 'src', 'shapes');
830
829
  _a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
831
830
  //copy default shape file
832
- log("Creating files for shape '" + name + "'");
831
+ log('Creating files for shape \'' + name + '\'');
833
832
  targetFile = path.join(targetFolder, hyphenName + '.ts');
834
833
  fs.copySync(path.join(__dirname, '..', 'defaults', 'shape.ts'), targetFile);
835
834
  //replace variables in some of the copied files
@@ -854,7 +853,7 @@ var createSetComponent = function (name, basePath) {
854
853
  targetFolder = ensureFolderExists(basePath, 'src', 'components');
855
854
  _a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
856
855
  //copy default shape file
857
- log("Creating files for set component '" + name + "'");
856
+ log('Creating files for set component \'' + name + '\'');
858
857
  targetFile = path.join(targetFolder, hyphenName + '.tsx');
859
858
  fs.copySync(path.join(__dirname, '..', 'defaults', 'set-component.tsx'), targetFile);
860
859
  targetFile2 = path.join(targetFolder, hyphenName + '.scss');
@@ -881,7 +880,7 @@ var createComponent = function (name, basePath) {
881
880
  targetFolder = ensureFolderExists(basePath, 'src', 'components');
882
881
  _a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
883
882
  //copy default shape file
884
- log("Creating files for component '" + name + "'");
883
+ log('Creating files for component \'' + name + '\'');
885
884
  targetFile = path.join(targetFolder, hyphenName + '.tsx');
886
885
  fs.copySync(path.join(__dirname, '..', 'defaults', 'component.tsx'), targetFile);
887
886
  targetFile2 = path.join(targetFolder, hyphenName + '.scss');
@@ -930,7 +929,7 @@ var createPackage = function (name, uriBase, basePath) {
930
929
  //extra variable for clarity (will be same as 'name')
931
930
  setVariable('output_file_name', name);
932
931
  _b = setNameVariables(cleanPackageName), hyphenName = _b.hyphenName, camelCaseName = _b.camelCaseName, underscoreName = _b.underscoreName;
933
- log("Creating new LINCD package '" + name + "'");
932
+ log('Creating new LINCD package \'' + name + '\'');
934
933
  fs.copySync(path.join(__dirname, '..', 'defaults', 'package'), targetFolder);
935
934
  //replace variables in some of the copied files
936
935
  return [4 /*yield*/, Promise.all([
@@ -983,7 +982,7 @@ var createPackage = function (name, uriBase, basePath) {
983
982
  var createApp = function (name, basePath) {
984
983
  if (basePath === void 0) { basePath = process.cwd(); }
985
984
  return __awaiter(void 0, void 0, void 0, function () {
986
- var _a, hyphenName, camelCaseName, underscoreName, targetFolder, hasYarn, installCommand, runCommand;
985
+ var _a, hyphenName, camelCaseName, underscoreName, targetFolder, hasYarn, installCommand;
987
986
  return __generator(this, function (_b) {
988
987
  switch (_b.label) {
989
988
  case 0:
@@ -996,15 +995,15 @@ var createApp = function (name, basePath) {
996
995
  fs.mkdirSync(targetFolder);
997
996
  }
998
997
  fs.copySync(path.join(__dirname, '..', 'defaults', 'app-with-backend'), targetFolder);
998
+ fs.renameSync(path.join(targetFolder, '.yarnrc.yml.template'), path.join(targetFolder, '.yarnrc.yml'));
999
999
  // fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
1000
- log("Creating new LINCD application '" + name + "'");
1000
+ log('Creating new LINCD application \'' + name + '\'');
1001
1001
  //replace variables in some copied files
1002
1002
  replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/App.scss.json', 'frontend/src/components/Spinner.scss.json');
1003
1003
  return [4 /*yield*/, hasYarnInstalled()];
1004
1004
  case 1:
1005
1005
  hasYarn = _b.sent();
1006
1006
  installCommand = hasYarn ? 'yarn install' : 'npm install';
1007
- runCommand = hasYarn ? 'yarn' : 'npm run';
1008
1007
  return [4 /*yield*/, execp("cd ".concat(hyphenName, " && ").concat(installCommand), true)["catch"](function (err) {
1009
1008
  console.warn('Could not install dependencies or start application');
1010
1009
  })];
@@ -1127,7 +1126,7 @@ var buildPackage = function (target, target2, packagePath, logResults) {
1127
1126
  nodeEnv = 'SET NODE_ENV=production&& ';
1128
1127
  }
1129
1128
  else {
1130
- nodeEnv = "NODE_ENV='production' ";
1129
+ nodeEnv = 'NODE_ENV=\'production\' ';
1131
1130
  }
1132
1131
  }
1133
1132
  if (!target) {
@@ -1201,11 +1200,13 @@ var publishUpdated = function (test) {
1201
1200
  var browserCoreBuilt = false;
1202
1201
  var p = Promise.resolve('');
1203
1202
  var packagesLeft = packages.length;
1204
- console.log('Checking which packages need to be published by comparing last published date with last git commit');
1203
+ var results = [];
1204
+ log('Checking which packages need to be published by comparing last published date with last git commit');
1205
+ // p = Promise.all(packages.map((pckg) => {
1205
1206
  packages.forEach(function (pckg) {
1206
1207
  p = p.then(function (previousResult) {
1207
- progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.packageName);
1208
- debugInfo('# Checking package ' + pckg.packageName);
1208
+ // progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.packageName);
1209
+ // log('# Checking package ' + pckg.packageName);
1209
1210
  // log('# Requesting ' + 'yarn info '+pkg.packageName+' --json');
1210
1211
  // return execPromise('yarn info '+pkg.packageName+' --json').then((output:string) => {
1211
1212
  // console.log("Will be requesting npm view from this current working directory:\n"+process.cwd());
@@ -1216,36 +1217,32 @@ var publishUpdated = function (test) {
1216
1217
  if (pack.private) {
1217
1218
  shouldPublish = false;
1218
1219
  debugInfo(chalk.blue('--> is private, skipping'));
1219
- return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
1220
+ return chalk.gray(pckg.packageName + ' is private');
1221
+ // return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
1220
1222
  }
1221
- return execPromise('yarn info ' + pckg.packageName + ' --json')
1223
+ return execPromise('npm info ' + pckg.packageName + ' --json')
1222
1224
  .then(function (output) { return __awaiter(_this, void 0, void 0, function () {
1223
- var info, lastPublish, lastPublishDate, lastCommit, res, browserModule;
1225
+ var info, lastPublish, lastPublishDate, lastCommit, err_1, res, browserModule;
1224
1226
  return __generator(this, function (_a) {
1225
1227
  switch (_a.label) {
1226
1228
  case 0:
1227
- try {
1228
- if (output == '') {
1229
- debugInfo('No response (empty) from `yarn info`. This package was probably not published before');
1230
- // throw new Error('Empty response from `yarn info`. This pkg was probably not published before');
1231
- // return;
1232
- shouldPublish = true;
1233
- //don't patch the version number (default, see above), use the current version
1234
- version = pack.version;
1235
- }
1236
- else {
1237
- info = JSON.parse(output);
1238
- }
1239
- // var stats = fs.statSync(path.join(packageDirectory));
1240
- // var files = fs.readdirSync(path.join(packageDirectory,'src'));
1229
+ _a.trys.push([0, 3, , 4]);
1230
+ if (output == '' || output.includes('E404')) {
1231
+ debugInfo('Empty or 404 response from `npm info`. This package was probably not published before');
1232
+ // throw new Error('Empty response from `yarn info`. This pkg was probably not published before');
1233
+ // return;
1234
+ shouldPublish = true;
1235
+ //don't patch the version number (default, see above), use the current version
1236
+ version = pack.version;
1241
1237
  }
1242
- catch (err) {
1243
- chalk.red(pckg.packageName + ' failed: ' + err.message + '\n');
1244
- console.warn('Returned JSON from npm: ' + output);
1245
- return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.packageName + ' failed: ' + err.message + '\n')];
1238
+ else {
1239
+ info = JSON.parse(output);
1246
1240
  }
1247
1241
  if (!info) return [3 /*break*/, 2];
1248
- lastPublish = info.data.time[info.data.version];
1242
+ lastPublish = void 0;
1243
+ //yarn:
1244
+ // let lastPublish = info.data.time[info.data.version];
1245
+ lastPublish = info.time[info.version];
1249
1246
  lastPublishDate = new Date(lastPublish);
1250
1247
  return [4 /*yield*/, getLastCommitTime(pckg.path)];
1251
1248
  case 1:
@@ -1253,25 +1250,37 @@ var publishUpdated = function (test) {
1253
1250
  if (!lastCommit) {
1254
1251
  shouldPublish = false;
1255
1252
  debugInfo('Could not determine last git commit');
1256
- return [2 /*return*/, previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n')];
1253
+ // return previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n');
1254
+ return [2 /*return*/, chalk.red(pckg.packageName + ' - could not determine last commit')];
1257
1255
  }
1258
1256
  else {
1259
1257
  //NOTE: removed lastModified, because switching branches will say that the file was modified and cause everything to publish
1260
1258
  //SO: now you NEED TO commit before it picks up that you should publish
1261
1259
  shouldPublish = lastPublishDate.getTime() < lastCommit.getTime();
1262
- if (shouldPublish) {
1263
- debugInfo(lastPublishDate.toDateString() +
1264
- ' ' +
1265
- lastPublishDate.toTimeString() +
1266
- ' published ' +
1267
- info.data.version);
1268
- debugInfo(lastCommit.toDateString() + ' ' + new Date(lastCommit).toTimeString() + ' source last committed');
1269
- }
1260
+ // if (shouldPublish) {
1261
+ // log(
1262
+ // lastPublishDate.toDateString() +
1263
+ // ' ' +
1264
+ // lastPublishDate.toTimeString() +
1265
+ // ' published ' +
1266
+ // info.version,
1267
+ // );
1268
+ // log(
1269
+ // lastCommit.toDateString() + ' ' + new Date(lastCommit).toTimeString() + ' source last committed',
1270
+ // );
1271
+ // }
1270
1272
  }
1271
1273
  _a.label = 2;
1272
- case 2:
1274
+ case 2: return [3 /*break*/, 4];
1275
+ case 3:
1276
+ err_1 = _a.sent();
1277
+ console.log(chalk.red(pckg.packageName + ' failed: ' + err_1.message + '\n'));
1278
+ console.warn('Returned JSON from npm: ' + output);
1279
+ // return previousResult + ' ' + chalk.red(pckg.packageName + ' failed: ' + err.message + '\n');
1280
+ return [2 /*return*/, chalk.red(pckg.packageName + ' failed: ' + err_1.message)];
1281
+ case 4:
1273
1282
  if (shouldPublish) {
1274
- res = publishPackage(pckg, previousResult, test, info, version);
1283
+ res = publishPackage(pckg, test, info, version);
1275
1284
  if (pckg.packageName == 'browser-core') {
1276
1285
  browserCoreBuilt = true;
1277
1286
  }
@@ -1280,33 +1289,53 @@ var publishUpdated = function (test) {
1280
1289
  browserModule = packages.find(function (m) { return m.packageName == 'browser-core'; });
1281
1290
  return [2 /*return*/, Promise.resolve(res).then(function (previousResult) {
1282
1291
  log('# Automatically also publishing package browser-core');
1283
- return publishPackage(browserModule, previousResult, test);
1292
+ return publishPackage(browserModule, test);
1284
1293
  })];
1285
1294
  }
1286
1295
  return [2 /*return*/, res];
1287
1296
  }
1288
- return [2 /*return*/, previousResult];
1297
+ // return previousResult + ' ' + chalk.green(pckg.packageName + ' latest version is up to date\n');
1298
+ return [2 /*return*/, chalk.green(pckg.packageName + ' latest version is up to date')];
1289
1299
  }
1290
1300
  });
1291
1301
  }); })["catch"](function (_a) {
1292
1302
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
1293
- console.log(error.message);
1294
- return previousResult + ' ' + chalk.red(pckg.packageName + ' failed\n');
1303
+ if (error) {
1304
+ console.log(error.message);
1305
+ }
1306
+ if (stdout) {
1307
+ console.log(stderr);
1308
+ }
1309
+ if (stderr) {
1310
+ console.log(stderr);
1311
+ }
1312
+ // return previousResult + ' ' + chalk.red(pckg.packageName + ' failed\n');
1313
+ console.warn(chalk.red(pckg.packageName + ' failed'));
1314
+ return chalk.red(pckg.packageName + ' failed');
1295
1315
  });
1316
+ }).then(function (res) {
1317
+ log(res);
1318
+ results.push(res);
1319
+ })["catch"](function (err) {
1320
+ console.warn(chalk.red(pckg.packageName + ' failed: ' + err.toString()));
1321
+ results.push(chalk.red(pckg.packageName + ' failed: ' + err.toString()));
1296
1322
  });
1297
1323
  });
1298
- return p.then(function (messages) {
1299
- if (messages == '') {
1300
- console.log('All published packages are already up-to-date.');
1301
- }
1302
- else {
1303
- console.log('Summary: \n' + messages);
1304
- }
1324
+ return p.then(function () {
1325
+ // if (messages == '')
1326
+ // {
1327
+ // console.log('All published packages are already up-to-date.');
1328
+ // }
1329
+ // else
1330
+ // {
1331
+ console.log('Summary: \n' + results.join('\n'));
1332
+ // }
1305
1333
  });
1306
1334
  };
1307
- var publishPackage = function (pkg, previousResult, test, info, publishVersion) {
1335
+ var publishPackage = function (pkg, test, info, publishVersion) {
1308
1336
  if (!publishVersion) {
1309
- publishVersion = info ? getNextVersion(info.data.version) : '';
1337
+ // publishVersion = info ? getNextVersion(info.data.version) : '';
1338
+ publishVersion = info ? getNextVersion(info.version) : '';
1310
1339
  }
1311
1340
  if (test) {
1312
1341
  debugInfo('should publish ' + pkg.packageName + ' ' + publishVersion);
@@ -1315,25 +1344,25 @@ var publishPackage = function (pkg, previousResult, test, info, publishVersion)
1315
1344
  console.log(chalk.blue('publishing ' + pkg.packageName + ' ' + publishVersion));
1316
1345
  }
1317
1346
  if (!test) {
1318
- return execPromise("cd ".concat(pkg.path, " && yarn publish").concat(publishVersion ? ' --new-version ' + publishVersion : ''), true, false, {}, true)
1347
+ return execPromise("cd ".concat(pkg.path, " && yarn version ").concat(publishVersion, " && yarn npm publish"), true, false, {}, true)
1319
1348
  .then(function (res) {
1320
1349
  if (res.indexOf('Aborted due to warnings') !== -1 ||
1321
1350
  res.indexOf('Could not publish') !== -1 ||
1322
- res.indexOf("Couldn't publish") !== -1) {
1351
+ res.indexOf('Couldn\'t publish') !== -1) {
1323
1352
  console.log(res);
1324
- return previousResult + ' ' + chalk.red(pkg.packageName + ' failed\n');
1353
+ return chalk.red(pkg.packageName + ' failed\n');
1325
1354
  }
1326
1355
  console.log(chalk.green('Successfully published ' + pkg.path + ' ' + publishVersion));
1327
- return previousResult + ' ' + chalk.green(pkg.packageName + ' published ' + publishVersion + '\n');
1356
+ return chalk.green(pkg.packageName + ' published ' + publishVersion + '\n');
1328
1357
  })["catch"](function (_a) {
1329
1358
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
1330
1359
  console.log(chalk.red('Failed to publish: ' + error.message));
1331
- return previousResult + ' ' + chalk.red(pkg.packageName + ' failed to publish\n');
1360
+ return chalk.red(pkg.packageName + ' failed to publish\n');
1332
1361
  });
1333
1362
  }
1334
1363
  else {
1335
1364
  //when testing what needs to be published
1336
- return previousResult + ' ' + chalk.blue(pkg.packageName + ' should publish\n');
1365
+ return chalk.blue(pkg.packageName + ' should publish');
1337
1366
  }
1338
1367
  };
1339
1368
  var buildUpdated = function (back, target, target2, test) {
@@ -1467,9 +1496,9 @@ var executeCommandForEachPackage = function (packages, command, filterMethod, fi
1467
1496
  return seen_1;
1468
1497
  });
1469
1498
  }
1470
- log("Executing '" +
1499
+ log('Executing \'' +
1471
1500
  chalk.blueBright(command) +
1472
- "' on packages " +
1501
+ '\' on packages ' +
1473
1502
  chalk.magenta(packages.map(function (m) { return m.packageName; }).join(', ')));
1474
1503
  var p = Promise.resolve(true);
1475
1504
  packages.forEach(function (pkg) {
@@ -1510,11 +1539,11 @@ var executeCommandForPackage = function (packageName, command) {
1510
1539
  return modDetails.packageName.indexOf(packageName) !== -1 || modDetails.packageName.indexOf(packageName) !== -1;
1511
1540
  });
1512
1541
  if (packageDetails) {
1513
- log("Executing 'cd " + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + "'");
1542
+ log('Executing \'cd ' + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + '\'');
1514
1543
  return execp('cd ' + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : ''));
1515
1544
  }
1516
1545
  else {
1517
- warn("Could not find a pkg who's name (partially) matched " + chalk.cyan(packageName));
1546
+ warn('Could not find a pkg who\'s name (partially) matched ' + chalk.cyan(packageName));
1518
1547
  }
1519
1548
  };
1520
1549
  program.parse(process.argv);
@@ -118,8 +118,8 @@ function setupGrunt(grunt, moduleName, config) {
118
118
  // log('setting grunt config');
119
119
  grunt.initConfig({
120
120
  exec: {
121
- 'build-lib': 'tsc --pretty',
122
- 'build-lib-es5': 'tsc --pretty -p tsconfig-es5.json',
121
+ 'build-lib': 'yarn exec tsc --pretty',
122
+ 'build-lib-es5': 'yarn exec tsc --pretty -p tsconfig-es5.json',
123
123
  beforeBuildCommand: config.beforeBuildCommand,
124
124
  'server-dev': 'tsc -w',
125
125
  test: 'tsc -w',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "@babel/preset-react": "^7.18.6",
36
36
  "@babel/preset-typescript": "^7.18.6",
37
37
  "@lodder/grunt-postcss": "^3.1.1",
38
- "@types/node": "^17.0.14",
38
+ "@types/node": "^18.11.10",
39
39
  "@types/react": "^18.0.17",
40
40
  "@types/react-dom": "^18.0.6",
41
41
  "babel-loader": "^8.2.5",
@@ -58,7 +58,7 @@
58
58
  "grunt-webpack": "^5.0.0",
59
59
  "license-info-webpack-plugin": "^3.0.0",
60
60
  "lincd": "^0.5",
61
- "lincd-jsonld": "^0.1.8",
61
+ "lincd-jsonld": "^0.1.13",
62
62
  "load-grunt-tasks": "^5.1.0",
63
63
  "mini-css-extract-plugin": "^2.6.1",
64
64
  "open": "^8.4.0",