-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(open-api-gateway): idomatic smithy project structure for better …
…ide support This change restructures the smithy-based projects to combine the `model` and `smithy-build` directories into a single `smithy` directory. This directory has a more similar structure to those found in the Smithy documentation, and in turn means that IDE tools can be more easily configured to help with the developer experience. Specifically with this change, the Smithy IntelliJ plugin can be used to enhance the development experience when authoring models. https://github.com/iancaffey/smithy-intellij-plugin We preserve the behaviour of abstracting away the gradle wrapper, whereby it is ignored from the generated project's source control by default, and copied from the PDK if it does not already exist. Similarly we allow users to bring their own `gradle wrapper` by choosing not to ignore it in source control, and placing it in the `smithy` directory. This replaces the `gradleWrapperPath` configuration option. While this is a breaking change, the migration steps are fairly straightforward: - Upgrade the open-api-gateway package - `npx projen` to regenerate code - notice the new `smithy` folder in your api project - Copy the contents of the old `model` directory into `smithy/src/main/smithy` - If any custom dependencies were added to the `smithy-build/build.gradle` file, add them to `smithy/build.gradle` - Delete the old `model` and `smithy-build` directories BREAKING CHANGE: Moved the location of the smithy model from 'model' to 'smithy/src/main/smithy'. Removed the gradleWrapperPath configuration option. fix #278
- Loading branch information
Showing
18 changed files
with
13,912 additions
and
5,259 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
plugins { | ||
id "software.amazon.smithy" version "0.6.0" | ||
id "idea" | ||
} | ||
|
||
idea { | ||
module { | ||
sourceDirs += file("src/main/smithy") | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
configurations { | ||
smithy | ||
} | ||
|
||
// Add more dependencies here if you'd like to reference them in smithy-build.json | ||
// Feel free to upgrade versions as appropriate | ||
// Additional Smithy dependencies can be added here | ||
dependencies { | ||
smithy("software.amazon.smithy:smithy-cli:1.24.0") | ||
smithy("software.amazon.smithy:smithy-model:1.24.0") | ||
smithy("software.amazon.smithy:smithy-openapi:1.24.0") | ||
smithy("software.amazon.smithy:smithy-aws-traits:1.24.0") | ||
implementation "software.amazon.smithy:smithy-cli:1.27.2" | ||
implementation "software.amazon.smithy:smithy-model:1.27.2" | ||
implementation "software.amazon.smithy:smithy-openapi:1.27.2" | ||
implementation "software.amazon.smithy:smithy-aws-traits:1.27.2" | ||
} | ||
|
||
// This task is called by the SmithyApiGateway project during project synthesis, modify at your own risk! | ||
// This task is called by the SmithyApiGateway project and should not be removed! | ||
task generate(type: JavaExec) { | ||
classpath configurations.smithy | ||
main = "software.amazon.smithy.cli.SmithyCli" | ||
configurations.implementation.setCanBeResolved(true) | ||
|
||
classpath = configurations.implementation | ||
mainClass.set('software.amazon.smithy.cli.SmithyCli') | ||
|
||
args("build", | ||
"--config", | ||
file(config).toString(), | ||
"--output", | ||
file(output).toString(), | ||
"--discover", | ||
file(discover).toString()) | ||
if (project.hasProperty("config") && project.hasProperty("output") && project.hasProperty("discover")) { | ||
args("build", | ||
"--config", | ||
file(project.getProperty("config")).toString(), | ||
"--output", | ||
file(project.getProperty("output")).toString(), | ||
"--discover", | ||
file(project.getProperty("discover")).toString()) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
packages/open-api-gateway/src/project/smithy/components/sample-executable.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,38 @@ | ||
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import { Project, SampleFile, SampleFileOptions } from "projen"; | ||
import { getFilePermissions } from "projen/lib/util"; | ||
|
||
/** | ||
* A sample file that is executable | ||
*/ | ||
export class SampleExecutable extends SampleFile { | ||
private readonly file: string; | ||
|
||
constructor(project: Project, filePath: string, options: SampleFileOptions) { | ||
super(project, filePath, options); | ||
this.file = filePath; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public synthesize() { | ||
const fullFilePath = path.join(this.project.outdir, this.file); | ||
if (fs.existsSync(fullFilePath)) { | ||
return; | ||
} | ||
|
||
super.synthesize(); | ||
|
||
fs.chmodSync( | ||
fullFilePath, | ||
getFilePermissions({ | ||
executable: true, | ||
readonly: false, | ||
}) | ||
); | ||
} | ||
} |
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.