vercel-cli 41.1.0__tar.gz

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.

Potentially problematic release.


This version of vercel-cli might be problematic. Click here for more details.

Files changed (99) hide show
  1. vercel_cli-41.1.0/.gitignore +5 -0
  2. vercel_cli-41.1.0/PKG-INFO +188 -0
  3. vercel_cli-41.1.0/README.md +180 -0
  4. vercel_cli-41.1.0/pyproject.toml +78 -0
  5. vercel_cli-41.1.0/vercel_cli/vendor/LICENSE +202 -0
  6. vercel_cli-41.1.0/vercel_cli/vendor/README.md +63 -0
  7. vercel_cli-41.1.0/vercel_cli/vendor/dist/VERCEL_DIR_README.txt +11 -0
  8. vercel_cli-41.1.0/vercel_cli/vendor/dist/builder-worker.js +62 -0
  9. vercel_cli-41.1.0/vercel_cli/vendor/dist/get-latest-worker.js +272 -0
  10. vercel_cli-41.1.0/vercel_cli/vendor/dist/index.js +172693 -0
  11. vercel_cli-41.1.0/vercel_cli/vendor/dist/vc.js +11 -0
  12. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/.package-lock.json +18 -0
  13. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/CHANGELOG.md +488 -0
  14. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/LICENSE +202 -0
  15. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/build.mjs +3 -0
  16. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/clone-env.d.ts +10 -0
  17. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/clone-env.js +43 -0
  18. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/debug.d.ts +1 -0
  19. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/debug.js +31 -0
  20. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/default-cache-path-glob.d.ts +1 -0
  21. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/default-cache-path-glob.js +28 -0
  22. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/edge-function.d.ts +41 -0
  23. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/edge-function.js +40 -0
  24. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/errors.d.ts +39 -0
  25. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/errors.js +95 -0
  26. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-blob.d.ts +23 -0
  27. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-blob.js +67 -0
  28. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-fs-ref.d.ts +27 -0
  29. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-fs-ref.js +113 -0
  30. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-ref.d.ts +38 -0
  31. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-ref.js +147 -0
  32. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/download.d.ts +9 -0
  33. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/download.js +136 -0
  34. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/get-writable-directory.d.ts +1 -0
  35. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/get-writable-directory.js +32 -0
  36. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/glob.d.ts +10 -0
  37. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/glob.js +111 -0
  38. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/node-version.d.ts +9 -0
  39. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/node-version.js +180 -0
  40. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/normalize-path.d.ts +4 -0
  41. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/normalize-path.js +31 -0
  42. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/read-config-file.d.ts +1 -0
  43. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/read-config-file.js +76 -0
  44. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/rename.d.ts +11 -0
  45. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/rename.js +30 -0
  46. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/run-user-scripts.d.ts +206 -0
  47. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/run-user-scripts.js +944 -0
  48. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/stream-to-buffer.d.ts +3 -0
  49. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/stream-to-buffer.js +87 -0
  50. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-ignore-filter.d.ts +1 -0
  51. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-ignore-filter.js +90 -0
  52. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-installed-package-version.d.ts +1 -0
  53. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-installed-package-version.js +53 -0
  54. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-platform-env.d.ts +5 -0
  55. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-platform-env.js +45 -0
  56. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-prefixed-env-vars.d.ts +14 -0
  57. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-prefixed-env-vars.js +51 -0
  58. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/hard-link-dir.d.ts +1 -0
  59. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/hard-link-dir.js +104 -0
  60. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/index.d.ts +33 -0
  61. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/index.js +24390 -0
  62. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/lambda.d.ts +81 -0
  63. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/lambda.js +231 -0
  64. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/nodejs-lambda.d.ts +16 -0
  65. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/nodejs-lambda.js +44 -0
  66. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/os.d.ts +3 -0
  67. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/os.js +62 -0
  68. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/prerender.d.ts +37 -0
  69. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/prerender.js +169 -0
  70. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/schemas.d.ts +60 -0
  71. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/schemas.js +87 -0
  72. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/should-serve.d.ts +2 -0
  73. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/should-serve.js +47 -0
  74. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/constants.d.ts +2 -0
  75. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/constants.js +31 -0
  76. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/index.d.ts +3 -0
  77. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/index.js +33 -0
  78. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/trace.d.ts +37 -0
  79. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/trace.js +92 -0
  80. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/types.d.ts +503 -0
  81. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/types.js +51 -0
  82. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/validate-npmrc.d.ts +12 -0
  83. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/dist/validate-npmrc.js +41 -0
  84. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/file-blob.js +1 -0
  85. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/file-fs-ref.js +1 -0
  86. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/file-ref.js +1 -0
  87. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/fs/download.js +1 -0
  88. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/fs/get-writable-directory.js +1 -0
  89. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/fs/glob.js +1 -0
  90. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/fs/rename.js +1 -0
  91. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/fs/run-user-scripts.js +1 -0
  92. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/fs/stream-to-buffer.js +1 -0
  93. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/lambda.js +1 -0
  94. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/build-utils/package.json +60 -0
  95. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/python/LICENSE +202 -0
  96. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/python/dist/index.js +3132 -0
  97. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/python/package.json +36 -0
  98. vercel_cli-41.1.0/vercel_cli/vendor/node_modules/@vercel/python/vc_init.py +681 -0
  99. vercel_cli-41.1.0/vercel_cli/vendor/package.json +40 -0
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ *.pyc
3
+ .coverage
4
+ .venv
5
+ /dist/
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: vercel-cli
3
+ Version: 41.1.0
4
+ Summary: Vercel CLI packaged for Python (bundled Node.js, vendored npm)
5
+ Requires-Python: >=3.8
6
+ Requires-Dist: nodejs-wheel-binaries==22.16.0
7
+ Description-Content-Type: text/markdown
8
+
9
+ # Python package wrapper for Vercel CLI
10
+
11
+ [![CI](https://github.com/nuage-studio/vercel-cli-python/actions/workflows/test.yml/badge.svg)](https://github.com/nuage-studio/vercel-cli-python/actions/workflows/test.yml)
12
+ [![codecov](https://codecov.io/gh/nuage-studio/vercel-cli-python/graph/badge.svg)](https://codecov.io/gh/nuage-studio/vercel-cli-python)
13
+ [![Supported Python Versions](https://img.shields.io/badge/python-3.8--3.13-blue.svg)](https://www.python.org/)
14
+
15
+ **vercel-cli** packages the npm `vercel` CLI for Python environments. It vendors the npm package under `vercel_cli/vendor/` and uses the bundled Node.js runtime provided by `nodejs-wheel-binaries`, so you can run `vercel` without installing Node.js.
16
+
17
+ It provides both a command-line interface and a Python API that other libraries can use programmatically instead of resorting to subprocess calls.
18
+
19
+ ## Quick start
20
+
21
+ - **Install**:
22
+
23
+ ```bash
24
+ pip install vercel-cli
25
+ ```
26
+
27
+ - **Use** (same arguments and behavior as the official npm CLI):
28
+
29
+ ```bash
30
+ vercel --version
31
+ vercel login
32
+ vercel deploy
33
+ ```
34
+
35
+ - **Use programmatically in Python** (for libraries that depend on this package):
36
+
37
+ ```python
38
+ from vercel_cli import run_vercel
39
+
40
+ # Deploy current directory
41
+ exit_code = run_vercel(["deploy"])
42
+
43
+ # Deploy specific directory with custom environment
44
+ exit_code = run_vercel(
45
+ ["deploy", "--prod"],
46
+ cwd="/path/to/project",
47
+ env={"VERCEL_TOKEN": "my-token"}
48
+ )
49
+
50
+ # Check version
51
+ exit_code = run_vercel(["--version"])
52
+ ```
53
+
54
+ ## What this provides
55
+
56
+ - **No system Node.js required**: The CLI runs via the Node binary from `nodejs-wheel-binaries` (currently Node 22.x).
57
+ - **Vendored npm package**: The `vercel` npm package (production deps only) is checked into `vercel_cli/vendor/`.
58
+ - **Console entrypoint**: The `vercel` command maps to `vercel_cli.run:main`, which executes `vercel_cli/vendor/dist/vc.js` with the bundled Node runtime.
59
+ - **Python API**: The `run_vercel()` function allows other Python libraries to use Vercel CLI programmatically without subprocess calls, with secure environment variable handling.
60
+
61
+ ## Requirements
62
+
63
+ - Python 3.8+
64
+ - macOS, Linux, or Windows supported by the Node wheels
65
+
66
+ ## How it works
67
+
68
+ At runtime, `vercel_cli.run` locates `vercel_cli/vendor/dist/vc.js` and launches it via the Node executable exposed by `nodejs_wheel_binaries`. CLI arguments are passed through unchanged, while environment variables are handled securely.
69
+
70
+ ## Programmatic usage
71
+
72
+ When using this package as a dependency in other Python libraries, you can call Vercel CLI commands directly without using subprocess:
73
+
74
+ ```python
75
+ from vercel_cli import run_vercel
76
+ import tempfile
77
+ import os
78
+
79
+ def deploy_my_app(source_dir: str, token: str) -> bool:
80
+ """Deploy an application to Vercel programmatically."""
81
+ with tempfile.TemporaryDirectory() as temp_dir:
82
+ # Copy your app to temp directory and modify as needed
83
+ # ...
84
+
85
+ # Deploy with custom environment
86
+ env = {
87
+ "VERCEL_TOKEN": token,
88
+ "NODE_ENV": "production"
89
+ }
90
+
91
+ exit_code = run_vercel(
92
+ ["deploy", "--prod", "--yes"],
93
+ cwd=temp_dir,
94
+ env=env
95
+ )
96
+
97
+ return exit_code == 0
98
+
99
+ # Usage
100
+ success = deploy_my_app("./my-app", "my-vercel-token")
101
+ ```
102
+
103
+ The `run_vercel()` function accepts:
104
+
105
+ - `args`: List of CLI arguments (same as command line)
106
+ - `cwd`: Working directory for the command
107
+ - `env`: Environment variables to set (passed directly to the Node.js runtime)
108
+
109
+ ## Security considerations
110
+
111
+ When using the `env` parameter, only explicitly provided environment variables are passed to the Vercel CLI. This prevents accidental leakage of sensitive environment variables from your Python process while still allowing you to set necessary variables like `VERCEL_TOKEN`.
112
+
113
+ Example with secure token handling:
114
+
115
+ ```python
116
+ from vercel_cli import run_vercel
117
+
118
+ # Secure: only VERCEL_TOKEN is passed to the CLI
119
+ exit_code = run_vercel(
120
+ ["deploy", "--prod"],
121
+ env={"VERCEL_TOKEN": "your-secure-token"}
122
+ )
123
+ ```
124
+
125
+ This approach avoids common security pitfalls of subprocess environment variable handling.
126
+
127
+ ## Updating the vendored Vercel CLI (maintainers)
128
+
129
+ There are two ways to update the vendored npm package under `vercel_cli/vendor/`:
130
+
131
+ 1) Manual update to a specific version
132
+
133
+ ```bash
134
+ # Using the console script defined in pyproject.toml
135
+ uv run update-vendor 46.0.2
136
+ # or equivalently
137
+ uv run python scripts/update_vendor.py 46.0.2
138
+ ```
139
+
140
+ This will:
141
+
142
+ - fetch `vercel@46.0.2` from npm,
143
+ - verify integrity/shasum,
144
+ - install production dependencies with `npm install --omit=dev`, and
145
+ - copy the result into `vercel_cli/vendor/`.
146
+
147
+ 1) Automatic check-and-release (GitHub Actions)
148
+
149
+ The workflow `.github/workflows/release.yml` checks npm `latest` and, if newer than the vendored version, will:
150
+
151
+ - vendor the new version using `scripts/check_and_update.py`,
152
+ - commit the changes and create a tag `v<version>`,
153
+ - build distributions, and
154
+ - publish to PyPI (requires `PYPI_API_TOKEN`).
155
+
156
+ ## Versioning
157
+
158
+ The Python package version is derived dynamically from the vendored `package.json` via Hatch’s version source:
159
+
160
+ ```toml
161
+ [tool.hatch.version]
162
+ path = "vercel_cli/vendor/package.json"
163
+ pattern = '"version"\s*:\s*"(?P<version>[^\\"]+)"'
164
+ ```
165
+
166
+ ## Development
167
+
168
+ - Build backend: `hatchling`
169
+ - Dependency management: `uv` (see `uv.lock`)
170
+ - Tests: `pytest` with coverage in `tests/`
171
+ - Lint/format: `ruff`; type-check: `basedpyright`
172
+
173
+ Common commands (using `uv`):
174
+
175
+ ```bash
176
+ # Run tests with coverage
177
+ uv run pytest --cov=vercel_cli --cov-report=term-missing
178
+
179
+ # Lint and format
180
+ uv run ruff check .
181
+ uv run ruff format .
182
+
183
+ # Type-check
184
+ uv run basedpyright
185
+
186
+ # Build wheel and sdist
187
+ uv run --with build python -m build
188
+ ```
@@ -0,0 +1,180 @@
1
+ # Python package wrapper for Vercel CLI
2
+
3
+ [![CI](https://github.com/nuage-studio/vercel-cli-python/actions/workflows/test.yml/badge.svg)](https://github.com/nuage-studio/vercel-cli-python/actions/workflows/test.yml)
4
+ [![codecov](https://codecov.io/gh/nuage-studio/vercel-cli-python/graph/badge.svg)](https://codecov.io/gh/nuage-studio/vercel-cli-python)
5
+ [![Supported Python Versions](https://img.shields.io/badge/python-3.8--3.13-blue.svg)](https://www.python.org/)
6
+
7
+ **vercel-cli** packages the npm `vercel` CLI for Python environments. It vendors the npm package under `vercel_cli/vendor/` and uses the bundled Node.js runtime provided by `nodejs-wheel-binaries`, so you can run `vercel` without installing Node.js.
8
+
9
+ It provides both a command-line interface and a Python API that other libraries can use programmatically instead of resorting to subprocess calls.
10
+
11
+ ## Quick start
12
+
13
+ - **Install**:
14
+
15
+ ```bash
16
+ pip install vercel-cli
17
+ ```
18
+
19
+ - **Use** (same arguments and behavior as the official npm CLI):
20
+
21
+ ```bash
22
+ vercel --version
23
+ vercel login
24
+ vercel deploy
25
+ ```
26
+
27
+ - **Use programmatically in Python** (for libraries that depend on this package):
28
+
29
+ ```python
30
+ from vercel_cli import run_vercel
31
+
32
+ # Deploy current directory
33
+ exit_code = run_vercel(["deploy"])
34
+
35
+ # Deploy specific directory with custom environment
36
+ exit_code = run_vercel(
37
+ ["deploy", "--prod"],
38
+ cwd="/path/to/project",
39
+ env={"VERCEL_TOKEN": "my-token"}
40
+ )
41
+
42
+ # Check version
43
+ exit_code = run_vercel(["--version"])
44
+ ```
45
+
46
+ ## What this provides
47
+
48
+ - **No system Node.js required**: The CLI runs via the Node binary from `nodejs-wheel-binaries` (currently Node 22.x).
49
+ - **Vendored npm package**: The `vercel` npm package (production deps only) is checked into `vercel_cli/vendor/`.
50
+ - **Console entrypoint**: The `vercel` command maps to `vercel_cli.run:main`, which executes `vercel_cli/vendor/dist/vc.js` with the bundled Node runtime.
51
+ - **Python API**: The `run_vercel()` function allows other Python libraries to use Vercel CLI programmatically without subprocess calls, with secure environment variable handling.
52
+
53
+ ## Requirements
54
+
55
+ - Python 3.8+
56
+ - macOS, Linux, or Windows supported by the Node wheels
57
+
58
+ ## How it works
59
+
60
+ At runtime, `vercel_cli.run` locates `vercel_cli/vendor/dist/vc.js` and launches it via the Node executable exposed by `nodejs_wheel_binaries`. CLI arguments are passed through unchanged, while environment variables are handled securely.
61
+
62
+ ## Programmatic usage
63
+
64
+ When using this package as a dependency in other Python libraries, you can call Vercel CLI commands directly without using subprocess:
65
+
66
+ ```python
67
+ from vercel_cli import run_vercel
68
+ import tempfile
69
+ import os
70
+
71
+ def deploy_my_app(source_dir: str, token: str) -> bool:
72
+ """Deploy an application to Vercel programmatically."""
73
+ with tempfile.TemporaryDirectory() as temp_dir:
74
+ # Copy your app to temp directory and modify as needed
75
+ # ...
76
+
77
+ # Deploy with custom environment
78
+ env = {
79
+ "VERCEL_TOKEN": token,
80
+ "NODE_ENV": "production"
81
+ }
82
+
83
+ exit_code = run_vercel(
84
+ ["deploy", "--prod", "--yes"],
85
+ cwd=temp_dir,
86
+ env=env
87
+ )
88
+
89
+ return exit_code == 0
90
+
91
+ # Usage
92
+ success = deploy_my_app("./my-app", "my-vercel-token")
93
+ ```
94
+
95
+ The `run_vercel()` function accepts:
96
+
97
+ - `args`: List of CLI arguments (same as command line)
98
+ - `cwd`: Working directory for the command
99
+ - `env`: Environment variables to set (passed directly to the Node.js runtime)
100
+
101
+ ## Security considerations
102
+
103
+ When using the `env` parameter, only explicitly provided environment variables are passed to the Vercel CLI. This prevents accidental leakage of sensitive environment variables from your Python process while still allowing you to set necessary variables like `VERCEL_TOKEN`.
104
+
105
+ Example with secure token handling:
106
+
107
+ ```python
108
+ from vercel_cli import run_vercel
109
+
110
+ # Secure: only VERCEL_TOKEN is passed to the CLI
111
+ exit_code = run_vercel(
112
+ ["deploy", "--prod"],
113
+ env={"VERCEL_TOKEN": "your-secure-token"}
114
+ )
115
+ ```
116
+
117
+ This approach avoids common security pitfalls of subprocess environment variable handling.
118
+
119
+ ## Updating the vendored Vercel CLI (maintainers)
120
+
121
+ There are two ways to update the vendored npm package under `vercel_cli/vendor/`:
122
+
123
+ 1) Manual update to a specific version
124
+
125
+ ```bash
126
+ # Using the console script defined in pyproject.toml
127
+ uv run update-vendor 46.0.2
128
+ # or equivalently
129
+ uv run python scripts/update_vendor.py 46.0.2
130
+ ```
131
+
132
+ This will:
133
+
134
+ - fetch `vercel@46.0.2` from npm,
135
+ - verify integrity/shasum,
136
+ - install production dependencies with `npm install --omit=dev`, and
137
+ - copy the result into `vercel_cli/vendor/`.
138
+
139
+ 1) Automatic check-and-release (GitHub Actions)
140
+
141
+ The workflow `.github/workflows/release.yml` checks npm `latest` and, if newer than the vendored version, will:
142
+
143
+ - vendor the new version using `scripts/check_and_update.py`,
144
+ - commit the changes and create a tag `v<version>`,
145
+ - build distributions, and
146
+ - publish to PyPI (requires `PYPI_API_TOKEN`).
147
+
148
+ ## Versioning
149
+
150
+ The Python package version is derived dynamically from the vendored `package.json` via Hatch’s version source:
151
+
152
+ ```toml
153
+ [tool.hatch.version]
154
+ path = "vercel_cli/vendor/package.json"
155
+ pattern = '"version"\s*:\s*"(?P<version>[^\\"]+)"'
156
+ ```
157
+
158
+ ## Development
159
+
160
+ - Build backend: `hatchling`
161
+ - Dependency management: `uv` (see `uv.lock`)
162
+ - Tests: `pytest` with coverage in `tests/`
163
+ - Lint/format: `ruff`; type-check: `basedpyright`
164
+
165
+ Common commands (using `uv`):
166
+
167
+ ```bash
168
+ # Run tests with coverage
169
+ uv run pytest --cov=vercel_cli --cov-report=term-missing
170
+
171
+ # Lint and format
172
+ uv run ruff check .
173
+ uv run ruff format .
174
+
175
+ # Type-check
176
+ uv run basedpyright
177
+
178
+ # Build wheel and sdist
179
+ uv run --with build python -m build
180
+ ```
@@ -0,0 +1,78 @@
1
+ [project]
2
+ name = "vercel-cli"
3
+ dynamic = ["version"]
4
+ description = "Vercel CLI packaged for Python (bundled Node.js, vendored npm)"
5
+ readme = "README.md"
6
+ requires-python = ">=3.8"
7
+ dependencies = [
8
+ "nodejs-wheel-binaries==22.16.0",
9
+ ]
10
+
11
+ [dependency-groups]
12
+ dev = [
13
+ "basedpyright>=1.31.3",
14
+ "pytest-cov>=5.0.0",
15
+ "ruff>=0.12.10",
16
+ ]
17
+
18
+ [project.scripts]
19
+ vercel = "vercel_cli.run:main"
20
+ vendor = "vercel_cli.vendor_cli:main"
21
+
22
+ [build-system]
23
+ requires = ["hatchling"]
24
+ build-backend = "hatchling.build"
25
+
26
+ [tool.hatch.build]
27
+ include = ["vercel_cli/vendor/**"]
28
+
29
+ [tool.hatch.build.targets.wheel]
30
+ packages = ["vercel_cli"]
31
+
32
+ [tool.hatch.version]
33
+ # Extract the version from the vendored package.json
34
+ path = "vercel_cli/vendor/package.json"
35
+ pattern = '"version"\s*:\s*"(?P<version>[^\"]+)"'
36
+
37
+
38
+ [tool.pytest.ini_options]
39
+ addopts = "--cov --cov-branch --cov-report=term-missing"
40
+ testpaths = ["tests"]
41
+
42
+ [tool.ruff]
43
+ # https://docs.astral.sh/ruff/settings/
44
+ preview = true
45
+ line-length = 88
46
+ target-version = "py38"
47
+
48
+ [tool.ruff.lint]
49
+ select = ["ALL"]
50
+ ignore = [
51
+ "CPY001", # We don't want warnings about missing Copyrights because it's private code
52
+ "TID252", # Nuage team disagrees about relative imports: we find them more readable
53
+ # Opinionated choices for conflicting rules
54
+ "D203", # 1 blank line required before class docstring (we prefer D211: no blank line)
55
+ "D213", # Multi-line docstring summary should start at the second line (we prefer D212: first line)
56
+ "COM812", # Trailing comma missing (conflicts with formatter, let formatter handle it)
57
+ ]
58
+ exclude = [".venv"]
59
+
60
+ [tool.ruff.format]
61
+ preview = true
62
+ skip-magic-trailing-comma = true
63
+
64
+ [tool.ruff.lint.per-file-ignores]
65
+ "tests/*.py" = [
66
+ "S", # none of these security focused rules are relevant for tests/build scripts
67
+ "D100", # Allow missing module docstrings in tests
68
+ "D103", # Allow missing function docstrings in tests
69
+ "S101", # Allow assert in tests
70
+ "PLR2004", # Allow magic numbers in tests
71
+ ]
72
+
73
+ [tool.ruff.lint.isort]
74
+ split-on-trailing-comma = false # Align with formatter's skip-magic-trailing-comma = true
75
+
76
+ [tool.pyright]
77
+ pythonVersion = "3.8"
78
+ typeCheckingMode = "strict"
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2017 Vercel, Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.