Skip to content

Commit

Permalink
\#2029: Completely replace yarn with npm commands throughout the project
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinEpam23 committed Mar 16, 2023
1 parent cedfabe commit 8687479
Show file tree
Hide file tree
Showing 18 changed files with 31,326 additions and 20,266 deletions.
24 changes: 12 additions & 12 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
# - name: Run audit
# run: npm audit --all --severity 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.

74 changes: 51 additions & 23 deletions DEVNOTES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
# NOTES

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.

Prerequisites: `npm >= 7` `node >= 16`

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
```

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

## Prerequisites

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

## Build instructions

Expand All @@ -14,8 +45,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 +59,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 +86,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 +131,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 +153,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
6 changes: 3 additions & 3 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:*",
"ketcher-core": "*",
"ketcher-react": "*",
"ketcher-standalone": "*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
Expand Down
18 changes: 9 additions & 9 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
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

0 comments on commit 8687479

Please sign in to comment.