@uisqueezy/config 0.0.0-stage → 1.0.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 +60 -2
- package/dist/index.cjs +238 -0
- package/dist/index.d.mts +61 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.mjs +204 -0
- package/package.json +53 -3
- package/schema.json +110 -0
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,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @uisqueezy/config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Schema, TypeScript type and validation for `uisqueezy.config.json`, the configuration file of the [UISqueezy CLI](../cli).
|
|
4
|
+
It is the single source of truth for the format. The CLI, the UISqueezy backend and the GitHub App all use this package.
|
|
5
|
+
|
|
6
|
+
```jsonc
|
|
7
|
+
{
|
|
8
|
+
"$schema": "https://unpkg.com/@uisqueezy/config@1/schema.json",
|
|
9
|
+
"projectId": "47b1dffa-0341-4ad4-9721-03e21852d264",
|
|
10
|
+
"outputs": [
|
|
11
|
+
{ "format": "tailwind", "path": "src/styles/acme.tailwind.css", "options": { "resetDefaults": true } },
|
|
12
|
+
{ "format": "ts", "path": "src/tokens/acme.tokens.ts", "modes": ["theme/dark"] },
|
|
13
|
+
{ "format": "js", "path": "dist/acme.tokens.js", "options": { "types": true } },
|
|
14
|
+
{ "format": "css", "path": "src/styles/acme.css" }
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Field | |
|
|
20
|
+
|---|---|
|
|
21
|
+
| `projectId` | Project UUID. The access token must belong to this project. |
|
|
22
|
+
| `apiUrl` | Optional. Default `https://api.uisqueezy.com`. |
|
|
23
|
+
| `outputs[].format` | `css`, `scss`, `dtcg`, `resolver`, `tailwind`, `ts`, `js` |
|
|
24
|
+
| `outputs[].path` | File to write, relative to the config file. |
|
|
25
|
+
| `outputs[].dir` | Reserved for multi-file formats (none yet). |
|
|
26
|
+
| `outputs[].modes` | `["axis/mode"]`: only these modes; the default mode is always included. Not for `dtcg`/`resolver`. |
|
|
27
|
+
| `outputs[].options.resetDefaults` | `tailwind` only. |
|
|
28
|
+
| `outputs[].options.types` | `js` only: also writes the `.d.ts` next to the file. |
|
|
29
|
+
|
|
30
|
+
The access token is **never** stored in this file. A field such as `token` or `apiKey` is rejected (`TOKEN_IN_CONFIG`).
|
|
31
|
+
Use the `UISQUEEZY_TOKEN` environment variable.
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { validateConfig, type UisqueezyConfig, ConfigSchema, FORMATS } from '@uisqueezy/config';
|
|
37
|
+
|
|
38
|
+
const result = validateConfig(JSON.parse(text));
|
|
39
|
+
if (!result.ok) {
|
|
40
|
+
for (const error of result.errors) console.error(`${error.path}: ${error.message}`);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- `ConfigSchema`: TypeBox schema. It is plain JSON Schema and is also published as `@uisqueezy/config/schema.json`.
|
|
45
|
+
- `validateConfig(input)`: returns `{ ok: true, config }` or `{ ok: false, errors: [{ path, message, code }] }`. It applies the schema plus per-format rules.
|
|
46
|
+
- `UisqueezyConfig` and `Output`: TypeScript types.
|
|
47
|
+
- `FORMATS`, `MODE_FORMATS`, `CONFIG_FILE_NAME`, `SCHEMA_URL`, `DEFAULT_API_URL`, `CONFIG_MAJOR`, `typesPathFor()`.
|
|
48
|
+
|
|
49
|
+
The package ships both CommonJS and ES modules and works on Node 18+.
|
|
50
|
+
|
|
51
|
+
## Versioning policy
|
|
52
|
+
|
|
53
|
+
The config file outlives CLI versions: it is committed to user repositories and read by several systems. The rules:
|
|
54
|
+
|
|
55
|
+
1. **A breaking schema change only ships in a new major version.**
|
|
56
|
+
Breaking means a config valid today fails or behaves differently. Examples: removing or renaming a field, making a field required, narrowing allowed values, changing a default.
|
|
57
|
+
Adding an optional field, a new `format` or a new option is a **minor** release.
|
|
58
|
+
2. **Consumers pin the major.** The UISqueezy backend and the GitHub App depend on `"@uisqueezy/config": "^1"` and do not upgrade the major implicitly.
|
|
59
|
+
3. **Two majors side by side during a transition.** When major `N+1` ships, the backend accepts both `N` and `N+1` until the transition ends. It installs both versions under aliases, e.g. `"@uisqueezy/config-v1": "npm:@uisqueezy/config@^1"`, and picks the validator from the file's `$schema` (`…/@uisqueezy/config@N/schema.json`). A file without `$schema` is treated as the oldest supported major.
|
|
60
|
+
4. **The end of a transition is announced** in the changelog and the CLI prints a warning for the old major before support is removed.
|
|
61
|
+
5. The `$schema` URL contains the major (`@1`), so editors validate against the major the file was written for.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
CONFIG_FILE_NAME: () => CONFIG_FILE_NAME,
|
|
24
|
+
CONFIG_MAJOR: () => CONFIG_MAJOR,
|
|
25
|
+
ConfigSchema: () => ConfigSchema,
|
|
26
|
+
DEFAULT_API_URL: () => DEFAULT_API_URL,
|
|
27
|
+
FORMATS: () => FORMATS,
|
|
28
|
+
MODE_FORMATS: () => MODE_FORMATS,
|
|
29
|
+
OutputSchema: () => OutputSchema,
|
|
30
|
+
SCHEMA_URL: () => SCHEMA_URL,
|
|
31
|
+
typesPathFor: () => typesPathFor,
|
|
32
|
+
validateConfig: () => validateConfig
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
|
+
var import_typebox = require("@sinclair/typebox");
|
|
36
|
+
var import_value = require("@sinclair/typebox/value");
|
|
37
|
+
var CONFIG_MAJOR = 1;
|
|
38
|
+
var CONFIG_FILE_NAME = "uisqueezy.config.json";
|
|
39
|
+
var SCHEMA_URL = `https://unpkg.com/@uisqueezy/config@${CONFIG_MAJOR}/schema.json`;
|
|
40
|
+
var DEFAULT_API_URL = "https://api.uisqueezy.com";
|
|
41
|
+
var FORMATS = ["css", "scss", "dtcg", "resolver", "tailwind", "ts", "js"];
|
|
42
|
+
var MODE_FORMATS = ["css", "scss", "tailwind", "ts", "js"];
|
|
43
|
+
var UUID = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$";
|
|
44
|
+
var OutputOptionsSchema = import_typebox.Type.Object(
|
|
45
|
+
{
|
|
46
|
+
resetDefaults: import_typebox.Type.Optional(
|
|
47
|
+
import_typebox.Type.Boolean({
|
|
48
|
+
description: "tailwind only: reset Tailwind's default theme in the namespaces the project uses (e.g. no bg-red-500)."
|
|
49
|
+
})
|
|
50
|
+
),
|
|
51
|
+
types: import_typebox.Type.Optional(
|
|
52
|
+
import_typebox.Type.Boolean({
|
|
53
|
+
description: "js only: also write the type declarations next to the file (`.d.ts`)."
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
},
|
|
57
|
+
{ additionalProperties: false, description: "Format-specific options." }
|
|
58
|
+
);
|
|
59
|
+
var OutputSchema = import_typebox.Type.Object(
|
|
60
|
+
{
|
|
61
|
+
format: import_typebox.Type.Union(
|
|
62
|
+
FORMATS.map((format) => import_typebox.Type.Literal(format)),
|
|
63
|
+
{ description: `Export format: ${FORMATS.join(", ")}.` }
|
|
64
|
+
),
|
|
65
|
+
path: import_typebox.Type.Optional(
|
|
66
|
+
import_typebox.Type.String({
|
|
67
|
+
minLength: 1,
|
|
68
|
+
description: "File to write, relative to this config file."
|
|
69
|
+
})
|
|
70
|
+
),
|
|
71
|
+
dir: import_typebox.Type.Optional(
|
|
72
|
+
import_typebox.Type.String({
|
|
73
|
+
minLength: 1,
|
|
74
|
+
description: "Reserved for multi-file formats; no current format writes a directory."
|
|
75
|
+
})
|
|
76
|
+
),
|
|
77
|
+
modes: import_typebox.Type.Optional(
|
|
78
|
+
import_typebox.Type.Array(
|
|
79
|
+
import_typebox.Type.String({
|
|
80
|
+
pattern: "^[^/\\s]+/[^/\\s]+$",
|
|
81
|
+
description: 'A mode as "axis/mode", e.g. "theme/dark".'
|
|
82
|
+
}),
|
|
83
|
+
{
|
|
84
|
+
minItems: 1,
|
|
85
|
+
uniqueItems: true,
|
|
86
|
+
description: "Only these modes (the default mode is always included). Omit for all modes. css, scss, tailwind, ts and js only."
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
),
|
|
90
|
+
options: import_typebox.Type.Optional(OutputOptionsSchema)
|
|
91
|
+
},
|
|
92
|
+
{ additionalProperties: false }
|
|
93
|
+
);
|
|
94
|
+
var ConfigSchema = import_typebox.Type.Object(
|
|
95
|
+
{
|
|
96
|
+
$schema: import_typebox.Type.Optional(import_typebox.Type.String({ description: "JSON Schema of this file." })),
|
|
97
|
+
projectId: import_typebox.Type.String({
|
|
98
|
+
pattern: UUID,
|
|
99
|
+
description: "UISqueezy project id. The access token must belong to this project."
|
|
100
|
+
}),
|
|
101
|
+
apiUrl: import_typebox.Type.Optional(
|
|
102
|
+
import_typebox.Type.String({
|
|
103
|
+
pattern: "^https?://",
|
|
104
|
+
description: `API base URL. Default: ${DEFAULT_API_URL}.`
|
|
105
|
+
})
|
|
106
|
+
),
|
|
107
|
+
outputs: import_typebox.Type.Array(OutputSchema, {
|
|
108
|
+
minItems: 1,
|
|
109
|
+
description: "Files the CLI writes."
|
|
110
|
+
})
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
$id: SCHEMA_URL,
|
|
114
|
+
title: "UISqueezy config",
|
|
115
|
+
description: "Configuration of the UISqueezy CLI (uisqueezy.config.json). The access token is never stored here: use the UISQUEEZY_TOKEN environment variable.",
|
|
116
|
+
additionalProperties: false
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
var SECRET_KEY = /^(token|access[-_]?token|api[-_]?key|secret|authorization|password)$/i;
|
|
120
|
+
function validateConfig(input) {
|
|
121
|
+
const secrets = findSecretKeys(input, "");
|
|
122
|
+
if (secrets.length > 0) {
|
|
123
|
+
return {
|
|
124
|
+
ok: false,
|
|
125
|
+
errors: secrets.map((path) => ({
|
|
126
|
+
path,
|
|
127
|
+
code: "TOKEN_IN_CONFIG",
|
|
128
|
+
message: "Do not put access tokens in the config file. Remove this field and set the UISQUEEZY_TOKEN environment variable instead."
|
|
129
|
+
}))
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const errors = schemaErrors(input);
|
|
133
|
+
if (errors.length > 0) return { ok: false, errors };
|
|
134
|
+
const config = input;
|
|
135
|
+
const seen = /* @__PURE__ */ new Map();
|
|
136
|
+
config.outputs.forEach((output, index) => {
|
|
137
|
+
const at = `outputs[${index}]`;
|
|
138
|
+
const error = (field, message) => errors.push({ path: field ? `${at}.${field}` : at, message, code: "SCHEMA" });
|
|
139
|
+
if (output.dir !== void 0) {
|
|
140
|
+
error(
|
|
141
|
+
"dir",
|
|
142
|
+
`"dir" is reserved for multi-file formats; ${output.format} writes one file \u2014 use "path".`
|
|
143
|
+
);
|
|
144
|
+
} else if (output.path === void 0) {
|
|
145
|
+
error("", 'Missing "path": the file to write, relative to the config file.');
|
|
146
|
+
}
|
|
147
|
+
if (output.modes && !MODE_FORMATS.includes(output.format)) {
|
|
148
|
+
error(
|
|
149
|
+
"modes",
|
|
150
|
+
`"modes" is not supported for ${output.format} (only ${MODE_FORMATS.join(", ")}).`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (output.options?.resetDefaults !== void 0 && output.format !== "tailwind") {
|
|
154
|
+
error("options.resetDefaults", '"resetDefaults" applies to the tailwind format only.');
|
|
155
|
+
}
|
|
156
|
+
if (output.options?.types !== void 0 && output.format !== "js") {
|
|
157
|
+
error("options.types", '"types" applies to the js format only.');
|
|
158
|
+
}
|
|
159
|
+
const files = output.path ? [output.path] : [];
|
|
160
|
+
if (output.path && output.format === "js" && output.options?.types) {
|
|
161
|
+
files.push(typesPathFor(output.path));
|
|
162
|
+
}
|
|
163
|
+
for (const file of files) {
|
|
164
|
+
const key = normalizePath(file);
|
|
165
|
+
const previous = seen.get(key);
|
|
166
|
+
if (previous !== void 0) {
|
|
167
|
+
error("path", `"${file}" is also written by outputs[${previous}].`);
|
|
168
|
+
} else {
|
|
169
|
+
seen.set(key, index);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return errors.length > 0 ? { ok: false, errors } : { ok: true, config };
|
|
174
|
+
}
|
|
175
|
+
function typesPathFor(path) {
|
|
176
|
+
const match = /\.([mc]?)js$/i.exec(path);
|
|
177
|
+
return match ? `${path.slice(0, match.index)}.d.${match[1]}ts` : `${path}.d.ts`;
|
|
178
|
+
}
|
|
179
|
+
function normalizePath(path) {
|
|
180
|
+
return path.replace(/\\/g, "/").replace(/^(\.\/)+/, "").toLowerCase();
|
|
181
|
+
}
|
|
182
|
+
function findSecretKeys(value, at) {
|
|
183
|
+
if (Array.isArray(value)) {
|
|
184
|
+
return value.flatMap((item, index) => findSecretKeys(item, `${at}[${index}]`));
|
|
185
|
+
}
|
|
186
|
+
if (value === null || typeof value !== "object") return [];
|
|
187
|
+
return Object.entries(value).flatMap(([key, child]) => {
|
|
188
|
+
const path = at ? `${at}.${key}` : key;
|
|
189
|
+
return SECRET_KEY.test(key) ? [path] : findSecretKeys(child, path);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function schemaErrors(input) {
|
|
193
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
194
|
+
return [{ path: "", message: "The config must be a JSON object.", code: "SCHEMA" }];
|
|
195
|
+
}
|
|
196
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
197
|
+
for (const error of import_value.Value.Errors(ConfigSchema, input)) {
|
|
198
|
+
const path = toDotPath(error.path);
|
|
199
|
+
if (byPath.has(path)) continue;
|
|
200
|
+
byPath.set(path, { path, message: describe(path, error.message, error.value), code: "SCHEMA" });
|
|
201
|
+
}
|
|
202
|
+
return [...byPath.values()];
|
|
203
|
+
}
|
|
204
|
+
function describe(path, message, value) {
|
|
205
|
+
const field = path.split(".").pop() ?? "";
|
|
206
|
+
if (/^Expected required property/i.test(message)) return `Missing required field "${field}".`;
|
|
207
|
+
if (/\.format$/.test(path))
|
|
208
|
+
return `Unknown format ${JSON.stringify(value)}; use one of: ${FORMATS.join(", ")}.`;
|
|
209
|
+
if (field === "projectId")
|
|
210
|
+
return "projectId must be the project UUID (project settings \u2192 Access tokens).";
|
|
211
|
+
if (/^outputs\[\d+\]\.modes\[\d+\]$/.test(path))
|
|
212
|
+
return `Mode ${JSON.stringify(value)} must look like "axis/mode", e.g. "theme/dark".`;
|
|
213
|
+
if (path === "outputs" && Array.isArray(value)) {
|
|
214
|
+
return 'outputs must list at least one file, e.g. { "format": "css", "path": "src/tokens.css" }.';
|
|
215
|
+
}
|
|
216
|
+
if (field === "apiUrl") return "apiUrl must start with https:// (or http:// for local servers).";
|
|
217
|
+
if (/^Unexpected property/i.test(message)) return `Unknown field "${field}".`;
|
|
218
|
+
return message;
|
|
219
|
+
}
|
|
220
|
+
function toDotPath(pointer) {
|
|
221
|
+
return pointer.split("/").slice(1).map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce(
|
|
222
|
+
(acc, part) => /^\d+$/.test(part) ? `${acc}[${part}]` : acc ? `${acc}.${part}` : part,
|
|
223
|
+
""
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
227
|
+
0 && (module.exports = {
|
|
228
|
+
CONFIG_FILE_NAME,
|
|
229
|
+
CONFIG_MAJOR,
|
|
230
|
+
ConfigSchema,
|
|
231
|
+
DEFAULT_API_URL,
|
|
232
|
+
FORMATS,
|
|
233
|
+
MODE_FORMATS,
|
|
234
|
+
OutputSchema,
|
|
235
|
+
SCHEMA_URL,
|
|
236
|
+
typesPathFor,
|
|
237
|
+
validateConfig
|
|
238
|
+
});
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `uisqueezy.config.json`: the single source of the schema, the TypeScript type and validation.
|
|
3
|
+
* Used by the UISqueezy CLI, the UISqueezy backend and the GitHub App. Breaking changes only in a
|
|
4
|
+
* new major version — see README.
|
|
5
|
+
*/
|
|
6
|
+
import { type Static } from '@sinclair/typebox';
|
|
7
|
+
/** Major version of this schema; also part of {@link SCHEMA_URL}. */
|
|
8
|
+
export declare const CONFIG_MAJOR = 1;
|
|
9
|
+
export declare const CONFIG_FILE_NAME = "uisqueezy.config.json";
|
|
10
|
+
export declare const SCHEMA_URL = "https://unpkg.com/@uisqueezy/config@1/schema.json";
|
|
11
|
+
export declare const DEFAULT_API_URL = "https://api.uisqueezy.com";
|
|
12
|
+
/** Export formats (`GET /api/v1/ui/variables/:projectId/export?format=…`). */
|
|
13
|
+
export declare const FORMATS: readonly ["css", "scss", "dtcg", "resolver", "tailwind", "ts", "js"];
|
|
14
|
+
export type Format = (typeof FORMATS)[number];
|
|
15
|
+
/** Formats that accept a `modes` selection (DTCG has the default mode only, resolver all modes). */
|
|
16
|
+
export declare const MODE_FORMATS: readonly Format[];
|
|
17
|
+
export declare const OutputSchema: import("@sinclair/typebox").TObject<{
|
|
18
|
+
format: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"css" | "scss" | "dtcg" | "resolver" | "tailwind" | "ts" | "js">[]>;
|
|
19
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
20
|
+
dir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
|
+
modes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
22
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
23
|
+
resetDefaults: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
24
|
+
types: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
25
|
+
}>>;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const ConfigSchema: import("@sinclair/typebox").TObject<{
|
|
28
|
+
$schema: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
29
|
+
projectId: import("@sinclair/typebox").TString;
|
|
30
|
+
apiUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
|
+
outputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
32
|
+
format: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"css" | "scss" | "dtcg" | "resolver" | "tailwind" | "ts" | "js">[]>;
|
|
33
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
34
|
+
dir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
35
|
+
modes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
36
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
37
|
+
resetDefaults: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
38
|
+
types: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
39
|
+
}>>;
|
|
40
|
+
}>>;
|
|
41
|
+
}>;
|
|
42
|
+
export type UisqueezyConfig = Static<typeof ConfigSchema>;
|
|
43
|
+
export type Output = Static<typeof OutputSchema>;
|
|
44
|
+
export interface ConfigError {
|
|
45
|
+
/** Location in the file, e.g. `outputs[1].format`; empty for the whole file. */
|
|
46
|
+
path: string;
|
|
47
|
+
message: string;
|
|
48
|
+
/** `TOKEN_IN_CONFIG` for a secret in the file; `SCHEMA` otherwise. */
|
|
49
|
+
code: 'TOKEN_IN_CONFIG' | 'SCHEMA';
|
|
50
|
+
}
|
|
51
|
+
export type ValidationResult = {
|
|
52
|
+
ok: true;
|
|
53
|
+
config: UisqueezyConfig;
|
|
54
|
+
} | {
|
|
55
|
+
ok: false;
|
|
56
|
+
errors: ConfigError[];
|
|
57
|
+
};
|
|
58
|
+
/** Validates a parsed config file: the schema plus rules JSON Schema cannot express well. */
|
|
59
|
+
export declare function validateConfig(input: unknown): ValidationResult;
|
|
60
|
+
/** `tokens.js` → `tokens.d.ts`, `tokens.mjs` → `tokens.d.mts`, `tokens.cjs` → `tokens.d.cts`. */
|
|
61
|
+
export declare function typesPathFor(path: string): string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `uisqueezy.config.json`: the single source of the schema, the TypeScript type and validation.
|
|
3
|
+
* Used by the UISqueezy CLI, the UISqueezy backend and the GitHub App. Breaking changes only in a
|
|
4
|
+
* new major version — see README.
|
|
5
|
+
*/
|
|
6
|
+
import { type Static } from '@sinclair/typebox';
|
|
7
|
+
/** Major version of this schema; also part of {@link SCHEMA_URL}. */
|
|
8
|
+
export declare const CONFIG_MAJOR = 1;
|
|
9
|
+
export declare const CONFIG_FILE_NAME = "uisqueezy.config.json";
|
|
10
|
+
export declare const SCHEMA_URL = "https://unpkg.com/@uisqueezy/config@1/schema.json";
|
|
11
|
+
export declare const DEFAULT_API_URL = "https://api.uisqueezy.com";
|
|
12
|
+
/** Export formats (`GET /api/v1/ui/variables/:projectId/export?format=…`). */
|
|
13
|
+
export declare const FORMATS: readonly ["css", "scss", "dtcg", "resolver", "tailwind", "ts", "js"];
|
|
14
|
+
export type Format = (typeof FORMATS)[number];
|
|
15
|
+
/** Formats that accept a `modes` selection (DTCG has the default mode only, resolver all modes). */
|
|
16
|
+
export declare const MODE_FORMATS: readonly Format[];
|
|
17
|
+
export declare const OutputSchema: import("@sinclair/typebox").TObject<{
|
|
18
|
+
format: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"css" | "scss" | "dtcg" | "resolver" | "tailwind" | "ts" | "js">[]>;
|
|
19
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
20
|
+
dir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
|
+
modes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
22
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
23
|
+
resetDefaults: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
24
|
+
types: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
25
|
+
}>>;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const ConfigSchema: import("@sinclair/typebox").TObject<{
|
|
28
|
+
$schema: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
29
|
+
projectId: import("@sinclair/typebox").TString;
|
|
30
|
+
apiUrl: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
|
+
outputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
32
|
+
format: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"css" | "scss" | "dtcg" | "resolver" | "tailwind" | "ts" | "js">[]>;
|
|
33
|
+
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
34
|
+
dir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
35
|
+
modes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
36
|
+
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
37
|
+
resetDefaults: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
38
|
+
types: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
39
|
+
}>>;
|
|
40
|
+
}>>;
|
|
41
|
+
}>;
|
|
42
|
+
export type UisqueezyConfig = Static<typeof ConfigSchema>;
|
|
43
|
+
export type Output = Static<typeof OutputSchema>;
|
|
44
|
+
export interface ConfigError {
|
|
45
|
+
/** Location in the file, e.g. `outputs[1].format`; empty for the whole file. */
|
|
46
|
+
path: string;
|
|
47
|
+
message: string;
|
|
48
|
+
/** `TOKEN_IN_CONFIG` for a secret in the file; `SCHEMA` otherwise. */
|
|
49
|
+
code: 'TOKEN_IN_CONFIG' | 'SCHEMA';
|
|
50
|
+
}
|
|
51
|
+
export type ValidationResult = {
|
|
52
|
+
ok: true;
|
|
53
|
+
config: UisqueezyConfig;
|
|
54
|
+
} | {
|
|
55
|
+
ok: false;
|
|
56
|
+
errors: ConfigError[];
|
|
57
|
+
};
|
|
58
|
+
/** Validates a parsed config file: the schema plus rules JSON Schema cannot express well. */
|
|
59
|
+
export declare function validateConfig(input: unknown): ValidationResult;
|
|
60
|
+
/** `tokens.js` → `tokens.d.ts`, `tokens.mjs` → `tokens.d.mts`, `tokens.cjs` → `tokens.d.cts`. */
|
|
61
|
+
export declare function typesPathFor(path: string): string;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { Value } from "@sinclair/typebox/value";
|
|
4
|
+
var CONFIG_MAJOR = 1;
|
|
5
|
+
var CONFIG_FILE_NAME = "uisqueezy.config.json";
|
|
6
|
+
var SCHEMA_URL = `https://unpkg.com/@uisqueezy/config@${CONFIG_MAJOR}/schema.json`;
|
|
7
|
+
var DEFAULT_API_URL = "https://api.uisqueezy.com";
|
|
8
|
+
var FORMATS = ["css", "scss", "dtcg", "resolver", "tailwind", "ts", "js"];
|
|
9
|
+
var MODE_FORMATS = ["css", "scss", "tailwind", "ts", "js"];
|
|
10
|
+
var UUID = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$";
|
|
11
|
+
var OutputOptionsSchema = Type.Object(
|
|
12
|
+
{
|
|
13
|
+
resetDefaults: Type.Optional(
|
|
14
|
+
Type.Boolean({
|
|
15
|
+
description: "tailwind only: reset Tailwind's default theme in the namespaces the project uses (e.g. no bg-red-500)."
|
|
16
|
+
})
|
|
17
|
+
),
|
|
18
|
+
types: Type.Optional(
|
|
19
|
+
Type.Boolean({
|
|
20
|
+
description: "js only: also write the type declarations next to the file (`.d.ts`)."
|
|
21
|
+
})
|
|
22
|
+
)
|
|
23
|
+
},
|
|
24
|
+
{ additionalProperties: false, description: "Format-specific options." }
|
|
25
|
+
);
|
|
26
|
+
var OutputSchema = Type.Object(
|
|
27
|
+
{
|
|
28
|
+
format: Type.Union(
|
|
29
|
+
FORMATS.map((format) => Type.Literal(format)),
|
|
30
|
+
{ description: `Export format: ${FORMATS.join(", ")}.` }
|
|
31
|
+
),
|
|
32
|
+
path: Type.Optional(
|
|
33
|
+
Type.String({
|
|
34
|
+
minLength: 1,
|
|
35
|
+
description: "File to write, relative to this config file."
|
|
36
|
+
})
|
|
37
|
+
),
|
|
38
|
+
dir: Type.Optional(
|
|
39
|
+
Type.String({
|
|
40
|
+
minLength: 1,
|
|
41
|
+
description: "Reserved for multi-file formats; no current format writes a directory."
|
|
42
|
+
})
|
|
43
|
+
),
|
|
44
|
+
modes: Type.Optional(
|
|
45
|
+
Type.Array(
|
|
46
|
+
Type.String({
|
|
47
|
+
pattern: "^[^/\\s]+/[^/\\s]+$",
|
|
48
|
+
description: 'A mode as "axis/mode", e.g. "theme/dark".'
|
|
49
|
+
}),
|
|
50
|
+
{
|
|
51
|
+
minItems: 1,
|
|
52
|
+
uniqueItems: true,
|
|
53
|
+
description: "Only these modes (the default mode is always included). Omit for all modes. css, scss, tailwind, ts and js only."
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
),
|
|
57
|
+
options: Type.Optional(OutputOptionsSchema)
|
|
58
|
+
},
|
|
59
|
+
{ additionalProperties: false }
|
|
60
|
+
);
|
|
61
|
+
var ConfigSchema = Type.Object(
|
|
62
|
+
{
|
|
63
|
+
$schema: Type.Optional(Type.String({ description: "JSON Schema of this file." })),
|
|
64
|
+
projectId: Type.String({
|
|
65
|
+
pattern: UUID,
|
|
66
|
+
description: "UISqueezy project id. The access token must belong to this project."
|
|
67
|
+
}),
|
|
68
|
+
apiUrl: Type.Optional(
|
|
69
|
+
Type.String({
|
|
70
|
+
pattern: "^https?://",
|
|
71
|
+
description: `API base URL. Default: ${DEFAULT_API_URL}.`
|
|
72
|
+
})
|
|
73
|
+
),
|
|
74
|
+
outputs: Type.Array(OutputSchema, {
|
|
75
|
+
minItems: 1,
|
|
76
|
+
description: "Files the CLI writes."
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
$id: SCHEMA_URL,
|
|
81
|
+
title: "UISqueezy config",
|
|
82
|
+
description: "Configuration of the UISqueezy CLI (uisqueezy.config.json). The access token is never stored here: use the UISQUEEZY_TOKEN environment variable.",
|
|
83
|
+
additionalProperties: false
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
var SECRET_KEY = /^(token|access[-_]?token|api[-_]?key|secret|authorization|password)$/i;
|
|
87
|
+
function validateConfig(input) {
|
|
88
|
+
const secrets = findSecretKeys(input, "");
|
|
89
|
+
if (secrets.length > 0) {
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
errors: secrets.map((path) => ({
|
|
93
|
+
path,
|
|
94
|
+
code: "TOKEN_IN_CONFIG",
|
|
95
|
+
message: "Do not put access tokens in the config file. Remove this field and set the UISQUEEZY_TOKEN environment variable instead."
|
|
96
|
+
}))
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const errors = schemaErrors(input);
|
|
100
|
+
if (errors.length > 0) return { ok: false, errors };
|
|
101
|
+
const config = input;
|
|
102
|
+
const seen = /* @__PURE__ */ new Map();
|
|
103
|
+
config.outputs.forEach((output, index) => {
|
|
104
|
+
const at = `outputs[${index}]`;
|
|
105
|
+
const error = (field, message) => errors.push({ path: field ? `${at}.${field}` : at, message, code: "SCHEMA" });
|
|
106
|
+
if (output.dir !== void 0) {
|
|
107
|
+
error(
|
|
108
|
+
"dir",
|
|
109
|
+
`"dir" is reserved for multi-file formats; ${output.format} writes one file \u2014 use "path".`
|
|
110
|
+
);
|
|
111
|
+
} else if (output.path === void 0) {
|
|
112
|
+
error("", 'Missing "path": the file to write, relative to the config file.');
|
|
113
|
+
}
|
|
114
|
+
if (output.modes && !MODE_FORMATS.includes(output.format)) {
|
|
115
|
+
error(
|
|
116
|
+
"modes",
|
|
117
|
+
`"modes" is not supported for ${output.format} (only ${MODE_FORMATS.join(", ")}).`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
if (output.options?.resetDefaults !== void 0 && output.format !== "tailwind") {
|
|
121
|
+
error("options.resetDefaults", '"resetDefaults" applies to the tailwind format only.');
|
|
122
|
+
}
|
|
123
|
+
if (output.options?.types !== void 0 && output.format !== "js") {
|
|
124
|
+
error("options.types", '"types" applies to the js format only.');
|
|
125
|
+
}
|
|
126
|
+
const files = output.path ? [output.path] : [];
|
|
127
|
+
if (output.path && output.format === "js" && output.options?.types) {
|
|
128
|
+
files.push(typesPathFor(output.path));
|
|
129
|
+
}
|
|
130
|
+
for (const file of files) {
|
|
131
|
+
const key = normalizePath(file);
|
|
132
|
+
const previous = seen.get(key);
|
|
133
|
+
if (previous !== void 0) {
|
|
134
|
+
error("path", `"${file}" is also written by outputs[${previous}].`);
|
|
135
|
+
} else {
|
|
136
|
+
seen.set(key, index);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
return errors.length > 0 ? { ok: false, errors } : { ok: true, config };
|
|
141
|
+
}
|
|
142
|
+
function typesPathFor(path) {
|
|
143
|
+
const match = /\.([mc]?)js$/i.exec(path);
|
|
144
|
+
return match ? `${path.slice(0, match.index)}.d.${match[1]}ts` : `${path}.d.ts`;
|
|
145
|
+
}
|
|
146
|
+
function normalizePath(path) {
|
|
147
|
+
return path.replace(/\\/g, "/").replace(/^(\.\/)+/, "").toLowerCase();
|
|
148
|
+
}
|
|
149
|
+
function findSecretKeys(value, at) {
|
|
150
|
+
if (Array.isArray(value)) {
|
|
151
|
+
return value.flatMap((item, index) => findSecretKeys(item, `${at}[${index}]`));
|
|
152
|
+
}
|
|
153
|
+
if (value === null || typeof value !== "object") return [];
|
|
154
|
+
return Object.entries(value).flatMap(([key, child]) => {
|
|
155
|
+
const path = at ? `${at}.${key}` : key;
|
|
156
|
+
return SECRET_KEY.test(key) ? [path] : findSecretKeys(child, path);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function schemaErrors(input) {
|
|
160
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
161
|
+
return [{ path: "", message: "The config must be a JSON object.", code: "SCHEMA" }];
|
|
162
|
+
}
|
|
163
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const error of Value.Errors(ConfigSchema, input)) {
|
|
165
|
+
const path = toDotPath(error.path);
|
|
166
|
+
if (byPath.has(path)) continue;
|
|
167
|
+
byPath.set(path, { path, message: describe(path, error.message, error.value), code: "SCHEMA" });
|
|
168
|
+
}
|
|
169
|
+
return [...byPath.values()];
|
|
170
|
+
}
|
|
171
|
+
function describe(path, message, value) {
|
|
172
|
+
const field = path.split(".").pop() ?? "";
|
|
173
|
+
if (/^Expected required property/i.test(message)) return `Missing required field "${field}".`;
|
|
174
|
+
if (/\.format$/.test(path))
|
|
175
|
+
return `Unknown format ${JSON.stringify(value)}; use one of: ${FORMATS.join(", ")}.`;
|
|
176
|
+
if (field === "projectId")
|
|
177
|
+
return "projectId must be the project UUID (project settings \u2192 Access tokens).";
|
|
178
|
+
if (/^outputs\[\d+\]\.modes\[\d+\]$/.test(path))
|
|
179
|
+
return `Mode ${JSON.stringify(value)} must look like "axis/mode", e.g. "theme/dark".`;
|
|
180
|
+
if (path === "outputs" && Array.isArray(value)) {
|
|
181
|
+
return 'outputs must list at least one file, e.g. { "format": "css", "path": "src/tokens.css" }.';
|
|
182
|
+
}
|
|
183
|
+
if (field === "apiUrl") return "apiUrl must start with https:// (or http:// for local servers).";
|
|
184
|
+
if (/^Unexpected property/i.test(message)) return `Unknown field "${field}".`;
|
|
185
|
+
return message;
|
|
186
|
+
}
|
|
187
|
+
function toDotPath(pointer) {
|
|
188
|
+
return pointer.split("/").slice(1).map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce(
|
|
189
|
+
(acc, part) => /^\d+$/.test(part) ? `${acc}[${part}]` : acc ? `${acc}.${part}` : part,
|
|
190
|
+
""
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
CONFIG_FILE_NAME,
|
|
195
|
+
CONFIG_MAJOR,
|
|
196
|
+
ConfigSchema,
|
|
197
|
+
DEFAULT_API_URL,
|
|
198
|
+
FORMATS,
|
|
199
|
+
MODE_FORMATS,
|
|
200
|
+
OutputSchema,
|
|
201
|
+
SCHEMA_URL,
|
|
202
|
+
typesPathFor,
|
|
203
|
+
validateConfig
|
|
204
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uisqueezy/config",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Schema, types and validation for uisqueezy.config.json (UISqueezy CLI and integrations).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Anystation Inc.",
|
|
7
|
+
"homepage": "https://github.com/uisqueezylabs/uisqueezy-cli/tree/main/packages/config#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/uisqueezylabs/uisqueezy-cli.git",
|
|
11
|
+
"directory": "packages/config"
|
|
12
|
+
},
|
|
13
|
+
"bugs": "https://github.com/uisqueezylabs/uisqueezy-cli/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"uisqueezy",
|
|
16
|
+
"design-tokens",
|
|
17
|
+
"config",
|
|
18
|
+
"json-schema"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
30
|
+
"default": "./dist/index.mjs"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.cjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"./schema.json": "./schema.json",
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"schema.json"
|
|
43
|
+
],
|
|
44
|
+
"sideEffects": false,
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@sinclair/typebox": "0.34.41"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "node scripts/build.mjs",
|
|
53
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
54
|
+
"test": "vitest run"
|
|
55
|
+
}
|
|
6
56
|
}
|
package/schema.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "https://unpkg.com/@uisqueezy/config@1/schema.json",
|
|
3
|
+
"title": "UISqueezy config",
|
|
4
|
+
"description": "Configuration of the UISqueezy CLI (uisqueezy.config.json). The access token is never stored here: use the UISQUEEZY_TOKEN environment variable.",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": {
|
|
9
|
+
"description": "JSON Schema of this file.",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"projectId": {
|
|
13
|
+
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
|
|
14
|
+
"description": "UISqueezy project id. The access token must belong to this project.",
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"apiUrl": {
|
|
18
|
+
"pattern": "^https?://",
|
|
19
|
+
"description": "API base URL. Default: https://api.uisqueezy.com.",
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"outputs": {
|
|
23
|
+
"minItems": 1,
|
|
24
|
+
"description": "Files the CLI writes.",
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": {
|
|
27
|
+
"additionalProperties": false,
|
|
28
|
+
"type": "object",
|
|
29
|
+
"properties": {
|
|
30
|
+
"format": {
|
|
31
|
+
"description": "Export format: css, scss, dtcg, resolver, tailwind, ts, js.",
|
|
32
|
+
"anyOf": [
|
|
33
|
+
{
|
|
34
|
+
"const": "css",
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"const": "scss",
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"const": "dtcg",
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"const": "resolver",
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"const": "tailwind",
|
|
51
|
+
"type": "string"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"const": "ts",
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"const": "js",
|
|
59
|
+
"type": "string"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"path": {
|
|
64
|
+
"minLength": 1,
|
|
65
|
+
"description": "File to write, relative to this config file.",
|
|
66
|
+
"type": "string"
|
|
67
|
+
},
|
|
68
|
+
"dir": {
|
|
69
|
+
"minLength": 1,
|
|
70
|
+
"description": "Reserved for multi-file formats; no current format writes a directory.",
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"modes": {
|
|
74
|
+
"minItems": 1,
|
|
75
|
+
"uniqueItems": true,
|
|
76
|
+
"description": "Only these modes (the default mode is always included). Omit for all modes. css, scss, tailwind, ts and js only.",
|
|
77
|
+
"type": "array",
|
|
78
|
+
"items": {
|
|
79
|
+
"pattern": "^[^/\\s]+/[^/\\s]+$",
|
|
80
|
+
"description": "A mode as \"axis/mode\", e.g. \"theme/dark\".",
|
|
81
|
+
"type": "string"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"options": {
|
|
85
|
+
"additionalProperties": false,
|
|
86
|
+
"description": "Format-specific options.",
|
|
87
|
+
"type": "object",
|
|
88
|
+
"properties": {
|
|
89
|
+
"resetDefaults": {
|
|
90
|
+
"description": "tailwind only: reset Tailwind's default theme in the namespaces the project uses (e.g. no bg-red-500).",
|
|
91
|
+
"type": "boolean"
|
|
92
|
+
},
|
|
93
|
+
"types": {
|
|
94
|
+
"description": "js only: also write the type declarations next to the file (`.d.ts`).",
|
|
95
|
+
"type": "boolean"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"required": [
|
|
101
|
+
"format"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"required": [
|
|
107
|
+
"projectId",
|
|
108
|
+
"outputs"
|
|
109
|
+
]
|
|
110
|
+
}
|