Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
fix(nx-mesh): sdk preset asks for sdk name
Browse files Browse the repository at this point in the history
  • Loading branch information
domjtalbot committed Dec 21, 2022
1 parent dea3c22 commit ff9b664
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changeset/strange-stingrays-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'nx-mesh': patch
---

Fix preset SDK name

The SDK preset will ask for an SDK name, rather than using the org name passed by Nx.
3 changes: 2 additions & 1 deletion libs/nx-mesh/src/generators/preset/preset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ describe('generators/preset', () => {

it('should create a workspace with the graphql-mesh sdk preset', async () => {
await presetGenerator(tree, {
name: 'hello-world',
name: 'myorg',
sdkName: 'hello-world',
compiler: 'tsc',
});

Expand Down
4 changes: 3 additions & 1 deletion libs/nx-mesh/src/generators/preset/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export async function presetGenerator(
tree: Tree,
options: PresetGeneratorSchema
) {
return await sdkGenerator(tree, options);
const { sdkName, ...config } = options;

return await sdkGenerator(tree, { ...config, name: sdkName });
}

export const presetSchematic = convertNxGenerator(presetGenerator);
Expand Down
4 changes: 3 additions & 1 deletion libs/nx-mesh/src/generators/preset/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { SdkGeneratorSchema } from '../sdk/schema';

export type PresetGeneratorSchema = SdkGeneratorSchema;
export interface PresetGeneratorSchema extends SdkGeneratorSchema {
sdkName: string;
}
7 changes: 6 additions & 1 deletion libs/nx-mesh/src/generators/preset/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
},
"x-prompt": "What name would you like to use?"
},
"sdkName": {
"type": "string",
"description": "What would you like to name the SDK?",
"x-prompt": "What would you like to name the SDK?"
},
"directory": {
"description": "The directory of the new sdk.",
"type": "string",
Expand Down Expand Up @@ -151,5 +156,5 @@
"default": false
}
},
"required": ["name"]
"required": ["name", "sdkName"]
}

0 comments on commit ff9b664

Please sign in to comment.