@rudderhq/cli 0.2.1-canary.0 → 0.2.1-canary.2
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/index.js +55 -13
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6132,6 +6132,7 @@ var CLI_REGISTRY_LATEST_URL = "https://registry.npmjs.org/@rudderhq%2fcli/latest
|
|
|
6132
6132
|
var DESKTOP_APP_NAME = "Rudder";
|
|
6133
6133
|
var DESKTOP_METADATA_FILE = ".rudder-desktop-install.json";
|
|
6134
6134
|
var DESKTOP_CHECKSUM_ASSET_NAME = "SHASUMS256.txt";
|
|
6135
|
+
var GITHUB_ASSET_DOWNLOAD_ACCEPT = "application/octet-stream";
|
|
6135
6136
|
function resolveCurrentCliVersion(env = process.env) {
|
|
6136
6137
|
const version = resolveCliVersion(import.meta.url, env);
|
|
6137
6138
|
return version === "0.0.0" ? "latest" : version;
|
|
@@ -6313,6 +6314,26 @@ function buildGithubReleaseAsset(repo, tag, assetName) {
|
|
|
6313
6314
|
browser_download_url: buildGithubReleaseAssetDownloadUrl(repo, tag, assetName)
|
|
6314
6315
|
};
|
|
6315
6316
|
}
|
|
6317
|
+
function uniqueAssetDownloadUrls(asset) {
|
|
6318
|
+
const urls = [asset.url, asset.browser_download_url].filter((url) => Boolean(url));
|
|
6319
|
+
return Array.from(new Set(urls));
|
|
6320
|
+
}
|
|
6321
|
+
function downloadHeadersForAssetUrl(asset, url) {
|
|
6322
|
+
return {
|
|
6323
|
+
Accept: url === asset.url ? GITHUB_ASSET_DOWNLOAD_ACCEPT : "*/*",
|
|
6324
|
+
"User-Agent": "rudder-cli-installer"
|
|
6325
|
+
};
|
|
6326
|
+
}
|
|
6327
|
+
function formatFetchError(error) {
|
|
6328
|
+
if (!(error instanceof Error)) return String(error);
|
|
6329
|
+
const cause = error.cause;
|
|
6330
|
+
if (cause instanceof Error) {
|
|
6331
|
+
const code = cause.code;
|
|
6332
|
+
const suffix = typeof code === "string" ? ` [${code}]` : "";
|
|
6333
|
+
return `${error.message}: ${cause.message}${suffix}`;
|
|
6334
|
+
}
|
|
6335
|
+
return error.message;
|
|
6336
|
+
}
|
|
6316
6337
|
function contentLengthFromHeaders(headers) {
|
|
6317
6338
|
const raw = headers.get("content-length");
|
|
6318
6339
|
if (!raw) return null;
|
|
@@ -6322,11 +6343,24 @@ function contentLengthFromHeaders(headers) {
|
|
|
6322
6343
|
async function downloadAsset(asset, outputDir, progressFactory = createByteProgress) {
|
|
6323
6344
|
mkdirSync(outputDir, { recursive: true });
|
|
6324
6345
|
const outputPath = path11.join(outputDir, path11.basename(asset.name));
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6346
|
+
let response = null;
|
|
6347
|
+
const failures = [];
|
|
6348
|
+
for (const url of uniqueAssetDownloadUrls(asset)) {
|
|
6349
|
+
try {
|
|
6350
|
+
const candidate = await fetch(url, {
|
|
6351
|
+
headers: downloadHeadersForAssetUrl(asset, url)
|
|
6352
|
+
});
|
|
6353
|
+
if (candidate.ok && candidate.body) {
|
|
6354
|
+
response = candidate;
|
|
6355
|
+
break;
|
|
6356
|
+
}
|
|
6357
|
+
failures.push(`Failed to download ${asset.name} from ${url} (${candidate.status}).`);
|
|
6358
|
+
} catch (error) {
|
|
6359
|
+
failures.push(`Failed to download ${asset.name} from ${url}: ${formatFetchError(error)}.`);
|
|
6360
|
+
}
|
|
6361
|
+
}
|
|
6362
|
+
if (!response) {
|
|
6363
|
+
throw new Error(failures.join("\n"));
|
|
6330
6364
|
}
|
|
6331
6365
|
const totalBytes = contentLengthFromHeaders(response.headers);
|
|
6332
6366
|
const progress = progressFactory(`Downloading ${asset.name}`);
|
|
@@ -6744,20 +6778,28 @@ async function startCommand(opts) {
|
|
|
6744
6778
|
}
|
|
6745
6779
|
const directReleaseVersion = resolveDesktopReleaseVersion(tag);
|
|
6746
6780
|
const progressFactory = createByteProgress;
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6781
|
+
let release = null;
|
|
6782
|
+
try {
|
|
6783
|
+
release = await runStartPhase(
|
|
6784
|
+
"Resolving Desktop release...",
|
|
6785
|
+
"Desktop release resolved.",
|
|
6786
|
+
() => fetchGithubRelease(repo, tag)
|
|
6787
|
+
);
|
|
6788
|
+
} catch (error) {
|
|
6789
|
+
if (!directReleaseVersion) throw error;
|
|
6790
|
+
p13.log.warn(
|
|
6791
|
+
`Desktop release metadata could not be resolved; falling back to deterministic download URLs. ${formatFetchError(error)}`
|
|
6792
|
+
);
|
|
6793
|
+
}
|
|
6794
|
+
const releaseTag = release?.tag_name ?? (directReleaseVersion ? tag : null);
|
|
6753
6795
|
if (!releaseTag) {
|
|
6754
6796
|
throw new Error(`Unable to resolve Rudder Desktop release tag for ${repo}@${tag}.`);
|
|
6755
6797
|
}
|
|
6756
|
-
const asset = directReleaseVersion ? buildGithubReleaseAsset(repo, tag, resolveDesktopAssetName(directReleaseVersion, target)) :
|
|
6798
|
+
const asset = selectDesktopAsset(release?.assets ?? [], target) ?? (directReleaseVersion ? buildGithubReleaseAsset(repo, tag, resolveDesktopAssetName(directReleaseVersion, target)) : null);
|
|
6757
6799
|
if (!asset) {
|
|
6758
6800
|
throw new Error(`No Rudder Desktop portable asset found for ${target.platform}/${target.arch} in ${repo}@${releaseTag}.`);
|
|
6759
6801
|
}
|
|
6760
|
-
const checksumAsset = directReleaseVersion ? buildGithubReleaseAsset(repo, tag, DESKTOP_CHECKSUM_ASSET_NAME) :
|
|
6802
|
+
const checksumAsset = selectChecksumAsset(release?.assets ?? []) ?? (directReleaseVersion ? buildGithubReleaseAsset(repo, tag, DESKTOP_CHECKSUM_ASSET_NAME) : null);
|
|
6761
6803
|
const checksums = await downloadChecksums(checksumAsset, outputDir, progressFactory);
|
|
6762
6804
|
const expectedChecksum = resolveAssetChecksum(checksums, asset.name);
|
|
6763
6805
|
const metadata = await readInstallMetadata(installPaths.metadataPath);
|