backend-manager 2.5.4 → 2.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli/cli.js +61 -2
package/package.json
CHANGED
package/src/cli/cli.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
// https://www.sitepoint.com/javascript-command-line-interface-cli-node-js/
|
|
6
6
|
// https://github.com/sitepoint-editors/ginit
|
|
7
7
|
|
|
8
|
-
let exec = require('child_process').exec;
|
|
9
8
|
const jetpack = require('fs-jetpack');
|
|
10
9
|
const path = require('path');
|
|
11
10
|
const chalk = require('chalk');
|
|
@@ -14,7 +13,7 @@ const log = console.log;
|
|
|
14
13
|
const Npm = require('npm-api');
|
|
15
14
|
const semver = require('semver');
|
|
16
15
|
const inquirer = require('inquirer');
|
|
17
|
-
const { spawn } = require('child_process');
|
|
16
|
+
const { spawn, child, exec, fork } = require('child_process');
|
|
18
17
|
const JSON5 = require('json5');
|
|
19
18
|
const fetch = require('wonderful-fetch');
|
|
20
19
|
const argv = require('yargs').argv;
|
|
@@ -87,6 +86,12 @@ Main.prototype.process = async function (args) {
|
|
|
87
86
|
console.log('cwd: ', self.firebaseProjectPath);
|
|
88
87
|
}
|
|
89
88
|
if (self.options.setup) {
|
|
89
|
+
// console.log(`Running Setup`);
|
|
90
|
+
// console.log(`node:`, process.versions.node);
|
|
91
|
+
// console.log(`pwd:`, await execute('pwd').catch(e => e));
|
|
92
|
+
// console.log(`node:`, await execute('node --version').catch(e => e));
|
|
93
|
+
// console.log(`firebase-tools:`, await execute('firebase --version').catch(e => e));
|
|
94
|
+
// console.log('');
|
|
90
95
|
await cmd_configGet(self).catch(e => log(chalk.red(`Failed to run config:get`)));
|
|
91
96
|
await self.setup();
|
|
92
97
|
}
|
|
@@ -1115,9 +1120,63 @@ async function cmd_indexesGet(self, filePath, log) {
|
|
|
1115
1120
|
});
|
|
1116
1121
|
}
|
|
1117
1122
|
|
|
1123
|
+
async function execute(command, cwd) {
|
|
1124
|
+
cwd = cwd || process.cwd();
|
|
1125
|
+
return new Promise(function(resolve, reject) {
|
|
1126
|
+
exec(command, { cwd: cwd, stdio: 'inherit' })
|
|
1127
|
+
.on('error', function(err) {
|
|
1128
|
+
reject(err);
|
|
1129
|
+
})
|
|
1130
|
+
.on('close', function (one, two, three) {
|
|
1131
|
+
console.log('===', one, two, three);
|
|
1132
|
+
resolve()
|
|
1133
|
+
})
|
|
1134
|
+
// fork(command, function (error, stdout, stderr) {
|
|
1135
|
+
// if (error) {
|
|
1136
|
+
// reject(error);
|
|
1137
|
+
// } else {
|
|
1138
|
+
// resolve(stdout);
|
|
1139
|
+
// }
|
|
1140
|
+
// });
|
|
1141
|
+
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// async function execute(command, args, cwd) {
|
|
1146
|
+
// cwd = cwd || process.cwd();
|
|
1147
|
+
// return new Promise(function(resolve, reject) {
|
|
1148
|
+
// spawn(command, args, { cwd: cwd, stdio: 'inherit' })
|
|
1149
|
+
// .on('error', function(err) {
|
|
1150
|
+
// reject(err);
|
|
1151
|
+
// })
|
|
1152
|
+
// .on('close', function (one, two, three) {
|
|
1153
|
+
// console.log('===', one, two, three);
|
|
1154
|
+
// resolve()
|
|
1155
|
+
// })
|
|
1156
|
+
// // fork(command, function (error, stdout, stderr) {
|
|
1157
|
+
// // if (error) {
|
|
1158
|
+
// // reject(error);
|
|
1159
|
+
// // } else {
|
|
1160
|
+
// // resolve(stdout);
|
|
1161
|
+
// // }
|
|
1162
|
+
// // });
|
|
1163
|
+
|
|
1164
|
+
// });
|
|
1165
|
+
// }
|
|
1166
|
+
|
|
1118
1167
|
async function cmd_configGet(self, filePath) {
|
|
1119
1168
|
return new Promise(function(resolve, reject) {
|
|
1120
1169
|
const finalPath = `${self.firebaseProjectPath}/${filePath || 'functions/.runtimeconfig.json'}`;
|
|
1170
|
+
// execute(`firebase functions:config:get > ${finalPath}`)
|
|
1171
|
+
// .then(r => {
|
|
1172
|
+
// console.log(chalk.green(`Saving config to: ${finalPath}`));
|
|
1173
|
+
// console.log(r);
|
|
1174
|
+
// resolve(require(finalPath));
|
|
1175
|
+
// })
|
|
1176
|
+
// .catch(e => {
|
|
1177
|
+
// console.error(e);
|
|
1178
|
+
// reject(e);
|
|
1179
|
+
// })
|
|
1121
1180
|
let cmd = exec(`firebase functions:config:get > ${finalPath}`, function (error, stdout, stderr) {
|
|
1122
1181
|
if (error) {
|
|
1123
1182
|
console.error(error);
|