-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from mediumroast/v0.7.0_competitive_insight
V0.7.0 competitive insight
- Loading branch information
Showing
14 changed files
with
1,055 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* A CLI utility used for accessing and reporting on mediumroast.io user objects | ||
* @author Michael Hay <michael.hay@mediumroast.io> | ||
* @file actions.js | ||
* @copyright 2024 Mediumroast, Inc. All rights reserved. | ||
* @license Apache-2.0 | ||
* @verstion 1.0.0 | ||
*/ | ||
|
||
// Import required modules | ||
import { Billings } from '../src/api/gitHubServer.js' | ||
import Environmentals from '../src/cli/env.js' | ||
import CLIOutput from '../src/cli/output.js' | ||
|
||
// Related object type | ||
const objectType = 'Actions' | ||
|
||
// Environmentals object | ||
const environment = new Environmentals( | ||
'2.0', | ||
`${objectType}`, | ||
`Command line interface to report on and update actions.`, | ||
objectType | ||
) | ||
|
||
/* | ||
----------------------------------------------------------------------- | ||
FUNCTIONS - Key functions needed for MAIN | ||
----------------------------------------------------------------------- | ||
*/ | ||
|
||
|
||
/* | ||
----------------------------------------------------------------------- | ||
MAIN - Steps below represent the main function of the program | ||
----------------------------------------------------------------------- | ||
*/ | ||
|
||
// Create the environmental settings | ||
let myProgram = environment.parseCLIArgs(true) | ||
|
||
// Remove command line options for reset_by_type, delete, update, and add_wizard by calling the removeArgByName method in the environmentals class | ||
myProgram = environment.removeArgByName(myProgram, '--delete') | ||
myProgram = environment.removeArgByName(myProgram, '--add_wizard') | ||
myProgram = environment.removeArgByName(myProgram, '--reset_by_type') | ||
myProgram = environment.removeArgByName(myProgram, '--report') | ||
myProgram = environment.removeArgByName(myProgram, '--find_by_name') | ||
myProgram = environment.removeArgByName(myProgram, '--find_by_x') | ||
myProgram = environment.removeArgByName(myProgram, '--find_by_id') | ||
myProgram = environment.removeArgByName(myProgram, '--report') | ||
myProgram = environment.removeArgByName(myProgram, '--package') | ||
myProgram = environment.removeArgByName(myProgram, '--splash') | ||
|
||
// Parse the command line arguments into myArgs and obtain the options | ||
let myArgs = myProgram.parse(process.argv) | ||
myArgs = myArgs.opts() | ||
|
||
const myConfig = environment.readConfig(myArgs.conf_file) | ||
let myEnv = environment.getEnv(myArgs, myConfig) | ||
const accessToken = await environment.verifyAccessToken() | ||
const processName = 'mrcli-actions' | ||
|
||
// Output object | ||
const output = new CLIOutput(myEnv, objectType) | ||
|
||
// Construct the controller objects | ||
const actionsCtl = new Billings(accessToken, myEnv.gitHubOrg, processName) | ||
|
||
// Predefine the results variable | ||
let [success, stat, results] = [null, null, null] | ||
|
||
if (myArgs.update) { | ||
[success, stat, results] = await billingsCtl.getActionsBilling() | ||
const myUserOutput = new CLIOutput(myEnv, 'ActionsBilling') | ||
myUserOutput.outputCLI([results], myArgs.output) | ||
process.exit() | ||
} else { | ||
[success, stat, results] = await billingsCtl.getAll() | ||
const myUserOutput = new CLIOutput(myEnv, 'AllBilling') | ||
myUserOutput.outputCLI(results, myArgs.output) | ||
process.exit() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.