-
Notifications
You must be signed in to change notification settings - Fork 0
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
50 changed files
with
1,589 additions
and
1,285 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,7 +1,7 @@ | ||
import { describe, expect, it } from '@jest/globals'; | ||
|
||
describe('pr-template', () => { | ||
it('hello world', () => { | ||
expect('hello world').toBe('hello world'); | ||
}); | ||
it('hello world', () => { | ||
expect('hello world').toBe('hello world'); | ||
}); | ||
}); |
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,65 +1,70 @@ | ||
#!/usr/bin/env node | ||
import {Option, Command} from 'commander'; | ||
import {version} from '../package.json'; | ||
import {NewCommand, GenerateCommand} from './commands'; | ||
import {LambdaNewCommand} from "./commands/lambda-new.command"; | ||
import { Option, Command } from 'commander'; | ||
import { version } from '../package.json'; | ||
import { NewCommand, GenerateCommand } from './commands'; | ||
import { LambdaNewCommand } from './commands/lambda-new.command'; | ||
|
||
const init = (): void => { | ||
const cuckoo = new Command('cuckoo'); | ||
const cuckoo = new Command('cuckoo'); | ||
|
||
cuckoo | ||
.version( | ||
version, | ||
'-v, --version', | ||
'Output the current version.', | ||
); | ||
cuckoo.version(version, '-v, --version', 'Output the current version.'); | ||
|
||
cuckoo | ||
.helpOption('-h, --help', 'Output usage information.') | ||
.showHelpAfterError() | ||
.usage('<command> [options]'); | ||
cuckoo | ||
.helpOption('-h, --help', 'Output usage information.') | ||
.showHelpAfterError() | ||
.usage('<command> [options]'); | ||
|
||
const nest = cuckoo | ||
.command('nest') | ||
.description('Generate nest template') | ||
const nest = cuckoo.command('nest').description('Generate nest template'); | ||
|
||
nest | ||
.command('new <name> [options...]') | ||
.alias('n') | ||
.description('Generate Nest application with basic tooling.') | ||
.action(async (name: string) => { | ||
await new NewCommand(name).execute(); | ||
}); | ||
nest | ||
.command('new <name> [options...]') | ||
.alias('n') | ||
.description('Generate Nest application with basic tooling.') | ||
.action(async (name: string) => { | ||
await new NewCommand(name).execute(); | ||
}); | ||
|
||
nest | ||
.command('generate <schematic> <name> [options...]') | ||
.alias('g') | ||
.description('Generate a Nest element.') | ||
.action(async (schematic: string, name: string, options: string[]) => { | ||
await new GenerateCommand(schematic, name, options).execute(); | ||
}); | ||
nest | ||
.command('generate <schematic> <name> [options...]') | ||
.alias('g') | ||
.description('Generate a Nest element.') | ||
.action(async (schematic: string, name: string, options: string[]) => { | ||
await new GenerateCommand(schematic, name, options).execute(); | ||
}); | ||
|
||
const lambda = cuckoo | ||
.command('lambda') | ||
.description('Generate lambda template') | ||
const lambda = cuckoo | ||
.command('lambda') | ||
.description('Generate lambda template'); | ||
|
||
lambda | ||
.command('new <name>') | ||
.alias('n') | ||
.description('Generate an AWS Lambda Quickstart') | ||
.addOption( | ||
new Option('-g, --git-provider <gitProvider>', 'Git provider to host the repo') | ||
.choices(['github', 'azuredevops']) | ||
.default('github')) | ||
.addOption( | ||
new Option('--skip-git-init', 'Skip git repository initialization') | ||
) | ||
.action(async (name: string, options: { gitProvider: string, skipGitInit: string}) => { | ||
await new LambdaNewCommand(name, options.gitProvider, !!options.skipGitInit).execute(); | ||
}); | ||
lambda | ||
.command('new <name>') | ||
.alias('n') | ||
.description('Generate an AWS Lambda Quickstart') | ||
.addOption( | ||
new Option( | ||
'-g, --git-provider <gitProvider>', | ||
'Git provider to host the repo', | ||
) | ||
.choices(['github', 'azuredevops']) | ||
.default('github'), | ||
) | ||
.addOption( | ||
new Option('--skip-git-init', 'Skip git repository initialization'), | ||
) | ||
.action( | ||
async ( | ||
name: string, | ||
options: { gitProvider: string; skipGitInit: string }, | ||
) => { | ||
await new LambdaNewCommand( | ||
name, | ||
options.gitProvider, | ||
!!options.skipGitInit, | ||
).execute(); | ||
}, | ||
); | ||
|
||
cuckoo | ||
.parse(process.argv); | ||
cuckoo.parse(process.argv); | ||
}; | ||
|
||
init(); |
19 changes: 12 additions & 7 deletions
19
packages/@guidesmiths/cuckoojs-cli/src/commands/abstract.command.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import Printer from '../lib/printer/printer'; | ||
|
||
export class AbstractCommand { | ||
protected static endProcess(status: number) { | ||
process.exit(status); | ||
} | ||
protected static endProcess(status: number) { | ||
process.exit(status); | ||
} | ||
|
||
protected printSuccess = Printer.format({fontColor: 'green', decoration: 'bold'}); | ||
protected printError = Printer.format({fontColor: 'red', decoration: 'bold'}); | ||
protected printNeutral = Printer.format({decoration: 'bold'}); | ||
protected printSuccess = Printer.format({ | ||
fontColor: 'green', | ||
decoration: 'bold', | ||
}); | ||
protected printError = Printer.format({ | ||
fontColor: 'red', | ||
decoration: 'bold', | ||
}); | ||
protected printNeutral = Printer.format({ decoration: 'bold' }); | ||
} | ||
|
50 changes: 28 additions & 22 deletions
50
packages/@guidesmiths/cuckoojs-cli/src/commands/generate.command.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
import {messages} from '../lib/ui/ui'; | ||
import {AbstractCommand} from './abstract.command'; | ||
import {NestRunner} from '../lib/runners/nest.runner'; | ||
import { messages } from '../lib/ui/ui'; | ||
import { AbstractCommand } from './abstract.command'; | ||
import { NestRunner } from '../lib/runners/nest.runner'; | ||
|
||
export class GenerateCommand extends AbstractCommand { | ||
private readonly schematicRunner: NestRunner = new NestRunner(); | ||
private readonly schematicRunner: NestRunner = new NestRunner(); | ||
|
||
constructor( | ||
private readonly schematic: string, | ||
private readonly name: string, | ||
private readonly options: string[], | ||
) { | ||
super(); | ||
} | ||
constructor( | ||
private readonly schematic: string, | ||
private readonly name: string, | ||
private readonly options: string[], | ||
) { | ||
super(); | ||
} | ||
|
||
public async execute() { | ||
this.printSuccess(messages.banner); | ||
public async execute() { | ||
this.printSuccess(messages.banner); | ||
|
||
try { | ||
this.printNeutral(`Generating Nest ${this.schematic}.`); | ||
await this.schematicRunner.generateNestElement(this.schematic, this.name, this.options); | ||
this.printSuccess(`Nest ${this.schematic} generated.`); | ||
} catch (error: unknown) { | ||
this.printError(`Error generating Nest ${this.schematic}: ${(error as Error).message}`); | ||
GenerateCommand.endProcess(1); | ||
} | ||
} | ||
try { | ||
this.printNeutral(`Generating Nest ${this.schematic}.`); | ||
await this.schematicRunner.generateNestElement( | ||
this.schematic, | ||
this.name, | ||
this.options, | ||
); | ||
this.printSuccess(`Nest ${this.schematic} generated.`); | ||
} catch (error: unknown) { | ||
this.printError( | ||
`Error generating Nest ${this.schematic}: ${(error as Error).message}`, | ||
); | ||
GenerateCommand.endProcess(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export {NewCommand} from './new.command'; | ||
export {GenerateCommand} from './generate.command'; | ||
export { NewCommand } from './new.command'; | ||
export { GenerateCommand } from './generate.command'; |
Oops, something went wrong.