Skip to content

Change PostCSS version strategy #471

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/bin/format-package-json.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
import { promises as fsp, constants } from 'fs';
import path from 'path';

async function postcssPeerDependencyVersion() {
// "postcss-tape" is our reference for PostCSS versions.
// This package is our test suite.
// If CI passes it means the plugin is compatible with the lower version in "postcss-tape".
const packageJSONInfoForPostCSS_Tape = JSON.parse(await fsp.readFile('../../packages/postcss-tape/package.json', 'utf8'));

// "postcss-tape" package.json:
//
// "dependencies": {
// "postcss": "~8.4",
// "postcss-8.2": "npm:postcss@~8.2"
// }
//
const lowerPostCSS_VersionKey = Object.keys(packageJSONInfoForPostCSS_Tape.dependencies).find((x) => {
return x.startsWith('postcss-') && packageJSONInfoForPostCSS_Tape.dependencies[x].includes('npm:postcss@~');
});

const lowerPostCSS_Version = packageJSONInfoForPostCSS_Tape.dependencies[lowerPostCSS_VersionKey];

// "npm:postcss@~8.2" -> "8.2"
return lowerPostCSS_Version.split('~')[1];
}

const packageJSONInfo = JSON.parse(await fsp.readFile('./package.json', 'utf8'));
const packageJSONInfoCopy = JSON.stringify(packageJSONInfo, null, '\t');
const formatted = {};
Expand Down Expand Up @@ -98,6 +121,10 @@ const formatted = {};
formatted.peerDependencies[dependencyKeys[i]] = packageJSONInfo.peerDependencies[dependencyKeys[i]];
}
delete packageJSONInfo.peerDependencies;

if (formatted.peerDependencies['postcss']) {
formatted.peerDependencies['postcss'] = '^' + (await postcssPeerDependencyVersion());
}
}

if (Object.keys(packageJSONInfo.devDependencies ?? {}).length) {
Expand Down
31 changes: 29 additions & 2 deletions UPDATING_POSTCSS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,40 @@

see : `packages/postcss-tape/package.json`

Set the `postcss` version to match the peer dependency of all plugins.<br>
Set the `postcss-oldest-supported` depending on community needs. This can be the same as the `postcss` version.
```js
"dependencies": {
// most recent version
"postcss": "~8.4",
// oldest supported
"postcss-8.2": "npm:postcss@~8.2"
},
```

## updating

- only update `postcss-tape`
- run `npm run lint` from the root

This will update the peer dependency version for PostCSS in all packages and plugins.

## most recent version

- kept up to date
- only used in CI to catch regressions

## oldest supported

- used as the peer dependency version in all plugins and packages
- updated based on community needs
- can be the same as the **most recent version** version

## semver flags

- Plugins use `^MAJOR.MINOR`.
- PostCSS Tape uses `~MAJOR.MINOR`.

## notes

Avoid increasing these versions when possible.

Major version updates are also always a breaking change.
2 changes: 1 addition & 1 deletion experimental/css-has-pseudo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"postcss-selector-parser": "^6.0.10"
},
"peerDependencies": {
"postcss": "^8.3"
"postcss": "^8.2"
},
"devDependencies": {
"@mrhenry/core-web": "^0.7.2",
Expand Down
Loading