styleflow 0.1.0 → 0.1.1

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 CHANGED
@@ -9,18 +9,21 @@ npm install --save-dev styleflow
9
9
  ```
10
10
 
11
11
  ## Quick start
12
+ ## Quick Start
12
13
 
13
14
  ```bash
14
15
  npx styleflow init
15
16
  npx styleflow pull
16
17
  npx styleflow build
18
+ npx styleflow doctor
17
19
  ```
18
20
 
19
21
  ## Commands
20
22
 
21
23
  - `styleflow init`: create `styleflow.config.ts` and ensure required `.env` keys.
22
- - `styleflow pull [all|tokens|stylesheet|figma-styles]`: pull project artifacts.
24
+ - `styleflow pull [all|tokens|stylesheet|figma-styles|published]`: pull project artifacts.
23
25
  - `styleflow build`: build output files from pulled artifacts.
26
+ - `styleflow doctor`: validate config/env/auth and local raw/build paths.
24
27
 
25
28
  ## Environment
26
29
 
@@ -28,3 +31,54 @@ npx styleflow build
28
31
  - `STYLEFLOW_PROJECT_ID`
29
32
  - `STYLEFLOW_API_URL` (default: `https://api.styleflow.app`)
30
33
  - `STYLEFLOW_PROJECT_VERSION_ID` (optional)
34
+ ## Environment Variables
35
+
36
+ - `STYLEFLOW_TOKEN`: JWT token from StyleFlow (`/api/users/login`).
37
+ - `STYLEFLOW_PROJECT_ID`: project slug/id.
38
+ - `STYLEFLOW_API_URL`: API base URL (default `https://api.styleflow.app`).
39
+ - `STYLEFLOW_PROJECT_VERSION_ID`: optional project version scope.
40
+
41
+ ## Config
42
+
43
+ `styleflow.config.ts`:
44
+
45
+ ```ts
46
+ export default {
47
+ projectId: process.env.STYLEFLOW_PROJECT_ID,
48
+ apiUrl: process.env.STYLEFLOW_API_URL ?? "https://api.styleflow.app",
49
+ rawDirectory: ".styleflow/raw",
50
+ output: {
51
+ tokens: { format: "css", path: "src/styles/styleflow-tokens.css" },
52
+ stylesheet: { format: "json", path: ".styleflow/build/stylesheet.json" },
53
+ figmaStyles: { format: "json", path: ".styleflow/build/figma-styles.json" },
54
+ published: { format: "json", path: ".styleflow/build/published.json" },
55
+ components: { path: ".styleflow/build/components", framework: "react", styling: "tailwind" }
56
+ },
57
+ mapping: {
58
+ classes: {
59
+ "btn-primary": "btn btn-primary"
60
+ }
61
+ }
62
+ };
63
+ ```
64
+
65
+ If you prefer type helpers, you can also use `defineConfig`:
66
+
67
+ ```ts
68
+ import { defineConfig } from "styleflow";
69
+ export default defineConfig({ /* ... */ });
70
+ ```
71
+
72
+ ## Commands
73
+
74
+ - `styleflow init`: scaffold `styleflow.config.ts` and env keys.
75
+ - `styleflow pull [all|tokens|stylesheet|figma-styles|published]`: pull project data into raw folder.
76
+ - `styleflow build`: generate output files from pulled raw data.
77
+ - `styleflow doctor [--no-network]`: run health checks (auth/config/filesystem).
78
+ - `styleflow get:all|get:tokens|get:stylesheet|get:figma-styles|get:published`: aliases for pull.
79
+
80
+ ## Notes
81
+
82
+ - `pull` writes raw artifacts in `.styleflow/raw` by default.
83
+ - `build` supports token formats: `css`, `scss`, `json`, `style-dictionary`, `tailwind`.
84
+ - `components` output currently generates a class mapping manifest from stylesheet classes.
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,8BAA8B,EAG/B,MAAM,YAAY,CAAC;AAEpB,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAyED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,WAAW,CAAC,CA4ItB"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,8BAA8B,EAG/B,MAAM,YAAY,CAAC;AAEpB,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAyED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,WAAW,CAAC,CA+JtB"}
package/dist/build.js CHANGED
@@ -158,6 +158,23 @@ export async function buildStyleflowOutputs(runtime) {
158
158
  warnings.push(`Figma styles output skipped: raw file not found at "${figmaStylesRawPath}".`);
159
159
  }
160
160
  }
161
+ const publishedOutput = runtime.config.output?.published;
162
+ if (publishedOutput?.path) {
163
+ const publishedRawPath = getRawFilePath(runtime, "published.json");
164
+ try {
165
+ const publishedData = await readJsonFile(publishedRawPath);
166
+ const resolvedOutputPath = path.resolve(runtime.cwd, publishedOutput.path);
167
+ await writeJsonFile(resolvedOutputPath, publishedData);
168
+ outputFiles.push({
169
+ type: "published",
170
+ format: "json",
171
+ path: resolvedOutputPath,
172
+ });
173
+ }
174
+ catch {
175
+ warnings.push(`Published output skipped: raw file not found at "${publishedRawPath}".`);
176
+ }
177
+ }
161
178
  const componentsOutput = runtime.config.output?.components;
162
179
  if (componentsOutput?.path) {
163
180
  const stylesheetRawPath = getRawFilePath(runtime, "stylesheet.json");
package/dist/cli.js CHANGED
@@ -6,6 +6,8 @@ import { Command } from "commander";
6
6
  import { ensureEnvKeys, getDefaultConfigTemplate, loadStyleflowConfig, resolveRuntimeConfig, } from "./config.js";
7
7
  import { buildStyleflowOutputs } from "./build.js";
8
8
  import { normalizePullResources, pullStyleflowData } from "./pull.js";
9
+ import { ensureDirectory, readJsonFile } from "./fs.js";
10
+ import { ApiError, apiGetJson } from "./http.js";
9
11
  const CLI_VERSION = "0.1.0";
10
12
  function formatError(error) {
11
13
  if (error instanceof Error)
@@ -18,6 +20,17 @@ function logInfo(message) {
18
20
  function logWarn(message) {
19
21
  process.stderr.write(`[styleflow] ${message}\n`);
20
22
  }
23
+ function logDoctorCheck(check) {
24
+ if (check.status === "ok") {
25
+ logInfo(`[ok] ${check.id}: ${check.message}`);
26
+ return;
27
+ }
28
+ if (check.status === "warn") {
29
+ logWarn(`[warn] ${check.id}: ${check.message}`);
30
+ return;
31
+ }
32
+ logWarn(`[fail] ${check.id}: ${check.message}`);
33
+ }
21
34
  async function buildRuntime(options) {
22
35
  const cwd = process.cwd();
23
36
  const loaded = await loadStyleflowConfig(cwd, options.config);
@@ -91,6 +104,227 @@ async function runInit(options) {
91
104
  logInfo(`set STYLEFLOW_API_URL="${options.apiUrl.trim()}" in ${envResult.envPath}`);
92
105
  }
93
106
  }
107
+ async function runDoctor(options) {
108
+ const cwd = process.cwd();
109
+ const checks = [];
110
+ const loaded = await loadStyleflowConfig(cwd, options.config);
111
+ if (loaded.configPath) {
112
+ checks.push({
113
+ id: "config",
114
+ status: "ok",
115
+ message: `loaded config at ${loaded.configPath}`,
116
+ });
117
+ }
118
+ else {
119
+ checks.push({
120
+ id: "config",
121
+ status: "warn",
122
+ message: "config file not found (styleflow.config.*). Run \"styleflow init\" or pass --config.",
123
+ });
124
+ }
125
+ let runtime = null;
126
+ try {
127
+ runtime = resolveRuntimeConfig(loaded, {
128
+ projectId: options.projectId,
129
+ projectVersionId: options.projectVersionId ?? null,
130
+ apiUrl: options.apiUrl,
131
+ token: options.token,
132
+ rawDirectory: options.rawDirectory,
133
+ });
134
+ checks.push({
135
+ id: "runtime",
136
+ status: "ok",
137
+ message: `project=${runtime.projectId}, api=${runtime.apiUrl}`,
138
+ });
139
+ }
140
+ catch (error) {
141
+ checks.push({
142
+ id: "runtime",
143
+ status: "fail",
144
+ message: formatError(error),
145
+ });
146
+ }
147
+ if (runtime) {
148
+ const rawDir = path.resolve(runtime.cwd, runtime.rawDirectory);
149
+ try {
150
+ await ensureDirectory(rawDir);
151
+ checks.push({
152
+ id: "raw-directory",
153
+ status: "ok",
154
+ message: `read/write ready at ${rawDir}`,
155
+ });
156
+ }
157
+ catch (error) {
158
+ checks.push({
159
+ id: "raw-directory",
160
+ status: "fail",
161
+ message: `cannot access ${rawDir}: ${formatError(error)}`,
162
+ });
163
+ }
164
+ const manifestPath = path.join(rawDir, "manifest.json");
165
+ if (existsSync(manifestPath)) {
166
+ try {
167
+ await readJsonFile(manifestPath);
168
+ checks.push({
169
+ id: "raw-manifest",
170
+ status: "ok",
171
+ message: `manifest readable at ${manifestPath}`,
172
+ });
173
+ }
174
+ catch (error) {
175
+ checks.push({
176
+ id: "raw-manifest",
177
+ status: "fail",
178
+ message: `manifest is not valid JSON (${formatError(error)})`,
179
+ });
180
+ }
181
+ }
182
+ else {
183
+ checks.push({
184
+ id: "raw-manifest",
185
+ status: "warn",
186
+ message: `manifest not found at ${manifestPath} (run "styleflow pull")`,
187
+ });
188
+ }
189
+ const outputChecks = [
190
+ { id: "output-tokens", outputPath: runtime.config.output?.tokens?.path || null },
191
+ { id: "output-stylesheet", outputPath: runtime.config.output?.stylesheet?.path || null },
192
+ { id: "output-figma-styles", outputPath: runtime.config.output?.figmaStyles?.path || null },
193
+ { id: "output-published", outputPath: runtime.config.output?.published?.path || null },
194
+ { id: "output-components", outputPath: runtime.config.output?.components?.path || null },
195
+ ];
196
+ for (const item of outputChecks) {
197
+ if (!item.outputPath) {
198
+ checks.push({
199
+ id: item.id,
200
+ status: "warn",
201
+ message: "path not configured",
202
+ });
203
+ continue;
204
+ }
205
+ const resolvedPath = path.resolve(runtime.cwd, item.outputPath);
206
+ const targetDirectory = item.id === "output-components"
207
+ ? resolvedPath
208
+ : path.dirname(resolvedPath);
209
+ try {
210
+ await ensureDirectory(targetDirectory);
211
+ checks.push({
212
+ id: item.id,
213
+ status: "ok",
214
+ message: `write-ready at ${targetDirectory}`,
215
+ });
216
+ }
217
+ catch (error) {
218
+ checks.push({
219
+ id: item.id,
220
+ status: "fail",
221
+ message: `cannot access ${targetDirectory}: ${formatError(error)}`,
222
+ });
223
+ }
224
+ }
225
+ if (options.network === false) {
226
+ checks.push({
227
+ id: "api-auth",
228
+ status: "warn",
229
+ message: "skipped (--no-network)",
230
+ });
231
+ }
232
+ else {
233
+ try {
234
+ const projectParam = encodeURIComponent(runtime.projectId);
235
+ const payload = await apiGetJson({
236
+ baseUrl: runtime.apiUrl,
237
+ token: runtime.token,
238
+ path: `/api/styleflow/projects/${projectParam}/tokens`,
239
+ query: {
240
+ format: "structured",
241
+ projectVersionId: runtime.projectVersionId,
242
+ },
243
+ });
244
+ if (!payload || typeof payload.tokens !== "object" || payload.tokens === null) {
245
+ checks.push({
246
+ id: "api-auth",
247
+ status: "fail",
248
+ message: "tokens endpoint returned an invalid payload",
249
+ });
250
+ }
251
+ else {
252
+ checks.push({
253
+ id: "api-auth",
254
+ status: "ok",
255
+ message: "authenticated and project/token endpoint reachable",
256
+ });
257
+ }
258
+ }
259
+ catch (error) {
260
+ if (error instanceof ApiError) {
261
+ if (error.status === 401 || error.status === 403) {
262
+ checks.push({
263
+ id: "api-auth",
264
+ status: "fail",
265
+ message: `unauthorized (${error.status}) - verify STYLEFLOW_TOKEN`,
266
+ });
267
+ }
268
+ else if (error.status === 404) {
269
+ checks.push({
270
+ id: "api-auth",
271
+ status: "fail",
272
+ message: runtime.projectVersionId
273
+ ? `project/version not found (${runtime.projectId}, version ${runtime.projectVersionId})`
274
+ : `project not found (${runtime.projectId})`,
275
+ });
276
+ }
277
+ else {
278
+ checks.push({
279
+ id: "api-auth",
280
+ status: "fail",
281
+ message: `API request failed (${error.status}) on ${error.path}`,
282
+ });
283
+ }
284
+ }
285
+ else {
286
+ checks.push({
287
+ id: "api-auth",
288
+ status: "fail",
289
+ message: `network error: ${formatError(error)}`,
290
+ });
291
+ }
292
+ }
293
+ }
294
+ }
295
+ else {
296
+ checks.push({
297
+ id: "raw-directory",
298
+ status: "warn",
299
+ message: "skipped because runtime is invalid",
300
+ });
301
+ checks.push({
302
+ id: "raw-manifest",
303
+ status: "warn",
304
+ message: "skipped because runtime is invalid",
305
+ });
306
+ checks.push({
307
+ id: "output-paths",
308
+ status: "warn",
309
+ message: "skipped because runtime is invalid",
310
+ });
311
+ checks.push({
312
+ id: "api-auth",
313
+ status: "warn",
314
+ message: "skipped because runtime is invalid",
315
+ });
316
+ }
317
+ for (const check of checks) {
318
+ logDoctorCheck(check);
319
+ }
320
+ const failed = checks.filter((check) => check.status === "fail").length;
321
+ const warnings = checks.filter((check) => check.status === "warn").length;
322
+ const passed = checks.filter((check) => check.status === "ok").length;
323
+ logInfo(`doctor summary: ${passed} ok, ${warnings} warnings, ${failed} failed`);
324
+ if (failed > 0) {
325
+ throw new Error(`doctor failed with ${failed} failing checks`);
326
+ }
327
+ }
94
328
  async function main() {
95
329
  const program = new Command();
96
330
  program
@@ -129,10 +363,23 @@ async function main() {
129
363
  .option("--token <token>", "Override API token")
130
364
  .option("--raw-directory <path>", "Override raw directory")
131
365
  .option("--pull", "Run pull before build", false)
132
- .option("--pull-resource <resource>", "Resource to pull before build (all|tokens|stylesheet|figma-styles)")
366
+ .option("--pull-resource <resource>", "Resource to pull before build (all|tokens|stylesheet|figma-styles|published)")
133
367
  .action(async (options) => {
134
368
  await runBuild(options);
135
369
  });
370
+ program
371
+ .command("doctor")
372
+ .description("Validate config/env/auth and local raw/build paths")
373
+ .option("-c, --config <path>", "Path to styleflow config file")
374
+ .option("--project-id <id>", "Override project id")
375
+ .option("--project-version-id <id>", "Override project version id")
376
+ .option("--api-url <url>", "Override API URL")
377
+ .option("--token <token>", "Override API token")
378
+ .option("--raw-directory <path>", "Override raw directory")
379
+ .option("--no-network", "Skip network/API checks")
380
+ .action(async (options) => {
381
+ await runDoctor(options);
382
+ });
136
383
  program
137
384
  .command("get:all")
138
385
  .description("Alias for: styleflow pull all")
@@ -181,6 +428,18 @@ async function main() {
181
428
  .action(async (options) => {
182
429
  await runPull("figma-styles", options);
183
430
  });
431
+ program
432
+ .command("get:published")
433
+ .description("Alias for: styleflow pull published")
434
+ .option("-c, --config <path>", "Path to styleflow config file")
435
+ .option("--project-id <id>", "Override project id")
436
+ .option("--project-version-id <id>", "Override project version id")
437
+ .option("--api-url <url>", "Override API URL")
438
+ .option("--token <token>", "Override API token")
439
+ .option("--raw-directory <path>", "Override raw directory")
440
+ .action(async (options) => {
441
+ await runPull("published", options);
442
+ });
184
443
  await program.parseAsync(process.argv);
185
444
  }
186
445
  main().catch((error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,8BAA8B,EAE/B,MAAM,YAAY,CAAC;AAsEpB,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,qBAAqB,CAAC,CAShC;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,qBAAqB,EAC7B,SAAS,GAAE;IACT,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,8BAA8B,CA0DhC;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CA+BjD;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC,CA6BD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,qBAAqB,EACrB,8BAA8B,EAE/B,MAAM,YAAY,CAAC;AAsEpB,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,qBAAqB,CAAC,CAShC;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,qBAAqB,EAC7B,SAAS,GAAE;IACT,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,8BAA8B,CA0DhC;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAmCjD;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC,CA6BD"}
package/dist/config.js CHANGED
@@ -127,6 +127,10 @@ export function getDefaultConfigTemplate() {
127
127
  format: "json",
128
128
  path: ".styleflow/build/figma-styles.json"
129
129
  },
130
+ published: {
131
+ format: "json",
132
+ path: ".styleflow/build/published.json"
133
+ },
130
134
  components: {
131
135
  framework: "react",
132
136
  styling: "tailwind",
@@ -1 +1 @@
1
- {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../src/pull.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAE/E,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAA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"}
package/dist/pull.js CHANGED
@@ -4,7 +4,7 @@ import { ApiError, apiGetJson } from "./http.js";
4
4
  export function normalizePullResources(input) {
5
5
  const normalized = String(input || "all").trim().toLowerCase();
6
6
  if (!normalized || normalized === "all") {
7
- return ["tokens", "stylesheet", "figmaStyles"];
7
+ return ["tokens", "stylesheet", "figmaStyles", "published"];
8
8
  }
9
9
  if (normalized === "tokens")
10
10
  return ["tokens"];
@@ -12,7 +12,9 @@ export function normalizePullResources(input) {
12
12
  return ["stylesheet"];
13
13
  if (normalized === "figma-styles" || normalized === "figmastyles")
14
14
  return ["figmaStyles"];
15
- throw new Error(`Unknown resource "${input}". Use one of: all, tokens, stylesheet, figma-styles.`);
15
+ if (normalized === "published")
16
+ return ["published"];
17
+ throw new Error(`Unknown resource "${input}". Use one of: all, tokens, stylesheet, figma-styles, published.`);
16
18
  }
17
19
  function toQuery(projectVersionId) {
18
20
  return {
@@ -42,6 +44,12 @@ export async function pullStyleflowData(runtime, resources) {
42
44
  version: null,
43
45
  pulled: false,
44
46
  },
47
+ published: {
48
+ path: path.join(rawDirectory, "published.json"),
49
+ hash: null,
50
+ version: null,
51
+ pulled: false,
52
+ },
45
53
  };
46
54
  const requested = new Set(resources);
47
55
  if (requested.has("tokens")) {
@@ -106,6 +114,29 @@ export async function pullStyleflowData(runtime, resources) {
106
114
  }
107
115
  }
108
116
  }
117
+ if (requested.has("published")) {
118
+ try {
119
+ const payload = await apiGetJson({
120
+ baseUrl: runtime.apiUrl,
121
+ token: runtime.token,
122
+ path: `/api/styleflow/projects/${projectParam}/published`,
123
+ query: {
124
+ ...toQuery(runtime.projectVersionId),
125
+ limit: "500",
126
+ },
127
+ });
128
+ await writeJsonFile(files.published.path, payload.items ?? []);
129
+ files.published.pulled = true;
130
+ }
131
+ catch (error) {
132
+ if (error instanceof ApiError && error.status === 404) {
133
+ warnings.push("Published objects not found for project/version. Skipped.");
134
+ }
135
+ else {
136
+ throw error;
137
+ }
138
+ }
139
+ }
109
140
  const manifestPath = path.join(rawDirectory, "manifest.json");
110
141
  await writeJsonFile(manifestPath, {
111
142
  schemaVersion: 1,
@@ -130,6 +161,12 @@ export async function pullStyleflowData(runtime, resources) {
130
161
  hash: files.figmaStyles.hash,
131
162
  version: files.figmaStyles.version,
132
163
  },
164
+ published: {
165
+ path: path.relative(rawDirectory, files.published.path),
166
+ pulled: files.published.pulled,
167
+ hash: files.published.hash,
168
+ version: files.published.version,
169
+ },
133
170
  },
134
171
  });
135
172
  const pulledResources = resources.filter((resource) => files[resource].pulled);
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type PullResource = "tokens" | "stylesheet" | "figmaStyles";
1
+ export type PullResource = "tokens" | "stylesheet" | "figmaStyles" | "published";
2
2
  export type TokenOutputFormat = "css" | "scss" | "json" | "style-dictionary" | "tailwind";
3
3
  export interface TokenOutputConfig {
4
4
  format?: TokenOutputFormat;
@@ -18,6 +18,7 @@ export interface StyleflowOutputConfig {
18
18
  tokens?: TokenOutputConfig;
19
19
  stylesheet?: JsonOutputConfig;
20
20
  figmaStyles?: JsonOutputConfig;
21
+ published?: JsonOutputConfig;
21
22
  components?: ComponentsOutputConfig;
22
23
  }
23
24
  export interface StyleflowMappingConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,GAAG,aAAa,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,kBAAkB,GAAG,UAAU,CAAC;AAE1F,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,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EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC7C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styleflow",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "StyleFlow design-to-dev CLI for pulling and building tokens/stylesheets",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",