nativescript 9.0.0-alpha.2 → 9.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/android-tools-info.js +12 -0
- package/lib/base-package-manager.js +7 -0
- package/lib/bootstrap.js +5 -1
- package/lib/bun-package-manager.js +14 -1
- package/lib/color.js +3 -0
- package/lib/commands/add-platform.js +1 -0
- package/lib/commands/apple-login.js +1 -0
- package/lib/commands/appstore-list.js +1 -0
- package/lib/commands/appstore-upload.js +3 -0
- package/lib/commands/build.js +3 -2
- package/lib/commands/clean.js +22 -1
- package/lib/commands/command-base.js +1 -0
- package/lib/commands/config.js +4 -0
- package/lib/commands/create-project.js +6 -0
- package/lib/commands/debug.js +6 -1
- package/lib/commands/deploy.js +3 -2
- package/lib/commands/embedding/embed.js +7 -0
- package/lib/commands/extensibility/install-extension.js +1 -0
- package/lib/commands/extensibility/list-extensions.js +1 -0
- package/lib/commands/extensibility/uninstall-extension.js +1 -0
- package/lib/commands/fonts.js +1 -0
- package/lib/commands/generate-assets.js +1 -0
- package/lib/commands/generate-help.js +1 -0
- package/lib/commands/generate.js +48 -1
- package/lib/commands/info.js +1 -0
- package/lib/commands/install.js +1 -0
- package/lib/commands/list-platforms.js +1 -0
- package/lib/commands/migrate.js +1 -0
- package/lib/commands/native-add.js +5 -0
- package/lib/commands/platform-clean.js +1 -0
- package/lib/commands/plugin/add-plugin.js +1 -0
- package/lib/commands/plugin/build-plugin.js +1 -0
- package/lib/commands/plugin/create-plugin.js +5 -0
- package/lib/commands/plugin/list-plugins.js +1 -0
- package/lib/commands/plugin/remove-plugin.js +2 -0
- package/lib/commands/plugin/update-plugin.js +1 -0
- package/lib/commands/post-install.js +6 -0
- package/lib/commands/prepare.js +4 -3
- package/lib/commands/preview.js +2 -0
- package/lib/commands/remove-platform.js +1 -0
- package/lib/commands/resources/resources-update.js +2 -0
- package/lib/commands/run.js +1 -0
- package/lib/commands/setup.js +1 -0
- package/lib/commands/start.js +1 -0
- package/lib/commands/test-init.js +4 -0
- package/lib/commands/test.js +9 -2
- package/lib/commands/typings.js +2 -1
- package/lib/commands/update-platform.js +5 -0
- package/lib/commands/update.js +2 -0
- package/lib/commands/widget.js +20 -1
- package/lib/common/bootstrap.js +1 -0
- package/lib/common/child-process.js +3 -0
- package/lib/common/codeGeneration/code-entity.js +1 -0
- package/lib/common/codeGeneration/code-printer.js +1 -0
- package/lib/common/command-params.js +1 -0
- package/lib/common/commands/analytics.js +3 -0
- package/lib/common/commands/autocompletion.js +3 -0
- package/lib/common/commands/device/device-log-stream.js +1 -0
- package/lib/common/commands/device/get-file.js +2 -0
- package/lib/common/commands/device/list-applications.js +1 -0
- package/lib/common/commands/device/list-devices.js +3 -0
- package/lib/common/commands/device/list-files.js +2 -0
- package/lib/common/commands/device/put-file.js +2 -0
- package/lib/common/commands/device/run-application.js +1 -0
- package/lib/common/commands/device/stop-application.js +1 -0
- package/lib/common/commands/device/uninstall-application.js +1 -0
- package/lib/common/commands/doctor.js +3 -2
- package/lib/common/commands/generate-messages.js +1 -0
- package/lib/common/commands/help.js +1 -0
- package/lib/common/commands/package-manager-get.js +1 -0
- package/lib/common/commands/package-manager-set.js +1 -0
- package/lib/common/commands/post-install.js +1 -0
- package/lib/common/commands/preuninstall.js +11 -2
- package/lib/common/commands/proxy/proxy-base.js +4 -0
- package/lib/common/commands/proxy/proxy-clear.js +1 -0
- package/lib/common/commands/proxy/proxy-get.js +1 -0
- package/lib/common/commands/proxy/proxy-set.js +1 -0
- package/lib/common/common-lib.js +1 -0
- package/lib/common/constants.js +11 -0
- package/lib/common/decorators.js +48 -0
- package/lib/common/dispatchers.js +10 -1
- package/lib/common/errors.js +13 -3
- package/lib/common/file-system.js +13 -2
- package/lib/common/header.js +3 -0
- package/lib/common/helpers.js +89 -3
- package/lib/common/host-info.js +4 -0
- package/lib/common/http-client.js +20 -0
- package/lib/common/logger/appenders/cli-appender.js +4 -0
- package/lib/common/logger/appenders/emit-appender.js +4 -0
- package/lib/common/logger/layouts/cli-layout.js +1 -0
- package/lib/common/logger/logger.js +5 -0
- package/lib/common/messages/messages.js +6 -0
- package/lib/common/mobile/android/android-application-manager.js +20 -1
- package/lib/common/mobile/android/android-debug-bridge-result-handler.js +1 -0
- package/lib/common/mobile/android/android-debug-bridge.js +6 -0
- package/lib/common/mobile/android/android-device-file-system.js +4 -0
- package/lib/common/mobile/android/android-device-hash-service.js +3 -0
- package/lib/common/mobile/android/android-device.js +8 -0
- package/lib/common/mobile/android/android-emulator-services.js +11 -8
- package/lib/common/mobile/android/android-ini-file-parser.js +9 -0
- package/lib/common/mobile/android/android-log-filter.js +4 -0
- package/lib/common/mobile/android/android-virtual-device-service.js +26 -0
- package/lib/common/mobile/android/device-android-debug-bridge.js +1 -0
- package/lib/common/mobile/android/genymotion/genymotion-service.js +6 -1
- package/lib/common/mobile/android/genymotion/virtualbox-service.js +11 -0
- package/lib/common/mobile/android/logcat-helper.js +13 -0
- package/lib/common/mobile/application-manager-base.js +6 -0
- 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 +1 -0
- 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 +4 -0
- package/lib/common/mobile/ios/device/ios-application-manager.js +3 -0
- package/lib/common/mobile/ios/device/ios-device-file-system.js +1 -0
- package/lib/common/mobile/ios/device/ios-device-operations.js +4 -0
- package/lib/common/mobile/ios/device/ios-device.js +4 -0
- package/lib/common/mobile/ios/ios-device-base.js +1 -0
- 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 +4 -0
- package/lib/common/mobile/ios/simulator/ios-sim-resolver.js +1 -0
- package/lib/common/mobile/ios/simulator/ios-simulator-application-manager.js +6 -0
- package/lib/common/mobile/ios/simulator/ios-simulator-device.js +5 -0
- package/lib/common/mobile/ios/simulator/ios-simulator-file-system.js +1 -0
- package/lib/common/mobile/ios/simulator/ios-simulator-log-provider.js +1 -0
- 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 +2 -0
- package/lib/common/mobile/mobile-core/android-emulator-discovery.js +3 -0
- package/lib/common/mobile/mobile-core/android-process-service.js +32 -0
- package/lib/common/mobile/mobile-core/device-discovery.js +1 -0
- package/lib/common/mobile/mobile-core/devices-service.js +69 -0
- package/lib/common/mobile/mobile-core/ios-device-discovery.js +2 -0
- package/lib/common/mobile/mobile-core/ios-simulator-discovery.js +3 -0
- package/lib/common/mobile/mobile-helper.js +1 -0
- package/lib/common/mobile/wp8/wp8-emulator-services.js +1 -0
- package/lib/common/opener.js +1 -0
- 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 +9 -1
- package/lib/common/queue.js +1 -0
- package/lib/common/resource-loader.js +1 -0
- package/lib/common/services/auto-completion-service.js +13 -1
- package/lib/common/services/cancellation.js +2 -1
- package/lib/common/services/commands-service.js +17 -6
- package/lib/common/services/help-service.js +11 -3
- package/lib/common/services/hooks-service.js +14 -1
- package/lib/common/services/ios-notification-service.js +1 -0
- package/lib/common/services/json-file-settings-service.js +6 -0
- package/lib/common/services/lock-service.js +6 -0
- package/lib/common/services/message-contract-generator.js +1 -0
- package/lib/common/services/messages-service.js +1 -0
- package/lib/common/services/micro-templating-service.js +6 -0
- package/lib/common/services/net-service.js +3 -0
- package/lib/common/services/project-files-manager.js +5 -0
- package/lib/common/services/project-files-provider-base.js +1 -0
- package/lib/common/services/proxy-service.js +1 -0
- package/lib/common/services/qr.js +1 -0
- package/lib/common/services/settings-service.js +1 -0
- package/lib/common/services/xcode-select-service.js +1 -0
- package/lib/common/utils.js +1 -0
- package/lib/common/validators/project-name-validator.js +1 -0
- package/lib/common/validators/validation-result.js +1 -0
- package/lib/common/verify-node-version.js +8 -1
- package/lib/common/yok.js +32 -11
- package/lib/config.js +22 -1
- package/lib/constants-provider.js +1 -0
- package/lib/constants.js +53 -0
- package/lib/controllers/build-controller.js +4 -3
- package/lib/controllers/debug-controller.js +8 -3
- package/lib/controllers/deploy-controller.js +1 -0
- package/lib/controllers/migrate-controller.js +90 -4
- package/lib/controllers/platform-controller.js +9 -1
- package/lib/controllers/prepare-controller.js +17 -4
- package/lib/controllers/run-controller.js +17 -1
- package/lib/controllers/update-controller-base.js +1 -0
- package/lib/controllers/update-controller.js +11 -0
- 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 +1 -0
- package/lib/data/run-data.js +1 -0
- package/lib/detached-processes/cleanup-js-subprocess.js +8 -2
- package/lib/detached-processes/cleanup-process.js +18 -14
- package/lib/detached-processes/file-log-service.js +2 -1
- package/lib/device-path-provider.js +1 -0
- package/lib/device-sockets/ios/app-debug-socket-proxy-factory.js +7 -0
- package/lib/device-sockets/ios/notification.js +3 -0
- package/lib/device-sockets/ios/socket-request-executor.js +3 -0
- package/lib/helpers/android-bundle-validator-helper.js +2 -1
- package/lib/helpers/deploy-command-helper.js +1 -0
- package/lib/helpers/key-command-helper.js +4 -2
- package/lib/helpers/livesync-command-helper.js +4 -1
- package/lib/helpers/network-connectivity-validator.js +1 -0
- package/lib/helpers/options-track-helper.js +3 -2
- package/lib/helpers/package-path-helper.js +1 -0
- package/lib/helpers/platform-command-helper.js +7 -2
- package/lib/helpers/version-validator-helper.js +1 -0
- package/lib/key-commands/bootstrap.js +3 -2
- package/lib/key-commands/index.js +5 -4
- package/lib/nativescript-cli-lib-bootstrap.js +4 -0
- package/lib/nativescript-cli-lib.js +1 -0
- package/lib/nativescript-cli.js +10 -1
- package/lib/node/pbxproj-dom-xcode.js +1 -0
- package/lib/node/xcode.js +1 -0
- package/lib/node-package-manager.js +11 -1
- package/lib/options.js +144 -119
- package/lib/package-installation-manager.js +8 -1
- package/lib/package-manager.js +2 -0
- package/lib/platform-command-param.js +1 -0
- package/lib/pnpm-package-manager.js +4 -1
- package/lib/project-data.js +12 -0
- package/lib/providers/project-files-provider.js +1 -0
- package/lib/resolvers/livesync-service-resolver.js +1 -0
- package/lib/services/analytics/analytics-broker-process.js +10 -6
- package/lib/services/analytics/analytics-broker.js +2 -1
- package/lib/services/analytics/analytics-service.js +29 -25
- package/lib/services/analytics/google-analytics-provider.js +13 -12
- package/lib/services/analytics-settings-service.js +5 -0
- package/lib/services/android/android-bundle-tool-service.js +1 -0
- package/lib/services/android/gradle-build-args-service.js +3 -0
- package/lib/services/android/gradle-build-service.js +1 -0
- package/lib/services/android/gradle-command-service.js +1 -0
- package/lib/services/android-device-debug-service.js +6 -0
- package/lib/services/android-plugin-build-service.js +31 -2
- package/lib/services/android-project-service.js +71 -4
- package/lib/services/android-resources-migration-service.js +7 -0
- package/lib/services/apple-portal/apple-portal-application-service.js +1 -0
- package/lib/services/apple-portal/apple-portal-cookie-service.js +1 -0
- package/lib/services/apple-portal/apple-portal-session-service.js +6 -4
- package/lib/services/apple-portal/srp/srp-wrapper.js +4 -1
- package/lib/services/assets-generation/assets-generation-service.js +10 -5
- package/lib/services/build-artifacts-service.js +2 -1
- package/lib/services/build-data-service.js +1 -0
- package/lib/services/build-info-file-service.js +1 -0
- package/lib/services/bundler/bundler-compiler-service.js +45 -1
- package/lib/services/bundler/bundler.js +1 -0
- package/lib/services/cleanup-service.js +13 -9
- package/lib/services/cocoapods-platform-manager.js +9 -0
- package/lib/services/cocoapods-service.js +21 -1
- 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 +2 -1
- package/lib/services/doctor-service.js +21 -6
- package/lib/services/extensibility-service.js +8 -0
- package/lib/services/files-hash-service.js +1 -0
- package/lib/services/hmr-status-service.js +2 -0
- package/lib/services/info-service.js +1 -0
- package/lib/services/initialize-service.js +5 -1
- package/lib/services/ios/export-options-plist-service.js +4 -0
- package/lib/services/ios/ios-signing-service.js +4 -0
- package/lib/services/ios/spm-service.js +11 -0
- package/lib/services/ios/xcodebuild-args-service.js +9 -0
- package/lib/services/ios/xcodebuild-command-service.js +1 -0
- package/lib/services/ios/xcodebuild-service.js +2 -1
- package/lib/services/ios-debugger-port-service.js +1 -0
- package/lib/services/ios-device-debug-service.js +1 -0
- package/lib/services/ios-entitlements-service.js +1 -0
- package/lib/services/ios-extensions-service.js +1 -0
- 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 +91 -1
- package/lib/services/ios-provision-service.js +3 -0
- package/lib/services/ios-watch-app-service.js +1 -0
- package/lib/services/ip-service.js +2 -0
- package/lib/services/itmstransporter-service.js +1 -0
- package/lib/services/karma-execution.js +2 -0
- package/lib/services/livesync/android-device-livesync-service-base.js +1 -0
- package/lib/services/livesync/android-device-livesync-service.js +2 -0
- package/lib/services/livesync/android-device-livesync-sockets-service.js +3 -0
- package/lib/services/livesync/android-livesync-service.js +1 -0
- package/lib/services/livesync/android-livesync-tool.js +4 -0
- package/lib/services/livesync/device-livesync-service-base.js +2 -0
- package/lib/services/livesync/ios-device-livesync-service.js +7 -0
- package/lib/services/livesync/ios-livesync-service.js +2 -0
- package/lib/services/livesync/livesync-socket.js +1 -0
- package/lib/services/livesync/platform-livesync-service-base.js +5 -0
- package/lib/services/livesync-process-data-service.js +1 -0
- package/lib/services/log-parser-service.js +1 -0
- package/lib/services/log-source-map-service.js +15 -0
- package/lib/services/marking-mode-service.js +8 -5
- package/lib/services/metadata-filtering-service.js +1 -0
- package/lib/services/npm-config-service.js +4 -0
- package/lib/services/pacote-service.js +7 -0
- package/lib/services/performance-service.js +3 -1
- package/lib/services/platform/add-platform-service.js +49 -2
- package/lib/services/platform/platform-validation-service.js +1 -0
- package/lib/services/platform/prepare-native-platform-service.js +5 -2
- package/lib/services/platform-environment-requirements.js +8 -3
- 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 +20 -2
- package/lib/services/prepare-data-service.js +1 -0
- package/lib/services/project-backup-service.js +4 -0
- package/lib/services/project-changes-service.js +14 -3
- package/lib/services/project-cleanup-service.js +2 -0
- package/lib/services/project-config-service.js +21 -2
- package/lib/services/project-data-service.js +36 -7
- package/lib/services/project-name-service.js +1 -0
- package/lib/services/project-service.js +10 -0
- package/lib/services/project-templates-service.js +3 -2
- package/lib/services/qr-code-terminal-service.js +1 -0
- package/lib/services/require-service.js +1 -0
- package/lib/services/start-service.js +1 -0
- package/lib/services/temp-service.js +1 -0
- package/lib/services/terminal-spinner-service.js +2 -0
- package/lib/services/test-execution-service.js +9 -2
- package/lib/services/test-initialization-service.js +4 -0
- package/lib/services/timeline-profiler-service.js +1 -0
- package/lib/services/user-settings-service.js +1 -0
- package/lib/services/versions-service.js +6 -4
- package/lib/services/watch-ignore-list-service.js +1 -0
- package/lib/services/xcconfig-service.js +2 -0
- package/lib/services/xcproj-service.js +1 -0
- package/lib/shared-event-bus.js +6 -0
- package/lib/sys-info.js +2 -1
- package/lib/tools/config-manipulation/config-transformer.js +12 -0
- package/lib/tools/node-modules/node-modules-builder.js +1 -0
- package/lib/tools/node-modules/node-modules-dependencies-builder.js +6 -0
- package/lib/yarn-package-manager.js +1 -0
- package/lib/yarn2-package-manager.js +3 -0
- package/package.json +6 -4
|
@@ -35,7 +35,7 @@ class BuildController extends events_1.EventEmitter {
|
|
|
35
35
|
const platform = buildData.platform.toLowerCase();
|
|
36
36
|
const projectData = this.$projectDataService.getProjectData(buildData.projectDir);
|
|
37
37
|
const platformData = this.$platformsDataService.getPlatformData(platform, projectData);
|
|
38
|
-
const action = "Build"
|
|
38
|
+
const action = "Build" /* constants.TrackActionNames.Build */;
|
|
39
39
|
const isForDevice = this.$mobileHelper.isAndroidPlatform(platform)
|
|
40
40
|
? null
|
|
41
41
|
: buildData && buildData.buildForDevice;
|
|
@@ -45,8 +45,8 @@ class BuildController extends events_1.EventEmitter {
|
|
|
45
45
|
platform,
|
|
46
46
|
projectDir: projectData.projectDir,
|
|
47
47
|
additionalData: `${buildData.release ? constants_1.Configurations.Release : constants_1.Configurations.Debug}_${buildData.clean
|
|
48
|
-
? "Clean"
|
|
49
|
-
: "Incremental"}`,
|
|
48
|
+
? "Clean" /* constants.BuildStates.Clean */
|
|
49
|
+
: "Incremental" /* constants.BuildStates.Incremental */}`,
|
|
50
50
|
});
|
|
51
51
|
if (buildData.clean) {
|
|
52
52
|
await platformData.platformProjectService.cleanProject(platformData.projectRoot);
|
|
@@ -114,3 +114,4 @@ class BuildController extends events_1.EventEmitter {
|
|
|
114
114
|
}
|
|
115
115
|
exports.BuildController = BuildController;
|
|
116
116
|
yok_1.injector.register("buildController", BuildController);
|
|
117
|
+
//# sourceMappingURL=build-controller.js.map
|
|
@@ -40,13 +40,13 @@ class DebugController extends events_1.EventEmitter {
|
|
|
40
40
|
this.$errors.fail(`The device with identifier ${debugData.deviceIdentifier} is unreachable. Make sure it is Trusted and try again.`);
|
|
41
41
|
}
|
|
42
42
|
await this.$analyticsService.trackEventActionInGoogleAnalytics({
|
|
43
|
-
action: "Debug"
|
|
43
|
+
action: "Debug" /* TrackActionNames.Debug */,
|
|
44
44
|
device,
|
|
45
45
|
additionalData: this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform) &&
|
|
46
46
|
options &&
|
|
47
47
|
options.inspector
|
|
48
|
-
? "Inspector"
|
|
49
|
-
: "Chrome"
|
|
48
|
+
? "Inspector" /* DebugTools.Inspector */
|
|
49
|
+
: "Chrome" /* DebugTools.Chrome */,
|
|
50
50
|
projectDir: debugData.projectDir,
|
|
51
51
|
});
|
|
52
52
|
if (!(await device.applicationManager.isApplicationInstalled(debugData.applicationIdentifier))) {
|
|
@@ -87,6 +87,7 @@ class DebugController extends events_1.EventEmitter {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
async attachDebugger(attachDebuggerData) {
|
|
90
|
+
// Default values
|
|
90
91
|
if (attachDebuggerData.debugOptions) {
|
|
91
92
|
attachDebuggerData.debugOptions.chrome =
|
|
92
93
|
attachDebuggerData.debugOptions.chrome === undefined
|
|
@@ -105,6 +106,9 @@ class DebugController extends events_1.EventEmitter {
|
|
|
105
106
|
}
|
|
106
107
|
const projectData = this.$projectDataService.getProjectData(attachDebuggerData.projectDir);
|
|
107
108
|
const debugData = this.$debugDataService.getDebugData(attachDebuggerData.deviceIdentifier, projectData, attachDebuggerData.debugOptions);
|
|
109
|
+
// const platformData = this.$platformsDataService.getPlatformData(settings.platform, projectData);
|
|
110
|
+
// Of the properties below only `buildForDevice` and `release` are currently used.
|
|
111
|
+
// Leaving the others with placeholder values so that they may not be forgotten in future implementations.
|
|
108
112
|
const debugInfo = await this.startDebug(debugData);
|
|
109
113
|
const result = this.printDebugInformation(debugInfo, attachDebuggerData.debugOptions.forceDebuggerAttachedEvent);
|
|
110
114
|
return result;
|
|
@@ -212,3 +216,4 @@ __decorate([
|
|
|
212
216
|
(0, decorators_1.performanceLog)()
|
|
213
217
|
], DebugController.prototype, "enableDebuggingCoreWithoutWaitingCurrentAction", null);
|
|
214
218
|
yok_1.injector.register("debugController", DebugController);
|
|
219
|
+
//# sourceMappingURL=debug-controller.js.map
|
|
@@ -12,8 +12,12 @@ const helpers_1 = require("../common/helpers");
|
|
|
12
12
|
const yok_1 = require("../common/yok");
|
|
13
13
|
const temp = require("temp");
|
|
14
14
|
const color_1 = require("../color");
|
|
15
|
+
// const wait: (ms: number) => Promise<void> = (ms: number = 1000) =>
|
|
16
|
+
// new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
17
|
class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
16
|
-
constructor($fs, $platformCommandHelper, $platformsDataService, $packageInstallationManager, $packageManager, $pacoteService,
|
|
18
|
+
constructor($fs, $platformCommandHelper, $platformsDataService, $packageInstallationManager, $packageManager, $pacoteService,
|
|
19
|
+
// private $androidResourcesMigrationService: IAndroidResourcesMigrationService,
|
|
20
|
+
$logger, $errors, $pluginsService, $projectDataService, $projectConfigService, $options, $resources, $injector, $settingsService, $staticConfig, $terminalSpinnerService, $projectCleanupService, $projectBackupService, $childProcess) {
|
|
17
21
|
super($fs, $platformCommandHelper, $platformsDataService, $packageInstallationManager, $packageManager, $pacoteService);
|
|
18
22
|
this.$fs = $fs;
|
|
19
23
|
this.$platformCommandHelper = $platformCommandHelper;
|
|
@@ -151,15 +155,18 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
151
155
|
{
|
|
152
156
|
packageName: "node-sass",
|
|
153
157
|
replaceWith: "sass",
|
|
154
|
-
minVersion: "0.0.0",
|
|
158
|
+
minVersion: "0.0.0", // ignore
|
|
155
159
|
isDev: true,
|
|
160
|
+
// shouldRemove: true,
|
|
156
161
|
},
|
|
157
162
|
{
|
|
158
163
|
packageName: "sass",
|
|
159
|
-
minVersion: "0.0.0",
|
|
164
|
+
minVersion: "0.0.0", // ignore
|
|
160
165
|
desiredVersion: "^1.49.9",
|
|
161
166
|
isDev: true,
|
|
167
|
+
// shouldRemove: true,
|
|
162
168
|
},
|
|
169
|
+
// runtimes
|
|
163
170
|
{
|
|
164
171
|
packageName: "tns-ios",
|
|
165
172
|
minVersion: "6.5.3",
|
|
@@ -202,8 +209,10 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
202
209
|
remainingPlatforms.push(platform);
|
|
203
210
|
continue;
|
|
204
211
|
}
|
|
212
|
+
// should only run in loose mode...
|
|
205
213
|
const cachedResult = await this.getCachedShouldMigrate(projectDir, platform);
|
|
206
214
|
this.$logger.trace(`Got cached result for shouldMigrate for platform: ${platform}: ${cachedResult}`);
|
|
215
|
+
// the cached result is only used if it's false, otherwise we need to check again
|
|
207
216
|
if (cachedResult !== false) {
|
|
208
217
|
remainingPlatforms.push(platform);
|
|
209
218
|
}
|
|
@@ -215,6 +224,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
215
224
|
loose,
|
|
216
225
|
});
|
|
217
226
|
this.$logger.trace(`Executed shouldMigrate for platforms: ${remainingPlatforms}. Result is: ${shouldMigrate}`);
|
|
227
|
+
// only cache results if running in loose mode
|
|
218
228
|
if (!shouldMigrate && loose) {
|
|
219
229
|
for (const remainingPlatform of remainingPlatforms) {
|
|
220
230
|
await this.setCachedShouldMigrate(projectDir, remainingPlatform);
|
|
@@ -241,37 +251,46 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
241
251
|
platforms,
|
|
242
252
|
loose: loose,
|
|
243
253
|
});
|
|
254
|
+
// ensure in git repo and require --force if not (for safety)
|
|
255
|
+
// ensure git branch is clean
|
|
244
256
|
const canMigrate = await this.ensureGitCleanOrForce(projectDir);
|
|
245
257
|
if (!canMigrate) {
|
|
246
258
|
this.spinner.fail("Pre-Migration verification failed");
|
|
247
259
|
return;
|
|
248
260
|
}
|
|
249
261
|
this.spinner.succeed("Pre-Migration verification complete");
|
|
262
|
+
// back up project files and folders
|
|
250
263
|
this.spinner.info("Backing up project files before migration");
|
|
251
264
|
const backup = await this.backupProject(projectDir);
|
|
252
265
|
this.spinner.succeed("Project files have been backed up");
|
|
266
|
+
// clean up project files
|
|
253
267
|
this.spinner.info("Cleaning up project files before migration");
|
|
254
268
|
await this.cleanUpProject(projectData);
|
|
255
269
|
this.spinner.succeed("Project files have been cleaned up");
|
|
270
|
+
// clean up artifacts
|
|
256
271
|
this.spinner.info("Cleaning up old artifacts");
|
|
257
272
|
await this.handleAutoGeneratedFiles(backup, projectData);
|
|
258
273
|
this.spinner.succeed("Cleaned old artifacts");
|
|
259
274
|
const newConfigPath = path.resolve(projectDir, "nativescript.config.ts");
|
|
260
275
|
if (!this.$fs.exists(newConfigPath)) {
|
|
276
|
+
// migrate configs
|
|
261
277
|
this.spinner.info(`Migrating project to use ${color_1.color.green("nativescript.config.ts")}`);
|
|
262
278
|
await this.migrateConfigs(projectDir);
|
|
263
279
|
this.spinner.succeed(`Project has been migrated to use ${color_1.color.green("nativescript.config.ts")}`);
|
|
264
280
|
}
|
|
281
|
+
// update dependencies
|
|
265
282
|
this.spinner.info("Updating project dependencies");
|
|
266
283
|
await this.migrateDependencies(projectData, platforms, loose);
|
|
267
284
|
this.spinner.succeed("Project dependencies have been updated");
|
|
268
285
|
const isAngular = this.hasDependency({
|
|
269
286
|
packageName: "@nativescript/angular",
|
|
270
287
|
}, projectData);
|
|
288
|
+
// ensure polyfills.ts exists in angular projects
|
|
271
289
|
let polyfillsPath;
|
|
272
290
|
if (isAngular) {
|
|
273
291
|
polyfillsPath = await this.checkOrCreatePolyfillsTS(projectData);
|
|
274
292
|
}
|
|
293
|
+
// update tsconfig
|
|
275
294
|
const tsConfigPath = path.resolve(projectDir, "tsconfig.json");
|
|
276
295
|
if (this.$fs.exists(tsConfigPath)) {
|
|
277
296
|
this.spinner.info(`Updating ${color_1.color.yellow("tsconfig.json")}`);
|
|
@@ -283,11 +302,19 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
283
302
|
this.spinner.succeed(`Updated ${color_1.color.yellow("tsconfig.json")}`);
|
|
284
303
|
}
|
|
285
304
|
await this.migrateWebpack5(projectDir, projectData);
|
|
305
|
+
// run @nativescript/eslint over codebase
|
|
286
306
|
await this.runESLint(projectDir);
|
|
287
307
|
this.spinner.succeed("Migration complete.");
|
|
288
308
|
this.$logger.info("");
|
|
289
309
|
this.$logger.printMarkdown("Project has been successfully migrated. The next step is to run `ns run <platform>` to ensure everything is working properly." +
|
|
290
310
|
"\n\nPlease note that you may need additional changes to complete the migration.");
|
|
311
|
+
// print markdown for next steps:
|
|
312
|
+
// if no runtime has been added, print a message that it will be added when they run ns run <platform>
|
|
313
|
+
// if all is good, run ns migrate clean to clean up backup folders
|
|
314
|
+
// in case of failure, print diagnostic data: what failed and why
|
|
315
|
+
// restore all files - or perhaps let the user sort it out
|
|
316
|
+
// or ns migrate restore - to restore from pre-migration backup
|
|
317
|
+
// for some known cases, print suggestions perhaps
|
|
291
318
|
}
|
|
292
319
|
async _shouldMigrate({ projectDir, platforms, loose, }) {
|
|
293
320
|
const isMigrate = _.get(this.$options, "argv._[0]") === "migrate";
|
|
@@ -304,6 +331,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
304
331
|
if (dependency.shouldAddIfMissing) {
|
|
305
332
|
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' is missing.`);
|
|
306
333
|
if (loose) {
|
|
334
|
+
// in loose mode we ignore missing dependencies
|
|
307
335
|
continue;
|
|
308
336
|
}
|
|
309
337
|
return true;
|
|
@@ -319,6 +347,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
319
347
|
}
|
|
320
348
|
if (dependency.replaceWith || dependency.shouldRemove) {
|
|
321
349
|
this.$logger.trace(`${shouldMigrateCommonMessage}'${dependency.packageName}' is deprecated.`);
|
|
350
|
+
// in loose mode we ignore deprecated dependencies
|
|
322
351
|
if (loose) {
|
|
323
352
|
continue;
|
|
324
353
|
}
|
|
@@ -361,11 +390,32 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
361
390
|
const projectPackageJsonFilePath = path.join(projectDir, constants.PACKAGE_JSON_FILE_NAME);
|
|
362
391
|
return await this.$fs.getFileShasum(projectPackageJsonFilePath);
|
|
363
392
|
}
|
|
393
|
+
// private async migrateOldAndroidAppResources(
|
|
394
|
+
// projectData: IProjectData,
|
|
395
|
+
// backupDir: string
|
|
396
|
+
// ) {
|
|
397
|
+
// const appResourcesPath = projectData.getAppResourcesDirectoryPath();
|
|
398
|
+
// if (!this.$androidResourcesMigrationService.hasMigrated(appResourcesPath)) {
|
|
399
|
+
// this.spinner.info("Migrate old Android App_Resources structure.");
|
|
400
|
+
// try {
|
|
401
|
+
// await this.$androidResourcesMigrationService.migrate(
|
|
402
|
+
// appResourcesPath,
|
|
403
|
+
// backupDir
|
|
404
|
+
// );
|
|
405
|
+
// } catch (error) {
|
|
406
|
+
// this.$logger.warn(
|
|
407
|
+
// "Migrate old Android App_Resources structure failed: ",
|
|
408
|
+
// error.message
|
|
409
|
+
// );
|
|
410
|
+
// }
|
|
411
|
+
// }
|
|
412
|
+
// }
|
|
364
413
|
async ensureGitCleanOrForce(projectDir) {
|
|
365
414
|
const git = (0, simple_git_1.default)(projectDir);
|
|
366
415
|
const isGit = await git.checkIsRepo();
|
|
367
416
|
const isForce = this.$options.force;
|
|
368
417
|
if (!isGit) {
|
|
418
|
+
// not a git repo and no --force
|
|
369
419
|
if (!isForce) {
|
|
370
420
|
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
421
|
this.$errors.fail("Not in Git repo.");
|
|
@@ -412,6 +462,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
412
462
|
const { dependencies, devDependencies } = await this.$pluginsService.getDependenciesFromPackageJson(projectData.projectDir);
|
|
413
463
|
const hasSchematics = [...dependencies, ...devDependencies].find((p) => p.name === "@nativescript/schematics");
|
|
414
464
|
if (!hasSchematics) {
|
|
465
|
+
// clean tsconfig.tns.json if not in a shared project
|
|
415
466
|
await this.$projectCleanupService.clean([
|
|
416
467
|
constants.TSCCONFIG_TNS_JSON_NAME,
|
|
417
468
|
]);
|
|
@@ -458,12 +509,14 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
458
509
|
});
|
|
459
510
|
}
|
|
460
511
|
isOutdatedVersion(current, target, loose) {
|
|
512
|
+
// in loose mode, a falsy version is not considered outdated
|
|
461
513
|
if (!current && loose) {
|
|
462
514
|
return false;
|
|
463
515
|
}
|
|
464
516
|
const installed = semver.coerce(current);
|
|
465
517
|
const min = semver.coerce(target.minVersion);
|
|
466
518
|
const desired = semver.coerce(target.desiredVersion);
|
|
519
|
+
// in loose mode we check if we satisfy the min version
|
|
467
520
|
if (loose) {
|
|
468
521
|
if (!installed || !min) {
|
|
469
522
|
return false;
|
|
@@ -473,6 +526,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
473
526
|
if (!installed || !desired) {
|
|
474
527
|
return true;
|
|
475
528
|
}
|
|
529
|
+
// otherwise we compare with the desired version
|
|
476
530
|
return semver.lt(installed, desired);
|
|
477
531
|
}
|
|
478
532
|
detectAppPath(projectDir, configData) {
|
|
@@ -535,6 +589,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
535
589
|
async migrateDependency(dependency, projectData, loose) {
|
|
536
590
|
var _a, _b, _c, _d, _e;
|
|
537
591
|
const hasDependency = this.hasDependency(dependency, projectData);
|
|
592
|
+
// show warning if needed
|
|
538
593
|
if (hasDependency && dependency.warning) {
|
|
539
594
|
this.$logger.warn(dependency.warning);
|
|
540
595
|
}
|
|
@@ -550,7 +605,9 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
550
605
|
return;
|
|
551
606
|
}
|
|
552
607
|
if (dependency.replaceWith || dependency.shouldRemove) {
|
|
608
|
+
// remove
|
|
553
609
|
this.$pluginsService.removeFromPackageJson(dependency.packageName, projectData.projectDir);
|
|
610
|
+
// no replacement required - we're done
|
|
554
611
|
if (!dependency.replaceWith) {
|
|
555
612
|
return;
|
|
556
613
|
}
|
|
@@ -559,6 +616,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
559
616
|
this.$errors.fail("Failed to find replacement dependency.");
|
|
560
617
|
}
|
|
561
618
|
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;
|
|
619
|
+
// add replacement dependency
|
|
562
620
|
this.$pluginsService.addToPackageJson(replacementDep.packageName, version, replacementDep.isDev, projectData.projectDir);
|
|
563
621
|
this.spinner.clear();
|
|
564
622
|
this.$logger.info(` - ${color_1.color.yellow(dependency.packageName)} has been replaced with ${color_1.color.cyan(replacementDep.packageName)} ${color_1.color.green(version)}`);
|
|
@@ -578,40 +636,57 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
578
636
|
}
|
|
579
637
|
async migrateConfigs(projectDir) {
|
|
580
638
|
const projectData = this.$projectDataService.getProjectData(projectDir);
|
|
639
|
+
// package.json
|
|
581
640
|
const rootPackageJsonPath = path.resolve(projectDir, constants.PACKAGE_JSON_FILE_NAME);
|
|
641
|
+
// nested package.json
|
|
582
642
|
const embeddedPackageJsonPath = path.resolve(projectData.projectDir, projectData.getAppDirectoryRelativePath(), constants.PACKAGE_JSON_FILE_NAME);
|
|
643
|
+
// nsconfig.json
|
|
583
644
|
const legacyNsConfigPath = path.resolve(projectData.projectDir, constants.CONFIG_NS_FILE_NAME);
|
|
584
645
|
let rootPackageJsonData = {};
|
|
585
646
|
if (this.$fs.exists(rootPackageJsonPath)) {
|
|
586
647
|
rootPackageJsonData = this.$fs.readJson(rootPackageJsonPath);
|
|
587
648
|
}
|
|
649
|
+
// write the default config unless it already exists
|
|
588
650
|
const newConfigPath = this.$projectConfigService.writeDefaultConfig(projectData.projectDir);
|
|
651
|
+
// force legacy config mode
|
|
589
652
|
this.$projectConfigService.setForceUsingLegacyConfig(true);
|
|
653
|
+
// all different sources are combined into configData (nested package.json, nsconfig and root package.json[nativescript])
|
|
590
654
|
const configData = this.$projectConfigService.readConfig(projectData.projectDir);
|
|
655
|
+
// we no longer want to force legacy config mode
|
|
591
656
|
this.$projectConfigService.setForceUsingLegacyConfig(false);
|
|
657
|
+
// move main key into root package.json
|
|
592
658
|
if (configData.main) {
|
|
593
659
|
rootPackageJsonData.main = configData.main;
|
|
594
660
|
delete configData.main;
|
|
595
661
|
}
|
|
662
|
+
// detect appPath and App_Resources path
|
|
596
663
|
configData.appPath = this.detectAppPath(projectDir, configData);
|
|
597
664
|
configData.appResourcesPath = this.detectAppResourcesPath(projectDir, configData);
|
|
665
|
+
// delete nativescript key from root package.json
|
|
598
666
|
if (rootPackageJsonData.nativescript) {
|
|
599
667
|
delete rootPackageJsonData.nativescript;
|
|
600
668
|
}
|
|
669
|
+
// force the config service to use nativescript.config.ts
|
|
601
670
|
this.$projectConfigService.setForceUsingNewConfig(true);
|
|
602
|
-
|
|
671
|
+
// migrate data into nativescript.config.ts
|
|
672
|
+
const hasUpdatedConfigSuccessfully = await this.$projectConfigService.setValue("", // root
|
|
673
|
+
configData);
|
|
603
674
|
if (!hasUpdatedConfigSuccessfully) {
|
|
604
675
|
if (typeof newConfigPath === "string") {
|
|
676
|
+
// only clean the config if it was created by the migration script
|
|
605
677
|
await this.$projectCleanupService.cleanPath(newConfigPath);
|
|
606
678
|
}
|
|
607
679
|
this.$errors.fail(`Failed to migrate project to use ${constants.CONFIG_FILE_NAME_TS}. One or more values could not be updated.`);
|
|
608
680
|
}
|
|
681
|
+
// save root package.json
|
|
609
682
|
this.$fs.writeJson(rootPackageJsonPath, rootPackageJsonData);
|
|
683
|
+
// delete migrated files
|
|
610
684
|
await this.$projectCleanupService.cleanPath(embeddedPackageJsonPath);
|
|
611
685
|
await this.$projectCleanupService.cleanPath(legacyNsConfigPath);
|
|
612
686
|
return true;
|
|
613
687
|
}
|
|
614
688
|
async migrateUnitTestRunner(projectData, migrationBackupDirPath) {
|
|
689
|
+
// Migrate karma.conf.js
|
|
615
690
|
const pathToKarmaConfig = path.join(migrationBackupDirPath, constants.KARMA_CONFIG_NAME);
|
|
616
691
|
if (this.$fs.exists(pathToKarmaConfig)) {
|
|
617
692
|
const oldKarmaContent = this.$fs.readText(pathToKarmaConfig);
|
|
@@ -629,6 +704,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
629
704
|
});
|
|
630
705
|
this.$fs.writeFile(path.join(projectData.projectDir, constants.KARMA_CONFIG_NAME), karmaConf);
|
|
631
706
|
}
|
|
707
|
+
// Dependencies to migrate
|
|
632
708
|
const dependencies = [
|
|
633
709
|
{
|
|
634
710
|
packageName: "karma-webpack",
|
|
@@ -670,6 +746,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
670
746
|
async migrateTSConfig({ tsConfigPath, isAngular, polyfillsPath, }) {
|
|
671
747
|
try {
|
|
672
748
|
const configContents = this.$fs.readJson(tsConfigPath);
|
|
749
|
+
// update
|
|
673
750
|
configContents.compilerOptions = configContents.compilerOptions || {};
|
|
674
751
|
configContents.compilerOptions.target = "es2020";
|
|
675
752
|
configContents.compilerOptions.module = "esnext";
|
|
@@ -680,6 +757,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
680
757
|
...new Set([...(configContents.compilerOptions.lib || []), "ESNext"]),
|
|
681
758
|
];
|
|
682
759
|
if (isAngular) {
|
|
760
|
+
// make sure polyfills.ts is in files
|
|
683
761
|
if (configContents.files) {
|
|
684
762
|
configContents.files = [
|
|
685
763
|
...new Set([
|
|
@@ -713,8 +791,10 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
713
791
|
const tempDir = temp.mkdirSync({
|
|
714
792
|
prefix: "migrate-angular-polyfills",
|
|
715
793
|
});
|
|
794
|
+
// get from default angular template
|
|
716
795
|
await this.$pacoteService.extractPackage(constants.RESERVED_TEMPLATE_NAMES["angular"], tempDir);
|
|
717
796
|
this.$fs.copyFile(path.resolve(tempDir, "src/polyfills.ts"), possiblePaths[0]);
|
|
797
|
+
// clean up temp project
|
|
718
798
|
this.$fs.deleteDirectory(tempDir);
|
|
719
799
|
this.spinner.succeed(`Created fresh ${color_1.color.cyan("polyfills.ts")}`);
|
|
720
800
|
return "./" + path.relative(projectDir, possiblePaths[0]);
|
|
@@ -783,6 +863,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
783
863
|
desiredVersion: "~0.15.0",
|
|
784
864
|
shouldAddIfMissing: true,
|
|
785
865
|
},
|
|
866
|
+
// devDependencies
|
|
786
867
|
{
|
|
787
868
|
packageName: "@angular/cli",
|
|
788
869
|
minVersion,
|
|
@@ -853,10 +934,12 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
853
934
|
packageName: "@babel/preset-env",
|
|
854
935
|
shouldRemove: true,
|
|
855
936
|
},
|
|
937
|
+
// remove any version of vue
|
|
856
938
|
{
|
|
857
939
|
packageName: "vue",
|
|
858
940
|
shouldRemove: true,
|
|
859
941
|
},
|
|
942
|
+
// add latest
|
|
860
943
|
{
|
|
861
944
|
packageName: "vue",
|
|
862
945
|
desiredVersion: "2.6.12",
|
|
@@ -952,6 +1035,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
952
1035
|
return;
|
|
953
1036
|
}
|
|
954
1037
|
}
|
|
1038
|
+
// clean old config before generating new one
|
|
955
1039
|
await this.$projectCleanupService.clean(["webpack.config.js"]);
|
|
956
1040
|
this.spinner.info(`Initializing new ${color_1.color.yellow("webpack.config.js")}`);
|
|
957
1041
|
const { desiredVersion: webpackVersion } = this.migrationDependencies.find((dep) => dep.packageName === constants.WEBPACK_PLUGIN_NAME);
|
|
@@ -1026,6 +1110,7 @@ class MigrateController extends update_controller_base_1.UpdateControllerBase {
|
|
|
1026
1110
|
}
|
|
1027
1111
|
}
|
|
1028
1112
|
exports.MigrateController = MigrateController;
|
|
1113
|
+
// static readonly typescriptPackageName: string = "typescript";
|
|
1029
1114
|
MigrateController.backupFolderName = ".migration_backup";
|
|
1030
1115
|
MigrateController.pathsToBackup = [
|
|
1031
1116
|
constants.LIB_DIR_NAME,
|
|
@@ -1038,3 +1123,4 @@ MigrateController.pathsToBackup = [
|
|
|
1038
1123
|
constants.CONFIG_NS_FILE_NAME,
|
|
1039
1124
|
];
|
|
1040
1125
|
yok_1.injector.register("migrateController", MigrateController);
|
|
1126
|
+
//# sourceMappingURL=migrate-controller.js.map
|
|
@@ -84,9 +84,13 @@ class PlatformController {
|
|
|
84
84
|
desiredRuntimePackage.version = version;
|
|
85
85
|
}
|
|
86
86
|
if (!desiredRuntimePackage.version) {
|
|
87
|
+
// if no version is explicitly added, then we use the latest
|
|
87
88
|
desiredRuntimePackage.version =
|
|
88
89
|
await this.$packageInstallationManager.getLatestCompatibleVersion(desiredRuntimePackage.name);
|
|
89
90
|
}
|
|
91
|
+
// const currentPlatformData = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
|
|
92
|
+
// version = (currentPlatformData && currentPlatformData.version) ||
|
|
93
|
+
// await this.$packageInstallationManager.getLatestCompatibleVersion(platformData.frameworkPackageName);
|
|
90
94
|
result = `${desiredRuntimePackage.name}@${desiredRuntimePackage.version}`;
|
|
91
95
|
}
|
|
92
96
|
return result;
|
|
@@ -98,11 +102,14 @@ class PlatformController {
|
|
|
98
102
|
const prepareInfo = this.$projectChangesService.getPrepareInfo(platformData);
|
|
99
103
|
const requiresNativePlatformAdd = prepareInfo &&
|
|
100
104
|
prepareInfo.nativePlatformStatus ===
|
|
101
|
-
"1"
|
|
105
|
+
"1" /* NativePlatformStatus.requiresPlatformAdd */;
|
|
102
106
|
const shouldAddPlatform = !hasPlatformDirectory ||
|
|
103
107
|
(shouldAddNativePlatform && requiresNativePlatformAdd);
|
|
104
108
|
if (hasPlatformDirectory && !shouldAddPlatform) {
|
|
105
109
|
const platformDirectoryItemCount = this.$fs.readDirectory(path.join(projectData.platformsDir, platformName)).length;
|
|
110
|
+
// 2 is a magic number to approximate a valid platform folder
|
|
111
|
+
// any valid platform should contain at least 2 files/folders
|
|
112
|
+
// we choose 2 to avoid false-positives due to system files like .DS_Store etc.
|
|
106
113
|
if (platformDirectoryItemCount <= 2) {
|
|
107
114
|
this.$logger.warn(`The platforms/${platformName} folder appears to be invalid. If the build fails, run 'ns clean' and rebuild the app.`, { wrapMessageWithBorders: true });
|
|
108
115
|
}
|
|
@@ -112,3 +119,4 @@ class PlatformController {
|
|
|
112
119
|
}
|
|
113
120
|
exports.PlatformController = PlatformController;
|
|
114
121
|
yok_1.injector.register("platformController", PlatformController);
|
|
122
|
+
//# sourceMappingURL=platform-controller.js.map
|
|
@@ -76,6 +76,10 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
76
76
|
await this.$platformController.addPlatformIfNeeded(prepareData, projectData);
|
|
77
77
|
await this.trackRuntimeVersion(prepareData.platform, projectData);
|
|
78
78
|
this.$logger.info("Preparing project...");
|
|
79
|
+
// we need to mark the ~/package.json (used by core modules)
|
|
80
|
+
// as external for us to be able to write the config to it
|
|
81
|
+
// in writeRuntimePackageJson() below, because otherwise
|
|
82
|
+
// webpack will inline it into the bundle/vendor chunks
|
|
79
83
|
prepareData.env = prepareData.env || {};
|
|
80
84
|
prepareData.env.externals = prepareData.env.externals || [];
|
|
81
85
|
prepareData.env.externals.push("~/package.json");
|
|
@@ -116,8 +120,8 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
116
120
|
},
|
|
117
121
|
};
|
|
118
122
|
}
|
|
119
|
-
await this.startJSWatcherWithPrepare(platformData, projectData, prepareData);
|
|
120
|
-
const hasNativeChanges = await this.startNativeWatcherWithPrepare(platformData, projectData, prepareData);
|
|
123
|
+
await this.startJSWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial compilation
|
|
124
|
+
const hasNativeChanges = await this.startNativeWatcherWithPrepare(platformData, projectData, prepareData); // -> start watcher + initial prepare
|
|
121
125
|
const result = {
|
|
122
126
|
platform: platformData.platformNameLowerCase,
|
|
123
127
|
hasNativeChanges,
|
|
@@ -126,6 +130,7 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
126
130
|
if (hasPersistedDataWithNativeChanges) {
|
|
127
131
|
result.hasNativeChanges = true;
|
|
128
132
|
}
|
|
133
|
+
// TODO: Do not persist this in `this` context. Also it should be per platform.
|
|
129
134
|
this.isInitialPrepareReady = true;
|
|
130
135
|
if (this.persistedData && this.persistedData.length) {
|
|
131
136
|
this.emitPrepareEvent({
|
|
@@ -178,7 +183,7 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
178
183
|
pollInterval: 100,
|
|
179
184
|
stabilityThreshold: 500,
|
|
180
185
|
},
|
|
181
|
-
ignored: ["**/.*", ".*"],
|
|
186
|
+
ignored: ["**/.*", ".*"], // hidden files
|
|
182
187
|
};
|
|
183
188
|
const watcher = (0, chokidar_1.watch)(patterns, watcherOptions).on("all", async (event, filePath) => {
|
|
184
189
|
if (this.isFileWatcherPaused())
|
|
@@ -220,6 +225,9 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
220
225
|
.concat(pluginsPackageJsonFiles);
|
|
221
226
|
return patterns;
|
|
222
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* TODO: move this logic to the webpack side of things - WIP and deprecate here with a webpack version check...
|
|
230
|
+
*/
|
|
223
231
|
async writeRuntimePackageJson(projectData, platformData, prepareData = null) {
|
|
224
232
|
const configInfo = this.$projectConfigService.detectProjectConfigs(projectData.projectDir);
|
|
225
233
|
if (configInfo.usingNSConfig) {
|
|
@@ -252,7 +260,11 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
252
260
|
packagePath = path.join(platformData.projectRoot, this.$options.hostProjectModuleName, "src", this.$options.hostProjectPath ? "nativescript" : "main", "assets", "app", "package.json");
|
|
253
261
|
}
|
|
254
262
|
try {
|
|
263
|
+
// this will read the package.json that is already emitted by
|
|
264
|
+
// the GenerateNativeScriptEntryPointsPlugin webpack plugin
|
|
255
265
|
const emittedPackageData = this.$fs.readJson(packagePath);
|
|
266
|
+
// since ns7 we only care about the main key from the emitted
|
|
267
|
+
// package.json, the rest is coming from the new config.
|
|
256
268
|
if (emittedPackageData === null || emittedPackageData === void 0 ? void 0 : emittedPackageData.main) {
|
|
257
269
|
packageData.main = emittedPackageData.main;
|
|
258
270
|
}
|
|
@@ -280,7 +292,7 @@ class PrepareController extends events_1.EventEmitter {
|
|
|
280
292
|
return;
|
|
281
293
|
}
|
|
282
294
|
await this.$analyticsService.trackEventActionInGoogleAnalytics({
|
|
283
|
-
action: "Using Runtime Version"
|
|
295
|
+
action: "Using Runtime Version" /* TrackActionNames.UsingRuntimeVersion */,
|
|
284
296
|
additionalData: `${platform.toLowerCase()}${constants_1.AnalyticsEventLabelDelimiter}${version}`,
|
|
285
297
|
});
|
|
286
298
|
}
|
|
@@ -325,3 +337,4 @@ __decorate([
|
|
|
325
337
|
(0, decorators_1.cache)()
|
|
326
338
|
], PrepareController.prototype, "trackRuntimeVersion", null);
|
|
327
339
|
yok_1.injector.register("prepareController", PrepareController);
|
|
340
|
+
//# sourceMappingURL=prepare-controller.js.map
|
|
@@ -78,11 +78,14 @@ class RunController extends events_1.EventEmitter {
|
|
|
78
78
|
const { projectDir, deviceIdentifiers, stopOptions } = data;
|
|
79
79
|
const liveSyncProcessInfo = this.$liveSyncProcessDataService.getPersistedData(projectDir);
|
|
80
80
|
if (liveSyncProcessInfo && !liveSyncProcessInfo.isStopped) {
|
|
81
|
+
// In case we are coming from error during livesync, the current action is the one that erred (but we are still executing it),
|
|
82
|
+
// so we cannot await it as this will cause infinite loop.
|
|
81
83
|
const shouldAwaitPendingOperation = !stopOptions || stopOptions.shouldAwaitAllActions;
|
|
82
84
|
const deviceIdentifiersToRemove = deviceIdentifiers && deviceIdentifiers.length
|
|
83
85
|
? deviceIdentifiers
|
|
84
86
|
: _.map(liveSyncProcessInfo.deviceDescriptors, (d) => d.identifier);
|
|
85
87
|
const removedDeviceIdentifiers = _.remove(liveSyncProcessInfo.deviceDescriptors, (descriptor) => _.includes(deviceIdentifiersToRemove, descriptor.identifier)).map((descriptor) => descriptor.identifier);
|
|
88
|
+
// Handle the case when no more devices left for any of the persisted platforms
|
|
86
89
|
for (let i = 0; i < liveSyncProcessInfo.platforms.length; i++) {
|
|
87
90
|
const platform = liveSyncProcessInfo.platforms[i];
|
|
88
91
|
const devices = this.$devicesService.getDevicesForPlatform(platform);
|
|
@@ -90,6 +93,7 @@ class RunController extends events_1.EventEmitter {
|
|
|
90
93
|
await this.$prepareController.stopWatchers(projectDir, platform);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
96
|
+
// In case deviceIdentifiers are not passed, we should stop the whole LiveSync.
|
|
93
97
|
if (!deviceIdentifiers ||
|
|
94
98
|
!deviceIdentifiers.length ||
|
|
95
99
|
!liveSyncProcessInfo.deviceDescriptors ||
|
|
@@ -120,6 +124,7 @@ class RunController extends events_1.EventEmitter {
|
|
|
120
124
|
shouldAwaitPendingOperation) {
|
|
121
125
|
await liveSyncProcessInfo.currentSyncAction;
|
|
122
126
|
}
|
|
127
|
+
// Emit RunOnDevice stopped when we've really stopped.
|
|
123
128
|
_.each(removedDeviceIdentifiers, (deviceIdentifier) => {
|
|
124
129
|
this.emitCore(constants_2.RunOnDeviceEvents.runOnDeviceStopped, {
|
|
125
130
|
projectDir,
|
|
@@ -157,6 +162,8 @@ class RunController extends events_1.EventEmitter {
|
|
|
157
162
|
shouldSkipEmitLiveSyncNotification: true,
|
|
158
163
|
shouldCheckDeveloperDiscImage: true,
|
|
159
164
|
});
|
|
165
|
+
// we do not stop the application when debugBrk is false, so we need to attach, instead of launch
|
|
166
|
+
// if we try to send the launch request, the debugger port will not be printed and the command will timeout
|
|
160
167
|
debugOptions.start = !debugOptions.debugBrk;
|
|
161
168
|
debugOptions.forceDebuggerAttachedEvent = refreshInfo.didRestart;
|
|
162
169
|
await this.$debugController.enableDebuggingCoreWithoutWaitingCurrentAction(projectData.projectDir, deviceDescriptor.identifier, debugOptions);
|
|
@@ -224,6 +231,7 @@ class RunController extends events_1.EventEmitter {
|
|
|
224
231
|
getDeviceDescriptorsForInitialSync(projectDir, deviceDescriptors) {
|
|
225
232
|
const currentRunData = this.$liveSyncProcessDataService.getPersistedData(projectDir);
|
|
226
233
|
const isAlreadyLiveSyncing = currentRunData && !currentRunData.isStopped;
|
|
234
|
+
// Prevent cases where liveSync is called consecutive times with the same device, for example [ A, B, C ] and then [ A, B, D ] - we want to execute initialSync only for D.
|
|
227
235
|
const deviceDescriptorsForInitialSync = isAlreadyLiveSyncing
|
|
228
236
|
? _.differenceBy(deviceDescriptors, currentRunData.deviceDescriptors, "identifier")
|
|
229
237
|
: deviceDescriptors;
|
|
@@ -277,6 +285,8 @@ class RunController extends events_1.EventEmitter {
|
|
|
277
285
|
const platformData = this.$platformsDataService.getPlatformData(device.deviceInfo.platform, projectData);
|
|
278
286
|
try {
|
|
279
287
|
let packageFilePath = null;
|
|
288
|
+
// Case where we have three devices attached, a change that requires build is found,
|
|
289
|
+
// we'll rebuild the app only for the first device, but we should install new package on all three devices.
|
|
280
290
|
if (rebuiltInformation[platformData.platformNameLowerCase] &&
|
|
281
291
|
(this.$mobileHelper.isAndroidPlatform(platformData.platformNameLowerCase) ||
|
|
282
292
|
rebuiltInformation[platformData.platformNameLowerCase]
|
|
@@ -300,7 +310,7 @@ class RunController extends events_1.EventEmitter {
|
|
|
300
310
|
}
|
|
301
311
|
else {
|
|
302
312
|
await this.$analyticsService.trackEventActionInGoogleAnalytics({
|
|
303
|
-
action: "LiveSync"
|
|
313
|
+
action: "LiveSync" /* TrackActionNames.LiveSync */,
|
|
304
314
|
device,
|
|
305
315
|
projectDir: projectData.projectDir,
|
|
306
316
|
});
|
|
@@ -370,6 +380,9 @@ class RunController extends events_1.EventEmitter {
|
|
|
370
380
|
const watchInfo = {
|
|
371
381
|
liveSyncDeviceData: deviceDescriptor,
|
|
372
382
|
projectData,
|
|
383
|
+
// todo: remove stale files once everything is stable
|
|
384
|
+
// currently, watcher fires multiple times & may clean up unsynced files
|
|
385
|
+
// filesToRemove: data.staleFiles ?? [],
|
|
373
386
|
filesToRemove: [],
|
|
374
387
|
filesToSync,
|
|
375
388
|
hmrData: data.hmrData,
|
|
@@ -415,6 +428,7 @@ class RunController extends events_1.EventEmitter {
|
|
|
415
428
|
const fullSyncAction = async () => {
|
|
416
429
|
watchInfo.filesToSync = allAppFiles;
|
|
417
430
|
const fullLiveSyncResultInfo = await platformLiveSyncService.liveSyncWatchAction(device, watchInfo);
|
|
431
|
+
// IMPORTANT: keep the same instance as we rely on side effects
|
|
418
432
|
_.assign(liveSyncResultInfo, fullLiveSyncResultInfo);
|
|
419
433
|
};
|
|
420
434
|
await this.$hooksService.executeBeforeHooks("watchAction", {
|
|
@@ -429,6 +443,7 @@ class RunController extends events_1.EventEmitter {
|
|
|
429
443
|
await this.refreshApplication(projectData, liveSyncResultInfo, data, deviceDescriptor, fullSyncAction);
|
|
430
444
|
if (!liveSyncResultInfo.didRecover && isInHMRMode) {
|
|
431
445
|
const status = await this.$hmrStatusService.getHmrStatus(device.deviceInfo.identifier, data.hmrData.hash);
|
|
446
|
+
// the timeout is assumed OK as the app could be blocked on a breakpoint
|
|
432
447
|
if (status === constants_1.HmrConstants.HMR_ERROR_STATUS) {
|
|
433
448
|
await fullSyncAction();
|
|
434
449
|
liveSyncResultInfo.isFullSync = true;
|
|
@@ -510,3 +525,4 @@ __decorate([
|
|
|
510
525
|
(0, decorators_1.cache)()
|
|
511
526
|
], RunController.prototype, "attachDeviceLostHandler", null);
|
|
512
527
|
yok_1.injector.register("runController", RunController);
|
|
528
|
+
//# sourceMappingURL=run-controller.js.map
|