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:
2026-04-25 14:26:22 -04:00
parent 5996157fbc
commit d7bfe34bb1
4 changed files with 17 additions and 1 deletions
+11
View File
@@ -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');