@token-forge/core 0.3.3 → 0.3.4-nightly-20260725040904
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/README.md +59 -0
- package/package.json +5 -5
- package/src/terrazzo-pipeline.ts +13 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @token-forge/core
|
|
2
|
+
|
|
3
|
+
Token Forge pipeline bundle — profile definition, the Terrazzo build pipeline, and re-exports of `@token-forge/lib`, `@token-forge/plugins`, and `@token-forge/token-schema` in one package.
|
|
4
|
+
|
|
5
|
+
Most consumers won't import this directly — it's pulled in automatically by [`@token-forge/cli`](https://www.npmjs.com/package/@token-forge/cli). Use it when you want to build a custom `terrazzo.config.ts` or bootstrap a design-system profile from code.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @token-forge/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
A consumer's `design-system.config.ts` calls `defineDesignSystemProfile` (re-exported from `@token-forge/lib`):
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { defineDesignSystemProfile } from "@token-forge/core";
|
|
19
|
+
|
|
20
|
+
export const designSystemProfile = defineDesignSystemProfile({
|
|
21
|
+
id: "acme",
|
|
22
|
+
designSystems: [{ id: "acme" }],
|
|
23
|
+
tokenLayers: ["quarks", "color", "fixed", "fluid"],
|
|
24
|
+
themes: { modifier: "theme", lightSuffix: "-light", darkSuffix: "-dark" },
|
|
25
|
+
outputs: { plugins: ["css-variables", "typography"] },
|
|
26
|
+
figma: { terrazzoRemap: "./remappers/acme.ts", sources: [/* … */] },
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
A thin `terrazzo.config.ts` builds on top of the profile:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// @token-forge/core/terrazzo
|
|
34
|
+
import { createTerrazzoPipeline } from "@token-forge/core/terrazzo";
|
|
35
|
+
import { designSystemProfile, SYSTEM_IDS } from "./design-system.config";
|
|
36
|
+
|
|
37
|
+
export const { configForSystem } = createTerrazzoPipeline({
|
|
38
|
+
profile: designSystemProfile,
|
|
39
|
+
systems: SYSTEM_IDS,
|
|
40
|
+
repoRoot: import.meta.dirname,
|
|
41
|
+
});
|
|
42
|
+
export default configForSystem(SYSTEM_IDS[0]);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Exports
|
|
46
|
+
|
|
47
|
+
| Entry point | What it provides |
|
|
48
|
+
| ----------------------------- | --------------------------------------------------------------------------------------------- |
|
|
49
|
+
| `@token-forge/core` | Profile schema, pipeline helpers, and everything from `lib`/`plugins`/`token-schema` |
|
|
50
|
+
| `@token-forge/core/bootstrap` | `bootstrapDesignSystem` — register a profile from code without a config file |
|
|
51
|
+
| `@token-forge/core/terrazzo` | `createTerrazzoPipeline` — builds `terrazzo.config.ts`'s `configForSystem`/`pluginsForSystem` |
|
|
52
|
+
|
|
53
|
+
## Docs
|
|
54
|
+
|
|
55
|
+
Full setup guide: [Adopting `@token-forge/core`](https://github.com/blabassi/token-forge/blob/main/docs/adopting-core.md).
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@token-forge/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4-nightly-20260725040904",
|
|
4
4
|
"description": "Token Forge pipeline bundle — profile, Terrazzo plugins, token schema, Figma import",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Badi Labassi",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@terrazzo/cli": "^2.2.0",
|
|
26
26
|
"@terrazzo/plugin-css": "^2.2.0",
|
|
27
|
-
"@token-forge/lib": "0.3.
|
|
28
|
-
"@token-forge/plugins": "0.3.
|
|
29
|
-
"@token-forge/figma-importer": "0.3.
|
|
30
|
-
"@token-forge/token-schema": "0.3.
|
|
27
|
+
"@token-forge/lib": "0.3.4-nightly-20260725040904",
|
|
28
|
+
"@token-forge/plugins": "0.3.4-nightly-20260725040904",
|
|
29
|
+
"@token-forge/figma-importer": "0.3.4-nightly-20260725040904",
|
|
30
|
+
"@token-forge/token-schema": "0.3.4-nightly-20260725040904"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^24.0.0",
|
package/src/terrazzo-pipeline.ts
CHANGED
|
@@ -92,8 +92,21 @@ export function resolveOutputPluginsSync(
|
|
|
92
92
|
if (!entries.length) {
|
|
93
93
|
throw new Error("profile.outputs.plugins must be a non-empty list");
|
|
94
94
|
}
|
|
95
|
+
const seenRefsById = new Map<string, string>();
|
|
95
96
|
const plugins = entries.map((entry) => {
|
|
96
97
|
const id = isPathRef(entry.id) ? derivedIdFromPath(entry.id) : entry.id;
|
|
98
|
+
const previousRef = seenRefsById.get(id);
|
|
99
|
+
if (previousRef !== undefined && previousRef !== entry.id) {
|
|
100
|
+
// Two distinct plugin refs (e.g. "./plugins/foo.ts" and "./shared/foo.ts") derive the
|
|
101
|
+
// same registry id from their filename — they'll silently resolve to the same
|
|
102
|
+
// registered plugin instead of two different ones. Warn instead of running one plugin
|
|
103
|
+
// twice with no indication the other was never actually loaded.
|
|
104
|
+
console.warn(
|
|
105
|
+
`resolveOutputPluginsSync: "${entry.id}" and "${previousRef}" both derive plugin id "${id}" — ` +
|
|
106
|
+
`they will resolve to the same registered plugin. Rename one file to avoid this collision.`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
seenRefsById.set(id, entry.id);
|
|
97
110
|
try {
|
|
98
111
|
return { plugin: getBuildPlugin(id), options: entry.options };
|
|
99
112
|
} catch {
|