@wavemaker/rn-codegen 11.16.0-rc.647821 → 11.16.1-rc.647845
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 +111 -269
- package/command.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/npm-shrinkwrap.json +4840 -3624
- package/package-lock.json +4840 -3624
- package/package.json +62 -42
- package/src/app.generator.js +249 -87
- package/src/app.generator.js.map +1 -1
- package/src/fomatter.js.map +1 -1
- package/src/handlebar-helpers.js.map +1 -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 +152 -0
- package/src/pipeline/build-pipeline.js.map +1 -0
- package/src/pipeline/generation-store.js +288 -0
- package/src/pipeline/generation-store.js.map +1 -0
- package/src/pipeline/shared-node-modules.js +775 -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 +17 -7
- package/src/project.service.js.map +1 -1
- package/src/templates/babel.config.js.template +0 -1
- package/src/templates/bootstrap.template +3 -1
- package/src/templates/device-plugin-service.template +7 -9
- package/src/templates/package.web.json +108 -83
- package/src/templates/page-stub.template +27 -0
- package/src/templates/project/app.json +4 -11
- package/src/templates/project/esbuild/esbuild.script.js +129 -89
- package/src/templates/project/metro/container-limits.js +195 -0
- package/src/templates/project/metro/metro.script.js +833 -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 +138 -0
- package/src/templates/project/metro/wm-crawl-override.js +147 -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.config.js +209 -8
- package/src/templates/project/package.json +106 -83
- package/src/templates/project/patch-utils.js +331 -0
- package/src/templates/project/scripts/post-build.js +3 -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/basic/base.styledef.js.map +1 -1
- package/src/theme/components/style-definition.provider.js.map +1 -1
- package/src/theme/font-stylesheet.transpiler.js +17 -7
- package/src/theme/font-stylesheet.transpiler.js.map +1 -1
- package/src/theme/rn-stylesheet.transpiler.js +17 -7
- package/src/theme/rn-stylesheet.transpiler.js.map +1 -1
- package/src/theme/theme.service.js +7 -19
- package/src/theme/theme.service.js.map +1 -1
- package/src/theme/token.transpiler.js +17 -7
- package/src/theme/token.transpiler.js.map +1 -1
- package/src/transpile/bind.ex.transformer.js +36 -23
- package/src/transpile/bind.ex.transformer.js.map +1 -1
- package/src/transpile/components/advanced/carousel.transformer.js.map +1 -1
- package/src/transpile/components/advanced/customwidget.transformer.js.map +1 -1
- package/src/transpile/components/advanced/login.transformer.js.map +1 -1
- package/src/transpile/components/advanced/webview.transformer.js.map +1 -1
- package/src/transpile/components/basic/buttongroup.transformer.js.map +1 -1
- package/src/transpile/components/basic/custom.transformer.js.map +1 -1
- package/src/transpile/components/basic/picture.transformer.js.map +1 -1
- package/src/transpile/components/basic/progress-bar.transformer.js.map +1 -1
- package/src/transpile/components/basic/search.transformer.js.map +1 -1
- package/src/transpile/components/chart/area-chart.transformer.js.map +1 -1
- package/src/transpile/components/container/accordion/accordionpane.transformer.js.map +1 -1
- package/src/transpile/components/container/accordion.transformer.js.map +1 -1
- package/src/transpile/components/container/container.transformer.js.map +1 -1
- package/src/transpile/components/container/layoutgrid/gridcolumn.transformer.js.map +1 -1
- package/src/transpile/components/container/layoutgrid/gridrow.transformer.js.map +1 -1
- package/src/transpile/components/container/layoutgrid.transformer.js.map +1 -1
- package/src/transpile/components/container/linearlayout.transformer.js.map +1 -1
- package/src/transpile/components/container/panel.transformer.js.map +1 -1
- package/src/transpile/components/container/tabs/tabpane.transformer.js.map +1 -1
- package/src/transpile/components/container/tabs.transformer.js.map +1 -1
- package/src/transpile/components/container/wizard/wizardstep.transformer.js.map +1 -1
- package/src/transpile/components/container/wizard.transformer.js.map +1 -1
- package/src/transpile/components/data/card/card-content.transformer.js.map +1 -1
- package/src/transpile/components/data/form/form-action.transformer.js.map +1 -1
- package/src/transpile/components/data/form/form-field.transformer.js.map +1 -1
- package/src/transpile/components/data/form.transformer.js.map +1 -1
- package/src/transpile/components/data/list.transformer.js +17 -7
- package/src/transpile/components/data/list.transformer.js.map +1 -1
- package/src/transpile/components/data/liveform.transformer.js.map +1 -1
- package/src/transpile/components/dialogs/dialog.transformer.js.map +1 -1
- package/src/transpile/components/input/checkboxset.transformer.js.map +1 -1
- package/src/transpile/components/input/chips.transformer.js.map +1 -1
- package/src/transpile/components/input/epoch/date.transformer.js.map +1 -1
- package/src/transpile/components/input/epoch/datetime.transformer.js.map +1 -1
- package/src/transpile/components/input/epoch/time.transformer.js.map +1 -1
- package/src/transpile/components/input/radioset.transformer.js.map +1 -1
- package/src/transpile/components/input/rating.transformer.js.map +1 -1
- package/src/transpile/components/input/select.transformer.js.map +1 -1
- package/src/transpile/components/input/slider.transformer.js.map +1 -1
- package/src/transpile/components/input/switch.transformer.js.map +1 -1
- package/src/transpile/components/input/textarea.transformer.js.map +1 -1
- package/src/transpile/components/input/toggle.transformer.js.map +1 -1
- package/src/transpile/components/navigation/appnavbar.transformer.js.map +1 -1
- package/src/transpile/components/navigation/menu.transformer.js.map +1 -1
- package/src/transpile/components/navigation/navbar.transformer.js.map +1 -1
- package/src/transpile/components/navigation/navitem.transformer.js.map +1 -1
- package/src/transpile/components/navigation/popover.transformer.js.map +1 -1
- package/src/transpile/components/page/left-panel.transformer.js.map +1 -1
- package/src/transpile/components/page/page.transformer.js.map +1 -1
- package/src/transpile/components/page/partial-container.transformer.js +17 -7
- package/src/transpile/components/page/partial-container.transformer.js.map +1 -1
- package/src/transpile/components/prefab/prefab.transformer.js.map +1 -1
- package/src/transpile/components/utils.js.map +1 -1
- package/src/transpile/property/property-parser.js.map +1 -1
- package/src/transpile/property/show-in-device.parser.js.map +1 -1
- package/src/transpile/style/background-image.parser.js.map +1 -1
- package/src/transpile/style/dimension-style.parser.js.map +1 -1
- package/src/transpile/style/multi-dimension-style.parser.js.map +1 -1
- package/src/transpile/style/numeric-style.parser.js.map +1 -1
- package/src/transpile/style.transformer.js.map +1 -1
- package/src/transpile/transpile.js +17 -7
- 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.map +1 -1
- package/src/wm-namespace.js +14 -0
- package/src/wm-namespace.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 +165 -0
- package/web-preview.js.map +1 -0
package/src/app.generator.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -41,6 +51,8 @@ const theme_service_1 = require("./theme/theme.service");
|
|
|
41
51
|
const profile_1 = __importDefault(require("./profiles/profile"));
|
|
42
52
|
const app_override_css_generator_1 = require("./theme/app-override-css.generator");
|
|
43
53
|
const command_1 = require("../command");
|
|
54
|
+
const web_preview_templates_1 = require("./pipeline/web-preview-templates");
|
|
55
|
+
const working_set_1 = require("./pipeline/working-set");
|
|
44
56
|
const APP_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/app.template');
|
|
45
57
|
const APP_THEME_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/app.theme.template');
|
|
46
58
|
const BABEL_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/babel.config.js.template');
|
|
@@ -52,6 +64,7 @@ const COMPONENT_PROPS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templat
|
|
|
52
64
|
const SCRIPT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/component/script.template');
|
|
53
65
|
const STYLE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/component/style.template');
|
|
54
66
|
const PAGE_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/pages-config.template');
|
|
67
|
+
const PAGE_STUB_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/page-stub.template');
|
|
55
68
|
const SERVICE_DEFINITIONS = (0, utils_1.loadTemplate)(__dirname + '/templates/service.defs.template');
|
|
56
69
|
const FORMATTERS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/extensions/formatters.template');
|
|
57
70
|
const VARIABLE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + '/templates/variables.template');
|
|
@@ -81,8 +94,8 @@ const ALLOWED_RESOURCE_EXT = [
|
|
|
81
94
|
];
|
|
82
95
|
const pluginOperationConfig = [];
|
|
83
96
|
const operationMap = {
|
|
84
|
-
'captureImage': { name: 'Camera', method: 'CaptureImageOperation', filename: 'capture-image', hasConstructorParams: true, packages: ['expo-camera', 'expo-file-system', 'expo-
|
|
85
|
-
'captureVideo': { name: 'Camera', method: 'CaptureVideoOperation', filename: 'capture-video', hasConstructorParams: true, packages: ['expo-camera', 'expo-file-system', 'expo-
|
|
97
|
+
'captureImage': { name: 'Camera', method: 'CaptureImageOperation', filename: 'capture-image', hasConstructorParams: true, packages: ['expo-camera', 'expo-file-system', 'expo-video'], tagName: ['WmCamera', 'WmBarcodescanner'], removePlugin: true },
|
|
98
|
+
'captureVideo': { name: 'Camera', method: 'CaptureVideoOperation', filename: 'capture-video', hasConstructorParams: true, packages: ['expo-camera', 'expo-file-system', 'expo-video'], tagName: ['WmCamera', 'WmBarcodescanner'], removePlugin: true },
|
|
86
99
|
'scanBarCode': { name: 'Scan', method: 'ScanOperation', filename: 'scan', hasConstructorParams: true, packages: ['expo-camera'], tagName: ['WmBarcodescanner'], removePlugin: true },
|
|
87
100
|
'getAppInfo': { name: 'Device', method: 'AppInfoOperation', filename: 'app-info', hasConstructorParams: false, packages: [], tagName: [], removePlugin: false },
|
|
88
101
|
'getDeviceInfo': { name: 'Device', method: 'DeviceInfoOperation', filename: 'device-info', hasConstructorParams: false, packages: ['expo-device'], tagName: [], removePlugin: false },
|
|
@@ -94,7 +107,7 @@ const operationMap = {
|
|
|
94
107
|
'createEvent': { name: 'Calendar', method: 'CreateEventOperation', filename: 'create-event', hasConstructorParams: true, packages: ['expo-calendar'], tagName: [], removePlugin: true },
|
|
95
108
|
'deleteEvent': { name: 'Calendar', method: 'DeleteEventOperation', filename: 'delete-event', hasConstructorParams: true, packages: ['expo-calendar'], tagName: [], removePlugin: true },
|
|
96
109
|
'upload': { name: 'File', method: 'UploadFileOperation', filename: 'upload-file', hasConstructorParams: false, packages: ['expo-document-picker'], tagName: ['WmFileupload'], removePlugin: true },
|
|
97
|
-
'playAudio': { name: 'Audio', method: 'PlayAudioOperation', filename: '', hasConstructorParams: false, packages: ['expo-
|
|
110
|
+
'playAudio': { name: 'Audio', method: 'PlayAudioOperation', filename: '', hasConstructorParams: false, packages: ['expo-audio'], tagName: ['WmAudio'], removePlugin: true },
|
|
98
111
|
'playVideo': { name: 'Video', method: 'PlayVideoOperation', filename: '', hasConstructorParams: false, packages: ['expo-video'], tagName: ['WmVideo'], removePlugin: true },
|
|
99
112
|
'openFile': { name: 'File', method: 'OpenFileOperation', filename: 'open-file', hasConstructorParams: false, packages: ['expo-sharing', 'expo-file-system'], tagName: [], removePlugin: true },
|
|
100
113
|
};
|
|
@@ -115,7 +128,7 @@ let deviceVariables = [];
|
|
|
115
128
|
let appVersion;
|
|
116
129
|
const servicesConfig = [];
|
|
117
130
|
class AppGenerator {
|
|
118
|
-
constructor(projectPath, projectService, appUrl, prefabName = '', incBuilder, options, dynamicPrefabProps) {
|
|
131
|
+
constructor(projectPath, projectService, appUrl, prefabName = '', incBuilder, options, dynamicPrefabProps, isWebPreview = false) {
|
|
119
132
|
this.projectPath = projectPath;
|
|
120
133
|
this.projectService = projectService;
|
|
121
134
|
this.appUrl = appUrl;
|
|
@@ -123,6 +136,7 @@ class AppGenerator {
|
|
|
123
136
|
this.incBuilder = incBuilder;
|
|
124
137
|
this.options = options;
|
|
125
138
|
this.dynamicPrefabProps = dynamicPrefabProps;
|
|
139
|
+
this.isWebPreview = isWebPreview;
|
|
126
140
|
this.transpiledComponents = {
|
|
127
141
|
pages: {},
|
|
128
142
|
partials: {},
|
|
@@ -139,6 +153,7 @@ class AppGenerator {
|
|
|
139
153
|
this.jsFileImports = new Set();
|
|
140
154
|
this.shouldNpmInstall = false;
|
|
141
155
|
this.shouldDoUnwantedPackagesCleanup = false;
|
|
156
|
+
this.forceGenerate = new Set();
|
|
142
157
|
this.options = options;
|
|
143
158
|
this.isPrefabApp = !!prefabName;
|
|
144
159
|
this.wmxComponents = this.projectService.getWMXComponents();
|
|
@@ -188,10 +203,12 @@ class AppGenerator {
|
|
|
188
203
|
* find all operations/packages (e.g, Camera, Scan, Location)
|
|
189
204
|
* that are used in the app
|
|
190
205
|
*/
|
|
206
|
+
// Web preview: scan pages once, not once per operation (minutes on large apps).
|
|
207
|
+
const sharedScan = this.isWebPreview ? Promise.all([this.getWidgetImports(), this.getDeviceVariables()]) : null;
|
|
191
208
|
await Promise.all(operations.map(async (operation) => {
|
|
192
209
|
let method = "";
|
|
193
|
-
const importedWidgets = await this.getWidgetImports();
|
|
194
|
-
const deviceVariables = await this.getDeviceVariables();
|
|
210
|
+
const importedWidgets = sharedScan ? (await sharedScan)[0] : await this.getWidgetImports();
|
|
211
|
+
const deviceVariables = sharedScan ? (await sharedScan)[1] : await this.getDeviceVariables();
|
|
195
212
|
const isWidgetImportedForCurrentOperation = importedWidgets.findIndex((w) => {
|
|
196
213
|
const widgetName = operation === "File"
|
|
197
214
|
? "WmFileupload"
|
|
@@ -409,7 +426,10 @@ class AppGenerator {
|
|
|
409
426
|
d = s.join(path_1.sep);
|
|
410
427
|
}
|
|
411
428
|
if (d) {
|
|
412
|
-
|
|
429
|
+
const binPath = fs_extra_1.default.existsSync(`${prettierPath}${path_1.sep}bin${path_1.sep}prettier.cjs`)
|
|
430
|
+
? `${prettierPath}${path_1.sep}bin${path_1.sep}prettier.cjs`
|
|
431
|
+
: `${prettierPath}${path_1.sep}bin-prettier.js`;
|
|
432
|
+
return (0, execa_1.default)('node', [binPath, '--write', `${this.projectPath}/${target}`]);
|
|
413
433
|
}
|
|
414
434
|
console.warn('Prettier is not found');
|
|
415
435
|
return Promise.reject();
|
|
@@ -503,15 +523,16 @@ class AppGenerator {
|
|
|
503
523
|
updateInSplashConfig(config, appConfig) {
|
|
504
524
|
var _a, _b, _c;
|
|
505
525
|
let filteredSplashConfig = this.removeOldKeys(config.splash);
|
|
526
|
+
const splashAssetPath = (src) => this.isWebPreview ? './assets/' + path_2.default.basename(src) : './assets/' + src;
|
|
506
527
|
if (filteredSplashConfig.image) {
|
|
507
|
-
filteredSplashConfig['image'] =
|
|
528
|
+
filteredSplashConfig['image'] = splashAssetPath(filteredSplashConfig.image);
|
|
508
529
|
}
|
|
509
530
|
if ((_a = filteredSplashConfig === null || filteredSplashConfig === void 0 ? void 0 : filteredSplashConfig.dark) === null || _a === void 0 ? void 0 : _a.image) {
|
|
510
|
-
filteredSplashConfig['dark']['image'] =
|
|
531
|
+
filteredSplashConfig['dark']['image'] = splashAssetPath((_b = filteredSplashConfig === null || filteredSplashConfig === void 0 ? void 0 : filteredSplashConfig.dark) === null || _b === void 0 ? void 0 : _b.image);
|
|
511
532
|
}
|
|
512
533
|
// support for old projects with splash in src and bgColor
|
|
513
534
|
if (filteredSplashConfig.src) {
|
|
514
|
-
filteredSplashConfig['image'] =
|
|
535
|
+
filteredSplashConfig['image'] = splashAssetPath(filteredSplashConfig.src);
|
|
515
536
|
delete filteredSplashConfig.src;
|
|
516
537
|
}
|
|
517
538
|
if (filteredSplashConfig.src) {
|
|
@@ -545,8 +566,9 @@ class AppGenerator {
|
|
|
545
566
|
appConfig['expo']['android']['package'] = config.id;
|
|
546
567
|
appConfig['expo']['ios']['bundleIdentifier'] = config.id;
|
|
547
568
|
appConfig['expo']['jsEngine'] = ((_a = config.preferences) === null || _a === void 0 ? void 0 : _a.enableHermes) === 'false' ? 'jsc' : 'hermes';
|
|
548
|
-
|
|
549
|
-
appConfig['expo']['
|
|
569
|
+
const iconPath = this.isWebPreview ? './assets/' + path_2.default.basename(config.icon.src) : './assets/' + config.icon.src;
|
|
570
|
+
appConfig['expo']['icon'] = iconPath;
|
|
571
|
+
appConfig['expo']['android']['adaptiveIcon']['foregroundImage'] = iconPath;
|
|
550
572
|
appConfig['expo']['orientation'] = config.orientation || 'portrait';
|
|
551
573
|
const adaptiveColorMode = !!config.enableAdaptiveColorMode;
|
|
552
574
|
appConfig.expo.userInterfaceStyle = adaptiveColorMode ? 'automatic' : 'light';
|
|
@@ -679,7 +701,7 @@ class AppGenerator {
|
|
|
679
701
|
async generateComponent(info, type, name, dynamicProps) {
|
|
680
702
|
// Also regenerate on an app-config change, not just a page edit: a page's cascaded
|
|
681
703
|
// pulltorefresh value (page.transformer.ts) comes from that config too.
|
|
682
|
-
if (this.incBuilder && !this.incBuilder.isFragmentModified(name) && !this.incBuilder.isConfigModified()) {
|
|
704
|
+
if (this.incBuilder && !this.incBuilder.isFragmentModified(name) && !this.incBuilder.isConfigModified() && !this.forceGenerate.has(name)) {
|
|
683
705
|
return Promise.resolve();
|
|
684
706
|
}
|
|
685
707
|
if (this.incBuilder) {
|
|
@@ -833,67 +855,103 @@ class AppGenerator {
|
|
|
833
855
|
return Promise.all(prefabs === null || prefabs === void 0 ? void 0 : prefabs.map(prefab => this.generatePrefabComponent(prefab, overwrite)));
|
|
834
856
|
});
|
|
835
857
|
}
|
|
858
|
+
checkWmxRuntimeDepsCompatibility(componentsPath, reactVersion, reactNativeVersion) {
|
|
859
|
+
const checks = [
|
|
860
|
+
{ name: 'react', expected: reactVersion },
|
|
861
|
+
{ name: 'react-native', expected: reactNativeVersion },
|
|
862
|
+
];
|
|
863
|
+
for (const { name, expected } of checks) {
|
|
864
|
+
const pkgPath = `${componentsPath}/node_modules/${name}/package.json`;
|
|
865
|
+
if (!expected || !fs_extra_1.default.existsSync(pkgPath)) {
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
const installedVersion = fs_extra_1.default.readJsonSync(pkgPath, { encoding: 'utf8' }).version;
|
|
869
|
+
const expectedClean = `${expected}`.replace('^', '').replace('~', '');
|
|
870
|
+
if (installedVersion && semver_1.default.major(installedVersion) !== semver_1.default.major(expectedClean)) {
|
|
871
|
+
console.warn(`Warning: wmx-component's "${name}" version (${installedVersion}) is not compatible with the app's "${name}" version (${expected}) — major version mismatch. `
|
|
872
|
+
+ `Update the wmx-component's dependency on "${name}" to a "${semver_1.default.major(expectedClean)}.x" version and rebuild.`);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
836
876
|
compileXComponentLib() {
|
|
837
877
|
var _a, _b;
|
|
838
878
|
const componentsPath = `${this.projectService.path}/extensions/components`;
|
|
839
|
-
|
|
840
|
-
|
|
879
|
+
// Under node_modules so it never ships with an exported/downloaded app. Not `.cache`: web preview
|
|
880
|
+
// symlinks every vendor-tree entry into node_modules, and a shared `.cache` would be read-only.
|
|
881
|
+
const npmCacheDir = (0, path_1.join)(this.projectPath, 'node_modules', '.wm-wmx-npm-cache');
|
|
882
|
+
fs_extra_1.default.removeSync((0, path_1.join)(this.projectPath, '.wmx-npm-cache')); // previous location
|
|
883
|
+
const wmxPackageJsonPath = `${componentsPath}/package.json`;
|
|
884
|
+
const readWmxPackageJson = () => {
|
|
885
|
+
if (!fs_extra_1.default.existsSync(wmxPackageJsonPath)) {
|
|
886
|
+
throw new Error(`wmx-components package.json not found at ${wmxPackageJsonPath} — extensions/components must be scaffolded before compiling wmx components.`);
|
|
887
|
+
}
|
|
888
|
+
try {
|
|
889
|
+
return fs_extra_1.default.readJsonSync(wmxPackageJsonPath, { encoding: 'utf8' });
|
|
890
|
+
}
|
|
891
|
+
catch (e) {
|
|
892
|
+
throw new Error(`Failed to parse ${wmxPackageJsonPath}: ${e.message}`);
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
const projectPackages = fs_extra_1.default.readJsonSync(`${__dirname}/templates/project/package.json`, {
|
|
896
|
+
encoding: 'utf8'
|
|
897
|
+
});
|
|
898
|
+
const reactVersion = (_a = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _a === void 0 ? void 0 : _a['react'];
|
|
899
|
+
const reactNativeVersion = (_b = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _b === void 0 ? void 0 : _b['react-native'];
|
|
841
900
|
if (!this.incBuilder) {
|
|
842
|
-
const
|
|
843
|
-
encoding: 'utf8'
|
|
844
|
-
});
|
|
845
|
-
const reactVersion = (_a = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _a === void 0 ? void 0 : _a['react'];
|
|
846
|
-
const reactNativeVersion = (_b = projectPackages === null || projectPackages === void 0 ? void 0 : projectPackages.dependencies) === null || _b === void 0 ? void 0 : _b['react-native'];
|
|
847
|
-
const wmxComponentPackage = fs_extra_1.default.readJsonSync(componentsPackageJson, {
|
|
848
|
-
encoding: 'utf8'
|
|
849
|
-
});
|
|
901
|
+
const wmxComponentPackage = readWmxPackageJson();
|
|
850
902
|
// semver considers ^x.x.x and ~x.x.x as invalid package versions.
|
|
851
903
|
if (semver_1.default.lt(`${wmxComponentPackage.devDependencies['@types/react']}`.replace('^', '').replace('~', ''), reactVersion) ||
|
|
852
904
|
semver_1.default.lt(`${wmxComponentPackage.devDependencies['react-native']}`.replace('^', '').replace('~', ''), reactNativeVersion)) {
|
|
853
905
|
wmxComponentPackage.devDependencies['@types/react'] = `${reactVersion}`;
|
|
854
906
|
wmxComponentPackage.devDependencies['react-native'] = `${reactNativeVersion}`;
|
|
855
907
|
}
|
|
856
|
-
fs_extra_1.default.writeJSONSync(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
}
|
|
880
|
-
return (0, execa_1.default)('npm', ['install'], {
|
|
908
|
+
fs_extra_1.default.writeJSONSync(wmxPackageJsonPath, wmxComponentPackage);
|
|
909
|
+
fs_extra_1.default.removeSync(`${componentsPath}/package-lock.json`);
|
|
910
|
+
fs_extra_1.default.emptyDirSync(`${componentsPath}/node_modules`);
|
|
911
|
+
// Clean build: never trust a previously cached npm tarball — wipe it outright.
|
|
912
|
+
fs_extra_1.default.removeSync(npmCacheDir);
|
|
913
|
+
}
|
|
914
|
+
const wmxComponentPackage = readWmxPackageJson();
|
|
915
|
+
const depsHash = crypto_1.default.createHash('md5')
|
|
916
|
+
.update(JSON.stringify(wmxComponentPackage.dependencies || {}) + JSON.stringify(wmxComponentPackage.devDependencies || {}))
|
|
917
|
+
.digest('hex')
|
|
918
|
+
.slice(0, 8);
|
|
919
|
+
const depsHashFile = (0, path_1.join)(npmCacheDir, '.deps-hash');
|
|
920
|
+
const cachedDepsHash = fs_extra_1.default.existsSync(depsHashFile) ? fs_extra_1.default.readFileSync(depsHashFile, 'utf8') : undefined;
|
|
921
|
+
if (cachedDepsHash !== depsHash) {
|
|
922
|
+
fs_extra_1.default.removeSync(npmCacheDir);
|
|
923
|
+
fs_extra_1.default.mkdirpSync(npmCacheDir);
|
|
924
|
+
fs_extra_1.default.writeFileSync(depsHashFile, depsHash);
|
|
925
|
+
}
|
|
926
|
+
// Same reasoning as npmInstall(): a failed or killed install can leave corrupt cache entries behind.
|
|
927
|
+
const dropCacheOnFailure = (err) => {
|
|
928
|
+
console.warn(`[npm] wmx install failed — removing wmx npm cache at ${npmCacheDir}`);
|
|
929
|
+
fs_extra_1.default.removeSync(npmCacheDir);
|
|
930
|
+
throw err;
|
|
931
|
+
};
|
|
932
|
+
return (0, execa_1.default)('npm', ['install', '--cache', npmCacheDir], {
|
|
881
933
|
cwd: componentsPath
|
|
882
|
-
}).then(() => {
|
|
934
|
+
}).catch(dropCacheOnFailure).then(() => {
|
|
883
935
|
return (0, execa_1.default)('npm', ['run', 'build'], {
|
|
884
936
|
cwd: componentsPath
|
|
885
937
|
});
|
|
886
938
|
}).then(() => {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
939
|
+
const wmxComponentsDest = `${this.projectPath}/wmx-components`;
|
|
940
|
+
const wmxNodeModulesDir = `${wmxComponentsDest}/node_modules`;
|
|
941
|
+
fs_extra_1.default.copySync(`${componentsPath}/build`, wmxComponentsDest);
|
|
942
|
+
if (!fs_extra_1.default.existsSync(`${wmxComponentsDest}/package.json`)) {
|
|
943
|
+
return;
|
|
891
944
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
945
|
+
if (!this.incBuilder) {
|
|
946
|
+
fs_extra_1.default.removeSync(wmxNodeModulesDir);
|
|
947
|
+
}
|
|
948
|
+
return (0, execa_1.default)('npm', ['install', '--cache', npmCacheDir], {
|
|
949
|
+
cwd: wmxComponentsDest
|
|
950
|
+
}).catch(dropCacheOnFailure).then(() => {
|
|
951
|
+
this.checkWmxRuntimeDepsCompatibility(wmxComponentsDest, reactVersion, reactNativeVersion);
|
|
952
|
+
}).finally(() => {
|
|
953
|
+
fs_extra_1.default.removeSync(wmxNodeModulesDir);
|
|
954
|
+
});
|
|
897
955
|
});
|
|
898
956
|
}
|
|
899
957
|
async generateWMXComponents(name, overwrite) {
|
|
@@ -1087,9 +1145,17 @@ class AppGenerator {
|
|
|
1087
1145
|
* @description Get all widget imports in the generated app
|
|
1088
1146
|
* @returns array of widgets imported (e.g, WmCamera, WmVideo)
|
|
1089
1147
|
*/
|
|
1090
|
-
|
|
1148
|
+
// Web preview: markup doesn't change mid-build, so every caller shares one scan of all pages.
|
|
1149
|
+
getWidgetImports() {
|
|
1150
|
+
var _a;
|
|
1151
|
+
if (!this.isWebPreview) {
|
|
1152
|
+
return this.scanWidgetImports();
|
|
1153
|
+
}
|
|
1154
|
+
return (_a = this.widgetImportsScan) !== null && _a !== void 0 ? _a : (this.widgetImportsScan = this.scanWidgetImports());
|
|
1155
|
+
}
|
|
1156
|
+
async scanWidgetImports(only) {
|
|
1091
1157
|
let widgetImports = [];
|
|
1092
|
-
const pageConfigs = await this.projectService.getPageConfigs();
|
|
1158
|
+
const pageConfigs = (await this.projectService.getPageConfigs()).filter(p => !only || only(p.name));
|
|
1093
1159
|
await Promise.all(pageConfigs.map(async (p) => {
|
|
1094
1160
|
const info = await this.projectService.getPageInfo(p.name);
|
|
1095
1161
|
const transpileArgs = {
|
|
@@ -1130,6 +1196,18 @@ class AppGenerator {
|
|
|
1130
1196
|
if (this.incBuilder) {
|
|
1131
1197
|
console.log(`Checking widget usage in component files.`);
|
|
1132
1198
|
}
|
|
1199
|
+
// Web preview incremental: only edited pages/partials can bring in a new widget, so scan just those.
|
|
1200
|
+
// A widget removed elsewhere keeps its plugin until the next clean preview, which is harmless.
|
|
1201
|
+
const buildCache = this.isWebPreview && this.incBuilder && !this.shouldDoUnwantedPackagesCleanup
|
|
1202
|
+
? fs_extra_1.default.readJSONSync(`${this.projectPath}/.build-cache`, { throws: false }) : null;
|
|
1203
|
+
if (buildCache === null || buildCache === void 0 ? void 0 : buildCache.widgetImports) {
|
|
1204
|
+
const known = new Set(buildCache.widgetImports.map((d) => d.name));
|
|
1205
|
+
const changed = await this.scanWidgetImports(name => this.incBuilder.isFragmentModified(name));
|
|
1206
|
+
if (!this.projectPackageDependencies.some((dep) => !known.has(dep.name)
|
|
1207
|
+
&& 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); }))) {
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1133
1211
|
const projectDependencies = (0, lodash_1.uniq)([...this.projectPackageDependencies]);
|
|
1134
1212
|
const imports = await this.getWidgetImports();
|
|
1135
1213
|
projectDependencies.forEach((dep, index) => {
|
|
@@ -1261,6 +1339,8 @@ class AppGenerator {
|
|
|
1261
1339
|
const scanPaths = [
|
|
1262
1340
|
`${this.projectPath}/src`,
|
|
1263
1341
|
`${this.projectPath}/assets/resources`,
|
|
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`] : []),
|
|
1264
1344
|
];
|
|
1265
1345
|
scanPaths.forEach(scanPath => {
|
|
1266
1346
|
scanDirectory(scanPath);
|
|
@@ -1338,25 +1418,71 @@ class AppGenerator {
|
|
|
1338
1418
|
}
|
|
1339
1419
|
return Promise.resolve();
|
|
1340
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
|
+
}
|
|
1341
1461
|
generatePagesAndPartials() {
|
|
1342
1462
|
let pageConfigs = null;
|
|
1343
1463
|
return this.projectService.getPageConfigs().then(_pageConfigs => {
|
|
1344
1464
|
pageConfigs = _pageConfigs;
|
|
1465
|
+
const workingSet = this.resolvePreviewWorkingSet(pageConfigs);
|
|
1345
1466
|
const pageCreationPromises = pageConfigs.map(p => {
|
|
1346
1467
|
if (p.type === 'PAGE') {
|
|
1347
|
-
return this.generatePageComponent(p.name);
|
|
1468
|
+
return workingSet ? this.generatePreviewFragment(p.name, 'pages', workingSet) : this.generatePageComponent(p.name);
|
|
1348
1469
|
}
|
|
1349
1470
|
if (this.isPartial(p.type)) {
|
|
1350
|
-
return this.generatePartialComponent(p.name);
|
|
1471
|
+
return workingSet ? this.generatePreviewFragment(p.name, 'partials', workingSet) : this.generatePartialComponent(p.name);
|
|
1351
1472
|
}
|
|
1352
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
|
+
}
|
|
1353
1479
|
return Promise.all(pageCreationPromises);
|
|
1354
1480
|
})
|
|
1355
1481
|
.then(() => this.generatePageConfig(pageConfigs))
|
|
1356
1482
|
.then(() => this.generatePartialConfig(pageConfigs));
|
|
1357
1483
|
}
|
|
1358
1484
|
async mergePackageJson() {
|
|
1359
|
-
var _a;
|
|
1485
|
+
var _a, _b, _c;
|
|
1360
1486
|
if (this.incBuilder) {
|
|
1361
1487
|
console.log(`Merging package.json .`);
|
|
1362
1488
|
}
|
|
@@ -1367,14 +1493,26 @@ class AppGenerator {
|
|
|
1367
1493
|
packageToOveride.description = config.description;
|
|
1368
1494
|
if (profile_1.default.targetPlatform === 'web') {
|
|
1369
1495
|
const webPackageJson = fs_extra_1.default.readJSONSync(`${__dirname}/templates/package.web.json`, { encoding: 'utf-8' });
|
|
1370
|
-
|
|
1371
|
-
packageToOveride.scripts = (0, lodash_1.merge)(packageToOveride.scripts, webPackageJson.scripts);
|
|
1496
|
+
packageToOveride = (0, lodash_1.merge)(packageToOveride, webPackageJson);
|
|
1372
1497
|
}
|
|
1373
1498
|
if (this.wmxComponents.length > 0) {
|
|
1374
|
-
packageToOveride.
|
|
1499
|
+
packageToOveride.scripts.postinstall = [
|
|
1500
|
+
'npm install --prefix ./wmx-components',
|
|
1501
|
+
...((packageToOveride.scripts.postinstall || '')
|
|
1502
|
+
.split('&&')
|
|
1503
|
+
.filter((s) => s && !!s.trim()))
|
|
1504
|
+
].join(' && ');
|
|
1375
1505
|
if (!this.incBuilder || this.incBuilder.isWMXComponentModified()) {
|
|
1376
1506
|
await this.compileXComponentLib();
|
|
1377
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
|
+
}
|
|
1378
1516
|
}
|
|
1379
1517
|
const packageOverride = await this.projectService.getPackageJSONOverride();
|
|
1380
1518
|
let packageOverriden = packageOverride ? (0, lodash_1.merge)(packageToOveride, packageOverride) : packageToOveride;
|
|
@@ -1384,7 +1522,7 @@ class AppGenerator {
|
|
|
1384
1522
|
'npm install --prefix ./wmx-components',
|
|
1385
1523
|
'npm install --prefix ./wmx-components --cache ./wmx-components/.npm-cache'
|
|
1386
1524
|
];
|
|
1387
|
-
const remainingSteps = (((
|
|
1525
|
+
const remainingSteps = (((_c = packageOverriden.scripts) === null || _c === void 0 ? void 0 : _c.postinstall) || '')
|
|
1388
1526
|
.split('&&')
|
|
1389
1527
|
.map((s) => s.trim())
|
|
1390
1528
|
.filter((s) => s && !priorWmxInstallForms.includes(s));
|
|
@@ -1516,8 +1654,9 @@ class AppGenerator {
|
|
|
1516
1654
|
}
|
|
1517
1655
|
fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(updatedPackageJson, null, 4));
|
|
1518
1656
|
// * installing packages whenever a package is added or removed
|
|
1519
|
-
|
|
1520
|
-
|
|
1657
|
+
// Web preview installs after generation (installDependencies), so not here as well.
|
|
1658
|
+
if (this.shouldNpmInstall && this.incBuilder && !this.isWebPreview) {
|
|
1659
|
+
await (0, command_1.npmInstall)(`${this.projectPath}`);
|
|
1521
1660
|
}
|
|
1522
1661
|
}
|
|
1523
1662
|
async copyPackageLockJson() {
|
|
@@ -1726,7 +1865,7 @@ class AppGenerator {
|
|
|
1726
1865
|
const themePath = `${this.projectService.path}/design-tokens/foundation`;
|
|
1727
1866
|
try {
|
|
1728
1867
|
const foundationPath = `${__dirname}/templates/foundation-theme/dist`;
|
|
1729
|
-
fs_extra_1.default.copySync(foundationPath, themePath);
|
|
1868
|
+
fs_extra_1.default.copySync(foundationPath, themePath, { preserveTimestamps: true });
|
|
1730
1869
|
}
|
|
1731
1870
|
catch (error) {
|
|
1732
1871
|
console.error(error);
|
|
@@ -1812,11 +1951,10 @@ class AppGenerator {
|
|
|
1812
1951
|
}
|
|
1813
1952
|
generateFonts() {
|
|
1814
1953
|
return this.projectService.getFontConfig().then((code) => {
|
|
1815
|
-
var _a;
|
|
1816
1954
|
const fontConfigUrl = `${this.projectPath}/font.config.js`;
|
|
1817
1955
|
code = code.replace('export default', 'module.exports = ');
|
|
1818
1956
|
(0, utils_1.writeFile)(fontConfigUrl, code);
|
|
1819
|
-
return
|
|
1957
|
+
return Promise.resolve(`${fontConfigUrl}`).then(s => __importStar(require(s))).then((fontConfig) => {
|
|
1820
1958
|
return Promise.all(fontConfig.default.fonts.map((font) => {
|
|
1821
1959
|
if (font.csspath) {
|
|
1822
1960
|
return this.themeService.getIconFontScripts(path_2.default.join(this.projectPath, '/assets/', font.csspath));
|
|
@@ -1826,14 +1964,32 @@ class AppGenerator {
|
|
|
1826
1964
|
});
|
|
1827
1965
|
}).then(() => this.generateResourceResolver());
|
|
1828
1966
|
}
|
|
1967
|
+
timed(label, fn) {
|
|
1968
|
+
console.time(`App creation: ${label}`);
|
|
1969
|
+
return Promise.resolve(fn()).finally(() => console.timeEnd(`App creation: ${label}`));
|
|
1970
|
+
}
|
|
1829
1971
|
async generateApp() {
|
|
1830
1972
|
this.rnConfig = await this.projectService.getRNConfig().then(data => JSON.parse(data));
|
|
1831
|
-
|
|
1973
|
+
// templates/project/metro/ (the split-bundle build) is only needed by
|
|
1974
|
+
// the web-preview profile; every other profile skips it.
|
|
1975
|
+
const templatesRoot = __dirname + '/templates/project';
|
|
1976
|
+
if (this.incBuilder && this.isWebPreview) {
|
|
1977
|
+
this.timed('copy templates: sync', () => (0, web_preview_templates_1.syncWebPreviewTemplates)(templatesRoot, this.projectPath));
|
|
1978
|
+
}
|
|
1979
|
+
this.incBuilder || this.timed('copy templates', () => fs_extra_1.default.copySync(templatesRoot, this.projectPath, {
|
|
1980
|
+
filter: (src) => {
|
|
1981
|
+
if (this.isWebPreview) {
|
|
1982
|
+
return true;
|
|
1983
|
+
}
|
|
1984
|
+
const rel = path_2.default.relative(templatesRoot, src);
|
|
1985
|
+
return rel !== 'metro' && !rel.startsWith(`metro${path_1.sep}`);
|
|
1986
|
+
}
|
|
1987
|
+
}));
|
|
1832
1988
|
const customMetroConfig = await this.projectService.getCustomMetroConfig();
|
|
1833
1989
|
if (customMetroConfig) {
|
|
1834
1990
|
(0, utils_1.writeFile)(`${this.projectPath}/custommetro.config.js`, customMetroConfig);
|
|
1835
1991
|
}
|
|
1836
|
-
return this.generatePagesAndPartials()
|
|
1992
|
+
return this.timed('pages+partials', () => this.generatePagesAndPartials())
|
|
1837
1993
|
.then(() => this.incBuilder && this.generateAllPrefabComponents())
|
|
1838
1994
|
.then(() => !this.incBuilder || this.incBuilder.isResourceModified())
|
|
1839
1995
|
.then((build) => (build && this.generateResourceResolver()))
|
|
@@ -1864,7 +2020,7 @@ class AppGenerator {
|
|
|
1864
2020
|
.then(() => !this.incBuilder || this.incBuilder.isConfigModified())
|
|
1865
2021
|
.then((build) => (build && this.generateBabelConfig()))
|
|
1866
2022
|
.then(() => !this.incBuilder || this.incBuilder.isThemeModified() || this.incBuilder.isFoundationThemeModified())
|
|
1867
|
-
.then((build) => (build && this.generateAppTheme()))
|
|
2023
|
+
.then((build) => (build && this.timed('theme', () => this.generateAppTheme())))
|
|
1868
2024
|
.then(() => !this.incBuilder || this.incBuilder.isi18nModified())
|
|
1869
2025
|
.then((build) => (build && this.copyi18nFiles()))
|
|
1870
2026
|
.then(() => !this.incBuilder || this.incBuilder.isi18nModified())
|
|
@@ -1880,21 +2036,25 @@ class AppGenerator {
|
|
|
1880
2036
|
|| this.incBuilder.isConfigModified()
|
|
1881
2037
|
|| this.incBuilder.isPrefabModified())
|
|
1882
2038
|
.then((build) => (build && this.addCustomPluginsToPackageJson()))
|
|
1883
|
-
.then(() => this.mergePackageJson())
|
|
2039
|
+
.then(() => this.timed('package.json merge (incl. wmx-component npm install+build)', () => this.mergePackageJson()))
|
|
1884
2040
|
.then(() => this.copyPackageLockJson())
|
|
1885
2041
|
.then(() => this.checkWidgetUsageInComponentFiles())
|
|
1886
2042
|
.then(() => this.checkPackageUsageInJSFiles())
|
|
1887
|
-
|
|
2043
|
+
// Web preview: mergePackageJson re-adds the project's package.json override every build, which brings
|
|
2044
|
+
// back packages an earlier build removed, so the removal (~0.2s) has to run every build too.
|
|
2045
|
+
.then(() => !this.incBuilder || this.shouldDoUnwantedPackagesCleanup || this.isWebPreview)
|
|
1888
2046
|
.then((removePackages) => {
|
|
1889
2047
|
if (removePackages) {
|
|
1890
|
-
return this.removeUnusedPackages();
|
|
2048
|
+
return this.timed('remove unused packages', () => this.removeUnusedPackages());
|
|
1891
2049
|
}
|
|
1892
2050
|
else {
|
|
1893
2051
|
return Promise.resolve();
|
|
1894
2052
|
}
|
|
1895
2053
|
})
|
|
1896
2054
|
.then(() => !this.incBuilder)
|
|
1897
|
-
.then((build) => (build
|
|
2055
|
+
.then((build) => (build
|
|
2056
|
+
&& !(this.isWebPreview && process.env.WM_PREVIEW_PRETTIFY !== '1')
|
|
2057
|
+
&& this.prettify()))
|
|
1898
2058
|
.then(() => this.projectService.copyNpmPackages(this.projectPath))
|
|
1899
2059
|
.then(() => this.copyScreenCapturePluginIfNeeded())
|
|
1900
2060
|
.then(() => this.copyPullToRefreshPluginIfNeeded())
|
|
@@ -1916,7 +2076,9 @@ class AppGenerator {
|
|
|
1916
2076
|
})
|
|
1917
2077
|
.then(() => this.generatePageConfig(pageConfigs))
|
|
1918
2078
|
.then(() => this.generatePartialConfig(pageConfigs))
|
|
1919
|
-
.then(() => this.
|
|
2079
|
+
.then(() => (this.isWebPreview && process.env.WM_PREVIEW_PRETTIFY !== '1')
|
|
2080
|
+
? undefined
|
|
2081
|
+
: this.prettify(`**/${name}/**/*.js`))
|
|
1920
2082
|
.then(() => console.log('code generated at ' + this.projectPath));
|
|
1921
2083
|
}
|
|
1922
2084
|
;
|