Skip to content

Commit d882d12

Browse files
KSXGitHubtksst
andauthored
feat: standalone binary (#92)
* feat: add an option to install the self-contained binary version of pnpm * test: add a test about nodejs_bundled * style: remove an empty line * chore: use newer pnpm * chore: update dependencies * feat: rename `nodejs_bundled` to `standalone` as @zkochan suggested * docs: add --------- Co-authored-by: Takashi Sato <[email protected]>
1 parent 0b715c7 commit d882d12

File tree

9 files changed

+288
-194
lines changed

9 files changed

+288
-194
lines changed

.github/workflows/test.yaml

+57-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ jobs:
3535
- name: 'Test: install'
3636
run: pnpm install
3737

38-
test_explicit_inputs:
39-
name: Test with explicit inputs
38+
test_dest:
39+
name: Test with dest
4040

4141
runs-on: ${{ matrix.os }}
4242

@@ -65,6 +65,61 @@ jobs:
6565
- name: 'Test: install'
6666
run: pnpm install
6767

68+
test_standalone:
69+
name: Test with standalone
70+
71+
runs-on: ${{ matrix.os }}
72+
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
os:
77+
- ubuntu-latest
78+
- macos-latest
79+
- windows-latest
80+
81+
standalone:
82+
- true
83+
- false
84+
85+
steps:
86+
- uses: actions/checkout@v3
87+
88+
- name: Run the action
89+
uses: ./
90+
with:
91+
version: 7.0.0
92+
standalone: ${{ matrix.standalone }}
93+
94+
- name: install Node.js
95+
uses: actions/setup-node@v3
96+
with:
97+
# [email protected] is not compatible with Node.js 12
98+
node-version: 12.22.12
99+
100+
- name: 'Test: which (pnpm)'
101+
run: which pnpm
102+
103+
- name: 'Test: which (pnpx)'
104+
if: matrix.standalone == false
105+
run: which pnpx
106+
107+
- name: 'Test: install when standalone is true'
108+
if: matrix.standalone
109+
run: pnpm install
110+
111+
- name: 'Test: install when standalone is false'
112+
if: matrix.standalone == false
113+
# Since the default shell on windows runner is pwsh, we specify bash explicitly
114+
shell: bash
115+
run: |
116+
if pnpm install; then
117+
echo "pnpm install should fail"
118+
exit 1
119+
else
120+
echo "pnpm install failed as expected"
121+
fi
122+
68123
test_run_install:
69124
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'
70125

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ If `run_install` is a YAML string representation of either an object or an array
4040

4141
### `package_json_file`
4242

43-
**Optional** File path to the `package.json` to read "packageManager" configutation. If not specified, `package.json` in the project root directory is used.
43+
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration.
44+
45+
### `standalone`
46+
47+
**Optional** (_type:_ `boolean`, _default:_ `false`) When set to true, [@pnpm/exe](https://www.npmjs.com/package/@pnpm/exe), which is a Node.js bundled package, will be installed, enabling using `pnpm` without Node.js.
48+
49+
This is useful when you want to use a incompatible pair of Node.js and pnpm.
4450

4551
## Outputs
4652

action.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ inputs:
1616
required: false
1717
default: 'null'
1818
package_json_file:
19-
description: File path to the package.json to read "packageManager" configutation
19+
description: File path to the package.json to read "packageManager" configuration
2020
required: false
2121
default: 'package.json'
22+
standalone:
23+
description: When set to true, @pnpm/exe, which is a Node.js bundled package, will be installed, enabling using pnpm without Node.js.
24+
required: false
25+
default: 'false'
2226
runs:
2327
using: node16
2428
main: dist/index.js

dist/index.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"@types/expand-tilde": "^2.0.0",
1212
"@types/fs-extra": "^9.0.13",
1313
"@types/js-yaml": "^4.0.5",
14-
"@types/node": "^14.18.32",
15-
"@types/node-fetch": "^2.6.2",
14+
"@types/node": "^14.18.54",
15+
"@types/node-fetch": "^2.6.4",
1616
"ajv": "^6.12.6",
1717
"expand-tilde": "^2.0.2",
1818
"fs-extra": "^10.1.0",
@@ -21,6 +21,6 @@
2121
"devDependencies": {
2222
"@ts-schema-autogen/cli": "^0.1.2",
2323
"@vercel/ncc": "^0.33.4",
24-
"typescript": "^4.8.4"
24+
"typescript": "^4.9.5"
2525
}
2626
}

0 commit comments

Comments
 (0)