Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional included files in smithy-templates for smithy init #1832

Merged
merged 4 commits into from
Jun 21, 2023

Conversation

hpmellema
Copy link
Contributor

@hpmellema hpmellema commented Jun 20, 2023

Description of changes:
This PR allows the inclusion of additional files and directories along with the template directory. The primary purpose of this is to allow templates to share common definitions of build files (i.e. gradlew, gradle/, gradle.properties, etc) without having to copy these files within each template directory.

For example, consider a gradle example for the smithy-quickstart-guide. The template directory for this template must contain:

my-template-repo/
├── smithy-templates.json
├── gradle
|        └── wrapper
│            ├── gradle-wrapper.jar
│            └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── other/files
└─ getting-started-gradle
          ├── README.md
          ├── build.gradle.kts
          ├── gradle
          │           └── wrapper
          │              ├── gradle-wrapper.jar
          │              └── gradle-wrapper.properties
          ├── gradle.properties
          ├── gradlew
          ├── gradlew.bat
          ├── models
          │         └── weather.smithy
          └── smithy-build.json

In a repository with multiple examples, every single gradle example would need to copy the same gradle/ directory, gradlew gradel wrapper, etc.

Instead, we can include these files from outside the template directory from another location in the template-containing repository. For example, with this change, we could re-define the template in the smithy-template.json file as:

    "included-files-gradle": {
            "documentation": "Smithy Quickstart example weather service using the Smithy CLI with gradle files included.",
            "path": "getting-started/getting-started-gradle",
            "include": [
                "gradle",
                "gradlew",
                "gradle.properties"
            ]
        }

This would include the gradle wrapper files from the root of the template repo in the cloned template. Each new gradle template could just repeat this "include" definition without needing to copy the gradle wrapper definitions. So now the template directory would look like:

my-template-repo/
├── smithy-templates.json
├── gradle
│        └── wrapper
│            ├── gradle-wrapper.jar
│            └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── other/files
└─ getting-started-gradle
        ├── README.md
        ├── build.gradle.kts
        ├── models
        │     └── weather.smithy
        └── smithy-build.json

As of right now all the files and directories are included at the root of the copied template directory

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hpmellema hpmellema marked this pull request as ready for review June 21, 2023 15:19
@hpmellema hpmellema requested a review from a team as a code owner June 21, 2023 15:19
@hpmellema hpmellema changed the title Additional included files Add additional included files in smithy-templates for smithy init Jun 21, 2023
@hpmellema hpmellema merged commit 5accc5e into smithy-lang:main Jun 21, 2023
@hpmellema hpmellema deleted the additional-included-files branch June 21, 2023 18:03
syall pushed a commit to Xtansia/smithy that referenced this pull request Aug 11, 2023
…ithy-lang#1832)

* Add additional file inclusion in smithy init template

* Add support for additional directories

* update list template integ tests to account for newly added templates

* correct line continuation spacing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants