https://github.com/nativescript-community/plugin-seed-tools
https://github.com/nativescript-community/plugin-seed-tools
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/nativescript-community/plugin-seed-tools
- Owner: nativescript-community
- Created: 2021-01-13T12:10:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-14T15:16:20.000Z (over 1 year ago)
- Last Synced: 2024-11-24T20:07:42.685Z (over 1 year ago)
- Language: JavaScript
- Size: 2.44 MB
- Stars: 0
- Watchers: 18
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.js
Awesome Lists containing this project
README
const fs = require('fs');
const path = require('path');
const exec = require('child_process').exec;
const pluginConfig = fs.readFileSync('config.json');
const pluginConfigJson = JSON.parse(pluginConfig);
function listFoldersSync(dir) {
const folders = [];
fs.readdirSync(dir).forEach((f) => {
const dirPath = path.join(dir, f);
const isDirectory = fs.statSync(dirPath).isDirectory();
if (isDirectory) {
folders.push(f);
}
});
return folders;
}
let enabled = false;
if ('readme' in pluginConfigJson) {
enabled = pluginConfigJson['readme'];
}
if (enabled) {
const files = listFoldersSync('./packages');
const packagesCount = files.length;
let readmeOutput = '';
if (fs.existsSync('header.md')) {
readmeOutput += '{{ load:header.md }}\n';
}
if (packagesCount > 1) {
readmeOutput += 'This monorepo contains multiple packages:
';
}
for (const package of files) {
const multiPackageMarkdown = `\n
${package}
\n{{ load:packages/${package}/README.md }}
`;
const singlePackageMarkdown = `{{ load:packages/${package}/README.md }}`;
if (packagesCount > 1) {
readmeOutput += multiPackageMarkdown;
} else {
readmeOutput += singlePackageMarkdown;
}
}
if (fs.existsSync('info.md')) {
readmeOutput += '\n{{ load:info.md }}';
}
readmeOutput += '\n{{ load:tools/readme/demos-and-development.md }}{{ load:tools/readme/questions.md }}';
if (fs.existsSync('footer.md')) {
readmeOutput += '\n{{ load:footer.md }}';
}
try {
fs.writeFileSync('blueprint.md', readmeOutput);
} catch (err) {
console.error(err);
}
exec('./node_modules/.bin/readme generate -c ./tools/readme/blueprint.json', function (err, stdout, stderr) {
if (err) {
console.log(stderr);
}
console.log(stdout);
});
} else {
console.log('README generation is disabled. To enable, add "readme": true to the config.json');
}