[ci] format
This commit is contained in:
parent
8021998bb6
commit
adc94076f7
4 changed files with 103 additions and 69 deletions
|
@ -176,7 +176,7 @@ export async function cli(args: string[]) {
|
|||
event.eventCliSession(
|
||||
{ astroVersion: process.env.PACKAGE_VERSION ?? '', cliCommand: 'check' },
|
||||
userConfig,
|
||||
flags,
|
||||
flags
|
||||
)
|
||||
);
|
||||
const ret = await check(astroConfig);
|
||||
|
|
|
@ -442,7 +442,7 @@ export async function openConfig(configOptions: LoadConfigOptions): Promise<Open
|
|||
astroConfig,
|
||||
userConfig,
|
||||
flags,
|
||||
root
|
||||
root,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -19,10 +19,14 @@ interface ConfigInfo {
|
|||
adapter: string | null;
|
||||
integrations: string[];
|
||||
trailingSlash: undefined | 'always' | 'never' | 'ignore';
|
||||
build: undefined | {
|
||||
format: undefined | 'file' | 'directory'
|
||||
build:
|
||||
| undefined
|
||||
| {
|
||||
format: undefined | 'file' | 'directory';
|
||||
};
|
||||
markdown: undefined | {
|
||||
markdown:
|
||||
| undefined
|
||||
| {
|
||||
mode: undefined | 'md' | 'mdx';
|
||||
syntaxHighlight: undefined | 'shiki' | 'prism' | false;
|
||||
};
|
||||
|
@ -85,9 +89,10 @@ function configKeys(obj: Record<string, any> | undefined, parentKey: string): st
|
|||
export function eventCliSession(
|
||||
event: EventCliSession,
|
||||
userConfig?: AstroUserConfig,
|
||||
flags?: Record<string, any>,
|
||||
flags?: Record<string, any>
|
||||
): { eventName: string; payload: EventCliSessionInternal }[] {
|
||||
const configValues = userConfig ? {
|
||||
const configValues = userConfig
|
||||
? {
|
||||
markdownPlugins: [
|
||||
userConfig?.markdown?.remarkPlugins ?? [],
|
||||
userConfig?.markdown?.rehypePlugins ?? [],
|
||||
|
@ -95,17 +100,22 @@ export function eventCliSession(
|
|||
adapter: userConfig?.adapter?.name ?? null,
|
||||
integrations: userConfig?.integrations?.map((i: any) => i.name) ?? [],
|
||||
trailingSlash: userConfig?.trailingSlash,
|
||||
build: userConfig?.build ? {
|
||||
format: userConfig?.build?.format
|
||||
} : undefined,
|
||||
markdown: userConfig?.markdown ? {
|
||||
build: userConfig?.build
|
||||
? {
|
||||
format: userConfig?.build?.format,
|
||||
}
|
||||
: undefined,
|
||||
markdown: userConfig?.markdown
|
||||
? {
|
||||
mode: userConfig?.markdown?.mode,
|
||||
syntaxHighlight: userConfig.markdown?.syntaxHighlight
|
||||
} : undefined,
|
||||
} : undefined;
|
||||
syntaxHighlight: userConfig.markdown?.syntaxHighlight,
|
||||
}
|
||||
: undefined,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
// Filter out yargs default `_` flag which is the cli command
|
||||
const cliFlags = flags ? Object.keys(flags).filter(name => name != '_'): undefined;
|
||||
const cliFlags = flags ? Object.keys(flags).filter((name) => name != '_') : undefined;
|
||||
|
||||
const payload: EventCliSessionInternal = {
|
||||
cliCommand: event.cliCommand,
|
||||
|
|
|
@ -32,12 +32,12 @@ describe('Session event', () => {
|
|||
srcDir: 1,
|
||||
build: {
|
||||
format: 'file',
|
||||
}
|
||||
},
|
||||
};
|
||||
const [{ payload }] = events.eventCliSession(
|
||||
{
|
||||
cliCommand: 'dev',
|
||||
astroVersion: '0.0.0'
|
||||
astroVersion: '0.0.0',
|
||||
},
|
||||
config
|
||||
);
|
||||
|
@ -49,12 +49,12 @@ describe('Session event', () => {
|
|||
srcDir: 1,
|
||||
build: {
|
||||
format: 'file',
|
||||
}
|
||||
},
|
||||
};
|
||||
const [{ payload }] = events.eventCliSession(
|
||||
{
|
||||
cliCommand: 'dev',
|
||||
astroVersion: '0.0.0'
|
||||
astroVersion: '0.0.0',
|
||||
},
|
||||
config
|
||||
);
|
||||
|
@ -68,13 +68,13 @@ describe('Session event', () => {
|
|||
srcDir: 1,
|
||||
server: {
|
||||
host: 'example.com',
|
||||
port: 8033
|
||||
}
|
||||
port: 8033,
|
||||
},
|
||||
};
|
||||
const [{ payload }] = events.eventCliSession(
|
||||
{
|
||||
cliCommand: 'dev',
|
||||
astroVersion: '0.0.0'
|
||||
astroVersion: '0.0.0',
|
||||
},
|
||||
config
|
||||
);
|
||||
|
@ -92,36 +92,45 @@ describe('Session event', () => {
|
|||
shikiConfig: {
|
||||
lang: 1,
|
||||
theme: 2,
|
||||
wrap: 3
|
||||
wrap: 3,
|
||||
},
|
||||
syntaxHighlight: 'shiki',
|
||||
remarkPlugins: [],
|
||||
rehypePlugins: [],
|
||||
}
|
||||
},
|
||||
};
|
||||
const [{ payload }] = events.eventCliSession(
|
||||
{
|
||||
cliCommand: 'dev',
|
||||
astroVersion: '0.0.0'
|
||||
astroVersion: '0.0.0',
|
||||
},
|
||||
config
|
||||
);
|
||||
expect(payload.configKeys).to.deep.equal(['publicDir', 'markdown',
|
||||
'markdown.drafts', 'markdown.mode', 'markdown.shikiConfig',
|
||||
'markdown.shikiConfig.lang', 'markdown.shikiConfig.theme', 'markdown.shikiConfig.wrap',
|
||||
'markdown.syntaxHighlight', 'markdown.remarkPlugins', 'markdown.rehypePlugins']);
|
||||
expect(payload.configKeys).to.deep.equal([
|
||||
'publicDir',
|
||||
'markdown',
|
||||
'markdown.drafts',
|
||||
'markdown.mode',
|
||||
'markdown.shikiConfig',
|
||||
'markdown.shikiConfig.lang',
|
||||
'markdown.shikiConfig.theme',
|
||||
'markdown.shikiConfig.wrap',
|
||||
'markdown.syntaxHighlight',
|
||||
'markdown.remarkPlugins',
|
||||
'markdown.rehypePlugins',
|
||||
]);
|
||||
});
|
||||
|
||||
it('mode', () => {
|
||||
const config = {
|
||||
markdown: {
|
||||
mode: 'mdx',
|
||||
}
|
||||
},
|
||||
};
|
||||
const [{ payload }] = events.eventCliSession(
|
||||
{
|
||||
cliCommand: 'dev',
|
||||
astroVersion: '0.0.0'
|
||||
astroVersion: '0.0.0',
|
||||
},
|
||||
config
|
||||
);
|
||||
|
@ -132,12 +141,12 @@ describe('Session event', () => {
|
|||
const config = {
|
||||
markdown: {
|
||||
syntaxHighlight: 'shiki',
|
||||
}
|
||||
},
|
||||
};
|
||||
const [{ payload }] = events.eventCliSession(
|
||||
{
|
||||
cliCommand: 'dev',
|
||||
astroVersion: '0.0.0'
|
||||
astroVersion: '0.0.0',
|
||||
},
|
||||
config
|
||||
);
|
||||
|
@ -198,7 +207,12 @@ describe('Session event', () => {
|
|||
},
|
||||
config
|
||||
);
|
||||
expect(payload.configKeys).is.deep.equal(['vite', 'vite.resolve', 'vite.resolve.alias', 'vite.resolve.dedupe']);
|
||||
expect(payload.configKeys).is.deep.equal([
|
||||
'vite',
|
||||
'vite.resolve',
|
||||
'vite.resolve.alias',
|
||||
'vite.resolve.dedupe',
|
||||
]);
|
||||
});
|
||||
|
||||
it('vite.css keys are captured', async () => {
|
||||
|
@ -363,7 +377,12 @@ describe('Session event', () => {
|
|||
},
|
||||
config
|
||||
);
|
||||
expect(payload.configKeys).is.deep.equal(['vite', 'vite.ssr', 'vite.ssr.external', 'vite.ssr.target']);
|
||||
expect(payload.configKeys).is.deep.equal([
|
||||
'vite',
|
||||
'vite.ssr',
|
||||
'vite.ssr.external',
|
||||
'vite.ssr.target',
|
||||
]);
|
||||
});
|
||||
|
||||
it('vite.worker keys are captured', async () => {
|
||||
|
@ -383,7 +402,12 @@ describe('Session event', () => {
|
|||
},
|
||||
config
|
||||
);
|
||||
expect(payload.configKeys).is.deep.equal(['vite', 'vite.worker', 'vite.worker.format', 'vite.worker.plugins']);
|
||||
expect(payload.configKeys).is.deep.equal([
|
||||
'vite',
|
||||
'vite.worker',
|
||||
'vite.worker.format',
|
||||
'vite.worker.plugins',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -399,7 +423,7 @@ describe('Session event', () => {
|
|||
experimentalSsr: true,
|
||||
experimentalIntegrations: true,
|
||||
drafts: true,
|
||||
}
|
||||
};
|
||||
const [{ payload }] = events.eventCliSession(
|
||||
{
|
||||
cliCommand: 'dev',
|
||||
|
@ -416,8 +440,8 @@ describe('Session event', () => {
|
|||
'config',
|
||||
'experimentalSsr',
|
||||
'experimentalIntegrations',
|
||||
'drafts'
|
||||
'drafts',
|
||||
]);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue