Skip to content

Commit

Permalink
build: back to lerna for now
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jul 1, 2021
1 parent 8a1a9ff commit 24de1af
Show file tree
Hide file tree
Showing 12 changed files with 2,966 additions and 481 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ indent_style = tab
indent_size = 4

# space indentation for some specific files
[{package.json}]
[{package.json,lerna.json}]
indent_style = space
indent_size = 2

Expand Down
37 changes: 14 additions & 23 deletions .github/actions/zwave-js-bot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,34 @@ async function publishPr() {
await exec.exec("git", ["config", "user.email", "[email protected]"]);
await exec.exec("git", ["config", "user.name", "Z-Wave JS Bot"]);

// Configure yarn
await exec.exec("yarn", [
"config",
"npmPublishRegistry",
`'https://registry.npmjs.org'`,
]);
await exec.exec("yarn", [
// Configure npm
await exec.exec("npm", [
"config",
"set",
`'npmRegistries["//registry.npmjs.org"].npmAuthToken'`,
npmToken,
`//registry.npmjs.org/:_authToken=${npmToken}`,
]);

// Figure out the next version
newVersion = `${semver.inc(
require(`${process.env.GITHUB_WORKSPACE}/package.json`).version,
require(`${process.env.GITHUB_WORKSPACE}/lerna.json`).version,
"prerelease",
)}-pr-${pr}-${pull.merge_commit_sha.slice(0, 7)}`;

// Bump versions
await exec.exec("yarn", [
"workspaces",
"foreach",
"version",
newVersion,
"--deferred",
]);
await exec.exec("yarn", ["version", "apply", "--all"]);
await exec.exec(
"yarn",
`lerna version ${newVersion} --exact --allow-branch * --ignore-scripts --no-commit-hooks --yes`.split(
" ",
),
);

// and release
await exec.exec("yarn", [
"workspaces",
"foreach",
"npm",
"lerna",
"publish",
"--tolerate-republish",
"--tag",
"from-package",
"--yes",
"--dist-tag",
"next",
]);
success = true;
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/nightly-config-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ jobs:
yarn install --immutable
# ===============================
# Double-check changes
# Double-check changes with lerna
# ===============================
# Verify that only @zwave-js/config and zwave-js are changed
WORKSPACE_CHANGED=$(yarn version check | grep "has been modified" | cut -d" " -f3 | sed -E "s/@workspace.+//")
if [[ $(echo -e "@zwave-js/config\nzwave-js") != "$WORKSPACE_CHANGED" ]]; then
echo "❌ Detected unexpected package changes, aborting..."
LERNA_CHANGED=$(yarn lerna changed)
if [[ $(echo -e "@zwave-js/config\nzwave-js") != "$LERNA_CHANGED" ]]; then
echo "❌ Lerna detected unexpected package changes, aborting..."
echo "These packages are changed:"
echo "$WORKSPACE_CHANGED"
echo "$LERNA_CHANGED"
exit 0
fi
Expand All @@ -73,7 +73,7 @@ jobs:
# ===============================
# Create a clean build
yarn run-deps build
yarn lerna run build
# Lint config files
yarn run lint:config
Expand All @@ -82,6 +82,10 @@ jobs:
# Bump the version and publish
# ===============================
cd packages/config
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
# Figure out next version
cat > ./script.js << 'EOF'
const semver = require("semver");
Expand All @@ -104,9 +108,5 @@ jobs:
VERSION=$(node script.js)
echo "Next version is $VERSION"
yarn workspace @zwave-js/config version "$VERSION"
yarn config set npmPublishRegistry 'https://registry.npmjs.org'
yarn config set 'npmRegistries["//registry.npmjs.org"].npmAuthToken' "${{ secrets.NPM_TOKEN }}"
yarn npm whoami
yarn workspace @zwave-js/config npm publish
npm version "$VERSION" --ignore-scripts --no-git-tag-version
npm publish
11 changes: 5 additions & 6 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: yarn install --immutable

- name: Compile TypeScript code
run: yarn run-all build
run: yarn lerna run build

- name: Run linters
run: yarn run lint
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
run: yarn install --immutable

- name: Compile TypeScript code
run: yarn run-all build
run: yarn lerna run build

- name: Lint config files
run: yarn run lint:config
Expand Down Expand Up @@ -277,10 +277,9 @@ jobs:

- name: Publish packages to npm
run: |
yarn config set npmPublishRegistry 'https://registry.npmjs.org'
yarn config set 'npmRegistries["//registry.npmjs.org"].npmAuthToken' "${{ secrets.NPM_TOKEN }}"
yarn npm whoami
yarn workspaces foreach npm publish --tolerate-republish
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
yarn lerna publish from-package --yes
- name: Create Github Release
uses: actions/create-release@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/to-log-entry-overview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: yarn install --immutable

- name: Compile TypeScript code
run: yarn run-all build
run: yarn lerna run build

- name: Update overview
uses: ./.github/actions/toLogEntry
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
}
],
"debug.javascript.unmapMissingSources": true,
"jest.jestCommandLine": "npx jest",
"jest.jestCommandLine": "yarn jest",
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
Expand Down
367 changes: 0 additions & 367 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

This file was deleted.

6 changes: 2 additions & 4 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ enableGlobalCache: true

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
spec: '@yarnpkg/plugin-workspace-tools'

preferInteractive: true

Expand Down
11 changes: 10 additions & 1 deletion docs/development/installing-from-github.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ If you need to test changes from GitHub, e.g. a branch that fixes an issue you h
}
```
And execute `yarn` in your repo to set up the links.
1. If your repo is using `npm`, you might be out of luck for now.
1. If your repo is using `npm` run this in the `node-zwave-js` repo:
```bash
lerna exec -- npm link
```
And this in your repo (for every package you use directly:)
```bash
npm link zwave-js
npm link @zwave-js/config
# ... others
```
1. (Re)start your application
1. If you're planning to work on `zwave-js`, run `yarn run watch` to continuously rebuild the changes
1. Don't forget to remove the `"resolutions"` field and run `yarn` again when you're done testing.
5 changes: 4 additions & 1 deletion docs/development/intro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Development introduction {docsify-ignore-all}

## Help, I know nothing about `npm`, `yarn` and whatever...
## Help, I know nothing about `npm`, `yarn`, `lerna` and whatever...

_Alright, here's a short introduction if you're new to this stuff. If you know the basics, feel free to [skip forward](`#Prerequisites`)._

Expand All @@ -12,6 +12,9 @@ _Alright, here's a short introduction if you're new to this stuff. If you know t
`yarn` has a [bunch of commands](https://classic.yarnpkg.com/en/docs/usage) but you'll likely only need to use `yarn` (short for `yarn install`) to install all dependencies. **Don't** install missing dependencies one by one, **don't** install them globally.
`yarn` can also run package scripts for you, which we use extensively, e.g. `yarn run build` to compile TypeScript into JavaScript. You'll find most of the scripts in `package.json` under `"scripts"`.

[`lerna`](https://github.com/lerna/lerna) is a tool to manage monorepos (multiple dependent packages in a single repo) that works hand in hand with `yarn`. Since it allows running package scripts of sub-packages, we use it for some of our workflows.
To use `lerna`, you need to install it globally with `npm i -g lerna`. If you prefer not to, you can alternatively just prefix the commands with `yarn`, e.g. `yarn lerna run <scriptname>`.

## Prerequisites

For the best possible development experience, you should use [VSCode](https://code.visualstudio.com/).
Expand Down
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@zwave-js/repo",
"version": "7.10.0",
"private": true,
"description": "Z-Wave driver written entirely in JavaScript/TypeScript",
"keywords": [],
Expand Down Expand Up @@ -62,6 +61,7 @@
"husky": "^6.0.0",
"jest": "^26.4.2",
"jest-extended": "^0.11.5",
"lerna": "^4.0.0",
"prettier": "^2.3.1",
"prettier-plugin-organize-imports": "^2.1.0",
"reflect-metadata": "^0.1.13",
Expand All @@ -74,14 +74,9 @@
},
"scripts": {
"run-all": "yarn workspaces foreach -vip --topological-dev --exclude @zwave-js/repo run",
"run-all:p": "yarn workspaces foreach -vip --exclude @zwave-js/repo run",
"run-zjs": "yarn workspaces foreach -vip --include zwave-js run",
"run-deps": "yarn workspaces foreach -vip --topological-dev --include \"@zwave-js/*\" --exclude @zwave-js/repo run",
"run-deps:p": "yarn workspaces foreach -vip --include \"@zwave-js/*\" --exclude @zwave-js/repo run",
"build": "yarn run-zjs build",
"build:full": "yarn run-deps build && yarn run-zjs build_full",
"clean": "yarn run-all clean",
"watch": "yarn run-all:p watch",
"build": "lerna run build --scope=zwave-js",
"build:full": "lerna run build --scope=@zwave-js/* && lerna run build_full",
"watch": "lerna run watch --parallel",
"test:reset": "jest --clear-cache",
"test:ts": "jest",
"test:ci": "yarn run test:ts --runInBand",
Expand All @@ -92,16 +87,20 @@
"show-coverage": "yarn run coverage && start ./coverage/index.html",
"lint:ts": "eslint --ext .ts \"packages/*/src/**/*.ts\"",
"lint:wotan": "wotan",
"lint:config": "yarn run-all lint_config",
"lint:config": "lerna run lint_config",
"lint:configjson": "prettier -c \"packages/config/config/**/*.json\"",
"lint:zwave": "yarn run-all lint_zwave",
"lint:zwave": "lerna run lint_zwave",
"lint": "yarn run lint:wotan && yarn run lint:ts && yarn run lint:configjson",
"implemented_ccs": "yarn ts packages/maintenance/src/implementedCCs.ts",
"gh-cc-table": "yarn run implemented_ccs --flavor=github --only-incomplete",
"toLogEntryOverview": "yarn ts packages/zwave-js/maintenance/checkCCToLogEntry.ts",
"usbdebug": "cmd.exe /c \"test\\usbdebug.bat\"",
"commit": "git-cz",
"release": "yarn run build && yarn release-script",
"release": "yarn run build && lerna version --no-commit-hooks",
"release:all": "yarn run build && lerna version --no-commit-hooks --force-publish",
"preversion": "release-script --lerna-check",
"version": "yarn install && release-script --lerna",
"postversion": "git push && git push --tags",
"config": "yarn ts packages/config/maintenance/importConfig.ts",
"docs": "docsify serve docs",
"docs:generate": "yarn ts packages/maintenance/src/generateTypedDocs.ts",
Expand Down
Loading

0 comments on commit 24de1af

Please sign in to comment.