From 9e1ce7dda00a9a6a3c3d93ed522bdc421599fb10 Mon Sep 17 00:00:00 2001 From: Brandon Bayer Date: Wed, 15 Apr 2020 16:35:47 +0700 Subject: [PATCH] Add the `blitz` package (#125) --- .../store/app/admin/pages/admin/index.tsx | 2 +- .../app/admin/pages/admin/products/[id].tsx | 2 +- .../app/admin/pages/admin/products/index.tsx | 2 +- .../app/admin/pages/admin/products/new.tsx | 2 +- examples/store/app/pages/index.tsx | 2 +- .../app/products/pages/products/[handle].tsx | 2 +- .../app/products/pages/products/index.tsx | 2 +- examples/store/next.config.js | 2 +- examples/store/package.json | 4 +- package.json | 8 +-- packages/blitz/.gitignore | 8 +++ packages/blitz/jest.setup.js | 1 + packages/blitz/package.json | 56 +++++++++++++++++++ packages/blitz/src/index.ts | 2 + packages/blitz/src/utils/index.ts | 1 + packages/blitz/test/todo.test.ts | 3 + packages/blitz/tsconfig.json | 13 +++++ packages/blitz/tsdx.config.js | 6 ++ packages/blitz/types/index.d.ts | 1 + 19 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 packages/blitz/.gitignore create mode 100644 packages/blitz/jest.setup.js create mode 100644 packages/blitz/package.json create mode 100644 packages/blitz/src/index.ts create mode 100644 packages/blitz/src/utils/index.ts create mode 100644 packages/blitz/test/todo.test.ts create mode 100644 packages/blitz/tsconfig.json create mode 100644 packages/blitz/tsdx.config.js create mode 100644 packages/blitz/types/index.d.ts diff --git a/examples/store/app/admin/pages/admin/index.tsx b/examples/store/app/admin/pages/admin/index.tsx index ac687b5eeb..c786da452f 100644 --- a/examples/store/app/admin/pages/admin/index.tsx +++ b/examples/store/app/admin/pages/admin/index.tsx @@ -1,4 +1,4 @@ -import {Link} from '@blitzjs/core' +import {Link} from 'blitz' export default function () { return ( diff --git a/examples/store/app/admin/pages/admin/products/[id].tsx b/examples/store/app/admin/pages/admin/products/[id].tsx index 20d0b728e9..954171b6e3 100644 --- a/examples/store/app/admin/pages/admin/products/[id].tsx +++ b/examples/store/app/admin/pages/admin/products/[id].tsx @@ -1,5 +1,5 @@ import {Suspense} from 'react' -import {Link, useRouter, useQuery} from '@blitzjs/core' +import {Link, useRouter, useQuery} from 'blitz' import getProduct from 'app/products/queries/getProduct' import ProductForm from 'app/products/components/ProductForm' diff --git a/examples/store/app/admin/pages/admin/products/index.tsx b/examples/store/app/admin/pages/admin/products/index.tsx index ebe62b1e98..69cbe9f39c 100644 --- a/examples/store/app/admin/pages/admin/products/index.tsx +++ b/examples/store/app/admin/pages/admin/products/index.tsx @@ -1,5 +1,5 @@ import {Suspense} from 'react' -import {useQuery, Link} from '@blitzjs/core' +import {useQuery, Link} from 'blitz' import getProducts from 'app/products/queries/getProducts' function ProductsList() { diff --git a/examples/store/app/admin/pages/admin/products/new.tsx b/examples/store/app/admin/pages/admin/products/new.tsx index 776b2f3ceb..415248774f 100644 --- a/examples/store/app/admin/pages/admin/products/new.tsx +++ b/examples/store/app/admin/pages/admin/products/new.tsx @@ -1,4 +1,4 @@ -import {Link, useRouter} from '@blitzjs/core' +import {Link, useRouter} from 'blitz' import ProductForm from 'app/products/components/ProductForm' export default function () { diff --git a/examples/store/app/pages/index.tsx b/examples/store/app/pages/index.tsx index 64fcca8fbf..1dbfd4a5de 100644 --- a/examples/store/app/pages/index.tsx +++ b/examples/store/app/pages/index.tsx @@ -1,5 +1,5 @@ import Head from 'next/head' -import {Link} from '@blitzjs/core' +import {Link} from 'blitz' const Home = () => (
diff --git a/examples/store/app/products/pages/products/[handle].tsx b/examples/store/app/products/pages/products/[handle].tsx index 8e7c383dd4..58251d5671 100644 --- a/examples/store/app/products/pages/products/[handle].tsx +++ b/examples/store/app/products/pages/products/[handle].tsx @@ -1,4 +1,4 @@ -import {Link, BlitzPage, GetStaticProps, GetStaticPaths} from '@blitzjs/core' +import {Link, BlitzPage, GetStaticProps, GetStaticPaths} from 'blitz' import getProduct from 'app/products/queries/getProduct' import getProducts from 'app/products/queries/getProducts' import {Product} from 'db' diff --git a/examples/store/app/products/pages/products/index.tsx b/examples/store/app/products/pages/products/index.tsx index 1a1555960d..bb91928a98 100644 --- a/examples/store/app/products/pages/products/index.tsx +++ b/examples/store/app/products/pages/products/index.tsx @@ -1,4 +1,4 @@ -import {Link, BlitzPage, GetStaticProps} from '@blitzjs/core' +import {Link, BlitzPage, GetStaticProps} from 'blitz' import getProducts from 'app/products/queries/getProducts' import {Product} from 'db' diff --git a/examples/store/next.config.js b/examples/store/next.config.js index 6a2db259c7..ea31f97124 100644 --- a/examples/store/next.config.js +++ b/examples/store/next.config.js @@ -1,3 +1,3 @@ -const {withBlitz} = require('@blitzjs/server') +const {withBlitz} = require('blitz') module.exports = withBlitz({}) diff --git a/examples/store/package.json b/examples/store/package.json index 8261a33f88..189bcfc989 100644 --- a/examples/store/package.json +++ b/examples/store/package.json @@ -6,9 +6,7 @@ "build": "blitz db migrate && blitz build" }, "dependencies": { - "@blitzjs/cli": "0.0.2-canary.0", - "@blitzjs/core": "0.0.2-canary.0", - "@blitzjs/server": "0.0.2-canary.0", + "blitz": "0.0.2-canary.0", "@prisma/cli": "2.0.0-beta.2", "@prisma/client": "2.0.0-beta.2", "final-form": "4.19.1", diff --git a/package.json b/package.json index 5238ac2ce6..b66719a05f 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,11 @@ "node": ">=12.16.1" }, "scripts": { - "dev": "lerna run start --scope @blitzjs/* --stream --parallel", + "dev": "lerna run start --scope blitz --scope @blitzjs/* --stream --parallel", "postinstall": "npm rebuild husky", - "build": "lerna run build --scope @blitzjs/* --stream", - "prepublishOnly": "lerna run build --scope @blitzjs/* && lerna run test --parallel", - "pretest": "lerna run build --scope @blitzjs/*", + "build": "lerna run build --scope blitz --scope @blitzjs/* --stream", + "prepublishOnly": "lerna run build --scope blitz --scope @blitzjs/* && lerna run test --parallel", + "pretest": "lerna run build --scope blitz --scope @blitzjs/*", "test": "lerna run test --parallel" }, "devDependencies": { diff --git a/packages/blitz/.gitignore b/packages/blitz/.gitignore new file mode 100644 index 0000000000..ff88468482 --- /dev/null +++ b/packages/blitz/.gitignore @@ -0,0 +1,8 @@ +*.log +.DS_Store +node_modules +.rts2_cache_cjs +.rts2_cache_esm +.rts2_cache_umd +.rts2_cache_system +dist diff --git a/packages/blitz/jest.setup.js b/packages/blitz/jest.setup.js new file mode 100644 index 0000000000..70c5472408 --- /dev/null +++ b/packages/blitz/jest.setup.js @@ -0,0 +1 @@ +require('@testing-library/jest-dom') diff --git a/packages/blitz/package.json b/packages/blitz/package.json new file mode 100644 index 0000000000..23806f1783 --- /dev/null +++ b/packages/blitz/package.json @@ -0,0 +1,56 @@ +{ + "name": "blitz", + "description": "Rails-like framework for monolithic, full-stack React apps without an API", + "version": "0.0.2-canary.0", + "license": "MIT", + "scripts": { + "start": "tsdx watch", + "build": "tsdx build", + "test": "tsdx test", + "test:watch": "tsdx test --watch", + "lint": "tsdx lint" + }, + "author": { + "name": "Brandon Bayer", + "email": "b@bayer.ws", + "url": "https://twitter.com/flybayer" + }, + "main": "dist/index.js", + "module": "dist/core.esm.js", + "types": "dist/packages/blitz/src/index.d.ts", + "files": [ + "dist" + ], + "husky": { + "hooks": { + "pre-commit": "tsdx lint" + } + }, + "jest": { + "setupFilesAfterEnv": [ + "/jest.setup.js" + ] + }, + "engines": { + "yarn": "^1.19.1", + "node": ">=12.16.1" + }, + "repository": { + "type": "git", + "url": "https://github.com/blitz-js/blitz" + }, + "dependencies": { + "@blitzjs/cli": "0.0.2-canary.0", + "@blitzjs/core": "0.0.2-canary.0", + "@blitzjs/server": "0.0.2-canary.0" + }, + "devDependencies": { + "@types/jest": "^25.1.3", + "@types/node": "^13.7.4", + "cross-env": "^7.0.0", + "husky": "^4.2.3", + "lint-staged": "^10.0.8", + "ts-jest": "24.3.0" + }, + "gitHead": "6719104cb3e78948e7f06aa948ff72bbb84cb682" +} diff --git a/packages/blitz/src/index.ts b/packages/blitz/src/index.ts new file mode 100644 index 0000000000..9d7abbab0e --- /dev/null +++ b/packages/blitz/src/index.ts @@ -0,0 +1,2 @@ +export * from '@blitzjs/core' +export {withBlitz} from '@blitzjs/server' diff --git a/packages/blitz/src/utils/index.ts b/packages/blitz/src/utils/index.ts new file mode 100644 index 0000000000..37b91914e6 --- /dev/null +++ b/packages/blitz/src/utils/index.ts @@ -0,0 +1 @@ +export const isServer = typeof window === 'undefined' diff --git a/packages/blitz/test/todo.test.ts b/packages/blitz/test/todo.test.ts new file mode 100644 index 0000000000..78c9ae4375 --- /dev/null +++ b/packages/blitz/test/todo.test.ts @@ -0,0 +1,3 @@ +it('todo', async () => { + expect(true).toBe(true) +}) diff --git a/packages/blitz/tsconfig.json b/packages/blitz/tsconfig.json new file mode 100644 index 0000000000..d0f89e8e35 --- /dev/null +++ b/packages/blitz/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src", "types", "test"], + "exclude": ["node_modules"], + "compilerOptions": { + "baseUrl": "./", + "declarationDir": "./dist", + "downlevelIteration": true, + "paths": { + "*": ["src/*", "node_modules/*"] + } + } +} diff --git a/packages/blitz/tsdx.config.js b/packages/blitz/tsdx.config.js new file mode 100644 index 0000000000..f4f8acaab2 --- /dev/null +++ b/packages/blitz/tsdx.config.js @@ -0,0 +1,6 @@ +module.exports = { + rollup(config, options) { + config.external('@prisma/client') + return config + }, +} diff --git a/packages/blitz/types/index.d.ts b/packages/blitz/types/index.d.ts new file mode 100644 index 0000000000..8337712ea5 --- /dev/null +++ b/packages/blitz/types/index.d.ts @@ -0,0 +1 @@ +//