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