tokvista 1.5.1 → 1.5.2

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/bin/tokvista.ts
4
4
  import { spawn } from "child_process";
5
- import { existsSync } from "fs";
5
+ import { existsSync, readdirSync } from "fs";
6
6
  import { readFile, writeFile } from "fs/promises";
7
7
  import { createServer } from "http";
8
8
  import path from "path";
@@ -245,6 +245,17 @@ function askRawQuestion(rl, prompt) {
245
245
  rl.question(prompt, (answer) => resolve(answer.trim()));
246
246
  });
247
247
  }
248
+ function createCompleter(cwd) {
249
+ return (line) => {
250
+ try {
251
+ const files = readdirSync(cwd);
252
+ const hits = files.filter((f) => f.startsWith(line));
253
+ return [hits.length ? hits : files, line];
254
+ } catch {
255
+ return [[], line];
256
+ }
257
+ };
258
+ }
248
259
  async function askWithDefault(rl, label, defaultValue) {
249
260
  const suffix = defaultValue != null && defaultValue !== "" ? ` [${defaultValue}]` : "";
250
261
  const answer = await askRawQuestion(rl, `${label}${suffix}: `);
@@ -326,7 +337,12 @@ async function buildInitConfigFromPrompt(cwd, askPreviewQuestion) {
326
337
  }
327
338
  console.log("TokVista init");
328
339
  console.log("Press Enter to accept defaults.\n");
329
- const rl = createInterface({ input: process.stdin, output: process.stdout });
340
+ const rl = createInterface({
341
+ input: process.stdin,
342
+ output: process.stdout,
343
+ completer: createCompleter(cwd),
344
+ tabSize: 2
345
+ });
330
346
  try {
331
347
  const title = await askWithDefault(rl, "Title", defaults.title);
332
348
  const subtitle = await askWithDefault(rl, "Subtitle", defaults.subtitle);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokvista",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Interactive visual documentation for design tokens.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",