@trayai/tray-sync-cli 1.0.13 → 1.0.15

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.
Files changed (139) hide show
  1. package/dist/api/resources/me.js +14 -0
  2. package/dist/api/resources/project.js +36 -0
  3. package/dist/commands/api/api.js +4 -0
  4. package/dist/commands/api/login.js +91 -0
  5. package/dist/commands/api/logout.js +39 -0
  6. package/dist/commands/api/project.js +116 -4
  7. package/dist/commands/api/shared.js +10 -4
  8. package/dist/commands/api/workflow.js +4 -4
  9. package/dist/commands/promote.js +2 -1
  10. package/dist/lib/apiAuth.js +25 -2
  11. package/dist/lib/apiSessionStore.js +104 -0
  12. package/dist/lib/browserOpener.js +24 -0
  13. package/dist/lib/dotenvEdit.js +31 -0
  14. package/dist/lib/oauth.js +125 -0
  15. package/dist/lib/oauthCallbackServer.js +97 -0
  16. package/dist/lib/oauthRefresh.js +65 -0
  17. package/dist/lib/promoteTarget.js +0 -24
  18. package/dist/lib/region.js +1 -0
  19. package/dist/views/api/project.v2.js +6 -0
  20. package/node_modules/bundle-name/index.js +5 -0
  21. package/node_modules/bundle-name/license +9 -0
  22. package/node_modules/bundle-name/package.json +45 -0
  23. package/node_modules/bundle-name/readme.md +23 -0
  24. package/node_modules/default-browser/index.d.ts +29 -0
  25. package/node_modules/default-browser/index.js +34 -0
  26. package/node_modules/default-browser/license +9 -0
  27. package/node_modules/default-browser/package.json +54 -0
  28. package/node_modules/default-browser/readme.md +24 -0
  29. package/node_modules/default-browser/windows.js +59 -0
  30. package/node_modules/default-browser-id/index.js +25 -0
  31. package/node_modules/default-browser-id/license +9 -0
  32. package/node_modules/default-browser-id/package.json +41 -0
  33. package/node_modules/default-browser-id/readme.md +19 -0
  34. package/node_modules/define-lazy-prop/index.d.ts +31 -0
  35. package/node_modules/define-lazy-prop/index.js +18 -0
  36. package/node_modules/define-lazy-prop/license +9 -0
  37. package/node_modules/define-lazy-prop/package.json +51 -0
  38. package/node_modules/define-lazy-prop/readme.md +55 -0
  39. package/node_modules/dotenv/CHANGELOG.md +643 -0
  40. package/node_modules/dotenv/LICENSE +23 -0
  41. package/node_modules/dotenv/README-es.md +757 -0
  42. package/node_modules/dotenv/README.md +812 -0
  43. package/node_modules/dotenv/SECURITY.md +1 -0
  44. package/node_modules/dotenv/config.d.ts +1 -0
  45. package/node_modules/dotenv/config.js +9 -0
  46. package/node_modules/dotenv/lib/cli-options.js +17 -0
  47. package/node_modules/dotenv/lib/env-options.js +28 -0
  48. package/node_modules/dotenv/lib/main.d.ts +179 -0
  49. package/node_modules/dotenv/lib/main.js +423 -0
  50. package/node_modules/dotenv/package.json +62 -0
  51. package/node_modules/dotenv/skills/dotenv/SKILL.md +200 -0
  52. package/node_modules/dotenv/skills/dotenvx/SKILL.md +118 -0
  53. package/node_modules/graceful-fs/LICENSE +15 -0
  54. package/node_modules/graceful-fs/README.md +143 -0
  55. package/node_modules/graceful-fs/clone.js +23 -0
  56. package/node_modules/graceful-fs/graceful-fs.js +448 -0
  57. package/node_modules/graceful-fs/legacy-streams.js +118 -0
  58. package/node_modules/graceful-fs/package.json +53 -0
  59. package/node_modules/graceful-fs/polyfills.js +355 -0
  60. package/node_modules/is-docker/cli.js +5 -0
  61. package/node_modules/is-docker/index.d.ts +13 -0
  62. package/node_modules/is-docker/index.js +29 -0
  63. package/node_modules/is-docker/license +9 -0
  64. package/node_modules/is-docker/package.json +44 -0
  65. package/node_modules/is-docker/readme.md +27 -0
  66. package/node_modules/is-in-ssh/index.d.ts +15 -0
  67. package/node_modules/is-in-ssh/index.js +7 -0
  68. package/node_modules/is-in-ssh/license +9 -0
  69. package/node_modules/is-in-ssh/package.json +43 -0
  70. package/node_modules/is-in-ssh/readme.md +43 -0
  71. package/node_modules/is-inside-container/cli.js +5 -0
  72. package/node_modules/is-inside-container/index.d.ts +13 -0
  73. package/node_modules/is-inside-container/index.js +23 -0
  74. package/node_modules/is-inside-container/license +9 -0
  75. package/node_modules/is-inside-container/package.json +51 -0
  76. package/node_modules/is-inside-container/readme.md +36 -0
  77. package/node_modules/is-wsl/index.d.ts +15 -0
  78. package/node_modules/is-wsl/index.js +36 -0
  79. package/node_modules/is-wsl/license +9 -0
  80. package/node_modules/is-wsl/package.json +58 -0
  81. package/node_modules/is-wsl/readme.md +21 -0
  82. package/node_modules/open/index.d.ts +158 -0
  83. package/node_modules/open/index.js +425 -0
  84. package/node_modules/open/license +9 -0
  85. package/node_modules/open/package.json +70 -0
  86. package/node_modules/open/readme.md +197 -0
  87. package/node_modules/open/xdg-open +1267 -0
  88. package/node_modules/powershell-utils/index.d.ts +175 -0
  89. package/node_modules/powershell-utils/index.js +79 -0
  90. package/node_modules/powershell-utils/license +9 -0
  91. package/node_modules/powershell-utils/package.json +47 -0
  92. package/node_modules/powershell-utils/readme.md +209 -0
  93. package/node_modules/proper-lockfile/CHANGELOG.md +108 -0
  94. package/node_modules/proper-lockfile/LICENSE +21 -0
  95. package/node_modules/proper-lockfile/README.md +183 -0
  96. package/node_modules/proper-lockfile/index.js +40 -0
  97. package/node_modules/proper-lockfile/lib/adapter.js +85 -0
  98. package/node_modules/proper-lockfile/lib/lockfile.js +342 -0
  99. package/node_modules/proper-lockfile/lib/mtime-precision.js +55 -0
  100. package/node_modules/proper-lockfile/package.json +71 -0
  101. package/node_modules/retry/.npmignore +3 -0
  102. package/node_modules/retry/.travis.yml +15 -0
  103. package/node_modules/retry/License +21 -0
  104. package/node_modules/retry/Makefile +18 -0
  105. package/node_modules/retry/README.md +227 -0
  106. package/node_modules/retry/equation.gif +0 -0
  107. package/node_modules/retry/example/dns.js +31 -0
  108. package/node_modules/retry/example/stop.js +40 -0
  109. package/node_modules/retry/index.js +1 -0
  110. package/node_modules/retry/lib/retry.js +100 -0
  111. package/node_modules/retry/lib/retry_operation.js +158 -0
  112. package/node_modules/retry/package.json +32 -0
  113. package/node_modules/retry/test/common.js +10 -0
  114. package/node_modules/retry/test/integration/test-forever.js +24 -0
  115. package/node_modules/retry/test/integration/test-retry-operation.js +258 -0
  116. package/node_modules/retry/test/integration/test-retry-wrap.js +101 -0
  117. package/node_modules/retry/test/integration/test-timeouts.js +69 -0
  118. package/node_modules/run-applescript/index.d.ts +66 -0
  119. package/node_modules/run-applescript/index.js +37 -0
  120. package/node_modules/run-applescript/license +9 -0
  121. package/node_modules/run-applescript/package.json +42 -0
  122. package/node_modules/run-applescript/readme.md +78 -0
  123. package/node_modules/signal-exit/LICENSE.txt +16 -0
  124. package/node_modules/signal-exit/README.md +39 -0
  125. package/node_modules/signal-exit/index.js +202 -0
  126. package/node_modules/signal-exit/package.json +38 -0
  127. package/node_modules/signal-exit/signals.js +53 -0
  128. package/node_modules/wsl-utils/index.d.ts +180 -0
  129. package/node_modules/wsl-utils/index.js +145 -0
  130. package/node_modules/wsl-utils/license +9 -0
  131. package/node_modules/wsl-utils/node_modules/powershell-utils/index.d.ts +122 -0
  132. package/node_modules/wsl-utils/node_modules/powershell-utils/index.js +58 -0
  133. package/node_modules/wsl-utils/node_modules/powershell-utils/license +9 -0
  134. package/node_modules/wsl-utils/node_modules/powershell-utils/package.json +47 -0
  135. package/node_modules/wsl-utils/node_modules/powershell-utils/readme.md +153 -0
  136. package/node_modules/wsl-utils/package.json +48 -0
  137. package/node_modules/wsl-utils/readme.md +223 -0
  138. package/node_modules/wsl-utils/utilities.js +19 -0
  139. package/package.json +8 -1
@@ -0,0 +1,32 @@
1
+ {
2
+ "author": "Tim Koschützki <tim@debuggable.com> (http://debuggable.com/)",
3
+ "name": "retry",
4
+ "description": "Abstraction for exponential and custom retry strategies for failed operations.",
5
+ "license": "MIT",
6
+ "version": "0.12.0",
7
+ "homepage": "https://github.com/tim-kos/node-retry",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git://github.com/tim-kos/node-retry.git"
11
+ },
12
+ "directories": {
13
+ "lib": "./lib"
14
+ },
15
+ "main": "index",
16
+ "engines": {
17
+ "node": ">= 4"
18
+ },
19
+ "dependencies": {},
20
+ "devDependencies": {
21
+ "fake": "0.2.0",
22
+ "istanbul": "^0.4.5",
23
+ "tape": "^4.8.0"
24
+ },
25
+ "scripts": {
26
+ "test": "./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape ./test/integration/*.js",
27
+ "release:major": "env SEMANTIC=major npm run release",
28
+ "release:minor": "env SEMANTIC=minor npm run release",
29
+ "release:patch": "env SEMANTIC=patch npm run release",
30
+ "release": "npm version ${SEMANTIC:-patch} -m \"Release %s\" && git push && git push --tags && npm publish"
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ var common = module.exports;
2
+ var path = require('path');
3
+
4
+ var rootDir = path.join(__dirname, '..');
5
+ common.dir = {
6
+ lib: rootDir + '/lib'
7
+ };
8
+
9
+ common.assert = require('assert');
10
+ common.fake = require('fake');
@@ -0,0 +1,24 @@
1
+ var common = require('../common');
2
+ var assert = common.assert;
3
+ var retry = require(common.dir.lib + '/retry');
4
+
5
+ (function testForeverUsesFirstTimeout() {
6
+ var operation = retry.operation({
7
+ retries: 0,
8
+ minTimeout: 100,
9
+ maxTimeout: 100,
10
+ forever: true
11
+ });
12
+
13
+ operation.attempt(function(numAttempt) {
14
+ console.log('>numAttempt', numAttempt);
15
+ var err = new Error("foo");
16
+ if (numAttempt == 10) {
17
+ operation.stop();
18
+ }
19
+
20
+ if (operation.retry(err)) {
21
+ return;
22
+ }
23
+ });
24
+ })();
@@ -0,0 +1,258 @@
1
+ var common = require('../common');
2
+ var assert = common.assert;
3
+ var fake = common.fake.create();
4
+ var retry = require(common.dir.lib + '/retry');
5
+
6
+ (function testReset() {
7
+ var error = new Error('some error');
8
+ var operation = retry.operation([1, 2, 3]);
9
+ var attempts = 0;
10
+
11
+ var finalCallback = fake.callback('finalCallback');
12
+ fake.expectAnytime(finalCallback);
13
+
14
+ var expectedFinishes = 1;
15
+ var finishes = 0;
16
+
17
+ var fn = function() {
18
+ operation.attempt(function(currentAttempt) {
19
+ attempts++;
20
+ assert.equal(currentAttempt, attempts);
21
+ if (operation.retry(error)) {
22
+ return;
23
+ }
24
+
25
+ finishes++
26
+ assert.equal(expectedFinishes, finishes);
27
+ assert.strictEqual(attempts, 4);
28
+ assert.strictEqual(operation.attempts(), attempts);
29
+ assert.strictEqual(operation.mainError(), error);
30
+
31
+ if (finishes < 2) {
32
+ attempts = 0;
33
+ expectedFinishes++;
34
+ operation.reset();
35
+ fn()
36
+ } else {
37
+ finalCallback();
38
+ }
39
+ });
40
+ };
41
+
42
+ fn();
43
+ })();
44
+
45
+ (function testErrors() {
46
+ var operation = retry.operation();
47
+
48
+ var error = new Error('some error');
49
+ var error2 = new Error('some other error');
50
+ operation._errors.push(error);
51
+ operation._errors.push(error2);
52
+
53
+ assert.deepEqual(operation.errors(), [error, error2]);
54
+ })();
55
+
56
+ (function testMainErrorReturnsMostFrequentError() {
57
+ var operation = retry.operation();
58
+ var error = new Error('some error');
59
+ var error2 = new Error('some other error');
60
+
61
+ operation._errors.push(error);
62
+ operation._errors.push(error2);
63
+ operation._errors.push(error);
64
+
65
+ assert.strictEqual(operation.mainError(), error);
66
+ })();
67
+
68
+ (function testMainErrorReturnsLastErrorOnEqualCount() {
69
+ var operation = retry.operation();
70
+ var error = new Error('some error');
71
+ var error2 = new Error('some other error');
72
+
73
+ operation._errors.push(error);
74
+ operation._errors.push(error2);
75
+
76
+ assert.strictEqual(operation.mainError(), error2);
77
+ })();
78
+
79
+ (function testAttempt() {
80
+ var operation = retry.operation();
81
+ var fn = new Function();
82
+
83
+ var timeoutOpts = {
84
+ timeout: 1,
85
+ cb: function() {}
86
+ };
87
+ operation.attempt(fn, timeoutOpts);
88
+
89
+ assert.strictEqual(fn, operation._fn);
90
+ assert.strictEqual(timeoutOpts.timeout, operation._operationTimeout);
91
+ assert.strictEqual(timeoutOpts.cb, operation._operationTimeoutCb);
92
+ })();
93
+
94
+ (function testRetry() {
95
+ var error = new Error('some error');
96
+ var operation = retry.operation([1, 2, 3]);
97
+ var attempts = 0;
98
+
99
+ var finalCallback = fake.callback('finalCallback');
100
+ fake.expectAnytime(finalCallback);
101
+
102
+ var fn = function() {
103
+ operation.attempt(function(currentAttempt) {
104
+ attempts++;
105
+ assert.equal(currentAttempt, attempts);
106
+ if (operation.retry(error)) {
107
+ return;
108
+ }
109
+
110
+ assert.strictEqual(attempts, 4);
111
+ assert.strictEqual(operation.attempts(), attempts);
112
+ assert.strictEqual(operation.mainError(), error);
113
+ finalCallback();
114
+ });
115
+ };
116
+
117
+ fn();
118
+ })();
119
+
120
+ (function testRetryForever() {
121
+ var error = new Error('some error');
122
+ var operation = retry.operation({ retries: 3, forever: true });
123
+ var attempts = 0;
124
+
125
+ var finalCallback = fake.callback('finalCallback');
126
+ fake.expectAnytime(finalCallback);
127
+
128
+ var fn = function() {
129
+ operation.attempt(function(currentAttempt) {
130
+ attempts++;
131
+ assert.equal(currentAttempt, attempts);
132
+ if (attempts !== 6 && operation.retry(error)) {
133
+ return;
134
+ }
135
+
136
+ assert.strictEqual(attempts, 6);
137
+ assert.strictEqual(operation.attempts(), attempts);
138
+ assert.strictEqual(operation.mainError(), error);
139
+ finalCallback();
140
+ });
141
+ };
142
+
143
+ fn();
144
+ })();
145
+
146
+ (function testRetryForeverNoRetries() {
147
+ var error = new Error('some error');
148
+ var delay = 50
149
+ var operation = retry.operation({
150
+ retries: null,
151
+ forever: true,
152
+ minTimeout: delay,
153
+ maxTimeout: delay
154
+ });
155
+
156
+ var attempts = 0;
157
+ var startTime = new Date().getTime();
158
+
159
+ var finalCallback = fake.callback('finalCallback');
160
+ fake.expectAnytime(finalCallback);
161
+
162
+ var fn = function() {
163
+ operation.attempt(function(currentAttempt) {
164
+ attempts++;
165
+ assert.equal(currentAttempt, attempts);
166
+ if (attempts !== 4 && operation.retry(error)) {
167
+ return;
168
+ }
169
+
170
+ var endTime = new Date().getTime();
171
+ var minTime = startTime + (delay * 3);
172
+ var maxTime = minTime + 20 // add a little headroom for code execution time
173
+ assert(endTime >= minTime)
174
+ assert(endTime < maxTime)
175
+ assert.strictEqual(attempts, 4);
176
+ assert.strictEqual(operation.attempts(), attempts);
177
+ assert.strictEqual(operation.mainError(), error);
178
+ finalCallback();
179
+ });
180
+ };
181
+
182
+ fn();
183
+ })();
184
+
185
+ (function testStop() {
186
+ var error = new Error('some error');
187
+ var operation = retry.operation([1, 2, 3]);
188
+ var attempts = 0;
189
+
190
+ var finalCallback = fake.callback('finalCallback');
191
+ fake.expectAnytime(finalCallback);
192
+
193
+ var fn = function() {
194
+ operation.attempt(function(currentAttempt) {
195
+ attempts++;
196
+ assert.equal(currentAttempt, attempts);
197
+
198
+ if (attempts === 2) {
199
+ operation.stop();
200
+
201
+ assert.strictEqual(attempts, 2);
202
+ assert.strictEqual(operation.attempts(), attempts);
203
+ assert.strictEqual(operation.mainError(), error);
204
+ finalCallback();
205
+ }
206
+
207
+ if (operation.retry(error)) {
208
+ return;
209
+ }
210
+ });
211
+ };
212
+
213
+ fn();
214
+ })();
215
+
216
+ (function testMaxRetryTime() {
217
+ var error = new Error('some error');
218
+ var maxRetryTime = 30;
219
+ var operation = retry.operation({
220
+ minTimeout: 1,
221
+ maxRetryTime: maxRetryTime
222
+ });
223
+ var attempts = 0;
224
+
225
+ var finalCallback = fake.callback('finalCallback');
226
+ fake.expectAnytime(finalCallback);
227
+
228
+ var longAsyncFunction = function (wait, callback){
229
+ setTimeout(callback, wait);
230
+ };
231
+
232
+ var fn = function() {
233
+ var startTime = new Date().getTime();
234
+ operation.attempt(function(currentAttempt) {
235
+ attempts++;
236
+ assert.equal(currentAttempt, attempts);
237
+
238
+ if (attempts !== 2) {
239
+ if (operation.retry(error)) {
240
+ return;
241
+ }
242
+ } else {
243
+ var curTime = new Date().getTime();
244
+ longAsyncFunction(maxRetryTime - (curTime - startTime - 1), function(){
245
+ if (operation.retry(error)) {
246
+ assert.fail('timeout should be occurred');
247
+ return;
248
+ }
249
+
250
+ assert.strictEqual(operation.mainError(), error);
251
+ finalCallback();
252
+ });
253
+ }
254
+ });
255
+ };
256
+
257
+ fn();
258
+ })();
@@ -0,0 +1,101 @@
1
+ var common = require('../common');
2
+ var assert = common.assert;
3
+ var fake = common.fake.create();
4
+ var retry = require(common.dir.lib + '/retry');
5
+
6
+ function getLib() {
7
+ return {
8
+ fn1: function() {},
9
+ fn2: function() {},
10
+ fn3: function() {}
11
+ };
12
+ }
13
+
14
+ (function wrapAll() {
15
+ var lib = getLib();
16
+ retry.wrap(lib);
17
+ assert.equal(lib.fn1.name, 'bound retryWrapper');
18
+ assert.equal(lib.fn2.name, 'bound retryWrapper');
19
+ assert.equal(lib.fn3.name, 'bound retryWrapper');
20
+ }());
21
+
22
+ (function wrapAllPassOptions() {
23
+ var lib = getLib();
24
+ retry.wrap(lib, {retries: 2});
25
+ assert.equal(lib.fn1.name, 'bound retryWrapper');
26
+ assert.equal(lib.fn2.name, 'bound retryWrapper');
27
+ assert.equal(lib.fn3.name, 'bound retryWrapper');
28
+ assert.equal(lib.fn1.options.retries, 2);
29
+ assert.equal(lib.fn2.options.retries, 2);
30
+ assert.equal(lib.fn3.options.retries, 2);
31
+ }());
32
+
33
+ (function wrapDefined() {
34
+ var lib = getLib();
35
+ retry.wrap(lib, ['fn2', 'fn3']);
36
+ assert.notEqual(lib.fn1.name, 'bound retryWrapper');
37
+ assert.equal(lib.fn2.name, 'bound retryWrapper');
38
+ assert.equal(lib.fn3.name, 'bound retryWrapper');
39
+ }());
40
+
41
+ (function wrapDefinedAndPassOptions() {
42
+ var lib = getLib();
43
+ retry.wrap(lib, {retries: 2}, ['fn2', 'fn3']);
44
+ assert.notEqual(lib.fn1.name, 'bound retryWrapper');
45
+ assert.equal(lib.fn2.name, 'bound retryWrapper');
46
+ assert.equal(lib.fn3.name, 'bound retryWrapper');
47
+ assert.equal(lib.fn2.options.retries, 2);
48
+ assert.equal(lib.fn3.options.retries, 2);
49
+ }());
50
+
51
+ (function runWrappedWithoutError() {
52
+ var callbackCalled;
53
+ var lib = {method: function(a, b, callback) {
54
+ assert.equal(a, 1);
55
+ assert.equal(b, 2);
56
+ assert.equal(typeof callback, 'function');
57
+ callback();
58
+ }};
59
+ retry.wrap(lib);
60
+ lib.method(1, 2, function() {
61
+ callbackCalled = true;
62
+ });
63
+ assert.ok(callbackCalled);
64
+ }());
65
+
66
+ (function runWrappedSeveralWithoutError() {
67
+ var callbacksCalled = 0;
68
+ var lib = {
69
+ fn1: function (a, callback) {
70
+ assert.equal(a, 1);
71
+ assert.equal(typeof callback, 'function');
72
+ callback();
73
+ },
74
+ fn2: function (a, callback) {
75
+ assert.equal(a, 2);
76
+ assert.equal(typeof callback, 'function');
77
+ callback();
78
+ }
79
+ };
80
+ retry.wrap(lib, {}, ['fn1', 'fn2']);
81
+ lib.fn1(1, function() {
82
+ callbacksCalled++;
83
+ });
84
+ lib.fn2(2, function() {
85
+ callbacksCalled++;
86
+ });
87
+ assert.equal(callbacksCalled, 2);
88
+ }());
89
+
90
+ (function runWrappedWithError() {
91
+ var callbackCalled;
92
+ var lib = {method: function(callback) {
93
+ callback(new Error('Some error'));
94
+ }};
95
+ retry.wrap(lib, {retries: 1});
96
+ lib.method(function(err) {
97
+ callbackCalled = true;
98
+ assert.ok(err instanceof Error);
99
+ });
100
+ assert.ok(!callbackCalled);
101
+ }());
@@ -0,0 +1,69 @@
1
+ var common = require('../common');
2
+ var assert = common.assert;
3
+ var retry = require(common.dir.lib + '/retry');
4
+
5
+ (function testDefaultValues() {
6
+ var timeouts = retry.timeouts();
7
+
8
+ assert.equal(timeouts.length, 10);
9
+ assert.equal(timeouts[0], 1000);
10
+ assert.equal(timeouts[1], 2000);
11
+ assert.equal(timeouts[2], 4000);
12
+ })();
13
+
14
+ (function testDefaultValuesWithRandomize() {
15
+ var minTimeout = 5000;
16
+ var timeouts = retry.timeouts({
17
+ minTimeout: minTimeout,
18
+ randomize: true
19
+ });
20
+
21
+ assert.equal(timeouts.length, 10);
22
+ assert.ok(timeouts[0] > minTimeout);
23
+ assert.ok(timeouts[1] > timeouts[0]);
24
+ assert.ok(timeouts[2] > timeouts[1]);
25
+ })();
26
+
27
+ (function testPassedTimeoutsAreUsed() {
28
+ var timeoutsArray = [1000, 2000, 3000];
29
+ var timeouts = retry.timeouts(timeoutsArray);
30
+ assert.deepEqual(timeouts, timeoutsArray);
31
+ assert.notStrictEqual(timeouts, timeoutsArray);
32
+ })();
33
+
34
+ (function testTimeoutsAreWithinBoundaries() {
35
+ var minTimeout = 1000;
36
+ var maxTimeout = 10000;
37
+ var timeouts = retry.timeouts({
38
+ minTimeout: minTimeout,
39
+ maxTimeout: maxTimeout
40
+ });
41
+ for (var i = 0; i < timeouts; i++) {
42
+ assert.ok(timeouts[i] >= minTimeout);
43
+ assert.ok(timeouts[i] <= maxTimeout);
44
+ }
45
+ })();
46
+
47
+ (function testTimeoutsAreIncremental() {
48
+ var timeouts = retry.timeouts();
49
+ var lastTimeout = timeouts[0];
50
+ for (var i = 0; i < timeouts; i++) {
51
+ assert.ok(timeouts[i] > lastTimeout);
52
+ lastTimeout = timeouts[i];
53
+ }
54
+ })();
55
+
56
+ (function testTimeoutsAreIncrementalForFactorsLessThanOne() {
57
+ var timeouts = retry.timeouts({
58
+ retries: 3,
59
+ factor: 0.5
60
+ });
61
+
62
+ var expected = [250, 500, 1000];
63
+ assert.deepEqual(expected, timeouts);
64
+ })();
65
+
66
+ (function testRetries() {
67
+ var timeouts = retry.timeouts({retries: 2});
68
+ assert.strictEqual(timeouts.length, 2);
69
+ })();
@@ -0,0 +1,66 @@
1
+ export type Options = {
2
+ /**
3
+ Change the output style.
4
+
5
+ When `false`, returns the value in a [recompilable source form](https://ss64.com/osx/osascript.html).
6
+
7
+ @default true
8
+
9
+ @example
10
+ ```
11
+ import {runAppleScript} from 'run-applescript';
12
+
13
+ const result = await runAppleScript('return "unicorn"', {humanReadableOutput: false});
14
+
15
+ console.log(result);
16
+ //=> '"unicorn"'
17
+ ```
18
+ */
19
+ readonly humanReadableOutput?: boolean;
20
+
21
+ /**
22
+ An AbortSignal that can be used to cancel the AppleScript execution.
23
+
24
+ Only supported by the async function.
25
+ */
26
+ readonly signal?: AbortSignal;
27
+ };
28
+
29
+ /**
30
+ Run AppleScript asynchronously.
31
+
32
+ @param script - The script to run.
33
+ @returns The script result.
34
+
35
+ @example
36
+ ```
37
+ import {runAppleScript} from 'run-applescript';
38
+
39
+ const result = await runAppleScript('return "unicorn"');
40
+
41
+ console.log(result);
42
+ //=> 'unicorn'
43
+ ```
44
+ */
45
+ export function runAppleScript(
46
+ script: string,
47
+ options?: Options
48
+ ): Promise<string>;
49
+
50
+ /**
51
+ Run AppleScript synchronously.
52
+
53
+ @param script - The script to run.
54
+ @returns The script result.
55
+
56
+ @example
57
+ ```
58
+ import {runAppleScriptSync} from 'run-applescript';
59
+
60
+ const result = runAppleScriptSync('return "unicorn"');
61
+
62
+ console.log(result);
63
+ //=> 'unicorn'
64
+ ```
65
+ */
66
+ export function runAppleScriptSync(script: string, options?: Options): string;
@@ -0,0 +1,37 @@
1
+ import process from 'node:process';
2
+ import {promisify} from 'node:util';
3
+ import {execFile, execFileSync} from 'node:child_process';
4
+
5
+ const execFileAsync = promisify(execFile);
6
+
7
+ export async function runAppleScript(script, {humanReadableOutput = true, signal} = {}) {
8
+ if (process.platform !== 'darwin') {
9
+ throw new Error('macOS only');
10
+ }
11
+
12
+ const outputArguments = humanReadableOutput ? [] : ['-ss'];
13
+
14
+ const execOptions = {};
15
+ if (signal) {
16
+ execOptions.signal = signal;
17
+ }
18
+
19
+ const {stdout} = await execFileAsync('osascript', ['-e', script, outputArguments], execOptions);
20
+ return stdout.trim();
21
+ }
22
+
23
+ export function runAppleScriptSync(script, {humanReadableOutput = true} = {}) {
24
+ if (process.platform !== 'darwin') {
25
+ throw new Error('macOS only');
26
+ }
27
+
28
+ const outputArguments = humanReadableOutput ? [] : ['-ss'];
29
+
30
+ const stdout = execFileSync('osascript', ['-e', script, ...outputArguments], {
31
+ encoding: 'utf8',
32
+ stdio: ['ignore', 'pipe', 'ignore'],
33
+ timeout: 500,
34
+ });
35
+
36
+ return stdout.trim();
37
+ }
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "run-applescript",
3
+ "version": "7.1.0",
4
+ "description": "Run AppleScript and get the result",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/run-applescript",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "author": {
9
+ "name": "Sindre Sorhus",
10
+ "email": "sindresorhus@gmail.com",
11
+ "url": "https://sindresorhus.com"
12
+ },
13
+ "type": "module",
14
+ "exports": {
15
+ "types": "./index.d.ts",
16
+ "default": "./index.js"
17
+ },
18
+ "sideEffects": false,
19
+ "engines": {
20
+ "node": ">=18"
21
+ },
22
+ "scripts": {
23
+ "test": "xo && ava && tsd"
24
+ },
25
+ "files": [
26
+ "index.js",
27
+ "index.d.ts"
28
+ ],
29
+ "keywords": [
30
+ "macos",
31
+ "mac",
32
+ "applescript",
33
+ "osascript",
34
+ "run",
35
+ "execute"
36
+ ],
37
+ "devDependencies": {
38
+ "ava": "^6.0.1",
39
+ "tsd": "^0.30.0",
40
+ "xo": "^0.56.0"
41
+ }
42
+ }