lincd-cli 0.2.20 → 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
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,9 +1325,43 @@ var publishUpdated = function (test) {
|
|
|
1329
1325
|
});
|
|
1330
1326
|
};
|
|
1331
1327
|
exports.publishUpdated = publishUpdated;
|
|
1328
|
+
function getEnvJsonPath(relativeToPath) {
|
|
1329
|
+
if (relativeToPath === void 0) { relativeToPath = process.cwd(); }
|
|
1330
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1331
|
+
var path, i, envFile;
|
|
1332
|
+
return __generator(this, function (_a) {
|
|
1333
|
+
switch (_a.label) {
|
|
1334
|
+
case 0:
|
|
1335
|
+
path = '';
|
|
1336
|
+
if (!relativeToPath.endsWith('/')) {
|
|
1337
|
+
relativeToPath += '/';
|
|
1338
|
+
}
|
|
1339
|
+
i = 0;
|
|
1340
|
+
_a.label = 1;
|
|
1341
|
+
case 1:
|
|
1342
|
+
if (!(i <= 10)) return [3 /*break*/, 4];
|
|
1343
|
+
return [4 /*yield*/, (0, get_env_vars_1.getEnvFile)({ filePath: relativeToPath + path + '.env.json' })["catch"](function (err) {
|
|
1344
|
+
return null;
|
|
1345
|
+
})];
|
|
1346
|
+
case 2:
|
|
1347
|
+
envFile = _a.sent();
|
|
1348
|
+
if (envFile) {
|
|
1349
|
+
//note: we're getting the actual contents here, so we could also use that more directly?
|
|
1350
|
+
return [2 /*return*/, path + '.env.json'];
|
|
1351
|
+
}
|
|
1352
|
+
path += '../';
|
|
1353
|
+
_a.label = 3;
|
|
1354
|
+
case 3:
|
|
1355
|
+
i++;
|
|
1356
|
+
return [3 /*break*/, 1];
|
|
1357
|
+
case 4: return [2 /*return*/];
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1332
1362
|
var publishPackage = function (pkg, test, info, publishVersion) {
|
|
1333
1363
|
return __awaiter(this, void 0, void 0, function () {
|
|
1334
|
-
var localPackageJson,
|
|
1364
|
+
var localPackageJson, envJsonPath;
|
|
1335
1365
|
return __generator(this, function (_a) {
|
|
1336
1366
|
switch (_a.label) {
|
|
1337
1367
|
case 0:
|
|
@@ -1351,42 +1381,24 @@ var publishPackage = function (pkg, test, info, publishVersion) {
|
|
|
1351
1381
|
return [2 /*return*/, chalk_1["default"].blue(pkg.packageName + ' should publish')];
|
|
1352
1382
|
}
|
|
1353
1383
|
console.log(chalk_1["default"].blue('publishing ' + pkg.packageName + ' ' + publishVersion));
|
|
1354
|
-
|
|
1355
|
-
envCmdFile = '';
|
|
1356
|
-
i = 0;
|
|
1357
|
-
_a.label = 1;
|
|
1384
|
+
return [4 /*yield*/, getEnvJsonPath(pkg.path)];
|
|
1358
1385
|
case 1:
|
|
1359
|
-
|
|
1360
|
-
return [
|
|
1361
|
-
|
|
1386
|
+
envJsonPath = _a.sent();
|
|
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)
|
|
1388
|
+
.then(function (res) {
|
|
1389
|
+
if (res.indexOf('Aborted due to warnings') !== -1 ||
|
|
1390
|
+
res.indexOf('Could not publish') !== -1 ||
|
|
1391
|
+
res.indexOf("Couldn't publish") !== -1) {
|
|
1392
|
+
console.log(res);
|
|
1393
|
+
return chalk_1["default"].red(pkg.packageName + ' failed\n');
|
|
1394
|
+
}
|
|
1395
|
+
console.log(chalk_1["default"].green('Successfully published ' + pkg.path + ' ' + publishVersion));
|
|
1396
|
+
return chalk_1["default"].green(pkg.packageName + ' published ' + publishVersion);
|
|
1397
|
+
})["catch"](function (_a) {
|
|
1398
|
+
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1399
|
+
console.log(chalk_1["default"].red('Failed to publish: ' + error.message));
|
|
1400
|
+
return chalk_1["default"].red(pkg.packageName + ' failed to publish');
|
|
1362
1401
|
})];
|
|
1363
|
-
case 2:
|
|
1364
|
-
envFile = _a.sent();
|
|
1365
|
-
if (envFile) {
|
|
1366
|
-
//note: we're getting the actual contents here, so we could also use that more directly?
|
|
1367
|
-
envCmdFile = path + '.env.json';
|
|
1368
|
-
return [3 /*break*/, 4];
|
|
1369
|
-
}
|
|
1370
|
-
path += '../';
|
|
1371
|
-
_a.label = 3;
|
|
1372
|
-
case 3:
|
|
1373
|
-
i++;
|
|
1374
|
-
return [3 /*break*/, 1];
|
|
1375
|
-
case 4: return [2 /*return*/, (0, utils_1.execPromise)("cd ".concat(pkg.path, " && ").concat(envCmdFile ? "env-cmd -f ".concat(envCmdFile, " --use-shell \"") : '', "yarn version ").concat(publishVersion, " && yarn npm publish").concat(envCmdFile ? "\"" : ''), true, false, {}, true)
|
|
1376
|
-
.then(function (res) {
|
|
1377
|
-
if (res.indexOf('Aborted due to warnings') !== -1 ||
|
|
1378
|
-
res.indexOf('Could not publish') !== -1 ||
|
|
1379
|
-
res.indexOf("Couldn't publish") !== -1) {
|
|
1380
|
-
console.log(res);
|
|
1381
|
-
return chalk_1["default"].red(pkg.packageName + ' failed\n');
|
|
1382
|
-
}
|
|
1383
|
-
console.log(chalk_1["default"].green('Successfully published ' + pkg.path + ' ' + publishVersion));
|
|
1384
|
-
return chalk_1["default"].green(pkg.packageName + ' published ' + publishVersion + '\n');
|
|
1385
|
-
})["catch"](function (_a) {
|
|
1386
|
-
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1387
|
-
console.log(chalk_1["default"].red('Failed to publish: ' + error.message));
|
|
1388
|
-
return chalk_1["default"].red(pkg.packageName + ' failed to publish\n');
|
|
1389
|
-
})];
|
|
1390
1402
|
}
|
|
1391
1403
|
});
|
|
1392
1404
|
});
|
|
@@ -1395,7 +1407,7 @@ exports.publishPackage = publishPackage;
|
|
|
1395
1407
|
var buildUpdated = function (back, target, target2, test) {
|
|
1396
1408
|
if (test === void 0) { test = false; }
|
|
1397
1409
|
return __awaiter(this, void 0, void 0, function () {
|
|
1398
|
-
var previousResult, packages, jsonldPkgUpdated,
|
|
1410
|
+
var previousResult, packages, jsonldPkgUpdated, rebuildAllModules, packagesLeft, p;
|
|
1399
1411
|
var _this = this;
|
|
1400
1412
|
return __generator(this, function (_a) {
|
|
1401
1413
|
switch (_a.label) {
|
|
@@ -1404,18 +1416,13 @@ var buildUpdated = function (back, target, target2, test) {
|
|
|
1404
1416
|
log(test ? 'Checking which packages need to be rebuild' : 'Building updated packages');
|
|
1405
1417
|
packages = getLocalLincdPackageMap();
|
|
1406
1418
|
jsonldPkgUpdated = needsRebuilding(packages.get('lincd-jsonld'));
|
|
1407
|
-
|
|
1408
|
-
if (!(jsonldPkgUpdated || cliPkgUpdated)) return [3 /*break*/, 2];
|
|
1419
|
+
if (!jsonldPkgUpdated) return [3 /*break*/, 2];
|
|
1409
1420
|
return [4 /*yield*/, (0, utils_1.execPromise)('yarn build-core', false, false, {}, true)];
|
|
1410
1421
|
case 1:
|
|
1411
1422
|
_a.sent();
|
|
1412
1423
|
_a.label = 2;
|
|
1413
1424
|
case 2:
|
|
1414
1425
|
rebuildAllModules = false;
|
|
1415
|
-
if (cliPkgUpdated) {
|
|
1416
|
-
rebuildAllModules = true;
|
|
1417
|
-
log(chalk_1["default"].magenta('Rebuilding all packages because the build tools (lincd-cli) got updated'));
|
|
1418
|
-
}
|
|
1419
1426
|
packagesLeft = packages.size;
|
|
1420
1427
|
runOnPackagesGroupedByDependencies(packages, function (packageGroup, dependencies) {
|
|
1421
1428
|
// console.log('Now checking: ' + chalk.blue(packageGroup.map((i) => i.packageName)));
|