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