@spicetify/kit 0.4.0 → 0.4.1

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.
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright (C) 2026 Afonso Jorge Ramos
3
+ * SPDX-License-Identifier: GPL-3.0-or-later
4
+ */
5
+ const KINDS = ["extension", "theme", "snippet", "app", "lib"];
6
+ // A submission may declare `kind` or, if it predates the migration, the old
7
+ // `tags` list; either way the vault records exactly one kind.
8
+ export const kindOfMeta = (meta) => {
9
+ if (typeof meta.kind === "string" && KINDS.includes(meta.kind)) {
10
+ return meta.kind;
11
+ }
12
+ const tags = Array.isArray(meta.tags) ? meta.tags : [];
13
+ return KINDS.find((kind) => tags.includes(kind));
14
+ };
15
+ // metadata.json authors are plain names; author objects (with a github)
16
+ // pass through, so an artifact may declare either.
17
+ const normalizeAuthors = (authors) => authors.flatMap((a) => {
18
+ if (typeof a === "string")
19
+ return [{ name: a }];
20
+ if (a && typeof a === "object" && typeof a.name === "string") {
21
+ const { name, github } = a;
22
+ return [{ name, ...(typeof github === "string" ? { github } : {}) }];
23
+ }
24
+ return [];
25
+ });
26
+ export const metadataSubset = (meta) => {
27
+ const out = {};
28
+ if (typeof meta.name === "string")
29
+ out.name = meta.name;
30
+ if (typeof meta.description === "string")
31
+ out.description = meta.description;
32
+ if (Array.isArray(meta.authors))
33
+ out.authors = normalizeAuthors(meta.authors);
34
+ const kind = kindOfMeta(meta);
35
+ if (kind)
36
+ out.kind = kind;
37
+ // Previews inside the zip are not hotlinkable; only absolute URLs are
38
+ // useful to the store.
39
+ if (typeof meta.preview === "string" && /^https?:\/\//.test(meta.preview))
40
+ out.preview = meta.preview;
41
+ // Source and readme links only when absolute; the store refuses
42
+ // anything else anyway.
43
+ if (typeof meta.repository === "string" && meta.repository.startsWith("https://"))
44
+ out.repository = meta.repository;
45
+ if (typeof meta.readme === "string" && meta.readme.startsWith("https://"))
46
+ out.readme = meta.readme;
47
+ if (typeof meta.license === "string" && meta.license.trim())
48
+ out.license = meta.license.trim();
49
+ return out;
50
+ };
package/dist/vault.js CHANGED
@@ -5,43 +5,15 @@
5
5
  /**
6
6
  * vault - record a built module into a vault file for the module store.
7
7
  *
8
- * Card data (name, description, authors, tags) is embedded at the module
8
+ * Card data (name, description, authors, kind) is embedded at the module
9
9
  * level from the dist dir's own metadata.json so it cannot drift from what
10
10
  * installs, alongside a per-version sha256 checksum of the artifact.
11
11
  */
12
12
  import { createHash } from "node:crypto";
13
13
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
14
14
  import path from "node:path";
15
+ import { metadataSubset } from "./vault-metadata.js";
15
16
  const USAGE = "spicetify-kit vault add <dist-dir> --artifact <url> [--zip <file>] [--vault <path>]\n (default target: vault/<id>.json, the shape a store submission takes)";
16
- const normalizeAuthors = (authors) => authors.flatMap((a) => {
17
- if (typeof a === "string")
18
- return [{ name: a }];
19
- if (a && typeof a === "object" && typeof a.name === "string") {
20
- const { name, github } = a;
21
- return [{ name, ...(typeof github === "string" ? { github } : {}) }];
22
- }
23
- return [];
24
- });
25
- const metadataSubset = (meta) => {
26
- const out = {};
27
- if (typeof meta.name === "string")
28
- out.name = meta.name;
29
- if (typeof meta.description === "string")
30
- out.description = meta.description;
31
- if (Array.isArray(meta.authors))
32
- out.authors = normalizeAuthors(meta.authors);
33
- if (Array.isArray(meta.tags))
34
- out.tags = meta.tags;
35
- if (typeof meta.preview === "string" && /^https?:\/\//.test(meta.preview))
36
- out.preview = meta.preview;
37
- if (typeof meta.repository === "string" && meta.repository.startsWith("https://"))
38
- out.repository = meta.repository;
39
- if (typeof meta.readme === "string" && meta.readme.startsWith("https://"))
40
- out.readme = meta.readme;
41
- if (typeof meta.license === "string" && meta.license.trim())
42
- out.license = meta.license.trim();
43
- return out;
44
- };
45
17
  const sha256 = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
46
18
  const today = () => new Date().toISOString().slice(0, 10);
47
19
  async function download(url) {
package/dist/version.js CHANGED
@@ -4,5 +4,5 @@
4
4
  */
5
5
  // Kept in lockstep with package.json by release-please. Scaffolds must depend
6
6
  // on the kit version that generated them, especially across pre-1.0 minors.
7
- export const KIT_VERSION = "0.4.0"; // x-release-please-version
7
+ export const KIT_VERSION = "0.4.1"; // x-release-please-version
8
8
  export const KIT_DEPENDENCY_RANGE = `^${KIT_VERSION}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicetify/kit",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Developer kit for spicetify v3 modules: scaffold, build, hot-push, and pack",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "homepage": "https://github.com/spicetify/modules#readme",