Skip to content

Commit

Permalink
Merge pull request #120 from CyCraft/esm
Browse files Browse the repository at this point in the history
Esm
  • Loading branch information
mesqueeb authored May 31, 2024
2 parents 7436970 + 6c5cbb3 commit c4d302e
Show file tree
Hide file tree
Showing 293 changed files with 5,828 additions and 14,735 deletions.
12 changes: 0 additions & 12 deletions .prettierrc

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import prettier from "@cycraft/eslint/prettier"

export default prettier
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"editor.insertSpaces": true,
// gitlens
"gitlens.defaultTimeFormat": "HH:mm",
"gitlens.codeLens.enabled": false
"gitlens.codeLens.enabled": false,
// auto import with .js extension
"javascript.preferences.importModuleSpecifierEnding": "js",
"typescript.preferences.importModuleSpecifierEnding": "js"
}
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## v1.0.0

##### ESM Only & Node v18+

- Magnetar is now ESM only. This means you need to use `import` instead of `require`.
- Magnetar now requires Node v18+.
- `@magnetarjs/plugin-vue2` was removed.

## v0.4.0

##### breaking changes
Expand All @@ -20,7 +28,7 @@ firebase.initializeApp({
})

// initialise PluginFirestore
import { PluginFirestore } from 'magnetar'
import { CreatePlugin as PluginFirestore } from '@magnetarjs/plugin-firestore'

const remote = PluginFirestore.CreatePlugin({ firebaseInstance: firebase })
```
Expand All @@ -38,7 +46,7 @@ const firebaseApp = initializeApp({
const db = getFirestore(firebaseApp)

// initialise PluginFirestore
import { PluginFirestore } from 'magnetar'
import { CreatePlugin as PluginFirestore } from '@magnetarjs/plugin-firestore'

const remote = PluginFirestore.CreatePlugin({ db })
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs-main/hooks-and-events/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function addUpdatedAt(payload) {
And then in the file(s) you define your modules:

```js
import { addCreatedAt, addUpdatedAt } from './helpers'
import { addCreatedAt, addUpdatedAt } from './helpers/index.js'

const pokedexModule = magnetar.collection('pokedex', {
modifyPayloadOn: {
Expand Down
27 changes: 3 additions & 24 deletions docs/docs-main/plugins/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Example setup:

<!-- prettier-ignore-start -->
```js
import { PluginFirestore } from 'magnetar'
import { PluginFirestore } from '@magnetarjs/plugin-firestore'
import { initializeApp } from 'firebase/app'
import { getFirestore } from 'firebase/firestore'

Expand Down Expand Up @@ -67,7 +67,7 @@ Use the Vue 3 plugin for Vue 3 projects.
Example setup:

```js
import { PluginVue3 } from 'magnetar'
import { CreatePlugin as PluginVue3 } from '@magnetarjs/plugin-vue3'

function generateRandomId() {
return [Math.random(), Math.random(), Math.random()].join('-')
Expand All @@ -78,27 +78,6 @@ function generateRandomId() {
const local = PluginVue3.CreatePlugin({ generateRandomId })
```

## Vue 2

> documentation WIP
Use the Vue 2 plugin for Vue 2 projects.

Example setup:

```js
import { CreatePlugin as CreatePluginVue2 } from '@magnetarjs/plugin-vue2'
import vue from 'vue'

function generateRandomId() {
return [Math.random(), Math.random(), Math.random()].join('-')
// you need to provide your own logic
// this function is used when you execute `insert` without specifying an ID
}

const local = CreatePluginVue2({ vueInstance: vue, generateRandomId })
```

## Simple Store

> documentation WIP
Expand All @@ -108,7 +87,7 @@ The Simple Store has no built-in reactivity. Good for a lightweight solution in
Example setup:

```js
import { PluginSimpleStore } from 'magnetar'
import { CreatePlugin as PluginSimpleStore } from '@magnetarjs/plugin-simple-store'

function generateRandomId() {
return [Math.random(), Math.random(), Math.random()].join('-')
Expand Down
5 changes: 4 additions & 1 deletion docs/docs-main/setup/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ This is a complete setup example which uses:
```javascript
import { initializeApp } from 'firebase/app'
import { getFirestore, collection, doc } from 'firebase/firestore'
import { PluginFirestore, PluginVue3, Magnetar, logger } from 'magnetar'
import { Magnetar } from '@magnetarjs/core'
import { CreatePlugin as PluginFirestore } from '@magnetarjs/plugin-firestore'
import { CreatePlugin as PluginVue3 } from '@magnetarjs/plugin-vue3'
import { logger } from '@magnetarjs/utils'
// ---------------------------------------------
// 0. Initialise firebase
// ---------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import config from '@cycraft/eslint/config'

export default [
{
ignores: ['**/dist/*'],
},
...config,
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
},
]
99 changes: 32 additions & 67 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,69 @@
{
"name": "magnetar-monorepo",
"private": true,
"version": "1.0.1",
"type": "module",
"workspaces": [
"packages/*"
],
"scripts": {
"dev:nuxt-firestore": "pnpm --filter dev-nuxt-firestore dev",
"dev:vue3-firestore": "pnpm --filter dev-vue3-firestore dev",
"dev:ui": "pnpm --filter @magnetarjs/ui dev",
"dep:del-all": "npm exec --workspaces -- npx rimraf node_modules && npx rimraf node_modules",
"dep:del-all": "npm exec --workspaces -- del-cli node_modules && del-cli node_modules",
"dep:update-minor": "ncu --target minor -u && pnpm --parallel exec ncu --target minor -u && echo \"review git changes and install with ni\"",
"dep:update-major": "ncu -u && pnpm --parallel exec ncu -u && echo \"review git changes and install with ni\"",
"dep:update-major": "ncu -ws -u && echo \"review git changes and install with ni\"",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:deploy": "pnpm docs:build && firebase deploy --only hosting && git add -A && git commit -m \"chore: deploy\"",
"docs:serve": "vitepress serve docs",
"build": "pnpm -r build",
"build": "turbo run build",
"typecheck": "turbo run typecheck",
"build-and-commit": "npm run build && git add -A && git commit -m \"chore: build\"",
"build:nuxt-firestore": "pnpm --filter dev-nuxt-firestore build",
"generate:nuxt-firestore": "pnpm --filter dev-nuxt-firestore generate",
"preview:nuxt-firestore": "pnpm --filter dev-nuxt-firestore preview",
"test": "pnpm test:core && pnpm test:plugin-simple-store && pnpm test:plugin-vue2 && pnpm test:plugin-vue3 && pnpm test:plugin-firestore",
"_test:admin-broken": "pnpm test:core && pnpm test:plugin-simple-store && pnpm test:plugin-vue2 && pnpm test:plugin-vue3 && pnpm test:plugin-firestore-admin",
"test": "turbo run test",
"_test:admin-broken": "pnpm test:core && pnpm test:plugin-simple-store && pnpm test:plugin-vue3 && pnpm test:plugin-firestore-admin",
"test:core": "pnpm --filter=@magnetarjs/core test",
"test:plugin-firestore": "pnpm --filter=@magnetarjs/plugin-firestore test",
"test:plugin-firestore-admin": "pnpm --filter=@magnetarjs/plugin-firestore-admin test",
"test:plugin-firestore:only": "pnpm --filter=@magnetarjs/plugin-firestore run test:only",
"test:plugin-simple-store": "pnpm --filter=@magnetarjs/plugin-simple-store test",
"test:plugin-vue2": "pnpm --filter=@magnetarjs/plugin-vue2 test",
"test:plugin-vue3": "pnpm --filter=@magnetarjs/plugin-vue3 test",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"prettier:run": "prettier --write \"packages/*/src/**/*.{vue,ts}\" && prettier --write \"docs/**/*.{vue,ts,md}\"",
"lint": "eslint",
"release": "pnpm build && bumpp package.json packages/*/package.json --commit --push --tag && pnpm -r publish --access public"
},
"devDependencies": {
"@types/node": "^18.19.33",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@cycraft/eslint": "^0.3.0",
"@cycraft/run-ts": "^0.0.0",
"@cycraft/tsconfig": "^0.1.2",
"@magnetarjs/core": "workspace:*",
"@magnetarjs/plugin-firestore": "workspace:*",
"@magnetarjs/plugin-vue3": "workspace:*",
"@magnetarjs/test-utils": "workspace:*",
"@vitejs/plugin-vue": "^5.0.5",
"@vue/typescript": "^1.8.20",
"ava": "^4.3.3",
"bumpp": "^8.2.1",
"array-shuffle": "^3.0.0",
"browser-env": "^3.3.0",
"bumpp": "^9.4.1",
"copyfiles": "^2.4.1",
"del-cli": "^5.1.0",
"esbuild": "^0.21.4",
"esbuild-register": "^3.5.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-tree-shaking": "^1.12.1",
"exec-sh": "^0.4.0",
"execa": "^9.1.0",
"firebase": "^10.12.2",
"firebase-admin": "^12.1.1",
"npm-check-updates": "^16.14.20",
"prettier": "^2.8.8",
"prettier-plugin-organize-imports": "^3.2.4",
"rimraf": "^3.0.2",
"tslib": "^2.6.2",
"tsup": "^6.7.0",
"roll-anything": "^3.0.4",
"sass": "^1.77.4",
"tsup": "^8.0.2",
"turbo": "^1.13.3",
"typescript": "^5.4.5",
"vitepress": "1.2.2"
"vite": "^5.2.12",
"vitepress": "1.2.2",
"vitest": "^1.6.0",
"vue": "^3.4.27",
"vue-tsc": "^2.0.19"
},
"author": "Luca Ban - Mesqueeb",
"funding": "https://github.com/sponsors/mesqueeb",
Expand All @@ -70,50 +77,8 @@
"url": "git+https://github.com/cycraft/magnetar.git"
},
"engines": {
"node": ">= 14.0.0",
"npm": ">= 7.8.0"
"node": ">=18"
},
"eslintConfig": {
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"tree-shaking"
],
"ignorePatterns": [
"node_modules",
"dist",
"/packages/dev-nuxt-firestore",
"/packages/dev-firestore",
"/packages/dev-vue2",
"/packages/dev-vue2-firestore",
"/packages/dev-vue3",
"/packages/dev-vue3-firestore",
"/packages/docs",
"/packages/ui",
"test"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"tree-shaking/no-side-effects-in-initialization": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"comma-dangle": [
"warn",
"always-multiline"
],
"@typescript-eslint/ban-ts-comment": "warn"
}
},
"version": "0.20.1",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
Expand Down
36 changes: 10 additions & 26 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
{
"name": "@magnetarjs/core",
"version": "0.20.1",
"version": "1.0.1",
"type": "module",
"sideEffects": false,
"description": "Magnetar core library.",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"default": "./dist/index.js"
}
".": "./dist/index.js"
},
"engines": {
"node": ">=18"
},
"files": [
"dist"
],
"scripts": {
"typecheck": "tsc --noEmit",
"build": "tsup src/index.ts --clean --format esm,cjs --dts",
"build": "del-cli dist && tsc",
"dev": "pnpm build --watch",
"test-and-build": "npm run test && npm run build",
"test": "ava",
"test--only": "ava --match='*only:*'"
"test": "vitest run"
},
"author": "Luca Ban - Mesqueeb",
"funding": "https://github.com/sponsors/mesqueeb",
Expand All @@ -30,13 +26,10 @@
"dependencies": {
"@magnetarjs/types": "workspace:*",
"@magnetarjs/utils": "workspace:*",
"getorset-anything": "^0.0.5",
"is-what": "^4.1.16",
"getorset-anything": "^0.1.0",
"is-what": "^5.0.0",
"merge-anything": "^5.1.7"
},
"devDependencies": {
"@magnetarjs/test-utils": "workspace:*"
},
"keywords": [
"vuex-easy-firestore",
"magnetar",
Expand Down Expand Up @@ -68,14 +61,5 @@
},
"bugs": {
"url": "https://github.com/cycraft/magnetar/issues"
},
"ava": {
"extensions": [
"ts"
],
"require": [
"esbuild-register"
],
"timeout": "60s"
}
}
Loading

0 comments on commit c4d302e

Please sign in to comment.