Skip to content

Commit

Permalink
Downstreamed @embroider/addon-blueprint@3.2.0 (#94)
Browse files Browse the repository at this point in the history
* chore: Removed single quotes to support Windows

* chore: Allowed Rollup to generate declaration files

* chore: Simplified types/global.d.ts for test-app

* chore: Updated latestVersions

* chore: Updated fixtures

---------

Co-authored-by: ijlee2 <ijlee2@users.noreply.github.com>
  • Loading branch information
ijlee2 and ijlee2 authored Jan 15, 2025
1 parent df153c3 commit 69e8694
Show file tree
Hide file tree
Showing 93 changed files with 434 additions and 480 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default {
'helpers/**/*.js',
'modifiers/**/*.js',
'services/**/*.js',
'utils/**/*.js',
]),

// Follow the V2 Addon rules about dependencies. Your code can import from
Expand All @@ -52,7 +53,10 @@ export default {
addon.hbs(),

// Ensure that .gjs files are properly integrated as Javascript
addon.gjs(),
addon.gjs(),<% if (options.packages.addon.hasTypeScript) { %>

// Emit .d.ts declaration files
addon.declarations('declarations'),<% } %>

// addons are allowed to contain imports of .css files, which we want rollup
// to leave alone and keep in the published output.
Expand Down
5 changes: 4 additions & 1 deletion src/blueprints/ember-addon/__addonLocation__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"emitDeclarationOnly": true,
"noEmit": false,
"noEmitOnError": false,
"rootDir": "./src"
"rootDir": "./src",
"types": [
"ember-source/types"
]
},
"include": [
"src/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<% if (options.packages.addon.hasGlint) { %>
import '@glint/environment-ember-loose';
import '@glint/environment-ember-template-imports';
import 'ember-source/types';

// Uncomment if you need to support consuming projects in loose mode
//
Expand Down
10 changes: 3 additions & 7 deletions src/blueprints/ember-addon/__testAppLocation__/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Types for compiled templates
declare module '<%= options.packages.testApp.name %>/templates/*' {
import { TemplateFactory } from 'ember-cli-htmlbars';

const tmpl: TemplateFactory;
export default tmpl;
}
<% if (options.packages.addon.hasGlint) { %>import '@glint/environment-ember-loose';
import '@glint/environment-ember-template-imports';
<% } %>
12 changes: 6 additions & 6 deletions src/blueprints/ember-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "npm run lint --workspaces --if-present",
"lint:fix": "npm run lint:fix --workspaces --if-present",
"prepare": "npm run build",
"start": "concurrently 'npm:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
"start": "concurrently \"npm:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
"start:addon": "npm start --workspace <%= options.packages.addon.name %>",
"start:test-app": "npm start --workspace <%= options.packages.testApp.name %>",
"test": "npm run test --workspaces --if-present"
Expand All @@ -31,13 +31,13 @@
"author": "",
"scripts": {
"build": "pnpm --filter <%= options.packages.addon.name %> build",
"lint": "pnpm --filter '*' lint",
"lint:fix": "pnpm --filter '*' lint:fix",
"lint": "pnpm --filter \"*\" lint",
"lint:fix": "pnpm --filter \"*\" lint:fix",
"prepare": "pnpm build",
"start": "concurrently 'pnpm:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
"start": "concurrently \"pnpm:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
"start:addon": "pnpm --filter <%= options.packages.addon.name %> start",
"start:test-app": "pnpm --filter <%= options.packages.testApp.name %> start",
"test": "pnpm --filter '*' test"
"test": "pnpm --filter \"*\" test"
},
"devDependencies": {
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
Expand All @@ -58,7 +58,7 @@
"lint": "yarn workspaces run lint",
"lint:fix": "yarn workspaces run lint:fix",
"prepare": "yarn build",
"start": "concurrently 'yarn:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
"start": "concurrently \"yarn:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
"start:addon": "yarn workspace <%= options.packages.addon.name %> run start",
"start:test-app": "yarn workspace <%= options.packages.testApp.name %> run start",
"test": "yarn workspaces run test"
Expand Down
25 changes: 9 additions & 16 deletions src/steps/update-addon-package-json/update-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ export function updateScripts(
*/
scripts.clear();

scripts.set('build', 'rollup --config');
scripts.set(
'lint',
`concurrently '${packageManager}:lint:*(!fix)' --names 'lint:'`,
// eslint-disable-next-line no-useless-escape
`concurrently \"${packageManager}:lint:*(!fix)\" --names \"lint:\"`,
);
scripts.set(
'lint:fix',
`concurrently '${packageManager}:lint:*:fix' --names 'fix:'`,
// eslint-disable-next-line no-useless-escape
`concurrently \"${packageManager}:lint:*:fix\" --names \"fix:\"`,
);
scripts.set(
'lint:hbs',
Expand All @@ -34,32 +37,22 @@ export function updateScripts(
);
scripts.set('lint:js', 'eslint . --cache');
scripts.set('lint:js:fix', 'eslint . --fix');
scripts.set('prepack', 'rollup --config');
scripts.set('start', 'rollup --config --watch');
scripts.set(
'test',
`echo 'A v2 addon does not have tests, run tests in ${locations.testApp}'`,
// eslint-disable-next-line no-useless-escape
`echo \"A v2 addon does not have tests, run tests in ${locations.testApp}\"`,
);

if (packages.addon.hasTypeScript) {
scripts.set('build', `concurrently '${packageManager}:build:*'`);
scripts.set('build:js', 'rollup --config');
scripts.delete('postpack');
scripts.set('prepack', `concurrently '${packageManager}:build:*'`);
scripts.set('start', `concurrently '${packageManager}:start:*'`);
scripts.set('start:js', 'rollup --config --watch --no-watch.clearScreen');

if (packages.addon.hasGlint) {
scripts.set('build:types', 'glint --declaration');
scripts.set('lint:types', 'glint');
scripts.set('start:types', 'glint --declaration --watch');
} else {
scripts.set('build:types', 'tsc');
scripts.set('lint:types', 'tsc --emitDeclarationOnly false --noEmit');
scripts.set('start:types', 'tsc --watch');
}
} else {
scripts.set('build', 'rollup --config');
scripts.set('prepack', 'rollup --config');
scripts.set('start', 'rollup --config --watch');
}

packageJson['scripts'] = convertToObject(scripts);
Expand Down
26 changes: 13 additions & 13 deletions src/utils/blueprints/get-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ import type { Options } from '../../types/index.js';

const latestVersions = new Map([
['@babel/core', '7.26.0'],
['@babel/eslint-parser', '7.25.9'],
['@babel/plugin-transform-typescript', '7.26.3'],
['@babel/eslint-parser', '7.26.5'],
['@babel/plugin-transform-typescript', '7.26.5'],
['@babel/runtime', '7.26.0'],
['@embroider/addon-dev', '7.1.1'],
['@embroider/addon-shim', '1.9.0'],
['@embroider/test-setup', '4.0.0'],
['@glint/core', '1.5.0'],
['@glint/environment-ember-loose', '1.5.0'],
['@glint/environment-ember-template-imports', '1.5.0'],
['@glint/template', '1.5.0'],
['@glint/core', '1.5.1'],
['@glint/environment-ember-loose', '1.5.1'],
['@glint/environment-ember-template-imports', '1.5.1'],
['@glint/template', '1.5.1'],
['@rollup/plugin-babel', '6.0.4'],
['@tsconfig/ember', '3.0.8'],
['@typescript-eslint/eslint-plugin', '8.18.2'],
['@typescript-eslint/parser', '8.18.2'],
['@typescript-eslint/eslint-plugin', '8.20.0'],
['@typescript-eslint/parser', '8.20.0'],
['babel-plugin-ember-template-compilation', '2.3.0'],
['concurrently', '9.1.0'],
['concurrently', '9.1.2'],
['decorator-transforms', '2.3.0'],
['ember-auto-import', '2.10.0'],
['ember-cli-babel', '8.2.0'],
['ember-cli-htmlbars', '6.3.0'],
['ember-source', '6.1.0'],
['ember-template-lint', '6.0.0'],
['eslint', '8.57.1'],
['eslint-config-prettier', '9.1.0'],
['eslint-config-prettier', '10.0.1'],
['eslint-plugin-ember', '12.3.3'],
['eslint-plugin-import', '2.31.0'],
['eslint-plugin-n', '17.15.1'],
['eslint-plugin-prettier', '5.2.1'],
['eslint-plugin-prettier', '5.2.2'],
['prettier', '3.4.2'],
['rollup', '4.29.1'],
['rollup', '4.30.1'],
['rollup-plugin-copy', '3.5.0'],
['typescript', '5.7.2'],
['typescript', '5.7.3'],
]);

export function getLatestVersion(packageName: string): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
// Types for compiled templates
declare module 'demo-app-for-ember-container-query/templates/*' {
import { TemplateFactory } from 'ember-cli-htmlbars';

const tmpl: TemplateFactory;
export default tmpl;
}
import '@glint/environment-ember-loose';
import '@glint/environment-ember-template-imports';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "yarn workspaces run lint",
"lint:fix": "yarn workspaces run lint:fix",
"prepare": "yarn build",
"start": "concurrently 'yarn:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
"start": "concurrently \"yarn:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
"start:addon": "yarn workspace ember-container-query run start",
"start:test-app": "yarn workspace demo-app-for-ember-container-query run start",
"test": "yarn workspaces run test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@
"test": "tests"
},
"scripts": {
"build": "concurrently 'yarn:build:*'",
"build:js": "rollup --config",
"build:types": "glint --declaration",
"lint": "concurrently 'yarn:lint:*(!fix)' --names 'lint:'",
"lint:fix": "concurrently 'yarn:lint:*:fix' --names 'fix:'",
"build": "rollup --config",
"lint": "concurrently \"yarn:lint:*(!fix)\" --names \"lint:\"",
"lint:fix": "concurrently \"yarn:lint:*:fix\" --names \"fix:\"",
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"prepack": "concurrently 'yarn:build:*'",
"start": "concurrently 'yarn:start:*'",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "glint --declaration --watch",
"test": "echo 'A v2 addon does not have tests, run tests in demo-app'"
"prepack": "rollup --config",
"start": "rollup --config --watch",
"test": "echo \"A v2 addon does not have tests, run tests in demo-app\""
},
"changelog": {
"labels": {
Expand All @@ -60,31 +56,31 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-transform-typescript": "^7.26.3",
"@babel/plugin-transform-typescript": "^7.26.5",
"@babel/runtime": "^7.26.0",
"@embroider/addon-dev": "^7.1.1",
"@glint/core": "^1.5.0",
"@glint/environment-ember-loose": "^1.5.0",
"@glint/environment-ember-template-imports": "^1.5.0",
"@glint/template": "^1.5.0",
"@glint/core": "^1.5.1",
"@glint/environment-ember-loose": "^1.5.1",
"@glint/environment-ember-template-imports": "^1.5.1",
"@glint/template": "^1.5.1",
"@rollup/plugin-babel": "^6.0.4",
"@tsconfig/ember": "^3.0.8",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"@typescript-eslint/eslint-plugin": "^8.20.0",
"@typescript-eslint/parser": "^8.20.0",
"babel-plugin-ember-template-compilation": "^2.3.0",
"concurrently": "^9.1.0",
"concurrently": "^9.1.2",
"ember-source": "^6.1.0",
"ember-template-lint": "^6.0.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-ember": "^12.3.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-prettier": "^5.2.2",
"prettier": "^3.4.2",
"rollup": "^4.29.1",
"rollup": "^4.30.1",
"rollup-plugin-copy": "^3.5.0",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
},
"engines": {
"node": "14.* || 16.* || >= 18"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default {
'helpers/**/*.js',
'modifiers/**/*.js',
'services/**/*.js',
'utils/**/*.js',
]),

// Follow the V2 Addon rules about dependencies. Your code can import from
Expand All @@ -54,6 +55,9 @@ export default {
// Ensure that .gjs files are properly integrated as Javascript
addon.gjs(),

// Emit .d.ts declaration files
addon.declarations('declarations'),

// addons are allowed to contain imports of .css files, which we want rollup
// to leave alone and keep in the published output.
addon.keepAssets(['**/*.css']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"emitDeclarationOnly": true,
"noEmit": false,
"noEmitOnError": false,
"rootDir": "./src"
"rootDir": "./src",
"types": [
"ember-source/types"
]
},
"include": [
"src/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import '@glint/environment-ember-loose';
import '@glint/environment-ember-template-imports';
import 'ember-source/types';

// Uncomment if you need to support consuming projects in loose mode
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@
"test": "tests"
},
"scripts": {
"build": "concurrently 'yarn:build:*'",
"build:js": "rollup --config",
"build:types": "glint --declaration",
"lint": "concurrently 'yarn:lint:*(!fix)' --names 'lint:'",
"lint:fix": "concurrently 'yarn:lint:*:fix' --names 'fix:'",
"build": "rollup --config",
"lint": "concurrently \"yarn:lint:*(!fix)\" --names \"lint:\"",
"lint:fix": "concurrently \"yarn:lint:*:fix\" --names \"fix:\"",
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"prepack": "concurrently 'yarn:build:*'",
"start": "concurrently 'yarn:start:*'",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "glint --declaration --watch",
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
"prepack": "rollup --config",
"start": "rollup --config --watch",
"test": "echo \"A v2 addon does not have tests, run tests in test-app\""
},
"changelog": {
"labels": {
Expand All @@ -60,31 +56,31 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-transform-typescript": "^7.26.3",
"@babel/plugin-transform-typescript": "^7.26.5",
"@babel/runtime": "^7.26.0",
"@embroider/addon-dev": "^7.1.1",
"@glint/core": "^1.5.0",
"@glint/environment-ember-loose": "^1.5.0",
"@glint/environment-ember-template-imports": "^1.5.0",
"@glint/template": "^1.5.0",
"@glint/core": "^1.5.1",
"@glint/environment-ember-loose": "^1.5.1",
"@glint/environment-ember-template-imports": "^1.5.1",
"@glint/template": "^1.5.1",
"@rollup/plugin-babel": "^6.0.4",
"@tsconfig/ember": "^3.0.8",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"@typescript-eslint/eslint-plugin": "^8.20.0",
"@typescript-eslint/parser": "^8.20.0",
"babel-plugin-ember-template-compilation": "^2.3.0",
"concurrently": "^9.1.0",
"concurrently": "^9.1.2",
"ember-source": "^6.1.0",
"ember-template-lint": "^6.0.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-ember": "^12.3.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-prettier": "^5.2.2",
"prettier": "^3.4.2",
"rollup": "^4.29.1",
"rollup": "^4.30.1",
"rollup-plugin-copy": "^3.5.0",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
},
"engines": {
"node": "14.* || 16.* || >= 18"
Expand Down
Loading

0 comments on commit 69e8694

Please sign in to comment.