- Move scripts/ to lib/scripts/ and convert to ESM modules - Consolidate dependencies: add live-server to lib/package.json - Remove root package.json and node_modules split - Preserve CLI integration via existing rebuild-library.sh - Add development quickstart guide for new unified workflow - Clean up outdated file references and duplicate assets
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', { 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 = './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'); |