Skip to content

Commit d96e735

Browse files
authored
postcss-preset-env v10 (#1369)
1 parent 697a54d commit d96e735

File tree

875 files changed

+3997
-5926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

875 files changed

+3997
-5926
lines changed

.github/bin/detect-executable-files/to-github-annotations.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs';
1+
import fs from 'node:fs';
22
const data = fs.readFileSync(0, 'utf-8');
33
let fileNames = data.split(/\r?\n/);
44

.github/bin/format-package-json.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
33

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

7777
formatted.engines = {
78-
node: '^14 || ^16 || >=18',
78+
node: '>=18',
7979
};
8080
delete packageJSONInfo.engines;
8181

.github/bin/generate-docs/api-documenter.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
3-
import path from 'path';
4-
import fs from 'fs';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
3+
import path from 'node:path';
4+
import fs from 'node:fs';
55
import { getFiles } from '../util/get-files.mjs';
66

77
const packageJSONInfo = JSON.parse(fs.readFileSync('./package.json', 'utf8'));

.github/bin/generate-docs/install.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import fs from 'fs';
2-
import path from 'path';
3-
import { fileURLToPath } from 'url';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
44
import { parallelBuildsNotice } from './parallel-builds-notice.mjs';
55

66
const template = fs.readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), './install-template.md'), 'utf8');

.github/bin/generate-docs/readme.mjs

+40-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import fs from 'fs';
2-
import path from 'path';
3-
import { fileURLToPath } from 'url';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import process from 'node:process';
5+
46
import { parallelBuildsNotice } from './parallel-builds-notice.mjs';
57

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

4547
// Insert "Header" section
46-
readmeDoc = readmeDoc.replace('<header>', `# <humanReadableName> [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
48+
function headerText() {
49+
const baselineBadge = packageJSONInfo.csstools?.cssdbId ?
50+
'<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/<cssdbId>.svg" height="20">][css-url] ' :
51+
'';
52+
53+
const cssdbBadge = packageJSONInfo.csstools?.cssdbId ?
54+
'[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/<cssdbId>.svg" height="20">][css-url] ' :
55+
'';
56+
57+
if (process.env.MINIMAL) {
58+
return `# <humanReadableName> [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
59+
60+
\`\`\`bash
61+
npm install <packageName> --save-dev
62+
\`\`\``;
63+
}
64+
65+
return `# <humanReadableName> [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
4766
4867
` +
4968
'[<img alt="npm version" src="https://img.shields.io/npm/v/<packageName>.svg" height="20">][npm-url] ' +
5069
'[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] ' +
5170
'[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]' +
52-
`${packageJSONInfo.csstools?.cssdbId ?
53-
'<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/<cssdbId>.svg" height="20">][css-url] ' :
54-
''
55-
}` +
56-
`${packageJSONInfo.csstools?.cssdbId ?
57-
'[<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/<cssdbId>.svg" height="20">][css-url] ' :
58-
''
59-
}` +
71+
baselineBadge +
72+
cssdbBadge +
6073
`\n
6174
\`\`\`bash
6275
npm install <packageName> --save-dev
63-
\`\`\``,
64-
);
76+
\`\`\``;
77+
}
78+
79+
readmeDoc = readmeDoc.replace('<header>', headerText());
6580

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

86-
// Insert "Env Support" section
87-
readmeDoc = readmeDoc.replace('<envSupport>', `[<humanReadableName>] runs in all Node environments, with special
101+
function envSupport() {
102+
if (process.env.MINIMAL) {
103+
return '';
104+
}
105+
106+
return `[<humanReadableName>] runs in all Node environments, with special
88107
instructions for:
89108
90109
- [Node](INSTALL.md#node)
@@ -93,7 +112,11 @@ instructions for:
93112
- [Webpack](INSTALL.md#webpack)
94113
- [Next.js](INSTALL.md#nextjs)
95114
- [Gulp](INSTALL.md#gulp)
96-
- [Grunt](INSTALL.md#grunt)`);
115+
- [Grunt](INSTALL.md#grunt)`;
116+
}
117+
118+
// Insert "Env Support" section
119+
readmeDoc = readmeDoc.replace('<envSupport>', envSupport());
97120

98121
// Insert "Link List" section
99122
readmeDoc = readmeDoc.replace('<linkList>', `[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test

.github/bin/license/check-license.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from 'path';
2-
import fs from 'fs';
1+
import path from 'node:path';
2+
import fs from 'node:fs';
33
import { getFiles } from '../util/get-files.mjs';
44
import { parseLicenseField } from './parse-license-field.mjs';
55
import { licenseIsOkByException, missingLicenseIsOkByException, osiApprovedWithCCO } from './allowed.mjs';

.github/bin/list-workspaces/list-workspaces.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import path from 'path';
1+
import path from 'node:path';
22
import { getFiles } from '../util/get-files.mjs';
3-
import fs, { promises as fsp } from 'fs';
3+
import fs from 'node:fs';
44
import { toposort } from '../util/toposort.mjs';
55

66
export async function listWorkspaces() {
77
try {
8-
const rootPackageJSON = JSON.parse(await fsp.readFile('package.json'));
8+
const rootPackageJSON = JSON.parse(await fs.promises.readFile('package.json'));
99
const workspaces = rootPackageJSON.workspaces;
1010

1111
const packages = new Set();
@@ -33,7 +33,7 @@ export async function listWorkspaces() {
3333
const result = [];
3434

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

3939
result.push({

.github/bin/modified-workspaces/list-modified-files.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import https from 'https';
1+
import https from 'node:https';
22

33
export async function listModifiedFilesInPullRequest(repository, pullRequestNumber) {
44
const allFiles = [];

.github/bin/modified-workspaces/log-modified-workspaces.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { listModifiedWorkspaces } from './modified-workspaces.mjs';
2-
import { promises as fsp } from 'fs';
2+
import fs from 'node:fs/promises';
33

44
const modifiedWorkspaces = await listModifiedWorkspaces();
55

@@ -27,7 +27,7 @@ if (process.env.GITHUB_STEP_SUMMARY) {
2727
`;
2828
}
2929

30-
await fsp.appendFile(
30+
await fs.appendFile(
3131
process.env.GITHUB_STEP_SUMMARY,
3232
summary,
3333
);

.github/bin/modified-workspaces/modified-workspaces.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { listModifiedFilesInPullRequest } from './list-modified-files.mjs';
22
import { listWorkspaces } from '../list-workspaces/list-workspaces.mjs';
3-
import path from 'path';
3+
import path from 'node:path';
44

55
const internalDependencies = [
66
path.relative(process.cwd(), path.resolve('.github')),

.github/bin/new-plugin.mjs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { promises as fsp } from 'fs';
2-
import path from 'path';
1+
import fs from 'node:fs/promises';
2+
import path from 'node:path';
33

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

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

3434
// Copy base plugin
3535
{
36-
await fsp.rm(pluginDir, { recursive: true, force: true });
37-
await fsp.cp(basePluginDir, pluginDir, { recursive: true });
36+
await fs.rm(pluginDir, { recursive: true, force: true });
37+
await fs.cp(basePluginDir, pluginDir, { recursive: true });
3838

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

4242
// Remove unnecessary files
4343
{
44-
await fsp.rm(path.join(pluginDir, 'dist'), { recursive: true, force: true });
45-
await fsp.rm(path.join(pluginDir, 'node_modules'), { recursive: true, force: true });
44+
await fs.rm(path.join(pluginDir, 'dist'), { recursive: true, force: true });
45+
await fs.rm(path.join(pluginDir, 'node_modules'), { recursive: true, force: true });
4646

4747
console.log('- Cleaned up files and directories not required in a new plugin');
4848
}
@@ -55,7 +55,7 @@ console.log(`- Creating new plugin ${pluginName}`);
5555
await replaceBasePluginReferencesForFilePath(path.join(pluginDir, 'test', '_tape.mjs'));
5656
await replaceBasePluginReferencesForFilePath(path.join(pluginDir, 'README.md'));
5757
await replaceBasePluginReferencesForFilePath(path.join(pluginDir, 'INSTALL.md'));
58-
await fsp.writeFile(
58+
await fs.writeFile(
5959
path.join(pluginDir, 'CHANGELOG.md'),
6060
`# Changes to PostCSS ${pluginName}
6161
@@ -70,7 +70,7 @@ console.log(`- Creating new plugin ${pluginName}`);
7070

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

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

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

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

105105
// Helpers
106106
async function replaceBasePluginReferencesForFilePath(filePath) {
107-
await fsp.writeFile(
107+
await fs.writeFile(
108108
filePath,
109109
replaceBasePluginReferences(
110-
(await fsp.readFile(filePath, 'utf8')).toString(),
110+
(await fs.readFile(filePath, 'utf8')).toString(),
111111
),
112112
);
113113
}

.github/bin/release-plan/commit.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { spawn } from 'child_process';
1+
import { spawn } from 'node:child_process';
22

33
export async function commitSingleDirectory(commitMessage, dir) {
44
await new Promise((resolve, reject) => {

.github/bin/release-plan/current-version.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from 'fs/promises';
2-
import path from 'path';
1+
import fs from 'node:fs/promises';
2+
import path from 'node:path';
33

44
export async function currentVersion(packageDirectory) {
55
return JSON.parse(await fs.readFile(path.join(packageDirectory, 'package.json'))).version;

.github/bin/release-plan/docs.mjs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
33

4-
export async function updateDocumentation(packageDirectory) {
4+
export async function updateDocumentation(packageDirectory, minimal = false) {
55
await new Promise((resolve, reject) => {
66
const docsCmd = spawn(
77
'npm',
@@ -11,6 +11,10 @@ export async function updateDocumentation(packageDirectory) {
1111
'--if-present',
1212
],
1313
{
14+
env: {
15+
...process.env,
16+
MINIMAL: minimal ? 'true': null,
17+
},
1418
cwd: packageDirectory,
1519
shell: platform === 'win32',
1620
},

.github/bin/release-plan/minify-changelog-and-package-json.mjs renamed to .github/bin/release-plan/minify-context-files.mjs

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import fs from 'fs/promises';
2-
import path from 'path';
1+
import fs from 'node:fs/promises';
2+
import path from 'node:path';
3+
import { updateDocumentation } from './docs.mjs';
34

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

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

2324
// CHANGELOG.md
2425
// - remove some older entries
25-
// - keep the last 3 entries
26+
// - keep the last 2 entries
2627
// - add a link to the full changelog
2728
{
2829
let headingIndex = -1;
29-
for (let i = 0; i < 4; i++) {
30+
for (let i = 0; i < 2; i++) {
3031
headingIndex = minifiedChangelog.indexOf('\n### ', headingIndex + 1);
3132

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

50+
// Render a smaller `README.md` file
51+
await updateDocumentation(workspace.path, true);
52+
4953
return async () => {
5054
await fs.writeFile(path.join(workspace.path, 'package.json'), JSON.stringify(originalPackageInfo, null, '\t') + '\n');
5155
await fs.writeFile(path.join(workspace.path, 'CHANGELOG.md'), originalChangelog);
56+
57+
// Render the full `README.md` file
58+
await updateDocumentation(workspace.path);
5259
};
5360
}

.github/bin/release-plan/npm-can-publish.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
33

44
export async function canPublish(packageName, myName) {
55
return new Promise((resolve, reject) => {

.github/bin/release-plan/npm-install.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
33

44
export async function npmInstall() {
55
await new Promise((resolve, reject) => {

.github/bin/release-plan/npm-prepublish-scripts.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
33

44
export async function npmPrepublishScripts(packageDirectory, packageName) {
55
await new Promise((resolve, reject) => {

.github/bin/release-plan/npm-publish.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
33

44
export async function npmPublish(packageDirectory, packageName) {
55
await new Promise((resolve, reject) => {

.github/bin/release-plan/npm-version.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
3-
import fs from 'fs/promises';
4-
import path from 'path';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
3+
import fs from 'node:fs/promises';
4+
import path from 'node:path';
55

66
export async function npmVersion(increment, packageDirectory) {
77
{

.github/bin/release-plan/npm-whoami.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { spawn } from 'child_process';
2-
import { platform } from 'process';
1+
import { spawn } from 'node:child_process';
2+
import { platform } from 'node:process';
33

44
export async function whoami() {
55
return await new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)