openhome-cli 0.1.15 → 0.1.17

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
@@ -122,10 +122,12 @@ var ApiClient = class {
122
122
  if (metadata.personality_id) {
123
123
  form.append("personality_id", metadata.personality_id);
124
124
  }
125
- return this.request(ENDPOINTS.uploadCapability, {
126
- method: "POST",
127
- body: form
128
- });
125
+ return this.request(
126
+ ENDPOINTS.uploadCapability,
127
+ { method: "POST", body: form },
128
+ true
129
+ // uses JWT
130
+ );
129
131
  }
130
132
  async listAbilities() {
131
133
  const data = await this.request(
@@ -878,6 +880,27 @@ async function deployCommand(pathArg, opts = {}) {
878
880
  });
879
881
  handleCancel(mode);
880
882
  if (mode === "zip") {
883
+ let scanForZips2 = function(dir, depth = 0) {
884
+ if (!existsSync2(dir)) return;
885
+ try {
886
+ const entries = readdirSync2(dir, { withFileTypes: true });
887
+ for (const entry of entries) {
888
+ const full = join2(dir, entry.name);
889
+ if (entry.isFile() && entry.name.endsWith(".zip") && !seen.has(full)) {
890
+ seen.add(full);
891
+ const shortDir = dir.startsWith(home) ? `~${dir.slice(home.length)}` : dir;
892
+ foundZips.push({
893
+ path: full,
894
+ label: `${entry.name} (${shortDir})`
895
+ });
896
+ } else if (entry.isDirectory() && depth < 2 && !entry.name.startsWith(".")) {
897
+ scanForZips2(full, depth + 1);
898
+ }
899
+ }
900
+ } catch {
901
+ }
902
+ };
903
+ var scanForZips = scanForZips2;
881
904
  const home = homedir();
882
905
  const scanDirs = [
883
906
  process.cwd(),
@@ -886,18 +909,9 @@ async function deployCommand(pathArg, opts = {}) {
886
909
  join2(home, "Documents")
887
910
  ];
888
911
  const foundZips = [];
912
+ const seen = /* @__PURE__ */ new Set();
889
913
  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 {
900
- }
914
+ scanForZips2(dir);
901
915
  }
902
916
  let zipPath;
903
917
  if (foundZips.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openhome-cli",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "CLI for managing OpenHome voice AI abilities",
5
5
  "type": "module",
6
6
  "bin": {
package/src/api/client.ts CHANGED
@@ -159,10 +159,11 @@ export class ApiClient implements IApiClient {
159
159
  form.append("personality_id", metadata.personality_id);
160
160
  }
161
161
 
162
- return this.request<UploadAbilityResponse>(ENDPOINTS.uploadCapability, {
163
- method: "POST",
164
- body: form,
165
- });
162
+ return this.request<UploadAbilityResponse>(
163
+ ENDPOINTS.uploadCapability,
164
+ { method: "POST", body: form },
165
+ true, // uses JWT
166
+ );
166
167
  }
167
168
 
168
169
  async listAbilities(): Promise<ListAbilitiesResponse> {
@@ -157,16 +157,33 @@ export async function deployCommand(
157
157
  ];
158
158
 
159
159
  const foundZips: { path: string; label: string }[] = [];
160
- for (const dir of scanDirs) {
161
- if (!existsSync(dir)) continue;
160
+ const seen = new Set<string>();
161
+
162
+ function scanForZips(dir: string, depth = 0): void {
163
+ if (!existsSync(dir)) return;
162
164
  try {
163
- for (const file of readdirSync(dir)) {
164
- if (file.endsWith(".zip")) {
165
- const full = join(dir, file);
165
+ const entries = readdirSync(dir, { withFileTypes: true });
166
+ for (const entry of entries) {
167
+ const full = join(dir, entry.name);
168
+ if (
169
+ entry.isFile() &&
170
+ entry.name.endsWith(".zip") &&
171
+ !seen.has(full)
172
+ ) {
173
+ seen.add(full);
166
174
  const shortDir = dir.startsWith(home)
167
175
  ? `~${dir.slice(home.length)}`
168
176
  : dir;
169
- foundZips.push({ path: full, label: `${file} (${shortDir})` });
177
+ foundZips.push({
178
+ path: full,
179
+ label: `${entry.name} (${shortDir})`,
180
+ });
181
+ } else if (
182
+ entry.isDirectory() &&
183
+ depth < 2 &&
184
+ !entry.name.startsWith(".")
185
+ ) {
186
+ scanForZips(full, depth + 1);
170
187
  }
171
188
  }
172
189
  } catch {
@@ -174,6 +191,10 @@ export async function deployCommand(
174
191
  }
175
192
  }
176
193
 
194
+ for (const dir of scanDirs) {
195
+ scanForZips(dir);
196
+ }
197
+
177
198
  let zipPath: string;
178
199
 
179
200
  if (foundZips.length > 0) {