-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
96 lines (84 loc) · 3.28 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
87
88
89
90
91
92
93
94
95
96
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')
};
function copyDependencies(inFolder, outFolder, subFolder) {
const folder = path.resolve(__dirname, inFolder);
fs.readdirSync(folder, { withFileTypes: true })
.filter((dir) => dir.isDirectory())
.forEach(({ name: folderName }) => {
const dirname = path.resolve(__dirname, inFolder + folderName);
console.log(`\nReading dir: ${dirname}`);
fs.readdirSync(dirname).forEach((file) => {
if (fileEndsValidator(file)) {
const inputFilePath = path.resolve(__dirname, inFolder + folderName) + '/' + file;
const outputFilePath = outFolder + folderName + '/' + file;
fs.copySync(inputFilePath, outputFilePath);
console.log(`${inputFilePath} ⮕ ${outputFilePath}`);
}
});
if (subFolder) {
try {
let subfolder = path.resolve(__dirname, inFolder + folderName + subFolder);
console.log(`\nReading dir: ${subfolder}`);
fs.readdirSync(subfolder).forEach((subFile) => {
if (fileEndsValidator(subFile)) {
const inputFile = path.resolve(__dirname, inFolder + folderName + subFolder) + '/' + subFile;
const outputFile = outFolder + folderName + subFolder + '/' + subFile;
fs.copySync(inputFile, outputFile);
console.log(`${inputFile} ⮕ ${outputFile}`);
}
});
} catch(error) {
console.log(error);
}
}
});
}
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`);