Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to new config #2962

Merged
merged 46 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
137af27
wip: config migration
Mar 30, 2022
0998a31
fix: formatting
bholmesdev Apr 1, 2022
1f53957
refactor: projectRoot -> root
bholmesdev Apr 1, 2022
bf072d8
refactor: pageUrlFormat -> format
bholmesdev Apr 1, 2022
df642c6
refactor: buildOptions.site -> site
bholmesdev Apr 1, 2022
2dc6b3e
refactor: public -> publicDir
bholmesdev Apr 1, 2022
08d9c02
refactor: dist -> outDir
bholmesdev Apr 1, 2022
a42559e
refactor: styleOptions -> style
bholmesdev Apr 1, 2022
b82564d
fix: some dist tests -> outDir
bholmesdev Apr 1, 2022
835126b
refactor: remove legacyBuild (with TODOs)
bholmesdev Apr 1, 2022
1afeecd
refactor: more legacyBuild cleanup
bholmesdev Apr 1, 2022
0603c07
refactor: server host and port
bholmesdev Apr 1, 2022
d332380
fix: remove experimentalStaticBuild CLI flag
bholmesdev Apr 1, 2022
a29af9c
refactor: src -> srcDir
bholmesdev Apr 1, 2022
959036c
refactor: devOptions.trailing -> trailing
bholmesdev Apr 1, 2022
5318b47
refactor: remove sitemap + related flags
bholmesdev Apr 1, 2022
10d2528
refactor: experimentalSSR -> experimental.ssr
bholmesdev Apr 1, 2022
7837f61
fix: last devOptions
bholmesdev Apr 1, 2022
2cc7682
refactor: drafts -> markdown.drafts
bholmesdev Apr 1, 2022
4ba2bf3
fix: TS error on port as const
bholmesdev Apr 1, 2022
658094e
refactor: remove pages
bholmesdev Apr 1, 2022
9d15648
refactor: more --project-root updates
bholmesdev Apr 1, 2022
8d18719
refactor: markdownOptions -> markdown
bholmesdev Apr 1, 2022
090e301
fix: remaining type errors
bholmesdev Apr 1, 2022
7c38c18
feat: update AstroUserConfig
bholmesdev Apr 1, 2022
e3ddd5f
refactor: update CLI flag mapper + server mapper
bholmesdev Apr 1, 2022
be7b62b
fix: loadFixture projectRoot
bholmesdev Apr 1, 2022
1d3fa13
fix: merge CLI flags before validating / transforming
bholmesdev Apr 1, 2022
4dab14c
wip: attempt to fix bad createRouteManifest config
bholmesdev Apr 1, 2022
1d60488
refactor: combine config.base and config.site
Apr 2, 2022
c8c6f86
fix: skip route manifest test for now
Apr 2, 2022
82ef288
fix: site and base handling
Apr 2, 2022
759c46c
refactor: update failing config testes
Apr 2, 2022
1dda1d0
fix: build failure
Apr 2, 2022
22b045c
feat: update config types with migration help
Apr 2, 2022
9038ff3
chore: update types
Apr 2, 2022
534394b
fix(deno): update deno fixture
Apr 2, 2022
d7cae89
chore: remove config migration logic
Apr 2, 2022
5c0bf81
chore: remove logLevel
Apr 2, 2022
7b4dd45
chore: clean-up config types
Apr 2, 2022
2f5035f
chore: update config warning
Apr 2, 2022
4ee4246
chore: add changeset
Apr 2, 2022
52ca910
Sitemap Integration (#2965)
natemoo-re Apr 2, 2022
ffcb645
fred pass
FredKSchott Apr 2, 2022
35dc594
fix: Astro.resolve typo
Apr 2, 2022
c382bdd
fix: public => publicDir
Apr 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: dist -> outDir
  • Loading branch information
bholmesdev authored and FredKSchott committed Apr 2, 2022
commit 08d9c026901322e2dfac9f627d2c903807ac3219
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { appendForwardSlash } from '../../core/path.js';
const STATUS_CODE_PAGES = new Set(['/404', '/500']);

function getOutRoot(astroConfig: AstroConfig): URL {
return new URL('./', astroConfig.dist);
return new URL('./', astroConfig.outDir);
}

export function getOutFolder(astroConfig: AstroConfig, pathname: string, routeType: RouteType): URL {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function generatePages(result: RollupOutput, opts: StaticBuildOptio

const ssr = isBuildingToSSR(opts.astroConfig);
const serverEntry = opts.buildConfig.serverEntry;
const outFolder = ssr ? opts.buildConfig.server : opts.astroConfig.dist;
const outFolder = ssr ? opts.buildConfig.server : opts.astroConfig.outDir;
const ssrEntryURL = new URL('./' + serverEntry + `?time=${Date.now()}`, outFolder);
const ssrEntry = await import(ssrEntryURL.toString());

Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class AstroBuilder {
private async build({ viteConfig, viteServer }: { viteConfig: ViteConfigWithSSR; viteServer: vite.ViteDevServer }) {
const { origin } = this;
const buildConfig: BuildConfig = {
client: new URL('./client/', this.config.dist),
server: new URL('./server/', this.config.dist),
client: new URL('./client/', this.config.outDir),
server: new URL('./server/', this.config.outDir),
serverEntry: 'entry.mjs',
staticMode: undefined,
};
Expand Down Expand Up @@ -171,7 +171,7 @@ class AstroBuilder {
pageNames.map((pageName) => new URL(pageName, this.config.site).href),
sitemapFilter
);
const sitemapPath = new URL('./sitemap.xml', this.config.dist);
const sitemapPath = new URL('./sitemap.xml', this.config.outDir);
await fs.promises.mkdir(new URL('./', sitemapPath), { recursive: true });
await fs.promises.writeFile(sitemapPath, sitemap, 'utf8');
debug('build', timerMessage('Sitemap built', this.timer.sitemapStart));
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/build/page-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C
if (rssResult.xml) {
const { url, content } = rssResult.xml;
if (content) {
const rssFile = new URL(url.replace(/^\/?/, './'), astroConfig.dist);
const rssFile = new URL(url.replace(/^\/?/, './'), astroConfig.outDir);
if (assets[fileURLToPath(rssFile)]) {
throw new Error(`[getStaticPaths] RSS feed ${url} already exists.\nUse \`rss(data, {url: '...'})\` to choose a unique, custom URL. (${route.component})`);
}
Expand All @@ -115,7 +115,7 @@ export async function collectPagesData(opts: CollectPagesDataOptions): Promise<C
}
if (rssResult.xsl?.content) {
const { url, content } = rssResult.xsl;
const stylesheetFile = new URL(url.replace(/^\/?/, './'), astroConfig.dist);
const stylesheetFile = new URL(url.replace(/^\/?/, './'), astroConfig.outDir);
if (assets[fileURLToPath(stylesheetFile)]) {
throw new Error(
`[getStaticPaths] RSS feed stylesheet ${url} already exists.\nUse \`rss(data, {stylesheet: '...'})\` to choose a unique, custom URL. (${route.component})`
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/scan-based-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function build(opts: ScanBasedBuildOptions): Promise<RollupOutput |
build: {
emptyOutDir: true,
minify: 'esbuild', // significantly faster than "terser" but may produce slightly-bigger bundles
outDir: fileURLToPath(astroConfig.dist),
outDir: fileURLToPath(astroConfig.outDir),
rollupOptions: {
// The `input` will be populated in the build rollup plugin.
input: [],
Expand Down
12 changes: 6 additions & 6 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
// Empty out the dist folder, if needed. Vite has a config for doing this
// but because we are running 2 vite builds in parallel, that would cause a race
// condition, so we are doing it ourselves
emptyDir(astroConfig.dist, new Set('.git'));
emptyDir(astroConfig.outDir, new Set('.git'));

timer.clientBuild = performance.now();
// Run client build first, so the assets can be fed into the SSR rendered version.
Expand All @@ -112,7 +112,7 @@ export async function staticBuild(opts: StaticBuildOptions) {
async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, input: Set<string>) {
const { astroConfig, viteConfig } = opts;
const ssr = isBuildingToSSR(astroConfig);
const out = ssr ? opts.buildConfig.server : astroConfig.dist;
const out = ssr ? opts.buildConfig.server : astroConfig.outDir;

const viteBuildConfig = {
logLevel: 'error',
Expand Down Expand Up @@ -170,7 +170,7 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
const { astroConfig, viteConfig } = opts;
const timer = performance.now();
const ssr = isBuildingToSSR(astroConfig);
const out = ssr ? opts.buildConfig.client : astroConfig.dist;
const out = ssr ? opts.buildConfig.client : astroConfig.outDir;

// Nothing to do if there is no client-side JS.
if (!input.size) {
Expand All @@ -184,7 +184,7 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,

// TODO: use vite.mergeConfig() here?
info(opts.logging, null, `\n${bgGreen(black(' building client '))}`);

const viteBuildConfig = {
logLevel: 'info',
mode: 'production',
Expand Down Expand Up @@ -231,11 +231,11 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
async function cleanSsrOutput(opts: StaticBuildOptions) {
// The SSR output is all .mjs files, the client output is not.
const files = await glob('**/*.mjs', {
cwd: fileURLToPath(opts.astroConfig.dist),
cwd: fileURLToPath(opts.astroConfig.outDir),
});
await Promise.all(
files.map(async (filename) => {
const url = new URL(filename, opts.astroConfig.dist);
const url = new URL(filename, opts.astroConfig.outDir);
await fs.promises.rm(url);
})
);
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/preview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default async function preview(config: AstroConfig, { logging }: PreviewO
const trailingSlash = config.devOptions.trailingSlash;
/** Base request URL. */
let baseURL = new URL(config.site || '/', defaultOrigin);
const staticFileServer = sirv(fileURLToPath(config.dist), {
const staticFileServer = sirv(fileURLToPath(config.outDir), {
dev: true,
etag: true,
maxAge: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export async function runHookBuildSetup({ config, vite, target }: { config: Astr
export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) {
for (const integration of config.integrations) {
if (integration.hooks['astro:build:done']) {
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.dist, routes });
await integration.hooks['astro:build:done']({ pages: pages.map((p) => ({ pathname: p })), dir: config.outDir, routes });
}
}
}
8 changes: 4 additions & 4 deletions packages/astro/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export async function loadFixture(inlineConfig) {
const previewServer = await preview(config, { logging, ...opts });
return previewServer;
},
readFile: (filePath) => fs.promises.readFile(new URL(filePath.replace(/^\//, ''), config.dist), 'utf8'),
readdir: (fp) => fs.promises.readdir(new URL(fp.replace(/^\//, ''), config.dist)),
clean: () => fs.promises.rm(config.dist, { maxRetries: 10, recursive: true, force: true }),
readFile: (filePath) => fs.promises.readFile(new URL(filePath.replace(/^\//, ''), config.outDir), 'utf8'),
readdir: (fp) => fs.promises.readdir(new URL(fp.replace(/^\//, ''), config.outDir)),
clean: () => fs.promises.rm(config.outDir, { maxRetries: 10, recursive: true, force: true }),
loadTestAdapterApp: async () => {
const url = new URL('./server/entry.mjs', config.dist);
const url = new URL('./server/entry.mjs', config.outDir);
const { createApp } = await import(url);
return createApp();
},
Expand Down
8 changes: 4 additions & 4 deletions packages/integrations/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
hooks: {
'astro:config:setup': ({ config }) => {
if (dist) {
config.dist = dist;
config.outDir = dist;
} else {
config.dist = new URL('./netlify/', config.root);
config.outDir = new URL('./netlify/', config.root);
}
},
'astro:config:done': ({ config, setAdapter }) => {
Expand All @@ -33,8 +33,8 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat
},
'astro:build:start': async ({ buildConfig }) => {
entryFile = buildConfig.serverEntry.replace(/\.m?js/, '');
buildConfig.client = _config.dist;
buildConfig.server = new URL('./functions/', _config.dist);
buildConfig.client = _config.outDir;
buildConfig.server = new URL('./functions/', _config.outDir);
},
'astro:build:done': async ({ routes, dir }) => {
const _redirectsURL = new URL('./_redirects', dir);
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/partytown/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function createPlugin(): AstroIntegration {
server.middlewares.use(sirv(partytownLibDirectory, { mount: '/~partytown', dev: true, etag: true, extensions: [] }));
},
'astro:build:done': async () => {
await copyLibFiles(fileURLToPath(new URL('~partytown', config.dist)), { debugDir: false });
await copyLibFiles(fileURLToPath(new URL('~partytown', config.outDir)), { debugDir: false });
},
},
};
Expand Down