From 9013a7976b8d7070a0efa531e53311369f81e69b Mon Sep 17 00:00:00 2001 From: Sergey Rubanov Date: Fri, 20 Oct 2023 19:22:28 +0200 Subject: [PATCH] patch package.json --- index.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 8e5ca37..f024453 100755 --- a/index.js +++ b/index.js @@ -81,10 +81,15 @@ viteProcess.on('close', (code) => { const socketIniPath = resolve(cwd, 'socket.ini') const socketIni = readFileSync(socketIniPath, 'utf-8') - const modifiedSocketIni = socketIni.replace( - 'copy = "src"', - 'copy = "dist"' - ) + const modifiedSocketIni = socketIni + .replace( + 'copy = "src"', + 'copy = "dist"' + ) + .replace( + '; script = "npm run build"', + 'script = "npm run build"' + ) writeFileSync(socketIniPath, modifiedSocketIni, 'utf8'); process.stdout.write('\nPatching index.html for the create-vite\n') @@ -92,6 +97,17 @@ viteProcess.on('close', (code) => { const indexHTMLPath = resolve(cwd, 'index.html') const indexHTML = readFileSync(indexHTMLPath, 'utf-8') const modifiedData = indexHTML.replace('', '\n' + CSP + '\n'); - writeFileSync(indexHTMLPath, modifiedData, 'utf8'); + + process.stdout.write('\nPatching package.json\n') + + const packageJSONPath = resolve(cwd, 'package.json') + const packageJSON = readFileSync(packageJSONPath, 'utf-8') + const modifiedPackageJSON = packageJSON.replace( + '"tsc && vite build"', + '"tsc && vite build --"' + ) + writeFileSync(packageJSONPath, modifiedPackageJSON, 'utf8'); + + process.stdout.write(`\nDone!\n\nBuild and run your app with:\nssc build -r ${projectName}`) })