mirror of
https://github.com/hunvreus/basecoat.git
synced 2026-11-11 04:38:18 +00:00
Reorganizing the CLI
This commit is contained in:
+5
-8
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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}`);
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user