nativescript 9.0.4-dev.1 → 9.0.4-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/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 +4 -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 +5 -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/hooks/common.js +2 -1
- package/lib/commands/hooks/hooks-lock.js +1 -0
- package/lib/commands/hooks/hooks.js +1 -0
- 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 +2 -1
- 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 +3 -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 +13 -0
- 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 +11 -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 +68 -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 +18 -0
- package/lib/services/ios/xcodebuild-args-service.js +11 -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 +100 -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 +3 -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 +1 -1
|
@@ -42,6 +42,7 @@ class HelpService {
|
|
|
42
42
|
this.$logger.trace("Opening help for command '%s'. FileName is '%s'.", commandName, htmlPage);
|
|
43
43
|
this.$fs.ensureDirectoryExists(this.pathToHtmlPages);
|
|
44
44
|
if (!this.tryOpeningSelectedPage(htmlPage)) {
|
|
45
|
+
// HTML pages may have been skipped on post-install, lets generate them.
|
|
45
46
|
this.$logger.trace("Required HTML file '%s' is missing. Let's try generating HTML files and see if we'll find it.", htmlPage);
|
|
46
47
|
await this.generateHtmlPages();
|
|
47
48
|
if (!this.tryOpeningSelectedPage(htmlPage)) {
|
|
@@ -98,6 +99,11 @@ class HelpService {
|
|
|
98
99
|
const help = await this.getCommandLineHelpForCommand(commandData);
|
|
99
100
|
this.$logger.printMarkdown(help);
|
|
100
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets the help content for a specific command that should be shown on the terminal.
|
|
104
|
+
* @param {string} commandName Name of the command for which to read the help.
|
|
105
|
+
* @returns {Promise<string>} Help content of the command parsed with all terminal rules applied (stripped content that should be shown only for html help).
|
|
106
|
+
*/
|
|
101
107
|
async getCommandLineHelpForCommand(commandData) {
|
|
102
108
|
const helpText = await this.readMdFileForCommand(commandData);
|
|
103
109
|
const commandLineHelp = (await this.$microTemplateService.parseContent(helpText, { isHtml: false }))
|
|
@@ -109,6 +115,7 @@ class HelpService {
|
|
|
109
115
|
.replace(HelpService.NEW_LINE_REGEX, os_1.EOL);
|
|
110
116
|
return commandLineHelp;
|
|
111
117
|
}
|
|
118
|
+
// This method should return Promise in order to generate all html pages simultaneously.
|
|
112
119
|
async createHtmlPage(htmlPageGenerationData) {
|
|
113
120
|
const { basicHtmlPage, pathToMdFile, pathToMdPages, pathToHtmlPages, extensionName, } = htmlPageGenerationData;
|
|
114
121
|
const mdFileName = path.basename(pathToMdFile);
|
|
@@ -155,8 +162,8 @@ class HelpService {
|
|
|
155
162
|
const commandName = commandData.commandName;
|
|
156
163
|
const commandInfo = {
|
|
157
164
|
inputStrings: [commandName, ...commandData.commandArguments],
|
|
158
|
-
commandDelimiter: "|"
|
|
159
|
-
defaultCommandDelimiter: "|*"
|
|
165
|
+
commandDelimiter: "|" /* CommandsDelimiters.HierarchicalCommand */,
|
|
166
|
+
defaultCommandDelimiter: "|*" /* CommandsDelimiters.DefaultHierarchicalCommand */,
|
|
160
167
|
};
|
|
161
168
|
const extensionData = await this.$extensibilityService.getExtensionNameWhereCommandIsRegistered(commandInfo);
|
|
162
169
|
if (extensionData) {
|
|
@@ -223,5 +230,6 @@ HelpService.RELATIVE_PATH_TO_INDEX_REGEX = /@RELATIVE_PATH_TO_INDEX@/g;
|
|
|
223
230
|
HelpService.EXTENSION_NAME_REGEX = /@EXTENSION_NAME@/g;
|
|
224
231
|
HelpService.MARKDOWN_LINK_REGEX = /\[([\w \-\`\<\>\*\:\\]+?)\]\([\s\S]+?\)/g;
|
|
225
232
|
HelpService.SPAN_REGEX = /([\s\S]*?)(?:\r?\n)?<span.*?>([\s\S]*?)<\/span>(?:\r?\n)*/g;
|
|
226
|
-
HelpService.NEW_LINE_REGEX = /<\/?\s*?br\s*?\/?>/g;
|
|
233
|
+
HelpService.NEW_LINE_REGEX = /<\/?\s*?br\s*?\/?>/g; // <br>, <br > <br/> <br />
|
|
227
234
|
yok_1.injector.register("helpService", HelpService);
|
|
235
|
+
//# sourceMappingURL=help-service.js.map
|
|
@@ -52,6 +52,7 @@ class HooksService {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
static formatHookName(commandName) {
|
|
55
|
+
// Remove everything after | (including the pipe)
|
|
55
56
|
return commandName.replace(/\|[\s\S]*$/, "");
|
|
56
57
|
}
|
|
57
58
|
executeBeforeHooks(commandName, hookArguments) {
|
|
@@ -131,6 +132,11 @@ class HooksService {
|
|
|
131
132
|
this.$logger.warn(`${hook.fullPath} will NOT be executed because it has invalid arguments - ${color_1.color.grey(invalidArguments.join(", "))}.`);
|
|
132
133
|
return;
|
|
133
134
|
}
|
|
135
|
+
// HACK for backwards compatibility:
|
|
136
|
+
// In case $projectData wasn't resolved by the time we got here (most likely we got here without running a command but through a service directly)
|
|
137
|
+
// then it is probably passed as a hookArg
|
|
138
|
+
// if that is the case then pass it directly to the hook instead of trying to resolve $projectData via injector
|
|
139
|
+
// This helps make hooks stateless
|
|
134
140
|
const projectDataHookArg = hookArguments["hookArgs"] && hookArguments["hookArgs"]["projectData"];
|
|
135
141
|
if (projectDataHookArg) {
|
|
136
142
|
hookArguments["projectData"] = hookArguments["$projectData"] =
|
|
@@ -149,6 +155,7 @@ class HooksService {
|
|
|
149
155
|
this.$logger.warn(err.message || err);
|
|
150
156
|
}
|
|
151
157
|
else {
|
|
158
|
+
// Print the actual error with its callstack, so it is easy to find out which hooks is causing troubles.
|
|
152
159
|
this.$logger.error(err);
|
|
153
160
|
throw err || new Error(`Failed to execute hook: ${hook.fullPath}.`);
|
|
154
161
|
}
|
|
@@ -253,6 +260,7 @@ class HooksService {
|
|
|
253
260
|
interpreter = sheBangMatch[1];
|
|
254
261
|
}
|
|
255
262
|
if (interpreter) {
|
|
263
|
+
// Likewise, make /usr/bin/bash work like "bash".
|
|
256
264
|
shMatch = interpreter.match(/bin\/((?:ba)?sh)$/);
|
|
257
265
|
}
|
|
258
266
|
if (shMatch) {
|
|
@@ -293,6 +301,7 @@ class HooksService {
|
|
|
293
301
|
}
|
|
294
302
|
validateHookArguments(hookConstructor, hookFullPath) {
|
|
295
303
|
const invalidArguments = [];
|
|
304
|
+
// We need to annotate the hook in order to have the arguments of the constructor.
|
|
296
305
|
(0, helpers_1.annotate)(hookConstructor);
|
|
297
306
|
_.each(hookConstructor.$inject.args, (argument) => {
|
|
298
307
|
try {
|
|
@@ -313,8 +322,12 @@ HooksService.HOOKS_DIRECTORY_NAME = "hooks";
|
|
|
313
322
|
__decorate([
|
|
314
323
|
(0, decorators_1.memoize)({
|
|
315
324
|
shouldCache() {
|
|
325
|
+
// only cache if we have hooks directories, the only case to
|
|
326
|
+
// not have hooks directories is when the project dir is
|
|
327
|
+
// not set yet, ie. when creating a project.
|
|
316
328
|
return !!this.hooksDirectories.length;
|
|
317
329
|
},
|
|
318
330
|
})
|
|
319
331
|
], HooksService.prototype, "initialize", null);
|
|
320
332
|
yok_1.injector.register("hooksService", HooksService);
|
|
333
|
+
//# sourceMappingURL=hooks-service.js.map
|
|
@@ -25,6 +25,8 @@ class JsonFileSettingsService {
|
|
|
25
25
|
const dataToReturn = data.modifiedByCacheMechanism ? data.value : data;
|
|
26
26
|
if (cacheOpts && cacheOpts.cacheTimeout) {
|
|
27
27
|
if (!data.modifiedByCacheMechanism) {
|
|
28
|
+
// If data has no cache, but we want to check the timeout, consider the data as outdated.
|
|
29
|
+
// this should be a really rare case
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
const currentTime = Date.now();
|
|
@@ -82,6 +84,8 @@ class JsonFileSettingsService {
|
|
|
82
84
|
if (!this.$fs.exists(this.jsonSettingsFilePath)) {
|
|
83
85
|
const unexistingDirs = this.getUnexistingDirectories(this.jsonSettingsFilePath);
|
|
84
86
|
this.$fs.writeFile(this.jsonSettingsFilePath, null);
|
|
87
|
+
// when running under 'sudo' we create the <path to home dir>/.local/share/.nativescript-cli dir with root as owner
|
|
88
|
+
// and other Applications cannot access this directory anymore. (bower/heroku/etc)
|
|
85
89
|
if (process.env.SUDO_USER) {
|
|
86
90
|
for (const dir of unexistingDirs) {
|
|
87
91
|
await this.$fs.setCurrentUserAsOwner(dir, process.env.SUDO_USER);
|
|
@@ -101,6 +105,7 @@ class JsonFileSettingsService {
|
|
|
101
105
|
const unexistingDirs = [];
|
|
102
106
|
let currentDir = path.join(filePath, "..");
|
|
103
107
|
while (true) {
|
|
108
|
+
// this directory won't be created.
|
|
104
109
|
if (this.$fs.exists(currentDir)) {
|
|
105
110
|
break;
|
|
106
111
|
}
|
|
@@ -112,3 +117,4 @@ class JsonFileSettingsService {
|
|
|
112
117
|
}
|
|
113
118
|
exports.JsonFileSettingsService = JsonFileSettingsService;
|
|
114
119
|
yok_1.injector.register("jsonFileSettingsService", JsonFileSettingsService, false);
|
|
120
|
+
//# sourceMappingURL=json-file-settings-service.js.map
|
|
@@ -22,6 +22,7 @@ class LockService {
|
|
|
22
22
|
}
|
|
23
23
|
get defaultLockParams() {
|
|
24
24
|
const lockParams = {
|
|
25
|
+
// https://www.npmjs.com/package/retry#retrytimeoutsoptions
|
|
25
26
|
retriesObj: { retries: 13, minTimeout: 100, maxTimeout: 1000, factor: 2 },
|
|
26
27
|
stale: 10 * 1000,
|
|
27
28
|
realpath: false,
|
|
@@ -72,6 +73,8 @@ class LockService {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
getPathsForCleanupAction(lockPath) {
|
|
76
|
+
// The proper-lockfile creates directory with the passed name and `.lock` at the end.
|
|
77
|
+
// Ensure we will take care of it as well.
|
|
75
78
|
return [lockPath, `${lockPath}.lock`];
|
|
76
79
|
}
|
|
77
80
|
getLockFileSettings(filePath, fileOpts) {
|
|
@@ -87,6 +90,7 @@ class LockService {
|
|
|
87
90
|
fileOpts.retriesObj.retries = fileOpts.retries;
|
|
88
91
|
}
|
|
89
92
|
if (fileOpts.retryWait) {
|
|
93
|
+
// backwards compatibility
|
|
90
94
|
fileOpts.retriesObj.minTimeout = fileOpts.retriesObj.maxTimeout =
|
|
91
95
|
fileOpts.retryWait;
|
|
92
96
|
}
|
|
@@ -109,4 +113,6 @@ __decorate([
|
|
|
109
113
|
(0, decorators_1.cache)()
|
|
110
114
|
], LockService.prototype, "defaultLockFilePath", null);
|
|
111
115
|
yok_1.injector.register("lockService", LockService);
|
|
116
|
+
// backwards compatibility
|
|
112
117
|
yok_1.injector.register("lockfile", LockService);
|
|
118
|
+
//# sourceMappingURL=lock-service.js.map
|
|
@@ -9,11 +9,15 @@ const _ = require("lodash");
|
|
|
9
9
|
class MicroTemplateService {
|
|
10
10
|
constructor($injector) {
|
|
11
11
|
this.$injector = $injector;
|
|
12
|
+
// Injector's dynamicCallRegex doesn't have 'g' option, which we need here.
|
|
13
|
+
// Use ( ) in order to use $1 to get whole expression later
|
|
12
14
|
this.dynamicCallRegex = new RegExp(util.format("(%s)", this.$injector.dynamicCallRegex.source), "g");
|
|
13
15
|
}
|
|
14
16
|
async parseContent(data, options) {
|
|
15
17
|
const localVariables = this.getLocalVariables(options);
|
|
16
18
|
const compiledTemplate = _.template(data.replace(this.dynamicCallRegex, 'this.$injector.getDynamicCallData("$1")'));
|
|
19
|
+
// When debugging parsing, uncomment the line below:
|
|
20
|
+
// console.log(compiledTemplate.source);
|
|
17
21
|
return await compiledTemplate.apply(this, [localVariables]);
|
|
18
22
|
}
|
|
19
23
|
isPlatform(...args) {
|
|
@@ -22,6 +26,7 @@ class MicroTemplateService {
|
|
|
22
26
|
}
|
|
23
27
|
getLocalVariables(options) {
|
|
24
28
|
const isHtml = options.isHtml;
|
|
29
|
+
// in html help we want to show all help. Only CONSOLE specific help(wrapped in if(isConsole) ) must be omitted
|
|
25
30
|
const localVariables = {
|
|
26
31
|
constants,
|
|
27
32
|
};
|
|
@@ -36,3 +41,4 @@ class MicroTemplateService {
|
|
|
36
41
|
}
|
|
37
42
|
exports.MicroTemplateService = MicroTemplateService;
|
|
38
43
|
yok_1.injector.register("microTemplateService", MicroTemplateService);
|
|
44
|
+
//# sourceMappingURL=micro-templating-service.js.map
|
|
@@ -14,6 +14,7 @@ class Net {
|
|
|
14
14
|
}
|
|
15
15
|
async getFreePort() {
|
|
16
16
|
const server = net.createServer((sock) => {
|
|
17
|
+
/* empty - noone will connect here */
|
|
17
18
|
});
|
|
18
19
|
return new Promise((resolve, reject) => {
|
|
19
20
|
let isResolved = false;
|
|
@@ -45,6 +46,7 @@ class Net {
|
|
|
45
46
|
});
|
|
46
47
|
server.once("close", () => {
|
|
47
48
|
if (!isResolved) {
|
|
49
|
+
// "close" will be emitted right after "error"
|
|
48
50
|
isResolved = true;
|
|
49
51
|
resolve(true);
|
|
50
52
|
}
|
|
@@ -118,3 +120,4 @@ class Net {
|
|
|
118
120
|
exports.Net = Net;
|
|
119
121
|
Net.DEFAULT_INTERVAL = 1000;
|
|
120
122
|
yok_1.injector.register("net", Net);
|
|
123
|
+
//# sourceMappingURL=net-service.js.map
|
|
@@ -53,6 +53,7 @@ class ProjectFilesManager {
|
|
|
53
53
|
this.processPlatformSpecificFilesCore(platform, files, projectFilesConfig);
|
|
54
54
|
}
|
|
55
55
|
processPlatformSpecificFilesCore(platform, files, projectFilesConfig) {
|
|
56
|
+
// Renames the files that have `platform` as substring and removes the files from other platform
|
|
56
57
|
_.each(files, (filePath) => {
|
|
57
58
|
const projectFileInfo = this.$projectFilesProvider.getProjectFileInfo(filePath, platform, projectFilesConfig);
|
|
58
59
|
if (!projectFileInfo.shouldIncludeFile) {
|
|
@@ -60,6 +61,7 @@ class ProjectFilesManager {
|
|
|
60
61
|
}
|
|
61
62
|
else if (projectFileInfo.onDeviceFileName) {
|
|
62
63
|
const onDeviceFilePath = path.join(path.dirname(filePath), projectFileInfo.onDeviceFileName);
|
|
64
|
+
// Fix .js.map entries
|
|
63
65
|
const extension = path.extname(projectFileInfo.onDeviceFileName);
|
|
64
66
|
if (onDeviceFilePath !== filePath) {
|
|
65
67
|
if (extension === ".js" || extension === ".map") {
|
|
@@ -73,6 +75,8 @@ class ProjectFilesManager {
|
|
|
73
75
|
fileContent = fileContent.replace(new RegExp(oldName, "g"), newName);
|
|
74
76
|
this.$fs.writeFile(filePath, fileContent);
|
|
75
77
|
}
|
|
78
|
+
// Rename the file
|
|
79
|
+
// this.$fs.rename is not called as it is error prone on some systems with slower hard drives and rigorous antivirus software
|
|
76
80
|
this.$fs.writeFile(onDeviceFilePath, this.$fs.readText(filePath));
|
|
77
81
|
this.$fs.deleteFile(filePath);
|
|
78
82
|
}
|
|
@@ -85,3 +89,4 @@ class ProjectFilesManager {
|
|
|
85
89
|
}
|
|
86
90
|
exports.ProjectFilesManager = ProjectFilesManager;
|
|
87
91
|
yok_1.injector.register("projectFilesManager", ProjectFilesManager);
|
|
92
|
+
//# sourceMappingURL=project-files-manager.js.map
|
package/lib/common/utils.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// This function must be separate to avoid dependencies on C++ modules - it must execute precisely when other functions cannot
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.verifyNodeVersion = verifyNodeVersion;
|
|
4
5
|
exports.getNodeWarning = getNodeWarning;
|
|
5
6
|
const color_1 = require("../color");
|
|
7
|
+
// Use only ES5 code here - pure JavaScript can be executed with any Node.js version (even 0.10, 0.12).
|
|
8
|
+
/* tslint:disable:no-var-keyword no-var-requires prefer-const*/
|
|
6
9
|
var os = require("os");
|
|
7
10
|
var semver = require("semver");
|
|
8
11
|
var util = require("util");
|
|
12
|
+
// These versions cannot be used with CLI due to bugs in the node itself.
|
|
13
|
+
// We are absolutely sure we cannot work with them, so inform the user if he is trying to use any of them and exit the process.
|
|
9
14
|
var versionsCausingFailure = ["0.10.34", "4.0.0", "4.2.0", "5.0.0"];
|
|
10
15
|
var minimumRequiredVersion = "8.0.0";
|
|
11
16
|
function getNodeVersionOpts() {
|
|
@@ -69,9 +74,11 @@ function getNodeWarning() {
|
|
|
69
74
|
if (warningMessage) {
|
|
70
75
|
nodeWarn = {
|
|
71
76
|
message: warningMessage,
|
|
72
|
-
severity: "medium"
|
|
77
|
+
severity: "medium" /* SystemWarningsSeverity.medium */,
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
return nodeWarn;
|
|
77
82
|
}
|
|
83
|
+
/* tslint:enable */
|
|
84
|
+
//# sourceMappingURL=verify-node-version.js.map
|
package/lib/common/yok.js
CHANGED
|
@@ -9,6 +9,13 @@ const helpers_1 = require("./helpers");
|
|
|
9
9
|
const constants_1 = require("./constants");
|
|
10
10
|
let indent = "";
|
|
11
11
|
function trace(formatStr, ...args) {
|
|
12
|
+
// uncomment following lines when debugging dependency injection
|
|
13
|
+
// const items: any[] = [];
|
|
14
|
+
// for (let _i = 1; _i < arguments.length; _i++) {
|
|
15
|
+
// items[_i - 1] = arguments[_i];
|
|
16
|
+
// }
|
|
17
|
+
// const util = require("util");
|
|
18
|
+
// console.log(util.format.apply(util, [indent + formatStr].concat(args)));
|
|
12
19
|
}
|
|
13
20
|
function pushIndent() {
|
|
14
21
|
indent += " ";
|
|
@@ -26,6 +33,7 @@ function forEachName(names, action) {
|
|
|
26
33
|
}
|
|
27
34
|
function register(...rest) {
|
|
28
35
|
return function (target) {
|
|
36
|
+
// TODO: Check if 'rest' has more arguments that have to be registered
|
|
29
37
|
exports.injector.register(rest[0], target);
|
|
30
38
|
};
|
|
31
39
|
}
|
|
@@ -44,7 +52,7 @@ class Yok {
|
|
|
44
52
|
}
|
|
45
53
|
requireCommand(names, file) {
|
|
46
54
|
forEachName(names, (commandName) => {
|
|
47
|
-
const commands = commandName.split("|");
|
|
55
|
+
const commands = commandName.split("|" /* CommandsDelimiters.HierarchicalCommand */);
|
|
48
56
|
if (commands.length > 1) {
|
|
49
57
|
if (_.startsWith(commands[1], "*") &&
|
|
50
58
|
this.modules[this.createCommandName(commands[0])]) {
|
|
@@ -54,7 +62,7 @@ class Yok {
|
|
|
54
62
|
if (!this.hierarchicalCommands[parentCommandName]) {
|
|
55
63
|
this.hierarchicalCommands[parentCommandName] = [];
|
|
56
64
|
}
|
|
57
|
-
this.hierarchicalCommands[parentCommandName].push(_.tail(commands).join("|"));
|
|
65
|
+
this.hierarchicalCommands[parentCommandName].push(_.tail(commands).join("|" /* CommandsDelimiters.HierarchicalCommand */));
|
|
58
66
|
}
|
|
59
67
|
if (commands.length > 1 &&
|
|
60
68
|
!this.modules[this.createCommandName(commands[0])]) {
|
|
@@ -125,7 +133,7 @@ class Yok {
|
|
|
125
133
|
}
|
|
126
134
|
registerCommand(names, resolver) {
|
|
127
135
|
forEachName(names, (name) => {
|
|
128
|
-
const commands = name.split("|");
|
|
136
|
+
const commands = name.split("|" /* CommandsDelimiters.HierarchicalCommand */);
|
|
129
137
|
this.register(this.createCommandName(name), resolver);
|
|
130
138
|
if (commands.length > 1) {
|
|
131
139
|
this.createHierarchicalCommand(commands[0]);
|
|
@@ -137,7 +145,7 @@ class Yok {
|
|
|
137
145
|
}
|
|
138
146
|
getDefaultCommand(name, commandArguments) {
|
|
139
147
|
const subCommands = this.hierarchicalCommands[name];
|
|
140
|
-
const defaultCommand = _.find(subCommands, (command) => _.some(command.split("|"), (c) => _.startsWith(c, "*")));
|
|
148
|
+
const defaultCommand = _.find(subCommands, (command) => _.some(command.split("|" /* CommandsDelimiters.HierarchicalCommand */), (c) => _.startsWith(c, "*" /* CommandsDelimiters.DefaultCommandSymbol */)));
|
|
141
149
|
return defaultCommand;
|
|
142
150
|
}
|
|
143
151
|
buildHierarchicalCommand(parentCommandName, commandLineArguments) {
|
|
@@ -153,7 +161,7 @@ class Yok {
|
|
|
153
161
|
remainingArguments = _.tail(remainingArguments);
|
|
154
162
|
if ((matchingSubCommandName = _.find(subCommands, (sc) => sc === currentSubCommandName ||
|
|
155
163
|
sc ===
|
|
156
|
-
`${"*"}${currentSubCommandName}`))) {
|
|
164
|
+
`${"*" /* CommandsDelimiters.DefaultCommandSymbol */}${currentSubCommandName}`))) {
|
|
157
165
|
finalSubCommandName = matchingSubCommandName;
|
|
158
166
|
finalRemainingArguments = remainingArguments;
|
|
159
167
|
}
|
|
@@ -162,8 +170,8 @@ class Yok {
|
|
|
162
170
|
finalSubCommandName =
|
|
163
171
|
this.getDefaultCommand(parentCommandName, commandLineArguments) || "";
|
|
164
172
|
finalRemainingArguments = _.difference(commandLineArguments, finalSubCommandName
|
|
165
|
-
.split("|")
|
|
166
|
-
.map((command) => _.startsWith(command, "*")
|
|
173
|
+
.split("|" /* CommandsDelimiters.HierarchicalCommand */)
|
|
174
|
+
.map((command) => _.startsWith(command, "*" /* CommandsDelimiters.DefaultCommandSymbol */)
|
|
167
175
|
? command.substr(1)
|
|
168
176
|
: command));
|
|
169
177
|
}
|
|
@@ -194,7 +202,9 @@ class Yok {
|
|
|
194
202
|
commandName = defaultCommand
|
|
195
203
|
? this.getHierarchicalCommandName(name, defaultCommand)
|
|
196
204
|
: "help";
|
|
197
|
-
|
|
205
|
+
// If we'll execute the default command, but it's full name had been written by the user
|
|
206
|
+
// for example "ns run ios", we have to remove the "ios" option from the arguments that we'll pass to the command.
|
|
207
|
+
if (_.includes(this.hierarchicalCommands[name], "*" /* CommandsDelimiters.DefaultCommandSymbol */ + args[0])) {
|
|
198
208
|
commandArguments = _.tail(args);
|
|
199
209
|
}
|
|
200
210
|
else {
|
|
@@ -203,11 +213,13 @@ class Yok {
|
|
|
203
213
|
}
|
|
204
214
|
}
|
|
205
215
|
else {
|
|
216
|
+
//Execute only default command without arguments
|
|
206
217
|
if (defaultCommand) {
|
|
207
218
|
commandName = this.getHierarchicalCommandName(name, defaultCommand);
|
|
208
219
|
}
|
|
209
220
|
else {
|
|
210
221
|
commandName = "help";
|
|
222
|
+
// Show command-line help
|
|
211
223
|
const options = this.resolve("options");
|
|
212
224
|
options.help = true;
|
|
213
225
|
}
|
|
@@ -219,7 +231,7 @@ class Yok {
|
|
|
219
231
|
exports.injector.registerCommand(name, factory);
|
|
220
232
|
}
|
|
221
233
|
getHierarchicalCommandName(parentCommandName, subCommandName) {
|
|
222
|
-
return [parentCommandName, subCommandName].join("|");
|
|
234
|
+
return [parentCommandName, subCommandName].join("|" /* CommandsDelimiters.HierarchicalCommand */);
|
|
223
235
|
}
|
|
224
236
|
async isValidHierarchicalCommand(commandName, commandArguments) {
|
|
225
237
|
if (_.includes(Object.keys(this.hierarchicalCommands), commandName)) {
|
|
@@ -227,6 +239,8 @@ class Yok {
|
|
|
227
239
|
if (subCommands) {
|
|
228
240
|
const fullCommandName = this.buildHierarchicalCommand(commandName, commandArguments);
|
|
229
241
|
if (!fullCommandName) {
|
|
242
|
+
// In case buildHierarchicalCommand doesn't find a valid command
|
|
243
|
+
// there isn't a valid command or default with those arguments
|
|
230
244
|
const errors = exports.injector.resolve("errors");
|
|
231
245
|
errors.failWithHelp(constants_1.ERROR_NO_VALID_SUBCOMMAND_FORMAT, commandName);
|
|
232
246
|
}
|
|
@@ -236,8 +250,8 @@ class Yok {
|
|
|
236
250
|
return false;
|
|
237
251
|
}
|
|
238
252
|
isDefaultCommand(commandName) {
|
|
239
|
-
return (commandName.indexOf("*") > 0 &&
|
|
240
|
-
commandName.indexOf("|") > 0);
|
|
253
|
+
return (commandName.indexOf("*" /* CommandsDelimiters.DefaultCommandSymbol */) > 0 &&
|
|
254
|
+
commandName.indexOf("|" /* CommandsDelimiters.HierarchicalCommand */) > 0);
|
|
241
255
|
}
|
|
242
256
|
register(name, resolver, shared) {
|
|
243
257
|
shared = shared === undefined ? true : shared;
|
|
@@ -284,6 +298,12 @@ class Yok {
|
|
|
284
298
|
return this.resolveByName(param, ctorArguments);
|
|
285
299
|
}
|
|
286
300
|
}
|
|
301
|
+
/* Regex to match dynamic calls in the following format:
|
|
302
|
+
#{moduleName.functionName} or
|
|
303
|
+
#{moduleName.functionName(param1)} or
|
|
304
|
+
#{moduleName.functionName(param1, param2)} - multiple parameters separated with comma are supported
|
|
305
|
+
Check dynamicCall method for sample usage of this regular expression and see how to determine the passed parameters
|
|
306
|
+
*/
|
|
287
307
|
get dynamicCallRegex() {
|
|
288
308
|
return /#{([^.]+)\.([^}]+?)(\((.+)\))*}/;
|
|
289
309
|
}
|
|
@@ -411,3 +431,4 @@ function setGlobalInjector(inj) {
|
|
|
411
431
|
global.$injector = exports.injector = inj;
|
|
412
432
|
return inj;
|
|
413
433
|
}
|
|
434
|
+
//# sourceMappingURL=yok.js.map
|
package/lib/config.js
CHANGED
|
@@ -7,8 +7,10 @@ const os = require("os");
|
|
|
7
7
|
const _ = require("lodash");
|
|
8
8
|
const yok_1 = require("./common/yok");
|
|
9
9
|
class Configuration {
|
|
10
|
+
/*don't require logger and everything that has logger as dependency in config.js due to cyclic dependency*/
|
|
10
11
|
constructor($fs) {
|
|
11
12
|
this.$fs = $fs;
|
|
13
|
+
// User specific config
|
|
12
14
|
this.DEBUG = false;
|
|
13
15
|
this.ANDROID_DEBUG_UI = null;
|
|
14
16
|
this.USE_POD_SANDBOX = false;
|
|
@@ -47,6 +49,7 @@ class StaticConfig {
|
|
|
47
49
|
this._userAgent = null;
|
|
48
50
|
}
|
|
49
51
|
get disableCommandHooks() {
|
|
52
|
+
// Never set this to false because it will duplicate execution of hooks realized through method decoration
|
|
50
53
|
return true;
|
|
51
54
|
}
|
|
52
55
|
get HTML_CLI_HELPERS_DIR() {
|
|
@@ -88,6 +91,7 @@ class StaticConfig {
|
|
|
88
91
|
async getAdbFilePathCore() {
|
|
89
92
|
const $childProcess = this.$injector.resolve("$childProcess");
|
|
90
93
|
try {
|
|
94
|
+
// Do NOT use the adb wrapper because it will end blow up with Segmentation fault because the wrapper uses this method!!!
|
|
91
95
|
const proc = await $childProcess.spawnFromEvent("adb", ["version"], "exit", undefined, { throwError: false });
|
|
92
96
|
if (proc.stderr) {
|
|
93
97
|
return await this.spawnPrivateAdb();
|
|
@@ -100,23 +104,40 @@ class StaticConfig {
|
|
|
100
104
|
}
|
|
101
105
|
return "adb";
|
|
102
106
|
}
|
|
107
|
+
/*
|
|
108
|
+
Problem:
|
|
109
|
+
1. Adb forks itself as a server which keeps running until adb kill-server is invoked or crashes
|
|
110
|
+
2. On Windows running processes lock their image files due to memory mapping. Locked files prevent their parent directories from deletion and cannot be overwritten.
|
|
111
|
+
3. Update and uninstall scenarios are broken
|
|
112
|
+
Solution:
|
|
113
|
+
- Copy adb and associated files into a temporary directory. Let this copy of adb run persistently
|
|
114
|
+
- On Posix OSes, immediately delete the file to not take file space
|
|
115
|
+
- Tie common lib version to updates of adb, so that when we integrate a newer adb we can use it
|
|
116
|
+
- Adb is named differently on OSes and may have additional files. The code is hairy to accommodate these differences
|
|
117
|
+
*/
|
|
103
118
|
async spawnPrivateAdb() {
|
|
104
119
|
const $fs = this.$injector.resolve("$fs"), $childProcess = this.$injector.resolve("$childProcess"), $hostInfo = this.$injector.resolve("$hostInfo");
|
|
120
|
+
// prepare the directory to host our copy of adb
|
|
105
121
|
const defaultAdbDirPath = path.join(__dirname, "common", "resources", "platform-tools", "android", process.platform);
|
|
106
122
|
const pathToPackageJson = path.join(__dirname, "..", "package.json");
|
|
107
123
|
const nsCliVersion = require(pathToPackageJson).version;
|
|
108
124
|
const tmpDir = path.join(os.tmpdir(), `nativescript-cli-${nsCliVersion}`);
|
|
109
125
|
$fs.createDirectory(tmpDir);
|
|
126
|
+
// copy the adb and associated files
|
|
110
127
|
const targetAdb = path.join(tmpDir, "adb");
|
|
128
|
+
// In case directory is missing or it's empty, copy the new adb
|
|
111
129
|
if (!$fs.exists(tmpDir) || !$fs.readDirectory(tmpDir).length) {
|
|
112
|
-
shelljs.cp(path.join(defaultAdbDirPath, "*"), tmpDir);
|
|
130
|
+
shelljs.cp(path.join(defaultAdbDirPath, "*"), tmpDir); // deliberately ignore copy errors
|
|
131
|
+
// adb loses its executable bit when packed inside electron asar file. Manually fix the issue
|
|
113
132
|
if (!$hostInfo.isWindows) {
|
|
114
133
|
shelljs.chmod("+x", targetAdb);
|
|
115
134
|
}
|
|
116
135
|
}
|
|
136
|
+
// let adb start its global server
|
|
117
137
|
await $childProcess.spawnFromEvent(targetAdb, ["start-server"], "exit");
|
|
118
138
|
return targetAdb;
|
|
119
139
|
}
|
|
120
140
|
}
|
|
121
141
|
exports.StaticConfig = StaticConfig;
|
|
122
142
|
yok_1.injector.register("staticConfig", StaticConfig);
|
|
143
|
+
//# sourceMappingURL=config.js.map
|