Skip to content

Commit

Permalink
feat: standalone binary (#92)
Browse files Browse the repository at this point in the history
* 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 <takashi@tks.st>
  • Loading branch information
KSXGitHub and tksst authored Jul 26, 2023
1 parent 0b715c7 commit d882d12
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 194 deletions.
59 changes: 57 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
- name: 'Test: install'
run: pnpm install

test_explicit_inputs:
name: Test with explicit inputs
test_dest:
name: Test with dest

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

Expand Down Expand Up @@ -65,6 +65,61 @@ jobs:
- name: 'Test: install'
run: pnpm install

test_standalone:
name: Test with standalone

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

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest

standalone:
- true
- false

steps:
- uses: actions/checkout@v3

- name: Run the action
uses: ./
with:
version: 7.0.0
standalone: ${{ matrix.standalone }}

- name: install Node.js
uses: actions/setup-node@v3
with:
# pnpm@7.0.0 is not compatible with Node.js 12
node-version: 12.22.12

- name: 'Test: which (pnpm)'
run: which pnpm

- name: 'Test: which (pnpx)'
if: matrix.standalone == false
run: which pnpx

- name: 'Test: install when standalone is true'
if: matrix.standalone
run: pnpm install

- name: 'Test: install when standalone is false'
if: matrix.standalone == false
# Since the default shell on windows runner is pwsh, we specify bash explicitly
shell: bash
run: |
if pnpm install; then
echo "pnpm install should fail"
exit 1
else
echo "pnpm install failed as expected"
fi
test_run_install:
name: 'Test with run_install (${{ matrix.run_install.name }}, ${{ matrix.os }})'

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ If `run_install` is a YAML string representation of either an object or an array

### `package_json_file`

**Optional** File path to the `package.json` to read "packageManager" configutation. If not specified, `package.json` in the project root directory is used.
**Optional** (_type:_ `string`, _default:_ `package.json`) File path to the `package.json` to read "packageManager" configuration.

### `standalone`

**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.

This is useful when you want to use a incompatible pair of Node.js and pnpm.

## Outputs

Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ inputs:
required: false
default: 'null'
package_json_file:
description: File path to the package.json to read "packageManager" configutation
description: File path to the package.json to read "packageManager" configuration
required: false
default: 'package.json'
standalone:
description: When set to true, @pnpm/exe, which is a Node.js bundled package, will be installed, enabling using pnpm without Node.js.
required: false
default: 'false'
runs:
using: node16
main: dist/index.js
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@types/expand-tilde": "^2.0.0",
"@types/fs-extra": "^9.0.13",
"@types/js-yaml": "^4.0.5",
"@types/node": "^14.18.32",
"@types/node-fetch": "^2.6.2",
"@types/node": "^14.18.54",
"@types/node-fetch": "^2.6.4",
"ajv": "^6.12.6",
"expand-tilde": "^2.0.2",
"fs-extra": "^10.1.0",
Expand All @@ -21,6 +21,6 @@
"devDependencies": {
"@ts-schema-autogen/cli": "^0.1.2",
"@vercel/ncc": "^0.33.4",
"typescript": "^4.8.4"
"typescript": "^4.9.5"
}
}
Loading

0 comments on commit d882d12

Please sign in to comment.