From 617a50b1b1103f197624137274a8b28bf97c5d6d Mon Sep 17 00:00:00 2001 From: Ty Hopp Date: Sun, 2 Oct 2022 18:25:27 +0800 Subject: [PATCH] chore: Monorepo tooling updates (#75) * chore: Update update-sites script to work on Node 16+ * chore: Test on lts and current Node versions * chore: Add docs workspace * chore: Add engines, OS to root package.json --- .github/workflows/integration-tests.yaml | 13 ++- package-lock.json | 141 ++++++++++++++++++++++- package.json | 13 ++- process-release.md | 2 +- scripts/update-sites.sh | 45 +++++--- 5 files changed, 193 insertions(+), 21 deletions(-) diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index 58e4ae9..1d51b6a 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -10,17 +10,24 @@ defaults: jobs: test: - name: ${{ matrix.os }} + name: ${{ matrix.os }}-node-${{ matrix.node }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] + node: [16, 18] + steps: - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.nodejs }} - name: Install monorepo dependencies - run: npm i + run: npm install - name: Build PRPL modules run: npm run build diff --git a/package-lock.json b/package-lock.json index 27ddd75..3f69ccd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,10 +4,16 @@ "requires": true, "packages": { "": { + "os": [ + "darwin", + "linux", + "win32" + ], "workspaces": [ "packages/*", "examples/*", - "tests" + "tests", + "docs" ], "devDependencies": { "@rollup/plugin-commonjs": "^19.0.0", @@ -17,12 +23,14 @@ "rollup": "^2.52.7", "rollup-plugin-typescript2": "^0.31.1", "typescript": "^4.3.5" + }, + "engines": { + "node": ">=16.17.1" } }, "docs": { "name": "prpl-docs", "version": "0.0.1", - "extraneous": true, "license": "MIT", "dependencies": { "@prpl/core": "^0.3.6", @@ -35,6 +43,71 @@ "@prpl/server": "^0.1.12" } }, + "docs/node_modules/@prpl/core": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@prpl/core/-/core-0.3.6.tgz", + "integrity": "sha512-tfkUZ9svPbSs7AuzXuxVkn0BjoNgBVOZBWnfSIRGjH45pUdJHe6Guew2uv3+A0SKgdbSpTF7hHRXtxTgV+qn7A==", + "dependencies": { + "marked": "^4.0.12" + }, + "bin": { + "prpl": "bin/prpl.js" + } + }, + "docs/node_modules/@prpl/plugin-code-highlight": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@prpl/plugin-code-highlight/-/plugin-code-highlight-0.3.8.tgz", + "integrity": "sha512-WbEZ+04MFco6WryIG71XUWaWys+b2mPBdD8KlTPagZx/68MyF3u3lFHyi0rpl6+bIlCbviy4bFyaRtjP3DX2jw==", + "dependencies": { + "highlight.js": "11.2.0", + "html-escaper": "^3.0.3" + }, + "peerDependencies": { + "@prpl/core": ">=0.3.4" + } + }, + "docs/node_modules/@prpl/plugin-css-imports": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/@prpl/plugin-css-imports/-/plugin-css-imports-0.2.13.tgz", + "integrity": "sha512-B5AmZqhg2fJIQTX+FBcpF+GHNFb5NJoVwcqNkNqaqi5wonsNfE4+5sLSBYQPtsaTWmO8jnibXVTaHdwArOATOw==", + "peerDependencies": { + "@prpl/core": ">=0.3.4" + } + }, + "docs/node_modules/@prpl/plugin-html-imports": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/@prpl/plugin-html-imports/-/plugin-html-imports-0.2.13.tgz", + "integrity": "sha512-tYlFRWvQuf74SXMLq++hvdsB25fX5yb4l9IoYprvRWpn8LlpQ5yHd3XBGKaqa1PROKqSo1yWvA1RX150uEy+SQ==", + "peerDependencies": { + "@prpl/core": ">=0.3.4" + } + }, + "docs/node_modules/@prpl/plugin-sitemap": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/@prpl/plugin-sitemap/-/plugin-sitemap-0.1.13.tgz", + "integrity": "sha512-ZzfrWGaMd8POzGAIPR8opwF9oQTmyP6hs7lJeiBd5wcDajAYC6VmPUkt/cJLdO+CslZxXhbLaXZnh9tRNmal7g==", + "peerDependencies": { + "@prpl/core": ">=0.3.4" + } + }, + "docs/node_modules/@prpl/server": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@prpl/server/-/server-0.1.12.tgz", + "integrity": "sha512-WQrxXL3ROHTeU1S03l3soBV9W+FYRBx5zM7nK6O3uzBjjeE2dBCVnyLpg/rPfJ9YEaVK0IR8R2Aqze07oXn8hw==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "faye-websocket": "^0.11.4", + "open": "^8.2.0", + "serve-handler": "^6.1.3" + }, + "bin": { + "prpl-server": "bin/prpl-server.js" + }, + "peerDependencies": { + "@prpl/core": ">=0.3.4" + } + }, "examples/basic": { "name": "prpl-example-basic", "version": "0.0.1", @@ -1239,6 +1312,10 @@ "node": ">=10.13.0" } }, + "node_modules/prpl-docs": { + "resolved": "docs", + "link": true + }, "node_modules/prpl-example-basic": { "resolved": "examples/basic", "link": true @@ -2694,6 +2771,66 @@ "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", "dev": true }, + "prpl-docs": { + "version": "file:docs", + "requires": { + "@prpl/core": "^0.3.6", + "@prpl/plugin-code-highlight": "^0.3.8", + "@prpl/plugin-css-imports": "^0.2.13", + "@prpl/plugin-html-imports": "^0.2.13", + "@prpl/plugin-sitemap": "^0.1.13", + "@prpl/server": "^0.1.12" + }, + "dependencies": { + "@prpl/core": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@prpl/core/-/core-0.3.6.tgz", + "integrity": "sha512-tfkUZ9svPbSs7AuzXuxVkn0BjoNgBVOZBWnfSIRGjH45pUdJHe6Guew2uv3+A0SKgdbSpTF7hHRXtxTgV+qn7A==", + "requires": { + "marked": "^4.0.12" + } + }, + "@prpl/plugin-code-highlight": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@prpl/plugin-code-highlight/-/plugin-code-highlight-0.3.8.tgz", + "integrity": "sha512-WbEZ+04MFco6WryIG71XUWaWys+b2mPBdD8KlTPagZx/68MyF3u3lFHyi0rpl6+bIlCbviy4bFyaRtjP3DX2jw==", + "requires": { + "highlight.js": "11.2.0", + "html-escaper": "^3.0.3" + } + }, + "@prpl/plugin-css-imports": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/@prpl/plugin-css-imports/-/plugin-css-imports-0.2.13.tgz", + "integrity": "sha512-B5AmZqhg2fJIQTX+FBcpF+GHNFb5NJoVwcqNkNqaqi5wonsNfE4+5sLSBYQPtsaTWmO8jnibXVTaHdwArOATOw==", + "requires": {} + }, + "@prpl/plugin-html-imports": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/@prpl/plugin-html-imports/-/plugin-html-imports-0.2.13.tgz", + "integrity": "sha512-tYlFRWvQuf74SXMLq++hvdsB25fX5yb4l9IoYprvRWpn8LlpQ5yHd3XBGKaqa1PROKqSo1yWvA1RX150uEy+SQ==", + "requires": {} + }, + "@prpl/plugin-sitemap": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/@prpl/plugin-sitemap/-/plugin-sitemap-0.1.13.tgz", + "integrity": "sha512-ZzfrWGaMd8POzGAIPR8opwF9oQTmyP6hs7lJeiBd5wcDajAYC6VmPUkt/cJLdO+CslZxXhbLaXZnh9tRNmal7g==", + "requires": {} + }, + "@prpl/server": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@prpl/server/-/server-0.1.12.tgz", + "integrity": "sha512-WQrxXL3ROHTeU1S03l3soBV9W+FYRBx5zM7nK6O3uzBjjeE2dBCVnyLpg/rPfJ9YEaVK0IR8R2Aqze07oXn8hw==", + "dev": true, + "requires": { + "chokidar": "^3.5.2", + "faye-websocket": "^0.11.4", + "open": "^8.2.0", + "serve-handler": "^6.1.3" + } + } + } + }, "prpl-example-basic": { "version": "file:examples/basic", "requires": { diff --git a/package.json b/package.json index 9609f36..24fa87e 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,24 @@ "workspaces": [ "packages/*", "examples/*", - "tests" + "tests", + "docs" ], + "os": [ + "darwin", + "linux", + "win32" + ], + "engines": { + "node": ">=16.17.1" + }, "scripts": { "dev": "bash scripts/dev.sh", "clear": "rm -rf packages/*/dist", "build": "npm run clear && rollup -c rollup.config.js", "version": "bash scripts/version.sh", "publish": "npm run build && bash scripts/publish.sh", - "update:sites": "bash scripts/update-sites.sh" + "update-sites": "bash scripts/update-sites.sh" }, "devDependencies": { "@rollup/plugin-commonjs": "^19.0.0", diff --git a/process-release.md b/process-release.md index e132b37..e527209 100644 --- a/process-release.md +++ b/process-release.md @@ -86,7 +86,7 @@ Update docs and example sites by checking out `main` and then running: ``` git checkout -b chore-update-sites -npm run update:sites +npm run update-sites git push --set-upstream origin chore-update-sites ``` diff --git a/scripts/update-sites.sh b/scripts/update-sites.sh index ed790f7..726bbf7 100644 --- a/scripts/update-sites.sh +++ b/scripts/update-sites.sh @@ -1,21 +1,40 @@ -# Docs site -------------------------------------------------- +# Update package.json and package-lock.json files with latest PRPL deps. +# Some workspace commands (e.g. install, update) are borked, so we have to do this manually. -# Update docs site -cd docs -npm i @prpl/core@latest @prpl/plugin-code-highlight@latest @prpl/plugin-css-imports@latest @prpl/plugin-html-imports@latest @prpl/plugin-sitemap@latest && npm i --workspaces=false -D @prpl/server@latest -cd .. -git add . -git commit -m "chore(docs): Update PRPL deps" +core_latest=$(npm view "@prpl/core" version) +server_latest=$(npm view "@prpl/server" version) + +# Update example site deps +npm pkg set "dependencies[@prpl/core]"="^${core_latest}" --workspace=examples +npm pkg set "devDependencies[@prpl/server]"="^${server_latest}" --workspace=examples -# Example sites -------------------------------------------------- +# Update docs deps +npm pkg set "dependencies[@prpl/core]"="^${core_latest}" --workspace=docs +npm pkg set "devDependencies[@prpl/server]"="^${server_latest}" --workspace=docs -examples=("basic" "esm" "commonjs" "deno") +plugins=("core" "plugin-code-highlight" "plugin-css-imports" "plugin-html-imports" "plugin-sitemap") + +for plugin in ${plugins[@]}; do + latest=$(npm view "@prpl/${plugin}" version) + npm pkg set "dependencies[@prpl/${plugin}]"="^${latest}" --workspace=docs +done +# Recreate lockfiles, workspaces + lockfiles are broken in npm +examples=("examples/basic" "examples/commonjs" "examples/deno" "examples/esm") + +# Recreate example lockfiles for example in ${examples[@]}; do - cd "examples/${example}" - npm i @prpl/core@latest @prpl/server@latest + cd $example + rm package-lock.json + npm install --workspaces=false cd ../.. done -git add . -git commit -m "chore(examples): Update PRPL deps" \ No newline at end of file +# Recreate docs lockfile +cd docs +rm package-lock.json +npm install --workspaces=false +cd ../ + +# Show if tree is borked or not +npm ls \ No newline at end of file