diff --git a/.changeset/six-comics-report.md b/.changeset/six-comics-report.md new file mode 100644 index 000000000000..769fa8e730a6 --- /dev/null +++ b/.changeset/six-comics-report.md @@ -0,0 +1,10 @@ +--- +'@sveltejs/adapter-cloudflare-workers': patch +'@sveltejs/adapter-netlify': patch +'@sveltejs/adapter-node': patch +'@sveltejs/adapter-static': patch +'@sveltejs/adapter-vercel': patch +'@sveltejs/kit': patch +--- + +revert adapters automatically updating .gitignore (#1924) diff --git a/documentation/docs/10-adapters.md b/documentation/docs/10-adapters.md index 1514ea3c5d34..fcfb8bbdef15 100644 --- a/documentation/docs/10-adapters.md +++ b/documentation/docs/10-adapters.md @@ -31,15 +31,6 @@ export default { }; ``` -Some adapters may modify your project's `.gitignore` to include their build output. In case you don't want those patterns included you can comment them out: - -```diff -.svelte-kit -.env - -- build -+ # build -``` A variety of official adapters exist for serverless platforms... - [`adapter-cloudflare-workers`](https://github.com/sveltejs/kit/tree/master/packages/adapter-cloudflare-workers) — for [Cloudflare Workers](https://developers.cloudflare.com/workers/) diff --git a/documentation/docs/80-adapter-api.md b/documentation/docs/80-adapter-api.md index 65877d51b728..64e189720312 100644 --- a/documentation/docs/80-adapter-api.md +++ b/documentation/docs/80-adapter-api.md @@ -26,7 +26,6 @@ The types for `Adapter` and its parameters are available in [types/config.d.ts]( Within the `adapt` method, there are a number of things that an adapter should do: - Clear out the build directory -- Call `utils.update_ignores` to ignore build output in existing `.gitignore` files at the location of `svelte.config.js` - Output code that: - Calls `init` - Converts from the platform's request to a [SvelteKit request](#hooks-handle), calls `render`, and converts from a [SvelteKit response](#hooks-handle) to the platform's @@ -35,4 +34,6 @@ Within the `adapt` method, there are a number of things that an adapter should d - Call `utils.prerender` - Put the user's static files and the generated JS/CSS in the correct location for the target platform +If possible, we recommend putting the adapter output under `'.svelte-kit/' + adapterName` with any intermediate output under `'.svelte-kit/' + adapterName + '/intermediate'`. + > The adapter API may change before 1.0. diff --git a/packages/adapter-cloudflare-workers/index.js b/packages/adapter-cloudflare-workers/index.js index 0dd32d8b7a67..c0913dc20024 100644 --- a/packages/adapter-cloudflare-workers/index.js +++ b/packages/adapter-cloudflare-workers/index.js @@ -25,8 +25,6 @@ export default function (options) { const files = fileURLToPath(new URL('./files', import.meta.url)); - utils.update_ignores({ patterns: [bucket, entrypoint] }); - utils.rimraf(bucket); utils.rimraf(entrypoint); diff --git a/packages/adapter-netlify/index.js b/packages/adapter-netlify/index.js index 1dfbeaa95913..24bab59a4047 100644 --- a/packages/adapter-netlify/index.js +++ b/packages/adapter-netlify/index.js @@ -26,8 +26,6 @@ export default function (options) { const files = fileURLToPath(new URL('./files', import.meta.url)); - utils.update_ignores({ patterns: [publish, functions] }); - utils.log.minor('Generating serverless function...'); utils.copy(join(files, 'entry.js'), '.svelte-kit/netlify/entry.js'); diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index 83762f86533e..cfc3a9b702fa 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -42,7 +42,6 @@ export default function ({ name: '@sveltejs/adapter-node', async adapt({ utils, config }) { - utils.update_ignores({ patterns: [out] }); utils.log.minor('Copying assets'); const static_directory = join(out, 'assets'); utils.copy_client_files(static_directory); diff --git a/packages/adapter-static/index.js b/packages/adapter-static/index.js index d684cba3dd48..5155fec1b8a6 100644 --- a/packages/adapter-static/index.js +++ b/packages/adapter-static/index.js @@ -11,7 +11,6 @@ export default function ({ pages = 'build', assets = pages, fallback } = {}) { name: '@sveltejs/adapter-static', async adapt({ utils }) { - utils.update_ignores({ patterns: [pages, assets] }); utils.copy_static_files(assets); utils.copy_client_files(assets); diff --git a/packages/adapter-static/test/apps/prerendered/.gitignore b/packages/adapter-static/test/apps/prerendered/.gitignore index 06f3fb94e666..0a4623184983 100644 --- a/packages/adapter-static/test/apps/prerendered/.gitignore +++ b/packages/adapter-static/test/apps/prerendered/.gitignore @@ -3,5 +3,3 @@ node_modules /.svelte-kit /build /functions - -build diff --git a/packages/adapter-static/test/apps/spa/.gitignore b/packages/adapter-static/test/apps/spa/.gitignore index 06f3fb94e666..0a4623184983 100644 --- a/packages/adapter-static/test/apps/spa/.gitignore +++ b/packages/adapter-static/test/apps/spa/.gitignore @@ -3,5 +3,3 @@ node_modules /.svelte-kit /build /functions - -build diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js index a49673c03b4d..da0322553e72 100644 --- a/packages/adapter-vercel/index.js +++ b/packages/adapter-vercel/index.js @@ -19,8 +19,6 @@ export default function (options) { async adapt({ utils }) { const dir = '.vercel_build_output'; - - utils.update_ignores({ patterns: [dir] }); utils.rimraf(dir); const files = fileURLToPath(new URL('./files', import.meta.url)); diff --git a/packages/kit/src/core/adapt/utils.js b/packages/kit/src/core/adapt/utils.js index 571ad49dd71e..2d6c7b36d871 100644 --- a/packages/kit/src/core/adapt/utils.js +++ b/packages/kit/src/core/adapt/utils.js @@ -1,7 +1,6 @@ import { SVELTE_KIT } from '../constants.js'; import { copy, rimraf, mkdirp } from '../filesystem/index.js'; import { prerender } from './prerender.js'; -import fs from 'fs'; /** * @param {{ @@ -43,25 +42,6 @@ export function get_utils({ cwd, config, build_data, log }) { log }); } - }, - - /** @param {{patterns: string[], log?: boolean}} options */ - update_ignores({ patterns, log = true }) { - const target = '.gitignore'; - if (!fs.existsSync(target)) return; - - const file = fs.readFileSync(target, { encoding: 'utf-8' }); - const eol = file.includes('\r\n') ? '\r\n' : '\n'; - const lines = file.split(eol); - const new_lines = new Set(patterns); - // remove repeated lines - for (const line of lines) { - // this will prevent commented ignores to be reinserted - new_lines.delete(line.replace(/#\s*/, '')); - } - if (new_lines.size === 0) return; - fs.writeFileSync(target, [...lines, ...new_lines].join(eol)); - if (log) this.log.success(`Updated ${target}`); } }; } diff --git a/packages/kit/types/config.d.ts b/packages/kit/types/config.d.ts index 67838f04f07c..6a10d370ba6e 100644 --- a/packages/kit/types/config.d.ts +++ b/packages/kit/types/config.d.ts @@ -9,8 +9,15 @@ export interface AdapterUtils { copy_server_files: (dest: string) => void; copy_static_files: (dest: string) => void; copy: (from: string, to: string, filter?: (basename: string) => boolean) => void; - update_ignores: ({ patterns, log }: { patterns: string[]; log?: boolean }) => void; - prerender: (options: { all?: boolean; dest: string; fallback?: string }) => Promise; + prerender: ({ + all, + dest, + fallback + }: { + all?: boolean; + dest: string; + fallback?: string; + }) => Promise; } export interface Adapter {