Skip to content

standalone cli #89

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 10 commits into from
Jan 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/css-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ body:
- type: dropdown
id: npx
attributes:
label: Does it happen with `npx <plugin-name> minimal-example.css`?
label: Does it happen with `npx @csstools/csstools-cli <plugin-name> minimal-example.css`?
multiple: false
options:
- "Yes"
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/plugin-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ body:
- type: dropdown
id: npx
attributes:
label: Can you reproduce it with `npx <plugin-name> minimal-example.css`?
label: Can you reproduce it with `npx @csstools/csstools-cli <plugin-name> minimal-example.css`?
multiple: false
options:
- "Yes"
Expand Down
7 changes: 4 additions & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
- plugins/postcss-base-plugin/**
- rollup/**

"packages/postcss-plugins-values-parser":
- packages/postcss-plugins-values-parser/**

"plugin-packs/postcss-preset-env":
- plugin-packs/postcss-preset-env/**

"cli":
- cli/csstools-cli/**
- packages/base-cli/**

"plugins/css-all-property":
- plugins/css-all-property/**

Expand Down
13 changes: 13 additions & 0 deletions cli/csstools-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
dist
package-lock.json
yarn.lock
browser.js
*.log*
*.result.css
*.result.css.map
!.editorconfig
!.gitignore
!.rollup.js
!.tape.js
!.travis.yml
1 change: 1 addition & 0 deletions cli/csstools-cli/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly nit and potentially unrelated but should we just add 16?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16 sounds good.

We can change it in a different PR, or straight to main.

5 changes: 5 additions & 0 deletions cli/csstools-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changes to CSSTools CLI

### 1.0.0

- Initial version
108 changes: 108 additions & 0 deletions cli/csstools-cli/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# CC0 1.0 Universal

## Statement of Purpose

The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an “owner”) of an original work of
authorship and/or a database (each, a “Work”).

Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific works
(“Commons”) that the public can reliably and without fear of later claims of
infringement build upon, modify, incorporate in other works, reuse and
redistribute as freely as possible in any form whatsoever and for any purposes,
including without limitation commercial purposes. These owners may contribute
to the Commons to promote the ideal of a free culture and the further
production of creative, cultural and scientific works, or to gain reputation or
greater distribution for their Work in part through the use and efforts of
others.

For these and/or other purposes and motivations, and without any expectation of
additional consideration or compensation, the person associating CC0 with a
Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.

1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights (“Copyright and
Related Rights”). Copyright and Related Rights include, but are not limited
to, the following:
1. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
2. moral rights retained by the original author(s) and/or performer(s);
3. publicity and privacy rights pertaining to a person’s image or likeness
depicted in a Work;
4. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(i), below;
5. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
6. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
7. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations
thereof.

2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the “Waiver”). Affirmer
makes the Waiver for the benefit of each member of the public at large and
to the detriment of Affirmer’s heirs and successors, fully intending that
such Waiver shall not be subject to revocation, rescission, cancellation,
termination, or any other legal or equitable action to disrupt the quiet
enjoyment of the Work by the public as contemplated by Affirmer’s express
Statement of Purpose.

3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer’s express Statement of Purpose. In addition, to the extent the
Waiver is so judged Affirmer hereby grants to each affected person a
royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer’s Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the “License”). The License
shall be deemed effective as of the date CC0 was applied by Affirmer to the
Work. Should any part of the License for any reason be judged legally
invalid or ineffective under applicable law, such partial invalidity or
ineffectiveness shall not invalidate the remainder of the License, and in
such case Affirmer hereby affirms that he or she will not (i) exercise any
of his or her remaining Copyright and Related Rights in the Work or (ii)
assert any associated claims and causes of action with respect to the Work,
in either case contrary to Affirmer’s express Statement of Purpose.

4. Limitations and Disclaimers.
1. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
2. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or
otherwise, including without limitation warranties of title,
merchantability, fitness for a particular purpose, non infringement, or
the absence of latent or other defects, accuracy, or the present or
absence of errors, whether or not discoverable, all to the greatest
extent permissible under applicable law.
3. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person’s Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the Work.
4. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.

For more information, please see
http://creativecommons.org/publicdomain/zero/1.0/.
196 changes: 196 additions & 0 deletions cli/csstools-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# CSSTools CLI [<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/@csstools/csstools-cli.svg" height="20">][npm-url]
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg" height="20">][cli-url]
[<img alt="Support Chat" src="https://img.shields.io/badge/support-chat-blue.svg" height="20">][git-url]

[CSSTools CLI] lets you run any plugin from [@csstools/postcss-plugins](https://github.com/csstools/postcss-plugins) from the command line.

## Usage

We recommend using the [CSSTools CLI] as a prototyping and debugging tool.
⚠️ If you are building/customizing a toolchain it is best **not** to use the CLI.

With `npx` you can use the CLI directly without installing it globally.

### General Help :

```bash
npx -y @csstools/csstools-cli
```

```
CSSTools CLI

Transform CSS with any plugin from https://github.com/csstools/postcss-plugins

Usage:
@csstools/csstools-cli postcss-preset-env [input.css] [OPTIONS] [-o|--output output.css]
@csstools/csstools-cli postcss-preset-env <input.css>... [OPTIONS] --dir <output-directory>
@csstools/csstools-cli postcss-preset-env <input.css>... [OPTIONS] --replace

Available Plugins:
css-blank-pseudo
css-has-pseudo
css-prefers-color-scheme
postcss-color-functional-notation
postcss-color-hex-alpha
postcss-color-rebeccapurple
postcss-custom-properties
postcss-dir-pseudo-class
postcss-double-position-gradients
postcss-env-function
postcss-focus-visible
postcss-focus-within
postcss-gap-properties
postcss-image-set-function
postcss-lab-function
postcss-logical
postcss-nesting
postcss-overflow-shorthand
postcss-place
postcss-pseudo-class-any-link

Plugin Help:
@csstools/csstools-cli <plugin-name>
@csstools/csstools-cli postcss-preset-env
```

### Plugin Help :

Each plugin can have specific options.
These can be found by running `npx -y @csstools/csstools-cli <plugin-name>`.
More details can always be found in the README of that plugin on github.

```bash
npx -y @csstools/cli postcss-preset-env
```

```
PostCSS Preset Env

Lets you convert modern CSS into something most browsers can understand, determining the polyfills you need based on your targeted browsers or runtime environments.

Usage:
@csstools/cli postcss-preset-env [input.css] [OPTIONS] [-o|--output output.css]
@csstools/cli postcss-preset-env <input.css>... [OPTIONS] --dir <output-directory>
@csstools/cli postcss-preset-env <input.css>... [OPTIONS] --replace

Options:
-o, --output Output file
-d, --dir Output directory
-r, --replace Replace (overwrite) the input file
-m, --map Create an external sourcemap
--no-map Disable the default inline sourcemaps
-p, --plugin-options Stringified JSON object with plugin options

Plugin Options:
stage number
features object
browsers string
autoprefixer object
preserve boolean
importFrom string
exportTo string

{
"stage": 0,
"features": {
"blank-pseudo-class": {
"preserve": false
},
"color-functional-notation": {
"preserve": true
}
},
"browsers": "last 2 versions",
"autoprefixer": {
"grid": true
},
"preserve": false,
"importFrom": "path/to/file.css",
"exportTo": "path/to/file.css"
}
```

## Example

Copy this bit of CSS to have it in your clipboard.

```pcss
a, b {
color: red;

& c, & d {
color: white;
}
}

```

Run :

_`pbpaste | ...` pipes the clipboard contents to the next command._

```bash
pbpaste | npx -y @csstools/csstools-cli postcss-nesting --no-map
```

Output :

```pcss
a, b {
color: red
}
a c, b c, a d, b d {
color: white;
}

```


Copy this bit of CSS to have it in your clipboard.

```pcss
.banner {
color: #222222;
inset: logical 0 5px 10px;
padding-inline: 20px 40px;
resize: block;
transition: color 200ms;
}

```

Run :

```bash
pbpaste | npx -y postcss-logical --no-map --plugin-options '{ "dir": "rtl" }'
```

_note the single quotes around the JSON object with plugin options._

Output :

```pcss
.banner {
color: #222222;
top: 0;
left: 5px;
bottom: 10px;
right: 5px;
padding-right: 20px;
padding-left: 40px;
resize: vertical;
transition: color 200ms;
}

```


[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
[git-url]: https://gitter.im/postcss/postcss
[npm-url]: https://www.npmjs.com/package/@csstools/csstools-cli

[postcss]: https://github.com/postcss/postcss
[CSSTools CLI]: https://github.com/csstools/postcss-plugins/tree/main/cli/csstools-cli
Loading