8bitsapps-gcp-utils 1.0.2 → 1.0.4

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.
@@ -1,4 +1,3 @@
1
- const { JWT } = require("google-auth-library");
2
1
  const axios = require("axios");
3
2
  const compute = require("@google-cloud/compute");
4
3
  const fs = require("fs/promises");
@@ -9,7 +8,6 @@ class Network {
9
8
  this.configurationName = configName;
10
9
  this.configuration = null;
11
10
  this.credentials = null;
12
- this.authClient = null;
13
11
  this.computeClient = null;
14
12
  }
15
13
 
@@ -29,12 +27,10 @@ class Network {
29
27
  console.log(`Loading credentials: ${credentialsFileName}.`);
30
28
  this.credentials = JSON.parse(await fs.readFile(credentialsFileName, "utf8"));
31
29
  //
32
- this.authClient = new JWT({
33
- email: this.credentials?.client_email,
34
- key: this.credentials?.private_key,
35
- scopes: ["https://www.googleapis.com/auth/cloud-platform"],
30
+ this.computeClient = new compute.FirewallsClient({
31
+ credentials: this.credentials,
32
+ projectId: this.configuration.defaultProjectId
36
33
  });
37
- this.computeClient = new compute.FirewallsClient({ auth: this.authClient });
38
34
  }
39
35
  catch (ex) {
40
36
  console.error(`Error while reading the config file: ${ex}.`);
@@ -45,7 +41,6 @@ class Network {
45
41
  unloadConfiguration() {
46
42
  this.configuration = null;
47
43
  this.credentials = null;
48
- this.authClient = null;
49
44
  this.computeClient = null;
50
45
  }
51
46
 
@@ -1,9 +1,11 @@
1
1
  const Network = require("./Network.js");
2
2
  const GCPUStorage = require("./Storage.js");
3
-
3
+ const packageJson = require("../package.json");
4
+ //
4
5
  const GCPUtils = {
5
6
  Network: Network,
6
- Storage: GCPUStorage
7
+ Storage: GCPUStorage,
8
+ version: packageJson.version
7
9
  };
8
10
 
9
11
  module.exports = GCPUtils;
package/gcpUtils.js CHANGED
@@ -7,7 +7,7 @@ const { listConfigurations } = require("./utils/configLoader.js");
7
7
  const commands = require("./commands/index.js");
8
8
  const ListWithEscapePrompt = require("./utils/prompts/listWithEscape.js");
9
9
  //
10
- const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
10
+ const packageJson = require("./package.json");
11
11
  //
12
12
  // Register custom prompt with ESC support.
13
13
  inquirer.registerPrompt("listWithEscape", ListWithEscapePrompt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "8bitsapps-gcp-utils",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "GCP Utility CLI for firewall and storage operations",
5
5
  "main": "gcpUtils.js",
6
6
  "bin": {