-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build(build): ⚗️ change target node to bun and add `semver` as external * refactor(utils): 👽 improve `highlighter` utils funciton * refactor(utils): 🚸 compatible framework version checking added * refactor(utils): 🚸 `getPluginVersion` utils function added get current plugin version * refactor(handlers): 🎨 Replace Promise chaining with `Promise.all` * style(src): 🎨 simpler & improve conditions & functions
- Loading branch information
1 parent
d3dfc92
commit 7ebf1d7
Showing
14 changed files
with
70 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
import { loadEnv } from "vite"; | ||
import type { ViteDevServer } from "vite"; | ||
|
||
import { getFrameworkVersion } from "@utils/version"; | ||
import { appConfig } from "@config/constant"; | ||
import { highlighter } from "@utils/decorate"; | ||
import packageJson from "./../../package.json"; | ||
import { getFrameworkVersion, getPluginVersion } from "@utils/version"; | ||
|
||
export const _handleLogger = (server: ViteDevServer): void => { | ||
const { placeholder } = appConfig; | ||
const { mode, envDir, logger } = server.config; | ||
const appUrl = { | ||
name: "App Url", | ||
version: loadEnv(mode, envDir || process.cwd(), "")[placeholder] ?? "undefined" | ||
}; | ||
|
||
setTimeout(() => { | ||
server.config.logger.info(""); | ||
logger.info(""); | ||
|
||
getFrameworkVersion() | ||
.then((framework) => { | ||
Promise.all([getFrameworkVersion(), getPluginVersion()]) | ||
.then((values) => { | ||
if (server.resolvedUrls) { | ||
server.config.logger.info(highlighter([framework, packageJson])); | ||
for (const value of values) { | ||
logger.info( | ||
highlighter({ | ||
name: value.name, | ||
version: `v${value.version.replace("v", "")}` | ||
}) | ||
); | ||
} | ||
} | ||
|
||
return framework; | ||
}) | ||
.catch((error) => { | ||
server.config.logger.error(error); | ||
logger.error(error); | ||
server.close(); | ||
}); | ||
}) | ||
.finally(() => logger.info("\n" + highlighter(appUrl))); | ||
}, 100); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
/* eslint-disable indent */ | ||
import type { AliasOptions, UserConfig } from "vite"; | ||
import { appConfig } from "@config/constant"; | ||
|
||
export const _resolveAliases = (config: UserConfig): AliasOptions => { | ||
if (Array.isArray(config.resolve?.alias)) { | ||
return [ | ||
...(config.resolve?.alias ?? []), | ||
...Object.keys(appConfig.alias).map((alias) => ({ | ||
find: alias, | ||
replacement: appConfig.alias[alias] | ||
})) | ||
]; | ||
} | ||
return { | ||
...appConfig.alias, | ||
...config.resolve?.alias | ||
}; | ||
}; | ||
export const _resolveAliases = (config: UserConfig): AliasOptions => | ||
Array.isArray(config.resolve?.alias) | ||
? [ | ||
...(config.resolve?.alias ?? []), | ||
...Object.keys(appConfig.alias).map((alias) => ({ | ||
find: alias, | ||
replacement: appConfig.alias[alias] | ||
})) | ||
] | ||
: { ...appConfig.alias, ...config.resolve?.alias }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
import colors from "picocolors"; | ||
import type { JsonVersion } from "src/types"; | ||
|
||
export const highlighter = (plugins: JsonVersion[]): string => { | ||
let versionString = ""; | ||
for (const plugin of plugins) { | ||
versionString = ` ${colors.green("➜")} ${colors.white(plugin.name)}: ${colors.cyan(`v${plugin.version.replace("v", "")}`)}`; | ||
} | ||
return versionString; | ||
}; | ||
export const highlighter = (plugin: JsonVersion): string => | ||
` ${colors.green("➜")} ${colors.white(plugin.name)}: ${colors.cyan(plugin.version)}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": ["./tsconfig.json"], | ||
"compilerOptions": { "rootDir": "./src/" }, | ||
"exclude": ["tests"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters