Skip to content

Commit 4859f6b

Browse files
authored
standalone cli (#89)
* standalone cli * noop test * some more plugins * cleanup * finish cli * Fixes * make it work * more docs * update labeler
1 parent d38782a commit 4859f6b

File tree

129 files changed

+1455
-480
lines changed

Some content is hidden

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

129 files changed

+1455
-480
lines changed

.github/ISSUE_TEMPLATE/css-issue.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ body:
3232
- type: dropdown
3333
id: npx
3434
attributes:
35-
label: Does it happen with `npx <plugin-name> minimal-example.css`?
35+
label: Does it happen with `npx @csstools/csstools-cli <plugin-name> minimal-example.css`?
3636
multiple: false
3737
options:
3838
- "Yes"

.github/ISSUE_TEMPLATE/plugin-issue.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ body:
3434
- type: dropdown
3535
id: npx
3636
attributes:
37-
label: Can you reproduce it with `npx <plugin-name> minimal-example.css`?
37+
label: Can you reproduce it with `npx @csstools/csstools-cli <plugin-name> minimal-example.css`?
3838
multiple: false
3939
options:
4040
- "Yes"

.github/labeler.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
- plugins/postcss-base-plugin/**
44
- rollup/**
55

6-
"packages/postcss-plugins-values-parser":
7-
- packages/postcss-plugins-values-parser/**
8-
96
"plugin-packs/postcss-preset-env":
107
- plugin-packs/postcss-preset-env/**
118

9+
"cli":
10+
- cli/csstools-cli/**
11+
- packages/base-cli/**
12+
1213
"plugins/css-all-property":
1314
- plugins/css-all-property/**
1415

cli/csstools-cli/.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules
2+
dist
3+
package-lock.json
4+
yarn.lock
5+
browser.js
6+
*.log*
7+
*.result.css
8+
*.result.css.map
9+
!.editorconfig
10+
!.gitignore
11+
!.rollup.js
12+
!.tape.js
13+
!.travis.yml

cli/csstools-cli/.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16.13.1

cli/csstools-cli/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changes to CSSTools CLI
2+
3+
### 1.0.0
4+
5+
- Initial version

cli/csstools-cli/LICENSE.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# CC0 1.0 Universal
2+
3+
## Statement of Purpose
4+
5+
The laws of most jurisdictions throughout the world automatically confer
6+
exclusive Copyright and Related Rights (defined below) upon the creator and
7+
subsequent owner(s) (each and all, an “owner”) of an original work of
8+
authorship and/or a database (each, a “Work”).
9+
10+
Certain owners wish to permanently relinquish those rights to a Work for the
11+
purpose of contributing to a commons of creative, cultural and scientific works
12+
(“Commons”) that the public can reliably and without fear of later claims of
13+
infringement build upon, modify, incorporate in other works, reuse and
14+
redistribute as freely as possible in any form whatsoever and for any purposes,
15+
including without limitation commercial purposes. These owners may contribute
16+
to the Commons to promote the ideal of a free culture and the further
17+
production of creative, cultural and scientific works, or to gain reputation or
18+
greater distribution for their Work in part through the use and efforts of
19+
others.
20+
21+
For these and/or other purposes and motivations, and without any expectation of
22+
additional consideration or compensation, the person associating CC0 with a
23+
Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
24+
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
25+
publicly distribute the Work under its terms, with knowledge of his or her
26+
Copyright and Related Rights in the Work and the meaning and intended legal
27+
effect of CC0 on those rights.
28+
29+
1. Copyright and Related Rights. A Work made available under CC0 may be
30+
protected by copyright and related or neighboring rights (“Copyright and
31+
Related Rights”). Copyright and Related Rights include, but are not limited
32+
to, the following:
33+
1. the right to reproduce, adapt, distribute, perform, display, communicate,
34+
and translate a Work;
35+
2. moral rights retained by the original author(s) and/or performer(s);
36+
3. publicity and privacy rights pertaining to a person’s image or likeness
37+
depicted in a Work;
38+
4. rights protecting against unfair competition in regards to a Work,
39+
subject to the limitations in paragraph 4(i), below;
40+
5. rights protecting the extraction, dissemination, use and reuse of data in
41+
a Work;
42+
6. database rights (such as those arising under Directive 96/9/EC of the
43+
European Parliament and of the Council of 11 March 1996 on the legal
44+
protection of databases, and under any national implementation thereof,
45+
including any amended or successor version of such directive); and
46+
7. other similar, equivalent or corresponding rights throughout the world
47+
based on applicable law or treaty, and any national implementations
48+
thereof.
49+
50+
2. Waiver. To the greatest extent permitted by, but not in contravention of,
51+
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
52+
unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright
53+
and Related Rights and associated claims and causes of action, whether now
54+
known or unknown (including existing as well as future claims and causes of
55+
action), in the Work (i) in all territories worldwide, (ii) for the maximum
56+
duration provided by applicable law or treaty (including future time
57+
extensions), (iii) in any current or future medium and for any number of
58+
copies, and (iv) for any purpose whatsoever, including without limitation
59+
commercial, advertising or promotional purposes (the “Waiver”). Affirmer
60+
makes the Waiver for the benefit of each member of the public at large and
61+
to the detriment of Affirmer’s heirs and successors, fully intending that
62+
such Waiver shall not be subject to revocation, rescission, cancellation,
63+
termination, or any other legal or equitable action to disrupt the quiet
64+
enjoyment of the Work by the public as contemplated by Affirmer’s express
65+
Statement of Purpose.
66+
67+
3. Public License Fallback. Should any part of the Waiver for any reason be
68+
judged legally invalid or ineffective under applicable law, then the Waiver
69+
shall be preserved to the maximum extent permitted taking into account
70+
Affirmer’s express Statement of Purpose. In addition, to the extent the
71+
Waiver is so judged Affirmer hereby grants to each affected person a
72+
royalty-free, non transferable, non sublicensable, non exclusive,
73+
irrevocable and unconditional license to exercise Affirmer’s Copyright and
74+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
75+
maximum duration provided by applicable law or treaty (including future time
76+
extensions), (iii) in any current or future medium and for any number of
77+
copies, and (iv) for any purpose whatsoever, including without limitation
78+
commercial, advertising or promotional purposes (the “License”). The License
79+
shall be deemed effective as of the date CC0 was applied by Affirmer to the
80+
Work. Should any part of the License for any reason be judged legally
81+
invalid or ineffective under applicable law, such partial invalidity or
82+
ineffectiveness shall not invalidate the remainder of the License, and in
83+
such case Affirmer hereby affirms that he or she will not (i) exercise any
84+
of his or her remaining Copyright and Related Rights in the Work or (ii)
85+
assert any associated claims and causes of action with respect to the Work,
86+
in either case contrary to Affirmer’s express Statement of Purpose.
87+
88+
4. Limitations and Disclaimers.
89+
1. No trademark or patent rights held by Affirmer are waived, abandoned,
90+
surrendered, licensed or otherwise affected by this document.
91+
2. Affirmer offers the Work as-is and makes no representations or warranties
92+
of any kind concerning the Work, express, implied, statutory or
93+
otherwise, including without limitation warranties of title,
94+
merchantability, fitness for a particular purpose, non infringement, or
95+
the absence of latent or other defects, accuracy, or the present or
96+
absence of errors, whether or not discoverable, all to the greatest
97+
extent permissible under applicable law.
98+
3. Affirmer disclaims responsibility for clearing rights of other persons
99+
that may apply to the Work or any use thereof, including without
100+
limitation any person’s Copyright and Related Rights in the Work.
101+
Further, Affirmer disclaims responsibility for obtaining any necessary
102+
consents, permissions or other rights required for any use of the Work.
103+
4. Affirmer understands and acknowledges that Creative Commons is not a
104+
party to this document and has no duty or obligation with respect to this
105+
CC0 or use of the Work.
106+
107+
For more information, please see
108+
http://creativecommons.org/publicdomain/zero/1.0/.

cli/csstools-cli/README.md

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# CSSTools CLI [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
2+
3+
[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/csstools-cli.svg" height="20">][npm-url]
4+
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg" height="20">][cli-url]
5+
[<img alt="Support Chat" src="https://img.shields.io/badge/support-chat-blue.svg" height="20">][git-url]
6+
7+
[CSSTools CLI] lets you run any plugin from [@csstools/postcss-plugins](https://github.com/csstools/postcss-plugins) from the command line.
8+
9+
## Usage
10+
11+
We recommend using the [CSSTools CLI] as a prototyping and debugging tool.
12+
⚠️ If you are building/customizing a toolchain it is best **not** to use the CLI.
13+
14+
With `npx` you can use the CLI directly without installing it globally.
15+
16+
### General Help :
17+
18+
```bash
19+
npx -y @csstools/csstools-cli
20+
```
21+
22+
```
23+
CSSTools CLI
24+
25+
Transform CSS with any plugin from https://github.com/csstools/postcss-plugins
26+
27+
Usage:
28+
@csstools/csstools-cli postcss-preset-env [input.css] [OPTIONS] [-o|--output output.css]
29+
@csstools/csstools-cli postcss-preset-env <input.css>... [OPTIONS] --dir <output-directory>
30+
@csstools/csstools-cli postcss-preset-env <input.css>... [OPTIONS] --replace
31+
32+
Available Plugins:
33+
css-blank-pseudo
34+
css-has-pseudo
35+
css-prefers-color-scheme
36+
postcss-color-functional-notation
37+
postcss-color-hex-alpha
38+
postcss-color-rebeccapurple
39+
postcss-custom-properties
40+
postcss-dir-pseudo-class
41+
postcss-double-position-gradients
42+
postcss-env-function
43+
postcss-focus-visible
44+
postcss-focus-within
45+
postcss-gap-properties
46+
postcss-image-set-function
47+
postcss-lab-function
48+
postcss-logical
49+
postcss-nesting
50+
postcss-overflow-shorthand
51+
postcss-place
52+
postcss-pseudo-class-any-link
53+
54+
Plugin Help:
55+
@csstools/csstools-cli <plugin-name>
56+
@csstools/csstools-cli postcss-preset-env
57+
```
58+
59+
### Plugin Help :
60+
61+
Each plugin can have specific options.
62+
These can be found by running `npx -y @csstools/csstools-cli <plugin-name>`.
63+
More details can always be found in the README of that plugin on github.
64+
65+
```bash
66+
npx -y @csstools/cli postcss-preset-env
67+
```
68+
69+
```
70+
PostCSS Preset Env
71+
72+
Lets you convert modern CSS into something most browsers can understand, determining the polyfills you need based on your targeted browsers or runtime environments.
73+
74+
Usage:
75+
@csstools/cli postcss-preset-env [input.css] [OPTIONS] [-o|--output output.css]
76+
@csstools/cli postcss-preset-env <input.css>... [OPTIONS] --dir <output-directory>
77+
@csstools/cli postcss-preset-env <input.css>... [OPTIONS] --replace
78+
79+
Options:
80+
-o, --output Output file
81+
-d, --dir Output directory
82+
-r, --replace Replace (overwrite) the input file
83+
-m, --map Create an external sourcemap
84+
--no-map Disable the default inline sourcemaps
85+
-p, --plugin-options Stringified JSON object with plugin options
86+
87+
Plugin Options:
88+
stage number
89+
features object
90+
browsers string
91+
autoprefixer object
92+
preserve boolean
93+
importFrom string
94+
exportTo string
95+
96+
{
97+
"stage": 0,
98+
"features": {
99+
"blank-pseudo-class": {
100+
"preserve": false
101+
},
102+
"color-functional-notation": {
103+
"preserve": true
104+
}
105+
},
106+
"browsers": "last 2 versions",
107+
"autoprefixer": {
108+
"grid": true
109+
},
110+
"preserve": false,
111+
"importFrom": "path/to/file.css",
112+
"exportTo": "path/to/file.css"
113+
}
114+
```
115+
116+
## Example
117+
118+
Copy this bit of CSS to have it in your clipboard.
119+
120+
```pcss
121+
a, b {
122+
color: red;
123+
124+
& c, & d {
125+
color: white;
126+
}
127+
}
128+
129+
```
130+
131+
Run :
132+
133+
_`pbpaste | ...` pipes the clipboard contents to the next command._
134+
135+
```bash
136+
pbpaste | npx -y @csstools/csstools-cli postcss-nesting --no-map
137+
```
138+
139+
Output :
140+
141+
```pcss
142+
a, b {
143+
color: red
144+
}
145+
a c, b c, a d, b d {
146+
color: white;
147+
}
148+
149+
```
150+
151+
152+
Copy this bit of CSS to have it in your clipboard.
153+
154+
```pcss
155+
.banner {
156+
color: #222222;
157+
inset: logical 0 5px 10px;
158+
padding-inline: 20px 40px;
159+
resize: block;
160+
transition: color 200ms;
161+
}
162+
163+
```
164+
165+
Run :
166+
167+
```bash
168+
pbpaste | npx -y postcss-logical --no-map --plugin-options '{ "dir": "rtl" }'
169+
```
170+
171+
_note the single quotes around the JSON object with plugin options._
172+
173+
Output :
174+
175+
```pcss
176+
.banner {
177+
color: #222222;
178+
top: 0;
179+
left: 5px;
180+
bottom: 10px;
181+
right: 5px;
182+
padding-right: 20px;
183+
padding-left: 40px;
184+
resize: vertical;
185+
transition: color 200ms;
186+
}
187+
188+
```
189+
190+
191+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
192+
[git-url]: https://gitter.im/postcss/postcss
193+
[npm-url]: https://www.npmjs.com/package/@csstools/csstools-cli
194+
195+
[postcss]: https://github.com/postcss/postcss
196+
[CSSTools CLI]: https://github.com/csstools/postcss-plugins/tree/main/cli/csstools-cli

0 commit comments

Comments
 (0)