openhome-cli 0.1.19 → 0.1.20

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 CHANGED
@@ -817,6 +817,12 @@ var MockApiClient = class {
817
817
  };
818
818
 
819
819
  // src/commands/deploy.ts
820
+ function expandPath(p2) {
821
+ if (p2.startsWith("~/") || p2 === "~") {
822
+ return join2(homedir(), p2.slice(2));
823
+ }
824
+ return resolve(p2);
825
+ }
820
826
  var IMAGE_EXTENSIONS = ["png", "jpg", "jpeg"];
821
827
  var ICON_NAMES = IMAGE_EXTENSIONS.flatMap((ext) => [
822
828
  `icon.${ext}`,
@@ -880,7 +886,7 @@ async function resolveAbilityDir(pathArg) {
880
886
  }
881
887
  });
882
888
  handleCancel(pathInput);
883
- return resolve(pathInput.trim());
889
+ return expandPath(pathInput.trim());
884
890
  }
885
891
  async function deployCommand(pathArg, opts = {}) {
886
892
  p.intro("\u{1F680} Upload Ability");
@@ -960,13 +966,13 @@ async function deployCommand(pathArg, opts = {}) {
960
966
  placeholder: "~/path/to/ability.zip",
961
967
  validate: (val) => {
962
968
  if (!val || !val.trim()) return "Path is required";
963
- if (!existsSync2(resolve(val.trim())))
969
+ if (!existsSync2(expandPath(val.trim())))
964
970
  return `File not found: ${val.trim()}`;
965
971
  if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
966
972
  }
967
973
  });
968
974
  handleCancel(zipInput);
969
- zipPath = resolve(zipInput.trim());
975
+ zipPath = expandPath(zipInput.trim());
970
976
  } else {
971
977
  zipPath = selected;
972
978
  }
@@ -976,13 +982,13 @@ async function deployCommand(pathArg, opts = {}) {
976
982
  placeholder: "~/Downloads/my-ability.zip",
977
983
  validate: (val) => {
978
984
  if (!val || !val.trim()) return "Path is required";
979
- if (!existsSync2(resolve(val.trim())))
985
+ if (!existsSync2(expandPath(val.trim())))
980
986
  return `File not found: ${val.trim()}`;
981
987
  if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
982
988
  }
983
989
  });
984
990
  handleCancel(zipInput);
985
- zipPath = resolve(zipInput.trim());
991
+ zipPath = expandPath(zipInput.trim());
986
992
  }
987
993
  await deployZip(zipPath, opts);
988
994
  return;
@@ -1105,7 +1111,7 @@ async function deployCommand(pathArg, opts = {}) {
1105
1111
  placeholder: "./icon.png",
1106
1112
  validate: (val) => {
1107
1113
  if (!val || !val.trim()) return void 0;
1108
- const resolved = resolve(val.trim());
1114
+ const resolved = expandPath(val.trim());
1109
1115
  if (!existsSync2(resolved)) return `File not found: ${val.trim()}`;
1110
1116
  if (!IMAGE_EXTS.has(extname(resolved).toLowerCase()))
1111
1117
  return "Image must be PNG or JPG";
@@ -1113,7 +1119,7 @@ async function deployCommand(pathArg, opts = {}) {
1113
1119
  });
1114
1120
  handleCancel(imgInput);
1115
1121
  const trimmed = imgInput.trim();
1116
- if (trimmed) imagePath = resolve(trimmed);
1122
+ if (trimmed) imagePath = expandPath(trimmed);
1117
1123
  } else if (selected !== "__skip__") {
1118
1124
  imagePath = selected;
1119
1125
  }
@@ -1123,7 +1129,7 @@ async function deployCommand(pathArg, opts = {}) {
1123
1129
  placeholder: "./icon.png",
1124
1130
  validate: (val) => {
1125
1131
  if (!val || !val.trim()) return void 0;
1126
- const resolved = resolve(val.trim());
1132
+ const resolved = expandPath(val.trim());
1127
1133
  if (!existsSync2(resolved)) return `File not found: ${val.trim()}`;
1128
1134
  if (!IMAGE_EXTS.has(extname(resolved).toLowerCase()))
1129
1135
  return "Image must be PNG or JPG";
@@ -1131,7 +1137,7 @@ async function deployCommand(pathArg, opts = {}) {
1131
1137
  });
1132
1138
  handleCancel(imgInput);
1133
1139
  const trimmed = imgInput.trim();
1134
- if (trimmed) imagePath = resolve(trimmed);
1140
+ if (trimmed) imagePath = expandPath(trimmed);
1135
1141
  }
1136
1142
  }
1137
1143
  const imageBuffer = imagePath ? readFileSync2(imagePath) : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openhome-cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "CLI for managing OpenHome voice AI abilities",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,6 +32,13 @@ interface AbilityConfig {
32
32
  [key: string]: unknown;
33
33
  }
34
34
 
35
+ function expandPath(p: string): string {
36
+ if (p.startsWith("~/") || p === "~") {
37
+ return join(homedir(), p.slice(2));
38
+ }
39
+ return resolve(p);
40
+ }
41
+
35
42
  const IMAGE_EXTENSIONS = ["png", "jpg", "jpeg"];
36
43
  const ICON_NAMES = IMAGE_EXTENSIONS.flatMap((ext) => [
37
44
  `icon.${ext}`,
@@ -114,7 +121,7 @@ async function resolveAbilityDir(pathArg?: string): Promise<string> {
114
121
  },
115
122
  });
116
123
  handleCancel(pathInput);
117
- return resolve((pathInput as string).trim());
124
+ return expandPath((pathInput as string).trim());
118
125
  }
119
126
 
120
127
  export async function deployCommand(
@@ -219,13 +226,13 @@ export async function deployCommand(
219
226
  placeholder: "~/path/to/ability.zip",
220
227
  validate: (val) => {
221
228
  if (!val || !val.trim()) return "Path is required";
222
- if (!existsSync(resolve(val.trim())))
229
+ if (!existsSync(expandPath(val.trim())))
223
230
  return `File not found: ${val.trim()}`;
224
231
  if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
225
232
  },
226
233
  });
227
234
  handleCancel(zipInput);
228
- zipPath = resolve((zipInput as string).trim());
235
+ zipPath = expandPath((zipInput as string).trim());
229
236
  } else {
230
237
  zipPath = selected as string;
231
238
  }
@@ -235,13 +242,13 @@ export async function deployCommand(
235
242
  placeholder: "~/Downloads/my-ability.zip",
236
243
  validate: (val) => {
237
244
  if (!val || !val.trim()) return "Path is required";
238
- if (!existsSync(resolve(val.trim())))
245
+ if (!existsSync(expandPath(val.trim())))
239
246
  return `File not found: ${val.trim()}`;
240
247
  if (!val.trim().endsWith(".zip")) return "Must be a .zip file";
241
248
  },
242
249
  });
243
250
  handleCancel(zipInput);
244
- zipPath = resolve((zipInput as string).trim());
251
+ zipPath = expandPath((zipInput as string).trim());
245
252
  }
246
253
 
247
254
  await deployZip(zipPath, opts);
@@ -387,7 +394,7 @@ export async function deployCommand(
387
394
  placeholder: "./icon.png",
388
395
  validate: (val) => {
389
396
  if (!val || !val.trim()) return undefined;
390
- const resolved = resolve(val.trim());
397
+ const resolved = expandPath(val.trim());
391
398
  if (!existsSync(resolved)) return `File not found: ${val.trim()}`;
392
399
  if (!IMAGE_EXTS.has(extname(resolved).toLowerCase()))
393
400
  return "Image must be PNG or JPG";
@@ -395,7 +402,7 @@ export async function deployCommand(
395
402
  });
396
403
  handleCancel(imgInput);
397
404
  const trimmed = (imgInput as string).trim();
398
- if (trimmed) imagePath = resolve(trimmed);
405
+ if (trimmed) imagePath = expandPath(trimmed);
399
406
  } else if (selected !== "__skip__") {
400
407
  imagePath = selected as string;
401
408
  }
@@ -406,7 +413,7 @@ export async function deployCommand(
406
413
  placeholder: "./icon.png",
407
414
  validate: (val) => {
408
415
  if (!val || !val.trim()) return undefined;
409
- const resolved = resolve(val.trim());
416
+ const resolved = expandPath(val.trim());
410
417
  if (!existsSync(resolved)) return `File not found: ${val.trim()}`;
411
418
  if (!IMAGE_EXTS.has(extname(resolved).toLowerCase()))
412
419
  return "Image must be PNG or JPG";
@@ -414,7 +421,7 @@ export async function deployCommand(
414
421
  });
415
422
  handleCancel(imgInput);
416
423
  const trimmed = (imgInput as string).trim();
417
- if (trimmed) imagePath = resolve(trimmed);
424
+ if (trimmed) imagePath = expandPath(trimmed);
418
425
  }
419
426
  }
420
427