mirror of
https://github.com/LukeHagar/firecamp.git
synced 2025-12-09 20:37:45 +00:00
refactor: release script refactoring
This commit is contained in:
@@ -2,10 +2,9 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
// const colors = require('colors');
|
require('shelljs/global');
|
||||||
const { Environment, AppFormat } = require('./constants');
|
const { Environment, AppFormat } = require('./constants');
|
||||||
const build = require('../webpack.prod');
|
const build = require('../webpack.prod');
|
||||||
require('shelljs/global');
|
|
||||||
|
|
||||||
const env = process.env.NODE_ENV;
|
const env = process.env.NODE_ENV;
|
||||||
|
|
||||||
@@ -36,15 +35,6 @@ module.exports = async () => {
|
|||||||
if (!fs.existsSync(directoryPath)) mkdir(directoryPath);
|
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
|
// Copy react app assets
|
||||||
cp(
|
cp(
|
||||||
'-R',
|
'-R',
|
||||||
@@ -55,74 +45,9 @@ module.exports = async () => {
|
|||||||
// generate package.json and manifest based on app environment
|
// generate package.json and manifest based on app environment
|
||||||
// exec(`node ${buildPath}/build-scripts/init-package.js`);
|
// 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) {
|
if (env === Environment.Production || env === Environment.Staging) {
|
||||||
await build();
|
await build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
|
|||||||
132
scripts/deprecated/build.js
Normal file
132
scripts/deprecated/build.js
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
require('dotenv').config();
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
// const colors = require('colors');
|
||||||
|
const { Environment, AppFormat } = require('./constants');
|
||||||
|
const build = require('../webpack.prod');
|
||||||
|
require('shelljs/global');
|
||||||
|
|
||||||
|
const env = process.env.NODE_ENV;
|
||||||
|
|
||||||
|
module.exports = async () => {
|
||||||
|
try {
|
||||||
|
// hold the build path as per the environment mode
|
||||||
|
const buildPath = path.join(`${__dirname}/../build/${env}`);
|
||||||
|
// copy project assets and generate config.
|
||||||
|
const directoryPaths = [path.join(`${__dirname}/../build`), buildPath];
|
||||||
|
if (env === Environment.Development) {
|
||||||
|
directoryPaths.push(
|
||||||
|
path.join(`${__dirname}/../build/${env}/build-scripts`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (env === Environment.Production) {
|
||||||
|
directoryPaths.push(
|
||||||
|
path.join(`${__dirname}/../build/${env}/build-scripts`),
|
||||||
|
path.join(`${__dirname}/../build/${env}/services`),
|
||||||
|
path.join(`${__dirname}/../build/${env}/packages-executors`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove build before start bundle
|
||||||
|
rm('-rf', buildPath);
|
||||||
|
|
||||||
|
// Create build directories
|
||||||
|
directoryPaths.forEach((directoryPath) => {
|
||||||
|
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',
|
||||||
|
path.join(`${__dirname}/../platform/firecamp-platform/public/assets/*`),
|
||||||
|
buildPath
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (env === Environment.Development) module.exports();
|
||||||
16
scripts/deprecated/constants.js
Normal file
16
scripts/deprecated/constants.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const Environment = {
|
||||||
|
Development: 'development',
|
||||||
|
Staging: 'staging', // staging will be for testing purpose
|
||||||
|
Production: 'production',
|
||||||
|
Canary: 'canary', // Canary is production but for early adopter
|
||||||
|
};
|
||||||
|
|
||||||
|
const AppFormat = {
|
||||||
|
WebApp: 'webapp',
|
||||||
|
Dmg: 'dmg',
|
||||||
|
AppImage: 'appImage',
|
||||||
|
Snap: 'snap',
|
||||||
|
NSIS: 'nsis',
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { Environment, AppFormat };
|
||||||
254
scripts/deprecated/release.js
Normal file
254
scripts/deprecated/release.js
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
require('dotenv-vault-core').config();
|
||||||
|
const { red, yellow } = require('colors');
|
||||||
|
const semver = require('semver');
|
||||||
|
require('shelljs/global');
|
||||||
|
const build = require('./build');
|
||||||
|
const { version } = require('../package.json');
|
||||||
|
const { Environment, AppFormat } = require('./constants');
|
||||||
|
|
||||||
|
const env = process.env.NODE_ENV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1. test variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
const validator = {
|
||||||
|
/** validate project version */
|
||||||
|
version: () => {
|
||||||
|
if (!semver.valid(version)) {
|
||||||
|
console.log(
|
||||||
|
`${red('Error:')} invalid project version(${yellow(version)})`
|
||||||
|
);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** validate env variables */
|
||||||
|
variables: () => {
|
||||||
|
const variables = [
|
||||||
|
'FIRECAMP_API_HOST',
|
||||||
|
'CSC_KEY_PASSWORD',
|
||||||
|
'CSC_LINK',
|
||||||
|
'DO_KEY_ID',
|
||||||
|
'DO_SECRET_KEY',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Check if environment variables set
|
||||||
|
variables.forEach((variable) => {
|
||||||
|
if (
|
||||||
|
!process.env.variable ||
|
||||||
|
typeof process.env[variable] === 'undefined' ||
|
||||||
|
process.env[variable].length < 5
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
`${red('Error:')} Env. variable ${yellow(variable)} not set`
|
||||||
|
);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const helper = {
|
||||||
|
buildWebApp: async () => {
|
||||||
|
process.env.NODE_OPTIONS = '--max-old-space-size=4096';
|
||||||
|
|
||||||
|
await build();
|
||||||
|
|
||||||
|
// Finished the process if build=chrome
|
||||||
|
if (process.env.AppFormat === AppFormat.WebApp) {
|
||||||
|
// remove unused packages
|
||||||
|
rm('-rf', `build/${env}/build-scripts`);
|
||||||
|
rm('-rf', `build/${env}/packages-executors`);
|
||||||
|
rm('-rf', `build/${env}/services`);
|
||||||
|
|
||||||
|
// remove chrome extension app files // TODO: remove it later
|
||||||
|
rm('-rf', `build/${env}/splashscreen.html`);
|
||||||
|
rm('-rf', `build/${env}/manifest.json`);
|
||||||
|
rm('-rf', `build/${env}/background.html`);
|
||||||
|
rm('-rf', `build/${env}/window.html`);
|
||||||
|
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// set app version in the environment
|
||||||
|
process.env.APP_VERSION = version;
|
||||||
|
|
||||||
|
// check FIRECAMP_API_HOST env. variable value does not contains invalid value
|
||||||
|
if (
|
||||||
|
env !== Environment.Staging &&
|
||||||
|
(process.env.FIRECAMP_API_HOST.includes('localhost') ||
|
||||||
|
process.env.FIRECAMP_API_HOST.includes('testing') ||
|
||||||
|
process.env.FIRECAMP_API_HOST.includes('127.0.0.1'))
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
`${red(
|
||||||
|
'Error:'
|
||||||
|
)} invalid value set for env. variable (FIRECAMP_API_HOST ${yellow(
|
||||||
|
process.env.FIRECAMP_API_HOST
|
||||||
|
)})`
|
||||||
|
);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
const _exec = (command) =>
|
||||||
|
new Promise((resolve) => {
|
||||||
|
let result;
|
||||||
|
|
||||||
|
const _command = exec(command, { async: true, silent: true });
|
||||||
|
|
||||||
|
_command.stdout.on('data', (data) => {
|
||||||
|
result = data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
_command.on('close', (code) => {
|
||||||
|
if (code !== 0) {
|
||||||
|
console.error(
|
||||||
|
`
|
||||||
|
${red('Error: ')}Failed to execute command: ${command}`
|
||||||
|
);
|
||||||
|
|
||||||
|
process.exit();
|
||||||
|
} else {
|
||||||
|
console.log(`
|
||||||
|
✅ ${command} executed successfully`);
|
||||||
|
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const preBuildCliCommands = async () => {
|
||||||
|
// Prevent check git tag while staging build
|
||||||
|
if (env === Environment.Staging) return Promise.resolve();
|
||||||
|
|
||||||
|
// Check is tag was checked out or not
|
||||||
|
// await _exec('git describe --tags', { async: true })
|
||||||
|
// .then((result) => {
|
||||||
|
// console.log(result);
|
||||||
|
// if (result.replace(/\n/g, '') !== `v${version}`) {
|
||||||
|
// console.log(
|
||||||
|
// `${red('Error:')} Please checkout tag '${yellow(
|
||||||
|
// `v${version}`
|
||||||
|
// )}' for release`
|
||||||
|
// );
|
||||||
|
// process.exit();
|
||||||
|
// } else return Promise.resolve();
|
||||||
|
// })
|
||||||
|
// .catch((e) => {
|
||||||
|
// console.log(e, 'this is the error');
|
||||||
|
// });
|
||||||
|
};
|
||||||
|
|
||||||
|
if (env === Environment.Staging) {
|
||||||
|
helper.buildWebApp();
|
||||||
|
}
|
||||||
|
if (env === Environment.Production) {
|
||||||
|
try {
|
||||||
|
preBuildCliCommands().then(async () => {
|
||||||
|
await helper.buildWebApp();
|
||||||
|
|
||||||
|
// Set bundle id for electron app
|
||||||
|
if (env === Environment.Production)
|
||||||
|
process.env.appBundleId = 'com.firecamp.app';
|
||||||
|
else if (env === Environment.Canary)
|
||||||
|
process.env.appBundleId = 'com.firecamp.canary';
|
||||||
|
|
||||||
|
// Copy release note and post build checks
|
||||||
|
// cp(
|
||||||
|
// '-R',
|
||||||
|
// 'packages/firecamp-desktop-app/public/release-notes.md',
|
||||||
|
// 'build/production'
|
||||||
|
// );
|
||||||
|
|
||||||
|
// Remove chrome extension app files
|
||||||
|
rm('-rf', 'build/production/background.html');
|
||||||
|
rm('-rf', 'build/production/window.html');
|
||||||
|
rm('-rf', 'build/production/js/background.bundle.js');
|
||||||
|
|
||||||
|
// Add library: electron
|
||||||
|
// cd('build/production');
|
||||||
|
// exec(
|
||||||
|
// 'export NODE_ENV=development && pnpm install && pnpm add_electron && export NODE_ENV=production'
|
||||||
|
// );
|
||||||
|
|
||||||
|
// Add library: electron-oauth-helper
|
||||||
|
// exec('pnpm add ../../../firecamp-forks/electron-oauth-helper -W');
|
||||||
|
|
||||||
|
// Prepare linux os 'AppImage' build
|
||||||
|
if (process.env.AppFormat === AppFormat.AppImage) {
|
||||||
|
// do not publish the app
|
||||||
|
if (process.argv[3] === 'l') exec('electron-builder --linux AppImage');
|
||||||
|
|
||||||
|
// publish the app
|
||||||
|
if (process.argv[3] === 'p') {
|
||||||
|
exec(
|
||||||
|
'electron-builder --linux AppImage -p always -c.releaseInfo.releaseNotesFile=release-notes.md'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get the hash value of the AppImage build
|
||||||
|
const shasum = await _exec(
|
||||||
|
`shasum -a 256 ./dist/Firecamp-${process.env.APP_VERSION}.AppImage`
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`${yellow('shasum:')} ${shasum}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare linux os 'Snap' build
|
||||||
|
if (process.env.AppFormat === AppFormat.Snap) {
|
||||||
|
// do not publish the app
|
||||||
|
if (process.argv[3] === 'l') exec('electron-builder --linux Snap');
|
||||||
|
|
||||||
|
// publish the app
|
||||||
|
if (process.argv[3] === 'p')
|
||||||
|
exec('electron-builder --linux Snap -p always');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare windows os 'nsis' build
|
||||||
|
if (process.env.AppFormat === AppFormat.NSIS) {
|
||||||
|
// do not publish the app
|
||||||
|
if (process.argv[3] === 'l') exec('electron-builder --win');
|
||||||
|
|
||||||
|
// publish the app
|
||||||
|
if (process.argv[3] === 'p') {
|
||||||
|
exec(
|
||||||
|
'electron-builder --win -p always -c.releaseInfo.releaseNotesFile=release-notes.md'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get the hash value of the nsis build
|
||||||
|
const shasum = await _exec(
|
||||||
|
`shasum -a 256 ./dist/Firecamp-${process.env.APP_VERSION}.exe`
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`${yellow('shasum:')} ${shasum}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare mac os 'dmg' build
|
||||||
|
if (process.env.AppFormat === AppFormat.Dmg) {
|
||||||
|
// do not publish the app
|
||||||
|
if (process.argv[3] === 'l') exec('electron-builder --mac');
|
||||||
|
|
||||||
|
// publish the app
|
||||||
|
if (process.argv[3] === 'p') {
|
||||||
|
exec(
|
||||||
|
'electron-builder --mac -p always -c.releaseInfo.releaseNotesFile=release-notes.md'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get the hash value of the nsis build
|
||||||
|
const shasum = await _exec(
|
||||||
|
`shasum -a 256 ./dist/Firecamp-${process.env.APP_VERSION}.dmg`
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`${yellow('shasum:')} ${shasum}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,69 +8,10 @@ const { version } = require('../package.json');
|
|||||||
const { Environment, AppFormat } = require('./constants');
|
const { Environment, AppFormat } = require('./constants');
|
||||||
|
|
||||||
const env = process.env.NODE_ENV;
|
const env = process.env.NODE_ENV;
|
||||||
|
|
||||||
/**
|
|
||||||
* 1. test variables
|
|
||||||
*/
|
|
||||||
|
|
||||||
const validator = {
|
|
||||||
/** validate project version */
|
|
||||||
version: () => {
|
|
||||||
if (!semver.valid(version)) {
|
|
||||||
console.log(
|
|
||||||
`${red('Error:')} invalid project version(${yellow(version)})`
|
|
||||||
);
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/** validate env variables */
|
|
||||||
variables: () => {
|
|
||||||
const variables = [
|
|
||||||
'FIRECAMP_API_HOST',
|
|
||||||
'CSC_KEY_PASSWORD',
|
|
||||||
'CSC_LINK',
|
|
||||||
'DO_KEY_ID',
|
|
||||||
'DO_SECRET_KEY',
|
|
||||||
];
|
|
||||||
|
|
||||||
// Check if environment variables set
|
|
||||||
variables.forEach((variable) => {
|
|
||||||
if (
|
|
||||||
!process.env.variable ||
|
|
||||||
typeof process.env[variable] === 'undefined' ||
|
|
||||||
process.env[variable].length < 5
|
|
||||||
) {
|
|
||||||
console.log(
|
|
||||||
`${red('Error:')} Env. variable ${yellow(variable)} not set`
|
|
||||||
);
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const helper = {
|
const helper = {
|
||||||
buildWebApp: async () => {
|
buildWebApp: async () => {
|
||||||
process.env.NODE_OPTIONS = '--max-old-space-size=4096';
|
process.env.NODE_OPTIONS = '--max-old-space-size=4096';
|
||||||
|
|
||||||
await build();
|
await build();
|
||||||
|
|
||||||
// Finished the process if build=chrome
|
|
||||||
if (process.env.AppFormat === AppFormat.WebApp) {
|
|
||||||
// remove unused packages
|
|
||||||
rm('-rf', `build/${env}/build-scripts`);
|
|
||||||
rm('-rf', `build/${env}/packages-executors`);
|
|
||||||
rm('-rf', `build/${env}/services`);
|
|
||||||
|
|
||||||
// remove chrome extension app files // TODO: remove it later
|
|
||||||
rm('-rf', `build/${env}/splashscreen.html`);
|
|
||||||
rm('-rf', `build/${env}/manifest.json`);
|
|
||||||
rm('-rf', `build/${env}/background.html`);
|
|
||||||
rm('-rf', `build/${env}/window.html`);
|
|
||||||
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -78,11 +19,12 @@ const helper = {
|
|||||||
process.env.APP_VERSION = version;
|
process.env.APP_VERSION = version;
|
||||||
|
|
||||||
// check FIRECAMP_API_HOST env. variable value does not contains invalid value
|
// check FIRECAMP_API_HOST env. variable value does not contains invalid value
|
||||||
|
const { FIRECAMP_API_HOST = '' } = process.env;
|
||||||
if (
|
if (
|
||||||
env !== Environment.Staging &&
|
env !== Environment.Staging &&
|
||||||
(process.env.FIRECAMP_API_HOST.includes('localhost') ||
|
(FIRECAMP_API_HOST.includes('localhost') ||
|
||||||
process.env.FIRECAMP_API_HOST.includes('testing') ||
|
FIRECAMP_API_HOST.includes('testing') ||
|
||||||
process.env.FIRECAMP_API_HOST.includes('127.0.0.1'))
|
FIRECAMP_API_HOST.includes('127.0.0.1'))
|
||||||
) {
|
) {
|
||||||
console.log(
|
console.log(
|
||||||
`${red(
|
`${red(
|
||||||
@@ -94,159 +36,15 @@ if (
|
|||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
const _exec = (command) =>
|
|
||||||
new Promise((resolve) => {
|
|
||||||
let result;
|
|
||||||
|
|
||||||
const _command = exec(command, { async: true, silent: true });
|
|
||||||
|
|
||||||
_command.stdout.on('data', (data) => {
|
|
||||||
result = data.toString();
|
|
||||||
});
|
|
||||||
|
|
||||||
_command.on('close', (code) => {
|
|
||||||
if (code !== 0) {
|
|
||||||
console.error(
|
|
||||||
`
|
|
||||||
${red('Error: ')}Failed to execute command: ${command}`
|
|
||||||
);
|
|
||||||
|
|
||||||
process.exit();
|
|
||||||
} else {
|
|
||||||
console.log(`
|
|
||||||
✅ ${command} executed successfully`);
|
|
||||||
|
|
||||||
resolve(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const preBuildCliCommands = async () => {
|
const preBuildCliCommands = async () => {
|
||||||
// Prevent check git tag while staging build
|
// pre conditions can be validated here
|
||||||
if (env === Environment.Staging) return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|
||||||
// Check is tag was checked out or not
|
|
||||||
// await _exec('git describe --tags', { async: true })
|
|
||||||
// .then((result) => {
|
|
||||||
// console.log(result);
|
|
||||||
// if (result.replace(/\n/g, '') !== `v${version}`) {
|
|
||||||
// console.log(
|
|
||||||
// `${red('Error:')} Please checkout tag '${yellow(
|
|
||||||
// `v${version}`
|
|
||||||
// )}' for release`
|
|
||||||
// );
|
|
||||||
// process.exit();
|
|
||||||
// } else return Promise.resolve();
|
|
||||||
// })
|
|
||||||
// .catch((e) => {
|
|
||||||
// console.log(e, 'this is the error');
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (env === Environment.Staging) {
|
if ([Environment.Production, Environment.Staging].includes(env)) {
|
||||||
helper.buildWebApp();
|
|
||||||
}
|
|
||||||
if (env === Environment.Production) {
|
|
||||||
try {
|
try {
|
||||||
preBuildCliCommands().then(async () => {
|
preBuildCliCommands().then(async () => {
|
||||||
await helper.buildWebApp();
|
await helper.buildWebApp();
|
||||||
|
|
||||||
// Set bundle id for electron app
|
|
||||||
if (env === Environment.Production)
|
|
||||||
process.env.appBundleId = 'com.firecamp.app';
|
|
||||||
else if (env === Environment.Canary)
|
|
||||||
process.env.appBundleId = 'com.firecamp.canary';
|
|
||||||
|
|
||||||
// Copy release note and post build checks
|
|
||||||
// cp(
|
|
||||||
// '-R',
|
|
||||||
// 'packages/firecamp-desktop-app/public/release-notes.md',
|
|
||||||
// 'build/production'
|
|
||||||
// );
|
|
||||||
|
|
||||||
// Remove chrome extension app files
|
|
||||||
rm('-rf', 'build/production/background.html');
|
|
||||||
rm('-rf', 'build/production/window.html');
|
|
||||||
rm('-rf', 'build/production/js/background.bundle.js');
|
|
||||||
|
|
||||||
// Add library: electron
|
|
||||||
// cd('build/production');
|
|
||||||
// exec(
|
|
||||||
// 'export NODE_ENV=development && pnpm install && pnpm add_electron && export NODE_ENV=production'
|
|
||||||
// );
|
|
||||||
|
|
||||||
// Add library: electron-oauth-helper
|
|
||||||
// exec('pnpm add ../../../firecamp-forks/electron-oauth-helper -W');
|
|
||||||
|
|
||||||
// Prepare linux os 'AppImage' build
|
|
||||||
if (process.env.AppFormat === AppFormat.AppImage) {
|
|
||||||
// do not publish the app
|
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --linux AppImage');
|
|
||||||
|
|
||||||
// publish the app
|
|
||||||
if (process.argv[3] === 'p') {
|
|
||||||
exec(
|
|
||||||
'electron-builder --linux AppImage -p always -c.releaseInfo.releaseNotesFile=release-notes.md'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get the hash value of the AppImage build
|
|
||||||
const shasum = await _exec(
|
|
||||||
`shasum -a 256 ./dist/Firecamp-${process.env.APP_VERSION}.AppImage`
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`${yellow('shasum:')} ${shasum}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare linux os 'Snap' build
|
|
||||||
if (process.env.AppFormat === AppFormat.Snap) {
|
|
||||||
// do not publish the app
|
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --linux Snap');
|
|
||||||
|
|
||||||
// publish the app
|
|
||||||
if (process.argv[3] === 'p')
|
|
||||||
exec('electron-builder --linux Snap -p always');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare windows os 'nsis' build
|
|
||||||
if (process.env.AppFormat === AppFormat.NSIS) {
|
|
||||||
// do not publish the app
|
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --win');
|
|
||||||
|
|
||||||
// publish the app
|
|
||||||
if (process.argv[3] === 'p') {
|
|
||||||
exec(
|
|
||||||
'electron-builder --win -p always -c.releaseInfo.releaseNotesFile=release-notes.md'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get the hash value of the nsis build
|
|
||||||
const shasum = await _exec(
|
|
||||||
`shasum -a 256 ./dist/Firecamp-${process.env.APP_VERSION}.exe`
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`${yellow('shasum:')} ${shasum}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare mac os 'dmg' build
|
|
||||||
if (process.env.AppFormat === AppFormat.Dmg) {
|
|
||||||
// do not publish the app
|
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --mac');
|
|
||||||
|
|
||||||
// publish the app
|
|
||||||
if (process.argv[3] === 'p') {
|
|
||||||
exec(
|
|
||||||
'electron-builder --mac -p always -c.releaseInfo.releaseNotesFile=release-notes.md'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get the hash value of the nsis build
|
|
||||||
const shasum = await _exec(
|
|
||||||
`shasum -a 256 ./dist/Firecamp-${process.env.APP_VERSION}.dmg`
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`${yellow('shasum:')} ${shasum}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user