@rudderhq/cli 0.1.0-canary.10 → 0.1.0-canary.12
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 +42 -9
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9937,6 +9937,7 @@ var CANARY_SEMVER_RE = /^[0-9]+\.[0-9]+\.[0-9]+-canary\.[0-9]+$/;
|
|
|
9937
9937
|
var CLI_REGISTRY_LATEST_URL = "https://registry.npmjs.org/@rudderhq%2fcli/latest";
|
|
9938
9938
|
var DESKTOP_APP_NAME = "Rudder";
|
|
9939
9939
|
var DESKTOP_METADATA_FILE = ".rudder-desktop-install.json";
|
|
9940
|
+
var DESKTOP_CHECKSUM_ASSET_NAME = "SHASUMS256.txt";
|
|
9940
9941
|
function resolveCurrentCliVersion(env = process.env) {
|
|
9941
9942
|
const envPackageName = env.npm_package_name?.trim();
|
|
9942
9943
|
const envPackageVersion = env.npm_package_version?.trim();
|
|
@@ -10091,7 +10092,7 @@ function selectDesktopAsset(assets2, target) {
|
|
|
10091
10092
|
return exactArch?.asset ?? best.asset;
|
|
10092
10093
|
}
|
|
10093
10094
|
function selectChecksumAsset(assets2) {
|
|
10094
|
-
return assets2.find((asset) =>
|
|
10095
|
+
return assets2.find((asset) => asset.name.toLowerCase() === DESKTOP_CHECKSUM_ASSET_NAME.toLowerCase()) ?? null;
|
|
10095
10096
|
}
|
|
10096
10097
|
function githubApiHeaders() {
|
|
10097
10098
|
return {
|
|
@@ -10107,6 +10108,32 @@ async function fetchGithubRelease(repo, tag) {
|
|
|
10107
10108
|
}
|
|
10108
10109
|
return await response.json();
|
|
10109
10110
|
}
|
|
10111
|
+
function resolveDesktopReleaseVersion(tag) {
|
|
10112
|
+
if (!tag || tag === "latest") return null;
|
|
10113
|
+
const name = tag.split("/").pop() ?? tag;
|
|
10114
|
+
if (!name.startsWith("v")) return null;
|
|
10115
|
+
const version = name.slice(1);
|
|
10116
|
+
if (STABLE_SEMVER_RE.test(version) || CANARY_SEMVER_RE.test(version)) return version;
|
|
10117
|
+
return null;
|
|
10118
|
+
}
|
|
10119
|
+
function resolveDesktopAssetName(version, target) {
|
|
10120
|
+
if (target.platform === "macos") return `${DESKTOP_APP_NAME}-${version}-macos-${target.arch}-portable.zip`;
|
|
10121
|
+
if (target.platform === "windows") return `${DESKTOP_APP_NAME}-${version}-windows-x64-portable.zip`;
|
|
10122
|
+
return `${DESKTOP_APP_NAME}-${version}-linux-x64.AppImage`;
|
|
10123
|
+
}
|
|
10124
|
+
function encodeReleaseTagForDownloadUrl(tag) {
|
|
10125
|
+
return tag.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
10126
|
+
}
|
|
10127
|
+
function buildGithubReleaseAssetDownloadUrl(repo, tag, assetName) {
|
|
10128
|
+
const encodedTag = encodeReleaseTagForDownloadUrl(tag);
|
|
10129
|
+
return `https://github.com/${repo}/releases/download/${encodedTag}/${encodeURIComponent(assetName)}`;
|
|
10130
|
+
}
|
|
10131
|
+
function buildGithubReleaseAsset(repo, tag, assetName) {
|
|
10132
|
+
return {
|
|
10133
|
+
name: assetName,
|
|
10134
|
+
browser_download_url: buildGithubReleaseAssetDownloadUrl(repo, tag, assetName)
|
|
10135
|
+
};
|
|
10136
|
+
}
|
|
10110
10137
|
async function downloadAsset(asset, outputDir) {
|
|
10111
10138
|
mkdirSync2(outputDir, { recursive: true });
|
|
10112
10139
|
const outputPath = path9.join(outputDir, path9.basename(asset.name));
|
|
@@ -10114,7 +10141,7 @@ async function downloadAsset(asset, outputDir) {
|
|
|
10114
10141
|
headers: { "User-Agent": "rudder-cli-installer" }
|
|
10115
10142
|
});
|
|
10116
10143
|
if (!response.ok || !response.body) {
|
|
10117
|
-
throw new Error(`Failed to download ${asset.name} (${response.status}).`);
|
|
10144
|
+
throw new Error(`Failed to download ${asset.name} from ${asset.browser_download_url} (${response.status}).`);
|
|
10118
10145
|
}
|
|
10119
10146
|
await pipeline(Readable.fromWeb(response.body), createWriteStream(outputPath));
|
|
10120
10147
|
return outputPath;
|
|
@@ -10460,15 +10487,21 @@ async function startCommand(opts) {
|
|
|
10460
10487
|
p13.outro(pc8.green("Dry run complete."));
|
|
10461
10488
|
return;
|
|
10462
10489
|
}
|
|
10463
|
-
const
|
|
10464
|
-
const
|
|
10490
|
+
const directReleaseVersion = resolveDesktopReleaseVersion(tag);
|
|
10491
|
+
const release = directReleaseVersion ? null : await fetchGithubRelease(repo, tag);
|
|
10492
|
+
const releaseTag = directReleaseVersion ? tag : release?.tag_name;
|
|
10493
|
+
if (!releaseTag) {
|
|
10494
|
+
throw new Error(`Unable to resolve Rudder Desktop release tag for ${repo}@${tag}.`);
|
|
10495
|
+
}
|
|
10496
|
+
const asset = directReleaseVersion ? buildGithubReleaseAsset(repo, tag, resolveDesktopAssetName(directReleaseVersion, target)) : selectDesktopAsset(release?.assets ?? [], target);
|
|
10465
10497
|
if (!asset) {
|
|
10466
|
-
throw new Error(`No Rudder Desktop portable asset found for ${target.platform}/${target.arch} in ${repo}@${
|
|
10498
|
+
throw new Error(`No Rudder Desktop portable asset found for ${target.platform}/${target.arch} in ${repo}@${releaseTag}.`);
|
|
10467
10499
|
}
|
|
10468
|
-
const
|
|
10500
|
+
const checksumAsset = directReleaseVersion ? buildGithubReleaseAsset(repo, tag, DESKTOP_CHECKSUM_ASSET_NAME) : selectChecksumAsset(release?.assets ?? []);
|
|
10501
|
+
const checksums = await downloadChecksums(checksumAsset, outputDir);
|
|
10469
10502
|
const expectedChecksum = resolveAssetChecksum(checksums, asset.name);
|
|
10470
10503
|
const metadata = await readInstallMetadata(installPaths.metadataPath);
|
|
10471
|
-
if (isInstalledDesktopCurrent(metadata,
|
|
10504
|
+
if (isInstalledDesktopCurrent(metadata, releaseTag, asset.name, expectedChecksum) && await pathExists(installPaths.executablePath)) {
|
|
10472
10505
|
p13.log.success(`Rudder Desktop is already installed at ${pc8.cyan(installPaths.appPath)}.`);
|
|
10473
10506
|
await removeMacQuarantine(installPaths, target);
|
|
10474
10507
|
await createPlatformLaunchers(installPaths, target);
|
|
@@ -10481,7 +10514,7 @@ async function startCommand(opts) {
|
|
|
10481
10514
|
await installPortableDesktop(installerPath, installPaths, target);
|
|
10482
10515
|
await removeMacQuarantine(installPaths, target);
|
|
10483
10516
|
await createPlatformLaunchers(installPaths, target);
|
|
10484
|
-
await writeInstallMetadata(installPaths,
|
|
10517
|
+
await writeInstallMetadata(installPaths, releaseTag, asset.name, checksum);
|
|
10485
10518
|
p13.log.success(`Installed Rudder Desktop to ${pc8.cyan(installPaths.appPath)}.`);
|
|
10486
10519
|
}
|
|
10487
10520
|
if (opts.open !== false) {
|
|
@@ -19534,7 +19567,7 @@ var DATA_DIR_OPTION_HELP = "Rudder data directory root (isolates state from ~/.r
|
|
|
19534
19567
|
var LOCAL_ENV_OPTION_HELP = "Local environment profile (dev, prod_local, e2e)";
|
|
19535
19568
|
function createProgram() {
|
|
19536
19569
|
const program = new Command();
|
|
19537
|
-
program.name("rudder").description("Rudder CLI \u2014 setup, diagnose, and configure your instance").version("0.1.0-canary.
|
|
19570
|
+
program.name("rudder").description("Rudder CLI \u2014 setup, diagnose, and configure your instance").version("0.1.0-canary.12");
|
|
19538
19571
|
program.option("--local-env <name>", LOCAL_ENV_OPTION_HELP);
|
|
19539
19572
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
19540
19573
|
const options = actionCommand.optsWithGlobals();
|