-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DP-1602 Add data pool export / batch import commands #133
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9b46e92
DP-1602 Add data pool batch push support
IvanGandacov 1180428
DP-1602 extend documentation
IvanGandacov 91474b1
DP-1602 extend documentation
IvanGandacov 9134cce
DP-1602 small change
IvanGandacov ba8c667
DP-1602 small change
IvanGandacov bb74ddf
DP-931 Small refactoring
IvanGandacov c882837
DP-931 Add import data pools command and refactor
IvanGandacov b856308
DP-931 cleanup
IvanGandacov b8a027a
DP-931 add export data-pool command + cleanup + refactor
IvanGandacov b3c7ca7
DP-931 cleanup
IvanGandacov 0a13a69
DP-931 cleanup
IvanGandacov 1c99107
DP-931 cleanup
IvanGandacov 92fc0d9
DP-931 update DOCUMENTATION.md
IvanGandacov cde8b39
DP-931 merge master
IvanGandacov 685d551
DP-931 cleanup
IvanGandacov 593aefc
DP-931 cleanup
IvanGandacov d3a1da4
DP-931 cleanup
IvanGandacov 5ab2929
Bump to v0.4.3
IvanGandacov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,63 @@ | ||
import {CommanderStatic} from "commander"; | ||
import {PackageCommand} from "./commands/package.command"; | ||
import {logger} from "./util/logger"; | ||
import {contextService} from "./services/context.service"; | ||
import * as commander from "commander"; | ||
import { CommanderStatic } from "commander"; | ||
import { PackageCommand } from "./commands/package.command"; | ||
import { DataPoolCommand } from "./commands/data-pool.command"; | ||
import { ContextInitializer } from "./util/context-initializer"; | ||
import { logger } from "./util/logger"; | ||
|
||
export class Import { | ||
|
||
public static packages(program: CommanderStatic): CommanderStatic { | ||
program | ||
.command("packages") | ||
.description("Command to import all given packages") | ||
.option("-p, --profile <profile>", "Profile which you want to use to list packages") | ||
.option("--spaceMappings <spaceMappings...>", "List of mappings for importing packages to different target spaces. Mappings should follow format 'packageKey:targetSpaceKey'") | ||
.option( | ||
"--spaceMappings <spaceMappings...>", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just prettifying |
||
"List of mappings for importing packages to different target spaces. Mappings should follow format 'packageKey:targetSpaceKey'" | ||
) | ||
.requiredOption("-f, --file <file>", "Exported packages file (relative path)") | ||
.action(async cmd => { | ||
await new PackageCommand().batchImportPackages(cmd.spaceMappings, cmd.file) | ||
await new PackageCommand().batchImportPackages(cmd.spaceMappings, cmd.file); | ||
process.exit(); | ||
}); | ||
|
||
return program; | ||
} | ||
} | ||
|
||
const options = commander.parseOptions(process.argv) | ||
const indexOfProfileOption = options.unknown.indexOf('-p') !== -1 ? options.unknown.indexOf('-p') : options.unknown.indexOf('--profile'); | ||
public static dataPools(program: CommanderStatic): CommanderStatic { | ||
program | ||
.command("data-pools") | ||
.description("Command to batch import multiple data pools with their objects and dependencies") | ||
.option("-p, --profile <profile>", "Profile which you want to use to import the data pools") | ||
.requiredOption("-f, --jsonFile <file>", "The file with the JSON data pool batch import request") | ||
.option("--outputToJsonFile", "Output the batch import result in a JSON file") | ||
.action(async cmd => { | ||
await new DataPoolCommand().batchImportDataPools(cmd.jsonFile, cmd.outputToJsonFile); | ||
process.exit(); | ||
}); | ||
|
||
process.on("unhandledRejection", (e, promise) => { | ||
logger.error(e.toString()); | ||
}) | ||
return program; | ||
} | ||
} | ||
|
||
contextService.resolveProfile(options.unknown[indexOfProfileOption + 1]).then(() => { | ||
const loadCommands = () => { | ||
getAllCommands(); | ||
}, ()=> { | ||
getAllCommands(); | ||
}).catch(e => { | ||
console.log(e) | ||
}); | ||
}; | ||
|
||
ContextInitializer.initContext() | ||
.then(loadCommands, loadCommands) | ||
.catch(e => { | ||
logger.error(e); | ||
}); | ||
|
||
if (!process.argv.slice(2).length) { | ||
commander.outputHelp(); | ||
process.exit(1); | ||
} | ||
|
||
function getAllCommands() { | ||
function getAllCommands(): void { | ||
Import.packages(commander); | ||
Import.dataPools(commander); | ||
|
||
commander.parse(process.argv); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,4 +129,3 @@ if (!process.argv.slice(2).length) { | |
commander.outputHelp(); | ||
process.exit(1); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we calling the loadCommands twice here? I haven't seen this syntax before/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's exactly as it was before, just instead of writting the
() => { getCommands(); }
twice, I put it into a variable.