@spica/cli 0.18.42 → 0.18.44

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.
Files changed (2) hide show
  1. package/index.js +9 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -3502,7 +3502,12 @@ function sanitizeSlug(slug) {
3502
3502
  function unwrapList(res) {
3503
3503
  if (Array.isArray(res))
3504
3504
  return res;
3505
- return res.data ?? [];
3505
+ if (res && typeof res === "object" && Array.isArray(res.data)) {
3506
+ return res.data;
3507
+ }
3508
+ const body = res;
3509
+ const got = typeof body === "string" ? `${body.slice(0, 80).replace(/\s+/g, " ")}\u2026` : typeof body;
3510
+ throw new Error(`Expected a list response but got: ${got}. Check that your context URL points at the Spica API (e.g. ".../api"), not the panel.`);
3506
3511
  }
3507
3512
  async function readLocalSchemas(rootDir, moduleName) {
3508
3513
  const dir = path9.join(rootDir, moduleName);
@@ -4014,7 +4019,8 @@ var functionModule = {
4014
4019
  return results;
4015
4020
  },
4016
4021
  async readRemote(http2) {
4017
- const fns = await http2.get("function");
4022
+ const res = await http2.get("function");
4023
+ const fns = unwrapList(res);
4018
4024
  return Promise.all(fns.map(async (fn) => {
4019
4025
  const id = fn._id;
4020
4026
  const [indexRes, depsRes] = await Promise.all([
@@ -4251,7 +4257,7 @@ var policyModule = {
4251
4257
  },
4252
4258
  async readRemote(http2) {
4253
4259
  const res = await http2.get("passport/policy");
4254
- const items = Array.isArray(res) ? res : res.data ?? [];
4260
+ const items = unwrapList(res);
4255
4261
  return items.filter((p) => !p.system).map((p) => ({
4256
4262
  slug: sanitizeSlug(p.name),
4257
4263
  id: p._id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spica/cli",
3
- "version": "0.18.42",
3
+ "version": "0.18.44",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {