Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STRIPES-861: Setup module federation #105

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft

STRIPES-861: Setup module federation #105

wants to merge 15 commits into from

Conversation

mkuklis
Copy link
Contributor

@mkuklis mkuklis commented Apr 25, 2023

https://issues.folio.org/browse/STRIPES-861

POC for Webpack Module Federation.

This PR is associated with additional PRs:

And a new repo:

https://github.com/folio-org/stripes-shared-context

How to test it

  1. Please copy and run the script below:
mkdir -p module_federation && cd module_federation

# checkout all stripes modules
stripes_modules=(
  webpack
  ui
  cli
  core
)

for m in "${stripes_modules[@]}"; do
  git clone "https://github.com/folio-org/stripes-$m.git" --branch STRIPES-861 &
done

git clone "https://github.com/folio-org/stripes-shared-context.git" &
git clone "https://github.com/folio-org/ui-users.git" &
git clone "https://github.com/folio-org/ui-inventory.git" &
wait

# create workspace via package.json
cat > package.json <<EOF
{
  "private": true,
  "workspaces": [
    "*"
  ]
}
EOF

# create stripes.config
cat > stripes.config.js <<EOF
module.exports = {
  okapi: {
    url: 'https://folio-snapshot-okapi.dev.folio.org',
    tenant: 'diku',
  },
  config: {
    logCategories: 'core,path,action,xhr',
    logPrefix: '--',
    showPerms: false,
    hasAllPerms: false,
    languages: ['en'],
    suppressIntlErrors: true,
  },
  modules: {
  }
};
EOF

# install dependencies
yarn
  1. Start host with yarn stripes ./stripes.config.js
  2. Open http://localhost:3000 to make sure host is up and running (this will also start a local registry on port 3001 under http://localhost:3001/registry)
  3. Open a separate terminal window and run cd ui-users && yarn stripes federate. This will start a remote on port 3002
  4. Go back to http://localhost:3000 and refresh the screen. ui-users should appear on the menu.
  5. Open a separate terminal window and run cd ui-inventory && yarn stripes federate. This will start a remote on port 3003
  6. Go back to http://localhost:3000 and refresh the screen. ui-inventory should appear on the menu.
  7. Open http://localhost:3001/registry. Two modules should be listed in the registry.
  8. Stop ui-inventory in the terminal and refresh the host screen. ui-inventory should disappear from the menu.
  9. Open http://localhost:3001/registry the ui-inventory should be removed from the list.

@github-actions
Copy link

github-actions bot commented Apr 25, 2023

Jest Unit Test Statistics

0 tests  ±0   0 ✔️ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ±0 

Results for commit ca0b291. ± Comparison against base commit 88fe37d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Apr 25, 2023

BigTest Unit Test Statistics

73 tests  ±0   68 ✔️  - 5   0s ⏱️ ±0s
39 suites ±0     0 💤 ±0 
  1 files   ±0     5 +5 

For more details on these failures, see this check.

Results for commit ca0b291. ± Comparison against base commit 88fe37d.

♻️ This comment has been updated with latest results.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4 Security Hotspots
16.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

mkuklis and others added 15 commits October 28, 2024 16:30
* map the `sounds` directory for remote applications, analogous to how
  translations and icons are served
* provide `/code` to make the registry human-readable
* catch and display startup errors in case humans make stupid coding
  mistakes and need help finding them
Icons in stripes-components are imported as components whereas those in
applications are just resources, so we need to load them differently.
Copy link

github-actions bot commented Dec 4, 2024

Jest Unit Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit 12613ed. ± Comparison against base commit a216c30.

Copy link

github-actions bot commented Dec 4, 2024

Jest Unit Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit 12613ed. ± Comparison against base commit a216c30.

Copy link

sonarqubecloud bot commented Dec 4, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3 Security Hotspots
0.0% Coverage on New Code (required ≥ 80%)
14.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

const { name } = metadata;

registry.remotes[name] = metadata;
res.status(200).send(`Remote ${name} metadata updated`);

Check failure

Code scanning / SonarCloud

Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks High

Change this code to not reflect user-controlled data. See more on SonarQube Cloud
app.get('/registry', (_, res) => res.json(registry));

// return entire registry for humans
app.get('/code', (_, res) => res.send(`<pre>${JSON.stringify(registry, null, 2)}</pre>`));

Check failure

Code scanning / SonarCloud

Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks High

Change this code to not reflect user-controlled data. See more on SonarQube Cloud

delete registry.remotes[name];

res.status(200).send(`Remote ${name} removed`);

Check failure

Code scanning / SonarCloud

Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks High

Change this code to not reflect user-controlled data. See more on SonarQube Cloud
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants