@wavemaker/rn-codegen 11.15.6-rc.647667 → 11.16.0-rc.647821

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 (89) hide show
  1. package/command.js +39 -9
  2. package/command.js.map +1 -1
  3. package/npm-shrinkwrap.json +201 -213
  4. package/package-lock.json +201 -213
  5. package/package.json +7 -4
  6. package/src/app.generator.js +167 -36
  7. package/src/app.generator.js.map +1 -1
  8. package/src/increment-builder.js +2 -1
  9. package/src/increment-builder.js.map +1 -1
  10. package/src/project.service.js +14 -0
  11. package/src/project.service.js.map +1 -1
  12. package/src/templates/app.template +74 -2
  13. package/src/templates/babel.config.js.template +3 -6
  14. package/src/templates/bootstrap.template +11 -1
  15. package/src/templates/component/component.template +1 -0
  16. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/icon.less +6 -4
  17. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/label.less +46 -4
  18. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
  19. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/data/form.less +14 -0
  20. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/chips.less +37 -0
  21. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/select.less +29 -1
  22. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/switch.less +4 -4
  23. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/navigation/menu.less +1 -0
  24. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/basic/icon.less +0 -3
  25. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/container/tabs.less +5 -1
  26. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/input/form.less +20 -5
  27. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/tokens.light.css +18 -1
  28. package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/variables/chips.variant.less +5 -1
  29. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/icon.less +6 -4
  30. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/label.less +46 -4
  31. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
  32. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/data/form.less +14 -0
  33. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/chips.less +37 -0
  34. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/select.less +29 -1
  35. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/switch.less +4 -4
  36. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/navigation/menu.less +1 -0
  37. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/basic/icon.less +0 -3
  38. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/container/tabs.less +5 -1
  39. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/input/form.less +20 -5
  40. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/tokens.light.css +18 -1
  41. package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/variables/chips.variant.less +5 -1
  42. package/src/templates/foundation-theme/dist/android/style.css +20 -3
  43. package/src/templates/foundation-theme/dist/android/style.js +178 -50
  44. package/src/templates/foundation-theme/dist/android/tokens.js +18 -1
  45. package/src/templates/foundation-theme/dist/ios/style.css +20 -3
  46. package/src/templates/foundation-theme/dist/ios/style.js +178 -50
  47. package/src/templates/foundation-theme/dist/ios/tokens.js +18 -1
  48. package/src/templates/foundation-theme/wavemaker/design-tokens/basic/icon.less +6 -4
  49. package/src/templates/foundation-theme/wavemaker/design-tokens/basic/label.less +46 -4
  50. package/src/templates/foundation-theme/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
  51. package/src/templates/foundation-theme/wavemaker/design-tokens/data/form.less +14 -0
  52. package/src/templates/foundation-theme/wavemaker/design-tokens/input/chips.less +37 -0
  53. package/src/templates/foundation-theme/wavemaker/design-tokens/input/select.less +29 -1
  54. package/src/templates/foundation-theme/wavemaker/design-tokens/input/switch.less +4 -4
  55. package/src/templates/foundation-theme/wavemaker/design-tokens/navigation/menu.less +1 -0
  56. package/src/templates/foundation-theme/wavemaker/design-tokens/studio/basic/icon.less +0 -3
  57. package/src/templates/foundation-theme/wavemaker/design-tokens/studio/container/tabs.less +5 -1
  58. package/src/templates/foundation-theme/wavemaker/design-tokens/studio/input/form.less +20 -5
  59. package/src/templates/foundation-theme/wavemaker/design-tokens/tokens.light.css +18 -1
  60. package/src/templates/foundation-theme/wavemaker/design-tokens/variables/chips.variant.less +5 -1
  61. package/src/templates/package.web.json +5 -4
  62. package/src/templates/project/.npmrc +1 -0
  63. package/src/templates/project/app.json +2 -1
  64. package/src/templates/project/esbuild/esbuild.script.js +42 -2
  65. package/src/templates/project/metro.config.js +7 -1
  66. package/src/templates/project/package.json +5 -4
  67. package/src/templates/project/plugins/expo-pull-to-refresh/android/build.gradle +15 -0
  68. package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshModule.kt +21 -0
  69. package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshView.kt +221 -0
  70. package/src/templates/project/plugins/expo-pull-to-refresh/expo-module.config.json +16 -0
  71. package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefresh.podspec +24 -0
  72. package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlModule.swift +17 -0
  73. package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlView.swift +92 -0
  74. package/src/templates/project/plugins/expo-pull-to-refresh/package.json +15 -0
  75. package/src/templates/project/scripts/wm-babel.transform.plugin.js +11 -1
  76. package/src/theme/rn-stylesheet.transpiler.js +30 -6
  77. package/src/theme/rn-stylesheet.transpiler.js.map +1 -1
  78. package/src/transpile/components/container/wizard/wizardstep.transformer.js +10 -2
  79. package/src/transpile/components/container/wizard/wizardstep.transformer.js.map +1 -1
  80. package/src/transpile/components/page/page.transformer.js +11 -1
  81. package/src/transpile/components/page/page.transformer.js.map +1 -1
  82. package/src/transpile/property/property-parser.js +7 -1
  83. package/src/transpile/property/property-parser.js.map +1 -1
  84. package/src/transpile/style.transformer.js +1 -0
  85. package/src/transpile/style.transformer.js.map +1 -1
  86. package/src/transpile/transpile.js +10 -1
  87. package/src/transpile/transpile.js.map +1 -1
  88. package/src/variables/variable.transformer.js +7 -7
  89. package/src/variables/variable.transformer.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker/rn-codegen",
3
- "version": "11.15.6-rc.647667",
3
+ "version": "11.16.0-rc.647821",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -25,8 +25,8 @@
25
25
  "@types/node": "18.11.10",
26
26
  "@types/prettier": "2.7.1",
27
27
  "@types/yargs": "17.0.15",
28
- "@wavemaker/custom-widgets-m3": "11.15.6-rc.647667",
29
- "@wavemaker/foundation-css": "11.15.6-rc.647667",
28
+ "@wavemaker/custom-widgets-m3": "11.16.0-rc.647821",
29
+ "@wavemaker/foundation-css": "11.16.0-rc.647821",
30
30
  "adm-zip": "0.5.9",
31
31
  "axios": "1.8.3",
32
32
  "clean-css": "5.1.5",
@@ -38,7 +38,7 @@
38
38
  "handlebars": "4.7.7",
39
39
  "html-entities": "2.3.2",
40
40
  "less": "4.1.1",
41
- "lodash": "4.17.21",
41
+ "lodash": "4.18.1",
42
42
  "node-html-parser": "5.0.0",
43
43
  "prettier": "2.3.0",
44
44
  "puppeteer": "5.4.0",
@@ -46,6 +46,9 @@
46
46
  "style-dictionary": "4.1.0",
47
47
  "yargs": "16.2.0"
48
48
  },
49
+ "overrides": {
50
+ "debug": "4.4.0"
51
+ },
49
52
  "devDependencies": {
50
53
  "@types/adm-zip": "0.5.0",
51
54
  "@types/babel__generator": "7.6.4",
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const fs_extra_1 = __importDefault(require("fs-extra"));
30
+ const crypto_1 = __importDefault(require("crypto"));
30
31
  const path_1 = require("path");
31
32
  const lodash_1 = require("lodash");
32
33
  const execa_1 = __importDefault(require("execa"));
@@ -468,6 +469,26 @@ class AppGenerator {
468
469
  (0, utils_1.writeFile)(`${this.projectPath}/wm_rn_config.json`, JSON.stringify(config, null, 4));
469
470
  });
470
471
  }
472
+ // Copies each enabled profile's pre-built <profile>.json into the generated app, and removes stale ones.
473
+ generateGlobalConfig() {
474
+ if (this.incBuilder) {
475
+ console.log(`Copying Global config.`);
476
+ }
477
+ return this.projectService.getRNConfig().then(data => {
478
+ const config = JSON.parse(data);
479
+ const enabledProfiles = config.enabledProfiles || [];
480
+ // Tracks profiles generated last time, so one removed (or whose file was deleted outright) still gets cleaned up.
481
+ const manifestPath = `${this.projectPath}/.profiles-manifest.json`;
482
+ const previousProfiles = fs_extra_1.default.existsSync(manifestPath) ? JSON.parse(fs_extra_1.default.readFileSync(manifestPath, 'utf8')) : [];
483
+ previousProfiles
484
+ .filter((profileName) => !enabledProfiles.includes(profileName))
485
+ .forEach((profileName) => fs_extra_1.default.removeSync(`${this.projectPath}/${profileName}.json`));
486
+ (0, utils_1.writeFile)(manifestPath, JSON.stringify(enabledProfiles));
487
+ return Promise.all(enabledProfiles.map(profileName => this.projectService.getGlobalConfig(profileName).then(data => {
488
+ (0, utils_1.writeFile)(`${this.projectPath}/${profileName}.json`, data);
489
+ })));
490
+ });
491
+ }
471
492
  removeOldKeys(splash) {
472
493
  const keysToRemove = ['animationSrc', 'width', 'height', 'modifiedSrc'];
473
494
  const filterKeys = (obj) => Object.fromEntries(Object.entries(obj).filter(([key]) => !keysToRemove.includes(key)));
@@ -592,23 +613,30 @@ class AppGenerator {
592
613
  }
593
614
  return this.projectService.getAppVariables().then(variables => {
594
615
  return this.projectService.getAppJs().then(script => {
595
- var _a;
596
- const supportedLocaleVariable = (_a = Object.values(variables).filter((v) => (v.startUpdate || v.category === 'wm.Variable') && v.name === 'supportedLocale')) === null || _a === void 0 ? void 0 : _a[0];
597
- const localeDataset = Object.keys(supportedLocaleVariable === null || supportedLocaleVariable === void 0 ? void 0 : supportedLocaleVariable.dataSet);
598
- const supportedLocales = localeDataset.filter(utils_1.isValidLocale);
599
- const output = APP_TEMPLATE({
600
- script: script,
601
- startUpVariables: Object.values(variables).filter((v) => (v.startUpdate || v.category === 'wm.Variable') && v.category !== 'wm.TimerVariable').map((v) => v.name),
602
- startUpActions: Object.values(variables).filter((v) => v.startUpdate && v.category === 'wm.TimerVariable').map((v) => v.name),
603
- autoUpdateVariables: Object.values(variables).filter((v) => v.autoUpdate || ((v.category === 'wm.Variable' || v.category === 'wm.LiveVariable') && v.dataBinding && v.dataBinding.length)).map((v) => v.name),
604
- supportedLocales: supportedLocales,
605
- animatedSplash: animatedSplash,
606
- sslPinning: sslPinning,
607
- enableWavePulse: enableWavePulse,
608
- enableDesignTokens: !!config.preferences.enableDesignTokens,
609
- enableAdaptiveColorMode: !!config.enableAdaptiveColorMode
616
+ return this.projectService.getAppWrapperJs().then(appWrapperJs => {
617
+ var _a;
618
+ const supportedLocaleVariable = (_a = Object.values(variables).filter((v) => (v.startUpdate || v.category === 'wm.Variable') && v.name === 'supportedLocale')) === null || _a === void 0 ? void 0 : _a[0];
619
+ const localeDataset = Object.keys(supportedLocaleVariable === null || supportedLocaleVariable === void 0 ? void 0 : supportedLocaleVariable.dataSet);
620
+ const supportedLocales = localeDataset.filter(utils_1.isValidLocale);
621
+ if (appWrapperJs) {
622
+ (0, utils_1.writeFile)(`${this.projectPath}/src/customapp.wrapper.js`, appWrapperJs);
623
+ }
624
+ const output = APP_TEMPLATE({
625
+ script: script,
626
+ startUpVariables: Object.values(variables).filter((v) => (v.startUpdate || v.category === 'wm.Variable') && v.category !== 'wm.TimerAction').map((v) => v.name),
627
+ startUpActions: Object.values(variables).filter((v) => v.startUpdate && v.category === 'wm.TimerAction').map((v) => v.name),
628
+ autoUpdateVariables: Object.values(variables).filter((v) => v.autoUpdate || ((v.category === 'wm.Variable' || v.category === 'wm.LiveVariable') && v.dataBinding && v.dataBinding.length)).map((v) => v.name),
629
+ supportedLocales: supportedLocales,
630
+ animatedSplash: animatedSplash,
631
+ sslPinning: sslPinning,
632
+ enableWavePulse: enableWavePulse,
633
+ enableDesignTokens: !!config.preferences.enableDesignTokens,
634
+ enableAdaptiveColorMode: !!config.enableAdaptiveColorMode,
635
+ enabledProfiles: config.enabledProfiles || [],
636
+ customAppWrapper: !!appWrapperJs
637
+ });
638
+ (0, utils_1.writeFile)(`${this.projectPath}/App.js`, output);
610
639
  });
611
- (0, utils_1.writeFile)(`${this.projectPath}/App.js`, output);
612
640
  });
613
641
  });
614
642
  });
@@ -649,7 +677,9 @@ class AppGenerator {
649
677
  return this.themeService.generateStudioStyles(styles);
650
678
  }
651
679
  async generateComponent(info, type, name, dynamicProps) {
652
- if (this.incBuilder && !this.incBuilder.isFragmentModified(name)) {
680
+ // Also regenerate on an app-config change, not just a page edit: a page's cascaded
681
+ // pulltorefresh value (page.transformer.ts) comes from that config too.
682
+ if (this.incBuilder && !this.incBuilder.isFragmentModified(name) && !this.incBuilder.isConfigModified()) {
653
683
  return Promise.resolve();
654
684
  }
655
685
  if (this.incBuilder) {
@@ -690,6 +720,15 @@ class AppGenerator {
690
720
  });
691
721
  }
692
722
  const imports = (0, lodash_1.sortBy)((0, lodash_1.uniqBy)(transpiledOutput.imports, i => i.name + i.from), i => i.name);
723
+ // Pull-to-refresh invokes this page's flagged variables plus the flagged app variables it references.
724
+ const appVariables = await Promise.resolve(this.projectService.getAppVariables()).catch(() => ({}));
725
+ const pageSource = `${info.markup || ''}\n${info.script || ''}`;
726
+ const pullToRefreshVariables = Array.from(new Set([
727
+ ...Object.values(variables).filter((v) => v.pullToRefreshUpdate).map((v) => v.name),
728
+ ...Object.values(appVariables || {})
729
+ .filter((v) => v.pullToRefreshUpdate && new RegExp(`\\bVariables\\.${(0, lodash_1.escapeRegExp)(v.name)}\\b`).test(pageSource))
730
+ .map((v) => v.name),
731
+ ]));
693
732
  const component = COMPONENT_TEMPLATE({
694
733
  name: name,
695
734
  type: type,
@@ -700,9 +739,10 @@ class AppGenerator {
700
739
  prefabName: this.prefabName,
701
740
  markup: '\n' + transpiledOutput.markup,
702
741
  components: transpiledOutput.components,
703
- startUpVariables: Object.values(variables).filter((v) => v.startUpdate && v.category !== 'wm.TimerVariable').map((v) => v.name),
704
- startUpActions: Object.values(variables).filter((v) => v.startUpdate && v.category === 'wm.TimerVariable').map((v) => v.name),
742
+ startUpVariables: Object.values(variables).filter((v) => v.startUpdate && v.category !== 'wm.TimerAction').map((v) => v.name),
743
+ startUpActions: Object.values(variables).filter((v) => v.startUpdate && v.category === 'wm.TimerAction').map((v) => v.name),
705
744
  autoUpdateVariables: Object.values(variables).filter((v) => v.autoUpdate || ((v.category === 'wm.Variable' || v.category === 'wm.LiveVariable') && v.dataBinding && v.dataBinding.length)).map((v) => v.name),
745
+ pullToRefreshVariables: pullToRefreshVariables,
706
746
  eagerImports: imports.filter(i => !i.lazy),
707
747
  lazyImports: imports.filter(i => i.lazy)
708
748
  });
@@ -795,13 +835,16 @@ class AppGenerator {
795
835
  }
796
836
  compileXComponentLib() {
797
837
  var _a, _b;
838
+ const componentsPath = `${this.projectService.path}/extensions/components`;
839
+ const componentsPackageJson = `${componentsPath}/package.json`;
840
+ const wmxDependenciesMarker = `${componentsPath}/.wmx-dependencies.info`;
798
841
  if (!this.incBuilder) {
799
842
  const projectPackages = fs_extra_1.default.readJsonSync(`${__dirname}/templates/project/package.json`, {
800
843
  encoding: 'utf8'
801
844
  });
802
845
  const reactVersion = (_a = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _a === void 0 ? void 0 : _a['react'];
803
846
  const reactNativeVersion = (_b = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _b === void 0 ? void 0 : _b['react-native'];
804
- const wmxComponentPackage = fs_extra_1.default.readJsonSync(`${this.projectService.path}/extensions/components/package.json`, {
847
+ const wmxComponentPackage = fs_extra_1.default.readJsonSync(componentsPackageJson, {
805
848
  encoding: 'utf8'
806
849
  });
807
850
  // semver considers ^x.x.x and ~x.x.x as invalid package versions.
@@ -810,20 +853,47 @@ class AppGenerator {
810
853
  wmxComponentPackage.devDependencies['@types/react'] = `${reactVersion}`;
811
854
  wmxComponentPackage.devDependencies['react-native'] = `${reactNativeVersion}`;
812
855
  }
813
- fs_extra_1.default.writeJSONSync(`${this.projectService.path}/extensions/components/package.json`, wmxComponentPackage);
814
- if (fs_extra_1.default.existsSync(`${this.projectService.path}/extensions/components/package-lock.json`)) {
815
- fs_extra_1.default.removeSync(`${this.projectService.path}/extensions/components/package-lock.json`);
816
- fs_extra_1.default.emptyDirSync(`${this.projectService.path}/extensions/components/node_modules`);
856
+ fs_extra_1.default.writeJSONSync(componentsPackageJson, wmxComponentPackage);
857
+ if (fs_extra_1.default.existsSync(`${componentsPath}/package-lock.json`)) {
858
+ fs_extra_1.default.removeSync(`${componentsPath}/package-lock.json`);
859
+ fs_extra_1.default.emptyDirSync(`${componentsPath}/node_modules`);
860
+ }
861
+ fs_extra_1.default.removeSync(wmxDependenciesMarker);
862
+ }
863
+ else if (fs_extra_1.default.existsSync(wmxDependenciesMarker)
864
+ && fs_extra_1.default.existsSync(`${componentsPath}/node_modules`)
865
+ && fs_extra_1.default.existsSync(`${this.projectPath}/wmx-components`)) {
866
+ try {
867
+ const marker = fs_extra_1.default.readJSONSync(wmxDependenciesMarker);
868
+ const currentHash = crypto_1.default.createHash('md5')
869
+ .update(fs_extra_1.default.readFileSync(componentsPackageJson, 'utf-8'), 'utf-8')
870
+ .digest('hex');
871
+ if (marker.packageHash === currentHash) {
872
+ console.log('wmx-components package.json unchanged since last build — skipping npm install/build.');
873
+ return Promise.resolve();
874
+ }
875
+ }
876
+ catch (e) {
877
+ console.error(e);
817
878
  }
818
879
  }
819
880
  return (0, execa_1.default)('npm', ['install'], {
820
- cwd: `${this.projectService.path}/extensions/components`
881
+ cwd: componentsPath
821
882
  }).then(() => {
822
883
  return (0, execa_1.default)('npm', ['run', 'build'], {
823
- cwd: `${this.projectService.path}/extensions/components`
884
+ cwd: componentsPath
824
885
  });
825
886
  }).then(() => {
826
- fs_extra_1.default.copySync(`${this.projectService.path}/extensions/components/build`, `${this.projectPath}/wmx-components`);
887
+ fs_extra_1.default.copySync(`${componentsPath}/build`, `${this.projectPath}/wmx-components`);
888
+ }).then(() => {
889
+ if (fs_extra_1.default.existsSync(`${componentsPath}/node_modules`)) {
890
+ fs_extra_1.default.copySync(`${componentsPath}/node_modules`, `${this.projectPath}/wmx-components/node_modules`);
891
+ }
892
+ }).then(() => {
893
+ const postBuildHash = crypto_1.default.createHash('md5')
894
+ .update(fs_extra_1.default.readFileSync(componentsPackageJson, 'utf-8'), 'utf-8')
895
+ .digest('hex');
896
+ fs_extra_1.default.writeJSONSync(wmxDependenciesMarker, { packageHash: postBuildHash, lastBuild: Date.now() });
827
897
  });
828
898
  }
829
899
  async generateWMXComponents(name, overwrite) {
@@ -1286,6 +1356,7 @@ class AppGenerator {
1286
1356
  .then(() => this.generatePartialConfig(pageConfigs));
1287
1357
  }
1288
1358
  async mergePackageJson() {
1359
+ var _a;
1289
1360
  if (this.incBuilder) {
1290
1361
  console.log(`Merging package.json .`);
1291
1362
  }
@@ -1300,22 +1371,31 @@ class AppGenerator {
1300
1371
  packageToOveride.scripts = (0, lodash_1.merge)(packageToOveride.scripts, webPackageJson.scripts);
1301
1372
  }
1302
1373
  if (this.wmxComponents.length > 0) {
1303
- packageToOveride.scripts.postinstall = [
1304
- 'npm install ./wmx-components',
1305
- ...((packageToOveride.scripts.postinstall || '')
1306
- .split('&&')
1307
- .filter((s) => s && !!s.trim()))
1308
- ].join(' && ');
1309
1374
  packageToOveride.dependencies['@wavemaker/wmx-component'] = 'file:wmx-components';
1310
1375
  if (!this.incBuilder || this.incBuilder.isWMXComponentModified()) {
1311
1376
  await this.compileXComponentLib();
1312
1377
  }
1313
1378
  }
1314
1379
  const packageOverride = await this.projectService.getPackageJSONOverride();
1315
- if (packageOverride) {
1316
- const packageOverriden = (0, lodash_1.merge)(packageToOveride, packageOverride);
1317
- fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(packageOverriden, null, 4));
1380
+ let packageOverriden = packageOverride ? (0, lodash_1.merge)(packageToOveride, packageOverride) : packageToOveride;
1381
+ if (this.wmxComponents.length > 0) {
1382
+ const priorWmxInstallForms = [
1383
+ 'npm install ./wmx-components',
1384
+ 'npm install --prefix ./wmx-components',
1385
+ 'npm install --prefix ./wmx-components --cache ./wmx-components/.npm-cache'
1386
+ ];
1387
+ const remainingSteps = (((_a = packageOverriden.scripts) === null || _a === void 0 ? void 0 : _a.postinstall) || '')
1388
+ .split('&&')
1389
+ .map((s) => s.trim())
1390
+ .filter((s) => s && !priorWmxInstallForms.includes(s));
1391
+ if (remainingSteps.length > 0) {
1392
+ packageOverriden.scripts.postinstall = remainingSteps.join(' && ');
1393
+ }
1394
+ else if (packageOverriden.scripts) {
1395
+ delete packageOverriden.scripts.postinstall;
1396
+ }
1318
1397
  }
1398
+ fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(packageOverriden, null, 4));
1319
1399
  }
1320
1400
  /**
1321
1401
  * update app.json with expo-video plugin
@@ -1514,6 +1594,50 @@ class AppGenerator {
1514
1594
  }
1515
1595
  fs_extra_1.default.writeJsonSync(appJsonPath, appJson, { spaces: 2 });
1516
1596
  }
1597
+ // Registered as a file: dependency (a native module, unlike expo-screen-capture-plugin's config plugin) so Expo autolinking discovers it.
1598
+ async copyPullToRefreshPluginIfNeeded() {
1599
+ const config = this.rnConfig;
1600
+ const packageJsonPath = `${this.projectPath}/package.json`;
1601
+ const pluginName = '@wavemaker/expo-pull-to-refresh';
1602
+ const pluginDestPath = `${this.projectPath}/plugins/expo-pull-to-refresh`;
1603
+ if (!fs_extra_1.default.existsSync(packageJsonPath)) {
1604
+ console.warn(`Warning: package.json not found at ${packageJsonPath}`);
1605
+ return;
1606
+ }
1607
+ const packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
1608
+ // Both flags: an animation alone with the feature off shouldn't ship the plugin.
1609
+ if ((config === null || config === void 0 ? void 0 : config.pulltorefresh) && (config === null || config === void 0 ? void 0 : config.pulltorefreshsource)) {
1610
+ const pluginSourcePath = __dirname + '/templates/project/plugins/expo-pull-to-refresh';
1611
+ if (!fs_extra_1.default.existsSync(pluginSourcePath)) {
1612
+ console.warn(`Warning: Pull to refresh plugin source not found at ${pluginSourcePath}`);
1613
+ return;
1614
+ }
1615
+ fs_extra_1.default.mkdirsSync(`${this.projectPath}/plugins`);
1616
+ fs_extra_1.default.copySync(pluginSourcePath, pluginDestPath);
1617
+ console.log(`Copied pull to refresh plugin to ${pluginDestPath}`);
1618
+ if (!packageJson.dependencies) {
1619
+ packageJson.dependencies = {};
1620
+ }
1621
+ if (packageJson.dependencies[pluginName] !== 'file:./plugins/expo-pull-to-refresh') {
1622
+ packageJson.dependencies[pluginName] = 'file:./plugins/expo-pull-to-refresh';
1623
+ console.log(`Added ${pluginName} to package.json`);
1624
+ }
1625
+ }
1626
+ else {
1627
+ if (fs_extra_1.default.existsSync(pluginDestPath)) {
1628
+ fs_extra_1.default.removeSync(pluginDestPath);
1629
+ const pluginsDir = `${this.projectPath}/plugins`;
1630
+ if (fs_extra_1.default.existsSync(pluginsDir) && fs_extra_1.default.readdirSync(pluginsDir).length === 0) {
1631
+ fs_extra_1.default.removeSync(pluginsDir);
1632
+ }
1633
+ }
1634
+ if (packageJson.dependencies && packageJson.dependencies[pluginName]) {
1635
+ delete packageJson.dependencies[pluginName];
1636
+ console.log(`Removed ${pluginName} from package.json`);
1637
+ }
1638
+ }
1639
+ fs_extra_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 4));
1640
+ }
1517
1641
  async addCustomPluginsToPackageJson() {
1518
1642
  if (this.incBuilder) {
1519
1643
  console.log(`Adding custom plugins.`);
@@ -1705,6 +1829,10 @@ class AppGenerator {
1705
1829
  async generateApp() {
1706
1830
  this.rnConfig = await this.projectService.getRNConfig().then(data => JSON.parse(data));
1707
1831
  this.incBuilder || fs_extra_1.default.copySync(__dirname + '/templates/project', this.projectPath);
1832
+ const customMetroConfig = await this.projectService.getCustomMetroConfig();
1833
+ if (customMetroConfig) {
1834
+ (0, utils_1.writeFile)(`${this.projectPath}/custommetro.config.js`, customMetroConfig);
1835
+ }
1708
1836
  return this.generatePagesAndPartials()
1709
1837
  .then(() => this.incBuilder && this.generateAllPrefabComponents())
1710
1838
  .then(() => !this.incBuilder || this.incBuilder.isResourceModified())
@@ -1727,6 +1855,8 @@ class AppGenerator {
1727
1855
  .then((build) => (build && this.generateFonts()))
1728
1856
  .then(() => !this.incBuilder || this.incBuilder.isConfigModified())
1729
1857
  .then((build) => (build && this.generateRNConfig()))
1858
+ .then(() => !this.incBuilder || this.incBuilder.isConfigModified() || this.incBuilder.isResourceModified())
1859
+ .then((build) => (build && this.generateGlobalConfig()))
1730
1860
  .then(() => !this.incBuilder || this.incBuilder.isFormatterModified())
1731
1861
  .then((build) => (build && this.generateFormatters()))
1732
1862
  .then(() => !this.incBuilder || this.incBuilder.isConfigModified())
@@ -1767,6 +1897,7 @@ class AppGenerator {
1767
1897
  .then((build) => (build && this.prettify()))
1768
1898
  .then(() => this.projectService.copyNpmPackages(this.projectPath))
1769
1899
  .then(() => this.copyScreenCapturePluginIfNeeded())
1900
+ .then(() => this.copyPullToRefreshPluginIfNeeded())
1770
1901
  .then(() => console.log('code generated at ' + this.projectPath));
1771
1902
  }
1772
1903
  generateFragment(name) {