-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
86 lines (76 loc) · 2.8 KB
/
build.js
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
const fs = require('fs-extra');
const path = require('path');
const pkg = require('./package.json');
const outDir = './dist';
function fileEndsValidator(f) {
return f === 'package.json' || f.endsWith('d.ts') || f.endsWith('vue') || f.endsWith('js') || f.endsWith('json')
};
function copyDependencies(inFolder, outFolder) {
const srcFolder = path.resolve(__dirname, inFolder);
const destFolder = path.resolve(__dirname, outFolder);
copyDependenciesRecursive(srcFolder, destFolder);
}
function copyDependenciesRecursive(srcDir, destDir) {
// Ensure the destination directory exists
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
fs.readdirSync(srcDir, { withFileTypes: true }).forEach((dirent) => {
const srcPath = path.join(srcDir, dirent.name);
const destPath = path.join(destDir, dirent.name);
if (dirent.isDirectory()) {
// Recursively copy contents of the directory
copyDependenciesRecursive(srcPath, destPath);
} else {
// Check if the file meets the criteria
if (fileEndsValidator(dirent.name)) {
fs.copySync(srcPath, destPath);
console.log(`${srcPath} ⮕ ${destPath}`);
}
}
});
}
function addPackageJson() {
const filename = 'package.json';
const packageJson = `{
"name": "${pkg.name}",
"version": "${pkg.version}",
"private": false,
"description": "azion-webkit is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, use UI blocks to build spectacular applications in no time.",
"repository": {
"type": "git",
"url": "git+https://github.com/aziontech/azion-webkit.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/aziontech/azion-webkit/issues"
},
"keywords": [
"primevue",
"vue",
"vue.js",
"vue3",
"ui library",
"component library",
"material",
"bootstrap",
"fluent",
"tailwind",
"unstyled",
"passthrough"
],
"peerDependencies": {
"vue": "^3.0.0"
}
}`;
!fs.existsSync(outDir) && fs.mkdirSync(outDir);
console.log(`Writting ${filename} into ${outDir}`);
fs.writeFileSync(path.resolve(outDir, filename), packageJson);
}
addPackageJson();
copyDependencies('./src/templates/', `${outDir}/`);
fs.copySync(path.resolve(__dirname, './tailwind.config.js'), `${outDir}/tailwind.config.js`);
fs.copySync(path.resolve(__dirname, './src/assets'), `${outDir}/src/assets`);
fs.copySync(path.resolve(__dirname, './src/services'), `${outDir}/src/services`);
fs.copySync(path.resolve(__dirname, './README.md'), `${outDir}/README.md`);
fs.copySync(path.resolve(__dirname, './LICENSE'), `${outDir}/LICENSE`);