From 744b3afadb5a03d38cf5ca9a52a873c6730ffe36 Mon Sep 17 00:00:00 2001
From: romainmenke
Date: Sun, 28 Nov 2021 17:08:30 +0100
Subject: [PATCH 1/2] Migrate postcss-place
---
plugins/postcss-place/.editorconfig | 15 ------------
.../postcss-place/.github/workflows/test.yml | 18 ---------------
plugins/postcss-place/.rollup.js | 2 +-
plugins/postcss-place/package.json | 23 ++++++++-----------
4 files changed, 10 insertions(+), 48 deletions(-)
delete mode 100644 plugins/postcss-place/.editorconfig
delete mode 100644 plugins/postcss-place/.github/workflows/test.yml
diff --git a/plugins/postcss-place/.editorconfig b/plugins/postcss-place/.editorconfig
deleted file mode 100644
index e06d7982b..000000000
--- a/plugins/postcss-place/.editorconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-root = true
-
-[*]
-charset = utf-8
-end_of_line = lf
-indent_style = tab
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-[*.md]
-trim_trailing_whitespace = false
-
-[*.{json,md,yml}]
-indent_size = 2
-indent_style = space
diff --git a/plugins/postcss-place/.github/workflows/test.yml b/plugins/postcss-place/.github/workflows/test.yml
deleted file mode 100644
index 4a287db8e..000000000
--- a/plugins/postcss-place/.github/workflows/test.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-name: test
-on:
- push:
-
-jobs:
- test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- node: [12, 16]
- steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-node@v2
- with:
- node-version: ${{ matrix.node }}
-
- - run: yarn install --ignore-scripts
- - run: yarn run test
diff --git a/plugins/postcss-place/.rollup.js b/plugins/postcss-place/.rollup.js
index 4e8adac9e..8025c82a1 100644
--- a/plugins/postcss-place/.rollup.js
+++ b/plugins/postcss-place/.rollup.js
@@ -14,7 +14,7 @@ export default {
corejs: 3,
loose: true,
modules: false,
- targets: { node: 10 },
+ targets: { node: 12 },
useBuiltIns: 'entry'
}]
]
diff --git a/plugins/postcss-place/package.json b/plugins/postcss-place/package.json
index f2321560c..f0eeba577 100755
--- a/plugins/postcss-place/package.json
+++ b/plugins/postcss-place/package.json
@@ -4,7 +4,6 @@
"description": "Use a place-* shorthand for align-* and justify-* in CSS",
"author": "Jonathan Neal ",
"license": "CC0-1.0",
- "repository": "csstools/postcss-place",
"homepage": "https://github.com/csstools/postcss-place#readme",
"bugs": "https://github.com/csstools/postcss-place/issues",
"main": "dist/index.js",
@@ -20,10 +19,11 @@
"pretest": "npm install && npm run build",
"test": "npm run lint && npm run tape",
"tape": "npx postcss-tape",
- "prepublishOnly": "npm test"
+ "prepublishOnly": "npm run build --if-present && npm run test --if-present",
+ "stryker": "stryker run --logLevel error"
},
"engines": {
- "node": ">=12"
+ "node": "^12 || ^14 || >=16"
},
"dependencies": {
"postcss-values-parser": "6.0.0"
@@ -51,16 +51,6 @@
]
]
},
- "eslintConfig": {
- "env": {
- "es6": true,
- "node": true
- },
- "extends": "eslint:recommended",
- "parserOptions": {
- "sourceType": "module"
- }
- },
"keywords": [
"postcss",
"css",
@@ -72,5 +62,10 @@
"aligns",
"contents",
"selfs"
- ]
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/csstools/postcss-plugins.git",
+ "directory": ""
+ }
}
From 8d4c74d1830c15f0f858e3d3cbd4be0039187a7f Mon Sep 17 00:00:00 2001
From: romainmenke
Date: Sun, 28 Nov 2021 17:14:58 +0100
Subject: [PATCH 2/2] Migrate postcss-place
---
plugins/postcss-place/.gitattributes | 1 -
plugins/postcss-place/.gitignore | 6 +-
plugins/postcss-place/.rollup.js | 26 --------
plugins/postcss-place/CONTRIBUTING.md | 65 -------------------
plugins/postcss-place/INSTALL.md | 2 +-
plugins/postcss-place/README.md | 6 +-
plugins/postcss-place/package.json | 51 ++++++---------
plugins/postcss-place/src/cli.js | 15 +++++
plugins/postcss-place/src/index.js | 16 ++---
plugins/postcss-place/src/onCSSDeclaration.js | 38 +++++------
plugins/postcss-place/src/options.js | 4 +-
11 files changed, 70 insertions(+), 160 deletions(-)
delete mode 100644 plugins/postcss-place/.gitattributes
delete mode 100644 plugins/postcss-place/.rollup.js
delete mode 100644 plugins/postcss-place/CONTRIBUTING.md
create mode 100644 plugins/postcss-place/src/cli.js
diff --git a/plugins/postcss-place/.gitattributes b/plugins/postcss-place/.gitattributes
deleted file mode 100644
index 6313b56c5..000000000
--- a/plugins/postcss-place/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-* text=auto eol=lf
diff --git a/plugins/postcss-place/.gitignore b/plugins/postcss-place/.gitignore
index 72a6a3d37..b5d13c8c0 100644
--- a/plugins/postcss-place/.gitignore
+++ b/plugins/postcss-place/.gitignore
@@ -1,13 +1,13 @@
-dist
node_modules
+dist
package-lock.json
yarn.lock
*.log*
*.result.css
-.*
+*.result.css.map
!.editorconfig
-!.gitattributes
!.gitignore
!.rollup.js
!.tape.js
+!.travis.yml
!.github
diff --git a/plugins/postcss-place/.rollup.js b/plugins/postcss-place/.rollup.js
deleted file mode 100644
index 8025c82a1..000000000
--- a/plugins/postcss-place/.rollup.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import babel from '@rollup/plugin-babel';
-
-export default {
- input: 'src/index.js',
- output: [
- { file: 'dist/index.js', format: 'cjs', sourcemap: true, exports: 'default' },
- { file: 'dist/index.mjs', format: 'esm', sourcemap: true, exports: 'default' }
- ],
- plugins: [
- babel({
- babelHelpers: 'bundled',
- presets: [
- ['@babel/preset-env', {
- corejs: 3,
- loose: true,
- modules: false,
- targets: { node: 12 },
- useBuiltIns: 'entry'
- }]
- ]
- }),
- ],
- onwarn(warning, warn) {
- if (warning.code !== 'UNRESOLVED_IMPORT') warn(warning)
- }
-}
diff --git a/plugins/postcss-place/CONTRIBUTING.md b/plugins/postcss-place/CONTRIBUTING.md
deleted file mode 100644
index 7f4dd7306..000000000
--- a/plugins/postcss-place/CONTRIBUTING.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# Contributing to PostCSS Place Properties
-
-You want to help? You rock! Now, take a moment to be sure your contributions
-make sense to everyone else.
-
-## Reporting Issues
-
-Found a problem? Want a new feature?
-
-- See if your issue or idea has [already been reported].
-- Provide a [reduced test case] or a [live example].
-
-Remember, a bug is a _demonstrable problem_ caused by _our_ code.
-
-## Submitting Pull Requests
-
-Pull requests are the greatest contributions, so be sure they are focused in
-scope and avoid unrelated commits.
-
-1. To begin; [fork this project], clone your fork, and add our upstream.
- ```bash
- # Clone your fork of the repo into the current directory
- git clone git@github.com:YOUR_USER/postcss-place.git
-
- # Navigate to the newly cloned directory
- cd postcss-place
-
- # Assign the original repo to a remote called "upstream"
- git remote add upstream git@github.com:csstools/postcss-place.git
-
- # Install the tools necessary for testing
- npm install
- ```
-
-2. Create a branch for your feature or fix:
- ```bash
- # Move into a new branch for your feature
- git checkout -b feature/thing
- ```
- ```bash
- # Move into a new branch for your fix
- git checkout -b fix/something
- ```
-
-3. If your code follows our practices, then push your feature branch:
- ```bash
- # Test current code
- npm test
- ```
- ```bash
- # Push the branch for your new feature
- git push origin feature/thing
- ```
- ```bash
- # Or, push the branch for your update
- git push origin update/something
- ```
-
-That’s it! Now [open a pull request] with a clear title and description.
-
-[already been reported]: issues
-[fork this project]: fork
-[live example]: https://codepen.io/pen
-[open a pull request]: https://help.github.com/articles/using-pull-requests/
-[reduced test case]: https://css-tricks.com/reduced-test-cases/
diff --git a/plugins/postcss-place/INSTALL.md b/plugins/postcss-place/INSTALL.md
index 287cd5333..2a356b822 100644
--- a/plugins/postcss-place/INSTALL.md
+++ b/plugins/postcss-place/INSTALL.md
@@ -157,6 +157,6 @@ grunt.initConfig({
[PostCSS]: https://github.com/postcss/postcss
[PostCSS CLI]: https://github.com/postcss/postcss-cli
[PostCSS Loader]: https://github.com/postcss/postcss-loader
-[PostCSS Place Properties]: https://github.com/csstools/postcss-place
+[PostCSS Place Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
[React App Rewired]: https://github.com/timarney/react-app-rewired
diff --git a/plugins/postcss-place/README.md b/plugins/postcss-place/README.md
index 20295ae2e..b060e1fb5 100644
--- a/plugins/postcss-place/README.md
+++ b/plugins/postcss-place/README.md
@@ -2,7 +2,7 @@
[
][npm-url]
[
][css-url]
-[
][cli-url]
+[
][cli-url]
[
][git-url]
[PostCSS Place Properties] lets you use `place-*` properties as shorthands for `align-*`
@@ -77,7 +77,7 @@ postcssPlace({ preserve: false })
}
```
-[cli-url]: https://github.com/csstools/postcss-place/actions/workflows/test.yml?query=workflow/test
+[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
[css-url]: https://cssdb.org/#place-properties
[git-url]: https://gitter.im/postcss/postcss
[npm-url]: https://www.npmjs.com/package/postcss-place
@@ -87,4 +87,4 @@ postcssPlace({ preserve: false })
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Loader]: https://github.com/postcss/postcss-loader
-[PostCSS Place Properties]: https://github.com/csstools/postcss-place
+[PostCSS Place Properties]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place
diff --git a/plugins/postcss-place/package.json b/plugins/postcss-place/package.json
index 1d5e9f60e..eede19f40 100755
--- a/plugins/postcss-place/package.json
+++ b/plugins/postcss-place/package.json
@@ -4,22 +4,25 @@
"description": "Use a place-* shorthand for align-* and justify-* in CSS",
"author": "Jonathan Neal ",
"license": "CC0-1.0",
- "homepage": "https://github.com/csstools/postcss-place#readme",
- "bugs": "https://github.com/csstools/postcss-place/issues",
- "main": "dist/index.js",
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-place#readme",
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
+ "main": "dist/index.cjs",
"module": "dist/index.mjs",
"files": [
+ "CHANGELOG.md",
+ "INSTALL.md",
+ "LICENSE.md",
+ "README.md",
"dist"
],
+ "bin": {
+ "postcss-place": "dist/cli.mjs"
+ },
"scripts": {
- "build": "npx rollup -c .rollup.js",
- "build:watch": "npx rollup -c .rollup.js --watch",
- "lint": "npx eslint --cache src",
- "lint:fix": "npx eslint --cache --fix",
- "pretest": "npm install && npm run build",
- "test": "npm run lint && npm run tape",
- "tape": "npx postcss-tape",
- "prepublishOnly": "npm run build --if-present && npm run test --if-present",
+ "prepublishOnly": "npm run build && npm run test",
+ "lint": "eslint src/**/*.js",
+ "test": "postcss-tape",
+ "build": "rollup -c ../../rollup/default.js",
"stryker": "stryker run --logLevel error"
},
"engines": {
@@ -28,28 +31,12 @@
"dependencies": {
"postcss-values-parser": "6.0.1"
},
- "peerDependencies": {
- "postcss": "^8.3"
- },
"devDependencies": {
- "@babel/core": "^7.16.0",
- "@babel/preset-env": "^7.16.4",
- "@rollup/plugin-babel": "^5.3.0",
- "eslint": "^8.2.0",
- "postcss": "^8.3.11",
- "postcss-tape": "^6.0.1",
- "pre-commit": "^1.2.2",
- "rollup": "^2.60.0"
+ "postcss": "8.3.6",
+ "postcss-tape": "6.0.1"
},
- "babel": {
- "presets": [
- [
- "@babel/env",
- {
- "targets": "maintained node versions"
- }
- ]
- ]
+ "peerDependencies": {
+ "postcss": "^8.3"
},
"keywords": [
"postcss",
@@ -66,6 +53,6 @@
"repository": {
"type": "git",
"url": "https://github.com/csstools/postcss-plugins.git",
- "directory": ""
+ "directory": "plugins/postcss-place"
}
}
diff --git a/plugins/postcss-place/src/cli.js b/plugins/postcss-place/src/cli.js
new file mode 100644
index 000000000..5a5d96ac7
--- /dev/null
+++ b/plugins/postcss-place/src/cli.js
@@ -0,0 +1,15 @@
+import plugin from './index';
+import { cli, helpTextLogger } from '@csstools/base-cli';
+
+cli(
+ plugin,
+ ['preserve'],
+ helpTextLogger(
+ 'postcss-place',
+ 'PostCSS Place',
+ 'Lets you use place-* properties as shorthands for align-* and justify-*, following the CSS Box Alignment specification.',
+ {
+ preserve: true,
+ },
+ ),
+);
diff --git a/plugins/postcss-place/src/index.js b/plugins/postcss-place/src/index.js
index c95266181..541884057 100755
--- a/plugins/postcss-place/src/index.js
+++ b/plugins/postcss-place/src/index.js
@@ -1,20 +1,20 @@
-import options from './options'
-import onCSSDeclaration, { placeMatch } from './onCSSDeclaration'
+import options from './options';
+import onCSSDeclaration, { placeMatch } from './onCSSDeclaration';
const creator = opts => {
// prepare options
- if ('preserve' in Object(opts)) options.preserve = Boolean(opts.preserve)
+ if ('preserve' in Object(opts)) options.preserve = Boolean(opts.preserve);
return {
postcssPlugin: 'postcss-place',
Declaration: (decl, { result }) => {
if (placeMatch.test(decl)) {
- onCSSDeclaration(decl, { result })
+ onCSSDeclaration(decl, { result });
}
},
- }
-}
+ };
+};
-creator.postcss = true
+creator.postcss = true;
-export default creator
+export default creator;
diff --git a/plugins/postcss-place/src/onCSSDeclaration.js b/plugins/postcss-place/src/onCSSDeclaration.js
index 4a7c33205..b941e919b 100644
--- a/plugins/postcss-place/src/onCSSDeclaration.js
+++ b/plugins/postcss-place/src/onCSSDeclaration.js
@@ -1,47 +1,47 @@
-import { parse } from 'postcss-values-parser'
-import options from './options'
+import { parse } from 'postcss-values-parser';
+import options from './options';
export default (decl, { result }) => {
// alignment
- const alignment = decl.prop.match(placeMatch)[1]
+ const alignment = decl.prop.match(placeMatch)[1];
// value ast and child nodes
- let value
+ let value;
try {
- value = parse(decl.value)
+ value = parse(decl.value);
} catch (error) {
decl.warn(
result,
- `Failed to parse value '${decl.value}'. Leaving the original value intact.`
- )
+ `Failed to parse value '${decl.value}'. Leaving the original value intact.`,
+ );
}
if (typeof value === 'undefined') {
- return
+ return;
}
- let alignmentValues = []
+ let alignmentValues = [];
value.walkWords(walk => {
alignmentValues.push(
- walk.parent.type === 'root' ? walk.toString() : walk.parent.toString()
- )
- })
+ walk.parent.type === 'root' ? walk.toString() : walk.parent.toString(),
+ );
+ });
decl.cloneBefore({
prop: `align-${alignment}`,
- value: alignmentValues[0]
- })
+ value: alignmentValues[0],
+ });
decl.cloneBefore({
prop: `justify-${alignment}`,
- value: alignmentValues[1] || alignmentValues[0]
- })
+ value: alignmentValues[1] || alignmentValues[0],
+ });
// conditionally remove place-[alignment]
if (!options.preserve) {
- decl.remove()
+ decl.remove();
}
-}
+};
-export const placeMatch = /^place-(content|items|self)/
+export const placeMatch = /^place-(content|items|self)/;
diff --git a/plugins/postcss-place/src/options.js b/plugins/postcss-place/src/options.js
index 62ef20da9..484ccd4a4 100644
--- a/plugins/postcss-place/src/options.js
+++ b/plugins/postcss-place/src/options.js
@@ -1,4 +1,4 @@
export default {
/** Whether to preserve the original place value. */
- preserve: true
-}
+ preserve: true,
+};