lincd-cli 0.2.25 → 0.2.27

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.
@@ -57,6 +57,7 @@
57
57
  "@types/react-dom": "^18.0.6",
58
58
  "env-cmd": "^10.1.0",
59
59
  "lincd-cli": "^0.2",
60
- "nodemon": "^2.0.6"
60
+ "nodemon": "^2.0.6",
61
+ "pm2": "^5.3.0"
61
62
  }
62
63
  }
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ apps: [
3
+ {
4
+ name: '${hyphen_name}',
5
+ script: 'yarn run server:prod',
6
+ time: true,
7
+ log_date_format: 'DD-MM-YYYY HH:mm Z',
8
+ out_file: "./data/out.log",
9
+ error_file: "./data/error.log",
10
+ }
11
+ ],
12
+ };
@@ -134,7 +134,7 @@ var createApp = function (name, basePath) {
134
134
  // fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
135
135
  log("Creating new LINCD application '" + name + "'");
136
136
  //replace variables in some copied files
137
- replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/package.ts', 'frontend/src/App.scss.json', '.vscode/launch.json', 'frontend/src/components/Spinner.scss.json');
137
+ replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'pm2.config.js', 'frontend/src/App.tsx', 'frontend/src/package.ts', 'frontend/src/App.scss.json', '.vscode/launch.json', 'frontend/src/components/Spinner.scss.json');
138
138
  return [4 /*yield*/, hasYarnInstalled()];
139
139
  case 1:
140
140
  hasYarn = _b.sent();
@@ -183,11 +183,11 @@ function debugInfo() {
183
183
  // console.log(gruntConfig);
184
184
  // process.exit();
185
185
  // }
186
- if (gruntConfig && gruntConfig.analyse === true) {
187
- messages.forEach(function (message) {
188
- console.log(chalk_1["default"].cyan('Info: ') + message);
189
- });
190
- }
186
+ // if (gruntConfig && gruntConfig.analyse === true) {
187
+ messages.forEach(function (message) {
188
+ console.log(chalk_1["default"].cyan('Info: ') + message);
189
+ });
190
+ // }
191
191
  }
192
192
  function warn() {
193
193
  var messages = [];
@@ -353,7 +353,7 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
353
353
  // console.log(p.packageName,dependency.packageName,p===dependency)
354
354
  return p === dependency;
355
355
  });
356
- }).map(function (p) { return chalk_1["default"].red('\t- ' + p.packageName + '\n'); }).join(" "));
356
+ }).map(function (p) { return chalk_1["default"].red('\t- ' + ((p === null || p === void 0 ? void 0 : p.packageName) ? p.packageName : p.toString()) + '\n'); }).join(" "));
357
357
  // console.log(chalk.red(pkg.packageName)+' has not been built yet. Built dependencies:\n' + deps.filter(dependency => {
358
358
  // return Array.from(done).some(p => p.packageName === pkg.packageName)
359
359
  // }).map(p => chalk.green('\t- '+p.packageName+'\n')).join(" "))
@@ -1061,6 +1061,7 @@ var buildMetadata = function () { return __awaiter(void 0, void 0, void 0, funct
1061
1061
  _c.sent(); //{recursive:true} but not needed with fs-extra
1062
1062
  _loop_1 = function (packageCodeName, packagePath, lincdPackagePath, isAppPackage) {
1063
1063
  var errors = false;
1064
+ //TODO: check if this resolves, if not, skip it (for initial setup)
1064
1065
  Promise.resolve().then(function () { return __importStar(require('lincd-modules/lib/scripts/package-metadata.js')); }).then(function (script) { return __awaiter(void 0, void 0, void 0, function () {
1065
1066
  return __generator(this, function (_a) {
1066
1067
  switch (_a.label) {
@@ -1271,7 +1272,7 @@ var publishUpdated = function (test) {
1271
1272
  p = p
1272
1273
  .then(function (previousResult) {
1273
1274
  // progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.packageName);
1274
- // log('# Checking package ' + pckg.packageName);
1275
+ log('# Checking package ' + pckg.packageName);
1275
1276
  // log('# Requesting ' + 'yarn info '+pkg.packageName+' --json');
1276
1277
  // return execPromise('yarn info '+pkg.packageName+' --json').then((output:string) => {
1277
1278
  // console.log("Will be requesting npm view from this current working directory:\n"+process.cwd());
@@ -1285,13 +1286,17 @@ var publishUpdated = function (test) {
1285
1286
  return chalk_1["default"].gray(pckg.packageName + ' is private');
1286
1287
  // return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
1287
1288
  }
1289
+ console.log("testing npm");
1288
1290
  return (0, utils_1.execPromise)('npm info ' + pckg.packageName + ' --json')
1289
1291
  .then(function (output) { return __awaiter(_this, void 0, void 0, function () {
1290
- var info, lastPublish, lastPublishDate, lastCommitInfo, err_1;
1292
+ var info, lastPublish, lastPublishDate, lastCommitInfo, changedFiles, numberOfFilesChanges, err_1;
1291
1293
  return __generator(this, function (_a) {
1292
1294
  switch (_a.label) {
1293
1295
  case 0:
1294
- _a.trys.push([0, 3, , 4]);
1296
+ console.log("testing npm done");
1297
+ _a.label = 1;
1298
+ case 1:
1299
+ _a.trys.push([1, 4, , 5]);
1295
1300
  if (output == '' || output.includes('E404')) {
1296
1301
  debugInfo('Empty or 404 response from `npm info`. This package was probably not published before');
1297
1302
  // throw new Error('Empty response from `yarn info`. This pkg was probably not published before');
@@ -1303,14 +1308,14 @@ var publishUpdated = function (test) {
1303
1308
  else {
1304
1309
  info = JSON.parse(output);
1305
1310
  }
1306
- if (!info) return [3 /*break*/, 2];
1311
+ if (!info) return [3 /*break*/, 3];
1307
1312
  lastPublish = void 0;
1308
1313
  //yarn:
1309
1314
  // let lastPublish = info.data.time[info.data.version];
1310
1315
  lastPublish = info.time[info.version];
1311
1316
  lastPublishDate = new Date(lastPublish);
1312
1317
  return [4 /*yield*/, getLastCommitTime(pckg.path)];
1313
- case 1:
1318
+ case 2:
1314
1319
  lastCommitInfo = _a.sent();
1315
1320
  if (!lastCommitInfo) {
1316
1321
  shouldPublish = false;
@@ -1322,6 +1327,12 @@ var publishUpdated = function (test) {
1322
1327
  //NOTE: removed lastModified, because switching branches will say that the file was modified and cause everything to publish
1323
1328
  //SO: now you NEED TO commit before it picks up that you should publish
1324
1329
  shouldPublish = lastPublishDate.getTime() < lastCommitInfo.date.getTime();
1330
+ changedFiles = lastCommitInfo.changes.split("\n").filter(function (line) { return line.includes("|"); });
1331
+ numberOfFilesChanges = changedFiles.length;
1332
+ // console.log("CHECK "+lastCommitInfo.changes.includes("package.json")+" - "+numberOfFilesChanges)
1333
+ if (shouldPublish && lastCommitInfo.changes.includes("package.json") && numberOfFilesChanges === 1) {
1334
+ shouldPublish = false;
1335
+ }
1325
1336
  if (shouldPublish) {
1326
1337
  log(chalk_1["default"].magenta(pckg.packageName) + ' should be published because:');
1327
1338
  log(lastPublishDate.toDateString() +
@@ -1333,9 +1344,9 @@ var publishUpdated = function (test) {
1333
1344
  log(lastCommitInfo.changes);
1334
1345
  }
1335
1346
  }
1336
- _a.label = 2;
1337
- case 2: return [3 /*break*/, 4];
1338
- case 3:
1347
+ _a.label = 3;
1348
+ case 3: return [3 /*break*/, 5];
1349
+ case 4:
1339
1350
  err_1 = _a.sent();
1340
1351
  // var stats = fs.statSync(path.join(packageDirectory));
1341
1352
  // var files = fs.readdirSync(path.join(packageDirectory,'src'));
@@ -1343,11 +1354,11 @@ var publishUpdated = function (test) {
1343
1354
  console.warn('Returned JSON from npm: ' + output);
1344
1355
  // return previousResult + ' ' + chalk.red(pckg.packageName + ' failed: ' + err.message + '\n');
1345
1356
  return [2 /*return*/, chalk_1["default"].red(pckg.packageName + ' failed: ' + err_1.message)];
1346
- case 4:
1357
+ case 5:
1347
1358
  if (shouldPublish) {
1348
1359
  return [2 /*return*/, (0, exports.publishPackage)(pckg, test, info, version)];
1349
1360
  }
1350
- return [2 /*return*/, chalk_1["default"].green(pckg.packageName + ' latest version is up to date')];
1361
+ return [2 /*return*/, chalk_1["default"].blue(pckg.packageName) + ' latest version is up to date'];
1351
1362
  }
1352
1363
  });
1353
1364
  }); })["catch"](function (_a) {
@@ -1453,8 +1464,8 @@ var publishPackage = function (pkg, test, info, publishVersion) {
1453
1464
  console.log(res);
1454
1465
  return chalk_1["default"].red(pkg.packageName + ' failed\n');
1455
1466
  }
1456
- console.log(chalk_1["default"].green('Successfully published ' + pkg.path + ' ' + publishVersion));
1457
- return chalk_1["default"].green(pkg.packageName + ' published ' + publishVersion);
1467
+ console.log('Successfully published ' + chalk_1["default"].green(pkg.path) + ' ' + chalk_1["default"].magenta(publishVersion));
1468
+ return chalk_1["default"].green(pkg.packageName) + ' published ' + chalk_1["default"].magenta(publishVersion);
1458
1469
  })["catch"](function (_a) {
1459
1470
  var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
1460
1471
  console.log(chalk_1["default"].red('Failed to publish: ' + error.message));
@@ -1492,7 +1503,6 @@ var buildUpdated = function (back, target, target2, test) {
1492
1503
  return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
1493
1504
  var needRebuild;
1494
1505
  return __generator(this, function (_a) {
1495
- debugInfo('# Checking package ' + pkg.packageName);
1496
1506
  needRebuild = needsRebuilding(pkg, true);
1497
1507
  if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated) {
1498
1508
  needRebuild = true;
@@ -1609,23 +1619,39 @@ exports.executeCommandForEachPackage = executeCommandForEachPackage;
1609
1619
  var addCapacitor = function (basePath) {
1610
1620
  if (basePath === void 0) { basePath = process.cwd(); }
1611
1621
  return __awaiter(this, void 0, void 0, function () {
1612
- var targetFolder, pack;
1622
+ var targetFolder, envCmdPath, envCmd, pack;
1613
1623
  return __generator(this, function (_a) {
1614
1624
  switch (_a.label) {
1615
1625
  case 0:
1616
1626
  targetFolder = ensureFolderExists(basePath);
1617
1627
  log('Adding capacitor');
1618
1628
  fs_extra_1["default"].copySync(path_1["default"].join(__dirname, '..', 'defaults', 'app-static'), targetFolder);
1629
+ envCmdPath = path_1["default"].resolve(basePath, '.env-cmdrc.json');
1630
+ envCmd = JSON.parse(fs_extra_1["default"].readFileSync(envCmdPath, { encoding: 'utf8' }));
1631
+ envCmd['static-dev'] = {
1632
+ "NODE_ENV": "production",
1633
+ "SITE_ROOT": "http://localhost:4000",
1634
+ "DATA_ROOT": "http://localhost:4000/data",
1635
+ "OUTPUT_PATH": "./frontend/web/assets",
1636
+ "ASSET_PATH": "./assets/",
1637
+ "ENTRY_PATH": "./frontend/src/index-static.tsx"
1638
+ };
1639
+ fs_extra_1["default"].writeFile(envCmdPath, JSON.stringify(envCmd, null, 2));
1640
+ log('Edited .env-cmdrc.json');
1619
1641
  pack = (0, utils_1.getPackageJSON)(basePath);
1620
1642
  pack.scripts['build-static'] = 'env-cmd -e static-dev node frontend/scripts/build.js';
1621
- fs_extra_1["default"].writeFile(path_1["default"].resolve(basePath, 'package.json'), JSON.stringify(pack));
1622
- return [4 /*yield*/, (0, utils_1.execPromise)("yarn add -W -D @capacitor/cli", false, false, null, true)];
1643
+ pack.scripts['cap:android'] = 'yarn cap open android';
1644
+ pack.scripts['cap:sync'] = 'yarn cap sync';
1645
+ fs_extra_1["default"].writeFile(path_1["default"].resolve(basePath, 'package.json'), JSON.stringify(pack, null, 2));
1646
+ log('Added new run script to package.json');
1647
+ return [4 /*yield*/, (0, utils_1.execPromise)("yarn add -D @capacitor/cli", true, false, null, true)];
1623
1648
  case 1:
1624
1649
  _a.sent();
1625
- return [4 /*yield*/, (0, utils_1.execPromise)("yarn add -W @capacitor/android @capacitor/core @capacitor/geolocation @capacitor/ios @capacitor/push-notifications", false, false, null, true)];
1650
+ return [4 /*yield*/, (0, utils_1.execPromise)("yarn add @capacitor/android @capacitor/core @capacitor/geolocation @capacitor/ios @capacitor/push-notifications", false, false, null, true)];
1626
1651
  case 2:
1627
1652
  _a.sent();
1628
- log('Done! Run `yarn build-static` to generate static bundles. Then `yarn cap add android` or `yarn cap add ios`');
1653
+ log("Done! Run ".concat(chalk_1["default"].magenta('yarn build-static'), " to generate static bundles. Then run ").concat(chalk_1["default"].magenta('yarn cap add android'), " and/or ").concat(chalk_1["default"].magenta('yarn cap add ios'), "')"));
1654
+ log("Also see the app icons in /frontend/web");
1629
1655
  return [2 /*return*/];
1630
1656
  }
1631
1657
  });
package/lib/cli.js CHANGED
@@ -132,7 +132,7 @@ program
132
132
  .argument('<name>', 'the name of the package. Can be a part of the name.')
133
133
  .argument('[command]', 'the lincd command you want to execute. Like dev or build')
134
134
  .argument('[args...]', 'the additional arguments of that command');
135
- program.command('add-capacitor').action(function () {
135
+ program.command('enable-capacitor').action(function () {
136
136
  (0, cli_methods_1.addCapacitor)();
137
137
  });
138
138
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lincd-cli",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "description": "Command line tools for the lincd.js library",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -59,8 +59,7 @@
59
59
  "grunt-webpack": "^5.0.0",
60
60
  "license-info-webpack-plugin": "^3.0.0",
61
61
  "lincd": "^0.5",
62
- "lincd-app": "^0.1",
63
- "lincd-jsonld": "^0.1.13",
62
+ "lincd-jsonld": "^0.1.20",
64
63
  "lincd-modules": "^0.1",
65
64
  "load-grunt-tasks": "^5.1.0",
66
65
  "mini-css-extract-plugin": "^2.7.5",
@@ -1,10 +0,0 @@
1
- {
2
- "static-dev": {
3
- "NODE_ENV": "production",
4
- "SITE_ROOT": "http://localhost:4000",
5
- "DATA_ROOT": "https://coolbock.lincd.org/data",
6
- "OUTPUT_PATH" : "./frontend/web/assets",
7
- "ASSET_PATH" : "./assets/",
8
- "ENTRY_PATH" : "./frontend/src/index-static.tsx"
9
- }
10
- }
@@ -1 +0,0 @@
1
- nodeLinker: "node-modules"