Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoCLI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
UI
DojoCLI
Commits
965a9082
Commit
965a9082
authored
8 months ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
Config => Adapt to getEnvVar function
parent
9c174a2f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NodeApp/src/config/Config.ts
+25
-25
25 additions, 25 deletions
NodeApp/src/config/Config.ts
NodeApp/src/config/ConfigFiles.ts
+23
-4
23 additions, 4 deletions
NodeApp/src/config/ConfigFiles.ts
NodeApp/src/config/LocalConfigFile.ts
+5
-4
5 additions, 4 deletions
NodeApp/src/config/LocalConfigFile.ts
with
53 additions
and
33 deletions
NodeApp/src/config/Config.ts
+
25
−
25
View file @
965a9082
import
getAppDataPath
from
'
appdata-path
'
;
import
ClientsSharedConfig
from
'
../sharedByClients/config/ClientsSharedConfig
'
;
import
GitlabManager
from
'
../managers/GitlabManager
'
;
class
Config
{
public
readonly
localConfig
:
{
folder
:
string
;
sessionFile
:
string
;
stateFile
:
string
;
};
public
gitlabManager
!
:
GitlabManager
;
public
readonly
versionUpdateInformationPeriodHours
:
number
;
public
versionUpdateInformationPeriodHours
!
:
number
;
public
readonly
gitlab
:
{
public
gitlab
!
:
{
cliReleasePage
:
string
cliPreAlphaReleasePage
:
string
};
public
readonly
login
:
{
public
login
!
:
{
server
:
{
port
:
number
,
route
:
string
},
gitlab
:
{
...
...
@@ -23,51 +22,52 @@ class Config {
}
};
public
readonly
folders
:
{
public
folders
!
:
{
defaultLocalExercise
:
string
};
public
readonly
exercise
:
{
public
exercise
!
:
{
neededFiles
:
Array
<
string
>
};
public
interactiveMode
:
boolean
;
public
interactiveMode
!
:
boolean
;
constructor
()
{
this
.
localConfig
=
{
folder
:
getAppDataPath
(
'
DojoCLI
'
),
sessionFile
:
process
.
env
.
LOCAL_CONFIG_FILE_SESSION
||
''
,
stateFile
:
process
.
env
.
LOCAL_CONFIG_STATE
||
''
};
constructor
()
{
}
async
init
(
apiUrl
:
string
)
{
await
ClientsSharedConfig
.
init
(
apiUrl
);
const
getEnvVar
=
ClientsSharedConfig
.
envVarGetter
();
this
.
gitlabManager
=
new
GitlabManager
(
ClientsSharedConfig
.
gitlab
.
URL
,
ClientsSharedConfig
.
login
.
gitlab
.
client
.
id
,
ClientsSharedConfig
.
login
.
gitlab
.
url
.
redirect
,
ClientsSharedConfig
.
login
.
gitlab
.
url
.
token
);
this
.
versionUpdateInformationPeriodHours
=
Number
(
process
.
env
.
VERSION_UPDATE_INFORMATION_PERIOD_HOURS
||
24
);
this
.
versionUpdateInformationPeriodHours
=
Number
(
getEnvVar
(
'
VERSION_UPDATE_INFORMATION_PERIOD_HOURS
'
,
'
24
'
)
);
this
.
gitlab
=
{
cliReleasePage
:
process
.
env
.
GITLAB_CLI_RELEASE_PAGE
||
''
,
cliPreAlphaReleasePage
:
process
.
env
.
GITLAB_CLI_PREALPHA_RELEASE_PAGE
||
''
cliReleasePage
:
getEnvVar
(
'
GITLAB_CLI_RELEASE_PAGE
'
,
''
)
,
cliPreAlphaReleasePage
:
getEnvVar
(
'
GITLAB_CLI_PREALPHA_RELEASE_PAGE
'
,
''
)
};
this
.
login
=
{
server
:
{
port
:
Number
(
process
.
env
.
LOGIN_SERVER_PORT
||
30992
),
route
:
process
.
env
.
LOGIN_SERVER_ROUTE
||
''
port
:
Number
(
getEnvVar
(
'
LOGIN_SERVER_PORT
'
,
'
30992
'
)
),
route
:
getEnvVar
(
'
LOGIN_SERVER_ROUTE
'
,
''
)
},
gitlab
:
{
url
:
{
code
:
process
.
env
.
LOGIN_GITLAB_URL_CODE
||
''
code
:
getEnvVar
(
'
LOGIN_GITLAB_URL_CODE
'
,
''
)
}
}
};
this
.
folders
=
{
defaultLocalExercise
:
process
.
env
.
LOCAL_EXERCISE_DEFAULT_FOLDER
||
'
./
'
defaultLocalExercise
:
getEnvVar
(
'
LOCAL_EXERCISE_DEFAULT_FOLDER
'
,
'
./
'
)
};
this
.
exercise
=
{
neededFiles
:
JSON
.
parse
(
process
.
env
.
EXERCISE_NEEDED_FILES
||
'
[]
'
)
neededFiles
:
JSON
.
parse
(
getEnvVar
(
'
EXERCISE_NEEDED_FILES
'
,
'
[]
'
)
)
};
this
.
interactiveMode
=
process
.
env
.
INTERACTIVE_MODE
===
'
true
'
;
this
.
interactiveMode
=
getEnvVar
(
'
INTERACTIVE_MODE
'
,
'
false
'
)
===
'
true
'
;
}
}
...
...
This diff is collapsed.
Click to expand it.
NodeApp/src/config/ConfigFiles.ts
+
23
−
4
View file @
965a9082
import
LocalConfigFile
from
'
./LocalConfigFile.js
'
;
import
Config
from
'
./Config.js
'
;
import
getAppDataPath
from
'
appdata-path
'
;
const
sessionConfigFile
=
new
LocalConfigFile
(
Config
.
localConfig
.
sessionFile
);
const
stateConfigFile
=
new
LocalConfigFile
(
Config
.
localConfig
.
stateFile
);
class
ConfigFiles
{
private
localConfig
:
{
folder
:
string
;
sessionFile
:
string
;
stateFile
:
string
;
};
public
sessionConfigFile
!
:
LocalConfigFile
;
public
stateConfigFile
!
:
LocalConfigFile
;
export
{
sessionConfigFile
,
stateConfigFile
};
\ No newline at end of file
constructor
()
{
this
.
localConfig
=
{
folder
:
getAppDataPath
(
'
DojoCLI
'
),
sessionFile
:
process
.
env
.
LOCAL_CONFIG_FILE_SESSION
??
''
,
stateFile
:
process
.
env
.
LOCAL_CONFIG_FILE_STATE
??
''
};
}
init
()
{
this
.
sessionConfigFile
=
new
LocalConfigFile
(
this
.
localConfig
.
folder
,
this
.
localConfig
.
sessionFile
);
this
.
stateConfigFile
=
new
LocalConfigFile
(
this
.
localConfig
.
folder
,
this
.
localConfig
.
stateFile
);
}
}
export
default
new
ConfigFiles
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
NodeApp/src/config/LocalConfigFile.ts
+
5
−
4
View file @
965a9082
import
*
as
fs
from
'
fs
'
;
import
Config
from
'
./Config.js
'
;
import
JSON5
from
'
json5
'
;
class
LocalConfigFile
{
private
readonly
folder
:
string
;
private
readonly
filename
:
string
;
constructor
(
filename
:
string
)
{
constructor
(
folder
:
string
,
filename
:
string
)
{
this
.
folder
=
folder
;
this
.
filename
=
filename
;
this
.
loadConfig
();
}
private
get
configPath
():
string
{
return
`
${
Config
.
localConfig
.
folder
}
/
${
this
.
filename
}
`
;
return
`
${
this
.
folder
}
/
${
this
.
filename
}
`
;
}
private
_config
:
{
[
key
:
string
]:
unknown
}
=
{};
loadConfig
()
{
if
(
!
fs
.
existsSync
(
this
.
configPath
)
)
{
fs
.
mkdirSync
(
Config
.
localConfig
.
folder
,
{
recursive
:
true
});
fs
.
mkdirSync
(
this
.
folder
,
{
recursive
:
true
});
fs
.
writeFileSync
(
this
.
configPath
,
JSON5
.
stringify
({}));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment