-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.js
85 lines (78 loc) · 2.58 KB
/
readme.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
const fs = require('node:fs');
const path = require('node:path');
// const demos = require('./demos.js').demos;
// function findDemo(group, uniqueName, demos, parent, category) {
// console.log('itt', parent, category);
// let found = false;
// let i = 0;
// while (!found && i < demos.length) {
// if (demos[i].unique === uniqueName && parent === group) {
// found = true;
// console.log('found!!!');
// return {
// name: demos[i].name,
// category,
// };
// }
// if (demos[i].items) {
// const res = findDemo(group, uniqueName, demos[i].items, demos[i].unique, category || demos[i].name);
// if (res) {
// return res;
// }
// }
// i++;
// }
// }
function createReadme(framework) {
const folderPath = './mobiscroll-demos-' + framework + '/src/demos';
const content =
// '# This is the ' +
// name +
// 'source of the' + ... + demo
'To download and run this example locally, please follow the instructions [in the readme file of the project](https://github.com/acidb/mobiscroll-demos-' +
framework +
'?tab=readme-ov-file#mobiscroll-' +
framework.replace('-ts', '-typescript') +
'-demos).\n\n' +
'To see this example live, check it out on our [demo page](https://demo.mobiscroll.com/' +
framework.replace('-ts', '') +
'/';
readAllFiles(folderPath, content);
}
function readAllFiles(dir, content) {
const files = fs.readdirSync(dir, { withFileTypes: true });
// console.log(files)
// console.log("PATH ", dir, " FILE ", files)
for (const file of files) {
if (file.isDirectory()) {
// console.log("DIR ", "PATH ", dir, " DIR ", file)
readAllFiles(path.join(dir, file.name), content);
} else {
path.join(dir, file.name);
const myPath = path.join(dir, 'README.md');
const pathList = dir.split('/');
const finalContent =
content +
(pathList[4] === 'calendar-view' ? 'eventcalendar' : pathList[4]) +
'/' +
(pathList[5] === 'conditional-move-resize'
? 'conditional-move-resize-drag-drop-fixed-event-length-fixed-to-resource'
: pathList[5]) +
'#).';
fs.writeFile(myPath, finalContent, (err) => {
if (err) console.log(err);
else {
console.log('DIR ', 'PATH ', dir, ' DIR ', file);
}
});
}
}
}
createReadme('angular');
createReadme('javascript');
createReadme('jquery');
createReadme('react');
createReadme('react-ts');
createReadme('vue');
createReadme('vue-ts');
// console.log(findDemo('calendar-view', 'customizing-header', demos));