Skip to content

Commit

Permalink
feat!: generate query options and support nested keys
Browse files Browse the repository at this point in the history
* refactor!: remove deprecated `default` and `toScope`

BREAKING CHANGE: `default` key and `toScope` method have been removed from the package

* feat!: add support for nested keys

BREAKING CHANGE: All intended query key returned values should be an array, returned objects are now used for the nested keys feature

* feat: generate query schema

* refactor!: make query options format a first class citizen

* test: write tests for new implementation

* chore: switch to pnpm

* build: switch from rollup to tsup

* test(`merge-query-keys`): improve tests and assert types

* test(`create-query-key-store`): improve tests and assert types

* ci: improve release pipeline
  • Loading branch information
lukemorales authored Oct 10, 2022
1 parent 14b3948 commit ba47907
Show file tree
Hide file tree
Showing 26 changed files with 6,064 additions and 5,006 deletions.
7 changes: 7 additions & 0 deletions .changeset/olive-zoos-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@lukemorales/query-key-factory': major
---

Generate query options and add support for nested keys

BREAKING CHANGE: All intended query key returned values should now be an array. Object returns are now used to declare query key, query fn and/or nested keys.
7 changes: 7 additions & 0 deletions .changeset/slimy-books-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@lukemorales/query-key-factory': major
---

Remove deprecated `default` and `toScope` methods

BREAKING CHANGE: `default` key and `toScope` method have been removed from the package.
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
}],
"no-shadow": "off",
"prefer-template": "error",
"@typescript-eslint/array-type": [
"warn",
{ "default": "array-simple", "readonly": "array-simple" }
],
"@typescript-eslint/ban-types": [
"error",
{
Expand Down
10 changes: 5 additions & 5 deletions .github/changeset-version.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// ORIGINALLY FROM CLOUDFLARE WRANGLER:
// https://github.com/cloudflare/wrangler2/blob/main/.github/changeset-version.js

const {exec} = require('child_process');
const { exec } = require('child_process');
// This script is used by the `release.yml` workflow to update the version of the packages being released.
// The standard step is only to run `changeset version` but this does not update the package-lock.json file.
// So we also run `npm install`, which does this update.
// The standard step is only to run `changeset version` but this does not update the pnpm-lock.yaml file.
// So we also run `pnpm install`, which does this update.
// This is a workaround until this is handled automatically by `changeset version`.
// See https://github.com/changesets/changesets/issues/421.
exec("yarn changeset version");
exec("yarn install");
exec("pnpm run changeset version");
exec("pnpm install --lockfile-only");
136 changes: 109 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,149 @@
name: CI
name: ci

on:
pull_request:
branches: ["*"]
on: [pull_request]

jobs:
lint-title:
runs-on: ubuntu-latest
name: 🚨 Lint Pull Request title
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

install-deps:
runs-on: ubuntu-latest
name: Install dependencies 🔧
name: 📦 Install dependencies
steps:
- name: Checkout Repository
- name: 🔑 Checkout Repository
uses: actions/checkout@v3

- uses: actions/cache@v3
id: yarn-cache
- name: 🔧 Install PNPM
uses: pnpm/[email protected]
with:
version: 7

- name: ♻️ Cache node_modules
uses: actions/cache@v3
id: pnpm-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Node and install project dependencies
- name: 🛠️ Setup Node and install project dependencies
uses: actions/setup-node@v3
with:
node-version: '14'
check-latest: true
cache: 'yarn'
cache: 'pnpm'

if: steps.yarn-cache.outputs.cache-hit != 'true'
- run: yarn install --frozen-lockfile
if: steps.pnpm-cache.outputs.cache-hit != 'true'
- run: pnpm install --prefer-offline

lint:
lint-package:
runs-on: ubuntu-latest
name: Check for errors 🚨
name: 🚨 Check for errors
needs: install-deps
steps:
- uses: actions/checkout@v3
- name: Load node_modules
- name: 🔑 Checkout Repository
uses: actions/checkout@v3

- name: 🔧 Install PNPM
uses: pnpm/[email protected]
with:
version: 7

- name: ♻️ Restore node_modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Restore ESLint Cache
- name: ♻️ Restore ESLint Cache
uses: actions/cache@v3
id: eslint-cache
with:
path: .eslintcache
key: ${{ matrix.os }}-eslint-${{ hashFiles('**/*.ts', 'package.json', 'tsconfig.json') }}

- name: 🛠️ Setup Node
uses: actions/setup-node@v3
with:
node-version: '14'
check-latest: true
cache: 'pnpm'

- name: 📦 Install dependencies
if: steps.pnpm-cache.outputs.cache-hit != 'true'
run: pnpm install --prefer-offline

- name: 🚨 Lint files
run: pnpm run lint

tests:
name: 🧪 Test package
runs-on: ubuntu-latest
needs: install-deps
steps:
- name: 🔑 Checkout Repository
uses: actions/checkout@v3

- name: 🔧 Install PNPM
uses: pnpm/[email protected]
with:
version: 7

- uses: actions/setup-node@v3
- name: ♻️ Restore node_modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: 🛠️ Setup Node
uses: actions/setup-node@v3
with:
node-version: '14'
check-latest: true
cache: 'yarn'
- run: yarn lint
cache: 'pnpm'

- name: 📦 Install dependencies
if: steps.pnpm-cache.outputs.cache-hit != 'true'
run: pnpm install --prefer-offline

lint-pr:
- name: 🧪 Run tests
run: pnpm run test:ci

build:
name: 🏗️ Build package
runs-on: ubuntu-latest
name: Lint the Pull Request Title 🚨
needs: install-deps
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔑 Checkout Repository
uses: actions/checkout@v3

- name: 🔧 Install PNPM
uses: pnpm/[email protected]
with:
version: 7

- name: ♻️ Load node_modules
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: 🛠️ Setup Node
uses: actions/setup-node@v3
with:
node-version: '14'
check-latest: true
cache: 'pnpm'

- name: 📦 Install dependencies
if: steps.pnpm-cache.outputs.cache-hit != 'true'
run: pnpm install --prefer-offline

- name: 🏗️ Build package
run: pnpm run build
Loading

0 comments on commit ba47907

Please sign in to comment.