From 307a4ad842182e0edc8cd1bc3c7c45fa16fd2a87 Mon Sep 17 00:00:00 2001 From: Axetroy Date: Sun, 3 Oct 2021 12:54:41 +0800 Subject: [PATCH] feat(BREAKING): remove npm publish BREAKING CHANGE: remove npm publish ```diff - npm install @axetroy/whatchanged -g ``` --- .github/workflows/ci.yml | 15 --------- README.md | 9 ----- README_zh-CN.md | 11 +----- npm/.gitignore | 4 --- npm/.npmignore | 7 ---- npm/bin/whatchanged | 30 ----------------- npm/download/.gitkeep | 0 npm/package.json | 26 --------------- npm/scripts/bump.js | 14 -------- npm/scripts/postinstall.js | 68 -------------------------------------- 10 files changed, 1 insertion(+), 183 deletions(-) delete mode 100644 npm/.gitignore delete mode 100644 npm/.npmignore delete mode 100755 npm/bin/whatchanged delete mode 100644 npm/download/.gitkeep delete mode 100644 npm/package.json delete mode 100644 npm/scripts/bump.js delete mode 100644 npm/scripts/postinstall.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f4ee93c..028cd752 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,18 +80,3 @@ jobs: args: release --rm-dist --release-notes=./release.md env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - - name: Prepare publish - env: - GITHUB_REF: ${{ github.ref }} - run: | - cp README.md ./npm/README.md - cp release.md ./npm/CHANGELOG.md - cp LICENSE ./npm/LICENSE - node ./npm/scripts/bump.js - - - name: Publish to NPM - uses: JS-DevTools/npm-publish@v1 - with: - package: ./npm/package.json - token: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index a2558d7b..80844bcb 100644 --- a/README.md +++ b/README.md @@ -120,15 +120,6 @@ SOURCE CODE: ### Installation -#### Install via npm - -```bash -# install in global -npm install -g @whatchanged-community/whatchanged -# run the command once -npx @whatchanged-community/whatchanged -``` - #### Install via shell If you are using Linux/macOS. you can install it with the following command: diff --git a/README_zh-CN.md b/README_zh-CN.md index a063214a..45abed29 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -18,7 +18,7 @@ 特性: - [x] 跨平台支持 -- [x] 生成 本地/远程 的git仓库 +- [x] 生成 本地/远程 的 git 仓库 - [x] 内置预设的生成模板 - [x] 自定义模版文件 - [x] 常规的 commit 解析器 @@ -120,15 +120,6 @@ SOURCE CODE: ### 安装 -#### 通过 npm 安装 - -```bash -# install in global -npm install -g @whatchanged-community/whatchanged -# run the command once -npx @whatchanged-community/whatchanged -``` - #### 通过 shell 安装 如果你使用的是 Linux/macOS,你可以通过以下命令进行安装 diff --git a/npm/.gitignore b/npm/.gitignore deleted file mode 100644 index 72d1ebfd..00000000 --- a/npm/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -./bin/whatchanged -./bin/whatchanged.exe -*-lock.json -*.lock \ No newline at end of file diff --git a/npm/.npmignore b/npm/.npmignore deleted file mode 100644 index ca604443..00000000 --- a/npm/.npmignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules -*.lock -package-lock.json -dist -whatchanged -whatchanged.exe -scripts/bump.js \ No newline at end of file diff --git a/npm/bin/whatchanged b/npm/bin/whatchanged deleted file mode 100755 index 9bc8a0e6..00000000 --- a/npm/bin/whatchanged +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env node -const fs = require("fs"); -const path = require("path"); -const os = require("os"); -const { spawn } = require("child_process"); - -const suffix = os.platform() === "win32" ? ".exe" : ""; - -const bin = path.join(__dirname, "..", "download", "whatchanged" + suffix); - -const argv = process.argv; - -if (!fs.existsSync(bin)) { - console.error( - `whatchanged did not downloaded. please run the following command 'node node_modules/@whatchanged-community/whatchanged/scripts/postinstall.js'` - ); - os.exit(1); -} - -const ps = spawn(bin, argv.slice(2), { - stdio: "inherit", -}); - -ps.on("error", (code) => { - process.exit(code); -}); - -ps.on("exit", (code) => { - process.exit(code); -}); diff --git a/npm/download/.gitkeep b/npm/download/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/npm/package.json b/npm/package.json deleted file mode 100644 index 964bb30e..00000000 --- a/npm/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "author": "Axetroy", - "bin": { - "whatchanged": "./bin/whatchanged" - }, - "dependencies": { - "download": "8.0.0", - "progress": "2.0.3" - }, - "description": "An elegant changelog generator", - "files": [ - "README.md", - "CHANGELOG.md", - "LICENSE", - "bin/whatchanged", - "scripts/postinstall.js", - "download/.gitkeep" - ], - "license": "MIT", - "name": "@whatchanged-community/whatchanged", - "scripts": { - "postinstall": "node scripts/postinstall.js", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "0.0.0" -} \ No newline at end of file diff --git a/npm/scripts/bump.js b/npm/scripts/bump.js deleted file mode 100644 index 57663f09..00000000 --- a/npm/scripts/bump.js +++ /dev/null @@ -1,14 +0,0 @@ -const fs = require("fs"); -const path = require("path"); - -const ref = process.env.GITHUB_REF; - -const version = ref.replace(/^refs\/tags\/v/, ""); - -const pkgPath = path.join(__dirname, "..", "package.json"); - -const pkg = require(pkgPath); - -pkg.version = version; - -fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); diff --git a/npm/scripts/postinstall.js b/npm/scripts/postinstall.js deleted file mode 100644 index f51c1261..00000000 --- a/npm/scripts/postinstall.js +++ /dev/null @@ -1,68 +0,0 @@ -const path = require("path"); -const os = require("os"); -const download = require("download"); -const ProgressBar = require("progress"); - -const pkg = require("../package.json"); - -function getArch() { - const arch = os.arch(); - switch (arch) { - case "ia32": - case "x32": - return "386"; - case "x64": - return "amd64"; - case "arm": - // @ts-expect-error ignore error - const armv = process.config.variables.arm_version; - - if (!armv) return "armv7"; - - return `armv${armv}`; - default: - return arch; - } -} - -function getPlatform() { - const platform = os.platform(); - switch (platform) { - case "win32": - return "windows"; - default: - return platform; - } -} - -function getDownloadURL(version) { - const url = `https://github.com/whatchanged-community/whatchanged/releases/download/${version}/whatchanged_${getPlatform()}_${getArch()}.tar.gz`; - return url; -} - -async function install(version) { - const url = getDownloadURL(version); - - console.log(`Downloading '${url}'`); - - const bar = new ProgressBar("[:bar] :percent :etas", { - complete: "=", - incomplete: " ", - width: 20, - total: 0, - }); - - await download(url, path.join(__dirname, "..", "download"), { - extract: true, - }).on("response", (res) => { - bar.total = res.headers["content-length"]; - res.on("data", (data) => bar.tick(data.length)); - res.on("error", (err) => { - console.error("error"); - }); - }); -} - -install("v" + pkg.version).catch((err) => { - throw err; -});