@webiny/pulumi-sdk 6.4.5 → 6.6.0-alpha.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/Pulumi.d.ts CHANGED
@@ -1,4 +1,14 @@
1
- import { ExecaChildProcess } from "execa";
1
+ import { type Readable, type Writable } from "node:stream";
2
+ export interface PulumiProcessResult {
3
+ readonly stdout: string;
4
+ readonly stderr: string;
5
+ readonly exitCode: number;
6
+ }
7
+ export interface PulumiProcess extends Promise<PulumiProcessResult> {
8
+ readonly stdin: Writable | null;
9
+ readonly stdout: Readable | null;
10
+ readonly stderr: Readable | null;
11
+ }
2
12
  type Command = string | string[];
3
13
  export interface PulumiArgs {
4
14
  [key: string]: string | boolean | undefined | string[];
@@ -37,7 +47,7 @@ export declare class Pulumi {
37
47
  pulumiBinaryPath: string;
38
48
  static create(options?: Options): Promise<Pulumi>;
39
49
  private constructor();
40
- run(rawArgs: RunArgs): ExecaChildProcess<string>;
50
+ run(rawArgs: RunArgs): PulumiProcess;
41
51
  private install;
42
52
  private ensureAwsPluginIsInstalled;
43
53
  }
package/Pulumi.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import os from "os";
2
- import execa from "execa";
2
+ import { execa, execaSync } from "execa";
3
3
  import fs_extra from "fs-extra";
4
4
  import merge from "lodash/merge.js";
5
5
  import kebabCase from "lodash/kebabCase.js";
@@ -76,7 +76,7 @@ class Pulumi {
76
76
  }
77
77
  async ensureAwsPluginIsInstalled() {
78
78
  let pulumiAwsVersion = "";
79
- const { stdout } = execa.sync("yarn", [
79
+ const { stdout } = execaSync("yarn", [
80
80
  "info",
81
81
  "@pulumi/aws",
82
82
  "-A",
@@ -90,7 +90,7 @@ class Pulumi {
90
90
  const pluginsDir = __rspack_external_path.join(this.pulumiFolder, "plugins");
91
91
  const requiredPluginDir = `resource-aws-v${pulumiAwsVersion}`;
92
92
  const pluginExists = fs_extra.pathExistsSync(__rspack_external_path.join(pluginsDir, requiredPluginDir, "pulumi-resource-aws"));
93
- if (!pluginExists) execa.sync(this.pulumiBinaryPath, [
93
+ if (!pluginExists) execaSync(this.pulumiBinaryPath, [
94
94
  "plugin",
95
95
  "install",
96
96
  "resource",
package/Pulumi.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Pulumi.js","sources":["../src/Pulumi.ts"],"sourcesContent":["import os from \"os\";\nimport execa, { ExecaChildProcess } from \"execa\";\nimport * as path from \"path\";\nimport fs from \"fs-extra\";\nimport merge from \"lodash/merge.js\";\nimport kebabCase from \"lodash/kebabCase.js\";\nimport set from \"lodash/set.js\";\nimport downloadBinaries from \"./downloadBinaries.js\";\n\ntype Command = string | string[];\n\nexport interface PulumiArgs {\n [key: string]: string | boolean | undefined | string[];\n}\n\nexport interface ExecaArgs {\n env?: {\n [key: string]: string | undefined;\n };\n\n [key: string]: any;\n}\n\nexport interface Options {\n args?: PulumiArgs;\n execa?: ExecaArgs;\n beforePulumiInstall?: () => any;\n afterPulumiInstall?: () => any;\n\n // A folder into which the Pulumi CLI, along with all of its meta data and config files, will be set up.\n // It's recommended this folder is not checked in into a code repository, since the Pulumi CLI can store\n // sensitive information here, for example - user's Pulumi Service credentials.\n pulumiFolder?: string;\n}\n\nexport interface RunArgs {\n command: Command;\n args?: PulumiArgs;\n execa?: ExecaArgs;\n beforePulumiInstall?: () => any;\n afterPulumiInstall?: () => any;\n}\n\nexport interface InstallArgs {\n beforePulumiInstall?: () => any;\n afterPulumiInstall?: () => any;\n}\n\nexport const FLAG_NON_INTERACTIVE = \"--non-interactive\";\n\nexport class PulumiError extends Error {}\n\nexport class Pulumi {\n options: Options;\n pulumiFolder: string;\n pulumiDownloadFolder: string;\n pulumiBinaryPath: string;\n\n static async create(options: Options = {}) {\n const pulumi = new Pulumi(options);\n // If not already installed, Pulumi binaries will be downloaded in this step.\n await pulumi.install();\n // No matter if it's a fresh installation or not, we make sure that Pulumi AWS plugin is installed.\n await pulumi.ensureAwsPluginIsInstalled();\n return pulumi;\n }\n\n private constructor(options: Options = {}) {\n this.options = options;\n\n this.pulumiDownloadFolder = path.join(\n options.pulumiFolder || process.cwd(),\n \"pulumi-cli\",\n os.platform()\n );\n\n this.pulumiFolder = path.join(this.pulumiDownloadFolder, \"pulumi\");\n this.pulumiBinaryPath = path.join(this.pulumiFolder, \"pulumi\");\n }\n\n run(rawArgs: RunArgs) {\n const args = merge({}, this.options, rawArgs);\n\n if (!Array.isArray(args.command)) {\n args.command = [args.command];\n }\n\n // 1. Prepare Pulumi args.\n const finalArgs = [];\n for (const key in args.args) {\n const value = args.args[key];\n if (!value) {\n continue;\n }\n\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n finalArgs.push(`--${kebabCase(key)}`, value[i]);\n }\n continue;\n }\n\n if (typeof value === \"boolean\") {\n finalArgs.push(`--${kebabCase(key)}`);\n continue;\n }\n\n finalArgs.push(`--${kebabCase(key)}`, value);\n }\n\n // Prepare execa args.\n if (!args.execa) {\n args.execa = {};\n }\n\n set(args.execa, \"env.PULUMI_SKIP_UPDATE_CHECK\", \"true\");\n set(args.execa, \"env.PULUMI_HOME\", this.pulumiFolder);\n\n if (os.arch() === \"arm64\") {\n /**\n * This variable is an attempt to resolve this issue:\n * https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/\n */\n set(args.execa, \"env.GODEBUG\", \"asyncpreemptoff=1\");\n }\n\n // Use \";\" when on Windows. For Mac and Linux, use \":\".\n const PATH_SEPARATOR = os.platform() === \"win32\" ? \";\" : \":\";\n\n const execaArgs = {\n ...args.execa,\n env: {\n ...(args.execa.env || {}),\n /**\n * Due to an issue with Pulumi https://github.com/pulumi/pulumi/issues/8374, and even though this\n * commit suggests it should already work like that https://github.com/pulumi/pulumi/commit/c878916901a997a9c0ffcbed23560e19e224a6f1,\n * we need to specify the exact location of our Pulumi binaries, using the PATH environment variable, so it can correctly resolve\n * plugins necessary for custom resources and dynamic providers to work.\n */\n PATH: this.pulumiFolder + PATH_SEPARATOR + process.env.PATH\n }\n };\n\n // We want to keep the \"interactive\" output format of the Pulumi command when `--preview` flag is passed in.\n const flags =\n args.command && args.command.includes(\"preview\") ? [] : [FLAG_NON_INTERACTIVE];\n\n const pulumiProcess = execa(\n this.pulumiBinaryPath,\n [...args.command, ...finalArgs, ...flags],\n execaArgs\n );\n\n // We want to throw an instance of PulumiError when the Pulumi command fails.\n // Makes it easier to catch and handle Pulumi errors in the code.\n // Note: this code definitely looks funky, but it is because how `execa` works.\n const wrapped = pulumiProcess.then(\n result => result,\n err => {\n throw new PulumiError(err.stderr || err.stdout || err.message, { cause: err });\n }\n );\n\n Object.assign(wrapped, pulumiProcess);\n\n return wrapped as ExecaChildProcess<string>;\n }\n\n private async install(rawArgs?: InstallArgs): Promise<boolean> {\n const args = merge({}, this.options, rawArgs);\n\n return await downloadBinaries(\n this.pulumiDownloadFolder,\n args.beforePulumiInstall,\n args.afterPulumiInstall\n );\n }\n\n private async ensureAwsPluginIsInstalled() {\n let pulumiAwsVersion = \"\";\n const { stdout } = execa.sync(\"yarn\", [\n \"info\",\n \"@pulumi/aws\",\n \"-A\",\n \"-R\",\n \"--name-only\",\n \"--json\"\n ]);\n\n const match = stdout.match(/npm:(.*?)\"/);\n if (match) {\n pulumiAwsVersion = match[1];\n }\n\n if (!pulumiAwsVersion) {\n throw new PulumiError(\n \"Could not determine the version of @pulumi/aws package. Please ensure it is installed.\"\n );\n }\n\n const pluginsDir = path.join(this.pulumiFolder, \"plugins\");\n // Pulumi names plugin directories with a \"v\" prefix (e.g. resource-aws-v7.25.0).\n const requiredPluginDir = `resource-aws-v${pulumiAwsVersion}`;\n\n const pluginExists = fs.pathExistsSync(\n path.join(pluginsDir, requiredPluginDir, \"pulumi-resource-aws\")\n );\n\n if (!pluginExists) {\n execa.sync(\n this.pulumiBinaryPath,\n [\"plugin\", \"install\", \"resource\", \"aws\", pulumiAwsVersion],\n {\n stdio: \"inherit\",\n env: {\n PULUMI_HOME: this.pulumiFolder,\n PULUMI_SKIP_UPDATE_CHECK: \"true\"\n }\n }\n );\n }\n\n // Remove stale resource-aws plugin versions to reclaim disk space.\n if (fs.pathExistsSync(pluginsDir)) {\n for (const entry of fs.readdirSync(pluginsDir)) {\n if (!entry.startsWith(\"resource-aws-\") || entry === requiredPluginDir) {\n continue;\n }\n // Strip the trailing \".lock\" suffix so both the directory and its\n // lock file are matched by the same prefix check.\n const baseName = entry.endsWith(\".lock\") ? entry.slice(0, -5) : entry;\n if (baseName !== requiredPluginDir) {\n fs.removeSync(path.join(pluginsDir, entry));\n }\n }\n }\n }\n}\n"],"names":["FLAG_NON_INTERACTIVE","PulumiError","Error","Pulumi","options","pulumi","path","process","os","rawArgs","args","merge","Array","finalArgs","key","value","i","kebabCase","set","PATH_SEPARATOR","execaArgs","flags","pulumiProcess","execa","wrapped","result","err","Object","downloadBinaries","pulumiAwsVersion","stdout","match","pluginsDir","requiredPluginDir","pluginExists","fs","entry","baseName"],"mappings":";;;;;;;;AAgDO,MAAMA,uBAAuB;AAE7B,MAAMC,oBAAoBC;AAAO;AAEjC,MAAMC;IAMT,aAAa,OAAOC,UAAmB,CAAC,CAAC,EAAE;QACvC,MAAMC,SAAS,IAAIF,OAAOC;QAE1B,MAAMC,OAAO,OAAO;QAEpB,MAAMA,OAAO,0BAA0B;QACvC,OAAOA;IACX;IAEA,YAAoBD,UAAmB,CAAC,CAAC,CAAE;QACvC,IAAI,CAAC,OAAO,GAAGA;QAEf,IAAI,CAAC,oBAAoB,GAAGE,uBAAAA,IAAS,CACjCF,QAAQ,YAAY,IAAIG,QAAQ,GAAG,IACnC,cACAC,GAAG,QAAQ;QAGf,IAAI,CAAC,YAAY,GAAGF,uBAAAA,IAAS,CAAC,IAAI,CAAC,oBAAoB,EAAE;QACzD,IAAI,CAAC,gBAAgB,GAAGA,uBAAAA,IAAS,CAAC,IAAI,CAAC,YAAY,EAAE;IACzD;IAEA,IAAIG,OAAgB,EAAE;QAClB,MAAMC,OAAOC,MAAM,CAAC,GAAG,IAAI,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AAAA,cAAiB,CAACH,aAClB,KAAK,MAAMI,SAASD,SAAAA,WAAc,CAACH,YAAa;YAC5C,IAAI,CAACI,MAAM,UAAU,CAAC,oBAAoBA,UAAUH,mBAChD;YAIJ,MAAMI,WAAWD,MAAM,QAAQ,CAAC,WAAWA,MAAM,KAAK,CAAC,GAAG,MAAMA;YAChE,IAAIC,aAAaJ,mBACbE,SAAAA,UAAa,CAAC7B,uBAAAA,IAAS,CAAC0B,YAAYI;QAE5C;IAER;AACJ"}
1
+ {"version":3,"file":"Pulumi.js","sources":["../src/Pulumi.ts"],"sourcesContent":["import os from \"os\";\nimport { execa, execaSync } from \"execa\";\nimport { type Readable, type Writable } from \"node:stream\";\nimport * as path from \"path\";\nimport fs from \"fs-extra\";\nimport merge from \"lodash/merge.js\";\nimport kebabCase from \"lodash/kebabCase.js\";\nimport set from \"lodash/set.js\";\nimport downloadBinaries from \"./downloadBinaries.js\";\n\nexport interface PulumiProcessResult {\n readonly stdout: string;\n readonly stderr: string;\n readonly exitCode: number;\n}\n\nexport interface PulumiProcess extends Promise<PulumiProcessResult> {\n readonly stdin: Writable | null;\n readonly stdout: Readable | null;\n readonly stderr: Readable | null;\n}\n\ntype Command = string | string[];\n\nexport interface PulumiArgs {\n [key: string]: string | boolean | undefined | string[];\n}\n\nexport interface ExecaArgs {\n env?: {\n [key: string]: string | undefined;\n };\n\n [key: string]: any;\n}\n\nexport interface Options {\n args?: PulumiArgs;\n execa?: ExecaArgs;\n beforePulumiInstall?: () => any;\n afterPulumiInstall?: () => any;\n\n // A folder into which the Pulumi CLI, along with all of its meta data and config files, will be set up.\n // It's recommended this folder is not checked in into a code repository, since the Pulumi CLI can store\n // sensitive information here, for example - user's Pulumi Service credentials.\n pulumiFolder?: string;\n}\n\nexport interface RunArgs {\n command: Command;\n args?: PulumiArgs;\n execa?: ExecaArgs;\n beforePulumiInstall?: () => any;\n afterPulumiInstall?: () => any;\n}\n\nexport interface InstallArgs {\n beforePulumiInstall?: () => any;\n afterPulumiInstall?: () => any;\n}\n\nexport const FLAG_NON_INTERACTIVE = \"--non-interactive\";\n\nexport class PulumiError extends Error {}\n\nexport class Pulumi {\n options: Options;\n pulumiFolder: string;\n pulumiDownloadFolder: string;\n pulumiBinaryPath: string;\n\n static async create(options: Options = {}) {\n const pulumi = new Pulumi(options);\n // If not already installed, Pulumi binaries will be downloaded in this step.\n await pulumi.install();\n // No matter if it's a fresh installation or not, we make sure that Pulumi AWS plugin is installed.\n await pulumi.ensureAwsPluginIsInstalled();\n return pulumi;\n }\n\n private constructor(options: Options = {}) {\n this.options = options;\n\n this.pulumiDownloadFolder = path.join(\n options.pulumiFolder || process.cwd(),\n \"pulumi-cli\",\n os.platform()\n );\n\n this.pulumiFolder = path.join(this.pulumiDownloadFolder, \"pulumi\");\n this.pulumiBinaryPath = path.join(this.pulumiFolder, \"pulumi\");\n }\n\n run(rawArgs: RunArgs) {\n const args = merge({}, this.options, rawArgs);\n\n if (!Array.isArray(args.command)) {\n args.command = [args.command];\n }\n\n // 1. Prepare Pulumi args.\n const finalArgs = [];\n for (const key in args.args) {\n const value = args.args[key];\n if (!value) {\n continue;\n }\n\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n finalArgs.push(`--${kebabCase(key)}`, value[i]);\n }\n continue;\n }\n\n if (typeof value === \"boolean\") {\n finalArgs.push(`--${kebabCase(key)}`);\n continue;\n }\n\n finalArgs.push(`--${kebabCase(key)}`, value);\n }\n\n // Prepare execa args.\n if (!args.execa) {\n args.execa = {};\n }\n\n set(args.execa, \"env.PULUMI_SKIP_UPDATE_CHECK\", \"true\");\n set(args.execa, \"env.PULUMI_HOME\", this.pulumiFolder);\n\n if (os.arch() === \"arm64\") {\n /**\n * This variable is an attempt to resolve this issue:\n * https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/\n */\n set(args.execa, \"env.GODEBUG\", \"asyncpreemptoff=1\");\n }\n\n // Use \";\" when on Windows. For Mac and Linux, use \":\".\n const PATH_SEPARATOR = os.platform() === \"win32\" ? \";\" : \":\";\n\n const execaArgs = {\n ...args.execa,\n env: {\n ...(args.execa.env || {}),\n /**\n * Due to an issue with Pulumi https://github.com/pulumi/pulumi/issues/8374, and even though this\n * commit suggests it should already work like that https://github.com/pulumi/pulumi/commit/c878916901a997a9c0ffcbed23560e19e224a6f1,\n * we need to specify the exact location of our Pulumi binaries, using the PATH environment variable, so it can correctly resolve\n * plugins necessary for custom resources and dynamic providers to work.\n */\n PATH: this.pulumiFolder + PATH_SEPARATOR + process.env.PATH\n }\n };\n\n // We want to keep the \"interactive\" output format of the Pulumi command when `--preview` flag is passed in.\n const flags =\n args.command && args.command.includes(\"preview\") ? [] : [FLAG_NON_INTERACTIVE];\n\n const pulumiProcess = execa(\n this.pulumiBinaryPath,\n [...args.command, ...finalArgs, ...flags],\n execaArgs\n );\n\n // We want to throw an instance of PulumiError when the Pulumi command fails.\n // Makes it easier to catch and handle Pulumi errors in the code.\n // Note: this code definitely looks funky, but it is because how `execa` works.\n const wrapped = pulumiProcess.then(\n result => result,\n err => {\n throw new PulumiError(err.stderr || err.stdout || err.message, { cause: err });\n }\n );\n\n Object.assign(wrapped, pulumiProcess);\n\n return wrapped as unknown as PulumiProcess;\n }\n\n private async install(rawArgs?: InstallArgs): Promise<boolean> {\n const args = merge({}, this.options, rawArgs);\n\n return await downloadBinaries(\n this.pulumiDownloadFolder,\n args.beforePulumiInstall,\n args.afterPulumiInstall\n );\n }\n\n private async ensureAwsPluginIsInstalled() {\n let pulumiAwsVersion = \"\";\n const { stdout } = execaSync(\"yarn\", [\n \"info\",\n \"@pulumi/aws\",\n \"-A\",\n \"-R\",\n \"--name-only\",\n \"--json\"\n ]);\n\n const match = stdout.match(/npm:(.*?)\"/);\n if (match) {\n pulumiAwsVersion = match[1];\n }\n\n if (!pulumiAwsVersion) {\n throw new PulumiError(\n \"Could not determine the version of @pulumi/aws package. Please ensure it is installed.\"\n );\n }\n\n const pluginsDir = path.join(this.pulumiFolder, \"plugins\");\n // Pulumi names plugin directories with a \"v\" prefix (e.g. resource-aws-v7.25.0).\n const requiredPluginDir = `resource-aws-v${pulumiAwsVersion}`;\n\n const pluginExists = fs.pathExistsSync(\n path.join(pluginsDir, requiredPluginDir, \"pulumi-resource-aws\")\n );\n\n if (!pluginExists) {\n execaSync(\n this.pulumiBinaryPath,\n [\"plugin\", \"install\", \"resource\", \"aws\", pulumiAwsVersion],\n {\n stdio: \"inherit\",\n env: {\n PULUMI_HOME: this.pulumiFolder,\n PULUMI_SKIP_UPDATE_CHECK: \"true\"\n }\n }\n );\n }\n\n // Remove stale resource-aws plugin versions to reclaim disk space.\n if (fs.pathExistsSync(pluginsDir)) {\n for (const entry of fs.readdirSync(pluginsDir)) {\n if (!entry.startsWith(\"resource-aws-\") || entry === requiredPluginDir) {\n continue;\n }\n // Strip the trailing \".lock\" suffix so both the directory and its\n // lock file are matched by the same prefix check.\n const baseName = entry.endsWith(\".lock\") ? entry.slice(0, -5) : entry;\n if (baseName !== requiredPluginDir) {\n fs.removeSync(path.join(pluginsDir, entry));\n }\n }\n }\n }\n}\n"],"names":["FLAG_NON_INTERACTIVE","PulumiError","Error","Pulumi","options","pulumi","path","process","os","rawArgs","args","merge","Array","finalArgs","key","value","i","kebabCase","set","PATH_SEPARATOR","execaArgs","flags","pulumiProcess","execa","wrapped","result","err","Object","downloadBinaries","pulumiAwsVersion","stdout","execaSync","match","pluginsDir","requiredPluginDir","pluginExists","fs","entry","baseName"],"mappings":";;;;;;;;AA6DO,MAAMA,uBAAuB;AAE7B,MAAMC,oBAAoBC;AAAO;AAEjC,MAAMC;IAMT,aAAa,OAAOC,UAAmB,CAAC,CAAC,EAAE;QACvC,MAAMC,SAAS,IAAIF,OAAOC;QAE1B,MAAMC,OAAO,OAAO;QAEpB,MAAMA,OAAO,0BAA0B;QACvC,OAAOA;IACX;IAEA,YAAoBD,UAAmB,CAAC,CAAC,CAAE;QACvC,IAAI,CAAC,OAAO,GAAGA;QAEf,IAAI,CAAC,o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AAc,EAAEL,kBAAkB;QAE7D,MAAMM,eAAeC,SAAAA,cAAiB,CAClC9B,uBAAAA,IAAS,CAAC2B,YAAYC,mBAAmB;QAG7C,IAAI,CAACC,cACDJ,UACI,IAAI,CAAC,gBAAgB,EACrB;YAAC;YAAU;YAAW;YAAY;YAAOF;SAAiB,EAC1D;YACI,OAAO;YACP,KAAK;gBACD,aAAa,IAAI,CAAC,YAAY;gBAC9B,0BAA0B;YAC9B;QACJ;QAKR,IAAIO,SAAAA,cAAiB,CAACH,aAClB,KAAK,MAAMI,SAASD,SAAAA,WAAc,CAACH,YAAa;YAC5C,IAAI,CAACI,MAAM,UAAU,CAAC,oBAAoBA,UAAUH,mBAChD;YAIJ,MAAMI,WAAWD,MAAM,QAAQ,CAAC,WAAWA,MAAM,KAAK,CAAC,GAAG,MAAMA;YAChE,IAAIC,aAAaJ,mBACbE,SAAAA,UAAa,CAAC9B,uBAAAA,IAAS,CAAC2B,YAAYI;QAE5C;IAER;AACJ"}
@@ -1,2 +1,2 @@
1
- declare const _default: (downloadFolder: string, beforeInstall?: () => void, afterInstall?: () => void) => Promise<boolean>;
2
1
  export default _default;
2
+ declare function _default(downloadFolder: string, beforeInstall?: () => void, afterInstall?: () => void): Promise<boolean>;
@@ -1,7 +1,7 @@
1
1
  import os from "os";
2
2
  import fs from "fs";
3
3
  import path from "path";
4
- import decompress from "decompress";
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
- switch(platform){
20
- case "darwin":
21
- await setupDarwin(downloadFolder);
22
- break;
23
- case "linux":
24
- await setupLinux(downloadFolder);
25
- break;
26
- case "win32":
27
- await setupWindows(downloadFolder);
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
- async function setupDarwin(downloadFolder) {
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 arch = SUPPORTED_ARCHITECTURES.includes(process.arch) ? process.arch : "x64";
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
- await __rspack_external_tar.extract({
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(path.join(downloadFolder, filename));
60
+ fs.unlinkSync(absoluteFilename);
51
61
  }
52
- async function setupWindows(downloadFolder) {
53
- const version = getPulumiVersion();
54
- const filename = `pulumi-v${version}-windows-x64.zip`;
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
- fs.unlinkSync(path.join(downloadFolder, filename));
63
- }
64
- async function setupLinux(downloadFolder) {
65
- const version = getPulumiVersion();
66
- const filename = `pulumi-v${version}-linux-x64.tar.gz`;
67
- const downloadUrl = "https://get.pulumi.com/releases/sdk/" + filename;
68
- const absoluteFilename = path.join(downloadFolder, filename);
69
- await downloadFile(downloadUrl, absoluteFilename);
70
- await __rspack_external_tar.extract({
71
- cwd: downloadFolder,
72
- file: absoluteFilename
73
- });
74
- fs.unlinkSync(path.join(downloadFolder, filename));
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
 
@@ -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\";\n// @ts-expect-error `tar` has no types.\nimport decompress from \"decompress\";\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 switch (platform) {\n case \"darwin\":\n await setupDarwin(downloadFolder);\n break;\n case \"linux\":\n await setupLinux(downloadFolder);\n break;\n case \"win32\":\n await setupWindows(downloadFolder);\n break;\n default:\n throw Error(\n `Cannot download Pulumi binaries - platform \"${platform}\" not supported. Supported ones are \"darwin\", \"linux\", and \"win32\"`\n );\n }\n\n if (typeof afterInstall === \"function\") {\n await afterInstall();\n }\n\n return true;\n};\n\nconst SUPPORTED_ARCHITECTURES = [\"x64\", \"arm64\"];\n\nasync function setupDarwin(downloadFolder: string) {\n const version = getPulumiVersion();\n const arch = SUPPORTED_ARCHITECTURES.includes(process.arch) ? process.arch : \"x64\";\n\n const filename = `pulumi-v${version}-darwin-${arch}.tar.gz`;\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 await tar.extract({\n cwd: downloadFolder,\n file: absoluteFilename\n });\n\n fs.unlinkSync(path.join(downloadFolder, filename));\n}\n\nasync function setupWindows(downloadFolder: string) {\n const version = getPulumiVersion();\n const filename = `pulumi-v${version}-windows-x64.zip`;\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 const destination = path.join(downloadFolder, \"pulumi\");\n await decompress(absoluteFilename, destination, { strip: 2 });\n\n fs.unlinkSync(path.join(downloadFolder, filename));\n}\n\nasync function setupLinux(downloadFolder: string) {\n const version = getPulumiVersion();\n const filename = `pulumi-v${version}-linux-x64.tar.gz`;\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 await tar.extract({\n cwd: downloadFolder,\n file: absoluteFilename\n });\n\n fs.unlinkSync(path.join(downloadFolder, filename));\n}\n"],"names":["getPulumiVersion","pkgJsonPath","findUpSync","version","loadJsonFileSync","semver","downloadFolder","beforeInstall","afterInstall","fs","platform","os","setupDarwin","setupLinux","setupWindows","Error","SUPPORTED_ARCHITECTURES","arch","process","filename","downloadUrl","absoluteFilename","path","downloadFile","tar","destination","decompress"],"mappings":";;;;;;;;;AAeA,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;IAC5B,OAAQD;QACJ,KAAK;YACD,MAAME,YAAYN;YAClB;QACJ,KAAK;YACD,MAAMO,WAAWP;YACjB;QACJ,KAAK;YACD,MAAMQ,aAAaR;YACnB;QACJ;YACI,MAAMS,MACF,CAAC,4CAA4C,EAAEL,SAAS,kEAAkE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lB;QACL,MAAMe;IACV;IAEAZ,GAAG,UAAU,CAACa,KAAK,IAAI,CAAChB,gBAAgBa;AAC5C"}
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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AAaC;IAEhC,IAAIX,AAAa,YAAbA,UACAc,WAAWH,kBAAkBC,KAAK,IAAI,CAAChB,gBAAgB;SAEvD,MAAMmB,sBAAAA,OAAW,CAAC;QAAE,KAAKnB;QAAgB,MAAMe;IAAiB;IAGpEZ,GAAG,UAAU,CAACY;AAClB;AAEA,SAASG,WAAWE,OAAe,EAAEC,WAAmB;IACpDlB,GAAG,SAAS,CAACkB,aAAa;QAAE,WAAW;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.5",
3
+ "version": "6.6.0-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,23 +17,24 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@pulumi/aws": "^7.35.0",
21
- "@pulumi/pulumi": "^3.251.0",
22
- "decompress": "4.2.1",
23
- "execa": "5.1.1",
20
+ "@pulumi/aws": "^7.39.0",
21
+ "@pulumi/pulumi": "^3.254.0",
22
+ "adm-zip": "0.6.0",
23
+ "execa": "10.0.0",
24
24
  "find-up": "8.0.0",
25
- "fs-extra": "11.3.6",
25
+ "fs-extra": "11.4.0",
26
26
  "load-json-file": "7.0.1",
27
27
  "lodash": "4.18.1",
28
28
  "semver": "7.8.5",
29
- "tar": "7.5.19"
29
+ "tar": "7.5.22"
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.5",
34
+ "@webiny/build-tools": "6.6.0-alpha.0",
34
35
  "rimraf": "6.1.3",
35
36
  "type-fest": "5.8.0",
36
- "typescript": "6.0.3"
37
+ "typescript": "7.0.2"
37
38
  },
38
39
  "adio": {
39
40
  "ignore": {