@advantacode/brander 0.1.3 → 0.1.5

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.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { runCli } from './index.js';
3
+ const args = process.argv.slice(2);
4
+ runCli(args).then((code) => process.exit(code));
@@ -77,6 +77,10 @@ async function loadBrandConfig() {
77
77
  return {};
78
78
  }
79
79
  try {
80
+ // enable TS config loading if needed
81
+ if (configPath.endsWith(".ts") || configPath.endsWith(".mts") || configPath.endsWith(".cts")) {
82
+ await import("tsx/esm");
83
+ }
80
84
  const importedConfig = await import(pathToFileURL(configPath).href);
81
85
  return parseBrandConfig(importedConfig.default ?? importedConfig, configPath);
82
86
  }
package/dist/index.js CHANGED
@@ -1,25 +1,19 @@
1
- #!/usr/bin/env node
2
- import fs from "fs";
3
- import { fileURLToPath, pathToFileURL } from "url";
4
- import { generateTokens, supportedFormats } from "./generate-tokens.js";
5
- import { setupProject } from "./setup.js";
6
- const packageVersion = loadPackageVersion();
7
- if (isCliEntryPoint()) {
8
- process.exit(await runCli(process.argv.slice(2)));
9
- }
1
+ import fs from 'fs';
2
+ import { generateTokens, supportedFormats } from './generate-tokens.js';
3
+ import { setupProject } from './setup.js';
10
4
  export async function runCli(args) {
11
5
  try {
12
- if (args.includes("--version") || args.includes("-v")) {
13
- console.log(packageVersion);
6
+ if (args.includes('--version') || args.includes('-v')) {
7
+ console.log(loadPackageVersion());
14
8
  return 0;
15
9
  }
16
10
  const command = resolveCommand(args);
17
- const commandArgs = command === "generate" ? args : args.slice(1);
18
- if (commandArgs.includes("--help") || commandArgs.includes("-h")) {
11
+ const commandArgs = command === 'generate' ? args : args.slice(1);
12
+ if (commandArgs.includes('--help') || commandArgs.includes('-h')) {
19
13
  console.log(getHelpText(command));
20
14
  return 0;
21
15
  }
22
- if (command === "generate") {
16
+ if (command === 'generate') {
23
17
  await generateTokens(parseGenerateArgs(commandArgs));
24
18
  return 0;
25
19
  }
@@ -27,21 +21,15 @@ export async function runCli(args) {
27
21
  return 0;
28
22
  }
29
23
  catch (error) {
30
- const message = error instanceof Error ? error.message : String(error);
31
- console.error(`Error: ${message}`);
24
+ console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
32
25
  return 1;
33
26
  }
34
27
  }
35
- function isCliEntryPoint() {
36
- const entryPoint = process.argv[1];
37
- return Boolean(entryPoint) && pathToFileURL(entryPoint).href === import.meta.url;
38
- }
39
28
  function loadPackageVersion() {
40
- const packageJsonPath = fileURLToPath(new URL("../package.json", import.meta.url));
41
- if (!fs.existsSync(packageJsonPath)) {
42
- return "0.0.0";
43
- }
44
- return (JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).version ?? "0.0.0");
29
+ const packageJsonPath = new URL('../package.json', import.meta.url);
30
+ if (!fs.existsSync(packageJsonPath))
31
+ return '0.0.0';
32
+ return JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')).version ?? '0.0.0';
45
33
  }
46
34
  function resolveCommand(args) {
47
35
  const firstArg = args[0];
package/dist/setup.js CHANGED
@@ -43,12 +43,12 @@ export async function setupProject(options) {
43
43
  }
44
44
  }
45
45
  function ensureBrandConfig() {
46
- const configPath = path.resolve(process.cwd(), "brand.config.ts");
46
+ const configPath = path.resolve(process.cwd(), "brand.config.js");
47
47
  if (fs.existsSync(configPath)) {
48
- return { message: "Kept existing brand.config.ts." };
48
+ return { message: "Kept existing brand.config.js." };
49
49
  }
50
50
  fs.writeFileSync(configPath, getDefaultBrandConfigTemplate());
51
- return { message: "Created brand.config.ts." };
51
+ return { message: "Created brand.config.js." };
52
52
  }
53
53
  function ensurePackageScript(scriptName, command) {
54
54
  const packageJsonPath = path.resolve(process.cwd(), "package.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@advantacode/brander",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "AdvantaCode Design System Brand Generator",
5
5
  "type": "module",
6
6
  "files": [
@@ -10,19 +10,20 @@
10
10
  "LICENSE"
11
11
  ],
12
12
  "bin": {
13
- "advantacode-brander": "./dist/index.js"
13
+ "advantacode-brander": "./dist/cli-wrapper.js"
14
14
  },
15
15
  "scripts": {
16
16
  "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
17
- "build": "npm run clean && tsc",
18
- "cli": "node --import tsx/esm dist/index.js",
17
+ "build": "npm run clean && tsc && chmod +x dist/cli-wrapper.js",
18
+ "cli": "node --import tsx/esm dist/cli-wrapper.js",
19
19
  "lint": "eslint --max-warnings=0 src test",
20
20
  "pretest": "npm run build",
21
21
  "test": "node --import tsx/esm --test",
22
22
  "release:check": "npm run lint && npm test && npm pack --dry-run",
23
23
  "tokens": "tsx src/generate-tokens.ts",
24
24
  "prepack": "npm run build",
25
- "brand:generate": "advantacode-brander --out src/brander"
25
+ "brand:generate": "advantacode-brander --out src/brander",
26
+ "brand:test": "node ./dist/cli-wrapper.js --out src/brander"
26
27
  },
27
28
  "license": "MIT",
28
29
  "author": "Anthony Penn",
@@ -54,6 +55,6 @@
54
55
  "dependencies": {
55
56
  "culori": "^4.0.2",
56
57
  "dotenv": "^17.3.1",
57
- "tsx": "^4.0.0"
58
+ "tsx": "^4.21.0"
58
59
  }
59
60
  }