1

我正在尝试发布一个使用 oclif 作为 tarball 构建的 cli。在本地环境中,我需要编写 npm link 以将代码与命令链接。但在产品中,我不希望用户在下载 zip 后打开终端并编写 npm 链接。

似乎 npm 无法运行预安装脚本,除非调用“npm install”。编写一个 shell 脚本听起来是个不错的解决方案,但是用户必须再次手动执行这个脚本。我想知道在用户下载 zip 后是否真的没有办法让这个“npm 链接”自动执行。我确定 Oclif 有它的东西,但我在文档https://oclif.io/docs/releasing中找不到它。

谢谢你的帮助。这是项目的package.json

{
  "name": "galaxycli",
  "version": "0.11.0",
  "description": "An open source CLI for darillium users, built with the OCLIF framework",
  "bin": {
    "galaxy": "./bin/run"
  },
  "oclif.macos.identifier": "com.heroku.cli",
  "dependencies": {
    "@oclif/command": "^1.5.18",
    "@oclif/config": "^1.13.3",
    "@oclif/plugin-autocomplete": "^0.1.3",
    "@oclif/plugin-help": "^2.2.1",
    "@oclif/plugin-not-found": "^1.2.3",
    "@types/inquirer": "^6.5.0",
    "@types/node-notifier": "^5.4.0",
    "axios": "^0.19.0",
    "chalk": "^2.4.2",
    "cli-ux": "^5.3.1",
    "inquirer": "^6.5.1",
    "node-notifier": "^5.4.3",
    "node-persist": "^3.0.5",
    "tslib": "^1.10.0"
  },
  "devDependencies": {
    "@oclif/dev-cli": "^1.22.2",
    "@types/node": "^10.14.16",
    "globby": "^10.0.1",
    "rimraf": "^3.0.0",
    "ts-node": "^8.3.0",
    "typescript": "^3.5.3",
    "aws-sdk": "^2.304.0"
  },
  "engines": {
    "node": ">=8.0.0"
  },
  "files": [
    "/bin",
    "/lib",
    "/npm-shrinkwrap.json",
    "/oclif.manifest.json"
  ],
  "homepage": "https://github.com/Darillium/kitlings",
  "keywords": [
    "oclif"
  ],
  "license": "MIT",
  "main": "lib/index.js",
  "oclif": {
    "commands": "./lib/commands",
    "bin": "galaxy",
    "plugins": [
      "@oclif/plugin-help",
      "@oclif/plugin-not-found",
      "@oclif/plugin-autocomplete"
    ],
    "s3": {
      "bucket": "oclif-staging",
      "templates": {
        "target": {
          "unversioned": "tarballs/<%- bin %>/<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-<%- platform %>-<%- arch %><%- ext %>",
          "versioned": "tarballs/<%- bin %>/<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %><%- ext %>",
          "manifest": "tarballs/<%- bin %>/<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- platform %>-<%- arch %>"
        },
        "vanilla": {
          "unversioned": "tarballs/<%- bin %>/<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %><%- ext %>",
          "versioned": "tarballs/<%- bin %>/<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %><%- ext %>",
          "manifest": "tarballs/<%- bin %>/<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %>version"
        }
      }
    },
    "node": {
      "version": "10.4.0",
      "targets": [
        "linux-x64",
        "win32-x64"
      ]
    }
  },
  "repository": "https://github.com/Darillium/kitlings",
  "scripts": {
    "postpack": "rimraf oclif.manifest.json",
    "prepack": "rimraf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
    "test": "echo NO TESTS",
    "version": "oclif-dev readme && git add README.md",
    "postinstall": "npm link"
  },
  "types": "lib/index.d.ts"
}


4

0 回答 0