lincd-cli 0.2.21 → 0.2.22
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/lib/cli-methods.js +45 -50
- package/package.json +1 -1
package/lib/cli-methods.js
CHANGED
|
@@ -1151,12 +1151,24 @@ var getLastModifiedSourceTime = function (packagePath) {
|
|
|
1151
1151
|
var getLastCommitTime = function (packagePath) {
|
|
1152
1152
|
// console.log(`git log -1 --format=%ci -- ${packagePath}`);
|
|
1153
1153
|
// process.exit();
|
|
1154
|
-
return (0, utils_1.execPromise)("git log -1 --format
|
|
1155
|
-
.then(function (result) {
|
|
1156
|
-
var
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1154
|
+
return (0, utils_1.execPromise)("git log -1 --format=\"%h %ci\" -- ".concat(packagePath))
|
|
1155
|
+
.then(function (result) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1156
|
+
var commitId, date, lastCommitDate, changes;
|
|
1157
|
+
return __generator(this, function (_a) {
|
|
1158
|
+
switch (_a.label) {
|
|
1159
|
+
case 0:
|
|
1160
|
+
commitId = result.substring(0, result.indexOf(" "));
|
|
1161
|
+
date = result.substring(commitId.length + 1);
|
|
1162
|
+
lastCommitDate = new Date(date);
|
|
1163
|
+
return [4 /*yield*/, (0, utils_1.execPromise)("git show --stat --oneline ".concat(commitId, " -- ").concat(packagePath))];
|
|
1164
|
+
case 1:
|
|
1165
|
+
changes = _a.sent();
|
|
1166
|
+
// log(packagePath,result,lastCommit);
|
|
1167
|
+
// log(changes);
|
|
1168
|
+
return [2 /*return*/, { date: lastCommitDate, changes: changes, commitId: commitId }];
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
}); })["catch"](function (_a) {
|
|
1160
1172
|
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1161
1173
|
debugInfo(chalk_1["default"].red('Git error: ') + error.message.toString());
|
|
1162
1174
|
return null;
|
|
@@ -1189,7 +1201,6 @@ var publishUpdated = function (test) {
|
|
|
1189
1201
|
var _this = this;
|
|
1190
1202
|
if (test === void 0) { test = false; }
|
|
1191
1203
|
var packages = getLocalLincdModules();
|
|
1192
|
-
var browserCoreBuilt = false;
|
|
1193
1204
|
var p = Promise.resolve('');
|
|
1194
1205
|
var packagesLeft = packages.length;
|
|
1195
1206
|
var results = [];
|
|
@@ -1215,7 +1226,7 @@ var publishUpdated = function (test) {
|
|
|
1215
1226
|
}
|
|
1216
1227
|
return (0, utils_1.execPromise)('npm info ' + pckg.packageName + ' --json')
|
|
1217
1228
|
.then(function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
1218
|
-
var info, lastPublish, lastPublishDate,
|
|
1229
|
+
var info, lastPublish, lastPublishDate, lastCommitInfo, err_1;
|
|
1219
1230
|
return __generator(this, function (_a) {
|
|
1220
1231
|
switch (_a.label) {
|
|
1221
1232
|
case 0:
|
|
@@ -1239,8 +1250,8 @@ var publishUpdated = function (test) {
|
|
|
1239
1250
|
lastPublishDate = new Date(lastPublish);
|
|
1240
1251
|
return [4 /*yield*/, getLastCommitTime(pckg.path)];
|
|
1241
1252
|
case 1:
|
|
1242
|
-
|
|
1243
|
-
if (!
|
|
1253
|
+
lastCommitInfo = _a.sent();
|
|
1254
|
+
if (!lastCommitInfo) {
|
|
1244
1255
|
shouldPublish = false;
|
|
1245
1256
|
debugInfo('Could not determine last git commit');
|
|
1246
1257
|
// return previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n');
|
|
@@ -1249,19 +1260,17 @@ var publishUpdated = function (test) {
|
|
|
1249
1260
|
else {
|
|
1250
1261
|
//NOTE: removed lastModified, because switching branches will say that the file was modified and cause everything to publish
|
|
1251
1262
|
//SO: now you NEED TO commit before it picks up that you should publish
|
|
1252
|
-
shouldPublish = lastPublishDate.getTime() <
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
// );
|
|
1264
|
-
// }
|
|
1263
|
+
shouldPublish = lastPublishDate.getTime() < lastCommitInfo.date.getTime();
|
|
1264
|
+
if (shouldPublish) {
|
|
1265
|
+
log(chalk_1["default"].magenta(pckg.packageName) + ' should be published because:');
|
|
1266
|
+
log(lastPublishDate.toDateString() +
|
|
1267
|
+
' ' +
|
|
1268
|
+
lastPublishDate.toTimeString() +
|
|
1269
|
+
' published ' +
|
|
1270
|
+
info.version);
|
|
1271
|
+
log(lastCommitInfo.date.toDateString() + ' ' + new Date(lastCommitInfo.date).toTimeString() + ' source last committed:');
|
|
1272
|
+
log(lastCommitInfo.changes);
|
|
1273
|
+
}
|
|
1265
1274
|
}
|
|
1266
1275
|
_a.label = 2;
|
|
1267
1276
|
case 2: return [3 /*break*/, 4];
|
|
@@ -1275,21 +1284,8 @@ var publishUpdated = function (test) {
|
|
|
1275
1284
|
return [2 /*return*/, chalk_1["default"].red(pckg.packageName + ' failed: ' + err_1.message)];
|
|
1276
1285
|
case 4:
|
|
1277
1286
|
if (shouldPublish) {
|
|
1278
|
-
|
|
1279
|
-
if (pckg.packageName == 'browser-core') {
|
|
1280
|
-
browserCoreBuilt = true;
|
|
1281
|
-
}
|
|
1282
|
-
//when publishing core, also make sure to publish browser-core
|
|
1283
|
-
if (pckg.packageName == 'core' && !browserCoreBuilt) {
|
|
1284
|
-
browserModule = packages.find(function (m) { return m.packageName == 'browser-core'; });
|
|
1285
|
-
return [2 /*return*/, Promise.resolve(res).then(function (previousResult) {
|
|
1286
|
-
log('# Automatically also publishing package browser-core');
|
|
1287
|
-
return (0, exports.publishPackage)(browserModule, test);
|
|
1288
|
-
})];
|
|
1289
|
-
}
|
|
1290
|
-
return [2 /*return*/, res];
|
|
1287
|
+
return [2 /*return*/, (0, exports.publishPackage)(pckg, test, info, version)];
|
|
1291
1288
|
}
|
|
1292
|
-
// return previousResult + ' ' + chalk.green(pckg.packageName + ' latest version is up to date\n');
|
|
1293
1289
|
return [2 /*return*/, chalk_1["default"].green(pckg.packageName + ' latest version is up to date')];
|
|
1294
1290
|
}
|
|
1295
1291
|
});
|
|
@@ -1329,18 +1325,22 @@ var publishUpdated = function (test) {
|
|
|
1329
1325
|
});
|
|
1330
1326
|
};
|
|
1331
1327
|
exports.publishUpdated = publishUpdated;
|
|
1332
|
-
function getEnvJsonPath() {
|
|
1328
|
+
function getEnvJsonPath(relativeToPath) {
|
|
1329
|
+
if (relativeToPath === void 0) { relativeToPath = process.cwd(); }
|
|
1333
1330
|
return __awaiter(this, void 0, void 0, function () {
|
|
1334
1331
|
var path, i, envFile;
|
|
1335
1332
|
return __generator(this, function (_a) {
|
|
1336
1333
|
switch (_a.label) {
|
|
1337
1334
|
case 0:
|
|
1338
|
-
path = '
|
|
1335
|
+
path = '';
|
|
1336
|
+
if (!relativeToPath.endsWith('/')) {
|
|
1337
|
+
relativeToPath += '/';
|
|
1338
|
+
}
|
|
1339
1339
|
i = 0;
|
|
1340
1340
|
_a.label = 1;
|
|
1341
1341
|
case 1:
|
|
1342
1342
|
if (!(i <= 10)) return [3 /*break*/, 4];
|
|
1343
|
-
return [4 /*yield*/, (0, get_env_vars_1.getEnvFile)({ filePath: path + '.env.json' })["catch"](function (err) {
|
|
1343
|
+
return [4 /*yield*/, (0, get_env_vars_1.getEnvFile)({ filePath: relativeToPath + path + '.env.json' })["catch"](function (err) {
|
|
1344
1344
|
return null;
|
|
1345
1345
|
})];
|
|
1346
1346
|
case 2:
|
|
@@ -1381,7 +1381,7 @@ var publishPackage = function (pkg, test, info, publishVersion) {
|
|
|
1381
1381
|
return [2 /*return*/, chalk_1["default"].blue(pkg.packageName + ' should publish')];
|
|
1382
1382
|
}
|
|
1383
1383
|
console.log(chalk_1["default"].blue('publishing ' + pkg.packageName + ' ' + publishVersion));
|
|
1384
|
-
return [4 /*yield*/, getEnvJsonPath()];
|
|
1384
|
+
return [4 /*yield*/, getEnvJsonPath(pkg.path)];
|
|
1385
1385
|
case 1:
|
|
1386
1386
|
envJsonPath = _a.sent();
|
|
1387
1387
|
return [2 /*return*/, (0, utils_1.execPromise)("cd ".concat(pkg.path, " && ").concat(envJsonPath ? "env-cmd -f ".concat(envJsonPath, " --use-shell \"") : '', "yarn version ").concat(publishVersion, " && yarn npm publish").concat(envJsonPath ? "\"" : ''), true, false, {}, true)
|
|
@@ -1393,11 +1393,11 @@ var publishPackage = function (pkg, test, info, publishVersion) {
|
|
|
1393
1393
|
return chalk_1["default"].red(pkg.packageName + ' failed\n');
|
|
1394
1394
|
}
|
|
1395
1395
|
console.log(chalk_1["default"].green('Successfully published ' + pkg.path + ' ' + publishVersion));
|
|
1396
|
-
return chalk_1["default"].green(pkg.packageName + ' published ' + publishVersion
|
|
1396
|
+
return chalk_1["default"].green(pkg.packageName + ' published ' + publishVersion);
|
|
1397
1397
|
})["catch"](function (_a) {
|
|
1398
1398
|
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1399
1399
|
console.log(chalk_1["default"].red('Failed to publish: ' + error.message));
|
|
1400
|
-
return chalk_1["default"].red(pkg.packageName + ' failed to publish
|
|
1400
|
+
return chalk_1["default"].red(pkg.packageName + ' failed to publish');
|
|
1401
1401
|
})];
|
|
1402
1402
|
}
|
|
1403
1403
|
});
|
|
@@ -1407,7 +1407,7 @@ exports.publishPackage = publishPackage;
|
|
|
1407
1407
|
var buildUpdated = function (back, target, target2, test) {
|
|
1408
1408
|
if (test === void 0) { test = false; }
|
|
1409
1409
|
return __awaiter(this, void 0, void 0, function () {
|
|
1410
|
-
var previousResult, packages, jsonldPkgUpdated,
|
|
1410
|
+
var previousResult, packages, jsonldPkgUpdated, rebuildAllModules, packagesLeft, p;
|
|
1411
1411
|
var _this = this;
|
|
1412
1412
|
return __generator(this, function (_a) {
|
|
1413
1413
|
switch (_a.label) {
|
|
@@ -1416,18 +1416,13 @@ var buildUpdated = function (back, target, target2, test) {
|
|
|
1416
1416
|
log(test ? 'Checking which packages need to be rebuild' : 'Building updated packages');
|
|
1417
1417
|
packages = getLocalLincdPackageMap();
|
|
1418
1418
|
jsonldPkgUpdated = needsRebuilding(packages.get('lincd-jsonld'));
|
|
1419
|
-
|
|
1420
|
-
if (!(jsonldPkgUpdated || cliPkgUpdated)) return [3 /*break*/, 2];
|
|
1419
|
+
if (!jsonldPkgUpdated) return [3 /*break*/, 2];
|
|
1421
1420
|
return [4 /*yield*/, (0, utils_1.execPromise)('yarn build-core', false, false, {}, true)];
|
|
1422
1421
|
case 1:
|
|
1423
1422
|
_a.sent();
|
|
1424
1423
|
_a.label = 2;
|
|
1425
1424
|
case 2:
|
|
1426
1425
|
rebuildAllModules = false;
|
|
1427
|
-
if (cliPkgUpdated) {
|
|
1428
|
-
rebuildAllModules = true;
|
|
1429
|
-
log(chalk_1["default"].magenta('Rebuilding all packages because the build tools (lincd-cli) got updated'));
|
|
1430
|
-
}
|
|
1431
1426
|
packagesLeft = packages.size;
|
|
1432
1427
|
runOnPackagesGroupedByDependencies(packages, function (packageGroup, dependencies) {
|
|
1433
1428
|
// console.log('Now checking: ' + chalk.blue(packageGroup.map((i) => i.packageName)));
|