PromucFlow_constructor/deploy/docker/utils/bin/index.js
Arpit Mohan 1af9e2042f
chore: Adding the appsmithctl command to estimate the bill for an existing Appsmith user (#15311)
## Description

This PR adds to the `estimate_billing` option to the `appsmithctl` command. This will help existing users estimate their bill when they consider upgrading to the paid edition.

Usage: 
```
appsmithctl estimate_billing 

Options:
  --sessionPrice    The price per active session. Defaults to 0.3 
  --priceCap        The price cap for a user in a given month. Defaults to 15
```

A user can also run the command for various scenarios to determine the optimum capacity tier.

## Type of change

- New feature (non-breaking change which adds functionality)
- This change requires a documentation update

## How Has This Been Tested?

Manually

## Checklist:

- [ ] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
2022-07-20 10:33:47 +05:30

57 lines
1.6 KiB
JavaScript
Executable File

#!/usr/bin/env node
const process = require("process");
const utils = require("./utils");
const export_db = require("./export_db.js");
const import_db = require("./import_db.js");
const migrate = require("./migrate.js");
const check_replica_set = require("./check_replica_set.js");
const estimate_billing = require("./estimate_billing.js");
const APPLICATION_CONFIG_PATH = "/appsmith-stacks/configuration/docker.env";
// Loading latest application configuration
require("dotenv").config({ path: APPLICATION_CONFIG_PATH });
const command = process.argv[2];
if (["export-db", "export_db", "ex"].includes(command)) {
console.log("Exporting database");
export_db.run();
console.log("Export database done");
return;
}
if (["import-db", "import_db", "im"].includes(command)) {
console.log("Importing database");
// Get Force option flag to run import DB immediately
const forceOption = process.argv[3] === "-f";
import_db.runImportDatabase(forceOption);
console.log("Importing database done");
return;
}
if (["migrate", "mi"].includes(command) && process.argv[3]) {
const arrString = process.argv[3].split("@");
console.log("Start migrate instance");
migrate.runMigrate(arrString[0], arrString[1]);
return;
}
if (["check-replica-set", "check_replica_set", "crs"].includes(command)) {
check_replica_set.exec();
return;
}
if (["backup", "restore"].includes(command)) {
require(`./${command}.js`).run(process.argv.slice(3));
return;
}
if (["estimate-billing", "estimate_billing"].includes(command)) {
estimate_billing.run(process.argv.slice(3));
return;
}
utils.showHelp();