makefx 1.0.5 → 1.0.6
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/README.md +1 -1
- package/makefx.mjs +1 -30
- package/package.json +1 -1
package/README.md
CHANGED
package/makefx.mjs
CHANGED
|
@@ -5454,17 +5454,11 @@ async function executeUpload(parsed, deps = defaultDeps$8) {
|
|
|
5454
5454
|
if (config.token.expiresAt < Date.now()) throw new Error(`Token expired for ${env} environment. Run: ${loginCommandForEnvironment(env)}`);
|
|
5455
5455
|
const baseUrl = deps.resolveBaseUrl(env);
|
|
5456
5456
|
const accessToken = config.token.accessToken;
|
|
5457
|
-
const ctx = {
|
|
5458
|
-
spaceId,
|
|
5459
|
-
baseUrl,
|
|
5460
|
-
accessToken
|
|
5461
|
-
};
|
|
5462
5457
|
if (env === "local") process$1.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
5463
5458
|
try {
|
|
5464
5459
|
const fileStat = await deps.stat(filePath);
|
|
5465
5460
|
if (!fileStat.isFile()) throw new Error(`"${filePath}" is not a file`);
|
|
5466
5461
|
if (fileStat.size > 10485760) throw new Error(`File too large (${(fileStat.size / 1024 / 1024).toFixed(2)}MB). Maximum size: 10MB`);
|
|
5467
|
-
await preflightSourceVariants(ctx, deps, sourceVariantIds);
|
|
5468
5462
|
const fileBuffer = await deps.readFile(filePath);
|
|
5469
5463
|
const fileName = path.basename(filePath);
|
|
5470
5464
|
const formData = new FormData();
|
|
@@ -5605,29 +5599,6 @@ function parseCsvOption(value, optionName) {
|
|
|
5605
5599
|
if (value === "true") throw new UploadUsageError(`${optionName} requires a value`);
|
|
5606
5600
|
return value.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
5607
5601
|
}
|
|
5608
|
-
async function preflightSourceVariants(ctx, deps, sourceVariantIds) {
|
|
5609
|
-
if (sourceVariantIds.length === 0) return;
|
|
5610
|
-
const state = await fetchVariantState(ctx, deps);
|
|
5611
|
-
for (const sourceVariantId of sourceVariantIds) if (!state.variantsById.has(sourceVariantId)) throw new Error(`Source variant not found in space: ${sourceVariantId}`);
|
|
5612
|
-
}
|
|
5613
|
-
async function fetchVariantState(ctx, deps) {
|
|
5614
|
-
const assets = (await fetchJson$1(ctx, deps, `/api/spaces/${ctx.spaceId}/assets`)).assets ?? [];
|
|
5615
|
-
const variantsById = /* @__PURE__ */ new Map();
|
|
5616
|
-
await Promise.all(assets.map(async (asset) => {
|
|
5617
|
-
const details = await fetchJson$1(ctx, deps, `/api/spaces/${ctx.spaceId}/assets/${encodeURIComponent(asset.id)}`);
|
|
5618
|
-
for (const variant of details.variants ?? []) variantsById.set(variant.id, variant);
|
|
5619
|
-
}));
|
|
5620
|
-
return { variantsById };
|
|
5621
|
-
}
|
|
5622
|
-
async function fetchJson$1(ctx, deps, requestPath) {
|
|
5623
|
-
const response = await deps.fetch(`${ctx.baseUrl}${requestPath}`, { headers: {
|
|
5624
|
-
Authorization: `Bearer ${ctx.accessToken}`,
|
|
5625
|
-
Accept: "application/json"
|
|
5626
|
-
} });
|
|
5627
|
-
const data = await response.json().catch(() => ({}));
|
|
5628
|
-
if (!response.ok) throw new Error("error" in data ? data.error : `Request failed: ${response.status}`);
|
|
5629
|
-
return data;
|
|
5630
|
-
}
|
|
5631
5602
|
function printUsage$8() {
|
|
5632
5603
|
console.log(`
|
|
5633
5604
|
Usage:
|
|
@@ -9504,7 +9475,7 @@ Options:
|
|
|
9504
9475
|
}
|
|
9505
9476
|
//#endregion
|
|
9506
9477
|
//#region src/cli/index.ts
|
|
9507
|
-
var CLI_VERSION = "1.0.
|
|
9478
|
+
var CLI_VERSION = "1.0.6+d87c3032db88";
|
|
9508
9479
|
async function main() {
|
|
9509
9480
|
const argv = process$1.argv.slice(2);
|
|
9510
9481
|
if (argv[0] === "--") argv.shift();
|