Skip to content

Commit 7d47917

Browse files
authored
Lerna -> nx, yarn -> npm (#6959)
* chore: yarn to npm * feat: run project with nx * chore: add most build and test scripts, use npm in CI * chore: add all npm scripts * fix: remove invalid cache seetting from nodejs.yml * fix: test:ci correct usage * fix: more scripts * fix: add npm install to cypress ci * chore: add changeset cli for versioning * docs(npm): update setup instructions and readmes * style(): cleanup * chore: remove changesets and upgrade lerna for versioning * fix: lock npm version for lerna * fix: use npm 9 to support node 16 build * chore: update scripts of aws cognito * chore: update workflow to use node 20 instead of 16
1 parent c999d93 commit 7d47917

File tree

49 files changed

+34097
-18312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+34097
-18312
lines changed

.github/workflows/nodejs.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
os: [macos-latest, windows-latest, ubuntu-latest]
30-
node-version: [16.x, 18.x]
30+
node-version: [18.x, 20.x]
3131
steps:
3232
- uses: actions/checkout@v3
3333
if: ${{ needs.changes.outputs.cms == 'true' }}
@@ -40,17 +40,17 @@ jobs:
4040
- name: log versions
4141
run: node --version && npm --version && yarn --version
4242
if: ${{ needs.changes.outputs.cms == 'true' }}
43-
- name: install dependencies
44-
run: yarn --frozen-lockfile --network-timeout 1000000 && yarn bootstrap
43+
- name: install dependecies
44+
run: npm install
4545
if: ${{ needs.changes.outputs.cms == 'true' }}
4646
- name: run unit tests
47-
run: yarn test:ci
47+
run: npm run test:ci
4848
env:
4949
CI: true
5050
NODE_OPTIONS: --max-old-space-size=4096
5151
if: ${{ needs.changes.outputs.cms == 'true' }}
5252
- name: build demo site
53-
run: yarn build:demo
53+
run: npm run build:demo
5454
env:
5555
NODE_OPTIONS: --max-old-space-size=4096
5656
if: ${{ needs.changes.outputs.cms == 'true' }}
@@ -66,7 +66,7 @@ jobs:
6666

6767
strategy:
6868
matrix:
69-
node-version: [16.x, 18.x]
69+
node-version: [18.x, 20.x]
7070
fail-fast: false
7171

7272
steps:
@@ -77,7 +77,6 @@ jobs:
7777
with:
7878
node-version: ${{ matrix.node-version }}
7979
check-latest: true
80-
cache: yarn
8180
if: ${{ needs.changes.outputs.cms == 'true' }}
8281
- uses: actions/download-artifact@master
8382
with:
@@ -89,11 +88,11 @@ jobs:
8988
node --version
9089
npm --version
9190
yarn --version
92-
yarn --frozen-lockfile
91+
npm install
9392
if: ${{ needs.changes.outputs.cms == 'true' }}
9493
- name: e2e test
9594
run: |
96-
yarn test:e2e:run-ci
95+
npm run test:e2e:run-ci
9796
env:
9897
IS_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true }}
9998
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ coverage/
2020
.env
2121
.temp/
2222
storybook-static/
23+
.nx/cache

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ public/
55
packages/decap-cms-backend-github/src/fragmentTypes.js
66
packages/decap-cms-backend-gitlab/src/AuthenticationPage.js
77
packages/decap-cms-backend-proxy/src/implementation.ts
8+
9+
/.nx/cache

CONTRIBUTING.md

+21-48
Original file line numberDiff line numberDiff line change
@@ -7,121 +7,94 @@ For details on contributing to documentation, see [Website Directory Readme](htt
77

88
## Setup
99

10-
> Install [Node.js (LTS)](https://nodejs.org/) and [yarn](https://yarnpkg.com/en/docs/install) on your system.
10+
> Install [Node.js (LTS)](https://nodejs.org/) on your system.
1111
1212
### Install dependencies
1313

14-
> Only required on the first run, subsequent runs can use `yarn start` to both bootstrap and run the development server.
15-
1614
```sh
1715
git clone https://github.com/decaporg/decap-cms
1816
cd decap-cms
19-
yarn
20-
yarn bootstrap
17+
npm install
2118
```
2219

2320
### Run locally
2421

2522
```sh
26-
yarn start
23+
npm run start
2724
```
2825

2926
## Available scripts
3027

31-
### bootstrap
32-
33-
Bootstraps the monorepo.
34-
35-
```sh
36-
yarn bootstrap
37-
```
38-
39-
### watch
40-
41-
Watches all CMS packages and transpiles them on change.
42-
43-
```sh
44-
yarn watch
45-
```
46-
47-
### start
48-
49-
Starts the development server. This task runs both the `bootstrap` and `watch` scripts.
50-
51-
```sh
52-
yarn start
53-
```
54-
5528
### clean
5629

5730
Removes all of the CMS package `dist` directories.
5831

5932
```sh
60-
yarn clean
33+
npm run clean
6134
```
6235

6336
### reset
6437

6538
Runs the `clean` script and removes all the `node_modules` from the CMS packages.
6639

6740
```sh
68-
yarn reset
41+
npm run reset
6942
```
7043

7144
### build
7245

7346
Runs the `clean` script and builds the CMS packages.
7447

7548
```sh
76-
yarn build
49+
npm run build
7750
```
7851

7952
### build-preview
8053

8154
Runs the `build` and `build-preview` scripts in each package and serves the resulting build locally.
8255

8356
```sh
84-
yarn build-preview
57+
npm run build-preview
8558
```
8659

8760
### test
8861

8962
Runs linting and Jest tests.
9063

9164
```sh
92-
yarn test
65+
npm run test
9366
```
9467

9568
### test:all
9669

9770
Runs linting, Jest, and Cypress tests.
9871

9972
```sh
100-
yarn test:all
73+
npm run test:all
10174
```
10275

10376
### test:e2e
10477

10578
Runs Cypress e2e tests.
10679

10780
```sh
108-
yarn test:e2e
81+
npm run test:e2e
10982
```
11083

11184
### test:e2e:dev
11285

11386
Runs Cypress e2e tests on watch mode with an open instance of Chrome.
11487

11588
```sh
116-
yarn test:e2e:dev
89+
npm run test:e2e:dev
11790
```
11891

11992
### format
12093

12194
Formats code and docs according to our style guidelines.
12295

12396
```sh
124-
yarn format
97+
npm run format
12598
```
12699

127100
## Pull Requests
@@ -136,14 +109,14 @@ Decap CMS uses the [Forking Workflow](https://www.atlassian.com/git/tutorials/co
136109
2. Create a branch from `master`. If you're addressing a specific issue, prefix your branch name with the issue number.
137110
3. If you've added code that should be tested, add tests.
138111
4. If you've changed APIs, update the documentation.
139-
5. Run `yarn test` and ensure the test suite passes.
140-
6. Use `yarn format` to format and lint your code.
112+
5. Run `npm run test` and ensure the test suite passes.
113+
6. Use `npm run format` to format and lint your code.
141114
7. PR's must be rebased before merge (feel free to ask for help).
142115
8. PR should be reviewed by two maintainers prior to merging.
143116

144117
## Debugging
145118

146-
`yarn start` spawns a development server and uses `dev-test/config.yml` and `dev-test/index.html` to serve the CMS.
119+
`npm run start` spawns a development server and uses `dev-test/config.yml` and `dev-test/index.html` to serve the CMS.
147120
In order to debug a specific issue follow the next steps:
148121

149122
1. Replace `dev-test/config.yml` with the relevant `config.yml`. If you want to test the backend, make sure that the `backend` property of the config indicates which backend you use (GitHub, Gitlab, Bitbucket etc) and path to the repo.
@@ -174,7 +147,7 @@ backend:
174147
```
175148
The most important thing is to make sure that Decap CMS is loaded from the `dist` folder. This way, every time you make changes to the source code, they will be compiled and reflected immediately on `localhost`.
176149

177-
3. Run `yarn start`
150+
3. Run `npm run start`
178151
4. Open `http://localhost:8080/` in the browser and you should have access to the CMS
179152

180153
### Debugging Git Gateway
@@ -197,25 +170,25 @@ There are situations where you would want to run a specific test file, or tests
197170
To run all the tests for a specific file, use this command:
198171

199172
```
200-
yarn jest <filename or file path>
173+
npx jest <filename or file path>
201174
```
202175

203-
The first part of the command, `yarn jest` means running the locally installed version of `jest`. It is equivalent to running `node_modules/.bin/jest`.
176+
The first part of the command, `npx jest` means running the locally installed version of `jest`. It is equivalent to running `node_modules/.bin/jest`.
204177

205-
Example for running all the tests for the file `gitlab.spec.js`: `yarn jest gitlab.spec.js`
178+
Example for running all the tests for the file `gitlab.spec.js`: `npx jest gitlab.spec.js`
206179

207180
Some test files like `API.spec.js` is available in several packages. You can pass a regexp pattern instead of file path to narrow down files.
208181

209182
Example for running all the tests for the file `API.spec.js` in the `decap-cms-backend-gitlab` package:
210183

211-
`yarn jest ".+backend-gitlab/.+/API.spec.js`
184+
`npx jest ".+backend-gitlab/.+/API.spec.js`
212185

213186
To run a specific test in a file, add the flag `--testNamePattern`, or `-t` for short followed by a regexp to match your test name.
214187

215188
Example for running the test "should return true on project access_level >= 30" in the API.spec.js in `decap-cms-backend-gitlab` package:
216189

217190
```
218-
yarn jest -t "true on p" ".+backend-gitlab/.+/API.spec.js"
191+
npx jest -t "true on p" ".+backend-gitlab/.+/API.spec.js"
219192
```
220193

221194
For more information about running tests exactly the way you want, check out the official documentation for [Jest CLI](https://jestjs.io/docs/cli).

cypress/Readme.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ Tests for the other backends use previously [recorded data](fixtures) and stub `
1515
## Run Tests Locally
1616

1717
```bash
18-
yarn test:e2e # builds the demo site and runs Cypress in headless mode with mock data
18+
npm run test:e2e # builds the demo site and runs Cypress in headless mode with mock data
1919
```
2020

2121
## Debug Tests
2222

2323
```bash
24-
yarn develop # starts a local dev server with the demo site
25-
yarn test:e2e:exec # runs Cypress in non-headless mode with mock data
24+
npm run develop # starts a local dev server with the demo site
25+
npm run test:e2e:exec # runs Cypress in non-headless mode with mock data
2626
```
2727

2828
## Recording Tests Data
@@ -54,10 +54,10 @@ NETLIFY_INSTALLATION_ID=netlifyGitHubInstallationId
5454
To start a recording run the following commands:
5555

5656
```bash
57-
yarn develop # starts a local dev server with the demo site
58-
yarn mock:server:start # starts the recording proxy
59-
yarn test:e2e:record-fixtures:dev # runs Cypress in non-headless and pass data through the recording proxy
60-
yarn mock:server:stop # stops the recording proxy
57+
npm run develop # starts a local dev server with the demo site
58+
npm run mock:server:start # starts the recording proxy
59+
npm run test:e2e:record-fixtures:dev # runs Cypress in non-headless and pass data through the recording proxy
60+
npm run mock:server:stop # stops the recording proxy
6161
```
6262

6363
> During the recorded process a clone of the relevant repo will be created under `.temp` and reset between tests.

cypress/plugins/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// the project's config changing)
1313
require('dotenv').config();
1414
const { merge } = require('lodash');
15-
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');
15+
const { addMatchImageSnapshotPlugin } = require('@simonsmith/cypress-image-snapshot/plugin');
1616

1717
const {
1818
setupGitHub,

cypress/support/e2e.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// ***********************************************************
1515
import 'cypress-plugin-tab';
1616
import 'cypress-jest-adapter';
17-
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
17+
import { addMatchImageSnapshotCommand } from '@simonsmith/cypress-image-snapshot/command';
1818

1919
addMatchImageSnapshotCommand({
2020
failureThreshold: 0.01,

lerna.json

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
2-
"lerna": "2.11.0",
32
"packages": ["packages/*"],
43
"version": "independent",
5-
"npmClient": "yarn",
6-
"useWorkspaces": true,
4+
"npmClient": "npm",
75
"loglevel": "success",
86
"command": {
97
"version": {
@@ -14,9 +12,6 @@
1412
"message": "chore(release): publish"
1513
}
1614
},
17-
"ignoreChanges": [
18-
"**/__fixtures__/**",
19-
"**/__tests__/**",
20-
"**/*.md"
21-
]
15+
"ignoreChanges": ["**/__fixtures__/**", "**/__tests__/**", "**/*.md"],
16+
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
2217
}

nx.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"targetDefaults": {
3+
"build:esm": {
4+
"cache": true
5+
},
6+
"build": {
7+
"cache": true
8+
}
9+
},
10+
"namedInputs": {
11+
"default": [
12+
"{projectRoot}/**/*",
13+
"sharedGlobals"
14+
],
15+
"sharedGlobals": [],
16+
"production": [
17+
"default"
18+
]
19+
}
20+
}

0 commit comments

Comments
 (0)