Skip to content

Commit

Permalink
revert #1924
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jul 31, 2021
1 parent 3e30a1b commit 61fee4f
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 53 deletions.
5 changes: 0 additions & 5 deletions .changeset/big-countries-pump.md

This file was deleted.

9 changes: 0 additions & 9 deletions documentation/docs/10-adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
1 change: 0 additions & 1 deletion documentation/docs/80-adapter-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions packages/adapter-cloudflare-workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
1 change: 0 additions & 1 deletion packages/adapter-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion packages/adapter-static/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions packages/adapter-static/test/apps/prerendered/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ node_modules
/.svelte-kit
/build
/functions

build
2 changes: 0 additions & 2 deletions packages/adapter-static/test/apps/spa/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ node_modules
/.svelte-kit
/build
/functions

build
2 changes: 0 additions & 2 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions packages/create-svelte/shared/+eslint+prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"eslint-config-prettier": "^8.1.0"
},
"scripts": {
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
"lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --write --plugin-search-dir=. ."
}
}
4 changes: 4 additions & 0 deletions packages/create-svelte/shared/+prettier/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.svelte-kit/**
static/**
build/**
node_modules/**
4 changes: 2 additions & 2 deletions packages/create-svelte/shared/-eslint+prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scripts": {
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
"lint": "prettier --check --plugin-search-dir=. .",
"format": "prettier --write --plugin-search-dir=. ."
}
}
20 changes: 0 additions & 20 deletions packages/kit/src/core/adapt/utils.js
Original file line number Diff line number Diff line change
@@ -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 {{
Expand Down Expand Up @@ -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}`);
}
};
}
11 changes: 9 additions & 2 deletions packages/kit/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,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<void>;
prerender: ({
all,
dest,
fallback
}: {
all?: boolean;
dest: string;
fallback?: string;
}) => Promise<void>;
}

export interface Adapter {
Expand Down

0 comments on commit 61fee4f

Please sign in to comment.