pulumi 0.0.1 → 3.230.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/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # pulumi
2
+
3
+ Lazily install the [Pulumi CLI](https://www.pulumi.com) via npx.
4
+
5
+ ```sh
6
+ npx pulumi up
7
+ ```
8
+
9
+ > **Note:** This is NOT the Pulumi SDK. If you're writing a Pulumi program you
10
+ > want [`@pulumi/pulumi`](https://www.npmjs.com/package/@pulumi/pulumi)
11
+ > instead. See the [language SDK
12
+ > docs](https://www.pulumi.com/docs/iac/languages-sdks/) for all supported
13
+ > runtimes.
14
+
15
+ ## How it works
16
+
17
+ On first use, the package downloads the Pulumi CLI binary for your platform from
18
+ [get.pulumi.com](https://get.pulumi.com) and caches it under `~/.pulumi/versions/`.
19
+ Subsequent invocations use the cached binary directly.
20
+
21
+ ## Version pinning
22
+
23
+ The npm package version matches the Pulumi CLI version exactly. Pin to a
24
+ specific release by specifying the version:
25
+
26
+ ```sh
27
+ npx pulumi@3.323.0 up
28
+ ```
29
+
30
+ ## Cache location
31
+
32
+ Binaries are cached at `~/.pulumi/versions/<version>/bin/`, shared with the
33
+ [Automation API](https://www.pulumi.com/docs/iac/packages/pulumi-automation/) so
34
+ both never download the same version twice. Set `PULUMI_HOME` to use a different
35
+ base directory:
36
+
37
+ ```sh
38
+ PULUMI_HOME=/path/to/pulumi npx pulumi up
39
+ ```
40
+
41
+ To clear the cache:
42
+
43
+ ```sh
44
+ rm -rf ~/.pulumi/versions
45
+ ```
package/lib/cache.js ADDED
@@ -0,0 +1,16 @@
1
+ // Copyright 2026, Pulumi Corporation. All rights reserved.
2
+
3
+ "use strict";
4
+
5
+ const os = require("os");
6
+ const path = require("path");
7
+
8
+ // cacheDir returns the install root for a specific Pulumi version, mirroring
9
+ // the default path used by the Automation API (PulumiCommand.install). This
10
+ // lets both systems share an installation without re-downloading.
11
+ function cacheDir(version) {
12
+ const home = process.env.PULUMI_HOME || path.join(os.homedir(), ".pulumi");
13
+ return path.join(home, "versions", version);
14
+ }
15
+
16
+ module.exports = { cacheDir };
@@ -0,0 +1,64 @@
1
+ // Copyright 2026, Pulumi Corporation. All rights reserved.
2
+
3
+ "use strict";
4
+
5
+ const fs = require("fs");
6
+ const os = require("os");
7
+ const path = require("path");
8
+ const { execFileSync } = require("child_process");
9
+
10
+ const INSTALL_SH_URL = "https://get.pulumi.com/install.sh";
11
+ const INSTALL_PS1_URL = "https://get.pulumi.com/install.ps1";
12
+
13
+ async function defaultFetchText(url) {
14
+ const res = await fetch(url);
15
+ if (!res.ok) throw new Error(`HTTP ${res.status} fetching ${url}`);
16
+ return res.text();
17
+ }
18
+
19
+ function defaultExecScript(scriptPath, args) {
20
+ if (process.platform === "win32") {
21
+ const ps = process.env.SystemRoot
22
+ ? path.join(process.env.SystemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
23
+ : "powershell.exe";
24
+ execFileSync(ps, ["-NoProfile", "-InputFormat", "None", "-ExecutionPolicy", "Bypass", "-File", scriptPath, ...args], {
25
+ stdio: "inherit",
26
+ });
27
+ } else {
28
+ execFileSync("/bin/sh", [scriptPath, ...args], { stdio: "inherit" });
29
+ }
30
+ }
31
+
32
+ // installCLI downloads and runs the official Pulumi install script, installing
33
+ // the CLI and all language hosts into {root}/bin/. Mirrors the approach used
34
+ // by the Automation API (sdk/nodejs/automation/cmd.ts installPosix/installWindows).
35
+ // IO functions are injectable for testing.
36
+ async function installCLI(
37
+ version,
38
+ root,
39
+ { fetchText = defaultFetchText, execScript = defaultExecScript } = {},
40
+ ) {
41
+ const isWindows = process.platform === "win32";
42
+ const scriptContent = await fetchText(isWindows ? INSTALL_PS1_URL : INSTALL_SH_URL);
43
+
44
+ const ext = isWindows ? ".ps1" : ".sh";
45
+ const scriptPath = path.join(os.tmpdir(), `pulumi-install-${process.pid}${ext}`);
46
+ try {
47
+ fs.writeFileSync(scriptPath, scriptContent, { mode: 0o700 });
48
+ const args = isWindows
49
+ ? ["-NoEditPath", "-InstallRoot", root, "-Version", version]
50
+ : ["--no-edit-path", "--install-root", root, "--version", version];
51
+ execScript(scriptPath, args);
52
+ } finally {
53
+ fs.rmSync(scriptPath, { force: true });
54
+ }
55
+ }
56
+
57
+ // fetchLatestVersion returns the latest stable Pulumi release version string.
58
+ async function fetchLatestVersion(fetchText = defaultFetchText) {
59
+ const text = await fetchText("https://api.github.com/repos/pulumi/pulumi/releases/latest");
60
+ const { tag_name } = JSON.parse(text);
61
+ return tag_name.replace(/^v/, "");
62
+ }
63
+
64
+ module.exports = { installCLI, fetchLatestVersion };
package/lib/resolve.js ADDED
@@ -0,0 +1,42 @@
1
+ // Copyright 2026, Pulumi Corporation. All rights reserved.
2
+
3
+ "use strict";
4
+
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const { cacheDir } = require("./cache");
8
+ const { installCLI, fetchLatestVersion } = require("./download");
9
+
10
+ const pkg = require("../package.json");
11
+
12
+ function isExecutable(filePath) {
13
+ try {
14
+ fs.accessSync(filePath, fs.constants.X_OK);
15
+ return fs.statSync(filePath).size > 0;
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ // resolve returns the path to the pulumi binary, installing it if not already
22
+ // cached. IO functions are injectable for testing.
23
+ async function resolve({
24
+ version = process.env.PULUMI_VERSION || pkg.version,
25
+ install = installCLI,
26
+ getLatestVersion = fetchLatestVersion,
27
+ } = {}) {
28
+ if (!version) {
29
+ version = await getLatestVersion();
30
+ }
31
+
32
+ const exe = process.platform === "win32" ? "pulumi.exe" : "pulumi";
33
+ const root = cacheDir(version);
34
+ const dest = path.join(root, "bin", exe);
35
+ if (isExecutable(dest)) return dest;
36
+
37
+ process.stderr.write(`Downloading pulumi v${version}...\n`);
38
+ await install(version, root);
39
+ return dest;
40
+ }
41
+
42
+ module.exports = { resolve, isExecutable };
package/package.json CHANGED
@@ -1,7 +1,24 @@
1
1
  {
2
2
  "name": "pulumi",
3
- "version": "0.0.1",
4
- "description": "",
5
- "main": "index.js",
6
- "author": ""
3
+ "version": "3.230.0",
4
+ "description": "Pulumi Infrastructure as Code CLI",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/pulumi/pulumi.git",
9
+ "directory": "npm"
10
+ },
11
+ "bin": {
12
+ "pulumi": "run.js"
13
+ },
14
+ "scripts": {
15
+ "test": "node --test test/cache.test.js test/download.test.js test/resolve.test.js",
16
+ "test:integration": "node --test test/integration.test.js"
17
+ },
18
+ "devDependencies": {
19
+ "@biomejs/biome": "1.8.3"
20
+ },
21
+ "engines": {
22
+ "node": ">=18"
23
+ }
7
24
  }
Binary file
Binary file
Binary file
Binary file
package/run.js ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2026, Pulumi Corporation. All rights reserved.
3
+
4
+ "use strict";
5
+
6
+ const path = require("path");
7
+ const { spawn } = require("child_process");
8
+ const { resolve } = require("./lib/resolve");
9
+
10
+ resolve()
11
+ .then((bin) => {
12
+ // Prepend the directory containing the CLI to PATH so that language
13
+ // hosts (pulumi-language-nodejs, etc.) installed alongside it are found.
14
+ const env = { ...process.env, PATH: path.dirname(bin) + path.delimiter + (process.env.PATH || "") };
15
+ const child = spawn(bin, process.argv.slice(2), { stdio: "inherit", env });
16
+ child.on("exit", (code, signal) => {
17
+ if (signal) {
18
+ // Propagate signal to the parent process.
19
+ process.kill(process.pid, signal);
20
+ } else {
21
+ process.exit(code ?? 0);
22
+ }
23
+ });
24
+ child.on("error", (err) => {
25
+ process.stderr.write(`pulumi: failed to start: ${err.message}\n`);
26
+ process.exit(1);
27
+ });
28
+ })
29
+ .catch((err) => {
30
+ process.stderr.write(`pulumi: ${err.message}\n`);
31
+ process.exit(1);
32
+ });