@@ -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+
158168async 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