backend-manager 3.2.123 → 3.2.124

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.2.123",
3
+ "version": "3.2.124",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
package/src/cli/cli.js CHANGED
@@ -1317,39 +1317,59 @@ async function cmd_configSet(self, newPath, newValue) {
1317
1317
  name: 'path',
1318
1318
  default: 'service.key'
1319
1319
  }
1320
- ]).then(answers => answers.path)
1320
+ ]).then(answers => answers.path);
1321
+
1322
+ let object = null;
1321
1323
 
1322
1324
  try {
1323
- const object = JSON5.parse(newPath)
1324
- try {
1325
- if (typeof object === 'object') {
1326
- const keyify = (obj, prefix = '') =>
1327
- Object.keys(obj).reduce((res, el) => {
1328
- if( Array.isArray(obj[el]) ) {
1329
- return res;
1330
- } else if( typeof obj[el] === 'object' && obj[el] !== null ) {
1331
- return [...res, ...keyify(obj[el], prefix + el + '.')];
1332
- }
1333
- return [...res, prefix + el];
1334
- }, []);
1335
- const pathArray = keyify(object);
1336
- for (var i = 0; i < pathArray.length; i++) {
1337
- const pathName = pathArray[i];
1338
- const pathValue = _.get(object, pathName);
1339
- // console.log(chalk.blue(`Setting object: ${chalk.bold(pathName)} = ${chalk.bold(pathValue)}`));
1340
- console.log(chalk.blue(`Setting object: ${chalk.bold(pathName)}`));
1341
- await cmd_configSet(self, pathName, pathValue)
1342
- .catch(e => {
1343
- log(chalk.red(`Failed to save object path: ${e}`));
1344
- })
1345
- }
1346
- return resolve();
1325
+ object = JSON5.parse(newPath);
1326
+ } catch (e) {
1327
+ }
1328
+
1329
+ const isObject = typeof object === 'object';
1330
+
1331
+ // If it's a string, ensure some things
1332
+ if (!isObject) {
1333
+ // Validate path
1334
+ if (!newPath.includes('.')) {
1335
+ console.log(chalk.red(`Path needs 2 parts (one.two): ${newPath}`));
1336
+ return reject();
1337
+ }
1338
+
1339
+ // Make sure it doesnt include space or special characters
1340
+ if (newPath.match(/[^a-zA-Z0-9.]/)) {
1341
+ console.log(chalk.red(`Path contains invalid characters: ${newPath}`));
1342
+ return reject();
1343
+ }
1344
+ }
1345
+
1346
+ try {
1347
+ if (isObject) {
1348
+ const keyify = (obj, prefix = '') =>
1349
+ Object.keys(obj).reduce((res, el) => {
1350
+ if( Array.isArray(obj[el]) ) {
1351
+ return res;
1352
+ } else if( typeof obj[el] === 'object' && obj[el] !== null ) {
1353
+ return [...res, ...keyify(obj[el], prefix + el + '.')];
1354
+ }
1355
+ return [...res, prefix + el];
1356
+ }, []);
1357
+ const pathArray = keyify(object);
1358
+ for (var i = 0; i < pathArray.length; i++) {
1359
+ const pathName = pathArray[i];
1360
+ const pathValue = _.get(object, pathName);
1361
+ // console.log(chalk.blue(`Setting object: ${chalk.bold(pathName)} = ${chalk.bold(pathValue)}`));
1362
+ console.log(chalk.blue(`Setting object: ${chalk.bold(pathName)}`));
1363
+ await cmd_configSet(self, pathName, pathValue)
1364
+ .catch(e => {
1365
+ log(chalk.red(`Failed to save object path: ${e}`));
1366
+ })
1347
1367
  }
1348
- } catch (e) {
1349
- log(chalk.red(`Failed to save object: ${e}`));
1350
- return reject(e)
1368
+ return resolve();
1351
1369
  }
1352
1370
  } catch (e) {
1371
+ log(chalk.red(`Failed to save object: ${e}`));
1372
+ return reject(e)
1353
1373
  }
1354
1374
 
1355
1375
  newValue = newValue || await inquirer.prompt([
@@ -52,6 +52,8 @@ Middleware.prototype.run = function (libPath, options) {
52
52
 
53
53
  // Wakeup trigger (quit immediately if wakeup is true to avoid cold start on a future request)
54
54
  if (data.wakeup) {
55
+ assistant.log(`Middleware.process(): Wakeup activated at ${new Date().toISOString()}`);
56
+
55
57
  return assistant.respond({wakeup: true});
56
58
  }
57
59