This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e5c42c
commit 57a2e32
Showing
7 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { convertNxGenerator } from '@nrwl/devkit'; | ||
|
||
import { presetGenerator } from './preset'; | ||
|
||
export const presetSchematic = convertNxGenerator(presetGenerator); | ||
|
||
export { presetGenerator } from './preset'; | ||
|
||
export default presetGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Tree } from '@nrwl/devkit'; | ||
|
||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { readProjectConfiguration } from '@nrwl/devkit'; | ||
|
||
import { presetGenerator } from './preset'; | ||
|
||
describe('generators/preset', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
|
||
tree.write( | ||
'workspace.json', | ||
JSON.stringify({ | ||
version: 2, | ||
projects: {}, | ||
}) | ||
); | ||
}); | ||
|
||
it('should create a workspace with the graphql-mesh sdk preset', async () => { | ||
await presetGenerator(tree, { | ||
name: 'hello-world', | ||
compiler: 'tsc', | ||
}); | ||
|
||
const config = readProjectConfiguration(tree, 'hello-world'); | ||
|
||
expect(config).toBeDefined(); | ||
expect(tree.exists('/libs/hello-world/.meshrc.yml')).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Tree } from '@nrwl/devkit'; | ||
|
||
import type { PresetGeneratorSchema } from './schema'; | ||
|
||
import { convertNxGenerator } from '@nrwl/devkit'; | ||
|
||
import { sdkGenerator } from '../sdk'; | ||
|
||
export async function presetGenerator( | ||
tree: Tree, | ||
options: PresetGeneratorSchema | ||
) { | ||
return await sdkGenerator(tree, options); | ||
} | ||
|
||
export const presetSchematic = convertNxGenerator(presetGenerator); | ||
|
||
export default presetGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { SdkGeneratorSchema } from '../sdk/schema'; | ||
|
||
export type PresetGeneratorSchema = SdkGeneratorSchema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "Preset", | ||
"title": "Create a GraphQL Mesh SDK in an empty workspace.", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use?" | ||
}, | ||
"directory": { | ||
"description": "The directory of the new sdk.", | ||
"type": "string", | ||
"alias": "d" | ||
}, | ||
"meshConfig": { | ||
"description": "The file extension to use for the Mesh config", | ||
"type": "string", | ||
"default": "yml", | ||
"alias": "mc", | ||
"x-prompt": { | ||
"message": "Which config format would you like to use?", | ||
"type": "list", | ||
"items": [ | ||
{ "value": "json", "label": "JSON" }, | ||
{ | ||
"value": "yml", | ||
"label": "YAML" | ||
}, | ||
{ | ||
"value": "js", | ||
"label": "JavaScript" | ||
}, | ||
{ | ||
"value": "cjs", | ||
"label": "Common JS" | ||
} | ||
] | ||
} | ||
}, | ||
"example": { | ||
"description": "Which example project would you like to start with?", | ||
"type": "string", | ||
"default": "star-wars-api", | ||
"x-prompt": { | ||
"message": "Which example project would you like to start with?", | ||
"type": "list", | ||
"items": [ | ||
{ "value": "country-info", "label": "Country Info (SOAP)" }, | ||
{ "value": "fake-api", "label": "Fake API (JSON Schema)" }, | ||
{ "value": "javascript-wiki", "label": "JavaScript Wiki (OpenAPI)" }, | ||
{ "value": "movies", "label": "Movies (Neo4j)" }, | ||
{ "value": "rfam", "label": "RFam (MySQL)" }, | ||
{ "value": "stackexchange", "label": "StackExchange (OpenAPI)" }, | ||
{ "value": "star-wars-api", "label": "Star Wars API (GraphQL)" }, | ||
{ "value": "trippin", "label": "Trip Pin (odata)" } | ||
] | ||
} | ||
}, | ||
"codegen": { | ||
"description": "Use `graphql-codegen` to generate custom files from the GraphQL Mesh schema.", | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"simpleModuleName": { | ||
"description": "Keep the module name simple (when using `--directory`).", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"linter": { | ||
"description": "The tool to use for running lint checks.", | ||
"type": "string", | ||
"enum": ["eslint", "tslint"], | ||
"default": "eslint" | ||
}, | ||
"unitTestRunner": { | ||
"type": "string", | ||
"enum": ["jest", "none"], | ||
"description": "Test runner to use for unit tests.", | ||
"default": "jest" | ||
}, | ||
"tags": { | ||
"type": "string", | ||
"description": "Add tags to the library (used for linting).", | ||
"alias": "t" | ||
}, | ||
"skipFormat": { | ||
"description": "Skip formatting files.", | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"skipTsConfig": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Do not update `tsconfig.base.json` for development experience." | ||
}, | ||
"compiler": { | ||
"type": "string", | ||
"enum": ["tsc", "swc"], | ||
"default": "tsc", | ||
"description": "The compiler used by the build and test targets." | ||
}, | ||
"importPath": { | ||
"type": "string", | ||
"description": "The library name used to import it, like `@myorg/my-awesome-lib`. Must be a valid npm name." | ||
}, | ||
"rootDir": { | ||
"type": "string", | ||
"description": "Sets the `rootDir` for TypeScript compilation. When not defined, it uses the project's root property, or `srcRootForCompilationRoot` if it is defined." | ||
}, | ||
"testEnvironment": { | ||
"type": "string", | ||
"enum": ["jsdom", "node"], | ||
"description": "The test environment to use if `unitTestRunner` is set to `jest`.", | ||
"default": "jsdom" | ||
}, | ||
"babelJest": { | ||
"type": "boolean", | ||
"description": "Use `babel` instead of `ts-jest`.", | ||
"default": false | ||
}, | ||
"pascalCaseFiles": { | ||
"type": "boolean", | ||
"description": "Use pascal case file names.", | ||
"alias": "P", | ||
"default": false | ||
}, | ||
"js": { | ||
"type": "boolean", | ||
"description": "Generate JavaScript files rather than TypeScript files.", | ||
"default": false | ||
}, | ||
"strict": { | ||
"type": "boolean", | ||
"description": "Whether to enable tsconfig strict mode or not.", | ||
"default": false | ||
}, | ||
"standaloneConfig": { | ||
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.", | ||
"type": "boolean" | ||
}, | ||
"setParserOptionsProject": { | ||
"type": "boolean", | ||
"description": "Whether or not to configure the ESLint `parserOptions.project`. We do not do this by default for lint performance reasons.", | ||
"default": false | ||
} | ||
}, | ||
"required": ["name"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { convertNxGenerator } from '@nrwl/devkit'; | ||
|
||
import { sdkGenerator } from './sdk'; | ||
|
||
export const sdkSchematic = convertNxGenerator(sdkGenerator); | ||
|
||
export { sdkGenerator } from './sdk'; | ||
|
||
export default sdkGenerator; |