被antdesign恐怖的scripts吓到了

10,693 阅读3分钟

近日无意中打开antdesignpackage.json,然后就看到一砣恐怖的scripts

 "scripts": {
    "api-collection": "antd-tools run api-collection",
    "authors": "tsx scripts/generate-authors.ts",
    "build": "npm run compile && cross-env NODE_OPTIONS='--max-old-space-size=4096' npm run dist",
    "changelog": "npm run lint:changelog && tsx scripts/print-changelog.ts",
    "check-commit": "tsx scripts/check-commit.ts",
    "clean": "antd-tools run clean && rimraf es lib coverage locale dist report.html artifacts.zip oss-artifacts.zip",
    "clean:lockfiles": "rimraf package-lock.json yarn.lock",
    "precompile": "npm run prestart",
    "compile": "npm run clean && antd-tools run compile",
    "predeploy": "antd-tools run clean && npm run site && cp CNAME _site && npm run test:site",
    "deploy": "gh-pages -d _site -b gh-pages -f",
    "deploy:china-mirror": "git checkout gh-pages && git pull origin gh-pages && git push git@gitee.com:ant-design/ant-design.git gh-pages -f",
    "predist": "npm run version && npm run token:statistic && npm run token:meta",
    "dist": "antd-tools run dist",
    "format": "biome format --write .",
    "install-react-16": "npm i --no-save --legacy-peer-deps react@16 react-dom@16 @testing-library/react@12",
    "install-react-17": "npm i --no-save --legacy-peer-deps react@17 react-dom@17 @testing-library/react@12",
    "bun-install-react-16": "bun remove react react-dom @testing-library/react && bun add --no-save react@16 react-dom@16 @testing-library/react@12",
    "bun-install-react-17": "bun remove react react-dom @testing-library/react && bun add --no-save react@17 react-dom@17 @testing-library/react@12",
    "prelint": "dumi setup",
    "lint": "npm run version && npm run tsc && npm run lint:script && npm run lint:biome && npm run lint:md && npm run lint:style && npm run lint:changelog",
    "lint:changelog": "tsx scripts/generate-component-changelog.ts",
    "lint:deps": "antd-tools run deps-lint",
    "lint:md": "remark . -f -q",
    "lint:script": "eslint . --cache",
    "lint:biome": "biome lint",
    "lint:style": "tsx scripts/check-cssinjs.tsx",
    "prepare": "is-ci || husky && dumi setup",
    "prepublishOnly": "tsx ./scripts/pre-publish.ts",
    "prettier": "prettier -c --write . --cache",
    "prettier-import-sort": "npm run prettier -- --plugin=@ianvs/prettier-plugin-sort-imports",
    "biome": "biome check --write",
    "pub": "echo 'Please use `npm publish` instead.'",
    "postpublish": "tsx scripts/post-publish.ts",
    "presite": "npm run prestart",
    "site": "npm i --no-save --legacy-peer-deps react@18.3.0-canary-c3048aab4-20240326 react-dom@18.3.0-canary-c3048aab4-20240326 && dumi build && cp .surgeignore _site",
    "size-limit": "size-limit",
    "sort:api-table": "antd-tools run sort-api-table",
    "sort:package-json": "npx sort-package-json",
    "prestart": "npm run version && npm run token:statistic && npm run token:meta && npm run lint:changelog",
    "start": "tsx ./scripts/set-node-options.ts cross-env PORT=8001 dumi dev",
    "pretest": "npm run version",
    "test": "jest --config .jest.js --no-cache",
    "test:all": "sh -e ./scripts/test-all.sh",
    "test:dekko": "node ./tests/dekko/index.test.js",
    "test:image": "jest --config .jest.image.js --no-cache -i -u --forceExit",
    "test:node": "npm run version && jest --config .jest.node.js --no-cache",
    "test:package-diff": "antd-tools run package-diff",
    "test:site": "jest --config .jest.site.js",
    "test:site-update": "npm run site && npm run test:site -- -u",
    "test:update": "jest --config .jest.js --no-cache -u",
    "test:visual-regression": "tsx scripts/visual-regression/build.ts",
    "token:meta": "tsx scripts/generate-token-meta.ts",
    "token:statistic": "tsx scripts/collect-token-statistic.ts",
    "tsc": "tsc --noEmit",
    "tsc:old": "tsc --noEmit -p tsconfig-old-react.json",
    "version": "tsx scripts/generate-version.ts"
  },

面对如此复杂的scripts,有没有被吓到。

相信我,在团队开发中,不要说团队成员,就算是开发者本身一段时间后也不一定能一眼就看到每一条脚本的作用了。

怎么办呢?最好是加点注释

但是众所周知,package.json是不支持注释了。

这里给大家推荐一个VSCODE插件json_comments_extension,可以用来给任意JSON文件添加注释.

效果如下:

preview.gif

preview2.gif

开源推荐

以下是我的一大波开源项目推荐: