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

feat: migrate to pnpm and vite #863

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
FROM node:20.2.0 as build
WORKDIR /app
COPY . /app
RUN yarn install
RUN yarn build --mode=production
RUN npm i -g [email protected]
RUN pnpm install
RUN pnpm build --mode=production

# production environment
FROM nginx:1.25.0-alpine
Expand All @@ -13,4 +14,4 @@ COPY --from=build /app/build /usr/share/nginx/html
COPY .docker/nginx/ /etc/nginx/
COPY .docker/scripts/ /etc/scripts/
EXPOSE 5000
CMD ["sh","/etc/scripts/startup.sh"]
CMD ["sh","/etc/scripts/startup.sh"]
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pids
*.pid.lock

build/
dist/
public/

# Jest test runner coverage files
Expand Down Expand Up @@ -54,4 +55,4 @@ typings/

#VS Code folder
.vscode/
.vs/slnx.sqlite
.vs/slnx.sqlite
7 changes: 4 additions & 3 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM node:20 as build
WORKDIR /app
COPY package*.json ./
COPY . .
RUN yarn install
RUN npm i -g [email protected]
RUN pnpm install

ENV VITE_AUTH_CLIENT="30a25122-c22c-4a5c-a7b8-366d31cb2c46"
ENV VITE_AUTHORITY="https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0"
Expand All @@ -14,7 +15,7 @@ ENV VITE_WEBAPI_SCOPE="api://47641c40-0135-459b-8ab4-459e68dc8d08/web_api"
ENV VITE_APP_INSIGHTS="cdb49dda-63f9-433d-99f3-c73dff5dc6a1"
ENV VITE_API_VERSION="&api-version=4.1"

RUN yarn build --mode=production
RUN pnpm build --mode=production

# production environment
FROM docker.io/nginxinc/nginx-unprivileged:alpine
Expand All @@ -33,4 +34,4 @@ USER 9999

EXPOSE 5000

CMD ["sh","/etc/scripts/startup.sh"]
CMD ["sh","/etc/scripts/startup.sh"]
7 changes: 4 additions & 3 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM node:20 as build
WORKDIR /app
COPY package*.json ./
COPY . .
RUN yarn install
RUN npm i -g [email protected]
RUN pnpm install

ENV VITE_AUTH_CLIENT="50b15344-28c9-45b5-9616-41da16fc9dcc"
ENV VITE_AUTHORITY="https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0"
Expand All @@ -14,7 +15,7 @@ ENV VITE_WEBAPI_SCOPE="api://47641c40-0135-459b-8ab4-459e68dc8d08/web_api"
ENV VITE_APP_INSIGHTS="ed1e9f1c-5b68-44ca-afec-76ece1f08f80"
ENV VITE_API_VERSION="&api-version=4.1"

RUN yarn build --mode=production
RUN pnpm build --mode=production

# production environment
FROM docker.io/nginxinc/nginx-unprivileged:alpine
Expand All @@ -33,4 +34,4 @@ USER 9999

EXPOSE 5000

CMD ["sh","/etc/scripts/startup.sh"]
CMD ["sh","/etc/scripts/startup.sh"]
7 changes: 4 additions & 3 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM node:20 as build
WORKDIR /app
COPY package*.json ./
COPY . .
RUN yarn install
RUN npm i -g [email protected]
RUN pnpm install

ENV VITE_AUTH_CLIENT="23d8e04c-9362-4870-bda2-dade6f9d0ffb"
ENV VITE_AUTHORITY="https://login.microsoftonline.com/3aa4a235-b6e2-48d5-9195-7fcf05b459b0"
Expand All @@ -14,7 +15,7 @@ ENV VITE_WEBAPI_SCOPE="api://47641c40-0135-459b-8ab4-459e68dc8d08/web_api"
ENV VITE_APP_INSIGHTS="2e63710e-308d-45c2-99b0-95a959a3de5a"
ENV VITE_API_VERSION="&api-version=4.1"

RUN yarn build --mode=production
RUN pnpm build --mode=production


# production environment
Expand All @@ -34,4 +35,4 @@ USER 9999

EXPOSE 5000

CMD ["sh","/etc/scripts/startup.sh"]
CMD ["sh","/etc/scripts/startup.sh"]
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="module" src="/src/index.tsx"></script>
<base href="/" />
<title>ProCoSys</title>
</head>

<body>
</body>
</html>
31 changes: 17 additions & 14 deletions jest.config.js → jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
const { defaults } = require('jest-config');
import { JestConfigWithTsJest } from 'ts-jest';

module.exports = {
const config: JestConfigWithTsJest = {
preset: 'ts-jest',
testEnvironment: "jsdom",
preset: 'ts-jest/presets/js-with-ts',
verbose: true,
globals: {
'ts-jest': {
babelConfig: true,
},
extensionsToTreatAsEsm: ['.ts'],
transform: {
// '^.+\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
},
],
},
verbose: true,
roots: ['<rootDir>/src'],
// transform: {
// '^.+\\.jsx?$': 'babel-jest', // Adding this line solved the issue
// '^.+\\.tsx?$': 'ts-jest',
// },
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!(@equinor/eds-tokens|@equinor/eds-icons))',
],
moduleDirectories: ['node_modules', '/src'],
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
moduleNameMapper: {
'\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js',
Expand All @@ -33,7 +34,7 @@ module.exports = {
"^@procosys/util/(.*)$": ["<rootDir>/src/util/$1"],
},
testPathIgnorePatterns: ['/node_modules/', '/build/'],
setupFilesAfterEnv: ['./jest.setup.js'],
setupFilesAfterEnv: ['./jest.setup.ts'],
collectCoverage: false,
coverageReporters: ["json", "lcov", "text", "clover", "cobertura"],
collectCoverageFrom: [
Expand All @@ -44,3 +45,5 @@ module.exports = {
],
coverageDirectory: '.coverage'
};

export default config
18 changes: 0 additions & 18 deletions jest.setup.js

This file was deleted.

18 changes: 18 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import '@testing-library/jest-dom';

function noOp() { }

if (typeof window.URL.createObjectURL === 'undefined') {
Object.defineProperty(window.URL, 'createObjectURL', { value: noOp })
}

jest.mock('react-virtualized-auto-sizer', () => {
return (props: any) => {
const renderCallback = props.children;

return renderCallback({
width: 1200,
height: 900
});
};
});
Loading
Loading