-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* start work on #166 * remove typescript * remove ts-node in favour of esm * Build kit package with sucrase * Convert tests to use sucrase * get build working again * fix gitignore files * add back some missing files * tidy up * bit more tidying * restrict uvu pattern * copy client files, not everything * remove generated file * implement adapter-static using builder API * ignore generated file * get svelte-kit-demo example working * update lockfile * add back svelte eslint config peer dependencies * move render logic into kit * update test * update adapter-netlify * fixes * simplify adapter-netlify * use netlify in hn example * add use strict pragmas * remove unused dependency * update lockfile * tidy up * update snowpack config * add changeset Co-authored-by: Ben McCann <[email protected]>
- Loading branch information
1 parent
104d962
commit b475ed4
Showing
51 changed files
with
621 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
'hn.svelte.dev': patch | ||
'svelte-kit-demo': patch | ||
'@sveltejs/adapter-netlify': patch | ||
'@sveltejs/adapter-node': patch | ||
'@sveltejs/adapter-static': patch | ||
'@sveltejs/app-utils': patch | ||
'@sveltejs/kit': patch | ||
'@sveltejs/snowpack-config': patch | ||
--- | ||
|
||
Overhaul adapter API - fixes #166 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[build] | ||
command = "npm run build" | ||
publish = "build/" | ||
functions = "functions/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
.DS_Store | ||
node_modules | ||
/index.js | ||
/render.js | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
const url = require('url'); | ||
const app = require('./app.js'); | ||
|
||
exports.handler = async (event) => { | ||
const { | ||
path, | ||
httpMethod, | ||
headers, | ||
queryStringParameters | ||
// body, // TODO pass this to renderer | ||
// isBase64Encoded // TODO is this useful? | ||
} = event; | ||
|
||
const query = new url.URLSearchParams(); | ||
for (const k in queryStringParameters) { | ||
const value = queryStringParameters[k]; | ||
value.split(', ').forEach((v) => { | ||
query.append(k, v); | ||
}); | ||
} | ||
|
||
const rendered = await app.render({ | ||
host: null, // TODO | ||
method: httpMethod, | ||
headers, | ||
path, | ||
query | ||
}); | ||
|
||
if (rendered) { | ||
return { | ||
isBase64Encoded: false, | ||
statusCode: rendered.status, | ||
headers: rendered.headers, | ||
body: rendered.body | ||
}; | ||
} | ||
|
||
return { | ||
statusCode: 404, | ||
body: 'Not found' | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const toml = require('toml'); | ||
|
||
module.exports = async function adapter(builder) { | ||
let netlify_config; | ||
|
||
if (fs.existsSync('netlify.toml')) { | ||
try { | ||
netlify_config = toml.parse(fs.readFileSync('netlify.toml', 'utf-8')); | ||
} catch (err) { | ||
err.message = `Error parsing netlify.toml: ${err.message}`; | ||
throw err; | ||
} | ||
} else { | ||
// TODO offer to create one? | ||
throw new Error( | ||
'Missing a netlify.toml file. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration' | ||
); | ||
} | ||
|
||
if (!netlify_config.build || !netlify_config.build.publish || !netlify_config.build.functions) { | ||
throw new Error( | ||
'You must specify build.publish and build.functions in netlify.toml. Consult https://github.com/sveltejs/adapter-netlify#configuration' | ||
); | ||
} | ||
|
||
const publish = path.resolve(netlify_config.build.publish); | ||
const functions = path.resolve(netlify_config.build.functions); | ||
|
||
builder.copy_static_files(publish); | ||
builder.copy_client_files(`${publish}/_app`); | ||
builder.copy_server_files(`${functions}/render`); | ||
|
||
// copy the renderer | ||
fs.copyFileSync(path.resolve(__dirname, 'files/render.js'), `${functions}/render/index.js`); | ||
|
||
// create _redirects | ||
fs.writeFileSync(`${publish}/_redirects`, '/* /.netlify/functions/render 200'); | ||
|
||
// prerender | ||
builder.log.info('Prerendering static pages...'); | ||
await builder.prerender({ | ||
dest: publish | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,16 @@ | ||
{ | ||
"name": "@sveltejs/adapter-netlify", | ||
"version": "0.0.11", | ||
"devDependencies": { | ||
"@sveltejs/app-utils": "workspace:*", | ||
"@types/aws-lambda": "^8.10.64", | ||
"devalue": "^2.0.1", | ||
"rollup": "^2.32.0" | ||
}, | ||
"main": "index.js", | ||
"files": [ | ||
"render.js" | ||
"files" | ||
], | ||
"scripts": { | ||
"dev": "rollup -cw", | ||
"build": "rollup -c", | ||
"lint": "eslint --ignore-pattern node_modules/ --ignore-pattern render.js \"**/*.{ts,js,svelte}\" && npm run check-format", | ||
"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore", | ||
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore", | ||
"prepublishOnly": "npm run build" | ||
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore" | ||
}, | ||
"dependencies": { | ||
"kleur": "^4.1.3", | ||
"tiny-glob": "^0.2.8", | ||
"toml": "^3.0.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
index.js | ||
index.d.ts | ||
server.js | ||
server.d.ts | ||
/files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
module.exports = async function adapter(builder) { | ||
const out = 'build'; // TODO implement adapter options | ||
|
||
builder.copy_server_files(out); | ||
builder.copy_client_files(`${out}/assets/_app`); | ||
|
||
fs.copyFileSync(`${__dirname}/files/server.js`, `${out}/index.js`); | ||
|
||
builder.log.info('Prerendering static pages...'); | ||
await builder.prerender({ | ||
dest: `${out}/prerendered` | ||
}); | ||
}; |
Oops, something went wrong.