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

feat: sync new SvelteKit & init test suite #52

Merged
merged 26 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b6dfd03
feat: sync to new SvelteKit version
jthegedus May 11, 2021
91a2f4b
chore: ignore examples dir in precommit xo script
jthegedus May 11, 2021
ae1ca82
test: example functions svelte-kit app
jthegedus May 11, 2021
60d0643
chore: bump tool versions. add Firebase CLI
jthegedus May 11, 2021
48be1a0
docs: new adapter-kit versions
jthegedus May 11, 2021
d6ccad0
test: integration test first pass
jthegedus May 11, 2021
1542d1a
fix: ignore paths of xojs
jthegedus May 11, 2021
cfcfa58
fix: verbose output during svelte-kit build
jthegedus May 11, 2021
0c8a238
ci: properly use cache in workflow
jthegedus May 11, 2021
cb1a07f
fix: typo
jthegedus May 11, 2021
2d8979b
ci: set ASDF_DIR in cicd
jthegedus May 11, 2021
8959856
ci: different cache names for push vs pr events
jthegedus May 11, 2021
0ae6a13
ci: simplify caching
jthegedus May 11, 2021
87bf2ad
ci: comment out caching
jthegedus May 11, 2021
6c26b42
ci: emulator and asdf cache
jthegedus May 11, 2021
d0bf4a4
fix: use correct asdf dir
jthegedus May 11, 2021
094daad
ci: bump cache key
jthegedus May 11, 2021
0a555fb
ci: bump asdf cache name
jthegedus May 11, 2021
68f2b82
ci: asdf install in each job. cach firebase emulator
jthegedus May 11, 2021
fb4b9c8
ci: e2e test
jthegedus May 11, 2021
0368812
Merge branch 'main' into ci/e2e-tests
jthegedus May 11, 2021
2cc1d14
test: use matrix for example tests
jthegedus May 11, 2021
e50c221
test: example cloud run sveltekit site
jthegedus May 11, 2021
c70de0d
test: skip e2e tests for now
jthegedus May 11, 2021
23268f5
chore: bump kit version
jthegedus May 12, 2021
64d4625
fix: cloudrun use package.json of SvelteKit app
jthegedus May 12, 2021
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
19 changes: 0 additions & 19 deletions .github/workflows/test.yaml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Tests

on: [push, pull_request]

env:
CI: true
ASDF_DIR: /home/runner/.asdf
FIREBASE_EMULATORS_PATH: ${{ github.workspace }}/emulator-cache

jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install asdf
uses: asdf-vm/actions/install@v1
with:
before_install: bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
- run: pnpm install
- run: pnpm run test

integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dirs:
- examples/functions_single_site
- examples/run_single_site
steps:
- uses: actions/checkout@v2
- name: install asdf
uses: asdf-vm/actions/install@v1
with:
before_install: bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
- name: Install svelte-adapter-firebase deps
run: pnpm install
- name: Install example app deps
run: pnpm install
working-directory: ${{ matrix.dirs }}
- name: Build example app
run: pnpm run build
working-directory: ${{ matrix.dirs }}
# end-to-end:
# runs-on: ubuntu-latest
# if: github.event_name == 'push'
# needs: [unit, integration]
# steps:
# - uses: actions/checkout@v2
# - name: install asdf
# uses: asdf-vm/actions/install@v1
# with:
# before_install: bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
# - name: Cache firebase emulators
# uses: actions/cache@v2
# with:
# path: ${{ env.FIREBASE_EMULATORS_PATH }}
# key: ${{ runner.os }}-firebase-emulators-${{ hashFiles('emulator-cache/**') }}
# - name: Install svelte-adapter-firebase deps
# run: pnpm install
# - name: Install example app deps
# run: pnpm install
# working-directory: examples/functions_single_site
# - name: Build example app
# run: pnpm run build
# working-directory: examples/functions_single_site
# - name: E2E tests with Firebase Emulator
# run: firebase emulators:exec --only hosting,functions
# working-directory: examples/functions_single_site '[ "$(curl localhost:5000/ -o /dev/stderr -w "%{http_code}")" -eq 200 ]'
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

JS_FILES=$(git diff --cached --name-only --diff-filter=ACMR "*.js" | sed 's| |\\ |g')
JS_FILES=$(git diff --cached --name-only --diff-filter=ACMR "*.js" ":!examples/" | sed 's| |\\ |g')

if [ -n "$JS_FILES" ]; then
# Fix all selected files
Expand Down
5 changes: 3 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
nodejs 16.0.0
pnpm 6.2.4
firebase 9.10.2
nodejs 14.16.1
pnpm 6.3.0
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# svelte-adapter-firebase

[![GitHub Release](https://img.shields.io/github/release/jthegedus/svelte-adapter-firebase.svg?color=green)](https://github.com/jthegedus/svelte-adapter-firebase/releases) [![npm](https://img.shields.io/npm/v/svelte-adapter-firebase?color=green)](https://www.npmjs.com/package/svelte-adapter-firebase) [![Test](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/test.yaml/badge.svg)](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/test.yaml) [![CodeQL](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/codeql-analysis.yml)
[![GitHub Release](https://img.shields.io/github/release/jthegedus/svelte-adapter-firebase.svg?color=green)](https://github.com/jthegedus/svelte-adapter-firebase/releases) [![npm](https://img.shields.io/npm/v/svelte-adapter-firebase?color=green)](https://www.npmjs.com/package/svelte-adapter-firebase) [![Tests](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/test.yml/badge.svg)](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/test.yml) [![CodeQL](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/jthegedus/svelte-adapter-firebase/actions/workflows/codeql-analysis.yml)

[Firebase](https://firebase.google.com/) adapter for [SvelteKit](https://github.com/sveltejs/kit). Support for:

Expand Down Expand Up @@ -48,7 +48,8 @@ Since SvelteKit is still in Beta, and the Adapter API is _most_ in flux, here is

| Adapter Version | SvelteKit Version |
| --------------- | ----------------- |
| `0.6.3` | `1.0.0-next.101` |
| `0.7.x` | `1.0.0-next.107` |
| `0.6.x` | `1.0.0-next.103` |
| `0.5.x` | `1.0.0-next.54` |
| `0.4.x` | `1.0.0-next.46` |
| `0.3.x` | `1.0.0-next.27` |
Expand Down
5 changes: 5 additions & 0 deletions examples/functions_single_site/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "demo"
}
}
19 changes: 19 additions & 0 deletions examples/functions_single_site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.DS_Store
node_modules
/.svelte-kit
/build

# Specific to this app's firebase.json
public/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*
firebase-debug.*.log*

# Firebase cache
.firebase/
1 change: 1 addition & 0 deletions examples/functions_single_site/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
38 changes: 38 additions & 0 deletions examples/functions_single_site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte);

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm init svelte@next

# create a new project in my-app
npm init svelte@next my-app
```

> Note: the `@next` is temporary

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then:

```bash
npm run build
```

> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production.
15 changes: 15 additions & 0 deletions examples/functions_single_site/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"hosting": {
"public": "public",
"site": "svelte-func-single-site",
"rewrites": [
{
"source": "**",
"function": "svelte_function_single_site"
}
]
},
"functions": {
"source": "functions"
}
}
5 changes: 5 additions & 0 deletions examples/functions_single_site/functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/

# Specific to this app's firebase.json
# ignore SvelteKit build output in Cloud Function
svelte_function_single_site/
13 changes: 13 additions & 0 deletions examples/functions_single_site/functions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const functions = require('firebase-functions');

let svelte_function_single_siteServer;
exports.svelte_function_single_site = functions.https.onRequest(async (request, response) => {
if (!svelte_function_single_siteServer) {
functions.logger.info('Initializing SvelteKit SSR Handler');
svelte_function_single_siteServer = require('./svelte_function_single_site/index').default;
functions.logger.info('SvelteKit SSR Handler initialised!');
}

functions.logger.info('Requested resource: ' + request.originalUrl);
return await svelte_function_single_siteServer(request, response);
});
23 changes: 23 additions & 0 deletions examples/functions_single_site/functions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^9.2.0",
"firebase-functions": "^3.11.0"
},
"devDependencies": {
"firebase-functions-test": "^0.2.0"
},
"private": true
}
Loading