Skip to content

Commit

Permalink
feat: drop support for node below 16 (#760)
Browse files Browse the repository at this point in the history
* feat: update node build version to 16 (#746)
* feat: remove all file system interaction directly in cypress-firebase
* chore: update badge in readme

BREAKING CHANGE: Drop support for Node versions below 16
Build for Node 16 (previously Node 12)
Drop support for environment variables auto-prefixed by CI env (such as `STAGE_SERVICE_ACCOUNT`) (#759)
Drop support for loading default service account file at ./serviceAccount.json - `GOOGLE_APPLICATION_CREDENTIALS` env variable should be used instead [as described in Firebase docs](https://firebase.google.com/docs/admin/setup#initialize-sdk)
  • Loading branch information
prescottprue authored Dec 31, 2022
1 parent 9e0ee0f commit e99e3e5
Show file tree
Hide file tree
Showing 14 changed files with 1,793 additions and 1,678 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
group: publish-${{ github.ref }}

env:
NODE_VERSION: 14.x
NODE_VERSION: 16.x

jobs:
publish-npm:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.x, 18.x]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Upload Test Coverage
uses: codecov/codecov-action@v3
if: matrix.node-version == '14.x'
if: matrix.node-version == '16.x'
with:
fail_ci_if_error: false

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,8 @@ If you experience this with an SDK version newer than v7 please create a new iss
[npm-image]: https://img.shields.io/npm/v/cypress-firebase.svg?style=flat-square
[npm-url]: https://npmjs.org/package/cypress-firebase
[npm-downloads-image]: https://img.shields.io/npm/dm/cypress-firebase.svg?style=flat-square
[build-status-image]: https://img.shields.io/github/workflow/status/prescottprue/cypress-firebase/NPM%20Package%20Publish?style=flat-square&logo=github
[build-status-url]: https://github.com/prescottprue/cypress-firebase/actions
[build-status-image]: https://img.shields.io/github/actions/workflow/status/prescottprue/cypress-firebase/publish.yml?branch=main&style=flat-square
[build-status-url]: https://github.com/prescottprue/cypress-firebase/actions/workflows/publish.yml
[coverage-image]: https://img.shields.io/codecov/c/gh/prescottprue/cypress-firebase?style=flat-square&logo=codecov
[coverage-url]: https://codecov.io/gh/prescottprue/cypress-firebase
[license-image]: https://img.shields.io/npm/l/cypress-firebase.svg?style=flat-square
Expand Down
53 changes: 27 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "cypress-firebase",
"version": "2.2.1",
"version": "0.0.0-development",
"description": "Utilities to help testing Firebase projects with Cypress.",
"main": "lib/index.js",
"module": "lib/index.js",
"module": "lib-esm/index.js",
"jsnext:main": "lib-esm/index.js",
"types": "lib/index.d.ts",
"scripts": {
Expand All @@ -15,53 +15,54 @@
"watch:es": "yarn build:esm --watch",
"lint": "eslint . --ext .js,.ts",
"lint:fix": "yarn lint --fix",
"test:base": "mocha ./test/unit/**/*.spec.ts",
"test:base": "GCLOUD_PROJECT=test-project mocha ./test/unit/**/*.spec.ts",
"test:cov:base": "nyc --reporter=lcov --reporter=html yarn test:base",
"test:watch": "yarn test:base --watch",
"emulators": "firebase emulators:start --only firestore,database",
"emulators": "firebase emulators:start --only firestore,database --project test-project",
"test": "firebase emulators:exec --only firestore,database \"yarn test:base\"",
"test:cov": "firebase emulators:exec --only firestore,database \"yarn test:cov:base\"",
"size": "yarn build && size-limit",
"prepare": "husky install && yarn clean && yarn build"
},
"peerDependencies": {
"firebase-admin": ">=8"
"firebase-admin": "^11.0.0"
},
"devDependencies": {
"@commitlint/cli": "16.3.0",
"@commitlint/config-conventional": "16.2.4",
"@firebase/rules-unit-testing": "1.3.16",
"@commitlint/cli": "17.3.0",
"@commitlint/config-conventional": "17.3.0",
"@firebase/rules-unit-testing": "2.0.5",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@size-limit/preset-small-lib": "7.0.3",
"@size-limit/webpack": "7.0.3",
"@tsconfig/node12": "1.0.11",
"@size-limit/preset-small-lib": "8.1.0",
"@size-limit/webpack": "8.1.0",
"@tsconfig/node16": "1.0.3",
"@types/chai": "4.3.4",
"@types/mocha": "9.1.1",
"@types/mocha": "10.0.1",
"@types/node": "16.18.11",
"@types/sinon-chai": "3.2.9",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"@typescript-eslint/eslint-plugin": "5.47.1",
"@typescript-eslint/parser": "5.47.1",
"chai": "4.3.7",
"cypress": "10.11.0",
"eslint": "8.29.0",
"cypress": "12.2.0",
"eslint": "8.31.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsdoc": "37.9.7",
"eslint-plugin-jsdoc": "39.6.4",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-prettier": "4.2.1",
"firebase-admin": "10.3.0",
"firebase-tools": "10.9.2",
"husky": "7.0.4",
"lint-staged": "12.5.0",
"mocha": "9.2.2",
"firebase": "9.15.0",
"firebase-admin": "11.4.1",
"firebase-tools": "11.19.0",
"husky": "8.0.2",
"lint-staged": "13.1.0",
"mocha": "10.2.0",
"nyc": "15.1.0",
"prettier": "2.8.1",
"rimraf": "3.0.2",
"sinon": "13.0.2",
"sinon": "15.0.1",
"sinon-chai": "3.7.0",
"size-limit": "7.0.3",
"size-limit": "8.1.0",
"ts-node": "10.9.1",
"typescript": "4.9.4"
},
Expand Down Expand Up @@ -109,14 +110,14 @@
"name": "CommonJS: attachCustomCommands",
"path": "lib/index.js",
"import": "{ attachCustomCommands }",
"limit": "10kb",
"limit": "7kb",
"webpack": false
},
{
"name": "CommonJS: plugin",
"path": "lib/index.js",
"import": "{ plugin }",
"limit": "10kb",
"limit": "7kb",
"webpack": false
},
{
Expand Down
9 changes: 8 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>prescottprue/renovate-config:library"]
"extends": ["github>prescottprue/renovate-config:library"],
"packageRules": [
{
"description": "Prevent upgrade of Node build version past 16 (until build version updated)",
"matchPackageNames": ["node", "@types/node"],
"allowedVersions": "^16"
}
]
}
36 changes: 35 additions & 1 deletion src/firebase-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { AppOptions, app, firestore, credential } from 'firebase-admin';
import { getServiceAccount } from './node-utils';
import { CallFirestoreOptions, WhereOptions } from './attachCustomCommands';
import { convertValueToTimestampOrGeoPointIfPossible } from './tasks';

Expand Down Expand Up @@ -36,6 +35,41 @@ function firestoreSettingsFromEnv(): FirebaseFirestore.Settings {
};
}

/* eslint-disable camelcase */
interface ServiceAccount {
type: string;
project_id: string;
private_key_id: string;
private_key: string;
client_email: string;
client_id: string;
auth_uri: string;
token_uri: string;
auth_provider_x509_cert_url: string;
client_x509_cert_url: string;
}
/* eslint-enable camelcase */

/**
* Get service account from either SERVICE_ACCOUNT environment variable
* @returns Service account object
*/
function getServiceAccount(): ServiceAccount | undefined {
// Environment variable
const serviceAccountEnvVar = process.env.SERVICE_ACCOUNT;
if (serviceAccountEnvVar) {
try {
return JSON.parse(serviceAccountEnvVar);
} catch (err) {
/* eslint-disable no-console */
console.warn(
`cypress-firebase: Issue parsing "SERVICE_ACCOUNT" environment variable from string to object, returning string`,
);
/* eslint-enable no-console */
}
}
}

/**
* @param adminInstance - firebase-admin instance to initialize
* @returns Firebase admin credential
Expand Down
149 changes: 0 additions & 149 deletions src/node-utils.ts

This file was deleted.

6 changes: 3 additions & 3 deletions test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import sinonChai from 'sinon-chai';
const projectId = 'test-project';
const databaseEmulatorPort = 9000;
const firstoreEmulatorPort = 8080;
const databaseURL = `http://localhost:${databaseEmulatorPort}?ns=${projectId}`;
const databaseURL = `http://127.0.0.1:${databaseEmulatorPort}?ns=${projectId}`;

// Set environment variables
process.env.NODE_ENV = 'test';
process.env.GCLOUD_PROJECT = projectId;
process.env.FIREBASE_DATABASE_EMULATOR_HOST = `localhost:${databaseEmulatorPort}`;
process.env.FIRESTORE_EMULATOR_HOST = `localhost:${firstoreEmulatorPort}`;
process.env.FIREBASE_DATABASE_EMULATOR_HOST = `127.0.0.1:${databaseEmulatorPort}`;
process.env.FIRESTORE_EMULATOR_HOST = `127.0.0.1:${firstoreEmulatorPort}`;

chai.use(sinonChai);

Expand Down
Loading

0 comments on commit e99e3e5

Please sign in to comment.