From 7d7118376b0d9069099ee45bcefdc59dc9571e0f Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 26 Dec 2023 19:06:57 +0100 Subject: [PATCH 1/4] feature: Checked whether the addon has blueprint files --- src/steps/analyze-addon.ts | 11 +++++++++++ src/types/index.ts | 1 + tests/helpers/shared-test-setups/customizations.ts | 1 + tests/helpers/shared-test-setups/glint.ts | 1 + tests/helpers/shared-test-setups/javascript.ts | 1 + tests/helpers/shared-test-setups/scoped.ts | 1 + tests/helpers/shared-test-setups/typescript.ts | 1 + tests/steps/analyze-addon/blueprints.test.ts | 1 + .../edge-case-folders-are-missing.test.ts | 1 + tests/steps/analyze-addon/public-assets.test.ts | 1 + tests/steps/analyze-addon/test-support.test.ts | 1 + .../update-addon-package-json/public-assets.test.ts | 1 + 12 files changed, 22 insertions(+) diff --git a/src/steps/analyze-addon.ts b/src/steps/analyze-addon.ts index 396b401b..ec4eca1a 100644 --- a/src/steps/analyze-addon.ts +++ b/src/steps/analyze-addon.ts @@ -31,9 +31,20 @@ function getPublicAssets(options: Options): Record { ); } +function hasBlueprints(options: Options): boolean { + const { projectRoot } = options; + + const filePaths = findFiles('blueprints/**/*', { + projectRoot, + }); + + return filePaths.length > 0; +} + export function analyzeAddon(options: Options): Context { return { addon: { + hasBlueprints: hasBlueprints(options), publicAssets: getPublicAssets(options), }, projectRoot: { diff --git a/src/types/index.ts b/src/types/index.ts index 05ca2267..5a8afb21 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -9,6 +9,7 @@ type CodemodOptions = { type Context = { addon: { + hasBlueprints: boolean; publicAssets: Record; }; projectRoot: { diff --git a/tests/helpers/shared-test-setups/customizations.ts b/tests/helpers/shared-test-setups/customizations.ts index 769fdd53..eb91b80c 100644 --- a/tests/helpers/shared-test-setups/customizations.ts +++ b/tests/helpers/shared-test-setups/customizations.ts @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = { const context: Context = { addon: { + hasBlueprints: false, publicAssets: {}, }, projectRoot: { diff --git a/tests/helpers/shared-test-setups/glint.ts b/tests/helpers/shared-test-setups/glint.ts index 942e4c30..e1e7f16f 100644 --- a/tests/helpers/shared-test-setups/glint.ts +++ b/tests/helpers/shared-test-setups/glint.ts @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = { const context: Context = { addon: { + hasBlueprints: false, publicAssets: {}, }, projectRoot: { diff --git a/tests/helpers/shared-test-setups/javascript.ts b/tests/helpers/shared-test-setups/javascript.ts index 302ac645..6446badd 100644 --- a/tests/helpers/shared-test-setups/javascript.ts +++ b/tests/helpers/shared-test-setups/javascript.ts @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = { const context: Context = { addon: { + hasBlueprints: false, publicAssets: {}, }, projectRoot: { diff --git a/tests/helpers/shared-test-setups/scoped.ts b/tests/helpers/shared-test-setups/scoped.ts index c2093cc0..b8df8a4d 100644 --- a/tests/helpers/shared-test-setups/scoped.ts +++ b/tests/helpers/shared-test-setups/scoped.ts @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = { const context: Context = { addon: { + hasBlueprints: false, publicAssets: {}, }, projectRoot: { diff --git a/tests/helpers/shared-test-setups/typescript.ts b/tests/helpers/shared-test-setups/typescript.ts index 0c1b5301..bfab0c8a 100644 --- a/tests/helpers/shared-test-setups/typescript.ts +++ b/tests/helpers/shared-test-setups/typescript.ts @@ -13,6 +13,7 @@ const codemodOptions: CodemodOptions = { const context: Context = { addon: { + hasBlueprints: false, publicAssets: {}, }, projectRoot: { diff --git a/tests/steps/analyze-addon/blueprints.test.ts b/tests/steps/analyze-addon/blueprints.test.ts index 541d09fd..9833febe 100644 --- a/tests/steps/analyze-addon/blueprints.test.ts +++ b/tests/steps/analyze-addon/blueprints.test.ts @@ -29,6 +29,7 @@ test('steps | analyze-addon > blueprints', function () { assert.deepStrictEqual(analyzeAddon(options), { addon: { + hasBlueprints: true, publicAssets: {}, }, projectRoot: { diff --git a/tests/steps/analyze-addon/edge-case-folders-are-missing.test.ts b/tests/steps/analyze-addon/edge-case-folders-are-missing.test.ts index 4016f1a0..1f4b62ac 100644 --- a/tests/steps/analyze-addon/edge-case-folders-are-missing.test.ts +++ b/tests/steps/analyze-addon/edge-case-folders-are-missing.test.ts @@ -13,6 +13,7 @@ test('steps | analyze-addon > edge case (folders are missing)', function () { assert.deepStrictEqual(analyzeAddon(options), { addon: { + hasBlueprints: false, publicAssets: {}, }, projectRoot: { diff --git a/tests/steps/analyze-addon/public-assets.test.ts b/tests/steps/analyze-addon/public-assets.test.ts index 81410467..0c5daba6 100644 --- a/tests/steps/analyze-addon/public-assets.test.ts +++ b/tests/steps/analyze-addon/public-assets.test.ts @@ -26,6 +26,7 @@ test('steps | analyze-addon > public-assets', function () { assert.deepStrictEqual(analyzeAddon(options), { addon: { + hasBlueprints: false, publicAssets: { './public/assets/documents/some-file.pdf': '/ember-container-query/assets/documents/some-file.pdf', diff --git a/tests/steps/analyze-addon/test-support.test.ts b/tests/steps/analyze-addon/test-support.test.ts index 199deb69..0d34c8fa 100644 --- a/tests/steps/analyze-addon/test-support.test.ts +++ b/tests/steps/analyze-addon/test-support.test.ts @@ -20,6 +20,7 @@ test('steps | analyze-addon > test-support', function () { assert.deepStrictEqual(analyzeAddon(options), { addon: { + hasBlueprints: false, publicAssets: {}, }, projectRoot: { diff --git a/tests/steps/update-addon-package-json/public-assets.test.ts b/tests/steps/update-addon-package-json/public-assets.test.ts index 56d35a2b..55ab4a5d 100644 --- a/tests/steps/update-addon-package-json/public-assets.test.ts +++ b/tests/steps/update-addon-package-json/public-assets.test.ts @@ -23,6 +23,7 @@ test('steps | update-addon-package-json > public-assets', function () { const context: Context = { addon: { + hasBlueprints: false, publicAssets: { './public/assets/documents/some-file.pdf': '/ember-container-query/assets/documents/some-file.pdf', From 649de4065042ca1eb5b9c2ec0d5c63569f5511f4 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 26 Dec 2023 19:17:46 +0100 Subject: [PATCH 2/4] refactor: Added failing tests --- .../files/some-folder/some-file.ts | 0 .../blueprints/some-command/index.js | 5 + .../input/ember-container-query/package.json | 156 ++++++++++++++++++ .../files/some-folder/some-file.ts | 0 .../blueprints/some-command/index.js | 5 + .../output/ember-container-query/package.json | 117 +++++++++++++ tests/steps/analyze-addon/blueprints.test.ts | 8 +- .../blueprints.test.ts | 41 +++++ .../public-assets.test.ts | 1 - 9 files changed, 329 insertions(+), 4 deletions(-) create mode 100644 tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/blueprints/some-command/files/some-folder/some-file.ts create mode 100644 tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/blueprints/some-command/index.js create mode 100644 tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/package.json create mode 100644 tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/blueprints/some-command/files/some-folder/some-file.ts create mode 100644 tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/blueprints/some-command/index.js create mode 100644 tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/package.json create mode 100644 tests/steps/update-addon-package-json/blueprints.test.ts diff --git a/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/blueprints/some-command/files/some-folder/some-file.ts b/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/blueprints/some-command/files/some-folder/some-file.ts new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/blueprints/some-command/index.js b/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/blueprints/some-command/index.js new file mode 100644 index 00000000..c37d6de0 --- /dev/null +++ b/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/blueprints/some-command/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + description: 'Generates something', +}; diff --git a/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/package.json b/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/package.json new file mode 100644 index 00000000..d0f35cf8 --- /dev/null +++ b/tests/fixtures/steps/update-addon-package-json/blueprints/input/ember-container-query/package.json @@ -0,0 +1,156 @@ +{ + "name": "ember-container-query", + "version": "3.2.0", + "description": "Container queries using Ember modifiers", + "keywords": [ + "container-queries", + "container-query", + "element-queries", + "element-query", + "ember-addon", + "ember-octane", + "emberjs", + "glint", + "responsive-design" + ], + "repository": { + "type": "git", + "url": "https://github.com/ijlee2/ember-container-query.git" + }, + "license": "MIT", + "author": "Isaac J. Lee", + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "build": "ember build --environment=production", + "build:test": "ember build --environment=test", + "changelog": "lerna-changelog", + "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", + "lint:css": "stylelint \"tests/dummy/app/**/*.css\" --cache", + "lint:css:fix": "stylelint \"tests/dummy/app/**/*.css\" --fix", + "lint:dependency": "ember dependency-lint", + "lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"", + "lint:hbs": "ember-template-lint .", + "lint:hbs:fix": "ember-template-lint . --fix", + "lint:js": "eslint . --cache --ext=.js,.ts", + "lint:js:fix": "eslint . --fix", + "lint:types": "tsc --noEmit", + "prepack": "ember ts:precompile", + "postpack": "ember ts:clean", + "start": "ember serve", + "test": "DEVICE='w3-h3' ember test", + "test:ember": "ember test", + "test:ember-compatibility": "./node_modules/.bin/ember try:one" + }, + "changelog": { + "labels": { + "breaking": "Breaking Change", + "bug": "Bug Fix", + "enhance: code": "Enhancement", + "enhance: dependency": "Internal", + "enhance: documentation": "Documentation", + "user feedback": "User Feedback" + } + }, + "dependencies": { + "ember-cli-babel": "^7.26.11", + "ember-cli-htmlbars": "^6.1.1", + "ember-cli-typescript": "^5.2.1", + "ember-element-helper": "^0.6.1", + "ember-modifier": "^3.2.7", + "ember-resize-observer-service": "^1.1.0", + "ember-test-selectors": "^6.0.0" + }, + "devDependencies": { + "@ember/optional-features": "^2.0.0", + "@ember/test-helpers": "^2.9.3", + "@embroider/test-setup": "^2.0.2", + "@glimmer/component": "^1.1.2", + "@glimmer/tracking": "^1.1.2", + "@percy/cli": "^1.16.0", + "@percy/ember": "^4.0.0", + "@tsconfig/ember": "^2.0.0", + "@types/ember__application": "^4.0.5", + "@types/ember__array": "^4.0.3", + "@types/ember__component": "^4.0.12", + "@types/ember__controller": "^4.0.4", + "@types/ember__debug": "^4.0.3", + "@types/ember__destroyable": "^4.0.1", + "@types/ember__engine": "^4.0.4", + "@types/ember__error": "^4.0.2", + "@types/ember__object": "^4.0.5", + "@types/ember__polyfills": "^4.0.1", + "@types/ember__routing": "^4.0.12", + "@types/ember__runloop": "^4.0.2", + "@types/ember__service": "^4.0.2", + "@types/ember__string": "^3.0.10", + "@types/ember__template": "^4.0.1", + "@types/ember__test": "^4.0.1", + "@types/ember__utils": "^4.0.2", + "@types/htmlbars-inline-precompile": "^3.0.0", + "@types/qunit": "^2.19.3", + "@types/rsvp": "^4.0.4", + "@typescript-eslint/eslint-plugin": "^5.48.0", + "@typescript-eslint/parser": "^5.48.0", + "broccoli-asset-rev": "^3.0.0", + "concurrently": "^7.6.0", + "d3-array": "^3.2.1", + "d3-axis": "^3.0.0", + "d3-scale": "^4.0.2", + "d3-selection": "^3.0.0", + "d3-shape": "^3.2.0", + "ember-a11y-refocus": "^3.0.2", + "ember-a11y-testing": "^5.1.0", + "ember-auto-import": "^2.5.0", + "ember-cli": "~4.9.2", + "ember-cli-dependency-checker": "^3.3.1", + "ember-cli-dependency-lint": "^2.0.1", + "ember-cli-inject-live-reload": "^2.1.0", + "ember-cli-netlify": "^0.4.1", + "ember-cli-sri": "^2.1.1", + "ember-cli-terser": "^4.0.2", + "ember-css-modules": "^2.0.1", + "ember-load-initializers": "^2.1.2", + "ember-page-title": "^7.0.0", + "ember-qunit": "^6.1.1", + "ember-resolver": "^9.0.1", + "ember-source": "~4.9.3", + "ember-source-channel-url": "^3.0.0", + "ember-svg-jar": "^2.4.2", + "ember-template-lint": "^5.3.0", + "ember-template-lint-plugin-prettier": "^4.1.0", + "ember-truth-helpers": "^3.1.1", + "ember-try": "^2.0.0", + "eslint": "^8.31.0", + "eslint-config-prettier": "^8.6.0", + "eslint-plugin-ember": "^11.4.2", + "eslint-plugin-n": "^15.6.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-qunit": "^7.3.4", + "eslint-plugin-simple-import-sort": "^8.0.0", + "eslint-plugin-typescript-sort-keys": "^2.1.0", + "lerna-changelog": "^2.2.0", + "loader.js": "^4.7.0", + "prettier": "^2.8.1", + "qunit": "^2.19.3", + "qunit-dom": "^2.0.0", + "stylelint": "^14.16.1", + "stylelint-config-standard": "^29.0.0", + "stylelint-no-unsupported-browser-features": "^6.0.1", + "stylelint-order": "^6.0.0", + "typescript": "^4.9.4", + "webpack": "^5.75.0" + }, + "engines": { + "node": "14.* || 16.* || >= 18" + }, + "ember": { + "edition": "octane" + }, + "ember-addon": { + "configPath": "tests/dummy/config", + "demoURL": "https://ember-container-query.netlify.app" + } +} diff --git a/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/blueprints/some-command/files/some-folder/some-file.ts b/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/blueprints/some-command/files/some-folder/some-file.ts new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/blueprints/some-command/index.js b/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/blueprints/some-command/index.js new file mode 100644 index 00000000..c37d6de0 --- /dev/null +++ b/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/blueprints/some-command/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + description: 'Generates something', +}; diff --git a/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/package.json b/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/package.json new file mode 100644 index 00000000..c1061090 --- /dev/null +++ b/tests/fixtures/steps/update-addon-package-json/blueprints/output/ember-container-query/package.json @@ -0,0 +1,117 @@ +{ + "name": "ember-container-query", + "version": "3.2.0", + "description": "Container queries using Ember modifiers", + "keywords": [ + "container-queries", + "container-query", + "element-queries", + "element-query", + "ember-addon", + "ember-octane", + "emberjs", + "glint", + "responsive-design" + ], + "repository": { + "type": "git", + "url": "https://github.com/ijlee2/ember-container-query.git" + }, + "license": "MIT", + "author": "Isaac J. Lee", + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "build": "concurrently \"npm:build:*\" --names \"build:\"", + "build:js": "rollup --config", + "build:test": "ember build --environment=test", + "build:types": "tsc", + "changelog": "lerna-changelog", + "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", + "lint:css": "stylelint \"tests/dummy/app/**/*.css\" --cache", + "lint:css:fix": "stylelint \"tests/dummy/app/**/*.css\" --fix", + "lint:dependency": "ember dependency-lint", + "lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"", + "lint:hbs": "ember-template-lint .", + "lint:hbs:fix": "ember-template-lint . --fix", + "lint:js": "eslint . --cache --ext=.js,.ts", + "lint:js:fix": "eslint . --fix", + "lint:types": "tsc --emitDeclarationOnly false --noEmit", + "prepack": "rollup --config", + "start": "concurrently \"npm:start:*\" --names \"start:\"", + "start:js": "rollup --config --watch --no-watch.clearScreen", + "start:types": "tsc --watch", + "test": "echo 'A v2 addon does not have tests, run tests in test-app'", + "test:ember": "ember test", + "test:ember-compatibility": "./node_modules/.bin/ember try:one" + }, + "changelog": { + "labels": { + "breaking": "Breaking Change", + "bug": "Bug Fix", + "enhance: code": "Enhancement", + "enhance: dependency": "Internal", + "enhance: documentation": "Documentation", + "user feedback": "User Feedback" + } + }, + "dependencies": { + "@embroider/addon-shim": "^1.8.7", + "decorator-transforms": "^1.0.1", + "ember-element-helper": "^0.6.1", + "ember-modifier": "^3.2.7", + "ember-resize-observer-service": "^1.1.0", + "ember-test-selectors": "^6.0.0" + }, + "devDependencies": { + "@babel/core": "^7.23.6", + "@babel/plugin-transform-typescript": "^7.23.6", + "@babel/runtime": "^7.23.6", + "@embroider/addon-dev": "^4.1.3", + "@rollup/plugin-babel": "^6.0.4", + "@tsconfig/ember": "^2.0.0", + "babel-plugin-ember-template-compilation": "^2.2.1", + "concurrently": "^7.6.0", + "rollup": "^4.9.1", + "rollup-plugin-copy": "^3.5.0", + "typescript": "^4.9.4" + }, + "engines": { + "node": "14.* || 16.* || >= 18" + }, + "ember": { + "edition": "octane" + }, + "ember-addon": { + "app-js": {}, + "main": "addon-main.cjs", + "type": "addon", + "version": 2 + }, + "exports": { + ".": { + "types": "./declarations/index.d.ts", + "default": "./dist/index.js" + }, + "./*": { + "types": "./declarations/*.d.ts", + "default": "./dist/*.js" + }, + "./addon-main.js": "./addon-main.cjs" + }, + "files": [ + "addon-main.cjs", + "blueprints", + "declarations", + "dist" + ], + "typesVersions": { + "*": { + "*": [ + "declarations/*" + ] + } + } +} diff --git a/tests/steps/analyze-addon/blueprints.test.ts b/tests/steps/analyze-addon/blueprints.test.ts index 9833febe..ec87f9bc 100644 --- a/tests/steps/analyze-addon/blueprints.test.ts +++ b/tests/steps/analyze-addon/blueprints.test.ts @@ -9,15 +9,17 @@ import { test('steps | analyze-addon > blueprints', function () { const inputProject = { blueprints: { - 'ember-container-query': { + 'some-command': { files: { 'some-folder': { 'some-file.ts': '', }, }, - 'index.ts': [ + 'index.js': [ + `'use strict';`, + ``, `module.exports = {`, - ` normalizeEntityName() {},`, + ` description: 'Generates something',`, `};`, ``, ].join('\n'), diff --git a/tests/steps/update-addon-package-json/blueprints.test.ts b/tests/steps/update-addon-package-json/blueprints.test.ts new file mode 100644 index 00000000..27c86f1f --- /dev/null +++ b/tests/steps/update-addon-package-json/blueprints.test.ts @@ -0,0 +1,41 @@ +import { + assertFixture, + convertFixtureToJson, + loadFixture, + test, +} from '@codemod-utils/tests'; + +import { updateAddonPackageJson } from '../../../src/steps/index.js'; +import type { Context } from '../../../src/types/index.js'; +import { + codemodOptions, + options, +} from '../../helpers/shared-test-setups/typescript.js'; + +test('steps | update-addon-package-json > blueprints', function () { + const inputProject = convertFixtureToJson( + 'steps/update-addon-package-json/blueprints/input', + ); + + const outputProject = convertFixtureToJson( + 'steps/update-addon-package-json/blueprints/output', + ); + + const context: Context = { + addon: { + hasBlueprints: true, + publicAssets: {}, + }, + projectRoot: { + devDependencies: { + concurrently: '^7.6.0', + }, + }, + }; + + loadFixture(inputProject, codemodOptions); + + updateAddonPackageJson(context, options); + + assertFixture(outputProject, codemodOptions); +}); diff --git a/tests/steps/update-addon-package-json/public-assets.test.ts b/tests/steps/update-addon-package-json/public-assets.test.ts index 55ab4a5d..835c782f 100644 --- a/tests/steps/update-addon-package-json/public-assets.test.ts +++ b/tests/steps/update-addon-package-json/public-assets.test.ts @@ -34,7 +34,6 @@ test('steps | update-addon-package-json > public-assets', function () { projectRoot: { devDependencies: { concurrently: '^7.6.0', - prettier: '^2.8.1', }, }, }; From d6c1caa07c7ad8ab3e0274ea75c99adfa77e23a8 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 26 Dec 2023 19:18:11 +0100 Subject: [PATCH 3/4] bugfix: Added blueprints to files --- .../update-addon-package-json/update-other-fields.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/steps/update-addon-package-json/update-other-fields.ts b/src/steps/update-addon-package-json/update-other-fields.ts index 1f5aae87..b27b8ec3 100644 --- a/src/steps/update-addon-package-json/update-other-fields.ts +++ b/src/steps/update-addon-package-json/update-other-fields.ts @@ -1,6 +1,7 @@ import type { Context, Options, PackageJson } from '../../types/index.js'; type Data = { + hasBlueprints: boolean; hasPublicAssets: boolean; hasTypeScript: boolean; publicAssets: Record; @@ -59,10 +60,14 @@ function updateExports(packageJson: PackageJson, data: Data): void { } function updateFiles(packageJson: PackageJson, data: Data): void { - const { hasPublicAssets, hasTypeScript } = data; + const { hasBlueprints, hasPublicAssets, hasTypeScript } = data; const files = new Set(['addon-main.cjs', 'dist']); + if (hasBlueprints) { + files.add('blueprints'); + } + if (hasPublicAssets) { files.add('public'); } @@ -99,6 +104,7 @@ export function updateOtherFields( const hasPublicAssets = Object.keys(addon.publicAssets).length > 0; const data = { + hasBlueprints: addon.hasBlueprints, hasPublicAssets, hasTypeScript: packages.addon.hasTypeScript, publicAssets: addon.publicAssets, From 0b851c0fd4a2c9c84a2d55fbd0009b5450e7f75d Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Tue, 26 Dec 2023 19:20:55 +0100 Subject: [PATCH 4/4] refactor: Improved code readability --- .../update-other-fields.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/steps/update-addon-package-json/update-other-fields.ts b/src/steps/update-addon-package-json/update-other-fields.ts index b27b8ec3..9fcb34a9 100644 --- a/src/steps/update-addon-package-json/update-other-fields.ts +++ b/src/steps/update-addon-package-json/update-other-fields.ts @@ -98,16 +98,14 @@ export function updateOtherFields( context: Context, options: Options, ): void { - const { addon } = context; - const { packages } = options; - - const hasPublicAssets = Object.keys(addon.publicAssets).length > 0; + const { hasBlueprints, publicAssets } = context.addon; + const { hasTypeScript } = options.packages.addon; const data = { - hasBlueprints: addon.hasBlueprints, - hasPublicAssets, - hasTypeScript: packages.addon.hasTypeScript, - publicAssets: addon.publicAssets, + hasBlueprints, + hasPublicAssets: Object.keys(publicAssets).length > 0, + hasTypeScript, + publicAssets, }; updateEmberAddon(packageJson, data);