feat(cli): integrate zen-modules sync into project initialization
- add postinstall, dev, and build scripts to run `zen-modules sync` - append `app/.zen/modules.generated.js` to .gitignore during init - add generated modules file template with empty modules export - import modules.generated.js in app layout and pass modules to initializeZen
This commit is contained in:
+11
@@ -41,6 +41,9 @@ async function initProject() {
|
||||
fs.writeFileSync('README.md', `# ${projectName}\n\nBuilt with Next.js, Tailwind CSS and @zen/core.`);
|
||||
packageJson.scripts ??= {};
|
||||
packageJson.scripts['make-favicon'] = 'node dev/icons/make-favicon.js';
|
||||
packageJson.scripts.postinstall = 'zen-modules sync';
|
||||
packageJson.scripts.dev = 'zen-modules sync && next dev';
|
||||
packageJson.scripts.build = 'zen-modules sync && next build';
|
||||
fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
|
||||
}
|
||||
done('Updated README and package.json');
|
||||
@@ -53,6 +56,14 @@ async function initProject() {
|
||||
fs.copySync(templatesPath, './', { overwrite: true });
|
||||
done('Copied template files');
|
||||
|
||||
const gitignorePath = './.gitignore';
|
||||
if (fs.existsSync(gitignorePath)) {
|
||||
const gitignore = fs.readFileSync(gitignorePath, 'utf-8');
|
||||
if (!gitignore.includes('app/.zen/modules.generated.js')) {
|
||||
fs.appendFileSync(gitignorePath, '\n# Generated by zen-modules sync\napp/.zen/modules.generated.js\n');
|
||||
}
|
||||
}
|
||||
|
||||
step('Installing @zen/core');
|
||||
execSync('npm install @zen/core', { stdio: 'inherit' });
|
||||
done('@zen/core installed');
|
||||
|
||||
Reference in New Issue
Block a user