Skip to content

Commit 76e68b6

Browse files
committed
Upgrade to use firebase-tools 3.0.4
This upgrades donejs-firebase to use firebase-tools 3.0.4, removing the need for donejs-deploy. Firebase support in donejs-deploy will be deprecated in favor of using firebase-tools directly. The workflow from the users perspectice will remain (mostly) the same: ```js donejs add firebase node_modules/.bin/firebase login donejs deploy ``` Will update the guides with the new information.
1 parent add242a commit 76e68b6

File tree

2 files changed

+67
-40
lines changed

2 files changed

+67
-40
lines changed

default/index.js

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var generator = require('yeoman-generator');
33
module.exports = generator.Base.extend({
44
initializing: function () {
55
this.pkgPath = this.destinationPath('package.json');
6+
this.firebaseJsonPath = this.destinationPath('firebase.json');
7+
this.firebaseRc = this.destinationPath('.firebaserc');
68
},
79

810
prompting: function () {
@@ -17,6 +19,11 @@ module.exports = generator.Base.extend({
1719
done();
1820
}.bind(this));
1921
},
22+
23+
installingFirebase: function () {
24+
this.npmInstall(['firebase-tools'], { saveDev: true });
25+
},
26+
2027
writing: function () {
2128
this.log('Modifying package.json');
2229

@@ -27,26 +34,9 @@ module.exports = generator.Base.extend({
2734

2835
// update package.json
2936
this.fs.extendJSON(this.pkgPath, {
30-
donejs: {
31-
deploy: {
32-
root: 'dist',
33-
services: {
34-
production: {
35-
type: 'firebase',
36-
config: {
37-
firebase: firebaseAppName,
38-
public: './dist',
39-
headers: [{
40-
source: '/**',
41-
headers: [{
42-
key: 'Access-Control-Allow-Origin',
43-
value: '*'
44-
}]
45-
}]
46-
}
47-
}
48-
}
49-
}
37+
scripts: {
38+
deploy: "firebase deploy",
39+
"deploy:ci": "firebase deploy --token \"$FIREBASE_TOKEN\""
5040
},
5141
system: {
5242
envs: {
@@ -57,6 +47,30 @@ module.exports = generator.Base.extend({
5747
}
5848
});
5949

50+
this.fs.extendJSON(this.firebaseJsonPath, {
51+
hosting: {
52+
firebase: firebaseAppName,
53+
"public": "./dist",
54+
headers: [
55+
{
56+
source: "/**",
57+
headers: [
58+
{
59+
key: "Access-Control-Allow-Origin",
60+
value: "*"
61+
}
62+
]
63+
}
64+
]
65+
}
66+
});
67+
68+
this.fs.extendJSON(this.firebaseRc, {
69+
projects: {
70+
"default": firebaseAppName
71+
}
72+
});
73+
6074
this.log('Finished modifying package.json');
6175
}
6276
});

test/index.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,9 @@ describe('donejs-firebase', function() {
2323
it('should update package.json with correct configuration', function() {
2424
assert.file(['package.json']);
2525
assert.JSONFileContent('package.json', {
26-
donejs: {
27-
deploy: {
28-
root: 'dist',
29-
services: {
30-
production: {
31-
type: 'firebase',
32-
config: {
33-
firebase: 'firebase-app-name',
34-
public: './dist',
35-
headers: [{
36-
source: '/**',
37-
headers: [{
38-
key: 'Access-Control-Allow-Origin',
39-
value: '*'
40-
}]
41-
}]
42-
}
43-
}
44-
}
45-
}
26+
scripts: {
27+
deploy: "firebase deploy",
28+
"deploy:ci": "firebase deploy --token \"$FIREBASE_TOKEN\""
4629
}
4730
});
4831
assert.JSONFileContent('package.json', {
@@ -73,4 +56,34 @@ describe('donejs-firebase', function() {
7356
}
7457
});
7558
});
59+
60+
it('should update firebase.json', function() {
61+
assert.file(['firebase.json']);
62+
assert.JSONFileContent('firebase.json', {
63+
hosting: {
64+
firebase: 'firebase-app-name',
65+
"public": "./dist",
66+
headers: [
67+
{
68+
source: "/**",
69+
headers: [
70+
{
71+
key: "Access-Control-Allow-Origin",
72+
value: "*"
73+
}
74+
]
75+
}
76+
]
77+
}
78+
});
79+
});
80+
81+
it('should update .firebaserc', function() {
82+
assert.file(['.firebaserc']);
83+
assert.JSONFileContent('.firebaserc', {
84+
projects: {
85+
'default': 'firebase-app-name'
86+
}
87+
});
88+
});
7689
});

0 commit comments

Comments
 (0)