-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature flag typescript blueprint functionality
- Loading branch information
Showing
97 changed files
with
1,137 additions
and
49 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
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,48 @@ | ||
'use strict'; | ||
|
||
const stringUtil = require('ember-cli-string-utils'); | ||
const path = require('path'); | ||
const inflector = require('inflection'); | ||
|
||
module.exports = { | ||
description: 'Generates an import wrapper.', | ||
|
||
fileMapTokens: function () { | ||
return { | ||
__name__: function (options) { | ||
return options.dasherizedModuleName; | ||
}, | ||
__path__: function (options) { | ||
return inflector.pluralize(options.locals.blueprintName); | ||
}, | ||
__root__: function (options) { | ||
if (options.inRepoAddon) { | ||
return path.join('lib', options.inRepoAddon, 'app'); | ||
} | ||
return 'app'; | ||
}, | ||
}; | ||
}, | ||
|
||
locals: function (options) { | ||
let addonRawName = options.inRepoAddon ? options.inRepoAddon : options.project.name(); | ||
let addonName = stringUtil.dasherize(addonRawName); | ||
let fileName = stringUtil.dasherize(options.entity.name); | ||
let blueprintName = options.originBlueprintName; | ||
let modulePathSegments = [ | ||
addonName, | ||
inflector.pluralize(options.originBlueprintName), | ||
fileName, | ||
]; | ||
|
||
if (blueprintName.match(/-addon/)) { | ||
blueprintName = blueprintName.substr(0, blueprintName.indexOf('-addon')); | ||
modulePathSegments = [addonName, inflector.pluralize(blueprintName), fileName]; | ||
} | ||
|
||
return { | ||
modulePath: modulePathSegments.join('/'), | ||
blueprintName: blueprintName, | ||
}; | ||
}, | ||
}; |
24 changes: 24 additions & 0 deletions
24
blueprints-js/acceptance-test/mocha-files/tests/acceptance/__name__-test.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,24 @@ | ||
import { describe, it, beforeEach, afterEach } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import startApp from '<%= dasherizedPackageName %>/tests/helpers/start-app'; | ||
<% if (destroyAppExists) { %>import destroyApp from '<%= dasherizedPackageName %>/tests/helpers/destroy-app';<% } else { %>import { run } from '@ember/runloop';<% } %> | ||
|
||
describe('<%= friendlyTestName %>', function () { | ||
let application; | ||
|
||
beforeEach(function () { | ||
application = startApp(); | ||
}); | ||
|
||
afterEach(function () { | ||
<% if (destroyAppExists) { %>destroyApp(application);<% } else { %>run(application, 'destroy');<% } %> | ||
}); | ||
|
||
it('can visit /<%= dasherizedModuleName %>', function () { | ||
visit('/<%= dasherizedModuleName %>'); | ||
|
||
return andThen(() => { | ||
expect(currentURL()).to.equal('/<%= dasherizedModuleName %>'); | ||
}); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
blueprints-js/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.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,13 @@ | ||
import { describe, it } from 'mocha'; | ||
import { expect } from 'chai'; | ||
import { setupApplicationTest } from 'ember-mocha'; | ||
import { visit, currentURL } from '@ember/test-helpers'; | ||
|
||
describe('<%= friendlyTestName %>', function () { | ||
setupApplicationTest(); | ||
|
||
it('can visit /<%= dasherizedModuleName %>', async function () { | ||
await visit('/<%= dasherizedModuleName %>'); | ||
expect(currentURL()).to.equal('/<%= dasherizedModuleName %>'); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
blueprints-js/acceptance-test/qunit-files/tests/acceptance/__name__-test.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,12 @@ | ||
import { test } from 'qunit'; | ||
import moduleForAcceptance from '<%= testFolderRoot %>/tests/helpers/module-for-acceptance'; | ||
|
||
moduleForAcceptance('<%= friendlyTestName %>'); | ||
|
||
test('visiting /<%= dasherizedModuleName %>', function (assert) { | ||
visit('/<%= dasherizedModuleName %>'); | ||
|
||
andThen(function () { | ||
assert.strictEqual(currentURL(), '/<%= dasherizedModuleName %>'); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
blueprints-js/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.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,13 @@ | ||
import { module, test } from 'qunit'; | ||
import { visit, currentURL } from '@ember/test-helpers'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
|
||
module('<%= friendlyTestName %>', function (hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
test('visiting /<%= dasherizedModuleName %>', async function (assert) { | ||
await visit('/<%= dasherizedModuleName %>'); | ||
|
||
assert.strictEqual(currentURL(), '/<%= dasherizedModuleName %>'); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
blueprints-js/component-addon/files/__root__/__path__/__name__.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 @@ | ||
export { default } from '<%= modulePath %>'; |
1 change: 1 addition & 0 deletions
1
blueprints-js/component-class-addon/files/__root__/__path__/__name__.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 @@ | ||
export { default } from '<%= modulePath %>'; |
3 changes: 3 additions & 0 deletions
3
blueprints-js/component-class/files/__root__/__path__/__name__.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 @@ | ||
<%= importComponent %> | ||
<%= importTemplate %> | ||
export default <%= defaultExport %> |
34 changes: 34 additions & 0 deletions
34
blueprints-js/component-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.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,34 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupComponentTest } from 'ember-mocha';<% if (testType === 'integration') { %> | ||
import hbs from 'htmlbars-inline-precompile';<% } %> | ||
|
||
describe('<%= friendlyTestDescription %>', function () { | ||
setupComponentTest('<%= componentPathName %>', { | ||
<% if (testType === 'integration' ) { %>integration: true,<% } else if(testType === 'unit') { %>// Specify the other units that are required for this test | ||
// needs: ['component:foo', 'helper:bar'], | ||
unit: true,<% } %> | ||
}); | ||
|
||
it('renders', function () { | ||
<% if (testType === 'integration' ) { %>// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
|
||
this.render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
expect(this.$()).to.have.length(1); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
expect(this.$().text().trim()).to.equal('template block text');<% } else if(testType === 'unit') { %>// creates the component instance | ||
let component = this.subject(); | ||
// renders the component on the page | ||
this.render(); | ||
expect(component).to.be.ok; | ||
expect(this.$()).to.have.length(1);<% } %> | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
blueprints-js/component-test/mocha-files/__root__/__testType__/__path__/__test__.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,36 @@ | ||
import { expect } from 'chai'; | ||
import { describeComponent, it } from 'ember-mocha';<% if (testType === 'integration') { %> | ||
import hbs from 'htmlbars-inline-precompile';<% } %> | ||
|
||
describeComponent( | ||
'<%= componentPathName %>', | ||
'<%= friendlyTestDescription %>', | ||
{ | ||
<% if (testType === 'integration' ) { %>integration: true,<% } else if(testType === 'unit') { %>// Specify the other units that are required for this test | ||
// needs: ['component:foo', 'helper:bar'], | ||
unit: true,<% } %> | ||
}, | ||
function () { | ||
it('renders', function () { | ||
<% if (testType === 'integration' ) { %>// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
|
||
this.render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
expect(this.$()).to.have.length(1); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
expect(this.$().text().trim()).to.equal('template block text');<% } else if(testType === 'unit') { %>// creates the component instance | ||
let component = this.subject(); | ||
// renders the component on the page | ||
this.render(); | ||
expect(component).to.be.ok; | ||
expect(this.$()).to.have.length(1);<% } %> | ||
}); | ||
} | ||
); |
38 changes: 38 additions & 0 deletions
38
blueprints-js/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.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,38 @@ | ||
<% if (testType === 'integration') { %>import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupRenderingTest } from 'ember-mocha'; | ||
import { render } from '@ember/test-helpers'; | ||
<%= hbsImportStatement %> | ||
|
||
describe('<%= friendlyTestDescription %>', function () { | ||
setupRenderingTest(); | ||
|
||
it('renders', async function () { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
|
||
expect(this.element.textContent.trim()).to.equal(''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
expect(this.element.textContent.trim()).to.equal('template block text'); | ||
}); | ||
});<% } else if (testType === 'unit') { %>import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
|
||
describe('<%= friendlyTestDescription %>', function () { | ||
setupTest(); | ||
|
||
it('exists', function () { | ||
let component = this.owner.factoryFor('component:<%= componentPathName %>').create(); | ||
expect(component).to.be.ok; | ||
}); | ||
});<% } %> |
31 changes: 31 additions & 0 deletions
31
blueprints-js/component-test/qunit-files/__root__/__testType__/__path__/__test__.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,31 @@ | ||
import { moduleForComponent, test } from 'ember-qunit';<% if (testType === 'integration') { %> | ||
import hbs from 'htmlbars-inline-precompile';<% } %> | ||
|
||
moduleForComponent('<%= componentPathName %>', '<%= friendlyTestDescription %>', { | ||
<% if (testType === 'integration' ) { %>integration: true,<% } else if(testType === 'unit') { %>// Specify the other units that are required for this test | ||
// needs: ['component:foo', 'helper:bar'], | ||
unit: true,<% } %> | ||
}); | ||
|
||
test('it renders', function (assert) {<% if (testType === 'integration' ) { %> | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
|
||
this.render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
|
||
assert.strictEqual(this.$().text().trim(), ''); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
assert.strictEqual(this.$().text().trim(), 'template block text');<% } else if(testType === 'unit') { %> | ||
// Creates the component instance | ||
/*let component =*/ this.subject(); | ||
// Renders the component to the page | ||
this.render(); | ||
assert.strictEqual(this.$().text().trim(), '');<% } %> | ||
}); |
36 changes: 36 additions & 0 deletions
36
blueprints-js/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.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,36 @@ | ||
<% if (testType === 'integration') { %>import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
<%= hbsImportStatement %> | ||
|
||
module('<%= friendlyTestDescription %>', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`<%= selfCloseComponent(componentName) %>`); | ||
|
||
assert.dom(this.element).hasText(''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
`); | ||
|
||
assert.dom(this.element).hasText('template block text'); | ||
}); | ||
});<% } else if (testType === 'unit') { %>import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('<%= friendlyTestDescription %>', function (hooks) { | ||
setupTest(hooks); | ||
|
||
test('it exists', function (assert) { | ||
let component = this.owner.factoryFor('component:<%= componentPathName %>').create(); | ||
assert.ok(component); | ||
}); | ||
});<% } %> |
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 @@ | ||
<%= importComponent %> | ||
<%= importTemplate %> | ||
export default <%= defaultExport %> |
1 change: 1 addition & 0 deletions
1
blueprints-js/component/files/__root__/__templatepath__/__templatename__.hbs
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 @@ | ||
{{yield}} |
16 changes: 16 additions & 0 deletions
16
blueprints-js/controller-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.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,16 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
|
||
describe('<%= friendlyTestDescription %>', function () { | ||
setupTest('controller:<%= dasherizedModuleName %>', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}); | ||
|
||
// TODO: Replace this with your real tests. | ||
it('exists', function () { | ||
let controller = this.subject(); | ||
expect(controller).to.be.ok; | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
blueprints-js/controller-test/mocha-files/__root__/__testType__/__path__/__test__.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,18 @@ | ||
import { expect } from 'chai'; | ||
import { describeModule, it } from 'ember-mocha'; | ||
|
||
describeModule( | ||
'controller:<%= dasherizedModuleName %>', | ||
'<%= friendlyTestDescription %>', | ||
{ | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}, | ||
function () { | ||
// TODO: Replace this with your real tests. | ||
it('exists', function () { | ||
let controller = this.subject(); | ||
expect(controller).to.be.ok; | ||
}); | ||
} | ||
); |
13 changes: 13 additions & 0 deletions
13
blueprints-js/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.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,13 @@ | ||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
|
||
describe('<%= friendlyTestDescription %>', function () { | ||
setupTest(); | ||
|
||
// TODO: Replace this with your real tests. | ||
it('exists', function () { | ||
let controller = this.owner.lookup('controller:<%= controllerPathName %>'); | ||
expect(controller).to.be.ok; | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
blueprints-js/controller-test/qunit-files/__root__/__testType__/__path__/__test__.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,12 @@ | ||
import { moduleFor, test } from 'ember-qunit'; | ||
|
||
moduleFor('controller:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}); | ||
|
||
// TODO: Replace this with your real tests. | ||
test('it exists', function (assert) { | ||
let controller = this.subject(); | ||
assert.ok(controller); | ||
}); |
Oops, something went wrong.