Skip to content

Commit

Permalink
Corrected the addon file locations for TypeScript projects (#90)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ijlee2 and ijlee2 authored Sep 5, 2024
1 parent b03f3eb commit 6192935
Show file tree
Hide file tree
Showing 151 changed files with 2,025 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/steps/move-addon-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/hello-world/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
19 changes: 19 additions & 0 deletions tests/fixtures/hello-world/input/.editorconfig
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/fixtures/hello-world/input/.ember-cli
Original file line number Diff line number Diff line change
@@ -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
}
25 changes: 25 additions & 0 deletions tests/fixtures/hello-world/input/.eslintignore
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions tests/fixtures/hello-world/input/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -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'],
},
],
};
32 changes: 32 additions & 0 deletions tests/fixtures/hello-world/input/.gitignore
Original file line number Diff line number Diff line change
@@ -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/
39 changes: 39 additions & 0 deletions tests/fixtures/hello-world/input/.npmignore
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions tests/fixtures/hello-world/input/.prettierignore
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/fixtures/hello-world/input/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
singleQuote: true,
};
5 changes: 5 additions & 0 deletions tests/fixtures/hello-world/input/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: 'recommended',
};
Loading

0 comments on commit 6192935

Please sign in to comment.