Skip to content

Commit 36d115b

Browse files
v1.3.0 (#134)
* feat(core): support serverTimestamp in firestore set (#133) - @james-dowell * fix(ci): remove usage of service account in CI * feat(ci): add creating of Github release to publish workflow * feat(ci): add caching of firebase emulator binaries * chore(deps): update dev dependencies including typescript, eslint and firebase-tools Co-authored-by: James Dowell <[email protected]>
1 parent 3f5b8c5 commit 36d115b

11 files changed

+1407
-1161
lines changed

.eslintrc.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
3-
'extends': [
3+
extends: [
44
'airbnb-base',
55
'prettier',
66
'plugin:@typescript-eslint/recommended',
77
'prettier/@typescript-eslint',
8-
"plugin:jsdoc/recommended"
8+
'plugin:jsdoc/recommended',
99
],
1010
root: true,
11-
plugins: ['@typescript-eslint', 'prettier' , 'jsdoc'],
11+
plugins: ['@typescript-eslint', 'prettier', 'jsdoc'],
1212
settings: {
1313
'import/resolver': {
1414
node: {
1515
moduleDirectory: ['node_modules', '/'],
16-
extensions: ['.js', '.jsx', '.ts', '.tsx']
17-
}
16+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
17+
},
1818
},
1919
react: {
20-
version: '16.0'
21-
}
20+
version: '16.0',
21+
},
2222
},
2323
env: {
2424
browser: true,
25-
node: true
25+
node: true,
2626
},
2727
rules: {
2828
'@typescript-eslint/no-explicit-any': 0,
@@ -41,23 +41,23 @@ module.exports = {
4141
{
4242
singleQuote: true, // airbnb
4343
trailingComma: 'all', // airbnb
44-
}
45-
]
44+
},
45+
],
4646
},
4747
overrides: [
4848
{
4949
files: ['cmds/**'],
5050
rules: {
51-
'comma-dangle': ['error', { 'functions': 'never' }],
51+
'comma-dangle': ['error', { functions: 'never' }],
5252
'@typescript-eslint/explicit-function-return-type': 0,
5353
'prettier/prettier': [
5454
'error',
5555
{
5656
singleQuote: true, // airbnb
5757
trailingComma: 'none', // airbnb
58-
}
59-
]
60-
}
61-
}
62-
]
63-
}
58+
},
59+
],
60+
},
61+
},
62+
],
63+
};

.github/workflows/publish.yml

+35-33
Original file line numberDiff line numberDiff line change
@@ -25,45 +25,37 @@ jobs:
2525
node-version: 12
2626
registry-url: https://registry.npmjs.org/
2727

28-
- name: Get yarn cache
28+
- name: Get cache settings
29+
id: cache-settings
30+
run: |
31+
echo "::set-output name=dir::$(yarn cache dir)"
32+
echo "::set-output name=firebase-tools::$(yarn list -s --depth=0 --pattern firebase-tools | tail -n 1 | sed 's/.*@//g')"
33+
34+
- name: Cache Yarn Dependencies
2935
if: steps.check.outputs.changed == 'true'
30-
id: yarn-cache
31-
run: echo "::set-output name=dir::$(yarn cache dir)"
36+
uses: actions/cache@v1
37+
with:
38+
path: ${{ steps.cache-settings.outputs.dir }}
39+
key: ${{ runner.os }}-yarn-${{ matrix.app }}-${{ hashFiles('yarn.lock') }}
3240

33-
- uses: actions/cache@v1
41+
- name: Cache Firebase Emulator Binaries
3442
if: steps.check.outputs.changed == 'true'
43+
uses: actions/cache@v1
3544
with:
36-
path: ${{ steps.yarn-cache.outputs.dir }}
37-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
45+
path: ~/.cache/firebase/emulators
46+
key: ${{ runner.os }}-firebase-${{ steps.cache-settings.outputs.firebase-tools }}
3847

3948
- name: Install Dependencies
4049
if: steps.check.outputs.changed == 'true'
41-
env:
42-
CI: true
4350
run: yarn install --frozen-lockfile
4451

4552
- name: Check For Lint
4653
if: steps.check.outputs.changed == 'true'
47-
env:
48-
CI: true
4954
run: yarn lint
5055

51-
- name: Expose Test Environment Variables
52-
if: steps.check.outputs.changed == 'true'
53-
env:
54-
SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT }}
55-
GITHUB_HEAD_REF: ${{ github.head_ref }}
56-
GITHUB_REF: ${{ github.ref }}
57-
# Generate Service Account file required to prevent credential error (jq used to format)
58-
run: |
59-
echo "Generating Service Account File..."
60-
echo "$(echo $SERVICE_ACCOUNT | jq .)" > $HOME/serviceAccount.json
61-
echo "::set-env name=GOOGLE_APPLICATION_CREDENTIALS::$HOME/serviceAccount.json"
62-
6356
- name: Run Unit Tests + Coverage
6457
if: steps.check.outputs.changed == 'true'
6558
env:
66-
CI: true
6759
CODE_CLIMATE: ${{ secrets.CODE_CLIMATE }}
6860
run: yarn test:cov
6961

@@ -89,23 +81,33 @@ jobs:
8981
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9082
GITHUB_REF: ${{ github.ref }}
9183
run: |
92-
export GIT_BRANCH=${GITHUB_REF##*/}
93-
export PUBLISH_FLAG=$(if [ "$GITHUB_REF" != 'refs/heads/master' ]; then eval echo '--tag $GIT_BRANCH'; else echo ''; fi;)
94-
npm publish $PUBLISH_FLAG
84+
gitBranch=${GITHUB_REF##*/}
85+
packageVersion=$(cat package.json | jq -r '.version')
86+
publishFlag=$(if [ "$GITHUB_REF" != 'refs/heads/master' ]; then eval echo '--tag $gitBranch'; else echo ''; fi;)
87+
echo "::set-env name=PACKAGE_VERSION::$packageVersion"
88+
npm publish $publishFlag
9589
9690
- name: Archive Build Artifact
9791
if: steps.check.outputs.changed == 'true'
98-
uses: actions/upload-artifact@master
92+
uses: actions/upload-artifact@v2
9993
with:
10094
name: build
10195
path: lib
10296

97+
# Upload to codecov.io. Curl used in place of codecov/codecov-action
98+
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
10399
- name: Upload Coverage
104100
if: steps.check.outputs.changed == 'true'
105-
env:
106-
CI: true
107-
CODE_COV: ${{ secrets.CODE_COV }}
108-
# Upload to Code Cover. Curl used in place of codecov/codecov-action
109-
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
110-
run: curl -s https://codecov.io/bash | bash -s -- -t $CODE_COV
101+
run: bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'
111102

103+
- name: Create Release
104+
if: steps.check.outputs.changed == 'true'
105+
id: create_release
106+
uses: actions/create-release@latest
107+
env:
108+
GITHUB_TOKEN: ${{ github.token }}
109+
with:
110+
tag_name: v${{ env.PACKAGE_VERSION }}
111+
release_name: v${{ env.PACKAGE_VERSION }}
112+
draft: false
113+
prerelease: github.ref != 'refs/heads/master'

.github/workflows/verify.yml

+18-28
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,31 @@ jobs:
1818
with:
1919
node-version: ${{ matrix.node-version }}
2020

21-
- name: Get yarn cache
22-
id: yarn-cache
23-
run: echo "::set-output name=dir::$(yarn cache dir)"
21+
- name: Get cache settings
22+
id: cache-settings
23+
run: |
24+
echo "::set-output name=dir::$(yarn cache dir)"
25+
echo "::set-output name=firebase-tools::$(yarn list -s --depth=0 --pattern firebase-tools | tail -n 1 | sed 's/.*@//g')"
26+
27+
- name: Cache Yarn Dependencies
28+
uses: actions/cache@v1
29+
with:
30+
path: ${{ steps.cache-settings.outputs.dir }}
31+
key: ${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ matrix.app }}-${{ hashFiles('yarn.lock') }}
2432

25-
# Setup dependency caching
26-
- uses: actions/cache@v1
33+
- name: Cache Firebase Emulator Binaries
34+
uses: actions/cache@v1
2735
with:
28-
path: ${{ steps.yarn-cache.outputs.dir }}
29-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
36+
path: ~/.cache/firebase/emulators
37+
key: ${{ runner.os }}-${{ matrix.node-version }}-firebase-${{ steps.cache-settings.outputs.firebase-tools }}
3038

3139
- name: Install Dependencies
32-
env:
33-
CI: true
3440
run: yarn install --frozen-lockfile
3541

3642
- name: Check For Lint
3743
run: yarn lint
3844

39-
- name: Expose Test Environment Variables
40-
env:
41-
SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT }}
42-
GITHUB_HEAD_REF: ${{ github.head_ref }}
43-
GITHUB_REF: ${{ github.ref }}
44-
# Generate Service Account file required to prevent credential error (jq used to format)
45-
run: |
46-
echo "Generating Service Account File..."
47-
echo "$(echo $SERVICE_ACCOUNT | jq .)" > $HOME/serviceAccount.json
48-
echo "::set-env name=GOOGLE_APPLICATION_CREDENTIALS::$HOME/serviceAccount.json"
49-
5045
- name: Run Unit Tests + Coverage
51-
if: success()
5246
run: yarn test:cov
5347

5448
- name: Run Build
@@ -65,11 +59,7 @@ jobs:
6559
- name: Size Check
6660
run: $(yarn bin)/size-limit
6761

62+
# Upload to codecov.io. Curl used in place of codecov/codecov-action
63+
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
6864
- name: Upload Coverage
69-
if: success()
70-
env:
71-
CI: true
72-
CODE_COV: ${{ secrets.CODE_COV }}
73-
# Upload to codecov.io. Curl used in place of codecov/codecov-action
74-
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
75-
run: curl -s https://codecov.io/bash | bash -s -- -t $CODE_COV
65+
run: bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'

.mocharc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
module.exports = {
44
require: ['ts-node/register', './test/setup.ts'],
5-
recursive: true
5+
recursive: true,
6+
timeout: 5000
67
};

index.d.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare module "attachCustomCommands" {
2+
import * as admin from 'firebase-admin';
23
/**
34
* Params for attachCustomCommand function for
45
* attaching custom commands.
@@ -49,6 +50,11 @@ declare module "attachCustomCommands" {
4950
* Limit to last n number of documents
5051
*/
5152
limitToLast?: number;
53+
/**
54+
* Firestore statics (i.e. admin.firestore). This should only be needed during
55+
* testing due to @firebase/testing not containing statics
56+
*/
57+
statics?: typeof admin.firestore;
5258
}
5359
/**
5460
* Action for Real Time Database
@@ -304,7 +310,7 @@ declare module "tasks" {
304310
* @param data - Data to pass to action
305311
* @returns Promise which resolves with results of calling Firestore
306312
*/
307-
export function callFirestore(adminInstance: any, action: FirestoreAction, actionPath: string, options?: CallFirestoreOptions, data?: FixtureData): Promise<any>;
313+
export function callFirestore(adminInstance: admin.app.App, action: FirestoreAction, actionPath: string, options?: CallFirestoreOptions, data?: FixtureData): Promise<any>;
308314
/**
309315
* Create a custom token
310316
* @param adminInstance - Admin SDK instance

package.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "cypress-firebase",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Utilities to help testing Firebase projects with Cypress.",
55
"main": "lib/index.js",
66
"module": "lib/index.js",
7-
"jsnext:main": "lib/index.js",
7+
"jsnext:main": "lib-esm/index.js",
88
"types": "./index.d.ts",
99
"scripts": {
1010
"clean": "rimraf lib lib-esm",
@@ -29,38 +29,38 @@
2929
"firebase-admin": "^8"
3030
},
3131
"devDependencies": {
32-
"@firebase/testing": "^0.19.2",
32+
"@firebase/testing": "^0.19.4",
3333
"@istanbuljs/nyc-config-typescript": "^1.0.1",
3434
"@size-limit/preset-small-lib": "^4.4.5",
3535
"@types/chai": "^4.2.11",
3636
"@types/mocha": "^7.0.2",
37-
"@types/node": "^13.13.4",
37+
"@types/node": "^14.0.1",
3838
"@types/sinon-chai": "^3.2.4",
39-
"@typescript-eslint/eslint-plugin": "^2.30.0",
40-
"@typescript-eslint/parser": "^2.30.0",
39+
"@typescript-eslint/eslint-plugin": "^2.34.0",
40+
"@typescript-eslint/parser": "^2.34.0",
4141
"chai": "^4.2.0",
42-
"eslint": "^6.8.0",
43-
"eslint-config-airbnb-base": "^14.1.0",
42+
"eslint": "^7.3.1",
43+
"eslint-config-airbnb-base": "^14.2.0",
4444
"eslint-config-prettier": "^6.11.0",
4545
"eslint-plugin-babel": "^5.3.0",
46-
"eslint-plugin-import": "^2.20.2",
47-
"eslint-plugin-jsdoc": "^24.0.0",
46+
"eslint-plugin-import": "^2.22.0",
47+
"eslint-plugin-jsdoc": "^28.5.1",
4848
"eslint-plugin-jsx-a11y": "^6.2.3",
4949
"eslint-plugin-prettier": "^3.1.3",
50-
"firebase-admin": "^8.11.0",
51-
"firebase-tools": "^8.2.0",
50+
"firebase-admin": "^8.12.1",
51+
"firebase-tools": "^8.4.3",
5252
"husky": "^4.2.5",
53-
"lint-staged": "^10.2.1",
54-
"mocha": "^7.1.2",
53+
"lint-staged": "^10.2.11",
54+
"mocha": "^8.0.1",
5555
"nyc": "^15.0.0",
5656
"prettier": "^2.0.5",
5757
"rimraf": "^3.0.2",
5858
"sinon": "^9.0.2",
5959
"sinon-chai": "^3.5.0",
60-
"size-limit": "^4.4.5",
60+
"size-limit": "^4.5.0",
6161
"source-map-support": "^0.5.19",
62-
"ts-node": "^8.9.1",
63-
"typescript": "^3.8.3"
62+
"ts-node": "^8.10.1",
63+
"typescript": "^3.9.5"
6464
},
6565
"keywords": [
6666
"cypress",
@@ -105,13 +105,13 @@
105105
{
106106
"name": "CommonJS",
107107
"path": "lib/*.js",
108-
"limit": "9kb",
108+
"limit": "10kb",
109109
"webpack": false
110110
},
111111
{
112112
"name": "ESM",
113113
"path": "lib-esm/*.js",
114-
"limit": "8.5kb",
114+
"limit": "9.5kb",
115115
"webpack": false
116116
}
117117
]

src/attachCustomCommands.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as admin from 'firebase-admin';
2+
13
/**
24
* Params for attachCustomCommand function for
35
* attaching custom commands.
@@ -55,6 +57,11 @@ export interface CallFirestoreOptions {
5557
* Limit to last n number of documents
5658
*/
5759
limitToLast?: number;
60+
/**
61+
* Firestore statics (i.e. admin.firestore). This should only be needed during
62+
* testing due to @firebase/testing not containing statics
63+
*/
64+
statics?: typeof admin.firestore;
5865
}
5966

6067
/**

0 commit comments

Comments
 (0)