Skip to content

Commit f9fc59b

Browse files
committed
add blueprints
1 parent f1fe77e commit f9fc59b

File tree

7 files changed

+79
-8
lines changed

7 files changed

+79
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
{{yield}}
3+
</template>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { module, test } from 'qunit';
2+
import { render } from '@ember/test-helpers';
3+
import { setupRenderingTest } from 'ember-qunit';
4+
5+
import <%= componentName %> from '../../../src/components/<%= name %>';
6+
7+
module('Integration | Component | <%= name %>', function (hooks) {
8+
setupRenderingTest(hooks);
9+
10+
test('it renders', async function (assert) {
11+
await render(<template><%= selfCloseComponent(componentName) %></template>);
12+
13+
assert.dom().hasText('');
14+
15+
// Template block usage:
16+
await render(<template>
17+
<%= openComponent(componentName) %>
18+
template block text
19+
<%= closeComponent(componentName) %>
20+
</template>);
21+
22+
assert.dom().hasText('template block text');
23+
});
24+
});

blueprints/component/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const stringUtil = require('ember-cli-string-utils');
2+
3+
function invocationFor(options) {
4+
let parts = options.entity.name.split('/');
5+
return parts.map((p) => stringUtil.classify(p)).join('::');
6+
}
7+
8+
9+
module.exports = {
10+
locals: function (options) {
11+
let templateInvocation = invocationFor(options);
12+
let componentName = templateInvocation;
13+
let openComponent = (descriptor) => `<${descriptor}>`;
14+
let closeComponent = (descriptor) => `</${descriptor}>`;
15+
let selfCloseComponent = (descriptor) => `<${descriptor} />`;
16+
17+
return {
18+
name: options.project.name(),
19+
componentName,
20+
openComponent,
21+
closeComponent,
22+
selfCloseComponent,
23+
};
24+
}
25+
}

files/package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@
3636
"ember-source": ">= 4.12.0"
3737
},
3838
"devDependencies": {
39-
"@babel/core": "^7.25.2",<% if (typescript) { %>"@babel/plugin-transform-typescript": "^7.25.2",<% } %>
39+
"@babel/core": "^7.25.2",<% if (typescript) { %>
40+
"@babel/plugin-transform-typescript": "^7.25.2",<% } %>
4041
"@babel/eslint-parser": "^7.25.1",
4142
"@babel/runtime": "^7.25.6",
43+
"@ember/addon-blueprint": "github:ember-cli/ember-addon-blueprint#blueprints",
44+
"@ember/test-helpers": "^5.2.1",
4245
"@embroider/addon-dev": "^7.1.0",
4346
"@embroider/core": "^4.0.0-alpha.10",
4447
"@embroider/macros": "^1.17.0-alpha.8",
4548
"@embroider/vite": "^1.0.0-alpha.12",
46-
"@ember/test-helpers": "^5.2.1",
4749
"@eslint/js": "^9.17.0",<% if (typescript) { %>
4850
"@glint/core": "^1.4.0",
4951
"@glint/environment-ember-loose": "^1.4.0",
@@ -53,21 +55,22 @@
5355
"@rollup/plugin-babel": "^6.0.4",
5456
"babel-plugin-ember-template-compilation": "^2.2.5",
5557
"concurrently": "^9.0.1",
56-
"ember-source": "^6.3.0",
58+
"ember-qunit": "^9.0.2",
5759
"ember-resolver": "^13.1.0",
60+
"ember-source": "^6.3.0",
5861
"ember-template-lint": "^6.0.0",
59-
"ember-qunit": "^9.0.2",
6062
"eslint": "^9.17.0",
6163
"eslint-config-prettier": "^9.1.0",
6264
"eslint-plugin-ember": "^12.3.3",
6365
"eslint-plugin-import": "^2.31.0",
6466
"eslint-plugin-n": "^17.15.1",
6567
"globals": "^15.14.0",
68+
"layer-gen": "^0.1.0",
6669
"prettier": "^3.4.2",
6770
"prettier-plugin-ember-template-tag": "^2.0.4",
68-
"rollup": "^4.22.5",
6971
"qunit": "^2.24.1",
7072
"qunit-dom": "^3.4.0",
73+
"rollup": "^4.22.5",
7174
"vite": "^6.2.4"<% if (typescript) { %>,
7275
"typescript-eslint": "^8.19.1",
7376
"typescript": "~5.6.0"<% } %>

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let date = new Date();
55
const description = 'The default blueprint for Embroider v2 addons.';
66

77
module.exports = {
8+
name: "face",
89
description,
910

1011
fileMapTokens(options) {

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.2.0",
44
"description": "Blueprint for scaffolding ember v2 addons",
55
"keywords": [
6-
"ember-blueprint"
6+
"ember-blueprint",
7+
"ember-addon"
78
],
89
"repository": {
910
"type": "git",
@@ -12,9 +13,14 @@
1213
"license": "MIT",
1314
"author": "",
1415
"scripts": {},
15-
"dependencies": {},
16+
"dependencies": {
17+
"ember-cli-string-utils": "^1.1.0"
18+
},
1619
"devDependencies": {
1720
"release-plan": "^0.16.0"
1821
},
19-
"packageManager": "pnpm@10.6.5"
22+
"packageManager": "pnpm@10.6.5",
23+
"blueprints": {
24+
"component": "./blueprints/component"
25+
}
2026
}

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)