1
0
mirror of synced 2026-02-04 12:08:33 -05:00

Compare commits

...

4 Commits

Author SHA1 Message Date
beerose
80ffbeaa4c Update pnpm-lock.yaml 2022-06-19 18:20:49 +02:00
github-actions[bot]
6bde1b07da Version Packages (alpha) (#3445)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-19 18:18:57 +02:00
Datner
b918055bf3 Add aliases for Blitz CLI commands (#3410)
Co-authored-by: Aleksandra <alexsandra.sikora@gmail.com>
2022-06-19 18:13:43 +02:00
Aleksandra
f9a2971f05 Improve typings in blitz cli package (#3444) 2022-06-19 15:48:27 +02:00
20 changed files with 129 additions and 65 deletions

View File

@@ -59,6 +59,7 @@
"small-socks-confess",
"stupid-walls-sell",
"swift-drinks-dress",
"tame-keys-reply",
"tasty-news-collect",
"ten-rivers-burn",
"tender-pianos-check",

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
Add aliases for Blitz CLI commands

View File

@@ -29,7 +29,7 @@
"@blitzjs/rpc": "workspace:*",
"@hookform/resolvers": "2.8.8",
"@prisma/client": "3.9.0",
"blitz": "workspace:2.0.0-alpha.38",
"blitz": "workspace:2.0.0-alpha.39",
"next": "12.1.6-canary.17",
"prisma": "3.9.0",
"react": "18.0.0",

View File

@@ -1,5 +1,12 @@
# @blitzjs/auth
## 2.0.0-alpha.39
### Patch Changes
- Updated dependencies [b918055b]
- blitz@2.0.0-alpha.39
## 2.0.0-alpha.38
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/auth",
"version": "2.0.0-alpha.38",
"version": "2.0.0-alpha.39",
"scripts": {
"build": "unbuild",
"predev": "wait-on -d 250 ../blitz/dist/index-server.d.ts",
@@ -26,7 +26,7 @@
"@types/secure-password": "3.1.1",
"b64-lite": "1.4.0",
"bad-behavior": "1.0.1",
"blitz": "2.0.0-alpha.38",
"blitz": "2.0.0-alpha.39",
"cookie": "0.4.1",
"cookie-session": "2.0.0",
"debug": "4.3.3",
@@ -39,7 +39,7 @@
"url": "0.11.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-alpha.38",
"@blitzjs/config": "workspace:2.0.0-alpha.39",
"@testing-library/react": "13.0.0",
"@testing-library/react-hooks": "7.0.2",
"@types/cookie": "0.4.1",

View File

@@ -1,5 +1,11 @@
# @blitzjs/next
## 2.0.0-alpha.39
### Patch Changes
- @blitzjs/rpc@2.0.0-alpha.39
## 2.0.0-alpha.38
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/next",
"version": "2.0.0-alpha.38",
"version": "2.0.0-alpha.39",
"scripts": {
"build": "unbuild",
"dev": "pnpm predev && pnpm watch unbuild src --wait=0.2",
@@ -23,7 +23,7 @@
"eslint.js"
],
"dependencies": {
"@blitzjs/rpc": "2.0.0-alpha.38",
"@blitzjs/rpc": "2.0.0-alpha.39",
"@types/hoist-non-react-statics": "3.3.1",
"debug": "4.3.3",
"fs-extra": "10.0.1",
@@ -32,7 +32,7 @@
"superjson": "1.8.0"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-alpha.38",
"@blitzjs/config": "workspace:2.0.0-alpha.39",
"@testing-library/dom": "8.13.0",
"@testing-library/jest-dom": "5.16.3",
"@testing-library/react": "13.0.0",
@@ -43,7 +43,7 @@
"@types/react": "18.0.1",
"@types/react-dom": "17.0.14",
"@types/testing-library__react-hooks": "4.0.0",
"blitz": "2.0.0-alpha.38",
"blitz": "2.0.0-alpha.39",
"cross-spawn": "7.0.3",
"find-up": "4.1.0",
"lodash.frompairs": "4.0.1",

View File

@@ -1,5 +1,13 @@
# @blitzjs/rpc
## 2.0.0-alpha.39
### Patch Changes
- Updated dependencies [b918055b]
- blitz@2.0.0-alpha.39
- @blitzjs/auth@2.0.0-alpha.39
## 2.0.0-alpha.38
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/rpc",
"version": "2.0.0-alpha.38",
"version": "2.0.0-alpha.39",
"scripts": {
"build": "unbuild",
"predev": "wait-on -d 250 ../blitz/dist/index-server.d.ts && wait-on -d 250 ../blitz-auth/dist/index-browser.d.ts",
@@ -20,7 +20,7 @@
"dist/**"
],
"dependencies": {
"@blitzjs/auth": "2.0.0-alpha.38",
"@blitzjs/auth": "2.0.0-alpha.39",
"b64-lite": "1.4.0",
"bad-behavior": "1.0.1",
"chalk": "^4.1.0",
@@ -30,11 +30,11 @@
"zod": "3.10.1"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-alpha.38",
"@blitzjs/config": "workspace:2.0.0-alpha.39",
"@types/debug": "4.1.7",
"@types/react": "18.0.1",
"@types/react-dom": "17.0.14",
"blitz": "2.0.0-alpha.38",
"blitz": "2.0.0-alpha.39",
"next": "12.1.6-canary.17",
"react": "18.0.0",
"react-dom": "18.0.0",
@@ -43,7 +43,7 @@
"watch": "1.0.2"
},
"peerDependencies": {
"blitz": "2.0.0-alpha.38",
"blitz": "2.0.0-alpha.39",
"next": "*"
},
"publishConfig": {

View File

@@ -1,5 +1,12 @@
# blitz
## 2.0.0-alpha.39
### Patch Changes
- b918055b: Add aliases for Blitz CLI commands
- @blitzjs/generator@2.0.0-alpha.39
## 2.0.0-alpha.38
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "blitz",
"version": "2.0.0-alpha.38",
"version": "2.0.0-alpha.39",
"scripts": {
"build": "unbuild",
"dev": "watch unbuild src --wait=0.2",
@@ -23,7 +23,7 @@
"blitz": "bin/blitz"
},
"dependencies": {
"@blitzjs/generator": "2.0.0-alpha.38",
"@blitzjs/generator": "2.0.0-alpha.39",
"arg": "5.0.1",
"chalk": "^4.1.0",
"console-table-printer": "2.10.0",
@@ -52,7 +52,7 @@
"watchpack": "2.1.1"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-alpha.38",
"@blitzjs/config": "workspace:2.0.0-alpha.39",
"@types/cookie": "0.4.1",
"@types/cross-spawn": "6.0.2",
"@types/debug": "4.1.7",

View File

@@ -1,6 +1,5 @@
import {NON_STANDARD_NODE_ENV} from "./utils/constants"
import arg from "arg"
import packageJson from "../../package.json"
import {loadEnvConfig} from "../env-utils"
import {getCommandBin} from "./utils/config"
import spawn from "cross-spawn"
@@ -10,7 +9,7 @@ import pkgDir from "pkg-dir"
import {join} from "path"
const commonArgs = {
// Types
// Flags
"--version": Boolean,
"--help": Boolean,
"--inspect": Boolean,
@@ -25,9 +24,9 @@ const args = arg(commonArgs, {
permissive: true,
})
const defaultCommand = "dev"
export type CliCommand = (argv?: string[]) => void
const commands: {[command: string]: () => Promise<CliCommand>} = {
const commands = {
dev: () => import("./commands/next/dev").then((i) => i.dev),
build: () => import("./commands/next/build").then((i) => i.build),
start: () => import("./commands/next/start").then((i) => i.start),
@@ -36,25 +35,34 @@ const commands: {[command: string]: () => Promise<CliCommand>} = {
codegen: () => import("./commands/codegen").then((i) => i.codegen),
db: () => import("./commands/db").then((i) => i.db),
}
const foundCommand = Boolean(commands[args._[0] as string])
const command = foundCommand ? (args._[0] as string) : defaultCommand
const forwardedArgs = foundCommand ? args._.slice(1) : args._
const aliases: Record<string, keyof typeof commands> = {
d: "dev",
b: "build",
s: "start",
n: "new",
g: "generate",
}
type Command = keyof typeof commands
type Alias = keyof typeof aliases
const defaultCommand: Command = "dev"
const foundCommand = Boolean(commands[args._[0] as Command])
const foundAlias = Boolean(aliases[args._[0] as Alias])
let command: Command = defaultCommand
if (foundCommand) {
command = args._[0] as Command
}
if (foundAlias) {
command = aliases[args._[0] as Alias] as Command
}
const forwardedArgs = foundCommand || foundAlias ? args._.slice(1) : args._
const globalBlitzPath = resolveFrom(__dirname, "blitz")
const localBlitzPath = resolveFrom.silent(process.cwd(), "blitz")
const isInDevelopmentAsGloballyLinked = __dirname.includes("packages/blitz/dist")
let blitzPkgPath
if (isInDevelopmentAsGloballyLinked) {
blitzPkgPath = globalBlitzPath
} else {
// localBlitzPath won't exist if used outside a blitz app directory
blitzPkgPath = localBlitzPath || globalBlitzPath
}
async function runCommandFromBin() {
const command = args._[0] as string
let commandBin: string | null = null
try {
commandBin = await getCommandBin(command)
@@ -96,10 +104,10 @@ async function printEnvInfo() {
{showNotFound: true},
)
const globalBlitzPkgJsonPath = pkgDir.sync(globalBlitzPath) as string
const globalBlitzPkgJsonPath = pkgDir.sync(globalBlitzPath)
const localBlitzPkgJsonPath = pkgDir.sync(localBlitzPath)
if (globalBlitzPkgJsonPath !== localBlitzPkgJsonPath) {
if (globalBlitzPkgJsonPath && globalBlitzPkgJsonPath !== localBlitzPkgJsonPath) {
// This branch won't run if user does `npx blitz` or `yarn blitz`
const globalVersion = require(join(globalBlitzPkgJsonPath, "package.json")).version
console.log(`Blitz version: ${globalVersion} (global)`)
@@ -141,14 +149,16 @@ async function main() {
if (process.env.NODE_ENV && !standardEnv.includes(process.env.NODE_ENV)) {
console.warn(NON_STANDARD_NODE_ENV)
}
;(process.env as any).NODE_ENV = process.env.NODE_ENV || defaultEnv
process.env.NODE_ENV = process.env.NODE_ENV || defaultEnv
// Make sure commands gracefully respect termination signals (e.g. from Docker)
process.on("SIGTERM", () => process.exit(0))
process.on("SIGINT", () => process.exit(0))
if (foundCommand) {
commands[command]?.()
if (foundCommand || foundAlias) {
const commandFn = commands[command] || aliases[command]
commandFn?.()
.then((exec: any) => exec(forwardedArgs))
.then(() => {
if (command === "build") {
@@ -162,13 +172,21 @@ async function main() {
})
} else {
if (args["--help"] && args._.length === 0) {
// TODO: add back the generate command description once it's working
// generate, g Generate new files for your Blitz project 🤠
console.log(`
Usage
$ blitz <command>
Available commands
${Object.keys(commands).join(", ")}
dev, d Start a development server 🪄
build, b Create a production build 🏗️
start, s Start the production server 🐎
new, n Create a new Blitz project ✨
codegen Run the blitz codegen 🤖
db Run database commands 🗄️
Options
--env, -e App environment name
--version, -v Version number

View File

@@ -1,5 +1,13 @@
# @blitzjs/codemod
## 2.0.0-alpha.39
### Patch Changes
- Updated dependencies [b918055b]
- blitz@2.0.0-alpha.39
- @blitzjs/generator@2.0.0-alpha.39
## 2.0.0-alpha.38
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/codemod",
"version": "2.0.0-alpha.38",
"version": "2.0.0-alpha.39",
"scripts": {
"build": "unbuild",
"dev": "watch unbuild src --wait=0.2",
@@ -25,9 +25,9 @@
"@babel/plugin-proposal-class-properties": "7.17.12",
"@babel/plugin-syntax-jsx": "7.17.12",
"@babel/plugin-syntax-typescript": "7.17.12",
"@blitzjs/generator": "2.0.0-alpha.38",
"@blitzjs/generator": "2.0.0-alpha.39",
"arg": "5.0.1",
"blitz": "2.0.0-alpha.38",
"blitz": "2.0.0-alpha.39",
"chalk": "^4.1.0",
"cross-spawn": "7.0.3",
"debug": "4.3.3",

View File

@@ -1,5 +1,7 @@
# @blitzjs/config
## 2.0.0-alpha.39
## 2.0.0-alpha.38
## 2.0.0-alpha.37

View File

@@ -1,7 +1,7 @@
{
"name": "@blitzjs/config",
"private": true,
"version": "2.0.0-alpha.38",
"version": "2.0.0-alpha.39",
"license": "MIT",
"dependencies": {
"@typescript-eslint/eslint-plugin": "5.9.1",

View File

@@ -1,5 +1,7 @@
# @blitzjs/generator
## 2.0.0-alpha.39
## 2.0.0-alpha.38
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/generator",
"version": "2.0.0-alpha.38",
"version": "2.0.0-alpha.39",
"scripts": {
"dev": "watch unbuild src --wait=0.2",
"build": "unbuild && pnpm build:templates",
@@ -45,7 +45,7 @@
"vinyl": "2.2.1"
},
"devDependencies": {
"@blitzjs/config": "2.0.0-alpha.38",
"@blitzjs/config": "2.0.0-alpha.39",
"@juanm04/cpx": "2.0.1",
"@types/babel__core": "7.1.19",
"@types/diff": "5.0.2",

View File

@@ -25,7 +25,7 @@
"@typescript-eslint/parser": "5.9.1"
},
"devDependencies": {
"@blitzjs/config": "2.0.0-alpha.38",
"@blitzjs/config": "2.0.0-alpha.39",
"@types/react": "18.0.1",
"@types/react-dom": "17.0.14",
"react": "18.0.0",

34
pnpm-lock.yaml generated
View File

@@ -50,7 +50,7 @@ importers:
"@types/node": 17.0.16
"@types/preview-email": 2.0.1
"@types/react": 18.0.1
blitz: workspace:2.0.0-alpha.38
blitz: workspace:2.0.0-alpha.39
eslint: 7.32.0
husky: 7.0.4
jest: 27.5.1
@@ -432,8 +432,8 @@ importers:
packages/blitz:
specifiers:
"@blitzjs/config": workspace:2.0.0-alpha.38
"@blitzjs/generator": 2.0.0-alpha.38
"@blitzjs/config": workspace:2.0.0-alpha.39
"@blitzjs/generator": 2.0.0-alpha.39
"@types/cookie": 0.4.1
"@types/cross-spawn": 6.0.2
"@types/debug": 4.1.7
@@ -539,7 +539,7 @@ importers:
packages/blitz-auth:
specifiers:
"@blitzjs/config": workspace:2.0.0-alpha.38
"@blitzjs/config": workspace:2.0.0-alpha.39
"@testing-library/react": 13.0.0
"@testing-library/react-hooks": 7.0.2
"@types/b64-lite": 1.3.0
@@ -553,7 +553,7 @@ importers:
"@types/secure-password": 3.1.1
b64-lite: 1.4.0
bad-behavior: 1.0.1
blitz: 2.0.0-alpha.38
blitz: 2.0.0-alpha.39
cookie: 0.4.1
cookie-session: 2.0.0
debug: 4.3.3
@@ -604,8 +604,8 @@ importers:
packages/blitz-next:
specifiers:
"@blitzjs/config": workspace:2.0.0-alpha.38
"@blitzjs/rpc": 2.0.0-alpha.38
"@blitzjs/config": workspace:2.0.0-alpha.39
"@blitzjs/rpc": 2.0.0-alpha.39
"@testing-library/dom": 8.13.0
"@testing-library/jest-dom": 5.16.3
"@testing-library/react": 13.0.0
@@ -617,7 +617,7 @@ importers:
"@types/react": 18.0.1
"@types/react-dom": 17.0.14
"@types/testing-library__react-hooks": 4.0.0
blitz: 2.0.0-alpha.38
blitz: 2.0.0-alpha.39
cross-spawn: 7.0.3
debug: 4.3.3
find-up: 4.1.0
@@ -669,14 +669,14 @@ importers:
packages/blitz-rpc:
specifiers:
"@blitzjs/auth": 2.0.0-alpha.38
"@blitzjs/config": workspace:2.0.0-alpha.38
"@blitzjs/auth": 2.0.0-alpha.39
"@blitzjs/config": workspace:2.0.0-alpha.39
"@types/debug": 4.1.7
"@types/react": 18.0.1
"@types/react-dom": 17.0.14
b64-lite: 1.4.0
bad-behavior: 1.0.1
blitz: 2.0.0-alpha.38
blitz: 2.0.0-alpha.39
chalk: ^4.1.0
debug: 4.3.3
next: 12.1.6-canary.17
@@ -718,12 +718,12 @@ importers:
"@babel/plugin-syntax-typescript": 7.17.12
"@babel/preset-env": 7.12.10
"@blitzjs/config": workspace:*
"@blitzjs/generator": 2.0.0-alpha.38
"@blitzjs/generator": 2.0.0-alpha.39
"@types/jscodeshift": 0.11.2
"@types/node": 17.0.16
arg: 5.0.1
ast-types: 0.14.2
blitz: 2.0.0-alpha.38
blitz: 2.0.0-alpha.39
chalk: ^4.1.0
cross-spawn: 7.0.3
debug: 4.3.3
@@ -778,7 +778,7 @@ importers:
"@babel/plugin-transform-typescript": 7.12.1
"@babel/preset-env": 7.12.10
"@babel/types": 7.12.10
"@blitzjs/config": 2.0.0-alpha.38
"@blitzjs/config": 2.0.0-alpha.39
"@juanm04/cpx": 2.0.1
"@mrleebo/prisma-ast": 0.2.6
"@types/babel__core": 7.1.19
@@ -869,7 +869,7 @@ importers:
packages/pkg-template:
specifiers:
"@blitzjs/config": 2.0.0-alpha.38
"@blitzjs/config": 2.0.0-alpha.39
"@types/react": 18.0.1
"@types/react-dom": 17.0.14
"@typescript-eslint/eslint-plugin": 5.9.1
@@ -10895,7 +10895,7 @@ packages:
pretty-format: 27.5.1
slash: 3.0.0
strip-json-comments: 3.1.1
ts-node: 10.7.0_typescript@4.6.3
ts-node: 10.7.0_fxg3r7oju3tntkxsvleuiot4fa
transitivePeerDependencies:
- bufferutil
- canvas
@@ -16080,7 +16080,6 @@ packages:
typescript: 4.6.3
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
dev: false
/ts-node/10.7.0_typescript@4.6.3:
resolution:
@@ -16113,6 +16112,7 @@ packages:
typescript: 4.6.3
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
dev: false
/tsconfig-paths/3.14.1:
resolution: