]?: E extends 'debug'
18 | ? '0' | '1'
19 | : string;
20 | };
21 |
22 | /**
23 | * Get a list of Env variables that can be passed to the
24 | * GraphQL Mesh CLI.
25 | */
26 | export const getCliEnv = (options: Env): CliEnv => {
27 | const CliEnv: CliEnv = {};
28 |
29 | (Object.keys(options) as (keyof Env)[]).forEach((key) => {
30 | const value = options[key];
31 | const cliKey = key.toUpperCase() as keyof CliEnv;
32 |
33 | if (key === 'debug' && value !== undefined) {
34 | CliEnv[cliKey] = (+value).toString() as typeof CliEnv['DEBUG'];
35 | }
36 | });
37 |
38 | return CliEnv;
39 | };
40 |
--------------------------------------------------------------------------------
/packages/nx-mesh/src/utils/mesh-cli/index.ts:
--------------------------------------------------------------------------------
1 | export * from './arguments';
2 | export * from './cli';
3 | export * from './commands';
4 | export * from './env';
5 |
--------------------------------------------------------------------------------
/packages/nx-mesh/src/utils/run-tasks-in-serial/index.ts:
--------------------------------------------------------------------------------
1 | export * from './run-tasks-in-serial';
2 |
--------------------------------------------------------------------------------
/packages/nx-mesh/src/utils/run-tasks-in-serial/run-tasks-in-serial.ts:
--------------------------------------------------------------------------------
1 | import type { GeneratorCallback } from '@nrwl/devkit';
2 |
3 | /**
4 | * Run Generator async tasks in priority order.
5 | *
6 | * @param tasks - An array of generator tasks, listed in priority order.
7 | * @returns
8 | */
9 | export const runTasksInSerial =
10 | (...tasks: GeneratorCallback[]): GeneratorCallback =>
11 | async () => {
12 | for (const task of tasks) {
13 | if (task instanceof Promise) {
14 | await task();
15 | } else {
16 | task();
17 | }
18 | }
19 | };
20 |
21 | export type { GeneratorCallback } from '@nrwl/devkit';
22 |
--------------------------------------------------------------------------------
/packages/nx-mesh/src/utils/typescript.ts:
--------------------------------------------------------------------------------
1 | import type { Tree } from '@nrwl/devkit';
2 |
3 | import { offsetFromRoot } from '@nrwl/devkit';
4 |
5 | export function getRootTsConfigPathInTree(tree: Tree): string | null {
6 | for (const path of ['tsconfig.base.json', 'tsconfig.json']) {
7 | if (tree.exists(path)) {
8 | return path;
9 | }
10 | }
11 |
12 | return 'tsconfig.base.json';
13 | }
14 |
15 | export const getRelativePathToRootTsConfig = (
16 | tree: Tree,
17 | targetPath: string
18 | ): string => offsetFromRoot(targetPath) + getRootTsConfigPathInTree(tree);
19 |
--------------------------------------------------------------------------------
/packages/nx-mesh/src/utils/versions.ts:
--------------------------------------------------------------------------------
1 | import { MeshPackages } from './mesh-packages';
2 |
3 | export type MeshPackageVersions = {
4 | [P in MeshPackages]?: Record;
5 | } & {
6 | '@graphql-typed-document-node/core': {
7 | '@graphql-typed-document-node/core': string;
8 | };
9 | graphql: {
10 | graphql: string;
11 | };
12 | };
13 |
14 | export const versions: MeshPackageVersions = {
15 | '@graphql-typed-document-node/core': {
16 | '@graphql-typed-document-node/core': '^3.2.0',
17 | },
18 | '@graphql-codegen/cli': {
19 | '@graphql-codegen/cli': '^3.2.2',
20 | },
21 | '@graphql-codegen/client-preset': {
22 | '@graphql-codegen/client-preset': '^2.1.1',
23 | },
24 | '@graphql-mesh/cli': {
25 | '@graphql-mesh/cli': '^0.82.34',
26 | },
27 | '@graphql-mesh/graphql': {
28 | '@graphql-mesh/graphql': '^1.0.0',
29 | },
30 | '@graphql-mesh/json-schema': {
31 | '@graphql-mesh/json-schema': '^1.0.0',
32 | },
33 | '@graphql-mesh/mysql': {
34 | '@graphql-mesh/mysql': '^1.0.0',
35 | },
36 | '@graphql-mesh/neo4j': {
37 | '@graphql-mesh/neo4j': '^1.0.0',
38 | },
39 | '@graphql-mesh/new-openapi': { '@graphql-mesh/new-openapi': '^0.8.2' },
40 | '@graphql-mesh/odata': { '@graphql-mesh/odata': '^1.0.0' },
41 | '@graphql-mesh/openapi': { '@graphql-mesh/openapi': '^1.0.0' },
42 | '@graphql-mesh/plugin-mock': {
43 | '@graphql-mesh/plugin-mock': '^1.0.0',
44 | },
45 | '@graphql-mesh/plugin-snapshot': {
46 | '@graphql-mesh/plugin-snapshot': '^1.0.0',
47 | },
48 | '@graphql-mesh/runtime': { '@graphql-mesh/runtime': '^1.0.0' },
49 | '@graphql-mesh/soap': { '@graphql-mesh/soap': '^1.0.0' },
50 | // '@graphql-mesh/utils': { '@graphql-mesh/utils': '0.42.6' },
51 | graphql: { graphql: '^16.6.0' },
52 | };
53 |
--------------------------------------------------------------------------------
/packages/nx-mesh/src/utils/watcher/index.ts:
--------------------------------------------------------------------------------
1 | export * from './watcher';
2 |
--------------------------------------------------------------------------------
/packages/nx-mesh/src/utils/watcher/watcher.ts:
--------------------------------------------------------------------------------
1 | import type { WatcherOptions } from 'watchpack';
2 |
3 | import { logger } from '@nrwl/devkit';
4 | import Watchpack from 'watchpack';
5 |
6 | export type WatchFunc = () => Promise;
7 |
8 | export type Options = Omit & {
9 | dir: string;
10 | watch?: boolean;
11 | };
12 |
13 | export async function watcher(func: WatchFunc, options: Options) {
14 | const { dir, watch, ...watcherOptions } = options;
15 |
16 | if (watch === true) {
17 | const wp = new Watchpack({
18 | ...watcherOptions,
19 | ignored: [
20 | '.eslintrc.json',
21 | '.swcrc',
22 | '**/.codegen',
23 | '**/.git',
24 | '**/.mesh',
25 | '**/node_modules',
26 | 'jest.config.ts',
27 | 'project.json',
28 | ],
29 | });
30 |
31 | wp.watch({ directories: [dir], startTime: 0 });
32 |
33 | wp.on('aggregated', async () => {
34 | await func();
35 |
36 | logger.info('');
37 | logger.info('');
38 | logger.info('Watching for changes...');
39 | });
40 |
41 | await new Promise<{ success: boolean }>(() => {
42 | // This Promise intentionally never resolves, leaving the process running.
43 | });
44 | } else {
45 | await func();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/packages/nx-mesh/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "compilerOptions": {
4 | "module": "commonjs"
5 | },
6 | "files": [],
7 | "include": [],
8 | "references": [
9 | {
10 | "path": "./tsconfig.lib.json"
11 | },
12 | {
13 | "path": "./tsconfig.spec.json"
14 | }
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/nx-mesh/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "declaration": true,
6 | "types": ["node"]
7 | },
8 | "include": ["**/*.ts"],
9 | "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/packages/nx-mesh/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "module": "commonjs",
6 | "types": ["jest", "node"]
7 | },
8 | "include": [
9 | "jest.config.ts",
10 | "**/*.test.ts",
11 | "**/*.spec.ts",
12 | "**/*.d.ts",
13 | "src/executors/build-gateway/schema.ts",
14 | "src/executors/build/schema.ts",
15 | "src/executors/build-swc/schema.ts",
16 | "src/executors/validate/schema.ts",
17 | "src/generators/sdk/schema.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - packages/*
3 |
--------------------------------------------------------------------------------
/socket.yml:
--------------------------------------------------------------------------------
1 | issues:
2 | binScriptConfusion: false
3 | # enable/disable GitHub app pull request alert checks
4 | # pullRequestAlertsEnabled: true
5 |
6 | # enable/disable Github app project report checks
7 | # projectReportsEnabled: true
8 |
--------------------------------------------------------------------------------
/sonar-project.properties:
--------------------------------------------------------------------------------
1 | sonar.organization=domjtalbot
2 | sonar.projectKey=domjtalbot_nx-mesh
3 |
4 | # compile-swc.ts & swc.impl.ts are both modified files
5 | # from the Nx source code.
6 | sonar.exclusions=**/example/*,./packages/nx-mesh/src/executors/build-swc/swc-executor/compile-swc.ts,./packages/nx-mesh/src/executors/build-swc/swc-executor/swc.impl.ts
7 | sonar.sources=packages/nx-mesh
8 |
9 | sonar.eslint.reportPaths=./reports/packages/nx-mesh/lint.json
10 | sonar.javascript.lcov.reportPaths=./coverage/packages/nx-mesh/lcov.info
11 | sonar.test.inclusions=packages/nx-mesh/**/*.spec.*
12 |
--------------------------------------------------------------------------------
/tools/tsconfig.tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.base.json",
3 | "compilerOptions": {
4 | "outDir": "../dist/out-tsc/tools",
5 | "rootDir": ".",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": ["node"],
9 | "importHelpers": false
10 | },
11 | "include": ["**/*.ts"]
12 | }
13 |
--------------------------------------------------------------------------------
/vercel.json:
--------------------------------------------------------------------------------
1 | {
2 | "buildCommand": "pnpm nx run examples-sdk-nextjs:build",
3 | "github": {
4 | "enabled": false
5 | },
6 | "installCommand": "mv .npmrc .npmrc-dev && mv .npmrc-vercel .npmrc && pnpm install",
7 | "outputDirectory": "dist/examples/sdk-nextjs/.next"
8 | }
9 |
--------------------------------------------------------------------------------