-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from vordgi/nic-21
nic-21 configure husky
- Loading branch information
Showing
19 changed files
with
109 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pnpm run lint |
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 +1 @@ | ||
export const buildConfig = process.env.NIMPL_CONFIG_BUILD && JSON.parse(process.env.NIMPL_CONFIG_BUILD); | ||
export const buildConfig = process.env.NIMPL_CONFIG_BUILD && JSON.parse(process.env.NIMPL_CONFIG_BUILD); |
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,8 +1,8 @@ | ||
import getConfig from "./get-config"; | ||
|
||
const getBuildConfig = async (configFolder?: string) => { | ||
const config = await getConfig({ variant: 'build', configFolder }); | ||
const config = await getConfig({ variant: "build", configFolder }); | ||
return config; | ||
} | ||
}; | ||
|
||
export default getBuildConfig; |
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,8 +1,8 @@ | ||
import getConfig from "./get-config"; | ||
|
||
const getRuntimeConfig = async (configFolder?: string) => { | ||
const config = await getConfig({ variant: 'runtime', configFolder }); | ||
const config = await getConfig({ variant: "runtime", configFolder }); | ||
return config; | ||
} | ||
}; | ||
|
||
export default getRuntimeConfig; |
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,8 +1,8 @@ | ||
import getConfig from "./get-config"; | ||
|
||
const getServerConfig = async (configFolder?: string) => { | ||
const config = await getConfig({ variant: 'server', configFolder }); | ||
const config = await getConfig({ variant: "server", configFolder }); | ||
return config; | ||
} | ||
}; | ||
|
||
export default getServerConfig; |
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,31 +1,29 @@ | ||
import type { EnvConfig, EnvConfigItem } from "./types"; | ||
|
||
const injectEnvs = (part: EnvConfigItem): EnvConfigItem => { | ||
if (typeof part === 'string') { | ||
if (typeof part === "string") { | ||
return process.env[part]; | ||
} | ||
|
||
if (Array.isArray(part)) { | ||
return part.map(injectEnvs); | ||
} | ||
|
||
if (part && typeof part === 'object') { | ||
if (part && typeof part === "object") { | ||
const newPart: EnvConfigItem = {}; | ||
Object.entries(part).map(([key, value]) => ( | ||
newPart[key] = injectEnvs(value) | ||
)); | ||
Object.entries(part).map(([key, value]) => (newPart[key] = injectEnvs(value))); | ||
return newPart; | ||
} | ||
|
||
throw new Error(`Invalid value in envs config: ${part}`) | ||
} | ||
throw new Error(`Invalid value in envs config: ${part}`); | ||
}; | ||
|
||
export const injectEnvsToConfig = (config: EnvConfig) => { | ||
const newConfig: EnvConfig = {}; | ||
|
||
Object.entries(config).map(([key, value]) => { | ||
newConfig[key] = injectEnvs(value); | ||
}) | ||
}); | ||
|
||
return newConfig; | ||
} | ||
}; |
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,17 +1,17 @@ | ||
type ConfigItemEl = string | boolean | number | null; | ||
|
||
type ConfigItemFunc = () => (ConfigItem | Promise<ConfigItem>); | ||
type ConfigItemFunc = () => ConfigItem | Promise<ConfigItem>; | ||
|
||
export type ConfigItem = {[key: string]: ConfigItem} | ConfigItem[] | ConfigItemEl | ConfigItemFunc; | ||
export type ConfigItem = { [key: string]: ConfigItem } | ConfigItem[] | ConfigItemEl | ConfigItemFunc; | ||
|
||
export type Config = { | ||
[key: string]: ConfigItem; | ||
} | ||
}; | ||
|
||
type EnvConfigItemEl = string | boolean | number | null | undefined; | ||
|
||
export type EnvConfigItem = {[key: string]: EnvConfigItem} | EnvConfigItem[] | EnvConfigItemEl; | ||
export type EnvConfigItem = { [key: string]: EnvConfigItem } | EnvConfigItem[] | EnvConfigItemEl; | ||
|
||
export type EnvConfig = { | ||
[key: string]: EnvConfigItem; | ||
} | ||
}; |
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,3 +1,5 @@ | ||
const configs: {[key: string]: any} | undefined = process.env.NIMPL_CONFIG_POSTBUILD && JSON.parse(process.env.NIMPL_CONFIG_POSTBUILD); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const configs: { [key: string]: any } | undefined = | ||
process.env.NIMPL_CONFIG_POSTBUILD && JSON.parse(process.env.NIMPL_CONFIG_POSTBUILD); | ||
|
||
export const postbuildConfig = process.env.NODE_ENV && configs?.[process.env.NODE_ENV] || null; | ||
export const postbuildConfig = (process.env.NODE_ENV && configs?.[process.env.NODE_ENV]) || null; |
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,8 +1,8 @@ | ||
import getRuntimeConfig from './lib/get-runtime-config'; | ||
import getRuntimeConfig from "./lib/get-runtime-config"; | ||
|
||
const runtimeConfig = getRuntimeConfig(process.env.NIMPL_CONFIG_FOLDER); | ||
|
||
export const runtimeConfigApi = async () => { | ||
const config = await runtimeConfig; | ||
return Response.json(config); | ||
} | ||
}; |
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
Oops, something went wrong.