lassiecoder 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/bin/index.js +43 -13
  2. package/package.json +2 -1
package/bin/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import fs from "fs";
3
+ import fs from "fs";
4
4
  import os from "os";
5
5
  import ora from 'ora';
6
6
  import path from "path";
@@ -11,9 +11,41 @@ import chalk from "chalk";
11
11
  import dotenv from 'dotenv';
12
12
  import inquirer from "inquirer";
13
13
  import cliSpinners from 'cli-spinners';
14
+ import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";
14
15
 
15
16
  dotenv.config();
16
17
 
18
+ // Create a Secrets Manager client
19
+ const secretsManager = new SecretsManagerClient({ region: process.env.AWS_REGION });
20
+
21
+ // Function to retrieve secrets
22
+ async function getSecrets() {
23
+ try {
24
+ // 'your-secret-id' is ARN or name of the secret
25
+ const command = new GetSecretValueCommand({ SecretId: process.env.SECRET_ID });
26
+ const data = await secretsManager.send(command);
27
+ if ('SecretString' in data) {
28
+ const secret = JSON.parse(data.SecretString);
29
+ return secret;
30
+ }
31
+ } catch (err) {
32
+ console.error("Error retrieving secrets");
33
+ throw err;
34
+ }
35
+ }
36
+
37
+ // Declare a global variable `secrets` to store the retrieved secrets
38
+ let secrets;
39
+
40
+ // Define an asynchronous function named `main` to retrieve secrets
41
+ async function main() {
42
+ try {
43
+ secrets = await getSecrets();
44
+ } catch (err) {
45
+ console.error("Error retrieving secrets");
46
+ }
47
+ }
48
+
17
49
  // Create a prompt module for interacting with the user via the command line interface
18
50
  const prompt = inquirer.createPromptModule();
19
51
 
@@ -47,8 +79,8 @@ const questions = [
47
79
  name: `Send me an ${chalk.green.bold("email")}?`,
48
80
  value: () => {
49
81
  setTimeout(() => {
50
- open(process.env.MAIL_TO);
51
- }, 2000);
82
+ open(secrets.MAIL_TO);
83
+ }, 2000);
52
84
  console.log(`\n${chalk.green.bold("Done")}, your email client should ${chalk.yellow.bold("open soon")}. \nI'll keep an eye out for your message! ${chalk.bold("👀")}\n`);
53
85
  }
54
86
  },
@@ -58,20 +90,20 @@ const questions = [
58
90
  loader.start();
59
91
  axios({
60
92
  method: 'get',
61
- url: process.env.GOOGLE_DRIVE_URL,
93
+ url: secrets.GOOGLE_DRIVE_URL,
62
94
  responseType: 'stream'
63
95
  })
64
96
  .then(function (response) {
65
97
  const writer = fs.createWriteStream(path.join(desktopDir, 'lassiecoder-resume.pdf'));
66
-
98
+
67
99
  response.data.pipe(writer);
68
100
 
69
101
  writer.on('finish', () => {
70
- console.log('\nResume downloaded successfully to desktop 📂 ✅\n');
102
+ console.log('\n\nResume downloaded successfully to desktop 📂 ✅\n');
71
103
  loader.stop();
72
104
  setTimeout(() => {
73
105
  open(path.join(desktopDir, 'lassiecoder-resume.pdf'));
74
- }, 2000);
106
+ }, 2000);
75
107
  });
76
108
  writer.on('error', (err) => {
77
109
  console.error('\nError downloading resume:', err);
@@ -88,7 +120,7 @@ const questions = [
88
120
  name: `Schedule a ${chalk.redBright.bold("Meeting")}?`,
89
121
  value: () => {
90
122
  setTimeout(() => {
91
- open(process.env.CALENDLY)
123
+ open(secrets.CALENDLY)
92
124
  }, 2000);
93
125
  console.log(chalk.hex("#4CAF50")(`\nI'm available on ${chalk.yellow("Fridays from 6:00 PM to 6:15 PM")} for a connection. When scheduling a meeting, please include the ${chalk.yellow("subject")} of our discussion. \nLooking forward to meeting you at the scheduled time! 🗓️\n \n`));
94
126
  }
@@ -125,6 +157,8 @@ const data = {
125
157
  intro: chalk.white.bold("I am Priyanka Sharma, a Software Developer known by the handle ") + chalk.hex("#7B68EE")("lassiecoder") + chalk.white.bold(" across various tech platforms. My expertise lies in developing both mobile and web solutions."),
126
158
  };
127
159
 
160
+ // main();
161
+
128
162
  // Concatenate data strings to display in the console output
129
163
  const newline = "\n";
130
164
  const working = `${data.work}`;
@@ -150,8 +184,4 @@ const output =
150
184
  // Display the formatted output in a box and prompt the user with the defined questions then execute the action based on the user's choice
151
185
  console.log(chalk.white(boxen(output, options)));
152
186
 
153
- console.log(process.env.MAIL_TO,
154
- process.env.GOOGLE_DRIVE_URL,
155
- process.env.CALENDLY)
156
-
157
- prompt(questions).then(answer => answer.action());
187
+ main(prompt(questions).then(answer => answer.action()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lassiecoder",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Priyanka's introduction on terminal.",
5
5
  "exports": "./index.js",
6
6
  "bin": {
@@ -32,6 +32,7 @@
32
32
  "bin/index.js"
33
33
  ],
34
34
  "dependencies": {
35
+ "@aws-sdk/client-secrets-manager": "^3.533.0",
35
36
  "axios": "^1.6.7",
36
37
  "boxen": "^7.1.0",
37
38
  "chalk": "^5.3.0",