Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

Commit a628e4d

Browse files
committed
Merge branch 'master' into v2
2 parents 02df258 + fd60135 commit a628e4d

File tree

89 files changed

+5541
-1051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5541
-1051
lines changed

azure-pipelines.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Node.js
2+
# Build a general Node.js project with npm.
3+
# Add steps that analyze code, save build artifacts, deploy, and more:
4+
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
5+
pool:
6+
vmImage: 'vs2017-win2016'
7+
8+
trigger:
9+
paths:
10+
exclude:
11+
- README.md
12+
- CHANGELOG.md
13+
- CODE_OF_CONDUCT.md
14+
steps:
15+
- task: NodeTool@0
16+
inputs:
17+
versionSpec: '8.x'
18+
displayName: 'Install Node.js'
19+
20+
- script: |
21+
npm install -g yarn ember-cli ts-node mocha
22+
displayName: 'Setup global tools'
23+
24+
- script: |
25+
yarn install
26+
displayName: 'Build'
27+
28+
- script: |
29+
mocha --recursive node-tests -R xunit > node-tests.xml
30+
displayName: 'Node Tests'
31+
- script: |
32+
echo " --- NODE TESTS --- " && cat node-tests.xml
33+
displayName: 'Log test output files'
34+
35+
- task: PublishTestResults@2
36+
inputs:
37+
testResultsFormat: 'jUnit'
38+
testResultsFiles: '*-tests.xml'

blueprints/acceptance-test/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3+
const fs = require('fs');
34
const path = require('path');
45
const pathUtil = require('ember-cli-path-utils');
56
const stringUtils = require('ember-cli-string-utils');
6-
const existsSync = require('exists-sync');
77

88
const useTestFrameworkDetector = require('../test-framework-detector');
99

@@ -17,7 +17,7 @@ module.exports = useTestFrameworkDetector({
1717
testFolderRoot = pathUtil.getRelativeParentPath(options.entity.name, -1, false);
1818
}
1919

20-
let destroyAppExists = existsSync(
20+
let destroyAppExists = fs.existsSync(
2121
path.join(this.project.root, '/tests/helpers/destroy-app.js')
2222
);
2323

@@ -29,7 +29,7 @@ module.exports = useTestFrameworkDetector({
2929
return {
3030
testFolderRoot: testFolderRoot,
3131
friendlyTestName,
32-
destroyAppExists: destroyAppExists,
32+
destroyAppExists,
3333
};
3434
},
3535
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { describe, it } from 'mocha';
2+
import { expect } from 'chai';
3+
import { setupApplicationTest } from 'ember-mocha';
4+
import { visit, currentURL } from '@ember/test-helpers';
5+
6+
describe('<%= friendlyTestName %>', function() {
7+
setupApplicationTest();
8+
9+
it('can visit /<%= dasherizedModuleName %>', async function() {
10+
await visit('/<%= dasherizedModuleName %>');
11+
expect(currentURL()).to.equal('/<%= dasherizedModuleName %>');
12+
});
13+
});

blueprints/component-test/index.js

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const isPackageMissing = require('ember-cli-is-package-missing');
66
const getPathOption = require('ember-cli-get-component-path-option');
77

88
const useTestFrameworkDetector = require('../test-framework-detector');
9-
const { isModuleUnificationProject } = require('../module-unification');
9+
const isModuleUnificationProject = require('../module-unification').isModuleUnificationProject;
1010

1111
module.exports = useTestFrameworkDetector({
1212
description: 'Generates a component integration or unit test.',
@@ -17,12 +17,12 @@ module.exports = useTestFrameworkDetector({
1717
type: ['integration', 'unit'],
1818
default: 'integration',
1919
aliases: [
20-
{ 'i': 'integration' },
21-
{ 'u': 'unit' },
22-
{ 'integration': 'integration' },
23-
{ 'unit': 'unit' }
24-
]
25-
}
20+
{ i: 'integration' },
21+
{ u: 'unit' },
22+
{ integration: 'integration' },
23+
{ unit: 'unit' },
24+
],
25+
},
2626
],
2727

2828
fileMapTokens: function() {
@@ -39,16 +39,17 @@ module.exports = useTestFrameworkDetector({
3939
},
4040
__testType__(options) {
4141
if (options.locals.testType === 'unit') {
42-
throw new Error('The --unit flag isn\'t supported within a module unification app');
42+
throw new Error("The --unit flag isn't supported within a module unification app");
4343
}
44+
4445
return '';
4546
},
4647
__path__(options) {
4748
if (options.pod) {
48-
throw new Error('Pods aren\'t supported within a module unification app');
49+
throw new Error("Pods aren't supported within a module unification app");
4950
}
5051
return path.join('ui', 'components', options.dasherizedModuleName);
51-
}
52+
},
5253
};
5354
} else {
5455
return {
@@ -63,10 +64,11 @@ module.exports = useTestFrameworkDetector({
6364
return path.join(options.podPath, options.locals.path, options.dasherizedModuleName);
6465
}
6566
return 'components';
66-
}
67+
},
6768
};
6869
}
6970
},
71+
7072
locals: function(options) {
7173
let dasherizedModuleName = stringUtil.dasherize(options.entity.name);
7274
let componentPathName = dasherizedModuleName;
@@ -80,20 +82,31 @@ module.exports = useTestFrameworkDetector({
8082

8183
if (options.pod && options.path !== 'components' && options.path !== '') {
8284
componentPathName = [options.path, dasherizedModuleName].filter(Boolean).join('/');
85+
} else if (isModuleUnificationProject(this.project)) {
86+
if (options.inRepoAddon) {
87+
componentPathName = `${options.inRepoAddon}::${dasherizedModuleName}`;
88+
} else if (this.project.isEmberCLIAddon()) {
89+
componentPathName = `${this.project.pkg.name}::${dasherizedModuleName}`;
90+
}
8391
}
8492

8593
return {
8694
path: getPathOption(options),
8795
testType: testType,
8896
componentPathName: componentPathName,
89-
friendlyTestDescription: friendlyTestDescription
97+
friendlyTestDescription: friendlyTestDescription,
9098
};
9199
},
100+
92101
afterInstall: function(options) {
93-
if (!options.dryRun && options.testType === 'integration' && isPackageMissing(this, 'ember-cli-htmlbars-inline-precompile')) {
102+
if (
103+
!options.dryRun &&
104+
options.testType === 'integration' &&
105+
isPackageMissing(this, 'ember-cli-htmlbars-inline-precompile')
106+
) {
94107
return this.addPackagesToProject([
95-
{ name: 'ember-cli-htmlbars-inline-precompile', target: '^0.3.1' }
108+
{ name: 'ember-cli-htmlbars-inline-precompile', target: '^0.3.1' },
96109
]);
97110
}
98-
}
111+
},
99112
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<% if (testType === 'integration') { %>import { expect } from 'chai';
2+
import { describe, it } from 'mocha';
3+
import { setupRenderingTest } from 'ember-mocha';
4+
import { render } from '@ember/test-helpers';
5+
import hbs from 'htmlbars-inline-precompile';
6+
7+
describe('<%= friendlyTestDescription %>', function() {
8+
setupRenderingTest();
9+
10+
it('renders', async function() {
11+
// Set any properties with this.set('myProperty', 'value');
12+
// Handle any actions with this.set('myAction', function(val) { ... });
13+
14+
await render(hbs`{{<%= componentPathName %>}}`);
15+
16+
expect(this.element.textContent.trim()).to.equal('');
17+
18+
// Template block usage:
19+
await render(hbs`
20+
{{#<%= componentPathName %>}}
21+
template block text
22+
{{/<%= componentPathName %>}}
23+
`);
24+
25+
expect(this.element.textContent.trim()).to.equal('template block text');
26+
});
27+
});<% } else if (testType === 'unit') { %>import { expect } from 'chai';
28+
import { describe, it } from 'mocha';
29+
import { setupTest } from 'ember-mocha';
30+
31+
describe('<%= friendlyTestDescription %>', function() {
32+
setupTest();
33+
34+
it('exists', function() {
35+
let component = this.owner.factoryFor('component:<%= componentPathName %>').create();
36+
expect(component).to.be.ok;
37+
});
38+
});<% } %>

blueprints/component/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@
33
const path = require('path');
44
const stringUtil = require('ember-cli-string-utils');
55
const pathUtil = require('ember-cli-path-utils');
6-
const validComponentName = require('ember-cli-valid-component-name');
76
const getPathOption = require('ember-cli-get-component-path-option');
87
const normalizeEntityName = require('ember-cli-normalize-entity-name');
98
const isModuleUnificationProject = require('../module-unification').isModuleUnificationProject;
9+
const EOL = require('os').EOL;
1010

1111
module.exports = {
12-
description: 'Generates a component. Name must contain a hyphen.',
12+
description: 'Generates a component.',
1313

1414
availableOptions: [
1515
{
1616
name: 'path',
1717
type: String,
1818
default: 'components',
19-
aliases: [
20-
{ 'no-path': '' }
21-
]
22-
}
19+
aliases: [{ 'no-path': '' }],
20+
},
2321
],
2422

2523
filesPath: function() {
@@ -53,8 +51,9 @@ module.exports = {
5351
__path__: function(options) {
5452
if (options.pod) {
5553
return path.join(options.podPath, options.locals.path, options.dasherizedModuleName);
54+
} else {
55+
return 'components';
5656
}
57-
return 'components';
5857
},
5958
__templatepath__: function(options) {
6059
if (options.pod) {
@@ -67,37 +66,38 @@ module.exports = {
6766
return 'template';
6867
}
6968
return options.dasherizedModuleName;
70-
}
69+
},
7170
};
7271
}
7372
},
7473

7574
normalizeEntityName: function(entityName) {
76-
entityName = normalizeEntityName(entityName);
77-
78-
return validComponentName(entityName);
75+
return normalizeEntityName(entityName);
7976
},
8077

8178
locals: function(options) {
8279
let templatePath = '';
8380
let importTemplate = '';
8481
let contents = '';
82+
8583
// if we're in an addon, build import statement
86-
if (options.project.isEmberCLIAddon() || options.inRepoAddon && !options.inDummy) {
84+
if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) {
8785
if (options.pod) {
8886
templatePath = './template';
8987
} else {
90-
templatePath = pathUtil.getRelativeParentPath(options.entity.name) +
91-
'templates/components/' + stringUtil.dasherize(options.entity.name);
88+
templatePath =
89+
pathUtil.getRelativeParentPath(options.entity.name) +
90+
'templates/components/' +
91+
stringUtil.dasherize(options.entity.name);
9292
}
93-
importTemplate = '// @ts-ignore: Ignore import of compiled template\nimport layout from \'' + templatePath + '\';\n';
94-
contents = '\n layout = layout;';
93+
importTemplate = '// @ts-ignore: Ignore import of compiled template' + EOL + 'import layout from \'' + templatePath + '\';' + EOL;
94+
contents = EOL + ' layout = layout;';
9595
}
9696

9797
return {
9898
importTemplate: importTemplate,
9999
contents: contents,
100-
path: getPathOption(options)
100+
path: getPathOption(options),
101101
};
102-
}
102+
},
103103
};

blueprints/controller-test/index.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,54 @@
33
const stringUtil = require('ember-cli-string-utils');
44

55
const useTestFrameworkDetector = require('../test-framework-detector');
6+
const isModuleUnificationProject = require('../module-unification').isModuleUnificationProject;
7+
const path = require('path');
68

79
module.exports = useTestFrameworkDetector({
810
description: 'Generates a controller unit test.',
911
locals: function(options) {
1012
let dasherizedModuleName = stringUtil.dasherize(options.entity.name);
1113
let controllerPathName = dasherizedModuleName;
14+
1215
return {
1316
controllerPathName: controllerPathName,
14-
friendlyTestDescription: ['Unit', 'Controller', dasherizedModuleName].join(' | ')
17+
friendlyTestDescription: ['Unit', 'Controller', dasherizedModuleName].join(' | '),
1518
};
16-
}
17-
});
19+
},
20+
fileMapTokens: function() {
21+
if (isModuleUnificationProject(this.project)) {
22+
return {
23+
__test__() {
24+
return 'controller-test';
25+
},
26+
__testType__() {
27+
return '';
28+
},
29+
__root__(options) {
30+
if (options.pod) {
31+
throw new Error("Pods aren't supported within a module unification app");
32+
}
33+
return 'src';
34+
},
35+
__path__(options) {
36+
return path.join('ui', 'routes', options.dasherizedModuleName);
37+
},
38+
};
39+
} else {
40+
return {
41+
__root__() {
42+
return 'tests';
43+
},
44+
__testType__() {
45+
return 'unit';
46+
},
47+
__path__(options) {
48+
if (options.pod) {
49+
return path.join(options.podPath, options.dasherizedModuleName);
50+
}
51+
return 'controllers';
52+
},
53+
};
54+
}
55+
},
56+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect } from 'chai';
2+
import { describe, it } from 'mocha';
3+
import { setupTest } from 'ember-mocha';
4+
5+
describe('<%= friendlyTestDescription %>', function() {
6+
setupTest();
7+
8+
// Replace this with your real tests.
9+
it('exists', function() {
10+
let controller = this.owner.lookup('controller:<%= controllerPathName %>');
11+
expect(controller).to.be.ok;
12+
});
13+
});

0 commit comments

Comments
 (0)