Compare commits

...
44 Commits
Author SHA1 Message Date
Zoltan Kochan 187ace9a18 test: don't check pnpx 2022-02-10 01:18:35 +02:00
Zoltan Kochan 7f8a57faa8 test: update pnpm version 2022-02-10 01:16:10 +02:00
Zoltan Kochan 268b4179de Install the self-contained binary version of pnpm
This is a breaking change because the binary version of pnpm
is only available from v6.17.1

close #18
2022-02-10 01:13:09 +02:00
khai96_ 2270f39ef6 v2.1.0 2022-02-08 19:53:18 +07:00
khai96_ 394c848db6 Update the bundle 2022-02-08 19:50:57 +07:00
Khải e13928ccc5 Merge pull request #27 from metonym/fix-jobs-syntax
Specify job name to fix syntax error
2022-02-08 19:48:36 +07:00
Khải 93bd5a123d Merge pull request #29 from pnpm/pnpm-v7
The pnpm home directory should be added to PATH and PNPM_HOME
2022-02-08 19:47:28 +07:00
Zoltan Kochan 9eb14dd77c decrease bundle size 2022-02-08 14:44:50 +02:00
Zoltan Kochan eafb777c56 download script from pnpm.io 2022-02-08 00:39:20 +02:00
Zoltan Kochan e6378df420 PNPM_HOME_PATH=>PNPM_HOME 2022-02-08 00:21:53 +02:00
Zoltan Kochan 6ff6e97bc6 The pnpm home directory should be added to PATH and PNPM_HOME
This change is needed to make the action compatible with pnpm v7.

Related breaking change in pnpm: pnpm/pnpm#4280
2022-02-07 23:15:44 +02:00
Eric Liu 45d9c91ff6 Specify job name to fix syntax error 2022-01-29 08:17:29 -08:00
Khải 15569a497d Merge pull request #26 from ai/patch-1
Improve `version` docs
2021-12-16 21:20:06 +07:00
Andrey SitnikandKhải d70eebd14a Update README.md
Co-authored-by: Khải <[email protected]>
2021-12-16 17:18:46 +03:00
Andrey Sitnik 3bf8acf16f Improve version docs 2021-12-16 17:12:07 +03:00
Khải 3c2fe8c592 Merge pull request #21 from gaggle/patch-1
Spelling
2021-10-12 19:45:45 +07:00
Jon Lauridsen 76cc04cd5e Spelling 2021-10-12 13:34:10 +02:00
Khải bcad811784 Remove unused env from examples 2021-07-24 08:25:23 +07:00
Khải 602b36f177 Remove uses of undefined variables from examples 2021-07-24 08:22:22 +07:00
Khải 74a0fdc1a4 Merge pull request #14 from Jack-Works-forks/master
Update README: use lockfile hash instead of package.json hash
2021-06-01 09:44:13 +07:00
Jack Works 493e98ec5e Update README.md 2021-06-01 10:42:26 +08:00
khai96_ 646cdf4821 Update versions in README examples to the latest 2021-04-24 21:13:36 +07:00
Khải a1ba6cf5ae Merge pull request #11 from pnpm/zkochan-patch-1
docs(readme): PNPM=>pnpm
2021-03-27 18:50:58 +07:00
Zoltan Kochan 41b381a08b docs(readme): PNPM=>pnpm 2021-03-27 13:45:01 +02:00
khai96_ 3236b209b5 Merge branch 'v2' 2021-03-27 16:56:27 +07:00
khai96_ 2124926520 Update README.md 2021-03-23 12:53:37 +07:00
khai96_ ba9826e81c Update test workflow 2021-03-23 12:53:25 +07:00
khai96_ 7c4472dbcf Forgot to specify working directory 2021-03-23 12:48:54 +07:00
khai96_ 0db7fb9961 Add .pnpm-store to .gitignore 2021-03-23 12:48:07 +07:00
khai96_ aefcd1e623 Use pnpm.js to install pnpm 2021-03-23 12:42:43 +07:00
khai96_ b7b9d6344b Instruct renovate to ignore ajv updates 2021-03-23 11:47:55 +07:00
khai96_ 7e61ea5847 Add "$schema" to renovate.json 2021-03-23 11:46:56 +07:00
khai96_ 3a2c7247e1 Fix js-yaml usage 2021-03-23 11:43:49 +07:00
khai96_ 2a105263a5 Update dependencies 2021-03-23 11:43:36 +07:00
Khải 9facd4db8e Merge pull request #9 from hildjj/cache-docs
Adds documentation hints for caching
2021-02-18 08:31:04 +07:00
Khải 6c1466d327 Make some tweaks to example code snippets 2021-02-18 08:30:07 +07:00
Joe Hildebrand b26427e53e Adds documentation hints for caching. Fixes #8. 2021-02-17 09:45:25 -07:00
Khải 086f5bd3b6 Update README.md
close https://github.com/pnpm/action-setup/issues/6
2020-10-19 14:10:51 +07:00
khai96_ bdb2a5ee76 Enable Dependabot 2020-10-05 22:16:14 +07:00
khai96_ 8e1abe543f Update dist/index.js 2020-10-05 21:51:43 +07:00
khai96_ af6247d08a Fix https://github.com/pnpm/action-setup/issues/5 2020-10-05 21:45:45 +07:00
khai96_ f87c8a916e Fix TypeScript error 2020-10-05 21:45:20 +07:00
khai96_ d6790970e0 Update dependencies 2020-10-05 21:44:44 +07:00
khai96_ fa62771e12 Add workflow_dispatch event 2020-08-27 08:25:30 +07:00
19 changed files with 634 additions and 544 deletions

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
labels:
- dependabot
- github-actions
+10 -11
View File
@@ -3,6 +3,7 @@ name: Test Action
on:
- push
- pull_request
- workflow_dispatch
jobs:
test_default_inputs:
@@ -14,7 +15,7 @@ jobs:
fail-fast: false
matrix:
pnpm:
- 4.11.1
- 6.17.1
os:
- ubuntu-latest
- macos-latest
@@ -26,10 +27,10 @@ jobs:
- name: Run the action
uses: ./
with:
version: 4.11.1
version: 6.17.1
- name: 'Test: which'
run: which pnpm; which pnpx
run: which pnpm
- name: 'Test: install'
run: pnpm install
@@ -43,7 +44,7 @@ jobs:
fail-fast: false
matrix:
pnpm:
- 4.11.1
- 6.17.1
os:
- ubuntu-latest
- macos-latest
@@ -55,13 +56,11 @@ jobs:
- name: Run the action
uses: ./
with:
version: 4.11.1
version: 6.17.1
dest: ~/test/pnpm
bin_dest: ~/test/pnpm/.bin
registry: http://registry.yarnpkg.com/
- name: 'Test: which'
run: which pnpm && which pnpx
run: which pnpm
- name: 'Test: install'
run: pnpm install
@@ -75,7 +74,7 @@ jobs:
fail-fast: false
matrix:
pnpm:
- 4.11.1
- 6.17.1
os:
- ubuntu-latest
- macos-latest
@@ -113,11 +112,11 @@ jobs:
- name: Run the action
uses: ./
with:
version: 4.11.1
version: 6.17.1
run_install: ${{ matrix.run_install.value }}
- name: 'Test: which'
run: which pnpm; which pnpx
run: which pnpm
- name: 'Test: install'
run: pnpm install
+1
View File
@@ -8,3 +8,4 @@ temp
*.temp
tmp.*
temp.*
.pnpm-store
+55 -30
View File
@@ -1,24 +1,16 @@
# Setup PNPM
# Setup pnpm
Install PNPM package manager.
Install pnpm package manager.
## Inputs
### `version`
**Required** Version of PNPM to install.
**Required** Version of pnpm to install. It supports npm versioning scheme, it could be an exact version (such as `6.24.1`), or a version range (such as `6`, `6.x.x`, `6.24.x`, `^6.24.1`, `*`, etc.), or `latest`.
### `dest`
**Optional** Where to store PNPM files.
### `bin_dest`
**Optional** Where to store executables (`pnpm` and `pnpx` commands).
### `registry`
**Optional** (_default:_ `https://registry.npmjs.com`) Registry to download PNPM from.
**Optional** Where to store pnpm files.
### `run_install`
@@ -50,11 +42,11 @@ Expanded path of inputs#dest.
### `bin_dest`
Expanded path of inputs#bin_dest.
Location of `pnpm` and `pnpx` command.
## Usage example
### Just install PNPM
### Just install pnpm
```yaml
on:
@@ -62,15 +54,16 @@ on:
- pull_request
jobs:
runs-on: ubuntu-latest
install:
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v1.2.0
with:
version: 4.11.1
steps:
- uses: pnpm/action-setup@v2.1.0
with:
version: 6.0.2
```
### Install PNPM and a few NPM packages
### Install pnpm and a few npm packages
```yaml
on:
@@ -78,20 +71,52 @@ on:
- pull_request
jobs:
runs-on: ubuntu-latest
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v1.2.0
with:
version: 4.11.1
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript]
- uses: pnpm/action-setup@v2.1.0
with:
version: 6.0.2
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript]
```
### Use cache to reduce installation time
```yaml
on:
- push
- pull_request
jobs:
cache-and-install:
runs-on: ubuntu-latest
steps:
build:
- uses: actions/checkout@v2
- name: Cache pnpm modules
uses: actions/cache@v2
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/[email protected]
with:
version: 6.0.2
run_install: true
```
**Note:** You don't need to run `pnpm store prune` at the end; post-action has already taken care of that.
## Notes
This action does not setup Node.js for you, use [actions/setup-node](https://github.com/actions/setup-node) yourself.
-8
View File
@@ -11,14 +11,6 @@ inputs:
description: Where to store PNPM files
required: false
default: ~/setup-pnpm
bin_dest:
description: Where to store executables (pnpm and pnpx commands)
required: false
default: ~/setup-pnpm/.bin
registry:
description: Registry to download PNPM from
required: false
default: https://registry.npmjs.com
run_install:
description: If specified, run `pnpm install`
required: false
+1 -1
View File
@@ -1 +1 @@
module.exports=function(n,e){"use strict";var f={};function __webpack_require__(e){if(f[e]){return f[e].exports}var r=f[e]={i:e,l:false,exports:{}};n[e].call(r.exports,r,r.exports,__webpack_require__);r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(803)}return startup()}({0:function(n,e){"use strict";Object.defineProperty(e,"__esModule",{value:true});e.ref="301414cec74a2b6b63c95b42f2ad1790ccb980ed";e.url=`https://raw.githubusercontent.com/pnpm/self-installer/${e.ref}/install.js`;e.default=e.url},17:function(n){"use strict";n.exports=function generate__limitItems(n,e,f){var r=" ";var l=n.level;var s=n.dataLevel;var v=n.schema[e];var c=n.schemaPath+n.util.getProperty(e);var p=n.errSchemaPath+"/"+e;var g=!n.opts.allErrors;var b;var i="data"+(s||"");var w=n.opts.$data&&v&&v.$data,d;if(w){r+=" var schema"+l+" = "+n.util.getData(v.$data,s,n.dataPathArr)+"; ";d="schema"+l}else{d=v}var A=e=="maxItems"?">":"<";r+="if ( ";if(w){r+=" ("+d+" !== undefined && typeof "+d+" != 'number') || "}r+=" "+i+".length "+A+" "+d+") { ";var b=e;var j=j||[];j.push(r);r="";if(n.createErrors!==false){r+=" { keyword: '"+(b||"_limitItems")+"' , dataPath: (dataPath || '') + "+n.errorPath+" , schemaPath: "+n.util.toQuotedString(p)+" , params: { limit: "+d+" } ";if(n.opts.messages!==false){r+=" , message: 'should NOT have ";if(e=="maxItems"){r+="more"}else{r+="fewer"}r+=" than ";if(w){r+="' + "+d+" + '"}else{r+=""+v}r+=" items' "}if(n.opts.verbose){r+=" , schema: ";if(w){r+="validate.schema"+c}else{r+=""+v}r+=" , parentSchema: validate.schema"+n.schemaPath+" , data: "+i+" "}r+=" } "}else{r+=" {} "}var E=r;r=j.pop();if(!n.compositeRule&&g){if(n.async){r+=" throw new ValidationError(["+E+"]); "}else{r+=" validate.errors = ["+E+"]; return false; "}}else{r+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}r+="} ";if(g){r+=" else { "}return r}},34:function(n){n.exports=require("https")},87:function(n){n.exports=require("os")},89:function(n,e,f){"use strict";var r=this&&this.__awaiter||function(n,e,f,r){function adopt(n){return n instanceof f?n:new f(function(e){e(n)})}return new(f||(f=Promise))(function(f,l){function fulfilled(n){try{step(r.next(n))}catch(n){l(n)}}function rejected(n){try{step(r["throw"](n))}catch(n){l(n)}}function step(n){n.done?f(n.value):adopt(n.value).then(fulfilled,rejected)}step((r=r.apply(n,e||[])).next())})};var l=this&&this.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var f in n)if(Object.hasOwnProperty.call(n,f))e[f]=n[f];e["default"]=n;return e};Object.defineProperty(e,"__esModule",{value:true});const s=f(486);const v=l(f(87));const c=l(f(622));var p;(function(n){n[n["Success"]=0]="Success";n[n["Failure"]=1]="Failure"})(p=e.ExitCode||(e.ExitCode={}));function exportVariable(n,e){const f=s.toCommandValue(e);process.env[n]=f;s.issueCommand("set-env",{name:n},f)}e.exportVariable=exportVariable;function setSecret(n){s.issueCommand("add-mask",{},n)}e.setSecret=setSecret;function addPath(n){s.issueCommand("add-path",{},n);process.env["PATH"]=`${n}${c.delimiter}${process.env["PATH"]}`}e.addPath=addPath;function getInput(n,e){const f=process.env[`INPUT_${n.replace(/ /g,"_").toUpperCase()}`]||"";if(e&&e.required&&!f){throw new Error(`Input required and not supplied: ${n}`)}return f.trim()}e.getInput=getInput;function setOutput(n,e){s.issueCommand("set-output",{name:n},e)}e.setOutput=setOutput;function setCommandEcho(n){s.issue("echo",n?"on":"off")}e.setCommandEcho=setCommandEcho;function setFailed(n){process.exitCode=p.Failure;error(n)}e.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}e.isDebug=isDebug;function debug(n){s.issueCommand("debug",{},n)}e.debug=debug;function error(n){s.issue("error",n instanceof Error?n.toString():n)}e.error=error;function warning(n){s.issue("warning",n instanceof Error?n.toString():n)}e.warning=warning;function info(n){process.stdout.write(n+v.EOL)}e.info=info;function startGroup(n){s.issue("group",n)}e.startGroup=startGroup;function endGroup(){s.issue("endgroup")}e.endGroup=endGroup;function group(n,e){return r(this,void 0,void 0,function*(){startGroup(n);let f;try{f=yield e()}finally{endGroup()}return f})}e.group=group;function saveState(n,e){s.issueCommand("save-state",{name:n},e)}e.saveState=saveState;function getState(n){return process.env[`STATE_${n}`]||""}e.getState=getState},90:function(n,e,f){"use strict";var r=f(205);function resolveJavascriptRegExp(n){if(n===null)return false;if(n.length===0)return false;var e=n,f=/\/([gim]*)$/.exec(n),r="";if(e[0]==="/"){if(f)r=f[1];if(r.length>3)return false;if(e[e.length-r.length-1]!=="/")return false}return true}function constructJavascriptRegExp(n){var e=n,f=/\/([gim]*)$/.exec(n),r="";if(e[0]==="/"){if(f)r=f[1];e=e.slice(1,e.length-r.length-1)}return new RegExp(e,r)}function representJavascriptRegExp(n){var e="/"+n.source+"/";if(n.global)e+="g";if(n.multiline)e+="m";ifLine truncated
module.exports=(()=>{var __webpack_modules__={2492:e=>{"use strict";e.exports=JSON.parse('{"anyOf":[{"$ref":"#/definitions/RunInstall"},{"type":"array","items":{"$ref":"#/definitions/RunInstall"}},{"type":["null","boolean"]}],"definitions":{"RunInstall":{"type":"object","properties":{"recursive":{"type":"boolean"},"cwd":{"type":"string"},"args":{"type":"array","items":{"type":"string"}}}}},"$schema":"http://json-schema.org/draft-07/schema#"}')},6152:function(e,p,d){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:true});const n=d(6105);const l=a(d(539));const r=a(d(7701));const i=a(d(9875));const s=a(d(4882));const m=a(d(4424));async function main(){const e=(0,l.default)();const p=(0,n.getState)("is_post");if(p==="true")return(0,m.default)(e);(0,n.saveState)("is_post","true");await(0,i.default)(e);console.log("Installation Completed!");(0,r.default)(e);(0,s.default)(e)}main().catch(e=>{console.error(e);(0,n.setFailed)(e)})},539:function(e,p,d){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:true});p.getInputs=void 0;const n=d(6105);const l=a(d(9413));const r=d(4019);const i={required:true};const s=e=>(0,l.default)((0,n.getInput)(e,i));const m=()=>({version:(0,n.getInput)("version",i),dest:s("dest"),runInstall:(0,r.parseRunInstall)("run_install")});p.getInputs=m;p.default=p.getInputs},4019:function(e,p,d){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:true});p.parseRunInstall=void 0;const n=a(d(1765));const l=d(6070);const r=a(d(6562));const i=d(6105);const s=a(d(2492));const m={required:true};function parseRunInstall(e){const p=(0,l.load)((0,i.getInput)(e,m));const d=new r.default({allErrors:true});const a=d.compile(s.default);if(!a(p)){for(const e of a.errors){(0,i.error)(`with.run_install${e.dataPath}: ${e.message}`)}return n.default.exit(1)}if(!p)return[];if(p===true)return[{recursive:true}];if(Array.isArray(p))return p;return[p]}p.parseRunInstall=parseRunInstall},9875:function(e,p,d){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:true});p.install=p.runSelfInstaller=void 0;const n=d(6105);const l=a(d(7529));p.runSelfInstaller=l.default;async function install(e){(0,n.startGroup)("Running self-installer...");const p=await(0,l.default)(e);(0,n.endGroup)();if(p){return(0,n.setFailed)(`Something went wrong, self-installer exits with code ${p}`)}}p.install=install;p.default=install},7529:function(e,p,d){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:true});p.runSelfInstaller=void 0;const n=d(6105);const l=d(3129);const r=d(1765);const i=a(d(5622));const s=d(4982);const m=a(d(6015));async function runSelfInstaller(e){const{version:p,dest:d}=e;const a=p?`@pnpm/exe@${p}`:"@pnpm/exe";const f=i.default.join(d,"package.json");await(0,s.remove)(d);await(0,s.ensureFile)(f);await(0,s.writeFile)(f,JSON.stringify({private:true}));const v=(0,l.spawn)(r.execPath,["-","install",a,"--no-lockfile"],{cwd:d,stdio:["pipe","inherit","inherit"]});const c=await(0,m.default)("https://get.pnpm.io/v6.16.js");c.body.pipe(v.stdin);const o=await new Promise((e,p)=>{v.on("error",p);v.on("close",e)});if(o===0){const e=i.default.join(d,"node_modules/.bin");(0,n.addPath)(e);(0,n.exportVariable)("PNPM_HOME",e)}return o}p.runSelfInstaller=runSelfInstaller;p.default=runSelfInstaller},7701:(e,p,d)=>{"use strict";Object.defineProperty(p,"__esModule",{value:true});p.setOutputs=void 0;const a=d(6105);const n=d(6656);function setOutputs(e){const p=(0,n.getBinDest)(e);(0,a.addPath)(p);(0,a.setOutput)("dest",e.dest);(0,a.setOutput)("bin_dest",p)}p.setOutputs=setOutputs;p.default=setOutputs},4882:(e,p,d)=>{"use strict";Object.defineProperty(p,"__esModule",{value:true});p.runPnpmInstall=void 0;const a=d(3129);const n=d(6105);const l=d(6656);function runPnpmInstall(e){const p=(0,l.patchPnpmEnv)(e);for(const d of e.runInstall){const e=["install"];if(d.recursive)e.unshift("recursive");if(d.args)e.push(...d.args);const l=["pnpm",...e].join(" ");(0,n.startGroup)(`Running ${l}...`);const{error:r,status:i}=(0,a.spawnSync)("pnpm",e,{stdio:"inherit",cwd:d.cwd,shell:true,env:p});(0,n.endGroup)();if(r){(0,n.setFailed)(r);continue}if(i){(0,n.setFailed)(`Command ${l} (cwd: ${d.cwd}) exits with status ${i}`);continue}}}p.runPnpmInstall=runPnpmInstall;p.default=runPnpmInstall},4424:(e,p,d)=>{"use strict";Object.defineProperty(p,"__esModule",{value:true});p.pruneStore=void 0;const a=d(3129);const n=d(6105);const l=d(6656);function pruneStore(e){if(e.runInstall.length===0){console.log("Pruning is unnecessary.");return}(0,n.startGroup)("Running pnpm store prune...");const{error:p,status:d}=(0,a.spawnSync)("pnpm"Line truncated
+12 -10
View File
@@ -7,19 +7,21 @@
"start": "pnpm run build && sh ./run.sh"
},
"dependencies": {
"node-fetch": "^2.6.0",
"expand-tilde": "^2.0.2",
"js-yaml": "^3.13.1",
"ajv": "^6.12.0",
"@actions/core": "^1.2.4",
"@actions/core": "^1.6.0",
"@types/expand-tilde": "^2.0.0",
"@types/node-fetch": "^2.5.7",
"@types/js-yaml": "^3.12.3",
"@types/node": "^13.13.5"
"@types/fs-extra": "^9.0.13",
"@types/js-yaml": "^4.0.5",
"@types/node": "^14.18.10",
"@types/node-fetch": "^2.5.12",
"ajv": "^6.12.6",
"expand-tilde": "^2.0.2",
"fs-extra": "^9.1.0",
"js-yaml": "^4.1.0",
"node-fetch": "^2.6.7"
},
"devDependencies": {
"typescript": "^3.8.3",
"@ts-schema-autogen/cli": "^0.1.2",
"@zeit/ncc": "^0.22.1"
"@vercel/ncc": "^0.27.0",
"typescript": "^4.5.5"
}
}
+509 -452
View File
File diff suppressed because it is too large. Load diff
+4
View File
@@ -1,6 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"pinVersions": false,
"extends": [
"config:base"
],
"ignoreDeps": [
"ajv"
]
}
-2
View File
@@ -3,7 +3,5 @@
export HOME="$(pwd)"
export INPUT_VERSION=4.11.1
export INPUT_DEST='~/pnpm.temp'
export INPUT_BIN_DEST='~/pnpm.temp/.bin'
export INPUT_REGISTRY=https://registry.npmjs.com
export INPUT_RUN_INSTALL=null
exec node dist/index.js
-4
View File
@@ -5,8 +5,6 @@ import { RunInstall, parseRunInstall } from './run-install'
export interface Inputs {
readonly version: string
readonly dest: string
readonly binDest: string
readonly registry: string
readonly runInstall: RunInstall[]
}
@@ -19,8 +17,6 @@ const parseInputPath = (name: string) => expandTilde(getInput(name, options))
export const getInputs = (): Inputs => ({
version: getInput('version', options),
dest: parseInputPath('dest'),
binDest: parseInputPath('bin_dest'),
registry: getInput('registry', options),
runInstall: parseRunInstall('run_install'),
})
+2 -3
View File
@@ -1,5 +1,5 @@
import process from 'process'
import { safeLoad } from 'js-yaml'
import { load } from 'js-yaml'
import Ajv from 'ajv'
import { getInput, error, InputOptions } from '@actions/core'
import runInstallSchema from './run-install-input.schema.json'
@@ -21,10 +21,9 @@ const options: InputOptions = {
}
export function parseRunInstall(name: string): RunInstall[] {
const result: RunInstallInput = safeLoad(getInput(name, options))
const result: RunInstallInput = load(getInput(name, options)) as any
const ajv = new Ajv({
allErrors: true,
async: false,
})
const validate = ajv.compile(runInstallSchema)
if (!validate(result)) {
+1 -1
View File
@@ -9,7 +9,7 @@ export async function install(inputs: Inputs) {
const status = await runSelfInstaller(inputs)
endGroup()
if (status) {
return setFailed(`Something does wrong, self-installer exits with code ${status}`)
return setFailed(`Something went wrong, self-installer exits with code ${status}`)
}
}
+22 -10
View File
@@ -1,26 +1,38 @@
import { addPath, exportVariable } from '@actions/core'
import { spawn } from 'child_process'
import { execPath } from 'process'
import { downloadSelfInstaller } from '../self-installer'
import path from 'path'
import { remove, ensureFile, writeFile } from 'fs-extra'
import fetch from 'node-fetch'
import { Inputs } from '../inputs'
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const cp = spawn(execPath, {
env: {
PNPM_VERSION: inputs.version,
PNPM_DEST: inputs.dest,
PNPM_BIN_DEST: inputs.binDest,
PNPM_REGISTRY: inputs.registry,
},
const { version, dest } = inputs
const target = version ? `@pnpm/exe@${version}` : '@pnpm/exe'
const pkgJson = path.join(dest, 'package.json')
await remove(dest)
await ensureFile(pkgJson)
await writeFile(pkgJson, JSON.stringify({ private: true }))
const cp = spawn(execPath, ['-', 'install', target, '--no-lockfile'], {
cwd: dest,
stdio: ['pipe', 'inherit', 'inherit'],
})
const response = await downloadSelfInstaller()
const response = await fetch('https://get.pnpm.io/v6.16.js')
response.body.pipe(cp.stdin)
return new Promise((resolve, reject) => {
const exitCode = await new Promise<number>((resolve, reject) => {
cp.on('error', reject)
cp.on('close', resolve)
})
if (exitCode === 0) {
const pnpmHome = path.join(dest, 'node_modules/.bin')
addPath(pnpmHome)
exportVariable('PNPM_HOME', pnpmHome)
}
return exitCode
}
export default runSelfInstaller
+4 -2
View File
@@ -1,10 +1,12 @@
import { setOutput, addPath } from '@actions/core'
import { Inputs } from '../inputs'
import { getBinDest } from '../utils'
export function setOutputs(inputs: Inputs) {
addPath(inputs.binDest)
const binDest = getBinDest(inputs)
addPath(binDest)
setOutput('dest', inputs.dest)
setOutput('bin_dest', inputs.binDest)
setOutput('bin_dest', binDest)
}
export default setOutputs
-4
View File
@@ -1,4 +0,0 @@
import fetch from 'node-fetch'
import url from './url'
export const downloadSelfInstaller = () => fetch(url)
export default downloadSelfInstaller
-2
View File
@@ -1,2 +0,0 @@
export * from './url'
export * from './download'
-3
View File
@@ -1,3 +0,0 @@
export const ref = '301414cec74a2b6b63c95b42f2ad1790ccb980ed'
export const url = `https://raw.githubusercontent.com/pnpm/self-installer/${ref}/install.js`
export default url
+3 -1
View File
@@ -2,7 +2,9 @@ import process from 'process'
import path from 'path'
import { Inputs } from '../inputs'
export const getBinDest = (inputs: Inputs): string => path.join(inputs.dest, 'node_modules', '.bin')
export const patchPnpmEnv = (inputs: Inputs): NodeJS.ProcessEnv => ({
...process.env,
PATH: inputs.binDest + path.delimiter + process.env.PATH
PATH: getBinDest(inputs) + path.delimiter + process.env.PATH
})