Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENHANCEMENT] Add template tag setup to ember new for apps #10447

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions blueprints/app/files/.eslintrc.js
Expand Up @@ -57,10 +57,32 @@ module.exports = {
node: true,
},
extends: ['plugin:n/recommended'],
},
},<% if (templateTag) { %>
// Template tag files
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to do this we need to move everything out of the root-object of the .eslintrc and move everything to overrides because we can't have top-level parsers: https://github.com/ember-cli/ember-cli/pull/10447/files#diff-042c163c37338253d4a1cc6bf038fb8b4b45eebef94ebbd439a81c38b158dcb6R5

parsers can't be overridden by overrides, and lead to really weird hard to trace errors when you try

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files: ['**/*.gjs'],
parser: 'ember-eslint-parser',
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gjs',
],
},<% if (typescript) { %>
{
files: ['**/*.gts'],
parser: 'ember-eslint-parser',
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gts',
],
},<% } %><% } %>
{
// test files
files: ['tests/**/*-test.{js,ts}'],
files: ['tests/**/*-test.{js,ts<% if (templateTag) { %>,gjs,gts<% } %>}'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for if statement (imo, obvs, but strongly), this should just be in the default.

extends: ['plugin:qunit/recommended'],
},
],
Expand Down
5 changes: 3 additions & 2 deletions blueprints/app/files/.prettierrc.js
@@ -1,9 +1,10 @@
'use strict';

module.exports = {
module.exports = {<% if (templateTag) { %>
plugins: ['prettier-plugin-ember-template-tag'],<% } %>
overrides: [
{
files: '*.{js,ts}',
files: '*.{js,ts<% if (templateTag) { %>,gjs,gts<% } %>}',
options: {
singleQuote: true,
},
Expand Down
8 changes: 5 additions & 3 deletions blueprints/app/files/package.json
Expand Up @@ -89,17 +89,19 @@
"ember-page-title": "^8.2.0",
"ember-qunit": "^8.0.2",
"ember-resolver": "^11.0.1",
"ember-source": "~5.7.0-beta.1",
"ember-source": "~5.7.0-beta.1<% if (templateTag) { %>",
"ember-template-imports": "^4.1.0<% } %>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can include ember-template-imports, specifically, until this is resolved: ember-template-imports/ember-template-imports#228

"ember-template-lint": "^5.13.0<% if (welcome) { %>",
"ember-welcome-page": "^7.0.2<% } %>",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^11.12.0",
"eslint-plugin-ember": "^12.0.2",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-qunit": "^8.0.1",
"loader.js": "^4.7.0",
"prettier": "^3.2.4",
"prettier": "^3.2.4<% if (templateTag) { %>",
"prettier-plugin-ember-template-tag": "^2.0.0<% } %>",
"qunit": "^2.20.0",
"qunit-dom": "^2.0.0",
"stylelint": "^15.11.0",
Expand Down
2 changes: 2 additions & 0 deletions blueprints/app/index.js
Expand Up @@ -41,6 +41,7 @@ module.exports = {
embroider && '"--embroider"',
options.ciProvider && `"--ci-provider=${options.ciProvider}"`,
options.typescript && `"--typescript"`,
options.templateTag && `"--template-tag"`,
]
.filter(Boolean)
.join(',\n ') +
Expand Down Expand Up @@ -78,6 +79,7 @@ module.exports = {
lang: options.lang,
ciProvider: options.ciProvider,
typescript: options.typescript,
templateTag: options.templateTag,
};
},

Expand Down
7 changes: 7 additions & 0 deletions lib/commands/new.js
Expand Up @@ -50,6 +50,13 @@ module.exports = Command.extend({
description: 'Create a new Ember app/addon in an interactive way.',
},
{ name: 'typescript', type: Boolean, default: false, description: 'Set up the app to use TypeScript' },
{
name: 'template-tag',
type: Boolean,
default: false,
description:
'Enables writing components in the template tag authoring format (.gjs, and .gts if TypeScript is enabled)',
},
],

anonymousOptions: ['<app-name>'],
Expand Down
8 changes: 8 additions & 0 deletions tests/acceptance/new-test.js
Expand Up @@ -423,6 +423,14 @@ describe('Acceptance: ember new', function () {
expect(pkgJson.devDependencies['@embroider/webpack']).to.exist;
});

it('template tag component format set up with --template-tag', async function () {
await ember(['new', 'foo', '--skip-npm', '--skip-git', '--template-tag']);

let pkgJson = fs.readJsonSync('package.json');
expect(pkgJson.devDependencies['ember-template-imports']).to.exist;
expect(pkgJson.devDependencies['prettier-plugin-ember-template-tag']).to.exist;
});

describe('verify fixtures', function () {
function checkEslintConfig(fixturePath) {
expect(file('.eslintrc.js')).to.equal(file(path.join(__dirname, '../fixtures', fixturePath, '.eslintrc.js')));
Expand Down