Compare commits
17 Commits
@blitzjs/a
...
bb-fix-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e08e9a348a | ||
|
|
f0f66c6214 | ||
|
|
37e7614f0c | ||
|
|
617f20fb21 | ||
|
|
a5bbfe2187 | ||
|
|
d89c3ac8cf | ||
|
|
d0e4308d81 | ||
|
|
5166e5e037 | ||
|
|
5203e7e6ff | ||
|
|
2533caf484 | ||
|
|
860d21bea3 | ||
|
|
85a71ffef9 | ||
|
|
803f533a3d | ||
|
|
f3c64ffbaf | ||
|
|
44169979ef | ||
|
|
63ee9423a9 | ||
|
|
89446b3656 |
@@ -3917,6 +3917,34 @@
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "GHKEN",
|
||||
"name": "Tetsuya Fukuda",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/5304351?v=4",
|
||||
"profile": "https://ghken.com",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "nerixim",
|
||||
"name": "Nikita Kamaev",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/26106502?v=4",
|
||||
"profile": "https://github.com/nerixim",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "nikola-wd",
|
||||
"name": "Nikola Ivanov",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11588823?v=4",
|
||||
"profile": "https://webredone.com/",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
||||
9
.changeset/big-turtles-tease.md
Normal file
9
.changeset/big-turtles-tease.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
"@blitzjs/next": patch
|
||||
"@blitzjs/rpc": patch
|
||||
"blitz": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
(feat) upgrade tslog to v4.8.2
|
||||
5
.changeset/few-elephants-approve.md
Normal file
5
.changeset/few-elephants-approve.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Fix return type of `requestMiddlewares` in `RpcServerPlugin`
|
||||
26
.changeset/good-oranges-pretend.md
Normal file
26
.changeset/good-oranges-pretend.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Fixes enormous memory consumption of the dev server by changing the default import strategy to "require" instead of "import" which in webpack causes multiple chunks to be created for each import.
|
||||
|
||||
## Blitz Configuration
|
||||
|
||||
To configure this behaviour, you can add the following to your next.config.js:
|
||||
|
||||
```js
|
||||
/**
|
||||
* @type {import('@blitzjs/next').BlitzConfig}
|
||||
**/
|
||||
const config = {
|
||||
blitz: {
|
||||
resolversDynamicImport: true,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
When `resolversDynamicImport` is set to `true`, the import strategy will be "import" instead of "require".
|
||||
|
||||
### On Vercel
|
||||
|
||||
If you are using Vercel, `resolversDynamicImport` will be set to `true` by default, since it is better for the separate chunks to be create for serverless lambdas.
|
||||
5
.changeset/yellow-numbers-serve.md
Normal file
5
.changeset/yellow-numbers-serve.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/recipe-tailwind": minor
|
||||
---
|
||||
|
||||
support both directory style in tailwind recipe
|
||||
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.0
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.0
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.0
|
||||
|
||||
- name: Setup node@16
|
||||
uses: actions/setup-node@v2
|
||||
@@ -129,7 +129,7 @@ jobs:
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.0
|
||||
|
||||
- name: Setup node@${{ matrix.NODE_VERSION }}
|
||||
uses: actions/setup-node@v2
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
pnpm manypkg check
|
||||
pnpm lint
|
||||
# pnpm lint
|
||||
pnpm pretty-quick --staged
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPfeAuTtA5ulPXYQ7wZ04Y+oOoDD9KZc9YOoOoDj9s4dwFzgXR6w1wIPoOvPWA9buAHEJ173o3gWiy3AnuBUHLEbgmYwvAk1/wuM8vAgexThzbwPDkx7/DHwVXfFOxP2GmsKd4Ab6zPeAyU8CI7AHFmH2BRCBPXAyk18GzUrqAXCTiR4ssyj0VFw/oCU8+e+RZ33AWz6KMaYbIIWxB+JSLs1bsbkeMN0AqakHvoku9oA2sAfqBvbAQdw0QArsgb25aYBUQT3QgT2gB+yBuqGcHij2UCqXDZACe2Anlw2QYg/QAOyBuoE98CL3DZDCuK4/rh/Q7oGL6U+TOvcNkJoijN8X1C48+T+g75eQDrAH/qmqAVJgDwyqaoAUe4AGYA/UDZX3QLUNkEIZPRCd5+6BahsgVUgPROwBTSijB7jpVAvGHriHvmw9wAZ4BpX1ABvgmakHtPcbRuwBTWAPULgAV9D/jKDY9YRvwvgEaurD44uQHvAol7qBW7WKluVtIHiUS7GyvA0s6CiXDnxrpQfsgbqBS7GKk/2jYHCrVlGyfxTMrVo0ALdq1Q3sgSKofh0M9oA61a+D2QM0AHugbmAPqClmSRjK2apVVQ8UsySsoK1aHdgDesCtWnUDeyCrIpeFg1u3sylyWTi3btMA7IG6gT2wuuK3hoE9sKrit4YVslWLPaAN7IG6ocKt2zmY2h4O9sDiTG0PZw/QANy6XTewBxZj9ogYVHy025LMHhEz9cBn0We6B0yfERReBLfhx0/R1YQHPx/QBPbA0VwcEwf2wNFcHBPHHjiem3MC2QPHcXdSaJjA+KfgTPQ8hhfjBzHC40mhlzJ+Xq9lK4a4PCs43AVaGTed5mZq+iOXZwWHi3AnOj2wFWNcnxYe7gTxLtBKHuamP/J+Wnh8a5irB7ZC5Yk9gPX1QuXC+usHWqGyhYvUYR0a7zboUOFCNVhnk0krZAOW7wFOvzXhom2xnEbIHizTA1wEYhWW6YFGyC6c1gOcfg9wfA80Qj7g8B7g9HuCww+haIR8wf49wOn3Cvv9k8tGyC/s7gFOv3fY3QONkH+v9MBWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
|
||||
</a>
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-413-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
|
||||
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-416-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE">
|
||||
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
|
||||
@@ -727,6 +727,11 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
|
||||
<td align="center"><a href="https://github.com/dbrxnds"><img src="https://avatars.githubusercontent.com/u/32268383?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="https://github.com/gjmoed"><img src="https://avatars.githubusercontent.com/u/4458993?v=4?s=100" width="100px;" alt=""/><br /><sub><b>G.J. Moed</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://ghken.com"><img src="https://avatars.githubusercontent.com/u/5304351?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tetsuya Fukuda</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/nerixim"><img src="https://avatars.githubusercontent.com/u/26106502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikita Kamaev</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nerixim" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://webredone.com/"><img src="https://avatars.githubusercontent.com/u/11588823?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikola Ivanov</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nikola-wd" title="Documentation">📖</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- markdownlint-restore -->
|
||||
|
||||
@@ -6,6 +6,9 @@ const { withBlitz } = require("@blitzjs/next")
|
||||
**/
|
||||
const config = {
|
||||
reactStrictMode: true,
|
||||
blitz: {
|
||||
resolversDynamicImport: true,
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = withBlitz(withNextAuthAdapter(config))
|
||||
|
||||
@@ -13,7 +13,6 @@ const {gSSP, gSP, api} = setupBlitzServer({
|
||||
}),
|
||||
],
|
||||
logger: BlitzLogger({
|
||||
colorizePrettyLogs: true,
|
||||
prefix: ["[blitz]>>>>>"],
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -220,7 +220,7 @@ export async function useAuthenticatedBlitzContext({
|
||||
redirectAuthenticatedTo?: string | RouteUrlObject | ((ctx: Ctx) => string | RouteUrlObject)
|
||||
role?: string | string[]
|
||||
}): Promise<void> {
|
||||
const log = baseLogger().getChildLogger()
|
||||
const log = baseLogger().getSubLogger({name: "useAuthenticatedBlitzContext"})
|
||||
const customChalk = new chalk.Instance({
|
||||
level: log.settings.type === "json" ? 0 : chalk.level,
|
||||
})
|
||||
|
||||
@@ -211,8 +211,9 @@ test("withErrorBoundary HOC", () => {
|
||||
expect(cleanStack(onErrorComponentStack)).toMatchInlineSnapshot(`
|
||||
{
|
||||
"componentStack": "
|
||||
at ErrorBoundaryRoot
|
||||
at withRouter
|
||||
at __vite_ssr_import_4__.withErrorBoundary.FallbackComponent
|
||||
at ErrorBoundaryRoot
|
||||
at WithRouterWrapper
|
||||
at withErrorBoundary",
|
||||
}
|
||||
`)
|
||||
|
||||
@@ -3,6 +3,7 @@ import {NextRouter, withRouter} from "next/router"
|
||||
import * as React from "react"
|
||||
import {RouterContext} from "./router-context"
|
||||
import _debug from "debug"
|
||||
import {ExcludeRouterProps} from "next/dist/client/with-router"
|
||||
|
||||
const debug = _debug("blitz:errorboundary")
|
||||
|
||||
@@ -72,7 +73,9 @@ type ErrorBoundaryState = {error: Error | null}
|
||||
|
||||
const initialState: ErrorBoundaryState = {error: null}
|
||||
|
||||
const ErrorBoundary = withRouter(
|
||||
const ErrorBoundary: React.ComponentType<
|
||||
ExcludeRouterProps<React.PropsWithChildren<ErrorBoundaryProps>>
|
||||
> = withRouter(
|
||||
class ErrorBoundaryRoot extends React.Component<
|
||||
React.PropsWithRef<React.PropsWithChildren<ErrorBoundaryProps>>,
|
||||
ErrorBoundaryState
|
||||
|
||||
@@ -230,6 +230,7 @@ export const setupBlitzServer = <TPlugins extends readonly BlitzServerPlugin<obj
|
||||
export interface BlitzConfig extends NextConfig {
|
||||
blitz?: {
|
||||
resolverPath?: ResolverPathOptions
|
||||
resolversDynamicImport?: boolean
|
||||
includeRPCFolders?: string[]
|
||||
customServer?: {
|
||||
hotReload?: boolean
|
||||
@@ -261,6 +262,8 @@ export function withBlitz(nextConfig: BlitzConfig = {}): NextConfig {
|
||||
webpackConfig: config,
|
||||
webpackRuleOptions: {
|
||||
resolverPath: nextConfig.blitz?.resolverPath,
|
||||
resolversDynamicImport:
|
||||
nextConfig.blitz?.resolversDynamicImport ?? Boolean(process.env.VERCEL),
|
||||
includeRPCFolders: nextConfig.blitz?.includeRPCFolders,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ import {NextApiRequest, NextApiResponse} from "next"
|
||||
import {deserialize, parse, serialize as superjsonSerialize} from "superjson"
|
||||
import {resolve} from "path"
|
||||
import chalk from "chalk"
|
||||
import {LoaderOptions} from "./server/loader/utils/loader-utils"
|
||||
|
||||
// TODO - optimize end user server bundles by not exporting all client stuff here
|
||||
export * from "./index-browser"
|
||||
@@ -60,16 +61,11 @@ const loaderClient = resolve(dir, "./loader-client.cjs")
|
||||
const loaderServer = resolve(dir, "./loader-server.cjs")
|
||||
const loaderServerResolvers = resolve(dir, "./loader-server-resolvers.cjs")
|
||||
|
||||
interface WebpackRuleOptions {
|
||||
resolverPath: ResolverPathOptions | undefined
|
||||
includeRPCFolders: string[] | undefined
|
||||
}
|
||||
|
||||
interface WebpackRule {
|
||||
test: RegExp
|
||||
use: Array<{
|
||||
loader: string
|
||||
options: WebpackRuleOptions
|
||||
options: LoaderOptions
|
||||
}>
|
||||
}
|
||||
|
||||
@@ -84,7 +80,7 @@ export interface InstallWebpackConfigOptions {
|
||||
rules: WebpackRule[]
|
||||
}
|
||||
}
|
||||
webpackRuleOptions: WebpackRuleOptions
|
||||
webpackRuleOptions: LoaderOptions
|
||||
}
|
||||
|
||||
export function installWebpackConfig({
|
||||
@@ -164,7 +160,8 @@ export function rpcHandler(config: RpcConfig) {
|
||||
const relativeRoutePath = (req.query.blitz as string[])?.join("/")
|
||||
const routePath = "/" + relativeRoutePath
|
||||
|
||||
const log = baseLogger().getChildLogger({
|
||||
const log = baseLogger().getSubLogger({
|
||||
name: "blitz-rpc",
|
||||
prefix: [routePath.replace(/(\/api\/rpc)?\//, "") + "()"],
|
||||
})
|
||||
const customChalk = new chalk.Instance({
|
||||
@@ -220,7 +217,7 @@ export function rpcHandler(config: RpcConfig) {
|
||||
const startTime = Date.now()
|
||||
const result = await resolver(data, (res as any).blitzCtx)
|
||||
const resolverDuration = Date.now() - startTime
|
||||
log.debug(customChalk.dim("Result:"), result ? result : JSON.stringify(result))
|
||||
log.info(customChalk.dim("Result:"), result ? result : JSON.stringify(result))
|
||||
|
||||
const serializerStartTime = Date.now()
|
||||
const serializedResult = superjsonSerialize(result)
|
||||
@@ -242,7 +239,7 @@ export function rpcHandler(config: RpcConfig) {
|
||||
const serializerDuration = Date.now() - serializerStartTime
|
||||
const duration = Date.now() - startTime
|
||||
|
||||
log.info(
|
||||
log.debug(
|
||||
customChalk.dim(
|
||||
`Finished: resolver:${prettyMs(resolverDuration)} serializer:${prettyMs(
|
||||
serializerDuration,
|
||||
|
||||
@@ -64,12 +64,14 @@ export async function transformBlitzRpcServer(
|
||||
extraRpcBasePaths: options?.includeRPCFolders,
|
||||
})
|
||||
|
||||
code += `__internal_addBlitzRpcResolver('${routePath}',() => import('${slash(
|
||||
const importStrategy = options?.resolversDynamicImport ? "import" : "require"
|
||||
|
||||
code += `__internal_addBlitzRpcResolver('${routePath}',() => ${importStrategy}('${slash(
|
||||
resolverFilePath,
|
||||
)}'));`
|
||||
code += "\n"
|
||||
}
|
||||
// console.log("NEW CODE", code)
|
||||
|
||||
return code
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {ResolverPathOptions} from "../../../index-server"
|
||||
export interface LoaderOptions {
|
||||
resolverPath: ResolverPathOptions
|
||||
includeRPCFolders?: string[]
|
||||
resolversDynamicImport?: boolean
|
||||
}
|
||||
|
||||
export interface Loader {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {createServerPlugin} from "blitz"
|
||||
import {RequestMiddleware, createServerPlugin} from "blitz"
|
||||
import {invoke} from "../client/invoke"
|
||||
|
||||
export const RpcServerPlugin = createServerPlugin(() => {
|
||||
return {
|
||||
requestMiddlewares: [],
|
||||
requestMiddlewares: [] as RequestMiddleware<any, any, void | Promise<void>>[],
|
||||
exports: () => ({
|
||||
invoke,
|
||||
}),
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
"tar": "6.1.11",
|
||||
"ts-node": "10.9.1",
|
||||
"tsconfig-paths": "4.0.0",
|
||||
"tslog": "3.3.4",
|
||||
"tslog": "4.8.2",
|
||||
"watchpack": "2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -45,7 +45,7 @@ const pipeline = promisify(Stream.pipeline)
|
||||
const got = async (url: string) => {
|
||||
return require("got")(url).catch((e: any) => {
|
||||
if (e.response.statusCode === 403) {
|
||||
baseLogger({displayDateTime: false}).error(e.response.body)
|
||||
baseLogger().error(e.response.body)
|
||||
} else {
|
||||
return e
|
||||
}
|
||||
@@ -264,7 +264,7 @@ const install: CliCommand = async () => {
|
||||
|
||||
if (!(await isUrlValid(packageJsonPath))) {
|
||||
debug("Url is invalid for ", packageJsonPath)
|
||||
baseLogger({displayDateTime: false}).error(`Could not find recipe "${args._[1]}"\n`)
|
||||
baseLogger().error(`Could not find recipe "${args._[1]}"\n`)
|
||||
console.log(`${chalk.bold("Please provide one of the following:")}
|
||||
|
||||
1. The name of a recipe to install (e.g. "tailwind")
|
||||
|
||||
@@ -41,11 +41,9 @@ export class RecipeExecutor<Options extends RecipeMeta> {
|
||||
{exitOnCtrlC: false},
|
||||
)
|
||||
await waitUntilExit()
|
||||
baseLogger({displayDateTime: false, displayLogLevel: false}).info(
|
||||
`\n🎉 The ${this.options.name} recipe has been installed!\n`,
|
||||
)
|
||||
baseLogger().info(`\n🎉 The ${this.options.name} recipe has been installed!\n`)
|
||||
} catch (e) {
|
||||
baseLogger({displayDateTime: false}).error(e as any)
|
||||
baseLogger().error(e as any)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import {ISettingsParam, Logger, TLogLevelName} from "tslog"
|
||||
import {ILogObj, ISettingsParam, Logger, IMeta} from "tslog"
|
||||
import c from "chalk"
|
||||
import {Table} from "console-table-printer"
|
||||
import ora from "ora"
|
||||
import readline from "readline"
|
||||
|
||||
export type BlitzLoggerSettings = ISettingsParam
|
||||
export type BlitzLogLevel = TLogLevelName
|
||||
export type BlitzLoggerSettings = ISettingsParam<ILogObj>
|
||||
export type BlitzLogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal"
|
||||
|
||||
declare namespace globalThis {
|
||||
let _blitz_baseLogger: Logger
|
||||
let _blitz_baseLogger: Logger<ILogObj>
|
||||
let _blitz_logLevel: BlitzLogLevel
|
||||
}
|
||||
|
||||
export const baseLogger = (options: BlitzLoggerSettings = {}): Logger => {
|
||||
export const baseLogger = (options: BlitzLoggerSettings = {}): Logger<ILogObj> => {
|
||||
if (globalThis._blitz_baseLogger) return globalThis._blitz_baseLogger
|
||||
|
||||
globalThis._blitz_baseLogger = BlitzLogger(options)
|
||||
@@ -22,34 +22,18 @@ export const baseLogger = (options: BlitzLoggerSettings = {}): Logger => {
|
||||
|
||||
export const BlitzLogger = (settings: BlitzLoggerSettings = {}) => {
|
||||
const baseLogger = new Logger({
|
||||
minLevel: "info",
|
||||
type: "pretty",
|
||||
dateTimePattern:
|
||||
process.env.NODE_ENV === "production"
|
||||
? "year-month-day hour:minute:second.millisecond"
|
||||
: "hour:minute:second.millisecond",
|
||||
displayFunctionName: false,
|
||||
displayFilePath: "hidden",
|
||||
displayRequestId: false,
|
||||
dateTimeTimezone:
|
||||
process.env.NODE_ENV === "production"
|
||||
? "utc"
|
||||
: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
prettyInspectHighlightStyles: {
|
||||
name: "yellow",
|
||||
number: "blue",
|
||||
bigint: "blue",
|
||||
boolean: "blue",
|
||||
},
|
||||
prettyLogTimeZone: process.env.NODE_ENV === "production" ? "UTC" : "local",
|
||||
maskValuesOfKeys: ["password", "passwordConfirmation", "currentPassword"],
|
||||
exposeErrorCodeFrame: process.env.NODE_ENV !== "production",
|
||||
type: process.env.NODE_ENV === "production" ? "json" : "pretty",
|
||||
prettyLogTemplate:
|
||||
"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t[{{filePathWithLine}}{{name}}]\t",
|
||||
...settings,
|
||||
})
|
||||
|
||||
return baseLogger
|
||||
}
|
||||
|
||||
export const initializeLogger = (logger: Logger) => {
|
||||
export const initializeLogger = (logger: Logger<ILogObj>) => {
|
||||
globalThis._blitz_baseLogger = logger
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"prettier": "^2.7.1",
|
||||
"recast": "0.20.5",
|
||||
"supports-color": "8.1.1",
|
||||
"tslog": "3.3.4",
|
||||
"tslog": "4.8.2",
|
||||
"username": "5.1.0",
|
||||
"vinyl": "2.2.1",
|
||||
"zod": "3.20.2"
|
||||
|
||||
@@ -90,8 +90,8 @@ export class AppGenerator extends Generator<AppGeneratorOptions> {
|
||||
|
||||
gitInitSuccessful = initResult.status === 0
|
||||
if (!gitInitSuccessful) {
|
||||
baseLogger({displayDateTime: false}).warn("Failed to run git init.")
|
||||
baseLogger({displayDateTime: false}).warn(
|
||||
baseLogger().warn("Failed to run git init.")
|
||||
baseLogger().warn(
|
||||
"Find out more about how to install git here: https://git-scm.com/downloads.",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {ISettingsParam, Logger} from "tslog"
|
||||
import {ILogObj, ISettingsParam, Logger} from "tslog"
|
||||
import c from "chalk"
|
||||
import {Table} from "console-table-printer"
|
||||
import ora from "ora"
|
||||
@@ -8,7 +8,7 @@ import {defaultConfig} from "./default-config"
|
||||
|
||||
// eslint-disable-next-line
|
||||
declare module globalThis {
|
||||
let _blitz_baseLogger: Logger
|
||||
let _blitz_baseLogger: Logger<ILogObj>
|
||||
let _blitz_logLevel: LogLevel
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export const newline = () => {
|
||||
}
|
||||
}
|
||||
|
||||
export const baseLogger = (options?: ISettingsParam): Logger => {
|
||||
export const baseLogger = (options?: ISettingsParam<ILogObj>): Logger<ILogObj> => {
|
||||
if (globalThis._blitz_baseLogger) return globalThis._blitz_baseLogger
|
||||
|
||||
let config
|
||||
@@ -114,28 +114,14 @@ export const baseLogger = (options?: ISettingsParam): Logger => {
|
||||
}
|
||||
|
||||
globalThis._blitz_baseLogger = new Logger({
|
||||
minLevel: config.log?.level || "info",
|
||||
minLevel: config.log?.level || 3,
|
||||
type: config.log?.type || "pretty",
|
||||
dateTimePattern:
|
||||
prettyLogTemplate:
|
||||
process.env.NODE_ENV === "production"
|
||||
? "year-month-day hour:minute:second.millisecond"
|
||||
: "hour:minute:second.millisecond",
|
||||
displayFunctionName: false,
|
||||
displayFilePath: "hidden",
|
||||
displayRequestId: false,
|
||||
dateTimeTimezone:
|
||||
process.env.NODE_ENV === "production"
|
||||
? "utc"
|
||||
: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
prettyInspectHighlightStyles: {
|
||||
name: "yellow",
|
||||
number: "blue",
|
||||
bigint: "blue",
|
||||
boolean: "blue",
|
||||
},
|
||||
colorizePrettyLogs: process.env.FORCE_COLOR === "0" ? false : true,
|
||||
maskValuesOfKeys: ["password", "passwordConfirmation"],
|
||||
exposeErrorCodeFrame: process.env.NODE_ENV !== "production",
|
||||
? "{{yyyy}}-{{mm}}-{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}"
|
||||
: "{{hh}}:{{MM}}:{{ss}}:{{ms}}",
|
||||
prettyLogTimeZone: process.env.NODE_ENV === "production" ? "UTC" : "local",
|
||||
maskValuesOfKeys: ["password", "passwordConfirmation", "currentPassword"],
|
||||
...options,
|
||||
})
|
||||
|
||||
|
||||
11457
pnpm-lock.yaml
generated
11457
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,7 @@ export default RecipeBuilder()
|
||||
stepId: "addStyles",
|
||||
stepName: "Stylesheet",
|
||||
explanation: `Adds a root CSS stylesheet where Tailwind is imported and where you can add global styles`,
|
||||
targetDirectory: "./app/core",
|
||||
targetDirectory: `./${paths.appSrcDirectory()}/core`,
|
||||
templatePath: join(__dirname, "templates", "styles"),
|
||||
templateValues: {},
|
||||
})
|
||||
@@ -39,7 +39,10 @@ export default RecipeBuilder()
|
||||
explanation: `Imports the stylesheet we just added into your app`,
|
||||
singleFileSearch: paths.app(),
|
||||
transform(program) {
|
||||
const stylesImport = j.importDeclaration([], j.literal("app/core/styles/index.css"))
|
||||
const stylesImport = j.importDeclaration(
|
||||
[],
|
||||
j.literal(`${paths.appSrcDirectory()}/core/styles/index.css`),
|
||||
)
|
||||
return addImport(program, stylesImport)
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user