-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2226 from embroider-build/codemod
template-tag-codemod
- Loading branch information
Showing
17 changed files
with
975 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# compiled output | ||
/src/**/*.js | ||
/src/**/*.d.ts | ||
|
||
# dependencies | ||
/node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/node_modules | ||
/src/**/*.js | ||
/src/**/*.d.ts | ||
/src/**/*.map | ||
/*/tests/**/*.js | ||
/*/tests/**/*.d.ts | ||
/*/tests/**/*.map | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "@embroider/template-tag-codemod", | ||
"version": "0.4.0", | ||
"private": false, | ||
"type": "module", | ||
"description": "Convert to HBS to GJS with <template></template>", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/embroider-build/embroider.git", | ||
"directory": "packages/template-tag-codemod" | ||
}, | ||
"license": "MIT", | ||
"author": "Edward Faulkner <[email protected]>", | ||
"exports": { | ||
".": "./src/index.js" | ||
}, | ||
"bin": { | ||
"template-tag-codemod": "./src/cli.js" | ||
}, | ||
"files": [ | ||
"src/**/*.js", | ||
"src/**/*.d.ts", | ||
"src/**/*.js.map" | ||
], | ||
"scripts": {}, | ||
"dependencies": { | ||
"@babel/core": "^7.26.0", | ||
"@babel/plugin-syntax-decorators": "^7.25.9", | ||
"@babel/plugin-syntax-typescript": "^7.25.9", | ||
"@embroider/compat": "workspace:^*", | ||
"@embroider/core": "workspace:^*", | ||
"@embroider/reverse-exports": "workspace:^*", | ||
"@types/babel__core": "^7.20.5", | ||
"@types/yargs": "^17.0.3", | ||
"babel-plugin-ember-template-compilation": "^2.3.0", | ||
"broccoli": "^3.5.2", | ||
"console-ui": "^3.1.2", | ||
"ember-cli": "^6.0.1", | ||
"glob": "^11.0.0", | ||
"yargs": "^17.0.1" | ||
}, | ||
"devDependencies": { | ||
"@glimmer/syntax": "^0.84.3", | ||
"@types/glob": "^8.1.0", | ||
"@types/node": "^22.9.3", | ||
"typescript": "^5.4.5" | ||
}, | ||
"engines": { | ||
"node": ">= 20" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env node | ||
import yargs from 'yargs/yargs'; | ||
import { type Options, optionsWithDefaults, run } from './index.js'; | ||
|
||
yargs(process.argv.slice(2)) | ||
.scriptName('template-tag-codemod') | ||
.command( | ||
'$0', | ||
"Converts Ember's .hbs format to .gjs or .gts format.", | ||
y => | ||
y | ||
.option('relativeLocalPaths', { | ||
default: optionsWithDefaults().relativeLocalPaths, | ||
type: 'boolean', | ||
describe: `When true, imports for other files in the same project will use relative paths with file extensions. This is the most compatible with modern Node ESM convensions, but it's not supported by Ember's classic build.`, | ||
}) | ||
.option('extensions', { | ||
array: true, | ||
type: 'string', | ||
default: optionsWithDefaults().extensions, | ||
describe: `File extensions to search when resolving components, helpers, and modifiers inside your hbs files`, | ||
}) | ||
.option('nativeRouteTemplates', { | ||
default: optionsWithDefaults().nativeRouteTemplates, | ||
type: 'boolean', | ||
describe: `When true, assume we can use template-tag directly in route files (requires ember-source >= 6.3.0-beta.3). When false, assume we can use the ember-route-template addon instead.`, | ||
}) | ||
.option('routeTemplates', { | ||
array: true, | ||
type: 'string', | ||
default: optionsWithDefaults().routeTemplates, | ||
describe: `Controls which route template files we will convert to template tag. Provide a list of globs.`, | ||
}) | ||
.option('components', { | ||
array: true, | ||
type: 'string', | ||
default: optionsWithDefaults().components, | ||
describe: `Controls which component files we will convert to template tag. Provide a list of globs.`, | ||
}) | ||
.option('defaultFormat', { | ||
type: 'string', | ||
default: optionsWithDefaults().defaultFormat, | ||
describe: `When a .js or .ts file already exists, we necessarily convert to .gjs or .gts respectively. But when only an .hbs file exists, we have a choice of default.`, | ||
}) | ||
.option('templateOnlyComponentSignature', { | ||
type: 'string', | ||
default: optionsWithDefaults().templateOnlyComponentSignature, | ||
describe: `Snippet of typescript to use as the type signature of newly-converted template-only components.`, | ||
}) | ||
.option('routeTemplateSignature', { | ||
type: 'string', | ||
default: optionsWithDefaults().routeTemplateSignature, | ||
describe: `Snippet of typescript to use as the type signature of route templates.`, | ||
}) | ||
.option('templateInsertion', { | ||
type: 'string', | ||
default: optionsWithDefaults().templateInsertion, | ||
describe: `Where should <template> be inserted inside existing class bodies? Say "beginning" or "end".`, | ||
}), | ||
|
||
async argv => { | ||
await run(argv as Options); | ||
} | ||
) | ||
.parse(); |
Oops, something went wrong.