mirror of
https://github.com/LukeHagar/firecamp.git
synced 2025-12-07 20:37:45 +00:00
feat(platform): release/build script optimised
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,10 +2,7 @@ node_modules
|
||||
npm-debug.log
|
||||
.DS_Store
|
||||
|
||||
packages/indexed-db/build
|
||||
build/
|
||||
stageBuild/
|
||||
dev/
|
||||
cypress/screenshots
|
||||
cypress/videos
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
"start": "npx webpack serve --config ./webpack.dev.js",
|
||||
"dev": "APP_VERSION=$npm_package_version RELEASE_SERVER=dev APP_FORMAT=extension && node scripts/build && npm run build:monorepo && yarn start",
|
||||
"electron": "npx electron .",
|
||||
"release:web-app": "export APP_FORMAT=webapp && node scripts/release production",
|
||||
"release:web-app:staging": "export APP_FORMAT=webapp && node scripts/release staging",
|
||||
"release:web-app": "APP_FORMAT=webapp && node scripts/release production",
|
||||
"release:web-app:staging": "APP_FORMAT=webapp && node scripts/release staging",
|
||||
"release:extension": "export APP_FORMAT=extension && node scripts/release production",
|
||||
"release:prod:mac-dmg": "export APP_FORMAT=dmg && node scripts/release production p",
|
||||
"release:prod:linux-appImage": "export APP_FORMAT=appImage && node scripts/release production",
|
||||
@@ -21,7 +21,7 @@
|
||||
"release:canary:mac-dmg": "export APP_FORMAT=dmg && node scripts/release canary p",
|
||||
"release:canary:linux-appImage": "export APP_FORMAT=appImage && node scripts/release canary p",
|
||||
"release:canary:win32-nsis": "export APP_FORMAT=nsis && node scripts/release canary p",
|
||||
"clean": "rimraf build/ dev/ *.zip* .crx",
|
||||
"clean": "rimraf build/ development/ *.zip* .crx",
|
||||
"lint": "eslint packages/firecamp-rest/src/**/*.{ts|tsx} packages/*.js packages-clients/*.js scripts webpack/*.js",
|
||||
"test-e2e": "cross-env NODE_ENV=test mocha -r ./test/setup-app test/e2e",
|
||||
"_test": "cross-env NODE_ENV=test mocha -r ./test/setup-app test/app",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
/* eslint-disable no-console */
|
||||
require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const colors = require('colors');
|
||||
const Environment = require('./environment');
|
||||
const build = require('../webpack.prod');
|
||||
require('shelljs/global');
|
||||
|
||||
@@ -33,9 +35,9 @@ module.exports = async () => {
|
||||
// Copy project assets and generate config.
|
||||
const directoryPaths = [
|
||||
path.join(`${__dirname}/../build`),
|
||||
path.join(`${__dirname}/../build/dev`),
|
||||
path.join(`${__dirname}/../build/development`),
|
||||
path.join(`${__dirname}/../build/production`),
|
||||
path.join(`${__dirname}/../build/dev/build-scripts`),
|
||||
path.join(`${__dirname}/../build/development/build-scripts`),
|
||||
path.join(`${__dirname}/../build/production/build-scripts`),
|
||||
path.join(`${__dirname}/../build/production/services`),
|
||||
path.join(`${__dirname}/../build/production/packages-executors`),
|
||||
@@ -56,13 +58,13 @@ module.exports = async () => {
|
||||
});
|
||||
|
||||
// Copy build-scripts to generate build
|
||||
cp(
|
||||
'-R',
|
||||
path.join(
|
||||
`${__dirname}/../packages/firecamp-desktop-app/src/build-scripts/*`
|
||||
),
|
||||
`${buildPath}/build-scripts`
|
||||
);
|
||||
// cp(
|
||||
// '-R',
|
||||
// path.join(
|
||||
// `${__dirname}/../packages/firecamp-desktop-app/src/build-scripts/*`
|
||||
// ),
|
||||
// `${buildPath}/build-scripts`
|
||||
// );
|
||||
|
||||
// Copy react app assets
|
||||
cp(
|
||||
@@ -120,7 +122,7 @@ module.exports = async () => {
|
||||
cp(
|
||||
'-R',
|
||||
path.join(
|
||||
`${__dirname}/../packages/firecamp-desktop-app/public/assets/${process.env.RELEASE_SERVER}/mac/*`
|
||||
`${__dirname}/../packages/firecamp-desktop-app/public/assets/${process.env.NODE_ENV}/mac/*`
|
||||
),
|
||||
`${buildPath}/build`
|
||||
);
|
||||
@@ -131,9 +133,7 @@ module.exports = async () => {
|
||||
'-R',
|
||||
path.join(
|
||||
`${__dirname}/../packages/firecamp-desktop-app/public/assets/${
|
||||
['production', 'staging', 'dev'].includes(
|
||||
process.env.RELEASE_SERVER
|
||||
)
|
||||
[...Object.values(Environment)].includes(process.env.NODE_ENV)
|
||||
? 'production'
|
||||
: 'canary'
|
||||
}`
|
||||
@@ -153,7 +153,7 @@ module.exports = async () => {
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (process.env.RELEASE_SERVER === 'production') {
|
||||
if (process.env.NODE_ENV === Environment.Production) {
|
||||
console.log(
|
||||
`${colors.red(
|
||||
'Error:'
|
||||
@@ -164,11 +164,11 @@ if (process.env.NODE_ENV === 'development') {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
if (process.env.RELEASE_SERVER === 'dev') module.exports();
|
||||
if (process.env.NODE_ENV === Environment.Development) module.exports();
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (process.env.RELEASE_SERVER === 'dev') {
|
||||
if (process.env.NODE_ENV === Environment.Development) {
|
||||
console.log(
|
||||
`${colors.red(
|
||||
'Error:'
|
||||
|
||||
8
scripts/environment.js
Normal file
8
scripts/environment.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const Environment = {
|
||||
Development: 'development',
|
||||
Staging: 'staging', // staging will be for testing purpose
|
||||
Production: 'production',
|
||||
Canary: 'canary', // Canary is production but for early adopter
|
||||
};
|
||||
|
||||
module.exports = Environment;
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-console */
|
||||
require('dotenv').config();
|
||||
const colors = require('colors');
|
||||
const semver = require('semver');
|
||||
@@ -5,6 +6,8 @@ require('shelljs/global');
|
||||
const build = require('./build');
|
||||
const { version } = require('../package.json');
|
||||
|
||||
const Environment = require('./environment');
|
||||
|
||||
const variables = [
|
||||
// 'FIRECAMP_API_HOST',
|
||||
// 'CSC_KEY_PASSWORD',
|
||||
@@ -25,6 +28,7 @@ if (!semver.valid(version)) {
|
||||
process.env.APP_VERSION = version;
|
||||
|
||||
// Set release server production/staging/canary
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
process.env.RELEASE_SERVER = process.argv[2];
|
||||
|
||||
// Check if environment variables set
|
||||
@@ -43,7 +47,7 @@ variables.forEach((variable) => {
|
||||
|
||||
// Check FIRECAMP_API_HOST env. variable value does not contains invalid value
|
||||
if (
|
||||
process.env.RELEASE_SERVER !== 'staging' &&
|
||||
process.env.NODE_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'))
|
||||
@@ -87,22 +91,27 @@ ${colors.red('Error: ')}Failed to execute command: ${command}`
|
||||
|
||||
const preBuildCliCommands = async () => {
|
||||
// Prevent check git tag while staging build
|
||||
if (process.env.RELEASE_SERVER === 'staging') return Promise.resolve();
|
||||
if (process.env.NODE_ENV === Environment.Staging) return Promise.resolve();
|
||||
|
||||
// Check is tag was checked out or not
|
||||
const result = await _exec('git describe --tags', { async: true });
|
||||
if (result.replace(/\n/g, '') !== `v${version}`) {
|
||||
console.log(
|
||||
`
|
||||
${colors.red('Error:')} Please checkout tag '${colors.yellow(
|
||||
`v${version}`
|
||||
)}' for release`
|
||||
);
|
||||
process.exit();
|
||||
} else return Promise.resolve();
|
||||
// await _exec('git describe --tags', { async: true })
|
||||
// .then((result) => {
|
||||
// console.log(result);
|
||||
// if (result.replace(/\n/g, '') !== `v${version}`) {
|
||||
// console.log(
|
||||
// `${colors.red('Error:')} Please checkout tag '${colors.yellow(
|
||||
// `v${version}`
|
||||
// )}' for release`
|
||||
// );
|
||||
// process.exit();
|
||||
// } else return Promise.resolve();
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// console.log(e, 'this is the error');
|
||||
// });
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
if (process.env.NODE_ENV === Environment.Production) {
|
||||
try {
|
||||
preBuildCliCommands().then(async () => {
|
||||
/**
|
||||
@@ -134,9 +143,9 @@ if (process.env.NODE_ENV === 'production') {
|
||||
}
|
||||
|
||||
// Set bundle id for electron app
|
||||
if (process.env.RELEASE_SERVER === 'production')
|
||||
if (process.env.NODE_ENV === Environment.Production)
|
||||
process.env.appBundleId = 'com.firecamp.app';
|
||||
else if (process.env.RELEASE_SERVER === 'canary')
|
||||
else if (process.env.NODE_ENV === Environment.Canary)
|
||||
process.env.appBundleId = 'com.firecamp.canary';
|
||||
|
||||
// Copy release note and post build checks
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
/* eslint-disable no-console */
|
||||
// import environments
|
||||
require('dotenv').config();
|
||||
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const metadata = require('./package.json');
|
||||
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
||||
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
|
||||
const metadata = require('./package.json');
|
||||
|
||||
exports.common = {
|
||||
entry: {
|
||||
app: path.join(
|
||||
@@ -58,17 +60,19 @@ exports.output = {
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
exports.output['path'] = path.join(__dirname, './build/dev/js');
|
||||
exports.output['clean'] = true;
|
||||
exports.output.path = path.join(__dirname, './build/development/js');
|
||||
exports.output.clean = true;
|
||||
} else {
|
||||
exports.output['path'] = path.join(__dirname, './build/production/js');
|
||||
exports.output.path = path.join(__dirname, './build/production/js');
|
||||
}
|
||||
|
||||
exports.env = {
|
||||
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
|
||||
FIRECAMP_API_HOST: JSON.stringify(process.env.FIRECAMP_API_HOST),
|
||||
FIRECAMP_PROXY_API_HOST: JSON.stringify(process.env.FIRECAMP_PROXY_API_HOST),
|
||||
FIRECAMP_EXTENSION_AGENT_ID: JSON.stringify(process.env.FIRECAMP_EXTENSION_AGENT_ID),
|
||||
FIRECAMP_EXTENSION_AGENT_ID: JSON.stringify(
|
||||
process.env.FIRECAMP_EXTENSION_AGENT_ID
|
||||
),
|
||||
APP_VERSION: JSON.stringify(metadata.version),
|
||||
APP_FORMAT: JSON.stringify(process.env.APP_FORMAT),
|
||||
SENTRY_DSN: JSON.stringify(process.env.SENTRY_DSN),
|
||||
@@ -92,7 +96,7 @@ exports.env = {
|
||||
exports.plugins = [
|
||||
new HtmlWebpackPlugin({
|
||||
inject: false,
|
||||
template: path.join(__dirname, './build/dev/app.html'),
|
||||
template: path.join(__dirname, './build/development/index.html'),
|
||||
}),
|
||||
new NodePolyfillPlugin(),
|
||||
new webpack.ProgressPlugin({
|
||||
@@ -102,7 +106,7 @@ exports.plugins = [
|
||||
profile: true,
|
||||
handler: (percentage, message, ...args) => {
|
||||
console.clear();
|
||||
console.log((percentage * 100).toFixed() + '%', message, ...args);
|
||||
console.log(`${(percentage * 100).toFixed()}%`, message, ...args);
|
||||
},
|
||||
}),
|
||||
new MonacoWebpackPlugin({
|
||||
|
||||
Reference in New Issue
Block a user