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

fix(odd-platform-ui): fix ui build for windows #1607

Merged
merged 3 commits into from
Feb 6, 2024
Merged
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
13 changes: 8 additions & 5 deletions odd-platform-ui/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@

## Requirements
- [nvm](https://github.com/nvm-sh/nvm) with installed [Node.js](https://nodejs.org/en/) of expected version (check `.nvmrc`)
- [pnpm](https://pnpm.io/installation) - package manager
- [Docker](https://www.docker.com/) - to run openapi generator.

**Note for Windows users:** You need to set a bash compatible shell, for example: `npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"`

## Initialize application

In the project directory, you can run:

### `npm install`
### `pnpm install`
Installs project dependencies

### `npm run generate`
### `pnpm run generate`
Generates an openApi client in `src/generated-sources` from API specification `prospectlog-specification//openapi.yml`

## Run application in dev mode

### `npm start`
### `pnpm start`

Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br />
You will also see any lint errors in the console.

### `npm test`
### `pnpm test`

Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

## Create build

### `npm run build`
### `pnpm run build`

Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
Expand Down
8 changes: 8 additions & 0 deletions odd-platform-ui/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

GENERATOR_IMAGE="openapitools/openapi-generator-cli:v5.1.1"
CONFIG_PATH="odd-platform-ui/openapi-config.yaml"
WORKDIR="//mnt" # Using double-slash for compatibility with Windows
HOST_DIRECTORY=/$(pwd)/..

docker run -v $HOST_DIRECTORY:$WORKDIR -w $WORKDIR --rm $GENERATOR_IMAGE generate -c $CONFIG_PATH
4 changes: 2 additions & 2 deletions odd-platform-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"build": "pnpm generate && tsc --noEmit && vite build",
"test": "vitest",
"tsc": "tsc",
"generate": "docker run -v `pwd`/..:/mnt -w /mnt --rm openapitools/openapi-generator-cli:v5.1.1 generate -c odd-platform-ui/openapi-config.yaml",
"generate": "chmod u+x ./generate.sh && ./generate.sh",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try to run pnpm build or gradle build to make sure that gradle can generate models and build ui too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, both pnpm build and gradle build work

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Running bash scripts is not looks safe from contributor's prospective.

"lint": "eslint --ext .tsx,.ts src/",
"lint:fix": "eslint --ext .tsx,.ts src/ --fix",
"prepare": "chmod u+x .husky/prepare.sh && .husky/prepare.sh",
"pre-commit": "pnpm tsc --noEmit && lint-staged",
"preinstall": "pnpm install husky && npx only-allow pnpm",
"preinstall": "pnpm install husky",
"i18n:scan": "mkdir -p ./tmp && rm -rf ./tmp && npx tsc --jsx preserve --target esnext --module esnext --noEmit false --outDir ./tmp && npx i18next-scanner"
},
"lint-staged": {
Expand Down
Loading