@wavemaker/rn-codegen 11.15.5-rc.647813 → 11.15.5-rc.647878
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/command.js +94 -232
- package/command.js.map +1 -1
- package/index.js +131 -125
- package/index.js.map +1 -1
- package/npm-shrinkwrap.json +567 -548
- package/package-lock.json +567 -548
- package/package.json +14 -10
- package/scripts/check-deps-compat.js +579 -0
- package/src/app.generator.js +457 -137
- package/src/app.generator.js.map +1 -1
- package/src/increment-builder.js +2 -1
- package/src/increment-builder.js.map +1 -1
- package/src/pipeline/build-common.js +63 -0
- package/src/pipeline/build-common.js.map +1 -0
- package/src/pipeline/build-pipeline.js +169 -0
- package/src/pipeline/build-pipeline.js.map +1 -0
- package/src/pipeline/generation-store.js +309 -0
- package/src/pipeline/generation-store.js.map +1 -0
- package/src/pipeline/shared-node-modules.js +934 -0
- package/src/pipeline/shared-node-modules.js.map +1 -0
- package/src/pipeline/web-preview-templates.js +80 -0
- package/src/pipeline/web-preview-templates.js.map +1 -0
- package/src/pipeline/working-set.js +103 -0
- package/src/pipeline/working-set.js.map +1 -0
- package/src/profiles/legacy-web-preview.profile.js +15 -0
- package/src/profiles/legacy-web-preview.profile.js.map +1 -0
- package/src/project.service.js +14 -0
- package/src/project.service.js.map +1 -1
- package/src/templates/app.template +74 -2
- package/src/templates/babel.config.js.template +3 -6
- package/src/templates/bootstrap.template +12 -1
- package/src/templates/component/component.template +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/date.less +8 -1
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/datetime.less +8 -1
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/epoch/time.less +8 -1
- package/src/templates/foundation-theme/build/android/wavemaker/components/input/number.less +14 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/button.less +2 -2
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/checkboxset.less +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/chips.less +49 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/radioset.less +1 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/input/currency.less +6 -2
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/tokens.light.css +21 -3
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/variables/button.variant.less +2 -2
- package/src/templates/foundation-theme/build/android/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/date.less +8 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/datetime.less +8 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/epoch/time.less +8 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/components/input/number.less +14 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/button.less +2 -2
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/checkboxset.less +1 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/chips.less +49 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/radioset.less +1 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/input/currency.less +6 -2
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/tokens.light.css +21 -3
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/variables/button.variant.less +2 -2
- package/src/templates/foundation-theme/build/ios/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/foundation-theme/dist/android/style.css +23 -5
- package/src/templates/foundation-theme/dist/android/style.js +200 -59
- package/src/templates/foundation-theme/dist/android/tokens.js +21 -3
- package/src/templates/foundation-theme/dist/ios/style.css +23 -5
- package/src/templates/foundation-theme/dist/ios/style.js +200 -59
- package/src/templates/foundation-theme/dist/ios/tokens.js +21 -3
- package/src/templates/foundation-theme/wavemaker/components/input/epoch/date.less +8 -1
- package/src/templates/foundation-theme/wavemaker/components/input/epoch/datetime.less +8 -1
- package/src/templates/foundation-theme/wavemaker/components/input/epoch/time.less +8 -1
- package/src/templates/foundation-theme/wavemaker/components/input/number.less +14 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/button.less +2 -2
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/icon.less +6 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/basic/label.less +46 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/container/tabs/tab-header.less +15 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/data/form.less +14 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/checkboxset.less +1 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/chips.less +49 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/radioset.less +1 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/select.less +29 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/input/switch.less +4 -4
- package/src/templates/foundation-theme/wavemaker/design-tokens/navigation/menu.less +1 -0
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/basic/icon.less +0 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/container/tabs.less +5 -1
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/input/currency.less +6 -2
- package/src/templates/foundation-theme/wavemaker/design-tokens/studio/input/form.less +20 -5
- package/src/templates/foundation-theme/wavemaker/design-tokens/tokens.light.css +21 -3
- package/src/templates/foundation-theme/wavemaker/design-tokens/variables/button.variant.less +2 -2
- package/src/templates/foundation-theme/wavemaker/design-tokens/variables/chips.variant.less +5 -1
- package/src/templates/package.web.json +17 -7
- package/src/templates/page-stub.template +27 -0
- package/src/templates/project/.npmrc +1 -0
- package/src/templates/project/app.json +2 -1
- package/src/templates/project/esbuild/esbuild.script.js +57 -8
- package/src/templates/project/metro/container-limits.js +195 -0
- package/src/templates/project/metro/metro.script.js +850 -0
- package/src/templates/project/metro/module-path.js +237 -0
- package/src/templates/project/metro/split.serializer.js +184 -0
- package/src/templates/project/metro/split.static.js +633 -0
- package/src/templates/project/metro/stable-module-ids.js +54 -0
- package/src/templates/project/metro/vendor-cache.js +475 -0
- package/src/templates/project/metro/wm-boundary.js +150 -0
- package/src/templates/project/metro/wm-crawl-override.js +161 -0
- package/src/templates/project/metro/wm-fastbuild.js +196 -0
- package/src/templates/project/metro/wm-live-reload.js +482 -0
- package/src/templates/project/metro/wm-metro-adapter.js +25 -0
- package/src/templates/project/metro/wm-prebuilt.js +31 -0
- package/src/templates/project/metro.config.js +13 -2
- package/src/templates/project/package-lock.json +15308 -0
- package/src/templates/project/package.json +14 -6
- package/src/templates/project/patch-utils.js +331 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/build.gradle +15 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshModule.kt +21 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/android/src/main/java/expo/modules/pulltorefresh/ExpoPullToRefreshView.kt +221 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/expo-module.config.json +16 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefresh.podspec +24 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlModule.swift +17 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/ios/ExpoPullToRefreshControlView.swift +92 -0
- package/src/templates/project/plugins/expo-pull-to-refresh/package.json +15 -0
- package/src/templates/project/scripts/wm-babel.transform.plugin.js +11 -1
- package/src/templates/project/wavepulse/rn2css.json +5 -0
- package/src/theme/app-override-css.generator.js +10 -4
- package/src/theme/app-override-css.generator.js.map +1 -1
- package/src/theme/components/input/epoch/datetime.styledef.js +5 -0
- package/src/theme/components/input/epoch/datetime.styledef.js.map +1 -1
- package/src/theme/components/input/number.styledef.js +10 -0
- package/src/theme/components/input/number.styledef.js.map +1 -1
- package/src/theme/rn-stylesheet.transpiler.js +30 -6
- package/src/theme/rn-stylesheet.transpiler.js.map +1 -1
- package/src/theme/theme.service.js +3 -2
- package/src/theme/theme.service.js.map +1 -1
- package/src/transpile/bind.ex.transformer.js +55 -37
- package/src/transpile/bind.ex.transformer.js.map +1 -1
- package/src/transpile/components/container/wizard/wizardstep.transformer.js +10 -2
- package/src/transpile/components/container/wizard/wizardstep.transformer.js.map +1 -1
- package/src/transpile/components/data/form/form-field.transformer.js +36 -1
- package/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
- package/src/transpile/components/page/page.transformer.js +11 -1
- package/src/transpile/components/page/page.transformer.js.map +1 -1
- package/src/transpile/property/property-parser.js +7 -1
- package/src/transpile/property/property-parser.js.map +1 -1
- package/src/transpile/style.transformer.js +1 -0
- package/src/transpile/style.transformer.js.map +1 -1
- package/src/transpile/transpile.js +10 -1
- package/src/transpile/transpile.js.map +1 -1
- package/src/utils.js +8 -1
- package/src/utils.js.map +1 -1
- package/src/variables/variable.transformer.js +7 -7
- package/src/variables/variable.transformer.js.map +1 -1
- package/src/wm-namespace.js +14 -0
- package/src/wm-namespace.js.map +1 -0
- package/test/pipeline/build-leftovers.test.js +172 -0
- package/test/pipeline/build-leftovers.test.js.map +1 -0
- package/test/pipeline/chmod-tree.test.js +54 -0
- package/test/pipeline/chmod-tree.test.js.map +1 -0
- package/test/pipeline/crawl-override.test.js +53 -0
- package/test/pipeline/crawl-override.test.js.map +1 -0
- package/test/pipeline/live-reload-pacing.test.js +76 -0
- package/test/pipeline/live-reload-pacing.test.js.map +1 -0
- package/test/pipeline/npm-install-retry.test.js +57 -0
- package/test/pipeline/npm-install-retry.test.js.map +1 -0
- package/test/pipeline/repair-vendor-packages.test.js +134 -0
- package/test/pipeline/repair-vendor-packages.test.js.map +1 -0
- package/test/pipeline/web-preview-files.test.js +48 -0
- package/test/pipeline/web-preview-files.test.js.map +1 -0
- package/web-preview.js +155 -0
- package/web-preview.js.map +1 -0
package/src/app.generator.js
CHANGED
|
@@ -27,12 +27,14 @@ 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"));
|
|
33
34
|
const semver_1 = __importDefault(require("semver"));
|
|
34
35
|
const path_2 = __importDefault(require("path"));
|
|
35
36
|
const transpile_1 = require("./transpile/transpile");
|
|
37
|
+
const wm_namespace_1 = require("./wm-namespace");
|
|
36
38
|
const variable_transformer_1 = __importDefault(require("./variables/variable.transformer"));
|
|
37
39
|
const utils_1 = require("./utils");
|
|
38
40
|
const bind_ex_transformer_1 = __importDefault(require("./transpile/bind.ex.transformer"));
|
|
@@ -40,6 +42,10 @@ const theme_service_1 = require("./theme/theme.service");
|
|
|
40
42
|
const profile_1 = __importDefault(require("./profiles/profile"));
|
|
41
43
|
const app_override_css_generator_1 = require("./theme/app-override-css.generator");
|
|
42
44
|
const command_1 = require("../command");
|
|
45
|
+
const web_preview_templates_1 = require("./pipeline/web-preview-templates");
|
|
46
|
+
const working_set_1 = require("./pipeline/working-set");
|
|
47
|
+
// Shared with the CLI and the release build (scripts/build.js copies it next to post-build.js).
|
|
48
|
+
const depsCompat = require(path_2.default.join(__dirname, '..', 'scripts', 'check-deps-compat.js'));
|
|
43
49
|
const APP_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/app.template');
|
|
44
50
|
const APP_THEME_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/app.theme.template');
|
|
45
51
|
const BABEL_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/babel.config.js.template');
|
|
@@ -51,6 +57,7 @@ const COMPONENT_PROPS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templat
|
|
|
51
57
|
const SCRIPT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/component/script.template');
|
|
52
58
|
const STYLE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/component/style.template');
|
|
53
59
|
const PAGE_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/pages-config.template');
|
|
60
|
+
const PAGE_STUB_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/page-stub.template');
|
|
54
61
|
const SERVICE_DEFINITIONS = (0, utils_1.loadTemplate)(__dirname + '/templates/service.defs.template');
|
|
55
62
|
const FORMATTERS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/extensions/formatters.template');
|
|
56
63
|
const VARIABLE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/variables.template');
|
|
@@ -114,7 +121,7 @@ let deviceVariables = [];
|
|
|
114
121
|
let appVersion;
|
|
115
122
|
const servicesConfig = [];
|
|
116
123
|
class AppGenerator {
|
|
117
|
-
constructor(projectPath, projectService, appUrl, prefabName = '', incBuilder, options, dynamicPrefabProps) {
|
|
124
|
+
constructor(projectPath, projectService, appUrl, prefabName = '', incBuilder, options, dynamicPrefabProps, isWebPreview = false) {
|
|
118
125
|
this.projectPath = projectPath;
|
|
119
126
|
this.projectService = projectService;
|
|
120
127
|
this.appUrl = appUrl;
|
|
@@ -122,6 +129,7 @@ class AppGenerator {
|
|
|
122
129
|
this.incBuilder = incBuilder;
|
|
123
130
|
this.options = options;
|
|
124
131
|
this.dynamicPrefabProps = dynamicPrefabProps;
|
|
132
|
+
this.isWebPreview = isWebPreview;
|
|
125
133
|
this.transpiledComponents = {
|
|
126
134
|
pages: {},
|
|
127
135
|
partials: {},
|
|
@@ -138,6 +146,7 @@ class AppGenerator {
|
|
|
138
146
|
this.jsFileImports = new Set();
|
|
139
147
|
this.shouldNpmInstall = false;
|
|
140
148
|
this.shouldDoUnwantedPackagesCleanup = false;
|
|
149
|
+
this.forceGenerate = new Set();
|
|
141
150
|
this.options = options;
|
|
142
151
|
this.isPrefabApp = !!prefabName;
|
|
143
152
|
this.wmxComponents = this.projectService.getWMXComponents();
|
|
@@ -187,10 +196,12 @@ class AppGenerator {
|
|
|
187
196
|
* find all operations/packages (e.g, Camera, Scan, Location)
|
|
188
197
|
* that are used in the app
|
|
189
198
|
*/
|
|
199
|
+
// Web preview: scan pages once, not once per operation (minutes on large apps).
|
|
200
|
+
const sharedScan = this.isWebPreview ? Promise.all([this.getWidgetImports(), this.getDeviceVariables()]) : null;
|
|
190
201
|
await Promise.all(operations.map(async (operation) => {
|
|
191
202
|
let method = "";
|
|
192
|
-
const importedWidgets = await this.getWidgetImports();
|
|
193
|
-
const deviceVariables = await this.getDeviceVariables();
|
|
203
|
+
const importedWidgets = sharedScan ? (await sharedScan)[0] : await this.getWidgetImports();
|
|
204
|
+
const deviceVariables = sharedScan ? (await sharedScan)[1] : await this.getDeviceVariables();
|
|
194
205
|
const isWidgetImportedForCurrentOperation = importedWidgets.findIndex((w) => {
|
|
195
206
|
const widgetName = operation === "File"
|
|
196
207
|
? "WmFileupload"
|
|
@@ -468,6 +479,26 @@ class AppGenerator {
|
|
|
468
479
|
(0, utils_1.writeFile)(`${this.projectPath}/wm_rn_config.json`, JSON.stringify(config, null, 4));
|
|
469
480
|
});
|
|
470
481
|
}
|
|
482
|
+
// Copies each enabled profile's pre-built <profile>.json into the generated app, and removes stale ones.
|
|
483
|
+
generateGlobalConfig() {
|
|
484
|
+
if (this.incBuilder) {
|
|
485
|
+
console.log(`Copying Global config.`);
|
|
486
|
+
}
|
|
487
|
+
return this.projectService.getRNConfig().then(data => {
|
|
488
|
+
const config = JSON.parse(data);
|
|
489
|
+
const enabledProfiles = config.enabledProfiles || [];
|
|
490
|
+
// Tracks profiles generated last time, so one removed (or whose file was deleted outright) still gets cleaned up.
|
|
491
|
+
const manifestPath = `${this.projectPath}/.profiles-manifest.json`;
|
|
492
|
+
const previousProfiles = fs_extra_1.default.existsSync(manifestPath) ? JSON.parse(fs_extra_1.default.readFileSync(manifestPath, 'utf8')) : [];
|
|
493
|
+
previousProfiles
|
|
494
|
+
.filter((profileName) => !enabledProfiles.includes(profileName))
|
|
495
|
+
.forEach((profileName) => fs_extra_1.default.removeSync(`${this.projectPath}/${profileName}.json`));
|
|
496
|
+
(0, utils_1.writeFile)(manifestPath, JSON.stringify(enabledProfiles));
|
|
497
|
+
return Promise.all(enabledProfiles.map(profileName => this.projectService.getGlobalConfig(profileName).then(data => {
|
|
498
|
+
(0, utils_1.writeFile)(`${this.projectPath}/${profileName}.json`, data);
|
|
499
|
+
})));
|
|
500
|
+
});
|
|
501
|
+
}
|
|
471
502
|
removeOldKeys(splash) {
|
|
472
503
|
const keysToRemove = ['animationSrc', 'width', 'height', 'modifiedSrc'];
|
|
473
504
|
const filterKeys = (obj) => Object.fromEntries(Object.entries(obj).filter(([key]) => !keysToRemove.includes(key)));
|
|
@@ -482,15 +513,16 @@ class AppGenerator {
|
|
|
482
513
|
updateInSplashConfig(config, appConfig) {
|
|
483
514
|
var _a, _b, _c;
|
|
484
515
|
let filteredSplashConfig = this.removeOldKeys(config.splash);
|
|
516
|
+
const splashAssetPath = (src) => this.isWebPreview ? './assets/' + path_2.default.basename(src) : './assets/' + src;
|
|
485
517
|
if (filteredSplashConfig.image) {
|
|
486
|
-
filteredSplashConfig['image'] =
|
|
518
|
+
filteredSplashConfig['image'] = splashAssetPath(filteredSplashConfig.image);
|
|
487
519
|
}
|
|
488
520
|
if ((_a = filteredSplashConfig === null || filteredSplashConfig === void 0 ? void 0 : filteredSplashConfig.dark) === null || _a === void 0 ? void 0 : _a.image) {
|
|
489
|
-
filteredSplashConfig['dark']['image'] =
|
|
521
|
+
filteredSplashConfig['dark']['image'] = splashAssetPath((_b = filteredSplashConfig === null || filteredSplashConfig === void 0 ? void 0 : filteredSplashConfig.dark) === null || _b === void 0 ? void 0 : _b.image);
|
|
490
522
|
}
|
|
491
523
|
// support for old projects with splash in src and bgColor
|
|
492
524
|
if (filteredSplashConfig.src) {
|
|
493
|
-
filteredSplashConfig['image'] =
|
|
525
|
+
filteredSplashConfig['image'] = splashAssetPath(filteredSplashConfig.src);
|
|
494
526
|
delete filteredSplashConfig.src;
|
|
495
527
|
}
|
|
496
528
|
if (filteredSplashConfig.src) {
|
|
@@ -524,8 +556,9 @@ class AppGenerator {
|
|
|
524
556
|
appConfig['expo']['android']['package'] = config.id;
|
|
525
557
|
appConfig['expo']['ios']['bundleIdentifier'] = config.id;
|
|
526
558
|
appConfig['expo']['jsEngine'] = ((_a = config.preferences) === null || _a === void 0 ? void 0 : _a.enableHermes) === 'false' ? 'jsc' : 'hermes';
|
|
527
|
-
|
|
528
|
-
appConfig['expo']['
|
|
559
|
+
const iconPath = this.isWebPreview ? './assets/' + path_2.default.basename(config.icon.src) : './assets/' + config.icon.src;
|
|
560
|
+
appConfig['expo']['icon'] = iconPath;
|
|
561
|
+
appConfig['expo']['android']['adaptiveIcon']['foregroundImage'] = iconPath;
|
|
529
562
|
appConfig['expo']['orientation'] = config.orientation || 'portrait';
|
|
530
563
|
const adaptiveColorMode = !!config.enableAdaptiveColorMode;
|
|
531
564
|
appConfig.expo.userInterfaceStyle = adaptiveColorMode ? 'automatic' : 'light';
|
|
@@ -536,6 +569,14 @@ class AppGenerator {
|
|
|
536
569
|
var _a, _b;
|
|
537
570
|
(_b = (_a = appConfigOverride === null || appConfigOverride === void 0 ? void 0 : appConfigOverride.expo) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.forEach((plugin) => {
|
|
538
571
|
var _a, _b;
|
|
572
|
+
// Expo's web export loads every config plugin; a missing local one fails the preview.
|
|
573
|
+
const pluginName = Array.isArray(plugin) ? plugin[0] : plugin;
|
|
574
|
+
if (this.isWebPreview && typeof pluginName === 'string' && /^\.\.?\//.test(pluginName)
|
|
575
|
+
&& !['', '.js', '.ts', '/index.js', '/index.ts', '/app.plugin.js']
|
|
576
|
+
.some(ext => fs_extra_1.default.existsSync(path_2.default.resolve(this.projectPath, pluginName + ext)))) {
|
|
577
|
+
console.warn(`Skipping config plugin ${pluginName} in web preview: no such file in the project.`);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
539
580
|
if ((_a = appConfig === null || appConfig === void 0 ? void 0 : appConfig.expo) === null || _a === void 0 ? void 0 : _a.plugins) {
|
|
540
581
|
const presentInIndex = appConfig.expo.plugins.findIndex((item) => item[0] === plugin[0]);
|
|
541
582
|
if (presentInIndex > -1 && Array.isArray(appConfig.expo.plugins[presentInIndex])) {
|
|
@@ -592,23 +633,30 @@ class AppGenerator {
|
|
|
592
633
|
}
|
|
593
634
|
return this.projectService.getAppVariables().then(variables => {
|
|
594
635
|
return this.projectService.getAppJs().then(script => {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
636
|
+
return this.projectService.getAppWrapperJs().then(appWrapperJs => {
|
|
637
|
+
var _a;
|
|
638
|
+
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];
|
|
639
|
+
const localeDataset = Object.keys(supportedLocaleVariable === null || supportedLocaleVariable === void 0 ? void 0 : supportedLocaleVariable.dataSet);
|
|
640
|
+
const supportedLocales = localeDataset.filter(utils_1.isValidLocale);
|
|
641
|
+
if (appWrapperJs) {
|
|
642
|
+
(0, utils_1.writeFile)(`${this.projectPath}/src/customapp.wrapper.js`, appWrapperJs);
|
|
643
|
+
}
|
|
644
|
+
const output = APP_TEMPLATE({
|
|
645
|
+
script: script,
|
|
646
|
+
startUpVariables: Object.values(variables).filter((v) => (v.startUpdate || v.category === 'wm.Variable') && v.category !== 'wm.TimerAction').map((v) => v.name),
|
|
647
|
+
startUpActions: Object.values(variables).filter((v) => v.startUpdate && v.category === 'wm.TimerAction').map((v) => v.name),
|
|
648
|
+
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),
|
|
649
|
+
supportedLocales: supportedLocales,
|
|
650
|
+
animatedSplash: animatedSplash,
|
|
651
|
+
sslPinning: sslPinning,
|
|
652
|
+
enableWavePulse: enableWavePulse,
|
|
653
|
+
enableDesignTokens: !!config.preferences.enableDesignTokens,
|
|
654
|
+
enableAdaptiveColorMode: !!config.enableAdaptiveColorMode,
|
|
655
|
+
enabledProfiles: config.enabledProfiles || [],
|
|
656
|
+
customAppWrapper: !!appWrapperJs
|
|
657
|
+
});
|
|
658
|
+
(0, utils_1.writeFile)(`${this.projectPath}/App.js`, output);
|
|
610
659
|
});
|
|
611
|
-
(0, utils_1.writeFile)(`${this.projectPath}/App.js`, output);
|
|
612
660
|
});
|
|
613
661
|
});
|
|
614
662
|
});
|
|
@@ -649,7 +697,9 @@ class AppGenerator {
|
|
|
649
697
|
return this.themeService.generateStudioStyles(styles);
|
|
650
698
|
}
|
|
651
699
|
async generateComponent(info, type, name, dynamicProps) {
|
|
652
|
-
|
|
700
|
+
// Also regenerate on an app-config change, not just a page edit: a page's cascaded
|
|
701
|
+
// pulltorefresh value (page.transformer.ts) comes from that config too.
|
|
702
|
+
if (this.incBuilder && !this.incBuilder.isFragmentModified(name) && !this.incBuilder.isConfigModified() && !this.forceGenerate.has(name)) {
|
|
653
703
|
return Promise.resolve();
|
|
654
704
|
}
|
|
655
705
|
if (this.incBuilder) {
|
|
@@ -690,6 +740,15 @@ class AppGenerator {
|
|
|
690
740
|
});
|
|
691
741
|
}
|
|
692
742
|
const imports = (0, lodash_1.sortBy)((0, lodash_1.uniqBy)(transpiledOutput.imports, i => i.name + i.from), i => i.name);
|
|
743
|
+
// Pull-to-refresh invokes this page's flagged variables plus the flagged app variables it references.
|
|
744
|
+
const appVariables = await Promise.resolve(this.projectService.getAppVariables()).catch(() => ({}));
|
|
745
|
+
const pageSource = `${info.markup || ''}\n${info.script || ''}`;
|
|
746
|
+
const pullToRefreshVariables = Array.from(new Set([
|
|
747
|
+
...Object.values(variables).filter((v) => v.pullToRefreshUpdate).map((v) => v.name),
|
|
748
|
+
...Object.values(appVariables || {})
|
|
749
|
+
.filter((v) => v.pullToRefreshUpdate && new RegExp(`\\bVariables\\.${(0, lodash_1.escapeRegExp)(v.name)}\\b`).test(pageSource))
|
|
750
|
+
.map((v) => v.name),
|
|
751
|
+
]));
|
|
693
752
|
const component = COMPONENT_TEMPLATE({
|
|
694
753
|
name: name,
|
|
695
754
|
type: type,
|
|
@@ -700,9 +759,10 @@ class AppGenerator {
|
|
|
700
759
|
prefabName: this.prefabName,
|
|
701
760
|
markup: '\n' + transpiledOutput.markup,
|
|
702
761
|
components: transpiledOutput.components,
|
|
703
|
-
startUpVariables: Object.values(variables).filter((v) => v.startUpdate && v.category !== 'wm.
|
|
704
|
-
startUpActions: Object.values(variables).filter((v) => v.startUpdate && v.category === 'wm.
|
|
762
|
+
startUpVariables: Object.values(variables).filter((v) => v.startUpdate && v.category !== 'wm.TimerAction').map((v) => v.name),
|
|
763
|
+
startUpActions: Object.values(variables).filter((v) => v.startUpdate && v.category === 'wm.TimerAction').map((v) => v.name),
|
|
705
764
|
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),
|
|
765
|
+
pullToRefreshVariables: pullToRefreshVariables,
|
|
706
766
|
eagerImports: imports.filter(i => !i.lazy),
|
|
707
767
|
lazyImports: imports.filter(i => i.lazy)
|
|
708
768
|
});
|
|
@@ -793,37 +853,103 @@ class AppGenerator {
|
|
|
793
853
|
return Promise.all(prefabs === null || prefabs === void 0 ? void 0 : prefabs.map(prefab => this.generatePrefabComponent(prefab, overwrite)));
|
|
794
854
|
});
|
|
795
855
|
}
|
|
856
|
+
checkWmxRuntimeDepsCompatibility(componentsPath, reactVersion, reactNativeVersion) {
|
|
857
|
+
const checks = [
|
|
858
|
+
{ name: 'react', expected: reactVersion },
|
|
859
|
+
{ name: 'react-native', expected: reactNativeVersion },
|
|
860
|
+
];
|
|
861
|
+
for (const { name, expected } of checks) {
|
|
862
|
+
const pkgPath = `${componentsPath}/node_modules/${name}/package.json`;
|
|
863
|
+
if (!expected || !fs_extra_1.default.existsSync(pkgPath)) {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
const installedVersion = fs_extra_1.default.readJsonSync(pkgPath, { encoding: 'utf8' }).version;
|
|
867
|
+
const expectedClean = `${expected}`.replace('^', '').replace('~', '');
|
|
868
|
+
if (installedVersion && semver_1.default.major(installedVersion) !== semver_1.default.major(expectedClean)) {
|
|
869
|
+
console.warn(`Warning: wmx-component's "${name}" version (${installedVersion}) is not compatible with the app's "${name}" version (${expected}) — major version mismatch. `
|
|
870
|
+
+ `Update the wmx-component's dependency on "${name}" to a "${semver_1.default.major(expectedClean)}.x" version and rebuild.`);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
796
874
|
compileXComponentLib() {
|
|
797
875
|
var _a, _b;
|
|
876
|
+
const componentsPath = `${this.projectService.path}/extensions/components`;
|
|
877
|
+
// Under node_modules so it never ships with an exported/downloaded app. Not `.cache`: web preview
|
|
878
|
+
// symlinks every vendor-tree entry into node_modules, and a shared `.cache` would be read-only.
|
|
879
|
+
const npmCacheDir = (0, path_1.join)(this.projectPath, 'node_modules', '.wm-wmx-npm-cache');
|
|
880
|
+
fs_extra_1.default.removeSync((0, path_1.join)(this.projectPath, '.wmx-npm-cache')); // previous location
|
|
881
|
+
const wmxPackageJsonPath = `${componentsPath}/package.json`;
|
|
882
|
+
const readWmxPackageJson = () => {
|
|
883
|
+
if (!fs_extra_1.default.existsSync(wmxPackageJsonPath)) {
|
|
884
|
+
throw new Error(`wmx-components package.json not found at ${wmxPackageJsonPath} — extensions/components must be scaffolded before compiling wmx components.`);
|
|
885
|
+
}
|
|
886
|
+
try {
|
|
887
|
+
return fs_extra_1.default.readJsonSync(wmxPackageJsonPath, { encoding: 'utf8' });
|
|
888
|
+
}
|
|
889
|
+
catch (e) {
|
|
890
|
+
throw new Error(`Failed to parse ${wmxPackageJsonPath}: ${e.message}`);
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
const projectPackages = fs_extra_1.default.readJsonSync(`${__dirname}/templates/project/package.json`, {
|
|
894
|
+
encoding: 'utf8'
|
|
895
|
+
});
|
|
896
|
+
const reactVersion = (_a = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _a === void 0 ? void 0 : _a['react'];
|
|
897
|
+
const reactNativeVersion = (_b = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _b === void 0 ? void 0 : _b['react-native'];
|
|
798
898
|
if (!this.incBuilder) {
|
|
799
|
-
const
|
|
800
|
-
encoding: 'utf8'
|
|
801
|
-
});
|
|
802
|
-
const reactVersion = (_a = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _a === void 0 ? void 0 : _a['react'];
|
|
803
|
-
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`, {
|
|
805
|
-
encoding: 'utf8'
|
|
806
|
-
});
|
|
899
|
+
const wmxComponentPackage = readWmxPackageJson();
|
|
807
900
|
// semver considers ^x.x.x and ~x.x.x as invalid package versions.
|
|
808
901
|
if (semver_1.default.lt(`${wmxComponentPackage.devDependencies['@types/react']}`.replace('^', '').replace('~', ''), reactVersion) ||
|
|
809
902
|
semver_1.default.lt(`${wmxComponentPackage.devDependencies['react-native']}`.replace('^', '').replace('~', ''), reactNativeVersion)) {
|
|
810
903
|
wmxComponentPackage.devDependencies['@types/react'] = `${reactVersion}`;
|
|
811
904
|
wmxComponentPackage.devDependencies['react-native'] = `${reactNativeVersion}`;
|
|
812
905
|
}
|
|
813
|
-
fs_extra_1.default.writeJSONSync(
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
906
|
+
fs_extra_1.default.writeJSONSync(wmxPackageJsonPath, wmxComponentPackage);
|
|
907
|
+
fs_extra_1.default.removeSync(`${componentsPath}/package-lock.json`);
|
|
908
|
+
fs_extra_1.default.emptyDirSync(`${componentsPath}/node_modules`);
|
|
909
|
+
// Clean build: never trust a previously cached npm tarball — wipe it outright.
|
|
910
|
+
fs_extra_1.default.removeSync(npmCacheDir);
|
|
911
|
+
}
|
|
912
|
+
const wmxComponentPackage = readWmxPackageJson();
|
|
913
|
+
const depsHash = crypto_1.default.createHash('md5')
|
|
914
|
+
.update(JSON.stringify(wmxComponentPackage.dependencies || {}) + JSON.stringify(wmxComponentPackage.devDependencies || {}))
|
|
915
|
+
.digest('hex')
|
|
916
|
+
.slice(0, 8);
|
|
917
|
+
const depsHashFile = (0, path_1.join)(npmCacheDir, '.deps-hash');
|
|
918
|
+
const cachedDepsHash = fs_extra_1.default.existsSync(depsHashFile) ? fs_extra_1.default.readFileSync(depsHashFile, 'utf8') : undefined;
|
|
919
|
+
if (cachedDepsHash !== depsHash) {
|
|
920
|
+
fs_extra_1.default.removeSync(npmCacheDir);
|
|
921
|
+
fs_extra_1.default.mkdirpSync(npmCacheDir);
|
|
922
|
+
fs_extra_1.default.writeFileSync(depsHashFile, depsHash);
|
|
923
|
+
}
|
|
924
|
+
// Same reasoning as npmInstall(): a failed or killed install can leave corrupt cache entries behind.
|
|
925
|
+
const dropCacheOnFailure = (err) => {
|
|
926
|
+
console.warn(`[npm] wmx install failed — removing wmx npm cache at ${npmCacheDir}`);
|
|
927
|
+
fs_extra_1.default.removeSync(npmCacheDir);
|
|
928
|
+
throw err;
|
|
929
|
+
};
|
|
930
|
+
return (0, execa_1.default)('npm', ['install', '--cache', npmCacheDir], {
|
|
931
|
+
cwd: componentsPath
|
|
932
|
+
}).catch(dropCacheOnFailure).then(() => {
|
|
822
933
|
return (0, execa_1.default)('npm', ['run', 'build'], {
|
|
823
|
-
cwd:
|
|
934
|
+
cwd: componentsPath
|
|
824
935
|
});
|
|
825
936
|
}).then(() => {
|
|
826
|
-
|
|
937
|
+
const wmxComponentsDest = `${this.projectPath}/wmx-components`;
|
|
938
|
+
const wmxNodeModulesDir = `${wmxComponentsDest}/node_modules`;
|
|
939
|
+
fs_extra_1.default.copySync(`${componentsPath}/build`, wmxComponentsDest);
|
|
940
|
+
if (!fs_extra_1.default.existsSync(`${wmxComponentsDest}/package.json`)) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
if (!this.incBuilder) {
|
|
944
|
+
fs_extra_1.default.removeSync(wmxNodeModulesDir);
|
|
945
|
+
}
|
|
946
|
+
return (0, execa_1.default)('npm', ['install', '--cache', npmCacheDir], {
|
|
947
|
+
cwd: wmxComponentsDest
|
|
948
|
+
}).catch(dropCacheOnFailure).then(() => {
|
|
949
|
+
this.checkWmxRuntimeDepsCompatibility(wmxComponentsDest, reactVersion, reactNativeVersion);
|
|
950
|
+
}).finally(() => {
|
|
951
|
+
fs_extra_1.default.removeSync(wmxNodeModulesDir);
|
|
952
|
+
});
|
|
827
953
|
});
|
|
828
954
|
}
|
|
829
955
|
async generateWMXComponents(name, overwrite) {
|
|
@@ -1017,9 +1143,17 @@ class AppGenerator {
|
|
|
1017
1143
|
* @description Get all widget imports in the generated app
|
|
1018
1144
|
* @returns array of widgets imported (e.g, WmCamera, WmVideo)
|
|
1019
1145
|
*/
|
|
1020
|
-
|
|
1146
|
+
// Web preview: markup doesn't change mid-build, so every caller shares one scan of all pages.
|
|
1147
|
+
getWidgetImports() {
|
|
1148
|
+
var _a;
|
|
1149
|
+
if (!this.isWebPreview) {
|
|
1150
|
+
return this.scanWidgetImports();
|
|
1151
|
+
}
|
|
1152
|
+
return (_a = this.widgetImportsScan) !== null && _a !== void 0 ? _a : (this.widgetImportsScan = this.scanWidgetImports());
|
|
1153
|
+
}
|
|
1154
|
+
async scanWidgetImports(only) {
|
|
1021
1155
|
let widgetImports = [];
|
|
1022
|
-
const pageConfigs = await this.projectService.getPageConfigs();
|
|
1156
|
+
const pageConfigs = (await this.projectService.getPageConfigs()).filter(p => !only || only(p.name));
|
|
1023
1157
|
await Promise.all(pageConfigs.map(async (p) => {
|
|
1024
1158
|
const info = await this.projectService.getPageInfo(p.name);
|
|
1025
1159
|
const transpileArgs = {
|
|
@@ -1060,6 +1194,18 @@ class AppGenerator {
|
|
|
1060
1194
|
if (this.incBuilder) {
|
|
1061
1195
|
console.log(`Checking widget usage in component files.`);
|
|
1062
1196
|
}
|
|
1197
|
+
// Web preview incremental: only edited pages/partials can bring in a new widget, so scan just those.
|
|
1198
|
+
// A widget removed elsewhere keeps its plugin until the next clean preview, which is harmless.
|
|
1199
|
+
const buildCache = this.isWebPreview && this.incBuilder && !this.shouldDoUnwantedPackagesCleanup
|
|
1200
|
+
? fs_extra_1.default.readJSONSync(`${this.projectPath}/.build-cache`, { throws: false }) : null;
|
|
1201
|
+
if (buildCache === null || buildCache === void 0 ? void 0 : buildCache.widgetImports) {
|
|
1202
|
+
const known = new Set(buildCache.widgetImports.map((d) => d.name));
|
|
1203
|
+
const changed = await this.scanWidgetImports(name => this.incBuilder.isFragmentModified(name));
|
|
1204
|
+
if (!this.projectPackageDependencies.some((dep) => !known.has(dep.name)
|
|
1205
|
+
&& changed.some((i) => { var _a; return (_a = dep.tagName) === null || _a === void 0 ? void 0 : _a.includes(i === null || i === void 0 ? void 0 : i.name); }))) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1063
1209
|
const projectDependencies = (0, lodash_1.uniq)([...this.projectPackageDependencies]);
|
|
1064
1210
|
const imports = await this.getWidgetImports();
|
|
1065
1211
|
projectDependencies.forEach((dep, index) => {
|
|
@@ -1158,7 +1304,7 @@ class AppGenerator {
|
|
|
1158
1304
|
if (stat.isDirectory()) {
|
|
1159
1305
|
scanDirectory(fullPath);
|
|
1160
1306
|
}
|
|
1161
|
-
else if (file.endsWith('.js') || file.endsWith('.ts') || file.endsWith('.tsx')) {
|
|
1307
|
+
else if (file.endsWith('.js') || file.endsWith('.jsx') || file.endsWith('.ts') || file.endsWith('.tsx')) {
|
|
1162
1308
|
try {
|
|
1163
1309
|
// Ignore checking for package imports in ignore list file names
|
|
1164
1310
|
if (scanFileIgnoreList.includes(file)) {
|
|
@@ -1191,6 +1337,10 @@ class AppGenerator {
|
|
|
1191
1337
|
const scanPaths = [
|
|
1192
1338
|
`${this.projectPath}/src`,
|
|
1193
1339
|
`${this.projectPath}/assets/resources`,
|
|
1340
|
+
// wmx components (compiled to .jsx) import their own packages, e.g. the barcode scanner's expo-camera.
|
|
1341
|
+
`${this.projectPath}/wmx-components/src`,
|
|
1342
|
+
// Stubbed pages have no generated script; scan their sources so their packages are kept.
|
|
1343
|
+
...(this.isWebPreview && (0, working_set_1.workingSetEnabled)(this.projectService.path) ? [`${this.projectService.path}/pages`] : []),
|
|
1194
1344
|
];
|
|
1195
1345
|
scanPaths.forEach(scanPath => {
|
|
1196
1346
|
scanDirectory(scanPath);
|
|
@@ -1268,24 +1418,71 @@ class AppGenerator {
|
|
|
1268
1418
|
}
|
|
1269
1419
|
return Promise.resolve();
|
|
1270
1420
|
}
|
|
1421
|
+
// Web preview: real components only for working-set pages and partials, a stub at the same path for the rest.
|
|
1422
|
+
resolvePreviewWorkingSet(pageConfigs) {
|
|
1423
|
+
if (!this.isWebPreview || this.isPrefabApp || !(0, working_set_1.workingSetEnabled)(this.projectService.path)) {
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
const pages = pageConfigs.filter(p => p.type === 'PAGE').map(p => p.name);
|
|
1427
|
+
const partials = pageConfigs.filter(p => this.isPartial(p.type)).map(p => p.name);
|
|
1428
|
+
const preview = this.rnConfig.preview;
|
|
1429
|
+
// Default: every page, as a working set (not null) so stubs left from an earlier build are replaced.
|
|
1430
|
+
if ((preview === null || preview === void 0 ? void 0 : preview.allPages) !== false) {
|
|
1431
|
+
return new Set([...pages, ...partials]);
|
|
1432
|
+
}
|
|
1433
|
+
const modified = this.incBuilder
|
|
1434
|
+
? [...pages, ...partials].filter(p => this.incBuilder.isFragmentModified(p)) : [];
|
|
1435
|
+
return (0, working_set_1.resolveWorkingSet)(this.projectPath, this.projectService.path, pages, partials, modified, Array.isArray(preview === null || preview === void 0 ? void 0 : preview.pages) ? preview.pages : []);
|
|
1436
|
+
}
|
|
1437
|
+
generatePreviewFragment(name, kind, workingSet) {
|
|
1438
|
+
const file = `${this.projectPath}/src/${kind}/${name}/${name}.component.js`;
|
|
1439
|
+
if (workingSet.has(name)) {
|
|
1440
|
+
// A stub (or missing file) has unchanged source, so the incremental check would skip it.
|
|
1441
|
+
if ((0, working_set_1.isStub)(file) || !fs_extra_1.default.existsSync(file)) {
|
|
1442
|
+
this.forceGenerate.add(name);
|
|
1443
|
+
}
|
|
1444
|
+
return kind === 'pages' ? this.generatePageComponent(name) : this.generatePartialComponent(name);
|
|
1445
|
+
}
|
|
1446
|
+
const stub = PAGE_STUB_TEMPLATE({ name, kind: kind === 'pages' ? 'page' : 'partial' });
|
|
1447
|
+
if (!(0, working_set_1.isStub)(file)) {
|
|
1448
|
+
// Drop the previously generated files; they are regenerated when this is built.
|
|
1449
|
+
fs_extra_1.default.emptyDirSync(path_2.default.dirname(file));
|
|
1450
|
+
(0, utils_1.writeFile)(file, stub);
|
|
1451
|
+
}
|
|
1452
|
+
else if (fs_extra_1.default.readFileSync(file, 'utf-8') !== stub) {
|
|
1453
|
+
// A stub written by an older template.
|
|
1454
|
+
(0, utils_1.writeFile)(file, stub);
|
|
1455
|
+
}
|
|
1456
|
+
// Entity metadata is built from every fragment's live variables, stubbed ones included.
|
|
1457
|
+
const variables = fs_extra_1.default.readJSONSync(`${this.projectService.path}/pages/${name}/${name}.variables.json`);
|
|
1458
|
+
this.liveVariables.push(...Object.values(variables).filter((v) => v.category === 'wm.LiveVariable'));
|
|
1459
|
+
return Promise.resolve();
|
|
1460
|
+
}
|
|
1271
1461
|
generatePagesAndPartials() {
|
|
1272
1462
|
let pageConfigs = null;
|
|
1273
1463
|
return this.projectService.getPageConfigs().then(_pageConfigs => {
|
|
1274
1464
|
pageConfigs = _pageConfigs;
|
|
1465
|
+
const workingSet = this.resolvePreviewWorkingSet(pageConfigs);
|
|
1275
1466
|
const pageCreationPromises = pageConfigs.map(p => {
|
|
1276
1467
|
if (p.type === 'PAGE') {
|
|
1277
|
-
return this.generatePageComponent(p.name);
|
|
1468
|
+
return workingSet ? this.generatePreviewFragment(p.name, 'pages', workingSet) : this.generatePageComponent(p.name);
|
|
1278
1469
|
}
|
|
1279
1470
|
if (this.isPartial(p.type)) {
|
|
1280
|
-
return this.generatePartialComponent(p.name);
|
|
1471
|
+
return workingSet ? this.generatePreviewFragment(p.name, 'partials', workingSet) : this.generatePartialComponent(p.name);
|
|
1281
1472
|
}
|
|
1282
1473
|
});
|
|
1474
|
+
// Stubs generate no prefabs or WMX components, but a page built later needs them in bootstrap.js
|
|
1475
|
+
// and in the compiled WMX library, which incremental builds do not redo.
|
|
1476
|
+
if (workingSet && !this.incBuilder) {
|
|
1477
|
+
pageCreationPromises.push(this.generateAllPrefabComponents(false), ...this.wmxComponents.map(c => this.generateWMXComponents(c, false)));
|
|
1478
|
+
}
|
|
1283
1479
|
return Promise.all(pageCreationPromises);
|
|
1284
1480
|
})
|
|
1285
1481
|
.then(() => this.generatePageConfig(pageConfigs))
|
|
1286
1482
|
.then(() => this.generatePartialConfig(pageConfigs));
|
|
1287
1483
|
}
|
|
1288
1484
|
async mergePackageJson() {
|
|
1485
|
+
var _a, _b, _c;
|
|
1289
1486
|
if (this.incBuilder) {
|
|
1290
1487
|
console.log(`Merging package.json .`);
|
|
1291
1488
|
}
|
|
@@ -1296,26 +1493,47 @@ class AppGenerator {
|
|
|
1296
1493
|
packageToOveride.description = config.description;
|
|
1297
1494
|
if (profile_1.default.targetPlatform === 'web') {
|
|
1298
1495
|
const webPackageJson = fs_extra_1.default.readJSONSync(`${__dirname}/templates/package.web.json`, { encoding: 'utf-8' });
|
|
1299
|
-
|
|
1300
|
-
packageToOveride.scripts = (0, lodash_1.merge)(packageToOveride.scripts, webPackageJson.scripts);
|
|
1496
|
+
packageToOveride = (0, lodash_1.merge)(packageToOveride, webPackageJson);
|
|
1301
1497
|
}
|
|
1302
1498
|
if (this.wmxComponents.length > 0) {
|
|
1303
1499
|
packageToOveride.scripts.postinstall = [
|
|
1304
|
-
'npm install ./wmx-components',
|
|
1500
|
+
'npm install --prefix ./wmx-components',
|
|
1305
1501
|
...((packageToOveride.scripts.postinstall || '')
|
|
1306
1502
|
.split('&&')
|
|
1307
1503
|
.filter((s) => s && !!s.trim()))
|
|
1308
1504
|
].join(' && ');
|
|
1309
|
-
packageToOveride.dependencies['@wavemaker/wmx-component'] = 'file:wmx-components';
|
|
1310
1505
|
if (!this.incBuilder || this.incBuilder.isWMXComponentModified()) {
|
|
1311
1506
|
await this.compileXComponentLib();
|
|
1312
1507
|
}
|
|
1508
|
+
// wmx-components/node_modules is removed after the build and blocked in metro.config.js, so wmx's
|
|
1509
|
+
// own packages (e.g. react-konva) must be app dependencies. Versions the app declares win.
|
|
1510
|
+
const wmxDependencies = ((_a = fs_extra_1.default.readJsonSync(`${this.projectPath}/wmx-components/package.json`, { throws: false })) === null || _a === void 0 ? void 0 : _a.dependencies) || {};
|
|
1511
|
+
for (const [name, range] of Object.entries(wmxDependencies)) {
|
|
1512
|
+
if (!packageToOveride.dependencies[name] && !((_b = packageToOveride.devDependencies) === null || _b === void 0 ? void 0 : _b[name]) && semver_1.default.validRange(range)) {
|
|
1513
|
+
packageToOveride.dependencies[name] = range;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1313
1516
|
}
|
|
1314
1517
|
const packageOverride = await this.projectService.getPackageJSONOverride();
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1518
|
+
let packageOverriden = packageOverride ? (0, lodash_1.merge)(packageToOveride, packageOverride) : packageToOveride;
|
|
1519
|
+
if (this.wmxComponents.length > 0) {
|
|
1520
|
+
const priorWmxInstallForms = [
|
|
1521
|
+
'npm install ./wmx-components',
|
|
1522
|
+
'npm install --prefix ./wmx-components',
|
|
1523
|
+
'npm install --prefix ./wmx-components --cache ./wmx-components/.npm-cache'
|
|
1524
|
+
];
|
|
1525
|
+
const remainingSteps = (((_c = packageOverriden.scripts) === null || _c === void 0 ? void 0 : _c.postinstall) || '')
|
|
1526
|
+
.split('&&')
|
|
1527
|
+
.map((s) => s.trim())
|
|
1528
|
+
.filter((s) => s && !priorWmxInstallForms.includes(s));
|
|
1529
|
+
if (remainingSteps.length > 0) {
|
|
1530
|
+
packageOverriden.scripts.postinstall = remainingSteps.join(' && ');
|
|
1531
|
+
}
|
|
1532
|
+
else if (packageOverriden.scripts) {
|
|
1533
|
+
delete packageOverriden.scripts.postinstall;
|
|
1534
|
+
}
|
|
1318
1535
|
}
|
|
1536
|
+
fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(packageOverriden, null, 4));
|
|
1319
1537
|
}
|
|
1320
1538
|
/**
|
|
1321
1539
|
* update app.json with expo-video plugin
|
|
@@ -1351,6 +1569,36 @@ class AppGenerator {
|
|
|
1351
1569
|
(0, utils_1.writeFile)(`${this.projectPath}/app.json`, JSON.stringify(appJson, null, 4));
|
|
1352
1570
|
}
|
|
1353
1571
|
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Packages the project adds itself: wm_rn_config.json plugins, prefab npm:// scripts and wmx component
|
|
1574
|
+
* dependencies. Only WaveMaker's own packages are pruned, so these stay even when the template also ships
|
|
1575
|
+
* them (e.g. expo-camera needed by a custom plugin), and npm keeps whatever they depend on.
|
|
1576
|
+
*/
|
|
1577
|
+
async getProjectAddedPackages() {
|
|
1578
|
+
var _a, _b, _c;
|
|
1579
|
+
const names = new Set();
|
|
1580
|
+
const config = fs_extra_1.default.readJsonSync(`${this.projectPath}/wm_rn_config.json`, { throws: false });
|
|
1581
|
+
[...((config === null || config === void 0 ? void 0 : config.plugins) || []), ...((config === null || config === void 0 ? void 0 : config.customPlugins) || [])]
|
|
1582
|
+
.forEach((p) => (p === null || p === void 0 ? void 0 : p.name) && names.add(p.name));
|
|
1583
|
+
const wmxDependencies = (_a = fs_extra_1.default.readJsonSync(`${this.projectPath}/wmx-components/package.json`, { throws: false })) === null || _a === void 0 ? void 0 : _a.dependencies;
|
|
1584
|
+
Object.keys(wmxDependencies || {}).forEach((name) => names.add(name));
|
|
1585
|
+
for (const prefab of Object.keys(this.transpiledComponents.prefabs || {})) {
|
|
1586
|
+
try {
|
|
1587
|
+
const info = await this.projectService.getPrefabInfo(prefab);
|
|
1588
|
+
(((_c = (_b = info === null || info === void 0 ? void 0 : info.config) === null || _b === void 0 ? void 0 : _b.resources) === null || _c === void 0 ? void 0 : _c.scripts) || []).forEach((script) => {
|
|
1589
|
+
var _a;
|
|
1590
|
+
const name = script.includes('npm://') && ((_a = script.match(/[\/]+(.*?)@\d/)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
1591
|
+
if (name) {
|
|
1592
|
+
names.add(name);
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
catch (e) {
|
|
1597
|
+
console.warn(`Could not read prefab ${prefab} config: ${e.message}`);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
return names;
|
|
1601
|
+
}
|
|
1354
1602
|
/**
|
|
1355
1603
|
* remove unused dependencies from package.json
|
|
1356
1604
|
* @param packageJsonData
|
|
@@ -1363,6 +1611,7 @@ class AppGenerator {
|
|
|
1363
1611
|
let removedPackages = [];
|
|
1364
1612
|
try {
|
|
1365
1613
|
const dependencies = (0, lodash_1.cloneDeep)(this.projectPackageDependencies);
|
|
1614
|
+
const projectAddedPackages = await this.getProjectAddedPackages();
|
|
1366
1615
|
const listOfPackagesUsed = await this.getListOfPackagesUsedInGeneratedApp();
|
|
1367
1616
|
const operationsUsed = Object.entries(listOfPackagesUsed)
|
|
1368
1617
|
.map(([key, value]) => {
|
|
@@ -1401,6 +1650,10 @@ class AppGenerator {
|
|
|
1401
1650
|
if (isPackageUsedByOtherOperation) {
|
|
1402
1651
|
return;
|
|
1403
1652
|
}
|
|
1653
|
+
if (projectAddedPackages.has(p)) {
|
|
1654
|
+
console.log(`Keeping package ${p}: added by the project (plugin, prefab or wmx component)`);
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1404
1657
|
delete updatedPackageJson.dependencies[p];
|
|
1405
1658
|
if (!removedPackages.includes(p)) {
|
|
1406
1659
|
removedPackages.push(p);
|
|
@@ -1436,19 +1689,33 @@ class AppGenerator {
|
|
|
1436
1689
|
}
|
|
1437
1690
|
fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(updatedPackageJson, null, 4));
|
|
1438
1691
|
// * installing packages whenever a package is added or removed
|
|
1439
|
-
|
|
1440
|
-
|
|
1692
|
+
// Web preview installs after generation (installDependencies), so not here as well.
|
|
1693
|
+
if (this.shouldNpmInstall && this.incBuilder && !this.isWebPreview) {
|
|
1694
|
+
await (0, command_1.npmInstall)(`${this.projectPath}`);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
// Report only; "dependencyCheck": false in wm_rn_config.json turns it off.
|
|
1698
|
+
reportCustomDependencies() {
|
|
1699
|
+
if (this.rnConfig.dependencyCheck === false) {
|
|
1700
|
+
return Promise.resolve();
|
|
1441
1701
|
}
|
|
1702
|
+
return depsCompat.reportCustomDependencies(this.projectPath, {
|
|
1703
|
+
baseDir: profile_1.default.packageLockFilePath ? path_2.default.dirname(profile_1.default.packageLockFilePath) : `${__dirname}/templates/project`,
|
|
1704
|
+
ownScope: wm_namespace_1.WM_NPM_SCOPE,
|
|
1705
|
+
});
|
|
1442
1706
|
}
|
|
1443
1707
|
async copyPackageLockJson() {
|
|
1444
|
-
|
|
1708
|
+
const hadLock = fs_extra_1.default.existsSync(`${this.projectPath}/package-lock.json`);
|
|
1709
|
+
if (!depsCompat.syncBaseLock(this.projectPath, profile_1.default.packageLockFilePath)) {
|
|
1445
1710
|
return;
|
|
1446
1711
|
}
|
|
1447
1712
|
if (this.incBuilder) {
|
|
1448
1713
|
console.log(`Copying package-lock.json .`);
|
|
1449
1714
|
}
|
|
1450
|
-
if (
|
|
1451
|
-
|
|
1715
|
+
if (hadLock) {
|
|
1716
|
+
// A replaced lock no longer lists the custom packages, so the next install must run to add them back
|
|
1717
|
+
// (it otherwise only runs when package.json changes).
|
|
1718
|
+
fs_extra_1.default.removeSync(`${this.projectPath}/dependencies.info`);
|
|
1452
1719
|
}
|
|
1453
1720
|
if (profile_1.default.yarnLockFilePath && fs_extra_1.default.existsSync(profile_1.default.yarnLockFilePath)) {
|
|
1454
1721
|
fs_extra_1.default.copySync(profile_1.default.yarnLockFilePath, `${this.projectPath}/yarn.json`);
|
|
@@ -1514,6 +1781,50 @@ class AppGenerator {
|
|
|
1514
1781
|
}
|
|
1515
1782
|
fs_extra_1.default.writeJsonSync(appJsonPath, appJson, { spaces: 2 });
|
|
1516
1783
|
}
|
|
1784
|
+
// Registered as a file: dependency (a native module, unlike expo-screen-capture-plugin's config plugin) so Expo autolinking discovers it.
|
|
1785
|
+
async copyPullToRefreshPluginIfNeeded() {
|
|
1786
|
+
const config = this.rnConfig;
|
|
1787
|
+
const packageJsonPath = `${this.projectPath}/package.json`;
|
|
1788
|
+
const pluginName = '@wavemaker/expo-pull-to-refresh';
|
|
1789
|
+
const pluginDestPath = `${this.projectPath}/plugins/expo-pull-to-refresh`;
|
|
1790
|
+
if (!fs_extra_1.default.existsSync(packageJsonPath)) {
|
|
1791
|
+
console.warn(`Warning: package.json not found at ${packageJsonPath}`);
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
const packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
|
|
1795
|
+
// Both flags: an animation alone with the feature off shouldn't ship the plugin.
|
|
1796
|
+
if ((config === null || config === void 0 ? void 0 : config.pulltorefresh) && (config === null || config === void 0 ? void 0 : config.pulltorefreshsource)) {
|
|
1797
|
+
const pluginSourcePath = __dirname + '/templates/project/plugins/expo-pull-to-refresh';
|
|
1798
|
+
if (!fs_extra_1.default.existsSync(pluginSourcePath)) {
|
|
1799
|
+
console.warn(`Warning: Pull to refresh plugin source not found at ${pluginSourcePath}`);
|
|
1800
|
+
return;
|
|
1801
|
+
}
|
|
1802
|
+
fs_extra_1.default.mkdirsSync(`${this.projectPath}/plugins`);
|
|
1803
|
+
fs_extra_1.default.copySync(pluginSourcePath, pluginDestPath);
|
|
1804
|
+
console.log(`Copied pull to refresh plugin to ${pluginDestPath}`);
|
|
1805
|
+
if (!packageJson.dependencies) {
|
|
1806
|
+
packageJson.dependencies = {};
|
|
1807
|
+
}
|
|
1808
|
+
if (packageJson.dependencies[pluginName] !== 'file:./plugins/expo-pull-to-refresh') {
|
|
1809
|
+
packageJson.dependencies[pluginName] = 'file:./plugins/expo-pull-to-refresh';
|
|
1810
|
+
console.log(`Added ${pluginName} to package.json`);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
else {
|
|
1814
|
+
if (fs_extra_1.default.existsSync(pluginDestPath)) {
|
|
1815
|
+
fs_extra_1.default.removeSync(pluginDestPath);
|
|
1816
|
+
const pluginsDir = `${this.projectPath}/plugins`;
|
|
1817
|
+
if (fs_extra_1.default.existsSync(pluginsDir) && fs_extra_1.default.readdirSync(pluginsDir).length === 0) {
|
|
1818
|
+
fs_extra_1.default.removeSync(pluginsDir);
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
if (packageJson.dependencies && packageJson.dependencies[pluginName]) {
|
|
1822
|
+
delete packageJson.dependencies[pluginName];
|
|
1823
|
+
console.log(`Removed ${pluginName} from package.json`);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
fs_extra_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 4));
|
|
1827
|
+
}
|
|
1517
1828
|
async addCustomPluginsToPackageJson() {
|
|
1518
1829
|
if (this.incBuilder) {
|
|
1519
1830
|
console.log(`Adding custom plugins.`);
|
|
@@ -1530,70 +1841,44 @@ class AppGenerator {
|
|
|
1530
1841
|
let plugins = config.plugins;
|
|
1531
1842
|
let data = fs_extra_1.default.readFileSync(`${this.projectPath}/package.json`, 'utf-8');
|
|
1532
1843
|
const jsonData = JSON.parse(data);
|
|
1533
|
-
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
});
|
|
1553
|
-
plugins.forEach((p) => {
|
|
1554
|
-
if (p.spec) {
|
|
1555
|
-
if (p.spec.includes('tgz')) {
|
|
1556
|
-
jsonData['dependencies'][p.name] = 'file:' + p.spec;
|
|
1557
|
-
shouldNpmInstall = true;
|
|
1558
|
-
}
|
|
1559
|
-
else if (semver_1.default.valid(p.spec) && !semver_1.default.lt(p.spec, jsonData['dependencies'][p.name] || '0.0.0')) {
|
|
1560
|
-
jsonData['dependencies'][p.name] = p.spec;
|
|
1561
|
-
shouldNpmInstall = true;
|
|
1562
|
-
}
|
|
1563
|
-
else if (!semver_1.default.valid(p.spec)) {
|
|
1564
|
-
jsonData['dependencies'][p.name] = p.spec;
|
|
1565
|
-
shouldNpmInstall = true;
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
});
|
|
1569
|
-
if (shouldNpmInstall) {
|
|
1570
|
-
this.shouldNpmInstall = true;
|
|
1571
|
-
}
|
|
1572
|
-
fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(jsonData, null, 4));
|
|
1573
|
-
});
|
|
1574
|
-
}
|
|
1575
|
-
else {
|
|
1576
|
-
plugins.forEach((p) => {
|
|
1577
|
-
if (p.spec) {
|
|
1578
|
-
if (p.spec.includes('tgz')) {
|
|
1579
|
-
jsonData['dependencies'][p.name] = 'file:' + p.spec;
|
|
1580
|
-
shouldNpmInstall = true;
|
|
1581
|
-
}
|
|
1582
|
-
else if (semver_1.default.valid(p.spec) && !semver_1.default.lt(p.spec, jsonData['dependencies'][p.name] || '0.0.0')) {
|
|
1583
|
-
jsonData['dependencies'][p.name] = p.spec;
|
|
1584
|
-
shouldNpmInstall = true;
|
|
1585
|
-
}
|
|
1586
|
-
else if (!semver_1.default.valid(p.spec)) {
|
|
1587
|
-
jsonData['dependencies'][p.name] = p.spec;
|
|
1588
|
-
shouldNpmInstall = true;
|
|
1589
|
-
}
|
|
1844
|
+
// Plugins added by an earlier build and since removed from wm_rn_config.json are dropped from package.json.
|
|
1845
|
+
const addedPluginsPath = `${this.projectPath}/.wm-config-plugins.json`;
|
|
1846
|
+
const configured = plugins.filter((p) => p.spec).map((p) => p.name);
|
|
1847
|
+
const templateDependencies = fs_extra_1.default.readJSONSync(`${__dirname}/templates/project/package.json`).dependencies;
|
|
1848
|
+
// Only a record of earlier builds: an unreadable one just means nothing is removed this time.
|
|
1849
|
+
(fs_extra_1.default.readJSONSync(addedPluginsPath, { throws: false }) || [])
|
|
1850
|
+
.filter((name) => !configured.includes(name) && !templateDependencies[name] && jsonData.dependencies[name])
|
|
1851
|
+
.forEach((name) => {
|
|
1852
|
+
console.log(`Removing plugin ${name}: no longer in wm_rn_config.json`);
|
|
1853
|
+
delete jsonData.dependencies[name];
|
|
1854
|
+
this.shouldNpmInstall = true;
|
|
1855
|
+
});
|
|
1856
|
+
fs_extra_1.default.writeJSONSync(addedPluginsPath, configured);
|
|
1857
|
+
// Every prefab's npm:// package is in package.json before the compatibility check runs.
|
|
1858
|
+
await Promise.all(Object.keys(this.transpiledComponents.prefabs || {}).map((prefab) => this.projectService.getPrefabInfo(prefab).then(info => {
|
|
1859
|
+
var _a;
|
|
1860
|
+
(_a = info.config["resources"]["scripts"]) === null || _a === void 0 ? void 0 : _a.forEach((script) => {
|
|
1861
|
+
if (script.includes('npm://')) {
|
|
1862
|
+
jsonData['dependencies'][script.match(/[\/]+(.*?)@\d/)[1]] = script.match('.*@(.*?)$')[1];
|
|
1590
1863
|
}
|
|
1591
1864
|
});
|
|
1592
|
-
|
|
1593
|
-
|
|
1865
|
+
})));
|
|
1866
|
+
plugins.forEach((p) => {
|
|
1867
|
+
if (!p.spec) {
|
|
1868
|
+
return;
|
|
1594
1869
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1870
|
+
if (p.spec.includes('tgz')) {
|
|
1871
|
+
jsonData['dependencies'][p.name] = 'file:' + p.spec;
|
|
1872
|
+
}
|
|
1873
|
+
else if (!semver_1.default.valid(p.spec) || !semver_1.default.lt(p.spec, semver_1.default.valid(jsonData['dependencies'][p.name]) || '0.0.0')) {
|
|
1874
|
+
jsonData['dependencies'][p.name] = p.spec;
|
|
1875
|
+
}
|
|
1876
|
+
else {
|
|
1877
|
+
return;
|
|
1878
|
+
}
|
|
1879
|
+
this.shouldNpmInstall = true;
|
|
1880
|
+
});
|
|
1881
|
+
fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(jsonData, null, 4));
|
|
1597
1882
|
}
|
|
1598
1883
|
async generateFoundationTheme() {
|
|
1599
1884
|
await new app_override_css_generator_1.AppOverrideCSSGenerator(this.projectService.path).generate();
|
|
@@ -1602,7 +1887,7 @@ class AppGenerator {
|
|
|
1602
1887
|
const themePath = `${this.projectService.path}/design-tokens/foundation`;
|
|
1603
1888
|
try {
|
|
1604
1889
|
const foundationPath = `${__dirname}/templates/foundation-theme/dist`;
|
|
1605
|
-
fs_extra_1.default.copySync(foundationPath, themePath);
|
|
1890
|
+
fs_extra_1.default.copySync(foundationPath, themePath, { preserveTimestamps: true });
|
|
1606
1891
|
}
|
|
1607
1892
|
catch (error) {
|
|
1608
1893
|
console.error(error);
|
|
@@ -1702,10 +1987,38 @@ class AppGenerator {
|
|
|
1702
1987
|
});
|
|
1703
1988
|
}).then(() => this.generateResourceResolver());
|
|
1704
1989
|
}
|
|
1990
|
+
timed(label, fn) {
|
|
1991
|
+
console.time(`App creation: ${label}`);
|
|
1992
|
+
return Promise.resolve(fn()).finally(() => console.timeEnd(`App creation: ${label}`));
|
|
1993
|
+
}
|
|
1705
1994
|
async generateApp() {
|
|
1706
1995
|
this.rnConfig = await this.projectService.getRNConfig().then(data => JSON.parse(data));
|
|
1707
|
-
this.incBuilder ||
|
|
1708
|
-
|
|
1996
|
+
const customPackagesChanged = !this.incBuilder || this.incBuilder.isConfigModified() || this.incBuilder.isPrefabModified();
|
|
1997
|
+
// templates/project/metro/ (the split-bundle build) is only needed by
|
|
1998
|
+
// the web-preview profile; every other profile skips it.
|
|
1999
|
+
const templatesRoot = __dirname + '/templates/project';
|
|
2000
|
+
if (this.incBuilder && this.isWebPreview) {
|
|
2001
|
+
this.timed('copy templates: sync', () => (0, web_preview_templates_1.syncWebPreviewTemplates)(templatesRoot, this.projectPath));
|
|
2002
|
+
}
|
|
2003
|
+
this.incBuilder || this.timed('copy templates', () => fs_extra_1.default.copySync(templatesRoot, this.projectPath, {
|
|
2004
|
+
filter: (src) => {
|
|
2005
|
+
const rel = path_2.default.relative(templatesRoot, src);
|
|
2006
|
+
// The template lock is input for the rn-app package, not a project file: copying it
|
|
2007
|
+
// would make copyPackageLockJson skip the rn-app lock the profile points at.
|
|
2008
|
+
if (rel === 'package-lock.json') {
|
|
2009
|
+
return false;
|
|
2010
|
+
}
|
|
2011
|
+
if (this.isWebPreview) {
|
|
2012
|
+
return true;
|
|
2013
|
+
}
|
|
2014
|
+
return rel !== 'metro' && !rel.startsWith(`metro${path_1.sep}`);
|
|
2015
|
+
}
|
|
2016
|
+
}));
|
|
2017
|
+
const customMetroConfig = await this.projectService.getCustomMetroConfig();
|
|
2018
|
+
if (customMetroConfig) {
|
|
2019
|
+
(0, utils_1.writeFile)(`${this.projectPath}/custommetro.config.js`, customMetroConfig);
|
|
2020
|
+
}
|
|
2021
|
+
return this.timed('pages+partials', () => this.generatePagesAndPartials())
|
|
1709
2022
|
.then(() => this.incBuilder && this.generateAllPrefabComponents())
|
|
1710
2023
|
.then(() => !this.incBuilder || this.incBuilder.isResourceModified())
|
|
1711
2024
|
.then((build) => (build && this.generateResourceResolver()))
|
|
@@ -1727,6 +2040,8 @@ class AppGenerator {
|
|
|
1727
2040
|
.then((build) => (build && this.generateFonts()))
|
|
1728
2041
|
.then(() => !this.incBuilder || this.incBuilder.isConfigModified())
|
|
1729
2042
|
.then((build) => (build && this.generateRNConfig()))
|
|
2043
|
+
.then(() => !this.incBuilder || this.incBuilder.isConfigModified() || this.incBuilder.isResourceModified())
|
|
2044
|
+
.then((build) => (build && this.generateGlobalConfig()))
|
|
1730
2045
|
.then(() => !this.incBuilder || this.incBuilder.isFormatterModified())
|
|
1731
2046
|
.then((build) => (build && this.generateFormatters()))
|
|
1732
2047
|
.then(() => !this.incBuilder || this.incBuilder.isConfigModified())
|
|
@@ -1734,7 +2049,7 @@ class AppGenerator {
|
|
|
1734
2049
|
.then(() => !this.incBuilder || this.incBuilder.isConfigModified())
|
|
1735
2050
|
.then((build) => (build && this.generateBabelConfig()))
|
|
1736
2051
|
.then(() => !this.incBuilder || this.incBuilder.isThemeModified() || this.incBuilder.isFoundationThemeModified())
|
|
1737
|
-
.then((build) => (build && this.generateAppTheme()))
|
|
2052
|
+
.then((build) => (build && this.timed('theme', () => this.generateAppTheme())))
|
|
1738
2053
|
.then(() => !this.incBuilder || this.incBuilder.isi18nModified())
|
|
1739
2054
|
.then((build) => (build && this.copyi18nFiles()))
|
|
1740
2055
|
.then(() => !this.incBuilder || this.incBuilder.isi18nModified())
|
|
@@ -1746,27 +2061,30 @@ class AppGenerator {
|
|
|
1746
2061
|
}
|
|
1747
2062
|
}).then(() => !this.incBuilder)
|
|
1748
2063
|
.then((build) => (this.prepareDeviceOperationLoader()))
|
|
1749
|
-
.then(() =>
|
|
1750
|
-
|
|
1751
|
-
|| this.incBuilder.isPrefabModified())
|
|
1752
|
-
.then((build) => (build && this.addCustomPluginsToPackageJson()))
|
|
1753
|
-
.then(() => this.mergePackageJson())
|
|
2064
|
+
.then(() => customPackagesChanged ? this.addCustomPluginsToPackageJson() : undefined)
|
|
2065
|
+
.then(() => this.timed('package.json merge (incl. wmx-component npm install+build)', () => this.mergePackageJson()))
|
|
1754
2066
|
.then(() => this.copyPackageLockJson())
|
|
2067
|
+
.then(() => customPackagesChanged ? this.timed('custom package report', () => this.reportCustomDependencies()) : undefined)
|
|
1755
2068
|
.then(() => this.checkWidgetUsageInComponentFiles())
|
|
1756
2069
|
.then(() => this.checkPackageUsageInJSFiles())
|
|
1757
|
-
|
|
2070
|
+
// Web preview: mergePackageJson re-adds the project's package.json override every build, which brings
|
|
2071
|
+
// back packages an earlier build removed, so the removal (~0.2s) has to run every build too.
|
|
2072
|
+
.then(() => !this.incBuilder || this.shouldDoUnwantedPackagesCleanup || this.isWebPreview)
|
|
1758
2073
|
.then((removePackages) => {
|
|
1759
2074
|
if (removePackages) {
|
|
1760
|
-
return this.removeUnusedPackages();
|
|
2075
|
+
return this.timed('remove unused packages', () => this.removeUnusedPackages());
|
|
1761
2076
|
}
|
|
1762
2077
|
else {
|
|
1763
2078
|
return Promise.resolve();
|
|
1764
2079
|
}
|
|
1765
2080
|
})
|
|
1766
2081
|
.then(() => !this.incBuilder)
|
|
1767
|
-
.then((build) => (build
|
|
2082
|
+
.then((build) => (build
|
|
2083
|
+
&& !(this.isWebPreview && process.env.WM_PREVIEW_PRETTIFY !== '1')
|
|
2084
|
+
&& this.prettify()))
|
|
1768
2085
|
.then(() => this.projectService.copyNpmPackages(this.projectPath))
|
|
1769
2086
|
.then(() => this.copyScreenCapturePluginIfNeeded())
|
|
2087
|
+
.then(() => this.copyPullToRefreshPluginIfNeeded())
|
|
1770
2088
|
.then(() => console.log('code generated at ' + this.projectPath));
|
|
1771
2089
|
}
|
|
1772
2090
|
generateFragment(name) {
|
|
@@ -1785,7 +2103,9 @@ class AppGenerator {
|
|
|
1785
2103
|
})
|
|
1786
2104
|
.then(() => this.generatePageConfig(pageConfigs))
|
|
1787
2105
|
.then(() => this.generatePartialConfig(pageConfigs))
|
|
1788
|
-
.then(() => this.
|
|
2106
|
+
.then(() => (this.isWebPreview && process.env.WM_PREVIEW_PRETTIFY !== '1')
|
|
2107
|
+
? undefined
|
|
2108
|
+
: this.prettify(`**/${name}/**/*.js`))
|
|
1789
2109
|
.then(() => console.log('code generated at ' + this.projectPath));
|
|
1790
2110
|
}
|
|
1791
2111
|
;
|