Skip to content

postcss-preset-env v10 #1369

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
merged 32 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2a8eabe
remove outdated internal logic
romainmenke Apr 20, 2024
d7a6de9
make node 18 the lowest supported version (#1371)
romainmenke Apr 21, 2024
b16726d
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke Apr 21, 2024
086320b
`postcss-nesting`: make edition `2024-02` the default (#1370)
romainmenke May 5, 2024
734298c
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke May 5, 2024
35fe3d2
add compilation cache
romainmenke May 5, 2024
b228ed0
fix
romainmenke May 5, 2024
592dafc
tweak
romainmenke May 5, 2024
e023769
tweak
romainmenke May 5, 2024
f292aba
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke May 10, 2024
af2be38
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke May 10, 2024
d8ffe76
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke May 11, 2024
a48a2a3
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke Jun 29, 2024
2c94f1a
fix
romainmenke Jun 29, 2024
88414c3
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke Jul 7, 2024
7a9ba3e
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke Jul 13, 2024
e5d4fa7
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke Jul 13, 2024
79d386c
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke Jul 13, 2024
63a7625
Merge remote-tracking branch 'origin/main' into v10--gregarious-seaho…
romainmenke Jul 29, 2024
ac08993
fix
romainmenke Jul 30, 2024
05901b4
tweak
romainmenke Jul 30, 2024
9eb1e96
fix
romainmenke Jul 30, 2024
411c4a5
update dependencies
romainmenke Jul 30, 2024
d5a2907
generate smaller npm artifacts
romainmenke Aug 2, 2024
8bfd753
update dependencies
romainmenke Aug 2, 2024
b5974e9
fix
romainmenke Aug 2, 2024
47686bd
fix
romainmenke Aug 2, 2024
e88d179
optimize color helpers
romainmenke Aug 3, 2024
d452f97
lint
romainmenke Aug 3, 2024
4a45411
add wiki link
romainmenke Aug 3, 2024
a00c4b7
update results
romainmenke Aug 3, 2024
faf2582
improve performance (#1448)
romainmenke Aug 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import fs from 'node:fs';
const data = fs.readFileSync(0, 'utf-8');
let fileNames = data.split(/\r?\n/);

Expand Down
6 changes: 3 additions & 3 deletions .github/bin/format-package-json.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';

function postcssPeerDependencyVersion() {
// "postcss-tape" is our reference for PostCSS versions.
Expand Down Expand Up @@ -75,7 +75,7 @@ const formatted = {};
delete packageJSONInfo.private;

formatted.engines = {
node: '^14 || ^16 || >=18',
node: '>=18',
};
delete packageJSONInfo.engines;

Expand Down
8 changes: 4 additions & 4 deletions .github/bin/generate-docs/api-documenter.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import path from 'path';
import fs from 'fs';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';
import path from 'node:path';
import fs from 'node:fs';
import { getFiles } from '../util/get-files.mjs';

const packageJSONInfo = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
Expand Down
6 changes: 3 additions & 3 deletions .github/bin/generate-docs/install.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { parallelBuildsNotice } from './parallel-builds-notice.mjs';

const template = fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), './install-template.md'), 'utf8');
Expand Down
57 changes: 40 additions & 17 deletions .github/bin/generate-docs/readme.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import process from 'node:process';

import { parallelBuildsNotice } from './parallel-builds-notice.mjs';

const template = fs.readFileSync(path.join('docs', './README.md'), 'utf8');
Expand Down Expand Up @@ -43,25 +45,38 @@ readmeDoc = readmeDoc.replace(`<!-- Available Variables: -->
readmeDoc = readmeDoc.replaceAll('<corsWarning>', corsTemplate);

// Insert "Header" section
readmeDoc = readmeDoc.replace('<header>', `# <humanReadableName> [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
function headerText() {
const baselineBadge = packageJSONInfo.csstools?.cssdbId ?
'<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/<cssdbId>.svg" height="20">][css-url] ' :
'';

const cssdbBadge = packageJSONInfo.csstools?.cssdbId ?
'[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/<cssdbId>.svg" height="20">][css-url] ' :
'';

if (process.env.MINIMAL) {
return `# <humanReadableName> [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]

\`\`\`bash
npm install <packageName> --save-dev
\`\`\``;
}

return `# <humanReadableName> [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]

` +
'[<img alt="npm version" src="https://img.shields.io/npm/v/<packageName>.svg" height="20">][npm-url] ' +
'[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] ' +
'[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]' +
`${packageJSONInfo.csstools?.cssdbId ?
'<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/<cssdbId>.svg" height="20">][css-url] ' :
''
}` +
`${packageJSONInfo.csstools?.cssdbId ?
'[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/<cssdbId>.svg" height="20">][css-url] ' :
''
}` +
baselineBadge +
cssdbBadge +
`\n
\`\`\`bash
npm install <packageName> --save-dev
\`\`\``,
);
\`\`\``;
}

readmeDoc = readmeDoc.replace('<header>', headerText());

// Insert "Usage" section
readmeDoc = readmeDoc.replace('<usage>', `## Usage
Expand All @@ -83,8 +98,12 @@ postcss([
]).process(YOUR_CSS /*, processOptions */);
\`\`\``);

// Insert "Env Support" section
readmeDoc = readmeDoc.replace('<envSupport>', `[<humanReadableName>] runs in all Node environments, with special
function envSupport() {
if (process.env.MINIMAL) {
return '';
}

return `[<humanReadableName>] runs in all Node environments, with special
instructions for:

- [Node](INSTALL.md#node)
Expand All @@ -93,7 +112,11 @@ instructions for:
- [Webpack](INSTALL.md#webpack)
- [Next.js](INSTALL.md#nextjs)
- [Gulp](INSTALL.md#gulp)
- [Grunt](INSTALL.md#grunt)`);
- [Grunt](INSTALL.md#grunt)`;
}

// Insert "Env Support" section
readmeDoc = readmeDoc.replace('<envSupport>', envSupport());

// Insert "Link List" section
readmeDoc = readmeDoc.replace('<linkList>', `[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
Expand Down
4 changes: 2 additions & 2 deletions .github/bin/license/check-license.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import fs from 'fs';
import path from 'node:path';
import fs from 'node:fs';
import { getFiles } from '../util/get-files.mjs';
import { parseLicenseField } from './parse-license-field.mjs';
import { licenseIsOkByException, missingLicenseIsOkByException, osiApprovedWithCCO } from './allowed.mjs';
Expand Down
8 changes: 4 additions & 4 deletions .github/bin/list-workspaces/list-workspaces.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'path';
import path from 'node:path';
import { getFiles } from '../util/get-files.mjs';
import fs, { promises as fsp } from 'fs';
import fs from 'node:fs';
import { toposort } from '../util/toposort.mjs';

export async function listWorkspaces() {
try {
const rootPackageJSON = JSON.parse(await fsp.readFile('package.json'));
const rootPackageJSON = JSON.parse(await fs.promises.readFile('package.json'));
const workspaces = rootPackageJSON.workspaces;

const packages = new Set();
Expand Down Expand Up @@ -33,7 +33,7 @@ export async function listWorkspaces() {
const result = [];

for (const packageJSONPath of Array.from(packages)) {
const packageJSON = JSON.parse(await fsp.readFile(packageJSONPath));
const packageJSON = JSON.parse(await fs.promises.readFile(packageJSONPath));
const packagePath = path.relative(process.cwd(), path.dirname(packageJSONPath));

result.push({
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/modified-workspaces/list-modified-files.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import https from 'https';
import https from 'node:https';

export async function listModifiedFilesInPullRequest(repository, pullRequestNumber) {
const allFiles = [];
Expand Down
4 changes: 2 additions & 2 deletions .github/bin/modified-workspaces/log-modified-workspaces.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { listModifiedWorkspaces } from './modified-workspaces.mjs';
import { promises as fsp } from 'fs';
import fs from 'node:fs/promises';

const modifiedWorkspaces = await listModifiedWorkspaces();

Expand Down Expand Up @@ -27,7 +27,7 @@ if (process.env.GITHUB_STEP_SUMMARY) {
`;
}

await fsp.appendFile(
await fs.appendFile(
process.env.GITHUB_STEP_SUMMARY,
summary,
);
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/modified-workspaces/modified-workspaces.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { listModifiedFilesInPullRequest } from './list-modified-files.mjs';
import { listWorkspaces } from '../list-workspaces/list-workspaces.mjs';
import path from 'path';
import path from 'node:path';

const internalDependencies = [
path.relative(process.cwd(), path.resolve('.github')),
Expand Down
22 changes: 11 additions & 11 deletions .github/bin/new-plugin.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { promises as fsp } from 'fs';
import path from 'path';
import fs from 'node:fs/promises';
import path from 'node:path';

const pluginName = process.argv.slice(2).join(' ');

Expand Down Expand Up @@ -33,16 +33,16 @@ console.log(`- Creating new plugin ${pluginName}`);

// Copy base plugin
{
await fsp.rm(pluginDir, { recursive: true, force: true });
await fsp.cp(basePluginDir, pluginDir, { recursive: true });
await fs.rm(pluginDir, { recursive: true, force: true });
await fs.cp(basePluginDir, pluginDir, { recursive: true });

console.log('- Copied base plugin to', pluginDir);
}

// Remove unnecessary files
{
await fsp.rm(path.join(pluginDir, 'dist'), { recursive: true, force: true });
await fsp.rm(path.join(pluginDir, 'node_modules'), { recursive: true, force: true });
await fs.rm(path.join(pluginDir, 'dist'), { recursive: true, force: true });
await fs.rm(path.join(pluginDir, 'node_modules'), { recursive: true, force: true });

console.log('- Cleaned up files and directories not required in a new plugin');
}
Expand All @@ -55,7 +55,7 @@ console.log(`- Creating new plugin ${pluginName}`);
await replaceBasePluginReferencesForFilePath(path.join(pluginDir, 'test', '_tape.mjs'));
await replaceBasePluginReferencesForFilePath(path.join(pluginDir, 'README.md'));
await replaceBasePluginReferencesForFilePath(path.join(pluginDir, 'INSTALL.md'));
await fsp.writeFile(
await fs.writeFile(
path.join(pluginDir, 'CHANGELOG.md'),
`# Changes to PostCSS ${pluginName}

Expand All @@ -70,7 +70,7 @@ console.log(`- Creating new plugin ${pluginName}`);

// Update package.json
{
const packageInfo = JSON.parse(await fsp.readFile(path.join(pluginDir, 'package.json'), 'utf8'));
const packageInfo = JSON.parse(await fs.readFile(path.join(pluginDir, 'package.json'), 'utf8'));
packageInfo.name = packageName;
packageInfo.description = `TODO: Add description for ${pluginName}`;
packageInfo.version = '0.0.0';
Expand All @@ -83,7 +83,7 @@ console.log(`- Creating new plugin ${pluginName}`);

packageInfo.repository.directory = `plugins/${pluginSlug}`;

await fsp.writeFile(path.join(pluginDir, 'package.json'), JSON.stringify(packageInfo, null, '\t'));
await fs.writeFile(path.join(pluginDir, 'package.json'), JSON.stringify(packageInfo, null, '\t'));

console.log('- Updated "package.json"');
}
Expand All @@ -104,10 +104,10 @@ console.log('\nDone! 🎉');

// Helpers
async function replaceBasePluginReferencesForFilePath(filePath) {
await fsp.writeFile(
await fs.writeFile(
filePath,
replaceBasePluginReferences(
(await fsp.readFile(filePath, 'utf8')).toString(),
(await fs.readFile(filePath, 'utf8')).toString(),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion .github/bin/release-plan/commit.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn } from 'child_process';
import { spawn } from 'node:child_process';

export async function commitSingleDirectory(commitMessage, dir) {
await new Promise((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions .github/bin/release-plan/current-version.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs/promises';
import path from 'path';
import fs from 'node:fs/promises';
import path from 'node:path';

export async function currentVersion(packageDirectory) {
return JSON.parse(await fs.readFile(path.join(packageDirectory, 'package.json'))).version;
Expand Down
10 changes: 7 additions & 3 deletions .github/bin/release-plan/docs.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';

export async function updateDocumentation(packageDirectory) {
export async function updateDocumentation(packageDirectory, minimal = false) {
await new Promise((resolve, reject) => {
const docsCmd = spawn(
'npm',
Expand All @@ -11,6 +11,10 @@ export async function updateDocumentation(packageDirectory) {
'--if-present',
],
{
env: {
...process.env,
MINIMAL: minimal ? 'true': null,
},
cwd: packageDirectory,
shell: platform === 'win32',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from 'fs/promises';
import path from 'path';
import fs from 'node:fs/promises';
import path from 'node:path';
import { updateDocumentation } from './docs.mjs';

export async function minifyChangelogAndPackageJSON(workspace) {
export async function minifyContextFiles(workspace) {
const originalPackageInfo = JSON.parse(await fs.readFile(path.join(workspace.path, 'package.json')));
const originalChangelog = (await fs.readFile(path.join(workspace.path, 'CHANGELOG.md'))).toString();

Expand All @@ -22,11 +23,11 @@ export async function minifyChangelogAndPackageJSON(workspace) {

// CHANGELOG.md
// - remove some older entries
// - keep the last 3 entries
// - keep the last 2 entries
// - add a link to the full changelog
{
let headingIndex = -1;
for (let i = 0; i < 4; i++) {
for (let i = 0; i < 2; i++) {
headingIndex = minifiedChangelog.indexOf('\n### ', headingIndex + 1);

if (headingIndex === -1) {
Expand All @@ -46,8 +47,14 @@ export async function minifyChangelogAndPackageJSON(workspace) {
await fs.writeFile(path.join(workspace.path, 'package.json'), JSON.stringify(minifiedPackageInfo, null, '\t') + '\n');
await fs.writeFile(path.join(workspace.path, 'CHANGELOG.md'), minifiedChangelog);

// Render a smaller `README.md` file
await updateDocumentation(workspace.path, true);

return async () => {
await fs.writeFile(path.join(workspace.path, 'package.json'), JSON.stringify(originalPackageInfo, null, '\t') + '\n');
await fs.writeFile(path.join(workspace.path, 'CHANGELOG.md'), originalChangelog);

// Render the full `README.md` file
await updateDocumentation(workspace.path);
};
}
4 changes: 2 additions & 2 deletions .github/bin/release-plan/npm-can-publish.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';

export async function canPublish(packageName, myName) {
return new Promise((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions .github/bin/release-plan/npm-install.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';

export async function npmInstall() {
await new Promise((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions .github/bin/release-plan/npm-prepublish-scripts.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';

export async function npmPrepublishScripts(packageDirectory, packageName) {
await new Promise((resolve, reject) => {
Expand Down
4 changes: 2 additions & 2 deletions .github/bin/release-plan/npm-publish.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';

export async function npmPublish(packageDirectory, packageName) {
await new Promise((resolve, reject) => {
Expand Down
8 changes: 4 additions & 4 deletions .github/bin/release-plan/npm-version.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import fs from 'fs/promises';
import path from 'path';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';
import fs from 'node:fs/promises';
import path from 'node:path';

export async function npmVersion(increment, packageDirectory) {
{
Expand Down
4 changes: 2 additions & 2 deletions .github/bin/release-plan/npm-whoami.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawn } from 'child_process';
import { platform } from 'process';
import { spawn } from 'node:child_process';
import { platform } from 'node:process';

export async function whoami() {
return await new Promise((resolve, reject) => {
Expand Down
Loading