FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
hlambda-cli/src/commands/save.js at master · hlambda/hlambda-cli · GitHub
hlambda
hlambda-cli
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
hlambda-cli
/
src
/
commands
/
save.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (48 loc) · 2 KB
Breadcrumbs
hlambda-cli
/
src
/
commands
/
save.js
Copy path
File metadata and controls
60 lines (48 loc) · 2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import
path
from
'path'
;
import
{
readFile
,
writeFile
}
from
'fs/promises'
;
import
fetch
from
'node-fetch'
;
import
{
errors
}
from
'./../errors/index.js'
;
import
CLIErrorHandler
from
'./../utils/CLIErrorHandler.js'
;
import
YAWN
from
'./../utils/YAWN.js'
;
import
{
loadConfigFromYAML
}
from
'./../utils/loadConfigFromYAML.js'
;
export
const
save
=
async
(
options
,
program
)
=>
{
await
(
async
(
)
=>
{
const
cwd
=
path
.
resolve
(
process
.
cwd
(
)
)
;
console
.
log
(
'Executing in cwd:'
.
green
,
`
${
cwd
}
`
.
yellow
)
;
// Load yaml configuration
const
configuration
=
await
loadConfigFromYAML
(
options
)
;
const
endpoint
=
options
?.
endpoint
??
configuration
?.
endpoint
??
'http://localhost:8081'
;
const
adminSecret
=
options
?.
adminSecret
??
configuration
?.
admin_secret
??
''
;
const
configurationFilePath
=
path
.
resolve
(
cwd
,
options
.
config
,
'config.yaml'
)
;
const
yawn
=
await
readFile
(
configurationFilePath
,
'utf8'
)
.
then
(
(
fileData
)
=>
{
const
result
=
new
YAWN
(
fileData
)
;
console
.
log
(
`[yawn] Config`
.
green
,
`
${
configurationFilePath
}
`
.
yellow
,
`successfully loaded...`
.
green
)
;
return
result
;
}
)
.
catch
(
(
error
)
=>
{
console
.
error
(
`[yawn] Config`
.
red
,
`
${
configurationFilePath
.
yellow
}
`
,
`errored out...`
.
red
)
;
// console.error(error);
return
undefined
;
}
)
;
yawn
.
json
=
{
...
yawn
.
json
,
endpoint
,
admin_secret
:
adminSecret
}
;
// console.log(yawn.yaml);
await
writeFile
(
configurationFilePath
,
yawn
.
yaml
,
'utf-8'
)
.
then
(
(
)
=>
{
console
.
log
(
`[configuration saver] Config`
.
green
,
`
${
configurationFilePath
}
`
.
yellow
,
`successfully saved...`
.
green
)
;
}
)
.
catch
(
(
error
)
=>
{
console
.
error
(
`[configuration saver] Config`
.
red
,
`
${
configurationFilePath
.
yellow
}
`
,
`errored out...`
.
red
)
;
// console.error(error);
return
undefined
;
}
)
;
console
.
log
(
'Configuration updated!'
)
;
}
)
(
)
.
then
(
(
)
=>
{
}
)
.
catch
(
CLIErrorHandler
(
program
)
)
;
}
;
export
default
save
;
Back
|
FazBrowse Home
|
New Git URL