mirror of
https://github.com/LukeHagar/firecamp.git
synced 2025-12-06 12:27:44 +00:00
refactor(release): release/bundle scripts are refactored with other intermideate fixes
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build:monorepo": "lerna run build --scope=@firecamp/js-executor --scope=@firecamp/rest-executor",
|
"build:monorepo": "lerna run build --scope=@firecamp/js-executor --scope=@firecamp/rest-executor",
|
||||||
"start": "npx webpack serve --config ./webpack.dev.js",
|
"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",
|
"dev": "APP_VERSION=$npm_package_version APP_FORMAT=web && node scripts/build && npm run build:monorepo && yarn start",
|
||||||
"electron": "npx electron .",
|
"electron": "npx electron .",
|
||||||
"release:web-app": "APP_FORMAT=webapp && node scripts/release production",
|
"release:web-app": "APP_FORMAT=webapp && node scripts/release production",
|
||||||
"release:web-app:staging": "APP_FORMAT=webapp && node scripts/release staging",
|
"release:web-app:staging": "APP_FORMAT=webapp && node scripts/release staging",
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import { IAuthResponse } from './types';
|
|
||||||
|
|
||||||
// Validate auth API response
|
|
||||||
export const validateAuthResponse = (response: IAuthResponse): boolean => {
|
|
||||||
if (
|
|
||||||
response?.user?.email &&
|
|
||||||
response?.user?._meta?.id &&
|
|
||||||
response?.meta?.access_token &&
|
|
||||||
response?.meta?.active_workspace &&
|
|
||||||
response?.workspace?.name &&
|
|
||||||
response?.workspace?.meta?.is_default &&
|
|
||||||
response?.workspace?.meta?.type &&
|
|
||||||
response?.workspace?._meta?.id
|
|
||||||
)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import { Rest } from '@firecamp/cloud-apis';
|
import { Rest } from '@firecamp/cloud-apis';
|
||||||
import { EProvider, IAuthResponse } from './types';
|
import { EProvider, IAuthResponse } from './types';
|
||||||
import { validateAuthResponse } from './helper';
|
|
||||||
import { githubAuth, googleAuth } from './oauth2';
|
import { githubAuth, googleAuth } from './oauth2';
|
||||||
|
|
||||||
/**
|
/** credentials require while sign-in using Firecamp domain */
|
||||||
* credentials require while sign-in using Firecamp domain
|
|
||||||
*/
|
|
||||||
export interface ICredentials {
|
export interface ICredentials {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
@@ -22,25 +19,16 @@ export default async (
|
|||||||
try {
|
try {
|
||||||
const { username = '', password = '' } = credentials;
|
const { username = '', password = '' } = credentials;
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// if (F.userMeta.isLoggedIn) return Promise.resolve();
|
|
||||||
|
|
||||||
switch (provider) {
|
switch (provider) {
|
||||||
case EProvider.LOCAL: {
|
case EProvider.LOCAL: {
|
||||||
// Request to sign-in via Firecamp domain
|
// Request to sign-in via Firecamp domain
|
||||||
try {
|
try {
|
||||||
const response = await Rest.auth.signIn(username, password);
|
const response = await Rest.auth.signIn(username, password);
|
||||||
|
|
||||||
// validate auth response
|
// validate auth response
|
||||||
if (validateAuthResponse(response?.data)) {
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
response: response.data,
|
response: response.data,
|
||||||
provider: EProvider.LOCAL,
|
provider: EProvider.LOCAL,
|
||||||
});
|
});
|
||||||
} else
|
|
||||||
return Promise.reject({
|
|
||||||
message: 'failed to sign in into your account',
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e, 'e...');
|
console.log(e, 'e...');
|
||||||
if (e.message == 'Network Error')
|
if (e.message == 'Network Error')
|
||||||
@@ -55,17 +43,11 @@ export default async (
|
|||||||
|
|
||||||
// Send token to authenticate
|
// Send token to authenticate
|
||||||
const response = await Rest.auth.viaGoogle(token);
|
const response = await Rest.auth.viaGoogle(token);
|
||||||
debugger;
|
|
||||||
|
|
||||||
if (validateAuthResponse(response?.data)) {
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
response: response.data,
|
response: response.data,
|
||||||
provider: EProvider.GOOGLE,
|
provider: EProvider.GOOGLE,
|
||||||
});
|
});
|
||||||
} else
|
|
||||||
return Promise.reject({
|
|
||||||
message: 'Failed to sign-in into your account',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
case EProvider.GITHUB:
|
case EProvider.GITHUB:
|
||||||
// Fetch auth code
|
// Fetch auth code
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Rest } from '@firecamp/cloud-apis';
|
import { Rest } from '@firecamp/cloud-apis';
|
||||||
import { EProvider, IAuthResponse } from './types';
|
import { EProvider, IAuthResponse } from './types';
|
||||||
import { validateAuthResponse } from './helper';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* credentials require for sign-up using Firecamp domain
|
* credentials require for sign-up using Firecamp domain
|
||||||
@@ -24,15 +23,10 @@ export default async ({
|
|||||||
const response = await Rest.auth.signUp(username, email, password);
|
const response = await Rest.auth.signUp(username, email, password);
|
||||||
|
|
||||||
// validate auth response
|
// validate auth response
|
||||||
if (validateAuthResponse(response?.data)) {
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
response: response.data,
|
response: response.data,
|
||||||
provider: EProvider.LOCAL,
|
provider: EProvider.LOCAL,
|
||||||
});
|
});
|
||||||
} else
|
|
||||||
return Promise.reject({
|
|
||||||
message: 'Failed to sign-up for your account',
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject({
|
return Promise.reject({
|
||||||
message: error?.data?.message
|
message: error?.data?.message
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require('dotenv').config();
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const colors = require('colors');
|
const colors = require('colors');
|
||||||
const Environment = require('./environment');
|
const { Environment, AppFormat } = require('./environment');
|
||||||
const build = require('../webpack.prod');
|
const build = require('../webpack.prod');
|
||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ module.exports = async () => {
|
|||||||
|
|
||||||
// Hold the build path as per the environment mode
|
// Hold the build path as per the environment mode
|
||||||
const buildPath =
|
const buildPath =
|
||||||
process.env.NODE_ENV === 'development'
|
process.env.NODE_ENV === Environment.Development
|
||||||
? directoryPaths[1]
|
? directoryPaths[1]
|
||||||
: directoryPaths[2];
|
: directoryPaths[2];
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ module.exports = async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// generate package.json and manifest based on app environment
|
// generate package.json and manifest based on app environment
|
||||||
if (process.env.NODE_ENV === 'development')
|
if (process.env.NODE_ENV === Environment.Development)
|
||||||
exec(`node ${buildPath}/build-scripts/init-package.js`);
|
exec(`node ${buildPath}/build-scripts/init-package.js`);
|
||||||
else exec(`node ${buildPath}/build-scripts/init-package.js`);
|
else exec(`node ${buildPath}/build-scripts/init-package.js`);
|
||||||
|
|
||||||
@@ -96,8 +96,8 @@ module.exports = async () => {
|
|||||||
|
|
||||||
// Copy electron agent assets, config and services
|
// Copy electron agent assets, config and services
|
||||||
if (
|
if (
|
||||||
process.env.NODE_ENV === 'production' &&
|
process.env.NODE_ENV === Environment.Production &&
|
||||||
process.env.APP_FORMAT !== 'extension'
|
process.env.APP_FORMAT !== AppFormat.WebApp
|
||||||
) {
|
) {
|
||||||
// Copy electron agent services
|
// Copy electron agent services
|
||||||
cp(
|
cp(
|
||||||
@@ -116,7 +116,7 @@ module.exports = async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Copy dmg app assets
|
// Copy dmg app assets
|
||||||
if (process.env.APP_FORMAT === 'dmg') {
|
if (process.env.APP_FORMAT === AppFormat.Dmg) {
|
||||||
mkdir(`${buildPath}/build`);
|
mkdir(`${buildPath}/build`);
|
||||||
|
|
||||||
cp(
|
cp(
|
||||||
|
|||||||
@@ -5,4 +5,12 @@ const Environment = {
|
|||||||
Canary: 'canary', // Canary is production but for early adopter
|
Canary: 'canary', // Canary is production but for early adopter
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Environment;
|
const AppFormat = {
|
||||||
|
WebApp: 'webapp',
|
||||||
|
Dmg: 'dmg',
|
||||||
|
AppImage: 'appImage',
|
||||||
|
Snap: 'snap',
|
||||||
|
NSIS: 'nsis',
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { Environment, AppFormat };
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ require('shelljs/global');
|
|||||||
const build = require('./build');
|
const build = require('./build');
|
||||||
const { version } = require('../package.json');
|
const { version } = require('../package.json');
|
||||||
|
|
||||||
const Environment = require('./environment');
|
const { Environment, AppFormat } = require('./environment');
|
||||||
|
|
||||||
const variables = [
|
const variables = [
|
||||||
// 'FIRECAMP_API_HOST',
|
// 'FIRECAMP_API_HOST',
|
||||||
@@ -27,10 +27,6 @@ if (!semver.valid(version)) {
|
|||||||
// Set app version in the environment
|
// Set app version in the environment
|
||||||
process.env.APP_VERSION = 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
|
// Check if environment variables set
|
||||||
variables.forEach((variable) => {
|
variables.forEach((variable) => {
|
||||||
if (
|
if (
|
||||||
@@ -122,13 +118,13 @@ if (process.env.NODE_ENV === Environment.Production) {
|
|||||||
await build();
|
await build();
|
||||||
|
|
||||||
// Finished the process if build=chrome
|
// Finished the process if build=chrome
|
||||||
if (['extension', 'webapp'].includes(process.env.APP_FORMAT)) {
|
if (['extension', AppFormat.WebApp].includes(process.env.APP_FORMAT)) {
|
||||||
// Remove unused packages
|
// Remove unused packages
|
||||||
rm('-rf', 'build/production/build-scripts');
|
rm('-rf', 'build/production/build-scripts');
|
||||||
rm('-rf', 'build/production/packages-executors');
|
rm('-rf', 'build/production/packages-executors');
|
||||||
rm('-rf', 'build/production/services');
|
rm('-rf', 'build/production/services');
|
||||||
|
|
||||||
if (process.env.APP_FORMAT === 'webapp') {
|
if (process.env.APP_FORMAT === AppFormat.WebApp) {
|
||||||
// Remove chrome extension app files
|
// Remove chrome extension app files
|
||||||
rm('-rf', 'build/production/splashscreen.html');
|
rm('-rf', 'build/production/splashscreen.html');
|
||||||
rm('-rf', 'build/production/manifest.json');
|
rm('-rf', 'build/production/manifest.json');
|
||||||
@@ -170,7 +166,7 @@ if (process.env.NODE_ENV === Environment.Production) {
|
|||||||
exec('yarn add ../../../firecamp-forks/electron-oauth-helper -W');
|
exec('yarn add ../../../firecamp-forks/electron-oauth-helper -W');
|
||||||
|
|
||||||
// Prepare linux os 'AppImage' build
|
// Prepare linux os 'AppImage' build
|
||||||
if (process.env.APP_FORMAT === 'appImage') {
|
if (process.env.APP_FORMAT === AppFormat.AppImage) {
|
||||||
// do not publish the app
|
// do not publish the app
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --linux AppImage');
|
if (process.argv[3] === 'l') exec('electron-builder --linux AppImage');
|
||||||
|
|
||||||
@@ -190,7 +186,7 @@ if (process.env.NODE_ENV === Environment.Production) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare linux os 'Snap' build
|
// Prepare linux os 'Snap' build
|
||||||
if (process.env.APP_FORMAT === 'snap') {
|
if (process.env.APP_FORMAT === AppFormat.Snap) {
|
||||||
// do not publish the app
|
// do not publish the app
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --linux Snap');
|
if (process.argv[3] === 'l') exec('electron-builder --linux Snap');
|
||||||
|
|
||||||
@@ -200,7 +196,7 @@ if (process.env.NODE_ENV === Environment.Production) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare windows os 'nsis' build
|
// Prepare windows os 'nsis' build
|
||||||
if (process.env.APP_FORMAT === 'nsis') {
|
if (process.env.APP_FORMAT === AppFormat.NSIS) {
|
||||||
// do not publish the app
|
// do not publish the app
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --win');
|
if (process.argv[3] === 'l') exec('electron-builder --win');
|
||||||
|
|
||||||
@@ -220,7 +216,7 @@ if (process.env.NODE_ENV === Environment.Production) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare mac os 'dmg' build
|
// Prepare mac os 'dmg' build
|
||||||
if (process.env.APP_FORMAT === 'dmg') {
|
if (process.env.APP_FORMAT === AppFormat.Dmg) {
|
||||||
// do not publish the app
|
// do not publish the app
|
||||||
if (process.argv[3] === 'l') exec('electron-builder --mac');
|
if (process.argv[3] === 'l') exec('electron-builder --mac');
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = {
|
|||||||
devtool: 'eval-cheap-module-source-map',
|
devtool: 'eval-cheap-module-source-map',
|
||||||
devServer: {
|
devServer: {
|
||||||
//server: 'https',
|
//server: 'https',
|
||||||
static: path.join(__dirname, './build/dev'),
|
static: path.join(__dirname, './build/development'),
|
||||||
compress: true,
|
compress: true,
|
||||||
port: 3000,
|
port: 3000,
|
||||||
open: true,
|
open: true,
|
||||||
@@ -36,7 +36,9 @@ module.exports = {
|
|||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
...env,
|
...env,
|
||||||
FIRECAMP_EXTENSION_AGENT_ID: JSON.stringify(process.env.FIRECAMP_EXTENSION_AGENT_ID),
|
FIRECAMP_EXTENSION_AGENT_ID: JSON.stringify(
|
||||||
|
process.env.FIRECAMP_EXTENSION_AGENT_ID
|
||||||
|
),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// new BundleAnalyzerPlugin(),
|
// new BundleAnalyzerPlugin(),
|
||||||
|
|||||||
Reference in New Issue
Block a user