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": {
|
||||
"build:monorepo": "lerna run build --scope=@firecamp/js-executor --scope=@firecamp/rest-executor",
|
||||
"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 .",
|
||||
"release:web-app": "APP_FORMAT=webapp && node scripts/release production",
|
||||
"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 { EProvider, IAuthResponse } from './types';
|
||||
import { validateAuthResponse } from './helper';
|
||||
import { githubAuth, googleAuth } from './oauth2';
|
||||
|
||||
/**
|
||||
* credentials require while sign-in using Firecamp domain
|
||||
*/
|
||||
/** credentials require while sign-in using Firecamp domain */
|
||||
export interface ICredentials {
|
||||
username: string;
|
||||
password: string;
|
||||
@@ -22,25 +19,16 @@ export default async (
|
||||
try {
|
||||
const { username = '', password = '' } = credentials;
|
||||
|
||||
// TODO:
|
||||
// if (F.userMeta.isLoggedIn) return Promise.resolve();
|
||||
|
||||
switch (provider) {
|
||||
case EProvider.LOCAL: {
|
||||
// Request to sign-in via Firecamp domain
|
||||
try {
|
||||
const response = await Rest.auth.signIn(username, password);
|
||||
|
||||
// validate auth response
|
||||
if (validateAuthResponse(response?.data)) {
|
||||
return Promise.resolve({
|
||||
response: response.data,
|
||||
provider: EProvider.LOCAL,
|
||||
});
|
||||
} else
|
||||
return Promise.reject({
|
||||
message: 'failed to sign in into your account',
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e, 'e...');
|
||||
if (e.message == 'Network Error')
|
||||
@@ -55,17 +43,11 @@ export default async (
|
||||
|
||||
// Send token to authenticate
|
||||
const response = await Rest.auth.viaGoogle(token);
|
||||
debugger;
|
||||
|
||||
if (validateAuthResponse(response?.data)) {
|
||||
return Promise.resolve({
|
||||
response: response.data,
|
||||
provider: EProvider.GOOGLE,
|
||||
});
|
||||
} else
|
||||
return Promise.reject({
|
||||
message: 'Failed to sign-in into your account',
|
||||
});
|
||||
}
|
||||
case EProvider.GITHUB:
|
||||
// Fetch auth code
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Rest } from '@firecamp/cloud-apis';
|
||||
import { EProvider, IAuthResponse } from './types';
|
||||
import { validateAuthResponse } from './helper';
|
||||
|
||||
/**
|
||||
* credentials require for sign-up using Firecamp domain
|
||||
@@ -24,15 +23,10 @@ export default async ({
|
||||
const response = await Rest.auth.signUp(username, email, password);
|
||||
|
||||
// validate auth response
|
||||
if (validateAuthResponse(response?.data)) {
|
||||
return Promise.resolve({
|
||||
response: response.data,
|
||||
provider: EProvider.LOCAL,
|
||||
});
|
||||
} else
|
||||
return Promise.reject({
|
||||
message: 'Failed to sign-up for your account',
|
||||
});
|
||||
} catch (error) {
|
||||
return Promise.reject({
|
||||
message: error?.data?.message
|
||||
|
||||
@@ -3,7 +3,7 @@ require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const colors = require('colors');
|
||||
const Environment = require('./environment');
|
||||
const { Environment, AppFormat } = require('./environment');
|
||||
const build = require('../webpack.prod');
|
||||
require('shelljs/global');
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = async () => {
|
||||
|
||||
// Hold the build path as per the environment mode
|
||||
const buildPath =
|
||||
process.env.NODE_ENV === 'development'
|
||||
process.env.NODE_ENV === Environment.Development
|
||||
? directoryPaths[1]
|
||||
: directoryPaths[2];
|
||||
|
||||
@@ -74,7 +74,7 @@ module.exports = async () => {
|
||||
);
|
||||
|
||||
// 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`);
|
||||
else exec(`node ${buildPath}/build-scripts/init-package.js`);
|
||||
|
||||
@@ -96,8 +96,8 @@ module.exports = async () => {
|
||||
|
||||
// Copy electron agent assets, config and services
|
||||
if (
|
||||
process.env.NODE_ENV === 'production' &&
|
||||
process.env.APP_FORMAT !== 'extension'
|
||||
process.env.NODE_ENV === Environment.Production &&
|
||||
process.env.APP_FORMAT !== AppFormat.WebApp
|
||||
) {
|
||||
// Copy electron agent services
|
||||
cp(
|
||||
@@ -116,7 +116,7 @@ module.exports = async () => {
|
||||
);
|
||||
|
||||
// Copy dmg app assets
|
||||
if (process.env.APP_FORMAT === 'dmg') {
|
||||
if (process.env.APP_FORMAT === AppFormat.Dmg) {
|
||||
mkdir(`${buildPath}/build`);
|
||||
|
||||
cp(
|
||||
|
||||
@@ -5,4 +5,12 @@ const Environment = {
|
||||
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 { version } = require('../package.json');
|
||||
|
||||
const Environment = require('./environment');
|
||||
const { Environment, AppFormat } = require('./environment');
|
||||
|
||||
const variables = [
|
||||
// 'FIRECAMP_API_HOST',
|
||||
@@ -27,10 +27,6 @@ if (!semver.valid(version)) {
|
||||
// Set app version in the environment
|
||||
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
|
||||
variables.forEach((variable) => {
|
||||
if (
|
||||
@@ -122,13 +118,13 @@ if (process.env.NODE_ENV === Environment.Production) {
|
||||
await build();
|
||||
|
||||
// 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
|
||||
rm('-rf', 'build/production/build-scripts');
|
||||
rm('-rf', 'build/production/packages-executors');
|
||||
rm('-rf', 'build/production/services');
|
||||
|
||||
if (process.env.APP_FORMAT === 'webapp') {
|
||||
if (process.env.APP_FORMAT === AppFormat.WebApp) {
|
||||
// Remove chrome extension app files
|
||||
rm('-rf', 'build/production/splashscreen.html');
|
||||
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');
|
||||
|
||||
// Prepare linux os 'AppImage' build
|
||||
if (process.env.APP_FORMAT === 'appImage') {
|
||||
if (process.env.APP_FORMAT === AppFormat.AppImage) {
|
||||
// do not publish the app
|
||||
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
|
||||
if (process.env.APP_FORMAT === 'snap') {
|
||||
if (process.env.APP_FORMAT === AppFormat.Snap) {
|
||||
// do not publish the app
|
||||
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
|
||||
if (process.env.APP_FORMAT === 'nsis') {
|
||||
if (process.env.APP_FORMAT === AppFormat.NSIS) {
|
||||
// do not publish the app
|
||||
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
|
||||
if (process.env.APP_FORMAT === 'dmg') {
|
||||
if (process.env.APP_FORMAT === AppFormat.Dmg) {
|
||||
// do not publish the app
|
||||
if (process.argv[3] === 'l') exec('electron-builder --mac');
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = {
|
||||
devtool: 'eval-cheap-module-source-map',
|
||||
devServer: {
|
||||
//server: 'https',
|
||||
static: path.join(__dirname, './build/dev'),
|
||||
static: path.join(__dirname, './build/development'),
|
||||
compress: true,
|
||||
port: 3000,
|
||||
open: true,
|
||||
@@ -36,7 +36,9 @@ module.exports = {
|
||||
new webpack.DefinePlugin({
|
||||
'process.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(),
|
||||
|
||||
Reference in New Issue
Block a user