lincd-cli 1.2.0 → 1.2.2

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 (106) hide show
  1. package/defaults/app-with-backend/.eslintignore +3 -1
  2. package/defaults/app-with-backend/lincd.config.js +4 -6
  3. package/defaults/app-with-backend/package.json +8 -16
  4. package/defaults/app-with-backend/scripts/storage-config.js +5 -5
  5. package/defaults/app-with-backend/src/App.module.css +17 -0
  6. package/defaults/app-with-backend/src/App.tsx +11 -15
  7. package/defaults/app-with-backend/src/backend.ts +8 -0
  8. package/defaults/app-with-backend/src/components/Error.tsx +2 -5
  9. package/defaults/app-with-backend/src/components/Spinner.tsx +3 -3
  10. package/defaults/app-with-backend/src/config-frontend.ts +6 -6
  11. package/defaults/app-with-backend/src/index.tsx +4 -3
  12. package/defaults/app-with-backend/src/layout/DefaultLayout.module.css +12 -0
  13. package/defaults/app-with-backend/src/layout/DefaultLayout.tsx +3 -4
  14. package/defaults/app-with-backend/src/layout/Header.module.css +25 -0
  15. package/defaults/app-with-backend/src/layout/Header.tsx +10 -6
  16. package/defaults/app-with-backend/src/package.ts +0 -1
  17. package/defaults/app-with-backend/src/pages/Home.tsx +3 -3
  18. package/defaults/app-with-backend/src/pages/PageNotFound.tsx +2 -1
  19. package/defaults/app-with-backend/src/routes.tsx +8 -7
  20. package/defaults/app-with-backend/src/theme.css +95 -0
  21. package/defaults/app-with-backend/src/types.ts +14 -0
  22. package/defaults/app-with-backend/tsconfig.json +9 -6
  23. package/defaults/package/package.json +30 -3
  24. package/defaults/package/src/index.ts +1 -1
  25. package/defaults/package/src/ontologies/example-ontology.ts +4 -4
  26. package/defaults/package/src/package.ts +2 -1
  27. package/defaults/shape.ts +1 -1
  28. package/lib/cjs/cli-methods.js +376 -113
  29. package/lib/cjs/cli-methods.js.map +1 -1
  30. package/lib/cjs/cli.js +15 -1
  31. package/lib/cjs/cli.js.map +1 -1
  32. package/lib/cjs/config-grunt.cjs +3 -3
  33. package/lib/cjs/config-grunt.cjs.map +1 -1
  34. package/lib/cjs/config-webpack-app.js +277 -133
  35. package/lib/cjs/config-webpack-app.js.map +1 -1
  36. package/lib/cjs/config-webpack.js +30 -22
  37. package/lib/cjs/config-webpack.js.map +1 -1
  38. package/lib/cjs/index.js +3 -1
  39. package/lib/cjs/index.js.map +1 -1
  40. package/lib/cjs/loaders/css-loader.mjs +28 -24
  41. package/lib/cjs/loaders/css-loader.mjs.map +1 -1
  42. package/lib/cjs/loaders/register.js +5 -0
  43. package/lib/cjs/loaders/register.js.map +1 -1
  44. package/lib/cjs/package.json +12 -10
  45. package/lib/cjs/plugins/check-imports.js +1 -1
  46. package/lib/cjs/plugins/check-imports.js.map +1 -1
  47. package/lib/cjs/plugins/declaration-plugin.js +17 -7
  48. package/lib/cjs/plugins/declaration-plugin.js.map +1 -1
  49. package/lib/cjs/plugins/externalise-modules.js.map +1 -1
  50. package/lib/cjs/plugins/lincd-tailwind-sources.js +32 -0
  51. package/lib/cjs/plugins/lincd-tailwind-sources.js.map +1 -0
  52. package/lib/cjs/plugins/watch-run.js.map +1 -1
  53. package/lib/cjs/tailwind.config.js +18 -0
  54. package/lib/cjs/tailwind.config.js.map +1 -0
  55. package/lib/cjs/utils.js +103 -41
  56. package/lib/cjs/utils.js.map +1 -1
  57. package/lib/esm/cli-methods.js +360 -113
  58. package/lib/esm/cli-methods.js.map +1 -1
  59. package/lib/esm/cli.js +16 -2
  60. package/lib/esm/cli.js.map +1 -1
  61. package/lib/esm/config-grunt.cjs +29 -26
  62. package/lib/esm/config-grunt.cjs.map +1 -1
  63. package/lib/esm/config-webpack-app.js +259 -123
  64. package/lib/esm/config-webpack-app.js.map +1 -1
  65. package/lib/esm/config-webpack.js +12 -13
  66. package/lib/esm/config-webpack.js.map +1 -1
  67. package/lib/esm/index.js +1 -0
  68. package/lib/esm/index.js.map +1 -1
  69. package/lib/esm/loaders/css-loader.mjs +23 -12
  70. package/lib/esm/loaders/css-loader.mjs.map +1 -1
  71. package/lib/esm/loaders/register.js +5 -0
  72. package/lib/esm/loaders/register.js.map +1 -1
  73. package/lib/esm/package.json +12 -10
  74. package/lib/esm/plugins/check-imports.js.map +1 -1
  75. package/lib/esm/plugins/declaration-plugin.js.map +1 -1
  76. package/lib/esm/plugins/externalise-modules.js.map +1 -1
  77. package/lib/esm/plugins/lincd-tailwind-sources.js +27 -0
  78. package/lib/esm/plugins/lincd-tailwind-sources.js.map +1 -0
  79. package/lib/esm/plugins/watch-run.js.map +1 -1
  80. package/lib/esm/tailwind.config.js +13 -0
  81. package/lib/esm/tailwind.config.js.map +1 -0
  82. package/lib/esm/utils.js +73 -24
  83. package/lib/esm/utils.js.map +1 -1
  84. package/lib-template/cjs/package.json +3 -0
  85. package/lib-template/esm/package.json +3 -0
  86. package/package.json +15 -12
  87. package/defaults/app-with-backend/babel.config.js +0 -4
  88. package/defaults/app-with-backend/src/App.scss +0 -6
  89. package/defaults/app-with-backend/src/App.scss.json +0 -1
  90. package/defaults/app-with-backend/src/components/Error.scss.json +0 -1
  91. package/defaults/app-with-backend/src/components/Spinner.scss.json +0 -1
  92. package/defaults/app-with-backend/src/layout/DefaultLayout.scss +0 -6
  93. package/defaults/app-with-backend/src/layout/DefaultLayout.scss.json +0 -1
  94. package/defaults/app-with-backend/src/layout/Header.scss +0 -10
  95. package/defaults/app-with-backend/src/layout/Header.scss.json +0 -1
  96. package/defaults/app-with-backend/src/pages/Home.scss.json +0 -1
  97. package/defaults/app-with-backend/src/scss/global-overwrites.scss +0 -11
  98. package/defaults/app-with-backend/src/scss/variables.scss +0 -23
  99. /package/defaults/app-with-backend/{web → public}/favicon-144x144.png +0 -0
  100. /package/defaults/app-with-backend/{web → public}/favicon-57x57.png +0 -0
  101. /package/defaults/app-with-backend/{web → public}/favicon-72x72.png +0 -0
  102. /package/defaults/app-with-backend/{web → public}/favicon.ico +0 -0
  103. /package/defaults/app-with-backend/src/components/{Error.scss → Error.module.css} +0 -0
  104. /package/defaults/app-with-backend/src/components/{Spinner.scss → Spinner.module.css} +0 -0
  105. /package/defaults/app-with-backend/src/pages/{Home.scss → Home.module.css} +0 -0
  106. /package/defaults/package/src/{types.d.ts → types.ts} +0 -0
@@ -13,10 +13,11 @@ import depcheck from 'depcheck';
13
13
  import { getEnvFile } from 'env-cmd/dist/get-env-vars.js';
14
14
  import fs from 'fs-extra';
15
15
  import path, { dirname } from 'path';
16
- import { debugInfo, execp, execPromise, getFileImports, getFiles, getLastCommitTime, getPackageJSON, isValidLINCDImport, needsRebuilding, } from './utils.js';
16
+ import { debugInfo, execp, execPromise, getFileImports, getFiles, getLastCommitTime, getPackageJSON, isImportOutsideOfPackage, isImportWithMissingExtension, isInvalidLINCDImport, needsRebuilding, } from './utils.js';
17
17
  import { statSync } from 'fs';
18
18
  import { findNearestPackageJson } from 'find-nearest-package-json';
19
19
  import { LinkedFileStorage } from 'lincd/utils/LinkedFileStorage';
20
+ import { spawn as spawnChild } from 'child_process';
20
21
  // import pkg from 'lincd/utils/LinkedFileStorage';
21
22
  // const { LinkedFileStorage } = pkg;
22
23
  // const config = require('lincd-server/site.webpack.config');
@@ -24,8 +25,10 @@ import { glob } from 'glob';
24
25
  import webpack from 'webpack';
25
26
  import stagedGitFiles from 'staged-git-files';
26
27
  import ora from 'ora';
28
+ //@ts-ignore
29
+ let dirname__ = typeof __dirname !== 'undefined' ? __dirname : dirname(import.meta.url).replace('file:/', '');
27
30
  var variables = {};
28
- export const createApp = (name, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
31
+ export const createApp = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...args_1], void 0, function* (name, basePath = process.cwd()) {
29
32
  if (!name) {
30
33
  console.warn('Please provide a name as the first argument');
31
34
  }
@@ -34,7 +37,7 @@ export const createApp = (name, basePath = process.cwd()) => __awaiter(void 0, v
34
37
  if (!fs.existsSync(targetFolder)) {
35
38
  fs.mkdirSync(targetFolder);
36
39
  }
37
- fs.copySync(path.join(__dirname, '..', 'defaults', 'app-with-backend'), targetFolder);
40
+ fs.copySync(path.join(dirname__, '..', '..', 'defaults', 'app-with-backend'), targetFolder);
38
41
  //make sure the data folder exists (even though its empty).. copying empty folders does not work with fs.copySync
39
42
  fs.mkdirSync(path.join(targetFolder, 'data'), { recursive: true });
40
43
  fs.mkdirSync(path.join(targetFolder, 'data/uploads/resized'), {
@@ -138,7 +141,7 @@ function checkPackagePath(rootPath, packagePath, res) {
138
141
  }
139
142
  }
140
143
  }
141
- function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStackEnd, sync = false) {
144
+ export function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStackEnd, sync = false) {
142
145
  let dependencies = new Map();
143
146
  //get dependencies of each package
144
147
  let leastDependentPackage;
@@ -605,7 +608,7 @@ const camelCase = (str) => {
605
608
  }
606
609
  return str;
607
610
  };
608
- export const createOntology = (prefix, uriBase, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
611
+ export const createOntology = (prefix_1, uriBase_1, ...args_1) => __awaiter(void 0, [prefix_1, uriBase_1, ...args_1], void 0, function* (prefix, uriBase, basePath = process.cwd()) {
609
612
  if (!prefix) {
610
613
  console.warn('Please provide a suggested prefix as the first argument');
611
614
  return;
@@ -620,18 +623,18 @@ export const createOntology = (prefix, uriBase, basePath = process.cwd()) => __a
620
623
  //copy ontology accessor file
621
624
  log('Creating files for ontology \'' + prefix + '\'');
622
625
  let targetFile = path.join(targetFolder, hyphenName + '.ts');
623
- fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
626
+ fs.copySync(path.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
624
627
  //copy data files
625
628
  let targetDataFile = path.join(targetFolder, '..', 'data', hyphenName + '.json');
626
629
  let targetDataFile2 = path.join(targetFolder, '..', 'data', hyphenName + '.json.d.ts');
627
- fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json'), targetDataFile);
628
- fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
630
+ fs.copySync(path.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json'), targetDataFile);
631
+ fs.copySync(path.join(dirname__, '..', '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
629
632
  yield replaceVariablesInFiles(targetFile, targetDataFile, targetDataFile2);
630
633
  log(`Prepared a new ontology data files in ${chalk.magenta(targetDataFile.replace(basePath, ''))}`, `And an ontology accessor file in ${chalk.magenta(targetFile.replace(basePath, ''))}`);
631
634
  //if this is not a lincd app (but a lincd package instead)
632
635
  if (!sourceFolder.includes('frontend')) {
633
636
  //then also add an import to index
634
- let indexPath = addLineToIndex(`import './ontologies/${hyphenName}';`, 'ontologies');
637
+ let indexPath = addLineToIndex(`import './ontologies/${hyphenName}.js';`, 'ontologies');
635
638
  log(`Added an import of this file from ${chalk.magenta(indexPath)}`);
636
639
  }
637
640
  });
@@ -755,17 +758,20 @@ function getSourceFolder(basePath = process.cwd()) {
755
758
  * get __dirname for either ESM/CJS
756
759
  */
757
760
  export const getScriptDir = () => {
758
- // @ts-ignore
759
- if (typeof __dirname !== 'undefined') {
760
- // @ts-ignore
761
- return __dirname;
762
- }
763
- else {
764
- // @ts-ignore
765
- return dirname(import.meta.url).replace('file:/', '');
766
- }
761
+ return dirname__;
762
+ // // @ts-ignore
763
+ // if (typeof __dirname !== 'undefined')
764
+ // {
765
+ // // @ts-ignore
766
+ // return __dirname;
767
+ // }
768
+ // else
769
+ // {
770
+ // // @ts-ignore
771
+ // return dirname(import.meta.url).replace('file:/','');
772
+ // }
767
773
  };
768
- export const createShape = (name, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
774
+ export const createShape = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...args_1], void 0, function* (name, basePath = process.cwd()) {
769
775
  let sourceFolder = getSourceFolder(basePath);
770
776
  let targetFolder = ensureFolderExists(sourceFolder, 'shapes');
771
777
  let { hyphenName, camelCaseName, underscoreName } = setNameVariables(name);
@@ -779,11 +785,11 @@ export const createShape = (name, basePath = process.cwd()) => __awaiter(void 0,
779
785
  //if this is NOT a lincd app (but a lincd package)
780
786
  let indexPath;
781
787
  if (!sourceFolder.includes('frontend')) {
782
- indexPath = addLineToIndex(`import './shapes/${hyphenName}';`, 'shapes');
788
+ indexPath = addLineToIndex(`import './shapes/${hyphenName}.js';`, 'shapes');
783
789
  log(`Added an import of this file from ${chalk.magenta(indexPath)}`);
784
790
  }
785
791
  });
786
- export const createSetComponent = (name, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
792
+ export const createSetComponent = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...args_1], void 0, function* (name, basePath = process.cwd()) {
787
793
  let targetFolder = ensureFolderExists(basePath, 'src', 'components');
788
794
  let { hyphenName, camelCaseName, underscoreName } = setNameVariables(name);
789
795
  //copy default shape file
@@ -794,10 +800,10 @@ export const createSetComponent = (name, basePath = process.cwd()) => __awaiter(
794
800
  fs.copySync(path.join(getScriptDir(), '..', '..', 'defaults', 'component.scss'), targetFile2);
795
801
  //replace variables in some of the copied files
796
802
  yield replaceVariablesInFiles(targetFile, targetFile2);
797
- let indexPath = addLineToIndex(`import './components/${hyphenName}';`, 'components');
803
+ let indexPath = addLineToIndex(`import './components/${hyphenName}.js';`, 'components');
798
804
  log(`Created a new set component in ${chalk.magenta(targetFile.replace(basePath, ''))}`, `Created a new stylesheet in ${chalk.magenta(targetFile2.replace(basePath, ''))}`, `Added an import of this file from ${chalk.magenta(indexPath)}`);
799
805
  });
800
- export const createComponent = (name, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
806
+ export const createComponent = (name_1, ...args_1) => __awaiter(void 0, [name_1, ...args_1], void 0, function* (name, basePath = process.cwd()) {
801
807
  let sourceFolder = getSourceFolder(basePath);
802
808
  let targetFolder = ensureFolderExists(sourceFolder, 'components');
803
809
  let { hyphenName, camelCaseName, underscoreName } = setNameVariables(name);
@@ -813,15 +819,15 @@ export const createComponent = (name, basePath = process.cwd()) => __awaiter(voi
813
819
  //if this is not a lincd app (but a lincd package instead)
814
820
  if (!sourceFolder.includes('frontend')) {
815
821
  //then also add an import to index
816
- let indexPath = addLineToIndex(`import './components/${hyphenName}';`, 'components');
822
+ let indexPath = addLineToIndex(`import './components/${hyphenName}.js';`, 'components');
817
823
  log(`Added an import of this file from ${chalk.magenta(indexPath)}`);
818
824
  }
819
825
  });
820
826
  //read the source of all ts/tsx files in the src folder
821
827
  //if there is an import that imports a lincd package with /src/ in it, then warn
822
- //if there is an import that imports outside of the src folder, then warn
823
- export const checkImports = (sourceFolder = getSourceFolder(), depth = 0, // Used to check if the import is outside of the src folder
824
- invalidImports = new Map()) => __awaiter(void 0, void 0, void 0, function* () {
828
+ //if there is an import that imports something from outside the src folder, then warn
829
+ export const checkImports = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (sourceFolder = getSourceFolder(), depth = 0, // Used to check if the import is outside the src folder
830
+ invalidImports = new Map()) {
825
831
  const dir = fs.readdirSync(sourceFolder);
826
832
  // Start checking each file in the source folder
827
833
  for (const file of dir) {
@@ -830,40 +836,66 @@ invalidImports = new Map()) => __awaiter(void 0, void 0, void 0, function* () {
830
836
  // INFO: For future use - if this part fails, it could be due to user permissions
831
837
  // i.e. the program not having access to check the file metadata
832
838
  if (!filename.match(/\.tsx?$/)) {
833
- if (statSync(filename).isDirectory()) {
834
- yield checkImports(filename, depth + 1, invalidImports);
839
+ try {
840
+ if (statSync(filename).isDirectory()) {
841
+ yield checkImports(filename, depth + 1, invalidImports);
842
+ }
843
+ else {
844
+ // Ignore all files that aren't one of the following:
845
+ // - .ts
846
+ // - .tsx
847
+ continue;
848
+ }
849
+ }
850
+ catch (e) {
851
+ console.log(e);
835
852
  }
836
- // Ignore all files that aren't one of the following:
837
- // - .ts
838
- // - .tsx
839
- continue;
840
853
  }
841
854
  const allImports = yield getFileImports(filename);
842
- const lincdImports = allImports.filter((i) => i.includes('lincd') || i.includes('..'));
843
- lincdImports.forEach((i) => {
844
- if (!isValidLINCDImport(i, depth)) {
845
- if (!invalidImports.has(filename)) {
846
- invalidImports.set(filename, []);
847
- }
848
- invalidImports.get(filename).push(i);
855
+ if (!invalidImports.has(filename)) {
856
+ invalidImports.set(filename, []);
857
+ }
858
+ allImports.forEach((i) => {
859
+ if (isImportOutsideOfPackage(i, depth)) {
860
+ invalidImports.get(filename).push({
861
+ type: 'outside_package',
862
+ importPath: i,
863
+ });
864
+ }
865
+ if (isInvalidLINCDImport(i, depth)) {
866
+ invalidImports.get(filename).push({
867
+ type: 'lincd',
868
+ importPath: i,
869
+ });
870
+ }
871
+ if (isImportWithMissingExtension(i)) {
872
+ invalidImports.get(filename).push({
873
+ type: 'missing_extension',
874
+ importPath: i,
875
+ });
849
876
  }
850
877
  });
851
878
  }
852
879
  let res = '';
880
+ //check if invalidImports has any
881
+ let flat = [...invalidImports.values()].flat();
853
882
  // All recursion must have finished, display any errors
854
- if (depth === 0 && invalidImports.size > 0) {
883
+ if (depth === 0 && flat.length > 0) {
855
884
  res += chalk.red('Invalid imports found.\n');
856
885
  invalidImports.forEach((value, key) => {
857
886
  // res += '- '+chalk.blueBright(key.split('/').pop()) + ':\n';
858
- value.forEach((i) => {
859
- res += chalk.red(key.split('/').pop() + ' imports from \'' + i + '\'\n');
860
- if (i.indexOf('../../') === 0) {
861
- res +=
862
- 'To fix: import from the NPM package directly.\n';
887
+ value.forEach(({ type, importPath }) => {
888
+ let message = key.split('/').pop() + ' imports from \'' + importPath + '\'';
889
+ if (type === 'outside_package') {
890
+ message += ' which is outside the package source root';
863
891
  }
864
- else if ('/src/') {
865
- res += 'To fix: you likely need to replace /src with /lib\n';
892
+ if (type === 'lincd') {
893
+ message += ' which should not contain /src/ or /lib/ in the import path';
866
894
  }
895
+ if (type === 'missing_extension') {
896
+ message += ' which should end with a file extension. Like .js or .scss';
897
+ }
898
+ res += chalk.red(message + '\n');
867
899
  });
868
900
  });
869
901
  throw res;
@@ -898,7 +930,7 @@ export const depCheckStaged = () => __awaiter(void 0, void 0, void 0, function*
898
930
  });
899
931
  });
900
932
  });
901
- export const depCheck = (packagePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
933
+ export const depCheck = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (packagePath = process.cwd()) {
902
934
  return new Promise((resolve, reject) => {
903
935
  depcheck(packagePath, {}, (results) => {
904
936
  if (results.missing) {
@@ -918,7 +950,10 @@ export const depCheck = (packagePath = process.cwd()) => __awaiter(void 0, void
918
950
  if (missingLincdPackages.length > 0) {
919
951
  reject(chalk.red(packagePath.split('/').pop() +
920
952
  '\n[ERROR] These LINCD packages are imported but they are not listed in package.json:\n- ' +
921
- missingLincdPackages.join(',\n- ')));
953
+ missingLincdPackages.map(missedKey => {
954
+ const files = results.missing[missedKey];
955
+ return `${missedKey} (${files.length} files: ${files.join(', ')})`;
956
+ }).join(',\n- ')));
922
957
  }
923
958
  else if (missing.length > 0) {
924
959
  resolve(chalk.redBright('warning: ' + packagePath.split('/').pop() +
@@ -985,9 +1020,80 @@ export const ensureEnvironmentLoaded = () => __awaiter(void 0, void 0, void 0, f
985
1020
  }
986
1021
  }
987
1022
  });
988
- export const startServer = (initOnly = false, ServerClass = null) => __awaiter(void 0, void 0, void 0, function* () {
1023
+ export const runMethod = (packageName, method, options) => __awaiter(void 0, void 0, void 0, function* () {
989
1024
  yield ensureEnvironmentLoaded();
990
- let lincdConfig = yield import(path.join(process.cwd(), 'lincd.config.js'));
1025
+ if (options.spawn) {
1026
+ let lincdConfig = (yield import(path.join(process.cwd(), 'lincd.config.js'))).default;
1027
+ //@ts-ignore
1028
+ const ServerClass = (yield import('lincd-server/shapes/LincdServer')).LincdServer;
1029
+ yield import(path.join(process.cwd(), 'scripts', 'storage-config.js'));
1030
+ let server = new ServerClass(Object.assign({ loadAppComponent: () => __awaiter(void 0, void 0, void 0, function* () { return (yield import(path.join(process.cwd(), 'src', 'App'))).default; }) }, lincdConfig));
1031
+ //init the server
1032
+ console.log('Initializing server...');
1033
+ server.initOnly().then(() => {
1034
+ //process the backend method call
1035
+ console.log('Running method ' + method);
1036
+ //mock the request and response objects
1037
+ let request = {
1038
+ body: {},
1039
+ query: {},
1040
+ params: {},
1041
+ headers: {},
1042
+ method: 'POST',
1043
+ url: '/' + packageName + '/' + method,
1044
+ };
1045
+ let response = {
1046
+ status: (statusCode) => {
1047
+ console.log('Response status code:', statusCode);
1048
+ return response;
1049
+ },
1050
+ json: (data) => {
1051
+ console.log('Response data:', data);
1052
+ },
1053
+ send: (data) => {
1054
+ console.log('Response data:', data);
1055
+ },
1056
+ };
1057
+ //TODO; allow sending args
1058
+ server.callBackendMethod(packageName, method, [], request, response).then(() => {
1059
+ console.log('Done');
1060
+ process.exit();
1061
+ });
1062
+ });
1063
+ }
1064
+ else {
1065
+ //reuse the existing running LincdServer instance.
1066
+ //make a HTTP call
1067
+ //'/call/:pkg/:method',
1068
+ fetch(process.env.SITE_ROOT + '/call/' + packageName + '/' + method, {
1069
+ method: 'POST',
1070
+ headers: {
1071
+ 'Content-Type': 'application/json',
1072
+ },
1073
+ }).then((response) => {
1074
+ if (!response.ok) {
1075
+ throw new Error('Network response was not ok');
1076
+ }
1077
+ return response.json();
1078
+ }).then((data) => {
1079
+ console.log('Response data:', data);
1080
+ process.exit();
1081
+ }).catch((error) => {
1082
+ var _a;
1083
+ if (error.code === 'ECONNREFUSED' || ((_a = error.cause) === null || _a === void 0 ? void 0 : _a.code) === 'ECONNREFUSED') {
1084
+ console.error(chalk.red('Could not connect to the backend server. Is it running?'));
1085
+ console.error(`Make sure you ${chalk.magenta('run "yarn start" in a separate process')} before calling this method.`);
1086
+ }
1087
+ else {
1088
+ console.error('Error during backend call:', error);
1089
+ }
1090
+ process.exit(1);
1091
+ });
1092
+ }
1093
+ });
1094
+ export const startServer = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (initOnly = false, ServerClass = null) {
1095
+ yield ensureEnvironmentLoaded();
1096
+ let lincdConfig = (yield import(path.join(process.cwd(), 'lincd.config.js'))).default;
991
1097
  // function scssLoadcall(source, filename) {
992
1098
  // return 'console.log("SCSS CALL: ' + filename + '");\n' + source;
993
1099
  // process.exit();
@@ -1003,7 +1109,16 @@ export const startServer = (initOnly = false, ServerClass = null) => __awaiter(v
1003
1109
  ServerClass = (yield import('lincd-server/shapes/LincdServer')).LincdServer;
1004
1110
  }
1005
1111
  yield import(path.join(process.cwd(), 'scripts', 'storage-config.js'));
1006
- let server = new ServerClass(Object.assign({ loadAppComponent: () => __awaiter(void 0, void 0, void 0, function* () { return (yield import(path.join(process.cwd(), 'src', 'App'))).default; }) }, lincdConfig));
1112
+ let appPromise;
1113
+ if (process.env.NODE_ENV !== 'development') {
1114
+ appPromise = (yield import(path.join(process.cwd(), 'lib', 'App.js'))).default;
1115
+ }
1116
+ else {
1117
+ appPromise = (yield import(path.join(process.cwd(), 'src', 'App.js'))).default;
1118
+ }
1119
+ let server = new ServerClass(Object.assign({ loadAppComponent: () => __awaiter(void 0, void 0, void 0, function* () {
1120
+ return appPromise;
1121
+ }) }, lincdConfig));
1007
1122
  //Important to use slice, because when using clusers, child processes need to be able to read the same arguments
1008
1123
  let args = process.argv.slice(2);
1009
1124
  //if --initOnly is passed, only initialize the server and don't start it
@@ -1015,10 +1130,15 @@ export const startServer = (initOnly = false, ServerClass = null) => __awaiter(v
1015
1130
  }
1016
1131
  });
1017
1132
  export const buildApp = () => __awaiter(void 0, void 0, void 0, function* () {
1133
+ yield buildFrontend();
1134
+ yield buildBackend();
1135
+ console.log(chalk.magenta(`✅ ${process.env.NODE_ENV} app build finished`));
1136
+ });
1137
+ export const buildFrontend = () => __awaiter(void 0, void 0, void 0, function* () {
1018
1138
  yield ensureEnvironmentLoaded();
1019
1139
  const webpackAppConfig = yield (yield import('./config-webpack-app.js')).getWebpackAppConfig();
1020
- console.log(chalk.magenta(`Building ${process.env.NODE_ENV} app bundles`));
1021
- return new Promise((resolve, reject) => {
1140
+ console.log(chalk.magenta(`🛠 Building ${process.env.NODE_ENV} frontend bundles`));
1141
+ yield new Promise((resolve, reject) => {
1022
1142
  webpack(webpackAppConfig, (err, stats) => __awaiter(void 0, void 0, void 0, function* () {
1023
1143
  if (err) {
1024
1144
  console.error(err.stack || err);
@@ -1056,11 +1176,13 @@ export const buildApp = () => __awaiter(void 0, void 0, void 0, function* () {
1056
1176
  // and if we want to upload to storage, we need set S3_BUCKET_ENDPOINT
1057
1177
  if (process.env.NODE_ENV === 'development' || !process.env.S3_BUCKET_ENDPOINT) {
1058
1178
  console.warn('Upload build to storage skip in development environment or S3_BUCKET_ENDPOINT is not set');
1059
- process.exit();
1179
+ return;
1180
+ // process.exit();
1060
1181
  }
1061
1182
  if (process.env.APP_ENV) {
1062
1183
  console.warn('Not uploading to CDN for app builds');
1063
- process.exit();
1184
+ return;
1185
+ // process.exit();
1064
1186
  }
1065
1187
  // load the storage config
1066
1188
  const storageConfig = yield import(path.join(process.cwd(), 'scripts', 'storage-config.js'));
@@ -1076,6 +1198,12 @@ export const buildApp = () => __awaiter(void 0, void 0, void 0, function* () {
1076
1198
  }
1077
1199
  // get all files in the web directory and then upload them to the storage
1078
1200
  const files = yield getFiles(pathDir);
1201
+ console.log(chalk.magenta(`🕊 Publishing ${files.length} public files to linked file storage`));
1202
+ const clearSpinner = ora({
1203
+ discardStdin: true,
1204
+ text: `Publishing ${files.length} public files`,
1205
+ }).start();
1206
+ let counter = 0;
1079
1207
  const uploads = files.map((filePath) => __awaiter(void 0, void 0, void 0, function* () {
1080
1208
  // read file content
1081
1209
  const fileContent = yield fs.promises.readFile(filePath);
@@ -1083,14 +1211,75 @@ export const buildApp = () => __awaiter(void 0, void 0, void 0, function* () {
1083
1211
  // example: /Users/username/project/www/index.html -> /project/www/index.html
1084
1212
  const pathname = filePath.replace(pathDir, `/${rootDirectory}`);
1085
1213
  // upload file to storage
1086
- return yield LinkedFileStorage.saveFile(pathname, fileContent);
1214
+ yield LinkedFileStorage.saveFile(pathname, fileContent).then(() => {
1215
+ clearSpinner.text = `${counter++}/${files.length}: - Published ${pathname} `;
1216
+ }).catch(console.error);
1087
1217
  }));
1088
1218
  const urls = yield Promise.all(uploads);
1089
- console.log(`${urls.length} files uploaded to storage`);
1090
- process.exit();
1219
+ clearSpinner.succeed(`${urls.length} files uploaded to storage`);
1091
1220
  }
1092
1221
  }));
1093
1222
  });
1223
+ export const buildBackend = () => __awaiter(void 0, void 0, void 0, function* () {
1224
+ console.log(chalk.magenta(`🛠 Preparing ${process.env.NODE_ENV} backend`));
1225
+ //run tsc in the backend folder
1226
+ yield ensureEnvironmentLoaded();
1227
+ const sourceFolder = path.join(process.cwd(), 'src');
1228
+ const targetFolder = path.join(process.cwd(), 'lib');
1229
+ // Step 1: Clear lib folder
1230
+ const clearSpinner = ora({
1231
+ discardStdin: true,
1232
+ text: 'Clearing lib folder',
1233
+ }).start();
1234
+ try {
1235
+ if (fs.existsSync(targetFolder)) {
1236
+ yield fs.remove(targetFolder);
1237
+ }
1238
+ clearSpinner.succeed('Lib folder cleared');
1239
+ }
1240
+ catch (e) {
1241
+ console.error(e);
1242
+ clearSpinner.fail('Failed to clear lib folder');
1243
+ return;
1244
+ }
1245
+ // Step 2: Compile TS files
1246
+ const compileSpinner = ora({
1247
+ discardStdin: true,
1248
+ text: 'Compiling backend TS files',
1249
+ }).start();
1250
+ try {
1251
+ yield execPromise(`yarn exec tsc`);
1252
+ compileSpinner.succeed('Backend TS files compiled');
1253
+ }
1254
+ catch (e) {
1255
+ console.error(e);
1256
+ compileSpinner.fail('Failed to compile backend TS files');
1257
+ return;
1258
+ }
1259
+ // Step 3: Copy CSS files
1260
+ const copySpinner = ora({
1261
+ discardStdin: true,
1262
+ text: 'Copying CSS files',
1263
+ }).start();
1264
+ try {
1265
+ const cssFiles = yield getFiles(sourceFolder, '.css');
1266
+ yield Promise.all(cssFiles.map((file) => {
1267
+ const targetFile = file.replace(sourceFolder, targetFolder);
1268
+ //ensure the target folder exists
1269
+ const targetDir = path.dirname(targetFile);
1270
+ if (!fs.existsSync(targetDir)) {
1271
+ fs.mkdirSync(targetDir, { recursive: true });
1272
+ }
1273
+ return fs.copyFile(file, targetFile);
1274
+ }));
1275
+ copySpinner.succeed(`${cssFiles.length} CSS files copied`);
1276
+ }
1277
+ catch (e) {
1278
+ console.error(e);
1279
+ copySpinner.fail('Failed to copy CSS files');
1280
+ }
1281
+ return true;
1282
+ });
1094
1283
  export const upgradePackages = () => __awaiter(void 0, void 0, void 0, function* () {
1095
1284
  yield ensureEnvironmentLoaded();
1096
1285
  // let packages = getLincdPackages();
@@ -1233,7 +1422,7 @@ export const upgradePackages = () => __awaiter(void 0, void 0, void 0, function*
1233
1422
  // })
1234
1423
  // });
1235
1424
  });
1236
- export const createPackage = (name, uriBase, basePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
1425
+ export const createPackage = (name_1, uriBase_1, ...args_1) => __awaiter(void 0, [name_1, uriBase_1, ...args_1], void 0, function* (name, uriBase, basePath = process.cwd()) {
1237
1426
  if (!name) {
1238
1427
  console.warn('Please provide a name as the first argument');
1239
1428
  return;
@@ -1366,31 +1555,36 @@ export const register = function (registryURL) {
1366
1555
  console.warn(chalk.red('Warning:') + ' not found: ' + process.cwd() + '/package.json');
1367
1556
  }
1368
1557
  };
1369
- export const buildPackage = (target, target2, packagePath = process.cwd(), logResults = true) => __awaiter(void 0, void 0, void 0, function* () {
1558
+ export const buildPackage = (target_1, target2_1, ...args_1) => __awaiter(void 0, [target_1, target2_1, ...args_1], void 0, function* (target, target2, packagePath = process.cwd(), logResults = true) {
1370
1559
  let spinner;
1371
1560
  if (logResults) {
1372
1561
  //TODO: replace with listr so we can show multiple processes at once
1373
1562
  spinner = ora({
1374
1563
  discardStdin: true,
1375
- text: 'Compiling code',
1564
+ text: 'Compiling ESM',
1376
1565
  }).start();
1377
1566
  }
1378
1567
  let buildProcess = Promise.resolve(true);
1379
1568
  let buildStep = (step) => {
1380
1569
  buildProcess = buildProcess.then((previousResult) => {
1570
+ if (!previousResult) {
1571
+ return false;
1572
+ }
1381
1573
  if (logResults) {
1382
1574
  spinner.text = step.name;
1383
1575
  spinner.start();
1384
1576
  }
1385
1577
  return step.apply().then(stepResult => {
1578
+ //if a build step returns a string,
1579
+ //a warning is shown but the build is still successful with warnings
1386
1580
  if (typeof stepResult === 'string') {
1387
1581
  // spinner.text = step.name + ' - ' + stepResult;
1388
1582
  if (logResults) {
1389
1583
  spinner.warn(step.name + ' - ' + stepResult);
1390
1584
  spinner.stop();
1391
1585
  }
1392
- //warning is shown, but build is still succesful with warnings
1393
- return false;
1586
+ //can still continue
1587
+ return true;
1394
1588
  }
1395
1589
  else if (stepResult === true || typeof stepResult === 'undefined') {
1396
1590
  if (logResults) {
@@ -1398,13 +1592,31 @@ export const buildPackage = (target, target2, packagePath = process.cwd(), logRe
1398
1592
  }
1399
1593
  return previousResult && true;
1400
1594
  }
1595
+ else if (typeof stepResult === 'object' && stepResult.error) {
1596
+ if (logResults) {
1597
+ spinner.fail(step.name + ' - ' + stepResult.error);
1598
+ spinner.stop();
1599
+ }
1600
+ //failed and should stop
1601
+ return false;
1602
+ }
1401
1603
  });
1402
1604
  });
1403
1605
  };
1404
1606
  buildStep({
1405
- name: 'Compiling code',
1607
+ name: 'Checking imports',
1608
+ apply: () => checkImports(packagePath + '/src'),
1609
+ });
1610
+ buildStep({
1611
+ name: 'Compiling ESM',
1612
+ apply: () => __awaiter(void 0, void 0, void 0, function* () {
1613
+ return compilePackageESM(packagePath);
1614
+ }),
1615
+ });
1616
+ buildStep({
1617
+ name: 'Compiling CJS',
1406
1618
  apply: () => __awaiter(void 0, void 0, void 0, function* () {
1407
- return compilePackage(packagePath);
1619
+ return compilePackageCJS(packagePath);
1408
1620
  }),
1409
1621
  });
1410
1622
  buildStep({
@@ -1441,29 +1653,26 @@ export const buildPackage = (target, target2, packagePath = process.cwd(), logRe
1441
1653
  return removeOldFiles(packagePath);
1442
1654
  }),
1443
1655
  });
1444
- buildStep({
1445
- name: 'Checking imports',
1446
- apply: () => checkImports(packagePath),
1447
- });
1448
1656
  buildStep({
1449
1657
  name: 'Checking dependencies',
1450
1658
  apply: () => depCheck(packagePath),
1451
1659
  });
1452
1660
  let success = yield buildProcess.catch(err => {
1453
- let msg = err.error ? err.error : err.stdout + '\n' + err.stderr;
1661
+ let msg = typeof err === 'string' || err instanceof Error ? err.toString() : (err.error && !err.error.toString().includes('Command failed:') ? err.error : err.stdout + '\n' + err.stderr);
1454
1662
  if (logResults) {
1455
1663
  spinner.stopAndPersist({
1456
1664
  symbol: chalk.red('✖'),
1457
- text: 'Build failed',
1665
+ // text: 'Build failed',
1458
1666
  });
1459
1667
  }
1460
1668
  else {
1461
1669
  console.log(chalk.red(packagePath.split('/').pop(), ' - Build failed:'));
1670
+ console.log(err);
1462
1671
  }
1463
1672
  console.log(msg);
1464
1673
  });
1465
1674
  //will be undefined if there was an error
1466
- if (typeof success !== 'undefined') {
1675
+ if (typeof success !== 'undefined' && success !== false) {
1467
1676
  if (logResults) {
1468
1677
  spinner.stopAndPersist({
1469
1678
  symbol: chalk.greenBright('✔'),
@@ -1471,31 +1680,57 @@ export const buildPackage = (target, target2, packagePath = process.cwd(), logRe
1471
1680
  });
1472
1681
  }
1473
1682
  }
1683
+ else {
1684
+ spinner.stopAndPersist({
1685
+ symbol: chalk.red('✖'),
1686
+ text: 'Build failed',
1687
+ });
1688
+ }
1474
1689
  return success;
1475
1690
  });
1476
- export const compilePackage = (packagePath = process.cwd()) => __awaiter(void 0, void 0, void 0, function* () {
1691
+ export const compilePackage = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (packagePath = process.cwd()) {
1477
1692
  //echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
1478
- let cjsConfig = fs.existsSync(path.join(packagePath, 'tsconfig-cjs.json'));
1479
- let esmConfig = fs.existsSync(path.join(packagePath, 'tsconfig-esm.json'));
1480
- let compileCJS = `yarn exec tsc -p tsconfig-cjs.json`;
1481
- let compileESM = `yarn exec tsc -p tsconfig-esm.json`;
1482
- let compileCommand;
1483
- if (cjsConfig && esmConfig) {
1484
- compileCommand = `${compileCJS} && ${compileESM}`;
1485
- }
1486
- else if (cjsConfig) {
1487
- compileCommand = compileCJS;
1488
- }
1489
- else if (esmConfig) {
1490
- compileCommand = compileESM;
1491
- }
1492
- else {
1493
- compileCommand = `yarn exec tsc`;
1494
- }
1693
+ // let cjsConfig = fs.existsSync(path.join(packagePath,'tsconfig-cjs.json'));
1694
+ // let esmConfig = fs.existsSync(path.join(packagePath,'tsconfig-esm.json'));
1695
+ // let compileCJS = `yarn exec tsc -p tsconfig-cjs.json`;
1696
+ // let compileESM = `yarn exec tsc -p tsconfig-esm.json`;
1697
+ // let compileCommand;
1698
+ // if (cjsConfig && esmConfig)
1699
+ // {
1700
+ // compileCommand = `${compileCJS} && ${compileESM}`;
1701
+ // }
1702
+ // else if (cjsConfig)
1703
+ // {
1704
+ // compileCommand = compileCJS;
1705
+ // }
1706
+ // else if (esmConfig)
1707
+ // {
1708
+ // compileCommand = compileESM;
1709
+ // }
1710
+ // else
1711
+ // {
1712
+ // compileCommand = `yarn exec tsc`;
1713
+ // }
1714
+ yield compilePackageESM(packagePath);
1715
+ yield compilePackageCJS(packagePath);
1716
+ });
1717
+ export const compilePackageESM = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (packagePath = process.cwd()) {
1718
+ //echo 'compiling CJS' && tsc -p tsconfig-cjs.json && echo 'compiling ESM' && tsc -p tsconfig-esm.json
1719
+ let compileCommand = `yarn exec tsc -p tsconfig-esm.json`;
1495
1720
  return execPromise(compileCommand, false, false, { cwd: packagePath }).then(res => {
1496
1721
  return res === '';
1497
1722
  });
1498
1723
  });
1724
+ export const compilePackageCJS = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (packagePath = process.cwd()) {
1725
+ let compileCommand = `yarn exec tsc -p tsconfig-cjs.json`;
1726
+ return execPromise(compileCommand, false, false, { cwd: packagePath }).then(res => {
1727
+ return res === '';
1728
+ }).catch(err => {
1729
+ return {
1730
+ error: err.stdout,
1731
+ };
1732
+ });
1733
+ });
1499
1734
  export var publishUpdated = function (test = false) {
1500
1735
  let packages = getLocalLincdModules();
1501
1736
  var p = Promise.resolve('');
@@ -1640,8 +1875,8 @@ export var publishUpdated = function (test = false) {
1640
1875
  // }
1641
1876
  });
1642
1877
  };
1643
- function getEnvJsonPath(relativeToPath = process.cwd()) {
1644
- return __awaiter(this, void 0, void 0, function* () {
1878
+ function getEnvJsonPath() {
1879
+ return __awaiter(this, arguments, void 0, function* (relativeToPath = process.cwd()) {
1645
1880
  let path = '';
1646
1881
  if (!relativeToPath.endsWith('/')) {
1647
1882
  relativeToPath += '/';
@@ -1703,8 +1938,8 @@ export var publishPackage = function (pkg, test, info, publishVersion) {
1703
1938
  });
1704
1939
  });
1705
1940
  };
1706
- export var buildUpdated = function (back, target, target2, useGitForLastModified = false, test = false) {
1707
- return __awaiter(this, void 0, void 0, function* () {
1941
+ export var buildUpdated = function (back_1, target_1, target2_1) {
1942
+ return __awaiter(this, arguments, void 0, function* (back, target, target2, useGitForLastModified = false, test = false) {
1708
1943
  // back = back || 1;
1709
1944
  // return execPromise(`git log -${back} --format=%ci`).then((result) => {
1710
1945
  // let now = new Date();
@@ -1715,16 +1950,26 @@ export var buildUpdated = function (back, target, target2, useGitForLastModified
1715
1950
  // let packages = getLocalLincdModules();
1716
1951
  let packages = getLocalLincdPackageMap();
1717
1952
  // console.log(packages);
1718
- let jsonldPkgUpdated = yield needsRebuilding(packages.get('lincd-jsonld'), useGitForLastModified);
1953
+ // let jsonldPkgUpdated = await needsRebuilding(
1954
+ // packages.get('lincd-jsonld'),
1955
+ // useGitForLastModified,
1956
+ // );
1719
1957
  // let cliPkgUpdated = await needsRebuilding(packages.get('lincd-cli'), useGitForLastModified);
1720
1958
  //if either cli or jsonldPkg needs to be rebuilt
1721
1959
  // if (jsonldPkgUpdated || cliPkgUpdated) {
1722
- if (jsonldPkgUpdated) {
1723
- yield execPromise('yarn exec tsc && echo "compiled lincd-jsonld"', false, false, {
1724
- cwd: packages.get('lincd-jsonld').path,
1725
- }, true);
1726
- // await execPromise('yarn build-core', false, false, {}, true);
1727
- }
1960
+ // if (jsonldPkgUpdated)
1961
+ // {
1962
+ // await execPromise(
1963
+ // 'yarn exec tsc && echo "compiled lincd-jsonld"',
1964
+ // false,
1965
+ // false,
1966
+ // {
1967
+ // cwd: packages.get('lincd-jsonld').path,
1968
+ // },
1969
+ // true,
1970
+ // );
1971
+ // // await execPromise('yarn build-core', false, false, {}, true);
1972
+ // }
1728
1973
  let rebuildAllModules = false;
1729
1974
  // if (cliPkgUpdated) {
1730
1975
  // rebuildAllModules = true;
@@ -1738,9 +1983,10 @@ export var buildUpdated = function (back, target, target2, useGitForLastModified
1738
1983
  return (pkg) => __awaiter(this, void 0, void 0, function* () {
1739
1984
  // debugInfo('# Checking package ' + pkg.packageName);
1740
1985
  let needRebuild = yield needsRebuilding(pkg, useGitForLastModified);
1741
- if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated) {
1742
- needRebuild = true;
1743
- }
1986
+ // if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated)
1987
+ // {
1988
+ // needRebuild = true;
1989
+ // }
1744
1990
  if (needRebuild || rebuildAllModules) {
1745
1991
  //TODO: when building a pkg, also rebuild all packages that depend on this package.. and iteratively build packages that depend on those packages..
1746
1992
  // log(packageName+' modified since last commit on '+now.toString());
@@ -1856,8 +2102,8 @@ export var addLinesToFile = function (filePath, entries) {
1856
2102
  });
1857
2103
  fs.writeFileSync(filePath, fileContents);
1858
2104
  };
1859
- export var addCapacitor = function (basePath = process.cwd()) {
1860
- return __awaiter(this, void 0, void 0, function* () {
2105
+ export var addCapacitor = function () {
2106
+ return __awaiter(this, arguments, void 0, function* (basePath = process.cwd()) {
1861
2107
  let targetFolder = ensureFolderExists(basePath);
1862
2108
  log('Adding capacitor');
1863
2109
  fs.copySync(path.join(getScriptDir(), '..', '..', 'defaults', 'app-static'), targetFolder);
@@ -1918,13 +2164,14 @@ export var executeCommandForPackage = function (packageName, command) {
1918
2164
  if (packageDetails) {
1919
2165
  log('Executing \'cd ' +
1920
2166
  packageDetails.path +
1921
- ' && yarn exec lincd' +
2167
+ ' && yarn lincd' +
1922
2168
  (command ? ' ' + command : '') +
1923
2169
  '\'');
1924
- return execp('cd ' +
1925
- packageDetails.path +
1926
- ' && yarn exec lincd' +
1927
- (command ? ' ' + command : ''));
2170
+ spawnChild(process.platform === 'win32' ? 'yarn.cmd' : 'yarn', // Windows quirk
2171
+ ['lincd', command || null], {
2172
+ cwd: packageDetails.path,
2173
+ stdio: 'inherit',
2174
+ });
1928
2175
  }
1929
2176
  else {
1930
2177
  warn('Could not find a pkg who\'s name (partially) matched ' +