Skip to content

Commit

Permalink
Merge pull request #848 from aws-amplify/main
Browse files Browse the repository at this point in the history
chore: release codegen packages
  • Loading branch information
phani-srikar authored May 22, 2024
2 parents cbbb1d3 + 45c26d9 commit 8285817
Show file tree
Hide file tree
Showing 26 changed files with 666 additions and 41 deletions.
8 changes: 8 additions & 0 deletions .codebuild/deprecate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 0.2
env:
shell: bash
git-credential-helper: yes
phases:
build:
commands:
- source ./shared-scripts.sh && _deprecate
14 changes: 14 additions & 0 deletions .codebuild/deprecate_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 0.2
env:
shell: bash
compute-type: BUILD_GENERAL1_SMALL

batch:
fast-fail: false
build-graph:
- identifier: install_linux
buildspec: .codebuild/install_linux.yml
- identifier: deprecate
buildspec: .codebuild/deprecate.yml
depend-on:
- install_linux
10 changes: 10 additions & 0 deletions .codebuild/install_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _installLinux
artifacts:
files:
- 'shared-scripts.sh'
2 changes: 1 addition & 1 deletion .codebuild/scripts/local_publish_helpers.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

custom_registry_url=http://localhost:4873
default_verdaccio_package=verdaccio@4.5.1
[email protected].2

function startLocalRegistry {
# Start local registry
Expand Down
42 changes: 42 additions & 0 deletions .github/ISSUE_TEMPLATE/1.gen2_bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Gen 2 Bug Report
description: Create a report to help us improve Amplify Gen 2 Codegen
labels: ['pending-triage']
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: env
attributes:
label: Environment information
description: |
Please copy and paste output of the following command. This will be automatically formatted into code, so no need for backticks.
```bash
npx ampx info
```
render: plain text
validations:
required: true
- type: textarea
id: env
attributes:
label: Codegen packages
description: |
Please copy and paste output of the following command. This will be automatically formatted into code, so no need for backticks.
```bash
npm list @aws-amplify/graphql-generator
```
render: plain text
validations:
required: true
- type: textarea
id: description
attributes:
label: Description
description: |
Describe the bug
How can this bug be reproduced?
Please include any code snippets or screenshots that you think would be helpful!
validations:
required: true
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/2.feature_request.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Bug report
description: Create a report to help us improve Amplify Codegen
name: Gen 1 Bug report
description: Create a report to help us improve Gen 1 CLI Amplify Codegen
body:
- type: markdown
attributes:
Expand Down
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/3.feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Feature request
description: Suggest an idea for the Amplify Codegen
labels: ['pending-triage']

body:
- type: markdown
attributes:
value: |
Thanks for taking the time to submit a feature request! Try to include as much information as you can.
- For **Amplify Backend** issues, please visit [amplify-backend](https://github.com/aws-amplify/amplify-backend/issues/new/choose)
- For **Amplify Hosting** issues, visit [amplify-hosting](https://github.com/aws-amplify/amplify-hosting/issues/new/choose)
- For **Amplify Codegen** issues, visit [amplify-codegen](https://github.com/aws-amplify/amplify-codegen/issues/new/choose)
- type: textarea
attributes:
label: Describe the feature you'd like to request
description: |
A clear and concise description of what you want to happen. Please include **any related issues**, documentation, etc.
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like
description: |
A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives you've considered
description: |
A clear and concise description of any alternative solutions or features you've considered.
validations:
required: true
- type: textarea
attributes:
label: Additional context
description: |
Add any other use cases or context about the feature request here. Please include any prototype, workaround, reference implementation, etc.
- type: checkboxes
attributes:
label: Is this something that you'd be interested in working on?
options:
- label: 👋 I may be able to implement this feature request
- type: checkboxes
attributes:
label: Would this feature include a breaking change?
options:
- label: ⚠️ This feature might incur a breaking change
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: I want help writing my Amplify application
url: https://discord.com/invite/amplify
about: Check out the `*-help` channels on Amplify's community Discord to ask your questions about building applications with the CLI or other Amplify libraries.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ package-lock.json
.idea
scripts/.env
.codebuild/debug_workflow.yml
.npmrc
verdaccio-logs.txt
scripts/components/private_packages.ts
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
**/package-lock.json
**/.eslintrc.js
**/tsconfig.json
packages/*/CHANGELOG.md
packages/*/CHANGELOG.md
scripts/components/private_packages.ts
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint-fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"clean": "lerna run clean && lerna exec yarn rimraf tsconfig.tsbuildinfo && lerna clean --yes && yarn rimraf node_modules",
"build": "lerna run build",
"production-build": "yarn --ignore-engines --frozen-lockfile && lerna run build --concurrency 3 --stream",
"production-install": "yarn --ignore-engines --frozen-lockfile",
"production-build": "yarn production-install && lerna run build --concurrency 3 --stream",
"publish:main": "lerna publish --canary --exact --force-publish --preid=dev --dist-tag=dev --include-merged-tags --conventional-prerelease --no-verify-access --yes",
"publish:release": "lerna publish --exact --conventional-commits --message 'chore(release): Publish [ci skip]' --no-verify-access --yes",
"publish:tag": "lerna publish --exact --dist-tag=$NPM_TAG --preid=$NPM_TAG --conventional-commits --conventional-prerelease --message 'chore(release): Publish tagged release $NPM_TAG [ci skip]' --no-verify-access --yes",
Expand All @@ -35,6 +36,7 @@
"verify-api-extract": "yarn extract-api && ./scripts/verify-extract-api.sh",
"trigger-release": "source ./scripts/cloud-release.sh && triggerRelease",
"trigger-tag-release": "source ./scripts/cloud-release.sh && triggerTagRelease",
"trigger-deprecate-release": "source ./scripts/cloud-release.sh && deprecateRelease",
"view-test-artifact": "./scripts/view-test-artifacts.sh",
"cleanup-stale-resources": "source ./scripts/cloud-utils.sh && cleanupStaleResources",
"cloud-e2e": "source scripts/cloud-utils.sh && cloudE2E",
Expand All @@ -44,7 +46,8 @@
"cloud-e2e-debug": "source scripts/cloud-utils.sh && cloudE2EDebug",
"authenticate-e2e-profile": "source scripts/cloud-utils.sh && authenticateWithE2EProfile",
"extract-dependency-licenses": "./scripts/extract-dependency-licenses.sh",
"verify-dependency-licenses-extract": "yarn extract-dependency-licenses && ./scripts/verify-dependency-licenses.sh"
"verify-dependency-licenses-extract": "yarn extract-dependency-licenses && ./scripts/verify-dependency-licenses.sh",
"deprecate": "ts-node scripts/deprecate_release.ts"
},
"bugs": {
"url": "https://github.com/aws-amplify/amplify-codegen/issues"
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-codegen-e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@aws-amplify/amplify-codegen-e2e-core": "1.6.5",
"@aws-amplify/graphql-schema-test-library": "^1.1.18",
"@aws-amplify/graphql-schema-test-library": "^2.2.28",
"amazon-cognito-identity-js": "^6.3.6",
"aws-amplify": "^5.3.3",
"aws-appsync": "^4.1.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,12 +1142,14 @@ class Contact {
Contact.fromJson(Map<String, dynamic> json)
: _contactName = json['contactName'],
_phone = json['phone'] != null
? Phone.fromJson(new Map<String, dynamic>.from(json['phone']))
? json['phone']['serializedData'] != null
? Phone.fromJson(new Map<String, dynamic>.from(json['phone']['serializedData']))
: Phone.fromJson(new Map<String, dynamic>.from(json['phone']))
: null,
_mailingAddresses = json['mailingAddresses'] is List
? (json['mailingAddresses'] as List)
.where((e) => e != null)
.map((e) => Address.fromJson(new Map<String, dynamic>.from(e)))
.map((e) => Address.fromJson(new Map<String, dynamic>.from(e['serializedData'] ?? e)))
.toList()
: null;

Expand Down Expand Up @@ -1390,12 +1392,14 @@ class Person extends amplify_core.Model {
: id = json['id'],
_name = json['name'],
_phone = json['phone'] != null
? Phone.fromJson(new Map<String, dynamic>.from(json['phone']))
? json['phone']['serializedData'] != null
? Phone.fromJson(new Map<String, dynamic>.from(json['phone']['serializedData']))
: Phone.fromJson(new Map<String, dynamic>.from(json['phone']))
: null,
_mailingAddresses = json['mailingAddresses'] is List
? (json['mailingAddresses'] as List)
.where((e) => e != null)
.map((e) => Address.fromJson(new Map<String, dynamic>.from(e)))
.map((e) => Address.fromJson(new Map<String, dynamic>.from(e['serializedData'] ?? e)))
.toList()
: null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,9 @@ export class AppSyncModelDartVisitor<
`${fieldName} = json['${varName}'] is List`,
indent(`? (json['${varName}'] as List)`),
indent(`.where((e) => e != null)`, 2),
indent(`.map((e) => ${this.getNativeType({ ...field, isList: false })}.fromJson(new Map<String, dynamic>.from(e)))`, 2),
indent(`.map((e) => ${this.getNativeType({ ...field, isList: false })}.fromJson(new Map<String, dynamic>.from(${
this.isNonModelType(field) ? "e['serializedData'] ?? e" : 'e'
})))`, 2),
indent(`.toList()`, 2),
indent(`: null`),
]
Expand All @@ -756,8 +758,10 @@ export class AppSyncModelDartVisitor<
// single non-model i.e. embedded
return [
`${fieldName} = json['${varName}'] != null`,
indent(`? ${this.getNativeType(field)}.fromJson(new Map<String, dynamic>.from(json['${varName}']))`),
indent(`: null`),
indent(`? json['${varName}']['serializedData'] != null`, 2),
indent(`? ${this.getNativeType(field)}.fromJson(new Map<String, dynamic>.from(json['${varName}']['serializedData']))`, 4),
indent(`: ${this.getNativeType(field)}.fromJson(new Map<String, dynamic>.from(json['${varName}']))`, 4),
indent(`: null`,),
].join('\n');
}
//regular type
Expand Down
11 changes: 11 additions & 0 deletions scripts/cloud-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source ./scripts/cloud-utils.sh
export RELEASE_ROLE_NAME=CodebuildDeveloper
export RELEASE_PROFILE_NAME=AmplifyAPIPluginRelease
export RELEASE_PROJECT_NAME=amplify-codegen-release-workflow
export DEPRECATE_PROJECT_NAME=amplify-codegen-deprecate-workflow

function triggerRelease {
triggerProjectBatch $RELEASE_ACCOUNT_PROD $RELEASE_ROLE_NAME "${RELEASE_PROFILE_NAME}Prod" $RELEASE_PROJECT_NAME "release"
Expand All @@ -20,3 +21,13 @@ function triggerTagRelease {
fi
triggerProjectBatch $RELEASE_ACCOUNT_PROD $RELEASE_ROLE_NAME "${RELEASE_PROFILE_NAME}Prod" $RELEASE_PROJECT_NAME $branch_name
}

function deprecateRelease {
DEPRECATION_MESSAGE=$1
SEARCH_FOR_RELEASE_STARTING_FROM=$2
USE_NPM_REGISTRY=$3
triggerProjectBatchWithEnvOverrides $RELEASE_ACCOUNT_PROD $RELEASE_ROLE_NAME "${RELEASE_PROFILE_NAME}Prod" $DEPRECATE_PROJECT_NAME "release" \
name=DEPRECATION_MESSAGE,value=\""$DEPRECATION_MESSAGE"\",type=PLAINTEXT \
name=SEARCH_FOR_RELEASE_STARTING_FROM,value=$SEARCH_FOR_RELEASE_STARTING_FROM,type=PLAINTEXT \
name=USE_NPM_REGISTRY,value=$USE_NPM_REGISTRY,type=PLAINTEXT
}
17 changes: 17 additions & 0 deletions scripts/cloud-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ function triggerProjectBatch {
echo "https://$REGION.console.aws.amazon.com/codesuite/codebuild/$account_number/projects/$project_name/batch/$RESULT?region=$REGION"
}

function triggerProjectBatchWithEnvOverrides {
account_number=$1
role_name=$2
profile_name=$3
project_name=$4
target_branch=$5
shift 5
authenticate $account_number $role_name $profile_name
echo AWS Account: $account_number
echo Project: $project_name
echo Target Branch: $target_branch
RESULT=$(aws codebuild start-build-batch --region=$REGION --profile="${profile_name}" --project-name $project_name --source-version=$target_branch \
--environment-variables-override name=BRANCH_NAME,value=$target_branch,type=PLAINTEXT "$@" \
--query 'buildBatch.id' --output text)
echo "https://$REGION.console.aws.amazon.com/codesuite/codebuild/$account_number/projects/$project_name/batch/$RESULT?region=$REGION"
}

function triggerProject {
account_number=$1
role_name=$2
Expand Down
59 changes: 59 additions & 0 deletions scripts/components/dist_tag_mover.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { EOL } from 'os';
import { NpmClient } from './npm_client.js';
import { releaseTagToNameAndVersion } from './release_tag_to_name_and_version';

type DistTagMoveAction = {
/**
* An NPM dist-tag
*/
distTag: string;
/**
* This is a string of the form <packageName>@<version>
*/
releaseTag: string;
};

/**
* Handles moving npm dist-tags from one package version to another
*/
export class DistTagMover {
/**
* Initialize with an npmClient
*/
constructor(private readonly npmClient: NpmClient) {}

/**
* Given a list of sourceReleaseTags and destReleaseTags,
* any npm dist-tags that are pointing to a sourceReleaseTag will be moved to point to the corresponding destReleaseTag
*/
moveDistTags = async (sourceReleaseTags: string[], destReleaseTags: string[]) => {
const moveActions: DistTagMoveAction[] = [];

for (const sourceReleaseTag of sourceReleaseTags) {
const { packageName, version: sourceVersion } = releaseTagToNameAndVersion(sourceReleaseTag);

const { 'dist-tags': distTags } = await this.npmClient.getPackageInfo(sourceReleaseTag);

Object.entries(distTags).forEach(([tagName, versionAtTag]) => {
if (versionAtTag !== sourceVersion) {
return;
}
const destReleaseTag = destReleaseTags.find(releaseTag => releaseTag.includes(packageName));
if (!destReleaseTag) {
console.warn(`No corresponding destination release tag found for ${sourceReleaseTag}. latest tag not moved.`);
} else {
moveActions.push({
releaseTag: destReleaseTag,
distTag: tagName,
});
}
});
}

for (const { distTag, releaseTag } of moveActions) {
console.log(`Moving dist tag "${distTag}" to release tag ${releaseTag}`);
await this.npmClient.setDistTag(releaseTag, distTag);
console.log(`Done!${EOL}`);
}
};
}
Loading

0 comments on commit 8285817

Please sign in to comment.