@uisqueezy/cli 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +194 -2
- package/dist/cli.js +7198 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anystation Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,195 @@
|
|
|
1
|
-
#
|
|
1
|
+
# UISqueezy CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pull your [UISqueezy](https://www.uisqueezy.com) design tokens into your repository as CSS, SCSS, Tailwind CSS v4, TypeScript, JavaScript or DTCG JSON. It works locally and in CI.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx uisqueezy init # once: creates uisqueezy.config.json
|
|
7
|
+
npx uisqueezy pull # download the files
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
- Requires **Node.js 20+** on Linux, macOS or Windows.
|
|
11
|
+
- Ships as a single file with no runtime dependencies.
|
|
12
|
+
- Unchanged files are not downloaded again: the CLI keeps an ETag cache and the server answers `304`.
|
|
13
|
+
- Files are written atomically, so dev servers never see a half-written file.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev @uisqueezy/cli # pinned in your project (recommended), runs as `npx uisqueezy`
|
|
19
|
+
npx uisqueezy@latest pull # or without installing
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Access token
|
|
23
|
+
|
|
24
|
+
The CLI needs a project **access token** (`uisq_pat_…`) with the `export:read` scope:
|
|
25
|
+
|
|
26
|
+
1. In UISqueezy, open **project settings → Access tokens** and create a token with the `export:read` scope.
|
|
27
|
+
2. Put it in the environment, never in the config file:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
export UISQUEEZY_TOKEN=uisq_pat_… # macOS / Linux
|
|
31
|
+
$env:UISQUEEZY_TOKEN = "uisq_pat_…" # PowerShell
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
In CI, store it as a secret named `UISQUEEZY_TOKEN`. To use a different variable name, pass `--token-env NAME`.
|
|
35
|
+
A config file that contains a `token`, `apiKey` or similar field is rejected.
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
| Command | |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `uisqueezy init` | Asks for the token (hidden) if `UISQUEEZY_TOKEN` is not set and finds the project from it. Suggests formats from your `package.json` (`tailwindcss` → tailwind, `typescript` → ts), writes `uisqueezy.config.json` and adds `.uisqueezy/` to `.gitignore`. Without prompts: `--yes [--format tailwind,ts] [--path file]`. `--force` replaces an existing config. |
|
|
42
|
+
| `uisqueezy pull` | Downloads every output. Unchanged files are not rewritten. |
|
|
43
|
+
| `uisqueezy pull --check` | Writes nothing. Exits **1** if a file is missing or differs from UISqueezy. Use it in CI to keep committed files in sync. |
|
|
44
|
+
| `uisqueezy status` | Shows the API, the token (prefix, name, scopes), the project, and per file whether it is up to date, edited locally, missing or never pulled. |
|
|
45
|
+
|
|
46
|
+
### Global options
|
|
47
|
+
|
|
48
|
+
| Option | |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `-c, --config <path>` | Config file. Default: the nearest `uisqueezy.config.json` from the current directory upwards. |
|
|
51
|
+
| `--api-url <url>` | API base URL. Precedence: this flag, then config `apiUrl`, then `UISQUEEZY_API_URL`, then `https://api.uisqueezy.com`. |
|
|
52
|
+
| `--token-env <name>` | Environment variable holding the token. Default `UISQUEEZY_TOKEN`. |
|
|
53
|
+
| `-q, --quiet` | Print errors only. |
|
|
54
|
+
| `--json` | Print machine-readable JSON on stdout, errors included. |
|
|
55
|
+
|
|
56
|
+
### Exit codes
|
|
57
|
+
|
|
58
|
+
| Code | Meaning |
|
|
59
|
+
|---|---|
|
|
60
|
+
| 0 | Success |
|
|
61
|
+
| 1 | `pull --check` found files that are out of date |
|
|
62
|
+
| 2 | Config or usage error, e.g. invalid config, unknown mode, unknown option |
|
|
63
|
+
| 3 | Token problem: missing, invalid or revoked token, missing `export:read` scope, or a token that belongs to another project |
|
|
64
|
+
| 4 | Network or server problem: unreachable, timeout, 5xx, rate limit. Network errors and 5xx are retried twice first. |
|
|
65
|
+
|
|
66
|
+
## Config: `uisqueezy.config.json`
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"$schema": "https://unpkg.com/@uisqueezy/config@1/schema.json",
|
|
71
|
+
"projectId": "47b1dffa-0341-4ad4-9721-03e21852d264",
|
|
72
|
+
"outputs": [
|
|
73
|
+
{ "format": "tailwind", "path": "src/styles/acme.tailwind.css", "options": { "resetDefaults": true } },
|
|
74
|
+
{ "format": "ts", "path": "src/tokens/acme.tokens.ts", "modes": ["theme/dark"] },
|
|
75
|
+
{ "format": "js", "path": "dist/acme.tokens.js", "options": { "types": true } },
|
|
76
|
+
{ "format": "css", "path": "src/styles/acme.css" }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| Field | |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `projectId` | The project the token belongs to. |
|
|
84
|
+
| `apiUrl` | Optional. Default `https://api.uisqueezy.com`. |
|
|
85
|
+
| `outputs[].format` | `css`, `scss`, `tailwind` (v4), `ts`, `js`, `dtcg`, `resolver` |
|
|
86
|
+
| `outputs[].path` | Relative to the config file. Always use `/`, on Windows too. |
|
|
87
|
+
| `outputs[].modes` | Only these modes, e.g. `["theme/dark"]`. The default mode is always included. Without it you get all modes. An unknown mode fails with the list of available modes. Supported by `css`, `scss`, `tailwind`, `ts` and `js`. |
|
|
88
|
+
| `outputs[].options.resetDefaults` | `tailwind`: drops Tailwind's default theme in the namespaces your project defines. |
|
|
89
|
+
| `outputs[].options.types` | `js`: also writes the `.d.ts` next to the file. |
|
|
90
|
+
|
|
91
|
+
The schema lives in [`@uisqueezy/config`](https://www.npmjs.com/package/@uisqueezy/config). Editors validate and autocomplete the file through `$schema`.
|
|
92
|
+
|
|
93
|
+
The `.uisqueezy/` directory contains only the download cache (ETags). Do not commit it.
|
|
94
|
+
Generated files carry a "Generated by UISqueezy — do not edit" header (JSON formats excepted). Edit tokens in UISqueezy, then run `pull`.
|
|
95
|
+
|
|
96
|
+
### Line endings
|
|
97
|
+
|
|
98
|
+
The server sends LF. A file that Git checked out with CRLF (`core.autocrlf` on Windows) counts as unchanged, so `pull --check` does not fail on Windows runners because of line endings.
|
|
99
|
+
|
|
100
|
+
## CI
|
|
101
|
+
|
|
102
|
+
Two common setups:
|
|
103
|
+
|
|
104
|
+
- **Commit the generated files** and verify them with `pull --check`. Recommended: reviewers see token changes in diffs.
|
|
105
|
+
- **Do not commit them** and run `pull` before the build.
|
|
106
|
+
|
|
107
|
+
### GitHub Actions
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
# .github/workflows/tokens.yml
|
|
111
|
+
name: tokens
|
|
112
|
+
on: [pull_request]
|
|
113
|
+
jobs:
|
|
114
|
+
check:
|
|
115
|
+
runs-on: ubuntu-latest
|
|
116
|
+
steps:
|
|
117
|
+
- uses: actions/checkout@v4
|
|
118
|
+
- uses: actions/setup-node@v4
|
|
119
|
+
with:
|
|
120
|
+
node-version: 22
|
|
121
|
+
- run: npm ci
|
|
122
|
+
- run: npx uisqueezy pull --check
|
|
123
|
+
env:
|
|
124
|
+
UISQUEEZY_TOKEN: ${{ secrets.UISQUEEZY_TOKEN }}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
To pull before the build instead:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
- run: npx uisqueezy pull
|
|
131
|
+
env:
|
|
132
|
+
UISQUEEZY_TOKEN: ${{ secrets.UISQUEEZY_TOKEN }}
|
|
133
|
+
- run: npm run build
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Scheduled sync that opens a PR when tokens change:
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
on:
|
|
140
|
+
schedule: [{ cron: '0 6 * * 1-5' }]
|
|
141
|
+
workflow_dispatch:
|
|
142
|
+
permissions:
|
|
143
|
+
contents: write
|
|
144
|
+
pull-requests: write
|
|
145
|
+
jobs:
|
|
146
|
+
sync:
|
|
147
|
+
runs-on: ubuntu-latest
|
|
148
|
+
steps:
|
|
149
|
+
- uses: actions/checkout@v4
|
|
150
|
+
- uses: actions/setup-node@v4
|
|
151
|
+
with: { node-version: 22 }
|
|
152
|
+
- run: npx uisqueezy@latest pull
|
|
153
|
+
env:
|
|
154
|
+
UISQUEEZY_TOKEN: ${{ secrets.UISQUEEZY_TOKEN }}
|
|
155
|
+
- uses: peter-evans/create-pull-request@v7
|
|
156
|
+
with:
|
|
157
|
+
branch: uisqueezy/tokens
|
|
158
|
+
title: 'chore: update design tokens'
|
|
159
|
+
commit-message: 'chore: update design tokens'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### GitLab CI
|
|
163
|
+
|
|
164
|
+
Add `UISQUEEZY_TOKEN` under **Settings → CI/CD → Variables**, marked *Masked* and *Protected*.
|
|
165
|
+
|
|
166
|
+
```yaml
|
|
167
|
+
# .gitlab-ci.yml
|
|
168
|
+
tokens:check:
|
|
169
|
+
image: node:22
|
|
170
|
+
stage: test
|
|
171
|
+
script:
|
|
172
|
+
- npm ci
|
|
173
|
+
- npx uisqueezy pull --check
|
|
174
|
+
rules:
|
|
175
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
To pull before the build instead:
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
build:
|
|
182
|
+
image: node:22
|
|
183
|
+
script:
|
|
184
|
+
- npm ci
|
|
185
|
+
- npx uisqueezy pull
|
|
186
|
+
- npm run build
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Rate limits
|
|
190
|
+
|
|
191
|
+
Every file in `outputs` is one request, and a `js` output with `types` is two. Unchanged files cost a `304` but still count toward the per-token rate limit. If you hit the limit, the CLI exits **4** and prints when to retry. A short `Retry-After` of 10 seconds or less is waited out automatically, once.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
MIT © Anystation Inc.
|