Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corepack strips empty lines from package.json when inserting packageManager #504

Open
msbit opened this issue Jun 17, 2024 · 1 comment
Open

Comments

@msbit
Copy link

msbit commented Jun 17, 2024

If I have a package.json with some empty lines (in this case intentionally), that doesn't specify packageManager, then running a shim (for example yarn install) adds the packageManager attribute but removes the empty lines. I would expect that any existing whitespace in the file would be preserved.

Versions

$ corepack --version
0.28.2
$ node --version
v18.20.2

Reproduction

For example, starting with:

{
  "name": "example",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest",

    "postinstall": "patch-package"
  },
  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.73.8",

    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-native-community/datetimepicker": "8.0.1",
    "@react-native-community/netinfo": "11.3.1",
    "@react-navigation/native": "~6.0.13",
    "@react-navigation/stack": "~6.3.2",
    "Base64": "^1.1.0",
    "deprecated-react-native-prop-types": "~4.1.0",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "rc-swipeout": "~2.0.11",
    "react-native-animatable": "^1.3.3",
    "react-native-blob-util": "~0.18.3",
    "react-native-camera": "~4.2.1",
    "react-native-draggable-flatlist": "~4.0.1",
    "react-native-elements": "~2.1.0",
    "react-native-fs": "~2.18.0",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-image-picker": "2.3.0",
    "react-native-keyboard-aware-scroll-view": "~0.9.5",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-markdown-renderer": "^3.2.8",
    "react-native-modal-selector": "~2.0.9",
    "react-native-orientation-locker": "1.4.0",
    "react-native-pdf": "~6.6.2",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.1",
    "react-native-screens": "3.31.1",
    "react-native-signature-capture": "^0.4.10",
    "react-native-svg": "15.2.0",
    "react-native-svg-charts": "^5.3.0",
    "react-native-table-component": "~1.2.2",
    "react-native-vector-icons": "~9.2.0",
    "react-native-video": "~5.2.1",
    "react-native-webview": "13.8.6",
    "react-redux": "~7.2.9",
    "redux": "^4.0.4",
    "redux-persist": "^6.0.0",
    "redux-persist-filesystem-storage": "~4.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.73.21",
    "@react-native/eslint-config": "0.73.2",
    "@react-native/metro-config": "0.73.5",
    "@react-native/typescript-config": "0.73.1",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4",

    "@babel/plugin-transform-class-properties": "~7.22.5",
    "@babel/plugin-transform-private-methods": "~7.22.5",
    "@testing-library/jest-native": "^5.4.2",
    "@testing-library/react-native": "^7.2.0",
    "babel-eslint": "^10.1.0",
    "eslint-plugin-react": "^7.20.6",
    "eslint-plugin-react-native": "~4.0.0",
    "patch-package": "~7.0.0"
  },
  "engines": {
    "node": ">=18"
  }
}

running:

yarn install

modifies this to:

{
  "name": "example",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest",
    "postinstall": "patch-package"
  },
  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.73.8",
    "@react-native-async-storage/async-storage": "1.23.1",
    "@react-native-community/datetimepicker": "8.0.1",
    "@react-native-community/netinfo": "11.3.1",
    "@react-navigation/native": "~6.0.13",
    "@react-navigation/stack": "~6.3.2",
    "Base64": "^1.1.0",
    "deprecated-react-native-prop-types": "~4.1.0",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "rc-swipeout": "~2.0.11",
    "react-native-animatable": "^1.3.3",
    "react-native-blob-util": "~0.18.3",
    "react-native-camera": "~4.2.1",
    "react-native-draggable-flatlist": "~4.0.1",
    "react-native-elements": "~2.1.0",
    "react-native-fs": "~2.18.0",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-image-picker": "2.3.0",
    "react-native-keyboard-aware-scroll-view": "~0.9.5",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-markdown-renderer": "^3.2.8",
    "react-native-modal-selector": "~2.0.9",
    "react-native-orientation-locker": "1.4.0",
    "react-native-pdf": "~6.6.2",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.1",
    "react-native-screens": "3.31.1",
    "react-native-signature-capture": "^0.4.10",
    "react-native-svg": "15.2.0",
    "react-native-svg-charts": "^5.3.0",
    "react-native-table-component": "~1.2.2",
    "react-native-vector-icons": "~9.2.0",
    "react-native-video": "~5.2.1",
    "react-native-webview": "13.8.6",
    "react-redux": "~7.2.9",
    "redux": "^4.0.4",
    "redux-persist": "^6.0.0",
    "redux-persist-filesystem-storage": "~4.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.73.21",
    "@react-native/eslint-config": "0.73.2",
    "@react-native/metro-config": "0.73.5",
    "@react-native/typescript-config": "0.73.1",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4",
    "@babel/plugin-transform-class-properties": "~7.22.5",
    "@babel/plugin-transform-private-methods": "~7.22.5",
    "@testing-library/jest-native": "^5.4.2",
    "@testing-library/react-native": "^7.2.0",
    "babel-eslint": "^10.1.0",
    "eslint-plugin-react": "^7.20.6",
    "eslint-plugin-react-native": "~4.0.0",
    "patch-package": "~7.0.0"
  },
  "engines": {
    "node": ">=18"
  },
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
@Ruandou
Copy link

Ruandou commented Aug 12, 2024

same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants