refactor: release script refactoring

This commit is contained in:
Nishchit Dhanani
2023-04-24 14:42:18 +05:30
parent 3abd426031
commit 8c5da0b7d3
5 changed files with 410 additions and 285 deletions

View File

@@ -2,10 +2,9 @@
require('dotenv').config();
const fs = require('fs');
const path = require('path');
// const colors = require('colors');
require('shelljs/global');
const { Environment, AppFormat } = require('./constants');
const build = require('../webpack.prod');
require('shelljs/global');
const env = process.env.NODE_ENV;
@@ -36,15 +35,6 @@ module.exports = async () => {
if (!fs.existsSync(directoryPath)) mkdir(directoryPath);
});
// Copy build-scripts to generate build
// cp(
// '-R',
// path.join(
// `${__dirname}/../packages/firecamp-desktop-app/src/build-scripts/*`
// ),
// `${buildPath}/build-scripts`
// );
// Copy react app assets
cp(
'-R',
@@ -55,74 +45,9 @@ module.exports = async () => {
// generate package.json and manifest based on app environment
// exec(`node ${buildPath}/build-scripts/init-package.js`);
// Generate .html
// exec(
// `pug -O "{ env: '${env}' }" -o ${buildPath} ${path.join(
// __dirname,
// '../platform/firecamp-platform/public/views/'
// )}`
// );
// cp(
// '-R',
// path.join(
// `${__dirname}/../packages/firecamp-desktop-app/public/splashscreen.html`
// ),
// `${buildPath}`
// );
// Copy electron agent assets, config and services
if (
env === Environment.Production &&
process.env.AppFormat !== AppFormat.WebApp
) {
// Copy electron agent services
cp(
'-R',
path.join(
`${__dirname}/../packages/firecamp-desktop-app/dist/services/*`
),
`${buildPath}/services`
);
// Copy http executor
cp(
'-R',
path.join(`${__dirname}/../packages-executors/*`),
`${buildPath}/packages-executors`
);
// Copy dmg app assets
if (process.env.AppFormat === AppFormat.Dmg) {
mkdir(`${buildPath}/build`);
cp(
'-R',
path.join(
`${__dirname}/../packages/firecamp-desktop-app/public/assets/${env}/mac/*`
),
`${buildPath}/build`
);
}
// Copy common assets
cp(
'-R',
path.join(
`${__dirname}/../packages/firecamp-desktop-app/public/assets/${
[...Object.values(Environment)].includes(env)
? 'production'
: 'canary'
}`
),
`${buildPath}/assets`
);
}
if (env === Environment.Production || env === Environment.Staging) {
await build();
}
return Promise.resolve();
} catch (error) {
return Promise.reject(error);