-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy-to-docs.js
More file actions
75 lines (61 loc) · 2 KB
/
copy-to-docs.js
File metadata and controls
75 lines (61 loc) · 2 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
/**
* Copy /dist files to /docs for GitHub Pages
* Maintains /dist for development, /docs for GitHub Pages publishing
*/
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, copyFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const distDir = join(__dirname, 'dist');
const docsDir = join(__dirname, 'docs');
/**
* Recursively copy directory
*/
function copyDir(src, dest) {
if (!existsSync(dest)) {
mkdirSync(dest, { recursive: true });
}
const entries = readdirSync(src);
for (const entry of entries) {
const srcPath = join(src, entry);
const destPath = join(dest, entry);
if (statSync(srcPath).isDirectory()) {
copyDir(srcPath, destPath);
} else {
copyFileSync(srcPath, destPath);
console.log(`📄 Copied: ${entry}`);
}
}
}
/**
* Main execution
*/
function main() {
console.log('📂 Copying /dist to /docs for GitHub Pages...\n');
if (!existsSync(distDir)) {
console.error('❌ /dist directory not found. Run "npm run build:single" first.');
process.exit(1);
}
// Create docs directory if it doesn't exist
if (!existsSync(docsDir)) {
mkdirSync(docsDir, { recursive: true });
console.log('📁 Created /docs directory');
}
try {
// Copy all files from dist to docs
copyDir(distDir, docsDir);
console.log('\n✅ Successfully copied /dist to /docs');
console.log('🚀 Ready for GitHub Pages!');
console.log('');
console.log('📋 Next steps:');
console.log('1. Commit changes: git add . && git commit -m "Update docs for GitHub Pages"');
console.log('2. Push to GitHub: git push');
console.log('3. Configure GitHub Pages to use /docs folder');
console.log('4. Access at: https://[username].github.io/personal-2fa/');
} catch (error) {
console.error('❌ Error copying files:', error.message);
process.exit(1);
}
}
main();