Skip to content

Commit

Permalink
integrate webapp with playbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lieut-data committed Mar 9, 2023
1 parent 31b4735 commit 8a22edd
Show file tree
Hide file tree
Showing 11 changed files with 22,851 additions and 11,329 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ webapp/coverage
.idea

/debug
/client
__debug_bin
report.xml
go.*.orig
Expand Down
27 changes: 26 additions & 1 deletion webapp/channels/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ const {getWorkspaceCommands} = require('./utils.js');
async function buildAll() {
console.log(chalk.inverse.bold('Building subpackages...') + '\n');

const commands = [
{command: 'npm run build:product', cwd: '../playbooks', name: 'playbooks', prefixColor: 'green'},
{command: `npm:build`, cwd: 'src/packages/client', name: 'client', prefixColor: 'red'},
{command: `npm:build`, cwd: 'src/packages/types', name: 'types', prefixColor: 'magenta'},
{command: `npm:build`, cwd: 'src/packages/components', name: 'components', prefixColor: 'blue'},
];

try {
const {result} = concurrently(
getWorkspaceCommands('build'),
commands,
{
killOthers: 'failure',
},
Expand Down Expand Up @@ -42,6 +49,24 @@ async function buildAll() {
}

console.log('\n' + chalk.inverse.bold('Web app built!'));

try {
const {result} = concurrently(
[
{command: 'npm run deploy:product', cwd: '../playbooks', name: 'playbooks', prefixColor: 'green'},
],
{
killOthers: 'failure',
},
);

await result;
} catch (e) {
console.error(chalk.inverse.bold.red('Failed to deploy products'), e);
return;
}

console.log('\n' + chalk.inverse.bold('Products deployed!'));
}

buildAll();
18 changes: 4 additions & 14 deletions webapp/channels/scripts/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const chalk = require('chalk');
const concurrently = require('concurrently');

const {makeRunner} = require('./runner.js');
const {getProductStartCommands, getWorkspaceCommands} = require('./utils.js');

async function watchAll(useRunner) {
if (!useRunner) {
Expand All @@ -16,21 +15,12 @@ async function watchAll(useRunner) {

const commands = [
{command: 'npm:run:webapp', name: 'webapp', prefixColor: 'cyan'},
{command: 'npm run start:product', cwd: '../playbooks', name: 'playbooks', prefixColor: 'green'},
{command: `npm:run`, cwd: 'src/packages/client', name: 'client', prefixColor: 'red'},
{command: `npm:run`, cwd: 'src/packages/types', name: 'types', prefixColor: 'magenta'},
{command: `npm:run`, cwd: 'src/packages/components', name: 'components', prefixColor: 'blue'},
];

const productCommands = getProductStartCommands();
commands.push(...productCommands);

if (!useRunner) {
if (productCommands.length > 0) {
console.log(chalk.green('Found products: ' + productCommands.map((command) => command.name).join(', ')));
} else {
console.log(chalk.yellow('No products found'));
}
}

commands.push(...getWorkspaceCommands('run'));

let runner;
if (useRunner) {
runner = makeRunner(commands);
Expand Down
6 changes: 5 additions & 1 deletion webapp/channels/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require('path');

const chalk = require('chalk');

const packageJson = require('../package.json');
const packageJson = require('../../package.json');

function getProductStartCommands() {
const commands = [];
Expand All @@ -15,6 +15,10 @@ function getProductStartCommands() {
commands.push({command: 'make watch-product', cwd: '../focalboard', name: 'boards', prefixColor: 'blue'});
}

if (fs.existsSync('../playbooks')) {
commands.push({command: 'npm run start:product', cwd: '../playbooks', name: 'playbooks', prefixColor: 'green'});
}

return commands;
}

Expand Down
4 changes: 4 additions & 0 deletions webapp/channels/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const targetIsEslint = NPM_TARGET === 'check' || NPM_TARGET === 'fix' || process
const DEV = targetIsRun || targetIsStats || targetIsDevServer;

const boardsDevServerUrl = process.env.MM_BOARDS_DEV_SERVER_URL ?? 'http://localhost:9006';
const playbooksDevServerUrl = process.env.MM_PLAYBOOKS_DEV_SERVER_URL ?? 'http://localhost:9007';

const STANDARD_EXCLUDE = [
/node_modules/,
Expand Down Expand Up @@ -308,6 +309,8 @@ function generateCSP() {
csp += ' \'unsafe-eval\'';

csp += ' ' + boardsDevServerUrl;

csp += ' ' + playbooksDevServerUrl;
}

return csp;
Expand Down Expand Up @@ -365,6 +368,7 @@ async function initializeModuleFederation() {
async function getRemoteContainers() {
const products = [
{name: 'boards', baseUrl: boardsDevServerUrl},
{name: 'playbooks', baseUrl: playbooksDevServerUrl},
];

const remotes = {};
Expand Down
Loading

0 comments on commit 8a22edd

Please sign in to comment.