nativescript 8.8.0 → 8.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/test-deps-versions-generated.json +1 -1
- package/lib/android-tools-info.js +12 -0
- package/lib/base-package-manager.js +11 -1
- package/lib/bootstrap.js +5 -1
- package/lib/bun-package-manager.js +17 -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 +4 -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 +3 -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 +12 -2
- 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/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 +30 -1
- package/lib/common/mobile/android/device-android-debug-bridge.js +1 -0
- package/lib/common/mobile/android/genymotion/genymotion-service.js +5 -0
- 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 +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 +91 -3
- 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 +143 -118
- 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 +6 -1
- package/lib/services/android-device-debug-service.js +6 -0
- package/lib/services/android-plugin-build-service.js +33 -1
- 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/assets-generation/assets-generation-service.js +16 -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/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 +9 -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 +1 -0
- 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 +94 -2
- 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 +22 -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/webpack/webpack-compiler-service.js +42 -1
- 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/node_modules/@npmcli/move-file/node_modules/mkdirp/CHANGELOG.md +15 -0
- package/node_modules/rimraf/CHANGELOG.md +65 -0
- package/node_modules/stringify-package/CHANGELOG.md +16 -0
- package/package.json +2 -2
package/lib/common/decorators.js
CHANGED
|
@@ -12,6 +12,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.deprecated = exports.performanceLog = exports.exported = exports.invokeInit = exports.invokeBefore = exports.memoize = exports.cache = void 0;
|
|
13
13
|
const constants_1 = require("../constants");
|
|
14
14
|
const yok_1 = require("./yok");
|
|
15
|
+
/**
|
|
16
|
+
* Caches the result of the first execution of the method and returns it whenever it is called instead of executing it again.
|
|
17
|
+
* Works with methods and getters.
|
|
18
|
+
* @example
|
|
19
|
+
* ```
|
|
20
|
+
* class CacheDecoratorsTest {
|
|
21
|
+
*
|
|
22
|
+
* @cache()
|
|
23
|
+
* public method(num: number): number {
|
|
24
|
+
* return num;
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* @cache()
|
|
28
|
+
* public get property(): any {
|
|
29
|
+
* // execute some heavy operation.
|
|
30
|
+
* return result;
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* const instance = new CacheDecoratorsTest();
|
|
35
|
+
* const result = instance.method(1); // returns 1;
|
|
36
|
+
*
|
|
37
|
+
* // all consecutive calls to instance.method will return 1.
|
|
38
|
+
* const result2 = instance.method(2); // returns 1;
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
15
41
|
function cache() {
|
|
16
42
|
return (target, propertyKey, descriptor) => {
|
|
17
43
|
let result;
|
|
@@ -32,6 +58,7 @@ exports.cache = cache;
|
|
|
32
58
|
let memoizeIDCounter = 0;
|
|
33
59
|
function memoize(options) {
|
|
34
60
|
return (target, propertyKey, descriptor) => {
|
|
61
|
+
// todo: remove once surely working as intended.
|
|
35
62
|
const DEBUG = false;
|
|
36
63
|
const memoizeID = memoizeIDCounter++;
|
|
37
64
|
const valueOrGet = descriptor.value ? "value" : "get";
|
|
@@ -52,6 +79,7 @@ function memoize(options) {
|
|
|
52
79
|
cacheMapName,
|
|
53
80
|
hashKey,
|
|
54
81
|
});
|
|
82
|
+
// initialize cache map if not exists
|
|
55
83
|
if (!this.hasOwnProperty(cacheMapName)) {
|
|
56
84
|
DEBUG && console.log("NO CACHE MAP YET, CREATING ONE NOW");
|
|
57
85
|
Object.defineProperty(this, cacheMapName, {
|
|
@@ -66,12 +94,16 @@ function memoize(options) {
|
|
|
66
94
|
console.log({
|
|
67
95
|
cacheMap,
|
|
68
96
|
});
|
|
97
|
+
// check if has memoized value based on hashFn
|
|
69
98
|
if (cacheMap.has(hashKey)) {
|
|
70
99
|
DEBUG && console.log("CACHE HIT");
|
|
100
|
+
// if yes, return cached value
|
|
71
101
|
return cacheMap.get(hashKey);
|
|
72
102
|
}
|
|
73
103
|
DEBUG && console.log("CACHE MISS");
|
|
104
|
+
// if not call original and get result
|
|
74
105
|
const result = originalMethod.apply(this, args);
|
|
106
|
+
// call shouldCache (if passed) with the result or default to true
|
|
75
107
|
let shouldCache = true;
|
|
76
108
|
if (options.shouldCache) {
|
|
77
109
|
shouldCache = options.shouldCache.call(this, result);
|
|
@@ -81,6 +113,7 @@ function memoize(options) {
|
|
|
81
113
|
DEBUG && console.log("CACHING NOW");
|
|
82
114
|
cacheMap.set(hashKey, result);
|
|
83
115
|
}
|
|
116
|
+
// if shouldCache: save result
|
|
84
117
|
DEBUG && console.log("RETURNING", result);
|
|
85
118
|
return result;
|
|
86
119
|
};
|
|
@@ -88,6 +121,14 @@ function memoize(options) {
|
|
|
88
121
|
};
|
|
89
122
|
}
|
|
90
123
|
exports.memoize = memoize;
|
|
124
|
+
/**
|
|
125
|
+
* Calls specific method of the instance before executing the decorated method.
|
|
126
|
+
* This is usable when some of your methods depend on initialize async method, that cannot be invoked in constructor of the class.
|
|
127
|
+
* IMPORTANT: The decorated method must be async.
|
|
128
|
+
* @param {string} methodName The name of the method that will be invoked before calling the decorated method.
|
|
129
|
+
* @param {any[]} methodArgs Args that will be passed to the method that will be invoked before calling the decorated one.
|
|
130
|
+
* @return {any} Result of the decorated method.
|
|
131
|
+
*/
|
|
91
132
|
function invokeBefore(methodName, methodArgs) {
|
|
92
133
|
return (target, propertyKey, descriptor) => {
|
|
93
134
|
const originalValue = descriptor.value;
|
|
@@ -124,6 +165,7 @@ function performanceLog(localInjector) {
|
|
|
124
165
|
const className = target.constructor.name;
|
|
125
166
|
const trackName = `${className}${constants_1.AnalyticsEventLabelDelimiter}${propertyKey}`;
|
|
126
167
|
const performanceService = localInjector.resolve("performanceService");
|
|
168
|
+
//needed for the returned function to have the same name as the original - used in hooks decorator
|
|
127
169
|
const functionWrapper = {
|
|
128
170
|
[originalMethod.name]: function (...args) {
|
|
129
171
|
const start = performanceService.now();
|
|
@@ -149,6 +191,7 @@ function performanceLog(localInjector) {
|
|
|
149
191
|
},
|
|
150
192
|
};
|
|
151
193
|
descriptor.value = functionWrapper[originalMethod.name];
|
|
194
|
+
// used to get parameter names in hooks decorator
|
|
152
195
|
descriptor.value.toString = () => {
|
|
153
196
|
return originalMethod.toString();
|
|
154
197
|
};
|
|
@@ -156,6 +199,7 @@ function performanceLog(localInjector) {
|
|
|
156
199
|
};
|
|
157
200
|
}
|
|
158
201
|
exports.performanceLog = performanceLog;
|
|
202
|
+
// inspired by https://github.com/NativeScript/NativeScript/blob/55dfe25938569edbec89255008e5ad9804901305/tns-core-modules/globals/globals.ts#L121-L137
|
|
159
203
|
function deprecated(additionalInfo, localInjector) {
|
|
160
204
|
const isDeprecatedMessage = " is deprecated.";
|
|
161
205
|
return (target, key, descriptor) => {
|
|
@@ -164,6 +208,7 @@ function deprecated(additionalInfo, localInjector) {
|
|
|
164
208
|
const $logger = localInjector.resolve("logger");
|
|
165
209
|
if (descriptor) {
|
|
166
210
|
if (descriptor.value) {
|
|
211
|
+
// method
|
|
167
212
|
const originalMethod = descriptor.value;
|
|
168
213
|
descriptor.value = function (...args) {
|
|
169
214
|
$logger.warn(`${key.toString()}${isDeprecatedMessage} ${additionalInfo}`);
|
|
@@ -172,6 +217,7 @@ function deprecated(additionalInfo, localInjector) {
|
|
|
172
217
|
return descriptor;
|
|
173
218
|
}
|
|
174
219
|
else {
|
|
220
|
+
// property
|
|
175
221
|
if (descriptor.set) {
|
|
176
222
|
const originalSetter = descriptor.set;
|
|
177
223
|
descriptor.set = function (...args) {
|
|
@@ -190,6 +236,7 @@ function deprecated(additionalInfo, localInjector) {
|
|
|
190
236
|
}
|
|
191
237
|
}
|
|
192
238
|
else {
|
|
239
|
+
// class
|
|
193
240
|
$logger.warn(`${(target &&
|
|
194
241
|
(target.name ||
|
|
195
242
|
(target.constructor && target.constructor.name))) ||
|
|
@@ -199,3 +246,4 @@ function deprecated(additionalInfo, localInjector) {
|
|
|
199
246
|
};
|
|
200
247
|
}
|
|
201
248
|
exports.deprecated = deprecated;
|
|
249
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -24,7 +24,9 @@ const yok_1 = require("./yok");
|
|
|
24
24
|
const constants_1 = require("../constants");
|
|
25
25
|
const semver = require("semver");
|
|
26
26
|
class CommandDispatcher {
|
|
27
|
-
constructor($logger,
|
|
27
|
+
constructor($logger,
|
|
28
|
+
// required by the hooksService
|
|
29
|
+
$injector, $cancellation, $commandsService, $staticConfig, $sysInfo, $options, $versionsService, $packageManager, $terminalSpinnerService) {
|
|
28
30
|
this.$logger = $logger;
|
|
29
31
|
this.$injector = $injector;
|
|
30
32
|
this.$cancellation = $cancellation;
|
|
@@ -42,6 +44,7 @@ class CommandDispatcher {
|
|
|
42
44
|
return this.printVersion();
|
|
43
45
|
}
|
|
44
46
|
if (this.$logger.getLevel() === "TRACE" && !this.$options.json) {
|
|
47
|
+
// CommandDispatcher is called from external CLI's only, so pass the path to their package.json
|
|
45
48
|
this.$logger.trace("Collecting system information...");
|
|
46
49
|
const sysInfo = yield this.$sysInfo.getSysInfo({
|
|
47
50
|
pathToNativeScriptCliPackageJson: path.join(__dirname, "..", "..", "package.json"),
|
|
@@ -73,6 +76,7 @@ class CommandDispatcher {
|
|
|
73
76
|
}
|
|
74
77
|
resolveCommand(commandName, commandArguments, argv) {
|
|
75
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
// just a hook point
|
|
76
80
|
return { commandName, commandArguments, argv };
|
|
77
81
|
});
|
|
78
82
|
}
|
|
@@ -81,6 +85,7 @@ class CommandDispatcher {
|
|
|
81
85
|
if (remaining.length > 0) {
|
|
82
86
|
return remaining[0].toString().toLowerCase();
|
|
83
87
|
}
|
|
88
|
+
// if only <CLI_NAME> is specified on console, show console help
|
|
84
89
|
this.$options.help = true;
|
|
85
90
|
return "";
|
|
86
91
|
}
|
|
@@ -88,6 +93,8 @@ class CommandDispatcher {
|
|
|
88
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
94
|
this.$logger.info(this.$staticConfig.version);
|
|
90
95
|
if (this.$options.json) {
|
|
96
|
+
// we don't check for updates when --json is passed
|
|
97
|
+
// useful for tools that rely on the output of the command
|
|
91
98
|
return;
|
|
92
99
|
}
|
|
93
100
|
const spinner = this.$terminalSpinnerService.createSpinner();
|
|
@@ -115,6 +122,7 @@ class CommandDispatcher {
|
|
|
115
122
|
if (semver.gte(nativescriptCliVersion.currentVersion, nativescriptCliVersion.latestVersion, {
|
|
116
123
|
loose: true,
|
|
117
124
|
})) {
|
|
125
|
+
// up-to-date
|
|
118
126
|
spinner.succeed("Up to date.");
|
|
119
127
|
}
|
|
120
128
|
else {
|
|
@@ -149,3 +157,4 @@ class FutureDispatcher {
|
|
|
149
157
|
}
|
|
150
158
|
}
|
|
151
159
|
yok_1.injector.register("dispatcher", FutureDispatcher, false);
|
|
160
|
+
//# sourceMappingURL=dispatchers.js.map
|
package/lib/common/errors.js
CHANGED
|
@@ -23,7 +23,9 @@ const source_map_1 = require("source-map");
|
|
|
23
23
|
const helpers_1 = require("./helpers");
|
|
24
24
|
const decorators_1 = require("./decorators");
|
|
25
25
|
const yok_1 = require("./yok");
|
|
26
|
+
// we need this to overwrite .stack property (read-only in Error)
|
|
26
27
|
function Exception() {
|
|
28
|
+
/* intentionally left blank */
|
|
27
29
|
}
|
|
28
30
|
Exception.prototype = new Error();
|
|
29
31
|
function resolveCallStack(error) {
|
|
@@ -69,6 +71,7 @@ function resolveCallStack(error) {
|
|
|
69
71
|
})));
|
|
70
72
|
let outputMessage = remapped.join("\n");
|
|
71
73
|
if (outputMessage.indexOf(error.message) === -1) {
|
|
74
|
+
// when fibers throw error in node 0.12.x, the stack does NOT contain the message
|
|
72
75
|
outputMessage = outputMessage.replace(/Error/, "Error: " + error.message);
|
|
73
76
|
}
|
|
74
77
|
return outputMessage;
|
|
@@ -93,7 +96,9 @@ function installUncaughtExceptionListener(actionOnException) {
|
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
catch (err) {
|
|
96
|
-
|
|
99
|
+
// In case the handler throws error and we do not catch it, we'll go in infinite loop of unhandled rejections.
|
|
100
|
+
// We cannot do anything here as even `console.error` may fail. So just exit the process.
|
|
101
|
+
process.exit(131 /* ErrorCodes.UNHANDLED_REJECTION_FAILURE */);
|
|
97
102
|
}
|
|
98
103
|
});
|
|
99
104
|
process.on("uncaughtException", handler);
|
|
@@ -107,6 +112,7 @@ function tryTrackException(error, localInjector) {
|
|
|
107
112
|
disableAnalytics = localInjector.resolve("staticConfig").disableAnalytics;
|
|
108
113
|
}
|
|
109
114
|
catch (err) {
|
|
115
|
+
// We should get here only in our unit tests.
|
|
110
116
|
disableAnalytics = true;
|
|
111
117
|
}
|
|
112
118
|
if (!disableAnalytics) {
|
|
@@ -115,6 +121,7 @@ function tryTrackException(error, localInjector) {
|
|
|
115
121
|
yield analyticsService.trackException(error, error.message);
|
|
116
122
|
}
|
|
117
123
|
catch (e) {
|
|
124
|
+
// Do not replace with logger due to cyclic dependency
|
|
118
125
|
console.error("Error while reporting exception: " + e);
|
|
119
126
|
}
|
|
120
127
|
}
|
|
@@ -153,9 +160,10 @@ class Errors {
|
|
|
153
160
|
exception.message = $messagesService.getMessage.apply($messagesService, [opts.formatStr].concat(argsArray));
|
|
154
161
|
}
|
|
155
162
|
catch (err) {
|
|
163
|
+
// Ignore
|
|
156
164
|
}
|
|
157
165
|
exception.stack = new Error(exception.message).stack;
|
|
158
|
-
exception.errorCode = opts.errorCode || 127
|
|
166
|
+
exception.errorCode = opts.errorCode || 127 /* ErrorCodes.UNKNOWN */;
|
|
159
167
|
exception.suggestCommandHelp = suggestCommandHelp;
|
|
160
168
|
exception.proxyAuthenticationRequired = !!opts.proxyAuthenticationRequired;
|
|
161
169
|
exception.printOnStdout = opts.printOnStdout;
|
|
@@ -188,10 +196,11 @@ class Errors {
|
|
|
188
196
|
yield printCommandHelpSuggestion();
|
|
189
197
|
}
|
|
190
198
|
yield tryTrackException(ex, this.$injector);
|
|
191
|
-
process.exit(_.isNumber(ex.errorCode) ? ex.errorCode : 127);
|
|
199
|
+
process.exit(_.isNumber(ex.errorCode) ? ex.errorCode : 127 /* ErrorCodes.UNKNOWN */);
|
|
192
200
|
}
|
|
193
201
|
});
|
|
194
202
|
}
|
|
203
|
+
// If you want to activate this function, start Node with flags --nouse_idle_notification and --expose_gc
|
|
195
204
|
verifyHeap(message) {
|
|
196
205
|
if (global.gc) {
|
|
197
206
|
console.log("verifyHeap: '%s'", message);
|
|
@@ -204,3 +213,4 @@ __decorate([
|
|
|
204
213
|
], Errors.prototype, "failWithoutHelp", null);
|
|
205
214
|
exports.Errors = Errors;
|
|
206
215
|
yok_1.injector.register("errors", Errors);
|
|
216
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -30,6 +30,7 @@ const os_1 = require("os");
|
|
|
30
30
|
const detectNewline = require("detect-newline");
|
|
31
31
|
const archiver_1 = require("archiver");
|
|
32
32
|
const stringifyPackage = require("stringify-package");
|
|
33
|
+
// TODO: Add .d.ts for mkdirp module (or use it from @types repo).
|
|
33
34
|
const mkdirp = require("mkdirp");
|
|
34
35
|
let FileSystem = FileSystem_1 = class FileSystem {
|
|
35
36
|
constructor($injector) {
|
|
@@ -37,6 +38,7 @@ let FileSystem = FileSystem_1 = class FileSystem {
|
|
|
37
38
|
}
|
|
38
39
|
zipFiles(zipFile, files, zipPathCallback) {
|
|
39
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
//we are resolving it here instead of in the constructor, because config has dependency on file system and config shouldn't require logger
|
|
40
42
|
const $logger = this.$injector.resolve("logger");
|
|
41
43
|
const zip = (0, archiver_1.create)("zip", {
|
|
42
44
|
zlib: {
|
|
@@ -75,10 +77,10 @@ let FileSystem = FileSystem_1 = class FileSystem {
|
|
|
75
77
|
proc = (0, path_1.join)(__dirname, "resources/platform-tools/unzip/win32/unzip");
|
|
76
78
|
}
|
|
77
79
|
else if ($hostInfo.isDarwin) {
|
|
78
|
-
proc = "unzip";
|
|
80
|
+
proc = "unzip"; // darwin unzip is info-zip
|
|
79
81
|
}
|
|
80
82
|
else if ($hostInfo.isLinux) {
|
|
81
|
-
proc = "unzip";
|
|
83
|
+
proc = "unzip"; // linux unzip is info-zip
|
|
82
84
|
}
|
|
83
85
|
if (!isCaseSensitive) {
|
|
84
86
|
zipFile = this.findFileCaseInsensitive(zipFile);
|
|
@@ -120,6 +122,7 @@ let FileSystem = FileSystem_1 = class FileSystem {
|
|
|
120
122
|
}
|
|
121
123
|
catch (err) {
|
|
122
124
|
if (err && err.code !== "ENOENT") {
|
|
125
|
+
// ignore "file doesn't exist" error
|
|
123
126
|
throw err;
|
|
124
127
|
}
|
|
125
128
|
}
|
|
@@ -158,6 +161,7 @@ let FileSystem = FileSystem_1 = class FileSystem {
|
|
|
158
161
|
}
|
|
159
162
|
});
|
|
160
163
|
if (root) {
|
|
164
|
+
// console.log("root", paths);
|
|
161
165
|
return Array.from(paths.values()).reduce((sum, current) => sum + current, 0);
|
|
162
166
|
}
|
|
163
167
|
};
|
|
@@ -232,6 +236,8 @@ let FileSystem = FileSystem_1 = class FileSystem {
|
|
|
232
236
|
writeFile(filename, data, encoding) {
|
|
233
237
|
this.createDirectory((0, path_1.dirname)(filename));
|
|
234
238
|
if (!data) {
|
|
239
|
+
// node 14 will no longer coerce unsupported input to strings anymore.
|
|
240
|
+
// clean any null or undefined data
|
|
235
241
|
data = "";
|
|
236
242
|
}
|
|
237
243
|
fs.writeFileSync(filename, data, { encoding: encoding });
|
|
@@ -262,6 +268,8 @@ let FileSystem = FileSystem_1 = class FileSystem {
|
|
|
262
268
|
return;
|
|
263
269
|
}
|
|
264
270
|
this.createDirectory((0, path_1.dirname)(destinationFileName));
|
|
271
|
+
// MobileApplication.app is resolved as a directory on Mac,
|
|
272
|
+
// therefore we need to copy it recursively as it's not a single file.
|
|
265
273
|
shelljs.cp("-rf", sourceFileName, destinationFileName);
|
|
266
274
|
const err = shelljs.error();
|
|
267
275
|
if (err) {
|
|
@@ -338,8 +346,10 @@ let FileSystem = FileSystem_1 = class FileSystem {
|
|
|
338
346
|
});
|
|
339
347
|
yield this.futureFromEvent(chown, "close");
|
|
340
348
|
}
|
|
349
|
+
// nothing to do on Windows, as chown does not work on this platform
|
|
341
350
|
});
|
|
342
351
|
}
|
|
352
|
+
// filterCallback: function(path: String, stat: fs.Stats): Boolean
|
|
343
353
|
enumerateFilesInDirectorySync(directoryPath, filterCallback, opts, foundFiles) {
|
|
344
354
|
foundFiles = foundFiles || [];
|
|
345
355
|
if (!this.exists(directoryPath)) {
|
|
@@ -439,3 +449,4 @@ FileSystem = FileSystem_1 = __decorate([
|
|
|
439
449
|
injector.register("fs")
|
|
440
450
|
], FileSystem);
|
|
441
451
|
exports.FileSystem = FileSystem;
|
|
452
|
+
//# sourceMappingURL=file-system.js.map
|
package/lib/common/header.js
CHANGED
|
@@ -13,11 +13,13 @@ function printHeader() {
|
|
|
13
13
|
color_1.color.cyanBright.bold("{N} NativeScript "),
|
|
14
14
|
color_1.color.whiteBright.bold("CLI"),
|
|
15
15
|
color_1.color.dim(` [v${version}] `),
|
|
16
|
+
// color.dim(" │"),
|
|
16
17
|
].join("");
|
|
17
18
|
const tagLine = [
|
|
18
19
|
color_1.color.dim("│ "),
|
|
19
20
|
color_1.color.dim(" → "),
|
|
20
21
|
color_1.color.whiteBright.bold("Empower JavaScript with native APIs "),
|
|
22
|
+
// color.dim(" │"),
|
|
21
23
|
].join("");
|
|
22
24
|
const headerLength = (0, color_1.stripColors)(header).length;
|
|
23
25
|
const tagLineLength = (0, color_1.stripColors)(tagLine).length;
|
|
@@ -28,3 +30,4 @@ function printHeader() {
|
|
|
28
30
|
console.info(" " + color_1.color.dim("└" + "─".repeat(width - 1) + "┘"));
|
|
29
31
|
}
|
|
30
32
|
exports.printHeader = printHeader;
|
|
33
|
+
//# sourceMappingURL=header.js.map
|
package/lib/common/helpers.js
CHANGED
|
@@ -32,6 +32,13 @@ function doesCurrentNpmCommandMatch(patterns) {
|
|
|
32
32
|
return result;
|
|
33
33
|
}
|
|
34
34
|
exports.doesCurrentNpmCommandMatch = doesCurrentNpmCommandMatch;
|
|
35
|
+
/**
|
|
36
|
+
* Equivalent of lodash's some, but instead of lambda, just pass array of Regular Expressions.
|
|
37
|
+
* If any of them matches any of the given elements, true is returned.
|
|
38
|
+
* @param {string[]} array Elements to be checked.
|
|
39
|
+
* @param {RegExp[]} patterns Regular expressions to be tested
|
|
40
|
+
* @returns {boolean} True in case any element of the array matches any of the patterns. False otherwise.
|
|
41
|
+
*/
|
|
35
42
|
function someWithRegExps(array, patterns) {
|
|
36
43
|
return _.some(array, (item) => _.some(patterns, (pattern) => !!item.match(pattern)));
|
|
37
44
|
}
|
|
@@ -44,6 +51,7 @@ function getCurrentNpmCommandArgv() {
|
|
|
44
51
|
result = npmConfigArgv.original || [];
|
|
45
52
|
}
|
|
46
53
|
catch (error) {
|
|
54
|
+
// ignore
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
return result;
|
|
@@ -64,6 +72,7 @@ function isInstallingNativeScriptGloballyWithNpm() {
|
|
|
64
72
|
return isInstallCommand && isGlobalCommand && hasNativeScriptPackage;
|
|
65
73
|
}
|
|
66
74
|
function isInstallingNativeScriptGloballyWithYarn() {
|
|
75
|
+
// yarn populates the same env used by npm - npm_config_argv, so check it for yarn specific command
|
|
67
76
|
const isInstallCommand = doesCurrentNpmCommandMatch([/^add$/]);
|
|
68
77
|
const isGlobalCommand = doesCurrentNpmCommandMatch([/^global$/]);
|
|
69
78
|
const hasNativeScriptPackage = doesCurrentNpmCommandMatch([
|
|
@@ -72,6 +81,13 @@ function isInstallingNativeScriptGloballyWithYarn() {
|
|
|
72
81
|
]);
|
|
73
82
|
return isInstallCommand && isGlobalCommand && hasNativeScriptPackage;
|
|
74
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates regular expression from input string.
|
|
86
|
+
* The method replaces all occurences of RegExp special symbols in the input string with \<symbol>.
|
|
87
|
+
* @param {string} input The string from which a regular expression should be created.
|
|
88
|
+
* @param {string} opts RegExp options, for example "gm" - global and multiline.
|
|
89
|
+
* @returns {RegExp} The regular expression created from the input string.
|
|
90
|
+
*/
|
|
75
91
|
function createRegExp(input, opts) {
|
|
76
92
|
if (!input || !_.isString(input)) {
|
|
77
93
|
throw new Error("Input must be a string.");
|
|
@@ -80,7 +96,13 @@ function createRegExp(input, opts) {
|
|
|
80
96
|
return new RegExp(escapedSource, opts);
|
|
81
97
|
}
|
|
82
98
|
exports.createRegExp = createRegExp;
|
|
99
|
+
/**
|
|
100
|
+
* Escapes all special symbols used in regex.
|
|
101
|
+
* @param {string} input The string in which to replace the special regexp symbols.
|
|
102
|
+
* @returns {string} A string in which all regex symbols are escaped.
|
|
103
|
+
*/
|
|
83
104
|
function regExpEscape(input) {
|
|
105
|
+
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
|
84
106
|
return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
85
107
|
}
|
|
86
108
|
exports.regExpEscape = regExpEscape;
|
|
@@ -89,6 +111,7 @@ function getShortPluginName(pluginName) {
|
|
|
89
111
|
}
|
|
90
112
|
exports.getShortPluginName = getShortPluginName;
|
|
91
113
|
function sanitizePluginName(pluginName) {
|
|
114
|
+
// avoid long plugin names, exclude the npm module scope (@scope/nativescript-plugin) from the android plugin name
|
|
92
115
|
return pluginName.split("/").pop();
|
|
93
116
|
}
|
|
94
117
|
function executeActionByChunks(initialData, chunkSize, elementAction) {
|
|
@@ -139,6 +162,13 @@ function deferPromise() {
|
|
|
139
162
|
};
|
|
140
163
|
}
|
|
141
164
|
exports.deferPromise = deferPromise;
|
|
165
|
+
/**
|
|
166
|
+
* Executes all promises and does not stop in case any of them throws.
|
|
167
|
+
* Returns the results of all promises in array when all are successfully resolved.
|
|
168
|
+
* In case any of the promises is rejected, rejects the resulted promise with all accumulated errors.
|
|
169
|
+
* @param {Promise<T>[]} promises Promises to be resolved.
|
|
170
|
+
* @returns {Promise<T[]>} New promise which will be resolved with the results of all promises.
|
|
171
|
+
*/
|
|
142
172
|
function settlePromises(promises) {
|
|
143
173
|
return new Promise((resolve, reject) => {
|
|
144
174
|
let settledPromisesCount = 0;
|
|
@@ -154,6 +184,7 @@ function settlePromises(promises) {
|
|
|
154
184
|
results[index] = result;
|
|
155
185
|
})
|
|
156
186
|
.catch((err) => {
|
|
187
|
+
// Accumulate all errors.
|
|
157
188
|
errors.push(err);
|
|
158
189
|
})
|
|
159
190
|
.then(() => {
|
|
@@ -187,12 +218,14 @@ function bashQuote(s) {
|
|
|
187
218
|
if (s[0] === "'" && s[s.length - 1] === "'") {
|
|
188
219
|
return s;
|
|
189
220
|
}
|
|
221
|
+
// replace ' with '"'"' and wrap in ''
|
|
190
222
|
return "'" + s.replace(/'/g, "'\"'\"'") + "'";
|
|
191
223
|
}
|
|
192
224
|
function cmdQuote(s) {
|
|
193
225
|
if (s[0] === '"' && s[s.length - 1] === '"') {
|
|
194
226
|
return s;
|
|
195
227
|
}
|
|
228
|
+
// replace " with \" and wrap in ""
|
|
196
229
|
return '"' + s.replace(/"/g, '\\"') + '"';
|
|
197
230
|
}
|
|
198
231
|
function quoteString(s) {
|
|
@@ -258,6 +291,9 @@ function isInteractive() {
|
|
|
258
291
|
return result;
|
|
259
292
|
}
|
|
260
293
|
exports.isInteractive = isInteractive;
|
|
294
|
+
/**
|
|
295
|
+
* Checks if current process is running in Text Terminal (TTY)
|
|
296
|
+
*/
|
|
261
297
|
function isRunningInTTY() {
|
|
262
298
|
return (process.stdout &&
|
|
263
299
|
process.stdout.isTTY &&
|
|
@@ -265,6 +301,10 @@ function isRunningInTTY() {
|
|
|
265
301
|
process.stdin.isTTY);
|
|
266
302
|
}
|
|
267
303
|
function isCIEnvironment() {
|
|
304
|
+
// The following CI environments set their own environment variables that we respect:
|
|
305
|
+
// travis: "CI",
|
|
306
|
+
// circleCI: "CI",
|
|
307
|
+
// jenkins: "JENKINS_HOME"
|
|
268
308
|
return !!(process.env && (process.env.CI || process.env.JENKINS_HOME));
|
|
269
309
|
}
|
|
270
310
|
function toBoolean(str) {
|
|
@@ -329,11 +369,11 @@ function getMessageWithBorders(message, spanLength = 3) {
|
|
|
329
369
|
const longestRowLength = message.split("\n").sort((a, b) => {
|
|
330
370
|
return b.length - a.length;
|
|
331
371
|
})[0].length;
|
|
332
|
-
let border = "*".repeat(longestRowLength + 2 * spanLength);
|
|
372
|
+
let border = "*".repeat(longestRowLength + 2 * spanLength); // * 2 for both sides
|
|
333
373
|
if (border.length % 2 === 0) {
|
|
334
|
-
border += "*";
|
|
374
|
+
border += "*"; // the * should always be an odd number in order to get * in each edge (we will remove the even *s below)
|
|
335
375
|
}
|
|
336
|
-
border = border.replace(/\*\*/g, "* ");
|
|
376
|
+
border = border.replace(/\*\*/g, "* "); // ***** => * * * in order to have similar padding to the side borders
|
|
337
377
|
const formatRow = function (row) {
|
|
338
378
|
return (_.padEnd("*", spanLength) +
|
|
339
379
|
_.padEnd(row, border.length - 2 * spanLength) +
|
|
@@ -366,9 +406,11 @@ function trimSymbol(str, symbol) {
|
|
|
366
406
|
}
|
|
367
407
|
exports.trimSymbol = trimSymbol;
|
|
368
408
|
function parseJson(data) {
|
|
409
|
+
// Replace BOM from the header of the file if it exists
|
|
369
410
|
return JSON.parse(data.replace(/^\uFEFF/, ""));
|
|
370
411
|
}
|
|
371
412
|
exports.parseJson = parseJson;
|
|
413
|
+
// TODO: Use generic for predicatе predicate: (element: T|T[]) when TypeScript support this.
|
|
372
414
|
function getFuturesResults(promises, predicate) {
|
|
373
415
|
return __awaiter(this, void 0, void 0, function* () {
|
|
374
416
|
const results = yield Promise.all(promises);
|
|
@@ -376,6 +418,12 @@ function getFuturesResults(promises, predicate) {
|
|
|
376
418
|
});
|
|
377
419
|
}
|
|
378
420
|
exports.getFuturesResults = getFuturesResults;
|
|
421
|
+
/**
|
|
422
|
+
* Appends zeroes to a version string until it reaches a specified length.
|
|
423
|
+
* @param {string} version The version on which to append zeroes.
|
|
424
|
+
* @param requiredVersionLength The required length of the version string.
|
|
425
|
+
* @returns {string} Appended version string. In case input is null, undefined or empty string, it is returned immediately without appending anything.
|
|
426
|
+
*/
|
|
379
427
|
function appendZeroesToVersion(version, requiredVersionLength) {
|
|
380
428
|
if (version) {
|
|
381
429
|
const zeroesToAppend = requiredVersionLength - version.split(".").length;
|
|
@@ -541,6 +589,14 @@ function getProjectFilesConfig(opts) {
|
|
|
541
589
|
return projectFilesConfig;
|
|
542
590
|
}
|
|
543
591
|
exports.getProjectFilesConfig = getProjectFilesConfig;
|
|
592
|
+
/**
|
|
593
|
+
* Tries to find the process id (PID) of the specified application identifier.
|
|
594
|
+
* This is specific implementation for iOS Simulator, where the running applications are real processes.
|
|
595
|
+
* Their PIDs are printed in a specific format in the the logs, once the application is started.
|
|
596
|
+
* @param {string} applicationIdentifier Application Identifier of the app for which we try to get the PID.
|
|
597
|
+
* @param {string} logLine Line that may contain the PID of the process.
|
|
598
|
+
* @returns {string} The PID of the searched application identifier in case it's found in the current line, null otherwise.
|
|
599
|
+
*/
|
|
544
600
|
function getPidFromiOSSimulatorLogs(applicationIdentifier, logLine) {
|
|
545
601
|
if (logLine) {
|
|
546
602
|
const pidRegExp = new RegExp(`${applicationIdentifier}:\\s?(\\d+)`);
|
|
@@ -592,6 +648,7 @@ function stringify(value, replacer, space) {
|
|
|
592
648
|
return JSON.stringify(value, replacer, space || 2);
|
|
593
649
|
}
|
|
594
650
|
exports.stringify = stringify;
|
|
651
|
+
//2019-01-07 18:29:50.745
|
|
595
652
|
function getFixedLengthDateString() {
|
|
596
653
|
const currentDate = new Date();
|
|
597
654
|
const year = currentDate.getFullYear();
|
|
@@ -617,6 +674,28 @@ function getFormattedMilliseconds(date) {
|
|
|
617
674
|
return milliseconds;
|
|
618
675
|
}
|
|
619
676
|
exports.getFormattedMilliseconds = getFormattedMilliseconds;
|
|
677
|
+
//--- begin part copied from AngularJS
|
|
678
|
+
//The MIT License
|
|
679
|
+
//
|
|
680
|
+
//Copyright (c) 2010-2012 Google, Inc. http://angularjs.org
|
|
681
|
+
//
|
|
682
|
+
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
683
|
+
//of this software and associated documentation files (the "Software"), to deal
|
|
684
|
+
//in the Software without restriction, including without limitation the rights
|
|
685
|
+
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
686
|
+
//copies of the Software, and to permit persons to whom the Software is
|
|
687
|
+
//furnished to do so, subject to the following conditions:
|
|
688
|
+
//
|
|
689
|
+
// The above copyright notice and this permission notice shall be included in
|
|
690
|
+
//all copies or substantial portions of the Software.
|
|
691
|
+
//
|
|
692
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
693
|
+
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
694
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
695
|
+
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
696
|
+
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
697
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
698
|
+
//THE SOFTWARE.
|
|
620
699
|
const CLASS_NAME = /class\s+([A-Z].+?)(?:\s+.*?)?\{/;
|
|
621
700
|
const CONSTRUCTOR_ARGS = /constructor\s*([^\(]*)\(\s*([^\)]*)\)/m;
|
|
622
701
|
const FN_NAME_AND_ARGS = /^(?:function)?\s*([^\(]*)\(\s*([^\)]*)\)\s*(=>)?\s*[{_]/m;
|
|
@@ -647,6 +726,11 @@ function annotate(fn) {
|
|
|
647
726
|
return $inject;
|
|
648
727
|
}
|
|
649
728
|
exports.annotate = annotate;
|
|
729
|
+
/**
|
|
730
|
+
* Returns true if all Android signing options are provided, false otherwise.
|
|
731
|
+
* @param {IAndroidSigningData} signingData The signing data to be validated.
|
|
732
|
+
* @return {void}
|
|
733
|
+
*/
|
|
650
734
|
function hasValidAndroidSigning(signingData) {
|
|
651
735
|
const isValid = signingData &&
|
|
652
736
|
signingData.keyStorePath &&
|
|
@@ -656,3 +740,5 @@ function hasValidAndroidSigning(signingData) {
|
|
|
656
740
|
return !!isValid;
|
|
657
741
|
}
|
|
658
742
|
exports.hasValidAndroidSigning = hasValidAndroidSigning;
|
|
743
|
+
//--- end part copied from AngularJS
|
|
744
|
+
//# sourceMappingURL=helpers.js.map
|
package/lib/common/host-info.js
CHANGED
|
@@ -75,6 +75,9 @@ class HostInfo {
|
|
|
75
75
|
catch (err) {
|
|
76
76
|
this.$logger.trace(`Unable to get macOS version from ${systemProfileCommand}. Error is: ${err}`);
|
|
77
77
|
}
|
|
78
|
+
// https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
|
|
79
|
+
// Each macOS version is labeled 10.<version>, where it looks like <versions> is taken from the major version returned by os.release() (16.x.x for example) and subtracting 4 from it.
|
|
80
|
+
// So the version becomes "10.12" in this case.
|
|
78
81
|
const osRelease = this.$osInfo.release();
|
|
79
82
|
const majorVersion = osRelease && _.first(osRelease.split("."));
|
|
80
83
|
macOSVersion = majorVersion && `10.${+majorVersion - 4}`;
|
|
@@ -131,3 +134,4 @@ __decorate([
|
|
|
131
134
|
], HostInfo.prototype, "getMacOSVersion", null);
|
|
132
135
|
exports.HostInfo = HostInfo;
|
|
133
136
|
yok_1.injector.register("hostInfo", HostInfo);
|
|
137
|
+
//# sourceMappingURL=host-info.js.map
|
|
@@ -36,6 +36,9 @@ class HttpClient {
|
|
|
36
36
|
catch (err) {
|
|
37
37
|
if (err.message === HttpClient.STUCK_REQUEST_ERROR_MESSAGE ||
|
|
38
38
|
err.message === HttpClient.STUCK_RESPONSE_ERROR_MESSAGE) {
|
|
39
|
+
// Retry the request immediately because there are at least 10 seconds between the two requests.
|
|
40
|
+
// We have to retry only once the sporadically stuck requests/responses.
|
|
41
|
+
// We can add exponential backoff retry here if we decide that we need to workaround bigger network issues on the client side.
|
|
39
42
|
this.$logger.warn("%s Retrying request to %s...", err.message, options.url || options);
|
|
40
43
|
const retryResult = yield this.httpRequestCore(options, proxySettings);
|
|
41
44
|
return {
|
|
@@ -63,6 +66,7 @@ class HttpClient {
|
|
|
63
66
|
yield this.useProxySettings(proxySettings, cliProxySettings, options, headers, requestProto);
|
|
64
67
|
if (!headers["User-Agent"]) {
|
|
65
68
|
if (!this.defaultUserAgent) {
|
|
69
|
+
//TODO: the user agent client name is also passed explicitly during login and should be kept in sync
|
|
66
70
|
this.defaultUserAgent = `${this.$staticConfig.USER_AGENT_NAME}/${this.$staticConfig.version} (Node.js ${process.versions.node}; ${process.platform}; ${process.arch})`;
|
|
67
71
|
this.$logger.trace("User-Agent: %s", this.defaultUserAgent);
|
|
68
72
|
}
|
|
@@ -91,14 +95,19 @@ class HttpClient {
|
|
|
91
95
|
}).catch((err) => {
|
|
92
96
|
this.$logger.trace("An error occurred while sending the request:", err);
|
|
93
97
|
if (err.response) {
|
|
98
|
+
// The request was made and the server responded with a status code
|
|
99
|
+
// that falls out of the range of 2xx
|
|
94
100
|
const errorMessage = this.getErrorMessage(err.response.status, null);
|
|
95
101
|
err.proxyAuthenticationRequired =
|
|
96
102
|
err.response.status === constants_1.HttpStatusCodes.PROXY_AUTHENTICATION_REQUIRED;
|
|
97
103
|
err.message = errorMessage || err.message;
|
|
98
104
|
}
|
|
99
105
|
else if (err.request) {
|
|
106
|
+
// The request was made but no response was received
|
|
107
|
+
// `err.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
100
108
|
}
|
|
101
109
|
else {
|
|
110
|
+
// Something happened in setting up the request that triggered an Error
|
|
102
111
|
}
|
|
103
112
|
throw err;
|
|
104
113
|
});
|
|
@@ -145,9 +154,18 @@ class HttpClient {
|
|
|
145
154
|
return body;
|
|
146
155
|
}
|
|
147
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* This method respects the proxySettings (or proxyCache) by modifying headers and options passed to http(s) module.
|
|
159
|
+
* @param {IProxySettings} proxySettings The settings passed for this specific call.
|
|
160
|
+
* @param {IProxySettings} cliProxySettings The globally set proxy for this CLI.
|
|
161
|
+
* @param {any}options The object that will be passed to http(s) module.
|
|
162
|
+
* @param {any} headers Headers of the current request.
|
|
163
|
+
* @param {string} requestProto The protocol used for the current request - http or https.
|
|
164
|
+
*/
|
|
148
165
|
useProxySettings(proxySettings, cliProxySettings, options, headers, requestProto) {
|
|
149
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
167
|
const isLocalRequest = options.host === "localhost" || options.host === "127.0.0.1";
|
|
168
|
+
// don't use the proxy for requests to localhost
|
|
151
169
|
if (!isLocalRequest && (proxySettings || cliProxySettings)) {
|
|
152
170
|
const proto = (proxySettings && proxySettings.protocol) ||
|
|
153
171
|
cliProxySettings.protocol ||
|
|
@@ -158,6 +176,7 @@ class HttpClient {
|
|
|
158
176
|
if (cliProxySettings.username && cliProxySettings.password) {
|
|
159
177
|
credentialsPart = `${cliProxySettings.username}:${cliProxySettings.password}@`;
|
|
160
178
|
}
|
|
179
|
+
// Note that proto ends with :
|
|
161
180
|
options.proxy = `${proto}//${credentialsPart}${host}:${port}`;
|
|
162
181
|
options.rejectUnauthorized = proxySettings
|
|
163
182
|
? proxySettings.rejectUnauthorized
|
|
@@ -171,3 +190,4 @@ HttpClient.STUCK_REQUEST_ERROR_MESSAGE = "The request can't receive any response
|
|
|
171
190
|
HttpClient.STUCK_RESPONSE_ERROR_MESSAGE = "Can't receive all parts of the response.";
|
|
172
191
|
exports.HttpClient = HttpClient;
|
|
173
192
|
yok_1.injector.register("httpClient", HttpClient);
|
|
193
|
+
//# sourceMappingURL=http-client.js.map
|