From 619293500f517db14ed18742a638b483f9486894 Mon Sep 17 00:00:00 2001 From: Isaac Lee <16869656+ijlee2@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:53:27 +0200 Subject: [PATCH] Corrected the addon file locations for TypeScript projects (#90) * bugfix: Replaced .js with .ts in publicEntrypoints() * chore: Updated fixtures * chore: Added fixtures (hello-world) to test addon-test-support * bugfix: Created the barrel file for test-support --------- Co-authored-by: ijlee2 --- .../__addonLocation__/rollup.config.mjs | 2 +- src/steps/move-addon-files.ts | 14 ++- .../input/tests/helpers/index.ts | 2 +- .../output/demo-app/tests/helpers/index.ts | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../input/tests/helpers/index.ts | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../output/test-app/tests/helpers/index.ts | 2 +- .../input/tests/helpers/index.js | 2 +- .../output/test-app/tests/helpers/index.js | 2 +- .../input/tests/helpers/index.ts | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../output/test-app/tests/helpers/index.ts | 2 +- .../input/tests/helpers/index.ts | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../output/test-app/tests/helpers/index.ts | 2 +- tests/fixtures/hello-world/index.ts | 6 + .../fixtures/hello-world/input/.editorconfig | 19 +++ tests/fixtures/hello-world/input/.ember-cli | 15 +++ .../fixtures/hello-world/input/.eslintignore | 25 ++++ tests/fixtures/hello-world/input/.eslintrc.js | 62 ++++++++++ tests/fixtures/hello-world/input/.gitignore | 32 +++++ tests/fixtures/hello-world/input/.npmignore | 39 +++++++ .../hello-world/input/.prettierignore | 25 ++++ .../fixtures/hello-world/input/.prettierrc.js | 5 + .../hello-world/input/.template-lintrc.js | 5 + .../hello-world/input/.watchmanconfig | 3 + .../hello-world/input/CONTRIBUTING.md | 25 ++++ .../addon-test-support/components/hello.ts | 3 + .../input/addon-test-support/index.ts | 1 + .../fixtures/hello-world/input/addon/.gitkeep | 0 .../input/addon/components/hello.css | 7 ++ .../input/addon/components/hello.hbs | 9 ++ .../input/addon/components/hello.ts | 3 + tests/fixtures/hello-world/input/app/.gitkeep | 0 .../hello-world/input/app/components/hello.js | 1 + .../hello-world/input/ember-cli-build.js | 25 ++++ tests/fixtures/hello-world/input/index.js | 5 + tests/fixtures/hello-world/input/package.json | 110 ++++++++++++++++++ .../fixtures/hello-world/input/pnpm-lock.yaml | 0 tests/fixtures/hello-world/input/testem.js | 23 ++++ .../hello-world/input/tests/dummy/app/app.js | 12 ++ .../input/tests/dummy/app/components/.gitkeep | 0 .../tests/dummy/app/controllers/.gitkeep | 0 .../input/tests/dummy/app/helpers/.gitkeep | 0 .../input/tests/dummy/app/index.html | 24 ++++ .../input/tests/dummy/app/models/.gitkeep | 0 .../input/tests/dummy/app/router.js | 9 ++ .../input/tests/dummy/app/routes/.gitkeep | 0 .../input/tests/dummy/app/styles/app.css | 0 .../tests/dummy/app/templates/application.hbs | 5 + .../tests/dummy/config/ember-cli-update.json | 20 ++++ .../input/tests/dummy/config/ember-try.js | 71 +++++++++++ .../input/tests/dummy/config/environment.js | 48 ++++++++ .../tests/dummy/config/optional-features.json | 6 + .../input/tests/dummy/config/targets.js | 11 ++ .../input/tests/dummy/public/robots.txt | 3 + .../hello-world/input/tests/helpers/index.js | 42 +++++++ .../hello-world/input/tests/index.html | 39 +++++++ .../input/tests/integration/.gitkeep | 0 .../integration/components/hello-test.ts | 15 +++ .../hello-world/input/tests/test-helper.js | 12 ++ .../hello-world/input/tests/unit/.gitkeep | 0 .../fixtures/hello-world/input/tsconfig.json | 42 +++++++ .../hello-world/input/types/dummy/index.d.ts | 0 .../hello-world/input/types/global.d.ts | 7 ++ .../fixtures/hello-world/output/.editorconfig | 19 +++ tests/fixtures/hello-world/output/.gitignore | 10 ++ .../hello-world/output/CONTRIBUTING.md | 25 ++++ .../output/hello-world/.eslintignore | 9 ++ .../output/hello-world/.eslintrc.cjs | 100 ++++++++++++++++ .../hello-world/output/hello-world/.gitignore | 17 +++ .../output/hello-world/.prettierignore | 9 ++ .../output/hello-world/.prettierrc.cjs | 5 + .../output/hello-world/.template-lintrc.cjs | 5 + .../output/hello-world/addon-main.cjs | 5 + .../output/hello-world/babel.config.json | 28 +++++ .../output/hello-world/package.json | 100 ++++++++++++++++ .../output/hello-world/rollup.config.mjs | 72 ++++++++++++ .../output/hello-world/src/.gitkeep | 0 .../hello-world/src/components/hello.css | 7 ++ .../hello-world/src/components/hello.hbs | 9 ++ .../hello-world/src/components/hello.ts | 3 + .../output/hello-world/src/test-support.ts | 1 + .../src/test-support/components/hello.ts | 3 + .../output/hello-world/tsconfig.json | 16 +++ .../unpublished-development-types/index.d.ts | 2 + .../fixtures/hello-world/output/package.json | 21 ++++ .../hello-world/output/pnpm-lock.yaml | 0 .../hello-world/output/pnpm-workspace.yaml | 3 + .../hello-world/output/test-app/.ember-cli | 15 +++ .../hello-world/output/test-app/.eslintignore | 25 ++++ .../hello-world/output/test-app/.eslintrc.js | 62 ++++++++++ .../hello-world/output/test-app/.gitignore | 32 +++++ .../output/test-app/.prettierignore | 25 ++++ .../output/test-app/.prettierrc.js | 5 + .../output/test-app/.template-lintrc.js | 5 + .../output/test-app/.watchmanconfig | 3 + .../hello-world/output/test-app/app/app.js | 12 ++ .../output/test-app/app/components/.gitkeep | 0 .../output/test-app/app/controllers/.gitkeep | 0 .../output/test-app/app/helpers/.gitkeep | 0 .../output/test-app/app/index.html | 24 ++++ .../output/test-app/app/models/.gitkeep | 0 .../hello-world/output/test-app/app/router.js | 9 ++ .../output/test-app/app/routes/.gitkeep | 0 .../output/test-app/app/styles/app.css | 0 .../test-app/app/templates/application.hbs | 5 + .../test-app/config/ember-cli-update.json | 20 ++++ .../output/test-app/config/ember-try.js | 71 +++++++++++ .../output/test-app/config/environment.js | 48 ++++++++ .../test-app/config/optional-features.json | 6 + .../output/test-app/config/targets.js | 11 ++ .../output/test-app/ember-cli-build.js | 19 +++ .../hello-world/output/test-app/package.json | 106 +++++++++++++++++ .../output/test-app/public/robots.txt | 3 + .../hello-world/output/test-app/testem.js | 23 ++++ .../output/test-app/tests/helpers/index.js | 42 +++++++ .../output/test-app/tests/index.html | 39 +++++++ .../test-app/tests/integration/.gitkeep | 0 .../integration/components/hello-test.ts | 15 +++ .../output/test-app/tests/test-helper.js | 12 ++ .../output/test-app/tests/unit/.gitkeep | 0 .../hello-world/output/test-app/tsconfig.json | 17 +++ .../output/test-app/types/global.d.ts | 7 ++ .../output/test-app/types/test-app/index.d.ts | 0 .../input/tests/helpers/index.ts | 2 +- .../input/types/dummy/index.d.ts | 1 - .../output/demo-app/tests/helpers/index.ts | 2 +- .../demo-app-for-new-v1-addon/index.d.ts | 1 - .../packages/new-v1-addon/rollup.config.mjs | 2 +- .../input/tests/helpers/index.js | 2 +- .../output/test-app/tests/helpers/index.js | 2 +- .../input/tests/helpers/index.js | 2 +- .../output/test-app/tests/helpers/index.js | 2 +- .../input/tests/helpers/index.js | 2 +- .../output/test-app/tests/helpers/index.js | 2 +- .../input/tests/helpers/index.ts | 2 +- .../input/types/dummy/index.d.ts | 1 - .../output/new-v1-addon/rollup.config.mjs | 2 +- .../output/test-app/tests/helpers/index.ts | 2 +- .../output/test-app/types/test-app/index.d.ts | 1 - .../ember-container-query/rollup.config.mjs | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- .../ember-container-query/rollup.config.mjs | 2 +- tests/index/hello-world/index.test.ts | 27 +++++ .../move-addon-files/test-support.test.ts | 2 +- update-test-fixtures.sh | 7 ++ 151 files changed, 2025 insertions(+), 39 deletions(-) create mode 100644 tests/fixtures/hello-world/index.ts create mode 100644 tests/fixtures/hello-world/input/.editorconfig create mode 100644 tests/fixtures/hello-world/input/.ember-cli create mode 100644 tests/fixtures/hello-world/input/.eslintignore create mode 100644 tests/fixtures/hello-world/input/.eslintrc.js create mode 100644 tests/fixtures/hello-world/input/.gitignore create mode 100644 tests/fixtures/hello-world/input/.npmignore create mode 100644 tests/fixtures/hello-world/input/.prettierignore create mode 100644 tests/fixtures/hello-world/input/.prettierrc.js create mode 100644 tests/fixtures/hello-world/input/.template-lintrc.js create mode 100644 tests/fixtures/hello-world/input/.watchmanconfig create mode 100644 tests/fixtures/hello-world/input/CONTRIBUTING.md create mode 100644 tests/fixtures/hello-world/input/addon-test-support/components/hello.ts create mode 100644 tests/fixtures/hello-world/input/addon-test-support/index.ts create mode 100644 tests/fixtures/hello-world/input/addon/.gitkeep create mode 100644 tests/fixtures/hello-world/input/addon/components/hello.css create mode 100644 tests/fixtures/hello-world/input/addon/components/hello.hbs create mode 100644 tests/fixtures/hello-world/input/addon/components/hello.ts create mode 100644 tests/fixtures/hello-world/input/app/.gitkeep create mode 100644 tests/fixtures/hello-world/input/app/components/hello.js create mode 100644 tests/fixtures/hello-world/input/ember-cli-build.js create mode 100644 tests/fixtures/hello-world/input/index.js create mode 100644 tests/fixtures/hello-world/input/package.json create mode 100644 tests/fixtures/hello-world/input/pnpm-lock.yaml create mode 100644 tests/fixtures/hello-world/input/testem.js create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/app.js create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/components/.gitkeep create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/controllers/.gitkeep create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/helpers/.gitkeep create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/index.html create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/models/.gitkeep create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/router.js create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/routes/.gitkeep create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/styles/app.css create mode 100644 tests/fixtures/hello-world/input/tests/dummy/app/templates/application.hbs create mode 100644 tests/fixtures/hello-world/input/tests/dummy/config/ember-cli-update.json create mode 100644 tests/fixtures/hello-world/input/tests/dummy/config/ember-try.js create mode 100644 tests/fixtures/hello-world/input/tests/dummy/config/environment.js create mode 100644 tests/fixtures/hello-world/input/tests/dummy/config/optional-features.json create mode 100644 tests/fixtures/hello-world/input/tests/dummy/config/targets.js create mode 100644 tests/fixtures/hello-world/input/tests/dummy/public/robots.txt create mode 100644 tests/fixtures/hello-world/input/tests/helpers/index.js create mode 100644 tests/fixtures/hello-world/input/tests/index.html create mode 100644 tests/fixtures/hello-world/input/tests/integration/.gitkeep create mode 100644 tests/fixtures/hello-world/input/tests/integration/components/hello-test.ts create mode 100644 tests/fixtures/hello-world/input/tests/test-helper.js create mode 100644 tests/fixtures/hello-world/input/tests/unit/.gitkeep create mode 100644 tests/fixtures/hello-world/input/tsconfig.json create mode 100644 tests/fixtures/hello-world/input/types/dummy/index.d.ts create mode 100644 tests/fixtures/hello-world/input/types/global.d.ts create mode 100644 tests/fixtures/hello-world/output/.editorconfig create mode 100644 tests/fixtures/hello-world/output/.gitignore create mode 100644 tests/fixtures/hello-world/output/CONTRIBUTING.md create mode 100644 tests/fixtures/hello-world/output/hello-world/.eslintignore create mode 100644 tests/fixtures/hello-world/output/hello-world/.eslintrc.cjs create mode 100644 tests/fixtures/hello-world/output/hello-world/.gitignore create mode 100644 tests/fixtures/hello-world/output/hello-world/.prettierignore create mode 100644 tests/fixtures/hello-world/output/hello-world/.prettierrc.cjs create mode 100644 tests/fixtures/hello-world/output/hello-world/.template-lintrc.cjs create mode 100644 tests/fixtures/hello-world/output/hello-world/addon-main.cjs create mode 100644 tests/fixtures/hello-world/output/hello-world/babel.config.json create mode 100644 tests/fixtures/hello-world/output/hello-world/package.json create mode 100644 tests/fixtures/hello-world/output/hello-world/rollup.config.mjs create mode 100644 tests/fixtures/hello-world/output/hello-world/src/.gitkeep create mode 100644 tests/fixtures/hello-world/output/hello-world/src/components/hello.css create mode 100644 tests/fixtures/hello-world/output/hello-world/src/components/hello.hbs create mode 100644 tests/fixtures/hello-world/output/hello-world/src/components/hello.ts create mode 100644 tests/fixtures/hello-world/output/hello-world/src/test-support.ts create mode 100644 tests/fixtures/hello-world/output/hello-world/src/test-support/components/hello.ts create mode 100644 tests/fixtures/hello-world/output/hello-world/tsconfig.json create mode 100644 tests/fixtures/hello-world/output/hello-world/unpublished-development-types/index.d.ts create mode 100644 tests/fixtures/hello-world/output/package.json create mode 100644 tests/fixtures/hello-world/output/pnpm-lock.yaml create mode 100644 tests/fixtures/hello-world/output/pnpm-workspace.yaml create mode 100644 tests/fixtures/hello-world/output/test-app/.ember-cli create mode 100644 tests/fixtures/hello-world/output/test-app/.eslintignore create mode 100644 tests/fixtures/hello-world/output/test-app/.eslintrc.js create mode 100644 tests/fixtures/hello-world/output/test-app/.gitignore create mode 100644 tests/fixtures/hello-world/output/test-app/.prettierignore create mode 100644 tests/fixtures/hello-world/output/test-app/.prettierrc.js create mode 100644 tests/fixtures/hello-world/output/test-app/.template-lintrc.js create mode 100644 tests/fixtures/hello-world/output/test-app/.watchmanconfig create mode 100644 tests/fixtures/hello-world/output/test-app/app/app.js create mode 100644 tests/fixtures/hello-world/output/test-app/app/components/.gitkeep create mode 100644 tests/fixtures/hello-world/output/test-app/app/controllers/.gitkeep create mode 100644 tests/fixtures/hello-world/output/test-app/app/helpers/.gitkeep create mode 100644 tests/fixtures/hello-world/output/test-app/app/index.html create mode 100644 tests/fixtures/hello-world/output/test-app/app/models/.gitkeep create mode 100644 tests/fixtures/hello-world/output/test-app/app/router.js create mode 100644 tests/fixtures/hello-world/output/test-app/app/routes/.gitkeep create mode 100644 tests/fixtures/hello-world/output/test-app/app/styles/app.css create mode 100644 tests/fixtures/hello-world/output/test-app/app/templates/application.hbs create mode 100644 tests/fixtures/hello-world/output/test-app/config/ember-cli-update.json create mode 100644 tests/fixtures/hello-world/output/test-app/config/ember-try.js create mode 100644 tests/fixtures/hello-world/output/test-app/config/environment.js create mode 100644 tests/fixtures/hello-world/output/test-app/config/optional-features.json create mode 100644 tests/fixtures/hello-world/output/test-app/config/targets.js create mode 100644 tests/fixtures/hello-world/output/test-app/ember-cli-build.js create mode 100644 tests/fixtures/hello-world/output/test-app/package.json create mode 100644 tests/fixtures/hello-world/output/test-app/public/robots.txt create mode 100644 tests/fixtures/hello-world/output/test-app/testem.js create mode 100644 tests/fixtures/hello-world/output/test-app/tests/helpers/index.js create mode 100644 tests/fixtures/hello-world/output/test-app/tests/index.html create mode 100644 tests/fixtures/hello-world/output/test-app/tests/integration/.gitkeep create mode 100644 tests/fixtures/hello-world/output/test-app/tests/integration/components/hello-test.ts create mode 100644 tests/fixtures/hello-world/output/test-app/tests/test-helper.js create mode 100644 tests/fixtures/hello-world/output/test-app/tests/unit/.gitkeep create mode 100644 tests/fixtures/hello-world/output/test-app/tsconfig.json create mode 100644 tests/fixtures/hello-world/output/test-app/types/global.d.ts create mode 100644 tests/fixtures/hello-world/output/test-app/types/test-app/index.d.ts create mode 100644 tests/index/hello-world/index.test.ts diff --git a/src/blueprints/ember-addon/__addonLocation__/rollup.config.mjs b/src/blueprints/ember-addon/__addonLocation__/rollup.config.mjs index 23500d8a..96da7ae0 100644 --- a/src/blueprints/ember-addon/__addonLocation__/rollup.config.mjs +++ b/src/blueprints/ember-addon/__addonLocation__/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js'<% if (options.packages.addon.hasGlint) {%>, 'template-registry.js'<% } %>]), + <% if (options.packages.addon.hasTypeScript) { %>addon.publicEntrypoints(['**/*.js', 'index.ts'<% if (options.packages.addon.hasGlint) {%>, 'template-registry.ts'<% } %>]),<% } else { %>addon.publicEntrypoints(['**/*.js', 'index.js']),<% } %> // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/src/steps/move-addon-files.ts b/src/steps/move-addon-files.ts index 6708ed98..b13020ba 100644 --- a/src/steps/move-addon-files.ts +++ b/src/steps/move-addon-files.ts @@ -25,7 +25,19 @@ function moveAddonFolder(options: Options): void { function moveAddonTestSupportFolder(options: Options): void { const { locations, projectRoot } = options; - const filePaths = findFiles('addon-test-support/**/*', { + let filePaths = findFiles('addon-test-support/index.{js,ts}', { + projectRoot, + }); + + if (filePaths.length === 1) { + const oldPath = filePaths[0]!; + const newPath = `${locations.addon}/src/test-support${oldPath.endsWith('.ts') ? '.ts' : 'js'}`; + + moveFiles(new Map([[oldPath, newPath]]), options); + } + + filePaths = findFiles('addon-test-support/**/*', { + ignoreList: ['addon-test-support/index.{js,ts}'], projectRoot, }); diff --git a/tests/fixtures/ember-container-query-customizations/input/tests/helpers/index.ts b/tests/fixtures/ember-container-query-customizations/input/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-customizations/input/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-customizations/input/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-customizations/output/demo-app/tests/helpers/index.ts b/tests/fixtures/ember-container-query-customizations/output/demo-app/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-customizations/output/demo-app/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-customizations/output/demo-app/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-customizations/output/packages/ember-container-query/rollup.config.mjs b/tests/fixtures/ember-container-query-customizations/output/packages/ember-container-query/rollup.config.mjs index 4472e2db..e0794c07 100644 --- a/tests/fixtures/ember-container-query-customizations/output/packages/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/ember-container-query-customizations/output/packages/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js', 'template-registry.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts', 'template-registry.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/ember-container-query-glint/input/tests/helpers/index.ts b/tests/fixtures/ember-container-query-glint/input/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-glint/input/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-glint/input/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-glint/output/ember-container-query/rollup.config.mjs b/tests/fixtures/ember-container-query-glint/output/ember-container-query/rollup.config.mjs index 4472e2db..e0794c07 100644 --- a/tests/fixtures/ember-container-query-glint/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/ember-container-query-glint/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js', 'template-registry.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts', 'template-registry.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/ember-container-query-glint/output/test-app/tests/helpers/index.ts b/tests/fixtures/ember-container-query-glint/output/test-app/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-glint/output/test-app/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-glint/output/test-app/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-javascript/input/tests/helpers/index.js b/tests/fixtures/ember-container-query-javascript/input/tests/helpers/index.js index c87ee260..d2276795 100644 --- a/tests/fixtures/ember-container-query-javascript/input/tests/helpers/index.js +++ b/tests/fixtures/ember-container-query-javascript/input/tests/helpers/index.js @@ -26,7 +26,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-javascript/output/test-app/tests/helpers/index.js b/tests/fixtures/ember-container-query-javascript/output/test-app/tests/helpers/index.js index c87ee260..d2276795 100644 --- a/tests/fixtures/ember-container-query-javascript/output/test-app/tests/helpers/index.js +++ b/tests/fixtures/ember-container-query-javascript/output/test-app/tests/helpers/index.js @@ -26,7 +26,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-scoped/input/tests/helpers/index.ts b/tests/fixtures/ember-container-query-scoped/input/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-scoped/input/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-scoped/input/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-scoped/output/ember-container-query/rollup.config.mjs b/tests/fixtures/ember-container-query-scoped/output/ember-container-query/rollup.config.mjs index 4472e2db..e0794c07 100644 --- a/tests/fixtures/ember-container-query-scoped/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/ember-container-query-scoped/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js', 'template-registry.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts', 'template-registry.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/ember-container-query-scoped/output/test-app/tests/helpers/index.ts b/tests/fixtures/ember-container-query-scoped/output/test-app/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-scoped/output/test-app/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-scoped/output/test-app/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-typescript/input/tests/helpers/index.ts b/tests/fixtures/ember-container-query-typescript/input/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-typescript/input/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-typescript/input/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/ember-container-query-typescript/output/ember-container-query/rollup.config.mjs b/tests/fixtures/ember-container-query-typescript/output/ember-container-query/rollup.config.mjs index cf1e4909..e704c415 100644 --- a/tests/fixtures/ember-container-query-typescript/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/ember-container-query-typescript/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/ember-container-query-typescript/output/test-app/tests/helpers/index.ts b/tests/fixtures/ember-container-query-typescript/output/test-app/tests/helpers/index.ts index 2f581490..918beb6c 100644 --- a/tests/fixtures/ember-container-query-typescript/output/test-app/tests/helpers/index.ts +++ b/tests/fixtures/ember-container-query-typescript/output/test-app/tests/helpers/index.ts @@ -34,7 +34,7 @@ function setupApplicationTest( // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/hello-world/index.ts b/tests/fixtures/hello-world/index.ts new file mode 100644 index 00000000..2b1a3d9a --- /dev/null +++ b/tests/fixtures/hello-world/index.ts @@ -0,0 +1,6 @@ +import { convertFixtureToJson } from '@codemod-utils/tests'; + +const inputProject = convertFixtureToJson('hello-world/input'); +const outputProject = convertFixtureToJson('hello-world/output'); + +export { inputProject, outputProject }; diff --git a/tests/fixtures/hello-world/input/.editorconfig b/tests/fixtures/hello-world/input/.editorconfig new file mode 100644 index 00000000..c35a0024 --- /dev/null +++ b/tests/fixtures/hello-world/input/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.hbs] +insert_final_newline = false + +[*.{diff,md}] +trim_trailing_whitespace = false diff --git a/tests/fixtures/hello-world/input/.ember-cli b/tests/fixtures/hello-world/input/.ember-cli new file mode 100644 index 00000000..978eea26 --- /dev/null +++ b/tests/fixtures/hello-world/input/.ember-cli @@ -0,0 +1,15 @@ +{ + /** + Ember CLI sends analytics information by default. The data is completely + anonymous, but there are times when you might want to disable this behavior. + + Setting `disableAnalytics` to true will prevent any data from being sent. + */ + "disableAnalytics": false, + + /** + Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript + rather than JavaScript by default, when a TypeScript version of a given blueprint is available. + */ + "isTypeScriptProject": true +} diff --git a/tests/fixtures/hello-world/input/.eslintignore b/tests/fixtures/hello-world/input/.eslintignore new file mode 100644 index 00000000..d474a40b --- /dev/null +++ b/tests/fixtures/hello-world/input/.eslintignore @@ -0,0 +1,25 @@ +# unconventional js +/blueprints/*/files/ +/vendor/ + +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ +/node_modules/ + +# misc +/coverage/ +!.* +.*/ +.eslintcache + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try diff --git a/tests/fixtures/hello-world/input/.eslintrc.js b/tests/fixtures/hello-world/input/.eslintrc.js new file mode 100644 index 00000000..72184615 --- /dev/null +++ b/tests/fixtures/hello-world/input/.eslintrc.js @@ -0,0 +1,62 @@ +'use strict'; + +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + ecmaFeatures: { + legacyDecorators: true, + }, + }, + plugins: ['ember', '@typescript-eslint'], + extends: [ + 'eslint:recommended', + 'plugin:ember/recommended', + 'plugin:prettier/recommended', + ], + env: { + browser: true, + }, + rules: {}, + overrides: [ + // ts files + { + files: ['**/*.ts'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], + rules: {}, + }, + // node files + { + files: [ + './.eslintrc.js', + './.prettierrc.js', + './.template-lintrc.js', + './ember-cli-build.js', + './index.js', + './testem.js', + './blueprints/*/index.js', + './config/**/*.js', + './tests/dummy/config/**/*.js', + ], + parserOptions: { + sourceType: 'script', + }, + env: { + browser: false, + node: true, + }, + plugins: ['node'], + extends: ['plugin:node/recommended'], + }, + { + // test files + files: ['tests/**/*-test.{js,ts}'], + extends: ['plugin:qunit/recommended'], + }, + ], +}; diff --git a/tests/fixtures/hello-world/input/.gitignore b/tests/fixtures/hello-world/input/.gitignore new file mode 100644 index 00000000..f1e859b2 --- /dev/null +++ b/tests/fixtures/hello-world/input/.gitignore @@ -0,0 +1,32 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ +/node_modules/ + +# misc +/.env* +/.pnp* +/.sass-cache +/.eslintcache +/connect.lock +/coverage/ +/libpeerconnection.log +/npm-debug.log* +/testem.log +/yarn-error.log + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try + +# broccoli-debug +/DEBUG/ diff --git a/tests/fixtures/hello-world/input/.npmignore b/tests/fixtures/hello-world/input/.npmignore new file mode 100644 index 00000000..38a2b086 --- /dev/null +++ b/tests/fixtures/hello-world/input/.npmignore @@ -0,0 +1,39 @@ +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ + +# misc +/.bowerrc +/.editorconfig +/.ember-cli +/.env* +/.eslintcache +/.eslintignore +/.eslintrc.js +/.git/ +/.github/ +/.gitignore +/.prettierignore +/.prettierrc.js +/.template-lintrc.js +/.travis.yml +/.watchmanconfig +/bower.json +/CONTRIBUTING.md +/ember-cli-build.js +/testem.js +/tests/ +/yarn-error.log +/yarn.lock +.gitkeep + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try diff --git a/tests/fixtures/hello-world/input/.prettierignore b/tests/fixtures/hello-world/input/.prettierignore new file mode 100644 index 00000000..4178fd57 --- /dev/null +++ b/tests/fixtures/hello-world/input/.prettierignore @@ -0,0 +1,25 @@ +# unconventional js +/blueprints/*/files/ +/vendor/ + +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ +/node_modules/ + +# misc +/coverage/ +!.* +.eslintcache +.lint-todo/ + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try diff --git a/tests/fixtures/hello-world/input/.prettierrc.js b/tests/fixtures/hello-world/input/.prettierrc.js new file mode 100644 index 00000000..534e6d35 --- /dev/null +++ b/tests/fixtures/hello-world/input/.prettierrc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + singleQuote: true, +}; diff --git a/tests/fixtures/hello-world/input/.template-lintrc.js b/tests/fixtures/hello-world/input/.template-lintrc.js new file mode 100644 index 00000000..f35f61c7 --- /dev/null +++ b/tests/fixtures/hello-world/input/.template-lintrc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + extends: 'recommended', +}; diff --git a/tests/fixtures/hello-world/input/.watchmanconfig b/tests/fixtures/hello-world/input/.watchmanconfig new file mode 100644 index 00000000..e7834e3e --- /dev/null +++ b/tests/fixtures/hello-world/input/.watchmanconfig @@ -0,0 +1,3 @@ +{ + "ignore_dirs": ["tmp", "dist"] +} diff --git a/tests/fixtures/hello-world/input/CONTRIBUTING.md b/tests/fixtures/hello-world/input/CONTRIBUTING.md new file mode 100644 index 00000000..404c138b --- /dev/null +++ b/tests/fixtures/hello-world/input/CONTRIBUTING.md @@ -0,0 +1,25 @@ +# How To Contribute + +## Installation + +* `git clone ` +* `cd hello-world` +* `pnpm install` + +## Linting + +* `pnpm lint` +* `pnpm lint:fix` + +## Running tests + +* `ember test` – Runs the test suite on the current Ember version +* `ember test --server` – Runs the test suite in "watch mode" +* `ember try:each` – Runs the test suite against multiple Ember versions + +## Running the dummy application + +* `ember serve` +* Visit the dummy application at [http://localhost:4200](http://localhost:4200). + +For more information on using ember-cli, visit [https://cli.emberjs.com/release/](https://cli.emberjs.com/release/). diff --git a/tests/fixtures/hello-world/input/addon-test-support/components/hello.ts b/tests/fixtures/hello-world/input/addon-test-support/components/hello.ts new file mode 100644 index 00000000..88594bca --- /dev/null +++ b/tests/fixtures/hello-world/input/addon-test-support/components/hello.ts @@ -0,0 +1,3 @@ +export function assertZoeyExists(assert: Assert) { + assert.dom('img').hasAttribute('src', '/my-addon/zoey.png'); +} diff --git a/tests/fixtures/hello-world/input/addon-test-support/index.ts b/tests/fixtures/hello-world/input/addon-test-support/index.ts new file mode 100644 index 00000000..be2c99a2 --- /dev/null +++ b/tests/fixtures/hello-world/input/addon-test-support/index.ts @@ -0,0 +1 @@ +export * from './components/hello'; diff --git a/tests/fixtures/hello-world/input/addon/.gitkeep b/tests/fixtures/hello-world/input/addon/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/addon/components/hello.css b/tests/fixtures/hello-world/input/addon/components/hello.css new file mode 100644 index 00000000..82c1e468 --- /dev/null +++ b/tests/fixtures/hello-world/input/addon/components/hello.css @@ -0,0 +1,7 @@ +.container { + /* Do something */ +} + +.image { + /* Do something */ +} diff --git a/tests/fixtures/hello-world/input/addon/components/hello.hbs b/tests/fixtures/hello-world/input/addon/components/hello.hbs new file mode 100644 index 00000000..7254a20f --- /dev/null +++ b/tests/fixtures/hello-world/input/addon/components/hello.hbs @@ -0,0 +1,9 @@ +
+ {{t "hello.message"}} + + +
\ No newline at end of file diff --git a/tests/fixtures/hello-world/input/addon/components/hello.ts b/tests/fixtures/hello-world/input/addon/components/hello.ts new file mode 100644 index 00000000..40ac0082 --- /dev/null +++ b/tests/fixtures/hello-world/input/addon/components/hello.ts @@ -0,0 +1,3 @@ +import Component from '@glimmer/component'; + +export default class HelloComponent extends Component {} diff --git a/tests/fixtures/hello-world/input/app/.gitkeep b/tests/fixtures/hello-world/input/app/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/app/components/hello.js b/tests/fixtures/hello-world/input/app/components/hello.js new file mode 100644 index 00000000..b5c6218a --- /dev/null +++ b/tests/fixtures/hello-world/input/app/components/hello.js @@ -0,0 +1 @@ +export { default } from 'hello-world/components/hello'; diff --git a/tests/fixtures/hello-world/input/ember-cli-build.js b/tests/fixtures/hello-world/input/ember-cli-build.js new file mode 100644 index 00000000..366cbe50 --- /dev/null +++ b/tests/fixtures/hello-world/input/ember-cli-build.js @@ -0,0 +1,25 @@ +'use strict'; + +const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); + +module.exports = function (defaults) { + const app = new EmberAddon(defaults, { + // Add options here + }); + + /* + This build file specifies the options for the dummy test app of this + addon, located in `/tests/dummy` + This build file does *not* influence how the addon or the app using it + behave. You most likely want to be modifying `./index.js` or app's build file + */ + + const { maybeEmbroider } = require('@embroider/test-setup'); + return maybeEmbroider(app, { + skipBabel: [ + { + package: 'qunit', + }, + ], + }); +}; diff --git a/tests/fixtures/hello-world/input/index.js b/tests/fixtures/hello-world/input/index.js new file mode 100644 index 00000000..0ca063d4 --- /dev/null +++ b/tests/fixtures/hello-world/input/index.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + name: require('./package').name, +}; diff --git a/tests/fixtures/hello-world/input/package.json b/tests/fixtures/hello-world/input/package.json new file mode 100644 index 00000000..09f9b1a7 --- /dev/null +++ b/tests/fixtures/hello-world/input/package.json @@ -0,0 +1,110 @@ +{ + "name": "hello-world", + "version": "0.0.0", + "description": "The default blueprint for ember-cli addons.", + "keywords": [ + "ember-addon" + ], + "repository": "", + "license": "MIT", + "author": "", + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "build": "ember build --environment=production", + "lint": "concurrently \"npm:lint:*(!fix)\" --names \"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", + "lint:js:fix": "eslint . --fix", + "lint:types": "tsc --noEmit", + "start": "ember serve", + "test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"", + "test:ember": "ember test", + "test:ember-compatibility": "ember try:each", + "prepack": "ember ts:precompile", + "postpack": "ember ts:clean" + }, + "dependencies": { + "ember-cli-babel": "^7.26.11", + "ember-cli-htmlbars": "^6.1.1", + "ember-cli-typescript": "^5.2.1" + }, + "devDependencies": { + "@ember/optional-features": "^2.0.0", + "@ember/test-helpers": "^2.8.1", + "@embroider/test-setup": "^2.0.2", + "@glimmer/component": "^1.1.2", + "@glimmer/tracking": "^1.1.2", + "@tsconfig/ember": "^2.0.0", + "@types/ember": "^4.0.3", + "@types/ember-qunit": "^6.1.1", + "@types/ember-resolver": "^9.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__test-helpers": "^2.9.1", + "@types/ember__utils": "^4.0.2", + "@types/qunit": "^2.19.4", + "@types/rsvp": "^4.0.4", + "@typescript-eslint/eslint-plugin": "^5.45.1", + "@typescript-eslint/parser": "^5.45.1", + "broccoli-asset-rev": "^3.0.0", + "concurrently": "^7.6.0", + "ember-auto-import": "^2.5.0", + "ember-cli": "~4.9.2", + "ember-cli-dependency-checker": "^3.3.1", + "ember-cli-inject-live-reload": "^2.1.0", + "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.0.0", + "ember-resolver": "^8.0.3", + "ember-source": "~4.9.1", + "ember-source-channel-url": "^3.0.0", + "ember-template-lint": "^5.2.0", + "ember-try": "^2.0.0", + "eslint": "^7.32.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-ember": "^11.2.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-qunit": "^7.3.4", + "loader.js": "^4.7.0", + "prettier": "^2.8.1", + "qunit": "^2.19.3", + "qunit-dom": "^2.0.0", + "typescript": "^4.9.4", + "webpack": "^5.75.0" + }, + "peerDependencies": { + "ember-source": "^3.28.0 || ^4.0.0" + }, + "engines": { + "node": "14.* || 16.* || >= 18" + }, + "ember": { + "edition": "octane" + }, + "ember-addon": { + "configPath": "tests/dummy/config" + } +} diff --git a/tests/fixtures/hello-world/input/pnpm-lock.yaml b/tests/fixtures/hello-world/input/pnpm-lock.yaml new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/testem.js b/tests/fixtures/hello-world/input/testem.js new file mode 100644 index 00000000..ed2f3712 --- /dev/null +++ b/tests/fixtures/hello-world/input/testem.js @@ -0,0 +1,23 @@ +'use strict'; + +module.exports = { + test_page: 'tests/index.html?hidepassed', + disable_watching: true, + launch_in_ci: ['Chrome'], + launch_in_dev: ['Chrome'], + browser_start_timeout: 120, + browser_args: { + Chrome: { + ci: [ + // --no-sandbox is needed when running Chrome inside a container + process.env.CI ? '--no-sandbox' : null, + '--headless', + '--disable-dev-shm-usage', + '--disable-software-rasterizer', + '--mute-audio', + '--remote-debugging-port=0', + '--window-size=1440,900', + ].filter(Boolean), + }, + }, +}; diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/app.js b/tests/fixtures/hello-world/input/tests/dummy/app/app.js new file mode 100644 index 00000000..523bad60 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/app/app.js @@ -0,0 +1,12 @@ +import Application from '@ember/application'; +import Resolver from 'ember-resolver'; +import loadInitializers from 'ember-load-initializers'; +import config from 'dummy/config/environment'; + +export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; +} + +loadInitializers(App, config.modulePrefix); diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/components/.gitkeep b/tests/fixtures/hello-world/input/tests/dummy/app/components/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/controllers/.gitkeep b/tests/fixtures/hello-world/input/tests/dummy/app/controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/helpers/.gitkeep b/tests/fixtures/hello-world/input/tests/dummy/app/helpers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/index.html b/tests/fixtures/hello-world/input/tests/dummy/app/index.html new file mode 100644 index 00000000..8c195bc4 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/app/index.html @@ -0,0 +1,24 @@ + + + + + Dummy + + + + {{content-for "head"}} + + + + + {{content-for "head-footer"}} + + + {{content-for "body"}} + + + + + {{content-for "body-footer"}} + + diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/models/.gitkeep b/tests/fixtures/hello-world/input/tests/dummy/app/models/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/router.js b/tests/fixtures/hello-world/input/tests/dummy/app/router.js new file mode 100644 index 00000000..64e543ab --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/app/router.js @@ -0,0 +1,9 @@ +import EmberRouter from '@ember/routing/router'; +import config from 'dummy/config/environment'; + +export default class Router extends EmberRouter { + location = config.locationType; + rootURL = config.rootURL; +} + +Router.map(function () {}); diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/routes/.gitkeep b/tests/fixtures/hello-world/input/tests/dummy/app/routes/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/styles/app.css b/tests/fixtures/hello-world/input/tests/dummy/app/styles/app.css new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tests/dummy/app/templates/application.hbs b/tests/fixtures/hello-world/input/tests/dummy/app/templates/application.hbs new file mode 100644 index 00000000..1001d149 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/app/templates/application.hbs @@ -0,0 +1,5 @@ +{{page-title "Dummy"}} + +

Welcome to Ember

+ +{{outlet}} \ No newline at end of file diff --git a/tests/fixtures/hello-world/input/tests/dummy/config/ember-cli-update.json b/tests/fixtures/hello-world/input/tests/dummy/config/ember-cli-update.json new file mode 100644 index 00000000..f1c483b8 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/config/ember-cli-update.json @@ -0,0 +1,20 @@ +{ + "schemaVersion": "1.0.0", + "packages": [ + { + "name": "ember-cli", + "version": "4.9.2", + "blueprints": [ + { + "name": "addon", + "outputRepo": "https://github.com/ember-cli/ember-addon-output", + "codemodsSource": "ember-addon-codemods-manifest@1", + "isBaseBlueprint": true, + "options": [ + "--ci-provider=github" + ] + } + ] + } + ] +} diff --git a/tests/fixtures/hello-world/input/tests/dummy/config/ember-try.js b/tests/fixtures/hello-world/input/tests/dummy/config/ember-try.js new file mode 100644 index 00000000..4746d2b9 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/config/ember-try.js @@ -0,0 +1,71 @@ +'use strict'; + +const getChannelURL = require('ember-source-channel-url'); +const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); + +module.exports = async function () { + return { + scenarios: [ + { + name: 'ember-lts-3.28', + npm: { + devDependencies: { + 'ember-source': '~3.28.0', + }, + }, + }, + { + name: 'ember-lts-4.4', + npm: { + devDependencies: { + 'ember-source': '~4.4.0', + }, + }, + }, + { + name: 'ember-release', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('release'), + }, + }, + }, + { + name: 'ember-beta', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('beta'), + }, + }, + }, + { + name: 'ember-canary', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('canary'), + }, + }, + }, + { + name: 'ember-classic', + env: { + EMBER_OPTIONAL_FEATURES: JSON.stringify({ + 'application-template-wrapper': true, + 'default-async-observers': false, + 'template-only-glimmer-components': false, + }), + }, + npm: { + devDependencies: { + 'ember-source': '~3.28.0', + }, + ember: { + edition: 'classic', + }, + }, + }, + embroiderSafe(), + embroiderOptimized(), + ], + }; +}; diff --git a/tests/fixtures/hello-world/input/tests/dummy/config/environment.js b/tests/fixtures/hello-world/input/tests/dummy/config/environment.js new file mode 100644 index 00000000..3b32e1fc --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/config/environment.js @@ -0,0 +1,48 @@ +'use strict'; + +module.exports = function (environment) { + const ENV = { + modulePrefix: 'dummy', + environment, + rootURL: '/', + locationType: 'history', + EmberENV: { + EXTEND_PROTOTYPES: false, + FEATURES: { + // Here you can enable experimental features on an ember canary build + // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true + }, + }, + + APP: { + // Here you can pass flags/options to your application instance + // when it is created + }, + }; + + if (environment === 'development') { + // ENV.APP.LOG_RESOLVER = true; + // ENV.APP.LOG_ACTIVE_GENERATION = true; + // ENV.APP.LOG_TRANSITIONS = true; + // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; + // ENV.APP.LOG_VIEW_LOOKUPS = true; + } + + if (environment === 'test') { + // Testem prefers this... + ENV.locationType = 'none'; + + // keep test console output quieter + ENV.APP.LOG_ACTIVE_GENERATION = false; + ENV.APP.LOG_VIEW_LOOKUPS = false; + + ENV.APP.rootElement = '#ember-testing'; + ENV.APP.autoboot = false; + } + + if (environment === 'production') { + // here you can enable a production-specific feature + } + + return ENV; +}; diff --git a/tests/fixtures/hello-world/input/tests/dummy/config/optional-features.json b/tests/fixtures/hello-world/input/tests/dummy/config/optional-features.json new file mode 100644 index 00000000..b26286e2 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/config/optional-features.json @@ -0,0 +1,6 @@ +{ + "application-template-wrapper": false, + "default-async-observers": true, + "jquery-integration": false, + "template-only-glimmer-components": true +} diff --git a/tests/fixtures/hello-world/input/tests/dummy/config/targets.js b/tests/fixtures/hello-world/input/tests/dummy/config/targets.js new file mode 100644 index 00000000..1e48e059 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/config/targets.js @@ -0,0 +1,11 @@ +'use strict'; + +const browsers = [ + 'last 1 Chrome versions', + 'last 1 Firefox versions', + 'last 1 Safari versions', +]; + +module.exports = { + browsers, +}; diff --git a/tests/fixtures/hello-world/input/tests/dummy/public/robots.txt b/tests/fixtures/hello-world/input/tests/dummy/public/robots.txt new file mode 100644 index 00000000..f5916452 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/dummy/public/robots.txt @@ -0,0 +1,3 @@ +# http://www.robotstxt.org +User-agent: * +Disallow: diff --git a/tests/fixtures/hello-world/input/tests/helpers/index.js b/tests/fixtures/hello-world/input/tests/helpers/index.js new file mode 100644 index 00000000..b1b8f293 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/helpers/index.js @@ -0,0 +1,42 @@ +import { + setupApplicationTest as upstreamSetupApplicationTest, + setupRenderingTest as upstreamSetupRenderingTest, + setupTest as upstreamSetupTest, +} from 'ember-qunit'; + +// This file exists to provide wrappers around ember-qunit's / ember-mocha's +// test setup functions. This way, you can easily extend the setup that is +// needed per test type. + +function setupApplicationTest(hooks, options) { + upstreamSetupApplicationTest(hooks, options); + + // Additional setup for application tests can be done here. + // + // For example, if you need an authenticated session for each + // application test, you could do: + // + // hooks.beforeEach(async function () { + // await authenticateSession(); // ember-simple-auth + // }); + // + // This is also a good place to call test setup functions coming + // from other addons: + // + // setupIntl(hooks, 'en-us'); // ember-intl + // setupMirage(hooks); // ember-cli-mirage +} + +function setupRenderingTest(hooks, options) { + upstreamSetupRenderingTest(hooks, options); + + // Additional setup for rendering tests can be done here. +} + +function setupTest(hooks, options) { + upstreamSetupTest(hooks, options); + + // Additional setup for unit tests can be done here. +} + +export { setupApplicationTest, setupRenderingTest, setupTest }; diff --git a/tests/fixtures/hello-world/input/tests/index.html b/tests/fixtures/hello-world/input/tests/index.html new file mode 100644 index 00000000..b74fc8be --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/index.html @@ -0,0 +1,39 @@ + + + + + Dummy Tests + + + + {{content-for "head"}} + {{content-for "test-head"}} + + + + + + {{content-for "head-footer"}} + {{content-for "test-head-footer"}} + + + {{content-for "body"}} + {{content-for "test-body"}} + +
+
+
+
+
+
+ + + + + + + + {{content-for "body-footer"}} + {{content-for "test-body-footer"}} + + diff --git a/tests/fixtures/hello-world/input/tests/integration/.gitkeep b/tests/fixtures/hello-world/input/tests/integration/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tests/integration/components/hello-test.ts b/tests/fixtures/hello-world/input/tests/integration/components/hello-test.ts new file mode 100644 index 00000000..ed13f9ff --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/integration/components/hello-test.ts @@ -0,0 +1,15 @@ +import { render } from '@ember/test-helpers'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import { assertZoeyExists } from 'my-addon/test-support'; +import { module, test } from 'qunit'; + +module('Integration | Component | hello', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs``); + + assertZoeyExists(assert); + }); +}); diff --git a/tests/fixtures/hello-world/input/tests/test-helper.js b/tests/fixtures/hello-world/input/tests/test-helper.js new file mode 100644 index 00000000..4efd6e58 --- /dev/null +++ b/tests/fixtures/hello-world/input/tests/test-helper.js @@ -0,0 +1,12 @@ +import Application from 'dummy/app'; +import config from 'dummy/config/environment'; +import * as QUnit from 'qunit'; +import { setApplication } from '@ember/test-helpers'; +import { setup } from 'qunit-dom'; +import { start } from 'ember-qunit'; + +setApplication(Application.create(config.APP)); + +setup(QUnit.assert); + +start(); diff --git a/tests/fixtures/hello-world/input/tests/unit/.gitkeep b/tests/fixtures/hello-world/input/tests/unit/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/tsconfig.json b/tests/fixtures/hello-world/input/tsconfig.json new file mode 100644 index 00000000..65e55ee1 --- /dev/null +++ b/tests/fixtures/hello-world/input/tsconfig.json @@ -0,0 +1,42 @@ +{ + "extends": "@tsconfig/ember/tsconfig.json", + "compilerOptions": { + + // The combination of `baseUrl` with `paths` allows Ember's classic package + // layout, which is not resolvable with the Node resolution algorithm, to + // work with TypeScript. + "baseUrl": ".", + "paths": { + "dummy/tests/*": [ + "tests/*" + ], + "dummy/*": [ + "tests/dummy/app/*", + "app/*" + ], + "hello-world": [ + "addon" + ], + "hello-world/*": [ + "addon/*" + ], + "hello-world/test-support": [ + "addon-test-support" + ], + "hello-world/test-support/*": [ + "addon-test-support/*" + ], + "*": [ + "types/*" + ] + } + }, + "include": [ + "app/**/*", + "addon/**/*", + "tests/**/*", + "types/**/*", + "test-support/**/*", + "addon-test-support/**/*" + ] +} diff --git a/tests/fixtures/hello-world/input/types/dummy/index.d.ts b/tests/fixtures/hello-world/input/types/dummy/index.d.ts new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/input/types/global.d.ts b/tests/fixtures/hello-world/input/types/global.d.ts new file mode 100644 index 00000000..c4f26d55 --- /dev/null +++ b/tests/fixtures/hello-world/input/types/global.d.ts @@ -0,0 +1,7 @@ +// Types for compiled templates +declare module 'new-v1-addon/templates/*' { + import { TemplateFactory } from 'ember-cli-htmlbars'; + + const tmpl: TemplateFactory; + export default tmpl; +} diff --git a/tests/fixtures/hello-world/output/.editorconfig b/tests/fixtures/hello-world/output/.editorconfig new file mode 100644 index 00000000..c35a0024 --- /dev/null +++ b/tests/fixtures/hello-world/output/.editorconfig @@ -0,0 +1,19 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.hbs] +insert_final_newline = false + +[*.{diff,md}] +trim_trailing_whitespace = false diff --git a/tests/fixtures/hello-world/output/.gitignore b/tests/fixtures/hello-world/output/.gitignore new file mode 100644 index 00000000..be29758a --- /dev/null +++ b/tests/fixtures/hello-world/output/.gitignore @@ -0,0 +1,10 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +node_modules/ + +# misc +.env* +.pnpm-debug.log +npm-debug.log* +yarn-error.log diff --git a/tests/fixtures/hello-world/output/CONTRIBUTING.md b/tests/fixtures/hello-world/output/CONTRIBUTING.md new file mode 100644 index 00000000..404c138b --- /dev/null +++ b/tests/fixtures/hello-world/output/CONTRIBUTING.md @@ -0,0 +1,25 @@ +# How To Contribute + +## Installation + +* `git clone ` +* `cd hello-world` +* `pnpm install` + +## Linting + +* `pnpm lint` +* `pnpm lint:fix` + +## Running tests + +* `ember test` – Runs the test suite on the current Ember version +* `ember test --server` – Runs the test suite in "watch mode" +* `ember try:each` – Runs the test suite against multiple Ember versions + +## Running the dummy application + +* `ember serve` +* Visit the dummy application at [http://localhost:4200](http://localhost:4200). + +For more information on using ember-cli, visit [https://cli.emberjs.com/release/](https://cli.emberjs.com/release/). diff --git a/tests/fixtures/hello-world/output/hello-world/.eslintignore b/tests/fixtures/hello-world/output/hello-world/.eslintignore new file mode 100644 index 00000000..4e982747 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/.eslintignore @@ -0,0 +1,9 @@ +# unconventional js +/blueprints/*/files/ + +# compiled output +/dist/ +/declarations/ + +# misc +/coverage/ diff --git a/tests/fixtures/hello-world/output/hello-world/.eslintrc.cjs b/tests/fixtures/hello-world/output/hello-world/.eslintrc.cjs new file mode 100644 index 00000000..06ae47cb --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/.eslintrc.cjs @@ -0,0 +1,100 @@ +'use strict'; + +module.exports = { + root: true, + // Only use overrides + // https://github.com/ember-cli/eslint-plugin-ember?tab=readme-ov-file#gtsgjs + overrides: [ + { + files: ['**/*.js', '**/*.ts'], + env: { browser: true }, + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 'latest', + }, + plugins: ['ember', 'import'], + extends: [ + 'eslint:recommended', + 'plugin:ember/recommended', + 'plugin:prettier/recommended', + ], + rules: { + // require relative imports use full extensions + 'import/extensions': ['error', 'always', { ignorePackages: true }], + // Add any custom rules here + }, + }, + // ts files + { + files: ['**/*.ts'], + extends: [ + 'eslint:recommended', + 'plugin:ember/recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + rules: { + // require relative imports use full extensions + 'import/extensions': ['error', 'always', { ignorePackages: true }], + // Add any custom rules here + }, + }, + { + files: ['**/*.gts'], + parser: 'ember-eslint-parser', + plugins: ['ember', 'import'], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:ember/recommended', + 'plugin:ember/recommended-gts', + 'plugin:prettier/recommended', + ], + rules: { + // require relative imports use full extensions + 'import/extensions': ['error', 'always', { ignorePackages: true }], + // Add any custom rules here + }, + }, + { + files: ['**/*.gjs'], + parser: 'ember-eslint-parser', + plugins: ['ember', 'import'], + extends: [ + 'eslint:recommended', + 'plugin:ember/recommended', + 'plugin:ember/recommended-gjs', + 'plugin:prettier/recommended', + ], + rules: { + // require relative imports use full extensions + 'import/extensions': ['error', 'always', { ignorePackages: true }], + // Add any custom rules here + }, + }, + // node files + { + files: [ + './.eslintrc.cjs', + './.prettierrc.cjs', + './.template-lintrc.cjs', + './addon-main.cjs', + ], + parserOptions: { + sourceType: 'script', + }, + env: { + browser: false, + node: true, + }, + plugins: ['n'], + extends: [ + 'eslint:recommended', + 'plugin:n/recommended', + 'plugin:prettier/recommended', + ], + }, + ], +}; diff --git a/tests/fixtures/hello-world/output/hello-world/.gitignore b/tests/fixtures/hello-world/output/hello-world/.gitignore new file mode 100644 index 00000000..eedd0d83 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/.gitignore @@ -0,0 +1,17 @@ +# The authoritative copies of these live in the monorepo root (because they're +# more useful on github that way), but the build copies them into here so they +# will also appear in published NPM packages. +/README.md +/LICENSE.md + +# compiled output +dist/ +declarations/ + +# npm/pnpm/yarn pack output +*.tgz + +# deps & caches +node_modules/ +.eslintcache +.prettiercache diff --git a/tests/fixtures/hello-world/output/hello-world/.prettierignore b/tests/fixtures/hello-world/output/hello-world/.prettierignore new file mode 100644 index 00000000..4e982747 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/.prettierignore @@ -0,0 +1,9 @@ +# unconventional js +/blueprints/*/files/ + +# compiled output +/dist/ +/declarations/ + +# misc +/coverage/ diff --git a/tests/fixtures/hello-world/output/hello-world/.prettierrc.cjs b/tests/fixtures/hello-world/output/hello-world/.prettierrc.cjs new file mode 100644 index 00000000..534e6d35 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/.prettierrc.cjs @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + singleQuote: true, +}; diff --git a/tests/fixtures/hello-world/output/hello-world/.template-lintrc.cjs b/tests/fixtures/hello-world/output/hello-world/.template-lintrc.cjs new file mode 100644 index 00000000..f35f61c7 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/.template-lintrc.cjs @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + extends: 'recommended', +}; diff --git a/tests/fixtures/hello-world/output/hello-world/addon-main.cjs b/tests/fixtures/hello-world/output/hello-world/addon-main.cjs new file mode 100644 index 00000000..d36b0c86 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/addon-main.cjs @@ -0,0 +1,5 @@ +'use strict'; + +const { addonV1Shim } = require('@embroider/addon-shim'); + +module.exports = addonV1Shim(__dirname); diff --git a/tests/fixtures/hello-world/output/hello-world/babel.config.json b/tests/fixtures/hello-world/output/hello-world/babel.config.json new file mode 100644 index 00000000..f6cb36b0 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/babel.config.json @@ -0,0 +1,28 @@ +{ + "plugins": [ + [ + "@babel/plugin-transform-typescript", + { + "allExtensions": true, + "allowDeclareFields": true, + "onlyRemoveTypeImports": true + } + ], + "@embroider/addon-dev/template-colocation-plugin", + [ + "babel-plugin-ember-template-compilation", + { + "targetFormat": "hbs", + "transforms": [] + } + ], + [ + "module:decorator-transforms", + { + "runtime": { + "import": "decorator-transforms/runtime" + } + } + ] + ] +} diff --git a/tests/fixtures/hello-world/output/hello-world/package.json b/tests/fixtures/hello-world/output/hello-world/package.json new file mode 100644 index 00000000..af420143 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/package.json @@ -0,0 +1,100 @@ +{ + "name": "hello-world", + "version": "0.0.0", + "description": "The default blueprint for ember-cli addons.", + "keywords": [ + "ember-addon" + ], + "repository": "", + "license": "MIT", + "author": "", + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "build": "concurrently 'pnpm:build:*'", + "build:js": "rollup --config", + "build:types": "tsc", + "lint": "concurrently 'pnpm:lint:*(!fix)' --names 'lint:'", + "lint:fix": "concurrently 'pnpm: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": "tsc --emitDeclarationOnly false --noEmit", + "prepack": "concurrently 'pnpm:build:*'", + "start": "concurrently 'pnpm: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'" + }, + "dependencies": { + "@embroider/addon-shim": "^1.8.9", + "decorator-transforms": "^2.0.0" + }, + "devDependencies": { + "@babel/core": "^7.25.2", + "@babel/plugin-transform-typescript": "^7.25.2", + "@babel/runtime": "^7.25.0", + "@embroider/addon-dev": "^5.0.0", + "@rollup/plugin-babel": "^6.0.4", + "@tsconfig/ember": "^3.0.8", + "@types/ember__component": "^4.0.22", + "@types/ember__object": "^4.0.12", + "@types/ember__service": "^4.0.9", + "@typescript-eslint/eslint-plugin": "^8.1.0", + "@typescript-eslint/parser": "^8.1.0", + "babel-plugin-ember-template-compilation": "^2.2.5", + "concurrently": "^8.2.2", + "ember-template-lint": "^6.0.0", + "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-ember": "^12.1.1", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-n": "^17.10.2", + "eslint-plugin-prettier": "^5.2.1", + "prettier": "^3.3.3", + "rollup": "^4.20.0", + "rollup-plugin-copy": "^3.5.0", + "typescript": "^5.5.4" + }, + "peerDependencies": { + "ember-source": "^3.28.0 || ^4.0.0" + }, + "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", + "declarations", + "dist" + ], + "typesVersions": { + "*": { + "*": [ + "declarations/*" + ] + } + } +} diff --git a/tests/fixtures/hello-world/output/hello-world/rollup.config.mjs b/tests/fixtures/hello-world/output/hello-world/rollup.config.mjs new file mode 100644 index 00000000..e704c415 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/rollup.config.mjs @@ -0,0 +1,72 @@ +import { Addon } from '@embroider/addon-dev/rollup'; +import { babel } from '@rollup/plugin-babel'; +import copy from 'rollup-plugin-copy'; + +const addon = new Addon({ + srcDir: 'src', + destDir: 'dist', +}); + +export default { + // This provides defaults that work well alongside `publicEntrypoints` below. + // You can augment this if you need to. + output: addon.output(), + + plugins: [ + // These are the modules that users should be able to import from your + // addon. Anything not listed here may get optimized away. + // By default all your JavaScript modules (**/*.js) will be importable. + // But you are encouraged to tweak this to only cover the modules that make + // up your addon's public API. Also make sure your package.json#exports + // is aligned to the config here. + // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon + addon.publicEntrypoints(['**/*.js', 'index.ts']), + + // These are the modules that should get reexported into the traditional + // "app" tree. Things in here should also be in publicEntrypoints above, but + // not everything in publicEntrypoints necessarily needs to go here. + addon.appReexports([ + 'components/**/*.js', + 'helpers/**/*.js', + 'modifiers/**/*.js', + 'services/**/*.js', + ]), + + // Follow the V2 Addon rules about dependencies. Your code can import from + // `dependencies` and `peerDependencies` as well as standard Ember-provided + // package names. + addon.dependencies(), + + // This babel config should *not* apply presets or compile away ES modules. + // It exists only to provide development niceties for you, like automatic + // template colocation. + // + // By default, this will load the actual babel config from the file + // babel.config.json. + babel({ + babelHelpers: 'bundled', + extensions: ['.js', '.gjs', '.ts', '.gts'], + }), + + // Ensure that standalone .hbs files are properly integrated as Javascript. + addon.hbs(), + + // Ensure that .gjs files are properly integrated as Javascript + addon.gjs(), + + // 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']), + + // Remove leftover build artifacts when starting a new build. + addon.clean(), + + // Copy Readme and License into published package + copy({ + targets: [ + { src: '../README.md', dest: '.' }, + { src: '../LICENSE.md', dest: '.' }, + ], + }), + ], +}; diff --git a/tests/fixtures/hello-world/output/hello-world/src/.gitkeep b/tests/fixtures/hello-world/output/hello-world/src/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/hello-world/src/components/hello.css b/tests/fixtures/hello-world/output/hello-world/src/components/hello.css new file mode 100644 index 00000000..82c1e468 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/src/components/hello.css @@ -0,0 +1,7 @@ +.container { + /* Do something */ +} + +.image { + /* Do something */ +} diff --git a/tests/fixtures/hello-world/output/hello-world/src/components/hello.hbs b/tests/fixtures/hello-world/output/hello-world/src/components/hello.hbs new file mode 100644 index 00000000..7254a20f --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/src/components/hello.hbs @@ -0,0 +1,9 @@ +
+ {{t "hello.message"}} + + +
\ No newline at end of file diff --git a/tests/fixtures/hello-world/output/hello-world/src/components/hello.ts b/tests/fixtures/hello-world/output/hello-world/src/components/hello.ts new file mode 100644 index 00000000..40ac0082 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/src/components/hello.ts @@ -0,0 +1,3 @@ +import Component from '@glimmer/component'; + +export default class HelloComponent extends Component {} diff --git a/tests/fixtures/hello-world/output/hello-world/src/test-support.ts b/tests/fixtures/hello-world/output/hello-world/src/test-support.ts new file mode 100644 index 00000000..be2c99a2 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/src/test-support.ts @@ -0,0 +1 @@ +export * from './components/hello'; diff --git a/tests/fixtures/hello-world/output/hello-world/src/test-support/components/hello.ts b/tests/fixtures/hello-world/output/hello-world/src/test-support/components/hello.ts new file mode 100644 index 00000000..88594bca --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/src/test-support/components/hello.ts @@ -0,0 +1,3 @@ +export function assertZoeyExists(assert: Assert) { + assert.dom('img').hasAttribute('src', '/my-addon/zoey.png'); +} diff --git a/tests/fixtures/hello-world/output/hello-world/tsconfig.json b/tests/fixtures/hello-world/output/hello-world/tsconfig.json new file mode 100644 index 00000000..21ba7094 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "@tsconfig/ember/tsconfig.json", + "compilerOptions": { + "allowImportingTsExtensions": true, + "allowJs": true, + "declarationDir": "declarations", + "emitDeclarationOnly": true, + "noEmit": false, + "noEmitOnError": false, + "rootDir": "./src" + }, + "include": [ + "src/**/*", + "unpublished-development-types/**/*" + ] +} diff --git a/tests/fixtures/hello-world/output/hello-world/unpublished-development-types/index.d.ts b/tests/fixtures/hello-world/output/hello-world/unpublished-development-types/index.d.ts new file mode 100644 index 00000000..e1d93ad4 --- /dev/null +++ b/tests/fixtures/hello-world/output/hello-world/unpublished-development-types/index.d.ts @@ -0,0 +1,2 @@ +// Add any types here that you need for local development only. +// These will *not* be published as part of your addon, so be careful that your published code does not rely on them! diff --git a/tests/fixtures/hello-world/output/package.json b/tests/fixtures/hello-world/output/package.json new file mode 100644 index 00000000..bc3b7310 --- /dev/null +++ b/tests/fixtures/hello-world/output/package.json @@ -0,0 +1,21 @@ +{ + "name": "workspace-root", + "version": "0.0.0", + "private": true, + "repository": "", + "license": "MIT", + "author": "", + "scripts": { + "build": "pnpm --filter hello-world build", + "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:addon": "pnpm --filter hello-world start", + "start:test-app": "pnpm --filter test-app start", + "test": "pnpm --filter '*' test" + }, + "devDependencies": { + "concurrently": "^7.6.0" + } +} diff --git a/tests/fixtures/hello-world/output/pnpm-lock.yaml b/tests/fixtures/hello-world/output/pnpm-lock.yaml new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/pnpm-workspace.yaml b/tests/fixtures/hello-world/output/pnpm-workspace.yaml new file mode 100644 index 00000000..12f8cb35 --- /dev/null +++ b/tests/fixtures/hello-world/output/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + - 'hello-world' + - 'test-app' diff --git a/tests/fixtures/hello-world/output/test-app/.ember-cli b/tests/fixtures/hello-world/output/test-app/.ember-cli new file mode 100644 index 00000000..978eea26 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.ember-cli @@ -0,0 +1,15 @@ +{ + /** + Ember CLI sends analytics information by default. The data is completely + anonymous, but there are times when you might want to disable this behavior. + + Setting `disableAnalytics` to true will prevent any data from being sent. + */ + "disableAnalytics": false, + + /** + Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript + rather than JavaScript by default, when a TypeScript version of a given blueprint is available. + */ + "isTypeScriptProject": true +} diff --git a/tests/fixtures/hello-world/output/test-app/.eslintignore b/tests/fixtures/hello-world/output/test-app/.eslintignore new file mode 100644 index 00000000..d474a40b --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.eslintignore @@ -0,0 +1,25 @@ +# unconventional js +/blueprints/*/files/ +/vendor/ + +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ +/node_modules/ + +# misc +/coverage/ +!.* +.*/ +.eslintcache + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try diff --git a/tests/fixtures/hello-world/output/test-app/.eslintrc.js b/tests/fixtures/hello-world/output/test-app/.eslintrc.js new file mode 100644 index 00000000..72184615 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.eslintrc.js @@ -0,0 +1,62 @@ +'use strict'; + +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + ecmaFeatures: { + legacyDecorators: true, + }, + }, + plugins: ['ember', '@typescript-eslint'], + extends: [ + 'eslint:recommended', + 'plugin:ember/recommended', + 'plugin:prettier/recommended', + ], + env: { + browser: true, + }, + rules: {}, + overrides: [ + // ts files + { + files: ['**/*.ts'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], + rules: {}, + }, + // node files + { + files: [ + './.eslintrc.js', + './.prettierrc.js', + './.template-lintrc.js', + './ember-cli-build.js', + './index.js', + './testem.js', + './blueprints/*/index.js', + './config/**/*.js', + './tests/dummy/config/**/*.js', + ], + parserOptions: { + sourceType: 'script', + }, + env: { + browser: false, + node: true, + }, + plugins: ['node'], + extends: ['plugin:node/recommended'], + }, + { + // test files + files: ['tests/**/*-test.{js,ts}'], + extends: ['plugin:qunit/recommended'], + }, + ], +}; diff --git a/tests/fixtures/hello-world/output/test-app/.gitignore b/tests/fixtures/hello-world/output/test-app/.gitignore new file mode 100644 index 00000000..f1e859b2 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.gitignore @@ -0,0 +1,32 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ +/node_modules/ + +# misc +/.env* +/.pnp* +/.sass-cache +/.eslintcache +/connect.lock +/coverage/ +/libpeerconnection.log +/npm-debug.log* +/testem.log +/yarn-error.log + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try + +# broccoli-debug +/DEBUG/ diff --git a/tests/fixtures/hello-world/output/test-app/.prettierignore b/tests/fixtures/hello-world/output/test-app/.prettierignore new file mode 100644 index 00000000..4178fd57 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.prettierignore @@ -0,0 +1,25 @@ +# unconventional js +/blueprints/*/files/ +/vendor/ + +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ +/node_modules/ + +# misc +/coverage/ +!.* +.eslintcache +.lint-todo/ + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try diff --git a/tests/fixtures/hello-world/output/test-app/.prettierrc.js b/tests/fixtures/hello-world/output/test-app/.prettierrc.js new file mode 100644 index 00000000..534e6d35 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.prettierrc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + singleQuote: true, +}; diff --git a/tests/fixtures/hello-world/output/test-app/.template-lintrc.js b/tests/fixtures/hello-world/output/test-app/.template-lintrc.js new file mode 100644 index 00000000..f35f61c7 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.template-lintrc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + extends: 'recommended', +}; diff --git a/tests/fixtures/hello-world/output/test-app/.watchmanconfig b/tests/fixtures/hello-world/output/test-app/.watchmanconfig new file mode 100644 index 00000000..e7834e3e --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/.watchmanconfig @@ -0,0 +1,3 @@ +{ + "ignore_dirs": ["tmp", "dist"] +} diff --git a/tests/fixtures/hello-world/output/test-app/app/app.js b/tests/fixtures/hello-world/output/test-app/app/app.js new file mode 100644 index 00000000..1ba93424 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/app/app.js @@ -0,0 +1,12 @@ +import Application from '@ember/application'; +import Resolver from 'ember-resolver'; +import loadInitializers from 'ember-load-initializers'; +import config from 'test-app/config/environment'; + +export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; +} + +loadInitializers(App, config.modulePrefix); diff --git a/tests/fixtures/hello-world/output/test-app/app/components/.gitkeep b/tests/fixtures/hello-world/output/test-app/app/components/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/app/controllers/.gitkeep b/tests/fixtures/hello-world/output/test-app/app/controllers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/app/helpers/.gitkeep b/tests/fixtures/hello-world/output/test-app/app/helpers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/app/index.html b/tests/fixtures/hello-world/output/test-app/app/index.html new file mode 100644 index 00000000..bbd2a2be --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/app/index.html @@ -0,0 +1,24 @@ + + + + + Dummy + + + + {{content-for "head"}} + + + + + {{content-for "head-footer"}} + + + {{content-for "body"}} + + + + + {{content-for "body-footer"}} + + diff --git a/tests/fixtures/hello-world/output/test-app/app/models/.gitkeep b/tests/fixtures/hello-world/output/test-app/app/models/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/app/router.js b/tests/fixtures/hello-world/output/test-app/app/router.js new file mode 100644 index 00000000..38a0b80a --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/app/router.js @@ -0,0 +1,9 @@ +import EmberRouter from '@ember/routing/router'; +import config from 'test-app/config/environment'; + +export default class Router extends EmberRouter { + location = config.locationType; + rootURL = config.rootURL; +} + +Router.map(function () {}); diff --git a/tests/fixtures/hello-world/output/test-app/app/routes/.gitkeep b/tests/fixtures/hello-world/output/test-app/app/routes/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/app/styles/app.css b/tests/fixtures/hello-world/output/test-app/app/styles/app.css new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/app/templates/application.hbs b/tests/fixtures/hello-world/output/test-app/app/templates/application.hbs new file mode 100644 index 00000000..1001d149 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/app/templates/application.hbs @@ -0,0 +1,5 @@ +{{page-title "Dummy"}} + +

Welcome to Ember

+ +{{outlet}} \ No newline at end of file diff --git a/tests/fixtures/hello-world/output/test-app/config/ember-cli-update.json b/tests/fixtures/hello-world/output/test-app/config/ember-cli-update.json new file mode 100644 index 00000000..f1c483b8 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/config/ember-cli-update.json @@ -0,0 +1,20 @@ +{ + "schemaVersion": "1.0.0", + "packages": [ + { + "name": "ember-cli", + "version": "4.9.2", + "blueprints": [ + { + "name": "addon", + "outputRepo": "https://github.com/ember-cli/ember-addon-output", + "codemodsSource": "ember-addon-codemods-manifest@1", + "isBaseBlueprint": true, + "options": [ + "--ci-provider=github" + ] + } + ] + } + ] +} diff --git a/tests/fixtures/hello-world/output/test-app/config/ember-try.js b/tests/fixtures/hello-world/output/test-app/config/ember-try.js new file mode 100644 index 00000000..4746d2b9 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/config/ember-try.js @@ -0,0 +1,71 @@ +'use strict'; + +const getChannelURL = require('ember-source-channel-url'); +const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); + +module.exports = async function () { + return { + scenarios: [ + { + name: 'ember-lts-3.28', + npm: { + devDependencies: { + 'ember-source': '~3.28.0', + }, + }, + }, + { + name: 'ember-lts-4.4', + npm: { + devDependencies: { + 'ember-source': '~4.4.0', + }, + }, + }, + { + name: 'ember-release', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('release'), + }, + }, + }, + { + name: 'ember-beta', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('beta'), + }, + }, + }, + { + name: 'ember-canary', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('canary'), + }, + }, + }, + { + name: 'ember-classic', + env: { + EMBER_OPTIONAL_FEATURES: JSON.stringify({ + 'application-template-wrapper': true, + 'default-async-observers': false, + 'template-only-glimmer-components': false, + }), + }, + npm: { + devDependencies: { + 'ember-source': '~3.28.0', + }, + ember: { + edition: 'classic', + }, + }, + }, + embroiderSafe(), + embroiderOptimized(), + ], + }; +}; diff --git a/tests/fixtures/hello-world/output/test-app/config/environment.js b/tests/fixtures/hello-world/output/test-app/config/environment.js new file mode 100644 index 00000000..113d30ae --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/config/environment.js @@ -0,0 +1,48 @@ +'use strict'; + +module.exports = function (environment) { + const ENV = { + modulePrefix: 'test-app', + environment, + rootURL: '/', + locationType: 'history', + EmberENV: { + EXTEND_PROTOTYPES: false, + FEATURES: { + // Here you can enable experimental features on an ember canary build + // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true + }, + }, + + APP: { + // Here you can pass flags/options to your application instance + // when it is created + }, + }; + + if (environment === 'development') { + // ENV.APP.LOG_RESOLVER = true; + // ENV.APP.LOG_ACTIVE_GENERATION = true; + // ENV.APP.LOG_TRANSITIONS = true; + // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; + // ENV.APP.LOG_VIEW_LOOKUPS = true; + } + + if (environment === 'test') { + // Testem prefers this... + ENV.locationType = 'none'; + + // keep test console output quieter + ENV.APP.LOG_ACTIVE_GENERATION = false; + ENV.APP.LOG_VIEW_LOOKUPS = false; + + ENV.APP.rootElement = '#ember-testing'; + ENV.APP.autoboot = false; + } + + if (environment === 'production') { + // here you can enable a production-specific feature + } + + return ENV; +}; diff --git a/tests/fixtures/hello-world/output/test-app/config/optional-features.json b/tests/fixtures/hello-world/output/test-app/config/optional-features.json new file mode 100644 index 00000000..b26286e2 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/config/optional-features.json @@ -0,0 +1,6 @@ +{ + "application-template-wrapper": false, + "default-async-observers": true, + "jquery-integration": false, + "template-only-glimmer-components": true +} diff --git a/tests/fixtures/hello-world/output/test-app/config/targets.js b/tests/fixtures/hello-world/output/test-app/config/targets.js new file mode 100644 index 00000000..1e48e059 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/config/targets.js @@ -0,0 +1,11 @@ +'use strict'; + +const browsers = [ + 'last 1 Chrome versions', + 'last 1 Firefox versions', + 'last 1 Safari versions', +]; + +module.exports = { + browsers, +}; diff --git a/tests/fixtures/hello-world/output/test-app/ember-cli-build.js b/tests/fixtures/hello-world/output/test-app/ember-cli-build.js new file mode 100644 index 00000000..b3e926ae --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/ember-cli-build.js @@ -0,0 +1,19 @@ +'use strict'; + +const EmberApp = require('ember-cli/lib/broccoli/ember-app'); + +module.exports = function (defaults) { + const app = new EmberApp(defaults, { + // Add options here + autoImport: { + watchDependencies: ['hello-world'], + }, + 'ember-cli-babel': { + enableTypeScriptTransform: true, + }, + }); + + const { maybeEmbroider } = require('@embroider/test-setup'); + + return maybeEmbroider(app); +}; diff --git a/tests/fixtures/hello-world/output/test-app/package.json b/tests/fixtures/hello-world/output/test-app/package.json new file mode 100644 index 00000000..05a41292 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/package.json @@ -0,0 +1,106 @@ +{ + "name": "test-app", + "version": "0.0.0", + "description": "The default blueprint for ember-cli addons.", + "keywords": [], + "repository": "", + "license": "MIT", + "author": "", + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "build": "ember build --environment=production", + "lint": "concurrently \"npm:lint:*(!fix)\" --names \"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", + "lint:js:fix": "eslint . --fix", + "lint:types": "tsc --noEmit", + "start": "ember serve", + "test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"", + "test:ember": "ember test", + "test:ember-compatibility": "ember try:each", + "prepack": "ember ts:precompile", + "postpack": "ember ts:clean" + }, + "dependencies": {}, + "devDependencies": { + "@ember/optional-features": "^2.0.0", + "@ember/test-helpers": "^2.8.1", + "@embroider/test-setup": "^2.0.2", + "@glimmer/component": "^1.1.2", + "@glimmer/tracking": "^1.1.2", + "@tsconfig/ember": "^2.0.0", + "@types/ember": "^4.0.3", + "@types/ember-qunit": "^6.1.1", + "@types/ember-resolver": "^9.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__test-helpers": "^2.9.1", + "@types/ember__utils": "^4.0.2", + "@types/qunit": "^2.19.4", + "@types/rsvp": "^4.0.4", + "@typescript-eslint/eslint-plugin": "^5.45.1", + "@typescript-eslint/parser": "^5.45.1", + "broccoli-asset-rev": "^3.0.0", + "concurrently": "^7.6.0", + "ember-auto-import": "^2.5.0", + "ember-cli": "~4.9.2", + "ember-cli-babel": "^7.26.11", + "ember-cli-dependency-checker": "^3.3.1", + "ember-cli-htmlbars": "^6.1.1", + "ember-cli-inject-live-reload": "^2.1.0", + "ember-cli-sri": "^2.1.1", + "ember-cli-terser": "^4.0.2", + "ember-cli-typescript": "^5.2.1", + "ember-css-modules": "^2.0.1", + "ember-load-initializers": "^2.1.2", + "ember-page-title": "^7.0.0", + "ember-qunit": "^6.0.0", + "ember-resolver": "^8.0.3", + "ember-source": "~4.9.1", + "ember-source-channel-url": "^3.0.0", + "ember-template-lint": "^5.2.0", + "ember-try": "^2.0.0", + "eslint": "^7.32.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-ember": "^11.2.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-qunit": "^7.3.4", + "hello-world": "0.0.0", + "loader.js": "^4.7.0", + "prettier": "^2.8.1", + "qunit": "^2.19.3", + "qunit-dom": "^2.0.0", + "typescript": "^4.9.4", + "webpack": "^5.75.0" + }, + "peerDependencies": { + "ember-source": "^3.28.0 || ^4.0.0" + }, + "engines": { + "node": "14.* || 16.* || >= 18" + }, + "ember": { + "edition": "octane" + }, + "private": true +} diff --git a/tests/fixtures/hello-world/output/test-app/public/robots.txt b/tests/fixtures/hello-world/output/test-app/public/robots.txt new file mode 100644 index 00000000..f5916452 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/public/robots.txt @@ -0,0 +1,3 @@ +# http://www.robotstxt.org +User-agent: * +Disallow: diff --git a/tests/fixtures/hello-world/output/test-app/testem.js b/tests/fixtures/hello-world/output/test-app/testem.js new file mode 100644 index 00000000..ed2f3712 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/testem.js @@ -0,0 +1,23 @@ +'use strict'; + +module.exports = { + test_page: 'tests/index.html?hidepassed', + disable_watching: true, + launch_in_ci: ['Chrome'], + launch_in_dev: ['Chrome'], + browser_start_timeout: 120, + browser_args: { + Chrome: { + ci: [ + // --no-sandbox is needed when running Chrome inside a container + process.env.CI ? '--no-sandbox' : null, + '--headless', + '--disable-dev-shm-usage', + '--disable-software-rasterizer', + '--mute-audio', + '--remote-debugging-port=0', + '--window-size=1440,900', + ].filter(Boolean), + }, + }, +}; diff --git a/tests/fixtures/hello-world/output/test-app/tests/helpers/index.js b/tests/fixtures/hello-world/output/test-app/tests/helpers/index.js new file mode 100644 index 00000000..b1b8f293 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/tests/helpers/index.js @@ -0,0 +1,42 @@ +import { + setupApplicationTest as upstreamSetupApplicationTest, + setupRenderingTest as upstreamSetupRenderingTest, + setupTest as upstreamSetupTest, +} from 'ember-qunit'; + +// This file exists to provide wrappers around ember-qunit's / ember-mocha's +// test setup functions. This way, you can easily extend the setup that is +// needed per test type. + +function setupApplicationTest(hooks, options) { + upstreamSetupApplicationTest(hooks, options); + + // Additional setup for application tests can be done here. + // + // For example, if you need an authenticated session for each + // application test, you could do: + // + // hooks.beforeEach(async function () { + // await authenticateSession(); // ember-simple-auth + // }); + // + // This is also a good place to call test setup functions coming + // from other addons: + // + // setupIntl(hooks, 'en-us'); // ember-intl + // setupMirage(hooks); // ember-cli-mirage +} + +function setupRenderingTest(hooks, options) { + upstreamSetupRenderingTest(hooks, options); + + // Additional setup for rendering tests can be done here. +} + +function setupTest(hooks, options) { + upstreamSetupTest(hooks, options); + + // Additional setup for unit tests can be done here. +} + +export { setupApplicationTest, setupRenderingTest, setupTest }; diff --git a/tests/fixtures/hello-world/output/test-app/tests/index.html b/tests/fixtures/hello-world/output/test-app/tests/index.html new file mode 100644 index 00000000..2b0bf427 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/tests/index.html @@ -0,0 +1,39 @@ + + + + + Dummy Tests + + + + {{content-for "head"}} + {{content-for "test-head"}} + + + + + + {{content-for "head-footer"}} + {{content-for "test-head-footer"}} + + + {{content-for "body"}} + {{content-for "test-body"}} + +
+
+
+
+
+
+ + + + + + + + {{content-for "body-footer"}} + {{content-for "test-body-footer"}} + + diff --git a/tests/fixtures/hello-world/output/test-app/tests/integration/.gitkeep b/tests/fixtures/hello-world/output/test-app/tests/integration/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/tests/integration/components/hello-test.ts b/tests/fixtures/hello-world/output/test-app/tests/integration/components/hello-test.ts new file mode 100644 index 00000000..386d9edf --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/tests/integration/components/hello-test.ts @@ -0,0 +1,15 @@ +import { render } from '@ember/test-helpers'; +import { setupRenderingTest } from 'test-app/tests/helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import { assertZoeyExists } from 'my-addon/test-support'; +import { module, test } from 'qunit'; + +module('Integration | Component | hello', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs``); + + assertZoeyExists(assert); + }); +}); diff --git a/tests/fixtures/hello-world/output/test-app/tests/test-helper.js b/tests/fixtures/hello-world/output/test-app/tests/test-helper.js new file mode 100644 index 00000000..81843044 --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/tests/test-helper.js @@ -0,0 +1,12 @@ +import Application from 'test-app/app'; +import config from 'test-app/config/environment'; +import * as QUnit from 'qunit'; +import { setApplication } from '@ember/test-helpers'; +import { setup } from 'qunit-dom'; +import { start } from 'ember-qunit'; + +setApplication(Application.create(config.APP)); + +setup(QUnit.assert); + +start(); diff --git a/tests/fixtures/hello-world/output/test-app/tests/unit/.gitkeep b/tests/fixtures/hello-world/output/test-app/tests/unit/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/hello-world/output/test-app/tsconfig.json b/tests/fixtures/hello-world/output/test-app/tsconfig.json new file mode 100644 index 00000000..1dd674ab --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "@tsconfig/ember/tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "test-app/tests/*": [ + "tests/*" + ], + "test-app/*": [ + "app/*" + ], + "*": [ + "types/*" + ] + } + } +} diff --git a/tests/fixtures/hello-world/output/test-app/types/global.d.ts b/tests/fixtures/hello-world/output/test-app/types/global.d.ts new file mode 100644 index 00000000..45a2e8ab --- /dev/null +++ b/tests/fixtures/hello-world/output/test-app/types/global.d.ts @@ -0,0 +1,7 @@ +// Types for compiled templates +declare module 'test-app/templates/*' { + import { TemplateFactory } from 'ember-cli-htmlbars'; + + const tmpl: TemplateFactory; + export default tmpl; +} diff --git a/tests/fixtures/hello-world/output/test-app/types/test-app/index.d.ts b/tests/fixtures/hello-world/output/test-app/types/test-app/index.d.ts new file mode 100644 index 00000000..e69de29b diff --git a/tests/fixtures/new-v1-addon-customizations/input/tests/helpers/index.ts b/tests/fixtures/new-v1-addon-customizations/input/tests/helpers/index.ts index 670bc643..4103c7d4 100644 --- a/tests/fixtures/new-v1-addon-customizations/input/tests/helpers/index.ts +++ b/tests/fixtures/new-v1-addon-customizations/input/tests/helpers/index.ts @@ -24,7 +24,7 @@ function setupApplicationTest(hooks: NestedHooks, options?: SetupTestOptions) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-customizations/input/types/dummy/index.d.ts b/tests/fixtures/new-v1-addon-customizations/input/types/dummy/index.d.ts index 8b137891..e69de29b 100644 --- a/tests/fixtures/new-v1-addon-customizations/input/types/dummy/index.d.ts +++ b/tests/fixtures/new-v1-addon-customizations/input/types/dummy/index.d.ts @@ -1 +0,0 @@ - diff --git a/tests/fixtures/new-v1-addon-customizations/output/demo-app/tests/helpers/index.ts b/tests/fixtures/new-v1-addon-customizations/output/demo-app/tests/helpers/index.ts index 670bc643..4103c7d4 100644 --- a/tests/fixtures/new-v1-addon-customizations/output/demo-app/tests/helpers/index.ts +++ b/tests/fixtures/new-v1-addon-customizations/output/demo-app/tests/helpers/index.ts @@ -24,7 +24,7 @@ function setupApplicationTest(hooks: NestedHooks, options?: SetupTestOptions) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-customizations/output/demo-app/types/demo-app-for-new-v1-addon/index.d.ts b/tests/fixtures/new-v1-addon-customizations/output/demo-app/types/demo-app-for-new-v1-addon/index.d.ts index 8b137891..e69de29b 100644 --- a/tests/fixtures/new-v1-addon-customizations/output/demo-app/types/demo-app-for-new-v1-addon/index.d.ts +++ b/tests/fixtures/new-v1-addon-customizations/output/demo-app/types/demo-app-for-new-v1-addon/index.d.ts @@ -1 +0,0 @@ - diff --git a/tests/fixtures/new-v1-addon-customizations/output/packages/new-v1-addon/rollup.config.mjs b/tests/fixtures/new-v1-addon-customizations/output/packages/new-v1-addon/rollup.config.mjs index cf1e4909..e704c415 100644 --- a/tests/fixtures/new-v1-addon-customizations/output/packages/new-v1-addon/rollup.config.mjs +++ b/tests/fixtures/new-v1-addon-customizations/output/packages/new-v1-addon/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/new-v1-addon-javascript/input/tests/helpers/index.js b/tests/fixtures/new-v1-addon-javascript/input/tests/helpers/index.js index 7f70de80..b1b8f293 100644 --- a/tests/fixtures/new-v1-addon-javascript/input/tests/helpers/index.js +++ b/tests/fixtures/new-v1-addon-javascript/input/tests/helpers/index.js @@ -23,7 +23,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-javascript/output/test-app/tests/helpers/index.js b/tests/fixtures/new-v1-addon-javascript/output/test-app/tests/helpers/index.js index 7f70de80..b1b8f293 100644 --- a/tests/fixtures/new-v1-addon-javascript/output/test-app/tests/helpers/index.js +++ b/tests/fixtures/new-v1-addon-javascript/output/test-app/tests/helpers/index.js @@ -23,7 +23,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-npm/input/tests/helpers/index.js b/tests/fixtures/new-v1-addon-npm/input/tests/helpers/index.js index 7f70de80..b1b8f293 100644 --- a/tests/fixtures/new-v1-addon-npm/input/tests/helpers/index.js +++ b/tests/fixtures/new-v1-addon-npm/input/tests/helpers/index.js @@ -23,7 +23,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-npm/output/test-app/tests/helpers/index.js b/tests/fixtures/new-v1-addon-npm/output/test-app/tests/helpers/index.js index 7f70de80..b1b8f293 100644 --- a/tests/fixtures/new-v1-addon-npm/output/test-app/tests/helpers/index.js +++ b/tests/fixtures/new-v1-addon-npm/output/test-app/tests/helpers/index.js @@ -23,7 +23,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-pnpm/input/tests/helpers/index.js b/tests/fixtures/new-v1-addon-pnpm/input/tests/helpers/index.js index 7f70de80..b1b8f293 100644 --- a/tests/fixtures/new-v1-addon-pnpm/input/tests/helpers/index.js +++ b/tests/fixtures/new-v1-addon-pnpm/input/tests/helpers/index.js @@ -23,7 +23,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-pnpm/output/test-app/tests/helpers/index.js b/tests/fixtures/new-v1-addon-pnpm/output/test-app/tests/helpers/index.js index 7f70de80..b1b8f293 100644 --- a/tests/fixtures/new-v1-addon-pnpm/output/test-app/tests/helpers/index.js +++ b/tests/fixtures/new-v1-addon-pnpm/output/test-app/tests/helpers/index.js @@ -23,7 +23,7 @@ function setupApplicationTest(hooks, options) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-typescript/input/tests/helpers/index.ts b/tests/fixtures/new-v1-addon-typescript/input/tests/helpers/index.ts index 670bc643..4103c7d4 100644 --- a/tests/fixtures/new-v1-addon-typescript/input/tests/helpers/index.ts +++ b/tests/fixtures/new-v1-addon-typescript/input/tests/helpers/index.ts @@ -24,7 +24,7 @@ function setupApplicationTest(hooks: NestedHooks, options?: SetupTestOptions) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-typescript/input/types/dummy/index.d.ts b/tests/fixtures/new-v1-addon-typescript/input/types/dummy/index.d.ts index 8b137891..e69de29b 100644 --- a/tests/fixtures/new-v1-addon-typescript/input/types/dummy/index.d.ts +++ b/tests/fixtures/new-v1-addon-typescript/input/types/dummy/index.d.ts @@ -1 +0,0 @@ - diff --git a/tests/fixtures/new-v1-addon-typescript/output/new-v1-addon/rollup.config.mjs b/tests/fixtures/new-v1-addon-typescript/output/new-v1-addon/rollup.config.mjs index cf1e4909..e704c415 100644 --- a/tests/fixtures/new-v1-addon-typescript/output/new-v1-addon/rollup.config.mjs +++ b/tests/fixtures/new-v1-addon-typescript/output/new-v1-addon/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/new-v1-addon-typescript/output/test-app/tests/helpers/index.ts b/tests/fixtures/new-v1-addon-typescript/output/test-app/tests/helpers/index.ts index 670bc643..4103c7d4 100644 --- a/tests/fixtures/new-v1-addon-typescript/output/test-app/tests/helpers/index.ts +++ b/tests/fixtures/new-v1-addon-typescript/output/test-app/tests/helpers/index.ts @@ -24,7 +24,7 @@ function setupApplicationTest(hooks: NestedHooks, options?: SetupTestOptions) { // This is also a good place to call test setup functions coming // from other addons: // - // setupIntl(hooks); // ember-intl + // setupIntl(hooks, 'en-us'); // ember-intl // setupMirage(hooks); // ember-cli-mirage } diff --git a/tests/fixtures/new-v1-addon-typescript/output/test-app/types/test-app/index.d.ts b/tests/fixtures/new-v1-addon-typescript/output/test-app/types/test-app/index.d.ts index 8b137891..e69de29b 100644 --- a/tests/fixtures/new-v1-addon-typescript/output/test-app/types/test-app/index.d.ts +++ b/tests/fixtures/new-v1-addon-typescript/output/test-app/types/test-app/index.d.ts @@ -1 +0,0 @@ - diff --git a/tests/fixtures/steps/create-files-from-blueprints/customizations/output/packages/ember-container-query/rollup.config.mjs b/tests/fixtures/steps/create-files-from-blueprints/customizations/output/packages/ember-container-query/rollup.config.mjs index 4472e2db..e0794c07 100644 --- a/tests/fixtures/steps/create-files-from-blueprints/customizations/output/packages/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/steps/create-files-from-blueprints/customizations/output/packages/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js', 'template-registry.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts', 'template-registry.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/steps/create-files-from-blueprints/glint/output/ember-container-query/rollup.config.mjs b/tests/fixtures/steps/create-files-from-blueprints/glint/output/ember-container-query/rollup.config.mjs index 4472e2db..e0794c07 100644 --- a/tests/fixtures/steps/create-files-from-blueprints/glint/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/steps/create-files-from-blueprints/glint/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js', 'template-registry.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts', 'template-registry.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/steps/create-files-from-blueprints/npm/output/ember-container-query/rollup.config.mjs b/tests/fixtures/steps/create-files-from-blueprints/npm/output/ember-container-query/rollup.config.mjs index cf1e4909..e704c415 100644 --- a/tests/fixtures/steps/create-files-from-blueprints/npm/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/steps/create-files-from-blueprints/npm/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/steps/create-files-from-blueprints/pnpm/output/ember-container-query/rollup.config.mjs b/tests/fixtures/steps/create-files-from-blueprints/pnpm/output/ember-container-query/rollup.config.mjs index cf1e4909..e704c415 100644 --- a/tests/fixtures/steps/create-files-from-blueprints/pnpm/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/steps/create-files-from-blueprints/pnpm/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/steps/create-files-from-blueprints/scoped/output/ember-container-query/rollup.config.mjs b/tests/fixtures/steps/create-files-from-blueprints/scoped/output/ember-container-query/rollup.config.mjs index 4472e2db..e0794c07 100644 --- a/tests/fixtures/steps/create-files-from-blueprints/scoped/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/steps/create-files-from-blueprints/scoped/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js', 'template-registry.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts', 'template-registry.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-container-query/rollup.config.mjs b/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-container-query/rollup.config.mjs index cf1e4909..e704c415 100644 --- a/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-container-query/rollup.config.mjs +++ b/tests/fixtures/steps/create-files-from-blueprints/typescript/output/ember-container-query/rollup.config.mjs @@ -20,7 +20,7 @@ export default { // up your addon's public API. Also make sure your package.json#exports // is aligned to the config here. // See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon - addon.publicEntrypoints(['**/*.js', 'index.js']), + addon.publicEntrypoints(['**/*.js', 'index.ts']), // These are the modules that should get reexported into the traditional // "app" tree. Things in here should also be in publicEntrypoints above, but diff --git a/tests/index/hello-world/index.test.ts b/tests/index/hello-world/index.test.ts new file mode 100644 index 00000000..1490745d --- /dev/null +++ b/tests/index/hello-world/index.test.ts @@ -0,0 +1,27 @@ +import { assertFixture, loadFixture, test } from '@codemod-utils/tests'; + +import { runCodemod } from '../../../src/index.js'; +import { + inputProject, + outputProject, +} from '../../fixtures/hello-world/index.js'; + +test('index | hello-world > index', function () { + const codemodOptions = { + addonLocation: undefined, + projectRoot: 'tmp/hello-world', + testAppLocation: undefined, + testAppName: undefined, + }; + + loadFixture(inputProject, codemodOptions); + + runCodemod(codemodOptions); + + assertFixture(outputProject, codemodOptions); + + // Check idempotence + runCodemod(codemodOptions); + + assertFixture(outputProject, codemodOptions); +}); diff --git a/tests/steps/move-addon-files/test-support.test.ts b/tests/steps/move-addon-files/test-support.test.ts index 9858602e..4a76198c 100644 --- a/tests/steps/move-addon-files/test-support.test.ts +++ b/tests/steps/move-addon-files/test-support.test.ts @@ -23,8 +23,8 @@ test('steps | move-addon-files > test-support', function () { components: { 'container-query.ts': '', }, - 'index.ts': `export * from './components/container-query';\n`, }, + 'test-support.ts': `export * from './components/container-query';\n`, }, }, }; diff --git a/update-test-fixtures.sh b/update-test-fixtures.sh index b189e4c3..445299bf 100755 --- a/update-test-fixtures.sh +++ b/update-test-fixtures.sh @@ -53,6 +53,13 @@ cp -r "tests/fixtures/ember-container-query-typescript/input" "tests/fixtures/em ./dist/bin/ember-codemod-v1-to-v2.js \ --root "tests/fixtures/ember-container-query-typescript/output" +# Update fixtures +rm -r "tests/fixtures/hello-world/output" +cp -r "tests/fixtures/hello-world/input" "tests/fixtures/hello-world/output" + +./dist/bin/ember-codemod-v1-to-v2.js \ + --root "tests/fixtures/hello-world/output" + # Update fixtures rm -r "tests/fixtures/new-v1-addon-customizations/output" cp -r "tests/fixtures/new-v1-addon-customizations/input" "tests/fixtures/new-v1-addon-customizations/output"