chore: add dist output for bin
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
dist
|
||||
templates/base/dist
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
import { fileURLToPath } from 'url';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const projectName = process.argv[2];
|
||||
if (!projectName) {
|
||||
console.error('❌ Please provide a project name');
|
||||
process.exit(1);
|
||||
}
|
||||
const targetDir = path.resolve(process.cwd(), projectName);
|
||||
const templateDir = path.resolve(__dirname, '../templates/base');
|
||||
if (fs.existsSync(targetDir)) {
|
||||
console.error('❌ Directory already exists');
|
||||
process.exit(1);
|
||||
}
|
||||
fs.cpSync(templateDir, targetDir, { recursive: true });
|
||||
const pkgPath = path.join(targetDir, 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
||||
pkg.name = projectName;
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
||||
const themePath = path.join(targetDir, 'theme.json');
|
||||
const theme = JSON.parse(fs.readFileSync(themePath, 'utf-8'));
|
||||
theme.name = projectName;
|
||||
fs.writeFileSync(themePath, JSON.stringify(theme, null, 2));
|
||||
console.log('📦 Installing dependencies...');
|
||||
execSync('npm install', { cwd: targetDir, stdio: 'inherit' });
|
||||
console.log(`\n✅ Theme created!\n`);
|
||||
Reference in New Issue
Block a user