Skip to content

Commit

Permalink
Disabled static/include path check when in standalone environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Netfloex committed May 12, 2022
1 parent 3623c2a commit d74e83d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
19 changes: 11 additions & 8 deletions src/lib/logMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,17 @@ export const logMessages = defineLogList({
chalk`Config is a promise, waiting until it resolves.`
],

warnNoHost: ({ host }: { host: string }) => [
Log.warn,
Tag.config,
chalk`Could not resolve {yellow ${host}}, normally this would exit.`
],
warnPathNotFound: ({ path }: { path: string }) => [
Log.warn,
Tag.config,
chalk`The path {dim ${path}} could not be found, but since you are using the standalone version you might not need it in this container.`
],

// CSS

downloadCSS: ({ url }: { url: string }) => [
Expand Down Expand Up @@ -500,13 +511,5 @@ export const logMessages = defineLogList({
Log.warn,
Tag.env,
chalk`Could not parse {dim ${string}} to a number, defaulting to ${or}`
],

// DNS

warnNoHost: ({ host }: { host: string }) => [
Log.warn,
Tag.dns,
chalk`Could not resolve {yellow ${host}}, normally this would exit.`
]
} as const);
6 changes: 2 additions & 4 deletions src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export enum Tag {
js,
cloudflare,
env,
nginx,
dns
nginx
}

const TagList: Record<Tag, string> = {
Expand All @@ -37,8 +36,7 @@ const TagList: Record<Tag, string> = {
"5": chalk`[{yellow JS}]`,
"6": chalk`[{hex("#FF8800") CLOUDFLARE}]`,
"7": chalk`[{blue ENV}]`,
"8": chalk`[{green NGINX}]`,
"9": chalk`[{red DNS}]`
"8": chalk`[{green NGINX}]`
};

const TypeList: Record<Log, string> = {
Expand Down
13 changes: 12 additions & 1 deletion src/lib/validateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,18 @@ const pathNameSchema = (error: string) =>
.string()
.transform((str) => resolve(str))
.refine(
async (path) => await pathExists(path),
async (path) => {
const exists = await pathExists(path);
if (exists) return true;

if (settings.standalone) {
logger.warnPathNotFound({ path });

return true;
}

return false;
},
(path) => ({
message: chalk`${error}: {dim ${path}}`
})
Expand Down
3 changes: 2 additions & 1 deletion src/tests/__snapshots__/log.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Error: undefined",
"[NCM] [INFO] [CONFIG] Config is valid undefined",
"[NCM] [WARN] [CONFIG] Config contains undefined, while process.env.undefined was not defined.",
"[NCM] [INFO] [CONFIG] Config is a promise, waiting until it resolves.",
"[NCM] [WARN] [CONFIG] Could not resolve undefined, normally this would exit.",
"[NCM] [WARN] [CONFIG] The path undefined could not be found, but since you are using the standalone version you might not need it in this container.",
"[NCM] [INFO] [CSS] Downloading CSS file... undefined",
"[NCM] [DONE] [CSS] CSS file is cached, skipping: undefined",
"[NCM] [DONE] [CSS] Downloaded CSS file undefined",
Expand All @@ -65,7 +67,6 @@ undefined",
"[NCM] [DONE] [CLOUDFLARE] Cloudflare ip list has been generated. Added undefined ip addresses.",
"[NCM] [ERROR] [CLOUDFLARE] undefined",
"[NCM] [WARN] [ENV] Could not parse undefined to a number, defaulting to undefined",
"[NCM] [WARN] [DNS] Could not resolve undefined, normally this would exit.",
{},
]
`;
2 changes: 2 additions & 0 deletions src/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const settings = {
authPath: r(env.AUTH_PATH, join(dataPath, "auth")),
storePath: r(env.STORE_PATH, join(dataPath, "store.json")),

standalone: env.STANDALONE == "true",

cloudflareExpiry: parseIntDefault(
env.CLOUDFLARE_CACHE_DURATION,
1000 * 60 * 60 * 24 * 7 // 7 Days
Expand Down

0 comments on commit d74e83d

Please sign in to comment.