File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
3+ import 'source-map-support/register' ;
4+
35import yargs from 'yargs' ;
46import { Logger } from './core/Logger' ;
57import { IArgs , runGenerator } from './index' ;
2931 runGenerator ( { directory, wrap } )
3032 . then ( ( ) => process . exit ( 0 ) )
3133 . catch ( err => {
34+ console . log ( err ) ;
3235 Logger . error ( err ) ;
3336 process . exit ( 1 ) ;
3437 } ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ import * as c from './temlpates/shared';
44
55/* istanbul ignore next */
66export class TemplateBase {
7- constructor ( protected vars : Variables ) { }
7+ protected vars : Variables ;
8+
9+ constructor ( vars : Variables ) {
10+ this . vars = vars ;
11+ }
812
913 protected getReactImportSpecifier ( ) : t . ImportSpecifier [ ] {
1014 return this . vars . hooks . map ( hook => c . importSpec ( hook ) ) ;
Original file line number Diff line number Diff line change 1- import { IComponentVariables } from '@/types' ;
21import { TemplateBase } from '@/core/TemplateBase' ;
2+ import { IComponentVariables } from '@/types' ;
33
44/* istanbul ignore next */
55export class ComponentTemplateBase extends TemplateBase {
6- protected vars : IComponentVariables ;
6+ constructor ( protected vars : IComponentVariables ) {
7+ super ( vars ) ;
8+ }
79
810 protected hasMod ( mod : string ) {
911 return this . vars . mods ?. includes ( mod ) ;
Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ import * as c from '../shared';
88export class ComponentTemplate
99 extends ComponentTemplateBase
1010 implements Template {
11- protected vars : IComponentVariables ;
11+ constructor ( protected vars : IComponentVariables ) {
12+ super ( vars ) ;
13+ }
1214
1315 private getStyleImport ( ) {
1416 const specifiers = [ ] ;
Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ import * as c from '../shared';
88export class ComponentTestTemplate
99 extends ComponentTemplateBase
1010 implements Template {
11- protected vars : IComponentVariables ;
11+ constructor ( protected vars : IComponentVariables ) {
12+ super ( vars ) ;
13+ }
1214
1315 generateAST ( ) : t . File {
1416 const componentPath = `./${ this . vars . componentName } ` ;
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ import { IHOCVariables } from '@/types';
66import * as c from '../shared' ;
77
88export class HOCTemplate extends TemplateBase implements Template {
9- protected vars : IHOCVariables ;
9+ constructor ( protected vars : IHOCVariables ) {
10+ super ( vars ) ;
11+ }
1012
1113 generateAST ( ) : t . File {
1214 const body : t . Statement [ ] = [ ] ;
Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ import { IHookVariables } from '@/types';
66import * as c from '../shared' ;
77
88export class HookTemplate extends TemplateBase implements Template {
9- protected vars : IHookVariables ;
9+ constructor ( protected vars : IHookVariables ) {
10+ super ( vars ) ;
11+ }
1012
1113 generateAST ( ) : t . File {
1214 const body : t . Statement [ ] = [ ] ;
Original file line number Diff line number Diff line change @@ -11,7 +11,12 @@ export interface IArgs {
1111 directory ?: string ;
1212}
1313
14- export async function runGenerator ( args : IArgs , data ?: any ) {
14+ type Data = {
15+ type ?: string ;
16+ answers ?: object ;
17+ } ;
18+
19+ export async function runGenerator ( args : IArgs , data : Data = { } ) {
1520 const { directory, wrap } = args ;
1621
1722 let { type } = data ;
You can’t perform that action at this time.
0 commit comments