This repository has been archived by the owner on Jan 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
56 lines (49 loc) · 1.45 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
const Generator = require('@ngx-rocket/core');
const chalk = require('chalk');
const pkg = require('../../package.json');
class AddonFirebaseGenerator extends Generator {
initializing() {
this.version = pkg.version;
this.log(`Using ${chalk.cyan('addon-firebase')} ${chalk.green(this.version)}`);
}
beforeWriting() {
Object.assign(this.props, this.sharedProps);
}
install() {
if (this.props.firebaseDeploy) {
this.log(`\nConfiguring ${chalk.cyan('Firebase')}:\n`);
const result = this.spawnCommandSync('firebase', ['login']);
if (result.error) {
this.log(`${chalk.red('Firebase CLI is not installed!')}`);
this.log(
`You have to run ${chalk.yellow('npm install -g firebase-tools')} and ${chalk.yellow(
'firebase use --add'
)} manually`
);
} else {
this.spawnCommandSync('firebase', ['use', '--add']);
}
}
}
end() {
if (this.props.firebaseDeploy && !this.updating) {
this.log(`- $ ${chalk.green(`${this.packageManager} run deploy`)}: deploy app to Firebase`);
}
}
}
module.exports = Generator.make({
baseDir: __dirname,
generator: AddonFirebaseGenerator,
prompts: [
{
type: 'confirm',
name: 'firebaseDeploy',
message: 'Use Firebase deploy?',
default: true
}
],
prefixRules: Object.assign(Generator.defaultPrefixRules, {
deploy: props => Boolean(props.firebaseDeploy)
})
});