-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
76 lines (64 loc) · 1.91 KB
/
Copy pathbuild.js
File metadata and controls
76 lines (64 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env node
/**
* Build script for unlockopen-slides
* Generates CSS from design tokens and copies files to Obsidian plugin directories
*/
import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
const OBSIDIAN_PLUGIN_BASE = '../.obsidian/plugins/obsidian-advanced-slides';
function ensureDir(dirPath) {
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
console.log(`📁 Created directory: ${dirPath}`);
}
}
function copyFile(src, dest) {
try {
ensureDir(path.dirname(dest));
fs.copyFileSync(src, dest);
console.log(`✅ Copied ${src} → ${dest}`);
} catch (error) {
console.error(`❌ Failed to copy ${src} → ${dest}:`, error.message);
}
}
function main() {
console.log('🚀 Building unlockopen-slides...\n');
// Step 1: Generate CSS from design tokens
console.log('1️⃣ Generating CSS from design tokens...');
try {
execSync('npm run build:tokens', { stdio: 'inherit' });
} catch (error) {
console.error('❌ Failed to generate tokens');
process.exit(1);
}
// Step 2: Copy files to Obsidian plugin directories
console.log('\n2️⃣ Copying files to Obsidian plugin...');
const filesToCopy = [
{
src: 'reveal.html',
dest: path.join(OBSIDIAN_PLUGIN_BASE, 'template', 'reveal.html')
},
{
src: 'mermaid.js',
dest: path.join(OBSIDIAN_PLUGIN_BASE, 'plugin', 'mermaid', 'mermaid.js')
},
{
src: 'tokens-generated.css',
dest: path.join(OBSIDIAN_PLUGIN_BASE, 'template', 'tokens-generated.css')
},
{
src: 'unlockopen.css',
dest: path.join(OBSIDIAN_PLUGIN_BASE, 'template', 'unlockopen.css')
}
];
filesToCopy.forEach(({ src, dest }) => {
if (fs.existsSync(src)) {
copyFile(src, dest);
} else {
console.warn(`⚠️ Source file not found: ${src}`);
}
});
console.log('\n✨ Build complete!');
}
main();