-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c5ca20
commit 407fcf1
Showing
25 changed files
with
113 additions
and
127 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
blueprint-plugins/blueprint-plugin-template/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
5 changes: 0 additions & 5 deletions
5
blueprint-plugins/blueprint-plugin-template/src/static/src/constants.ts
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
blueprint-plugins/blueprint-plugin-template/src/static/src/index.ts
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
1 change: 1 addition & 0 deletions
1
blueprint-plugins/blueprint-plugin-template/static/src/constants.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const PLUGIN_ID = "{{PLUGIN_KEBAB_CASE_NAME}}"; |
69 changes: 69 additions & 0 deletions
69
blueprint-plugins/blueprint-plugin-template/static/src/index.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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
blueprintPluginEventsParams as blueprint, | ||
blueprintPluginEventsTypes, | ||
blueprintTypes, | ||
IFile, | ||
} from "@amplication/code-gen-types"; | ||
import { CodeBlock } from "@amplication/csharp-ast"; | ||
import { resolve } from "path"; | ||
import { pascalCase } from "pascal-case"; | ||
|
||
class PluginName implements blueprintTypes.AmplicationPlugin { | ||
register(): blueprintPluginEventsTypes.BlueprintEvents { | ||
return { | ||
createBlueprint: { | ||
before: this.beforeCreateBlueprint, | ||
}, | ||
}; | ||
} | ||
async beforeCreateBlueprint( | ||
context: blueprintTypes.DsgContext, | ||
eventParams: blueprint.CreateBlueprintParams, | ||
): Promise<blueprint.CreateBlueprintParams> { | ||
context.logger.info("Generating Files from PluginName..."); | ||
|
||
const params = {} as Record<string, string>; | ||
|
||
params.SERVICE_DISPLAY_NAME = context.resourceInfo?.name || "Service Name"; | ||
params.SERVICE_NAME = pascalCase(params.SERVICE_DISPLAY_NAME); | ||
|
||
//resource catalog properties | ||
const resourceCatalogProperties = (context.resourceInfo?.properties || | ||
{}) as Record<string, string>; | ||
const resourceSetting = (context.resourceSettings?.properties || | ||
({} as Record<string, string>)) as Record<string, string>; | ||
|
||
//all catalog and resource settings are available for use in the template | ||
const placeholders = { | ||
...params, | ||
...resourceCatalogProperties, | ||
...resourceSetting, | ||
}; | ||
|
||
const stringReplacements = { | ||
ServiceName: params.SERVICE_NAME, | ||
}; | ||
|
||
// set the path to the static files and fetch them for manipulation | ||
const staticPath = resolve(__dirname, "./static"); | ||
const files = await context.utils.importStaticFilesWithReplacements( | ||
staticPath, | ||
".", | ||
placeholders, | ||
stringReplacements, | ||
); | ||
|
||
for (const file of files.getAll()) { | ||
const codeBlock: IFile<CodeBlock> = { | ||
path: file.path, | ||
code: new CodeBlock({ | ||
code: file.code, | ||
}), | ||
}; | ||
context.files.set(codeBlock); | ||
} | ||
return eventParams; | ||
} | ||
} | ||
|
||
export default PluginName; |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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