Unverified Commit 65f91abe authored by dish's avatar dish Committed by GitHub
Browse files

prettier: don't put anything in package root, and wrap plugins properly (#454726)

parents dcf66dd3 2597cbe7
Loading
Loading
Loading
Loading
+0 −224
Original line number Diff line number Diff line
{
  "name": "prettier",
  "version": "3.6.2",
  "description": "Prettier is an opinionated code formatter",
  "bin": "./bin/prettier.cjs",
  "repository": "prettier/prettier",
  "funding": "https://github.com/prettier/prettier?sponsor=1",
  "homepage": "https://prettier.io",
  "author": "James Long",
  "type": "module",
  "license": "MIT",
  "main": "./src/index.cjs",
  "browser": "./standalone.js",
  "unpkg": "./standalone.js",
  "exports": {
    ".": {
      "types": "./src/index.d.ts",
      "require": "./src/index.cjs",
      "default": "./src/index.js"
    },
    "./standalone": "./src/standalone.js",
    "./plugins/*": "./src/plugins/*.js",
    "./*": "./*"
  },
  "engines": {
    "node": ">=18"
  },
  "files": [
    "index.js",
    "standalone.js",
    "src",
    "bin"
  ],
  "dependencies": {
    "@angular/compiler": "20.0.5",
    "@babel/code-frame": "7.27.1",
    "@babel/parser": "7.27.7",
    "@babel/types": "7.27.7",
    "@glimmer/syntax": "0.94.9",
    "@prettier/cli": "0.9.0",
    "@prettier/html-tags": "1.0.0",
    "@prettier/parse-srcset": "3.1.0",
    "@typescript-eslint/typescript-estree": "8.34.1",
    "@typescript-eslint/visitor-keys": "8.34.1",
    "acorn": "8.15.0",
    "acorn-jsx": "5.3.2",
    "angular-estree-parser": "12.1.0",
    "angular-html-parser": "8.1.0",
    "camelcase": "8.0.0",
    "ci-info": "4.2.0",
    "cjk-regex": "3.3.0",
    "collapse-white-space": "1.0.6",
    "css-units-list": "2.1.0",
    "dashify": "2.0.0",
    "deno-path-from-file-url": "0.0.3",
    "diff": "8.0.2",
    "editorconfig": "0.15.3",
    "emoji-regex": "10.4.0",
    "escape-string-regexp": "5.0.0",
    "espree": "10.4.0",
    "fast-glob": "3.3.3",
    "fast-json-stable-stringify": "2.1.0",
    "file-entry-cache": "10.1.1",
    "find-cache-directory": "6.0.0",
    "flow-parser": "0.274.1",
    "get-east-asian-width": "1.3.0",
    "get-stdin": "9.0.0",
    "graphql": "16.11.0",
    "hermes-parser": "0.29.0",
    "html-element-attributes": "3.4.0",
    "html-ua-styles": "0.0.8",
    "ignore": "7.0.5",
    "import-meta-resolve": "4.1.0",
    "index-to-position": "1.1.0",
    "is-es5-identifier-name": "1.0.0",
    "jest-docblock": "30.0.1",
    "json5": "2.2.3",
    "leven": "4.0.0",
    "linguist-languages": "8.0.0",
    "meriyah": "6.1.3",
    "micromatch": "4.0.8",
    "minimist": "1.2.8",
    "n-readlines": "1.0.1",
    "outdent": "0.8.0",
    "oxc-parser": "0.75.0",
    "parse-json": "8.3.0",
    "picocolors": "1.1.1",
    "please-upgrade-node": "3.2.0",
    "postcss": "8.5.6",
    "postcss-less": "6.0.0",
    "postcss-media-query-parser": "0.2.3",
    "postcss-scss": "4.0.9",
    "postcss-selector-parser": "2.2.3",
    "postcss-values-parser": "2.0.1",
    "regexp-util": "2.0.3",
    "remark-footnotes": "2.0.0",
    "remark-math": "3.0.1",
    "remark-parse": "8.0.3",
    "sdbm": "2.0.0",
    "search-closest": "1.1.0",
    "smol-toml": "1.3.4",
    "strip-ansi": "7.1.0",
    "to-fast-properties": "4.0.0",
    "trim-newlines": "5.0.0",
    "typescript": "5.8.3",
    "unicode-regex": "4.1.2",
    "unified": "9.2.2",
    "url-or-path": "2.6.1",
    "vnopts": "2.0.2",
    "wcwidth.js": "2.0.0",
    "yaml": "1.10.2",
    "yaml-unist-parser": "2.0.5"
  },
  "devDependencies": {
    "@babel/generator": "7.27.5",
    "@eslint-react/eslint-plugin": "1.52.2",
    "@eslint/js": "9.29.0",
    "@stylistic/eslint-plugin": "5.0.0",
    "@types/estree": "1.0.8",
    "@typescript-eslint/eslint-plugin": "8.34.1",
    "@typescript-eslint/parser": "8.34.1",
    "browserslist": "4.25.1",
    "browserslist-to-esbuild": "2.1.1",
    "buffer": "6.0.3",
    "c8": "10.1.3",
    "cross-env": "7.0.3",
    "cspell": "9.1.1",
    "enquirer": "2.4.1",
    "esbuild": "0.25.5",
    "esbuild-plugins-node-modules-polyfill": "1.7.1",
    "esbuild-visualizer": "0.7.0",
    "eslint": "9.29.0",
    "eslint-config-prettier": "10.1.5",
    "eslint-formatter-friendly": "7.0.0",
    "eslint-plugin-compat": "6.0.2",
    "eslint-plugin-jest": "29.0.1",
    "eslint-plugin-n": "17.20.0",
    "eslint-plugin-regexp": "2.9.0",
    "eslint-plugin-simple-import-sort": "12.1.1",
    "eslint-plugin-unicorn": "59.0.1",
    "esm-utils": "4.4.2",
    "globals": "16.2.0",
    "jest": "30.0.3",
    "jest-light-runner": "0.7.9",
    "jest-snapshot-serializer-ansi": "2.2.1",
    "jest-snapshot-serializer-raw": "2.0.0",
    "jest-watch-typeahead": "3.0.1",
    "knip": "5.61.2",
    "magic-string": "0.30.17",
    "nano-spawn": "1.0.2",
    "node-style-text": "0.0.8",
    "npm-run-all2": "8.0.4",
    "prettier": "3.6.1",
    "pretty-bytes": "7.0.0",
    "pretty-ms": "9.2.0",
    "rollup-plugin-license": "3.6.0",
    "semver": "7.7.2",
    "serialize-javascript": "6.0.2",
    "snapshot-diff": "0.10.0",
    "tempy": "3.1.0",
    "tinybench": "4.0.1",
    "ts-expect": "1.3.0"
  },
  "resolutions": {
    "trim": "1.0.1"
  },
  "scripts": {
    "prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
    "test": "jest",
    "test:dev-package": "cross-env INSTALL_PACKAGE=1 yarn test",
    "test:production": "cross-env NODE_ENV=production yarn test",
    "test:production-standalone": "cross-env TEST_STANDALONE=1 yarn test:production",
    "test:production-lint": "eslint dist/prettier --config=./scripts/bundle-eslint-config.js --quiet --format friendly",
    "perf": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/prettier/bin/prettier.cjs",
    "perf:inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/prettier/bin/prettier.cjs",
    "perf:benchmark": "yarn perf --debug-benchmark",
    "perf:compare": "./scripts/benchmark/compare.sh",
    "lint": "run-p --continue-on-error \"lint:*\"",
    "lint:typecheck": "tsc",
    "lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
    "lint:changelog": "node ./scripts/lint-changelog.js",
    "lint:prettier": "prettier . --check --cache",
    "lint:spellcheck": "cspell --no-progress --relative --dot --gitignore",
    "lint:deps": "node ./scripts/check-deps.js",
    "lint:knip": "knip",
    "lint:format-test": "node ./scripts/format-test-lint.js",
    "fix": "run-s --continue-on-error fix:eslint fix:prettier",
    "fix:eslint": "yarn lint:eslint --fix",
    "fix:prettier": "yarn lint:prettier --write",
    "build": "node ./scripts/build/build.js",
    "build:website": "node ./scripts/build-website.js",
    "gen:changelog": "node ./scripts/generate-changelog.js",
    "debug": "node bin/prettier.js --ignore-path=.prettierignore --plugin=./packages/plugin-oxc/index.js --plugin=./packages/plugin-hermes/index.js",
    "debug:watch": "node --watch bin/prettier.js --ignore-path=.prettierignore --plugin=./packages/plugin-oxc/index.js --plugin=./packages/plugin-hermes/index.js",
    "debug:inspect": "node --inspect-brk bin/prettier.js --ignore-path=.prettierignore --plugin=./packages/plugin-oxc/index.js --plugin=./packages/plugin-hermes/index.js"
  },
  "c8": {
    "reporter": [
      "lcov",
      "text"
    ],
    "all": true,
    "include": [
      "src/**",
      "bin/**"
    ],
    "exclude": [
      "bin/prettier.js",
      "src/standalone.js",
      "src/index.cjs",
      "src/document/debug.js",
      "src/utils/unexpected-node-error.js",
      "src/language-js/types/estree.d.ts",
      "src/**/**/*.d.ts"
    ]
  },
  "browserslist": [
    ">0.5%",
    "not dead",
    "not op_mini all"
  ],
  "preferUnplugged": true,
  "packageManager": "yarn@4.9.2"
}
+7 −6
Original line number Diff line number Diff line
@@ -98,12 +98,12 @@ let
    # Arguments

    plugin
    : Attribute set with `.packageName` and `.outPath` defined
    : Attribute set with `.pname` and `.outPath` defined
  */
  nodeEntryPointOf =
    plugin:
    let
      pluginDir = "${plugin.outPath}/lib/node_modules/${plugin.packageName}";
      pluginDir = "${plugin.outPath}/lib/node_modules/${plugin.pname}";

      packageJsonAttrs = builtins.fromJSON (builtins.readFile "${pluginDir}/package.json");

@@ -118,10 +118,10 @@ let
      pathAbsoluteFallback
    else
      lib.warn ''
        ${plugin.packageName}: error context, tried finding entry point under;
        ${plugin.pname}: error context, tried finding entry point under;
        pathAbsoluteNaive -> ${pathAbsoluteNaive}
        pathAbsoluteFallback -> ${pathAbsoluteFallback}
      '' throw ''${plugin.packageName}: does not provide parse-able entry point'';
      '' throw ''${plugin.pname}: does not provide parse-able entry point'';
in
stdenv.mkDerivation (finalAttrs: {
  pname = "prettier";
@@ -153,10 +153,11 @@ stdenv.mkDerivation (finalAttrs: {
    yarn install --immutable
    yarn build --clean

    cp --recursive dist/prettier "$out"
    mkdir -p $out/lib/node_modules
    cp --recursive dist/prettier "$out/lib/node_modules/prettier"

    makeBinaryWrapper "${lib.getExe nodejs}" "$out/bin/prettier" \
      --add-flags "$out/bin/prettier.cjs"
      --add-flags "$out/lib/node_modules/prettier/bin/prettier.cjs"
  ''
  + lib.optionalString (builtins.length plugins > 0) ''
    wrapProgram $out/bin/prettier --add-flags "${
+1 −0
Original line number Diff line number Diff line
@@ -45,3 +45,4 @@ update-source-version "${package}" "${latest_version}"
echo "Update yarn offline cache hash…"
nix-build --attr "${package}.src"
yarn-berry-fetcher missing-hashes result/yarn.lock >"${package_dir}/missing-hashes.json"
rm -f "${package_dir}/package.json"