Skip to content

Commit 27bcc97

Browse files
JshhhhJustin Shih
andauthored
fix(form-generator): pass v6 config to utils file generator (#1011)
Co-authored-by: Justin Shih <[email protected]>
1 parent 8fd5c5c commit 27bcc97

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/form-generator': minor
3+
---
4+
5+
Fix utils file generator to generate aws-amplify v6 imports

packages/form-generator/src/local_codegen_graphql_form_generator.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,25 @@ void describe('LocalCodegenGraphqlFormGenerator', () => {
6060
);
6161
const output = await l.generateForms();
6262
const fsMock = mock.method(fs, 'open');
63+
const writeFileMock = mock.fn();
6364
fsMock.mock.mockImplementation(async () => ({
64-
writeFile: async () => undefined,
65+
writeFile: writeFileMock,
6566
stat: async () => ({}),
6667
close: async () => undefined,
6768
}));
6869
const mockLog = mock.fn();
6970
await output.writeToDirectory('./', (message) => mockLog(message));
7071
const writeArgs = fsMock.mock.calls.flatMap((c) => c.arguments[0]);
72+
const writeFileArgs = writeFileMock.mock.calls.flatMap(
73+
(c) => c.arguments[0]
74+
);
75+
76+
assert(
77+
writeFileArgs.some((fileContent) =>
78+
fileContent.includes('import { signOut } from "aws-amplify/auth')
79+
)
80+
);
81+
7182
const utilFSWriteArgs = writeArgs.filter((e) =>
7283
/utils\.[jt]s[x]?/.test(e.toString())
7384
);

packages/form-generator/src/local_codegen_graphql_form_generator.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,7 @@ export class LocalGraphqlFormGenerator implements GraphqlFormGenerator {
271271
};
272272

273273
private createUtilFile = (utils: UtilTemplateType[]) => {
274-
const renderer = new ReactUtilsStudioTemplateRenderer(
275-
utils,
276-
LocalGraphqlFormGenerator.defaultConfig
277-
);
274+
const renderer = new ReactUtilsStudioTemplateRenderer(utils, this.config);
278275
const { componentText } = renderer.renderComponentInternal();
279276
return {
280277
componentText,

0 commit comments

Comments
 (0)