diff --git a/package.json b/package.json index 8161212..ba86209 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,17 @@ "description": "shadcn/ui for the rest of us", "author": "hunvreus", "type": "module", + "workspaces": [ + "packages/*" + ], "files": [ "src/css", "src/js", "src/nunjucks", - "src/jinja", - "cli" + "src/jinja" ], "bin": { - "basecoat": "cli/index.js" + "add": "./packages/cli/index.js" }, "exports": { ".": "./src/css/basecoat.css" @@ -48,16 +50,11 @@ "dev": "concurrently \"npm:css:dev\" \"npm:eleventy:serve\"", "build": "tailwindcss -i ./docs/css/styles.css -o ./docs/src/assets/styles.css --minify && eleventy" }, - "dependencies": { - "commander": "^13.1.0" - }, "devDependencies": { "@11ty/eleventy": "^3.0.0", "@grimlink/eleventy-plugin-lucide-icons": "^2.1.4", "@tailwindcss/cli": "^4.1.3", "concurrently": "^9.1.2", - "fs-extra": "^11.3.0", - "inquirer": "^12.6.0", "prettier": "^3.5.3", "tailwindcss": "^4.1.3" } diff --git a/cli/index.js b/packages/cli/index.js similarity index 91% rename from cli/index.js rename to packages/cli/index.js index 21e913e..6c7e64d 100755 --- a/cli/index.js +++ b/packages/cli/index.js @@ -26,7 +26,7 @@ let config = { ...DEFAULT_CONFIG }; async function getAvailableComponents() { try { - const packageRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..'); + const packageRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '../..'); const jsSourceDir = path.join(packageRoot, 'src', 'js'); const jsFiles = await fs.readdir(jsSourceDir); return jsFiles @@ -76,13 +76,9 @@ async function ensureConfiguration() { console.log('Basecoat CLI'); program - .name('basecoat') + .name('add') .description('Add Basecoat components to your project') - .version(packageVersion); - -program - .command('add') - .description('Add one or more components to your project') + .version(packageVersion) .argument('[components...]', 'Names of components to add') .action(async (componentsArg) => { let componentsToAdd = componentsArg; @@ -135,11 +131,11 @@ async function addComponent(componentName) { console.log(`\nProcessing component: ${componentName}...`); // 1. Determine source paths (relative to package root) - const cliScriptDir = path.dirname(new URL(import.meta.url).pathname); // Get directory of the current script file - // Go UP from cli/, then DOWN into src/, then the specific folder + const cliScriptDir = path.dirname(new URL(import.meta.url).pathname); + const packageRoot = path.resolve(cliScriptDir, '../..'); const templateExt = config.templateEngine === 'jinja' ? '.html.jinja' : '.njk'; - const templateSource = path.resolve(cliScriptDir, '..', 'src', config.templateEngine, `${componentName}${templateExt}`); - const scriptSource = path.resolve(cliScriptDir, '..', 'src', 'js', `${componentName}.js`); + const templateSource = path.join(packageRoot, 'src', config.templateEngine, `${componentName}${templateExt}`); + const scriptSource = path.join(packageRoot, 'src', 'js', `${componentName}.js`); // 2. Determine destination paths (relative to user's current working directory) const templateDestPath = path.resolve(process.cwd(), config.templateDest, `${componentName}${templateExt}`); diff --git a/packages/cli/package.json b/packages/cli/package.json new file mode 100644 index 0000000..4d4a460 --- /dev/null +++ b/packages/cli/package.json @@ -0,0 +1,14 @@ +{ + "name": "@hunvreus/basecoat-cli", + "version": "0.1.0", + "description": "CLI for Basecoat UI components", + "type": "module", + "bin": { + "basecoat": "./index.js" + }, + "dependencies": { + "commander": "^13.1.0", + "inquirer": "^12.6.0", + "fs-extra": "^11.3.0" + } +} \ No newline at end of file