Skip to content

Commit

Permalink
chore(smithy): Service clients prep
Browse files Browse the repository at this point in the history
- Updates to latest SDK models
- Updates to latest goldens
	- Updates `aft` to correctly pull latest Smithy version ([commit](26568b3))
	- Fixes minor issue with HTTP metadata ([commit](b2684a4))
- Removes most prefixing in generated code (e.g. `_i0.` - [commit](0ebba56))
- Adds AWS credentials provider chain ([commit](0460933))
  • Loading branch information
dnys1 authored Aug 14, 2023
2 parents 92694fb + 06312ce commit e3fda03
Show file tree
Hide file tree
Showing 4,570 changed files with 133,381 additions and 136,510 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import 'dart:io';

import 'package:aft/aft.dart';
import 'package:aws_common/aws_common.dart';
import 'package:collection/collection.dart';
import 'package:file/local.dart';
import 'package:git/git.dart';
import 'package:glob/glob.dart';
import 'package:libgit2dart/libgit2dart.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import 'package:pubspec_parse/pubspec_parse.dart';
import 'package:smithy/ast.dart';
import 'package:smithy_codegen/smithy_codegen.dart';
Expand Down Expand Up @@ -36,6 +40,7 @@ class GenerateGoldensCommand extends AmplifyCommand {
'update',
help: 'Whether to update test models from git',
defaultsTo: false,
negatable: false,
);
}

Expand Down Expand Up @@ -81,28 +86,43 @@ class GenerateGoldensCommand extends AmplifyCommand {
/// v1 models are no longer committed to git and are fixed at the last commit
/// in which they were updated.
Future<void> updateModels() async {
final smithyVersion = File(
p.join(goldensRoot, 'smithy-version'),
).readAsStringSync().trim();
const url = 'https://github.com/awslabs/smithy';
final tmpDir = Directory.systemTemp.createTempSync('smithy');
final process = await Process.start(
'git',
[
'clone',
'--depth=1',
'--branch',
smithyVersion,
url,
tmpDir.path,
],
mode: ProcessStartMode.inheritStdio,
workingDirectory: goldensRoot,
);
if (await process.exitCode != 0) {
stderr.writeln('Could not clone $url');
exit(1);
}

final gitRepo = Repository.open(tmpDir.path);
final versions = gitRepo.tags
.map((tag) {
try {
return Version.parse(tag);
} on Object {
return null;
}
})
.nonNulls
.sorted((a, b) => a.compareTo(b));
final latestVersion = versions.last.toString();
logger.info('Updating models to Smithy $latestVersion');

final gitDir = await GitDir.fromExisting(tmpDir.path);
await gitDir.runCommand(
['checkout', latestVersion],
echoOutput: false,
throwOnError: true,
);

for (final protocol in awsProtocols) {
final src = p.join(
tmpDir.path,
Expand Down Expand Up @@ -142,6 +162,25 @@ class GenerateGoldensCommand extends AmplifyCommand {
final content = file.readAsStringSync();
file.writeAsStringSync(content.replaceAll('coral', 'example'));
}

// Update smithy-build.json and smithy-version
final smithyBuildJson = File(p.join(goldensRoot, 'smithy-build.json'));
await smithyBuildJson.writeAsString(
prettyPrintJson({
'mavenDependencies': [
'software.amazon.smithy:smithy-model:$latestVersion',
'software.amazon.smithy:smithy-aws-apigateway-traits:$latestVersion',
'software.amazon.smithy:smithy-aws-cloudformation-traits:$latestVersion',
'software.amazon.smithy:smithy-aws-iam-traits:$latestVersion',
'software.amazon.smithy:smithy-aws-traits:$latestVersion',
'software.amazon.smithy:smithy-mqtt-traits:$latestVersion',
'software.amazon.smithy:smithy-protocol-test-traits:$latestVersion',
'software.amazon.smithy:smithy-validation-model:$latestVersion'
]
}),
);
final smithyVersion = File(p.join(goldensRoot, 'smithy-version'));
await smithyVersion.writeAsString(latestVersion);
}

Future<SmithyAst> _transform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ abstract class AWSIamAmplifyAuthProvider extends AmplifyAuthProvider
AWSBaseHttpRequest request, {
covariant IamAuthProviderOptions options,
});

@override
String get runtimeTypeName => 'AWSIamAmplifyAuthProvider';
}

abstract class ApiKeyAmplifyAuthProvider extends AmplifyAuthProvider {
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e3fda03

Please sign in to comment.