[ci] format
This commit is contained in:
parent
5821323285
commit
f224c539c8
2 changed files with 42 additions and 35 deletions
|
@ -376,43 +376,46 @@ export function createRelativeSchema(cmd: string, fileProtocolRoot: string) {
|
||||||
.optional()
|
.optional()
|
||||||
.default({})
|
.default({})
|
||||||
),
|
),
|
||||||
}).transform((config) => {
|
})
|
||||||
// If the user changed outDir but not build.server, build.config, adjust so those
|
.transform((config) => {
|
||||||
// are relative to the outDir, as is the expected default.
|
// If the user changed outDir but not build.server, build.config, adjust so those
|
||||||
if (
|
// are relative to the outDir, as is the expected default.
|
||||||
!config.build.server.toString().startsWith(config.outDir.toString()) &&
|
if (
|
||||||
config.build.server.toString().endsWith('dist/server/')
|
!config.build.server.toString().startsWith(config.outDir.toString()) &&
|
||||||
) {
|
config.build.server.toString().endsWith('dist/server/')
|
||||||
config.build.server = new URL('./dist/server/', config.outDir);
|
) {
|
||||||
}
|
config.build.server = new URL('./dist/server/', config.outDir);
|
||||||
if (
|
}
|
||||||
!config.build.client.toString().startsWith(config.outDir.toString()) &&
|
if (
|
||||||
config.build.client.toString().endsWith('dist/client/')
|
!config.build.client.toString().startsWith(config.outDir.toString()) &&
|
||||||
) {
|
config.build.client.toString().endsWith('dist/client/')
|
||||||
config.build.client = new URL('./dist/client/', config.outDir);
|
) {
|
||||||
}
|
config.build.client = new URL('./dist/client/', config.outDir);
|
||||||
const trimmedBase = trimSlashes(config.base);
|
}
|
||||||
|
const trimmedBase = trimSlashes(config.base);
|
||||||
|
|
||||||
// If there is no base but there is a base for site config, warn.
|
// If there is no base but there is a base for site config, warn.
|
||||||
const sitePathname = config.site && new URL(config.site).pathname;
|
const sitePathname = config.site && new URL(config.site).pathname;
|
||||||
if (!trimmedBase.length && sitePathname && sitePathname !== '/') {
|
if (!trimmedBase.length && sitePathname && sitePathname !== '/') {
|
||||||
config.base = sitePathname;
|
config.base = sitePathname;
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.warn(`The site configuration value includes a pathname of ${sitePathname} but there is no base configuration.
|
console.warn(`The site configuration value includes a pathname of ${sitePathname} but there is no base configuration.
|
||||||
|
|
||||||
A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`);
|
A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trimmedBase.length && config.trailingSlash === 'never') {
|
if (trimmedBase.length && config.trailingSlash === 'never') {
|
||||||
config.base = prependForwardSlash(trimmedBase);
|
config.base = prependForwardSlash(trimmedBase);
|
||||||
} else {
|
} else {
|
||||||
config.base = prependForwardSlash(appendForwardSlash(trimmedBase));
|
config.base = prependForwardSlash(appendForwardSlash(trimmedBase));
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}).refine((obj) => !obj.outDir.toString().startsWith(obj.publicDir.toString()), {
|
})
|
||||||
message: '`outDir` must not be placed inside `publicDir` to prevent an infinite loop. Please adjust the directory configuration and try again'
|
.refine((obj) => !obj.outDir.toString().startsWith(obj.publicDir.toString()), {
|
||||||
});
|
message:
|
||||||
|
'`outDir` must not be placed inside `publicDir` to prevent an infinite loop. Please adjust the directory configuration and try again',
|
||||||
|
});
|
||||||
|
|
||||||
return AstroConfigRelativeSchema;
|
return AstroConfigRelativeSchema;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,13 @@ describe('Config Validation', () => {
|
||||||
expect(configError).to.be.not.instanceOf(Error);
|
expect(configError).to.be.not.instanceOf(Error);
|
||||||
});
|
});
|
||||||
it('Error when outDir is placed within publicDir', async () => {
|
it('Error when outDir is placed within publicDir', async () => {
|
||||||
const configError = await validateConfig({ outDir: './public/dist' }, process.cwd()).catch((err) => err);
|
const configError = await validateConfig({ outDir: './public/dist' }, process.cwd()).catch(
|
||||||
|
(err) => err
|
||||||
|
);
|
||||||
expect(configError instanceof z.ZodError).to.equal(true);
|
expect(configError instanceof z.ZodError).to.equal(true);
|
||||||
expect(configError.errors[0].message).to.equal('`outDir` must not be placed inside `publicDir` to prevent an infinite loop. \
|
expect(configError.errors[0].message).to.equal(
|
||||||
Please adjust the directory configuration and try again')
|
'`outDir` must not be placed inside `publicDir` to prevent an infinite loop. \
|
||||||
|
Please adjust the directory configuration and try again'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue