Compare commits

...

7 Commits

Author SHA1 Message Date
Rich Harris
666c113297 -> v0.15.6 2018-08-06 22:36:17 -04:00
Rich Harris
84a58f34a0 add test for exporting with custom basepath 2018-08-06 22:35:02 -04:00
Rich Harris
75f5b5c721 Merge pull request #342 from aubergene/gh-338
Remove basepath from deferred urls and add trailing slash to root
2018-08-06 22:06:09 -04:00
Julian Burgess
a176a3b79b Remove basepath from deferred urls and add trailing slash to root request 2018-08-06 16:43:02 +01:00
Rich Harris
1627a5767a -> v0.15.5 2018-08-03 01:18:12 -04:00
Rich Harris
6ff3a9e9ab Merge branch 'master' of github.com:sveltejs/sapper 2018-08-03 01:16:43 -04:00
Rich Harris
3ce2bd30f9 Use npm ci instead of npm install (#336)
* dont write server_info.json either - second half of #318

* use npm ci

* update lockfile

* try this
2018-08-03 01:16:26 -04:00
6 changed files with 34 additions and 11 deletions

View File

@@ -18,4 +18,4 @@ addons:
install: install:
- export DISPLAY=':99.0' - export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- npm install - npm ci || npm i

View File

@@ -1,5 +1,9 @@
# sapper changelog # sapper changelog
## 0.15.6
* Fix exporting with custom basepath ([#342](https://github.com/sveltejs/sapper/pull/342))
## 0.15.5 ## 0.15.5
* Faster `export` with more explanatory output ([#335](https://github.com/sveltejs/sapper/pull/335)) * Faster `export` with more explanatory output ([#335](https://github.com/sveltejs/sapper/pull/335))

View File

@@ -14,7 +14,7 @@ environment:
install: install:
- ps: Install-Product node $env:nodejs_version - ps: Install-Product node $env:nodejs_version
- npm install - npm ci
test_script: test_script:
- node --version && npm --version - node --version && npm --version

View File

@@ -1,6 +1,6 @@
{ {
"name": "sapper", "name": "sapper",
"version": "0.15.4", "version": "0.15.6",
"description": "Military-grade apps, engineered by Svelte", "description": "Military-grade apps, engineered by Svelte",
"main": "dist/middleware.ts.js", "main": "dist/middleware.ts.js",
"bin": { "bin": {

View File

@@ -51,9 +51,10 @@ async function execute(emitter: EventEmitter, {
const port = await ports.find(3000); const port = await ports.find(3000);
const origin = `http://localhost:${port}`; const origin = `http://localhost:${port}`;
const root = new URL(basepath || '', origin);
emitter.emit('info', { emitter.emit('info', {
message: `Crawling ${origin}` message: `Crawling ${root.href}`
}); });
const proc = child_process.fork(path.resolve(`${build}/server.js`), [], { const proc = child_process.fork(path.resolve(`${build}/server.js`), [], {
@@ -71,6 +72,8 @@ async function execute(emitter: EventEmitter, {
const deferreds = new Map(); const deferreds = new Map();
function get_deferred(pathname: string) { function get_deferred(pathname: string) {
pathname = pathname.replace(root.pathname, '');
if (!deferreds.has(pathname)) { if (!deferreds.has(pathname)) {
deferreds.set(pathname, new Deferred()); deferreds.set(pathname, new Deferred());
} }
@@ -107,7 +110,7 @@ async function execute(emitter: EventEmitter, {
}); });
async function handle(url: URL) { async function handle(url: URL) {
const pathname = url.pathname || '/'; const pathname = (url.pathname.replace(root.pathname, '') || '/');
if (seen.has(pathname)) return; if (seen.has(pathname)) return;
seen.add(pathname); seen.add(pathname);
@@ -138,6 +141,9 @@ async function execute(emitter: EventEmitter, {
} }
return ports.wait(port) return ports.wait(port)
.then(() => handle(new URL(`/${basepath}`, origin))) // TODO all static routes .then(() => {
// TODO all static routes
return handle(root);
})
.then(() => proc.kill()); .then(() => proc.kill());
} }

View File

@@ -59,9 +59,19 @@ describe('sapper', function() {
basepath: '/custom-basepath' basepath: '/custom-basepath'
}); });
describe('export', () => { testExport({});
testExport({ basepath: '/custom-basepath' });
});
function testExport({ basepath = '' }) {
describe(basepath ? `export --basepath ${basepath}` : 'export', () => {
before(() => { before(() => {
return exec(`node ${cli} export`); if (basepath) {
process.env.BASEPATH = basepath;
}
return exec(`node ${cli} export ${basepath ? `--basepath ${basepath}` : ''}`);
}); });
it('export all pages', () => { it('export all pages', () => {
@@ -96,7 +106,10 @@ describe('sapper', function() {
'service-worker.js', 'service-worker.js',
'svelte-logo-192.png', 'svelte-logo-192.png',
'svelte-logo-512.png', 'svelte-logo-512.png',
]; ].map(file => {
return basepath ? path.join(basepath.replace(/^\//, ''), file) : file;
});
// Client scripts that should show up in the extraction directory. // Client scripts that should show up in the extraction directory.
const expectedClientRegexes = [ const expectedClientRegexes = [
/client\/[^/]+\/main(\.\d+)?\.js/, /client\/[^/]+\/main(\.\d+)?\.js/,
@@ -126,7 +139,7 @@ describe('sapper', function() {
}); });
}); });
}); });
}); }
function run({ mode, basepath = '' }) { function run({ mode, basepath = '' }) {
describe(`mode=${mode}`, function () { describe(`mode=${mode}`, function () {