nativescript 8.9.0-alpha.3 → 8.9.0-dev.0
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/config/test-deps-versions-generated.json +1 -1
- package/lib/android-tools-info.js +9 -20
- package/lib/base-package-manager.js +47 -64
- package/lib/bun-package-manager.js +65 -88
- package/lib/color.js +2 -2
- package/lib/commands/add-platform.js +14 -30
- package/lib/commands/apple-login.js +18 -29
- package/lib/commands/appstore-list.js +34 -45
- package/lib/commands/appstore-upload.js +52 -65
- package/lib/commands/build.js +55 -87
- package/lib/commands/clean.js +161 -176
- package/lib/commands/command-base.js +14 -27
- package/lib/commands/config.js +48 -67
- package/lib/commands/create-project.js +210 -229
- package/lib/commands/debug.js +66 -88
- package/lib/commands/deploy.js +28 -44
- package/lib/commands/embedding/embed.js +33 -52
- package/lib/commands/extensibility/install-extension.js +5 -16
- package/lib/commands/extensibility/list-extensions.js +13 -24
- package/lib/commands/extensibility/uninstall-extension.js +4 -15
- package/lib/commands/fonts.js +30 -41
- package/lib/commands/generate-assets.js +13 -28
- package/lib/commands/generate-help.js +2 -13
- package/lib/commands/generate.js +12 -60
- package/lib/commands/info.js +2 -13
- package/lib/commands/install.js +34 -49
- package/lib/commands/list-platforms.js +14 -25
- package/lib/commands/migrate.js +15 -26
- package/lib/commands/native-add.js +23 -46
- package/lib/commands/platform-clean.js +19 -32
- package/lib/commands/plugin/add-plugin.js +12 -25
- package/lib/commands/plugin/build-plugin.js +31 -44
- package/lib/commands/plugin/create-plugin.js +110 -133
- package/lib/commands/plugin/list-plugins.js +22 -33
- package/lib/commands/plugin/remove-plugin.js +20 -33
- package/lib/commands/plugin/update-plugin.js +20 -33
- package/lib/commands/post-install.js +20 -33
- package/lib/commands/prepare.js +19 -35
- package/lib/commands/preview.js +49 -62
- package/lib/commands/remove-platform.js +7 -18
- package/lib/commands/resources/resources-update.js +13 -26
- package/lib/commands/run.js +55 -76
- package/lib/commands/start.js +6 -19
- package/lib/commands/test-init.js +123 -134
- package/lib/commands/test.js +66 -89
- package/lib/commands/typings.js +126 -142
- package/lib/commands/update-platform.js +22 -35
- package/lib/commands/update.js +30 -43
- package/lib/common/child-process.js +53 -72
- package/lib/common/codeGeneration/code-entity.js +1 -1
- package/lib/common/codeGeneration/code-printer.js +1 -1
- package/lib/common/command-params.js +7 -18
- package/lib/common/commands/analytics.js +27 -40
- package/lib/common/commands/autocompletion.js +39 -56
- package/lib/common/commands/device/device-log-stream.js +12 -23
- package/lib/common/commands/device/get-file.js +22 -33
- package/lib/common/commands/device/list-applications.js +12 -23
- package/lib/common/commands/device/list-devices.js +72 -87
- package/lib/common/commands/device/list-files.js +23 -34
- package/lib/common/commands/device/put-file.js +22 -33
- package/lib/common/commands/device/run-application.js +12 -25
- package/lib/common/commands/device/stop-application.js +11 -22
- package/lib/common/commands/device/uninstall-application.js +6 -17
- package/lib/common/commands/generate-messages.js +17 -28
- package/lib/common/commands/help.js +20 -33
- package/lib/common/commands/package-manager-get.js +6 -17
- package/lib/common/commands/package-manager-set.js +9 -20
- package/lib/common/commands/post-install.js +2 -13
- package/lib/common/commands/preuninstall.js +23 -38
- package/lib/common/commands/proxy/proxy-base.js +8 -19
- package/lib/common/commands/proxy/proxy-clear.js +4 -15
- package/lib/common/commands/proxy/proxy-get.js +3 -14
- package/lib/common/commands/proxy/proxy-set.js +87 -100
- package/lib/common/constants.js +11 -11
- package/lib/common/decorators.js +10 -22
- package/lib/common/dispatchers.js +79 -96
- package/lib/common/errors.js +89 -104
- package/lib/common/file-system.js +108 -130
- package/lib/common/header.js +1 -2
- package/lib/common/helpers.js +149 -178
- package/lib/common/host-info.js +37 -50
- package/lib/common/http-client.js +93 -108
- package/lib/common/logger/appenders/cli-appender.js +1 -2
- package/lib/common/logger/appenders/emit-appender.js +1 -2
- package/lib/common/logger/layouts/cli-layout.js +1 -2
- package/lib/common/logger/logger.js +4 -4
- package/lib/common/mobile/android/android-application-manager.js +121 -142
- package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -1
- package/lib/common/mobile/android/android-debug-bridge.js +87 -112
- package/lib/common/mobile/android/android-device-file-system.js +98 -131
- package/lib/common/mobile/android/android-device-hash-service.js +50 -75
- package/lib/common/mobile/android/android-device.js +68 -85
- package/lib/common/mobile/android/android-emulator-services.js +105 -130
- package/lib/common/mobile/android/android-ini-file-parser.js +8 -6
- package/lib/common/mobile/android/android-log-filter.js +1 -1
- package/lib/common/mobile/android/android-virtual-device-service.js +76 -97
- package/lib/common/mobile/android/device-android-debug-bridge.js +13 -29
- package/lib/common/mobile/android/genymotion/genymotion-service.js +91 -118
- package/lib/common/mobile/android/genymotion/virtualbox-service.js +64 -81
- package/lib/common/mobile/android/logcat-helper.js +108 -127
- package/lib/common/mobile/application-manager-base.js +84 -107
- package/lib/common/mobile/device-log-provider-base.js +7 -18
- package/lib/common/mobile/ios/device/ios-application-manager.js +79 -108
- package/lib/common/mobile/ios/device/ios-device-file-system.js +78 -105
- package/lib/common/mobile/ios/device/ios-device-operations.js +105 -142
- package/lib/common/mobile/ios/device/ios-device.js +20 -36
- package/lib/common/mobile/ios/ios-device-base.js +58 -81
- package/lib/common/mobile/ios/simulator/ios-emulator-services.js +63 -92
- package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -1
- package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +60 -89
- package/lib/common/mobile/ios/simulator/ios-simulator-device.js +27 -43
- package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +37 -62
- package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +24 -35
- package/lib/common/mobile/mobile-core/android-device-discovery.js +43 -62
- package/lib/common/mobile/mobile-core/android-emulator-discovery.js +21 -32
- package/lib/common/mobile/mobile-core/android-process-service.js +143 -182
- package/lib/common/mobile/mobile-core/device-discovery.js +2 -13
- package/lib/common/mobile/mobile-core/devices-service.js +386 -436
- package/lib/common/mobile/mobile-core/ios-device-discovery.js +24 -35
- package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +47 -62
- package/lib/common/mobile/mobile-helper.js +15 -26
- package/lib/common/mobile/wp8/wp8-emulator-services.js +25 -52
- package/lib/common/opener.js +2 -2
- package/lib/common/prompter.js +90 -105
- package/lib/common/queue.js +9 -20
- package/lib/common/services/auto-completion-service.js +39 -52
- package/lib/common/services/cancellation.js +17 -28
- package/lib/common/services/commands-service.js +146 -169
- package/lib/common/services/help-service.js +132 -157
- package/lib/common/services/hooks-service.js +93 -108
- package/lib/common/services/ios-notification-service.js +21 -34
- package/lib/common/services/json-file-settings-service.js +52 -71
- package/lib/common/services/lock-service.js +35 -52
- package/lib/common/services/message-contract-generator.js +35 -46
- package/lib/common/services/micro-templating-service.js +4 -15
- package/lib/common/services/net-service.js +90 -107
- package/lib/common/services/project-files-manager.js +10 -23
- package/lib/common/services/proxy-service.js +13 -24
- package/lib/common/services/qr.js +13 -24
- package/lib/common/services/settings-service.js +1 -1
- package/lib/common/services/xcode-select-service.js +20 -35
- package/lib/common/utils.js +2 -2
- package/lib/common/validators/project-name-validator.js +1 -1
- package/lib/common/validators/validation-result.js +1 -1
- package/lib/common/verify-node-version.js +2 -3
- package/lib/common/yok.js +23 -36
- package/lib/config.js +36 -51
- package/lib/constants.js +24 -24
- package/lib/controllers/build-controller.js +82 -99
- package/lib/controllers/debug-controller.js +107 -128
- package/lib/controllers/deploy-controller.js +15 -23
- package/lib/controllers/migrate-controller.js +722 -795
- package/lib/controllers/platform-controller.js +70 -85
- package/lib/controllers/prepare-controller.js +232 -261
- package/lib/controllers/run-controller.js +397 -411
- package/lib/controllers/update-controller-base.js +16 -29
- package/lib/controllers/update-controller.js +94 -119
- package/lib/data/prepare-data.js +4 -1
- package/lib/definitions/ios.d.ts +9 -1
- package/lib/detached-processes/cleanup-js-subprocess.js +3 -12
- package/lib/detached-processes/cleanup-process.js +16 -25
- package/lib/device-path-provider.js +23 -34
- package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +149 -164
- package/lib/device-sockets/ios/notification.js +1 -1
- package/lib/device-sockets/ios/socket-request-executor.js +24 -39
- package/lib/helpers/android-bundle-validator-helper.js +1 -1
- package/lib/helpers/deploy-command-helper.js +44 -49
- package/lib/helpers/key-command-helper.js +4 -13
- package/lib/helpers/livesync-command-helper.js +137 -152
- package/lib/helpers/network-connectivity-validator.js +6 -17
- package/lib/helpers/options-track-helper.js +6 -17
- package/lib/helpers/platform-command-helper.js +99 -120
- package/lib/key-commands/index.js +150 -200
- package/lib/nativescript-cli.js +5 -14
- package/lib/node-package-manager.js +81 -104
- package/lib/options.js +3 -12
- package/lib/package-installation-manager.js +130 -165
- package/lib/package-manager.js +63 -86
- package/lib/platform-command-param.js +4 -15
- package/lib/pnpm-package-manager.js +59 -78
- package/lib/project-data.js +1 -1
- package/lib/providers/project-files-provider.js +1 -1
- package/lib/services/analytics/analytics-broker-process.js +13 -22
- package/lib/services/analytics/analytics-broker.js +17 -30
- package/lib/services/analytics/analytics-service.js +163 -199
- package/lib/services/analytics/google-analytics-provider.js +41 -56
- package/lib/services/analytics-settings-service.js +15 -32
- package/lib/services/android/android-bundle-tool-service.js +43 -60
- package/lib/services/android/gradle-build-args-service.js +9 -20
- package/lib/services/android/gradle-build-service.js +22 -35
- package/lib/services/android/gradle-command-service.js +22 -35
- package/lib/services/android-device-debug-service.js +90 -117
- package/lib/services/android-plugin-build-service.js +205 -231
- package/lib/services/android-project-service.js +126 -171
- package/lib/services/android-resources-migration-service.js +51 -64
- package/lib/services/apple-portal/apple-portal-application-service.js +46 -63
- package/lib/services/apple-portal/apple-portal-session-service.js +195 -214
- package/lib/services/apple-portal/srp/srp-wrapper.js +43 -58
- package/lib/services/assets-generation/assets-generation-service.js +103 -117
- package/lib/services/build-artifacts-service.js +9 -20
- package/lib/services/build-info-file-service.js +20 -35
- package/lib/services/cleanup-service.js +47 -76
- package/lib/services/cocoapods-service.js +111 -132
- package/lib/services/device/device-install-app-service.js +54 -71
- package/lib/services/doctor-service.js +99 -118
- package/lib/services/extensibility-service.js +81 -100
- package/lib/services/files-hash-service.js +26 -43
- package/lib/services/hmr-status-service.js +1 -1
- package/lib/services/initialize-service.js +37 -50
- package/lib/services/ios/export-options-plist-service.js +38 -51
- package/lib/services/ios/ios-signing-service.js +168 -187
- package/lib/services/ios/spm-service.js +43 -53
- package/lib/services/ios/xcodebuild-args-service.js +77 -94
- package/lib/services/ios/xcodebuild-command-service.js +14 -25
- package/lib/services/ios/xcodebuild-service.js +52 -71
- package/lib/services/ios-debugger-port-service.js +24 -37
- package/lib/services/ios-device-debug-service.js +75 -102
- package/lib/services/ios-entitlements-service.js +31 -42
- package/lib/services/ios-extensions-service.js +18 -29
- package/lib/services/ios-project-service.js +419 -460
- package/lib/services/ios-provision-service.js +108 -129
- package/lib/services/ios-watch-app-service.js +21 -32
- package/lib/services/ip-service.js +38 -53
- package/lib/services/itmstransporter-service.js +129 -152
- package/lib/services/livesync/android-device-livesync-service-base.js +31 -48
- package/lib/services/livesync/android-device-livesync-service.js +120 -149
- package/lib/services/livesync/android-device-livesync-sockets-service.js +121 -152
- package/lib/services/livesync/android-livesync-service.js +14 -35
- package/lib/services/livesync/android-livesync-tool.js +90 -113
- package/lib/services/livesync/device-livesync-service-base.js +15 -28
- package/lib/services/livesync/ios-device-livesync-service.js +114 -143
- package/lib/services/livesync/ios-livesync-service.js +42 -58
- package/lib/services/livesync/platform-livesync-service-base.js +94 -119
- package/lib/services/log-parser-service.js +1 -1
- package/lib/services/log-source-map-service.js +30 -41
- package/lib/services/marking-mode-service.js +15 -28
- package/lib/services/npm-config-service.js +1 -1
- package/lib/services/pacote-service.js +51 -66
- package/lib/services/performance-service.js +1 -1
- package/lib/services/platform/add-platform-service.js +50 -71
- package/lib/services/platform/platform-validation-service.js +22 -33
- package/lib/services/platform/prepare-native-platform-service.js +49 -62
- package/lib/services/platform-environment-requirements.js +26 -37
- package/lib/services/plugins-service.js +122 -147
- package/lib/services/project-backup-service.js +1 -1
- package/lib/services/project-changes-service.js +124 -141
- package/lib/services/project-cleanup-service.js +64 -77
- package/lib/services/project-config-service.js +71 -80
- package/lib/services/project-data-service.js +101 -118
- package/lib/services/project-name-service.js +28 -43
- package/lib/services/project-service.js +84 -103
- package/lib/services/project-templates-service.js +52 -67
- package/lib/services/start-service.js +41 -59
- package/lib/services/temp-service.js +8 -21
- package/lib/services/terminal-spinner-service.js +15 -26
- package/lib/services/test-execution-service.js +59 -72
- package/lib/services/test-initialization-service.js +2 -2
- package/lib/services/timeline-profiler-service.js +1 -1
- package/lib/services/versions-service.js +119 -138
- package/lib/services/webpack/webpack-compiler-service.js +214 -234
- package/lib/services/xcconfig-service.js +8 -19
- package/lib/sys-info.js +45 -62
- package/lib/tools/node-modules/node-modules-builder.js +16 -27
- package/lib/yarn-package-manager.js +59 -78
- package/lib/yarn2-package-manager.js +60 -79
- package/package.json +66 -81
- package/node_modules/@npmcli/move-file/LICENSE.md +0 -22
- package/node_modules/@npmcli/move-file/README.md +0 -69
- package/node_modules/@npmcli/move-file/lib/index.js +0 -185
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/LICENSE +0 -21
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/bin/cmd.js +0 -68
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/index.js +0 -31
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/find-made.js +0 -29
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-manual.js +0 -64
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/mkdirp-native.js +0 -39
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/opts-arg.js +0 -23
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/path-arg.js +0 -29
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/lib/use-native.js +0 -10
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/package.json +0 -44
- package/node_modules/@npmcli/move-file/node_modules/mkdirp/readme.markdown +0 -266
- package/node_modules/@npmcli/move-file/package.json +0 -47
- package/node_modules/balanced-match/.github/FUNDING.yml +0 -2
- package/node_modules/balanced-match/LICENSE.md +0 -21
- package/node_modules/balanced-match/README.md +0 -97
- package/node_modules/balanced-match/index.js +0 -62
- package/node_modules/balanced-match/package.json +0 -48
- package/node_modules/concat-map/.travis.yml +0 -4
- package/node_modules/concat-map/LICENSE +0 -18
- package/node_modules/concat-map/README.markdown +0 -62
- package/node_modules/concat-map/example/map.js +0 -6
- package/node_modules/concat-map/index.js +0 -13
- package/node_modules/concat-map/package.json +0 -43
- package/node_modules/concat-map/test/map.js +0 -39
- package/node_modules/fs.realpath/LICENSE +0 -43
- package/node_modules/fs.realpath/README.md +0 -33
- package/node_modules/fs.realpath/index.js +0 -66
- package/node_modules/fs.realpath/old.js +0 -303
- package/node_modules/fs.realpath/package.json +0 -26
- package/node_modules/inflight/LICENSE +0 -15
- package/node_modules/inflight/README.md +0 -37
- package/node_modules/inflight/inflight.js +0 -54
- package/node_modules/inflight/package.json +0 -29
- package/node_modules/inherits/LICENSE +0 -16
- package/node_modules/inherits/README.md +0 -42
- package/node_modules/inherits/inherits.js +0 -9
- package/node_modules/inherits/inherits_browser.js +0 -27
- package/node_modules/inherits/package.json +0 -29
- package/node_modules/once/LICENSE +0 -15
- package/node_modules/once/README.md +0 -79
- package/node_modules/once/once.js +0 -42
- package/node_modules/once/package.json +0 -33
- package/node_modules/path-is-absolute/index.js +0 -20
- package/node_modules/path-is-absolute/license +0 -21
- package/node_modules/path-is-absolute/package.json +0 -43
- package/node_modules/path-is-absolute/readme.md +0 -59
- package/node_modules/rimraf/LICENSE +0 -15
- package/node_modules/rimraf/README.md +0 -101
- package/node_modules/rimraf/bin.js +0 -68
- package/node_modules/rimraf/node_modules/brace-expansion/LICENSE +0 -21
- package/node_modules/rimraf/node_modules/brace-expansion/README.md +0 -129
- package/node_modules/rimraf/node_modules/brace-expansion/index.js +0 -201
- package/node_modules/rimraf/node_modules/brace-expansion/package.json +0 -47
- package/node_modules/rimraf/node_modules/glob/LICENSE +0 -21
- package/node_modules/rimraf/node_modules/glob/README.md +0 -378
- package/node_modules/rimraf/node_modules/glob/common.js +0 -238
- package/node_modules/rimraf/node_modules/glob/glob.js +0 -790
- package/node_modules/rimraf/node_modules/glob/package.json +0 -55
- package/node_modules/rimraf/node_modules/glob/sync.js +0 -486
- package/node_modules/rimraf/node_modules/minimatch/LICENSE +0 -15
- package/node_modules/rimraf/node_modules/minimatch/README.md +0 -230
- package/node_modules/rimraf/node_modules/minimatch/minimatch.js +0 -947
- package/node_modules/rimraf/node_modules/minimatch/package.json +0 -33
- package/node_modules/rimraf/package.json +0 -32
- package/node_modules/rimraf/rimraf.js +0 -360
- package/node_modules/stringify-package/LICENSE +0 -13
- package/node_modules/stringify-package/README.md +0 -55
- package/node_modules/stringify-package/index.js +0 -18
- package/node_modules/stringify-package/package.json +0 -38
- package/node_modules/wrappy/LICENSE +0 -15
- package/node_modules/wrappy/README.md +0 -36
- package/node_modules/wrappy/package.json +0 -29
- package/node_modules/wrappy/wrappy.js +0 -33
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.MigrateController = void 0;
|
|
13
4
|
const path = require("path");
|
|
@@ -76,10 +67,8 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
76
67
|
replaceWith: "@nativescript/webpack",
|
|
77
68
|
shouldRemove: true,
|
|
78
69
|
isDev: true,
|
|
79
|
-
shouldMigrateAction() {
|
|
80
|
-
return
|
|
81
|
-
return true;
|
|
82
|
-
});
|
|
70
|
+
async shouldMigrateAction() {
|
|
71
|
+
return true;
|
|
83
72
|
},
|
|
84
73
|
migrateAction: this.migrateWebpack.bind(this),
|
|
85
74
|
},
|
|
@@ -94,13 +83,11 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
94
83
|
packageName: "nativescript-vue",
|
|
95
84
|
minVersion: "2.7.0",
|
|
96
85
|
desiredVersion: "~2.9.3",
|
|
97
|
-
shouldMigrateAction(dependency, projectData, loose) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return yield this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
103
|
-
});
|
|
86
|
+
async shouldMigrateAction(dependency, projectData, loose) {
|
|
87
|
+
if (!this.hasDependency(dependency, projectData)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return await this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
104
91
|
},
|
|
105
92
|
migrateAction: this.migrateNativeScriptVue.bind(this),
|
|
106
93
|
},
|
|
@@ -113,13 +100,11 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
113
100
|
packageName: "@nativescript/angular",
|
|
114
101
|
minVersion: "10.0.0",
|
|
115
102
|
desiredVersion: "^18.0.0",
|
|
116
|
-
shouldMigrateAction(dependency, projectData, loose) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return yield this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
122
|
-
});
|
|
103
|
+
async shouldMigrateAction(dependency, projectData, loose) {
|
|
104
|
+
if (!this.hasDependency(dependency, projectData)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return await this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
123
108
|
},
|
|
124
109
|
migrateAction: this.migrateNativeScriptAngular.bind(this),
|
|
125
110
|
},
|
|
@@ -127,13 +112,11 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
127
112
|
packageName: "svelte-native",
|
|
128
113
|
minVersion: "0.9.0",
|
|
129
114
|
desiredVersion: "~0.9.4",
|
|
130
|
-
shouldMigrateAction(dependency, projectData, loose) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return yield this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
136
|
-
});
|
|
115
|
+
async shouldMigrateAction(dependency, projectData, loose) {
|
|
116
|
+
if (!this.hasDependency(dependency, projectData)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return await this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
137
120
|
},
|
|
138
121
|
migrateAction: this.migrateNativeScriptSvelte.bind(this),
|
|
139
122
|
},
|
|
@@ -142,10 +125,8 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
142
125
|
replaceWith: "@nativescript/unit-test-runner",
|
|
143
126
|
shouldRemove: true,
|
|
144
127
|
isDev: true,
|
|
145
|
-
shouldMigrateAction() {
|
|
146
|
-
return
|
|
147
|
-
return true;
|
|
148
|
-
});
|
|
128
|
+
async shouldMigrateAction() {
|
|
129
|
+
return true;
|
|
149
130
|
},
|
|
150
131
|
migrateAction: this.migrateUnitTestRunner.bind(this),
|
|
151
132
|
},
|
|
@@ -153,13 +134,11 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
153
134
|
packageName: "@nativescript/unit-test-runner",
|
|
154
135
|
minVersion: "1.0.0",
|
|
155
136
|
desiredVersion: "~3.0.0",
|
|
156
|
-
shouldMigrateAction(dependency, projectData, loose) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return yield this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
162
|
-
});
|
|
137
|
+
async shouldMigrateAction(dependency, projectData, loose) {
|
|
138
|
+
if (!this.hasDependency(dependency, projectData)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return await this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
163
142
|
},
|
|
164
143
|
migrateAction: this.migrateUnitTestRunner.bind(this),
|
|
165
144
|
},
|
|
@@ -215,276 +194,252 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
215
194
|
jsonFileSettingsPath: shouldMigrateCacheFilePath,
|
|
216
195
|
});
|
|
217
196
|
}
|
|
218
|
-
shouldMigrate({ projectDir, platforms, loose = false, }) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
const cachedResult = yield this.getCachedShouldMigrate(projectDir, platform);
|
|
228
|
-
this.$logger.trace(`Got cached result for shouldMigrate for platform: ${platform}: ${cachedResult}`);
|
|
229
|
-
if (cachedResult !== false) {
|
|
230
|
-
remainingPlatforms.push(platform);
|
|
231
|
-
}
|
|
197
|
+
async shouldMigrate({ projectDir, platforms, loose = false, }) {
|
|
198
|
+
const remainingPlatforms = [];
|
|
199
|
+
let shouldMigrate = false;
|
|
200
|
+
for (const platform of platforms) {
|
|
201
|
+
if (!loose) {
|
|
202
|
+
remainingPlatforms.push(platform);
|
|
203
|
+
continue;
|
|
232
204
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
loose,
|
|
238
|
-
});
|
|
239
|
-
this.$logger.trace(`Executed shouldMigrate for platforms: ${remainingPlatforms}. Result is: ${shouldMigrate}`);
|
|
240
|
-
if (!shouldMigrate && loose) {
|
|
241
|
-
for (const remainingPlatform of remainingPlatforms) {
|
|
242
|
-
yield this.setCachedShouldMigrate(projectDir, remainingPlatform);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
205
|
+
const cachedResult = await this.getCachedShouldMigrate(projectDir, platform);
|
|
206
|
+
this.$logger.trace(`Got cached result for shouldMigrate for platform: ${platform}: ${cachedResult}`);
|
|
207
|
+
if (cachedResult !== false) {
|
|
208
|
+
remainingPlatforms.push(platform);
|
|
245
209
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
validate({ projectDir, platforms, loose = true, }) {
|
|
250
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
251
|
-
const shouldMigrate = yield this.shouldMigrate({
|
|
210
|
+
}
|
|
211
|
+
if (remainingPlatforms.length > 0) {
|
|
212
|
+
shouldMigrate = await this._shouldMigrate({
|
|
252
213
|
projectDir,
|
|
253
|
-
platforms,
|
|
214
|
+
platforms: remainingPlatforms,
|
|
254
215
|
loose,
|
|
255
216
|
});
|
|
256
|
-
|
|
257
|
-
|
|
217
|
+
this.$logger.trace(`Executed shouldMigrate for platforms: ${remainingPlatforms}. Result is: ${shouldMigrate}`);
|
|
218
|
+
if (!shouldMigrate && loose) {
|
|
219
|
+
for (const remainingPlatform of remainingPlatforms) {
|
|
220
|
+
await this.setCachedShouldMigrate(projectDir, remainingPlatform);
|
|
221
|
+
}
|
|
258
222
|
}
|
|
223
|
+
}
|
|
224
|
+
return shouldMigrate;
|
|
225
|
+
}
|
|
226
|
+
async validate({ projectDir, platforms, loose = true, }) {
|
|
227
|
+
const shouldMigrate = await this.shouldMigrate({
|
|
228
|
+
projectDir,
|
|
229
|
+
platforms,
|
|
230
|
+
loose,
|
|
259
231
|
});
|
|
232
|
+
if (shouldMigrate) {
|
|
233
|
+
this.$errors.fail(`The current application is not compatible with NativeScript CLI ${this.$staticConfig.version}.\n\nRun 'ns migrate' to migrate your project to the latest NativeScript version.\n\nAlternatively you may try running it with '--force' to skip this check.`);
|
|
234
|
+
}
|
|
260
235
|
}
|
|
261
|
-
migrate({ projectDir, platforms, loose = false, }) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
loose: loose,
|
|
269
|
-
});
|
|
270
|
-
const canMigrate = yield this.ensureGitCleanOrForce(projectDir);
|
|
271
|
-
if (!canMigrate) {
|
|
272
|
-
this.spinner.fail("Pre-Migration verification failed");
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
this.spinner.succeed("Pre-Migration verification complete");
|
|
276
|
-
this.spinner.info("Backing up project files before migration");
|
|
277
|
-
const backup = yield this.backupProject(projectDir);
|
|
278
|
-
this.spinner.succeed("Project files have been backed up");
|
|
279
|
-
this.spinner.info("Cleaning up project files before migration");
|
|
280
|
-
yield this.cleanUpProject(projectData);
|
|
281
|
-
this.spinner.succeed("Project files have been cleaned up");
|
|
282
|
-
this.spinner.info("Cleaning up old artifacts");
|
|
283
|
-
yield this.handleAutoGeneratedFiles(backup, projectData);
|
|
284
|
-
this.spinner.succeed("Cleaned old artifacts");
|
|
285
|
-
const newConfigPath = path.resolve(projectDir, "nativescript.config.ts");
|
|
286
|
-
if (!this.$fs.exists(newConfigPath)) {
|
|
287
|
-
this.spinner.info(`Migrating project to use ${color_1.color.green("nativescript.config.ts")}`);
|
|
288
|
-
yield this.migrateConfigs(projectDir);
|
|
289
|
-
this.spinner.succeed(`Project has been migrated to use ${color_1.color.green("nativescript.config.ts")}`);
|
|
290
|
-
}
|
|
291
|
-
this.spinner.info("Updating project dependencies");
|
|
292
|
-
yield this.migrateDependencies(projectData, platforms, loose);
|
|
293
|
-
this.spinner.succeed("Project dependencies have been updated");
|
|
294
|
-
const isAngular = this.hasDependency({
|
|
295
|
-
packageName: "@nativescript/angular",
|
|
296
|
-
}, projectData);
|
|
297
|
-
let polyfillsPath;
|
|
298
|
-
if (isAngular) {
|
|
299
|
-
polyfillsPath = yield this.checkOrCreatePolyfillsTS(projectData);
|
|
300
|
-
}
|
|
301
|
-
const tsConfigPath = path.resolve(projectDir, "tsconfig.json");
|
|
302
|
-
if (this.$fs.exists(tsConfigPath)) {
|
|
303
|
-
this.spinner.info(`Updating ${color_1.color.yellow("tsconfig.json")}`);
|
|
304
|
-
yield this.migrateTSConfig({
|
|
305
|
-
tsConfigPath,
|
|
306
|
-
isAngular,
|
|
307
|
-
polyfillsPath,
|
|
308
|
-
});
|
|
309
|
-
this.spinner.succeed(`Updated ${color_1.color.yellow("tsconfig.json")}`);
|
|
310
|
-
}
|
|
311
|
-
yield this.migrateWebpack5(projectDir, projectData);
|
|
312
|
-
yield this.runESLint(projectDir);
|
|
313
|
-
this.spinner.succeed("Migration complete.");
|
|
314
|
-
this.$logger.info("");
|
|
315
|
-
this.$logger.printMarkdown("Project has been successfully migrated. The next step is to run `ns run <platform>` to ensure everything is working properly." +
|
|
316
|
-
"\n\nPlease note that you may need additional changes to complete the migration.");
|
|
236
|
+
async migrate({ projectDir, platforms, loose = false, }) {
|
|
237
|
+
this.spinner = this.$terminalSpinnerService.createSpinner();
|
|
238
|
+
const projectData = this.$projectDataService.getProjectData(projectDir);
|
|
239
|
+
this.$logger.trace("MigrationController.migrate called with", {
|
|
240
|
+
projectDir,
|
|
241
|
+
platforms,
|
|
242
|
+
loose: loose,
|
|
317
243
|
});
|
|
244
|
+
const canMigrate = await this.ensureGitCleanOrForce(projectDir);
|
|
245
|
+
if (!canMigrate) {
|
|
246
|
+
this.spinner.fail("Pre-Migration verification failed");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
this.spinner.succeed("Pre-Migration verification complete");
|
|
250
|
+
this.spinner.info("Backing up project files before migration");
|
|
251
|
+
const backup = await this.backupProject(projectDir);
|
|
252
|
+
this.spinner.succeed("Project files have been backed up");
|
|
253
|
+
this.spinner.info("Cleaning up project files before migration");
|
|
254
|
+
await this.cleanUpProject(projectData);
|
|
255
|
+
this.spinner.succeed("Project files have been cleaned up");
|
|
256
|
+
this.spinner.info("Cleaning up old artifacts");
|
|
257
|
+
await this.handleAutoGeneratedFiles(backup, projectData);
|
|
258
|
+
this.spinner.succeed("Cleaned old artifacts");
|
|
259
|
+
const newConfigPath = path.resolve(projectDir, "nativescript.config.ts");
|
|
260
|
+
if (!this.$fs.exists(newConfigPath)) {
|
|
261
|
+
this.spinner.info(`Migrating project to use ${color_1.color.green("nativescript.config.ts")}`);
|
|
262
|
+
await this.migrateConfigs(projectDir);
|
|
263
|
+
this.spinner.succeed(`Project has been migrated to use ${color_1.color.green("nativescript.config.ts")}`);
|
|
264
|
+
}
|
|
265
|
+
this.spinner.info("Updating project dependencies");
|
|
266
|
+
await this.migrateDependencies(projectData, platforms, loose);
|
|
267
|
+
this.spinner.succeed("Project dependencies have been updated");
|
|
268
|
+
const isAngular = this.hasDependency({
|
|
269
|
+
packageName: "@nativescript/angular",
|
|
270
|
+
}, projectData);
|
|
271
|
+
let polyfillsPath;
|
|
272
|
+
if (isAngular) {
|
|
273
|
+
polyfillsPath = await this.checkOrCreatePolyfillsTS(projectData);
|
|
274
|
+
}
|
|
275
|
+
const tsConfigPath = path.resolve(projectDir, "tsconfig.json");
|
|
276
|
+
if (this.$fs.exists(tsConfigPath)) {
|
|
277
|
+
this.spinner.info(`Updating ${color_1.color.yellow("tsconfig.json")}`);
|
|
278
|
+
await this.migrateTSConfig({
|
|
279
|
+
tsConfigPath,
|
|
280
|
+
isAngular,
|
|
281
|
+
polyfillsPath,
|
|
282
|
+
});
|
|
283
|
+
this.spinner.succeed(`Updated ${color_1.color.yellow("tsconfig.json")}`);
|
|
284
|
+
}
|
|
285
|
+
await this.migrateWebpack5(projectDir, projectData);
|
|
286
|
+
await this.runESLint(projectDir);
|
|
287
|
+
this.spinner.succeed("Migration complete.");
|
|
288
|
+
this.$logger.info("");
|
|
289
|
+
this.$logger.printMarkdown("Project has been successfully migrated. The next step is to run `ns run <platform>` to ensure everything is working properly." +
|
|
290
|
+
"\n\nPlease note that you may need additional changes to complete the migration.");
|
|
318
291
|
}
|
|
319
|
-
_shouldMigrate({ projectDir, platforms, loose, }) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (
|
|
332
|
-
|
|
333
|
-
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' is missing.`);
|
|
334
|
-
if (loose) {
|
|
335
|
-
continue;
|
|
336
|
-
}
|
|
337
|
-
return true;
|
|
338
|
-
}
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
341
|
-
if (dependency.shouldMigrateAction) {
|
|
342
|
-
const shouldMigrate = yield dependency.shouldMigrateAction.bind(this)(dependency, projectData, loose);
|
|
343
|
-
if (shouldMigrate) {
|
|
344
|
-
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' requires an update.`);
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
if (dependency.replaceWith || dependency.shouldRemove) {
|
|
349
|
-
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' is deprecated.`);
|
|
292
|
+
async _shouldMigrate({ projectDir, platforms, loose, }) {
|
|
293
|
+
const isMigrate = _.get(this.$options, "argv._[0]") === "migrate";
|
|
294
|
+
const projectData = this.$projectDataService.getProjectData(projectDir);
|
|
295
|
+
const projectInfo = this.$projectConfigService.detectProjectConfigs(projectData.projectDir);
|
|
296
|
+
if (!isMigrate && projectInfo.hasNSConfig) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const shouldMigrateCommonMessage = "The app is not compatible with this CLI version and it should be migrated. Reason: ";
|
|
300
|
+
for (let i = 0; i < this.migrationDependencies.length; i++) {
|
|
301
|
+
const dependency = this.migrationDependencies[i];
|
|
302
|
+
const hasDependency = this.hasDependency(dependency, projectData);
|
|
303
|
+
if (!hasDependency) {
|
|
304
|
+
if (dependency.shouldAddIfMissing) {
|
|
305
|
+
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' is missing.`);
|
|
350
306
|
if (loose) {
|
|
351
307
|
continue;
|
|
352
308
|
}
|
|
353
309
|
return true;
|
|
354
310
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
if (dependency.shouldMigrateAction) {
|
|
314
|
+
const shouldMigrate = await dependency.shouldMigrateAction.bind(this)(dependency, projectData, loose);
|
|
315
|
+
if (shouldMigrate) {
|
|
316
|
+
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' requires an update.`);
|
|
358
317
|
return true;
|
|
359
318
|
}
|
|
360
319
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
367
|
-
const installedVersion = yield this.$packageInstallationManager.getInstalledDependencyVersion(dependency.packageName, projectData.projectDir);
|
|
368
|
-
const desiredVersion = (_a = dependency.desiredVersion) !== null && _a !== void 0 ? _a : dependency.minVersion;
|
|
369
|
-
const minVersion = (_b = dependency.minVersion) !== null && _b !== void 0 ? _b : dependency.desiredVersion;
|
|
370
|
-
if (dependency.shouldUseExactVersion &&
|
|
371
|
-
installedVersion !== desiredVersion) {
|
|
320
|
+
if (dependency.replaceWith || dependency.shouldRemove) {
|
|
321
|
+
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' is deprecated.`);
|
|
322
|
+
if (loose) {
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
372
325
|
return true;
|
|
373
326
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
379
|
-
let cachedShouldMigrateValue = null;
|
|
380
|
-
const cachedHash = yield this.$jsonFileSettingsService.getSettingValue((0, helpers_1.getHash)(`${projectDir}${platform.toLowerCase()}`));
|
|
381
|
-
const packageJsonHash = yield this.getPackageJsonHash(projectDir);
|
|
382
|
-
if (cachedHash === packageJsonHash) {
|
|
383
|
-
cachedShouldMigrateValue = false;
|
|
327
|
+
const shouldUpdate = await this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
328
|
+
if (shouldUpdate) {
|
|
329
|
+
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' should be updated.`);
|
|
330
|
+
return true;
|
|
384
331
|
}
|
|
385
|
-
|
|
386
|
-
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
387
334
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
335
|
+
async shouldMigrateDependencyVersion(dependency, projectData, loose) {
|
|
336
|
+
var _a, _b;
|
|
337
|
+
const installedVersion = await this.$packageInstallationManager.getInstalledDependencyVersion(dependency.packageName, projectData.projectDir);
|
|
338
|
+
const desiredVersion = (_a = dependency.desiredVersion) !== null && _a !== void 0 ? _a : dependency.minVersion;
|
|
339
|
+
const minVersion = (_b = dependency.minVersion) !== null && _b !== void 0 ? _b : dependency.desiredVersion;
|
|
340
|
+
if (dependency.shouldUseExactVersion &&
|
|
341
|
+
installedVersion !== desiredVersion) {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
return this.isOutdatedVersion(installedVersion, { minVersion, desiredVersion }, loose);
|
|
394
345
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
346
|
+
async getCachedShouldMigrate(projectDir, platform) {
|
|
347
|
+
let cachedShouldMigrateValue = null;
|
|
348
|
+
const cachedHash = await this.$jsonFileSettingsService.getSettingValue((0, helpers_1.getHash)(`${projectDir}${platform.toLowerCase()}`));
|
|
349
|
+
const packageJsonHash = await this.getPackageJsonHash(projectDir);
|
|
350
|
+
if (cachedHash === packageJsonHash) {
|
|
351
|
+
cachedShouldMigrateValue = false;
|
|
352
|
+
}
|
|
353
|
+
return cachedShouldMigrateValue;
|
|
400
354
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
355
|
+
async setCachedShouldMigrate(projectDir, platform) {
|
|
356
|
+
this.$logger.trace(`Caching shouldMigrate result for platform ${platform}.`);
|
|
357
|
+
const packageJsonHash = await this.getPackageJsonHash(projectDir);
|
|
358
|
+
await this.$jsonFileSettingsService.saveSetting((0, helpers_1.getHash)(`${projectDir}${platform.toLowerCase()}`), packageJsonHash);
|
|
359
|
+
}
|
|
360
|
+
async getPackageJsonHash(projectDir) {
|
|
361
|
+
const projectPackageJsonFilePath = path.join(projectDir, constants.PACKAGE_JSON_FILE_NAME);
|
|
362
|
+
return await this.$fs.getFileShasum(projectPackageJsonFilePath);
|
|
363
|
+
}
|
|
364
|
+
async ensureGitCleanOrForce(projectDir) {
|
|
365
|
+
const git = (0, simple_git_1.default)(projectDir);
|
|
366
|
+
const isGit = await git.checkIsRepo();
|
|
367
|
+
const isForce = this.$options.force;
|
|
368
|
+
if (!isGit) {
|
|
369
|
+
if (!isForce) {
|
|
370
|
+
this.$logger.printMarkdown(`Running \`ns migrate\` in a non-git project is not recommended. If you want to skip this check run \`ns migrate --force\`.`);
|
|
371
|
+
this.$errors.fail("Not in Git repo.");
|
|
372
|
+
return false;
|
|
414
373
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.
|
|
423
|
-
return
|
|
374
|
+
this.spinner.warn(`Not in Git repo, but using ${color_1.color.red("--force")}`);
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
const isClean = (await git.status()).isClean();
|
|
378
|
+
if (!isClean) {
|
|
379
|
+
if (!isForce) {
|
|
380
|
+
this.$logger.printMarkdown(`Current git branch has uncommitted changes. Please commit the changes and try again. Alternatively run \`ns migrate --force\` to skip this check.`);
|
|
381
|
+
this.$errors.fail("Git branch not clean.");
|
|
382
|
+
return false;
|
|
424
383
|
}
|
|
384
|
+
this.spinner.warn(`Git branch not clean, but using ${color_1.color.red("--force")}`);
|
|
425
385
|
return true;
|
|
426
|
-
}
|
|
386
|
+
}
|
|
387
|
+
return true;
|
|
427
388
|
}
|
|
428
|
-
backupProject(projectDir) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
});
|
|
389
|
+
async backupProject(projectDir) {
|
|
390
|
+
const projectData = this.$projectDataService.getProjectData(projectDir);
|
|
391
|
+
const backup = this.$projectBackupService.getBackup("migration");
|
|
392
|
+
backup.addPaths([
|
|
393
|
+
...MigrateController.pathsToBackup,
|
|
394
|
+
path.join(projectData.getAppDirectoryRelativePath(), "package.json"),
|
|
395
|
+
]);
|
|
396
|
+
try {
|
|
397
|
+
return backup.create();
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
this.spinner.fail(`Project backup failed.`);
|
|
401
|
+
backup.remove();
|
|
402
|
+
this.$errors.fail(`Project backup failed. Error is: ${error.message}`);
|
|
403
|
+
}
|
|
445
404
|
}
|
|
446
|
-
cleanUpProject(projectData) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
405
|
+
async cleanUpProject(projectData) {
|
|
406
|
+
await this.$projectCleanupService.clean([
|
|
407
|
+
constants.HOOKS_DIR_NAME,
|
|
408
|
+
constants.PLATFORMS_DIR_NAME,
|
|
409
|
+
constants.NODE_MODULES_FOLDER_NAME,
|
|
410
|
+
constants.PACKAGE_LOCK_JSON_FILE_NAME,
|
|
411
|
+
]);
|
|
412
|
+
const { dependencies, devDependencies } = await this.$pluginsService.getDependenciesFromPackageJson(projectData.projectDir);
|
|
413
|
+
const hasSchematics = [...dependencies, ...devDependencies].find((p) => p.name === "@nativescript/schematics");
|
|
414
|
+
if (!hasSchematics) {
|
|
415
|
+
await this.$projectCleanupService.clean([
|
|
416
|
+
constants.TSCCONFIG_TNS_JSON_NAME,
|
|
453
417
|
]);
|
|
454
|
-
|
|
455
|
-
const hasSchematics = [...dependencies, ...devDependencies].find((p) => p.name === "@nativescript/schematics");
|
|
456
|
-
if (!hasSchematics) {
|
|
457
|
-
yield this.$projectCleanupService.clean([
|
|
458
|
-
constants.TSCCONFIG_TNS_JSON_NAME,
|
|
459
|
-
]);
|
|
460
|
-
}
|
|
461
|
-
});
|
|
418
|
+
}
|
|
462
419
|
}
|
|
463
|
-
handleAutoGeneratedFiles(backup, projectData) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
});
|
|
420
|
+
async handleAutoGeneratedFiles(backup, projectData) {
|
|
421
|
+
const globOptions = {
|
|
422
|
+
nocase: true,
|
|
423
|
+
matchBase: true,
|
|
424
|
+
nodir: true,
|
|
425
|
+
absolute: false,
|
|
426
|
+
cwd: projectData.appDirectoryPath,
|
|
427
|
+
withFileTypes: false,
|
|
428
|
+
};
|
|
429
|
+
const jsFiles = (0, glob_1.globSync)("*.@(js|ts|js.map)", globOptions);
|
|
430
|
+
const autoGeneratedJsFiles = this.getGeneratedFiles(jsFiles, [".js"], [".ts"]);
|
|
431
|
+
const autoGeneratedJsMapFiles = this.getGeneratedFiles(jsFiles, [".map"], [""]);
|
|
432
|
+
const cssFiles = (0, glob_1.globSync)("*.@(less|sass|scss|css)", globOptions);
|
|
433
|
+
const autoGeneratedCssFiles = this.getGeneratedFiles(cssFiles, [".css"], [".scss", ".sass", ".less"]);
|
|
434
|
+
const allGeneratedFiles = autoGeneratedJsFiles
|
|
435
|
+
.concat(autoGeneratedJsMapFiles)
|
|
436
|
+
.concat(autoGeneratedCssFiles);
|
|
437
|
+
const pathsToBackup = allGeneratedFiles.map((generatedFile) => path.join(projectData.appDirectoryPath, generatedFile));
|
|
438
|
+
backup.addPaths(pathsToBackup);
|
|
439
|
+
backup.create();
|
|
440
|
+
if (backup.isUpToDate()) {
|
|
441
|
+
await this.$projectCleanupService.clean(pathsToBackup);
|
|
442
|
+
}
|
|
488
443
|
}
|
|
489
444
|
getGeneratedFiles(allFiles, generatedFileExts, sourceFileExts) {
|
|
490
445
|
return allFiles.filter((file) => {
|
|
@@ -554,550 +509,523 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
554
509
|
return relativeAppResourcesPath.toString();
|
|
555
510
|
}
|
|
556
511
|
}
|
|
557
|
-
runMigrateActionIfAny(dependency, projectData, loose, force = false) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
yield this.migrateDependency(newDependency, projectData, loose);
|
|
566
|
-
}
|
|
512
|
+
async runMigrateActionIfAny(dependency, projectData, loose, force = false) {
|
|
513
|
+
if (dependency.migrateAction) {
|
|
514
|
+
const shouldMigrate = force ||
|
|
515
|
+
(await dependency.shouldMigrateAction.bind(this)(dependency, projectData, loose));
|
|
516
|
+
if (shouldMigrate) {
|
|
517
|
+
const newDependencies = await dependency.migrateAction(projectData, path.join(projectData.projectDir, MigrateController.backupFolderName));
|
|
518
|
+
for (const newDependency of newDependencies) {
|
|
519
|
+
await this.migrateDependency(newDependency, projectData, loose);
|
|
567
520
|
}
|
|
568
521
|
}
|
|
569
|
-
}
|
|
522
|
+
}
|
|
570
523
|
}
|
|
571
|
-
migrateDependencies(projectData, platforms, loose) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
yield this.runMigrateActionIfAny(dependency, projectData, loose);
|
|
580
|
-
yield this.migrateDependency(dependency, projectData, loose);
|
|
524
|
+
async migrateDependencies(projectData, platforms, loose) {
|
|
525
|
+
for (let i = 0; i < this.migrationDependencies.length; i++) {
|
|
526
|
+
const dependency = this.migrationDependencies[i];
|
|
527
|
+
const hasDependency = this.hasDependency(dependency, projectData);
|
|
528
|
+
if (!hasDependency && !dependency.shouldAddIfMissing) {
|
|
529
|
+
continue;
|
|
581
530
|
}
|
|
582
|
-
|
|
531
|
+
await this.runMigrateActionIfAny(dependency, projectData, loose);
|
|
532
|
+
await this.migrateDependency(dependency, projectData, loose);
|
|
533
|
+
}
|
|
583
534
|
}
|
|
584
|
-
migrateDependency(dependency, projectData, loose) {
|
|
535
|
+
async migrateDependency(dependency, projectData, loose) {
|
|
585
536
|
var _a, _b, _c, _d, _e;
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
if (!
|
|
592
|
-
if (!dependency.shouldAddIfMissing) {
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
const version = (_a = dependency.desiredVersion) !== null && _a !== void 0 ? _a : dependency.minVersion;
|
|
596
|
-
this.$pluginsService.addToPackageJson(dependency.packageName, version, dependency.isDev, projectData.projectDir);
|
|
597
|
-
this.spinner.clear();
|
|
598
|
-
this.$logger.info(` - ${color_1.color.yellow(dependency.packageName)} ${color_1.color.green(version)} has been added`);
|
|
599
|
-
this.spinner.render();
|
|
537
|
+
const hasDependency = this.hasDependency(dependency, projectData);
|
|
538
|
+
if (hasDependency && dependency.warning) {
|
|
539
|
+
this.$logger.warn(dependency.warning);
|
|
540
|
+
}
|
|
541
|
+
if (!hasDependency) {
|
|
542
|
+
if (!dependency.shouldAddIfMissing) {
|
|
600
543
|
return;
|
|
601
544
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
this.$pluginsService.addToPackageJson(replacementDep.packageName, version, replacementDep.isDev, projectData.projectDir);
|
|
613
|
-
this.spinner.clear();
|
|
614
|
-
this.$logger.info(` - ${color_1.color.yellow(dependency.packageName)} has been replaced with ${color_1.color.cyan(replacementDep.packageName)} ${color_1.color.green(version)}`);
|
|
615
|
-
this.spinner.render();
|
|
616
|
-
yield this.runMigrateActionIfAny(replacementDep, projectData, loose, true);
|
|
545
|
+
const version = (_a = dependency.desiredVersion) !== null && _a !== void 0 ? _a : dependency.minVersion;
|
|
546
|
+
this.$pluginsService.addToPackageJson(dependency.packageName, version, dependency.isDev, projectData.projectDir);
|
|
547
|
+
this.spinner.clear();
|
|
548
|
+
this.$logger.info(` - ${color_1.color.yellow(dependency.packageName)} ${color_1.color.green(version)} has been added`);
|
|
549
|
+
this.spinner.render();
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (dependency.replaceWith || dependency.shouldRemove) {
|
|
553
|
+
this.$pluginsService.removeFromPackageJson(dependency.packageName, projectData.projectDir);
|
|
554
|
+
if (!dependency.replaceWith) {
|
|
617
555
|
return;
|
|
618
556
|
}
|
|
619
|
-
const
|
|
620
|
-
if (!
|
|
621
|
-
|
|
557
|
+
const replacementDep = _.find(this.migrationDependencies, (migrationPackage) => migrationPackage.packageName === dependency.replaceWith);
|
|
558
|
+
if (!replacementDep) {
|
|
559
|
+
this.$errors.fail("Failed to find replacement dependency.");
|
|
622
560
|
}
|
|
623
|
-
const version = (
|
|
624
|
-
this.$pluginsService.addToPackageJson(
|
|
561
|
+
const version = (_d = (_c = (_b = replacementDep.desiredVersion) !== null && _b !== void 0 ? _b : replacementDep.minVersion) !== null && _c !== void 0 ? _c : dependency.desiredVersion) !== null && _d !== void 0 ? _d : dependency.minVersion;
|
|
562
|
+
this.$pluginsService.addToPackageJson(replacementDep.packageName, version, replacementDep.isDev, projectData.projectDir);
|
|
625
563
|
this.spinner.clear();
|
|
626
|
-
this.$logger.info(` - ${color_1.color.yellow(dependency.packageName)} has been
|
|
564
|
+
this.$logger.info(` - ${color_1.color.yellow(dependency.packageName)} has been replaced with ${color_1.color.cyan(replacementDep.packageName)} ${color_1.color.green(version)}`);
|
|
627
565
|
this.spinner.render();
|
|
628
|
-
|
|
566
|
+
await this.runMigrateActionIfAny(replacementDep, projectData, loose, true);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const shouldMigrateVersion = await this.shouldMigrateDependencyVersion(dependency, projectData, loose);
|
|
570
|
+
if (!shouldMigrateVersion) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
const version = (_e = dependency.desiredVersion) !== null && _e !== void 0 ? _e : dependency.minVersion;
|
|
574
|
+
this.$pluginsService.addToPackageJson(dependency.packageName, version, dependency.isDev, projectData.projectDir);
|
|
575
|
+
this.spinner.clear();
|
|
576
|
+
this.$logger.info(` - ${color_1.color.yellow(dependency.packageName)} has been updated to ${color_1.color.green(version)}`);
|
|
577
|
+
this.spinner.render();
|
|
629
578
|
}
|
|
630
|
-
migrateConfigs(projectDir) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
yield this.$projectCleanupService.cleanPath(newConfigPath);
|
|
658
|
-
}
|
|
659
|
-
this.$errors.fail(`Failed to migrate project to use ${constants.CONFIG_FILE_NAME_TS}. One or more values could not be updated.`);
|
|
579
|
+
async migrateConfigs(projectDir) {
|
|
580
|
+
const projectData = this.$projectDataService.getProjectData(projectDir);
|
|
581
|
+
const rootPackageJsonPath = path.resolve(projectDir, constants.PACKAGE_JSON_FILE_NAME);
|
|
582
|
+
const embeddedPackageJsonPath = path.resolve(projectData.projectDir, projectData.getAppDirectoryRelativePath(), constants.PACKAGE_JSON_FILE_NAME);
|
|
583
|
+
const legacyNsConfigPath = path.resolve(projectData.projectDir, constants.CONFIG_NS_FILE_NAME);
|
|
584
|
+
let rootPackageJsonData = {};
|
|
585
|
+
if (this.$fs.exists(rootPackageJsonPath)) {
|
|
586
|
+
rootPackageJsonData = this.$fs.readJson(rootPackageJsonPath);
|
|
587
|
+
}
|
|
588
|
+
const newConfigPath = this.$projectConfigService.writeDefaultConfig(projectData.projectDir);
|
|
589
|
+
this.$projectConfigService.setForceUsingLegacyConfig(true);
|
|
590
|
+
const configData = this.$projectConfigService.readConfig(projectData.projectDir);
|
|
591
|
+
this.$projectConfigService.setForceUsingLegacyConfig(false);
|
|
592
|
+
if (configData.main) {
|
|
593
|
+
rootPackageJsonData.main = configData.main;
|
|
594
|
+
delete configData.main;
|
|
595
|
+
}
|
|
596
|
+
configData.appPath = this.detectAppPath(projectDir, configData);
|
|
597
|
+
configData.appResourcesPath = this.detectAppResourcesPath(projectDir, configData);
|
|
598
|
+
if (rootPackageJsonData.nativescript) {
|
|
599
|
+
delete rootPackageJsonData.nativescript;
|
|
600
|
+
}
|
|
601
|
+
this.$projectConfigService.setForceUsingNewConfig(true);
|
|
602
|
+
const hasUpdatedConfigSuccessfully = await this.$projectConfigService.setValue("", configData);
|
|
603
|
+
if (!hasUpdatedConfigSuccessfully) {
|
|
604
|
+
if (typeof newConfigPath === "string") {
|
|
605
|
+
await this.$projectCleanupService.cleanPath(newConfigPath);
|
|
660
606
|
}
|
|
661
|
-
this.$
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
607
|
+
this.$errors.fail(`Failed to migrate project to use ${constants.CONFIG_FILE_NAME_TS}. One or more values could not be updated.`);
|
|
608
|
+
}
|
|
609
|
+
this.$fs.writeJson(rootPackageJsonPath, rootPackageJsonData);
|
|
610
|
+
await this.$projectCleanupService.cleanPath(embeddedPackageJsonPath);
|
|
611
|
+
await this.$projectCleanupService.cleanPath(legacyNsConfigPath);
|
|
612
|
+
return true;
|
|
666
613
|
}
|
|
667
|
-
migrateUnitTestRunner(projectData, migrationBackupDirPath) {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
return dependencies;
|
|
723
|
-
});
|
|
614
|
+
async migrateUnitTestRunner(projectData, migrationBackupDirPath) {
|
|
615
|
+
const pathToKarmaConfig = path.join(migrationBackupDirPath, constants.KARMA_CONFIG_NAME);
|
|
616
|
+
if (this.$fs.exists(pathToKarmaConfig)) {
|
|
617
|
+
const oldKarmaContent = this.$fs.readText(pathToKarmaConfig);
|
|
618
|
+
const regExp = /frameworks:\s+\[([\S\s]*?)\]/g;
|
|
619
|
+
const matches = regExp.exec(oldKarmaContent);
|
|
620
|
+
const frameworks = (matches && matches[1] && matches[1].trim()) || '["jasmine"]';
|
|
621
|
+
const testsDir = path.join(projectData.appDirectoryPath, "tests");
|
|
622
|
+
const relativeTestsDir = path.relative(projectData.projectDir, testsDir);
|
|
623
|
+
const testFiles = `'${(0, helpers_1.fromWindowsRelativePathToUnix)(relativeTestsDir)}/**/*.*'`;
|
|
624
|
+
const karmaConfTemplate = this.$resources.readText("test/karma.conf.js");
|
|
625
|
+
const karmaConf = _.template(karmaConfTemplate)({
|
|
626
|
+
frameworks,
|
|
627
|
+
testFiles,
|
|
628
|
+
basePath: projectData.getAppDirectoryRelativePath(),
|
|
629
|
+
});
|
|
630
|
+
this.$fs.writeFile(path.join(projectData.projectDir, constants.KARMA_CONFIG_NAME), karmaConf);
|
|
631
|
+
}
|
|
632
|
+
const dependencies = [
|
|
633
|
+
{
|
|
634
|
+
packageName: "karma-webpack",
|
|
635
|
+
shouldRemove: true,
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
packageName: "karma-jasmine",
|
|
639
|
+
minVersion: "2.0.1",
|
|
640
|
+
desiredVersion: "~4.0.1",
|
|
641
|
+
isDev: true,
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
packageName: "karma-mocha",
|
|
645
|
+
minVersion: "1.3.0",
|
|
646
|
+
desiredVersion: "~2.0.1",
|
|
647
|
+
isDev: true,
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
packageName: "karma-chai",
|
|
651
|
+
minVersion: "0.1.0",
|
|
652
|
+
desiredVersion: "~0.1.0",
|
|
653
|
+
isDev: true,
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
packageName: "karma-qunit",
|
|
657
|
+
minVersion: "3.1.2",
|
|
658
|
+
desiredVersion: "~4.1.2",
|
|
659
|
+
isDev: true,
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
packageName: "karma",
|
|
663
|
+
minVersion: "4.1.0",
|
|
664
|
+
desiredVersion: "~6.3.4",
|
|
665
|
+
isDev: true,
|
|
666
|
+
},
|
|
667
|
+
];
|
|
668
|
+
return dependencies;
|
|
724
669
|
}
|
|
725
|
-
migrateTSConfig({ tsConfigPath, isAngular, polyfillsPath, }) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
configContents.compilerOptions.lib
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
if (
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
...
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
];
|
|
746
|
-
}
|
|
670
|
+
async migrateTSConfig({ tsConfigPath, isAngular, polyfillsPath, }) {
|
|
671
|
+
try {
|
|
672
|
+
const configContents = this.$fs.readJson(tsConfigPath);
|
|
673
|
+
configContents.compilerOptions = configContents.compilerOptions || {};
|
|
674
|
+
configContents.compilerOptions.target = "es2020";
|
|
675
|
+
configContents.compilerOptions.module = "esnext";
|
|
676
|
+
configContents.compilerOptions.moduleResolution = "node";
|
|
677
|
+
configContents.compilerOptions.experimentalDecorators = true;
|
|
678
|
+
configContents.compilerOptions.removeComments = false;
|
|
679
|
+
configContents.compilerOptions.lib = [
|
|
680
|
+
...new Set([...(configContents.compilerOptions.lib || []), "ESNext"]),
|
|
681
|
+
];
|
|
682
|
+
if (isAngular) {
|
|
683
|
+
if (configContents.files) {
|
|
684
|
+
configContents.files = [
|
|
685
|
+
...new Set([
|
|
686
|
+
...(configContents.files || []),
|
|
687
|
+
polyfillsPath !== null && polyfillsPath !== void 0 ? polyfillsPath : "./src/polyfills.ts",
|
|
688
|
+
]),
|
|
689
|
+
];
|
|
747
690
|
}
|
|
748
|
-
this.$fs.writeJson(tsConfigPath, configContents);
|
|
749
|
-
return true;
|
|
750
691
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
692
|
+
this.$fs.writeJson(tsConfigPath, configContents);
|
|
693
|
+
return true;
|
|
694
|
+
}
|
|
695
|
+
catch (error) {
|
|
696
|
+
this.$logger.trace("Failed to migrate tsconfig.json. Error is: ", error);
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
756
699
|
}
|
|
757
|
-
checkOrCreatePolyfillsTS(projectData) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
return this.$fs.exists(possiblePath);
|
|
767
|
-
});
|
|
768
|
-
if (polyfillsPath) {
|
|
769
|
-
return "./" + path.relative(projectDir, polyfillsPath);
|
|
770
|
-
}
|
|
771
|
-
const tempDir = temp.mkdirSync({
|
|
772
|
-
prefix: "migrate-angular-polyfills",
|
|
773
|
-
});
|
|
774
|
-
yield this.$pacoteService.extractPackage(constants.RESERVED_TEMPLATE_NAMES["angular"], tempDir);
|
|
775
|
-
this.$fs.copyFile(path.resolve(tempDir, "src/polyfills.ts"), possiblePaths[0]);
|
|
776
|
-
this.$fs.deleteDirectory(tempDir);
|
|
777
|
-
this.spinner.succeed(`Created fresh ${color_1.color.cyan("polyfills.ts")}`);
|
|
778
|
-
return "./" + path.relative(projectDir, possiblePaths[0]);
|
|
700
|
+
async checkOrCreatePolyfillsTS(projectData) {
|
|
701
|
+
const { projectDir, appDirectoryPath } = projectData;
|
|
702
|
+
const possiblePaths = [
|
|
703
|
+
`${appDirectoryPath}/polyfills.ts`,
|
|
704
|
+
`./src/polyfills.ts`,
|
|
705
|
+
`./app/polyfills.ts`,
|
|
706
|
+
].map((possiblePath) => path.resolve(projectDir, possiblePath));
|
|
707
|
+
let polyfillsPath = possiblePaths.find((possiblePath) => {
|
|
708
|
+
return this.$fs.exists(possiblePath);
|
|
779
709
|
});
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
const dependencies = [
|
|
786
|
-
{
|
|
787
|
-
packageName: "@angular/animations",
|
|
788
|
-
minVersion,
|
|
789
|
-
desiredVersion,
|
|
790
|
-
shouldAddIfMissing: true,
|
|
791
|
-
},
|
|
792
|
-
{
|
|
793
|
-
packageName: "@angular/common",
|
|
794
|
-
minVersion,
|
|
795
|
-
desiredVersion,
|
|
796
|
-
shouldAddIfMissing: true,
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
packageName: "@angular/compiler",
|
|
800
|
-
minVersion,
|
|
801
|
-
desiredVersion,
|
|
802
|
-
shouldAddIfMissing: true,
|
|
803
|
-
},
|
|
804
|
-
{
|
|
805
|
-
packageName: "@angular/core",
|
|
806
|
-
minVersion,
|
|
807
|
-
desiredVersion,
|
|
808
|
-
shouldAddIfMissing: true,
|
|
809
|
-
},
|
|
810
|
-
{
|
|
811
|
-
packageName: "@angular/forms",
|
|
812
|
-
minVersion,
|
|
813
|
-
desiredVersion,
|
|
814
|
-
shouldAddIfMissing: true,
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
packageName: "@angular/platform-browser",
|
|
818
|
-
minVersion,
|
|
819
|
-
desiredVersion,
|
|
820
|
-
shouldAddIfMissing: true,
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
packageName: "@angular/platform-browser-dynamic",
|
|
824
|
-
minVersion,
|
|
825
|
-
desiredVersion,
|
|
826
|
-
shouldAddIfMissing: true,
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
packageName: "@angular/router",
|
|
830
|
-
minVersion,
|
|
831
|
-
desiredVersion,
|
|
832
|
-
shouldAddIfMissing: true,
|
|
833
|
-
},
|
|
834
|
-
{
|
|
835
|
-
packageName: "rxjs",
|
|
836
|
-
minVersion: "6.6.0",
|
|
837
|
-
desiredVersion: "~7.8.0",
|
|
838
|
-
shouldAddIfMissing: true,
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
packageName: "zone.js",
|
|
842
|
-
minVersion: "0.11.1",
|
|
843
|
-
desiredVersion: "~0.14.0",
|
|
844
|
-
shouldAddIfMissing: true,
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
packageName: "@angular/cli",
|
|
848
|
-
minVersion,
|
|
849
|
-
desiredVersion,
|
|
850
|
-
isDev: true,
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
packageName: "@angular/compiler-cli",
|
|
854
|
-
minVersion,
|
|
855
|
-
desiredVersion,
|
|
856
|
-
isDev: true,
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
packageName: "@ngtools/webpack",
|
|
860
|
-
minVersion,
|
|
861
|
-
desiredVersion,
|
|
862
|
-
isDev: true,
|
|
863
|
-
},
|
|
864
|
-
{
|
|
865
|
-
packageName: "@angular-devkit/build-angular",
|
|
866
|
-
minVersion,
|
|
867
|
-
desiredVersion,
|
|
868
|
-
isDev: true,
|
|
869
|
-
},
|
|
870
|
-
];
|
|
871
|
-
return dependencies;
|
|
710
|
+
if (polyfillsPath) {
|
|
711
|
+
return "./" + path.relative(projectDir, polyfillsPath);
|
|
712
|
+
}
|
|
713
|
+
const tempDir = temp.mkdirSync({
|
|
714
|
+
prefix: "migrate-angular-polyfills",
|
|
872
715
|
});
|
|
716
|
+
await this.$pacoteService.extractPackage(constants.RESERVED_TEMPLATE_NAMES["angular"], tempDir);
|
|
717
|
+
this.$fs.copyFile(path.resolve(tempDir, "src/polyfills.ts"), possiblePaths[0]);
|
|
718
|
+
this.$fs.deleteDirectory(tempDir);
|
|
719
|
+
this.spinner.succeed(`Created fresh ${color_1.color.cyan("polyfills.ts")}`);
|
|
720
|
+
return "./" + path.relative(projectDir, possiblePaths[0]);
|
|
873
721
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
722
|
+
async migrateNativeScriptAngular() {
|
|
723
|
+
const minVersion = "10.0.0";
|
|
724
|
+
const desiredVersion = "~18.0.0";
|
|
725
|
+
const dependencies = [
|
|
726
|
+
{
|
|
727
|
+
packageName: "@angular/animations",
|
|
728
|
+
minVersion,
|
|
729
|
+
desiredVersion,
|
|
730
|
+
shouldAddIfMissing: true,
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
packageName: "@angular/common",
|
|
734
|
+
minVersion,
|
|
735
|
+
desiredVersion,
|
|
736
|
+
shouldAddIfMissing: true,
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
packageName: "@angular/compiler",
|
|
740
|
+
minVersion,
|
|
741
|
+
desiredVersion,
|
|
742
|
+
shouldAddIfMissing: true,
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
packageName: "@angular/core",
|
|
746
|
+
minVersion,
|
|
747
|
+
desiredVersion,
|
|
748
|
+
shouldAddIfMissing: true,
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
packageName: "@angular/forms",
|
|
752
|
+
minVersion,
|
|
753
|
+
desiredVersion,
|
|
754
|
+
shouldAddIfMissing: true,
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
packageName: "@angular/platform-browser",
|
|
758
|
+
minVersion,
|
|
759
|
+
desiredVersion,
|
|
760
|
+
shouldAddIfMissing: true,
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
packageName: "@angular/platform-browser-dynamic",
|
|
764
|
+
minVersion,
|
|
765
|
+
desiredVersion,
|
|
766
|
+
shouldAddIfMissing: true,
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
packageName: "@angular/router",
|
|
770
|
+
minVersion,
|
|
771
|
+
desiredVersion,
|
|
772
|
+
shouldAddIfMissing: true,
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
packageName: "rxjs",
|
|
776
|
+
minVersion: "6.6.0",
|
|
777
|
+
desiredVersion: "~7.8.0",
|
|
778
|
+
shouldAddIfMissing: true,
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
packageName: "zone.js",
|
|
782
|
+
minVersion: "0.11.1",
|
|
783
|
+
desiredVersion: "~0.14.0",
|
|
784
|
+
shouldAddIfMissing: true,
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
packageName: "@angular/cli",
|
|
788
|
+
minVersion,
|
|
789
|
+
desiredVersion,
|
|
790
|
+
isDev: true,
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
packageName: "@angular/compiler-cli",
|
|
794
|
+
minVersion,
|
|
795
|
+
desiredVersion,
|
|
796
|
+
isDev: true,
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
packageName: "@ngtools/webpack",
|
|
800
|
+
minVersion,
|
|
801
|
+
desiredVersion,
|
|
802
|
+
isDev: true,
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
packageName: "@angular-devkit/build-angular",
|
|
806
|
+
minVersion,
|
|
807
|
+
desiredVersion,
|
|
808
|
+
isDev: true,
|
|
809
|
+
},
|
|
810
|
+
];
|
|
811
|
+
return dependencies;
|
|
930
812
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
813
|
+
async migrateNativeScriptVue() {
|
|
814
|
+
const dependencies = [
|
|
815
|
+
{
|
|
816
|
+
packageName: "nativescript-vue-template-compiler",
|
|
817
|
+
minVersion: "2.7.0",
|
|
818
|
+
desiredVersion: "~2.9.3",
|
|
819
|
+
isDev: true,
|
|
820
|
+
shouldAddIfMissing: true,
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
packageName: "nativescript-vue-devtools",
|
|
824
|
+
minVersion: "1.4.0",
|
|
825
|
+
desiredVersion: "~1.5.1",
|
|
826
|
+
isDev: true,
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
packageName: "vue-loader",
|
|
830
|
+
shouldRemove: true,
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
packageName: "babel-loader",
|
|
834
|
+
shouldRemove: true,
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
packageName: "babel-traverse",
|
|
838
|
+
shouldRemove: true,
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
packageName: "babel-types",
|
|
842
|
+
shouldRemove: true,
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
packageName: "babylon",
|
|
846
|
+
shouldRemove: true,
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
packageName: "@babel/core",
|
|
850
|
+
shouldRemove: true,
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
packageName: "@babel/preset-env",
|
|
854
|
+
shouldRemove: true,
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
packageName: "vue",
|
|
858
|
+
shouldRemove: true,
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
packageName: "vue",
|
|
862
|
+
desiredVersion: "2.6.12",
|
|
863
|
+
isDev: true,
|
|
864
|
+
},
|
|
865
|
+
];
|
|
866
|
+
return dependencies;
|
|
970
867
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
"
|
|
975
|
-
"
|
|
976
|
-
"
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
"
|
|
982
|
-
"
|
|
983
|
-
"
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
"
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
"
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
"
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
"
|
|
1001
|
-
"
|
|
1002
|
-
"
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
868
|
+
async migrateNativeScriptSvelte() {
|
|
869
|
+
const dependencies = [
|
|
870
|
+
{
|
|
871
|
+
packageName: "svelte-native-nativescript-ui",
|
|
872
|
+
minVersion: "0.9.0",
|
|
873
|
+
desiredVersion: "~0.9.0",
|
|
874
|
+
isDev: true,
|
|
875
|
+
shouldAddIfMissing: true,
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
packageName: "svelte-native-preprocessor",
|
|
879
|
+
minVersion: "0.2.0",
|
|
880
|
+
desiredVersion: "~0.2.0",
|
|
881
|
+
isDev: true,
|
|
882
|
+
shouldAddIfMissing: true,
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
packageName: "svelte-loader",
|
|
886
|
+
shouldRemove: true,
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
packageName: "svelte-loader-hot",
|
|
890
|
+
shouldRemove: true,
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
packageName: "svelte",
|
|
894
|
+
shouldRemove: true,
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
packageName: "svelte",
|
|
898
|
+
minVersion: "3.24.1",
|
|
899
|
+
desiredVersion: "3.24.1",
|
|
900
|
+
shouldUseExactVersion: true,
|
|
901
|
+
isDev: true,
|
|
902
|
+
},
|
|
903
|
+
];
|
|
904
|
+
return dependencies;
|
|
905
|
+
}
|
|
906
|
+
async migrateWebpack() {
|
|
907
|
+
const webpackDependencies = [
|
|
908
|
+
"@angular-devkit/core",
|
|
909
|
+
"clean-webpack-plugin",
|
|
910
|
+
"copy-webpack-plugin",
|
|
911
|
+
"css",
|
|
912
|
+
"css-loader",
|
|
913
|
+
"escape-string-regexp",
|
|
914
|
+
"fork-ts-checker-webpack-plugin",
|
|
915
|
+
"global-modules-path",
|
|
916
|
+
"loader-utils",
|
|
917
|
+
"minimatch",
|
|
918
|
+
"@nativescript/hook",
|
|
919
|
+
"nativescript-worker-loader",
|
|
920
|
+
"properties-reader",
|
|
921
|
+
"proxy-lib",
|
|
922
|
+
"raw-loader",
|
|
923
|
+
"resolve-url-loader",
|
|
924
|
+
"sass-loader",
|
|
925
|
+
"sax",
|
|
926
|
+
"schema-utils",
|
|
927
|
+
"semver",
|
|
928
|
+
"shelljs",
|
|
929
|
+
"tapable",
|
|
930
|
+
"terser",
|
|
931
|
+
"terser-webpack-plugin",
|
|
932
|
+
"ts-loader",
|
|
933
|
+
"webpack",
|
|
934
|
+
"webpack-bundle-analyzer",
|
|
935
|
+
"webpack-cli",
|
|
936
|
+
"webpack-sources",
|
|
937
|
+
];
|
|
938
|
+
return webpackDependencies.map((dep) => {
|
|
939
|
+
return {
|
|
940
|
+
packageName: dep,
|
|
941
|
+
shouldRemove: true,
|
|
942
|
+
};
|
|
1010
943
|
});
|
|
1011
944
|
}
|
|
1012
|
-
migrateWebpack5(projectDir, projectData) {
|
|
945
|
+
async migrateWebpack5(projectDir, projectData) {
|
|
1013
946
|
var _a;
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
yield this.$projectCleanupService.clean(["webpack.config.js"]);
|
|
1024
|
-
this.spinner.info(`Initializing new ${color_1.color.yellow("webpack.config.js")}`);
|
|
1025
|
-
const { desiredVersion: webpackVersion } = this.migrationDependencies.find((dep) => dep.packageName === constants.WEBPACK_PLUGIN_NAME);
|
|
1026
|
-
try {
|
|
1027
|
-
const scopedWebpackPackage = `@nativescript/webpack`;
|
|
1028
|
-
const resolvedVersion = yield this.$packageInstallationManager.getMaxSatisfyingVersion(scopedWebpackPackage, webpackVersion);
|
|
1029
|
-
yield this.runNPX([
|
|
1030
|
-
"--package",
|
|
1031
|
-
`${scopedWebpackPackage}@${resolvedVersion}`,
|
|
1032
|
-
"nativescript-webpack",
|
|
1033
|
-
"init",
|
|
1034
|
-
]);
|
|
1035
|
-
this.spinner.succeed(`Initialized new ${color_1.color.yellow("webpack.config.js")}`);
|
|
1036
|
-
}
|
|
1037
|
-
catch (err) {
|
|
1038
|
-
this.spinner.fail(`Failed to initialize ${color_1.color.yellow("webpack.config.js")}`);
|
|
1039
|
-
this.$logger.trace("Failed to initialize webpack.config.js. Error is: ", err);
|
|
1040
|
-
this.$logger.printMarkdown(`You can try again by running \`npm install\` (or yarn, pnpm) and then \`npx @nativescript/webpack init\`.`);
|
|
1041
|
-
}
|
|
1042
|
-
const packageJSON = this.$fs.readJson(projectData.projectFilePath);
|
|
1043
|
-
const currentMain = (_a = packageJSON.main) !== null && _a !== void 0 ? _a : "app.js";
|
|
1044
|
-
const currentMainTS = currentMain.replace(/.js$/, ".ts");
|
|
1045
|
-
const appPath = projectData.appDirectoryPath;
|
|
1046
|
-
const possibleMains = [
|
|
1047
|
-
`./${appPath}/${currentMain}`,
|
|
1048
|
-
`./${appPath}/${currentMainTS}`,
|
|
1049
|
-
`./${appPath}/main.js`,
|
|
1050
|
-
`./${appPath}/main.ts`,
|
|
1051
|
-
`./app/${currentMain}`,
|
|
1052
|
-
`./app/${currentMainTS}`,
|
|
1053
|
-
`./src/${currentMain}`,
|
|
1054
|
-
`./src/${currentMainTS}`,
|
|
1055
|
-
`./app/main.js`,
|
|
1056
|
-
`./app/main.ts`,
|
|
1057
|
-
`./src/main.js`,
|
|
1058
|
-
`./src/main.ts`,
|
|
1059
|
-
].map((possibleMain) => path.resolve(projectDir, possibleMain));
|
|
1060
|
-
let replacedMain = possibleMains.find((possibleMain) => {
|
|
1061
|
-
return this.$fs.exists(possibleMain);
|
|
1062
|
-
});
|
|
1063
|
-
if (replacedMain) {
|
|
1064
|
-
replacedMain = `./${path.relative(projectDir, replacedMain)}`.replace(/\\/g, "/");
|
|
1065
|
-
packageJSON.main = replacedMain;
|
|
1066
|
-
this.$fs.writeJson(projectData.projectFilePath, packageJSON);
|
|
1067
|
-
this.spinner.info(`Updated ${color_1.color.yellow("package.json")} main field to ${color_1.color.green(replacedMain)}`);
|
|
1068
|
-
}
|
|
1069
|
-
else {
|
|
1070
|
-
this.$logger.warn();
|
|
1071
|
-
this.$logger.warn("Note:\n-----");
|
|
1072
|
-
this.$logger.printMarkdown(`Could not determine the correct \`main\` field for \`package.json\`. Make sure to update it manually, pointing to the actual entry file relative to the \`package.json\`.\n`);
|
|
947
|
+
const webpackConfigPath = path.resolve(projectDir, "webpack.config.js");
|
|
948
|
+
if (this.$fs.exists(webpackConfigPath)) {
|
|
949
|
+
const webpackConfigContent = this.$fs.readText(webpackConfigPath);
|
|
950
|
+
if (webpackConfigContent.includes("webpack.init(")) {
|
|
951
|
+
this.spinner.succeed(`Project already using new ${color_1.color.yellow("webpack.config.js")}`);
|
|
952
|
+
return;
|
|
1073
953
|
}
|
|
954
|
+
}
|
|
955
|
+
await this.$projectCleanupService.clean(["webpack.config.js"]);
|
|
956
|
+
this.spinner.info(`Initializing new ${color_1.color.yellow("webpack.config.js")}`);
|
|
957
|
+
const { desiredVersion: webpackVersion } = this.migrationDependencies.find((dep) => dep.packageName === constants.WEBPACK_PLUGIN_NAME);
|
|
958
|
+
try {
|
|
959
|
+
const scopedWebpackPackage = `@nativescript/webpack`;
|
|
960
|
+
const resolvedVersion = await this.$packageInstallationManager.getMaxSatisfyingVersion(scopedWebpackPackage, webpackVersion);
|
|
961
|
+
await this.runNPX([
|
|
962
|
+
"--package",
|
|
963
|
+
`${scopedWebpackPackage}@${resolvedVersion}`,
|
|
964
|
+
"nativescript-webpack",
|
|
965
|
+
"init",
|
|
966
|
+
]);
|
|
967
|
+
this.spinner.succeed(`Initialized new ${color_1.color.yellow("webpack.config.js")}`);
|
|
968
|
+
}
|
|
969
|
+
catch (err) {
|
|
970
|
+
this.spinner.fail(`Failed to initialize ${color_1.color.yellow("webpack.config.js")}`);
|
|
971
|
+
this.$logger.trace("Failed to initialize webpack.config.js. Error is: ", err);
|
|
972
|
+
this.$logger.printMarkdown(`You can try again by running \`npm install\` (or yarn, pnpm) and then \`npx @nativescript/webpack init\`.`);
|
|
973
|
+
}
|
|
974
|
+
const packageJSON = this.$fs.readJson(projectData.projectFilePath);
|
|
975
|
+
const currentMain = (_a = packageJSON.main) !== null && _a !== void 0 ? _a : "app.js";
|
|
976
|
+
const currentMainTS = currentMain.replace(/.js$/, ".ts");
|
|
977
|
+
const appPath = projectData.appDirectoryPath;
|
|
978
|
+
const possibleMains = [
|
|
979
|
+
`./${appPath}/${currentMain}`,
|
|
980
|
+
`./${appPath}/${currentMainTS}`,
|
|
981
|
+
`./${appPath}/main.js`,
|
|
982
|
+
`./${appPath}/main.ts`,
|
|
983
|
+
`./app/${currentMain}`,
|
|
984
|
+
`./app/${currentMainTS}`,
|
|
985
|
+
`./src/${currentMain}`,
|
|
986
|
+
`./src/${currentMainTS}`,
|
|
987
|
+
`./app/main.js`,
|
|
988
|
+
`./app/main.ts`,
|
|
989
|
+
`./src/main.js`,
|
|
990
|
+
`./src/main.ts`,
|
|
991
|
+
].map((possibleMain) => path.resolve(projectDir, possibleMain));
|
|
992
|
+
let replacedMain = possibleMains.find((possibleMain) => {
|
|
993
|
+
return this.$fs.exists(possibleMain);
|
|
1074
994
|
});
|
|
995
|
+
if (replacedMain) {
|
|
996
|
+
replacedMain = `./${path.relative(projectDir, replacedMain)}`.replace(/\\/g, "/");
|
|
997
|
+
packageJSON.main = replacedMain;
|
|
998
|
+
this.$fs.writeJson(projectData.projectFilePath, packageJSON);
|
|
999
|
+
this.spinner.info(`Updated ${color_1.color.yellow("package.json")} main field to ${color_1.color.green(replacedMain)}`);
|
|
1000
|
+
}
|
|
1001
|
+
else {
|
|
1002
|
+
this.$logger.warn();
|
|
1003
|
+
this.$logger.warn("Note:\n-----");
|
|
1004
|
+
this.$logger.printMarkdown(`Could not determine the correct \`main\` field for \`package.json\`. Make sure to update it manually, pointing to the actual entry file relative to the \`package.json\`.\n`);
|
|
1005
|
+
}
|
|
1075
1006
|
}
|
|
1076
|
-
runESLint(projectDir) {
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1087
|
-
});
|
|
1007
|
+
async runESLint(projectDir) {
|
|
1008
|
+
this.spinner.start(`Running ESLint fixes`);
|
|
1009
|
+
try {
|
|
1010
|
+
await this.runNPX(["@nativescript/eslint-plugin", projectDir]);
|
|
1011
|
+
this.spinner.succeed(`Applied ESLint fixes`);
|
|
1012
|
+
}
|
|
1013
|
+
catch (err) {
|
|
1014
|
+
this.spinner.fail(`Failed to apply ESLint fixes`);
|
|
1015
|
+
this.$logger.trace("Failed to apply ESLint fixes. Error is:", err);
|
|
1016
|
+
}
|
|
1088
1017
|
}
|
|
1089
|
-
runNPX(args = []) {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
yield this.$childProcess.exec(args_.join(" "));
|
|
1098
|
-
});
|
|
1018
|
+
async runNPX(args = []) {
|
|
1019
|
+
const npxVersion = await this.$childProcess.exec("npx -v");
|
|
1020
|
+
const npxFlags = [];
|
|
1021
|
+
if (semver.gt(semver.coerce(npxVersion), "7.0.0")) {
|
|
1022
|
+
npxFlags.push("-y");
|
|
1023
|
+
}
|
|
1024
|
+
const args_ = ["npx", ...npxFlags, ...args];
|
|
1025
|
+
await this.$childProcess.exec(args_.join(" "));
|
|
1099
1026
|
}
|
|
1100
1027
|
}
|
|
1028
|
+
exports.MigrateController = MigrateController;
|
|
1101
1029
|
MigrateController.backupFolderName = ".migration_backup";
|
|
1102
1030
|
MigrateController.pathsToBackup = [
|
|
1103
1031
|
constants.LIB_DIR_NAME,
|
|
@@ -1109,5 +1037,4 @@ MigrateController.pathsToBackup = [
|
|
|
1109
1037
|
constants.KARMA_CONFIG_NAME,
|
|
1110
1038
|
constants.CONFIG_NS_FILE_NAME,
|
|
1111
1039
|
];
|
|
1112
|
-
exports.MigrateController = MigrateController;
|
|
1113
1040
|
yok_1.injector.register("migrateController", MigrateController);
|