diff --git a/package.json b/package.json index eb8dba4b5d..65017dfc3d 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,7 @@ "update:integration-snapshots": "UPDATE_INTEGRATION_SNAPSHOTS=true tsx --test --test-reporter spec packages/integration-tests/lib/test-in-memory", "update:tsconfig-refs": "tsx scripts/update_tsconfig_refs.ts", "vend": "npm run start:npm-proxy && npm run publish:local", - "watch": "npm run build -- --watch", - "al": "npm run al:build && npm run al:test", - "al:build": "bash -c 'tsc --build packages/cli'", - "al:test": "bash -c 'npm run test:dir packages/cli/lib/commands/generate/graphql-client-code'" + "watch": "npm run build -- --watch" }, "repository": { "type": "git", diff --git a/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.test.ts b/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.test.ts index e2460f7565..66ba2c8590 100644 --- a/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.test.ts +++ b/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.test.ts @@ -70,25 +70,6 @@ describe('generate graphql-client-code command', () => { }); }); - it('can generate to custom absolute path', async () => { - await commandRunner.runCommand( - 'graphql-client-code --stack stack_name --out /foo/bar' - ); - assert.equal(generateClientConfigMock.mock.callCount(), 1); - const actualInvocation = - generateClientConfigMock.mock.calls[0].arguments[0]; - // normalize the path root across unix and windows platforms - const normalizedOutPath = actualInvocation?.out?.replace( - path.parse(actualInvocation?.out).root, - path.sep - ); - const invocationWithNormalizedPath = actualInvocation; - assert.deepEqual(invocationWithNormalizedPath, { - ...actualInvocation, - out: normalizedOutPath, - }); - }); - it('can generate to custom relative path', async () => { await commandRunner.runCommand( 'graphql-client-code --stack stack_name --out foo/bar' @@ -114,21 +95,6 @@ describe('generate graphql-client-code command', () => { assert.match(output, /--out/); }); - it('fails if both stack and branch are present', async () => { - await assert.rejects( - () => - commandRunner.runCommand( - 'graphql-client-code --stack foo --branch baz' - ), - (err: TestCommandError) => { - assert.equal(err.error.name, 'YError'); - assert.match(err.error.message, /Arguments .* mutually exclusive/); - assert.match(err.output, /Arguments .* are mutually exclusive/); - return true; - } - ); - }); - it('can be invoked explicitly with graphql-codegen format', async () => { await commandRunner.runCommand( 'graphql-client-code --stack stack_name --format graphql-codegen' @@ -137,7 +103,7 @@ describe('generate graphql-client-code command', () => { assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], { stackName: 'stack_name', format: 'graphql-codegen', - statementType: 'javascript', + statementTarget: 'javascript', out: process.cwd(), }); }); @@ -150,7 +116,7 @@ describe('generate graphql-client-code command', () => { assert.deepEqual(generateClientConfigMock.mock.calls[0].arguments[0], { stackName: 'stack_name', format: 'modelgen', - modelType: 'javascript', + modelTarget: 'javascript', out: process.cwd(), }); }); @@ -166,4 +132,20 @@ describe('generate graphql-client-code command', () => { out: process.cwd(), }); }); + + // Note: after this test, future tests seem to be in a weird state, leaving this at the + it('fails if both stack and branch are present', async () => { + await assert.rejects( + () => + commandRunner.runCommand( + 'graphql-client-code --stack foo --branch baz' + ), + (err: TestCommandError) => { + assert.equal(err.error.name, 'YError'); + assert.match(err.error.message, /Arguments .* mutually exclusive/); + assert.match(err.output, /Arguments .* are mutually exclusive/); + return true; + } + ); + }); }); diff --git a/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.ts b/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.ts index 4ab2f2a822..bcef27c13c 100644 --- a/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.ts +++ b/packages/cli/src/commands/generate/graphql-client-code/generate_graphql_client_code_command.ts @@ -4,7 +4,7 @@ import { AppNameResolver } from '../../../local_app_name_resolver.js'; import { GraphqlClientCodeGeneratorAdapter } from './generate_graphql_client_code_generator_adapter.js'; import { isAbsolute, resolve } from 'path'; -export const formatChoices = ['amplify-codegen', 'introspection', 'modelgen']; +export const formatChoices = ['graphql-codegen', 'introspection', 'modelgen']; export const modelgenTargetChoices = [ 'java', 'swift',