@computesdk/cmd 0.1.0 → 0.3.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/dist/index.cjs +129 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -21
- package/dist/index.d.ts +106 -21
- package/dist/index.js +128 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -110,6 +110,66 @@ declare const cmd: ((command: Command, options?: {
|
|
|
110
110
|
cwd?: string;
|
|
111
111
|
background?: boolean;
|
|
112
112
|
}) => Command) & {
|
|
113
|
+
install: (options?: {
|
|
114
|
+
apiKey?: string;
|
|
115
|
+
version?: string;
|
|
116
|
+
silent?: boolean;
|
|
117
|
+
}) => Command;
|
|
118
|
+
isInstalled: () => Command;
|
|
119
|
+
version: () => Command;
|
|
120
|
+
start: (options?: {
|
|
121
|
+
apiKey?: string;
|
|
122
|
+
accessToken?: string;
|
|
123
|
+
port?: number;
|
|
124
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
125
|
+
}) => Command;
|
|
126
|
+
stop: () => Command;
|
|
127
|
+
health: (options?: {
|
|
128
|
+
host?: string;
|
|
129
|
+
port?: number;
|
|
130
|
+
}) => Command;
|
|
131
|
+
isSetup: (options?: {
|
|
132
|
+
host?: string;
|
|
133
|
+
port?: number;
|
|
134
|
+
}) => Command;
|
|
135
|
+
setup: (options?: {
|
|
136
|
+
apiKey?: string;
|
|
137
|
+
accessToken?: string;
|
|
138
|
+
port?: number;
|
|
139
|
+
version?: string;
|
|
140
|
+
silent?: boolean;
|
|
141
|
+
}) => Command;
|
|
142
|
+
compute: {
|
|
143
|
+
install: (options?: {
|
|
144
|
+
apiKey?: string;
|
|
145
|
+
version?: string;
|
|
146
|
+
silent?: boolean;
|
|
147
|
+
}) => Command;
|
|
148
|
+
isInstalled: () => Command;
|
|
149
|
+
version: () => Command;
|
|
150
|
+
start: (options?: {
|
|
151
|
+
apiKey?: string;
|
|
152
|
+
accessToken?: string;
|
|
153
|
+
port?: number;
|
|
154
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
155
|
+
}) => Command;
|
|
156
|
+
stop: () => Command;
|
|
157
|
+
health: (options?: {
|
|
158
|
+
host?: string;
|
|
159
|
+
port?: number;
|
|
160
|
+
}) => Command;
|
|
161
|
+
setup: (options?: {
|
|
162
|
+
apiKey?: string;
|
|
163
|
+
accessToken?: string;
|
|
164
|
+
port?: number;
|
|
165
|
+
version?: string;
|
|
166
|
+
silent?: boolean;
|
|
167
|
+
}) => Command;
|
|
168
|
+
isSetup: (options?: {
|
|
169
|
+
host?: string;
|
|
170
|
+
port?: number;
|
|
171
|
+
}) => Command;
|
|
172
|
+
};
|
|
113
173
|
echo: (text: string) => Command;
|
|
114
174
|
env: () => Command;
|
|
115
175
|
printenv: (name?: string) => Command;
|
|
@@ -122,12 +182,12 @@ declare const cmd: ((command: Command, options?: {
|
|
|
122
182
|
df: (path?: string, options?: {
|
|
123
183
|
human?: boolean;
|
|
124
184
|
}) => Command;
|
|
125
|
-
du: (path: string,
|
|
185
|
+
du: (path: string, // As command builders
|
|
186
|
+
options?: {
|
|
126
187
|
human?: boolean;
|
|
127
188
|
summarize?: boolean;
|
|
128
189
|
}) => Command;
|
|
129
|
-
sleep: (
|
|
130
|
-
seconds: number) => Command;
|
|
190
|
+
sleep: (seconds: number) => Command;
|
|
131
191
|
date: (format?: string) => Command;
|
|
132
192
|
find: (path: string, options?: {
|
|
133
193
|
name?: string;
|
|
@@ -375,25 +435,16 @@ declare const cmd: ((command: Command, options?: {
|
|
|
375
435
|
mkdir: (path: string, options?: {
|
|
376
436
|
recursive?: boolean;
|
|
377
437
|
}) => Command;
|
|
378
|
-
rm: (path: string, options?: {
|
|
438
|
+
rm: ((path: string, options?: {
|
|
379
439
|
recursive?: boolean;
|
|
380
440
|
force?: boolean;
|
|
381
|
-
}) => Command
|
|
441
|
+
}) => Command) & {
|
|
442
|
+
rf: (path: string) => Command;
|
|
443
|
+
auto: (path: string) => Command;
|
|
444
|
+
};
|
|
382
445
|
cp: (src: string, dest: string, options?: {
|
|
383
446
|
recursive?: boolean;
|
|
384
|
-
}
|
|
385
|
-
* Command builders for common shell operations - callable with shell wrapper + command methods
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* // As shell wrapper (default: sh)
|
|
389
|
-
* cmd(npm.install(), { cwd: '/app' })
|
|
390
|
-
* // => ['sh', '-c', 'cd '/app' && npm install']
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* // As command builders
|
|
394
|
-
* cmd.npm.install('express')
|
|
395
|
-
* // => ['npm', 'install', 'express']
|
|
396
|
-
*/) => Command;
|
|
447
|
+
}) => Command;
|
|
397
448
|
mv: (src: string, dest: string) => Command;
|
|
398
449
|
ls: (path?: string, options?: {
|
|
399
450
|
all?: boolean;
|
|
@@ -437,10 +488,13 @@ declare const cmd: ((command: Command, options?: {
|
|
|
437
488
|
declare const mkdir: (path: string, options?: {
|
|
438
489
|
recursive?: boolean;
|
|
439
490
|
}) => Command;
|
|
440
|
-
declare const rm: (path: string, options?: {
|
|
491
|
+
declare const rm: ((path: string, options?: {
|
|
441
492
|
recursive?: boolean;
|
|
442
493
|
force?: boolean;
|
|
443
|
-
}) => Command
|
|
494
|
+
}) => Command) & {
|
|
495
|
+
rf: (path: string) => Command;
|
|
496
|
+
auto: (path: string) => Command;
|
|
497
|
+
};
|
|
444
498
|
declare const cp: (src: string, dest: string, options?: {
|
|
445
499
|
recursive?: boolean;
|
|
446
500
|
}) => Command;
|
|
@@ -743,5 +797,36 @@ declare const sha256sum: (file: string, options?: {
|
|
|
743
797
|
declare const sha1sum: (file: string, options?: {
|
|
744
798
|
check?: boolean;
|
|
745
799
|
}) => Command;
|
|
800
|
+
declare const compute: {
|
|
801
|
+
install: (options?: {
|
|
802
|
+
apiKey?: string;
|
|
803
|
+
version?: string;
|
|
804
|
+
silent?: boolean;
|
|
805
|
+
}) => Command;
|
|
806
|
+
isInstalled: () => Command;
|
|
807
|
+
version: () => Command;
|
|
808
|
+
start: (options?: {
|
|
809
|
+
apiKey?: string;
|
|
810
|
+
accessToken?: string;
|
|
811
|
+
port?: number;
|
|
812
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
813
|
+
}) => Command;
|
|
814
|
+
stop: () => Command;
|
|
815
|
+
health: (options?: {
|
|
816
|
+
host?: string;
|
|
817
|
+
port?: number;
|
|
818
|
+
}) => Command;
|
|
819
|
+
setup: (options?: {
|
|
820
|
+
apiKey?: string;
|
|
821
|
+
accessToken?: string;
|
|
822
|
+
port?: number;
|
|
823
|
+
version?: string;
|
|
824
|
+
silent?: boolean;
|
|
825
|
+
}) => Command;
|
|
826
|
+
isSetup: (options?: {
|
|
827
|
+
host?: string;
|
|
828
|
+
port?: number;
|
|
829
|
+
}) => Command;
|
|
830
|
+
};
|
|
746
831
|
|
|
747
|
-
export { type Command, type ShellOptions, awk, base64, bash, buildShellCommand, bun, bunx, cat, chmod, chown, cmd, cp, curl, cut, date, cmd as default, deno, df, diff, du, echo, env, esc, escapeArgs, find, git, grep, head, hostname, jq, kill, ln, ls, md5sum, mkdir, mv, net, node, npm, npx, parallel, pip, pipx, pkill, pnpm, poetry, port, printenv, ps, pwd, python, raw, readlink, rm, rsync, sed, sh, sha1sum, sha256sum, shell, shellEscape, sleep, sort, tail, tar, tee, test, timeout, touch, tr, uname, uniq, unzip, uv, wc, wget, which, whoami, xargs, yarn, zsh };
|
|
832
|
+
export { type Command, type ShellOptions, awk, base64, bash, buildShellCommand, bun, bunx, cat, chmod, chown, cmd, compute, cp, curl, cut, date, cmd as default, deno, df, diff, du, echo, env, esc, escapeArgs, find, git, grep, head, hostname, jq, kill, ln, ls, md5sum, mkdir, mv, net, node, npm, npx, parallel, pip, pipx, pkill, pnpm, poetry, port, printenv, ps, pwd, python, raw, readlink, rm, rsync, sed, sh, sha1sum, sha256sum, shell, shellEscape, sleep, sort, tail, tar, tee, test, timeout, touch, tr, uname, uniq, unzip, uv, wc, wget, which, whoami, xargs, yarn, zsh };
|
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,66 @@ declare const cmd: ((command: Command, options?: {
|
|
|
110
110
|
cwd?: string;
|
|
111
111
|
background?: boolean;
|
|
112
112
|
}) => Command) & {
|
|
113
|
+
install: (options?: {
|
|
114
|
+
apiKey?: string;
|
|
115
|
+
version?: string;
|
|
116
|
+
silent?: boolean;
|
|
117
|
+
}) => Command;
|
|
118
|
+
isInstalled: () => Command;
|
|
119
|
+
version: () => Command;
|
|
120
|
+
start: (options?: {
|
|
121
|
+
apiKey?: string;
|
|
122
|
+
accessToken?: string;
|
|
123
|
+
port?: number;
|
|
124
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
125
|
+
}) => Command;
|
|
126
|
+
stop: () => Command;
|
|
127
|
+
health: (options?: {
|
|
128
|
+
host?: string;
|
|
129
|
+
port?: number;
|
|
130
|
+
}) => Command;
|
|
131
|
+
isSetup: (options?: {
|
|
132
|
+
host?: string;
|
|
133
|
+
port?: number;
|
|
134
|
+
}) => Command;
|
|
135
|
+
setup: (options?: {
|
|
136
|
+
apiKey?: string;
|
|
137
|
+
accessToken?: string;
|
|
138
|
+
port?: number;
|
|
139
|
+
version?: string;
|
|
140
|
+
silent?: boolean;
|
|
141
|
+
}) => Command;
|
|
142
|
+
compute: {
|
|
143
|
+
install: (options?: {
|
|
144
|
+
apiKey?: string;
|
|
145
|
+
version?: string;
|
|
146
|
+
silent?: boolean;
|
|
147
|
+
}) => Command;
|
|
148
|
+
isInstalled: () => Command;
|
|
149
|
+
version: () => Command;
|
|
150
|
+
start: (options?: {
|
|
151
|
+
apiKey?: string;
|
|
152
|
+
accessToken?: string;
|
|
153
|
+
port?: number;
|
|
154
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
155
|
+
}) => Command;
|
|
156
|
+
stop: () => Command;
|
|
157
|
+
health: (options?: {
|
|
158
|
+
host?: string;
|
|
159
|
+
port?: number;
|
|
160
|
+
}) => Command;
|
|
161
|
+
setup: (options?: {
|
|
162
|
+
apiKey?: string;
|
|
163
|
+
accessToken?: string;
|
|
164
|
+
port?: number;
|
|
165
|
+
version?: string;
|
|
166
|
+
silent?: boolean;
|
|
167
|
+
}) => Command;
|
|
168
|
+
isSetup: (options?: {
|
|
169
|
+
host?: string;
|
|
170
|
+
port?: number;
|
|
171
|
+
}) => Command;
|
|
172
|
+
};
|
|
113
173
|
echo: (text: string) => Command;
|
|
114
174
|
env: () => Command;
|
|
115
175
|
printenv: (name?: string) => Command;
|
|
@@ -122,12 +182,12 @@ declare const cmd: ((command: Command, options?: {
|
|
|
122
182
|
df: (path?: string, options?: {
|
|
123
183
|
human?: boolean;
|
|
124
184
|
}) => Command;
|
|
125
|
-
du: (path: string,
|
|
185
|
+
du: (path: string, // As command builders
|
|
186
|
+
options?: {
|
|
126
187
|
human?: boolean;
|
|
127
188
|
summarize?: boolean;
|
|
128
189
|
}) => Command;
|
|
129
|
-
sleep: (
|
|
130
|
-
seconds: number) => Command;
|
|
190
|
+
sleep: (seconds: number) => Command;
|
|
131
191
|
date: (format?: string) => Command;
|
|
132
192
|
find: (path: string, options?: {
|
|
133
193
|
name?: string;
|
|
@@ -375,25 +435,16 @@ declare const cmd: ((command: Command, options?: {
|
|
|
375
435
|
mkdir: (path: string, options?: {
|
|
376
436
|
recursive?: boolean;
|
|
377
437
|
}) => Command;
|
|
378
|
-
rm: (path: string, options?: {
|
|
438
|
+
rm: ((path: string, options?: {
|
|
379
439
|
recursive?: boolean;
|
|
380
440
|
force?: boolean;
|
|
381
|
-
}) => Command
|
|
441
|
+
}) => Command) & {
|
|
442
|
+
rf: (path: string) => Command;
|
|
443
|
+
auto: (path: string) => Command;
|
|
444
|
+
};
|
|
382
445
|
cp: (src: string, dest: string, options?: {
|
|
383
446
|
recursive?: boolean;
|
|
384
|
-
}
|
|
385
|
-
* Command builders for common shell operations - callable with shell wrapper + command methods
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* // As shell wrapper (default: sh)
|
|
389
|
-
* cmd(npm.install(), { cwd: '/app' })
|
|
390
|
-
* // => ['sh', '-c', 'cd '/app' && npm install']
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* // As command builders
|
|
394
|
-
* cmd.npm.install('express')
|
|
395
|
-
* // => ['npm', 'install', 'express']
|
|
396
|
-
*/) => Command;
|
|
447
|
+
}) => Command;
|
|
397
448
|
mv: (src: string, dest: string) => Command;
|
|
398
449
|
ls: (path?: string, options?: {
|
|
399
450
|
all?: boolean;
|
|
@@ -437,10 +488,13 @@ declare const cmd: ((command: Command, options?: {
|
|
|
437
488
|
declare const mkdir: (path: string, options?: {
|
|
438
489
|
recursive?: boolean;
|
|
439
490
|
}) => Command;
|
|
440
|
-
declare const rm: (path: string, options?: {
|
|
491
|
+
declare const rm: ((path: string, options?: {
|
|
441
492
|
recursive?: boolean;
|
|
442
493
|
force?: boolean;
|
|
443
|
-
}) => Command
|
|
494
|
+
}) => Command) & {
|
|
495
|
+
rf: (path: string) => Command;
|
|
496
|
+
auto: (path: string) => Command;
|
|
497
|
+
};
|
|
444
498
|
declare const cp: (src: string, dest: string, options?: {
|
|
445
499
|
recursive?: boolean;
|
|
446
500
|
}) => Command;
|
|
@@ -743,5 +797,36 @@ declare const sha256sum: (file: string, options?: {
|
|
|
743
797
|
declare const sha1sum: (file: string, options?: {
|
|
744
798
|
check?: boolean;
|
|
745
799
|
}) => Command;
|
|
800
|
+
declare const compute: {
|
|
801
|
+
install: (options?: {
|
|
802
|
+
apiKey?: string;
|
|
803
|
+
version?: string;
|
|
804
|
+
silent?: boolean;
|
|
805
|
+
}) => Command;
|
|
806
|
+
isInstalled: () => Command;
|
|
807
|
+
version: () => Command;
|
|
808
|
+
start: (options?: {
|
|
809
|
+
apiKey?: string;
|
|
810
|
+
accessToken?: string;
|
|
811
|
+
port?: number;
|
|
812
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
813
|
+
}) => Command;
|
|
814
|
+
stop: () => Command;
|
|
815
|
+
health: (options?: {
|
|
816
|
+
host?: string;
|
|
817
|
+
port?: number;
|
|
818
|
+
}) => Command;
|
|
819
|
+
setup: (options?: {
|
|
820
|
+
apiKey?: string;
|
|
821
|
+
accessToken?: string;
|
|
822
|
+
port?: number;
|
|
823
|
+
version?: string;
|
|
824
|
+
silent?: boolean;
|
|
825
|
+
}) => Command;
|
|
826
|
+
isSetup: (options?: {
|
|
827
|
+
host?: string;
|
|
828
|
+
port?: number;
|
|
829
|
+
}) => Command;
|
|
830
|
+
};
|
|
746
831
|
|
|
747
|
-
export { type Command, type ShellOptions, awk, base64, bash, buildShellCommand, bun, bunx, cat, chmod, chown, cmd, cp, curl, cut, date, cmd as default, deno, df, diff, du, echo, env, esc, escapeArgs, find, git, grep, head, hostname, jq, kill, ln, ls, md5sum, mkdir, mv, net, node, npm, npx, parallel, pip, pipx, pkill, pnpm, poetry, port, printenv, ps, pwd, python, raw, readlink, rm, rsync, sed, sh, sha1sum, sha256sum, shell, shellEscape, sleep, sort, tail, tar, tee, test, timeout, touch, tr, uname, uniq, unzip, uv, wc, wget, which, whoami, xargs, yarn, zsh };
|
|
832
|
+
export { type Command, type ShellOptions, awk, base64, bash, buildShellCommand, bun, bunx, cat, chmod, chown, cmd, compute, cp, curl, cut, date, cmd as default, deno, df, diff, du, echo, env, esc, escapeArgs, find, git, grep, head, hostname, jq, kill, ln, ls, md5sum, mkdir, mv, net, node, npm, npx, parallel, pip, pipx, pkill, pnpm, poetry, port, printenv, ps, pwd, python, raw, readlink, rm, rsync, sed, sh, sha1sum, sha256sum, shell, shellEscape, sleep, sort, tail, tar, tee, test, timeout, touch, tr, uname, uniq, unzip, uv, wc, wget, which, whoami, xargs, yarn, zsh };
|
package/dist/index.js
CHANGED
|
@@ -80,12 +80,29 @@ var mkdir = (path, options) => {
|
|
|
80
80
|
const recursive = options?.recursive ?? true;
|
|
81
81
|
return recursive ? ["mkdir", "-p", path] : ["mkdir", path];
|
|
82
82
|
};
|
|
83
|
-
var rm = (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
83
|
+
var rm = Object.assign(
|
|
84
|
+
(path, options) => {
|
|
85
|
+
const flags = [];
|
|
86
|
+
if (options?.recursive) flags.push("r");
|
|
87
|
+
if (options?.force) flags.push("f");
|
|
88
|
+
return flags.length > 0 ? ["rm", `-${flags.join("")}`, path] : ["rm", path];
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
/**
|
|
92
|
+
* Force remove file or directory (always uses -rf)
|
|
93
|
+
* @example rm.rf('/app/tmp')
|
|
94
|
+
*/
|
|
95
|
+
rf: (path) => ["rm", "-rf", path],
|
|
96
|
+
/**
|
|
97
|
+
* Smart remove - automatically detects if path is a directory and uses appropriate flags
|
|
98
|
+
* Uses a shell one-liner to check if directory and apply -r flag accordingly
|
|
99
|
+
* @example rm.auto('/app/tmp')
|
|
100
|
+
*/
|
|
101
|
+
auto: (path) => {
|
|
102
|
+
return ["sh", "-c", `if [ -d "${path}" ]; then rm -rf "${path}"; else rm -f "${path}"; fi`];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
89
106
|
var cp = (src, dest, options) => {
|
|
90
107
|
return options?.recursive ? ["cp", "-r", src, dest] : ["cp", src, dest];
|
|
91
108
|
};
|
|
@@ -916,6 +933,106 @@ var sha1sum = (file, options) => {
|
|
|
916
933
|
return options?.check ? ["sha1sum", "-c", file] : ["sha1sum", file];
|
|
917
934
|
};
|
|
918
935
|
|
|
936
|
+
// src/commands/compute.ts
|
|
937
|
+
var compute_exports = {};
|
|
938
|
+
__export(compute_exports, {
|
|
939
|
+
compute: () => compute,
|
|
940
|
+
health: () => health,
|
|
941
|
+
install: () => install,
|
|
942
|
+
isInstalled: () => isInstalled,
|
|
943
|
+
isSetup: () => isSetup,
|
|
944
|
+
setup: () => setup,
|
|
945
|
+
start: () => start,
|
|
946
|
+
stop: () => stop,
|
|
947
|
+
version: () => version
|
|
948
|
+
});
|
|
949
|
+
var install = (options) => {
|
|
950
|
+
const installUrl = options?.version ? `https://computesdk.com/install.sh?version=${options.version}` : "https://computesdk.com/install.sh";
|
|
951
|
+
const curlFlags = options?.silent ? "-fsSL" : "-fSL";
|
|
952
|
+
let installCmd = `curl ${curlFlags} ${installUrl} | bash`;
|
|
953
|
+
if (options?.apiKey) {
|
|
954
|
+
installCmd = `COMPUTESDK_API_KEY="${options.apiKey}" ${installCmd}`;
|
|
955
|
+
} else if (typeof process !== "undefined" && process.env?.COMPUTESDK_API_KEY) {
|
|
956
|
+
installCmd = `COMPUTESDK_API_KEY="${process.env.COMPUTESDK_API_KEY}" ${installCmd}`;
|
|
957
|
+
}
|
|
958
|
+
return ["sh", "-c", installCmd];
|
|
959
|
+
};
|
|
960
|
+
var isInstalled = () => {
|
|
961
|
+
return ["sh", "-c", "which compute > /dev/null 2>&1"];
|
|
962
|
+
};
|
|
963
|
+
var version = () => {
|
|
964
|
+
return ["compute", "--version"];
|
|
965
|
+
};
|
|
966
|
+
var start = (options) => {
|
|
967
|
+
const args = ["compute", "start"];
|
|
968
|
+
const apiKey = options?.apiKey || typeof process !== "undefined" && process.env?.COMPUTESDK_API_KEY;
|
|
969
|
+
const accessToken = options?.accessToken;
|
|
970
|
+
if (accessToken) {
|
|
971
|
+
args.push("--access-token", accessToken);
|
|
972
|
+
} else if (apiKey) {
|
|
973
|
+
args.push("--api-key", apiKey);
|
|
974
|
+
}
|
|
975
|
+
if (options?.port) {
|
|
976
|
+
args.push("--port", String(options.port));
|
|
977
|
+
}
|
|
978
|
+
if (options?.logLevel === "debug") {
|
|
979
|
+
args.push("--verbose");
|
|
980
|
+
}
|
|
981
|
+
return args;
|
|
982
|
+
};
|
|
983
|
+
var stop = () => {
|
|
984
|
+
return ["pkill", "-f", "compute start"];
|
|
985
|
+
};
|
|
986
|
+
var health = (options) => {
|
|
987
|
+
const host = options?.host || "localhost";
|
|
988
|
+
const port3 = options?.port || 18080;
|
|
989
|
+
return ["sh", "-c", `curl -f http://${host}:${port3}/health > /dev/null 2>&1`];
|
|
990
|
+
};
|
|
991
|
+
var isSetup = (options) => {
|
|
992
|
+
const host = options?.host || "localhost";
|
|
993
|
+
const port3 = options?.port || 18080;
|
|
994
|
+
return ["sh", "-c", `
|
|
995
|
+
if ! which compute > /dev/null 2>&1; then
|
|
996
|
+
exit 1
|
|
997
|
+
fi
|
|
998
|
+
if ! curl -f http://${host}:${port3}/health > /dev/null 2>&1; then
|
|
999
|
+
exit 1
|
|
1000
|
+
fi
|
|
1001
|
+
exit 0
|
|
1002
|
+
`.trim()];
|
|
1003
|
+
};
|
|
1004
|
+
var setup = (options) => {
|
|
1005
|
+
const apiKey = options?.apiKey || typeof process !== "undefined" && process.env?.COMPUTESDK_API_KEY;
|
|
1006
|
+
const accessToken = options?.accessToken;
|
|
1007
|
+
const installUrl = options?.version ? `https://computesdk.com/install.sh?version=${options.version}` : "https://computesdk.com/install.sh";
|
|
1008
|
+
const curlFlags = options?.silent ? "-fsSL" : "-fSL";
|
|
1009
|
+
let installCmd = `curl ${curlFlags} ${installUrl} | bash`;
|
|
1010
|
+
if (apiKey) {
|
|
1011
|
+
installCmd = `COMPUTESDK_API_KEY="${apiKey}" ${installCmd}`;
|
|
1012
|
+
}
|
|
1013
|
+
let startCmd = "compute start";
|
|
1014
|
+
if (accessToken) {
|
|
1015
|
+
startCmd += ` --access-token "${accessToken}"`;
|
|
1016
|
+
} else if (apiKey) {
|
|
1017
|
+
startCmd += ` --api-key "${apiKey}"`;
|
|
1018
|
+
}
|
|
1019
|
+
if (options?.port) {
|
|
1020
|
+
startCmd += ` --port ${options.port}`;
|
|
1021
|
+
}
|
|
1022
|
+
const fullCmd = `${installCmd} && ${startCmd} > /dev/null 2>&1 &`;
|
|
1023
|
+
return ["sh", "-c", fullCmd];
|
|
1024
|
+
};
|
|
1025
|
+
var compute = {
|
|
1026
|
+
install,
|
|
1027
|
+
isInstalled,
|
|
1028
|
+
version,
|
|
1029
|
+
start,
|
|
1030
|
+
stop,
|
|
1031
|
+
health,
|
|
1032
|
+
setup,
|
|
1033
|
+
isSetup
|
|
1034
|
+
};
|
|
1035
|
+
|
|
919
1036
|
// src/index.ts
|
|
920
1037
|
var cmd = Object.assign(
|
|
921
1038
|
// Callable: shell wrapper with sh default
|
|
@@ -938,7 +1055,9 @@ var cmd = Object.assign(
|
|
|
938
1055
|
// Archives
|
|
939
1056
|
...archive_exports,
|
|
940
1057
|
// System
|
|
941
|
-
...system_exports
|
|
1058
|
+
...system_exports,
|
|
1059
|
+
// Compute
|
|
1060
|
+
...compute_exports
|
|
942
1061
|
}
|
|
943
1062
|
);
|
|
944
1063
|
var {
|
|
@@ -985,6 +1104,7 @@ var {
|
|
|
985
1104
|
sha256sum: sha256sum2,
|
|
986
1105
|
sha1sum: sha1sum2
|
|
987
1106
|
} = system_exports;
|
|
1107
|
+
var { compute: compute2 } = compute_exports;
|
|
988
1108
|
var src_default = cmd;
|
|
989
1109
|
export {
|
|
990
1110
|
awk2 as awk,
|
|
@@ -997,6 +1117,7 @@ export {
|
|
|
997
1117
|
chmod2 as chmod,
|
|
998
1118
|
chown2 as chown,
|
|
999
1119
|
cmd,
|
|
1120
|
+
compute2 as compute,
|
|
1000
1121
|
cp2 as cp,
|
|
1001
1122
|
curl2 as curl,
|
|
1002
1123
|
cut2 as cut,
|