lincd-cli 0.2.59 → 0.2.62

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 (82) hide show
  1. package/.husky/post-merge +3 -3
  2. package/.husky/pre-commit +4 -4
  3. package/.prettierignore +3 -3
  4. package/.prettierrc.json +23 -23
  5. package/.yarn/plugins/@yarnpkg/plugin-version.cjs +550 -0
  6. package/.yarn/versions/d035ef78.yml +0 -0
  7. package/LICENSE +373 -373
  8. package/README.md +24 -24
  9. package/defaults/app/Gruntfile.js +5 -5
  10. package/defaults/app/index.html +12 -12
  11. package/defaults/app/package.json +30 -30
  12. package/defaults/app/src/App.scss +2 -2
  13. package/defaults/app/src/App.tsx +4 -4
  14. package/defaults/app/src/index.tsx +10 -10
  15. package/defaults/app/tsconfig-es5.json +18 -18
  16. package/defaults/app/tsconfig.json +21 -21
  17. package/defaults/app-static/capacitor.config.ts +48 -48
  18. package/defaults/app-static/src/index-static.tsx +27 -27
  19. package/defaults/app-static/web/index.html +21 -21
  20. package/defaults/app-with-backend/.env-cmdrc.json +16 -16
  21. package/defaults/app-with-backend/.eslintignore +2 -2
  22. package/defaults/app-with-backend/.eslintrc.json +40 -40
  23. package/defaults/app-with-backend/.husky/post-merge +3 -3
  24. package/defaults/app-with-backend/.husky/pre-commit +4 -4
  25. package/defaults/app-with-backend/.prettierignore +3 -3
  26. package/defaults/app-with-backend/.prettierrc.json +27 -27
  27. package/defaults/app-with-backend/.run/start.run.xml +11 -11
  28. package/defaults/app-with-backend/.vscode/launch.json +11 -11
  29. package/defaults/app-with-backend/.yarn/plugins/@yarnpkg/plugin-version.cjs +550 -550
  30. package/defaults/app-with-backend/.yarn/releases/yarn-3.6.1.cjs +874 -874
  31. package/defaults/app-with-backend/babel.config.js +4 -4
  32. package/defaults/app-with-backend/gitignore.template +22 -22
  33. package/defaults/app-with-backend/lincd.config.js +7 -7
  34. package/defaults/app-with-backend/package.json +92 -92
  35. package/defaults/app-with-backend/pm2.config.js +12 -12
  36. package/defaults/app-with-backend/readme.md +8 -8
  37. package/defaults/app-with-backend/scripts/build.js +41 -42
  38. package/defaults/app-with-backend/scripts/setup_storage.js +6 -6
  39. package/defaults/app-with-backend/scripts/start-server.js +11 -11
  40. package/defaults/app-with-backend/src/App.scss +6 -6
  41. package/defaults/app-with-backend/src/App.tsx +34 -34
  42. package/defaults/app-with-backend/src/backend.ts +1 -1
  43. package/defaults/app-with-backend/src/components/Error.scss +9 -9
  44. package/defaults/app-with-backend/src/components/Error.tsx +14 -14
  45. package/defaults/app-with-backend/src/components/Spinner.scss +17 -17
  46. package/defaults/app-with-backend/src/components/Spinner.tsx +12 -12
  47. package/defaults/app-with-backend/src/index.tsx +32 -32
  48. package/defaults/app-with-backend/src/layout/DefaultLayout.scss +6 -6
  49. package/defaults/app-with-backend/src/layout/DefaultLayout.tsx +13 -13
  50. package/defaults/app-with-backend/src/layout/Header.scss +10 -10
  51. package/defaults/app-with-backend/src/layout/Header.tsx +23 -23
  52. package/defaults/app-with-backend/src/package.ts +14 -14
  53. package/defaults/app-with-backend/src/pages/Home.scss +15 -15
  54. package/defaults/app-with-backend/src/pages/Home.tsx +21 -21
  55. package/defaults/app-with-backend/src/pages/Page1.tsx +11 -11
  56. package/defaults/app-with-backend/src/pages/PageNotFound.tsx +11 -11
  57. package/defaults/app-with-backend/src/pages/Signin.tsx +12 -12
  58. package/defaults/app-with-backend/src/routes.tsx +72 -72
  59. package/defaults/app-with-backend/src/scss/global-overwrites.scss +11 -11
  60. package/defaults/app-with-backend/src/scss/variables.scss +23 -23
  61. package/defaults/app-with-backend/tsconfig.json +21 -21
  62. package/defaults/app-with-backend/yarnrc.yml.template +8 -8
  63. package/defaults/capacitor/scripts/fix-namespace.js +41 -41
  64. package/defaults/component.scss +2 -2
  65. package/defaults/component.tsx +11 -11
  66. package/defaults/package/package.json +38 -38
  67. package/defaults/package/src/components/ExampleComponent.tsx +8 -8
  68. package/defaults/package/src/data/example-ontology.json +20 -20
  69. package/defaults/package/src/data/example-ontology.json.d.ts +1 -1
  70. package/defaults/package/src/index.ts +7 -7
  71. package/defaults/package/src/ontologies/example-ontology.ts +36 -36
  72. package/defaults/package/src/package.ts +4 -4
  73. package/defaults/package/src/shapes/ExampleShapeClass.ts +29 -29
  74. package/defaults/set-component.tsx +15 -15
  75. package/defaults/shape.ts +8 -8
  76. package/expose-grunt.js +1 -1
  77. package/lib/cli-methods.js +44 -98
  78. package/lib/cli.js +5 -3
  79. package/lib/config-grunt.js +5 -5
  80. package/lib/plugins/check-imports.js +1 -1
  81. package/lib/utils.js +83 -1
  82. package/package.json +1 -1
@@ -23,7 +23,6 @@ const depcheck_1 = __importDefault(require("depcheck"));
23
23
  var glob = require('glob');
24
24
  var variables = {};
25
25
  var open = require('open');
26
- var gruntConfig;
27
26
  const createApp = (name, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
28
27
  if (!name) {
29
28
  console.warn('Please provide a name as the first argument');
@@ -67,24 +66,6 @@ function progressUpdate(message) {
67
66
  process.stdout.write(' \r');
68
67
  process.stdout.write(message + '\r');
69
68
  }
70
- function debugInfo(...messages) {
71
- // messages.forEach((message) => {
72
- // console.log(chalk.cyan('Info: ') + message);
73
- // });
74
- //@TODO: let packages also use lincd.config.json? instead of gruntfile...
75
- // that way we can read "analyse" here and see if we need to log debug info
76
- // if(!gruntConfig)
77
- // {
78
- // gruntConfig = getGruntConfig();
79
- // console.log(gruntConfig);
80
- // process.exit();
81
- // }
82
- if (gruntConfig && gruntConfig.analyse === true) {
83
- messages.forEach((message) => {
84
- console.log(chalk_1.default.cyan('Info: ') + message);
85
- });
86
- }
87
- }
88
69
  function warn(...messages) {
89
70
  messages.forEach((message) => {
90
71
  console.log(chalk_1.default.magenta('Warning: ') + message);
@@ -359,10 +340,10 @@ function buildAll(options) {
359
340
  // let packagesLeft = lincdPackages.size - done.size;
360
341
  runOnPackagesGroupedByDependencies(lincdPackages, (packageGroup, dependencies) => {
361
342
  if (done.size > 0) {
362
- debugInfo(chalk_1.default.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
343
+ (0, utils_1.debugInfo)(chalk_1.default.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
363
344
  // log(stack);
364
345
  }
365
- debugInfo('Now building: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
346
+ (0, utils_1.debugInfo)('Now building: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
366
347
  return (pkg) => __awaiter(this, void 0, void 0, function* () {
367
348
  let command;
368
349
  let skipping = false;
@@ -1008,54 +989,6 @@ const buildPackage = (target, target2, packagePath = process.cwd(), logResults =
1008
989
  }
1009
990
  };
1010
991
  exports.buildPackage = buildPackage;
1011
- const getLastBuildTime = (packagePath) => {
1012
- return getLastModifiedFile(packagePath + '/@(builds|lib|dist)/**/*.js');
1013
- };
1014
- const getLastModifiedSourceTime = (packagePath) => {
1015
- return getLastModifiedFile(packagePath + '/@(src|data|scss)/**/*', {
1016
- ignore: [packagePath + '/**/*.scss.json', packagePath + '/**/*.d.ts'],
1017
- });
1018
- };
1019
- const getLastCommitTime = (packagePath) => {
1020
- // console.log(`git log -1 --format=%ci -- ${packagePath}`);
1021
- // process.exit();
1022
- return (0, utils_1.execPromise)(`git log -1 --format="%h %ci" -- ${packagePath}`)
1023
- .then((result) => __awaiter(void 0, void 0, void 0, function* () {
1024
- let commitId = result.substring(0, result.indexOf(' '));
1025
- let date = result.substring(commitId.length + 1);
1026
- let lastCommitDate = new Date(date);
1027
- let changes = yield (0, utils_1.execPromise)(`git show --stat --oneline ${commitId} -- ${packagePath}`);
1028
- // log(packagePath,result,lastCommit);
1029
- // log(changes);
1030
- return { date: lastCommitDate, changes, commitId };
1031
- }))
1032
- .catch(({ error, stdout, stderr }) => {
1033
- debugInfo(chalk_1.default.red('Git error: ') + error.message.toString());
1034
- return null;
1035
- });
1036
- };
1037
- const getLastModifiedFile = (filePath, config = {}) => {
1038
- var files = glob.sync(filePath, config);
1039
- // console.log(files.join(" - "));
1040
- var lastModifiedName;
1041
- var lastModified;
1042
- var lastModifiedTime = 0;
1043
- files.forEach((fileName) => {
1044
- if (fs_extra_1.default.lstatSync(fileName).isDirectory()) {
1045
- // console.log("skipping directory "+fileName);
1046
- return;
1047
- }
1048
- let mtime = fs_extra_1.default.statSync(path_1.default.join(fileName)).mtime;
1049
- let modifiedTime = mtime.getTime();
1050
- if (modifiedTime > lastModifiedTime) {
1051
- // console.log(fileName,mtime);
1052
- lastModifiedName = fileName;
1053
- lastModified = mtime;
1054
- lastModifiedTime = modifiedTime;
1055
- }
1056
- });
1057
- return { lastModified, lastModifiedName, lastModifiedTime };
1058
- };
1059
992
  var publishUpdated = function (test = false) {
1060
993
  let packages = getLocalLincdModules();
1061
994
  var p = Promise.resolve('');
@@ -1077,7 +1010,7 @@ var publishUpdated = function (test = false) {
1077
1010
  let version = getNextVersion(pack.version);
1078
1011
  if (pack.private) {
1079
1012
  shouldPublish = false;
1080
- debugInfo(chalk_1.default.blue('--> is private, skipping'));
1013
+ (0, utils_1.debugInfo)(chalk_1.default.blue('--> is private, skipping'));
1081
1014
  return chalk_1.default.gray(pckg.packageName + ' is private');
1082
1015
  // return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
1083
1016
  }
@@ -1088,7 +1021,7 @@ var publishUpdated = function (test = false) {
1088
1021
  var info;
1089
1022
  try {
1090
1023
  if (output == '' || output.includes('E404')) {
1091
- debugInfo('Empty or 404 response from `npm info`. This package was probably not published before');
1024
+ (0, utils_1.debugInfo)('Empty or 404 response from `npm info`. This package was probably not published before');
1092
1025
  // throw new Error('Empty response from `yarn info`. This pkg was probably not published before');
1093
1026
  // return;
1094
1027
  shouldPublish = true;
@@ -1111,10 +1044,10 @@ var publishUpdated = function (test = false) {
1111
1044
  // }
1112
1045
  let lastPublishDate = new Date(lastPublish);
1113
1046
  // let {lastModifiedTime, lastModifiedName, lastModified} = getLastModifiedSourceTime(pkg.path);
1114
- let lastCommitInfo = yield getLastCommitTime(pckg.path);
1047
+ let lastCommitInfo = yield (0, utils_1.getLastCommitTime)(pckg.path);
1115
1048
  if (!lastCommitInfo) {
1116
1049
  shouldPublish = false;
1117
- debugInfo('Could not determine last git commit');
1050
+ (0, utils_1.debugInfo)('Could not determine last git commit');
1118
1051
  // return previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n');
1119
1052
  return chalk_1.default.red(pckg.packageName + ' - could not determine last commit');
1120
1053
  }
@@ -1235,7 +1168,7 @@ var publishPackage = function (pkg, test, info, publishVersion) {
1235
1168
  publishVersion = info ? getNextVersion(info.version) : 'patch';
1236
1169
  }
1237
1170
  if (test) {
1238
- debugInfo('should publish ' + pkg.packageName + ' ' + publishVersion);
1171
+ (0, utils_1.debugInfo)('should publish ' + pkg.packageName + ' ' + publishVersion);
1239
1172
  //when testing what needs to be published
1240
1173
  return chalk_1.default.blue(pkg.packageName + ' should publish');
1241
1174
  }
@@ -1265,7 +1198,7 @@ var publishPackage = function (pkg, test, info, publishVersion) {
1265
1198
  });
1266
1199
  };
1267
1200
  exports.publishPackage = publishPackage;
1268
- var buildUpdated = function (back, target, target2, test = false) {
1201
+ var buildUpdated = function (back, target, target2, useGitForLastModified = false, test = false) {
1269
1202
  return __awaiter(this, void 0, void 0, function* () {
1270
1203
  // back = back || 1;
1271
1204
  // return execPromise(`git log -${back} --format=%ci`).then((result) => {
@@ -1277,8 +1210,8 @@ var buildUpdated = function (back, target, target2, test = false) {
1277
1210
  // let packages = getLocalLincdModules();
1278
1211
  let packages = getLocalLincdPackageMap();
1279
1212
  // console.log(packages);
1280
- let jsonldPkgUpdated = needsRebuilding(packages.get('lincd-jsonld'));
1281
- // let cliPkgUpdated = needsRebuilding(packages.get('lincd-cli'));
1213
+ let jsonldPkgUpdated = yield needsRebuilding(packages.get('lincd-jsonld'), useGitForLastModified);
1214
+ // let cliPkgUpdated = await needsRebuilding(packages.get('lincd-cli'), useGitForLastModified);
1282
1215
  //if either cli or jsonldPkg needs to be rebuilt
1283
1216
  // if (jsonldPkgUpdated || cliPkgUpdated) {
1284
1217
  if (jsonldPkgUpdated) {
@@ -1291,12 +1224,12 @@ var buildUpdated = function (back, target, target2, test = false) {
1291
1224
  // }
1292
1225
  let packagesLeft = packages.size;
1293
1226
  runOnPackagesGroupedByDependencies(packages, (packageGroup, dependencies) => {
1294
- debugInfo('Now checking: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
1295
- debugInfo(packagesLeft + ' packages left.');
1227
+ (0, utils_1.debugInfo)('Now checking: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
1228
+ (0, utils_1.debugInfo)(packagesLeft + ' packages left.');
1296
1229
  packagesLeft = packagesLeft - packageGroup.length;
1297
1230
  return (pkg) => __awaiter(this, void 0, void 0, function* () {
1298
1231
  // debugInfo('# Checking package ' + pkg.packageName);
1299
- let needRebuild = needsRebuilding(pkg, true);
1232
+ let needRebuild = yield needsRebuilding(pkg, useGitForLastModified, true);
1300
1233
  if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated) {
1301
1234
  needRebuild = true;
1302
1235
  }
@@ -1304,7 +1237,7 @@ var buildUpdated = function (back, target, target2, test = false) {
1304
1237
  //TODO: when building a pkg, also rebuild all packages that depend on this package.. and iteratively build packages that depend on those packages..
1305
1238
  // log(packageName+' modified since last commit on '+now.toString());
1306
1239
  if (test) {
1307
- debugInfo('Need to build ' + pkg.packageName);
1240
+ (0, utils_1.debugInfo)('Need to build ' + pkg.packageName);
1308
1241
  return chalk_1.default.blue(pkg.packageName + ' should be build');
1309
1242
  }
1310
1243
  log('Building ' + pkg.packageName);
@@ -1314,7 +1247,7 @@ var buildUpdated = function (back, target, target2, test = false) {
1314
1247
  (target ? ' ' + target : '') +
1315
1248
  (target2 ? ' ' + target2 : ''))
1316
1249
  .then((res) => {
1317
- debugInfo(chalk_1.default.green(pkg.packageName + ' successfully built'));
1250
+ (0, utils_1.debugInfo)(chalk_1.default.green(pkg.packageName + ' successfully built'));
1318
1251
  return chalk_1.default.green(pkg.packageName + ' built');
1319
1252
  })
1320
1253
  .catch(({ error, stdout, stderr }) => {
@@ -1345,22 +1278,35 @@ var buildUpdated = function (back, target, target2, test = false) {
1345
1278
  });
1346
1279
  };
1347
1280
  exports.buildUpdated = buildUpdated;
1348
- const needsRebuilding = function (pkg, log = false) {
1349
- let lastModifiedSource = getLastModifiedSourceTime(pkg.path);
1350
- let lastModifiedBundle = getLastBuildTime(pkg.path);
1351
- let result = lastModifiedSource.lastModifiedTime > lastModifiedBundle.lastModifiedTime;
1352
- if (log) {
1353
- console.log(chalk_1.default.cyan('Last modified source: ' +
1354
- lastModifiedSource.lastModifiedName +
1355
- ' on ' +
1356
- lastModifiedSource.lastModified.toString()));
1357
- console.log(chalk_1.default.cyan('Last build: ' +
1358
- (lastModifiedBundle &&
1359
- typeof lastModifiedBundle.lastModified !== 'undefined'
1360
- ? lastModifiedBundle.lastModified.toString()
1361
- : 'never')));
1362
- }
1363
- return result;
1281
+ const needsRebuilding = function (pkg, useGitForLastModified, log = false) {
1282
+ return __awaiter(this, void 0, void 0, function* () {
1283
+ let lastModifiedSourceDate;
1284
+ let lastModifiedSourceName;
1285
+ if (useGitForLastModified) {
1286
+ const { changes, commitId, date } = yield (0, utils_1.getLastCommitTime)(pkg.path);
1287
+ lastModifiedSourceDate = date;
1288
+ lastModifiedSourceName = commitId;
1289
+ }
1290
+ else {
1291
+ const { lastModified, lastModifiedName, lastModifiedTime } = (0, utils_1.getLastModifiedSourceTime)(pkg.path);
1292
+ lastModifiedSourceName = lastModifiedName;
1293
+ lastModifiedSourceDate = lastModified;
1294
+ }
1295
+ let lastModifiedBundle = (0, utils_1.getLastBuildTime)(pkg.path);
1296
+ let result = lastModifiedSourceDate.getTime() > lastModifiedBundle.lastModifiedTime;
1297
+ if (log) {
1298
+ console.log(chalk_1.default.cyan('Last modified source: ' +
1299
+ lastModifiedSourceName +
1300
+ ' on ' +
1301
+ lastModifiedSourceDate.toString()));
1302
+ console.log(chalk_1.default.cyan('Last build: ' +
1303
+ (lastModifiedBundle &&
1304
+ typeof lastModifiedBundle.lastModified !== 'undefined'
1305
+ ? lastModifiedBundle.lastModified.toString()
1306
+ : 'never')));
1307
+ }
1308
+ return result;
1309
+ });
1364
1310
  };
1365
1311
  const printBuildResults = function (failed, done) {
1366
1312
  log('Successfully built: ' +
package/lib/cli.js CHANGED
@@ -97,9 +97,11 @@ program.command('status').action(() => {
97
97
  });
98
98
  program
99
99
  .command('build-updated [target] [target2]')
100
- .action((target, target2) => {
101
- return (0, cli_methods_1.buildUpdated)(1, target, target2);
102
- });
100
+ .action((target, target2, options) => {
101
+ const { useGit } = options;
102
+ return (0, cli_methods_1.buildUpdated)(1, target, target2, useGit || false);
103
+ })
104
+ .option('--use-git', 'Use git commit timestamps to check which packages have been updated since the last build');
103
105
  program
104
106
  .command('build-updated-since [num-commits-back] [target] [target2]')
105
107
  .action((back, target, target2) => {
@@ -269,11 +269,11 @@ function setupGrunt(grunt, moduleName, config) {
269
269
  grunt.task.loadTasks(nestedWorkspacePath);
270
270
  }
271
271
  else {
272
- (0, utils_1.warn)(`Could not load grunt task module ${taskName}
273
- Could not find task at any of these paths:
274
- ${localPath}
275
- ${localPath2}
276
- ${workspacePath}
272
+ (0, utils_1.warn)(`Could not load grunt task module ${taskName}
273
+ Could not find task at any of these paths:
274
+ ${localPath}
275
+ ${localPath2}
276
+ ${workspacePath}
277
277
  ${nestedWorkspacePath}`);
278
278
  }
279
279
  });
@@ -54,7 +54,7 @@ function handler(source) {
54
54
  if (isRelativeReq &&
55
55
  this.resourcePath.indexOf(baseUrl) !== 0 &&
56
56
  this.resourcePath.indexOf('node_modules') === -1) {
57
- this.emitError(Error(`LINCD Error: You are importing a file from outside the baseUrl ${tsconfig.compilerOptions.baseUrl}.
57
+ this.emitError(Error(`LINCD Error: You are importing a file from outside the baseUrl ${tsconfig.compilerOptions.baseUrl}.
58
58
  ${relativePath} is not in ${tsconfig.compilerOptions.baseUrl}.`));
59
59
  }
60
60
  // if (this.resourcePath.indexOf(path.resolve('./src')) !== 0) {
package/lib/utils.js CHANGED
@@ -22,16 +22,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
28
37
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getLinkedTailwindColors = exports.flatten = exports.warn = exports.debug = exports.log = exports.generateScopedName = exports.execPromise = exports.execp = exports.getGruntConfig = exports.getModulePackageJSON = exports.getLINCDDependencies = exports.getPackageJSON = void 0;
38
+ exports.getLinkedTailwindColors = exports.flatten = exports.warn = exports.debugInfo = exports.debug = exports.log = exports.generateScopedName = exports.execPromise = exports.execp = exports.getGruntConfig = exports.getModulePackageJSON = exports.getLastModifiedFile = exports.getLastCommitTime = exports.getLastModifiedSourceTime = exports.getLastBuildTime = exports.getLINCDDependencies = exports.getPackageJSON = void 0;
30
39
  const fs = __importStar(require("fs"));
31
40
  const path = __importStar(require("path"));
32
41
  const chalk_1 = __importDefault(require("chalk"));
33
42
  const child_process_1 = require("child_process");
34
43
  const { findNearestPackageJson, findNearestPackageJsonSync, } = require('find-nearest-package-json');
44
+ var glob = require('glob');
45
+ var gruntConfig;
35
46
  var getPackageJSON = function (root = process.cwd(), error = true) {
36
47
  let packagePath = path.join(root, 'package.json');
37
48
  if (fs.existsSync(packagePath)) {
@@ -156,6 +167,58 @@ var getLINCDDependencies = function (packageJson, checkedPackages = new Set()) {
156
167
  return lincdPackagePaths;
157
168
  };
158
169
  exports.getLINCDDependencies = getLINCDDependencies;
170
+ const getLastBuildTime = (packagePath) => {
171
+ return (0, exports.getLastModifiedFile)(packagePath + '/@(builds|lib|dist)/**/*.js');
172
+ };
173
+ exports.getLastBuildTime = getLastBuildTime;
174
+ const getLastModifiedSourceTime = (packagePath) => {
175
+ return (0, exports.getLastModifiedFile)(packagePath + '/@(src|data|scss)/**/*', {
176
+ ignore: [packagePath + '/**/*.scss.json', packagePath + '/**/*.d.ts'],
177
+ });
178
+ };
179
+ exports.getLastModifiedSourceTime = getLastModifiedSourceTime;
180
+ const getLastCommitTime = (packagePath) => {
181
+ // console.log(`git log -1 --format=%ci -- ${packagePath}`);
182
+ // process.exit();
183
+ return execPromise(`git log -1 --format="%h %ci" -- ${packagePath}`)
184
+ .then((result) => __awaiter(void 0, void 0, void 0, function* () {
185
+ let commitId = result.substring(0, result.indexOf(' '));
186
+ let date = result.substring(commitId.length + 1);
187
+ let lastCommitDate = new Date(date);
188
+ let changes = yield execPromise(`git show --stat --oneline ${commitId} -- ${packagePath}`);
189
+ // log(packagePath,result,lastCommit);
190
+ // log(changes);
191
+ return { date: lastCommitDate, changes, commitId };
192
+ }))
193
+ .catch(({ error, stdout, stderr }) => {
194
+ debugInfo(chalk_1.default.red('Git error: ') + error.message.toString());
195
+ return null;
196
+ });
197
+ };
198
+ exports.getLastCommitTime = getLastCommitTime;
199
+ const getLastModifiedFile = (filePath, config = {}) => {
200
+ var files = glob.sync(filePath, config);
201
+ // console.log(files.join(" - "));
202
+ var lastModifiedName;
203
+ var lastModified;
204
+ var lastModifiedTime = 0;
205
+ files.forEach((fileName) => {
206
+ if (fs.lstatSync(fileName).isDirectory()) {
207
+ // console.log("skipping directory "+fileName);
208
+ return;
209
+ }
210
+ let mtime = fs.statSync(path.join(fileName)).mtime;
211
+ let modifiedTime = mtime.getTime();
212
+ if (modifiedTime > lastModifiedTime) {
213
+ // console.log(fileName,mtime);
214
+ lastModifiedName = fileName;
215
+ lastModified = mtime;
216
+ lastModifiedTime = modifiedTime;
217
+ }
218
+ });
219
+ return { lastModified, lastModifiedName, lastModifiedTime };
220
+ };
221
+ exports.getLastModifiedFile = getLastModifiedFile;
159
222
  //from https://github.com/haalcala/node-packagejson/blob/master/index.js
160
223
  var getModulePackageJSON = function (module_name, work_dir) {
161
224
  if (!work_dir) {
@@ -311,6 +374,25 @@ function debug(config, ...messages) {
311
374
  }
312
375
  }
313
376
  exports.debug = debug;
377
+ function debugInfo(...messages) {
378
+ // messages.forEach((message) => {
379
+ // console.log(chalk.cyan('Info: ') + message);
380
+ // });
381
+ //@TODO: let packages also use lincd.config.json? instead of gruntfile...
382
+ // that way we can read "analyse" here and see if we need to log debug info
383
+ // if(!gruntConfig)
384
+ // {
385
+ // gruntConfig = getGruntConfig();
386
+ // console.log(gruntConfig);
387
+ // process.exit();
388
+ // }
389
+ if (gruntConfig && gruntConfig.analyse === true) {
390
+ messages.forEach((message) => {
391
+ console.log(chalk_1.default.cyan('Info: ') + message);
392
+ });
393
+ }
394
+ }
395
+ exports.debugInfo = debugInfo;
314
396
  function warn(...messages) {
315
397
  messages.forEach((message) => {
316
398
  console.log(chalk_1.default.red(message));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.2.59",
3
+ "version": "0.2.62",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {