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