Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit b0ae9cd

Browse files
Merge pull request #167 from Cloud-Code-AI/166-bug-update-command-with-editor-installed-loses-the-scripts-to-run-editor
fix: update editor packages on update
2 parents 139e8cf + cd7bff7 commit b0ae9cd

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

packages/create-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-akiradocs",
3-
"version": "1.0.39",
3+
"version": "1.0.40",
44
"description": "Create Akira Docs documentation sites with one command",
55
"main": "./dist/index.js",
66
"type": "module",

packages/create-app/src/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ async function copyEditor(targetDir: string) {
155155
}
156156
}
157157

158+
async function isEditorInstalled(targetDir: string) {
159+
try {
160+
const editorDir = path.join(targetDir, 'editor');
161+
await readFile(path.join(editorDir, 'package.json'), 'utf-8');
162+
return true;
163+
} catch (error) {
164+
return false;
165+
}
166+
}
167+
158168
async function main() {
159169
const packageJsonPath = path.resolve(__dirname, '../package.json');
160170
const packageJson = await readJson(packageJsonPath);
@@ -236,6 +246,31 @@ async function main() {
236246
const templateDir = path.join(__dirname, '../template/default');
237247
await updateDir(templateDir, '.');
238248

249+
// Check if editor is installed
250+
if (await isEditorInstalled('.')) {
251+
spinner.text = 'Updating editor files...';
252+
const editorCopied = await copyEditor('.');
253+
254+
if (editorCopied) {
255+
await updateEditorDependencies('.');
256+
257+
// Update package.json scripts
258+
const pkgJsonPath = path.join('.', 'package.json');
259+
const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
260+
pkgJson.scripts = {
261+
...pkgJson.scripts,
262+
'dev:editor': 'cd editor && npm run dev',
263+
'dev:docs': 'npm run dev',
264+
'dev:all': 'concurrently "npm run dev:docs" "npm run dev:editor"',
265+
};
266+
pkgJson.devDependencies = {
267+
...pkgJson.devDependencies,
268+
'concurrently': '^8.0.0',
269+
};
270+
await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
271+
}
272+
}
273+
239274
spinner.succeed(chalk.green('Project updated successfully!'));
240275
console.log('\nNext steps:');
241276
console.log(chalk.cyan(' npm install'));

0 commit comments

Comments
 (0)