Skip to content

Commit

Permalink
(chore) Take advantage of Yarn's workspace versioning capabilities (#801
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ibacher authored Nov 1, 2023
1 parent 812a0d4 commit f7c1190
Show file tree
Hide file tree
Showing 25 changed files with 224 additions and 3,664 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ jobs:
server-token: ${{ secrets.TURBO_SERVER_TOKEN }}

- name: Version
run: yarn lerna version "$(node -e "console.log(require('semver').inc(require('./lerna.json').version, 'patch'))")-pre.${{ github.run_number }}" --no-git-tag-version --no-push --yes
# This command CANNOT be run in parallel
run: yarn workspaces foreach --all --toplogical version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-pre.${{ github.run_number }}"

- name: Build
run: yarn turbo run build --color --concurrency=5
Expand All @@ -95,7 +96,7 @@ jobs:
- run: git add . && git commit -m "Prerelease version" --no-verify

- name: Pre-release
run: yarn run ci:publish-next
run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:publish-next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

Expand Down Expand Up @@ -135,7 +136,7 @@ jobs:
run: yarn turbo run build --color --concurrency=5

- name: Publish
run: yarn run ci:publish
run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -e # die on error

yarn turbo extract-translations
yarn pretty-quick --staged
yarn lerna run document --since main
yarn turbo document --since main
7 changes: 0 additions & 7 deletions docs/getting_started/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ If the repository you're looking at has a `yarn.lock` file, then it uses `yarn`,
and you'll want to read the [Yarn docs](https://classic.yarnpkg.com/en/docs/getting-started).
Otherwise it uses `npm`. Yarn and npm are exclusive of each other within a repository.

### Lerna

Most OpenMRS 3 projects use Lerna. If the repository you're looking
at has a `packages` directory at the top level,
then it is a "monorepo" and is using Lerna, and you'll want to read the
[Lerna docs](https://github.com/lerna/lerna#readme).

## React

You should know everything from [React Main Concepts](https://reactjs.org/docs/hello-world.html),
Expand Down
2 changes: 1 addition & 1 deletion docs/main/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rm -rf node_modules/
yarn
```

This will only delete the root `node_modules` folder. You may also want to delete the `node_modules` of all packages in a monorepo. If the monorepo has Lerna you can simply run `npx lerna clean` followed by `yarn`. Otherwise delete these manually, then run `yarn`.
This will only delete the root `node_modules` folder. You may also want to delete the `node_modules` of all packages in a monorepo.

Yarn is smart and will quickly compile the new `node_modules` folder from its internal cache. If you are worried that yarn has cached an invalid version of a package you can clear yarn cache to force it to download the packages again

Expand Down
16 changes: 0 additions & 16 deletions lerna.json

This file was deleted.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@openmrs/esm-core",
"version": "5.2.0",
"private": true,
"workspaces": [
"packages/apps/*",
Expand All @@ -11,9 +12,9 @@
"run:docs": "docsify serve docs",
"run:omrs": "openmrs",
"run:shell": "turbo run watch --filter=@openmrs/esm-app-shell --parallel --no-cache",
"ci:publish-next": "lerna publish from-package --no-git-reset --dist-tag next --yes",
"ci:publish": "lerna publish from-package --yes",
"release": "lerna version --no-git-tag-version",
"ci:publish-next": "yarn workspaces foreach --all --topological npm publish --access public --tag latest",
"ci:publish": "yarn workspaces foreach --all --topological npm publish --access public --tag latest",
"release": "yarn workspaces foreach --all --topological version",
"build": "turbo run build",
"build:apps": "turbo run build --filter='@openmrs/*-app'",
"setup": "yarn install && turbo run build && lerna clean --yes && yarn install --immutable",
Expand All @@ -26,7 +27,6 @@
"coverage": "yarn test --coverage"
},
"devDependencies": {
"@babel/highlight": "^7.18.6",
"@jest/types": "^29.6.3",
"@playwright/test": "1.39.0",
"@swc/core": "^1.3.58",
Expand Down Expand Up @@ -55,8 +55,7 @@
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lerna": "^4.0.0",
"openmrs": "workspace:^",
"openmrs": "workspace:*",
"postcss": "^8.4.6",
"prettier": "^2.0.5",
"pretty-quick": "^3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/framework/esm-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"@openmrs/esm-offline": "5.x"
},
"devDependencies": {
"@openmrs/esm-config": "^5.2.0",
"@openmrs/esm-error-handling": "^5.2.0",
"@openmrs/esm-state": "^5.2.0",
"@openmrs/esm-config": "workspace:*",
"@openmrs/esm-error-handling": "workspace:*",
"@openmrs/esm-state": "workspace:*",
"rxjs": "^6.5.3",
"webpack": "^5.88.0"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/esm-breadcrumbs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
"@openmrs/esm-state": "5.x"
},
"devDependencies": {
"@openmrs/esm-state": "^5.2.0"
"@openmrs/esm-state": "workspace:*"
}
}
5 changes: 2 additions & 3 deletions packages/framework/esm-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@
"single-spa": "5.x"
},
"devDependencies": {
"@openmrs/esm-globals": "^5.2.0",
"@openmrs/esm-state": "^5.2.0",
"@openmrs/esm-globals": "workspace:*",
"@openmrs/esm-state": "workspace:*",
"@types/ramda": "^0.26.44",
"babel-plugin-ramda": "^2.0.0",
"single-spa": "^5.9.2"
}
}
6 changes: 3 additions & 3 deletions packages/framework/esm-dynamic-loading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@openmrs/esm-globals": "^5.2.0"
},
"peerDependencies": {
"@openmrs/esm-globals": "5.x"
},
"devDependencies": {
"@openmrs/esm-globals": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/framework/esm-error-handling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
"@openmrs/esm-globals": "5.x"
},
"devDependencies": {
"@openmrs/esm-globals": "^5.2.0"
"@openmrs/esm-globals": "workspace:*"
}
}
8 changes: 4 additions & 4 deletions packages/framework/esm-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
"single-spa": "5.x"
},
"devDependencies": {
"@openmrs/esm-api": "^5.2.0",
"@openmrs/esm-config": "^5.2.0",
"@openmrs/esm-feature-flags": "^5.2.0",
"@openmrs/esm-state": "^5.2.0",
"@openmrs/esm-api": "workspace:*",
"@openmrs/esm-config": "workspace:*",
"@openmrs/esm-feature-flags": "workspace:*",
"@openmrs/esm-state": "workspace:*",
"single-spa": "^5.9.2"
},
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/framework/esm-feature-flags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"single-spa": "5.x"
},
"devDependencies": {
"@openmrs/esm-globals": "^5.2.0",
"@openmrs/esm-state": "^5.2.0"
"@openmrs/esm-globals": "workspace:*",
"@openmrs/esm-state": "workspace:*",
"single-spa": "^5.9.2"
}
}
26 changes: 13 additions & 13 deletions packages/framework/esm-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@
"access": "public"
},
"dependencies": {
"@openmrs/esm-api": "^5.2.0",
"@openmrs/esm-breadcrumbs": "^5.2.0",
"@openmrs/esm-config": "^5.2.0",
"@openmrs/esm-dynamic-loading": "^5.2.0",
"@openmrs/esm-error-handling": "^5.2.0",
"@openmrs/esm-extensions": "^5.2.0",
"@openmrs/esm-feature-flags": "^5.2.0",
"@openmrs/esm-globals": "^5.2.0",
"@openmrs/esm-offline": "^5.2.0",
"@openmrs/esm-react-utils": "^5.2.0",
"@openmrs/esm-state": "^5.2.0",
"@openmrs/esm-styleguide": "^5.2.0",
"@openmrs/esm-utils": "^5.2.0",
"@openmrs/esm-api": "workspace:*",
"@openmrs/esm-breadcrumbs": "workspace:*",
"@openmrs/esm-config": "workspace:*",
"@openmrs/esm-dynamic-loading": "workspace:*",
"@openmrs/esm-error-handling": "workspace:*",
"@openmrs/esm-extensions": "workspace:*",
"@openmrs/esm-feature-flags": "workspace:*",
"@openmrs/esm-globals": "workspace:*",
"@openmrs/esm-offline": "workspace:*",
"@openmrs/esm-react-utils": "workspace:*",
"@openmrs/esm-state": "workspace:*",
"@openmrs/esm-styleguide": "workspace:*",
"@openmrs/esm-utils": "workspace:*",
"dayjs": "^1.10.7"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/esm-globals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"single-spa": "5.x"
},
"devDependencies": {
"single-spa": "^5.9.3"
"single-spa": "^5.9.2"
}
}
16 changes: 8 additions & 8 deletions packages/framework/esm-offline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@openmrs/esm-api": "^5.2.0",
"@openmrs/esm-globals": "^5.2.0",
"@openmrs/esm-state": "^5.2.0",
"@openmrs/esm-styleguide": "^5.2.0",
"@types/uuid": "^9.0.1",
"rxjs": "^6.5.3"
},
"peerDependencies": {
"@openmrs/esm-api": "5.x",
"@openmrs/esm-globals": "5.x",
Expand All @@ -57,5 +49,13 @@
"lodash-es": "^4.17.21",
"uuid": "^9.0.0",
"workbox-window": "^6.1.5"
},
"devDependencies": {
"@openmrs/esm-api": "workspace:*",
"@openmrs/esm-globals": "workspace:*",
"@openmrs/esm-state": "workspace:*",
"@openmrs/esm-styleguide": "workspace:*",
"@types/uuid": "^9.0.1",
"rxjs": "^6.5.3"
}
}
13 changes: 7 additions & 6 deletions packages/framework/esm-react-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@
"react": "18.x",
"react-dom": "18.x",
"react-i18next": "11.x",
"rxjs": "6.x",
"swr": "2.x"
},
"devDependencies": {
"@openmrs/esm-api": "^5.2.0",
"@openmrs/esm-config": "^5.2.0",
"@openmrs/esm-error-handling": "^5.2.0",
"@openmrs/esm-extensions": "^5.2.0",
"@openmrs/esm-feature-flags": "^5.2.0",
"@openmrs/esm-globals": "^5.2.0",
"@openmrs/esm-api": "workspace:*",
"@openmrs/esm-config": "workspace:*",
"@openmrs/esm-error-handling": "workspace:*",
"@openmrs/esm-extensions": "workspace:*",
"@openmrs/esm-feature-flags": "workspace:*",
"@openmrs/esm-globals": "workspace:*",
"dayjs": "^1.10.8",
"i18next": "^21.10.0",
"react": "^18.1.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/framework/esm-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
},
"peerDependencies": {
"@openmrs/esm-globals": "5.x"
},
"devDependencies": {
"@openmrs/esm-globals": "workspace:*"
}
}
6 changes: 3 additions & 3 deletions packages/framework/esm-styleguide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
"rxjs": "6.x"
},
"devDependencies": {
"@openmrs/esm-extensions": "^5.2.0",
"@openmrs/esm-react-utils": "^5.2.0",
"@openmrs/esm-state": "^5.2.0",
"@openmrs/esm-extensions": "workspace:*",
"@openmrs/esm-react-utils": "workspace:*",
"@openmrs/esm-state": "workspace:*",
"autoprefixer": "^9.8.8",
"css-minimizer-webpack-plugin": "^1.2.0",
"i18next": "^21.10.0",
Expand Down
7 changes: 3 additions & 4 deletions packages/shell/esm-app-shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"build:development": "cross-env OMRS_OFFLINE=\"enable\" OMRS_CLEAN_BEFORE_BUILD=\"true\" NODE_ENV=\"development\" webpack --mode development",
"build": "npm run build:production && npm run build:development",
"analyze": "webpack --mode=production --env analyze=true",
"lint": "eslint src --ext ts,tsx",
"version": "yarn add @openmrs/esm-framework@$npm_package_version --exact @openmrs/esm-styleguide@$npm_package_version --exact"
"lint": "eslint src --ext ts,tsx"
},
"keywords": [
"openmrs",
Expand All @@ -35,8 +34,8 @@
},
"dependencies": {
"@carbon/react": "^1.37.0",
"@openmrs/esm-framework": "5.2.0",
"@openmrs/esm-styleguide": "5.2.0",
"@openmrs/esm-framework": "workspace:*",
"@openmrs/esm-styleguide": "workspace:*",
"dayjs": "^1.10.4",
"dexie": "^3.0.3",
"html-webpack-plugin": "^5.5.0",
Expand Down
6 changes: 4 additions & 2 deletions packages/shell/esm-app-shell/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,10 @@ module.exports = (env, argv = {}) => {
} else if (version.startsWith("~")) {
const semVer = semver.parse(version.slice(1));
version = `${semVer.major}.${semVer.minor}.x`;
} else if (depName === "@openmrs/esm-framework") {
version = `${semver.parse(version).major}.x`;
} else if (version === "workspace:*") {
version = `${
semver.parse(require(`${depName}/package.json`).version).major
}.X`;
}
}

Expand Down
7 changes: 3 additions & 4 deletions packages/tooling/openmrs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"start": "node ./dist/cli.js",
"test": "jest --passWithNoTests",
"build": "tsc",
"lint": "eslint src --ext ts,tsx",
"version": "yarn add @openmrs/esm-app-shell@$npm_package_version @openmrs/webpack-config@$npm_package_version --exact"
"lint": "eslint src --ext ts,tsx"
},
"repository": {
"type": "git",
Expand All @@ -30,8 +29,8 @@
],
"homepage": "https://github.com/openmrs/openmrs-esm-core#readme",
"dependencies": {
"@openmrs/esm-app-shell": "5.2.0",
"@openmrs/webpack-config": "5.2.0",
"@openmrs/esm-app-shell": "workspace:*",
"@openmrs/webpack-config": "workspace:*",
"@pnpm/npm-conf": "^2.1.0",
"@swc/core": "^1.3.58",
"autoprefixer": "^10.4.2",
Expand Down
1 change: 0 additions & 1 deletion packages/tooling/webpack-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"homepage": "https://github.com/openmrs/openmrs-esm-core#readme",
"dependencies": {
"@swc/core": "^1.3.58",
"babel-preset-minify": "^0.5.1",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^5.2.4",
Expand Down
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"dependsOn": ["^build:development"],
"outputs": ["dist/**"]
},
"document": {
"outputs": ["docs/**"]
},
"test": {},
"test:watch": {},
"watch": {},
Expand Down
Loading

0 comments on commit f7c1190

Please sign in to comment.