Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-akiradocs",
"version": "1.0.39",
"version": "1.0.40",
"description": "Create Akira Docs documentation sites with one command",
"main": "./dist/index.js",
"type": "module",
Expand Down
35 changes: 35 additions & 0 deletions packages/create-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ async function copyEditor(targetDir: string) {
}
}

async function isEditorInstalled(targetDir: string) {
try {
const editorDir = path.join(targetDir, 'editor');
await readFile(path.join(editorDir, 'package.json'), 'utf-8');
return true;
} catch (error) {
return false;
}
}

async function main() {
const packageJsonPath = path.resolve(__dirname, '../package.json');
const packageJson = await readJson(packageJsonPath);
Expand Down Expand Up @@ -236,6 +246,31 @@ async function main() {
const templateDir = path.join(__dirname, '../template/default');
await updateDir(templateDir, '.');

// Check if editor is installed
if (await isEditorInstalled('.')) {
spinner.text = 'Updating editor files...';
const editorCopied = await copyEditor('.');

if (editorCopied) {
await updateEditorDependencies('.');

// Update package.json scripts
const pkgJsonPath = path.join('.', 'package.json');
const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
pkgJson.scripts = {
...pkgJson.scripts,
'dev:editor': 'cd editor && npm run dev',
'dev:docs': 'npm run dev',
'dev:all': 'concurrently "npm run dev:docs" "npm run dev:editor"',
};
pkgJson.devDependencies = {
...pkgJson.devDependencies,
'concurrently': '^8.0.0',
};
await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
}
}

spinner.succeed(chalk.green('Project updated successfully!'));
console.log('\nNext steps:');
console.log(chalk.cyan(' npm install'));
Expand Down
Loading