@triflare/fx 2.3.0-alpha.2 → 2.3.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triflare/fx",
3
- "version": "2.3.0-alpha.2",
3
+ "version": "2.3.0-beta.1",
4
4
  "description": "Code PenguinMod projects with text.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/product.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  # Identity
2
2
  name: "Triflare Fx"
3
3
  command: "fx"
4
- version: "2.3.0-alpha.2"
4
+ version: "2.3.0-beta.1"
5
5
  tagline: "Code PenguinMod projects with text."
6
6
  author: "Triflare"
7
7
  homepage: "https://github.com/triflare/fx"
@@ -1,4 +1,8 @@
1
1
  import path from "node:path";
2
+ import {
3
+ isMarketplaceSource,
4
+ resolveMarketplaceExtension,
5
+ } from "../../../marketplace.js";
2
6
  import { defaultVendorName, installVendorEntry } from "../../../vendor.js";
3
7
  import { UsageError } from "../../errors.js";
4
8
  import {
@@ -14,6 +18,7 @@ export async function addVendor({
14
18
  cwd,
15
19
  reporter,
16
20
  product,
21
+ fetchImpl,
17
22
  }) {
18
23
  if (!source) throw new UsageError("vendor add requires a path or URL");
19
24
  const configPath = requireConfigPath(cwd, product);
@@ -22,15 +27,24 @@ export async function addVendor({
22
27
 
23
28
  if (typeof options.as === "string" && options.as.trim() === "")
24
29
  throw new UsageError("--as needs a non-empty name");
30
+ const resolved = isMarketplaceSource(source)
31
+ ? await resolveMarketplaceExtension({ source, fetchImpl })
32
+ : null;
25
33
  const name =
26
- typeof options.as === "string" ? options.as : defaultVendorName(source);
27
- const configSource = vendorConfigSource(source, configDir, cwd);
34
+ typeof options.as === "string"
35
+ ? options.as
36
+ : (resolved?.id ?? defaultVendorName(source));
37
+ const configSource = resolved
38
+ ? resolved.downloadUrl
39
+ : vendorConfigSource(source, configDir, cwd);
28
40
  const existing = loaded.vendor.find((entry) => entry.name === name);
29
41
  if (existing && existing.source !== configSource && !options.force)
30
42
  throw new UsageError(
31
43
  `A vendored extension named ${JSON.stringify(name)} already exists.`,
32
44
  {
33
- hint: `run "${product.command} vendor update ${name}" or pass --force to replace it`,
45
+ hint: resolved
46
+ ? `pass --force to replace it with ${resolved.package}@${resolved.version}, or choose another name with --as`
47
+ : `run "${product.command} vendor update ${name}" or pass --force to replace it`,
34
48
  },
35
49
  );
36
50
 
@@ -50,8 +64,18 @@ export async function addVendor({
50
64
  vendorDir: path.resolve(configDir, loaded.vendorDir || "extensions"),
51
65
  unsandboxed: Boolean(options.unsandboxed) || Boolean(existing?.unsandboxed),
52
66
  volatile: existingVolatile,
67
+ marketplace: resolved?.marketplace,
68
+ prefetched: resolved
69
+ ? {
70
+ buffer: resolved.buffer,
71
+ etag: resolved.etag,
72
+ lastModified: resolved.lastModified,
73
+ }
74
+ : undefined,
53
75
  });
54
76
 
77
+ if (resolved)
78
+ reporter.info(`Resolved ${source} to ${resolved.package}@${resolved.version}`);
55
79
  reporter.success(
56
80
  `Vendored ${name} -> ${result.file} (${result.lockEntry.sha256.slice(0, 12)}…)`,
57
81
  );
@@ -64,15 +88,17 @@ export async function addVendor({
64
88
  source: configSource,
65
89
  file: result.file,
66
90
  sha256: result.lockEntry.sha256,
91
+ marketplace: resolved?.marketplace ?? null,
67
92
  replaced: Boolean(existing),
68
93
  };
69
94
  }
70
95
 
71
96
  export const vendorAddCommand = {
72
97
  name: "add",
73
- summary: "Vendor an extension by URL or path",
98
+ summary: "Vendor an extension by URL, path, or Marketplace package",
74
99
  description: `Copy an extension into the vendor directory, record its SHA-256 in
75
- fx.lock, and add it to the project config.`,
100
+ fx.lock, and add it to the project config. Marketplace sources are resolved to a
101
+ pinned download URL first.`,
76
102
  arguments: ["<source>"],
77
103
  options: [
78
104
  { flags: "--as <name>", description: "Name for the vendored extension" },
@@ -85,6 +111,7 @@ fx.lock, and add it to the project config.`,
85
111
  examples: [
86
112
  "fx vendor add https://example.com/signals.js --as signals",
87
113
  "fx vendor add ./src/mything.js",
114
+ "fx vendor add marketplace:@handle/extension@latest",
88
115
  ],
89
116
  run(context) {
90
117
  return addVendor({
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { resolveMarketplaceExtension } from "../../../marketplace.js";
2
3
  import { outdatedVendor } from "../../../vendor.js";
3
4
  import { UsageError } from "../../errors.js";
4
5
  import { outcome } from "../../define-command.js";
@@ -7,7 +8,8 @@ import { loadVendorConfig, requireConfigPath } from "./helpers.js";
7
8
  export const vendorOutdatedCommand = {
8
9
  name: "outdated",
9
10
  summary: "Compare upstream sources with fx.lock",
10
- description: "Check whether any vendored extension changed upstream.",
11
+ description:
12
+ "Check whether any vendored extension changed upstream or a Marketplace dist-tag points at a newer release.",
11
13
  examples: ["fx vendor outdated"],
12
14
  async run({ cwd, reporter, product }) {
13
15
  const configPath = requireConfigPath(cwd, product);
@@ -16,7 +18,17 @@ export const vendorOutdatedCommand = {
16
18
  if (loaded.vendor.length === 0)
17
19
  throw new UsageError(`No vendor entries in ${path.basename(configPath)}`);
18
20
 
19
- const results = await outdatedVendor({ configDir, config: loaded });
21
+ const results = await outdatedVendor({
22
+ configDir,
23
+ config: loaded,
24
+ resolveEntry: async (entry, lockEntry) => {
25
+ const marketplace = lockEntry?.marketplace;
26
+ if (!marketplace) return null;
27
+ return resolveMarketplaceExtension({
28
+ source: `marketplace:${marketplace.package}@${marketplace.ref}`,
29
+ });
30
+ },
31
+ });
20
32
  let outdated = 0;
21
33
  let errors = 0;
22
34
  for (const result of results) {
@@ -35,6 +47,14 @@ export const vendorOutdatedCommand = {
35
47
  ? "danger"
36
48
  : "success";
37
49
  reporter.item(result.name, label, { width: 24, tone });
50
+ if (
51
+ result.version &&
52
+ result.previousVersion &&
53
+ result.version !== result.previousVersion
54
+ )
55
+ reporter.info(
56
+ `${result.name}: ${result.previousVersion} -> ${result.version}`,
57
+ );
38
58
  if (result.error) reporter.warn(result.error);
39
59
  }
40
60
  if (outdated > 0)
@@ -1,4 +1,5 @@
1
1
  import path from "node:path";
2
+ import { resolveMarketplaceExtension } from "../../../marketplace.js";
2
3
  import { updateVendor } from "../../../vendor.js";
3
4
  import { UsageError } from "../../errors.js";
4
5
  import { loadVendorConfig, requireConfigPath } from "./helpers.js";
@@ -7,7 +8,8 @@ export const vendorUpdateCommand = {
7
8
  name: "update",
8
9
  summary: "Update vendored extensions and show diffs",
9
10
  description: `Re-fetch upstream sources, update the vendored copies, and show a
10
- diff for each change. Use --dry-run to preview without writing.`,
11
+ diff for each change. Marketplace entries re-resolve the version or dist-tag
12
+ recorded in fx.lock. Use --dry-run to preview without writing.`,
11
13
  arguments: ["[name]"],
12
14
  options: [
13
15
  { flags: "--dry-run", description: "Show diffs without writing files" },
@@ -26,24 +28,43 @@ diff for each change. Use --dry-run to preview without writing.`,
26
28
  config: loaded,
27
29
  name: args[0],
28
30
  write: !options.dryRun,
31
+ resolveEntry: async (entry, lockEntry) => {
32
+ const marketplace = lockEntry?.marketplace;
33
+ if (!marketplace || entry.source !== lockEntry.source) return null;
34
+ return resolveMarketplaceExtension({
35
+ source: `marketplace:${marketplace.package}@${marketplace.ref}`,
36
+ });
37
+ },
29
38
  });
30
39
  for (const entry of result.entries) {
40
+ if (entry.versionChanged)
41
+ reporter.info(
42
+ `${entry.name}: ${entry.previousVersion} -> ${entry.version}`,
43
+ );
31
44
  if (!entry.changed) {
32
- reporter.info(`${entry.name} is up to date`);
45
+ if (!entry.sourceChanged) reporter.info(`${entry.name} is up to date`);
33
46
  continue;
34
47
  }
35
48
  reporter.text(entry.diff);
36
49
  }
37
- if (options.dryRun && result.changed > 0)
38
- reporter.info(`Dry run: ${result.changed} extension(s) would change`);
39
- else if (result.changed > 0)
40
- reporter.success(`Updated ${result.changed} extension(s)`);
50
+ if (options.dryRun && result.updated > 0)
51
+ reporter.info(`Dry run: ${result.updated} extension(s) would change`);
52
+ else if (result.updated > 0)
53
+ reporter.success(`Updated ${result.updated} extension(s)`);
41
54
  else reporter.success("Everything is up to date");
42
55
 
43
56
  return {
44
57
  dryRun: Boolean(options.dryRun),
58
+ updated: result.updated,
45
59
  changed: result.changed,
46
- entries: result.entries.map(({ name, changed }) => ({ name, changed })),
60
+ entries: result.entries.map(
61
+ ({ name, changed, versionChanged, version }) => ({
62
+ name,
63
+ changed,
64
+ versionChanged,
65
+ version,
66
+ }),
67
+ ),
47
68
  };
48
69
  },
49
70
  };
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Triflare Marketplace sources.
3
+ *
4
+ * `fx vendor add marketplace:@handle/extension@ref` resolves the requested
5
+ * version or dist-tag to a pinned download URL before anything is written.
6
+ * `fx.yml` keeps that URL, and `fx.lock` records the resolved version and
7
+ * digest, so reinstalls and builds never query the registry.
8
+ */
9
+ import { VendorError, fetchVendorSource, sha256 } from "./vendor.js";
10
+
11
+ export const DEFAULT_MARKETPLACE_API = "https://marketplace.sdisk.us/api/v1";
12
+
13
+ const SOURCE_PATTERN =
14
+ /^marketplace:@([a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?)\/([a-z0-9]{1,64})(?:@([A-Za-z0-9._+-]+))?$/;
15
+
16
+ /** @param {unknown} source */
17
+ export function isMarketplaceSource(source) {
18
+ return /^marketplace:/i.test(String(source));
19
+ }
20
+
21
+ /**
22
+ * Parse `marketplace:@handle/extension@ref`.
23
+ *
24
+ * @param {string} source
25
+ * @returns {{namespace: string, id: string, ref: string, package: string}}
26
+ */
27
+ export function parseMarketplaceSource(source) {
28
+ const match = SOURCE_PATTERN.exec(String(source).trim());
29
+ if (!match)
30
+ throw new VendorError(
31
+ `Invalid marketplace source ${JSON.stringify(String(source))}. ` +
32
+ "Use marketplace:@handle/extension@optionalVersionOrDistTag.",
33
+ );
34
+ const [, namespace, id, ref] = match;
35
+ return {
36
+ namespace,
37
+ id,
38
+ ref: ref ?? "latest",
39
+ package: `@${namespace}/${id}`,
40
+ };
41
+ }
42
+
43
+ /** The API root, with `FX_MARKETPLACE_API` available for self-hosted instances. */
44
+ export function marketplaceApiBase(apiBase) {
45
+ return String(
46
+ apiBase || process.env.FX_MARKETPLACE_API || DEFAULT_MARKETPLACE_API,
47
+ ).replace(/\/+$/, "");
48
+ }
49
+
50
+ /** Fetch and parse a JSON response, turning failures into VendorError. */
51
+ async function fetchJson(url, fetchImpl, label) {
52
+ const fetchFn = fetchImpl || globalThis.fetch;
53
+ if (typeof fetchFn !== "function")
54
+ throw new VendorError("global fetch is unavailable");
55
+ let response;
56
+ try {
57
+ response = await fetchFn(url, { headers: { accept: "application/json" } });
58
+ } catch (error) {
59
+ throw new VendorError(
60
+ `Could not reach Triflare Marketplace for ${label}: ${error.message}`,
61
+ { cause: error },
62
+ );
63
+ }
64
+ if (!response.ok) {
65
+ const status = `${response.status} ${response.statusText ?? ""}`.trim();
66
+ const problem =
67
+ response.status === 404
68
+ ? `could not find ${label}`
69
+ : `request for ${label} failed`;
70
+ throw new VendorError(`Triflare Marketplace ${problem}: HTTP ${status}`);
71
+ }
72
+ try {
73
+ return await response.json();
74
+ } catch (error) {
75
+ throw new VendorError(
76
+ `Triflare Marketplace returned invalid JSON for ${label}`,
77
+ { cause: error },
78
+ );
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Resolve a marketplace source to its compiled bytes.
84
+ *
85
+ * The version endpoint accepts a SemVer string, a dist-tag, or `latest`.
86
+ * The downloaded file must match the SHA-256 the registry reports.
87
+ *
88
+ * @param {object} options
89
+ * @param {string} options.source
90
+ * @param {typeof fetch} [options.fetchImpl]
91
+ * @param {string} [options.apiBase]
92
+ */
93
+ export async function resolveMarketplaceExtension({
94
+ source,
95
+ fetchImpl,
96
+ apiBase,
97
+ }) {
98
+ const parsed = parseMarketplaceSource(source);
99
+ const base = marketplaceApiBase(apiBase);
100
+ const label =
101
+ parsed.ref === "latest"
102
+ ? parsed.package
103
+ : `${parsed.package}@${parsed.ref}`;
104
+ const versionUrl = `${base}/@${parsed.namespace}/${parsed.id}/versions/${encodeURIComponent(
105
+ parsed.ref,
106
+ )}`;
107
+ const info = await fetchJson(versionUrl, fetchImpl, label);
108
+ if (!info || typeof info !== "object" || Array.isArray(info))
109
+ throw new VendorError(
110
+ `Triflare Marketplace returned no version for ${label}`,
111
+ );
112
+
113
+ const version = info.version;
114
+ if (typeof version !== "string" || version === "")
115
+ throw new VendorError(
116
+ `Triflare Marketplace returned no version for ${label}`,
117
+ );
118
+ const status = info.status ?? "published";
119
+ if (status !== "published" && status !== "deprecated")
120
+ throw new VendorError(
121
+ `${parsed.package}@${version} is ${status} on Triflare Marketplace; ` +
122
+ "only published versions can be vendored.",
123
+ );
124
+
125
+ const downloadUrl = info.dist?.downloadUrl;
126
+ if (typeof downloadUrl !== "string" || downloadUrl === "")
127
+ throw new VendorError(
128
+ `${parsed.package}@${version} has no compiled download on Triflare Marketplace; ` +
129
+ "this extension cannot be vendored.",
130
+ );
131
+ const digest = String(info.dist?.digest ?? "")
132
+ .replace(/^sha256:/i, "")
133
+ .toLowerCase();
134
+ if (!/^[0-9a-f]{64}$/.test(digest))
135
+ throw new VendorError(
136
+ `${parsed.package}@${version} has no SHA-256 digest on Triflare Marketplace; ` +
137
+ "refusing to vendor an unverifiable download.",
138
+ );
139
+
140
+ const downloaded = await fetchVendorSource(downloadUrl, { fetchImpl });
141
+ const actual = sha256(downloaded.buffer);
142
+ if (actual !== digest)
143
+ throw new VendorError(
144
+ `${parsed.package}@${version} did not match the SHA-256 reported by ` +
145
+ `Triflare Marketplace (expected ${digest.slice(0, 12)}…, found ${actual.slice(
146
+ 0,
147
+ 12,
148
+ )}…).`,
149
+ );
150
+
151
+ return {
152
+ ...parsed,
153
+ version,
154
+ status,
155
+ downloadUrl,
156
+ buffer: downloaded.buffer,
157
+ digest: `sha256:${digest}`,
158
+ sha256: actual,
159
+ etag: downloaded.etag,
160
+ lastModified: downloaded.lastModified,
161
+ marketplace: {
162
+ package: parsed.package,
163
+ version,
164
+ ref: parsed.ref,
165
+ },
166
+ };
167
+ }
package/src/vendor.js CHANGED
@@ -116,6 +116,19 @@ function looksLikeLockEntry(value) {
116
116
  );
117
117
  }
118
118
 
119
+ /** Normalize marketplace provenance recorded in the lock. */
120
+ function normalizeMarketplaceLock(value) {
121
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
122
+ const name = value.package ?? value.spec;
123
+ if (typeof name !== "string" || typeof value.version !== "string")
124
+ return null;
125
+ return {
126
+ package: name,
127
+ version: value.version,
128
+ ref: typeof value.ref === "string" ? value.ref : "latest",
129
+ };
130
+ }
131
+
119
132
  /** Normalize legacy lock-entry spellings into the current shape. */
120
133
  function normalizeLockEntry(name, raw) {
121
134
  const file = raw.file ?? raw.vendored ?? raw.vendorFile ?? raw.vendor_path;
@@ -137,6 +150,7 @@ function normalizeLockEntry(name, raw) {
137
150
  volatile: raw.volatile != null ? Boolean(raw.volatile) : undefined,
138
151
  etag: raw.etag ?? null,
139
152
  lastModified: raw.lastModified ?? raw.last_modified ?? null,
153
+ marketplace: normalizeMarketplaceLock(raw.marketplace),
140
154
  };
141
155
  }
142
156
 
@@ -205,6 +219,8 @@ export function writeLock(configDir, lock) {
205
219
  };
206
220
  if (entry.etag) clean.etag = entry.etag;
207
221
  if (entry.lastModified) clean.lastModified = entry.lastModified;
222
+ const marketplace = normalizeMarketplaceLock(entry.marketplace);
223
+ if (marketplace) clean.marketplace = marketplace;
208
224
  out.extensions[name] = clean;
209
225
  }
210
226
  writeFileAtomic(file, `${JSON.stringify(out, null, 2)}\n`);
@@ -482,7 +498,7 @@ function writeVendorFile(
482
498
  function lockEntryForInstall(name, entry, file, buffer, extra = {}) {
483
499
  return {
484
500
  name,
485
- source: entry.source,
501
+ source: extra.source ?? entry.source,
486
502
  file: posix(file),
487
503
  sha256: sha256(buffer),
488
504
  fetched: new Date().toISOString(),
@@ -491,6 +507,7 @@ function lockEntryForInstall(name, entry, file, buffer, extra = {}) {
491
507
  volatile: Boolean(entry.volatile),
492
508
  etag: extra.etag ?? null,
493
509
  lastModified: extra.lastModified ?? null,
510
+ marketplace: normalizeMarketplaceLock(extra.marketplace),
494
511
  };
495
512
  }
496
513
 
@@ -507,6 +524,8 @@ function lockEntryForInstall(name, entry, file, buffer, extra = {}) {
507
524
  * @param {typeof fetch} [options.fetchImpl]
508
525
  * @param {boolean} [options.unsandboxed]
509
526
  * @param {boolean} [options.volatile]
527
+ * @param {{buffer: Buffer, etag?: string|null, lastModified?: string|null}} [options.prefetched]
528
+ * @param {{package: string, version: string, ref: string}} [options.marketplace]
510
529
  * @returns {Promise<{entry: object, lockEntry: object, file: string}>}
511
530
  */
512
531
  export async function installVendorEntry({
@@ -519,6 +538,8 @@ export async function installVendorEntry({
519
538
  fetchImpl,
520
539
  unsandboxed,
521
540
  volatile,
541
+ prefetched,
542
+ marketplace,
522
543
  }) {
523
544
  const dir = vendorDir
524
545
  ? path.resolve(configDir, vendorDir)
@@ -533,13 +554,21 @@ export async function installVendorEntry({
533
554
  volatile == null ? entry.volatile || undefined : Boolean(volatile);
534
555
 
535
556
  let buffer;
536
- let extra = {};
537
- if (entry.remote) {
557
+ let extra;
558
+ if (prefetched) {
559
+ buffer = prefetched.buffer;
560
+ extra = {
561
+ etag: prefetched.etag,
562
+ lastModified: prefetched.lastModified,
563
+ marketplace,
564
+ };
565
+ } else if (entry.remote) {
538
566
  const read = await readEntrySource(entry, configDir, fetchImpl);
539
567
  buffer = read.buffer;
540
- extra = read.extra;
568
+ extra = { ...read.extra, marketplace };
541
569
  } else {
542
570
  buffer = readLocalSource(entry, configDir).buffer;
571
+ extra = { marketplace };
543
572
  }
544
573
  const stored = storedContent(entry, buffer);
545
574
 
@@ -616,6 +645,7 @@ export async function installVendor({ configDir, config, fetchImpl } = {}) {
616
645
  entry,
617
646
  file,
618
647
  stored,
648
+ { marketplace: previous?.marketplace },
619
649
  );
620
650
  results.push({
621
651
  name: entry.name,
@@ -653,6 +683,7 @@ export async function installVendor({ configDir, config, fetchImpl } = {}) {
653
683
  entry,
654
684
  file,
655
685
  buffer,
686
+ { marketplace: previous?.marketplace },
656
687
  );
657
688
  }
658
689
  results.push({ name: entry.name, file, status: "verified" });
@@ -682,7 +713,7 @@ export async function installVendor({ configDir, config, fetchImpl } = {}) {
682
713
  entry,
683
714
  file,
684
715
  read.buffer,
685
- read.extra,
716
+ { ...read.extra, marketplace: previous?.marketplace },
686
717
  );
687
718
  results.push({ name: entry.name, file, status: "fetched" });
688
719
  }
@@ -702,13 +733,19 @@ export async function installVendor({ configDir, config, fetchImpl } = {}) {
702
733
  /**
703
734
  * Re-fetch remote entries (or re-copy local ones) and update the lock.
704
735
  * Returns the changed entries and a textual diff for each.
736
+ *
737
+ * `resolveEntry` may return a freshly resolved source for an entry (used by
738
+ * `vendor update` to re-resolve Marketplace dist-tags). When its download URL
739
+ * differs from `fx.yml`, the config is updated too.
705
740
  */
706
741
  export async function updateVendor({
742
+ configPath,
707
743
  configDir,
708
744
  config,
709
745
  name,
710
746
  fetchImpl,
711
747
  write = true,
748
+ resolveEntry,
712
749
  } = {}) {
713
750
  const entries = config?.vendor || [];
714
751
  const dirName = config?.vendorDir || DEFAULT_VENDOR_DIR;
@@ -734,9 +771,23 @@ export async function updateVendor({
734
771
  const existed = fs.existsSync(absolute);
735
772
  const before = existed ? fs.readFileSync(absolute) : Buffer.alloc(0);
736
773
 
774
+ const resolved =
775
+ typeof resolveEntry === "function"
776
+ ? await resolveEntry(entry, lockEntry)
777
+ : null;
737
778
  let after;
738
779
  let extra = {};
739
- if (entry.local || entry.data) {
780
+ let source = entry.source;
781
+ let marketplace =
782
+ entry.source === lockEntry?.source
783
+ ? (lockEntry?.marketplace ?? null)
784
+ : null;
785
+ if (resolved) {
786
+ after = resolved.buffer;
787
+ extra = { etag: resolved.etag, lastModified: resolved.lastModified };
788
+ source = resolved.downloadUrl;
789
+ marketplace = resolved.marketplace;
790
+ } else if (entry.local || entry.data) {
740
791
  after = storedContent(entry, readLocalSource(entry, configDir).buffer);
741
792
  } else {
742
793
  const read = await readEntrySource(entry, configDir, fetchImpl);
@@ -745,12 +796,19 @@ export async function updateVendor({
745
796
  }
746
797
 
747
798
  const different = !after.equals(before);
748
- const sourceChanged = lockEntry?.source !== entry.source;
799
+ const versionChanged =
800
+ (marketplace?.version ?? null) !==
801
+ (lockEntry?.marketplace?.version ?? null);
802
+ const sourceChanged =
803
+ lockEntry?.source !== source || entry.source !== source || versionChanged;
749
804
  results.push({
750
805
  name: entry.name,
751
806
  file,
752
807
  changed: different,
753
808
  sourceChanged,
809
+ versionChanged,
810
+ version: marketplace?.version ?? null,
811
+ previousVersion: lockEntry?.marketplace?.version ?? null,
754
812
  diff: different
755
813
  ? formatDiff(before.toString("utf8"), after.toString("utf8"), file)
756
814
  : "",
@@ -765,6 +823,8 @@ export async function updateVendor({
765
823
  before,
766
824
  after,
767
825
  extra,
826
+ source,
827
+ marketplace,
768
828
  different,
769
829
  lockEntry,
770
830
  });
@@ -772,6 +832,9 @@ export async function updateVendor({
772
832
 
773
833
  if (write && pending.length > 0) {
774
834
  const backups = new Map();
835
+ const configBefore = configPath
836
+ ? fs.readFileSync(configPath, "utf8")
837
+ : null;
775
838
  try {
776
839
  for (const item of pending) {
777
840
  if (!item.different) continue;
@@ -783,13 +846,29 @@ export async function updateVendor({
783
846
  allowOverwrite: Boolean(item.lockEntry),
784
847
  });
785
848
  }
849
+ const configChanges = pending.filter(
850
+ (item) => item.source !== item.entry.source,
851
+ );
852
+ if (configChanges.length > 0 && !configPath)
853
+ throw new VendorError(
854
+ `Cannot update ${configChanges[0].entry.name}: no config file was provided`,
855
+ );
856
+ for (const item of configChanges)
857
+ addVendorEntry(configPath, item.entry.name, item.source, {
858
+ unsandboxed: item.entry.unsandboxed,
859
+ volatile: item.entry.volatile,
860
+ });
786
861
  for (const item of pending)
787
862
  lock.extensions[item.entry.name] = lockEntryForInstall(
788
863
  item.entry.name,
789
864
  item.entry,
790
865
  item.file,
791
866
  item.after,
792
- item.extra,
867
+ {
868
+ ...item.extra,
869
+ source: item.source,
870
+ marketplace: item.marketplace,
871
+ },
793
872
  );
794
873
  writeLock(configDir, lock);
795
874
  } catch (error) {
@@ -797,11 +876,12 @@ export async function updateVendor({
797
876
  if (backup.existed) fs.writeFileSync(absolute, backup.buffer);
798
877
  else fs.rmSync(absolute, { force: true });
799
878
  }
879
+ if (configBefore != null) fs.writeFileSync(configPath, configBefore);
800
880
  throw error;
801
881
  }
802
882
  }
803
883
 
804
- return { entries: results, warnings, changed, lock };
884
+ return { entries: results, warnings, changed, updated: pending.length, lock };
805
885
  }
806
886
 
807
887
  /**
@@ -894,8 +974,16 @@ export function verifyVendor({ configDir, config } = {}) {
894
974
  /**
895
975
  * Compare upstream sources with `fx.lock` without writing anything.
896
976
  * ETag/Last-Modified are sent when the lock has them.
977
+ *
978
+ * `resolveEntry` may return a freshly resolved source (used by
979
+ * `vendor outdated` to compare Marketplace dist-tags).
897
980
  */
898
- export async function outdatedVendor({ configDir, config, fetchImpl } = {}) {
981
+ export async function outdatedVendor({
982
+ configDir,
983
+ config,
984
+ fetchImpl,
985
+ resolveEntry,
986
+ } = {}) {
899
987
  const entries = config?.vendor || [];
900
988
  const dirName = config?.vendorDir || DEFAULT_VENDOR_DIR;
901
989
  const vendorDir = path.resolve(configDir, dirName);
@@ -929,6 +1017,29 @@ export async function outdatedVendor({ configDir, config, fetchImpl } = {}) {
929
1017
  }
930
1018
 
931
1019
  try {
1020
+ const resolved =
1021
+ typeof resolveEntry === "function"
1022
+ ? await resolveEntry(entry, lockEntry)
1023
+ : null;
1024
+ if (resolved) {
1025
+ const sameVersion =
1026
+ lockEntry?.marketplace?.version === resolved.marketplace?.version;
1027
+ results.push({
1028
+ name: entry.name,
1029
+ file,
1030
+ status:
1031
+ sameVersion &&
1032
+ entry.source === lockEntry?.source &&
1033
+ lockEntry?.source === resolved.downloadUrl &&
1034
+ lockEntry?.sha256 === resolved.sha256
1035
+ ? "current"
1036
+ : "outdated",
1037
+ version: resolved.marketplace?.version ?? resolved.version ?? null,
1038
+ previousVersion: lockEntry?.marketplace?.version ?? null,
1039
+ });
1040
+ continue;
1041
+ }
1042
+
932
1043
  const sameSource = lockEntry?.source === entry.source;
933
1044
  const fetched = await fetchVendorSource(entry.source, {
934
1045
  fetchImpl,
@@ -1051,6 +1162,7 @@ export async function loadVendorExtensions({
1051
1162
  entry,
1052
1163
  file,
1053
1164
  stored,
1165
+ { marketplace: lockEntry?.marketplace },
1054
1166
  );
1055
1167
  lockChanged.value = true;
1056
1168
  }
@@ -1081,6 +1193,7 @@ export async function loadVendorExtensions({
1081
1193
  entry,
1082
1194
  file,
1083
1195
  buffer,
1196
+ { marketplace: lockEntry?.marketplace },
1084
1197
  );
1085
1198
  lockChanged.value = true;
1086
1199
  }
@@ -1108,7 +1221,7 @@ export async function loadVendorExtensions({
1108
1221
  entry,
1109
1222
  file,
1110
1223
  buffer,
1111
- read.extra,
1224
+ { ...read.extra, marketplace: lockEntry?.marketplace },
1112
1225
  );
1113
1226
  lockChanged.value = true;
1114
1227
  }
@@ -2,5 +2,5 @@
2
2
  "name": "@penguinmod/packager",
3
3
  "version": "1.9.2",
4
4
  "commit": "53f868b85ec21d2edab9ce00fd2d709da93da6d6",
5
- "builtAt": "2026-11-26T19:16:44.275Z"
5
+ "builtAt": "2026-11-26T20:45:33.392Z"
6
6
  }
@@ -3,5 +3,5 @@
3
3
  "version": "0.2.0",
4
4
  "commit": "3822f284c8cda2c3a0a5c6dd928221dd9ff2cee1",
5
5
  "inputHash": "bb8f99fcce9f4ecdc563f11df5a0510dcc94c25d256c6931c7f1f113e0a1998b",
6
- "builtAt": "2026-11-26T19:17:49.724Z"
6
+ "builtAt": "2026-11-26T20:46:36.431Z"
7
7
  }