fix(core): update
This commit is contained in:
@ -11,6 +11,11 @@ const incompatibleLicenses: string[] = [
|
||||
];
|
||||
|
||||
export const run = async (projectArg: Project) => {
|
||||
const nodeModulesInstalled = await plugins.smartfile.fs.isDirectory(plugins.path.join(paths.cwd, 'node_modules'));
|
||||
if (!nodeModulesInstalled) {
|
||||
logger.log('warn', 'No node_modules found. Skipping license check');
|
||||
return;
|
||||
}
|
||||
const licenseChecker = await plugins.smartlegal.createLicenseChecker();
|
||||
const licenseCheckResult = await licenseChecker.excludeLicenseWithinPath(paths.cwd, incompatibleLicenses);
|
||||
if (licenseCheckResult.failingModules.length === 0) {
|
||||
|
@ -1,47 +1,25 @@
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import * as paths from '../paths.js';
|
||||
import { GitzoneConfig } from '../classes.gitzoneconfig.js';
|
||||
import { Project } from '../classes.project.js';
|
||||
|
||||
export const run = async (projectArg: Project) => {
|
||||
export const run = async () => {
|
||||
const readmePath = plugins.path.join(paths.cwd, 'readme.md');
|
||||
const readmeFile = await plugins.smartfile.SmartFile.fromFilePath(readmePath);
|
||||
const readmeHintsPath = plugins.path.join(paths.cwd, 'readme.hints.md');
|
||||
|
||||
// lets do our transformation
|
||||
|
||||
let usageInfo: string = '';
|
||||
const gitzoneConfig = await GitzoneConfig.fromCwd();
|
||||
|
||||
if (readmeFile) {
|
||||
const readmeFileString = readmeFile.contentBuffer.toString();
|
||||
const stringArray1 = readmeFileString.split('## Usage\n');
|
||||
if (stringArray1[1]) {
|
||||
const stringArray2 = stringArray1[1].split(
|
||||
'\nFor further information read the linked docs at the top of this readme.'
|
||||
);
|
||||
const stringArray3 = stringArray2[0].split('\n\n## Contribution');
|
||||
usageInfo = stringArray3[0];
|
||||
}
|
||||
// Check and initialize readme.md if it doesn't exist
|
||||
const readmeExists = await plugins.smartfile.fs.fileExists(readmePath);
|
||||
if (!readmeExists) {
|
||||
await plugins.smartfile.fs.toFs('# Project Readme\n\nThis is the initial readme file.', readmePath);
|
||||
console.log('Initialized readme.md');
|
||||
} else {
|
||||
console.log('readme.md already exists');
|
||||
}
|
||||
|
||||
if (gitzoneConfig.data.module && gitzoneConfig.data.module.license === 'MIT') {
|
||||
usageInfo +=
|
||||
'\n\n## Contribution\n\n' +
|
||||
'We are always happy for code contributions. If you are not the code contributing type that is ok. ' +
|
||||
'Still, maintaining Open Source repositories takes considerable time and thought. ' +
|
||||
'If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: ' +
|
||||
'You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)\n';
|
||||
// Check and initialize readme.hints.md if it doesn't exist
|
||||
const readmeHintsExists = await plugins.smartfile.fs.fileExists(readmeHintsPath);
|
||||
if (!readmeHintsExists) {
|
||||
await plugins.smartfile.fs.toFs('# Project Readme Hints\n\nThis is the initial readme hints file.', readmeHintsPath);
|
||||
console.log('Initialized readme.hints.md');
|
||||
} else {
|
||||
console.log('readme.hints.md already exists');
|
||||
}
|
||||
|
||||
const templateModule = await import('../mod_template/index.js');
|
||||
const readmeTemplate = await templateModule.getTemplate('readme');
|
||||
console.log(gitzoneConfig.data);
|
||||
await readmeTemplate.supplyVariables({
|
||||
module: {
|
||||
...gitzoneConfig.data.module,
|
||||
},
|
||||
usageInfo,
|
||||
});
|
||||
await readmeTemplate.askCliForMissingVariables();
|
||||
await readmeTemplate.writeToDisk(paths.cwd);
|
||||
};
|
||||
};
|
@ -34,5 +34,5 @@ export let run = async (write: boolean = true): Promise<any> => {
|
||||
|
||||
// format readme.md
|
||||
const formatReadme = await import('./format.readme.js');
|
||||
// await formatReadme.run();
|
||||
await formatReadme.run();
|
||||
};
|
||||
|
Reference in New Issue
Block a user