Skip to content

Commit

Permalink
fix(nx-mesh): nx peer dependencies (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
domjtalbot committed Jan 15, 2023
1 parent a76a8ad commit bdb85d1
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 79 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-camels-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nx-mesh': patch
---

Fix peer dependency ranges
21 changes: 17 additions & 4 deletions .github/actions/setup-job/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ inputs:
Pass `config` (default value) to use the Volta config.
required: false
default: 'config'
skip_node_cache:
description: >
Should node_modules cahce be skipped?
required: false
default: 'false'
save_cache:
description: Should the cache be saved upon completion?
required: false
Expand Down Expand Up @@ -45,6 +50,9 @@ outputs:
The value intended for use with --head or NX_HEAD in all subsequent
`nx affected` commands within the current workflow.
value: ${{ steps.nx_shas.outputs.head }}
pnpm_directory:
description: The installed pnpm directory.
value: ${{ steps.directory.outputs.path }}
pnpm_version:
description: The installed pnpm version.
value: ${{ steps.pnpm.outputs.version }}
Expand Down Expand Up @@ -192,24 +200,28 @@ runs:
- name: Create restore cache key
id: restore_cache_key
if: inputs.skip_node_cache == 'false'
shell: bash
run: |
echo "key=cache-version-7--os-${{ runner.os }}--volta-${{ steps.volta.outputs.version }}--node-${{ steps.node.outputs.version }}--pnpm-${{ steps.pnpm.outputs.version }}" >> $GITHUB_OUTPUT
- name: Create cache key
id: cache_key
if: inputs.skip_node_cache == 'false'
shell: bash
run: |
echo "key=${{ steps.restore_cache_key.outputs.key }}--lockfile-${{ hashFiles('*/pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT
- name: Nx Shas
id: nx_shas
if: inputs.skip_node_cache == 'false'
uses: nrwl/nx-set-shas@v3

# Restore Cache

- name: Restore PNPM cache
uses: actions/cache/restore@v3
if: inputs.skip_node_cache == 'false'
id: pnpm-cache
with:
path: |
Expand All @@ -224,7 +236,7 @@ runs:
- name: Restore Cypress Cache
uses: actions/cache@v3
id: cypress-cache
if: inputs.browsers == 'true'
if: inputs.browsers == 'true' && inputs.skip_node_cache == 'false'
with:
path: |
~/.cache/Cypress
Expand All @@ -236,7 +248,7 @@ runs:
# Install

- name: Install Node Dependencies
if: steps.pnpm-cache.outputs.cache-hit != 'true'
if: steps.pnpm-cache.outputs.cache-hit != 'true' && inputs.skip_node_cache == 'false'
shell: bash
run: |
pnpm install --frozen-lockfile
Expand All @@ -245,13 +257,14 @@ runs:

- name: Affected
id: affected
if: inputs.skip_node_cache == 'false'
uses: ./.github/actions/nx-affected

# Save Cache

- name: Save Cypress cache
uses: actions/cache/save@v3
if: inputs.save_cache == 'true' && steps.pnpm-cache.outputs.cache-hit != 'true'
if: inputs.save_cache == 'true' && steps.pnpm-cache.outputs.cache-hit != 'true' && inputs.skip_node_cache == 'false'
with:
path: |
~/.cache/Cypress
Expand All @@ -260,7 +273,7 @@ runs:
- name: Save PNPM cache
uses: actions/cache/save@v3
if: inputs.save_cache == 'true' && steps.pnpm-cache.outputs.cache-hit != 'true'
if: inputs.save_cache == 'true' && steps.pnpm-cache.outputs.cache-hit != 'true' && inputs.skip_node_cache == 'false'
with:
path: |
${{ steps.pnpm.outputs.cache_dir }}
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ on:
required: true

concurrency:
group: build--${{ github.workflow }}--${{ github.ref }}
group: build--${{ github.workflow }}--${{ github.ref }}--node-${{ inputs.node_version }}--affected-${{ inputs.affected }}--save_cache-${{ inputs.save_cache }}

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
Expand Down Expand Up @@ -85,3 +85,20 @@ jobs:
--parallel=2 \
--all \
--configuration=production
- name: Create build artifact tar
if: inputs.node_version == 'lts'
shell: bash
run: |
cd dist/libs
tar cvzf nx-mesh.tar.gz nx-mesh
mv nx-mesh.tar.gz ../../
- name: Upload build artifact
uses: actions/upload-artifact@v3
if: inputs.node_version == 'lts'
with:
name: nx-mesh
retention-days: 2
path: |
nx-mesh.tar.gz
52 changes: 41 additions & 11 deletions .github/workflows/_generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ env:

jobs:
generator:
name: Generator - ${{ matrix.type }}/${{ matrix.example }}
name: Generator - nx-${{ matrix.nx_version }}/${{ matrix.type }}/${{ matrix.example }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
type: [application, sdk, preset]
example:
Expand All @@ -55,6 +56,10 @@ jobs:
- 'stackexchange'
- 'star-wars-api'
- 'trippin'
nx_version:
- 15.4
- 15.5
- latest
steps:
- name: Check out repository
uses: actions/checkout@v3
Expand All @@ -63,24 +68,49 @@ jobs:

- name: Setup Job
uses: ./.github/actions/setup-job
id: setup
with:
node_version: ${{ inputs.node_version }}
save_cache: '${{ inputs.save_cache }}'
skip_node_cache: 'true'

- name: Build Nx-mesh
shell: bash
run: |
pnpm nx run nx-mesh:build
- name: Restore PNPM cache
uses: actions/cache/restore@v3
id: pnpm-cache
with:
path: |
${{ steps.setup.outputs.pnpm_directory }}
key: |
generators--pnpm--nx-${{ matrix.nx_version }}--type-${{ matrix.type }}--example-${{ matrix.example }}
- name: Download Nx Mesh
uses: actions/download-artifact@v3
with:
name: nx-mesh

- name: Generate Example
- name: Test Generator - (node-${{ inputs.node_version }}/nx-${{ matrix.nx_version }}/${{ matrix.type }}-${{ matrix.example }})
shell: bash
run: |
cd ../
pnpm dlx create-nx-workspace@${{ matrix.nx_version }} \
--name=generator \
--appName=${{ matrix.example }} \
--preset=apps \
--interactive=false \
--nxCloud=false \
--style=css \
--skipGit
cd generator
pnpm add ../nx-mesh/nx-mesh.tar.gz
pnpm exec nx generate nx-mesh:${{ matrix.type }} \
${{ matrix.example }} \
--example=${{ matrix.example }} \
--no-interactive
- name: Build example
shell: bash
run: |
pnpm nx run ${{ matrix.example }}:build
- name: Save PNPM cache
uses: actions/cache/save@v3
with:
path: |
${{ steps.setup.outputs.pnpm_directory }}
key: |
generators--pnpm--nx-${{ matrix.nx_version }}--type-${{ matrix.type }}--example-${{ matrix.example }}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ yarn add -D nx-mesh

### Peer Dependencies

| Name | Version | Required | Auto-installed by generators |
| --------------------- | ------------- | :------: | :--------------------------: |
| `nx` | `>= 14 <= 16` || - |
| `@graphql-mesh/cli` | `>=0.71.0` |||
| `@graphql-codgen/cli` | `>=2.16.1` |||
| Name | Version | Required | Auto-installed by generators |
| --------------------- | ---------- | :------: | :--------------------------: |
| `nx` | `>=15.4.1` || - |
| `@graphql-mesh/cli` | `>=0.71.0` |||
| `@graphql-codgen/cli` | `>=2.16.1` |||

<br/>

Expand Down
14 changes: 7 additions & 7 deletions libs/nx-mesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
}
},
"dependencies": {
"@nrwl/cypress": "15.4.1",
"@nrwl/devkit": "15.4.1",
"@nrwl/js": "15.4.1",
"@nrwl/linter": "15.4.1",
"@nrwl/node": "15.4.1",
"@nrwl/workspace": "15.4.1",
"@nrwl/cypress": "^15.4.1",
"@nrwl/devkit": "^15.4.1",
"@nrwl/js": "^15.4.1",
"@nrwl/linter": "^15.4.1",
"@nrwl/node": "^15.4.1",
"@nrwl/workspace": "^15.4.1",
"fs-extra": "^10.1.0",
"get-port": "5.1.1",
"tslib": "2.4.0",
"tslib": "^2.4.0",
"type-fest": "^2.18.0"
},
"keywords": [
Expand Down
42 changes: 28 additions & 14 deletions libs/nx-mesh/src/generators/base/__snapshots__/base.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,8 @@ exports[`generators/base app directory --linter should use eslint for linting 1`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -1811,7 +1812,8 @@ exports[`generators/base app directory --linter should use eslint for linting 2`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -1849,7 +1851,8 @@ exports[`generators/base app directory --linter should use eslint for linting 3`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -1887,7 +1890,8 @@ exports[`generators/base app directory --linter should use eslint for linting 4`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -1925,7 +1929,8 @@ exports[`generators/base app directory --linter should use eslint for linting 5`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -2904,7 +2909,8 @@ exports[`generators/base app with standalone config --linter should use eslint f
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -4910,7 +4916,8 @@ exports[`generators/base lib directory --linter should use eslint for linting 1`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -4948,7 +4955,8 @@ exports[`generators/base lib directory --linter should use eslint for linting 2`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -4986,7 +4994,8 @@ exports[`generators/base lib directory --linter should use eslint for linting 3`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -5024,7 +5033,8 @@ exports[`generators/base lib directory --linter should use eslint for linting 4`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -5062,7 +5072,8 @@ exports[`generators/base lib directory --linter should use eslint for linting 5`
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -6126,7 +6137,8 @@ exports[`generators/base lib with standalone config --linter should use eslint f
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -6651,7 +6663,8 @@ exports[`generators/base nested within app directory --linter should use eslint
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down Expand Up @@ -7173,7 +7186,8 @@ exports[`generators/base nested within lib directory --linter should use eslint
],
\\"ignorePatterns\\": [
\\"!**/*\\",
\\".mesh\\"
\\".mesh\\",
\\".codegen\\"
],
\\"overrides\\": [
{
Expand Down
Loading

0 comments on commit bdb85d1

Please sign in to comment.