Skip to content

Commit

Permalink
chore: setup npm workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnowack committed Dec 4, 2023
1 parent 8bca29d commit 3af825b
Show file tree
Hide file tree
Showing 83 changed files with 3,045 additions and 6,751 deletions.
32 changes: 32 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs')
const path = require('path')
const fg = require('fast-glob')
const { workspaces } = require('./package.json')

const projectDirs = workspaces
.flatMap(pattern => fg.sync(pattern, { onlyDirectories: true }))
.filter(projectPath => fs.existsSync(path.join(__dirname, projectPath, 'package.json')))

module.exports = {
extends: [
'airbnb-base',
Expand Down Expand Up @@ -43,6 +53,26 @@ module.exports = {
commonjs: true,
node: true,
},
overrides: [
// https://github.com/import-js/eslint-plugin-import/issues/1913#issuecomment-1034025709
...projectDirs.map(projectDir => ({
files: [`${projectDir}/**/*.{t,j}s`],
rules: {
'import/no-extraneous-dependencies': ['error', {
devDependencies: [
'.eslintrc.js',
'**/*.test.ts',
'**/*.spec.ts',
'__tests__/**/*.ts',
'*.config.ts',
'docs/.vitepress/config.ts',
'**/vite.config.ts',
],
packageDir: [__dirname, path.join(__dirname, projectDir)],
}],
},
})),
],
rules: {
/*
* Typescript
Expand Down Expand Up @@ -100,11 +130,13 @@ module.exports = {
}],
'import/no-extraneous-dependencies': ['error', {
devDependencies: [
'.eslintrc.js',
'**/*.test.ts',
'**/*.spec.ts',
'__tests__/**/*.ts',
'*.config.ts',
'docs/.vitepress/config.ts',
'vite.config.ts',
],
}],
'arrow-parens': ['error', 'as-needed', {
Expand Down
49 changes: 12 additions & 37 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -30,21 +30,13 @@ jobs:
continue-on-error: true
with:
path: |
node_modules
examples/rxdb/node_modules
examples/firebase/node_modules
examples/appwrite/node_modules
examples/supabase/node_modules
**/node_modules
key: ${{ runner.OS }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-modules-${{ matrix.node-version }}-
- name: install modules
run: |
npm install --no-audit --force --loglevel=error --no-update-notifier
(cd examples/rxdb && npm install --no-audit --force --loglevel=error --no-update-notifier)
(cd examples/firebase && npm install --no-audit --force --loglevel=error --no-update-notifier)
(cd examples/appwrite && npm install --no-audit --force --loglevel=error --no-update-notifier)
(cd examples/supabase && npm install --no-audit --force --loglevel=error --no-update-notifier)
linting:
needs: preflight
Expand All @@ -62,14 +54,11 @@ jobs:
with:
fail-on-cache-miss: true
path: |
node_modules
examples/rxdb/node_modules
examples/firebase/node_modules
examples/appwrite/node_modules
examples/supabase/node_modules
**/node_modules
key: ${{ runner.OS }}-modules-20.x-${{ hashFiles('**/package-lock.json') }}
- name: linting
run: |
npm run build
npm run lint
typecheck:
Expand All @@ -88,22 +77,19 @@ jobs:
with:
fail-on-cache-miss: true
path: |
node_modules
examples/rxdb/node_modules
examples/firebase/node_modules
examples/appwrite/node_modules
examples/supabase/node_modules
**/node_modules
key: ${{ runner.OS }}-modules-20.x-${{ hashFiles('**/package-lock.json') }}
- name: typecheck
run: |
npm run build
npm run type-check
unit-tests:
needs: preflight
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -117,14 +103,11 @@ jobs:
with:
fail-on-cache-miss: true
path: |
node_modules
examples/rxdb/node_modules
examples/firebase/node_modules
examples/appwrite/node_modules
examples/supabase/node_modules
**/node_modules
key: ${{ runner.OS }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: unit testing
run: |
npm run build
npm test -- --coverage run
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand All @@ -136,7 +119,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -150,11 +133,7 @@ jobs:
with:
fail-on-cache-miss: true
path: |
node_modules
examples/rxdb/node_modules
examples/firebase/node_modules
examples/appwrite/node_modules
examples/supabase/node_modules
**/node_modules
key: ${{ runner.OS }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: build package
run: |
Expand All @@ -176,11 +155,7 @@ jobs:
with:
fail-on-cache-miss: true
path: |
node_modules
examples/rxdb/node_modules
examples/firebase/node_modules
examples/appwrite/node_modules
examples/supabase/node_modules
**/node_modules
key: ${{ runner.OS }}-modules-20.x-${{ hashFiles('**/package-lock.json') }}
- name: build docs
run: |
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,13 @@ jobs:
continue-on-error: true
with:
path: |
node_modules
examples/rxdb/node_modules
examples/firebase/node_modules
examples/appwrite/node_modules
examples/supabase/node_modules
**/node_modules
key: ${{ runner.OS }}-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-modules-
- name: install modules
run: |
npm install --no-audit --force --loglevel=error --no-update-notifier
(cd examples/rxdb && npm install --no-audit --force --loglevel=error --no-update-notifier)
(cd examples/firebase && npm install --no-audit --force --loglevel=error --no-update-notifier)
(cd examples/appwrite && npm install --no-audit --force --loglevel=error --no-update-notifier)
(cd examples/supabase && npm install --no-audit --force --loglevel=error --no-update-notifier)
- name: Build vitepress
run: npm run docs:build
- name: Upload artifact
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Collection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vi, beforeEach, describe, it, expect } from 'vitest'
import { Collection, createMemoryAdapter, createIndex } from '../src/index'
import { Collection, createMemoryAdapter, createIndex } from 'signaldb'

describe('Collection', () => {
let collection: Collection<{ id: string, name: string }>
Expand Down
4 changes: 2 additions & 2 deletions __tests__/Cursor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi, describe, it, expect } from 'vitest'
import type { ObserveCallbacks, Transform } from '../src/index'
import { Collection } from '../src/index'
import type { ObserveCallbacks, Transform } from 'signaldb'
import { Collection } from 'signaldb'

// Helper function to wait for async operations
const wait = () => new Promise((resolve) => { setImmediate(resolve) })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/PersistentCollection.client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @vitest-environment happy-dom
import { describe, it, expect } from 'vitest'
import { PersistentCollection } from '../src/index'
import waitForEvent from '../src/utils/waitForEvent'
import { PersistentCollection } from 'signaldb'
import waitForEvent from './helpers/waitForEvent'

describe('PersistentCollection', () => {
it('should create a persistent collection on the clientside', async () => {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/PersistentCollection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs'
import { describe, it, expect } from 'vitest'
import { PersistentCollection } from '../src/index'
import waitForEvent from '../src/utils/waitForEvent'
import { PersistentCollection } from 'signaldb'
import waitForEvent from './helpers/waitForEvent'

describe('PersistentCollection', () => {
it('should create a persistent collection on the serverside', async () => {
Expand Down
10 changes: 5 additions & 5 deletions __tests__/Queries.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { Collection } from '../src/index'
import { Collection } from 'signaldb'

describe('Queries', () => {
// thanks to https://github.com/meteor/meteor/blob/devel/packages/minimongo/minimongo_tests_client.js
Expand All @@ -17,7 +17,7 @@ describe('Queries', () => {
expect(c.find({ type: 'cryptographer' }).count()).toBe(3)
expect(c.find({ type: 'kitten' }).fetch().length).toBe(2)
expect(c.find({ type: 'cryptographer' }).fetch().length).toBe(3)
expect(fluffyKittenId).toBe(c.findOne({ type: 'kitten', name: 'fluffy' }).id)
expect(fluffyKittenId).toBe(c.findOne({ type: 'kitten', name: 'fluffy' })?.id)

c.removeMany({ name: 'cara' })
expect(c.find().count()).toBe(4)
Expand Down Expand Up @@ -67,9 +67,9 @@ describe('Queries', () => {
expect(c.find({ tags: 'fruit' }).fetch().length).toBe(2)
expect(c.find({ tags: 'red' }).fetch().length).toBe(3)

expect(c.findOne({ id: 1 }).name).toBe('strawberry')
expect(c.findOne({ id: 2 }).name).toBe('apple')
expect(c.findOne({ id: 3 }).name).toBe('rose')
expect(c.findOne({ id: 1 })?.name).toBe('strawberry')
expect(c.findOne({ id: 2 })?.name).toBe('apple')
expect(c.findOne({ id: 3 })?.name).toBe('rose')
expect(c.findOne({ id: 4 })).toBeUndefined()
expect(c.findOne({ id: 'abc' })).toBeUndefined()
expect(c.findOne({ id: undefined })).toBeUndefined()
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions __tests__/persistence.client.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @vitest-environment happy-dom
import { describe, it, expect } from 'vitest'
import { Collection, createLocalStorageAdapter } from '../src/index'
import waitForEvent from '../src/utils/waitForEvent'
import { Collection, createLocalStorageAdapter } from 'signaldb'
import waitForEvent from './helpers/waitForEvent'

const persistence = createLocalStorageAdapter('test')

Expand Down
6 changes: 3 additions & 3 deletions __tests__/persistence.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs/promises'
import { describe, it, expect, vi } from 'vitest'
import type { PersistenceAdapter } from '../src/index'
import { Collection, createFilesystemAdapter } from '../src/index'
import waitForEvent from '../src/utils/waitForEvent'
import type { PersistenceAdapter } from 'signaldb'
import { Collection, createFilesystemAdapter } from 'signaldb'
import waitForEvent from './helpers/waitForEvent'

// eslint-disable-next-line max-len
function memoryPersistenceAdapter<T extends { id: I } & Record<string, any>, I = any>(
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/maverick-js.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getScope,
onDispose,
} from '@maverick-js/signals'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('@maverick-js/signals', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/mobx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
runInAction,
onBecomeUnobserved,
} from 'mobx'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('MobX', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/oby.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import $oby, {
owner,
tick,
} from 'oby'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('oby', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/preact.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi, describe, it, expect } from 'vitest'
import { signal, effect } from '@preact/signals-core'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('preact', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/reactively.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi, describe, it, expect } from 'vitest'
import { reactive, onCleanup } from '@reactively/core'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('@reactively/core', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/s-js.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi, describe, it, expect } from 'vitest'
import S from 's-js'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('S.js', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/sinuous.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
observable,
api,
} from 'sinuous'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('sinuous', () => {
const reactivity = createReactivityAdapter({
Expand Down
4 changes: 3 additions & 1 deletion __tests__/reactivity/solid-js.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {
createEffect,
onCleanup,
createRoot,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
} from 'solid-js/dist/solid'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('solid', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/tracker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi, describe, it, expect } from 'vitest'
import { Tracker } from 'meteor-ts-tracker'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('Tracker', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/usignal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
signal,
effect,
} from 'usignal'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('usignal', () => {
const reactivity = createReactivityAdapter({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/reactivity/vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
nextTick as vueNextTick,
effectScope as vueEffectScope,
} from 'vue'
import { Collection, createReactivityAdapter } from '../../src/index'
import { Collection, createReactivityAdapter } from 'signaldb'

describe('Vue.js', () => {
const reactivity = createReactivityAdapter({
Expand Down
Loading

0 comments on commit 3af825b

Please sign in to comment.