lincd-cli 0.2.60 → 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.
@@ -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
  }
@@ -1291,8 +1224,8 @@ var buildUpdated = function (back, target, target2, useGitForLastModified = fals
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);
@@ -1304,7 +1237,7 @@ var buildUpdated = function (back, target, target2, useGitForLastModified = fals
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, useGitForLastModified = fals
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 }) => {
@@ -1350,16 +1283,16 @@ const needsRebuilding = function (pkg, useGitForLastModified, log = false) {
1350
1283
  let lastModifiedSourceDate;
1351
1284
  let lastModifiedSourceName;
1352
1285
  if (useGitForLastModified) {
1353
- const { changes, commitId, date } = yield getLastCommitTime(pkg.path);
1286
+ const { changes, commitId, date } = yield (0, utils_1.getLastCommitTime)(pkg.path);
1354
1287
  lastModifiedSourceDate = date;
1355
1288
  lastModifiedSourceName = commitId;
1356
1289
  }
1357
1290
  else {
1358
- const { lastModified, lastModifiedName, lastModifiedTime } = getLastModifiedSourceTime(pkg.path);
1291
+ const { lastModified, lastModifiedName, lastModifiedTime } = (0, utils_1.getLastModifiedSourceTime)(pkg.path);
1359
1292
  lastModifiedSourceName = lastModifiedName;
1360
1293
  lastModifiedSourceDate = lastModified;
1361
1294
  }
1362
- let lastModifiedBundle = getLastBuildTime(pkg.path);
1295
+ let lastModifiedBundle = (0, utils_1.getLastBuildTime)(pkg.path);
1363
1296
  let result = lastModifiedSourceDate.getTime() > lastModifiedBundle.lastModifiedTime;
1364
1297
  if (log) {
1365
1298
  console.log(chalk_1.default.cyan('Last modified source: ' +
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.60",
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": {