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

fix: use SK computed config to determine if static dirs differ #97

Merged
merged 5 commits into from
May 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ SvelteKit is still in Beta and the Adapter API is in flux, this can result in th
| --------------- | ----------------- |
| `0.8.x` | `1.0.0-next.111` |
| `NA` | `1.0.0-next.110` |
| `NA` | `1.0.0-next.109` |
| `0.7.x` | `1.0.0-next.107` |
| `0.6.x` | `1.0.0-next.103` |
| `0.5.x` | `1.0.0-next.54` |
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,18 @@
},
"scripts": {
"prepare": "husky install",
"fix": "xo --ignore examples/ --fix",
"test": "xo --ignore examples/ && ava",
"fix": "xo --fix",
"test": "xo && ava",
"test:e2e": "./tests/e2e-healthcheck.sh"
},
"xo":{
"ignores": [
"examples"
],
"rules": {
"unicorn/prefer-node-protocol": "off"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
Expand Down
10 changes: 3 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {readFileSync, writeFileSync} from 'fs';
import path from 'path';
import {fileURLToPath, pathToFileURL} from 'url';
import {fileURLToPath} from 'url';
import esbuild from 'esbuild';
import kleur from 'kleur';
import {copyFileIfExistsSync,
Expand All @@ -26,15 +26,11 @@ const entrypoint = function ({
/** @type {import('@sveltejs/kit').Adapter} */
const adapter = {
name: 'svelte-adapter-firebase',
async adapt({utils}) {
async adapt({utils, config}) {
utils.log.minor(`Adapter configuration:\n\t${kleur.italic(JSON.stringify({firebaseJson, hostingSite, sourceRewriteMatch, cloudRunBuildDir}))}`);
const {firebaseJsonDir, functions, cloudRun, publicDir} = parseFirebaseConfiguration({firebaseJson, hostingSite, sourceRewriteMatch});

// START: Temporary solution until - https://github.com/sveltejs/kit/issues/1435 - is resolved
const svelteConfig = await import(pathToFileURL(path.join(process.cwd(), 'svelte.config.js')).toString());
const svelteStaticDir = path.join(process.cwd(), svelteConfig?.kit?.files?.assets || 'static');
ensureStaticResourceDirsDiffer({source: svelteStaticDir, dest: publicDir});
// END
ensureStaticResourceDirsDiffer({source: path.join(process.cwd(), config.kit.files.assets), dest: publicDir});

if (functions !== false) {
await adaptToCloudFunctions({utils, ...functions});
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava';
import {fileURLToPath} from 'url';
import path from 'path';
import test from 'ava';
import {ensureCompatibleCloudFunctionVersion, ensureStaticResourceDirsDiffer, parseFirebaseConfiguration, validCloudFunctionName, validCloudRunServiceId} from '../src/utils.js';

// ParseFirebaseConfiguration: Valid configs
Expand Down