@harryhope/fdeploy 1.0.0 → 1.2.0
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/index.js +36 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -6,11 +6,38 @@ const path = require('path')
|
|
|
6
6
|
const yargs = require('yargs/yargs')
|
|
7
7
|
const { hideBin } = require('yargs/helpers')
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const maskValue = (value) => {
|
|
10
|
+
if (!value || value.length <= 8) {
|
|
11
|
+
return value
|
|
12
|
+
}
|
|
13
|
+
const first4 = value.slice(0, 4)
|
|
14
|
+
const last4 = value.slice(-4)
|
|
15
|
+
const masked = 'x'.repeat(value.length - 8)
|
|
16
|
+
return `${first4}${masked}${last4}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const maskEnvironmentVariables = (data) => {
|
|
20
|
+
if (!data?.Environment?.Variables) {
|
|
21
|
+
return data
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const maskedData = JSON.parse(JSON.stringify(data))
|
|
25
|
+
const variables = maskedData.Environment.Variables
|
|
26
|
+
|
|
27
|
+
for (const key in variables) {
|
|
28
|
+
variables[key] = maskValue(variables[key])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return maskedData
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const deploy = async (funcName, dir, region, envPath) => {
|
|
10
35
|
const folder = path.resolve(dir || process.cwd())
|
|
11
|
-
const
|
|
36
|
+
const envFilePath = envPath
|
|
37
|
+
? path.resolve(envPath)
|
|
38
|
+
: path.resolve(process.cwd(), '.env')
|
|
12
39
|
|
|
13
|
-
dotenv.config({ path:
|
|
40
|
+
dotenv.config({ path: envFilePath })
|
|
14
41
|
|
|
15
42
|
const ora = await import('ora')
|
|
16
43
|
const chalk = (await import ('chalk')).default
|
|
@@ -46,7 +73,7 @@ const deploy = async (funcName, dir, region) => {
|
|
|
46
73
|
console.log()
|
|
47
74
|
console.log(chalk.bgRed.bold(`Failed to deploy ${funcName}`))
|
|
48
75
|
} else {
|
|
49
|
-
console.log(data)
|
|
76
|
+
console.log(maskEnvironmentVariables(data))
|
|
50
77
|
console.log()
|
|
51
78
|
console.log(chalk.bgGreen.bold(`${funcName} deployed successfully`))
|
|
52
79
|
console.log()
|
|
@@ -72,9 +99,13 @@ yargs(hideBin(process.argv))
|
|
|
72
99
|
alias: 'r',
|
|
73
100
|
describe: 'The AWS region to deploy the lambda to',
|
|
74
101
|
default: 'us-east-1'
|
|
102
|
+
},
|
|
103
|
+
envPath: {
|
|
104
|
+
alias: 'e',
|
|
105
|
+
describe: 'The path to the .env file'
|
|
75
106
|
}
|
|
76
107
|
},
|
|
77
|
-
argv => { deploy(argv.name, argv.directory, argv.region)}
|
|
108
|
+
argv => { deploy(argv.name, argv.directory, argv.region, argv.envPath)}
|
|
78
109
|
)
|
|
79
110
|
.help()
|
|
80
111
|
.demandCommand(1, 'Enter a command from the list above')
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harryhope/fdeploy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A CLI for deploying AWS Lambda functions",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"fdeploy": "
|
|
10
|
+
"fdeploy": "index.js"
|
|
11
11
|
},
|
|
12
12
|
"author": "Harry Hope",
|
|
13
13
|
"license": "MIT",
|