@computesdk/cmd 0.3.0 → 0.4.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/README.md +23 -18
- package/dist/index.cjs +41 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -13
- package/dist/index.d.ts +37 -13
- package/dist/index.js +41 -29
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.d.cts
CHANGED
|
@@ -94,26 +94,33 @@ declare const zsh: (command: Command, options?: ShellOptions) => Command;
|
|
|
94
94
|
*/
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* Command builders for common shell operations
|
|
97
|
+
* Command builders for common shell operations
|
|
98
98
|
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
99
|
+
* Namespace containing command builder functions for filesystem operations,
|
|
100
|
+
* package managers, git, network utilities, and more.
|
|
101
|
+
*
|
|
102
|
+
* For shell wrapping with cwd/background options, use `shell()` instead.
|
|
103
103
|
*
|
|
104
104
|
* @example
|
|
105
|
-
* //
|
|
105
|
+
* // Command builders
|
|
106
106
|
* cmd.npm.install('express')
|
|
107
107
|
* // => ['npm', 'install', 'express']
|
|
108
|
+
*
|
|
109
|
+
* cmd.mkdir('/app/src')
|
|
110
|
+
* // => ['mkdir', '-p', '/app/src']
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // For shell wrapping, use shell() instead
|
|
114
|
+
* import { shell, npm } from '@computesdk/cmd';
|
|
115
|
+
* shell(npm.install(), { cwd: '/app' })
|
|
116
|
+
* // => ['sh', '-c', 'cd '/app' && npm install']
|
|
108
117
|
*/
|
|
109
|
-
declare const cmd:
|
|
110
|
-
cwd?: string;
|
|
111
|
-
background?: boolean;
|
|
112
|
-
}) => Command) & {
|
|
118
|
+
declare const cmd: {
|
|
113
119
|
install: (options?: {
|
|
114
120
|
apiKey?: string;
|
|
115
121
|
version?: string;
|
|
116
122
|
silent?: boolean;
|
|
123
|
+
interactive?: boolean;
|
|
117
124
|
}) => Command;
|
|
118
125
|
isInstalled: () => Command;
|
|
119
126
|
version: () => Command;
|
|
@@ -122,6 +129,8 @@ declare const cmd: ((command: Command, options?: {
|
|
|
122
129
|
accessToken?: string;
|
|
123
130
|
port?: number;
|
|
124
131
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
132
|
+
wait?: boolean;
|
|
133
|
+
waitTimeout?: number;
|
|
125
134
|
}) => Command;
|
|
126
135
|
stop: () => Command;
|
|
127
136
|
health: (options?: {
|
|
@@ -138,12 +147,16 @@ declare const cmd: ((command: Command, options?: {
|
|
|
138
147
|
port?: number;
|
|
139
148
|
version?: string;
|
|
140
149
|
silent?: boolean;
|
|
150
|
+
interactive?: boolean;
|
|
151
|
+
wait?: boolean;
|
|
152
|
+
waitTimeout?: number;
|
|
141
153
|
}) => Command;
|
|
142
154
|
compute: {
|
|
143
155
|
install: (options?: {
|
|
144
156
|
apiKey?: string;
|
|
145
157
|
version?: string;
|
|
146
158
|
silent?: boolean;
|
|
159
|
+
interactive?: boolean;
|
|
147
160
|
}) => Command;
|
|
148
161
|
isInstalled: () => Command;
|
|
149
162
|
version: () => Command;
|
|
@@ -152,6 +165,8 @@ declare const cmd: ((command: Command, options?: {
|
|
|
152
165
|
accessToken?: string;
|
|
153
166
|
port?: number;
|
|
154
167
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
168
|
+
wait?: boolean;
|
|
169
|
+
waitTimeout?: number;
|
|
155
170
|
}) => Command;
|
|
156
171
|
stop: () => Command;
|
|
157
172
|
health: (options?: {
|
|
@@ -164,6 +179,9 @@ declare const cmd: ((command: Command, options?: {
|
|
|
164
179
|
port?: number;
|
|
165
180
|
version?: string;
|
|
166
181
|
silent?: boolean;
|
|
182
|
+
interactive?: boolean;
|
|
183
|
+
wait?: boolean;
|
|
184
|
+
waitTimeout?: number;
|
|
167
185
|
}) => Command;
|
|
168
186
|
isSetup: (options?: {
|
|
169
187
|
host?: string;
|
|
@@ -182,8 +200,7 @@ declare const cmd: ((command: Command, options?: {
|
|
|
182
200
|
df: (path?: string, options?: {
|
|
183
201
|
human?: boolean;
|
|
184
202
|
}) => Command;
|
|
185
|
-
du: (path: string,
|
|
186
|
-
options?: {
|
|
203
|
+
du: (path: string, options?: {
|
|
187
204
|
human?: boolean;
|
|
188
205
|
summarize?: boolean;
|
|
189
206
|
}) => Command;
|
|
@@ -243,7 +260,8 @@ declare const cmd: ((command: Command, options?: {
|
|
|
243
260
|
words?: boolean;
|
|
244
261
|
chars?: boolean;
|
|
245
262
|
}) => Command;
|
|
246
|
-
sort: (
|
|
263
|
+
sort: (// Compute
|
|
264
|
+
file: string, options?: {
|
|
247
265
|
reverse?: boolean;
|
|
248
266
|
numeric?: boolean;
|
|
249
267
|
unique?: boolean;
|
|
@@ -802,6 +820,7 @@ declare const compute: {
|
|
|
802
820
|
apiKey?: string;
|
|
803
821
|
version?: string;
|
|
804
822
|
silent?: boolean;
|
|
823
|
+
interactive?: boolean;
|
|
805
824
|
}) => Command;
|
|
806
825
|
isInstalled: () => Command;
|
|
807
826
|
version: () => Command;
|
|
@@ -810,6 +829,8 @@ declare const compute: {
|
|
|
810
829
|
accessToken?: string;
|
|
811
830
|
port?: number;
|
|
812
831
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
832
|
+
wait?: boolean;
|
|
833
|
+
waitTimeout?: number;
|
|
813
834
|
}) => Command;
|
|
814
835
|
stop: () => Command;
|
|
815
836
|
health: (options?: {
|
|
@@ -822,6 +843,9 @@ declare const compute: {
|
|
|
822
843
|
port?: number;
|
|
823
844
|
version?: string;
|
|
824
845
|
silent?: boolean;
|
|
846
|
+
interactive?: boolean;
|
|
847
|
+
wait?: boolean;
|
|
848
|
+
waitTimeout?: number;
|
|
825
849
|
}) => Command;
|
|
826
850
|
isSetup: (options?: {
|
|
827
851
|
host?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -94,26 +94,33 @@ declare const zsh: (command: Command, options?: ShellOptions) => Command;
|
|
|
94
94
|
*/
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* Command builders for common shell operations
|
|
97
|
+
* Command builders for common shell operations
|
|
98
98
|
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
99
|
+
* Namespace containing command builder functions for filesystem operations,
|
|
100
|
+
* package managers, git, network utilities, and more.
|
|
101
|
+
*
|
|
102
|
+
* For shell wrapping with cwd/background options, use `shell()` instead.
|
|
103
103
|
*
|
|
104
104
|
* @example
|
|
105
|
-
* //
|
|
105
|
+
* // Command builders
|
|
106
106
|
* cmd.npm.install('express')
|
|
107
107
|
* // => ['npm', 'install', 'express']
|
|
108
|
+
*
|
|
109
|
+
* cmd.mkdir('/app/src')
|
|
110
|
+
* // => ['mkdir', '-p', '/app/src']
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // For shell wrapping, use shell() instead
|
|
114
|
+
* import { shell, npm } from '@computesdk/cmd';
|
|
115
|
+
* shell(npm.install(), { cwd: '/app' })
|
|
116
|
+
* // => ['sh', '-c', 'cd '/app' && npm install']
|
|
108
117
|
*/
|
|
109
|
-
declare const cmd:
|
|
110
|
-
cwd?: string;
|
|
111
|
-
background?: boolean;
|
|
112
|
-
}) => Command) & {
|
|
118
|
+
declare const cmd: {
|
|
113
119
|
install: (options?: {
|
|
114
120
|
apiKey?: string;
|
|
115
121
|
version?: string;
|
|
116
122
|
silent?: boolean;
|
|
123
|
+
interactive?: boolean;
|
|
117
124
|
}) => Command;
|
|
118
125
|
isInstalled: () => Command;
|
|
119
126
|
version: () => Command;
|
|
@@ -122,6 +129,8 @@ declare const cmd: ((command: Command, options?: {
|
|
|
122
129
|
accessToken?: string;
|
|
123
130
|
port?: number;
|
|
124
131
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
132
|
+
wait?: boolean;
|
|
133
|
+
waitTimeout?: number;
|
|
125
134
|
}) => Command;
|
|
126
135
|
stop: () => Command;
|
|
127
136
|
health: (options?: {
|
|
@@ -138,12 +147,16 @@ declare const cmd: ((command: Command, options?: {
|
|
|
138
147
|
port?: number;
|
|
139
148
|
version?: string;
|
|
140
149
|
silent?: boolean;
|
|
150
|
+
interactive?: boolean;
|
|
151
|
+
wait?: boolean;
|
|
152
|
+
waitTimeout?: number;
|
|
141
153
|
}) => Command;
|
|
142
154
|
compute: {
|
|
143
155
|
install: (options?: {
|
|
144
156
|
apiKey?: string;
|
|
145
157
|
version?: string;
|
|
146
158
|
silent?: boolean;
|
|
159
|
+
interactive?: boolean;
|
|
147
160
|
}) => Command;
|
|
148
161
|
isInstalled: () => Command;
|
|
149
162
|
version: () => Command;
|
|
@@ -152,6 +165,8 @@ declare const cmd: ((command: Command, options?: {
|
|
|
152
165
|
accessToken?: string;
|
|
153
166
|
port?: number;
|
|
154
167
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
168
|
+
wait?: boolean;
|
|
169
|
+
waitTimeout?: number;
|
|
155
170
|
}) => Command;
|
|
156
171
|
stop: () => Command;
|
|
157
172
|
health: (options?: {
|
|
@@ -164,6 +179,9 @@ declare const cmd: ((command: Command, options?: {
|
|
|
164
179
|
port?: number;
|
|
165
180
|
version?: string;
|
|
166
181
|
silent?: boolean;
|
|
182
|
+
interactive?: boolean;
|
|
183
|
+
wait?: boolean;
|
|
184
|
+
waitTimeout?: number;
|
|
167
185
|
}) => Command;
|
|
168
186
|
isSetup: (options?: {
|
|
169
187
|
host?: string;
|
|
@@ -182,8 +200,7 @@ declare const cmd: ((command: Command, options?: {
|
|
|
182
200
|
df: (path?: string, options?: {
|
|
183
201
|
human?: boolean;
|
|
184
202
|
}) => Command;
|
|
185
|
-
du: (path: string,
|
|
186
|
-
options?: {
|
|
203
|
+
du: (path: string, options?: {
|
|
187
204
|
human?: boolean;
|
|
188
205
|
summarize?: boolean;
|
|
189
206
|
}) => Command;
|
|
@@ -243,7 +260,8 @@ declare const cmd: ((command: Command, options?: {
|
|
|
243
260
|
words?: boolean;
|
|
244
261
|
chars?: boolean;
|
|
245
262
|
}) => Command;
|
|
246
|
-
sort: (
|
|
263
|
+
sort: (// Compute
|
|
264
|
+
file: string, options?: {
|
|
247
265
|
reverse?: boolean;
|
|
248
266
|
numeric?: boolean;
|
|
249
267
|
unique?: boolean;
|
|
@@ -802,6 +820,7 @@ declare const compute: {
|
|
|
802
820
|
apiKey?: string;
|
|
803
821
|
version?: string;
|
|
804
822
|
silent?: boolean;
|
|
823
|
+
interactive?: boolean;
|
|
805
824
|
}) => Command;
|
|
806
825
|
isInstalled: () => Command;
|
|
807
826
|
version: () => Command;
|
|
@@ -810,6 +829,8 @@ declare const compute: {
|
|
|
810
829
|
accessToken?: string;
|
|
811
830
|
port?: number;
|
|
812
831
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
832
|
+
wait?: boolean;
|
|
833
|
+
waitTimeout?: number;
|
|
813
834
|
}) => Command;
|
|
814
835
|
stop: () => Command;
|
|
815
836
|
health: (options?: {
|
|
@@ -822,6 +843,9 @@ declare const compute: {
|
|
|
822
843
|
port?: number;
|
|
823
844
|
version?: string;
|
|
824
845
|
silent?: boolean;
|
|
846
|
+
interactive?: boolean;
|
|
847
|
+
wait?: boolean;
|
|
848
|
+
waitTimeout?: number;
|
|
825
849
|
}) => Command;
|
|
826
850
|
isSetup: (options?: {
|
|
827
851
|
host?: string;
|
package/dist/index.js
CHANGED
|
@@ -946,10 +946,15 @@ __export(compute_exports, {
|
|
|
946
946
|
stop: () => stop,
|
|
947
947
|
version: () => version
|
|
948
948
|
});
|
|
949
|
+
var isTTYEnvironment = () => {
|
|
950
|
+
if (typeof process === "undefined") return false;
|
|
951
|
+
return Boolean(process.stdin?.isTTY || process.stdout?.isTTY);
|
|
952
|
+
};
|
|
949
953
|
var install = (options) => {
|
|
950
954
|
const installUrl = options?.version ? `https://computesdk.com/install.sh?version=${options.version}` : "https://computesdk.com/install.sh";
|
|
951
955
|
const curlFlags = options?.silent ? "-fsSL" : "-fSL";
|
|
952
|
-
|
|
956
|
+
const isInteractive = options?.interactive ?? isTTYEnvironment();
|
|
957
|
+
let installCmd = isInteractive ? `curl ${curlFlags} ${installUrl} | bash -s` : `curl ${curlFlags} ${installUrl} | bash -s -- --non-interactive`;
|
|
953
958
|
if (options?.apiKey) {
|
|
954
959
|
installCmd = `COMPUTESDK_API_KEY="${options.apiKey}" ${installCmd}`;
|
|
955
960
|
} else if (typeof process !== "undefined" && process.env?.COMPUTESDK_API_KEY) {
|
|
@@ -978,6 +983,12 @@ var start = (options) => {
|
|
|
978
983
|
if (options?.logLevel === "debug") {
|
|
979
984
|
args.push("--verbose");
|
|
980
985
|
}
|
|
986
|
+
if (options?.wait) {
|
|
987
|
+
args.push("--wait");
|
|
988
|
+
if (options.waitTimeout) {
|
|
989
|
+
args.push("--wait-timeout", String(options.waitTimeout));
|
|
990
|
+
}
|
|
991
|
+
}
|
|
981
992
|
return args;
|
|
982
993
|
};
|
|
983
994
|
var stop = () => {
|
|
@@ -1006,7 +1017,8 @@ var setup = (options) => {
|
|
|
1006
1017
|
const accessToken = options?.accessToken;
|
|
1007
1018
|
const installUrl = options?.version ? `https://computesdk.com/install.sh?version=${options.version}` : "https://computesdk.com/install.sh";
|
|
1008
1019
|
const curlFlags = options?.silent ? "-fsSL" : "-fSL";
|
|
1009
|
-
|
|
1020
|
+
const isInteractive = options?.interactive ?? isTTYEnvironment();
|
|
1021
|
+
let installCmd = isInteractive ? `curl ${curlFlags} ${installUrl} | bash -s` : `curl ${curlFlags} ${installUrl} | bash -s -- --non-interactive`;
|
|
1010
1022
|
if (apiKey) {
|
|
1011
1023
|
installCmd = `COMPUTESDK_API_KEY="${apiKey}" ${installCmd}`;
|
|
1012
1024
|
}
|
|
@@ -1019,7 +1031,13 @@ var setup = (options) => {
|
|
|
1019
1031
|
if (options?.port) {
|
|
1020
1032
|
startCmd += ` --port ${options.port}`;
|
|
1021
1033
|
}
|
|
1022
|
-
|
|
1034
|
+
if (options?.wait) {
|
|
1035
|
+
startCmd += " --wait";
|
|
1036
|
+
if (options.waitTimeout) {
|
|
1037
|
+
startCmd += ` --wait-timeout ${options.waitTimeout}`;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
const fullCmd = options?.wait ? `${installCmd} && ${startCmd}` : `${installCmd} && ${startCmd} > /dev/null 2>&1 &`;
|
|
1023
1041
|
return ["sh", "-c", fullCmd];
|
|
1024
1042
|
};
|
|
1025
1043
|
var compute = {
|
|
@@ -1034,32 +1052,26 @@ var compute = {
|
|
|
1034
1052
|
};
|
|
1035
1053
|
|
|
1036
1054
|
// src/index.ts
|
|
1037
|
-
var cmd =
|
|
1038
|
-
//
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
// System
|
|
1058
|
-
...system_exports,
|
|
1059
|
-
// Compute
|
|
1060
|
-
...compute_exports
|
|
1061
|
-
}
|
|
1062
|
-
);
|
|
1055
|
+
var cmd = {
|
|
1056
|
+
// Filesystem
|
|
1057
|
+
...filesystem_exports,
|
|
1058
|
+
// Process
|
|
1059
|
+
...process_exports,
|
|
1060
|
+
// Package managers
|
|
1061
|
+
...packages_exports,
|
|
1062
|
+
// Git
|
|
1063
|
+
...git_exports,
|
|
1064
|
+
// Network
|
|
1065
|
+
...network_exports,
|
|
1066
|
+
// Text processing
|
|
1067
|
+
...text_exports,
|
|
1068
|
+
// Archives
|
|
1069
|
+
...archive_exports,
|
|
1070
|
+
// System
|
|
1071
|
+
...system_exports,
|
|
1072
|
+
// Compute
|
|
1073
|
+
...compute_exports
|
|
1074
|
+
};
|
|
1063
1075
|
var {
|
|
1064
1076
|
mkdir: mkdir2,
|
|
1065
1077
|
rm: rm2,
|