This repository has been archived by the owner on Feb 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from FountainJS/poc-subgenerators
Add subgenerators
- Loading branch information
Showing
88 changed files
with
619 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const fountain = require('fountain-generator'); | ||
|
||
module.exports = fountain.Base.extend({ | ||
writing() { | ||
const name = this.options.name || 'component'; | ||
const titleCase = string => string.charAt(0).toUpperCase() + string.slice(1); | ||
const lowerCase = string => string.charAt(0).toLowerCase() + string.slice(1); | ||
const path = this.options.dir ? `app/${this.options.dir}` : `app`; | ||
const typings = this.options.dir ? this.options.dir.split('/').reduce(prev => `../${prev}`, '../../typings/index.d.ts') : '../../typings/index.d.ts'; | ||
const props = { | ||
componentName: lowerCase(name), | ||
className: titleCase(name), | ||
modules: this.config.get('props').modules, | ||
js: this.config.get('props').js, | ||
framework: this.config.get('props').framework, | ||
name, | ||
typings, | ||
templateUrl: this.config.get('props').modules === 'systemjs' ? `src/${path}/${name}.html` : `${path}/${name}.html` | ||
}; | ||
this.copyTemplate(`src/app/component.js`, `src/${path}/${name}.js`, props); | ||
this.copyTemplate(`src/app/component.spec.js`, `src/${path}/${name}.spec.js`, props); | ||
this.copyTemplate('src/app/component.html', `src/${path}/${name}.html`, props); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class <%- className %>Controller { | ||
constructor() { | ||
this.text = 'My brand new component!'; | ||
} | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/component.babel %> | ||
<% } else { -%> | ||
<% include modules/component.babel %> | ||
<% } -%> |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="component"> | ||
<h2>{{$ctrl.text}}</h2> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function <%- componentName %>Controller() { | ||
this.text = 'My brand new component!'; | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/component.js %> | ||
<% } else { -%> | ||
<% include modules/component.js %> | ||
<% } -%> |
15 changes: 15 additions & 0 deletions
15
generators/component/templates/src/app/component.spec.babel
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% if (modules !== 'inject') { -%> | ||
<% include modules/component.spec.header.babel %> | ||
<% } -%> | ||
describe('<%- componentName %> component', () => { | ||
<% if (modules === 'inject') { -%> | ||
<% include inject/component.spec.babel %> | ||
<% } else { -%> | ||
<% include modules/component.spec.babel %> | ||
<% } -%> | ||
it('should...', angular.mock.inject(($rootScope, $compile) => { | ||
const element = $compile('<<%- componentName %>></<%- componentName %>>')($rootScope); | ||
$rootScope.$digest(); | ||
expect(element).not.toBeNull(); | ||
})); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% if (modules !== 'inject') { -%> | ||
<% include modules/component.spec.header.js %> | ||
<% } -%> | ||
describe('<%- componentName %> component', function () { | ||
<% if (modules === 'inject') { -%> | ||
<% include inject/component.spec.js %> | ||
<% } else { -%> | ||
<% include modules/component.spec.js %> | ||
<% } -%> | ||
it('should...', angular.mock.inject(function ($rootScope, $compile) { | ||
var element = $compile('<<%- componentName %>></<%- componentName %>>')($rootScope); | ||
$rootScope.$digest(); | ||
expect(element).not.toBeNull(); | ||
})); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference path="<%- typings %>" /> | ||
|
||
<% if (modules !== 'inject') { -%> | ||
<% include modules/component.spec.header.ts %> | ||
<% } -%> | ||
describe('<%- componentName %> component', () => { | ||
<% if (modules === 'inject') { -%> | ||
<% include inject/component.spec.ts %> | ||
<% } else { -%> | ||
<% include modules/component.spec.ts %> | ||
<% } -%> | ||
it('should...', <%- modules === 'webpack' ? 'angular.mock.' : '' %>inject(($rootScope: ng.IRootScopeService, $compile: ng.ICompileService) => { | ||
const element = $compile('<<%- componentName %>></<%- componentName %>>')($rootScope); | ||
$rootScope.$digest(); | ||
expect(element).not.toBeNull(); | ||
})); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class <%- className %>Controller { | ||
public text: string; | ||
|
||
constructor() { | ||
this.text = 'My brand new component!'; | ||
} | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/component.babel %> | ||
<% } else { -%> | ||
<% include modules/component.babel %> | ||
<% } -%> |
6 changes: 6 additions & 0 deletions
6
generators/component/templates/src/app/inject/component.babel
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
angular | ||
.module('app') | ||
.component('<%- componentName %>', { | ||
templateUrl: '<%- templateUrl %>', | ||
controller: <%- className %>Controller | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
angular | ||
.module('app') | ||
.component('<%- componentName %>', { | ||
templateUrl: '<%- templateUrl %>', | ||
controller: <%- componentName %>Controller | ||
}); |
7 changes: 7 additions & 0 deletions
7
generators/component/templates/src/app/inject/component.spec.babel
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
beforeEach(module('app', $provide => { | ||
$provide.factory('<%- componentName %>', () => { | ||
return { | ||
templateUrl: 'app/<%- name %>.html' | ||
}; | ||
}); | ||
})); |
7 changes: 7 additions & 0 deletions
7
generators/component/templates/src/app/inject/component.spec.js
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
beforeEach(module('app', function ($provide) { | ||
$provide.factory('<%- componentName %>', function () { | ||
return { | ||
templateUrl: 'app/<%- name %>.html' | ||
}; | ||
}); | ||
})); |
7 changes: 7 additions & 0 deletions
7
generators/component/templates/src/app/inject/component.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
beforeEach(module('app', ($provide: ng.auto.IProvideService) => { | ||
$provide.factory('<%- componentName %>', () => { | ||
return { | ||
templateUrl: 'app/<%- name %>.html' | ||
}; | ||
}); | ||
})); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
angular | ||
.module('app') | ||
.component('<%- componentName %>', { | ||
templateUrl: '<%- templateUrl %>', | ||
controller: <%- className %>Controller | ||
}); |
4 changes: 4 additions & 0 deletions
4
generators/component/templates/src/app/modules/component.babel
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const <%- componentName %> = { | ||
templateUrl: '<%- templateUrl %>', | ||
controller: <%- className %>Controller | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
templateUrl: '<%- templateUrl %>', | ||
controller: <%- componentName %>Controller | ||
}; |
6 changes: 6 additions & 0 deletions
6
generators/component/templates/src/app/modules/component.spec.babel
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
beforeEach(() => { | ||
angular | ||
.module('<%- componentName %>', ['<%- templateUrl %>']) | ||
.component('<%- componentName %>', <%- componentName %>); | ||
angular.mock.module('<%- componentName %>'); | ||
}); |
3 changes: 3 additions & 0 deletions
3
generators/component/templates/src/app/modules/component.spec.header.babel
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import angular from 'angular'; | ||
import 'angular-mocks'; | ||
import {<%- componentName %>} from './<%- name %>'; |
3 changes: 3 additions & 0 deletions
3
generators/component/templates/src/app/modules/component.spec.header.js
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var angular = require('angular'); | ||
require('angular-mocks'); | ||
var <%- componentName %> = require('./<%- name %>'); |
3 changes: 3 additions & 0 deletions
3
generators/component/templates/src/app/modules/component.spec.header.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as angular from 'angular'; | ||
import 'angular-mocks'; | ||
import {<%- componentName %>} from './<%- name %>'; |
6 changes: 6 additions & 0 deletions
6
generators/component/templates/src/app/modules/component.spec.js
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
beforeEach(function () { | ||
angular | ||
.module('<%- componentName %>', ['<%- templateUrl %>']) | ||
.component('<%- componentName %>', <%- componentName %>); | ||
angular.mock.module('<%- componentName %>'); | ||
}); |
6 changes: 6 additions & 0 deletions
6
generators/component/templates/src/app/modules/component.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
beforeEach(() => { | ||
angular | ||
.module('<%- componentName %>', ['<%- templateUrl %>']) | ||
.component('<%- componentName %>', <%- componentName %>); | ||
<%- modules === 'webpack' ? 'angular.mock.' : '' %>module('<%- componentName %>'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const <%- componentName %> = { | ||
templateUrl: '<%- templateUrl %>', | ||
controller: <%- className %>Controller | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const fountain = require('fountain-generator'); | ||
|
||
module.exports = fountain.Base.extend({ | ||
writing() { | ||
const name = this.options.name || 'directive'; | ||
const lowerCase = string => string.charAt(0).toLowerCase() + string.slice(1); | ||
const path = this.options.dir ? `src/app/${this.options.dir}` : `src/app`; | ||
const typings = this.options.dir ? this.options.dir.split('/').reduce(prev => `../${prev}`, '../../typings/index.d.ts') : '../../typings/index.d.ts'; | ||
const props = { | ||
directiveName: lowerCase(name), | ||
modules: this.config.get('props').modules, | ||
js: this.config.get('props').js, | ||
framework: this.config.get('props').framework, | ||
name, | ||
typings | ||
}; | ||
this.copyTemplate(`src/app/directive.js`, `${path}/${name}.js`, props); | ||
this.copyTemplate(`src/app/directive.spec.js`, `${path}/${name}.spec.js`, props); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function <%- directiveName %>() { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
data: '=' | ||
}, | ||
link: (scope, element, attrs) => {}, | ||
controller: () => {}, | ||
controllerAs: 'ctrl' | ||
}; | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/directive.babel %> | ||
<% } else { -%> | ||
<% include modules/directive.babel %> | ||
<% } -%> |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function <%- directiveName %>() { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
data: '=' | ||
}, | ||
link: function (scope, element, attrs) {}, | ||
controller: function () {}, | ||
controllerAs: 'ctrl' | ||
}; | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/directive.js %> | ||
<% } else { -%> | ||
<% include modules/directive.js %> | ||
<% } -%> |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<% if (modules !== 'inject') { -%> | ||
<% include modules/directive.spec.header.babel %> | ||
<% } -%> | ||
describe('<%- directiveName %> directive', () => { | ||
it('should...', angular.mock.inject(($rootScope, $compile) => { | ||
})); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<% if (modules !== 'inject') { -%> | ||
<% include modules/directive.spec.header.js %> | ||
<% } -%> | ||
describe('<%- directiveName %> directive', function () { | ||
it('should...', angular.mock.inject(function ($rootScope, $compile) { | ||
})); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference path="<%- typings %>" /> | ||
|
||
<% if (modules !== 'inject') { -%> | ||
<% include modules/directive.spec.header.ts %> | ||
<% } -%> | ||
describe('<%- directiveName %> directive', () => { | ||
it('should...', <%- modules === 'webpack' ? 'angular.mock.' : '' %>inject(($rootScope: ng.IRootScopeService, $compile: ng.ICompileService) => { | ||
})); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function <%- directiveName %>() { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
data: '=' | ||
}, | ||
link: (scope, element, attrs) => {}, | ||
controller: () => {}, | ||
controllerAs: 'ctrl' | ||
}; | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/directive.ts %> | ||
<% } else { -%> | ||
<% include modules/directive.ts %> | ||
<% } -%> |
3 changes: 3 additions & 0 deletions
3
generators/directive/templates/src/app/inject/directive.babel
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
angular | ||
.module('app') | ||
.directive('<%- directiveName %>', <%- directiveName %>); |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
angular | ||
.module('app') | ||
.directive('<%- directiveName %>', <%- directiveName %>); |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
angular | ||
.module('app') | ||
.directive('<%- directiveName %>', <%- directiveName %>); |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export default <%- directiveName %>; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = <%- directiveName %>; |
2 changes: 2 additions & 0 deletions
2
generators/directive/templates/src/app/modules/directive.spec.header.babel
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import angular from 'angular'; | ||
import 'angular-mocks'; |
2 changes: 2 additions & 0 deletions
2
generators/directive/templates/src/app/modules/directive.spec.header.js
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var angular = require('angular'); | ||
require('angular-mocks'); |
2 changes: 2 additions & 0 deletions
2
generators/directive/templates/src/app/modules/directive.spec.header.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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import * as angular from 'angular'; | ||
import 'angular-mocks'; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export default <%- directiveName %>; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const fountain = require('fountain-generator'); | ||
|
||
module.exports = fountain.Base.extend({ | ||
writing() { | ||
const name = this.options.name || 'filter'; | ||
const lowerCase = string => string.charAt(0).toLowerCase() + string.slice(1); | ||
const path = this.options.dir ? `src/app/${this.options.dir}` : `src/app`; | ||
const typings = this.options.dir ? this.options.dir.split('/').reduce(prev => `../${prev}`, '../../typings/index.d.ts') : '../../typings/index.d.ts'; | ||
const props = { | ||
filterName: lowerCase(name), | ||
modules: this.config.get('props').modules, | ||
js: this.config.get('props').js, | ||
framework: this.config.get('props').framework, | ||
name, | ||
typings | ||
}; | ||
this.copyTemplate(`src/app/filter.js`, `${path}/${name}.js`, props); | ||
this.copyTemplate(`src/app/filter.spec.js`, `${path}/${name}.spec.js`, props); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function <%- filterName %>() { | ||
return (item, arg1, arg2) => { | ||
// transform the item and return it | ||
}; | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/filter.babel %> | ||
<% } else { -%> | ||
<% include modules/filter.babel %> | ||
<% } -%> |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function <%- filterName %>() { | ||
return function (item, arg1, arg2) { | ||
// transform the item and return it | ||
}; | ||
} | ||
|
||
<% if (modules === 'inject') { -%> | ||
<% include inject/filter.babel %> | ||
<% } else { -%> | ||
<% include modules/filter.babel %> | ||
<% } -%> |
Oops, something went wrong.