-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplan.config.js
43 lines (34 loc) · 1.29 KB
/
plan.config.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
const fs = require('fs');
const path = require('path');
function getJson(file) {
const configJsonPath = path.join(__dirname, file);
const data = fs.readFileSync(configJsonPath, 'utf8');
return JSON.parse(data);
}
const planConfig = getJson('plan.json');
function freePlanConfiguration() {
const { plan } = planConfig;
// console.log(`Current Plan: ${plan}`)
if (plan.toLowerCase() === 'free') {
const componentsDir = path.join(__dirname, 'src', 'components');
const deprecatedDir = path.join(componentsDir, '_deprecated');
const filesToKeep = ['index.js', 'writedocsComponentsFolder', '_deprecated'];
if (!fs.existsSync(deprecatedDir)) {
fs.mkdirSync(deprecatedDir);
}
fs.readdir(componentsDir, (err, files) => {
if (err) throw err;
files.forEach(file => {
const filePath = path.join(componentsDir, file);
const isDirectory = fs.statSync(filePath).isDirectory();
const shouldKeep = filesToKeep.includes(file) || (isDirectory && filesToKeep.includes(file));
if (!shouldKeep) {
const targetPath = path.join(deprecatedDir, file);
fs.renameSync(filePath, targetPath);
// console.log(`Moved: ${filePath} -> ${targetPath}`);
}
});
});
}
}
freePlanConfiguration();