From 50a377a7c4df21e51fb46bb065e3a7c8fcb90620 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 29 Sep 2022 21:27:30 -0300 Subject: [PATCH] Add package.json to allow users to install Task using npm Closes #870 --- .gitignore | 1 + CHANGELOG.md | 2 ++ Taskfile.yml | 5 +++++ docs/docs/installation.md | 11 ++++++++++- docs/docs/releasing.md | 17 +++++++++++------ package-lock.json | 32 ++++++++++++++++++++++++++++++++ package.json | 34 ++++++++++++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 21c645e3f1..9827564c10 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ tags !/bin/.keep /testdata/vars/v1 /tmp +node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b6d4698a..801a2f6fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Add `npm` as new installation method: `npm i -g @go-task/cli` + ([#870](https://github.com/go-task/task/issues/870), [#871](https://github.com/go-task/task/pull/871), [npm package](https://www.npmjs.com/package/@go-task/cli)). - Add support to marking tasks and includes as internal, which will hide them from `--list` and `--list-all` ([#818](https://github.com/go-task/task/pull/818)). diff --git a/Taskfile.yml b/Taskfile.yml index 16fe4dc5f5..b0ed62486e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -93,6 +93,11 @@ tasks: - 'echo "" >> {{.FILE}}' - 'cat CHANGELOG.md >> {{.FILE}}' + npm:publish: + desc: Publish release to npm + cmds: + - npm publish --access=public + packages: cmds: - echo '{{.GO_PACKAGES}}' diff --git a/docs/docs/installation.md b/docs/docs/installation.md index b21f7d8e44..fba1d0db84 100644 --- a/docs/docs/installation.md +++ b/docs/docs/installation.md @@ -71,7 +71,7 @@ the source code instead of downloading the binary from the yay -S go-task ``` -This installation method is community owned. +This installation method is community owned. ### Fedora @@ -97,6 +97,15 @@ nix-env -iA nixpkgs.go-task This installation method is community owned. After a new release of Task, it may take some time until it's available in [nixpkgs](https://github.com/NixOS/nixpkgs). +### npm + +You can also use Node and npm to install Task by installing +[this package](https://www.npmjs.com/package/@go-task/cli). + +```bash +npm install -g @go-task/cli +``` + ## Get The Binary ### Binary diff --git a/docs/docs/releasing.md b/docs/docs/releasing.md index 180e4bc647..663981a62c 100644 --- a/docs/docs/releasing.md +++ b/docs/docs/releasing.md @@ -19,15 +19,19 @@ defined in the above GitHub Actions. # Homebrew -To release a new version on the [Homebrew tap][homebrewtap] edit the -[Formula/go-task.rb][gotaskrb] file, updating with the new version, download -URL and sha256. +Goreleaser will automatically push a new commit to the +[Formula/go-task.rb][gotaskrb] file in the [Homebrew tap][homebrewtap] +repository to release the new version. + +# npm + +To release to npm update the version in the [`package.json`][packagejson] file +and then run `task npm:publish` to push it. # Snapcraft -The exception is the publishing of a new version of the -[snap package][snappackage]. This current require two steps after publishing -the binaries: +The [snap package][snappackage] requires to manual steps to release a new +version: * Updating the current version on [snapcraft.yaml][snapcraftyaml]. * Moving both `amd64`, `armhf` and `arm64` new artifacts to the stable channel on @@ -50,6 +54,7 @@ If you think its Task version is outdated, open an issue to let us know. [goreleaser]: https://goreleaser.com/ [homebrewtap]: https://github.com/go-task/homebrew-tap [gotaskrb]: https://github.com/go-task/homebrew-tap/blob/master/Formula/go-task.rb +[packagejson]: https://github.com/go-task/homebrew-tap/blob/master/package.json#3 [snappackage]: https://github.com/go-task/snap [snapcraftyaml]: https://github.com/go-task/snap/blob/master/snap/snapcraft.yaml#L2 [snapcraftdashboard]: https://snapcraft.io/task/releases diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000..897200dd4a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,32 @@ +{ + "name": "@go-task/cli", + "version": "3.15.2", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@go-task/cli", + "version": "3.15.2", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "@go-task/go-npm": "^0.1.15" + } + }, + "node_modules/@go-task/go-npm": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/@go-task/go-npm/-/go-npm-0.1.15.tgz", + "integrity": "sha512-xG+6SsSQsa6MzWML1CABWHTwHrCrBqXc/D1POoMDGIgjsRE/PB1noSBGLFhvU5DWHdPksqbAt/w9VOjbqlXpYw==", + "bin": { + "go-npm": "bin/index.js" + } + } + }, + "dependencies": { + "@go-task/go-npm": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/@go-task/go-npm/-/go-npm-0.1.15.tgz", + "integrity": "sha512-xG+6SsSQsa6MzWML1CABWHTwHrCrBqXc/D1POoMDGIgjsRE/PB1noSBGLFhvU5DWHdPksqbAt/w9VOjbqlXpYw==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000000..9db5c27d65 --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "@go-task/cli", + "version": "3.15.2", + "description": "A task runner / simpler Make alternative written in Go", + "scripts": { + "postinstall": "go-npm install", + "preuninstall": "go-npm uninstall" + }, + "goBinary": { + "name": "task", + "path": "./bin", + "url": "https://github.com/go-task/task/releases/download/v{{version}}/task_{{platform}}_{{arch}}{{archive_ext}}" + }, + "files": [], + "repository": { + "type": "git", + "url": "https://github.com/go-task/task.git" + }, + "keywords": [ + "task", + "taskfile", + "build-tool", + "task-runner" + ], + "author": "Andrey Nering", + "license": "MIT", + "bugs": { + "url": "https://github.com/go-task/task/issues" + }, + "homepage": "https://taskfile.dev", + "dependencies": { + "@go-task/go-npm": "^0.1.15" + } +}