@trayai/tray-sync-cli 1.0.12 → 1.0.14
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/dist/api/resources/me.js +14 -0
- package/dist/api/resources/workflow.js +38 -0
- package/dist/commands/api/api.js +6 -0
- package/dist/commands/api/login.js +91 -0
- package/dist/commands/api/logout.js +39 -0
- package/dist/commands/api/project.js +2 -2
- package/dist/commands/api/shared.js +10 -4
- package/dist/commands/api/workflow.js +166 -0
- package/dist/lib/apiAuth.js +25 -2
- package/dist/lib/apiSessionStore.js +104 -0
- package/dist/lib/browserOpener.js +24 -0
- package/dist/lib/dotenvEdit.js +31 -0
- package/dist/lib/oauth.js +125 -0
- package/dist/lib/oauthCallbackServer.js +97 -0
- package/dist/lib/oauthRefresh.js +65 -0
- package/dist/lib/region.js +1 -0
- package/dist/views/api/workflow.v2.js +21 -0
- package/node_modules/bundle-name/index.js +5 -0
- package/node_modules/bundle-name/license +9 -0
- package/node_modules/bundle-name/package.json +45 -0
- package/node_modules/bundle-name/readme.md +23 -0
- package/node_modules/default-browser/index.d.ts +29 -0
- package/node_modules/default-browser/index.js +34 -0
- package/node_modules/default-browser/license +9 -0
- package/node_modules/default-browser/package.json +54 -0
- package/node_modules/default-browser/readme.md +24 -0
- package/node_modules/default-browser/windows.js +59 -0
- package/node_modules/default-browser-id/index.js +25 -0
- package/node_modules/default-browser-id/license +9 -0
- package/node_modules/default-browser-id/package.json +41 -0
- package/node_modules/default-browser-id/readme.md +19 -0
- package/node_modules/define-lazy-prop/index.d.ts +31 -0
- package/node_modules/define-lazy-prop/index.js +18 -0
- package/node_modules/define-lazy-prop/license +9 -0
- package/node_modules/define-lazy-prop/package.json +51 -0
- package/node_modules/define-lazy-prop/readme.md +55 -0
- package/node_modules/dotenv/CHANGELOG.md +643 -0
- package/node_modules/dotenv/LICENSE +23 -0
- package/node_modules/dotenv/README-es.md +757 -0
- package/node_modules/dotenv/README.md +812 -0
- package/node_modules/dotenv/SECURITY.md +1 -0
- package/node_modules/dotenv/config.d.ts +1 -0
- package/node_modules/dotenv/config.js +9 -0
- package/node_modules/dotenv/lib/cli-options.js +17 -0
- package/node_modules/dotenv/lib/env-options.js +28 -0
- package/node_modules/dotenv/lib/main.d.ts +179 -0
- package/node_modules/dotenv/lib/main.js +423 -0
- package/node_modules/dotenv/package.json +62 -0
- package/node_modules/dotenv/skills/dotenv/SKILL.md +200 -0
- package/node_modules/dotenv/skills/dotenvx/SKILL.md +118 -0
- package/node_modules/graceful-fs/LICENSE +15 -0
- package/node_modules/graceful-fs/README.md +143 -0
- package/node_modules/graceful-fs/clone.js +23 -0
- package/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/node_modules/graceful-fs/package.json +53 -0
- package/node_modules/graceful-fs/polyfills.js +355 -0
- package/node_modules/is-docker/cli.js +5 -0
- package/node_modules/is-docker/index.d.ts +13 -0
- package/node_modules/is-docker/index.js +29 -0
- package/node_modules/is-docker/license +9 -0
- package/node_modules/is-docker/package.json +44 -0
- package/node_modules/is-docker/readme.md +27 -0
- package/node_modules/is-in-ssh/index.d.ts +15 -0
- package/node_modules/is-in-ssh/index.js +7 -0
- package/node_modules/is-in-ssh/license +9 -0
- package/node_modules/is-in-ssh/package.json +43 -0
- package/node_modules/is-in-ssh/readme.md +43 -0
- package/node_modules/is-inside-container/cli.js +5 -0
- package/node_modules/is-inside-container/index.d.ts +13 -0
- package/node_modules/is-inside-container/index.js +23 -0
- package/node_modules/is-inside-container/license +9 -0
- package/node_modules/is-inside-container/package.json +51 -0
- package/node_modules/is-inside-container/readme.md +36 -0
- package/node_modules/is-wsl/index.d.ts +15 -0
- package/node_modules/is-wsl/index.js +36 -0
- package/node_modules/is-wsl/license +9 -0
- package/node_modules/is-wsl/package.json +58 -0
- package/node_modules/is-wsl/readme.md +21 -0
- package/node_modules/open/index.d.ts +158 -0
- package/node_modules/open/index.js +425 -0
- package/node_modules/open/license +9 -0
- package/node_modules/open/package.json +70 -0
- package/node_modules/open/readme.md +197 -0
- package/node_modules/open/xdg-open +1267 -0
- package/node_modules/powershell-utils/index.d.ts +175 -0
- package/node_modules/powershell-utils/index.js +79 -0
- package/node_modules/powershell-utils/license +9 -0
- package/node_modules/powershell-utils/package.json +47 -0
- package/node_modules/powershell-utils/readme.md +209 -0
- package/node_modules/proper-lockfile/CHANGELOG.md +108 -0
- package/node_modules/proper-lockfile/LICENSE +21 -0
- package/node_modules/proper-lockfile/README.md +183 -0
- package/node_modules/proper-lockfile/index.js +40 -0
- package/node_modules/proper-lockfile/lib/adapter.js +85 -0
- package/node_modules/proper-lockfile/lib/lockfile.js +342 -0
- package/node_modules/proper-lockfile/lib/mtime-precision.js +55 -0
- package/node_modules/proper-lockfile/package.json +71 -0
- package/node_modules/retry/.npmignore +3 -0
- package/node_modules/retry/.travis.yml +15 -0
- package/node_modules/retry/License +21 -0
- package/node_modules/retry/Makefile +18 -0
- package/node_modules/retry/README.md +227 -0
- package/node_modules/retry/equation.gif +0 -0
- package/node_modules/retry/example/dns.js +31 -0
- package/node_modules/retry/example/stop.js +40 -0
- package/node_modules/retry/index.js +1 -0
- package/node_modules/retry/lib/retry.js +100 -0
- package/node_modules/retry/lib/retry_operation.js +158 -0
- package/node_modules/retry/package.json +32 -0
- package/node_modules/retry/test/common.js +10 -0
- package/node_modules/retry/test/integration/test-forever.js +24 -0
- package/node_modules/retry/test/integration/test-retry-operation.js +258 -0
- package/node_modules/retry/test/integration/test-retry-wrap.js +101 -0
- package/node_modules/retry/test/integration/test-timeouts.js +69 -0
- package/node_modules/run-applescript/index.d.ts +66 -0
- package/node_modules/run-applescript/index.js +37 -0
- package/node_modules/run-applescript/license +9 -0
- package/node_modules/run-applescript/package.json +42 -0
- package/node_modules/run-applescript/readme.md +78 -0
- package/node_modules/signal-exit/LICENSE.txt +16 -0
- package/node_modules/signal-exit/README.md +39 -0
- package/node_modules/signal-exit/index.js +202 -0
- package/node_modules/signal-exit/package.json +38 -0
- package/node_modules/signal-exit/signals.js +53 -0
- package/node_modules/wsl-utils/index.d.ts +180 -0
- package/node_modules/wsl-utils/index.js +145 -0
- package/node_modules/wsl-utils/license +9 -0
- package/node_modules/wsl-utils/node_modules/powershell-utils/index.d.ts +122 -0
- package/node_modules/wsl-utils/node_modules/powershell-utils/index.js +58 -0
- package/node_modules/wsl-utils/node_modules/powershell-utils/license +9 -0
- package/node_modules/wsl-utils/node_modules/powershell-utils/package.json +47 -0
- package/node_modules/wsl-utils/node_modules/powershell-utils/readme.md +153 -0
- package/node_modules/wsl-utils/package.json +48 -0
- package/node_modules/wsl-utils/readme.md +223 -0
- package/node_modules/wsl-utils/utilities.js +19 -0
- package/package.json +8 -1
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
var constants = require('constants')
|
|
2
|
+
|
|
3
|
+
var origCwd = process.cwd
|
|
4
|
+
var cwd = null
|
|
5
|
+
|
|
6
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
|
|
7
|
+
|
|
8
|
+
process.cwd = function() {
|
|
9
|
+
if (!cwd)
|
|
10
|
+
cwd = origCwd.call(process)
|
|
11
|
+
return cwd
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
process.cwd()
|
|
15
|
+
} catch (er) {}
|
|
16
|
+
|
|
17
|
+
// This check is needed until node.js 12 is required
|
|
18
|
+
if (typeof process.chdir === 'function') {
|
|
19
|
+
var chdir = process.chdir
|
|
20
|
+
process.chdir = function (d) {
|
|
21
|
+
cwd = null
|
|
22
|
+
chdir.call(process, d)
|
|
23
|
+
}
|
|
24
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = patch
|
|
28
|
+
|
|
29
|
+
function patch (fs) {
|
|
30
|
+
// (re-)implement some things that are known busted or missing.
|
|
31
|
+
|
|
32
|
+
// lchmod, broken prior to 0.6.2
|
|
33
|
+
// back-port the fix here.
|
|
34
|
+
if (constants.hasOwnProperty('O_SYMLINK') &&
|
|
35
|
+
process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
36
|
+
patchLchmod(fs)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// lutimes implementation, or no-op
|
|
40
|
+
if (!fs.lutimes) {
|
|
41
|
+
patchLutimes(fs)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// https://github.com/isaacs/node-graceful-fs/issues/4
|
|
45
|
+
// Chown should not fail on einval or eperm if non-root.
|
|
46
|
+
// It should not fail on enosys ever, as this just indicates
|
|
47
|
+
// that a fs doesn't support the intended operation.
|
|
48
|
+
|
|
49
|
+
fs.chown = chownFix(fs.chown)
|
|
50
|
+
fs.fchown = chownFix(fs.fchown)
|
|
51
|
+
fs.lchown = chownFix(fs.lchown)
|
|
52
|
+
|
|
53
|
+
fs.chmod = chmodFix(fs.chmod)
|
|
54
|
+
fs.fchmod = chmodFix(fs.fchmod)
|
|
55
|
+
fs.lchmod = chmodFix(fs.lchmod)
|
|
56
|
+
|
|
57
|
+
fs.chownSync = chownFixSync(fs.chownSync)
|
|
58
|
+
fs.fchownSync = chownFixSync(fs.fchownSync)
|
|
59
|
+
fs.lchownSync = chownFixSync(fs.lchownSync)
|
|
60
|
+
|
|
61
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync)
|
|
62
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync)
|
|
63
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync)
|
|
64
|
+
|
|
65
|
+
fs.stat = statFix(fs.stat)
|
|
66
|
+
fs.fstat = statFix(fs.fstat)
|
|
67
|
+
fs.lstat = statFix(fs.lstat)
|
|
68
|
+
|
|
69
|
+
fs.statSync = statFixSync(fs.statSync)
|
|
70
|
+
fs.fstatSync = statFixSync(fs.fstatSync)
|
|
71
|
+
fs.lstatSync = statFixSync(fs.lstatSync)
|
|
72
|
+
|
|
73
|
+
// if lchmod/lchown do not exist, then make them no-ops
|
|
74
|
+
if (fs.chmod && !fs.lchmod) {
|
|
75
|
+
fs.lchmod = function (path, mode, cb) {
|
|
76
|
+
if (cb) process.nextTick(cb)
|
|
77
|
+
}
|
|
78
|
+
fs.lchmodSync = function () {}
|
|
79
|
+
}
|
|
80
|
+
if (fs.chown && !fs.lchown) {
|
|
81
|
+
fs.lchown = function (path, uid, gid, cb) {
|
|
82
|
+
if (cb) process.nextTick(cb)
|
|
83
|
+
}
|
|
84
|
+
fs.lchownSync = function () {}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// on Windows, A/V software can lock the directory, causing this
|
|
88
|
+
// to fail with an EACCES or EPERM if the directory contains newly
|
|
89
|
+
// created files. Try again on failure, for up to 60 seconds.
|
|
90
|
+
|
|
91
|
+
// Set the timeout this long because some Windows Anti-Virus, such as Parity
|
|
92
|
+
// bit9, may lock files for up to a minute, causing npm package install
|
|
93
|
+
// failures. Also, take care to yield the scheduler. Windows scheduling gives
|
|
94
|
+
// CPU to a busy looping process, which can cause the program causing the lock
|
|
95
|
+
// contention to be starved of CPU by node, so the contention doesn't resolve.
|
|
96
|
+
if (platform === "win32") {
|
|
97
|
+
fs.rename = typeof fs.rename !== 'function' ? fs.rename
|
|
98
|
+
: (function (fs$rename) {
|
|
99
|
+
function rename (from, to, cb) {
|
|
100
|
+
var start = Date.now()
|
|
101
|
+
var backoff = 0;
|
|
102
|
+
fs$rename(from, to, function CB (er) {
|
|
103
|
+
if (er
|
|
104
|
+
&& (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
|
|
105
|
+
&& Date.now() - start < 60000) {
|
|
106
|
+
setTimeout(function() {
|
|
107
|
+
fs.stat(to, function (stater, st) {
|
|
108
|
+
if (stater && stater.code === "ENOENT")
|
|
109
|
+
fs$rename(from, to, CB);
|
|
110
|
+
else
|
|
111
|
+
cb(er)
|
|
112
|
+
})
|
|
113
|
+
}, backoff)
|
|
114
|
+
if (backoff < 100)
|
|
115
|
+
backoff += 10;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (cb) cb(er)
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename)
|
|
122
|
+
return rename
|
|
123
|
+
})(fs.rename)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// if read() returns EAGAIN, then just try it again.
|
|
127
|
+
fs.read = typeof fs.read !== 'function' ? fs.read
|
|
128
|
+
: (function (fs$read) {
|
|
129
|
+
function read (fd, buffer, offset, length, position, callback_) {
|
|
130
|
+
var callback
|
|
131
|
+
if (callback_ && typeof callback_ === 'function') {
|
|
132
|
+
var eagCounter = 0
|
|
133
|
+
callback = function (er, _, __) {
|
|
134
|
+
if (er && er.code === 'EAGAIN' && eagCounter < 10) {
|
|
135
|
+
eagCounter ++
|
|
136
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
|
137
|
+
}
|
|
138
|
+
callback_.apply(this, arguments)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// This ensures `util.promisify` works as it does for native `fs.read`.
|
|
145
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read)
|
|
146
|
+
return read
|
|
147
|
+
})(fs.read)
|
|
148
|
+
|
|
149
|
+
fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
|
|
150
|
+
: (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
|
|
151
|
+
var eagCounter = 0
|
|
152
|
+
while (true) {
|
|
153
|
+
try {
|
|
154
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position)
|
|
155
|
+
} catch (er) {
|
|
156
|
+
if (er.code === 'EAGAIN' && eagCounter < 10) {
|
|
157
|
+
eagCounter ++
|
|
158
|
+
continue
|
|
159
|
+
}
|
|
160
|
+
throw er
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}})(fs.readSync)
|
|
164
|
+
|
|
165
|
+
function patchLchmod (fs) {
|
|
166
|
+
fs.lchmod = function (path, mode, callback) {
|
|
167
|
+
fs.open( path
|
|
168
|
+
, constants.O_WRONLY | constants.O_SYMLINK
|
|
169
|
+
, mode
|
|
170
|
+
, function (err, fd) {
|
|
171
|
+
if (err) {
|
|
172
|
+
if (callback) callback(err)
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
// prefer to return the chmod error, if one occurs,
|
|
176
|
+
// but still try to close, and report closing errors if they occur.
|
|
177
|
+
fs.fchmod(fd, mode, function (err) {
|
|
178
|
+
fs.close(fd, function(err2) {
|
|
179
|
+
if (callback) callback(err || err2)
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
fs.lchmodSync = function (path, mode) {
|
|
186
|
+
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)
|
|
187
|
+
|
|
188
|
+
// prefer to return the chmod error, if one occurs,
|
|
189
|
+
// but still try to close, and report closing errors if they occur.
|
|
190
|
+
var threw = true
|
|
191
|
+
var ret
|
|
192
|
+
try {
|
|
193
|
+
ret = fs.fchmodSync(fd, mode)
|
|
194
|
+
threw = false
|
|
195
|
+
} finally {
|
|
196
|
+
if (threw) {
|
|
197
|
+
try {
|
|
198
|
+
fs.closeSync(fd)
|
|
199
|
+
} catch (er) {}
|
|
200
|
+
} else {
|
|
201
|
+
fs.closeSync(fd)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return ret
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function patchLutimes (fs) {
|
|
209
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
|
|
210
|
+
fs.lutimes = function (path, at, mt, cb) {
|
|
211
|
+
fs.open(path, constants.O_SYMLINK, function (er, fd) {
|
|
212
|
+
if (er) {
|
|
213
|
+
if (cb) cb(er)
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
fs.futimes(fd, at, mt, function (er) {
|
|
217
|
+
fs.close(fd, function (er2) {
|
|
218
|
+
if (cb) cb(er || er2)
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
fs.lutimesSync = function (path, at, mt) {
|
|
225
|
+
var fd = fs.openSync(path, constants.O_SYMLINK)
|
|
226
|
+
var ret
|
|
227
|
+
var threw = true
|
|
228
|
+
try {
|
|
229
|
+
ret = fs.futimesSync(fd, at, mt)
|
|
230
|
+
threw = false
|
|
231
|
+
} finally {
|
|
232
|
+
if (threw) {
|
|
233
|
+
try {
|
|
234
|
+
fs.closeSync(fd)
|
|
235
|
+
} catch (er) {}
|
|
236
|
+
} else {
|
|
237
|
+
fs.closeSync(fd)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return ret
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
} else if (fs.futimes) {
|
|
244
|
+
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
|
|
245
|
+
fs.lutimesSync = function () {}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function chmodFix (orig) {
|
|
250
|
+
if (!orig) return orig
|
|
251
|
+
return function (target, mode, cb) {
|
|
252
|
+
return orig.call(fs, target, mode, function (er) {
|
|
253
|
+
if (chownErOk(er)) er = null
|
|
254
|
+
if (cb) cb.apply(this, arguments)
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function chmodFixSync (orig) {
|
|
260
|
+
if (!orig) return orig
|
|
261
|
+
return function (target, mode) {
|
|
262
|
+
try {
|
|
263
|
+
return orig.call(fs, target, mode)
|
|
264
|
+
} catch (er) {
|
|
265
|
+
if (!chownErOk(er)) throw er
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
function chownFix (orig) {
|
|
272
|
+
if (!orig) return orig
|
|
273
|
+
return function (target, uid, gid, cb) {
|
|
274
|
+
return orig.call(fs, target, uid, gid, function (er) {
|
|
275
|
+
if (chownErOk(er)) er = null
|
|
276
|
+
if (cb) cb.apply(this, arguments)
|
|
277
|
+
})
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function chownFixSync (orig) {
|
|
282
|
+
if (!orig) return orig
|
|
283
|
+
return function (target, uid, gid) {
|
|
284
|
+
try {
|
|
285
|
+
return orig.call(fs, target, uid, gid)
|
|
286
|
+
} catch (er) {
|
|
287
|
+
if (!chownErOk(er)) throw er
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function statFix (orig) {
|
|
293
|
+
if (!orig) return orig
|
|
294
|
+
// Older versions of Node erroneously returned signed integers for
|
|
295
|
+
// uid + gid.
|
|
296
|
+
return function (target, options, cb) {
|
|
297
|
+
if (typeof options === 'function') {
|
|
298
|
+
cb = options
|
|
299
|
+
options = null
|
|
300
|
+
}
|
|
301
|
+
function callback (er, stats) {
|
|
302
|
+
if (stats) {
|
|
303
|
+
if (stats.uid < 0) stats.uid += 0x100000000
|
|
304
|
+
if (stats.gid < 0) stats.gid += 0x100000000
|
|
305
|
+
}
|
|
306
|
+
if (cb) cb.apply(this, arguments)
|
|
307
|
+
}
|
|
308
|
+
return options ? orig.call(fs, target, options, callback)
|
|
309
|
+
: orig.call(fs, target, callback)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function statFixSync (orig) {
|
|
314
|
+
if (!orig) return orig
|
|
315
|
+
// Older versions of Node erroneously returned signed integers for
|
|
316
|
+
// uid + gid.
|
|
317
|
+
return function (target, options) {
|
|
318
|
+
var stats = options ? orig.call(fs, target, options)
|
|
319
|
+
: orig.call(fs, target)
|
|
320
|
+
if (stats) {
|
|
321
|
+
if (stats.uid < 0) stats.uid += 0x100000000
|
|
322
|
+
if (stats.gid < 0) stats.gid += 0x100000000
|
|
323
|
+
}
|
|
324
|
+
return stats;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// ENOSYS means that the fs doesn't support the op. Just ignore
|
|
329
|
+
// that, because it doesn't matter.
|
|
330
|
+
//
|
|
331
|
+
// if there's no getuid, or if getuid() is something other
|
|
332
|
+
// than 0, and the error is EINVAL or EPERM, then just ignore
|
|
333
|
+
// it.
|
|
334
|
+
//
|
|
335
|
+
// This specific case is a silent failure in cp, install, tar,
|
|
336
|
+
// and most other unix tools that manage permissions.
|
|
337
|
+
//
|
|
338
|
+
// When running as root, or if other types of errors are
|
|
339
|
+
// encountered, then it's strict.
|
|
340
|
+
function chownErOk (er) {
|
|
341
|
+
if (!er)
|
|
342
|
+
return true
|
|
343
|
+
|
|
344
|
+
if (er.code === "ENOSYS")
|
|
345
|
+
return true
|
|
346
|
+
|
|
347
|
+
var nonroot = !process.getuid || process.getuid() !== 0
|
|
348
|
+
if (nonroot) {
|
|
349
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
350
|
+
return true
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return false
|
|
354
|
+
}
|
|
355
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Check if the process is running inside a Docker container.
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
```
|
|
6
|
+
import isDocker from 'is-docker';
|
|
7
|
+
|
|
8
|
+
if (isDocker()) {
|
|
9
|
+
console.log('Running inside a Docker container');
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
*/
|
|
13
|
+
export default function isDocker(): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
|
|
3
|
+
let isDockerCached;
|
|
4
|
+
|
|
5
|
+
function hasDockerEnv() {
|
|
6
|
+
try {
|
|
7
|
+
fs.statSync('/.dockerenv');
|
|
8
|
+
return true;
|
|
9
|
+
} catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function hasDockerCGroup() {
|
|
15
|
+
try {
|
|
16
|
+
return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function isDocker() {
|
|
23
|
+
// TODO: Use `??=` when targeting Node.js 16.
|
|
24
|
+
if (isDockerCached === undefined) {
|
|
25
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return isDockerCached;
|
|
29
|
+
}
|
|
@@ -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,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "is-docker",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Check if the process is running inside a Docker container",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/is-docker",
|
|
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": "./index.js",
|
|
15
|
+
"bin": "./cli.js",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "xo && ava && tsd"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"index.js",
|
|
24
|
+
"index.d.ts",
|
|
25
|
+
"cli.js"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"detect",
|
|
29
|
+
"docker",
|
|
30
|
+
"dockerized",
|
|
31
|
+
"container",
|
|
32
|
+
"inside",
|
|
33
|
+
"is",
|
|
34
|
+
"env",
|
|
35
|
+
"environment",
|
|
36
|
+
"process"
|
|
37
|
+
],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"ava": "^3.15.0",
|
|
40
|
+
"sinon": "^11.1.2",
|
|
41
|
+
"tsd": "^0.17.0",
|
|
42
|
+
"xo": "^0.44.0"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# is-docker
|
|
2
|
+
|
|
3
|
+
> Check if the process is running inside a Docker container
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
$ npm install is-docker
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import isDocker from 'is-docker';
|
|
15
|
+
|
|
16
|
+
if (isDocker()) {
|
|
17
|
+
console.log('Running inside a Docker container');
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## CLI
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
$ is-docker
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Exits with code 0 if inside a Docker container and 2 if not.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Check if the process is running in an SSH session.
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
```
|
|
6
|
+
import isInSsh from 'is-in-ssh';
|
|
7
|
+
|
|
8
|
+
if (isInSsh) {
|
|
9
|
+
console.log('Running in an SSH session');
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
*/
|
|
13
|
+
declare const isInSsh: boolean;
|
|
14
|
+
|
|
15
|
+
export default isInSsh;
|
|
@@ -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,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "is-in-ssh",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Check if the process is running in an SSH session",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/is-in-ssh",
|
|
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": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "xo && node --test"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"index.js",
|
|
27
|
+
"index.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"ssh",
|
|
31
|
+
"detect",
|
|
32
|
+
"detection",
|
|
33
|
+
"session",
|
|
34
|
+
"remote",
|
|
35
|
+
"connection",
|
|
36
|
+
"environment",
|
|
37
|
+
"check",
|
|
38
|
+
"is"
|
|
39
|
+
],
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"xo": "^1.2.3"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# is-in-ssh
|
|
2
|
+
|
|
3
|
+
> Check if the process is running in an SSH session
|
|
4
|
+
|
|
5
|
+
Useful for determining if your Node.js process is being executed over SSH, which can affect how you handle operations like opening files, browsers, or using system-specific commands.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install is-in-ssh
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import isInSsh from 'is-in-ssh';
|
|
17
|
+
|
|
18
|
+
if (isInSsh) {
|
|
19
|
+
console.log('Running in an SSH session');
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
The package detects SSH sessions by checking for the presence of standard SSH environment variables:
|
|
26
|
+
|
|
27
|
+
- `SSH_CONNECTION`
|
|
28
|
+
- `SSH_CLIENT`
|
|
29
|
+
- `SSH_TTY`
|
|
30
|
+
|
|
31
|
+
These variables are automatically set by SSH servers when establishing a connection.
|
|
32
|
+
|
|
33
|
+
## Limitations
|
|
34
|
+
|
|
35
|
+
- The detection relies on environment variables, which could theoretically be spoofed or cleared
|
|
36
|
+
- May return `true` for `ssh localhost` connections (which are technically SSH sessions)
|
|
37
|
+
- Environment variables might not be inherited by all child processes or after privilege escalation (e.g., `sudo`)
|
|
38
|
+
|
|
39
|
+
## Related
|
|
40
|
+
|
|
41
|
+
- [is-wsl](https://github.com/sindresorhus/is-wsl) - Check if the process is running inside Windows Subsystem for Linux
|
|
42
|
+
- [is-docker](https://github.com/sindresorhus/is-docker) - Check if the process is running inside a Docker container
|
|
43
|
+
- [is-inside-container](https://github.com/sindresorhus/is-inside-container) - Check if the process is running inside a container
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Check if the process is running inside a container.
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
```
|
|
6
|
+
import isInsideContainer from 'is-inside-container';
|
|
7
|
+
|
|
8
|
+
if (isInsideContainer()) {
|
|
9
|
+
console.log('Running inside a container');
|
|
10
|
+
}
|
|
11
|
+
```
|
|
12
|
+
*/
|
|
13
|
+
export default function isInsideContainer(): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import isDocker from 'is-docker';
|
|
3
|
+
|
|
4
|
+
let cachedResult;
|
|
5
|
+
|
|
6
|
+
// Podman detection
|
|
7
|
+
const hasContainerEnv = () => {
|
|
8
|
+
try {
|
|
9
|
+
fs.statSync('/run/.containerenv');
|
|
10
|
+
return true;
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default function isInsideContainer() {
|
|
17
|
+
// TODO: Use `??=` when targeting Node.js 16.
|
|
18
|
+
if (cachedResult === undefined) {
|
|
19
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return cachedResult;
|
|
23
|
+
}
|
|
@@ -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.
|