1
0
mirror of synced 2026-02-05 06:00:08 -05:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Dillon Raphael
4e9c1f60b6 pnpm lock 2022-06-07 11:36:45 -04:00
github-actions[bot]
508682c8f8 Version Packages (alpha) (#3400)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-07 11:35:42 -04:00
Dillon Raphael
962eb58af6 Migrate printEnvInfo to CLI (#3394)
* init printEnvInfo function

* changeset
2022-06-07 11:31:56 -04:00
18 changed files with 259 additions and 104 deletions

View File

@@ -0,0 +1,5 @@
---
"blitz": patch
---
detailed print env info

View File

@@ -30,6 +30,7 @@
"flat-bees-approve",
"four-meals-fry",
"great-months-train",
"healthy-rice-shout",
"hot-drinks-approve",
"lovely-colts-share",
"modern-cameras-pull",

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.28",
"blitz": "workspace:2.0.0-alpha.29",
"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.29
### Patch Changes
- Updated dependencies [962eb58a]
- blitz@2.0.0-alpha.29
## 2.0.0-alpha.28
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/auth",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"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.28",
"blitz": "2.0.0-alpha.29",
"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.28",
"@blitzjs/config": "workspace:2.0.0-alpha.29",
"@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.29
### Patch Changes
- @blitzjs/rpc@2.0.0-alpha.29
## 2.0.0-alpha.28
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/next",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"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.28",
"@blitzjs/rpc": "2.0.0-alpha.29",
"@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.28",
"@blitzjs/config": "workspace:2.0.0-alpha.29",
"@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.28",
"blitz": "2.0.0-alpha.29",
"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.29
### Patch Changes
- Updated dependencies [962eb58a]
- blitz@2.0.0-alpha.29
- @blitzjs/auth@2.0.0-alpha.29
## 2.0.0-alpha.28
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/rpc",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"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.28",
"@blitzjs/auth": "2.0.0-alpha.29",
"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.28",
"@blitzjs/config": "workspace:2.0.0-alpha.29",
"@types/debug": "4.1.7",
"@types/react": "18.0.1",
"@types/react-dom": "17.0.14",
"blitz": "2.0.0-alpha.28",
"blitz": "2.0.0-alpha.29",
"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.28",
"blitz": "2.0.0-alpha.29",
"next": "*"
},
"publishConfig": {

View File

@@ -1,5 +1,12 @@
# blitz
## 2.0.0-alpha.29
### Patch Changes
- 962eb58a: detailed print env info
- @blitzjs/generator@2.0.0-alpha.29
## 2.0.0-alpha.28
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "blitz",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"scripts": {
"build": "unbuild",
"dev": "watch unbuild src --wait=0.2",
@@ -23,7 +23,7 @@
"blitz": "bin/blitz"
},
"dependencies": {
"@blitzjs/generator": "2.0.0-alpha.28",
"@blitzjs/generator": "2.0.0-alpha.29",
"arg": "5.0.1",
"chalk": "^4.1.0",
"console-table-printer": "2.10.0",
@@ -32,12 +32,14 @@
"detect-port": "1.3.0",
"dotenv": "16.0.0",
"dotenv-expand": "8.0.3",
"envinfo": "7.8.1",
"esbuild": "0.14.34",
"find-up": "4.1.0",
"fs-extra": "10.0.1",
"hasbin": "1.2.3",
"npm-which": "3.0.1",
"ora": "5.3.0",
"os-name": "5.0.1",
"p-event": "4.2.0",
"pkg-dir": "5.0.0",
"prompts": "2.4.2",
@@ -50,11 +52,12 @@
"watchpack": "2.1.1"
},
"devDependencies": {
"@blitzjs/config": "workspace:2.0.0-alpha.28",
"@blitzjs/config": "workspace:2.0.0-alpha.29",
"@types/cookie": "0.4.1",
"@types/cross-spawn": "6.0.2",
"@types/debug": "4.1.7",
"@types/detect-port": "1.3.2",
"@types/envinfo": "7.8.1",
"@types/express": "4.17.13",
"@types/fs-extra": "9.0.13",
"@types/hasbin": "1.2.0",

View File

@@ -4,6 +4,10 @@ import packageJson from "../../package.json"
import {loadEnvConfig} from "../env-utils"
import {getCommandBin} from "./utils/config"
import spawn from "cross-spawn"
import {readdirSync} from "fs-extra"
import resolveFrom from "resolve-from"
import pkgDir from "pkg-dir"
import {join} from "path"
const commonArgs = {
// Types
@@ -17,6 +21,9 @@ const commonArgs = {
"-h": "--help",
"-e": "--env",
}
const args = arg(commonArgs, {
permissive: true,
})
const defaultCommand = "dev"
export type CliCommand = (argv?: string[]) => void
@@ -29,84 +36,21 @@ const commands: {[command: string]: () => Promise<CliCommand>} = {
codegen: () => import("./commands/codegen").then((i) => i.codegen),
db: () => import("./commands/db").then((i) => i.db),
}
const args = arg(commonArgs, {
permissive: true,
})
if (args["--env"]) {
process.env.APP_ENV = args["--env"]
}
loadEnvConfig(process.cwd(), undefined, {error: console.error, info: console.info})
// Version is inlined into the file using taskr build pipeline
if (args["--version"]) {
console.log(`Blitz.js v${packageJson.version}`)
process.exit(0)
}
const foundCommand = Boolean(commands[args._[0] as string])
const command = foundCommand ? (args._[0] as string) : defaultCommand
const forwardedArgs = foundCommand ? args._.slice(1) : args._
if (args["--env"]) {
process.env.APP_ENV = args["--env"]
}
const globalBlitzPath = resolveFrom(__dirname, "blitz")
const localBlitzPath = resolveFrom.silent(process.cwd(), "blitz")
if (args["--help"]) {
forwardedArgs.push("--help")
}
const isInDevelopmentAsGloballyLinked = __dirname.includes("packages/blitz/dist")
// env variable should default to dev unless the command is build or start
const defaultEnv = command === "build" || command === "start" ? "production" : "development"
const standardEnv = ["production", "development", "test"]
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
// 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]?.()
.then((exec: any) => exec(forwardedArgs))
.then(() => {
if (command === "build") {
// ensure process exits after build completes so open handles/connections
// don't cause process to hang
process.exit(0)
}
})
.catch((err) => {
console.log(err)
})
let blitzPkgPath
if (isInDevelopmentAsGloballyLinked) {
blitzPkgPath = globalBlitzPath
} else {
if (args["--help"] && args._.length === 0) {
console.log(`
Usage
$ blitz <command>
Available commands
${Object.keys(commands).join(", ")}
Options
--env, -e App environment name
--version, -v Version number
--help, -h Displays this message
For more information run a command with the --help flag
$ blitz build --help
`)
process.exit(0)
} else {
// If the command is not found, we assume it is a command from the bin
void runCommandFromBin()
}
// localBlitzPath won't exist if used outside a blitz app directory
blitzPkgPath = localBlitzPath || globalBlitzPath
}
async function runCommandFromBin() {
@@ -125,3 +69,122 @@ async function runCommandFromBin() {
const result = spawn.sync(commandBin, process.argv.slice(3), {stdio: "inherit"})
process.exit(result.status || 0)
}
async function printEnvInfo() {
const osName = await import("os-name")
const envinfo = await import("envinfo")
const pkgManager = readdirSync(process.cwd()).includes("pnpm-lock.yaml")
? "pnpm"
: readdirSync(process.cwd()).includes("yarn-lock.yaml")
? "yarn"
: "npm"
const env = await envinfo.default.run(
{
System: ["OS", "CPU", "Memory", "Shell"],
Binaries: ["Node", "Yarn", "npm", "pnpm"],
npmPackages: [
"blitz",
"typescript",
"react",
"react-dom",
"prisma",
"@prisma/client",
"next",
],
},
{showNotFound: true},
)
const globalBlitzPkgJsonPath = pkgDir.sync(globalBlitzPath) as string
const localBlitzPkgJsonPath = pkgDir.sync(localBlitzPath)
if (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)`)
}
if (localBlitzPkgJsonPath) {
const localVersion = require(join(localBlitzPkgJsonPath, "package.json")).version
console.log(`Blitz version: ${localVersion} (local)`)
}
console.log(
`${osName.default()} | ${process.platform}-${process.arch} | Node: ${process.version}\n`,
)
console.log(`\n Package manager: ${pkgManager}`)
console.log(env)
process.exit(0)
}
async function main() {
loadEnvConfig(process.cwd(), undefined, {error: console.error, info: console.info})
// Version is inlined into the file using taskr build pipeline
if (args["_"].length === 0 && args["--version"]) {
await printEnvInfo()
}
if (args["--env"]) {
process.env.APP_ENV = args["--env"]
}
if (args["--help"]) {
forwardedArgs.push("--help")
}
// env variable should default to dev unless the command is build or start
const defaultEnv = command === "build" || command === "start" ? "production" : "development"
const standardEnv = ["production", "development", "test"]
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
// 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]?.()
.then((exec: any) => exec(forwardedArgs))
.then(() => {
if (command === "build") {
// ensure process exits after build completes so open handles/connections
// don't cause process to hang
process.exit(0)
}
})
.catch((err) => {
console.log(err)
})
} else {
if (args["--help"] && args._.length === 0) {
console.log(`
Usage
$ blitz <command>
Available commands
${Object.keys(commands).join(", ")}
Options
--env, -e App environment name
--version, -v Version number
--help, -h Displays this message
For more information run a command with the --help flag
$ blitz build --help
`)
process.exit(0)
} else {
// If the command is not found, we assume it is a command from the bin
void runCommandFromBin()
}
}
}
main().catch((e) => {
console.error(e)
})

View File

@@ -1,5 +1,7 @@
# @blitzjs/config
## 2.0.0-alpha.29
## 2.0.0-alpha.28
## 2.0.0-alpha.27

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@blitzjs/generator",
"version": "2.0.0-alpha.28",
"version": "2.0.0-alpha.29",
"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.28",
"@blitzjs/config": "2.0.0-alpha.29",
"@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.28",
"@blitzjs/config": "2.0.0-alpha.29",
"@types/react": "18.0.1",
"@types/react-dom": "17.0.14",
"react": "18.0.0",

77
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.28
blitz: workspace:2.0.0-alpha.29
eslint: 7.32.0
husky: 7.0.4
jest: 27.5.1
@@ -432,12 +432,13 @@ importers:
packages/blitz:
specifiers:
"@blitzjs/config": workspace:2.0.0-alpha.28
"@blitzjs/generator": 2.0.0-alpha.28
"@blitzjs/config": workspace:2.0.0-alpha.29
"@blitzjs/generator": 2.0.0-alpha.29
"@types/cookie": 0.4.1
"@types/cross-spawn": 6.0.2
"@types/debug": 4.1.7
"@types/detect-port": 1.3.2
"@types/envinfo": 7.8.1
"@types/express": 4.17.13
"@types/fs-extra": 9.0.13
"@types/hasbin": 1.2.0
@@ -456,6 +457,7 @@ importers:
detect-port: 1.3.0
dotenv: 16.0.0
dotenv-expand: 8.0.3
envinfo: 7.8.1
esbuild: 0.14.34
express: 4.17.3
find-up: 4.1.0
@@ -464,6 +466,7 @@ importers:
node-fetch: 3.2.3
npm-which: 3.0.1
ora: 5.3.0
os-name: 5.0.1
p-event: 4.2.0
pkg-dir: 5.0.0
prompts: 2.4.2
@@ -490,12 +493,14 @@ importers:
detect-port: 1.3.0
dotenv: 16.0.0
dotenv-expand: 8.0.3
envinfo: 7.8.1
esbuild: 0.14.34
find-up: 4.1.0
fs-extra: 10.0.1
hasbin: 1.2.3
npm-which: 3.0.1
ora: 5.3.0
os-name: 5.0.1
p-event: 4.2.0
pkg-dir: 5.0.0
prompts: 2.4.2
@@ -512,6 +517,7 @@ importers:
"@types/cross-spawn": 6.0.2
"@types/debug": 4.1.7
"@types/detect-port": 1.3.2
"@types/envinfo": 7.8.1
"@types/express": 4.17.13
"@types/fs-extra": 9.0.13
"@types/hasbin": 1.2.0
@@ -533,7 +539,7 @@ importers:
packages/blitz-auth:
specifiers:
"@blitzjs/config": workspace:2.0.0-alpha.28
"@blitzjs/config": workspace:2.0.0-alpha.29
"@testing-library/react": 13.0.0
"@testing-library/react-hooks": 7.0.2
"@types/b64-lite": 1.3.0
@@ -547,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.28
blitz: 2.0.0-alpha.29
cookie: 0.4.1
cookie-session: 2.0.0
debug: 4.3.3
@@ -598,8 +604,8 @@ importers:
packages/blitz-next:
specifiers:
"@blitzjs/config": workspace:2.0.0-alpha.28
"@blitzjs/rpc": 2.0.0-alpha.28
"@blitzjs/config": workspace:2.0.0-alpha.29
"@blitzjs/rpc": 2.0.0-alpha.29
"@testing-library/dom": 8.13.0
"@testing-library/jest-dom": 5.16.3
"@testing-library/react": 13.0.0
@@ -611,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.28
blitz: 2.0.0-alpha.29
cross-spawn: 7.0.3
debug: 4.3.3
find-up: 4.1.0
@@ -663,14 +669,14 @@ importers:
packages/blitz-rpc:
specifiers:
"@blitzjs/auth": 2.0.0-alpha.28
"@blitzjs/config": workspace:2.0.0-alpha.28
"@blitzjs/auth": 2.0.0-alpha.29
"@blitzjs/config": workspace:2.0.0-alpha.29
"@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.28
blitz: 2.0.0-alpha.29
chalk: ^4.1.0
debug: 4.3.3
next: 12.1.6-canary.17
@@ -725,7 +731,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.28
"@blitzjs/config": 2.0.0-alpha.29
"@juanm04/cpx": 2.0.1
"@mrleebo/prisma-ast": 0.2.6
"@types/babel__core": 7.1.19
@@ -816,7 +822,7 @@ importers:
packages/pkg-template:
specifiers:
"@blitzjs/config": 2.0.0-alpha.28
"@blitzjs/config": 2.0.0-alpha.29
"@types/react": 18.0.1
"@types/react-dom": 17.0.14
"@typescript-eslint/eslint-plugin": 5.9.1
@@ -4071,6 +4077,13 @@ packages:
}
dev: true
/@types/envinfo/7.8.1:
resolution:
{
integrity: sha512-pTyshpmGxqB9lRwG75v2YR0oqKYpCrklOYlZWQ88z/JB0fimT8EVmYekuIwpU3IxPZDHSXCqXKzkCrtAcKY25g==,
}
dev: true
/@types/estree/0.0.39:
resolution:
{
@@ -7349,6 +7362,15 @@ packages:
}
dev: true
/envinfo/7.8.1:
resolution:
{
integrity: sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==,
}
engines: {node: ">=4"}
hasBin: true
dev: false
/error-ex/1.3.2:
resolution:
{
@@ -12052,6 +12074,14 @@ packages:
hasBin: true
dev: true
/macos-release/3.0.1:
resolution:
{
integrity: sha512-3l6OrhdDg2H2SigtuN3jBh+5dRJRWxNKuJTPBbGeNJTsmt/pj9PO25wYaNb05NuNmAsl435j4rDP6rgNXz7s7g==,
}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dev: false
/magic-string/0.25.9:
resolution:
{
@@ -13109,6 +13139,17 @@ packages:
wcwidth: 1.0.1
dev: false
/os-name/5.0.1:
resolution:
{
integrity: sha512-0EQpaHUHq7olp2/YFUr+0vZi9tMpDTblHGz+Ch5RntKxiRXOAY0JOz1UlxhSjMSksHvkm13eD6elJj3M8Ht/kw==,
}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
macos-release: 3.0.1
windows-release: 5.0.1
dev: false
/os-tmpdir/1.0.2:
resolution:
{
@@ -16882,6 +16923,16 @@ packages:
string-width: 4.2.3
dev: false
/windows-release/5.0.1:
resolution:
{
integrity: sha512-y1xFdFvdMiDXI3xiOhMbJwt1Y7dUxidha0CWPs1NgjZIjZANTcX7+7bMqNjuezhzb8s5JGEiBAbQjQQYYy7ulw==,
}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
execa: 5.1.1
dev: false
/with/7.0.2:
resolution:
{