Skip to content

Commit

Permalink
Merge branch 'main' into array-enum-type
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch committed Sep 26, 2023
2 parents 290b76d + 1e484af commit dfa0bc8
Show file tree
Hide file tree
Showing 49 changed files with 2,868 additions and 939 deletions.
9 changes: 5 additions & 4 deletions .codebuild/e2e_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,23 @@ batch:
depend-on:
- publish_to_local_registry
- identifier: >-
build_app_ts_uninitialized_project_modelgen_android_uninitialized_project_modelgen_flutter_uninitialized_project_modelgen_ios
build_app_ts_uninitialized_project_codegen_js_uninitialized_project_modelgen_android_uninitialized_project_modelgen_flutter
buildspec: .codebuild/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
TEST_SUITE: >-
src/__tests__/build-app-ts.test.ts|src/__tests__/uninitialized-project-modelgen-android.test.ts|src/__tests__/uninitialized-project-modelgen-flutter.test.ts|src/__tests__/uninitialized-project-modelgen-ios.test.ts
src/__tests__/build-app-ts.test.ts|src/__tests__/uninitialized-project-codegen-js.test.ts|src/__tests__/uninitialized-project-modelgen-android.test.ts|src/__tests__/uninitialized-project-modelgen-flutter.test.ts
CLI_REGION: ap-southeast-1
depend-on:
- publish_to_local_registry
- identifier: uninitialized_project_modelgen_js
- identifier: uninitialized_project_modelgen_ios_uninitialized_project_modelgen_js
buildspec: .codebuild/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
TEST_SUITE: src/__tests__/uninitialized-project-modelgen-js.test.ts
TEST_SUITE: >-
src/__tests__/uninitialized-project-modelgen-ios.test.ts|src/__tests__/uninitialized-project-modelgen-js.test.ts
CLI_REGION: ap-southeast-2
depend-on:
- publish_to_local_registry
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module.exports = {
'@typescript-eslint/interface-name-prefix': 'off',
'no-throw-literal': 'off',
'react/static-property-placement': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-extraneous-dependencies': ['error', {devDependencies: true}],
'spaced-comment': 'off',
'@typescript-eslint/no-array-constructor': 'off',
'prefer-rest-params': 'off',
Expand Down
7 changes: 7 additions & 0 deletions packages/amplify-codegen-e2e-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.6.0](https://github.com/aws-amplify/amplify-codegen/compare/@aws-amplify/[email protected]...@aws-amplify/[email protected]) (2023-09-19)

### Features

- merge noinit-modelgen into main to support executing amplify codegen models without an initialized amplify app ([#698](https://github.com/aws-amplify/amplify-codegen/issues/698)) ([d9ce4ea](https://github.com/aws-amplify/amplify-codegen/commit/d9ce4eab58ec4ac72fc737461c11783562d96167)), closes [#686](https://github.com/aws-amplify/amplify-codegen/issues/686) [#693](https://github.com/aws-amplify/amplify-codegen/issues/693) [#694](https://github.com/aws-amplify/amplify-codegen/issues/694) [#696](https://github.com/aws-amplify/amplify-codegen/issues/696)
- support running codegen without an initialized amplify backend set up locally. ([#702](https://github.com/aws-amplify/amplify-codegen/issues/702)) ([8279f35](https://github.com/aws-amplify/amplify-codegen/commit/8279f35d84cb10f0df3c4fb0f4a141f86dbc3e60)), closes [#683](https://github.com/aws-amplify/amplify-codegen/issues/683) [#684](https://github.com/aws-amplify/amplify-codegen/issues/684) [#689](https://github.com/aws-amplify/amplify-codegen/issues/689) [#704](https://github.com/aws-amplify/amplify-codegen/issues/704) [#705](https://github.com/aws-amplify/amplify-codegen/issues/705) [#706](https://github.com/aws-amplify/amplify-codegen/issues/706)

## [1.5.4](https://github.com/aws-amplify/amplify-codegen/compare/@aws-amplify/[email protected]...@aws-amplify/[email protected]) (2023-08-15)

**Note:** Version bump only for package @aws-amplify/amplify-codegen-e2e-core
Expand Down
6 changes: 5 additions & 1 deletion packages/amplify-codegen-e2e-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/amplify-codegen-e2e-core",
"version": "1.5.4",
"version": "1.6.0",
"description": "",
"repository": {
"type": "git",
Expand All @@ -22,10 +22,14 @@
"clean": "rimraf ./lib"
},
"dependencies": {
"aws-sdk": "^2.1465.0",
"chalk": "^3.0.0",
"dotenv": "^8.6.0",
"execa": "^4.1.0",
"fs-extra": "^8.1.0",
"glob": "^10.3.9",
"ini": "^3.0.1",
"jest-circus": "^27.5.1",
"jest-environment-node": "^26.6.2",
"lodash": "^4.17.19",
"node-pty": "beta",
Expand Down
102 changes: 84 additions & 18 deletions packages/amplify-codegen-e2e-core/src/categories/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,40 @@ export const generateModelsWithOptions = (cwd: string, options: Record<string, a
});
});

export function generateStatementsAndTypes(cwd: string) : Promise<void> {
export function generateStatementsAndTypes(cwd: string, errorMessage?: string) : Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['codegen'], { cwd, stripColors: true })
const chain = spawn(getCLIPath(), ['codegen'], { cwd, stripColors: true })

if (errorMessage) {
chain.wait(errorMessage);
}

return chain.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
})
});
}

export function generateStatements(cwd: string) : Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['codegen', 'statements'], { cwd, stripColors: true })
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
})
});
}

export function generateTypes(cwd: string) : Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['codegen', 'types'], { cwd, stripColors: true })
.run((err: Error) => {
if (!err) {
resolve();
Expand All @@ -46,7 +77,10 @@ export function generateStatementsAndTypes(cwd: string) : Promise<void> {
// CLI workflow to add codegen to Amplify project
export function addCodegen(cwd: string, settings: any = {}): Promise<void> {
return new Promise((resolve, reject) => {
const chain = spawn(getCLIPath(), ['codegen', 'add'], { cwd, stripColors: true });
const params = settings.params
? ['codegen', 'add', ...settings.params]
: ['codegen', 'add'];
const chain = spawn(getCLIPath(), params, { cwd, stripColors: true });
if (settings.isAPINotAdded) {
chain.wait("There are no GraphQL APIs available.");
chain.wait("Add by running $amplify api add");
Expand Down Expand Up @@ -166,22 +200,26 @@ export function generateModelIntrospection(cwd: string, settings: { outputDir?:
}

// CLI workflow to add codegen to non-Amplify JS project
export function addCodegenNonAmplifyJS(cwd: string): Promise<void> {
export function addCodegenNonAmplifyJS(cwd: string, params: Array<string>, initialFailureMessage?: string): Promise<void> {
return new Promise((resolve, reject) => {
const cmdOptions = ['codegen', 'add', '--apiId', 'mockapiid'];
const chain = spawn(getCLIPath(), cmdOptions, { cwd, stripColors: true });
chain
.wait("Choose the type of app that you're building")
.sendCarriageReturn()
.wait('What javascript framework are you using')
.sendCarriageReturn()
.wait('Choose the code generation language target').sendCarriageReturn()
.wait('Enter the file name pattern of graphql queries, mutations and subscriptions')
.sendCarriageReturn()
.wait('Do you want to generate/update all possible GraphQL operations')
.sendLine('y')
.wait('Enter maximum statement depth [increase from default if your schema is deeply')
.sendCarriageReturn();
const chain = spawn(getCLIPath(), ['codegen', 'add', ...params], { cwd, stripColors: true });

if (initialFailureMessage) {
chain.wait(initialFailureMessage)
} else {
chain
.wait("Choose the type of app that you're building")
.sendCarriageReturn()
.wait('What javascript framework are you using')
.sendCarriageReturn()
.wait('Choose the code generation language target').sendCarriageReturn()
.wait('Enter the file name pattern of graphql queries, mutations and subscriptions')
.sendCarriageReturn()
.wait('Do you want to generate/update all possible GraphQL operations')
.sendLine('y')
.wait('Enter maximum statement depth [increase from default if your schema is deeply')
.sendCarriageReturn();
}

chain.run((err: Error) => {
if (!err) {
Expand All @@ -192,3 +230,31 @@ export function addCodegenNonAmplifyJS(cwd: string): Promise<void> {
});
});
}

export function addCodegenNonAmplifyTS(cwd: string, params: Array<string>, initialFailureMessage?: string): Promise<void> {
return new Promise((resolve, reject) => {
const chain = spawn(getCLIPath(), ['codegen', 'add', ...params], { cwd, stripColors: true });

if (initialFailureMessage) {
chain.wait(initialFailureMessage)
} else {
chain
.wait("Choose the type of app that you're building").sendCarriageReturn()
.wait('What javascript framework are you using').sendCarriageReturn()
.wait('Choose the code generation language target').sendKeyDown().sendCarriageReturn()
.wait('Enter the file name pattern of graphql queries, mutations and subscriptions').sendCarriageReturn()
.wait('Do you want to generate/update all possible GraphQL operations').sendLine('y')
.wait('Enter maximum statement depth [increase from default if your schema is deeply').sendCarriageReturn()
.wait('Enter the file name for the generated code').sendCarriageReturn()
.wait('Do you want to generate code for your newly created GraphQL API').sendCarriageReturn();
}

chain.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
});
}
7 changes: 7 additions & 0 deletions packages/amplify-codegen-e2e-tests/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.44.0](https://github.com/aws-amplify/amplify-codegen/compare/@aws-amplify/[email protected]...@aws-amplify/[email protected]) (2023-09-19)

### Features

- merge noinit-modelgen into main to support executing amplify codegen models without an initialized amplify app ([#698](https://github.com/aws-amplify/amplify-codegen/issues/698)) ([d9ce4ea](https://github.com/aws-amplify/amplify-codegen/commit/d9ce4eab58ec4ac72fc737461c11783562d96167)), closes [#686](https://github.com/aws-amplify/amplify-codegen/issues/686) [#693](https://github.com/aws-amplify/amplify-codegen/issues/693) [#694](https://github.com/aws-amplify/amplify-codegen/issues/694) [#696](https://github.com/aws-amplify/amplify-codegen/issues/696)
- support running codegen without an initialized amplify backend set up locally. ([#702](https://github.com/aws-amplify/amplify-codegen/issues/702)) ([8279f35](https://github.com/aws-amplify/amplify-codegen/commit/8279f35d84cb10f0df3c4fb0f4a141f86dbc3e60)), closes [#683](https://github.com/aws-amplify/amplify-codegen/issues/683) [#684](https://github.com/aws-amplify/amplify-codegen/issues/684) [#689](https://github.com/aws-amplify/amplify-codegen/issues/689) [#704](https://github.com/aws-amplify/amplify-codegen/issues/704) [#705](https://github.com/aws-amplify/amplify-codegen/issues/705) [#706](https://github.com/aws-amplify/amplify-codegen/issues/706)

## [2.43.4](https://github.com/aws-amplify/amplify-codegen/compare/@aws-amplify/[email protected]...@aws-amplify/[email protected]) (2023-08-15)

**Note:** Version bump only for package @aws-amplify/amplify-codegen-e2e-tests
Expand Down
7 changes: 5 additions & 2 deletions packages/amplify-codegen-e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/amplify-codegen-e2e-tests",
"version": "2.43.4",
"version": "2.44.0",
"description": "",
"repository": {
"type": "git",
Expand All @@ -22,8 +22,9 @@
"clean-e2e-resources": "ts-node ./src/cleanup-e2e-resources.ts"
},
"dependencies": {
"@aws-amplify/amplify-codegen-e2e-core": "1.5.4",
"@aws-amplify/amplify-codegen-e2e-core": "1.6.0",
"@aws-amplify/graphql-schema-test-library": "^1.1.18",
"amazon-cognito-identity-js": "^6.3.6",
"aws-amplify": "^5.3.3",
"aws-appsync": "^4.1.9",
"aws-sdk": "^2.1413.0",
Expand All @@ -33,7 +34,9 @@
"graphql-tag": "^2.10.1",
"js-yaml": "^4.0.0",
"lodash": "^4.17.19",
"node-fetch": "^3.3.2",
"uuid": "^3.4.0",
"ws": "^8.14.2",
"yargs": "^15.1.0"
},
"devDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions packages/amplify-codegen-e2e-tests/schemas/sdl/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type Query {
echo: String
}

type Mutation {
mymutation: String
}

type Subscription {
mysub: String
}
Loading

0 comments on commit dfa0bc8

Please sign in to comment.