Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #65 from commercelayer/mfe-setup
Browse files Browse the repository at this point in the history
Setup app to be loaded as MFE
  • Loading branch information
gciotola authored Mar 6, 2024
2 parents 6e33871 + af92f47 commit 27fbdb5
Show file tree
Hide file tree
Showing 23 changed files with 599 additions and 719 deletions.
17 changes: 10 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ parameters:
default: "imports"

orbs:
aws-s3: circleci/aws-s3@3.1.1
aws-cli: circleci/aws-cli@4.1.3
aws-s3: circleci/aws-s3@4.0.0

image: &image
docker:
- image: cimg/node:18.15.0
- image: cimg/node:20.11.0
resource_class: medium+

setup: &setup
Expand All @@ -28,7 +29,7 @@ jobs:
- <<: *setup
- run:
name: Audit
command: pnpm audit --audit-level high && pnpm audit || exit 0
command: pnpm audit || exit 0
- run:
name: Test
command: pnpm --if-present lint && pnpm --if-present ts:check && pnpm --if-present test
Expand All @@ -42,9 +43,10 @@ jobs:
- run:
name: Build
command: pnpm build
- aws-cli/setup:
aws_access_key_id: AWS_ACCESS_KEY
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
- aws-s3/sync:
aws-access-key-id: AWS_ACCESS_KEY
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
from: packages/app/dist
to: "s3://$S3_ASSETS_BUCKET/team/fe-static-apps/<< pipeline.parameters.project-name >>/<< pipeline.git.tag >>"

Expand All @@ -65,9 +67,10 @@ jobs:
- run:
name: Inject configuration
command: "cp packages/app/public/config.preview-<< parameters.preview-env >>.js packages/app/dist/config.local.js"
- aws-cli/setup:
aws_access_key_id: AWS_ACCESS_KEY
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
- aws-s3/sync:
aws-access-key-id: AWS_ACCESS_KEY
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
from: packages/app/dist
to: "s3://$S3_ASSETS_DEV_BUCKET/team/fe-static-apps/<< pipeline.parameters.project-name >>/<< pipeline.git.tag >>-<< parameters.preview-env >>"

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/tag_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Tag Pull Request

on:
pull_request_target:

jobs:
tag-pull-request:
uses: commercelayer/.github/.github/workflows/tag_pull_request.yaml@main
secrets: inherit
12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# System
.DS_Store

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down Expand Up @@ -69,13 +72,8 @@ typings/
.yarn-integrity

# dotenv environment variables file
.env
.env.local
.env.test
.env.staging.local
.env.development.local
.env.test.local
.env.production.local
# .env --> we want to keep it versionated by default. Use `.env.(local|production)` for custom env to be ignored
.env.*

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//registry.npmjs.org/:_authToken=${NPM_READ_TOKEN}
use-node-version=18.7.0
use-node-version=20.11.0
auto-install-peers=true
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"lint:fix": "pnpm -r lint:fix",
"test": "pnpm -r test",
"test:watch": "pnpm -r test:watch",
"bumpver": "pnpm lerna version -m '%s [skip ci]'",
"dep:upgrade:major": "pnpm -r exec npm-check-updates -u",
"dep:upgrade:minor": "pnpm dep:upgrade:major -t minor",
"dep:self-upgrade:major": "pnpm exec npm-check-updates -u",
Expand All @@ -27,7 +26,7 @@
"license": "MIT",
"engines": {
"node": ">=18",
"pnpm": ">=7"
"pnpm": ">=8"
},
"workspaces": [
"packages/*"
Expand Down
4 changes: 4 additions & 0 deletions packages/app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Base router path for the project
PUBLIC_PROJECT_PATH=
# When set it defines the slug for the self hosted version of the project
PUBLIC_SELF_HOSTED_SLUG=
2 changes: 0 additions & 2 deletions packages/app/.env.local.sample

This file was deleted.

66 changes: 21 additions & 45 deletions packages/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,48 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build
/dist

# misc
.DS_Store
*.pem
.yalc
yalc.lock

# debug
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# envs
.env
.env.local
.env.test
.env.staging.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# typescript
*.tsbuildinfo
/test-results/
/playwright-report/
/playwright/.cache/
/dist-pw/
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
2 changes: 1 addition & 1 deletion packages/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You need a local Node.JS (version 18+) environment and some React.JS knowledge t
git clone https://github.com/<your username>/app-imports.git && cd app-imports
```

3. Set your environment by creating a new `/src/app/.env.local` file starting from `/src/app/.env.local.sample` (not required for local development).
3. Set your environment by creating a new `/src/app/.env.local` file starting from `/src/app/.env` (not required for local development).

4. Install dependencies and run the development server:

Expand Down
22 changes: 0 additions & 22 deletions packages/app/global.d.ts

This file was deleted.

17 changes: 15 additions & 2 deletions packages/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,35 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Imports | Commerce Layer</title>
<title>Commerce Layer</title>
<link
rel="icon"
type="image/png"
href="https://data.commercelayer.app/assets/images/favicons/favicon-32x32.png"
/>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<script src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<link
href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
<div id="root-app"></div>

<script src="/config.local.js"></script>
<script src="/config.js"></script>

<script type="module" src="/src/main.tsx"></script>

<script>
window.addEventListener('DOMContentLoaded', () => {
window.clApp_imports.init(document.getElementById('root-app'), {
organizationSlug: '%PUBLIC_SELF_HOSTED_SLUG%',
routerBase: '%PUBLIC_PROJECT_PATH%'
})
})
</script>
</body>
</html>
40 changes: 21 additions & 19 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,37 @@
"prepare": "touch ./public/config.local.js"
},
"dependencies": {
"@commercelayer/app-elements": "^1.14.6",
"@commercelayer/app-elements": "^1.16.0",
"@commercelayer/eslint-config-ts-react": "^1.3.0",
"@commercelayer/sdk": "5.32.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@types/lodash-es": "^4.17.12",
"@types/node": "20.11.19",
"@types/papaparse": "^5.3.14",
"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19",
"@types/testing-library__jest-dom": "^5.14.9",
"@commercelayer/sdk": "5.33.1",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"jsdom": "^24.0.0",
"lodash-es": "^4.17.21",
"only-allow": "^1.2.1",
"lodash": "^4.17.21",
"papaparse": "^5.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-select": "^5.8.0",
"typescript": "^5.3.3",
"vite": "^5.1.3",
"vitest": "^1.3.0",
"wouter": "^3.0.0",
"wouter": "^3.0.1",
"zod": "3.22.4"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@types/lodash-es": "^4.17.12",
"@types/lodash": "^4.14.202",
"@types/node": "20.11.24",
"@types/papaparse": "^5.3.14",
"@types/react-dom": "^18.2.20",
"@types/react": "^18.2.63",
"@types/testing-library__jest-dom": "^5.14.9",
"dotenv": "^16.4.5",
"type-fest": "^4.10.2"
"eslint": "^8.57.0",
"jsdom": "^24.0.0",
"rollup-plugin-external-globals": "^0.9.2",
"type-fest": "^4.11.1",
"typescript": "^5.3.3",
"vite-tsconfig-paths": "^4.3.1",
"vite": "^5.1.5",
"vitest": "^1.3.1"
},
"engines": {
"node": ">=18"
Expand Down
3 changes: 1 addition & 2 deletions packages/app/public/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
window.clAppConfig = Object.assign(
{
domain: 'commercelayer.io',
skipSchemaValidation: true
domain: 'commercelayer.io'
},
window.clAppConfig
)
3 changes: 3 additions & 0 deletions packages/app/public/config.preview-prd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
window.clAppConfig = {
domain: 'commercelayer.io'
}
3 changes: 3 additions & 0 deletions packages/app/public/config.preview-stg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
window.clAppConfig = {
domain: 'commercelayer.co'
}
Binary file removed packages/app/public/favicon.png
Binary file not shown.
Loading

0 comments on commit 27fbdb5

Please sign in to comment.