diff --git a/README.md b/README.md index 7464fea..641c1ab 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ npm i -g runme runme list ``` +By default this package downloads the [Runme CLI](https://github.com/stateful/runme) when the interface is used for the first time. You can download it after running `npm install` by setting the `RUNME_DOWNLOAD_ON_INSTALL` environment flag. You can also modify the Runme version that is being installed by setting `RUNME_VERSION`, e.g.: + +```sh +RUNME_DOWNLOAD_ON_INSTALL=1 RUNME_VERSION=1.0.0 npm install runme +npx runme --version +``` + ## Usage The module exposes the following methods: diff --git a/package-lock.json b/package-lock.json index 2ca31dc..8f40359 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,13 @@ { "name": "runme", - "version": "0.4.4", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "runme", - "version": "0.4.4", + "version": "1.0.0", + "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { "@actions/exec": "^1.1.1", diff --git a/package.json b/package.json index 8208866..f84d0e4 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "clean": "rimraf dist", "compile": "tsc -p ./tsconfig.json", "copy": "cp src/cjs/package.json dist/cjs/package.json", + "postinstall": "node ./postInstall.js", "release": "release-it --github.release --ci --npm.skipChecks --no-git.requireCleanWorkingDir", "test": "run-s test:*", "test:nodejs": "vitest --config ./vitest.config.ts", diff --git a/postInstall.js b/postInstall.js new file mode 100644 index 0000000..b69bb74 --- /dev/null +++ b/postInstall.js @@ -0,0 +1,9 @@ +import fs from 'node:fs/promises' + +const isCompiled = await fs.access('./dist').then(() => true, () => false) +if (isCompiled && process.env.RUNME_DOWNLOAD_ON_INSTALL) { + const { download } = await import('./dist/installer.js') + const version = process.env.RUNME_VERSION || 'latest' + console.log(`Download Runme ${version}`) + await download(version) +}