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