Skip to content

Commit 63be0d3

Browse files
authored
chore: Updated package.json file for entry points (#1176)
* chore: Added package.json files for all entry points * fix: Added newline at eof * chore: Bumped minimum Node version to 12; Added typeVersions workaround
1 parent 56bdc81 commit 63be0d3

File tree

5 files changed

+166
-6
lines changed

5 files changed

+166
-6
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [10.x, 12.x, 14.x]
12+
node-version: [12.x, 14.x]
1313

1414
steps:
1515
- uses: actions/checkout@v1

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Set up Node.js
4848
uses: actions/setup-node@v1
4949
with:
50-
node-version: 10.x
50+
node-version: 12.x
5151

5252
- name: Install and build
5353
run: |
@@ -115,7 +115,7 @@ jobs:
115115
- name: Set up Node.js
116116
uses: actions/setup-node@v1
117117
with:
118-
node-version: 10.x
118+
node-version: 12.x
119119

120120
- name: Publish preflight check
121121
id: preflight

package.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache-2.0",
77
"homepage": "https://firebase.google.com/",
88
"engines": {
9-
"node": ">=10.10.0"
9+
"node": ">=12.7.0"
1010
},
1111
"scripts": {
1212
"build": "gulp build",
@@ -55,6 +55,35 @@
5555
"package.json"
5656
],
5757
"types": "./lib/index.d.ts",
58+
"typesVersions": {
59+
"*": {
60+
"app": ["lib/app"],
61+
"auth": ["lib/auth"],
62+
"database": ["lib/database"],
63+
"firestore": ["lib/firestore"],
64+
"instance-id": ["lib/instance-id"],
65+
"machine-learning": ["lib/machine-learning"],
66+
"messaging": ["lib/messaging"],
67+
"project-management": ["lib/project-management"],
68+
"remote-config": ["lib/remote-config"],
69+
"security-rules": ["lib/security-rules"],
70+
"storage": ["lib/storage"]
71+
}
72+
},
73+
"exports": {
74+
".": "./lib/index.js",
75+
"./app": "./lib/app/index.js",
76+
"./auth": "./lib/auth/index.js",
77+
"./database": "./lib/database/index.js",
78+
"./firestore": "./lib/firestore/index.js",
79+
"./instance-id": "./lib/instance-id/index.js",
80+
"./machine-learning": "./lib/machine-learning/index.js",
81+
"./messaging": "./lib/messaging/index.js",
82+
"./project-management": "./lib/project-management/index.js",
83+
"./remote-config": "./lib/remote-config/index.js",
84+
"./security-rules": "./lib/security-rules/index.js",
85+
"./storage": "./lib/storage/index.js"
86+
},
5887
"dependencies": {
5988
"@firebase/database": "^0.8.1",
6089
"@firebase/database-types": "^0.6.1",
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*!
2+
* @license
3+
* Copyright 2021 Google Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { expect } from 'chai';
19+
20+
import { cert, deleteApp, initializeApp, App } from 'firebase-admin/app';
21+
import { getAuth, Auth } from 'firebase-admin/auth';
22+
import { getDatabase, getDatabaseWithUrl, Database, ServerValue } from 'firebase-admin/database';
23+
import { getFirestore, DocumentReference, Firestore, FieldValue } from 'firebase-admin/firestore';
24+
import { getInstanceId, InstanceId } from 'firebase-admin/instance-id';
25+
import { getMachineLearning, MachineLearning } from 'firebase-admin/machine-learning';
26+
import { getMessaging, Messaging } from 'firebase-admin/messaging';
27+
import { getProjectManagement, ProjectManagement } from 'firebase-admin/project-management';
28+
import { getRemoteConfig, RemoteConfig } from 'firebase-admin/remote-config';
29+
import { getSecurityRules, SecurityRules } from 'firebase-admin/security-rules';
30+
import { getStorage, Storage } from 'firebase-admin/storage';
31+
32+
import { Bucket } from '@google-cloud/storage';
33+
34+
35+
// eslint-disable-next-line @typescript-eslint/no-var-requires
36+
const serviceAccount = require('../mock.key.json');
37+
38+
describe('Modular API', () => {
39+
let app: App;
40+
41+
before(() => {
42+
app = initializeApp({
43+
credential: cert(serviceAccount),
44+
databaseURL: 'https://mock.firebaseio.com'
45+
}, 'TestApp');
46+
});
47+
48+
after(() => {
49+
return deleteApp(app);
50+
});
51+
52+
it('Should return an initialized App', () => {
53+
expect(app.name).to.equal('TestApp');
54+
});
55+
56+
it('Should return an Auth client', () => {
57+
const client = getAuth(app);
58+
expect(client).to.be.instanceOf(Auth);
59+
});
60+
61+
it('Should return a Messaging client', () => {
62+
const client = getMessaging(app);
63+
expect(client).to.be.instanceOf(Messaging);
64+
});
65+
66+
it('Should return a ProjectManagement client', () => {
67+
const client = getProjectManagement(app);
68+
expect(client).to.be.instanceOf(ProjectManagement);
69+
});
70+
71+
it('Should return a SecurityRules client', () => {
72+
const client = getSecurityRules(app);
73+
expect(client).to.be.instanceOf(SecurityRules);
74+
});
75+
76+
it('Should return a Database client', () => {
77+
const db: Database = getDatabase(app);
78+
expect(db).to.be.not.undefined;
79+
expect(typeof db.getRules).to.equal('function');
80+
});
81+
82+
it('Should return a Database client for URL', () => {
83+
const db: Database = getDatabaseWithUrl('https://other-mock.firebaseio.com', app);
84+
expect(db).to.be.not.undefined;
85+
expect(typeof db.getRules).to.equal('function');
86+
});
87+
88+
it('Should return a Database ServerValue', () => {
89+
expect(ServerValue.increment(1)).to.be.not.undefined;
90+
});
91+
92+
it('Should return a Cloud Storage client', () => {
93+
const storage = getStorage(app);
94+
expect(storage).to.be.instanceOf(Storage)
95+
const bucket: Bucket = storage.bucket('TestBucket');
96+
expect(bucket.name).to.equal('TestBucket');
97+
});
98+
99+
it('Should return a Firestore client', () => {
100+
const firestore = getFirestore(app);
101+
expect(firestore).to.be.instanceOf(Firestore);
102+
});
103+
104+
it('Should return a Firestore FieldValue', () => {
105+
expect(FieldValue.increment(1)).to.be.not.undefined;
106+
});
107+
108+
it('Should return a DocumentReference', () => {
109+
const ref = getFirestore(app).collection('test').doc();
110+
expect(ref).to.be.instanceOf(DocumentReference);
111+
});
112+
113+
it('Should return an InstanceId client', () => {
114+
const client = getInstanceId(app);
115+
expect(client).to.be.instanceOf(InstanceId);
116+
});
117+
118+
it('Should return a MachineLearning client', () => {
119+
const client = getMachineLearning(app);
120+
expect(client).to.be.instanceOf(MachineLearning);
121+
});
122+
123+
it('Should return a RemoteConfig client', () => {
124+
const client = getRemoteConfig(app);
125+
expect(client).to.be.instanceOf(RemoteConfig);
126+
});
127+
});

test/integration/typescript/src/example.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ import * as admin from 'firebase-admin';
2525
// eslint-disable-next-line @typescript-eslint/no-var-requires
2626
const serviceAccount = require('../mock.key.json');
2727

28-
describe('Init App', () => {
29-
const app: admin.app.App = initApp(serviceAccount, 'TestApp');
28+
describe('Legacy API', () => {
29+
let app: admin.app.App;
30+
31+
before(() => {
32+
app = initApp(serviceAccount, 'TestApp');
33+
});
3034

3135
after(() => {
3236
return app.delete();

0 commit comments

Comments
 (0)