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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo_Project_Nguyen
UI
DojoCLI
Commits
14953733
Commit
14953733
authored
11 months ago
by
kelly.nguyen
Browse files
Options
Downloads
Patches
Plain Diff
fix issue with export portfolio and add options to cmd
parent
184385ce
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#33650
failed
11 months ago
Stage: code_quality
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
NodeApp/src/commander/user/subcommands/UserCreateResumeCommand.ts
+51
-48
51 additions, 48 deletions
...src/commander/user/subcommands/UserCreateResumeCommand.ts
with
51 additions
and
48 deletions
NodeApp/src/commander/user/subcommands/UserCreateResumeCommand.ts
+
51
−
48
View file @
14953733
...
@@ -9,7 +9,7 @@ import TextStyle from "../../../types/TextStyle";
...
@@ -9,7 +9,7 @@ import TextStyle from "../../../types/TextStyle";
import
GitlabManager
from
"
../../../managers/GitlabManager
"
;
import
GitlabManager
from
"
../../../managers/GitlabManager
"
;
import
User
from
"
../../../sharedByClients/models/User
"
;
import
User
from
"
../../../sharedByClients/models/User
"
;
//
type CommandOptions = {
name: string
}
type
CommandOptions
=
{
id
:
string
,
nameFile
:
string
,
full
:
boolean
}
// type CommandOptions = { name: string, template?: string, members_id?: Array<number>, members_username?: Array<string>, clone?: string | boolean }
// type CommandOptions = { name: string, template?: string, members_id?: Array<number>, members_username?: Array<string>, clone?: string | boolean }
class
UserCreateResumeCommand
extends
CommanderCommand
{
class
UserCreateResumeCommand
extends
CommanderCommand
{
...
@@ -18,14 +18,14 @@ class UserCreateResumeCommand extends CommanderCommand {
...
@@ -18,14 +18,14 @@ class UserCreateResumeCommand extends CommanderCommand {
protected
defineCommand
():
void
{
protected
defineCommand
():
void
{
this
.
command
this
.
command
.
description
(
'
export the portfolio of an user
'
)
.
description
(
'
export the portfolio of an user
'
)
.
argument
(
'
<userI
d>
'
,
'
id of the user
'
)
.
requiredOption
(
'
-u, --id <i
d>
'
,
'
id of the user
'
)
.
argument
(
'
<pathFile
>
'
,
'
path of the file
'
)
.
requiredOption
(
'
-n, --nameFile <string
>
'
,
'
path of the file
'
)
//
.option('-
n, --name <name>', 'name of the assignmen
t')
.
option
(
'
-
-full
'
,
'
full expor
t
'
)
.
action
(
this
.
commandAction
.
bind
(
this
));
.
action
(
this
.
commandAction
.
bind
(
this
));
// .action((options) => this.commandAction(options));
// .action((options) => this.commandAction(options));
}
}
// protected async commandAction(options: { name: string }): Promise<void> {
// protected async commandAction(options: { name: string }): Promise<void> {
protected
async
commandAction
(
userId
:
string
,
pathFile
:
string
):
Promise
<
void
>
{
protected
async
commandAction
(
options
:
CommandOptions
):
Promise
<
void
>
{
// check privileges
// check privileges
console
.
log
(
chalk
.
cyan
(
'
Please wait while we are exporting the resume...
'
));
console
.
log
(
chalk
.
cyan
(
'
Please wait while we are exporting the resume...
'
));
...
@@ -42,7 +42,7 @@ class UserCreateResumeCommand extends CommanderCommand {
...
@@ -42,7 +42,7 @@ class UserCreateResumeCommand extends CommanderCommand {
}).
start
();
}).
start
();
try
{
try
{
const
resumeCreated
=
await
DojoBackendManager
.
createResumeUser
(
userI
d
);
const
resumeCreated
=
await
DojoBackendManager
.
createResumeUser
(
options
.
i
d
);
if
(
!
resumeCreated
)
{
if
(
!
resumeCreated
)
{
resumeSpinner
.
fail
(
'
Failed to create resume
'
);
resumeSpinner
.
fail
(
'
Failed to create resume
'
);
...
@@ -50,19 +50,20 @@ class UserCreateResumeCommand extends CommanderCommand {
...
@@ -50,19 +50,20 @@ class UserCreateResumeCommand extends CommanderCommand {
}
}
// START LIGHT EXPORT
// START LIGHT EXPORT
// const portfolioCreated = await DojoBackendManager.createPortfolio(userId);
if
(
!
options
.
full
)
{
const
portfolioCreated
=
await
DojoBackendManager
.
createPortfolio
(
options
.
id
);
//
if (!portfolioCreated) {
if
(
!
portfolioCreated
)
{
//
resumeSpinner.fail('Failed to create portfolio');
resumeSpinner
.
fail
(
'
Failed to create portfolio
'
);
//
return;
return
;
//
}
}
//
await this.sleep(2000);
await
this
.
sleep
(
2000
);
// END LIGHT EXPORT
// END LIGHT EXPORT
}
else
{
// START COMPLET EXPORT
// START COMPLET EXPORT
const
userDataAssignment
:
User
=
await
DojoBackendManager
.
getUserAssignments
(
userI
d
);
const
userDataAssignment
:
User
=
await
DojoBackendManager
.
getUserAssignments
(
options
.
i
d
);
const
userDataExercise
:
User
=
await
DojoBackendManager
.
getUserExercises
(
userI
d
);
const
userDataExercise
:
User
=
await
DojoBackendManager
.
getUserExercises
(
options
.
i
d
);
if
(
!
userDataAssignment
)
{
if
(
!
userDataAssignment
)
{
resumeSpinner
.
fail
(
'
Failed to create portfolio
'
);
resumeSpinner
.
fail
(
'
Failed to create portfolio
'
);
...
@@ -84,13 +85,14 @@ class UserCreateResumeCommand extends CommanderCommand {
...
@@ -84,13 +85,14 @@ class UserCreateResumeCommand extends CommanderCommand {
});
});
// END COMPLET EXPORT
// END COMPLET EXPORT
resumeSpinner
.
succeed
(
'
File downloaded and saved successfully.
'
);
await
this
.
sleep
(
2000
);
}
//
this.downloadFile(
userId, pathFile
).then(() => {
this
.
downloadFile
(
options
).
then
(()
=>
{
//
resumeSpinner.succeed('File downloaded and saved successfully.');
resumeSpinner
.
succeed
(
'
File downloaded and saved successfully.
'
);
//
}).catch((error) => {
}).
catch
((
error
)
=>
{
//
resumeSpinner.fail(`Error download : ${error}`);
resumeSpinner
.
fail
(
`Error download :
${
error
}
`
);
//
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -103,11 +105,12 @@ class UserCreateResumeCommand extends CommanderCommand {
...
@@ -103,11 +105,12 @@ class UserCreateResumeCommand extends CommanderCommand {
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
}
private
async
downloadFile
(
id
:
string
,
pathFile
:
string
)
{
private
async
downloadFile
(
options
:
CommandOptions
)
{
try
{
try
{
const
response
=
await
DojoBackendManager
.
createZip
(
id
);
const
response
=
await
DojoBackendManager
.
createZip
(
options
.
id
);
const
filePath
=
path
.
join
(
__dirname
,
pathFile
);
// const filePath = path.join(options.pathFile);
const
filePath
=
path
.
join
(
__dirname
,
options
.
nameFile
);
const
writer
=
fs
.
createWriteStream
(
filePath
);
const
writer
=
fs
.
createWriteStream
(
filePath
);
response
.
data
.
pipe
(
writer
);
response
.
data
.
pipe
(
writer
);
...
...
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