-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
265 additions
and
126 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,49 @@ | ||
import { Command, InvalidArgumentError } from "commander"; | ||
import { Deployment } from "./deployment"; | ||
import * as colors from "colors"; | ||
import { DigiwfLib } from "@miragon-process-ide/digiwf-lib"; | ||
|
||
const deployment = new Deployment(); | ||
export class DeploymentCommand { | ||
private deployment: Deployment; | ||
|
||
export function deployFileCommand(): Command { | ||
return new Command() | ||
.command("deploy-file") | ||
.description("deploys an artifact to the target environment") | ||
.requiredOption("-f --file <file>", "specify the file (full path)") | ||
.requiredOption("-t, --target <target>", "specify the target environment") | ||
.requiredOption("--type <type>", "specify the file type") | ||
.option("-p, --project <project>", "specify the project") | ||
.hook("preAction", (thisCommand) => { | ||
// validate inputs before action is called | ||
const type = thisCommand.opts()["type"]; | ||
if (!(type === "bpmn" || type === "dmn" || type === "form" || type === "config")) { | ||
throw new InvalidArgumentError("type must be either bpmn, dmn, form or config"); | ||
} | ||
}) | ||
.action((options) => { | ||
deployment.deployArtifact(options.file, options.type, options.project, options.target) | ||
.then( () => console.log("Deployment was successfully")) | ||
.catch(err => console.log(colors.red.bold("FAILED") + ` with -> ${err}`)); | ||
}); | ||
} | ||
constructor(digiwfLib: DigiwfLib) { | ||
this.deployment = new Deployment(digiwfLib); | ||
} | ||
|
||
public deployFileCommand(): Command { | ||
return new Command() | ||
.command("deploy-file") | ||
.description("deploys an artifact to the target environment") | ||
.requiredOption("-f --file <file>", "specify the file (full path)") | ||
.requiredOption("-t, --target <target>", "specify the target environment") | ||
.requiredOption("--type <type>", "specify the file type") | ||
.option("-p, --project <project>", "specify the project") | ||
.hook("preAction", (thisCommand) => { | ||
// validate inputs before action is called | ||
const type = thisCommand.opts()["type"]; | ||
if (!(type === "bpmn" || type === "dmn" || type === "form" || type === "config")) { | ||
throw new InvalidArgumentError("type must be either bpmn, dmn, form or config"); | ||
} | ||
}) | ||
.action((options) => { | ||
this.deployment.deployArtifact(options.file, options.type, options.project, options.target) | ||
.then( () => console.log("Deployment was successfully")) | ||
.catch(err => console.log(colors.red.bold("FAILED") + ` with -> ${err}`)); | ||
}); | ||
} | ||
|
||
public deployAllFiles(): Command { | ||
return new Command() | ||
.command("deploy-all") | ||
.description("deploys all artifacts to the target environment") | ||
.requiredOption("-d --directory <directory>", "specify the directory of the source files") | ||
.requiredOption("-t, --target <target>", "specify the target environment") | ||
.option("-p, --project <project>", "specify the project") | ||
.action((options) => { | ||
this.deployment.deployAllArtifacts(options.directory, options.project, options.target) | ||
.then( () => console.log(`Project ${options.project} was successfully deployed to environment ${options.target}`)) | ||
.catch(err => console.log(colors.red.bold("FAILED") + ` with -> ${err}`)); | ||
}); | ||
} | ||
|
||
export function deployAllFiles(): Command { | ||
return new Command() | ||
.command("deploy-all") | ||
.description("deploys all artifacts to the target environment") | ||
.requiredOption("-d --directory <directory>", "specify the directory of the source files") | ||
.requiredOption("-t, --target <target>", "specify the target environment") | ||
.option("-p, --project <project>", "specify the project") | ||
.action((options) => { | ||
deployment.deployAllArtifacts(options.directory, options.project, options.target) | ||
.then( () => console.log(`Project ${options.project} was successfully deployed to environment ${options.target}`)) | ||
.catch(err => console.log(colors.red.bold("FAILED") + ` with -> ${err}`)); | ||
}); | ||
} |
7 changes: 2 additions & 5 deletions
7
apps/miragon-process-ide-cli/src/app/deployment/deployment.ts
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
8 changes: 4 additions & 4 deletions
8
apps/miragon-process-ide-cli/src/app/deployment/deployments.spec.ts
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,39 +1,48 @@ | ||
import { Command } from "commander"; | ||
import { ProjectGenerator } from "./generate"; | ||
import { DigiwfLib } from "@miragon-process-ide/digiwf-lib"; | ||
|
||
const generate = new ProjectGenerator(); | ||
export class GenerateCommand { | ||
private generate: ProjectGenerator; | ||
|
||
export function generateProject(): Command { | ||
return new Command() | ||
.command("generate-project") | ||
.description("generates a project foundation") | ||
.requiredOption("-n, --name <name>", "specify the project name") | ||
.option("-p, --path <filepath>", "specify the targeted path") | ||
.action((options) => { | ||
generate.generateProject(options.name, options.path) | ||
.then(() => console.log(`Successfully generated project ${options.name}`)) | ||
.catch(err => { | ||
console.log(`Project ${options.name} could not be created`); | ||
console.log(err); | ||
}); | ||
}); | ||
} | ||
constructor(digiwfLib: DigiwfLib) { | ||
this.generate = new ProjectGenerator(digiwfLib); | ||
} | ||
|
||
public generateProject(): Command { | ||
return new Command() | ||
.command("generate-project") | ||
.description("generates a project foundation") | ||
.requiredOption("-n, --name <name>", "specify the project name") | ||
.option("-p, --path <filepath>", "specify the targeted path") | ||
.action((options) => { | ||
this.generate.generateProject(options.name, options.path) | ||
.then(() => console.log(`Successfully generated project ${options.name}`)) | ||
.catch(err => { | ||
console.log(`Project ${options.name} could not be created`); | ||
console.log(err); | ||
}); | ||
}); | ||
} | ||
|
||
export function generateFile(): Command { | ||
return new Command() | ||
.command("generate-file") | ||
.description("generates a process model") | ||
.requiredOption("-t --type <type>", "specify the file type that is to be generated") | ||
.requiredOption("-n, --name <name>", "specify the name") | ||
.requiredOption("-p, --path <filepath>", "specify the targeted path") | ||
.option("--template <filepath>", "specify a custom template that is to be used") | ||
.option("-d --data <data>", "specify the data that is to be used for your template") | ||
.action((options) => { | ||
generate.generateFile(options.name, options.type, options.path, options.template, options.data) | ||
.then(() => console.log(`Successfully created file ${options.name}`)) | ||
.catch(err => { | ||
console.log(`File ${options.name} could not be created`); | ||
console.log(err); | ||
}); | ||
}); | ||
public generateFile(): Command { | ||
return new Command() | ||
.command("generate-file") | ||
.description("generates a process model") | ||
.requiredOption("-t --type <type>", "specify the file type that is to be generated") | ||
.requiredOption("-n, --name <name>", "specify the name") | ||
.requiredOption("-p, --path <filepath>", "specify the targeted path") | ||
.option("--template <filepath>", "specify a custom template that is to be used") | ||
.option("-d --data <data>", "specify the data that is to be used for your template") | ||
.action((options) => { | ||
this.generate.generateFile(options.name, options.type, options.path, options.template, options.data) | ||
.then(() => console.log(`Successfully created file ${options.name}`)) | ||
.catch(err => { | ||
console.log(`File ${options.name} could not be created`); | ||
console.log(err); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
|
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,3 +1,4 @@ | ||
export * from "./lib/digiwf-lib"; | ||
export * from "./lib/types"; | ||
export * from "./lib/deployment/plugins"; | ||
export * from "./lib/deployment/rest/digiwf-deployment-plugin-rest"; |
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.