- Add root package.json with development scripts and dependencies - Move scripts/ from lib back to root for intuitive developer experience - Clean lib/package.json to contain only runtime dependencies - Add comprehensive justfile with cross-platform command shortcuts - Update README.md with new development workflow instructions - Maintain lib as clean, publishable package while enabling root-level commands
58 lines
1.7 KiB
JavaScript
Executable File
58 lines
1.7 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Build script for Insertr library and CLI integration
|
|
* This ensures the CLI always has the latest library version embedded
|
|
*/
|
|
|
|
import { execSync } from 'child_process';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
console.log('🔨 Building Insertr library and CLI...\n');
|
|
|
|
// 1. Build the library
|
|
console.log('📦 Building JavaScript library...');
|
|
try {
|
|
execSync('npm run build', { cwd: 'lib', stdio: 'inherit' });
|
|
console.log('✅ Library built successfully\n');
|
|
} catch (error) {
|
|
console.error('❌ Library build failed:', error.message);
|
|
process.exit(1);
|
|
}
|
|
|
|
// 2. Copy built library to CLI assets
|
|
console.log('📁 Copying library to CLI assets...');
|
|
const srcDir = './lib/dist';
|
|
const destDir = './insertr-cli/pkg/content/assets';
|
|
|
|
// Ensure destination directory exists
|
|
fs.mkdirSync(destDir, { recursive: true });
|
|
|
|
// Copy files
|
|
const files = fs.readdirSync(srcDir);
|
|
files.forEach(file => {
|
|
const src = path.join(srcDir, file);
|
|
const dest = path.join(destDir, file);
|
|
fs.copyFileSync(src, dest);
|
|
console.log(` ✅ Copied ${file}`);
|
|
});
|
|
|
|
console.log('📁 Assets copied successfully\n');
|
|
|
|
// 3. Build the CLI
|
|
console.log('🔧 Building Go CLI...');
|
|
try {
|
|
execSync('go build -o insertr', { cwd: './insertr-cli', stdio: 'inherit' });
|
|
console.log('✅ CLI built successfully\n');
|
|
} catch (error) {
|
|
console.error('❌ CLI build failed:', error.message);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('🎉 Build complete!\n');
|
|
console.log('📋 What was built:');
|
|
console.log(' • JavaScript library (lib/dist/)');
|
|
console.log(' • Go CLI with embedded library (insertr-cli/insertr)');
|
|
console.log('\n🚀 Ready to use:');
|
|
console.log(' cd insertr-cli && ./insertr --help'); |