tthr 0.0.6
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/chunk-MCKGQKYU.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1766 -0
- package/dist/open-OC46UHP7.js +344 -0
- package/package.json +39 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require
|
|
4
|
+
} from "./chunk-MCKGQKYU.js";
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/open/node_modules/is-docker/index.js
|
|
7
|
+
var require_is_docker = __commonJS({
|
|
8
|
+
"../../node_modules/open/node_modules/is-docker/index.js"(exports, module) {
|
|
9
|
+
"use strict";
|
|
10
|
+
var fs = __require("fs");
|
|
11
|
+
var isDocker;
|
|
12
|
+
function hasDockerEnv() {
|
|
13
|
+
try {
|
|
14
|
+
fs.statSync("/.dockerenv");
|
|
15
|
+
return true;
|
|
16
|
+
} catch (_) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function hasDockerCGroup() {
|
|
21
|
+
try {
|
|
22
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
23
|
+
} catch (_) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
module.exports = () => {
|
|
28
|
+
if (isDocker === void 0) {
|
|
29
|
+
isDocker = hasDockerEnv() || hasDockerCGroup();
|
|
30
|
+
}
|
|
31
|
+
return isDocker;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/open/node_modules/is-wsl/index.js
|
|
37
|
+
var require_is_wsl = __commonJS({
|
|
38
|
+
"../../node_modules/open/node_modules/is-wsl/index.js"(exports, module) {
|
|
39
|
+
"use strict";
|
|
40
|
+
var os = __require("os");
|
|
41
|
+
var fs = __require("fs");
|
|
42
|
+
var isDocker = require_is_docker();
|
|
43
|
+
var isWsl = () => {
|
|
44
|
+
if (process.platform !== "linux") {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
48
|
+
if (isDocker()) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isDocker() : false;
|
|
55
|
+
} catch (_) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (process.env.__IS_WSL_TEST__) {
|
|
60
|
+
module.exports = isWsl;
|
|
61
|
+
} else {
|
|
62
|
+
module.exports = isWsl();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// ../../node_modules/define-lazy-prop/index.js
|
|
68
|
+
var require_define_lazy_prop = __commonJS({
|
|
69
|
+
"../../node_modules/define-lazy-prop/index.js"(exports, module) {
|
|
70
|
+
"use strict";
|
|
71
|
+
module.exports = (object, propertyName, fn) => {
|
|
72
|
+
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
73
|
+
Object.defineProperty(object, propertyName, {
|
|
74
|
+
configurable: true,
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get() {
|
|
77
|
+
const result = fn();
|
|
78
|
+
define(result);
|
|
79
|
+
return result;
|
|
80
|
+
},
|
|
81
|
+
set(value) {
|
|
82
|
+
define(value);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return object;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// ../../node_modules/open/index.js
|
|
91
|
+
var require_open = __commonJS({
|
|
92
|
+
"../../node_modules/open/index.js"(exports, module) {
|
|
93
|
+
var path = __require("path");
|
|
94
|
+
var childProcess = __require("child_process");
|
|
95
|
+
var { promises: fs, constants: fsConstants } = __require("fs");
|
|
96
|
+
var isWsl = require_is_wsl();
|
|
97
|
+
var isDocker = require_is_docker();
|
|
98
|
+
var defineLazyProperty = require_define_lazy_prop();
|
|
99
|
+
var localXdgOpenPath = path.join(__dirname, "xdg-open");
|
|
100
|
+
var { platform, arch } = process;
|
|
101
|
+
var hasContainerEnv = () => {
|
|
102
|
+
try {
|
|
103
|
+
fs.statSync("/run/.containerenv");
|
|
104
|
+
return true;
|
|
105
|
+
} catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var cachedResult;
|
|
110
|
+
function isInsideContainer() {
|
|
111
|
+
if (cachedResult === void 0) {
|
|
112
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
113
|
+
}
|
|
114
|
+
return cachedResult;
|
|
115
|
+
}
|
|
116
|
+
var getWslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
117
|
+
const defaultMountPoint = "/mnt/";
|
|
118
|
+
let mountPoint;
|
|
119
|
+
return async function() {
|
|
120
|
+
if (mountPoint) {
|
|
121
|
+
return mountPoint;
|
|
122
|
+
}
|
|
123
|
+
const configFilePath = "/etc/wsl.conf";
|
|
124
|
+
let isConfigFileExists = false;
|
|
125
|
+
try {
|
|
126
|
+
await fs.access(configFilePath, fsConstants.F_OK);
|
|
127
|
+
isConfigFileExists = true;
|
|
128
|
+
} catch {
|
|
129
|
+
}
|
|
130
|
+
if (!isConfigFileExists) {
|
|
131
|
+
return defaultMountPoint;
|
|
132
|
+
}
|
|
133
|
+
const configContent = await fs.readFile(configFilePath, { encoding: "utf8" });
|
|
134
|
+
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
135
|
+
if (!configMountPoint) {
|
|
136
|
+
return defaultMountPoint;
|
|
137
|
+
}
|
|
138
|
+
mountPoint = configMountPoint.groups.mountPoint.trim();
|
|
139
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
140
|
+
return mountPoint;
|
|
141
|
+
};
|
|
142
|
+
})();
|
|
143
|
+
var pTryEach = async (array, mapper) => {
|
|
144
|
+
let latestError;
|
|
145
|
+
for (const item of array) {
|
|
146
|
+
try {
|
|
147
|
+
return await mapper(item);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
latestError = error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
throw latestError;
|
|
153
|
+
};
|
|
154
|
+
var baseOpen = async (options) => {
|
|
155
|
+
options = {
|
|
156
|
+
wait: false,
|
|
157
|
+
background: false,
|
|
158
|
+
newInstance: false,
|
|
159
|
+
allowNonzeroExitCode: false,
|
|
160
|
+
...options
|
|
161
|
+
};
|
|
162
|
+
if (Array.isArray(options.app)) {
|
|
163
|
+
return pTryEach(options.app, (singleApp) => baseOpen({
|
|
164
|
+
...options,
|
|
165
|
+
app: singleApp
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
let { name: app, arguments: appArguments = [] } = options.app || {};
|
|
169
|
+
appArguments = [...appArguments];
|
|
170
|
+
if (Array.isArray(app)) {
|
|
171
|
+
return pTryEach(app, (appName) => baseOpen({
|
|
172
|
+
...options,
|
|
173
|
+
app: {
|
|
174
|
+
name: appName,
|
|
175
|
+
arguments: appArguments
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
let command;
|
|
180
|
+
const cliArguments = [];
|
|
181
|
+
const childProcessOptions = {};
|
|
182
|
+
if (platform === "darwin") {
|
|
183
|
+
command = "open";
|
|
184
|
+
if (options.wait) {
|
|
185
|
+
cliArguments.push("--wait-apps");
|
|
186
|
+
}
|
|
187
|
+
if (options.background) {
|
|
188
|
+
cliArguments.push("--background");
|
|
189
|
+
}
|
|
190
|
+
if (options.newInstance) {
|
|
191
|
+
cliArguments.push("--new");
|
|
192
|
+
}
|
|
193
|
+
if (app) {
|
|
194
|
+
cliArguments.push("-a", app);
|
|
195
|
+
}
|
|
196
|
+
} else if (platform === "win32" || isWsl && !isInsideContainer() && !app) {
|
|
197
|
+
const mountPoint = await getWslDrivesMountPoint();
|
|
198
|
+
command = isWsl ? `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` : `${process.env.SYSTEMROOT}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
|
|
199
|
+
cliArguments.push(
|
|
200
|
+
"-NoProfile",
|
|
201
|
+
"-NonInteractive",
|
|
202
|
+
"\u2013ExecutionPolicy",
|
|
203
|
+
"Bypass",
|
|
204
|
+
"-EncodedCommand"
|
|
205
|
+
);
|
|
206
|
+
if (!isWsl) {
|
|
207
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
208
|
+
}
|
|
209
|
+
const encodedArguments = ["Start"];
|
|
210
|
+
if (options.wait) {
|
|
211
|
+
encodedArguments.push("-Wait");
|
|
212
|
+
}
|
|
213
|
+
if (app) {
|
|
214
|
+
encodedArguments.push(`"\`"${app}\`""`, "-ArgumentList");
|
|
215
|
+
if (options.target) {
|
|
216
|
+
appArguments.unshift(options.target);
|
|
217
|
+
}
|
|
218
|
+
} else if (options.target) {
|
|
219
|
+
encodedArguments.push(`"${options.target}"`);
|
|
220
|
+
}
|
|
221
|
+
if (appArguments.length > 0) {
|
|
222
|
+
appArguments = appArguments.map((arg) => `"\`"${arg}\`""`);
|
|
223
|
+
encodedArguments.push(appArguments.join(","));
|
|
224
|
+
}
|
|
225
|
+
options.target = Buffer.from(encodedArguments.join(" "), "utf16le").toString("base64");
|
|
226
|
+
} else {
|
|
227
|
+
if (app) {
|
|
228
|
+
command = app;
|
|
229
|
+
} else {
|
|
230
|
+
const isBundled = !__dirname || __dirname === "/";
|
|
231
|
+
let exeLocalXdgOpen = false;
|
|
232
|
+
try {
|
|
233
|
+
await fs.access(localXdgOpenPath, fsConstants.X_OK);
|
|
234
|
+
exeLocalXdgOpen = true;
|
|
235
|
+
} catch {
|
|
236
|
+
}
|
|
237
|
+
const useSystemXdgOpen = process.versions.electron || platform === "android" || isBundled || !exeLocalXdgOpen;
|
|
238
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
239
|
+
}
|
|
240
|
+
if (appArguments.length > 0) {
|
|
241
|
+
cliArguments.push(...appArguments);
|
|
242
|
+
}
|
|
243
|
+
if (!options.wait) {
|
|
244
|
+
childProcessOptions.stdio = "ignore";
|
|
245
|
+
childProcessOptions.detached = true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (options.target) {
|
|
249
|
+
cliArguments.push(options.target);
|
|
250
|
+
}
|
|
251
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
252
|
+
cliArguments.push("--args", ...appArguments);
|
|
253
|
+
}
|
|
254
|
+
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
255
|
+
if (options.wait) {
|
|
256
|
+
return new Promise((resolve, reject) => {
|
|
257
|
+
subprocess.once("error", reject);
|
|
258
|
+
subprocess.once("close", (exitCode) => {
|
|
259
|
+
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
260
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
resolve(subprocess);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
subprocess.unref();
|
|
268
|
+
return subprocess;
|
|
269
|
+
};
|
|
270
|
+
var open = (target, options) => {
|
|
271
|
+
if (typeof target !== "string") {
|
|
272
|
+
throw new TypeError("Expected a `target`");
|
|
273
|
+
}
|
|
274
|
+
return baseOpen({
|
|
275
|
+
...options,
|
|
276
|
+
target
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
var openApp = (name, options) => {
|
|
280
|
+
if (typeof name !== "string") {
|
|
281
|
+
throw new TypeError("Expected a `name`");
|
|
282
|
+
}
|
|
283
|
+
const { arguments: appArguments = [] } = options || {};
|
|
284
|
+
if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {
|
|
285
|
+
throw new TypeError("Expected `appArguments` as Array type");
|
|
286
|
+
}
|
|
287
|
+
return baseOpen({
|
|
288
|
+
...options,
|
|
289
|
+
app: {
|
|
290
|
+
name,
|
|
291
|
+
arguments: appArguments
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
function detectArchBinary(binary) {
|
|
296
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
297
|
+
return binary;
|
|
298
|
+
}
|
|
299
|
+
const { [arch]: archBinary } = binary;
|
|
300
|
+
if (!archBinary) {
|
|
301
|
+
throw new Error(`${arch} is not supported`);
|
|
302
|
+
}
|
|
303
|
+
return archBinary;
|
|
304
|
+
}
|
|
305
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
306
|
+
if (wsl && isWsl) {
|
|
307
|
+
return detectArchBinary(wsl);
|
|
308
|
+
}
|
|
309
|
+
if (!platformBinary) {
|
|
310
|
+
throw new Error(`${platform} is not supported`);
|
|
311
|
+
}
|
|
312
|
+
return detectArchBinary(platformBinary);
|
|
313
|
+
}
|
|
314
|
+
var apps = {};
|
|
315
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
316
|
+
darwin: "google chrome",
|
|
317
|
+
win32: "chrome",
|
|
318
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium"]
|
|
319
|
+
}, {
|
|
320
|
+
wsl: {
|
|
321
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
322
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
323
|
+
}
|
|
324
|
+
}));
|
|
325
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
326
|
+
darwin: "firefox",
|
|
327
|
+
win32: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
|
|
328
|
+
linux: "firefox"
|
|
329
|
+
}, {
|
|
330
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
331
|
+
}));
|
|
332
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
333
|
+
darwin: "microsoft edge",
|
|
334
|
+
win32: "msedge",
|
|
335
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
336
|
+
}, {
|
|
337
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
338
|
+
}));
|
|
339
|
+
open.apps = apps;
|
|
340
|
+
open.openApp = openApp;
|
|
341
|
+
module.exports = open;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
export default require_open();
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tthr",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "Tether CLI - project scaffolding, migrations, and deployment",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tthr": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
22
|
+
"dev": "tsup src/index.ts --format esm --watch",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"start": "TETHER_DEV=true node dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"commander": "^13.0.0",
|
|
28
|
+
"chalk": "^5.4.1",
|
|
29
|
+
"ora": "^8.1.1",
|
|
30
|
+
"prompts": "^2.4.2",
|
|
31
|
+
"fs-extra": "^11.2.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/fs-extra": "^11.0.4",
|
|
35
|
+
"@types/prompts": "^2.4.9",
|
|
36
|
+
"tsup": "^8.3.6",
|
|
37
|
+
"typescript": "^5.7.2"
|
|
38
|
+
}
|
|
39
|
+
}
|