Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NodeSharedCode
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
Shared
NodeSharedCode
Compare revisions
bf75a99ba472386daa111c2fefbe69a4272ef48c to de8af98ab1085f83a5756e797812b400298689dd
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
dojo_project/projects/shared/nodesharedcode
Select target project
No results found
de8af98ab1085f83a5756e797812b400298689dd
Select Git revision
Branches
jw_sonar
jw_sonar_backup
main
move-to-esm-only
open_tool_for_self_hosting
v5.0
Tags
v4.1
v4.2
8 results
Swap
Target
dojo_project/projects/shared/nodesharedcode
Select target project
dojo_project/projects/shared/nodesharedcode
1 result
bf75a99ba472386daa111c2fefbe69a4272ef48c
Select Git revision
Branches
jw_sonar
jw_sonar_backup
main
move-to-esm-only
open_tool_for_self_hosting
v5.0
Tags
v4.1
v4.2
8 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (5)
SharedConfig => Remove vars given by a request to the server
· 22127072
michael.minelli
authored
8 months ago
22127072
SharedGitlabManager => Adapt to new config usage
· 567b34b6
michael.minelli
authored
8 months ago
567b34b6
SharedAssignmentHelper => Add a init function with gitlabManager
· d9ecaee5
michael.minelli
authored
8 months ago
d9ecaee5
Merge branch 'open_tool_for_self_hosting' into v5.0
· e92ee8a0
michael.minelli
authored
7 months ago
e92ee8a0
Merge branch 'v5.0'
· de8af98a
michael.minelli
authored
7 months ago
de8af98a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/SharedConfig.ts
+0
-31
0 additions, 31 deletions
config/SharedConfig.ts
helpers/Dojo/SharedAssignmentHelper.ts
+8
-2
8 additions, 2 deletions
helpers/Dojo/SharedAssignmentHelper.ts
managers/SharedGitlabManager.ts
+9
-6
9 additions, 6 deletions
managers/SharedGitlabManager.ts
with
17 additions
and
39 deletions
config/SharedConfig.ts
View file @
de8af98a
...
...
@@ -4,42 +4,11 @@ class SharedConfig {
public
readonly
logsFolder
:
string
;
public
gitlab
:
{
URL
:
string
,
apiURL
:
string
};
public
readonly
login
:
{
gitlab
:
{
client
:
{
id
:
string
},
url
:
{
redirect
:
string
,
token
:
string
}
}
};
constructor
()
{
this
.
production
=
process
.
env
.
NODE_ENV
===
'
production
'
;
this
.
logsFolder
=
process
.
env
.
LOGS_FOLDER
??
''
;
this
.
gitlab
=
{
URL
:
process
.
env
.
GITLAB_URL
??
''
,
apiURL
:
process
.
env
.
GITLAB_API_URL
??
''
};
this
.
login
=
{
gitlab
:
{
client
:
{
id
:
process
.
env
.
LOGIN_GITLAB_CLIENT_ID
??
''
},
url
:
{
redirect
:
process
.
env
.
LOGIN_GITLAB_URL_REDIRECT
??
''
,
token
:
process
.
env
.
LOGIN_GITLAB_URL_TOKEN
??
''
}
}
};
}
}
...
...
This diff is collapsed.
Click to expand it.
helpers/Dojo/SharedAssignmentHelper.ts
View file @
de8af98a
...
...
@@ -3,10 +3,16 @@ import DojoStatusCode from '../../types/Dojo/DojoStatusCode.js';
import
Json5FileValidator
from
'
../Json5FileValidator.js
'
;
import
*
as
Gitlab
from
'
@gitbeaker/rest
'
;
import
GitlabPipelineStatus
from
'
../../types/Gitlab/GitlabPipelineStatus.js
'
;
import
GitlabManager
from
'
../../
../
managers/GitlabManager
.js
'
;
import
Shared
GitlabManager
from
'
../../managers/
Shared
GitlabManager
'
;
class
SharedAssignmentHelper
{
private
gitlabManager
!
:
SharedGitlabManager
;
init
(
gitlabManager
:
SharedGitlabManager
)
{
this
.
gitlabManager
=
gitlabManager
;
}
validateDescriptionFile
(
filePathOrStr
:
string
,
isFile
:
boolean
=
true
,
version
:
number
=
1
):
{
content
:
AssignmentFile
|
undefined
,
isValid
:
boolean
,
error
:
string
|
null
}
{
if
(
version
===
1
)
{
return
Json5FileValidator
.
validateFile
(
AssignmentFile
,
filePathOrStr
,
isFile
);
...
...
@@ -20,7 +26,7 @@ class SharedAssignmentHelper {
}
async
isPublishable
(
repositoryId
:
number
):
Promise
<
{
isPublishable
:
boolean
,
lastPipeline
:
Gitlab
.
PipelineSchema
|
null
,
status
?:
{
code
:
DojoStatusCode
,
message
:
string
}
}
>
{
const
pipelines
=
await
G
itlabManager
.
getRepositoryPipelines
(
repositoryId
,
'
main
'
);
const
pipelines
=
await
this
.
g
itlabManager
.
getRepositoryPipelines
(
repositoryId
,
'
main
'
);
if
(
pipelines
.
length
>
0
)
{
const
lastPipeline
=
pipelines
[
0
];
if
(
lastPipeline
.
status
!==
GitlabPipelineStatus
.
SUCCESS
.
valueOf
()
)
{
...
...
This diff is collapsed.
Click to expand it.
managers/SharedGitlabManager.ts
View file @
de8af98a
import
axios
from
'
axios
'
;
import
SharedConfig
from
'
../config/SharedConfig.js
'
;
import
*
as
GitlabCore
from
'
@gitbeaker/core
'
;
import
{
GitbeakerRequestError
}
from
'
@gitbeaker/requester-utils
'
;
import
{
Gitlab
,
PipelineSchema
,
ProjectSchema
,
UserSchema
}
from
'
@gitbeaker/rest
'
;
...
...
@@ -12,11 +11,11 @@ class SharedGitlabManager {
setToken
(
token
:
string
)
{
this
.
api
=
new
Gitlab
(
Object
.
assign
({
host
:
SharedConfig
.
gitlab
.
URL
host
:
this
.
gitlabUrl
??
''
},
this
.
refreshTokenFunction
?
{
oauthToken
:
token
}
:
{
token
:
token
}));
}
constructor
(
token
:
string
,
refreshTokenFunction
?:
()
=>
Promise
<
string
>
)
{
constructor
(
public
gitlabUrl
:
string
,
token
:
string
,
public
clientId
?:
string
,
public
urlRedirect
?:
string
,
public
urlToken
?
:
string
,
refreshTokenFunction
?:
()
=>
Promise
<
string
>
)
{
this
.
refreshTokenFunction
=
refreshTokenFunction
;
this
.
setToken
(
token
);
}
...
...
@@ -36,13 +35,17 @@ class SharedGitlabManager {
}
async
getTokens
(
codeOrRefresh
:
string
,
isRefresh
:
boolean
=
false
,
clientSecret
:
string
=
''
):
Promise
<
GitlabToken
>
{
const
response
=
await
axios
.
post
<
GitlabToken
>
(
SharedConfig
.
login
.
gitlab
.
url
.
token
,
{
client_id
:
SharedConfig
.
login
.
gitlab
.
client
.
id
,
if
(
!
this
.
urlToken
)
{
throw
new
Error
(
'
Error when initializing GitlabManager
'
);
}
const
response
=
await
axios
.
post
<
GitlabToken
>
(
this
.
urlToken
,
{
client_id
:
this
.
clientId
,
client_secret
:
clientSecret
,
grant_type
:
isRefresh
?
'
refresh_token
'
:
'
authorization_code
'
,
refresh_token
:
codeOrRefresh
,
code
:
codeOrRefresh
,
redirect_uri
:
SharedConfig
.
login
.
gitlab
.
url
.
r
edirect
redirect_uri
:
this
.
url
R
edirect
});
return
response
.
data
;
...
...
This diff is collapsed.
Click to expand it.