ASIDE で init したときの "Generate package.json?" の意味

結論

  • Yes だと npm init 的な package.json が生成される
  • No だと 最低限の package.json が生成される
  • つまり、No にしたからといって package.json が生成されないということではない
  • デフォルト選択肢は Yes になっているが、自分ではデフォルトは No でいいと思う

具体例

Yes を選んだときの package.json

{
  "name": "foobar",
  "version": "0.0.0",
  "description": "",
  "main": "build/index.js",
  "license": "Apache-2.0",
  "keywords": [],
  "scripts": {
    "clean": "rimraf build dist",
    "lint": "npm run license && eslint --fix --no-error-on-unmatched-pattern src/ test/",
    "bundle": "rollup --no-treeshake -c rollup.config.mjs",
    "build": "npm run clean && npm run bundle && ncp appsscript.json dist/appsscript.json",
    "license": "license-check-and-add add -f license-config.json",
    "test": "jest test/ --passWithNoTests --detectOpenHandles",
    "deploy": "npm run lint && npm run test && npm run build && ncp .clasp-dev.json .clasp.json && clasp push -f",
    "deploy:prod": "npm run lint && npm run test && npm run build && ncp .clasp-prod.json .clasp.json && clasp push"
  },
  "engines": {
    "node": ">=12"
  },
  "dependencies": {
    "@google/clasp": "^2.4.2",
    "@types/google-apps-script": "^1.0.89",
    "@types/jest": "^29.5.14",
    "@typescript-eslint/eslint-plugin": "^8.19.0",
    "eslint": "^8.57.1",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "gts": "^6.0.2",
    "jest": "^29.7.0",
    "license-check-and-add": "^4.0.5",
    "ncp": "^2.0.0",
    "prettier": "^3.4.2",
    "rimraf": "^6.0.1",
    "rollup": "^4.29.1",
    "rollup-plugin-cleanup": "^3.2.1",
    "rollup-plugin-license": "^3.5.3",
    "rollup-plugin-prettier": "^4.1.1",
    "rollup-plugin-typescript2": "^0.36.0",
    "ts-jest": "^29.2.5",
    "typescript": "^5.7.2"
  }
}

No を選んだときの package.json

{
  "scripts": {
    "clean": "rimraf build dist",
    "lint": "npm run license && eslint --fix --no-error-on-unmatched-pattern src/ test/",
    "bundle": "rollup --no-treeshake -c rollup.config.mjs",
    "build": "npm run clean && npm run bundle && ncp appsscript.json dist/appsscript.json",
    "license": "license-check-and-add add -f license-config.json",
    "test": "jest test/ --passWithNoTests --detectOpenHandles",
    "deploy": "npm run lint && npm run test && npm run build && ncp .clasp-dev.json .clasp.json && clasp push -f",
    "deploy:prod": "npm run lint && npm run test && npm run build && ncp .clasp-prod.json .clasp.json && clasp push"
  },
  "dependencies": {
    "@google/clasp": "^2.4.2",
    "@types/google-apps-script": "^1.0.89",
    "@types/jest": "^29.5.14",
    "@typescript-eslint/eslint-plugin": "^8.19.0",
    "eslint": "^8.57.1",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "gts": "^6.0.2",
    "jest": "^29.7.0",
    "license-check-and-add": "^4.0.5",
    "ncp": "^2.0.0",
    "prettier": "^3.4.2",
    "rimraf": "^6.0.1",
    "rollup": "^4.29.1",
    "rollup-plugin-cleanup": "^3.2.1",
    "rollup-plugin-license": "^3.5.3",
    "rollup-plugin-prettier": "^4.1.1",
    "rollup-plugin-typescript2": "^0.36.0",
    "ts-jest": "^29.2.5",
    "typescript": "^5.7.2"
  }
}

このあたりを実行している ASIDE のコード

Yes を選んだときにだけ、以下の部分が実行されるという分岐になっています。

github.com

Powered by はてなブログ