Skip to content

Commit b182975

Browse files
authored
Test client generated from released codegenerator (#1094)
1 parent 599e95a commit b182975

File tree

5 files changed

+75
-9
lines changed

5 files changed

+75
-9
lines changed

scripts/build-generated-test-packages.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ const { spawnProcess } = require("./utils/spawn-process");
99

1010
const root = path.join(__dirname, "..");
1111

12-
const codegenTestDir = path.join(
12+
const testProjectDir = path.join(
1313
root,
1414
"smithy-typescript-codegen-test",
15+
);
16+
17+
const codegenTestDir = path.join(
18+
testProjectDir,
1519
"build",
1620
"smithyprojections",
1721
"smithy-typescript-codegen-test",
@@ -23,6 +27,16 @@ const weatherClientDir = path.join(
2327
"typescript-client-codegen"
2428
);
2529

30+
const releasedClientDir = path.join(
31+
testProjectDir,
32+
"released-version-test",
33+
"build",
34+
"smithyprojections",
35+
"released-version-test",
36+
"source",
37+
"typescript-codegen"
38+
);
39+
2640
// TODO(experimentalIdentityAndAuth): build generic client for integration tests
2741
const weatherExperimentalIdentityAndAuthClientDir = path.join(
2842
codegenTestDir,
@@ -61,13 +75,15 @@ const buildAndCopyToNodeModules = async (packageName, codegenDir, nodeModulesDir
6175
await spawnProcess("touch", ["yarn.lock"], { cwd: codegenDir });
6276
await spawnProcess("yarn", { cwd: codegenDir });
6377
await spawnProcess("yarn", ["build"], { cwd: codegenDir });
64-
// After building the package, it's packed and copied to node_modules so that
78+
// Optionally, after building the package, it's packed and copied to node_modules so that
6579
// it can be used in integration tests by other packages within the monorepo.
66-
await spawnProcess("yarn", ["pack"], { cwd: codegenDir });
67-
await spawnProcess("rm", ["-rf", packageName], { cwd: nodeModulesDir });
68-
await spawnProcess("mkdir", ["-p", packageName], { cwd: nodeModulesDir });
69-
const targetPackageDir = path.join(nodeModulesDir, packageName);
70-
await spawnProcess("tar", ["-xf", "package.tgz", "-C", targetPackageDir, "--strip-components", "1"], { cwd: codegenDir });
80+
if (nodeModulesDir != undefined) {
81+
await spawnProcess("yarn", ["pack"], { cwd: codegenDir });
82+
await spawnProcess("rm", ["-rf", packageName], { cwd: nodeModulesDir });
83+
await spawnProcess("mkdir", ["-p", packageName], { cwd: nodeModulesDir });
84+
const targetPackageDir = path.join(nodeModulesDir, packageName);
85+
await spawnProcess("tar", ["-xf", "package.tgz", "-C", targetPackageDir, "--strip-components", "1"], { cwd: codegenDir });
86+
}
7187
} catch (e) {
7288
console.log(`Building and copying package \`${packageName}\` in \`${codegenDir}\` to \`${nodeModulesDir}\` failed:`)
7389
console.log(e);
@@ -84,4 +100,6 @@ const buildAndCopyToNodeModules = async (packageName, codegenDir, nodeModulesDir
84100
await buildAndCopyToNodeModules("@smithy/identity-and-auth-http-api-key-auth-service", httpApiKeyAuthClientDir, nodeModulesDir);
85101
// TODO(experimentalIdentityAndAuth): add `@httpBearerAuth` client for integration tests
86102
await buildAndCopyToNodeModules("@smithy/identity-and-auth-http-bearer-auth-service", httpBearerAuthClientDir, nodeModulesDir);
103+
// Test released version of smithy-typescript codegenerators, but
104+
await buildAndCopyToNodeModules("released", releasedClientDir, undefined);
87105
})();

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ rootProject.name = "smithy-typescript"
2020
include(":smithy-typescript-codegen")
2121
include(":smithy-typescript-codegen-test")
2222
include(":smithy-typescript-codegen-test:example-weather-customizations")
23+
include(":smithy-typescript-codegen-test:released-version-test")
2324
include(":smithy-typescript-ssdk-codegen-test-utils")
2425

2526
file(

smithy-typescript-codegen-test/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
extra["displayName"] = "Smithy :: Typescript :: Codegen :: Test"
1717
extra["moduleName"] = "software.amazon.smithy.typescript.codegen.test"
1818

19-
tasks["jar"].enabled = false
20-
2119
val smithyVersion: String by project
2220

2321
buildscript {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
tasks["jar"].enabled = false
7+
8+
val smithyVersion: String by project
9+
val version: String by project
10+
11+
buildscript {
12+
val smithyVersion: String by project
13+
14+
repositories {
15+
mavenCentral()
16+
}
17+
dependencies {
18+
"classpath"("software.amazon.smithy:smithy-cli:$smithyVersion")
19+
}
20+
}
21+
22+
plugins {
23+
id("software.amazon.smithy")
24+
}
25+
26+
repositories {
27+
mavenCentral()
28+
}
29+
30+
dependencies {
31+
implementation("software.amazon.smithy.typescript:smithy-typescript-codegen:$version!!")
32+
implementation("software.amazon.smithy.typescript:smithy-aws-typescript-codegen:$version!!")
33+
implementation(project(":smithy-typescript-codegen-test"))
34+
implementation(project(":smithy-typescript-codegen-test:example-weather-customizations"))
35+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "1.0",
3+
"plugins": {
4+
"typescript-codegen": {
5+
"service": "example.weather#Weather",
6+
"package": "weather",
7+
"packageVersion": "0.0.1",
8+
"packageJson": {
9+
"license": "Apache-2.0",
10+
"private": true
11+
}
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)