openhome-cli 0.1.14 → 0.1.15
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/cli.js +66 -11
- package/package.json +1 -1
- package/src/commands/deploy.ts +75 -12
package/dist/cli.js
CHANGED
|
@@ -878,18 +878,73 @@ async function deployCommand(pathArg, opts = {}) {
|
|
|
878
878
|
});
|
|
879
879
|
handleCancel(mode);
|
|
880
880
|
if (mode === "zip") {
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
881
|
+
const home = homedir();
|
|
882
|
+
const scanDirs = [
|
|
883
|
+
process.cwd(),
|
|
884
|
+
join2(home, "Desktop"),
|
|
885
|
+
join2(home, "Downloads"),
|
|
886
|
+
join2(home, "Documents")
|
|
887
|
+
];
|
|
888
|
+
const foundZips = [];
|
|
889
|
+
for (const dir of scanDirs) {
|
|
890
|
+
if (!existsSync2(dir)) continue;
|
|
891
|
+
try {
|
|
892
|
+
for (const file of readdirSync2(dir)) {
|
|
893
|
+
if (file.endsWith(".zip")) {
|
|
894
|
+
const full = join2(dir, file);
|
|
895
|
+
const shortDir = dir.startsWith(home) ? `~${dir.slice(home.length)}` : dir;
|
|
896
|
+
foundZips.push({ path: full, label: `${file} (${shortDir})` });
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
} catch {
|
|
889
900
|
}
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
|
|
901
|
+
}
|
|
902
|
+
let zipPath;
|
|
903
|
+
if (foundZips.length > 0) {
|
|
904
|
+
const zipOptions = [
|
|
905
|
+
...foundZips.map((z) => ({ value: z.path, label: z.label })),
|
|
906
|
+
{
|
|
907
|
+
value: "__custom__",
|
|
908
|
+
label: "Other...",
|
|
909
|
+
hint: "Enter a path manually"
|
|
910
|
+
}
|
|
911
|
+
];
|
|
912
|
+
const selected = await p.select({
|
|
913
|
+
message: "Select your zip file",
|
|
914
|
+
options: zipOptions
|
|
915
|
+
});
|
|
916
|
+
handleCancel(selected);
|
|
917
|
+
if (selected === "__custom__") {
|
|
918
|
+
const zipInput = await p.text({
|
|
919
|
+
message: "Path to your zip file",
|
|
920
|
+
placeholder: "~/path/to/ability.zip",
|
|
921
|
+
validate: (val) => {
|
|
922
|
+
if (!val || !val.trim()) return "Path is required";
|
|
923
|
+
if (!existsSync2(resolve(val.trim())))
|
|
924
|
+
return `File not found: ${val.trim()}`;
|
|
925
|
+
if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
handleCancel(zipInput);
|
|
929
|
+
zipPath = resolve(zipInput.trim());
|
|
930
|
+
} else {
|
|
931
|
+
zipPath = selected;
|
|
932
|
+
}
|
|
933
|
+
} else {
|
|
934
|
+
const zipInput = await p.text({
|
|
935
|
+
message: "Path to your zip file",
|
|
936
|
+
placeholder: "~/Downloads/my-ability.zip",
|
|
937
|
+
validate: (val) => {
|
|
938
|
+
if (!val || !val.trim()) return "Path is required";
|
|
939
|
+
if (!existsSync2(resolve(val.trim())))
|
|
940
|
+
return `File not found: ${val.trim()}`;
|
|
941
|
+
if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
handleCancel(zipInput);
|
|
945
|
+
zipPath = resolve(zipInput.trim());
|
|
946
|
+
}
|
|
947
|
+
await deployZip(zipPath, opts);
|
|
893
948
|
return;
|
|
894
949
|
}
|
|
895
950
|
}
|
package/package.json
CHANGED
package/src/commands/deploy.ts
CHANGED
|
@@ -148,18 +148,81 @@ export async function deployCommand(
|
|
|
148
148
|
handleCancel(mode);
|
|
149
149
|
|
|
150
150
|
if (mode === "zip") {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
const home = homedir();
|
|
152
|
+
const scanDirs = [
|
|
153
|
+
process.cwd(),
|
|
154
|
+
join(home, "Desktop"),
|
|
155
|
+
join(home, "Downloads"),
|
|
156
|
+
join(home, "Documents"),
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
const foundZips: { path: string; label: string }[] = [];
|
|
160
|
+
for (const dir of scanDirs) {
|
|
161
|
+
if (!existsSync(dir)) continue;
|
|
162
|
+
try {
|
|
163
|
+
for (const file of readdirSync(dir)) {
|
|
164
|
+
if (file.endsWith(".zip")) {
|
|
165
|
+
const full = join(dir, file);
|
|
166
|
+
const shortDir = dir.startsWith(home)
|
|
167
|
+
? `~${dir.slice(home.length)}`
|
|
168
|
+
: dir;
|
|
169
|
+
foundZips.push({ path: full, label: `${file} (${shortDir})` });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} catch {
|
|
173
|
+
// skip unreadable dirs
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let zipPath: string;
|
|
178
|
+
|
|
179
|
+
if (foundZips.length > 0) {
|
|
180
|
+
const zipOptions = [
|
|
181
|
+
...foundZips.map((z) => ({ value: z.path, label: z.label })),
|
|
182
|
+
{
|
|
183
|
+
value: "__custom__",
|
|
184
|
+
label: "Other...",
|
|
185
|
+
hint: "Enter a path manually",
|
|
186
|
+
},
|
|
187
|
+
];
|
|
188
|
+
const selected = await p.select({
|
|
189
|
+
message: "Select your zip file",
|
|
190
|
+
options: zipOptions,
|
|
191
|
+
});
|
|
192
|
+
handleCancel(selected);
|
|
193
|
+
|
|
194
|
+
if (selected === "__custom__") {
|
|
195
|
+
const zipInput = await p.text({
|
|
196
|
+
message: "Path to your zip file",
|
|
197
|
+
placeholder: "~/path/to/ability.zip",
|
|
198
|
+
validate: (val) => {
|
|
199
|
+
if (!val || !val.trim()) return "Path is required";
|
|
200
|
+
if (!existsSync(resolve(val.trim())))
|
|
201
|
+
return `File not found: ${val.trim()}`;
|
|
202
|
+
if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
handleCancel(zipInput);
|
|
206
|
+
zipPath = resolve((zipInput as string).trim());
|
|
207
|
+
} else {
|
|
208
|
+
zipPath = selected as string;
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
const zipInput = await p.text({
|
|
212
|
+
message: "Path to your zip file",
|
|
213
|
+
placeholder: "~/Downloads/my-ability.zip",
|
|
214
|
+
validate: (val) => {
|
|
215
|
+
if (!val || !val.trim()) return "Path is required";
|
|
216
|
+
if (!existsSync(resolve(val.trim())))
|
|
217
|
+
return `File not found: ${val.trim()}`;
|
|
218
|
+
if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
handleCancel(zipInput);
|
|
222
|
+
zipPath = resolve((zipInput as string).trim());
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
await deployZip(zipPath, opts);
|
|
163
226
|
return;
|
|
164
227
|
}
|
|
165
228
|
}
|