lincd-cli 1.1.8 → 1.1.9

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 (97) hide show
  1. package/defaults/app-static/src/index-static.tsx +3 -3
  2. package/defaults/app-with-backend/.env-cmdrc.json +4 -1
  3. package/defaults/app-with-backend/package.json +9 -8
  4. package/defaults/app-with-backend/scripts/storage-config.js +2 -2
  5. package/defaults/app-with-backend/src/package.ts +2 -1
  6. package/defaults/component.tsx +3 -1
  7. package/defaults/package/package.json +2 -2
  8. package/defaults/package/src/index.ts +0 -1
  9. package/defaults/package/src/ontologies/example-ontology.ts +3 -10
  10. package/defaults/package/src/package.ts +3 -11
  11. package/defaults/set-component.tsx +5 -2
  12. package/defaults/shape.ts +2 -2
  13. package/lib/{cjs/cli-methods.js → cli-methods.js} +291 -665
  14. package/lib/cli-methods.js.map +1 -0
  15. package/lib/{esm/cli.js → cli.js} +44 -59
  16. package/lib/cli.js.map +1 -0
  17. package/lib/{cjs/config-grunt.cjs → config-grunt.js} +13 -15
  18. package/lib/config-grunt.js.map +1 -0
  19. package/lib/config-webpack-app.js +367 -0
  20. package/lib/config-webpack-app.js.map +1 -0
  21. package/lib/{esm/config-webpack.js → config-webpack.js} +39 -27
  22. package/lib/config-webpack.js.map +1 -0
  23. package/lib/{cjs/index.js → index.js} +5 -3
  24. package/lib/index.js.map +1 -0
  25. package/lib/{cjs/interfaces.js.map → interfaces.js.map} +1 -1
  26. package/lib/metadata.js +149 -0
  27. package/lib/metadata.js.map +1 -0
  28. package/lib/plugins/check-imports.js.map +1 -0
  29. package/lib/{esm/plugins → plugins}/declaration-plugin.js +8 -9
  30. package/lib/plugins/declaration-plugin.js.map +1 -0
  31. package/lib/{esm/plugins → plugins}/externalise-modules.js +6 -5
  32. package/lib/plugins/externalise-modules.js.map +1 -0
  33. package/lib/plugins/watch-run.js.map +1 -0
  34. package/lib/{cjs/utils.js → utils.js} +18 -23
  35. package/lib/utils.js.map +1 -0
  36. package/package.json +15 -54
  37. package/defaults/app-static/.env-cmdrc.json +0 -17
  38. package/defaults/app-static/package.json +0 -8
  39. package/defaults/package/src/types.d.ts +0 -9
  40. package/defaults/package/tsconfig-cjs.json +0 -8
  41. package/defaults/package/tsconfig-esm.json +0 -9
  42. package/lib/cjs/cli-methods.js.map +0 -1
  43. package/lib/cjs/cli.js +0 -202
  44. package/lib/cjs/cli.js.map +0 -1
  45. package/lib/cjs/config-grunt.cjs.map +0 -1
  46. package/lib/cjs/config-webpack-app.js +0 -353
  47. package/lib/cjs/config-webpack-app.js.map +0 -1
  48. package/lib/cjs/config-webpack.js +0 -436
  49. package/lib/cjs/config-webpack.js.map +0 -1
  50. package/lib/cjs/index.js.map +0 -1
  51. package/lib/cjs/loaders/css-loader.mjs +0 -82
  52. package/lib/cjs/loaders/css-loader.mjs.map +0 -1
  53. package/lib/cjs/loaders/register.js +0 -6
  54. package/lib/cjs/loaders/register.js.map +0 -1
  55. package/lib/cjs/metadata.js +0 -155
  56. package/lib/cjs/metadata.js.map +0 -1
  57. package/lib/cjs/package.json +0 -141
  58. package/lib/cjs/plugins/check-imports.js.map +0 -1
  59. package/lib/cjs/plugins/declaration-plugin.js +0 -275
  60. package/lib/cjs/plugins/declaration-plugin.js.map +0 -1
  61. package/lib/cjs/plugins/externalise-modules.js +0 -190
  62. package/lib/cjs/plugins/externalise-modules.js.map +0 -1
  63. package/lib/cjs/plugins/watch-run.js.map +0 -1
  64. package/lib/cjs/utils.js.map +0 -1
  65. package/lib/esm/cli-methods.js +0 -1966
  66. package/lib/esm/cli-methods.js.map +0 -1
  67. package/lib/esm/cli.js.map +0 -1
  68. package/lib/esm/config-grunt.cjs +0 -270
  69. package/lib/esm/config-grunt.cjs.map +0 -1
  70. package/lib/esm/config-webpack-app.js +0 -326
  71. package/lib/esm/config-webpack-app.js.map +0 -1
  72. package/lib/esm/config-webpack.js.map +0 -1
  73. package/lib/esm/index.js +0 -9
  74. package/lib/esm/index.js.map +0 -1
  75. package/lib/esm/interfaces.js +0 -2
  76. package/lib/esm/interfaces.js.map +0 -1
  77. package/lib/esm/loaders/css-loader.mjs +0 -75
  78. package/lib/esm/loaders/css-loader.mjs.map +0 -1
  79. package/lib/esm/loaders/register.js +0 -4
  80. package/lib/esm/loaders/register.js.map +0 -1
  81. package/lib/esm/metadata.js +0 -155
  82. package/lib/esm/metadata.js.map +0 -1
  83. package/lib/esm/package.json +0 -141
  84. package/lib/esm/plugins/check-imports.js +0 -65
  85. package/lib/esm/plugins/check-imports.js.map +0 -1
  86. package/lib/esm/plugins/declaration-plugin.js.map +0 -1
  87. package/lib/esm/plugins/externalise-modules.js.map +0 -1
  88. package/lib/esm/plugins/watch-run.js +0 -44
  89. package/lib/esm/plugins/watch-run.js.map +0 -1
  90. package/lib/esm/utils.js +0 -479
  91. package/lib/esm/utils.js.map +0 -1
  92. package/tsconfig-cjs.json +0 -9
  93. package/tsconfig-esm.json +0 -10
  94. /package/{expose-grunt.cjs → expose-grunt.js} +0 -0
  95. /package/lib/{cjs/interfaces.js → interfaces.js} +0 -0
  96. /package/lib/{cjs/plugins → plugins}/check-imports.js +0 -0
  97. /package/lib/{cjs/plugins → plugins}/watch-run.js +0 -0
@@ -1,50 +1,24 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.removeOldFiles = exports.executeCommandForPackage = exports.addCapacitor = exports.addLinesToFile = exports.executeCommandForEachPackage = exports.buildUpdated = exports.publishPackage = exports.publishUpdated = exports.compilePackage = exports.buildPackage = exports.register = exports.createPackage = exports.upgradePackages = exports.buildApp = exports.startServer = exports.ensureEnvironmentLoaded = exports.depCheck = exports.depCheckStaged = exports.checkImports = exports.createComponent = exports.createSetComponent = exports.createShape = exports.getScriptDir = exports.setNameVariables = exports.createOntology = exports.getLincdPackages = exports.buildAll = exports.developPackage = exports.warn = exports.createApp = void 0;
6
+ exports.executeCommandForPackage = exports.addCapacitor = exports.addLinesToFile = exports.executeCommandForEachPackage = exports.buildUpdated = exports.publishPackage = exports.publishUpdated = exports.buildPackage = exports.removeOldFiles = exports.register = exports.createPackage = exports.buildApp = exports.startServer = exports.ensureEnvironmentLoaded = exports.depCheck = exports.depCheckStaged = exports.checkImports = exports.createComponent = exports.createSetComponent = exports.createShape = exports.setNameVariables = exports.createOntology = exports.getLincdPackages = exports.buildAll = exports.developPackage = exports.warn = exports.createApp = void 0;
30
7
  const chalk_1 = __importDefault(require("chalk"));
31
8
  const child_process_1 = require("child_process");
32
9
  const depcheck_1 = __importDefault(require("depcheck"));
33
- const get_env_vars_js_1 = require("env-cmd/dist/get-env-vars.js");
10
+ const get_env_vars_1 = require("env-cmd/dist/get-env-vars");
34
11
  const fs_extra_1 = __importDefault(require("fs-extra"));
35
- const path_1 = __importStar(require("path"));
36
- const utils_js_1 = require("./utils.js");
12
+ const path_1 = __importDefault(require("path"));
13
+ const utils_1 = require("./utils");
37
14
  const fs_1 = require("fs");
38
15
  const find_nearest_package_json_1 = require("find-nearest-package-json");
39
- const LinkedFileStorage_1 = require("lincd/utils/LinkedFileStorage");
40
- // import pkg from 'lincd/utils/LinkedFileStorage';
41
- // const { LinkedFileStorage } = pkg;
42
16
  // const config = require('lincd-server/site.webpack.config');
43
- const glob_1 = require("glob");
44
- const webpack_1 = __importDefault(require("webpack"));
45
- const staged_git_files_1 = __importDefault(require("staged-git-files"));
46
- const ora_1 = __importDefault(require("ora"));
17
+ var glob = require('glob');
47
18
  var variables = {};
19
+ var open = require('open');
20
+ var stagedGitFiles = require('staged-git-files');
21
+ const webpack = require('webpack');
48
22
  const createApp = async (name, basePath = process.cwd()) => {
49
23
  if (!name) {
50
24
  console.warn('Please provide a name as the first argument');
@@ -63,21 +37,21 @@ const createApp = async (name, basePath = process.cwd()) => {
63
37
  fs_extra_1.default.renameSync(path_1.default.join(targetFolder, 'gitignore.template'), path_1.default.join(targetFolder, '.gitignore'));
64
38
  fs_extra_1.default.renameSync(path_1.default.join(targetFolder, 'yarnrc.yml.template'), path_1.default.join(targetFolder, '.yarnrc.yml'));
65
39
  // fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
66
- log('Creating new LINCD application \'' + name + '\'');
40
+ log("Creating new LINCD application '" + name + "'");
67
41
  //replace variables in some copied files
68
42
  await replaceVariablesInFolder(targetFolder);
69
43
  let hasYarn = await hasYarnInstalled();
70
44
  let installCommand = hasYarn
71
45
  ? 'export NODE_OPTIONS="--no-network-family-autoselection" && yarn install'
72
46
  : 'npm install';
73
- await (0, utils_js_1.execp)(`cd ${hyphenName} && ${installCommand}`, true).catch((err) => {
47
+ await (0, utils_1.execp)(`cd ${hyphenName} && ${installCommand}`, true).catch((err) => {
74
48
  console.warn('Could not install dependencies or start application');
75
49
  });
76
50
  log(`Your LINCD App is ready at ${chalk_1.default.blueBright(targetFolder)}`, `To start, run\n${chalk_1.default.blueBright(`cd ${hyphenName}`)} and then ${chalk_1.default.blueBright((hasYarn ? 'yarn' : 'npm') + ' start')}`);
77
51
  };
78
52
  exports.createApp = createApp;
79
53
  function logHelp() {
80
- (0, utils_js_1.execp)('yarn exec lincd help');
54
+ (0, utils_1.execp)('yarn exec lincd help');
81
55
  }
82
56
  function log(...messages) {
83
57
  messages.forEach((message) => {
@@ -90,7 +64,7 @@ function progressUpdate(message) {
90
64
  }
91
65
  function warn(...messages) {
92
66
  messages.forEach((message) => {
93
- console.log(chalk_1.default.redBright('Warning: ') + message);
67
+ console.log(chalk_1.default.magenta('Warning: ') + message);
94
68
  // console.log(chalk.red(message));
95
69
  });
96
70
  }
@@ -166,7 +140,7 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
166
140
  //get dependencies of each package
167
141
  let leastDependentPackage;
168
142
  lincdPackages.forEach((pkg) => {
169
- var pack = (0, utils_js_1.getPackageJSON)(pkg.path);
143
+ var pack = (0, utils_1.getPackageJSON)(pkg.path);
170
144
  if (pack) {
171
145
  //get lincd related dependencies and get the actual package details from the package map by removing '@dacore/' from the package name
172
146
  let packageDependencies = Object.keys(pack.dependencies)
@@ -191,17 +165,9 @@ function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStack
191
165
  let startStack = [leastDependentPackage];
192
166
  const runPackage = (runFunction, pck) => {
193
167
  return runFunction(pck)
194
- .catch((errorObj) => {
195
- if (errorObj.error) {
196
- let { error, stdout, stderr } = errorObj;
197
- warn('Uncaught exception whilst running parallel function on ' +
198
- pck.packageName, (error === null || error === void 0 ? void 0 : error.message) ? error.message : error === null || error === void 0 ? void 0 : error.toString());
199
- }
200
- else {
201
- warn('Uncaught exception whilst running parallel function on ' +
202
- pck.packageName, errorObj === null || errorObj === void 0 ? void 0 : errorObj.toString());
203
- process.exit();
204
- }
168
+ .catch(({ error, stdout, stderr }) => {
169
+ warn('Uncaught exception whilst running parallel function on ' +
170
+ pck.packageName, error.message);
205
171
  // warn(chalk.red(pck.packageName+' failed:'));
206
172
  // console.log(stdout);
207
173
  })
@@ -370,10 +336,10 @@ function buildAll(options) {
370
336
  // let packagesLeft = lincdPackages.size - done.size;
371
337
  runOnPackagesGroupedByDependencies(lincdPackages, (packageGroup, dependencies) => {
372
338
  if (done.size > 0) {
373
- (0, utils_js_1.debugInfo)(chalk_1.default.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
339
+ (0, utils_1.debugInfo)(chalk_1.default.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
374
340
  // log(stack);
375
341
  }
376
- (0, utils_js_1.debugInfo)('Now building: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
342
+ (0, utils_1.debugInfo)('Now building: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
377
343
  return async (pkg) => {
378
344
  let command;
379
345
  let skipping = false;
@@ -392,119 +358,50 @@ function buildAll(options) {
392
358
  }
393
359
  //unless told otherwise, build the package
394
360
  if (!command) {
395
- command = (0, exports.buildPackage)(null, null, path_1.default.join(process.cwd(), pkg.path), false);
396
- // command = execPromise(
397
- // 'cd ' + pkg.path + ' && yarn exec lincd build',
398
- // // (target ? ' ' + target : '') +
399
- // // (target2 ? ' ' + target2 : ''),
400
- // false,
401
- // false,
402
- // {},
403
- // false,
404
- // );
361
+ command = (0, utils_1.execPromise)('cd ' + pkg.path + ' && yarn exec lincd build',
362
+ // (target ? ' ' + target : '') +
363
+ // (target2 ? ' ' + target2 : ''),
364
+ false, false, {}, false);
405
365
  log(chalk_1.default.cyan('Building ' + pkg.packageName));
406
366
  process.stdout.write(packagesLeft + ' packages left\r');
407
367
  }
408
- return command.then(res => {
409
- //empty string or true is success
410
- //false is success with warnings
411
- //any other string is the build error text
412
- //undefined result means it failed
413
- // if (res !== '' && res !== true && res !== false) {
414
- if (typeof res === 'undefined') {
415
- failedModules.push(pkg.packageName);
416
- let dependentModules = getDependentPackages(dependencies, pkg);
417
- if (dependentModules.length > 0) {
418
- printBuildResults(failedModules, done);
419
- console.log('Stopping build process because an error occurred whilst building ' +
420
- pkg.packageName +
421
- ', which ' +
422
- dependentModules.length +
423
- ' other packages depend on.'); //"+dependentModules.map(d => d.packageName).join(", ")));
424
- log('Run ' +
425
- chalk_1.default.greenBright(`lincd build-all --from=${pkg.packageName}`) +
426
- ' to build only the remaining packages'); //"+dependentModules.map(d => d.packageName).join(", ")));
427
- process.exit(1);
428
- }
368
+ return command
369
+ .catch(({ error, stdout, stderr }) => {
370
+ //this prints out the webpack output, including the build errors
371
+ warn('Failed to build ' + pkg.packageName);
372
+ console.log(stdout);
373
+ failedModules.push(pkg.packageName);
374
+ let dependentModules = getDependentPackages(dependencies, pkg);
375
+ if (dependentModules.length > 0) {
376
+ printBuildResults(failedModules, done);
377
+ console.log(chalk_1.default.magenta('Stopping build process because an error occurred whilst building ' +
378
+ pkg.packageName +
379
+ ', which ' +
380
+ dependentModules.length +
381
+ ' other packages depend on.')); //"+dependentModules.map(d => d.packageName).join(", ")));
382
+ console.log(chalk_1.default.cyanBright('tip ') +
383
+ 'Run ' +
384
+ chalk_1.default.green(`lincd build-all --from=${pkg.packageName}`) +
385
+ ' to build only the remaining packages'); //"+dependentModules.map(d => d.packageName).join(", ")));
386
+ process.exit(1);
429
387
  }
430
- else {
431
- if (!skipping) {
432
- log(chalk_1.default.green('Built ' + pkg.packageName) + (res === false ? chalk_1.default.redBright(' (with warnings)') : ''));
433
- }
434
- done.add(pkg);
435
- packagesLeft--;
436
- // log(chalk.magenta(packagesLeft + ' packages left'));
437
- process.stdout.write(packagesLeft + ' packages left\r');
438
- if (packagesLeft == 0) {
439
- printBuildResults(failedModules, done);
440
- if (failedModules.length > 0) {
441
- process.exit(1);
442
- }
388
+ })
389
+ .then((res) => {
390
+ if (!skipping) {
391
+ log(chalk_1.default.green('Built ' + pkg.packageName));
392
+ }
393
+ done.add(pkg);
394
+ packagesLeft--;
395
+ // log(chalk.magenta(packagesLeft + ' packages left'));
396
+ process.stdout.write(packagesLeft + ' packages left\r');
397
+ if (packagesLeft == 0) {
398
+ printBuildResults(failedModules, done);
399
+ if (failedModules.length > 0) {
400
+ process.exit(1);
443
401
  }
444
- return res;
445
402
  }
446
- })
447
- .catch(({ error, stdout, stderr }) => {
448
- warn(chalk_1.default.red('Failed to build ' + pkg.packageName));
449
- console.log(stdout);
450
- process.exit(1);
451
- // let dependentModules = getDependentP
403
+ return res;
452
404
  });
453
- //undefined result means it failed
454
- /*if (typeof res === 'undefined')
455
- {
456
- // .catch(({ error,stdout,stderr }) => {
457
- //this prints out the webpack output, including the build errors
458
- // warn('Failed to build ' + pkg.packageName);
459
- // console.log(stdout);
460
- failedModules.push(pkg.packageName);
461
- let dependentModules = getDependentPackages(dependencies,pkg);
462
- if (dependentModules.length > 0)
463
- {
464
- printBuildResults(failedModules,done);
465
- console.log(
466
- 'Stopping build process because an error occurred whilst building ' +
467
- pkg.packageName +
468
- ', which ' +
469
- dependentModules.length +
470
- ' other packages depend on.',
471
- ); //"+dependentModules.map(d => d.packageName).join(", ")));
472
- log(
473
- 'Run ' +
474
- chalk.greenBright(`lincd build-all --from=${pkg.packageName}`) +
475
- ' to build only the remaining packages',
476
- ); //"+dependentModules.map(d => d.packageName).join(", ")));
477
- process.exit(1);
478
- }
479
- }
480
- else //true is successful build, false is successful but with warnings
481
- {
482
- //successful build
483
- // })
484
- // .then((res) => {
485
- if (!skipping)
486
- {
487
- log(chalk.green('Built ' + pkg.packageName)+(res === false ? chalk.redBright(' (with warnings)') : ''));
488
- }
489
- done.add(pkg);
490
-
491
- packagesLeft--;
492
- // log(chalk.magenta(packagesLeft + ' packages left'));
493
- process.stdout.write(packagesLeft + ' packages left\r');
494
- if (packagesLeft == 0)
495
- {
496
- printBuildResults(failedModules,done);
497
- if (failedModules.length > 0)
498
- {
499
- process.exit(1);
500
- }
501
- }
502
-
503
- return res;
504
- }*/
505
- // }).catch(err => {
506
- // console.log(err);
507
- // })
508
405
  };
509
406
  }, (dependencies) => {
510
407
  //if no more packages to build but we never started building...
@@ -576,11 +473,11 @@ function getLocalLincdModules(rootPath = './') {
576
473
  });
577
474
  }
578
475
  function getLincdPackages(rootPath = process.cwd()) {
579
- let pack = (0, utils_js_1.getPackageJSON)();
476
+ let pack = (0, utils_1.getPackageJSON)();
580
477
  if (!pack || !pack.workspaces) {
581
478
  for (let i = 0; i <= 3; i++) {
582
479
  rootPath = path_1.default.join(process.cwd(), ...Array(i).fill('..'));
583
- pack = (0, utils_js_1.getPackageJSON)(rootPath);
480
+ pack = (0, utils_1.getPackageJSON)(rootPath);
584
481
  if (pack && pack.workspaces) {
585
482
  // log('Found workspace at '+packagePath);
586
483
  break;
@@ -643,7 +540,7 @@ const createOntology = async (prefix, uriBase, basePath = process.cwd()) => {
643
540
  setVariable('uri_base', uriBase);
644
541
  let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(prefix);
645
542
  //copy ontology accessor file
646
- log('Creating files for ontology \'' + prefix + '\'');
543
+ log("Creating files for ontology '" + prefix + "'");
647
544
  let targetFile = path_1.default.join(targetFolder, hyphenName + '.ts');
648
545
  fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
649
546
  //copy data files
@@ -661,10 +558,10 @@ const createOntology = async (prefix, uriBase, basePath = process.cwd()) => {
661
558
  }
662
559
  };
663
560
  exports.createOntology = createOntology;
664
- const addLineToIndex = function (line, insertMatchString, root = process.cwd(), insertAtStart = false) {
561
+ const addLineToIndex = function (line, insertMatchString) {
665
562
  //import ontology in index
666
563
  let indexPath = ['index.ts', 'index.tsx']
667
- .map((f) => path_1.default.join(root, 'src', f))
564
+ .map((f) => path_1.default.join('src', f))
668
565
  .find((indexFileName) => {
669
566
  return fs_extra_1.default.existsSync(indexFileName);
670
567
  });
@@ -673,9 +570,8 @@ const addLineToIndex = function (line, insertMatchString, root = process.cwd(),
673
570
  let lines = indexContents.split(/\n/g);
674
571
  let newContents;
675
572
  for (var key in lines) {
676
- //if the match string is found
677
573
  if (lines[key].indexOf(insertMatchString) !== -1) {
678
- //add the new line after this line
574
+ //remove lines after this line and insert new line in its place
679
575
  lines[key] += `\n${line}`;
680
576
  newContents = lines.join('\n');
681
577
  // log("Found at "+key,lines,newContents);
@@ -683,12 +579,7 @@ const addLineToIndex = function (line, insertMatchString, root = process.cwd(),
683
579
  }
684
580
  }
685
581
  if (!newContents) {
686
- if (insertAtStart) {
687
- newContents = `${line}\n${indexContents}`;
688
- }
689
- else {
690
- newContents = `${indexContents}\n${line}`;
691
- }
582
+ newContents = indexContents + `\n${line}`;
692
583
  // log("Added at end",newContents);
693
584
  }
694
585
  fs_extra_1.default.writeFileSync(indexPath, newContents);
@@ -702,13 +593,13 @@ const replaceVariablesInFiles = function (...files) {
702
593
  };
703
594
  const replaceVariablesInFolder = function (folder) {
704
595
  //get all files in folder, including files that start with a dot
705
- glob_1.glob(folder + '/**/*', { dot: true, nodir: true }, async function (err, files) {
596
+ glob(folder + '/**/*', { dot: true, nodir: true }, function (err, files) {
706
597
  if (err) {
707
598
  console.log('Error', err);
708
599
  }
709
600
  else {
710
601
  // console.log(files);
711
- await Promise.all(files.map((file) => {
602
+ return Promise.all(files.map((file) => {
712
603
  return replaceVariablesInFile(file);
713
604
  }));
714
605
  }
@@ -718,7 +609,7 @@ const replaceVariablesInFilesWithRoot = function (root, ...files) {
718
609
  return replaceVariablesInFiles(...files.map((f) => path_1.default.join(root, f)));
719
610
  };
720
611
  const hasYarnInstalled = async function () {
721
- let version = (await (0, utils_js_1.execPromise)('yarn --version').catch((err) => {
612
+ let version = (await (0, utils_1.execPromise)('yarn --version').catch((err) => {
722
613
  console.log('yarn probably not working');
723
614
  return '';
724
615
  }));
@@ -774,21 +665,6 @@ function getSourceFolder(basePath = process.cwd()) {
774
665
  return path_1.default.join(basePath, 'src');
775
666
  }
776
667
  }
777
- /**
778
- * get __dirname for either ESM/CJS
779
- */
780
- const getScriptDir = () => {
781
- // @ts-ignore
782
- if (typeof __dirname !== 'undefined') {
783
- // @ts-ignore
784
- return __dirname;
785
- }
786
- else {
787
- // @ts-ignore
788
- return (0, path_1.dirname)(import.meta.url).replace('file:/', '');
789
- }
790
- };
791
- exports.getScriptDir = getScriptDir;
792
668
  const createShape = async (name, basePath = process.cwd()) => {
793
669
  let sourceFolder = getSourceFolder(basePath);
794
670
  let targetFolder = ensureFolderExists(sourceFolder, 'shapes');
@@ -796,7 +672,7 @@ const createShape = async (name, basePath = process.cwd()) => {
796
672
  //copy default shape file
797
673
  // log("Creating files for shape '" + name + "'");
798
674
  let targetFile = path_1.default.join(targetFolder, hyphenName + '.ts');
799
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'shape.ts'), targetFile);
675
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'shape.ts'), targetFile);
800
676
  //replace variables in some of the copied files
801
677
  await replaceVariablesInFiles(targetFile);
802
678
  log(`Created a new shape class template in ${chalk_1.default.magenta(targetFile.replace(basePath, ''))}`);
@@ -812,11 +688,11 @@ const createSetComponent = async (name, basePath = process.cwd()) => {
812
688
  let targetFolder = ensureFolderExists(basePath, 'src', 'components');
813
689
  let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(name);
814
690
  //copy default shape file
815
- log('Creating files for set component \'' + name + '\'');
691
+ log("Creating files for set component '" + name + "'");
816
692
  let targetFile = path_1.default.join(targetFolder, hyphenName + '.tsx');
817
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'set-component.tsx'), targetFile);
693
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'set-component.tsx'), targetFile);
818
694
  let targetFile2 = path_1.default.join(targetFolder, hyphenName + '.scss');
819
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'component.scss'), targetFile2);
695
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'component.scss'), targetFile2);
820
696
  //replace variables in some of the copied files
821
697
  await replaceVariablesInFiles(targetFile, targetFile2);
822
698
  let indexPath = addLineToIndex(`import './components/${hyphenName}';`, 'components');
@@ -828,11 +704,11 @@ const createComponent = async (name, basePath = process.cwd()) => {
828
704
  let targetFolder = ensureFolderExists(sourceFolder, 'components');
829
705
  let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(name);
830
706
  //copy default shape file
831
- log('Creating files for component \'' + name + '\'');
707
+ log("Creating files for component '" + name + "'");
832
708
  let targetFile = path_1.default.join(targetFolder, hyphenName + '.tsx');
833
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', 'defaults', 'component.tsx'), targetFile);
709
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'component.tsx'), targetFile);
834
710
  let targetFile2 = path_1.default.join(targetFolder, hyphenName + '.scss');
835
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', 'defaults', 'component.scss'), targetFile2);
711
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'component.scss'), targetFile2);
836
712
  //replace variables in some of the copied files
837
713
  await replaceVariablesInFiles(targetFile, targetFile2);
838
714
  log(`Created a new component template in ${chalk_1.default.magenta(targetFile.replace(basePath, ''))}`, `Created component stylesheet template in ${chalk_1.default.magenta(targetFile2.replace(basePath, ''))}`);
@@ -865,10 +741,10 @@ invalidImports = new Map()) => {
865
741
  // - .tsx
866
742
  continue;
867
743
  }
868
- const allImports = await (0, utils_js_1.getFileImports)(filename);
744
+ const allImports = await (0, utils_1.getFileImports)(filename);
869
745
  const lincdImports = allImports.filter((i) => i.includes('lincd') || i.includes('..'));
870
746
  lincdImports.forEach((i) => {
871
- if (!(0, utils_js_1.isValidLINCDImport)(i, depth)) {
747
+ if (!(0, utils_1.isValidLINCDImport)(i, depth)) {
872
748
  if (!invalidImports.has(filename)) {
873
749
  invalidImports.set(filename, []);
874
750
  }
@@ -876,36 +752,26 @@ invalidImports = new Map()) => {
876
752
  }
877
753
  });
878
754
  }
879
- let res = '';
880
755
  // All recursion must have finished, display any errors
881
756
  if (depth === 0 && invalidImports.size > 0) {
882
- res += chalk_1.default.red('Invalid imports found.\n');
757
+ console.warn(chalk_1.default.red('\n' + 'Invalid imports found. See fixes below:'));
758
+ console.warn(chalk_1.default.red(" - For relative imports, ensure you don't import outside of the /src/ folder"));
759
+ console.warn(chalk_1.default.red(' - For lincd imports, access the /lib/ folder instead of /src/'));
883
760
  invalidImports.forEach((value, key) => {
884
- // res += '- '+chalk.blueBright(key.split('/').pop()) + ':\n';
885
- value.forEach((i) => {
886
- res += chalk_1.default.red(key.split('/').pop() + ' imports from \'' + i + '\'\n');
887
- if (i.indexOf('../../') === 0) {
888
- res +=
889
- 'To fix: import from the NPM package directly.\n';
890
- }
891
- else if ('/src/') {
892
- res += 'To fix: you likely need to replace /src with /lib\n';
893
- }
894
- });
761
+ console.info(chalk_1.default.red('\nFound in file ') + chalk_1.default.blue(key) + chalk_1.default.red(':'));
762
+ value.forEach((i) => console.warn(chalk_1.default.red("- '" + i + "'")));
895
763
  });
896
- throw res;
897
- // process.exit(1);
764
+ process.exit(1);
898
765
  }
899
766
  else if (depth === 0 && invalidImports.size === 0) {
900
- // console.info('All imports OK');
901
- // process.exit(0);
902
- return true;
767
+ console.info('All imports OK');
768
+ process.exit(0);
903
769
  }
904
770
  };
905
771
  exports.checkImports = checkImports;
906
772
  const depCheckStaged = async () => {
907
773
  console.log('Checking dependencies of staged files');
908
- (0, staged_git_files_1.default)(async function (err, results) {
774
+ stagedGitFiles(async function (err, results) {
909
775
  const packages = new Set();
910
776
  await Promise.all(results.map(async (file) => {
911
777
  // console.log('STAGED: ', file.filename);
@@ -925,54 +791,50 @@ const depCheckStaged = async () => {
925
791
  });
926
792
  };
927
793
  exports.depCheckStaged = depCheckStaged;
928
- const depCheck = async (packagePath = process.cwd()) => {
929
- return new Promise((resolve, reject) => {
930
- (0, depcheck_1.default)(packagePath, {}, (results) => {
931
- if (results.missing) {
932
- let lincdPackages = getLocalLincdModules();
933
- let missing = Object.keys(results.missing);
934
- //filter out missing types, if it builds we're not too concerned about that at the moment?
935
- //especially things like @types/react, @types/react-dom, @types/node (they are added elsewhere?)
936
- // missing = missing.filter(m => m.indexOf('@types/') === 0);
937
- //currently react is not an explicit dependency, but we should add it as a peer dependency
938
- missing.splice(missing.indexOf('react'), 1);
939
- let missingLincdPackages = missing.filter((missingDep) => {
940
- return lincdPackages.some((lincdPackage) => {
941
- return lincdPackage.packageName === missingDep;
942
- });
794
+ const depCheck = async (path = process.cwd()) => {
795
+ (0, depcheck_1.default)(path, {}, (results) => {
796
+ if (results.missing) {
797
+ let lincdPackages = getLocalLincdModules();
798
+ let missing = Object.keys(results.missing);
799
+ //filter out missing types, if it builds we're not too concerned about that at the moment?
800
+ //especially things like @types/react, @types/react-dom, @types/node (they are added elsewhere?)
801
+ // missing = missing.filter(m => m.indexOf('@types/') === 0);
802
+ //currently react is not an explicit dependency, but we should add it as a peer dependency
803
+ missing.splice(missing.indexOf('react'), 1);
804
+ let missingLincdPackages = missing.filter((missingDep) => {
805
+ return lincdPackages.some((lincdPackage) => {
806
+ return lincdPackage.packageName === missingDep;
943
807
  });
944
- //currently just missing LINCD packages cause a hard failure exit code
945
- if (missingLincdPackages.length > 0) {
946
- reject(chalk_1.default.red(packagePath.split('/').pop() +
947
- '\n[ERROR] These LINCD packages are imported but they are not listed in package.json:\n- ' +
948
- missingLincdPackages.join(',\n- ')));
949
- }
950
- else if (missing.length > 0) {
951
- resolve(chalk_1.default.redBright('warning: ' + packagePath.split('/').pop() +
952
- ' is missing dependencies:\n - ' +
953
- missing.join('\n - ')));
954
- }
955
- else {
956
- resolve(true);
957
- }
808
+ });
809
+ //currently just missing LINCD packages cause a hard failure exit code
810
+ if (missingLincdPackages.length > 0) {
811
+ console.warn(chalk_1.default.red(path +
812
+ '\n[ERROR] These LINCD packages are imported but they are not listed in package.json:\n- ' +
813
+ missingLincdPackages.join(',\n- ')));
814
+ process.exit(1);
958
815
  }
959
- // if(Object.keys(results.invalidFiles).length > 0) {
960
- // console.warn(chalk.red("Invalid files:\n")+Object.keys(results.invalidFiles).join(",\n"));
961
- // }
962
- // if(Object.keys(results.invalidDirs).length > 0) {
963
- // console.warn(chalk.red("Invalid dirs:\n")+results.invalidDirs.toString());
964
- // }
965
- // if(results.unused) {
966
- // console.warn("Unused dependencies: "+results.missing.join(", "));
967
- // }
968
- });
816
+ else if (missing.length > 0) {
817
+ console.warn(chalk_1.default.magenta(path +
818
+ '\nMissing dependencies (for now a warning, soon an error):\n\t' +
819
+ missing.join(',\n\t')));
820
+ }
821
+ }
822
+ // if(Object.keys(results.invalidFiles).length > 0) {
823
+ // console.warn(chalk.red("Invalid files:\n")+Object.keys(results.invalidFiles).join(",\n"));
824
+ // }
825
+ // if(Object.keys(results.invalidDirs).length > 0) {
826
+ // console.warn(chalk.red("Invalid dirs:\n")+results.invalidDirs.toString());
827
+ // }
828
+ // if(results.unused) {
829
+ // console.warn("Unused dependencies: "+results.missing.join(", "));
830
+ // }
969
831
  });
970
832
  };
971
833
  exports.depCheck = depCheck;
972
834
  const ensureEnvironmentLoaded = async () => {
973
835
  if (!process.env.NODE_ENV) {
974
836
  //load env-cmd for development environment
975
- let { GetEnvVars } = await Promise.resolve().then(() => __importStar(require('env-cmd')));
837
+ let { GetEnvVars } = require('env-cmd');
976
838
  let envCmdrcPath = path_1.default.join(process.cwd(), '.env-cmdrc.json');
977
839
  if (!fs_extra_1.default.existsSync(envCmdrcPath)) {
978
840
  console.warn('No .env-cmdrc.json found in this folder. Are you running this command from the root of a LINCD app?');
@@ -1015,26 +877,14 @@ const ensureEnvironmentLoaded = async () => {
1015
877
  };
1016
878
  exports.ensureEnvironmentLoaded = ensureEnvironmentLoaded;
1017
879
  const startServer = async (initOnly = false, ServerClass = null) => {
1018
- var _a, _b;
1019
880
  await (0, exports.ensureEnvironmentLoaded)();
1020
- let lincdConfig = await (_a = path_1.default.join(process.cwd(), 'lincd.config.js'), Promise.resolve().then(() => __importStar(require(_a))));
1021
- // function scssLoadcall(source, filename) {
1022
- // return 'console.log("SCSS CALL: ' + filename + '");\n' + source;
1023
- // process.exit();
1024
- // }
1025
- // hook.hook('.scss', scssLoadcall);
1026
- // hook.hook('.css', scssLoadcall);
1027
- // import.meta.
1028
- // // hook.hook('*.css', scssLoadcall);
1029
- // // hook.hook('Body.module.css', scssLoadcall);
1030
- // hook.hook('.module.css', scssLoadcall);
881
+ let lincdConfig = require(path_1.default.join(process.cwd(), 'lincd.config'));
1031
882
  if (!ServerClass) {
1032
- //@ts-ignore
1033
- ServerClass = (await Promise.resolve().then(() => __importStar(require('lincd-server/shapes/LincdServer')))).LincdServer;
883
+ ServerClass = require('lincd-server/lib/shapes/LincdServer').LincdServer;
1034
884
  }
1035
- await (_b = path_1.default.join(process.cwd(), 'scripts', 'storage-config.js'), Promise.resolve().then(() => __importStar(require(_b))));
885
+ require(path_1.default.join(process.cwd(), 'scripts', 'storage-config'));
1036
886
  let server = new ServerClass({
1037
- loadAppComponent: async () => { var _a; return (await (_a = path_1.default.join(process.cwd(), 'src', 'App'), Promise.resolve().then(() => __importStar(require(_a))))).default; },
887
+ loadAppComponent: () => require(path_1.default.join(process.cwd(), 'src', 'App')).default,
1038
888
  ...lincdConfig,
1039
889
  });
1040
890
  //Important to use slice, because when using clusers, child processes need to be able to read the same arguments
@@ -1050,12 +900,15 @@ const startServer = async (initOnly = false, ServerClass = null) => {
1050
900
  exports.startServer = startServer;
1051
901
  const buildApp = async () => {
1052
902
  await (0, exports.ensureEnvironmentLoaded)();
1053
- const webpackAppConfig = await (await Promise.resolve().then(() => __importStar(require('./config-webpack-app.js')))).getWebpackAppConfig();
903
+ const webpackAppConfig = require('./config-webpack-app').webpackAppConfig;
1054
904
  console.log(chalk_1.default.magenta(`Building ${process.env.NODE_ENV} app bundles`));
1055
905
  return new Promise((resolve, reject) => {
1056
- (0, webpack_1.default)(webpackAppConfig, async (err, stats) => {
906
+ webpack(webpackAppConfig, async (err, stats) => {
1057
907
  if (err) {
1058
908
  console.error(err.stack || err);
909
+ if (err.details) {
910
+ console.error(err.details);
911
+ }
1059
912
  process.exit(1);
1060
913
  }
1061
914
  const info = stats.toJson();
@@ -1069,9 +922,10 @@ const buildApp = async () => {
1069
922
  console.log(stats.toString({
1070
923
  chunks: false,
1071
924
  assets: true,
1072
- entrypoints: false,
925
+ entryPoints: false,
1073
926
  modules: false,
1074
927
  moduleAssets: false,
928
+ moduleChunks: false,
1075
929
  colors: true,
1076
930
  }));
1077
931
  console.log('App build process finished');
@@ -1085,191 +939,9 @@ const buildApp = async () => {
1085
939
  }
1086
940
  // process.exit();
1087
941
  });
1088
- }).then(async () => {
1089
- var _a;
1090
- // make sure environment is not development for storage config
1091
- // and if we want to upload to storage, we need set S3_BUCKET_ENDPOINT
1092
- if (process.env.NODE_ENV === 'development' || !process.env.S3_BUCKET_ENDPOINT) {
1093
- console.warn('Upload build to storage skip in development environment or S3_BUCKET_ENDPOINT is not set');
1094
- process.exit();
1095
- }
1096
- if (process.env.APP_ENV) {
1097
- console.warn('Not uploading to CDN for app builds');
1098
- process.exit();
1099
- }
1100
- // load the storage config
1101
- const storageConfig = await (_a = path_1.default.join(process.cwd(), 'scripts', 'storage-config.js'), Promise.resolve().then(() => __importStar(require(_a))));
1102
- // check if LincdFileStorage has a default FileStore
1103
- // if yes: copy all the files in the build folder over with LincdFileStorage
1104
- if (LinkedFileStorage_1.LinkedFileStorage.getDefaultStore()) {
1105
- // get public directory
1106
- const rootDirectory = 'public';
1107
- const pathDir = path_1.default.join(process.cwd(), rootDirectory);
1108
- if (!fs_extra_1.default.existsSync(pathDir)) {
1109
- console.warn('No public directory found. Please create a public directory in the root of your project');
1110
- return;
1111
- }
1112
- // get all files in the web directory and then upload them to the storage
1113
- const files = await (0, utils_js_1.getFiles)(pathDir);
1114
- const uploads = files.map(async (filePath) => {
1115
- // read file content
1116
- const fileContent = await fs_extra_1.default.promises.readFile(filePath);
1117
- // replace pathDir with rootDirectory in filePath to get pathname
1118
- // example: /Users/username/project/www/index.html -> /project/www/index.html
1119
- const pathname = filePath.replace(pathDir, `/${rootDirectory}`);
1120
- // upload file to storage
1121
- return await LinkedFileStorage_1.LinkedFileStorage.saveFile(pathname, fileContent);
1122
- });
1123
- const urls = await Promise.all(uploads);
1124
- console.log(`${urls.length} files uploaded to storage`);
1125
- process.exit();
1126
- }
1127
942
  });
1128
943
  };
1129
944
  exports.buildApp = buildApp;
1130
- const upgradePackages = async () => {
1131
- await (0, exports.ensureEnvironmentLoaded)();
1132
- // let packages = getLincdPackages();
1133
- // let packages = getLocalLincdModules();
1134
- let packages = getLocalLincdPackageMap();
1135
- let dirname = (0, exports.getScriptDir)();
1136
- const tsConfigCJS = path_1.default.join(dirname, '../../defaults/package', 'tsconfig-cjs.json');
1137
- const tsConfigESM = path_1.default.join(dirname, '../../defaults/package', 'tsconfig-esm.json');
1138
- const typesFile = path_1.default.join(dirname, '../../defaults/package/src', 'types.d.ts');
1139
- const tsConfigTemplate = await fs_extra_1.default.readJson(path_1.default.join(dirname, '../../defaults/package', 'tsconfig.json')).catch(err => {
1140
- console.log(err);
1141
- });
1142
- runOnPackagesGroupedByDependencies(packages, (packageGroup, dependencies) => {
1143
- // packageGroup.forEach((pkg) => {
1144
- // console.log(' Upgrading ' + pkg.packageName);
1145
- console.log('-----');
1146
- return async (pkg) => {
1147
- if (pkg.packageName === 'lincd')
1148
- return;
1149
- // await execPromise(`cd ${pkg.path} && yarn upgrade`);
1150
- console.log('Upgrading ' + pkg.packageName);
1151
- //
1152
- // //create a new file src/tsconfig-cjs.json
1153
- // //copy the contents of tsconfig.json into it
1154
- // if (!fs.existsSync(path.join(pkg.path,'tsconfig-cjs.json')))
1155
- // {
1156
- // await fs.copy(tsConfigCJS,path.join(pkg.path,'tsconfig-cjs.json'));
1157
- // await fs.copy(tsConfigESM,path.join(pkg.path,'tsconfig-esm.json'));
1158
- // console.log('Copied new tsconfig to ' + pkg.packageName);
1159
- // }
1160
- //
1161
- // //read tsconfig
1162
- // await fs.readJson(path.join(pkg.path,'tsconfig.json')).then((tsconfig) => {
1163
- // let oldCompilerOpts = tsconfig.compilerOptions;
1164
- // tsconfig.compilerOptions = tsConfigTemplate.compilerOptions;
1165
- // tsconfig.compilerOptions.types = oldCompilerOpts.types;
1166
- // tsconfig.compilerOptions.plugins = [{"name": "typescript-plugin-css-modules"}];
1167
- //
1168
- // console.log('Upgraded tsconfig for ' + pkg.packageName);
1169
- // return fs.writeJson(path.join(pkg.path,'tsconfig.json'),tsconfig,{spaces: 2});
1170
- // });
1171
- // //import types at the beginning of index.ts
1172
- // addLineToIndex(`import './types';`,null,pkg.path,true);
1173
- // //copy over the types file
1174
- // await fs.copy(typesFile,path.join(pkg.path,'src','types.d.ts'));
1175
- // await fs.readJson(path.join(pkg.path,'package.json')).then((packageJson) => {
1176
- // let version = packageJson.version;
1177
- // let nextVersion;
1178
- // if (version.split('.').shift() === '0')
1179
- // {
1180
- // nextVersion = getNextMajorVersion(version);
1181
- // }
1182
- // else
1183
- // {
1184
- // nextVersion = getNextMinorVersion(version);
1185
- // }
1186
- // console.log('Upgraded version for ' + pkg.packageName + ' to ' + nextVersion);
1187
- //
1188
- // packageJson.version = nextVersion;
1189
- // packageJson.devDependencies['tsconfig-to-dual-package'] = '^1.2.0';
1190
- // packageJson.devDependencies['typescript-plugin-css-modules'] = '^5.1.0';
1191
- //
1192
- // packageJson.main = 'lib/cjs/index.js';
1193
- // packageJson.module = 'lib/esm/index.js';
1194
- // packageJson.exports = {
1195
- // '.': {
1196
- // 'types': './lib/esm/index.d.ts',
1197
- // 'import': './lib/esm/index.js',
1198
- // 'require': './lib/cjs/index.js',
1199
- // },
1200
- // './*': {
1201
- // 'types': './lib/esm/*.d.ts',
1202
- // 'import': './lib/esm/*.js',
1203
- // 'require': './lib/cjs/*.js',
1204
- // },
1205
- // };
1206
- // packageJson.typesVersions = {
1207
- // '*': {
1208
- // '*': [
1209
- // 'lib/esm/*',
1210
- // ],
1211
- // },
1212
- // };
1213
- //
1214
- // return fs.writeJson(path.join(pkg.path,'package.json'),packageJson,{ spaces: 2 });
1215
- // });
1216
- //change .css files and .scss files to .module.css and .module.scss
1217
- let files = await (0, utils_js_1.getFiles)(path_1.default.join(pkg.path, 'src'));
1218
- // let tsFiles = files.filter(f => f.match(/\.(ts|tsx)$/));
1219
- // let cssFiles = files.filter(f => f.match(/\.(css|scss)$/)).filter(f => !f.match(/\.module\.(css|scss)$/));
1220
- // cssFiles.forEach(cssFile => {
1221
- // let cssFileName = path.basename(cssFile);
1222
- // let newFile = cssFileName.replace(/\.s?css$/,'.module$&');
1223
- // let newFilePath = cssFile.replace(/\.s?css$/,'.module$&');
1224
- // let jsonFile = cssFileName.replace(/\.s?css$/,'$&.json');
1225
- // fs.renameSync(cssFile,newFilePath);
1226
- // console.log('Renaming ' + cssFileName + ' to ' + newFilePath);
1227
- // //find other files that import this file and update them
1228
- // tsFiles.forEach(tsFile => {
1229
- // //read contents of f2
1230
- // let contents = fs.readFileSync(tsFile,'utf8');
1231
- // //if it imports f
1232
- // if (contents.indexOf(cssFileName) !== -1)
1233
- // {
1234
- // //find the whole line that imports f
1235
- // let line = contents.split('\n').find(l => l.indexOf(cssFileName) !== -1);
1236
- // // console.log("OLD: "+line);
1237
- // let jsonLine = contents.split('\n').find(l => l.indexOf(jsonFile) !== -1);
1238
- // // console.log("JSON: "+jsonLine);
1239
- // //if not commented out
1240
- // if(line.indexOf('//') === -1) {
1241
- // let previousImportPath = line.match(/['"](.*)['"]/)[1];
1242
- // let newImportPath = previousImportPath.replace(cssFileName,newFile);
1243
- // let newContents = contents.replace(line,`import style from '${newImportPath}';`)
1244
- // .replace(jsonLine+'\n','');
1245
- // // console.log("\n");
1246
- // fs.writeFileSync(tsFile,newContents);
1247
- // console.log('Updated imports in ' + tsFile);
1248
- // // fs.writeFileSync
1249
- // // fs.writeFileSync(i,fs.readFileSync(i,'utf8').replace(f,newFile));
1250
- // }
1251
- // }
1252
- // })
1253
- // });
1254
- files.filter(f => f.match(/\.(scss\.json|css\.json)$/)).forEach(cssJsonFile => {
1255
- console.log('Removing ' + cssJsonFile);
1256
- fs_extra_1.default.unlinkSync(cssJsonFile);
1257
- });
1258
- };
1259
- // });
1260
- }, () => {
1261
- console.log('Finished upgrading packages');
1262
- });
1263
- // packages.forEach((pkg,key) => {
1264
- // console.log(key+' Upgrading ' + pkg.packageName);
1265
- // execPromise(`cd ${pkg.path} && yarn upgrade`).then(() => {
1266
- // console.log('Upgraded ' + pkg.packageName);
1267
- // }).catch(err => {
1268
- // console.warn(err);
1269
- // })
1270
- // });
1271
- };
1272
- exports.upgradePackages = upgradePackages;
1273
945
  const createPackage = async (name, uriBase, basePath = process.cwd()) => {
1274
946
  if (!name) {
1275
947
  console.warn('Please provide a name as the first argument');
@@ -1301,8 +973,8 @@ const createPackage = async (name, uriBase, basePath = process.cwd()) => {
1301
973
  //extra variable for clarity (will be same as 'name')
1302
974
  setVariable('output_file_name', name);
1303
975
  let { hyphenName, camelCaseName, underscoreName } = (0, exports.setNameVariables)(cleanPackageName);
1304
- log('Creating new LINCD package \'' + name + '\'');
1305
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'package'), targetFolder);
976
+ log("Creating new LINCD package '" + name + "'");
977
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'package'), targetFolder);
1306
978
  //replace variables in some of the copied files
1307
979
  await Promise.all([
1308
980
  'src/index.ts',
@@ -1329,14 +1001,14 @@ const createPackage = async (name, uriBase, basePath = process.cwd()) => {
1329
1001
  console.log('rename ', path_1.default.join(targetFolder, f), path_1.default.join(targetFolder, ...newParts, newName));
1330
1002
  fs_extra_1.default.renameSync(path_1.default.join(targetFolder, f), path_1.default.join(targetFolder, ...newParts, newName));
1331
1003
  });
1332
- let version = (await (0, utils_js_1.execPromise)('yarn --version').catch((err) => {
1004
+ let version = (await (0, utils_1.execPromise)('yarn --version').catch((err) => {
1333
1005
  console.log('yarn probably not working');
1334
1006
  return '';
1335
1007
  }));
1336
1008
  let installCommand = version.toString().match(/[0-9]+/)
1337
1009
  ? 'yarn install'
1338
1010
  : 'npm install';
1339
- await (0, utils_js_1.execp)(`cd ${targetFolder} && ${installCommand} && npm exec lincd build`, true).catch((err) => {
1011
+ await (0, utils_1.execp)(`cd ${targetFolder} && ${installCommand} && npm exec lincd build`, true).catch((err) => {
1340
1012
  console.warn('Could not install dependencies');
1341
1013
  });
1342
1014
  log(`Prepared a new LINCD package in ${chalk_1.default.magenta(targetFolder)}`, `Run ${chalk_1.default.blueBright('yarn build')} from this directory to build once`, `Or ${chalk_1.default.blueBright('yarn dev')} to continuously rebuild on file changes`);
@@ -1358,6 +1030,43 @@ var buildFailed = function (output) {
1358
1030
  return (output.indexOf('Aborted due to warnings') !== -1 &&
1359
1031
  output.indexOf('Command failed') !== -1);
1360
1032
  };
1033
+ /*program.command('shapes').action(async () => {
1034
+ //we've imported require-extensions from npm so that we can use this
1035
+ //we want to avoid nodejs tripping up over @import commands in css files
1036
+ require.extensions['.scss'] = function (sourcecode, filename) {
1037
+ return {};
1038
+ };
1039
+ require.extensions['.css'] = function (sourcecode, filename) {
1040
+ return {};
1041
+ };
1042
+
1043
+ if (fs.existsSync(process.cwd() + '/package.json')) {
1044
+ var pack = JSON.parse(
1045
+ fs.readFileSync(process.cwd() + '/package.json', 'utf8'),
1046
+ );
1047
+ let packageName = pack.name;
1048
+
1049
+ //just making sure the library is loaded in correct order because circular references are currently happening when importing BlankNode before NamedNode for example
1050
+ // require('lincd');
1051
+ //TODO: replace with actual index file from package.json, or tsconfig
1052
+ let indexExports = require(process.cwd() + '/lib/index.js');
1053
+ if(indexExports.packageExports)
1054
+ {
1055
+ let shapeJSONLD = await getShapesJSONLD(indexExports.packageExports);
1056
+ console.log(indexExports.packageExports);
1057
+ console.log(shapeJSONLD);
1058
+ console.log(chalk.bold(chalk.green(packageName+'/dist/shapes.json')));
1059
+ return fs.writeFile(path.join('dist', 'shapes.json'), shapeJSONLD);
1060
+ }
1061
+ else
1062
+ {
1063
+ console.warn("Invalid LINCD package. Index file should export a packageExports object. See examples.")
1064
+ }
1065
+
1066
+ } else {
1067
+ console.warn('Not a project');
1068
+ }
1069
+ });*/
1361
1070
  const register = function (registryURL) {
1362
1071
  if (fs_extra_1.default.existsSync(process.cwd() + '/package.json')) {
1363
1072
  var pack = JSON.parse(fs_extra_1.default.readFileSync(process.cwd() + '/package.json', 'utf8'));
@@ -1405,138 +1114,98 @@ const register = function (registryURL) {
1405
1114
  }
1406
1115
  };
1407
1116
  exports.register = register;
1408
- const buildPackage = async (target, target2, packagePath = process.cwd(), logResults = true) => {
1409
- let spinner;
1410
- if (logResults) {
1411
- //TODO: replace with listr so we can show multiple processes at once
1412
- spinner = (0, ora_1.default)({
1413
- discardStdin: true,
1414
- text: 'Compiling code',
1415
- }).start();
1416
- }
1417
- let buildProcess = Promise.resolve(true);
1418
- let buildStep = (step) => {
1419
- buildProcess = buildProcess.then((previousResult) => {
1420
- if (logResults) {
1421
- spinner.text = step.name;
1422
- spinner.start();
1423
- }
1424
- return step.apply().then(stepResult => {
1425
- if (typeof stepResult === 'string') {
1426
- // spinner.text = step.name + ' - ' + stepResult;
1427
- if (logResults) {
1428
- spinner.warn(step.name + ' - ' + stepResult);
1429
- spinner.stop();
1430
- }
1431
- //warning is shown, but build is still succesful with warnings
1432
- return false;
1433
- }
1434
- else if (stepResult === true || typeof stepResult === 'undefined') {
1435
- if (logResults) {
1436
- spinner.succeed();
1437
- }
1438
- return previousResult && true;
1439
- }
1440
- });
1441
- });
1442
- };
1443
- buildStep({
1444
- name: 'Compiling code',
1445
- apply: async () => {
1446
- return (0, exports.compilePackage)(packagePath);
1447
- },
1448
- });
1449
- buildStep({
1450
- name: 'Copying files to lib folder',
1451
- apply: async () => {
1452
- const files = await (0, glob_1.glob)(packagePath + '/src/**/*.{json,d.ts,css,scss}');
1453
- return Promise.all(files.map((async (file) => {
1454
- try {
1455
- await fs_extra_1.default.copy(file, packagePath + '/lib/esm/' + file.replace(packagePath + '/src/', ''));
1456
- await fs_extra_1.default.copy(file, packagePath + '/lib/cjs/' + file.replace(packagePath + '/src/', ''));
1457
- return true;
1458
- }
1459
- catch (err) {
1460
- console.warn(err);
1461
- return false;
1117
+ /**
1118
+ * Function to remove files older than 10 seconds from the 'lib' folder.
1119
+ * @param {string} packagePath - The path to the package directory.
1120
+ */
1121
+ const removeOldFiles = async (packagePath) => {
1122
+ const libPath = path_1.default.join(packagePath, 'lib');
1123
+ try {
1124
+ // Read all files in the 'lib' folder asynchronously
1125
+ const files = await fs_extra_1.default.readdir(libPath);
1126
+ // Iterate through each file
1127
+ for (const file of files) {
1128
+ const filePath = path_1.default.join(libPath, file);
1129
+ // Check if the file exists before attempting to delete it
1130
+ if (await fs_extra_1.default.pathExists(filePath)) {
1131
+ const stats = await fs_extra_1.default.stat(filePath);
1132
+ const currentTime = new Date().getTime();
1133
+ const lastModifiedTime = stats.mtime.getTime();
1134
+ // Check if the difference between the current time and last modified time is greater than 10 seconds
1135
+ if (currentTime - lastModifiedTime > 10000) {
1136
+ // Attempt to delete the file
1137
+ await fs_extra_1.default.remove(filePath);
1138
+ console.log(`Removed: ${filePath}`);
1462
1139
  }
1463
- ;
1464
- }))).then((allResults) => {
1465
- return allResults.every(r => r === true);
1466
- });
1467
- },
1468
- });
1469
- buildStep({
1470
- name: 'Dual package support',
1471
- apply: () => {
1472
- return (0, utils_js_1.execPromise)('yarn tsconfig-to-dual-package ./tsconfig-cjs.json ./tsconfig-esm.json', false, false, { cwd: packagePath }).then(res => {
1473
- return res === '';
1474
- });
1475
- },
1476
- });
1477
- buildStep({
1478
- name: 'Removing old files from lib folder',
1479
- apply: async () => {
1480
- return (0, exports.removeOldFiles)(packagePath);
1481
- },
1482
- });
1483
- buildStep({
1484
- name: 'Checking imports',
1485
- apply: () => (0, exports.checkImports)(packagePath),
1486
- });
1487
- buildStep({
1488
- name: 'Checking dependencies',
1489
- apply: () => (0, exports.depCheck)(packagePath),
1490
- });
1491
- let success = await buildProcess.catch(err => {
1492
- let msg = err.error ? err.error : err.stdout + '\n' + err.stderr;
1493
- if (logResults) {
1494
- spinner.stopAndPersist({
1495
- symbol: chalk_1.default.red('✖'),
1496
- text: 'Build failed',
1497
- });
1498
- }
1499
- else {
1500
- console.log(chalk_1.default.red(packagePath.split('/').pop(), ' - Build failed:'));
1501
- }
1502
- console.log(msg);
1503
- });
1504
- //will be undefined if there was an error
1505
- if (typeof success !== 'undefined') {
1506
- if (logResults) {
1507
- spinner.stopAndPersist({
1508
- symbol: chalk_1.default.greenBright('✔'),
1509
- text: success === true ? 'Build successful' : 'Build successful with warnings',
1510
- });
1140
+ }
1141
+ else {
1142
+ console.warn(`File ${filePath} does not exist.`);
1143
+ }
1511
1144
  }
1512
1145
  }
1513
- return success;
1514
- };
1515
- exports.buildPackage = buildPackage;
1516
- const compilePackage = async (packagePath = process.cwd()) => {
1517
- //echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
1518
- let cjsConfig = fs_extra_1.default.existsSync(path_1.default.join(packagePath, 'tsconfig-cjs.json'));
1519
- let esmConfig = fs_extra_1.default.existsSync(path_1.default.join(packagePath, 'tsconfig-esm.json'));
1520
- let compileCJS = `yarn exec tsc -p tsconfig-cjs.json`;
1521
- let compileESM = `yarn exec tsc -p tsconfig-esm.json`;
1522
- let compileCommand;
1523
- if (cjsConfig && esmConfig) {
1524
- compileCommand = `${compileCJS} && ${compileESM}`;
1525
- }
1526
- else if (cjsConfig) {
1527
- compileCommand = compileCJS;
1146
+ catch (error) {
1147
+ console.error(`Error removing files: ${error.message}`);
1528
1148
  }
1529
- else if (esmConfig) {
1530
- compileCommand = compileESM;
1149
+ };
1150
+ exports.removeOldFiles = removeOldFiles;
1151
+ const buildPackage = (target, target2, packagePath = process.cwd(), logResults = true) => {
1152
+ if (target == 'production' || target == 'es5' || target == 'es6' || !target) {
1153
+ if (!fs_extra_1.default.existsSync(path_1.default.join(packagePath, 'Gruntfile.js'))) {
1154
+ console.warn(`No Gruntfile found at ${packagePath}\\Gruntfile.js. Cannot build.`);
1155
+ return;
1156
+ }
1157
+ var nodeEnv = '';
1158
+ if (target == 'production') {
1159
+ if (!(target2 == 'es5' || target2 == 'es6' || typeof target2 == 'undefined')) {
1160
+ console.warn('unknown second build target. Use es5 or es6', target2);
1161
+ return;
1162
+ }
1163
+ var isWindows = /^win/.test(process.platform);
1164
+ if (isWindows) {
1165
+ nodeEnv = 'SET NODE_ENV=production&& ';
1166
+ }
1167
+ else {
1168
+ nodeEnv = "NODE_ENV='production' ";
1169
+ }
1170
+ }
1171
+ if (!target) {
1172
+ target = 'es6';
1173
+ }
1174
+ log('building once: ' +
1175
+ nodeEnv +
1176
+ 'grunt build' +
1177
+ (target ? '-' + target : '') +
1178
+ (target2 ? '-' + target2 : '') +
1179
+ ' --color');
1180
+ let method = logResults ? utils_1.execp : utils_1.execPromise;
1181
+ //NOTE: we moved SCSS:JSON out of webpack and grunt, into this file
1182
+ //this is the beginning of a transition away from grunt
1183
+ //but for the time being it's perhaps a bit strange that we
1184
+ // let x = postcss([
1185
+ // postcssModules({
1186
+ // generateScopedName,
1187
+ // }),
1188
+ // ]);
1189
+ //execute the command to build the method, and provide the current work directory as option
1190
+ return method(nodeEnv +
1191
+ 'grunt build' +
1192
+ (target ? '-' + target : '') +
1193
+ (target2 ? '-' + target2 : '') +
1194
+ ' --color', false, false, { cwd: packagePath })
1195
+ .then(() => {
1196
+ // Once the build is complete, remove old files
1197
+ return (0, exports.removeOldFiles)(packagePath);
1198
+ })
1199
+ .catch((err) => {
1200
+ console.error('Error building package:', err);
1201
+ process.exit(1);
1202
+ });
1531
1203
  }
1532
1204
  else {
1533
- compileCommand = `yarn exec tsc`;
1205
+ console.warn('unknown build target. Use es5, es6, or production.');
1534
1206
  }
1535
- return (0, utils_js_1.execPromise)(compileCommand, false, false, { cwd: packagePath }).then(res => {
1536
- return res === '';
1537
- });
1538
1207
  };
1539
- exports.compilePackage = compilePackage;
1208
+ exports.buildPackage = buildPackage;
1540
1209
  var publishUpdated = function (test = false) {
1541
1210
  let packages = getLocalLincdModules();
1542
1211
  var p = Promise.resolve('');
@@ -1554,22 +1223,22 @@ var publishUpdated = function (test = false) {
1554
1223
  // console.log("Will be requesting npm view from this current working directory:\n"+process.cwd());
1555
1224
  // return execPromise('npm view '+pkg.packageName+' --json').then((output:string) => {
1556
1225
  let shouldPublish;
1557
- var pack = (0, utils_js_1.getPackageJSON)(pckg.path);
1226
+ var pack = (0, utils_1.getPackageJSON)(pckg.path);
1558
1227
  let version = getNextVersion(pack.version);
1559
1228
  if (pack.private) {
1560
1229
  shouldPublish = false;
1561
- (0, utils_js_1.debugInfo)(chalk_1.default.blue('--> is private, skipping'));
1230
+ (0, utils_1.debugInfo)(chalk_1.default.blue('--> is private, skipping'));
1562
1231
  return chalk_1.default.gray(pckg.packageName + ' is private');
1563
1232
  // return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
1564
1233
  }
1565
1234
  console.log('testing npm');
1566
- return (0, utils_js_1.execPromise)('npm info ' + pckg.packageName + ' --json')
1235
+ return (0, utils_1.execPromise)('npm info ' + pckg.packageName + ' --json')
1567
1236
  .then(async (output) => {
1568
1237
  console.log('testing npm done');
1569
1238
  var info;
1570
1239
  try {
1571
1240
  if (output == '' || output.includes('E404')) {
1572
- (0, utils_js_1.debugInfo)('Empty or 404 response from `npm info`. This package was probably not published before');
1241
+ (0, utils_1.debugInfo)('Empty or 404 response from `npm info`. This package was probably not published before');
1573
1242
  // throw new Error('Empty response from `yarn info`. This pkg was probably not published before');
1574
1243
  // return;
1575
1244
  shouldPublish = true;
@@ -1592,10 +1261,10 @@ var publishUpdated = function (test = false) {
1592
1261
  // }
1593
1262
  let lastPublishDate = new Date(lastPublish);
1594
1263
  // let {lastModifiedTime, lastModifiedName, lastModified} = getLastModifiedSourceTime(pkg.path);
1595
- let lastCommitInfo = await (0, utils_js_1.getLastCommitTime)(pckg.path);
1264
+ let lastCommitInfo = await (0, utils_1.getLastCommitTime)(pckg.path);
1596
1265
  if (!lastCommitInfo) {
1597
1266
  shouldPublish = false;
1598
- (0, utils_js_1.debugInfo)('Could not determine last git commit');
1267
+ (0, utils_1.debugInfo)('Could not determine last git commit');
1599
1268
  // return previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n');
1600
1269
  return chalk_1.default.red(pckg.packageName + ' - could not determine last commit');
1601
1270
  }
@@ -1689,7 +1358,7 @@ async function getEnvJsonPath(relativeToPath = process.cwd()) {
1689
1358
  }
1690
1359
  // let path = './';
1691
1360
  for (let i = 0; i <= 10; i++) {
1692
- let envFile = await (0, get_env_vars_js_1.getEnvFile)({
1361
+ let envFile = await (0, get_env_vars_1.getEnvFile)({
1693
1362
  filePath: relativeToPath + path + '.env.json',
1694
1363
  }).catch((err) => {
1695
1364
  return null;
@@ -1703,7 +1372,7 @@ async function getEnvJsonPath(relativeToPath = process.cwd()) {
1703
1372
  }
1704
1373
  var publishPackage = async function (pkg, test, info, publishVersion) {
1705
1374
  if (!pkg) {
1706
- let localPackageJson = (0, utils_js_1.getPackageJSON)();
1375
+ let localPackageJson = (0, utils_1.getPackageJSON)();
1707
1376
  pkg = {
1708
1377
  path: process.cwd(),
1709
1378
  packageName: localPackageJson.name,
@@ -1713,18 +1382,18 @@ var publishPackage = async function (pkg, test, info, publishVersion) {
1713
1382
  publishVersion = info ? getNextVersion(info.version) : 'patch';
1714
1383
  }
1715
1384
  if (test) {
1716
- (0, utils_js_1.debugInfo)('should publish ' + pkg.packageName + ' ' + publishVersion);
1385
+ (0, utils_1.debugInfo)('should publish ' + pkg.packageName + ' ' + publishVersion);
1717
1386
  //when testing what needs to be published
1718
1387
  return chalk_1.default.blue(pkg.packageName + ' should publish');
1719
1388
  }
1720
1389
  console.log(chalk_1.default.blue('publishing ' + pkg.packageName + ' ' + publishVersion));
1721
1390
  //looking for an .env.json file in our workspace, which may store our NPM AUTH key
1722
1391
  let envJsonPath = await getEnvJsonPath(pkg.path);
1723
- return (0, utils_js_1.execPromise)(`cd ${pkg.path} && ${envJsonPath ? `env-cmd -f ${envJsonPath} --use-shell "` : ''}yarn version ${publishVersion} && yarn npm publish${envJsonPath ? `"` : ''}`, true, false, {}, true)
1392
+ return (0, utils_1.execPromise)(`cd ${pkg.path} && ${envJsonPath ? `env-cmd -f ${envJsonPath} --use-shell "` : ''}yarn version ${publishVersion} && yarn npm publish${envJsonPath ? `"` : ''}`, true, false, {}, true)
1724
1393
  .then((res) => {
1725
1394
  if (res.indexOf('Aborted due to warnings') !== -1 ||
1726
1395
  res.indexOf('Could not publish') !== -1 ||
1727
- res.indexOf('Couldn\'t publish') !== -1) {
1396
+ res.indexOf("Couldn't publish") !== -1) {
1728
1397
  console.log(res);
1729
1398
  return chalk_1.default.red(pkg.packageName + ' failed\n');
1730
1399
  }
@@ -1753,12 +1422,12 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
1753
1422
  // let packages = getLocalLincdModules();
1754
1423
  let packages = getLocalLincdPackageMap();
1755
1424
  // console.log(packages);
1756
- let jsonldPkgUpdated = await (0, utils_js_1.needsRebuilding)(packages.get('lincd-jsonld'), useGitForLastModified);
1425
+ let jsonldPkgUpdated = await (0, utils_1.needsRebuilding)(packages.get('lincd-jsonld'), useGitForLastModified);
1757
1426
  // let cliPkgUpdated = await needsRebuilding(packages.get('lincd-cli'), useGitForLastModified);
1758
1427
  //if either cli or jsonldPkg needs to be rebuilt
1759
1428
  // if (jsonldPkgUpdated || cliPkgUpdated) {
1760
1429
  if (jsonldPkgUpdated) {
1761
- await (0, utils_js_1.execPromise)('yarn exec tsc && echo "compiled lincd-jsonld"', false, false, {
1430
+ await (0, utils_1.execPromise)('yarn exec tsc && echo "compiled lincd-jsonld"', false, false, {
1762
1431
  cwd: packages.get('lincd-jsonld').path,
1763
1432
  }, true);
1764
1433
  // await execPromise('yarn build-core', false, false, {}, true);
@@ -1770,12 +1439,12 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
1770
1439
  // }
1771
1440
  let packagesLeft = packages.size;
1772
1441
  runOnPackagesGroupedByDependencies(packages, (packageGroup, dependencies) => {
1773
- (0, utils_js_1.debugInfo)('Now checking: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
1774
- (0, utils_js_1.debugInfo)(packagesLeft + ' packages left.');
1442
+ (0, utils_1.debugInfo)('Now checking: ' + chalk_1.default.blue(packageGroup.map((i) => i.packageName)));
1443
+ (0, utils_1.debugInfo)(packagesLeft + ' packages left.');
1775
1444
  packagesLeft = packagesLeft - packageGroup.length;
1776
1445
  return async (pkg) => {
1777
1446
  // debugInfo('# Checking package ' + pkg.packageName);
1778
- let needRebuild = await (0, utils_js_1.needsRebuilding)(pkg, useGitForLastModified);
1447
+ let needRebuild = await (0, utils_1.needsRebuilding)(pkg, useGitForLastModified);
1779
1448
  if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated) {
1780
1449
  needRebuild = true;
1781
1450
  }
@@ -1783,26 +1452,18 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
1783
1452
  //TODO: when building a pkg, also rebuild all packages that depend on this package.. and iteratively build packages that depend on those packages..
1784
1453
  // log(packageName+' modified since last commit on '+now.toString());
1785
1454
  if (test) {
1786
- (0, utils_js_1.debugInfo)('Need to build ' + pkg.packageName);
1455
+ (0, utils_1.debugInfo)('Need to build ' + pkg.packageName);
1787
1456
  return chalk_1.default.blue(pkg.packageName + ' should be build');
1788
1457
  }
1789
1458
  log('Building ' + pkg.packageName);
1790
- // return buildPackage(null,null,pkg.path)
1791
- return (0, utils_js_1.execPromise)('cd ' +
1459
+ return (0, utils_1.execPromise)('cd ' +
1792
1460
  pkg.path +
1793
1461
  ' && yarn build' +
1794
1462
  (target ? ' ' + target : '') +
1795
1463
  (target2 ? ' ' + target2 : ''))
1796
1464
  .then((res) => {
1797
- if (res === '') {
1798
- (0, utils_js_1.debugInfo)(chalk_1.default.green(pkg.packageName + ' successfully built'));
1799
- return chalk_1.default.green(pkg.packageName + ' built');
1800
- }
1801
- else if (typeof res === 'string') {
1802
- warn(chalk_1.default.red('Failed to build ' + pkg.packageName));
1803
- console.log(res);
1804
- process.exit(1);
1805
- }
1465
+ (0, utils_1.debugInfo)(chalk_1.default.green(pkg.packageName + ' successfully built'));
1466
+ return chalk_1.default.green(pkg.packageName + ' built');
1806
1467
  })
1807
1468
  .catch(({ error, stdout, stderr }) => {
1808
1469
  warn(chalk_1.default.red('Failed to build ' + pkg.packageName));
@@ -1834,11 +1495,9 @@ var buildUpdated = async function (back, target, target2, useGitForLastModified
1834
1495
  };
1835
1496
  exports.buildUpdated = buildUpdated;
1836
1497
  const printBuildResults = function (failed, done) {
1837
- if (done.size > 0 || done.length > 0) {
1838
- log('Successfully built: ' +
1839
- chalk_1.default.green([...done].map((m) => m.packageName).join(', ')) +
1840
- '\n');
1841
- }
1498
+ log('Successfully built: ' +
1499
+ chalk_1.default.green([...done].map((m) => m.packageName).join(', ')) +
1500
+ '\n');
1842
1501
  if (failed.length > 0) {
1843
1502
  warn('Failed to build: ' + chalk_1.default.red(failed.join(', ')) + '\n');
1844
1503
  }
@@ -1863,21 +1522,21 @@ var executeCommandForEachPackage = function (packages, command, filterMethod, fi
1863
1522
  let seen = false;
1864
1523
  packages = packages.filter((pkg) => {
1865
1524
  if (!seen &&
1866
- pkg.packageName.includes(startFrom)) {
1525
+ (pkg.packageName == startFrom || pkg.packageName == startFrom)) {
1867
1526
  seen = true;
1868
1527
  }
1869
1528
  return seen;
1870
1529
  });
1871
1530
  }
1872
- log('Executing \'' +
1531
+ log("Executing '" +
1873
1532
  chalk_1.default.blueBright(command) +
1874
- '\' on packages ' +
1533
+ "' on packages " +
1875
1534
  chalk_1.default.magenta(packages.map((m) => m.packageName).join(', ')));
1876
1535
  var p = Promise.resolve(true);
1877
1536
  packages.forEach((pkg) => {
1878
1537
  p = p.then(() => {
1879
1538
  log('# Package ' + chalk_1.default.magenta(pkg.packageName));
1880
- return (0, utils_js_1.execp)('cd ' + pkg.path + ' && ' + command);
1539
+ return (0, utils_1.execp)('cd ' + pkg.path + ' && ' + command);
1881
1540
  });
1882
1541
  });
1883
1542
  return p;
@@ -1899,8 +1558,8 @@ exports.addLinesToFile = addLinesToFile;
1899
1558
  var addCapacitor = async function (basePath = process.cwd()) {
1900
1559
  let targetFolder = ensureFolderExists(basePath);
1901
1560
  log('Adding capacitor');
1902
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'app-static'), targetFolder);
1903
- fs_extra_1.default.copySync(path_1.default.join((0, exports.getScriptDir)(), '..', '..', 'defaults', 'capacitor', 'scripts'), path_1.default.join(targetFolder, 'scripts'));
1561
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'app-static'), targetFolder);
1562
+ fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'defaults', 'capacitor', 'scripts'), path_1.default.join(targetFolder, 'scripts'));
1904
1563
  //update .env-cmdrc.json file
1905
1564
  let envCmdPath = path_1.default.resolve(basePath, '.env-cmdrc.json');
1906
1565
  let envCmd = JSON.parse(fs_extra_1.default.readFileSync(envCmdPath, { encoding: 'utf8' }));
@@ -1922,7 +1581,7 @@ var addCapacitor = async function (basePath = process.cwd()) {
1922
1581
  log('Edited .env-cmdrc.json');
1923
1582
  gitIgnore('android/app/build', 'android/**/capacitor.build.gradle', 'ios/App/App/public');
1924
1583
  //update package.json scripts
1925
- let pack = (0, utils_js_1.getPackageJSON)(basePath);
1584
+ let pack = (0, utils_1.getPackageJSON)(basePath);
1926
1585
  pack.scripts['build-staging'] =
1927
1586
  'env-cmd -e _main, staging node scripts/build.js';
1928
1587
  pack.scripts['fix-app'] = 'node scripts/fix-namespace.js';
@@ -1937,8 +1596,8 @@ var addCapacitor = async function (basePath = process.cwd()) {
1937
1596
  pack.scripts['cap:sync'] = 'yarn cap sync';
1938
1597
  fs_extra_1.default.writeFile(path_1.default.resolve(basePath, 'package.json'), JSON.stringify(pack, null, 2));
1939
1598
  log('Added new run script to package.json');
1940
- await (0, utils_js_1.execPromise)(`yarn add -D @capacitor/cli`, true, false, null, true);
1941
- await (0, utils_js_1.execPromise)(`yarn add @capacitor/android @capacitor/core @capacitor/app @capacitor/ios`, false, false, null, true);
1599
+ await (0, utils_1.execPromise)(`yarn add -D @capacitor/cli`, true, false, null, true);
1600
+ await (0, utils_1.execPromise)(`yarn add @capacitor/android @capacitor/core @capacitor/app @capacitor/ios`, false, false, null, true);
1942
1601
  // TODO: Do we need to add `npx cap init`? If yes, we should not copy capacitor config.ts yet
1943
1602
  // await execPromise(`npx cap init`, true, false, null, true);
1944
1603
  // got error:
@@ -1955,53 +1614,20 @@ var executeCommandForPackage = function (packageName, command) {
1955
1614
  let packageDetails = getLincdPackages().find((modDetails) => modDetails.packageName.indexOf(packageName) !== -1 ||
1956
1615
  modDetails.packageName.indexOf(packageName) !== -1);
1957
1616
  if (packageDetails) {
1958
- log('Executing \'cd ' +
1617
+ log("Executing 'cd " +
1959
1618
  packageDetails.path +
1960
1619
  ' && yarn exec lincd' +
1961
1620
  (command ? ' ' + command : '') +
1962
- '\'');
1963
- return (0, utils_js_1.execp)('cd ' +
1621
+ "'");
1622
+ return (0, utils_1.execp)('cd ' +
1964
1623
  packageDetails.path +
1965
1624
  ' && yarn exec lincd' +
1966
1625
  (command ? ' ' + command : ''));
1967
1626
  }
1968
1627
  else {
1969
- warn('Could not find a pkg who\'s name (partially) matched ' +
1628
+ warn("Could not find a pkg who's name (partially) matched " +
1970
1629
  chalk_1.default.cyan(packageName));
1971
1630
  }
1972
1631
  };
1973
1632
  exports.executeCommandForPackage = executeCommandForPackage;
1974
- /**
1975
- * Function to remove files older than 10 seconds from the 'lib' folder.
1976
- * @param {string} packagePath - The path to the package directory.
1977
- */
1978
- const removeOldFiles = async (packagePath) => {
1979
- const libPath = path_1.default.join(packagePath, 'lib');
1980
- try {
1981
- // Read all files in the 'lib' folder asynchronously
1982
- const files = await (0, glob_1.glob)(packagePath + '/lib/**/*.*');
1983
- // Iterate through each file
1984
- for (const file of files) {
1985
- // const filePath = path.join(libPath, file);
1986
- // Check if the file exists before attempting to delete it
1987
- // if (await fs.pathExists(filePath)) {
1988
- const stats = await fs_extra_1.default.stat(file);
1989
- const currentTime = new Date().getTime();
1990
- const lastModifiedTime = stats.mtime.getTime();
1991
- // Check if the difference between the current time and last modified time is greater than 120 seconds
1992
- if (currentTime - lastModifiedTime > 120000) {
1993
- // Attempt to delete the file
1994
- await fs_extra_1.default.unlink(file);
1995
- // console.log(`Removed: ${file}`);
1996
- }
1997
- // }
1998
- }
1999
- return true;
2000
- }
2001
- catch (error) {
2002
- console.error(`Error removing files: ${error.message}`);
2003
- return false;
2004
- }
2005
- };
2006
- exports.removeOldFiles = removeOldFiles;
2007
1633
  //# sourceMappingURL=cli-methods.js.map