Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3e7146

Browse files
authored
postcss-preset-env: add @csstools/postcss-contrast-color-function (#1688)
1 parent 67963ea commit e3e7146

Some content is hidden

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

48 files changed

+345
-196
lines changed

package-lock.json

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/pack-test/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Unreleased (patch)
44

55
- Use `--engine-strict=false` when testing `npm install`
6+
- Use `--ignore-scripts` when testing `npm install`
67

78
### 1.0.1
89

packages/pack-test/dist/index.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"use strict";var e=require("node:url"),n=require("node:fs/promises"),t=require("node:path"),i=require("node:os"),o=require("node:process"),a=require("node:child_process"),r="undefined"!=typeof document?document.currentScript:null;const s="package";async function findPackageJsonFromDir(e,i=10){const o=t.join(e,"package.json");try{return await n.access(o),o}catch{if("/"===e||i<=0)throw new Error("Could not find package.json")}return findPackageJsonFromDir(t.dirname(e),i-1)}async function pack(e,i){const r=await n.mkdir(t.join(i,"pack"),{recursive:!0}),s=a.spawn("npm",["pack","--pack-destination",r],{cwd:e,shell:"win32"===o.platform}),c=await new Promise((e,n)=>{let t="",i="";s.stdout.on("data",e=>{t+=e.toString()}),s.stderr.on("data",e=>{i+=e.toString()}),s.on("close",o=>{0===o?e(t.trim()):(console.error(i),n(new Error(`npm pack exited with code ${o}`)))})});return t.join(r,c)}async function unpack(e,i){const o=t.join(i,s);await n.mkdir(o,{recursive:!0});const r=a.spawn("tar",["-xf",e,"-C",s,"--strip-components","1"],{cwd:i});return await new Promise((e,n)=>{r.on("close",t=>{0===t?e():n(new Error(`tar exited with code ${t}`))})}),o}async function eraseDevDependenciesInfo(e){const t=JSON.parse(await n.readFile(e,"utf8"));delete t.devDependencies,await n.writeFile(e,JSON.stringify(t,null,"\t"))}async function getPackageInfo(e){return JSON.parse(await n.readFile(e,"utf8"))}async function createRootPackage(e,i){await n.writeFile(t.join(e,"package.json"),JSON.stringify({name:"@csstools/pack-test--root",private:!0,type:"module",version:"1.0.0",description:"",workspaces:[s],dependencies:i.peerDependencies??{},scripts:{test:"node --test"}},null,"\t")),await n.writeFile(t.join(e,"index.mjs"),`import '${i.name}';`)}async function runNPMInstall(e){const n=a.spawn("npm",["install","--omit","dev","--engine-strict","false"],{cwd:e,stdio:"inherit",shell:"win32"===o.platform});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}async function runTest(e){const n=a.spawn("node",["index.mjs"],{cwd:e,stdio:"inherit",shell:"win32"===o.platform});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}exports.testPack=async function testPack(a){if(o.platform.startsWith("win"))return void console.log("Skipping test on Windows");if(!("resolve"in{url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index.cjs",document.baseURI).href}))return void console.log("Skipping test on platform without `import.meta.resolve` support");const s=await n.mkdtemp(t.join(i.tmpdir(),"csstools-pack-test-"));try{const n=new URL((void 0)(a));console.log(`Testing module: ${a}`);const i=e.fileURLToPath(n),o=await findPackageJsonFromDir(t.dirname(i)),r=t.dirname(o),c=await pack(r,s),d=await unpack(c,s),p=await getPackageInfo(t.join(d,"package.json"));await eraseDevDependenciesInfo(t.join(d,"package.json")),await createRootPackage(s,p),await runNPMInstall(s),await runTest(s)}finally{await n.rm(s,{recursive:!0})}};
1+
"use strict";var e=require("node:url"),n=require("node:fs/promises"),t=require("node:path"),i=require("node:os"),o=require("node:process"),a=require("node:child_process"),r="undefined"!=typeof document?document.currentScript:null;const s="package";async function findPackageJsonFromDir(e,i=10){const o=t.join(e,"package.json");try{return await n.access(o),o}catch{if("/"===e||i<=0)throw new Error("Could not find package.json")}return findPackageJsonFromDir(t.dirname(e),i-1)}async function pack(e,i){const r=await n.mkdir(t.join(i,"pack"),{recursive:!0}),s=a.spawn("npm",["pack","--pack-destination",r],{cwd:e,shell:"win32"===o.platform}),c=await new Promise((e,n)=>{let t="",i="";s.stdout.on("data",e=>{t+=e.toString()}),s.stderr.on("data",e=>{i+=e.toString()}),s.on("close",o=>{0===o?e(t.trim()):(console.error(i),n(new Error(`npm pack exited with code ${o}`)))})});return t.join(r,c)}async function unpack(e,i){const o=t.join(i,s);await n.mkdir(o,{recursive:!0});const r=a.spawn("tar",["-xf",e,"-C",s,"--strip-components","1"],{cwd:i});return await new Promise((e,n)=>{r.on("close",t=>{0===t?e():n(new Error(`tar exited with code ${t}`))})}),o}async function eraseDevDependenciesInfo(e){const t=JSON.parse(await n.readFile(e,"utf8"));delete t.devDependencies,await n.writeFile(e,JSON.stringify(t,null,"\t"))}async function getPackageInfo(e){return JSON.parse(await n.readFile(e,"utf8"))}async function createRootPackage(e,i){await n.writeFile(t.join(e,"package.json"),JSON.stringify({name:"@csstools/pack-test--root",private:!0,type:"module",version:"1.0.0",description:"",workspaces:[s],dependencies:i.peerDependencies??{},scripts:{test:"node --test"}},null,"\t")),await n.writeFile(t.join(e,"index.mjs"),`import '${i.name}';`)}async function runNPMInstall(e){const n=a.spawn("npm",["install","--ignore-scripts","--omit","dev","--engine-strict","false"],{cwd:e,stdio:"inherit",shell:"win32"===o.platform});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}async function runTest(e){const n=a.spawn("node",["index.mjs"],{cwd:e,stdio:"inherit",shell:"win32"===o.platform});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}exports.testPack=async function testPack(a){if(o.platform.startsWith("win"))return void console.log("Skipping test on Windows");if(!("resolve"in{url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index.cjs",document.baseURI).href}))return void console.log("Skipping test on platform without `import.meta.resolve` support");const s=await n.mkdtemp(t.join(i.tmpdir(),"csstools-pack-test-"));try{const n=new URL((void 0)(a));console.log(`Testing module: ${a}`);const i=e.fileURLToPath(n),o=await findPackageJsonFromDir(t.dirname(i)),r=t.dirname(o),c=await pack(r,s),d=await unpack(c,s),p=await getPackageInfo(t.join(d,"package.json"));await eraseDevDependenciesInfo(t.join(d,"package.json")),await createRootPackage(s,p),await runNPMInstall(s),await runTest(s)}finally{await n.rm(s,{recursive:!0})}};

packages/pack-test/dist/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import e from"node:url";import n from"node:fs/promises";import t from"node:path";import o from"node:os";import{platform as i}from"node:process";import{spawn as a}from"node:child_process";const r="package";async function testPack(a){if(i.startsWith("win"))return void console.log("Skipping test on Windows");if(!("resolve"in import.meta))return void console.log("Skipping test on platform without `import.meta.resolve` support");const r=await n.mkdtemp(t.join(o.tmpdir(),"csstools-pack-test-"));try{const n=new URL(import.meta.resolve(a));console.log(`Testing module: ${a}`);const o=e.fileURLToPath(n),i=await findPackageJsonFromDir(t.dirname(o)),s=t.dirname(i),c=await pack(s,r),p=await unpack(c,r),d=await getPackageInfo(t.join(p,"package.json"));await eraseDevDependenciesInfo(t.join(p,"package.json")),await createRootPackage(r,d),await runNPMInstall(r),await runTest(r)}finally{await n.rm(r,{recursive:!0})}}async function findPackageJsonFromDir(e,o=10){const i=t.join(e,"package.json");try{return await n.access(i),i}catch{if("/"===e||o<=0)throw new Error("Could not find package.json")}return findPackageJsonFromDir(t.dirname(e),o-1)}async function pack(e,o){const r=await n.mkdir(t.join(o,"pack"),{recursive:!0}),s=a("npm",["pack","--pack-destination",r],{cwd:e,shell:"win32"===i}),c=await new Promise((e,n)=>{let t="",o="";s.stdout.on("data",e=>{t+=e.toString()}),s.stderr.on("data",e=>{o+=e.toString()}),s.on("close",i=>{0===i?e(t.trim()):(console.error(o),n(new Error(`npm pack exited with code ${i}`)))})});return t.join(r,c)}async function unpack(e,o){const i=t.join(o,r);await n.mkdir(i,{recursive:!0});const s=a("tar",["-xf",e,"-C",r,"--strip-components","1"],{cwd:o});return await new Promise((e,n)=>{s.on("close",t=>{0===t?e():n(new Error(`tar exited with code ${t}`))})}),i}async function eraseDevDependenciesInfo(e){const t=JSON.parse(await n.readFile(e,"utf8"));delete t.devDependencies,await n.writeFile(e,JSON.stringify(t,null,"\t"))}async function getPackageInfo(e){return JSON.parse(await n.readFile(e,"utf8"))}async function createRootPackage(e,o){await n.writeFile(t.join(e,"package.json"),JSON.stringify({name:"@csstools/pack-test--root",private:!0,type:"module",version:"1.0.0",description:"",workspaces:[r],dependencies:o.peerDependencies??{},scripts:{test:"node --test"}},null,"\t")),await n.writeFile(t.join(e,"index.mjs"),`import '${o.name}';`)}async function runNPMInstall(e){const n=a("npm",["install","--omit","dev","--engine-strict","false"],{cwd:e,stdio:"inherit",shell:"win32"===i});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}async function runTest(e){const n=a("node",["index.mjs"],{cwd:e,stdio:"inherit",shell:"win32"===i});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}export{testPack};
1+
import e from"node:url";import n from"node:fs/promises";import t from"node:path";import o from"node:os";import{platform as i}from"node:process";import{spawn as a}from"node:child_process";const r="package";async function testPack(a){if(i.startsWith("win"))return void console.log("Skipping test on Windows");if(!("resolve"in import.meta))return void console.log("Skipping test on platform without `import.meta.resolve` support");const r=await n.mkdtemp(t.join(o.tmpdir(),"csstools-pack-test-"));try{const n=new URL(import.meta.resolve(a));console.log(`Testing module: ${a}`);const o=e.fileURLToPath(n),i=await findPackageJsonFromDir(t.dirname(o)),s=t.dirname(i),c=await pack(s,r),p=await unpack(c,r),d=await getPackageInfo(t.join(p,"package.json"));await eraseDevDependenciesInfo(t.join(p,"package.json")),await createRootPackage(r,d),await runNPMInstall(r),await runTest(r)}finally{await n.rm(r,{recursive:!0})}}async function findPackageJsonFromDir(e,o=10){const i=t.join(e,"package.json");try{return await n.access(i),i}catch{if("/"===e||o<=0)throw new Error("Could not find package.json")}return findPackageJsonFromDir(t.dirname(e),o-1)}async function pack(e,o){const r=await n.mkdir(t.join(o,"pack"),{recursive:!0}),s=a("npm",["pack","--pack-destination",r],{cwd:e,shell:"win32"===i}),c=await new Promise((e,n)=>{let t="",o="";s.stdout.on("data",e=>{t+=e.toString()}),s.stderr.on("data",e=>{o+=e.toString()}),s.on("close",i=>{0===i?e(t.trim()):(console.error(o),n(new Error(`npm pack exited with code ${i}`)))})});return t.join(r,c)}async function unpack(e,o){const i=t.join(o,r);await n.mkdir(i,{recursive:!0});const s=a("tar",["-xf",e,"-C",r,"--strip-components","1"],{cwd:o});return await new Promise((e,n)=>{s.on("close",t=>{0===t?e():n(new Error(`tar exited with code ${t}`))})}),i}async function eraseDevDependenciesInfo(e){const t=JSON.parse(await n.readFile(e,"utf8"));delete t.devDependencies,await n.writeFile(e,JSON.stringify(t,null,"\t"))}async function getPackageInfo(e){return JSON.parse(await n.readFile(e,"utf8"))}async function createRootPackage(e,o){await n.writeFile(t.join(e,"package.json"),JSON.stringify({name:"@csstools/pack-test--root",private:!0,type:"module",version:"1.0.0",description:"",workspaces:[r],dependencies:o.peerDependencies??{},scripts:{test:"node --test"}},null,"\t")),await n.writeFile(t.join(e,"index.mjs"),`import '${o.name}';`)}async function runNPMInstall(e){const n=a("npm",["install","--ignore-scripts","--omit","dev","--engine-strict","false"],{cwd:e,stdio:"inherit",shell:"win32"===i});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}async function runTest(e){const n=a("node",["index.mjs"],{cwd:e,stdio:"inherit",shell:"win32"===i});await new Promise((e,t)=>{n.on("close",n=>{0===n?e():t(new Error(`npm install exited with code ${n}`))})})}export{testPack};

packages/pack-test/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async function createRootPackage(rootDir: string, packageInfo: packageInfo): Pro
182182
}
183183

184184
async function runNPMInstall(rootDir: string): Promise<void> {
185-
const npm = spawn('npm', ['install', '--omit', 'dev', '--engine-strict', 'false'], {
185+
const npm = spawn('npm', ['install', '--ignore-scripts', '--omit', 'dev', '--engine-strict', 'false'], {
186186
cwd: rootDir,
187187
stdio: 'inherit',
188188
shell: platform === 'win32',

plugin-packs/postcss-preset-env/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changes to PostCSS Preset Env
22

3+
### Unreleased (minor)
4+
5+
_August 22, 2025_
6+
7+
- Added `@csstools/postcss-contrast-color-function` [Check the plugin README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-contrast-color-function#readme) for usage details.
8+
39
### 10.3.1
410

511
_August 27, 2025_

plugin-packs/postcss-preset-env/FEATURES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The `ID` listed is the key for PostCSS Preset Env configuration in your project.
1818
| [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/color-mix.svg" height="18">](https://cssdb.org/#color-mix) | `color-mix` | `color-mix()` Function | [example](https://preset-env.cssdb.org/features/#color-mix) | [docs](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-mix-function#readme) |
1919
| [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/color-mix-variadic-function-arguments.svg" height="18">](https://cssdb.org/#color-mix-variadic-function-arguments) | `color-mix-variadic-function-arguments` | `color-mix()` Function with 1+ arguments | [example](https://preset-env.cssdb.org/features/#color-mix-variadic-function-arguments) | [docs](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-mix-variadic-function-arguments#readme) |
2020
| [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/content-alt-text.svg" height="18">](https://cssdb.org/#content-alt-text) | `content-alt-text` | Alt text for `content` | [example](https://preset-env.cssdb.org/features/#content-alt-text) | [docs](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-content-alt-text#readme) |
21+
| [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/contrast-color-function.svg" height="18">](https://cssdb.org/#contrast-color-function) | `contrast-color-function` | `contrast-color()` Function | [example](https://preset-env.cssdb.org/features/#contrast-color-function) | [docs](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-contrast-color-function#readme) |
2122
| [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/custom-media-queries.svg" height="18">](https://cssdb.org/#custom-media-queries) | `custom-media-queries` | Custom Media Queries | [example](https://preset-env.cssdb.org/features/#custom-media-queries) | [docs](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-media#readme) |
2223
| [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/custom-properties.svg" height="18">](https://cssdb.org/#custom-properties) | `custom-properties` | Custom Properties | [example](https://preset-env.cssdb.org/features/#custom-properties) | [docs](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-properties#readme) |
2324
| [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/custom-selectors.svg" height="18">](https://cssdb.org/#custom-selectors) | `custom-selectors` | Custom Selectors | [example](https://preset-env.cssdb.org/features/#custom-selectors) | [docs](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-custom-selectors#readme) |

plugin-packs/postcss-preset-env/dist/index.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)