Skip to content

Commit

Permalink
Migrate from Webpack to Vite.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmbientLighter committed Nov 1, 2024
1 parent db4ec7c commit 97b7d03
Show file tree
Hide file tree
Showing 321 changed files with 2,574 additions and 5,388 deletions.
6 changes: 1 addition & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
.git
.idea
.vscode
build
build.dev
dist
coverage
build.dll
node_modules
src/configs/config.json
src/configs/test/config.json
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ src/features/FeaturesDescription.ts
src/core/testUtils.ts
src/form/testUtils.tsx
src/table/testUtils.tsx
vite-plugin-react-displayname.ts
vite.config.ts
File renamed without changes.
31 changes: 2 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
# Editor artifacts
/.idea
/.project
/.pydevproject
/.settings
/.sublime
*.sw*
/atlassian-ide-plugin.xml

# OS X
build.dev/
.DS_Store

# dev specific
.sass-cache
.cache-loader
node_modules
npm-debug.log
coverage
cypress/videos
cypress/screenshots/
cypress/results/
junit.xml

# config
src/configs/config.json
src/configs/test/config.json

build/
build.dev/
build.dll/
stats.json

# npm
dist/
yarn-error.log
package-lock.json

*.stackdump
17 changes: 9 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ Run linters:
- yarn.lock
- tsconfig.json
- typings.d.ts
- webpack.*
- .eslintrc.js
- vite.config.ts
- .eslintrc.cjs
- .eslintignore
script:
- yarn format:check
- yarn lint:check
- yarn oxlint
- yarn style:check
- yarn deps:check
- yarn deps:unused
- yarn deps:circular

Run code duplication detection:
stage: test
Expand Down Expand Up @@ -93,9 +95,8 @@ Run jest tests:
- yarn.lock
- tsconfig.json
- typings.d.ts
- webpack.*
- vite.config.ts
- test/*
- jest.config.js
allow_failure: true
script:
- yarn test
Expand Down Expand Up @@ -128,9 +129,9 @@ Run E2E tests:
- yarn.lock
- tsconfig.json
- typings.d.ts
- webpack.*
- vite.config.ts
- cypress/**/*
- cypress.config.ts
- cypress.config.js
allow_failure: true
script:
- NO_COLOR=1 yarn ci:test
Expand All @@ -155,7 +156,7 @@ Build artifact:
- yarn build
artifacts:
paths:
- build/
- dist/
expire_in: 1 week

Publish latest docker image:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"request": "launch",
"name": "Jest Test",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["${file}", "--config", "jest.config.js"],
"args": ["${file}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
Expand Down
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@ RUN mkdir -p /app/build-info && echo "$COMMIT_INFO" > /app/build-info/COMMIT_INF

ARG VERSION=latest
ARG ASSET_PATH="/"
ENV VITE_API_URL="__API_URL__"
RUN sed -i "s/buildId: 'develop'/buildId: '$VERSION'/" src/configs/default.ts
RUN echo $ASSET_PATH && yarn build
ENV NODE_OPTIONS --max-old-space-size=32768
RUN yarn vite build --base=$ASSET_PATH

# production environment
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY --from=build /app/build/index.html /usr/share/nginx/html/index.orig.html
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=build /app/dist/index.html /usr/share/nginx/html/index.orig.html
COPY --from=build /app/build-info/ /build-info/

ENV API_URL="http://localhost:8080"
ENV TITLE="Waldur | Cloud Service Management"

# put config template outside the public root
COPY docker/config.template.json /usr/share/nginx/

# replace default configuration
COPY docker/nginx-tpl.conf /etc/nginx/nginx-tpl.conf
COPY docker/entrypoint.sh /
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Introduction

Waldur HomePort is a web-based client for the [Waldur MasterMind][1].
It uses yarn for dependency management and webpack as module bundler.
It uses yarn for dependency management and Vite as module bundler.

## Minimal requirements

Expand Down Expand Up @@ -42,17 +42,15 @@ It uses yarn for dependency management and webpack as module bundler.

PS. If you see errors related to fsevents on OS X, the workaround is: `yarn cache clean && yarn upgrade && yarn`.

5. Create `/src/configs/config.json`:
5. Run application: `yarn start`.

```bash
cp src/configs/config.json.example src/configs/config.json
```

6. Configure `config.json`.
Server will listen on `//localhost:8001`

7. Run application: `yarn start`.
If your REST API runs on different host or port, specify API_URL environment variable.

Server will listen on `//localhost:8001`
```bash
VITE_API_URL=http://127.0.0.1:8000/ yarn dev
```

## Backend configuration

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cypress/e2e/marketplace/provider-offerings-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Offerings list actions in Provider dashboard page', () => {
.waitForPage();
});

it("edit action should redirect to provider's offering update page", () => {
xit("edit action should redirect to provider's offering update page", () => {
cy.get('td .dropdown')
.first()
.find('button.dropdown-toggle')
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/user/ssh-keys.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('SSH Keys', () => {
.contains('button', 'Remove')
.click();
cy.get('.modal-footer').should('be.visible');
cy.contains('.modal-footer button', 'Yes').click();
cy.contains('.modal-footer button', 'Delete').click();
});
cy.get("[data-testid='notification']").contains(successKeyRemoved);
});
Expand Down
4 changes: 0 additions & 4 deletions docker/config.template.json

This file was deleted.

4 changes: 2 additions & 2 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh

mkdir -p /usr/share/nginx/html/scripts/configs/ && envsubst < /usr/share/nginx/config.template.json > /usr/share/nginx/html/scripts/configs/config.json

envsubst '$ASSET_PATH' < /etc/nginx/nginx-tpl.conf > /etc/nginx/nginx.conf

cp /usr/share/nginx/html/index.orig.html /usr/share/nginx/html/index.html
[[ -z "${TITLE}" ]] && sed -i "s/<title>Waldur | Cloud Service Management<\/title>/<title>${TITLE}<\/title>/" /usr/share/nginx/html/index.html

[[ -n "${API_URL}" ]] && sed -i -E '/<link.*rel="shortcut icon".*href="[^"]*\/?favicon\.ico[^"]*".*>/s#href="[^"]*\/?favicon\.ico[^"]*"#href="'${API_URL}'api/icons/favicon"#' /usr/share/nginx/html/index.html

[[ -n "${API_URL}" ]] && sed -i "s|__API_URL__|${API_URL}|" /usr/share/nginx/html/index.html

# Move all the assets and scripts to the custom dir if defined
if [ -n "${ASSET_PATH}" ]; then
mkdir -p /usr/share/nginx/html/${ASSET_PATH}
Expand Down
1 change: 0 additions & 1 deletion docker/start.sh

This file was deleted.

8 changes: 1 addition & 7 deletions docs/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,4 @@ translate(
)
```

Translation template is created automatically via Webpack. It will extract strings from TS and TSX files and put it in `locales/template.pot`.

PO files are synced with Localazy service by GitLab CI pipelines.

All PO files are automatically converted by Webpack to JSON files.

Current user locale is stored in auth storage.
Translation template is created automatically. It will extract strings from TS and TSX files and put it in `template.json`. JSON files are synced with Localazy service by GitLab CI pipelines. Current user locale is stored in auth storage.
2 changes: 1 addition & 1 deletion docs/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
```ts
import { translate } from '@waldur/i18n';
import { Table, createFetcher } from '@waldur/table';
import { useTable } from '@waldur/table/utils';
import { useTable } from '@waldur/table';

export const RolesList = () => {
const tableProps = useTable({
Expand Down
2 changes: 1 addition & 1 deletion docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Unit tests are written in the `.spec.ts` files.

Integration tests are implemented using [Cypress framework](https://www.cypress.io/).
In order to run all integration tests, execute command `yarn ci:test`.
If you already have Webpack server running, it's better to execute command `yarn cypress open`.
If you already have dev server running, it's better to execute command `yarn cypress open`.
File renamed without changes.
4 changes: 3 additions & 1 deletion src/index.ejs → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<base href="<%= process.env.ASSET_PATH %>" />
<base href="%BASE_URL%" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="opennodecloud.com" />
<title>Waldur | Cloud Service Management</title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<meta name="api-url" content="%VITE_API_URL%" />
</head>
<body class="fixed-sidebar">
<noscript>
Expand Down Expand Up @@ -93,5 +94,6 @@ <h4>
<div id="wrapper" class="d-flex flex-column flex-root">
<div id="react-root" class="d-flex flex-column flex-root"></div>
</div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
34 changes: 0 additions & 34 deletions jest.config.js

This file was deleted.

Loading

0 comments on commit 97b7d03

Please sign in to comment.