frakment 0.0.3 → 0.0.4

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/bin/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { readFileSync } from "node:fs";
3
3
  import path from "node:path";
4
+ import chalk from "chalk";
4
5
  import { Command } from "commander";
5
- import pc from "picocolors";
6
6
 
7
7
  import { add } from "../src/commands/add.js";
8
8
  import { init } from "../src/commands/init.js";
@@ -23,9 +23,9 @@ program
23
23
  "after",
24
24
  `
25
25
  Examples:
26
- ${pc.dim("$ frakment init")}
27
- ${pc.dim("$ frakment add status-chip")}
28
- ${pc.dim("$ frakment list")}
26
+ ${chalk.dim("$ frakment init")}
27
+ ${chalk.dim("$ frakment add button")}
28
+ ${chalk.dim("$ frakment list")}
29
29
  `
30
30
  );
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frakment",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "CLI and design system for the frakment component registry",
5
5
  "keywords": [
6
6
  "components",
@@ -2,34 +2,33 @@ import { existsSync } from "node:fs";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
 
5
- import * as p from "@clack/prompts";
6
- import pc from "picocolors";
5
+ import chalk from "chalk";
6
+ import ora from "ora";
7
7
 
8
8
  import { findProjectRoot } from "../utils/detect.js";
9
+ import { logger } from "../utils/logger.js";
9
10
 
10
11
  export async function list(options) {
11
- p.intro(`${pc.dim("frakment")} list`);
12
-
13
12
  let cwd;
13
+ const preflight = ora("Preflight checks").start();
14
14
  try {
15
15
  cwd = findProjectRoot(process.cwd());
16
+ preflight.succeed("Preflight checks. Found project root.");
16
17
  } catch (error) {
17
- p.outro(pc.red("error ") + error.message);
18
+ preflight.fail(error.message);
18
19
  process.exit(1);
19
20
  }
20
21
 
21
22
  const configPath = path.join(cwd, "components.json");
22
23
  if (!existsSync(configPath)) {
23
- p.outro(
24
- `${pc.red("error ")}components.json not found. Run \`frakment init\` first.`
25
- );
24
+ logger.error(`${chalk.red("Error:")} components.json not found.`);
25
+ logger.info("Run `frakment init` first.");
26
26
  process.exit(1);
27
27
  }
28
28
 
29
29
  const config = JSON.parse(await readFile(configPath, "utf-8"));
30
30
  const registryUrl = (options.registry ?? config.registry).replace(/\/$/u, "");
31
- const s = p.spinner();
32
- s.start("fetching components");
31
+ const s = ora("Fetching components").start();
33
32
 
34
33
  let index;
35
34
  try {
@@ -39,23 +38,25 @@ export async function list(options) {
39
38
  }
40
39
  index = await res.json();
41
40
  } catch {
42
- s.stop(`${pc.red("✗")} failed to fetch component list`);
41
+ s.fail("Failed to fetch component list.");
43
42
  process.exit(1);
44
43
  }
45
- s.stop(`${pc.green("✓")} found ${index.components.length} component(s)`);
44
+ s.succeed(`Found ${index.components.length} component(s).`);
46
45
 
47
46
  if (!index.components.length) {
48
- p.outro(pc.dim("no components available yet"));
47
+ logger.break();
48
+ logger.log(chalk.dim("No components available yet."));
49
49
  return;
50
50
  }
51
51
 
52
52
  const nameWidth = Math.max(...index.components.map((c) => c.name.length));
53
- const lines = index.components.map(
54
- (c) =>
55
- ` ${pc.cyan(c.name.padEnd(nameWidth))} ${pc.dim(c.description ?? "")}`
56
- );
57
-
58
- p.outro(
59
- `${lines.join("\n")}\n\n Add one with ${pc.cyan("frakment add <name>")}`
60
- );
53
+ logger.break();
54
+ for (const c of index.components) {
55
+ logger.log(
56
+ ` ${chalk.cyan(c.name.padEnd(nameWidth))} ${chalk.dim(c.description ?? "")}`
57
+ );
58
+ }
59
+ logger.break();
60
+ logger.log(`Add one with ${chalk.cyan("frakment add <name>")}`);
61
+ logger.break();
61
62
  }