pulumi 0.0.2 → 3.241.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 CHANGED
@@ -15,13 +15,8 @@ npx pulumi up
15
15
  ## How it works
16
16
 
17
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 in npm's cache directory
19
- (`~/.npm/_pulumi/` by default). The download is checksum-verified to detect
20
- corruption in transit. Subsequent invocations use the cached binary directly.
21
-
22
- If a `pulumi` binary is already on your `PATH` (e.g. installed via Homebrew or
23
- the [install script](https://www.pulumi.com/docs/install/)), that installation
24
- is used instead of downloading a new one.
18
+ [get.pulumi.com](https://get.pulumi.com) and caches it under `~/.pulumi/versions/`.
19
+ Subsequent invocations use the cached binary directly.
25
20
 
26
21
  ## Version pinning
27
22
 
@@ -34,9 +29,17 @@ npx pulumi@3.323.0 up
34
29
 
35
30
  ## Cache location
36
31
 
37
- Binaries are cached at `_pulumi/<version>/` inside npm's configured cache
38
- directory. To change the location, set `npm_config_cache`:
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:
39
42
 
40
43
  ```sh
41
- npm_config_cache=/path/to/cache npx pulumi up
44
+ rm -rf ~/.pulumi/versions
42
45
  ```
package/lib/cache.js CHANGED
@@ -5,27 +5,12 @@
5
5
  const os = require("os");
6
6
  const path = require("path");
7
7
 
8
- // npmDefaultCache returns npm's default cache directory when npm_config_cache
9
- // is not set in the environment. These are npm's own documented defaults:
10
- // https://docs.npmjs.com/cli/v11/using-npm/config#cache
11
- function npmDefaultCache() {
12
- if (process.platform === "win32") {
13
- return path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), "npm-cache");
14
- }
15
- return path.join(os.homedir(), ".npm");
16
- }
17
-
18
- // cacheDir returns the directory where the pulumi binaries for a specific
19
- // version should be cached. Follows npm's _subdirectory naming convention
20
- // (e.g. _npx, _cacache, _prebuilds) so binaries live alongside other
21
- // npm-managed caches.
22
- //
23
- // When invoked via npx or an npm script, npm injects npm_config_cache into
24
- // the environment — that is the authoritative cache path. Otherwise we fall
25
- // back to npm's documented default so the cache location is consistent.
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.
26
11
  function cacheDir(version) {
27
- const base = process.env.npm_config_cache || npmDefaultCache();
28
- return path.join(base, "_pulumi", version);
12
+ const home = process.env.PULUMI_HOME || path.join(os.homedir(), ".pulumi");
13
+ return path.join(home, "versions", version);
29
14
  }
30
15
 
31
16
  module.exports = { cacheDir };
package/lib/resolve.js CHANGED
@@ -9,52 +9,22 @@ const { installCLI, fetchLatestVersion } = require("./download");
9
9
 
10
10
  const pkg = require("../package.json");
11
11
 
12
- // Canonical path of this package's entry point. Used by isExecutable to skip
13
- // our own wrapper when a global `npm install` symlinks it onto PATH, which
14
- // would otherwise cause infinite recursion.
15
- const SELF = fs.realpathSync(path.resolve(__dirname, "..", "run.js"));
16
-
17
- // isExecutable returns true if filePath is a non-empty executable that does
18
- // not resolve to this package's own entry point.
19
12
  function isExecutable(filePath) {
20
13
  try {
21
14
  fs.accessSync(filePath, fs.constants.X_OK);
22
- return fs.realpathSync(filePath) !== SELF && fs.statSync(filePath).size > 0;
15
+ return fs.statSync(filePath).size > 0;
23
16
  } catch {
24
17
  return false;
25
18
  }
26
19
  }
27
20
 
28
- // findSystemPulumi searches PATH for a native pulumi binary, skipping any
29
- // path component that contains "node_modules" to avoid calling ourselves.
30
- // pathEnv defaults to process.env.PATH and is injectable for testing.
31
- function findSystemPulumi(pathEnv) {
32
- const search = pathEnv !== undefined ? pathEnv : process.env.PATH || "";
33
- const exe = process.platform === "win32" ? "pulumi.exe" : "pulumi";
34
- for (const dir of search.split(path.delimiter)) {
35
- if (!dir || dir.includes("node_modules")) continue;
36
- const candidate = path.join(dir, exe);
37
- if (isExecutable(candidate)) return candidate;
38
- }
39
- return null;
40
- }
41
-
42
- // resolve returns the path to the pulumi binary to invoke, using the
43
- // following priority:
44
- // 1. A native pulumi binary found on PATH (defers to existing installs).
45
- // 2. A version-pinned binary in the local cache.
46
- // 3. A freshly installed binary (cached for future invocations).
47
- //
48
- // IO functions are injectable for testing.
21
+ // resolve returns the path to the pulumi binary, installing it if not already
22
+ // cached. IO functions are injectable for testing.
49
23
  async function resolve({
50
- pathEnv,
51
24
  version = process.env.PULUMI_VERSION || pkg.version,
52
25
  install = installCLI,
53
26
  getLatestVersion = fetchLatestVersion,
54
27
  } = {}) {
55
- const system = findSystemPulumi(pathEnv);
56
- if (system) return system;
57
-
58
28
  if (!version) {
59
29
  version = await getLatestVersion();
60
30
  }
@@ -69,4 +39,4 @@ async function resolve({
69
39
  return dest;
70
40
  }
71
41
 
72
- module.exports = { resolve, findSystemPulumi, isExecutable };
42
+ module.exports = { resolve, isExecutable };
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
- "name": "pulumi",
3
- "version": "0.0.2",
4
- "description": "Pulumi Infrastructure as Code CLI",
5
- "license": "Apache-2.0",
6
- "repository": {
7
- "type": "git",
8
- "url": "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
- }
2
+ "name": "pulumi",
3
+ "version": "3.241.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
+ }
24
24
  }
Binary file
Binary file
Binary file
Binary file