@advantacode/brander 0.1.2 → 0.1.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.
@@ -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));
package/dist/index.js CHANGED
@@ -1,25 +1,19 @@
1
- #!/usr/bin/env -S node --import tsx/esm
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@advantacode/brander",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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",