@seedcli/system 0.1.0
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/LICENSE +21 -0
- package/dist/env.d.ts +3 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +4 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/exec.d.ts +3 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +59 -0
- package/dist/exec.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/info.d.ts +11 -0
- package/dist/info.d.ts.map +1 -0
- package/dist/info.js +40 -0
- package/dist/info.js.map +1 -0
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +19 -0
- package/dist/open.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/which.d.ts +7 -0
- package/dist/which.d.ts.map +1 -0
- package/dist/which.js +20 -0
- package/dist/which.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Seed CLI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACrD,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC"}
|
package/dist/env.js
ADDED
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,YAAqB;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC;AACzC,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class ExecError extends Error {
|
|
2
|
+
command: string;
|
|
3
|
+
exitCode: number;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
constructor(command: string, exitCode: number, stdout: string, stderr: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class ExecTimeoutError extends Error {
|
|
9
|
+
command: string;
|
|
10
|
+
timeout: number;
|
|
11
|
+
constructor(command: string, timeout: number);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;gBAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ7E;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;gBAEJ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAM5C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class ExecError extends Error {
|
|
2
|
+
command;
|
|
3
|
+
exitCode;
|
|
4
|
+
stdout;
|
|
5
|
+
stderr;
|
|
6
|
+
constructor(command, exitCode, stdout, stderr) {
|
|
7
|
+
super(`Command failed: ${command} (exit code ${exitCode})\n${stderr}`);
|
|
8
|
+
this.name = "ExecError";
|
|
9
|
+
this.command = command;
|
|
10
|
+
this.exitCode = exitCode;
|
|
11
|
+
this.stdout = stdout;
|
|
12
|
+
this.stderr = stderr;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class ExecTimeoutError extends Error {
|
|
16
|
+
command;
|
|
17
|
+
timeout;
|
|
18
|
+
constructor(command, timeout) {
|
|
19
|
+
super(`Command timed out after ${timeout}ms: ${command}`);
|
|
20
|
+
this.name = "ExecTimeoutError";
|
|
21
|
+
this.command = command;
|
|
22
|
+
this.timeout = timeout;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAU,SAAQ,KAAK;IACnC,OAAO,CAAS;IAChB,QAAQ,CAAS;IACjB,MAAM,CAAS;IACf,MAAM,CAAS;IAEf,YAAY,OAAe,EAAE,QAAgB,EAAE,MAAc,EAAE,MAAc;QAC5E,KAAK,CAAC,mBAAmB,OAAO,eAAe,QAAQ,MAAM,MAAM,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAED,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAC1C,OAAO,CAAS;IAChB,OAAO,CAAS;IAEhB,YAAY,OAAe,EAAE,OAAe;QAC3C,KAAK,CAAC,2BAA2B,OAAO,OAAO,OAAO,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;CACD"}
|
package/dist/exec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE1D,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAqEtF"}
|
package/dist/exec.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ExecError, ExecTimeoutError } from "./errors.js";
|
|
2
|
+
export async function exec(command, options) {
|
|
3
|
+
const throwOnError = options?.throwOnError ?? true;
|
|
4
|
+
const useShell = options?.shell ?? true;
|
|
5
|
+
const isWin = process.platform === "win32";
|
|
6
|
+
const args = useShell
|
|
7
|
+
? isWin
|
|
8
|
+
? ["cmd", "/c", command]
|
|
9
|
+
: ["sh", "-c", command]
|
|
10
|
+
: command.split(/\s+/);
|
|
11
|
+
const cmd = args[0];
|
|
12
|
+
const cmdArgs = args.slice(1);
|
|
13
|
+
const proc = Bun.spawn([cmd, ...cmdArgs], {
|
|
14
|
+
cwd: options?.cwd,
|
|
15
|
+
env: options?.env ? { ...process.env, ...options.env } : undefined,
|
|
16
|
+
stdout: options?.stream ? "inherit" : "pipe",
|
|
17
|
+
stderr: options?.stream ? "inherit" : "pipe",
|
|
18
|
+
stdin: options?.stdin ? "pipe" : undefined,
|
|
19
|
+
});
|
|
20
|
+
// Write stdin if provided
|
|
21
|
+
if (options?.stdin && proc.stdin) {
|
|
22
|
+
const data = typeof options.stdin === "string" ? new TextEncoder().encode(options.stdin) : options.stdin;
|
|
23
|
+
proc.stdin.write(data);
|
|
24
|
+
proc.stdin.end();
|
|
25
|
+
}
|
|
26
|
+
// Handle timeout
|
|
27
|
+
if (options?.timeout) {
|
|
28
|
+
let timedOut = false;
|
|
29
|
+
const timer = setTimeout(() => {
|
|
30
|
+
timedOut = true;
|
|
31
|
+
proc.kill("SIGKILL");
|
|
32
|
+
}, options.timeout);
|
|
33
|
+
try {
|
|
34
|
+
const exitCode = await proc.exited;
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
if (timedOut) {
|
|
37
|
+
throw new ExecTimeoutError(command, options.timeout);
|
|
38
|
+
}
|
|
39
|
+
const stdout = options?.stream ? "" : await new Response(proc.stdout).text();
|
|
40
|
+
const stderr = options?.stream ? "" : await new Response(proc.stderr).text();
|
|
41
|
+
if (throwOnError && exitCode !== 0) {
|
|
42
|
+
throw new ExecError(command, exitCode, stdout, stderr);
|
|
43
|
+
}
|
|
44
|
+
return { stdout, stderr, exitCode };
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
throw err;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const exitCode = await proc.exited;
|
|
52
|
+
const stdout = options?.stream ? "" : await new Response(proc.stdout).text();
|
|
53
|
+
const stderr = options?.stream ? "" : await new Response(proc.stderr).text();
|
|
54
|
+
if (throwOnError && exitCode !== 0) {
|
|
55
|
+
throw new ExecError(command, exitCode, stdout, stderr);
|
|
56
|
+
}
|
|
57
|
+
return { stdout, stderr, exitCode };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=exec.js.map
|
package/dist/exec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAe,EAAE,OAAqB;IAChE,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,IAAI,CAAC;IACnD,MAAM,QAAQ,GAAG,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC;IAExC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;IAC3C,MAAM,IAAI,GAAG,QAAQ;QACpB,CAAC,CAAC,KAAK;YACN,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC;YACxB,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC;QACxB,CAAC,CAAC,OAAO,CAAC,KAAK,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,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAE7E,IAAI,YAAY,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { env } from "./env.js";
|
|
2
|
+
export { ExecError, ExecTimeoutError } from "./errors.js";
|
|
3
|
+
export { exec } from "./exec.js";
|
|
4
|
+
export { arch, cpus, hostname, memory, os, platform, uptime } from "./info.js";
|
|
5
|
+
export { open } from "./open.js";
|
|
6
|
+
export declare const shell: typeof Bun.$;
|
|
7
|
+
export type { ExecOptions, ExecResult } from "./types.js";
|
|
8
|
+
export { ExecutableNotFoundError, which, whichOrThrow } from "./which.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,eAAO,MAAM,KAAK,cAAQ,CAAC;AAC3B,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { env } from "./env.js";
|
|
2
|
+
export { ExecError, ExecTimeoutError } from "./errors.js";
|
|
3
|
+
export { exec } from "./exec.js";
|
|
4
|
+
export { arch, cpus, hostname, memory, os, platform, uptime } from "./info.js";
|
|
5
|
+
export { open } from "./open.js";
|
|
6
|
+
export const shell = Bun.$;
|
|
7
|
+
export { ExecutableNotFoundError, which, whichOrThrow } from "./which.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;AAE3B,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/info.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function os(): "macos" | "linux" | "windows";
|
|
2
|
+
export declare function arch(): "x64" | "arm64" | "arm";
|
|
3
|
+
export declare function platform(): NodeJS.Platform;
|
|
4
|
+
export declare function hostname(): string;
|
|
5
|
+
export declare function cpus(): number;
|
|
6
|
+
export declare function memory(): {
|
|
7
|
+
total: number;
|
|
8
|
+
free: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function uptime(): number;
|
|
11
|
+
//# sourceMappingURL=info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"AAEA,wBAAgB,EAAE,IAAI,OAAO,GAAG,OAAO,GAAG,SAAS,CAWlD;AAED,wBAAgB,IAAI,IAAI,KAAK,GAAG,OAAO,GAAG,KAAK,CAK9C;AAED,wBAAgB,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAE1C;AAED,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAED,wBAAgB,MAAM,IAAI;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAKxD;AAED,wBAAgB,MAAM,IAAI,MAAM,CAE/B"}
|
package/dist/info.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import nodeOs from "node:os";
|
|
2
|
+
export function os() {
|
|
3
|
+
switch (process.platform) {
|
|
4
|
+
case "darwin":
|
|
5
|
+
return "macos";
|
|
6
|
+
case "linux":
|
|
7
|
+
return "linux";
|
|
8
|
+
case "win32":
|
|
9
|
+
return "windows";
|
|
10
|
+
default:
|
|
11
|
+
return "linux";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function arch() {
|
|
15
|
+
const a = process.arch;
|
|
16
|
+
if (a === "x64")
|
|
17
|
+
return "x64";
|
|
18
|
+
if (a === "arm64")
|
|
19
|
+
return "arm64";
|
|
20
|
+
return "arm";
|
|
21
|
+
}
|
|
22
|
+
export function platform() {
|
|
23
|
+
return process.platform;
|
|
24
|
+
}
|
|
25
|
+
export function hostname() {
|
|
26
|
+
return nodeOs.hostname();
|
|
27
|
+
}
|
|
28
|
+
export function cpus() {
|
|
29
|
+
return nodeOs.cpus().length;
|
|
30
|
+
}
|
|
31
|
+
export function memory() {
|
|
32
|
+
return {
|
|
33
|
+
total: nodeOs.totalmem(),
|
|
34
|
+
free: nodeOs.freemem(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function uptime() {
|
|
38
|
+
return nodeOs.uptime();
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=info.js.map
|
package/dist/info.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,MAAM,UAAU,EAAE;IACjB,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC1B,KAAK,QAAQ;YACZ,OAAO,OAAO,CAAC;QAChB,KAAK,OAAO;YACX,OAAO,OAAO,CAAC;QAChB,KAAK,OAAO;YACX,OAAO,SAAS,CAAC;QAClB;YACC,OAAO,OAAO,CAAC;IACjB,CAAC;AACF,CAAC;AAED,MAAM,UAAU,IAAI;IACnB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IACvB,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC9B,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IAClC,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,QAAQ;IACvB,OAAO,OAAO,CAAC,QAAQ,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,QAAQ;IACvB,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,IAAI;IACnB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,MAAM;IACrB,OAAO;QACN,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE;QACxB,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE;KACtB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,MAAM;IACrB,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;AACxB,CAAC"}
|
package/dist/open.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../src/open.ts"],"names":[],"mappings":"AAEA,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBxD"}
|
package/dist/open.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { os } from "./info.js";
|
|
2
|
+
export async function open(target) {
|
|
3
|
+
const platform = os();
|
|
4
|
+
let cmd;
|
|
5
|
+
switch (platform) {
|
|
6
|
+
case "macos":
|
|
7
|
+
cmd = ["open", target];
|
|
8
|
+
break;
|
|
9
|
+
case "linux":
|
|
10
|
+
cmd = ["xdg-open", target];
|
|
11
|
+
break;
|
|
12
|
+
case "windows":
|
|
13
|
+
cmd = ["cmd", "/c", "start", "", target];
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
const proc = Bun.spawn(cmd, { stdout: "ignore", stderr: "ignore" });
|
|
17
|
+
await proc.exited;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=open.js.map
|
package/dist/open.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../src/open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,MAAc;IACxC,MAAM,QAAQ,GAAG,EAAE,EAAE,CAAC;IAEtB,IAAI,GAAa,CAAC;IAClB,QAAQ,QAAQ,EAAE,CAAC;QAClB,KAAK,OAAO;YACX,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACvB,MAAM;QACP,KAAK,OAAO;YACX,GAAG,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAC3B,MAAM;QACP,KAAK,SAAS;YACb,GAAG,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;YACzC,MAAM;IACR,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACpE,MAAM,IAAI,CAAC,MAAM,CAAC;AACnB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ExecOptions {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
env?: Record<string, string>;
|
|
4
|
+
stream?: boolean;
|
|
5
|
+
stdin?: string | Buffer;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
throwOnError?: boolean;
|
|
8
|
+
shell?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ExecResult {
|
|
11
|
+
stdout: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
exitCode: number;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/which.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class ExecutableNotFoundError extends Error {
|
|
2
|
+
execName: string;
|
|
3
|
+
constructor(name: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function which(name: string): Promise<string | undefined>;
|
|
6
|
+
export declare function whichOrThrow(name: string): Promise<string>;
|
|
7
|
+
//# sourceMappingURL=which.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"which.d.ts","sourceRoot":"","sources":["../src/which.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,QAAQ,EAAE,MAAM,CAAC;gBAEL,IAAI,EAAE,MAAM;CAOxB;AAED,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAGrE;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMhE"}
|
package/dist/which.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class ExecutableNotFoundError extends Error {
|
|
2
|
+
execName;
|
|
3
|
+
constructor(name) {
|
|
4
|
+
super(`Executable not found: ${name}\nMake sure ${name} is installed and available in your PATH.`);
|
|
5
|
+
this.name = "ExecutableNotFoundError";
|
|
6
|
+
this.execName = name;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export async function which(name) {
|
|
10
|
+
const result = Bun.which(name);
|
|
11
|
+
return result ?? undefined;
|
|
12
|
+
}
|
|
13
|
+
export async function whichOrThrow(name) {
|
|
14
|
+
const result = Bun.which(name);
|
|
15
|
+
if (!result) {
|
|
16
|
+
throw new ExecutableNotFoundError(name);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=which.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"which.js","sourceRoot":"","sources":["../src/which.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACjD,QAAQ,CAAS;IAEjB,YAAY,IAAY;QACvB,KAAK,CACJ,yBAAyB,IAAI,eAAe,IAAI,2CAA2C,CAC3F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,CAAC;CACD;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAY;IACvC,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,MAAM,IAAI,SAAS,CAAC;AAC5B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC9C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@seedcli/system",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "System utilities: exec, shell, which, OS info, open, environment variables",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Rully Ardiansyah <rully@dreamshive.io>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/SeedCLI/seed",
|
|
11
|
+
"directory": "packages/system"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://seedcli.dev",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"cli",
|
|
16
|
+
"system",
|
|
17
|
+
"exec",
|
|
18
|
+
"shell",
|
|
19
|
+
"which",
|
|
20
|
+
"spawn"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"bun": ">=1.3.0"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
]
|
|
40
|
+
}
|