Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-plugins-store
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-plugins-store
Commits
9083a7a8
Commit
9083a7a8
authored
1 year ago
by
Xavier Jouslin de Noray
Browse files
Options
Downloads
Patches
Plain Diff
Version Request Broken: give the version for one plugin
Gitlab:
#13
Change-Id: I32fcf48eada33c3049d79cb50abca20bd0c6e97f
parent
f3604f05
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/controllers/plugins.controller.ts
+12
-5
12 additions, 5 deletions
src/controllers/plugins.controller.ts
src/services/plugins.manager.service.ts
+18
-11
18 additions, 11 deletions
src/services/plugins.manager.service.ts
tests/plugins.manager.test.ts
+1
-1
1 addition, 1 deletion
tests/plugins.manager.test.ts
with
31 additions
and
17 deletions
src/controllers/plugins.controller.ts
+
12
−
5
View file @
9083a7a8
...
@@ -303,8 +303,12 @@ export class PluginsController {
...
@@ -303,8 +303,12 @@ export class PluginsController {
.
status
(
isUploadable
?
StatusCodes
.
OK
:
StatusCodes
.
FORBIDDEN
)
.
status
(
isUploadable
?
StatusCodes
.
OK
:
StatusCodes
.
FORBIDDEN
)
.
send
()
.
send
()
)
)
.
catch
(()
=>
res
.
status
(
StatusCodes
.
INTERNAL_SERVER_ERROR
).
send
());
.
catch
(
e
=>
{
console
.
log
(
e
);
res
.
status
(
StatusCodes
.
INTERNAL_SERVER_ERROR
).
send
();
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
);
res
.
status
(
StatusCodes
.
INTERNAL_SERVER_ERROR
).
send
();
res
.
status
(
StatusCodes
.
INTERNAL_SERVER_ERROR
).
send
();
}
}
});
});
...
@@ -407,16 +411,19 @@ export class PluginsController {
...
@@ -407,16 +411,19 @@ export class PluginsController {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
// eslint-disable-next-line @typescript-eslint/no-misused-promises
this
.
router
.
get
(
'
/versions/:id
'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
this
.
router
.
get
(
'
/versions/:id
'
,
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
try
{
if
(
req
.
query
.
arch
===
undefined
)
{
if
(
req
.
query
.
arch
===
undefined
||
req
.
params
.
id
===
undefined
)
{
res
.
status
(
StatusCodes
.
BAD_REQUEST
).
send
();
res
.
status
(
StatusCodes
.
BAD_REQUEST
).
send
();
return
;
return
;
}
}
const
versions
=
await
this
.
pluginsManager
.
getVersions
();
const
version
=
await
this
.
pluginsManager
.
getVersion
(
req
.
params
.
id
,
req
.
query
.
arch
as
string
);
res
res
.
status
(
.
status
(
version
s
.
length
===
0
?
StatusCodes
.
NOT_FOUND
:
StatusCodes
.
OK
version
===
undefined
?
StatusCodes
.
NOT_FOUND
:
StatusCodes
.
OK
)
)
.
send
(
version
s
===
undefined
?
undefined
:
version
s
);
.
send
(
version
===
undefined
?
undefined
:
[{
version
}]
);
return
;
return
;
}
catch
(
e
)
{
}
catch
(
e
)
{
res
.
status
(
StatusCodes
.
INTERNAL_SERVER_ERROR
).
send
();
res
.
status
(
StatusCodes
.
INTERNAL_SERVER_ERROR
).
send
();
...
...
This diff is collapsed.
Click to expand it.
src/services/plugins.manager.service.ts
+
18
−
11
View file @
9083a7a8
...
@@ -275,22 +275,29 @@ export class PluginsManager {
...
@@ -275,22 +275,29 @@ export class PluginsManager {
);
);
}
}
async
getVersions
():
Promise
<
Array
<
{
id
:
string
;
version
:
string
}
>>
{
async
getVersion
(
id
:
string
,
arch
:
string
):
Promise
<
string
|
undefined
>
{
const
plugin
=
await
this
.
findPlugin
(
id
,
arch
);
return
plugin
===
undefined
?
undefined
:
plugin
.
version
;
}
async
getVersions
(
arch
:
string
):
Promise
<
Array
<
{
id
:
string
;
version
:
string
}
>>
{
if
(
this
.
plugins
.
length
===
0
)
{
if
(
this
.
plugins
.
length
===
0
)
{
await
this
.
setPlugins
();
await
this
.
setPlugins
();
}
}
const
versions
:
Array
<
{
id
:
string
;
version
:
string
}
>
=
[];
return
this
.
plugins
for
(
const
plugin
of
this
.
plugins
)
{
.
filter
(
const
version
=
plugin
.
version
;
(
plugins
:
Plugins
)
=>
if
(
version
!==
undefined
)
{
plugins
.
arches
.
includes
(
arch
)
&&
plugins
.
version
!==
undefined
versions
.
push
({
)
.
map
((
plugin
:
Plugins
)
=>
{
return
{
id
:
plugin
.
id
,
id
:
plugin
.
id
,
version
,
version
:
plugin
.
version
,
};
});
});
}
}
}
return
versions
;
}
private
async
setPlugins
():
Promise
<
void
>
{
private
async
setPlugins
():
Promise
<
void
>
{
let
dataDirectory
=
process
.
env
.
DATA_DIRECTORY
;
let
dataDirectory
=
process
.
env
.
DATA_DIRECTORY
;
...
...
This diff is collapsed.
Click to expand it.
tests/plugins.manager.test.ts
+
1
−
1
View file @
9083a7a8
...
@@ -318,7 +318,7 @@ describe('Plugins manager service tests', function () {
...
@@ -318,7 +318,7 @@ describe('Plugins manager service tests', function () {
{
id
:
'
plugin3
'
,
version
:
'
3.0.0
'
},
{
id
:
'
plugin3
'
,
version
:
'
3.0.0
'
},
];
];
const
actualVersions
=
await
pluginsManagerService
.
getVersions
();
const
actualVersions
=
await
pluginsManagerService
.
getVersions
(
'
x64
'
);
expect
(
actualVersions
).
toEqual
(
expectedVersions
);
expect
(
actualVersions
).
toEqual
(
expectedVersions
);
});
});
...
...
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