summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/src/cli/index.ts2
-rw-r--r--packages/astro/src/core/config.ts2
-rw-r--r--packages/telemetry/src/events/session.ts60
-rw-r--r--packages/telemetry/test/session-event.test.js108
4 files changed, 103 insertions, 69 deletions
diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts
index 473b3a6cc..7494f2551 100644
--- a/packages/astro/src/cli/index.ts
+++ b/packages/astro/src/cli/index.ts
@@ -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);
diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts
index 918ed9d90..c868425f9 100644
--- a/packages/astro/src/core/config.ts
+++ b/packages/astro/src/core/config.ts
@@ -442,7 +442,7 @@ export async function openConfig(configOptions: LoadConfigOptions): Promise<Open
astroConfig,
userConfig,
flags,
- root
+ root,
};
}
diff --git a/packages/telemetry/src/events/session.ts b/packages/telemetry/src/events/session.ts
index abe7704a9..d63b87f05 100644
--- a/packages/telemetry/src/events/session.ts
+++ b/packages/telemetry/src/events/session.ts
@@ -19,13 +19,17 @@ interface ConfigInfo {
adapter: string | null;
integrations: string[];
trailingSlash: undefined | 'always' | 'never' | 'ignore';
- build: undefined | {
- format: undefined | 'file' | 'directory'
- };
- markdown: undefined | {
- mode: undefined | 'md' | 'mdx';
- syntaxHighlight: undefined | 'shiki' | 'prism' | false;
- };
+ build:
+ | undefined
+ | {
+ format: undefined | 'file' | 'directory';
+ };
+ markdown:
+ | undefined
+ | {
+ mode: undefined | 'md' | 'mdx';
+ syntaxHighlight: undefined | 'shiki' | 'prism' | false;
+ };
}
interface EventCliSessionInternal extends EventCliSession {
@@ -85,27 +89,33 @@ 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 ? {
- markdownPlugins: [
- userConfig?.markdown?.remarkPlugins ?? [],
- userConfig?.markdown?.rehypePlugins ?? [],
- ].flat(1),
- 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 ? {
- mode: userConfig?.markdown?.mode,
- syntaxHighlight: userConfig.markdown?.syntaxHighlight
- } : undefined,
- } : undefined;
+ const configValues = userConfig
+ ? {
+ markdownPlugins: [
+ userConfig?.markdown?.remarkPlugins ?? [],
+ userConfig?.markdown?.rehypePlugins ?? [],
+ ].flat(1),
+ 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
+ ? {
+ mode: userConfig?.markdown?.mode,
+ 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,
diff --git a/packages/telemetry/test/session-event.test.js b/packages/telemetry/test/session-event.test.js
index c3196787f..70705512f 100644
--- a/packages/telemetry/test/session-event.test.js
+++ b/packages/telemetry/test/session-event.test.js
@@ -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
);
@@ -159,7 +168,7 @@ describe('Session event', () => {
publicDir: 'some/dir',
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -178,7 +187,7 @@ describe('Session event', () => {
'vite.publicDir',
]);
});
-
+
it('vite.resolve keys are captured', async () => {
const config = {
vite: {
@@ -190,7 +199,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -198,9 +207,14 @@ 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 () => {
const config = {
vite: {
@@ -213,7 +227,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -230,7 +244,7 @@ describe('Session event', () => {
'vite.css.postcss',
]);
});
-
+
it('vite.server keys are captured', async () => {
const config = {
vite: {
@@ -244,7 +258,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -262,7 +276,7 @@ describe('Session event', () => {
'vite.server.fs.allow',
]);
});
-
+
it('vite.build keys are captured', async () => {
const config = {
vite: {
@@ -275,7 +289,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -291,7 +305,7 @@ describe('Session event', () => {
'vite.build.cssTarget',
]);
});
-
+
it('vite.preview keys are captured', async () => {
const config = {
vite: {
@@ -304,7 +318,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -320,7 +334,7 @@ describe('Session event', () => {
'vite.preview.another',
]);
});
-
+
it('vite.optimizeDeps keys are captured', async () => {
const config = {
vite: {
@@ -330,7 +344,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -345,7 +359,7 @@ describe('Session event', () => {
'vite.optimizeDeps.exclude',
]);
});
-
+
it('vite.ssr keys are captured', async () => {
const config = {
vite: {
@@ -355,7 +369,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -363,9 +377,14 @@ 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 () => {
const config = {
vite: {
@@ -375,7 +394,7 @@ describe('Session event', () => {
},
},
};
-
+
const [{ payload }] = events.eventCliSession(
{
cliCommand: 'dev',
@@ -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',
]);
- })
- })
+ });
+ });
});