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

#2029: Completely replace yarn with npm commands throughout the project #2126

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
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Get npm cache directory path
id: npm-cache-dir-path
run: echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
id: npm-cache # use this to check for `cache-hit` (`steps.npm-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-npm-

- name: Install Dependencies
run: yarn install
run: npm install

- name: Run audit
run: yarn npm audit --all --severity critical
run: npm audit --all --audit-level=critical

- name: Run build
run: npx cross-env CI=false yarn build
run: npx cross-env CI=false npm run build

- name: Run tests
run: yarn test
run: npm test
env:
CI: true
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,4 @@ yarn-error.log*
/.idea

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn/*
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn run precommit
npm run precommit
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn run prepush
npm run prepush
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
...require('prettier-config-standard')
...require('prettier-config-standard'),
bracketSameLine: false
}
28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

768 changes: 0 additions & 768 deletions .yarn/releases/yarn-3.1.0.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions .yarnrc.yml

This file was deleted.

75 changes: 51 additions & 24 deletions DEVNOTES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
## Prerequisites

- Stable [Node.js](https://nodejs.org) version >= 16
- Stable [npm](https://npmjs.com) version >= 7

# NOTES

## Prerequisites
The project switched from using yarn to using npm for managing packages.
If you want to convert your current codebase from yarn to npm you can follow the instructions below.

- Stable [Node.js](https://nodejs.org) version
- [Yarn](https://yarnpkg.com/) installed globally
Remove current node_modules from all directories:
```
rm -rf node_modules
rm -rf ./packages/ketcher-core/node_modules
rm -rf ./packages/ketcher-react/node_modules
rm -rf ./packages/ketcher-standalone/node_modules
rm -rf ./packages/ketcher-polymer-editor-react/node_modules
rm -rf ./example/node_modules
rm -rf ./demo/node_modules
```

Remove yarn.lock:
```
rm yarn.lock
```

Install all packages with npm:
```
npm install
```
*NOTE!* this command should only be run from root directory

Build the project:
```
npm run build
```

## Build instructions

Expand All @@ -14,8 +44,8 @@ The latest version of Ketcher has been splitted into two packages: component lib
To create production build of ready-to-run application execute the following command from root directory:

```sh
yarn install
yarn build
npm install
npm run build
```

The following parameters are used by default:
Expand All @@ -28,25 +58,25 @@ PUBLIC_URL='./'
If you want to change these parameters you can build application by using the following command:

```sh
npx cross-env API_PATH='{your_api_path_here}' PUBLIC_URL='{your_public_url_here}' yarn build
npx cross-env API_PATH='{your_api_path_here}' PUBLIC_URL='{your_public_url_here}' npm run build
```

To serve results of build locally run the following command from root directory:

```sh
yarn serve:remote
npm run serve:remote
or
yarn serve:standalone
npm run serve:standalone
or
yarn serve
npm run serve
```

### Development

The latest version of Ketcher is based on yarn workspaces. So before starting development it is necessary to run the following command from root directory:
The latest version of Ketcher is based on npm workspaces. So before starting development it is necessary to run the following command from root directory:

```sh
yarn install
npm install
```

After that component library and application should be started separately. First should be started ketcher-core package.
Expand All @@ -55,33 +85,30 @@ After that component library and application should be started separately. First

```sh
cd packages/ketcher-core
yarn install
yarn start
npm start
```

#### Build ketcher-react package

```sh
cd packages/ketcher-react
yarn install
yarn start
npm start
```

#### Build ketcher-standalone package

```sh
cd packages/ketcher-standalone
yarn install
yarn start
npm start
```

#### Build example application

```sh
cd example
yarn start:remote
npm run start:remote
or
yarn start:standalone
npm run start:standalone
```

## Indigo service
Expand All @@ -103,9 +130,9 @@ You can find the instruction for service installation
### Start unit tests

```sh
yarn test:unit
npm run test:unit
or
yarn test:watch
npm run test:watch
```

### Start prettier
Expand All @@ -125,15 +152,15 @@ test:lint
### Start stylelint

```sh
yarn stylelint
npm run stylelint
or
yarn stylelint:fix
npm run stylelint:fix
```

### Start all tests and formatting

```sh
yarn test
npm test
```

## Simple server
Expand Down
8 changes: 4 additions & 4 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.1",
"@types/node": "^16.11.26",
"ketcher-core": "workspace:*",
"ketcher-react": "workspace:*",
"ketcher-standalone": "workspace:*",
KonstantinEpam23 marked this conversation as resolved.
Show resolved Hide resolved
"ketcher-core": "*",
"ketcher-react": "*",
"ketcher-standalone": "*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
Expand Down Expand Up @@ -45,6 +45,6 @@
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"serve": "^13.0.2"
"serve": "^14.2.0"
}
}
20 changes: 10 additions & 10 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"scripts": {
"start:standalone": "cross-env MODE=standalone react-app-rewired start",
"start:remote": "cross-env MODE=remote react-app-rewired start",
"clean:build": "shx rm -rf build",
"delete:dist": "shx rm -rf dist/$MODE",
"init:build": "shx mkdir -p build",
"init:dist": "shx mkdir -p dist/$MODE",
"delete:dist": "shx rm -rf dist/$MODE",
"copy:build": "shx cp -r build/. dist/$MODE",
"prebuild": "run-s delete:dist init:dist",
"postbuild": "run-s copy:build clean:build",
"prebuild": "run-s init:build delete:dist init:dist",
"postbuild": "npm run copy:build",
"build:remote": "cross-env MODE=remote run-s prebuild build:react postbuild",
"build:standalone": "cross-env MODE=standalone run-s prebuild build:react postbuild",
"build:react": "react-app-rewired build",
"build:react:analyze": "react-app-rewired build --analyze",
"build": "run-s build:standalone build:remote",
"build": "npm run build:standalone && npm run build:remote",
"build:standalone:analyze": "cross-env MODE=standalone run-s prebuild build:react:analyze postbuild",
"build:remote:analyze": "cross-env MODE=remote run-s prebuild build:react:analyze postbuild",
"test": "run-s test:prettier test:stylelint test:eslint test:unit",
Expand All @@ -30,10 +30,10 @@
"eject": "react-scripts eject"
},
"dependencies": {
"ketcher-core": "workspace:*",
"ketcher-polymer-editor-react": "workspace:*",
"ketcher-react": "workspace:*",
"ketcher-standalone": "workspace:*",
"ketcher-core": "*",
"ketcher-polymer-editor-react": "*",
"ketcher-react": "*",
"ketcher-standalone": "*",
"normalize.css": "^8.0.1",
"react": "^18.2.0",
"react-app-polyfill": "^2.0.0",
Expand Down Expand Up @@ -62,7 +62,7 @@
"source-map-loader": "^3.0.1",
"stylelint": "13.13.1",
"typescript": "^4.5.2",
"webpack-bundle-analyzer": "^3.9.0"
"webpack-bundle-analyzer": "^4.8.0"
},
"browserslist": {
"production": [
Expand Down
1 change: 0 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
RemoteStructServiceProvider,
StructServiceProvider
} from 'ketcher-core'

import { ErrorModal } from './ErrorModal'
import { PolymerToggler } from './PolymerToggler'
import { useState } from 'react'
Expand Down
Loading