@webiny/pulumi-sdk 6.4.8-beta.0 → 6.4.9-beta.0
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/downloadBinaries.js +46 -40
- package/downloadBinaries.js.map +1 -1
- package/package.json +4 -3
package/downloadBinaries.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os from "os";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import
|
|
4
|
+
import adm_zip from "adm-zip";
|
|
5
5
|
import semver from "semver";
|
|
6
6
|
import { findUpSync } from "find-up";
|
|
7
7
|
import { loadJsonFileSync } from "load-json-file";
|
|
@@ -16,18 +16,15 @@ const downloadBinaries = async (downloadFolder, beforeInstall, afterInstall)=>{
|
|
|
16
16
|
if (fs.existsSync(downloadFolder)) return false;
|
|
17
17
|
if ("function" == typeof beforeInstall) await beforeInstall();
|
|
18
18
|
const platform = os.platform();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
throw Error(`Cannot download Pulumi binaries - platform "${platform}" not supported. Supported ones are "darwin", "linux", and "win32"`);
|
|
19
|
+
if ("darwin" !== platform && "linux" !== platform && "win32" !== platform) throw Error(`Cannot download Pulumi binaries - platform "${platform}" not supported. Supported ones are "darwin", "linux", and "win32"`);
|
|
20
|
+
try {
|
|
21
|
+
await setupPlatform(downloadFolder, platform);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
fs.rmSync(downloadFolder, {
|
|
24
|
+
recursive: true,
|
|
25
|
+
force: true
|
|
26
|
+
});
|
|
27
|
+
throw error;
|
|
31
28
|
}
|
|
32
29
|
if ("function" == typeof afterInstall) await afterInstall();
|
|
33
30
|
return true;
|
|
@@ -36,42 +33,51 @@ const SUPPORTED_ARCHITECTURES = [
|
|
|
36
33
|
"x64",
|
|
37
34
|
"arm64"
|
|
38
35
|
];
|
|
39
|
-
|
|
36
|
+
function getDownloadFilename(version, platform) {
|
|
37
|
+
switch(platform){
|
|
38
|
+
case "darwin":
|
|
39
|
+
{
|
|
40
|
+
const arch = SUPPORTED_ARCHITECTURES.includes(process.arch) ? process.arch : "x64";
|
|
41
|
+
return `pulumi-v${version}-darwin-${arch}.tar.gz`;
|
|
42
|
+
}
|
|
43
|
+
case "linux":
|
|
44
|
+
return `pulumi-v${version}-linux-x64.tar.gz`;
|
|
45
|
+
case "win32":
|
|
46
|
+
return `pulumi-v${version}-windows-x64.zip`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function setupPlatform(downloadFolder, platform) {
|
|
40
50
|
const version = getPulumiVersion();
|
|
41
|
-
const
|
|
42
|
-
const filename = `pulumi-v${version}-darwin-${arch}.tar.gz`;
|
|
51
|
+
const filename = getDownloadFilename(version, platform);
|
|
43
52
|
const downloadUrl = "https://get.pulumi.com/releases/sdk/" + filename;
|
|
44
53
|
const absoluteFilename = path.join(downloadFolder, filename);
|
|
45
54
|
await downloadFile(downloadUrl, absoluteFilename);
|
|
46
|
-
|
|
55
|
+
if ("win32" === platform) extractZip(absoluteFilename, path.join(downloadFolder, "pulumi"));
|
|
56
|
+
else await __rspack_external_tar.extract({
|
|
47
57
|
cwd: downloadFolder,
|
|
48
58
|
file: absoluteFilename
|
|
49
59
|
});
|
|
50
|
-
fs.unlinkSync(
|
|
60
|
+
fs.unlinkSync(absoluteFilename);
|
|
51
61
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const downloadUrl = "https://get.pulumi.com/releases/sdk/" + filename;
|
|
56
|
-
const absoluteFilename = path.join(downloadFolder, filename);
|
|
57
|
-
await downloadFile(downloadUrl, absoluteFilename);
|
|
58
|
-
const destination = path.join(downloadFolder, "pulumi");
|
|
59
|
-
await decompress(absoluteFilename, destination, {
|
|
60
|
-
strip: 2
|
|
62
|
+
function extractZip(zipPath, destination) {
|
|
63
|
+
fs.mkdirSync(destination, {
|
|
64
|
+
recursive: true
|
|
61
65
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
const zip = new adm_zip(zipPath);
|
|
67
|
+
const stripComponents = 2;
|
|
68
|
+
const destinationResolved = path.resolve(destination);
|
|
69
|
+
for (const entry of zip.getEntries()){
|
|
70
|
+
if (entry.isDirectory) continue;
|
|
71
|
+
const segments = entry.entryName.split(/[\\/]+/).slice(stripComponents);
|
|
72
|
+
if (0 === segments.length) continue;
|
|
73
|
+
if (segments.some((s)=>".." === s || path.isAbsolute(s))) throw new Error(`Unsafe zip entry: ${entry.entryName}`);
|
|
74
|
+
const targetPath = path.resolve(destinationResolved, ...segments);
|
|
75
|
+
if (!targetPath.startsWith(destinationResolved + path.sep)) throw new Error(`Zip slip detected: ${entry.entryName}`);
|
|
76
|
+
fs.mkdirSync(path.dirname(targetPath), {
|
|
77
|
+
recursive: true
|
|
78
|
+
});
|
|
79
|
+
fs.writeFileSync(targetPath, entry.getData());
|
|
80
|
+
}
|
|
75
81
|
}
|
|
76
82
|
export default downloadBinaries;
|
|
77
83
|
|
package/downloadBinaries.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloadBinaries.js","sources":["../src/downloadBinaries.ts"],"sourcesContent":["import os from \"os\";\nimport * as tar from \"tar\";\nimport fs from \"fs\";\nimport path from \"path\";\
|
|
1
|
+
{"version":3,"file":"downloadBinaries.js","sources":["../src/downloadBinaries.ts"],"sourcesContent":["import os from \"os\";\nimport * as tar from \"tar\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport AdmZip from \"adm-zip\";\nimport semver from \"semver\";\nimport { findUpSync } from \"find-up\";\nimport { loadJsonFileSync } from \"load-json-file\";\nimport { downloadFile } from \"./downloadFile.js\";\nimport { PackageJson } from \"type-fest\";\n\n// We need to sanitize the package version because, occasionally, we've noticed that the Pulumi version\n// can look like the following: \"2.25.2+dirty\". We want to ensure only \"2.25.2\" is returned.\n// @see https://github.com/pulumi/pulumi/issues/6847\nconst getPulumiVersion = () => {\n const pkgJsonPath = findUpSync(\"node_modules/@pulumi/pulumi/package.json\");\n const { version } = loadJsonFileSync<PackageJson>(pkgJsonPath!);\n return semver.clean(version!);\n};\n\nexport default async (\n downloadFolder: string,\n beforeInstall?: () => void,\n afterInstall?: () => void\n) => {\n if (fs.existsSync(downloadFolder)) {\n return false;\n }\n\n if (typeof beforeInstall === \"function\") {\n await beforeInstall();\n }\n\n const platform = os.platform();\n if (platform !== \"darwin\" && platform !== \"linux\" && platform !== \"win32\") {\n throw Error(\n `Cannot download Pulumi binaries - platform \"${platform}\" not supported. Supported ones are \"darwin\", \"linux\", and \"win32\"`\n );\n }\n\n try {\n await setupPlatform(downloadFolder, platform);\n } catch (error) {\n fs.rmSync(downloadFolder, { recursive: true, force: true });\n throw error;\n }\n\n if (typeof afterInstall === \"function\") {\n await afterInstall();\n }\n\n return true;\n};\n\nconst SUPPORTED_ARCHITECTURES = [\"x64\", \"arm64\"];\n\ntype SupportedPlatform = \"darwin\" | \"linux\" | \"win32\";\n\nfunction getDownloadFilename(version: string, platform: SupportedPlatform): string {\n switch (platform) {\n case \"darwin\": {\n const arch = SUPPORTED_ARCHITECTURES.includes(process.arch) ? process.arch : \"x64\";\n return `pulumi-v${version}-darwin-${arch}.tar.gz`;\n }\n case \"linux\":\n return `pulumi-v${version}-linux-x64.tar.gz`;\n case \"win32\":\n return `pulumi-v${version}-windows-x64.zip`;\n }\n}\n\nasync function setupPlatform(downloadFolder: string, platform: SupportedPlatform) {\n const version = getPulumiVersion();\n const filename = getDownloadFilename(version!, platform);\n const downloadUrl = \"https://get.pulumi.com/releases/sdk/\" + filename;\n\n const absoluteFilename = path.join(downloadFolder, filename);\n await downloadFile(downloadUrl, absoluteFilename);\n\n if (platform === \"win32\") {\n extractZip(absoluteFilename, path.join(downloadFolder, \"pulumi\"));\n } else {\n await tar.extract({ cwd: downloadFolder, file: absoluteFilename });\n }\n\n fs.unlinkSync(absoluteFilename);\n}\n\nfunction extractZip(zipPath: string, destination: string) {\n fs.mkdirSync(destination, { recursive: true });\n\n const zip = new AdmZip(zipPath);\n const stripComponents = 2;\n const destinationResolved = path.resolve(destination);\n\n for (const entry of zip.getEntries()) {\n if (entry.isDirectory) {\n continue;\n }\n\n const segments = entry.entryName.split(/[\\\\/]+/).slice(stripComponents);\n if (segments.length === 0) {\n continue;\n }\n\n if (segments.some(s => s === \"..\" || path.isAbsolute(s))) {\n throw new Error(`Unsafe zip entry: ${entry.entryName}`);\n }\n\n const targetPath = path.resolve(destinationResolved, ...segments);\n if (!targetPath.startsWith(destinationResolved + path.sep)) {\n throw new Error(`Zip slip detected: ${entry.entryName}`);\n }\n\n fs.mkdirSync(path.dirname(targetPath), { recursive: true });\n fs.writeFileSync(targetPath, entry.getData());\n }\n}\n"],"names":["getPulumiVersion","pkgJsonPath","findUpSync","version","loadJsonFileSync","semver","downloadFolder","beforeInstall","afterInstall","fs","platform","os","Error","setupPlatform","error","SUPPORTED_ARCHITECTURES","getDownloadFilename","arch","process","filename","downloadUrl","absoluteFilename","path","downloadFile","extractZip","tar","zipPath","destination","zip","AdmZip","stripComponents","destinationResolved","entry","segments","s","targetPath"],"mappings":";;;;;;;;;AAcA,MAAMA,mBAAmB;IACrB,MAAMC,cAAcC,WAAW;IAC/B,MAAM,EAAEC,OAAO,EAAE,GAAGC,iBAA8BH;IAClD,OAAOI,OAAO,KAAK,CAACF;AACxB;AAEA,yBAAe,OACXG,gBACAC,eACAC;IAEA,IAAIC,GAAG,UAAU,CAACH,iBACd,OAAO;IAGX,IAAI,AAAyB,cAAzB,OAAOC,eACP,MAAMA;IAGV,MAAMG,WAAWC,GAAG,QAAQ;IAC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W;IAAK;IAE5C,MAAMC,MAAM,IAAIC,QAAOH;IACvB,MAAMI,kBAAkB;IACxB,MAAMC,sBAAsBT,KAAK,OAAO,CAACK;IAEzC,KAAK,MAAMK,SAASJ,IAAI,UAAU,GAAI;QAClC,IAAII,MAAM,WAAW,EACjB;QAGJ,MAAMC,WAAWD,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,KAAK,CAACF;QACvD,IAAIG,AAAoB,MAApBA,SAAS,MAAM,EACf;QAGJ,IAAIA,SAAS,IAAI,CAACC,CAAAA,IAAKA,AAAM,SAANA,KAAcZ,KAAK,UAAU,CAACY,KACjD,MAAM,IAAItB,MAAM,CAAC,kBAAkB,EAAEoB,MAAM,SAAS,EAAE;QAG1D,MAAMG,aAAab,KAAK,OAAO,CAACS,wBAAwBE;QACxD,IAAI,CAACE,WAAW,UAAU,CAACJ,sBAAsBT,KAAK,GAAG,GACrD,MAAM,IAAIV,MAAM,CAAC,mBAAmB,EAAEoB,MAAM,SAAS,EAAE;QAG3DvB,GAAG,SAAS,CAACa,KAAK,OAAO,CAACa,aAAa;YAAE,WAAW;QAAK;QACzD1B,GAAG,aAAa,CAAC0B,YAAYH,MAAM,OAAO;IAC9C;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/pulumi-sdk",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.9-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@pulumi/aws": "^7.35.0",
|
|
21
21
|
"@pulumi/pulumi": "^3.251.0",
|
|
22
|
-
"
|
|
22
|
+
"adm-zip": "0.6.0",
|
|
23
23
|
"execa": "5.1.1",
|
|
24
24
|
"find-up": "8.0.0",
|
|
25
25
|
"fs-extra": "11.3.6",
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"tar": "7.5.19"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@types/adm-zip": "0.5.8",
|
|
32
33
|
"@types/lodash": "4.17.24",
|
|
33
|
-
"@webiny/build-tools": "6.4.
|
|
34
|
+
"@webiny/build-tools": "6.4.9-beta.0",
|
|
34
35
|
"rimraf": "6.1.3",
|
|
35
36
|
"type-fest": "5.8.0",
|
|
36
37
|
"typescript": "6.0.3"
|