-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopyComponents.js
More file actions
94 lines (78 loc) · 3.45 KB
/
copyComponents.js
File metadata and controls
94 lines (78 loc) · 3.45 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const fs = require('fs');
const path = require('path');
// Copy .html and .js files from src/components/** to dist/components/**
function copyFiles(srcDir, destDir) {
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
const items = fs.readdirSync(srcDir);
items.forEach(item => {
const srcPath = path.join(srcDir, item);
const destPath = path.join(destDir, item);
const stat = fs.statSync(srcPath);
if (stat.isDirectory()) {
copyFiles(srcPath, destPath);
} else if (stat.isFile() && !srcPath.endsWith('.ts')) {
fs.copyFileSync(srcPath, destPath);
console.log(`Copied: ${srcPath} to ${destPath}`);
}
});
}
// Generate version file from package.json (or copy existing if it exists and matches)
const packageJsonPath = path.join(__dirname, 'package.json');
const versionFileDest = path.join(__dirname, 'dist', 'version');
if (fs.existsSync(packageJsonPath)) {
try {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
if (packageJson.version) {
// Write version to dist/version
fs.writeFileSync(versionFileDest, packageJson.version, 'utf-8');
console.log(`Generated version file from package.json: ${packageJson.version}`);
// Also update root version file if it exists (or create it)
const rootVersionFile = path.join(__dirname, 'version');
fs.writeFileSync(rootVersionFile, packageJson.version, 'utf-8');
}
} catch (error) {
console.error(`Failed to read version from package.json: ${error.message}`);
// Fallback: copy existing version file if it exists
const versionFileSrc = path.join(__dirname, 'version');
if (fs.existsSync(versionFileSrc)) {
fs.copyFileSync(versionFileSrc, versionFileDest);
console.log(`Copied existing version file: ${versionFileSrc} to ${versionFileDest}`);
} else {
console.log('No version file found and failed to read from package.json.');
}
}
} else {
console.log('No package.json found in the root directory.');
}
const srcDir = 'src/components';
const destDir = 'dist/components';
copyFiles(srcDir, destDir);
// Copy bundled plugins from root plugins/ to dist/plugins/
const pluginsSrcDir = path.join(__dirname, 'plugins');
const pluginsDestDir = path.join(__dirname, 'dist', 'plugins');
if (fs.existsSync(pluginsSrcDir)) {
copyFiles(pluginsSrcDir, pluginsDestDir);
console.log('Copied bundled plugins to dist/plugins/');
} else {
console.log('No plugins folder found in the root directory.');
}
// Copy bundled themes from root themes/ to dist/themes/
const themesSrcDir = path.join(__dirname, 'themes');
const themesDestDir = path.join(__dirname, 'dist', 'themes');
if (fs.existsSync(themesSrcDir)) {
copyFiles(themesSrcDir, themesDestDir);
console.log('Copied bundled themes to dist/themes/');
} else {
console.log('No themes folder found in the root directory.');
}
// Copy party app (StreamGo Party / Peario) from root party/ to dist/party/
const partySrcDir = path.join(__dirname, 'party');
const partyDestDir = path.join(__dirname, 'dist', 'party');
if (fs.existsSync(partySrcDir)) {
copyFiles(partySrcDir, partyDestDir);
console.log('Copied StreamGo Party app to dist/party/');
} else {
console.log('No party folder found in the root directory.');
}