-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented generate commands (Part 2) (#7)
* chore: Added fixtures * feature: Guaranteed idempotency * refactor: Defined variations of entity name in create-options * feature: Updated barrel file * feature: Updated template registry * bugfix, feature: Created test file * chore: Updated fixtures * chore: Added changeset --------- Co-authored-by: ijlee2 <ijlee2@users.noreply.github.com>
- Loading branch information
Showing
71 changed files
with
558 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"blueprints-addon": minor | ||
--- | ||
|
||
Implemented generate commands (Part 2) |
6 changes: 3 additions & 3 deletions
6
...ueprints-addon/src/blueprints/run-generate/component/__testAppLocation__/__fileName__.gts
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
8 changes: 4 additions & 4 deletions
8
.../blueprints-addon/src/blueprints/run-generate/helper/__testAppLocation__/__fileName__.gts
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
11 changes: 5 additions & 6 deletions
11
...lueprints-addon/src/blueprints/run-generate/modifier/__testAppLocation__/__fileName__.gts
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
4 changes: 2 additions & 2 deletions
4
.../blueprints-addon/src/blueprints/run-generate/service/__testAppLocation__/__fileName__.ts
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
4 changes: 2 additions & 2 deletions
4
packages/blueprints-addon/src/blueprints/run-generate/service/class/__fileName__.ts
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import Service from '@ember/service'; | ||
|
||
export default class <%= data.entity.classifiedName %>Service extends Service {} | ||
export default class <%= options.entity.classifiedName %>Service extends Service {} | ||
|
||
declare module '@ember/service' { | ||
interface Registry { | ||
'<%= data.entity.name %>': <%= data.entity.classifiedName %>Service; | ||
'<%= options.entity.name %>': <%= options.entity.classifiedName %>Service; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...ges/blueprints-addon/src/blueprints/run-generate/util/__testAppLocation__/__fileName__.ts
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
2 changes: 1 addition & 1 deletion
2
packages/blueprints-addon/src/blueprints/run-generate/util/function/__fileName__.ts
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export default function <%= data.entity.camelizedName %>() { | ||
export default function <%= options.entity.camelizedName %>() { | ||
return true; | ||
} |
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 |
---|---|---|
@@ -1,8 +1,35 @@ | ||
import { createEntity, createOptions } from './steps/run-generate/index.js'; | ||
import type { CodemodOptions } from './types/run-generate.js'; | ||
import { join } from 'node:path'; | ||
|
||
import { findFiles } from '@codemod-utils/files'; | ||
|
||
import { | ||
createEntity, | ||
createOptions, | ||
createTestFile, | ||
updateBarrelFile, | ||
updateTemplateRegistry, | ||
} from './steps/run-generate/index.js'; | ||
import type { CodemodOptions, Options } from './types/run-generate.js'; | ||
|
||
function entityExists(options: Options): boolean { | ||
const { entity, projectRoot } = options; | ||
|
||
const files = findFiles(join('src', `${entity.type}s`, `${entity.name}.*`), { | ||
projectRoot, | ||
}); | ||
|
||
return files.length > 0; | ||
} | ||
|
||
export function runGenerate(codemodOptions: CodemodOptions): void { | ||
const options = createOptions(codemodOptions); | ||
|
||
if (entityExists(options)) { | ||
return; | ||
} | ||
|
||
createEntity(options); | ||
updateBarrelFile(options); | ||
updateTemplateRegistry(options); | ||
createTestFile(options); | ||
} |
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
Oops, something went wrong.