@trackunit/react-graphql-tools 0.0.84-alpha-2936c016d71.0 → 0.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,17 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
- ## [0.0.84-alpha-2936c016d71.0](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.83...react-graphql-tools/0.0.84-alpha-2936c016d71.0) (2024-07-26)
5
+ ## [0.0.86](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.85...react-graphql-tools/0.0.86) (2024-08-12)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `test-setup` updated to version `0.0.85`
10
+ ## [0.0.85](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.84...react-graphql-tools/0.0.85) (2024-08-12)
11
+
12
+ ### Dependency Updates
13
+
14
+ * `test-setup` updated to version `0.0.84`
15
+ ## [0.0.84](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.83...react-graphql-tools/0.0.84) (2024-08-09)
6
16
 
7
17
  ## [0.0.83](https://github.com/Trackunit/manager/compare/react-graphql-tools/0.0.82...react-graphql-tools/0.0.83) (2024-07-09)
8
18
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@trackunit/react-graphql-tools",
3
- "version": "0.0.84-alpha-2936c016d71.0",
4
- "main": "./src/index.js",
3
+ "version": "0.0.86",
4
+ "main": "src/index.js",
5
5
  "executors": "./executors.json",
6
6
  "generators": "./generators.json",
7
7
  "repository": "https://github.com/Trackunit/manager",
@@ -10,7 +10,7 @@
10
10
  "node": ">=20.x"
11
11
  },
12
12
  "dependencies": {
13
- "@nx/devkit": "18.3.3",
13
+ "@nx/devkit": "19.5.6",
14
14
  "@graphql-codegen/cli": "^5.0.0",
15
15
  "@graphql-codegen/client-preset": "^4.1.0",
16
16
  "prettier": "3.3.2",
@@ -19,5 +19,6 @@
19
19
  "win-ca": "^3.5.1",
20
20
  "tslib": "^2.6.2"
21
21
  },
22
- "type": "commonjs"
23
- }
22
+ "type": "commonjs",
23
+ "types": "./src/index.d.ts"
24
+ }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CreateGraphqlHooks = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const fs_1 = require("fs");
6
5
  const path_1 = require("path");
7
6
  require("win-ca");
@@ -14,7 +13,7 @@ const scrubFile_1 = require("./scrubFile");
14
13
  * @param context The execution context for this executor
15
14
  * @returns {Promise<{ success: number; }>} success when finished
16
15
  */
17
- const CreateGraphqlHooks = (_unused, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
16
+ const CreateGraphqlHooks = async (_unused, context) => {
18
17
  var _a;
19
18
  const nxRoot = `${context.root}`;
20
19
  if (!context.projectsConfigurations) {
@@ -47,7 +46,7 @@ const config: CodegenConfig = {
47
46
  export default config;
48
47
  `);
49
48
  }
50
- const result = yield (0, generateHooks_1.generateHooks)({
49
+ const result = await (0, generateHooks_1.generateHooks)({
51
50
  nxRoot: context.root,
52
51
  codeGenFilePath,
53
52
  isVerbose: context.isVerbose,
@@ -60,11 +59,11 @@ export default config;
60
59
  // eslint-disable-next-line no-console
61
60
  console.log("Scrubbing file: ", pathToGenerateFile);
62
61
  }
63
- yield (0, scrubFile_1.scrubFile)(pathToGenerateFile, nxRoot, context.isVerbose);
62
+ await (0, scrubFile_1.scrubFile)(pathToGenerateFile, nxRoot, context.isVerbose);
64
63
  }
65
64
  }
66
65
  return { success: result };
67
- });
66
+ };
68
67
  exports.CreateGraphqlHooks = CreateGraphqlHooks;
69
68
  exports.default = exports.CreateGraphqlHooks;
70
69
  //# sourceMappingURL=executor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/executor.ts"],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WAAW;;;;;;;;;CAS9D,CAAC,CAAC;IACD,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAa,EAAC;QACjC,MAAM,EAAE,OAAO,CAAC,IAAI;QACpB,eAAe;QACf,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,YAAY;KACb,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QACtC,MAAM,kBAAkB,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;QAC9F,IAAI,IAAA,eAAU,EAAC,kBAAkB,CAAC,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACtB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;YACtD,CAAC;YACD,MAAM,IAAA,qBAAS,EAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC,CAAA,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B;AAEF,kBAAe,0BAAkB,CAAC","sourcesContent":["import { ExecutorContext } from \"@nx/devkit\";\nimport { existsSync } from \"fs\";\nimport { join } from \"path\";\nimport \"win-ca\";\nimport { generateHooks } from \"./generateHooks\";\nimport { scrubFile } from \"./scrubFile\";\n\n/**\n * This executor generates react hooks for all graphql files.\n *\n * @param _unused unused props from nx\n * @param context The execution context for this executor\n * @returns {Promise<{ success: number; }>} success when finished\n */\nexport const CreateGraphqlHooks = async (_unused: unknown, context: ExecutorContext) => {\n const nxRoot = `${context.root}`;\n if (!context.projectsConfigurations) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n if (!context.projectName) {\n throw new Error(\"context projectName is required\");\n }\n\n const libRoot = context.projectsConfigurations.projects[context.projectName]?.root;\n\n if (!libRoot) {\n throw new Error(\"Missing library root\");\n }\n\n const fullLibRoot = join(nxRoot, libRoot);\n const tsConfigPath = existsSync(join(fullLibRoot, \"tsconfig.lib.json\"))\n ? join(fullLibRoot, \"tsconfig.lib.json\")\n : join(fullLibRoot, \"tsconfig.app.json\");\n\n if (!tsConfigPath) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n\n const codeGenFilePath = join(fullLibRoot, \"codegen.ts\");\n if (!existsSync(codeGenFilePath)) {\n throw new Error(`codegen.ts file not found in ${fullLibRoot} please add this file and run again to generate hooks. The content should be\nimport { type CodegenConfig } from \"@graphql-codegen/cli\";\nimport { getGraphqlCodegenConfig } from \"@trackunit/iris-app-build-utilities\";\n\nconst config: CodegenConfig = {\n ...getGraphqlCodegenConfig(__dirname),\n // You can override codegen default config here\n};\nexport default config;\n`);\n }\n\n const result = await generateHooks({\n nxRoot: context.root,\n codeGenFilePath,\n isVerbose: context.isVerbose,\n tsConfigPath,\n });\n if (process.env.SKIP_SCRUB !== \"true\") {\n const pathToGenerateFile = join(fullLibRoot, \"src\", \"generated\", \"graphql-api\", \"graphql.ts\");\n if (existsSync(pathToGenerateFile)) {\n if (context.isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"Scrubbing file: \", pathToGenerateFile);\n }\n await scrubFile(pathToGenerateFile, nxRoot, context.isVerbose);\n }\n }\n return { success: result };\n};\n\nexport default CreateGraphqlHooks;\n"]}
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/executor.ts"],"names":[],"mappings":";;;AACA,2BAAgC;AAChC,+BAA4B;AAC5B,kBAAgB;AAChB,mDAAgD;AAChD,2CAAwC;AAExC;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAAgB,EAAE,OAAwB,EAAE,EAAE;;IACrF,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;I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G,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QACtC,MAAM,kBAAkB,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;QAC9F,IAAI,IAAA,eAAU,EAAC,kBAAkB,CAAC,EAAE,CAAC;YACnC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACtB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;YACtD,CAAC;YACD,MAAM,IAAA,qBAAS,EAAC,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B;AAEF,kBAAe,0BAAkB,CAAC","sourcesContent":["import { ExecutorContext } from \"@nx/devkit\";\nimport { existsSync } from \"fs\";\nimport { join } from \"path\";\nimport \"win-ca\";\nimport { generateHooks } from \"./generateHooks\";\nimport { scrubFile } from \"./scrubFile\";\n\n/**\n * This executor generates react hooks for all graphql files.\n *\n * @param _unused unused props from nx\n * @param context The execution context for this executor\n * @returns {Promise<{ success: number; }>} success when finished\n */\nexport const CreateGraphqlHooks = async (_unused: unknown, context: ExecutorContext) => {\n const nxRoot = `${context.root}`;\n if (!context.projectsConfigurations) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n if (!context.projectName) {\n throw new Error(\"context projectName is required\");\n }\n\n const libRoot = context.projectsConfigurations.projects[context.projectName]?.root;\n\n if (!libRoot) {\n throw new Error(\"Missing library root\");\n }\n\n const fullLibRoot = join(nxRoot, libRoot);\n const tsConfigPath = existsSync(join(fullLibRoot, \"tsconfig.lib.json\"))\n ? join(fullLibRoot, \"tsconfig.lib.json\")\n : join(fullLibRoot, \"tsconfig.app.json\");\n\n if (!tsConfigPath) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n\n const codeGenFilePath = join(fullLibRoot, \"codegen.ts\");\n if (!existsSync(codeGenFilePath)) {\n throw new Error(`codegen.ts file not found in ${fullLibRoot} please add this file and run again to generate hooks. The content should be\nimport { type CodegenConfig } from \"@graphql-codegen/cli\";\nimport { getGraphqlCodegenConfig } from \"@trackunit/iris-app-build-utilities\";\n\nconst config: CodegenConfig = {\n ...getGraphqlCodegenConfig(__dirname),\n // You can override codegen default config here\n};\nexport default config;\n`);\n }\n\n const result = await generateHooks({\n nxRoot: context.root,\n codeGenFilePath,\n isVerbose: context.isVerbose,\n tsConfigPath,\n });\n if (process.env.SKIP_SCRUB !== \"true\") {\n const pathToGenerateFile = join(fullLibRoot, \"src\", \"generated\", \"graphql-api\", \"graphql.ts\");\n if (existsSync(pathToGenerateFile)) {\n if (context.isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"Scrubbing file: \", pathToGenerateFile);\n }\n await scrubFile(pathToGenerateFile, nxRoot, context.isVerbose);\n }\n }\n return { success: result };\n};\n\nexport default CreateGraphqlHooks;\n"]}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateHooks = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const cli_1 = require("@graphql-codegen/cli");
6
5
  /**
7
6
  * Generates React hooks from your graphql files.
@@ -11,7 +10,7 @@ const cli_1 = require("@graphql-codegen/cli");
11
10
  * @param options.tsConfigPath the path to the tsconfig file.
12
11
  * @param options.isVerbose if true, will log more information.
13
12
  */
14
- const generateHooks = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
+ const generateHooks = async (options) => {
15
14
  const contextConfig = {
16
15
  watch: false,
17
16
  overwrite: true,
@@ -28,8 +27,8 @@ const generateHooks = (options) => tslib_1.__awaiter(void 0, void 0, void 0, fun
28
27
  // eslint-disable-next-line no-console
29
28
  console.log(contextConfig);
30
29
  }
31
- const context = yield (0, cli_1.createContext)(contextConfig);
32
- return yield (0, cli_1.generate)(context);
33
- });
30
+ const context = await (0, cli_1.createContext)(contextConfig);
31
+ return await (0, cli_1.generate)(context);
32
+ };
34
33
  exports.generateHooks = generateHooks;
35
34
  //# sourceMappingURL=generateHooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateHooks.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/generateHooks.ts"],"names":[],"mappings":";;;;AAAA,8CAA+D;AAC/D;;;;;;;GAOG;AACI,MAAM,aAAa,GAAG,CAAO,OAKnC,EAAE,EAAE;IACH,MAAM,aAAa,GAAG;QACpB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS;QAC1B,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,MAAM,EAAE,OAAO,CAAC,eAAe;QAC/B,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,OAAO,CAAC,SAAS;QAC1B,KAAK,EAAE,OAAO,CAAC,SAAS;KACzB,CAAC;IACF,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAa,EAAC,aAAa,CAAC,CAAC;IAEnD,OAAO,MAAM,IAAA,cAAQ,EAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAA,CAAC;AA1BW,QAAA,aAAa,iBA0BxB","sourcesContent":["import { createContext, generate } from \"@graphql-codegen/cli\";\n/**\n * Generates React hooks from your graphql files.\n *\n * @param options.codeGenFilePath the path to the codegen file.\n * @param options.nxRoot the nx root.\n * @param options.tsConfigPath the path to the tsconfig file.\n * @param options.isVerbose if true, will log more information.\n */\nexport const generateHooks = async (options: {\n codeGenFilePath: string;\n nxRoot: string;\n isVerbose?: boolean;\n tsConfigPath: string;\n}) => {\n const contextConfig = {\n watch: false,\n overwrite: true,\n silent: !options.isVerbose,\n errorsOnly: false,\n profile: false,\n project: options.tsConfigPath,\n config: options.codeGenFilePath,\n require: [],\n verbose: options.isVerbose,\n debug: options.isVerbose,\n };\n if (options.isVerbose) {\n // eslint-disable-next-line no-console\n console.log(contextConfig);\n }\n\n const context = await createContext(contextConfig);\n\n return await generate(context);\n};\n"]}
1
+ {"version":3,"file":"generateHooks.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/generateHooks.ts"],"names":[],"mappings":";;;AAAA,8CAA+D;AAC/D;;;;;;;GAOG;AACI,MAAM,aAAa,GAAG,KAAK,EAAE,OAKnC,EAAE,EAAE;IACH,MAAM,aAAa,GAAG;QACpB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS;QAC1B,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,MAAM,EAAE,OAAO,CAAC,eAAe;QAC/B,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,OAAO,CAAC,SAAS;QAC1B,KAAK,EAAE,OAAO,CAAC,SAAS;KACzB,CAAC;IACF,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAa,EAAC,aAAa,CAAC,CAAC;IAEnD,OAAO,MAAM,IAAA,cAAQ,EAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC;AA1BW,QAAA,aAAa,iBA0BxB","sourcesContent":["import { createContext, generate } from \"@graphql-codegen/cli\";\n/**\n * Generates React hooks from your graphql files.\n *\n * @param options.codeGenFilePath the path to the codegen file.\n * @param options.nxRoot the nx root.\n * @param options.tsConfigPath the path to the tsconfig file.\n * @param options.isVerbose if true, will log more information.\n */\nexport const generateHooks = async (options: {\n codeGenFilePath: string;\n nxRoot: string;\n isVerbose?: boolean;\n tsConfigPath: string;\n}) => {\n const contextConfig = {\n watch: false,\n overwrite: true,\n silent: !options.isVerbose,\n errorsOnly: false,\n profile: false,\n project: options.tsConfigPath,\n config: options.codeGenFilePath,\n require: [],\n verbose: options.isVerbose,\n debug: options.isVerbose,\n };\n if (options.isVerbose) {\n // eslint-disable-next-line no-console\n console.log(contextConfig);\n }\n\n const context = await createContext(contextConfig);\n\n return await generate(context);\n};\n"]}
@@ -11,7 +11,7 @@ const utils_1 = require("./utils");
11
11
  /**
12
12
  * Generates React hooks from your graphql files.
13
13
  */
14
- const scrubFileContent = (fileContent, nxRoot, isVerbose) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
14
+ const scrubFileContent = async (fileContent, nxRoot, isVerbose) => {
15
15
  const start = new Date().getTime();
16
16
  const sourceFile = (0, utils_1.createSourceFile)(fileContent);
17
17
  let resultFileContent = "";
@@ -47,20 +47,20 @@ const scrubFileContent = (fileContent, nxRoot, isVerbose) => tslib_1.__awaiter(v
47
47
  console.log("Execution time: " + time);
48
48
  }
49
49
  return result;
50
- });
50
+ };
51
51
  exports.scrubFileContent = scrubFileContent;
52
52
  /**
53
53
  * Scrubs the file content.
54
54
  *
55
55
  * @param file The file to scrub.
56
56
  */
57
- const scrubFile = (file, nxRoot, isVerbose) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ const scrubFile = async (file, nxRoot, isVerbose) => {
58
58
  const fileContent = (0, fs_1.readFileSync)(file, { encoding: "utf-8" });
59
59
  if (fileContent.length === 0) {
60
60
  console.warn(`File ${file} is empty`);
61
61
  }
62
- const scrubbedMockFileContent = yield (0, scrubMockFile_1.scrubMockFileContent)(fileContent, nxRoot, isVerbose);
63
- const scrubbedFileContent = yield (0, exports.scrubFileContent)(fileContent, nxRoot, isVerbose);
62
+ const scrubbedMockFileContent = await (0, scrubMockFile_1.scrubMockFileContent)(fileContent, nxRoot, isVerbose);
63
+ const scrubbedFileContent = await (0, exports.scrubFileContent)(fileContent, nxRoot, isVerbose);
64
64
  let options = null;
65
65
  try {
66
66
  options = prettier
@@ -77,12 +77,12 @@ const scrubFile = (file, nxRoot, isVerbose) => tslib_1.__awaiter(void 0, void 0,
77
77
  if (!options) {
78
78
  throw new Error("Could not find prettier config");
79
79
  }
80
- const prettierOptions = yield options;
80
+ const prettierOptions = await options;
81
81
  let prettySrc = scrubbedFileContent;
82
82
  if (prettierOptions) {
83
83
  prettierOptions.parser = "typescript";
84
84
  try {
85
- prettySrc = yield prettier.format(scrubbedFileContent, prettierOptions);
85
+ prettySrc = await prettier.format(scrubbedFileContent, prettierOptions);
86
86
  }
87
87
  catch (error) {
88
88
  console.error("Error in prettier.format:", error);
@@ -93,7 +93,7 @@ const scrubFile = (file, nxRoot, isVerbose) => tslib_1.__awaiter(void 0, void 0,
93
93
  if (prettierOptions) {
94
94
  prettierOptions.parser = "typescript";
95
95
  try {
96
- prettyMockSrc = yield prettier.format(scrubbedMockFileContent, prettierOptions);
96
+ prettyMockSrc = await prettier.format(scrubbedMockFileContent, prettierOptions);
97
97
  }
98
98
  catch (error) {
99
99
  console.error("Error in prettier.format:", error);
@@ -102,6 +102,6 @@ const scrubFile = (file, nxRoot, isVerbose) => tslib_1.__awaiter(void 0, void 0,
102
102
  const parentDir = (0, path_1.dirname)(file);
103
103
  (0, fs_1.writeFileSync)((0, path_1.join)(parentDir, "mock.ts"), prettyMockSrc, { encoding: "utf-8" });
104
104
  return prettySrc;
105
- });
105
+ };
106
106
  exports.scrubFile = scrubFile;
107
107
  //# sourceMappingURL=scrubFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scrubFile.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/scrubFile.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,2BAAiD;AACjD,+BAAqC;AACrC,2DAAqC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YACH,SAAS,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;QAC1E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IACD,IAAA,kBAAa,EAAC,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAEtD,IAAI,aAAa,GAAG,uBAAuB,CAAC;IAC5C,IAAI,eAAe,EAAE,CAAC;QACpB,eAAe,CAAC,MAAM,GAAG,YAAY,CAAC;QACtC,IAAI,CAAC;YACH,aAAa,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;QAClF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IACD,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;IAChC,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,SAAS,CAAC,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAChF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA,CAAC;AAjDW,QAAA,SAAS,aAiDpB","sourcesContent":["/* eslint-disable no-console */\nimport { readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport * as prettier from \"prettier\";\nimport { scrubMockFileContent } from \"./scrubMockFile\";\nimport { convertEnumToConstObject, createSourceFile, getPreservedTypes, isFragment } from \"./utils\";\n\n/**\n * Generates React hooks from your graphql files.\n */\nexport const scrubFileContent = async (fileContent: string, nxRoot: string, isVerbose?: boolean) => {\n const start = new Date().getTime();\n\n const sourceFile = createSourceFile(fileContent);\n\n let resultFileContent = \"\";\n const scalarsType = sourceFile.getTypeAliasOrThrow(\"Scalars\");\n scalarsType.getEndLineNumber();\n resultFileContent += fileContent.split(\"\\n\").slice(0, scalarsType.getEndLineNumber()).join(\"\\n\") + \"\\n\";\n const alreadyAdded = sourceFile\n .getTypeAliases()\n .filter(typeAlias => typeAlias.getStartLineNumber() < scalarsType.getEndLineNumber())\n .map(typeAlias => typeAlias.getName());\n\n resultFileContent = resultFileContent.replace(\n \"export type InputMaybe<T> = Maybe<T>;\",\n \"export type InputMaybe<T> = Maybe<T> | undefined;\"\n );\n\n const { preservedTypes, queryAndMutations } = getPreservedTypes(sourceFile, isVerbose);\n isVerbose && console.log(\"PreservedTypes:\", preservedTypes);\n\n sourceFile.getEnums().forEach(enumType => {\n const typeName = enumType.getName();\n if (preservedTypes.includes(typeName) && !alreadyAdded.includes(typeName) && !isFragment(typeName)) {\n alreadyAdded.push(typeName);\n resultFileContent += \"\\n\" + convertEnumToConstObject(enumType) + \"\\n\";\n }\n });\n sourceFile.getTypeAliases().forEach(typeAlias => {\n const typeName = typeAlias.getName();\n if (preservedTypes.includes(typeName) && !alreadyAdded.includes(typeName) && !isFragment(typeName)) {\n alreadyAdded.push(typeName);\n resultFileContent += \"\\n\" + typeAlias.getText() + \"\\n\";\n }\n });\n\n const resultQueryAndMutations = queryAndMutations.map(queryOrMutation => queryOrMutation.getFullText()).join(\"\\n\");\n\n const result = resultFileContent + \"\\n\" + resultQueryAndMutations;\n if (isVerbose) {\n const end = new Date().getTime();\n const time = end - start;\n console.log(\"Execution time: \" + time);\n }\n\n return result;\n};\n\n/**\n * Scrubs the file content.\n *\n * @param file The file to scrub.\n */\nexport const scrubFile = async (file: string, nxRoot: string, isVerbose?: boolean) => {\n const fileContent = readFileSync(file, { encoding: \"utf-8\" });\n if (fileContent.length === 0) {\n console.warn(`File ${file} is empty`);\n }\n const scrubbedMockFileContent = await scrubMockFileContent(fileContent, nxRoot, isVerbose);\n\n const scrubbedFileContent = await scrubFileContent(fileContent, nxRoot, isVerbose);\n\n let options = null;\n try {\n options = prettier\n .resolveConfig(join(nxRoot, \".prettierrc\"), {\n useCache: false,\n editorconfig: false,\n config: join(nxRoot, \".prettierrc\"),\n })\n .catch((error: Error) => console.log(error));\n } catch (e) {\n console.log(e);\n }\n if (!options) {\n throw new Error(\"Could not find prettier config\");\n }\n const prettierOptions = await options;\n\n let prettySrc = scrubbedFileContent;\n if (prettierOptions) {\n prettierOptions.parser = \"typescript\";\n try {\n prettySrc = await prettier.format(scrubbedFileContent, prettierOptions);\n } catch (error) {\n console.error(\"Error in prettier.format:\", error);\n }\n }\n writeFileSync(file, prettySrc, { encoding: \"utf-8\" });\n\n let prettyMockSrc = scrubbedMockFileContent;\n if (prettierOptions) {\n prettierOptions.parser = \"typescript\";\n try {\n prettyMockSrc = await prettier.format(scrubbedMockFileContent, prettierOptions);\n } catch (error) {\n console.error(\"Error in prettier.format:\", error);\n }\n }\n const parentDir = dirname(file);\n writeFileSync(join(parentDir, \"mock.ts\"), prettyMockSrc, { encoding: \"utf-8\" });\n return prettySrc;\n};\n"]}
1
+ {"version":3,"file":"scrubFile.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/scrubFile.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,2BAAiD;AACjD,+BAAqC;AACrC,2DAAqC;AACrC,mDAAuD;AACvD,mCAAoG;AAEpG;;GAEG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,WAAmB,EAAE,MAAc,EAAE,SAAmB,EAAE,EAAE;IACjG,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAEnC,MAAM,UAAU,GAAG,IAAA,wBAAgB,EAAC,WAAW,CAAC,CAAC;IAEjD,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,UAAU,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC9D,WAAW,CAAC,gBAAgB,EAAE,CAAC;I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YAAY,CAAC;QACtC,IAAI,CAAC;YACH,aAAa,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;QAClF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IACD,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;IAChC,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,SAAS,CAAC,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAChF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAjDW,QAAA,SAAS,aAiDpB","sourcesContent":["/* eslint-disable no-console */\nimport { readFileSync, writeFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport * as prettier from \"prettier\";\nimport { scrubMockFileContent } from \"./scrubMockFile\";\nimport { convertEnumToConstObject, createSourceFile, getPreservedTypes, isFragment } from \"./utils\";\n\n/**\n * Generates React hooks from your graphql files.\n */\nexport const scrubFileContent = async (fileContent: string, nxRoot: string, isVerbose?: boolean) => {\n const start = new Date().getTime();\n\n const sourceFile = createSourceFile(fileContent);\n\n let resultFileContent = \"\";\n const scalarsType = sourceFile.getTypeAliasOrThrow(\"Scalars\");\n scalarsType.getEndLineNumber();\n resultFileContent += fileContent.split(\"\\n\").slice(0, scalarsType.getEndLineNumber()).join(\"\\n\") + \"\\n\";\n const alreadyAdded = sourceFile\n .getTypeAliases()\n .filter(typeAlias => typeAlias.getStartLineNumber() < scalarsType.getEndLineNumber())\n .map(typeAlias => typeAlias.getName());\n\n resultFileContent = resultFileContent.replace(\n \"export type InputMaybe<T> = Maybe<T>;\",\n \"export type InputMaybe<T> = Maybe<T> | undefined;\"\n );\n\n const { preservedTypes, queryAndMutations } = getPreservedTypes(sourceFile, isVerbose);\n isVerbose && console.log(\"PreservedTypes:\", preservedTypes);\n\n sourceFile.getEnums().forEach(enumType => {\n const typeName = enumType.getName();\n if (preservedTypes.includes(typeName) && !alreadyAdded.includes(typeName) && !isFragment(typeName)) {\n alreadyAdded.push(typeName);\n resultFileContent += \"\\n\" + convertEnumToConstObject(enumType) + \"\\n\";\n }\n });\n sourceFile.getTypeAliases().forEach(typeAlias => {\n const typeName = typeAlias.getName();\n if (preservedTypes.includes(typeName) && !alreadyAdded.includes(typeName) && !isFragment(typeName)) {\n alreadyAdded.push(typeName);\n resultFileContent += \"\\n\" + typeAlias.getText() + \"\\n\";\n }\n });\n\n const resultQueryAndMutations = queryAndMutations.map(queryOrMutation => queryOrMutation.getFullText()).join(\"\\n\");\n\n const result = resultFileContent + \"\\n\" + resultQueryAndMutations;\n if (isVerbose) {\n const end = new Date().getTime();\n const time = end - start;\n console.log(\"Execution time: \" + time);\n }\n\n return result;\n};\n\n/**\n * Scrubs the file content.\n *\n * @param file The file to scrub.\n */\nexport const scrubFile = async (file: string, nxRoot: string, isVerbose?: boolean) => {\n const fileContent = readFileSync(file, { encoding: \"utf-8\" });\n if (fileContent.length === 0) {\n console.warn(`File ${file} is empty`);\n }\n const scrubbedMockFileContent = await scrubMockFileContent(fileContent, nxRoot, isVerbose);\n\n const scrubbedFileContent = await scrubFileContent(fileContent, nxRoot, isVerbose);\n\n let options = null;\n try {\n options = prettier\n .resolveConfig(join(nxRoot, \".prettierrc\"), {\n useCache: false,\n editorconfig: false,\n config: join(nxRoot, \".prettierrc\"),\n })\n .catch((error: Error) => console.log(error));\n } catch (e) {\n console.log(e);\n }\n if (!options) {\n throw new Error(\"Could not find prettier config\");\n }\n const prettierOptions = await options;\n\n let prettySrc = scrubbedFileContent;\n if (prettierOptions) {\n prettierOptions.parser = \"typescript\";\n try {\n prettySrc = await prettier.format(scrubbedFileContent, prettierOptions);\n } catch (error) {\n console.error(\"Error in prettier.format:\", error);\n }\n }\n writeFileSync(file, prettySrc, { encoding: \"utf-8\" });\n\n let prettyMockSrc = scrubbedMockFileContent;\n if (prettierOptions) {\n prettierOptions.parser = \"typescript\";\n try {\n prettyMockSrc = await prettier.format(scrubbedMockFileContent, prettierOptions);\n } catch (error) {\n console.error(\"Error in prettier.format:\", error);\n }\n }\n const parentDir = dirname(file);\n writeFileSync(join(parentDir, \"mock.ts\"), prettyMockSrc, { encoding: \"utf-8\" });\n return prettySrc;\n};\n"]}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.scrubMockFileContent = void 0;
4
- const tslib_1 = require("tslib");
5
4
  /* eslint-disable no-console */
6
5
  const faker_1 = require("@faker-js/faker");
7
6
  const ts_morph_1 = require("ts-morph");
@@ -59,7 +58,7 @@ const generateMockFromType = (type, text) => {
59
58
  /**
60
59
  * Generates React hooks from your graphql files.
61
60
  */
62
- const scrubMockFileContent = (fileContent, nxRoot, isVerbose) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
61
+ const scrubMockFileContent = async (fileContent, nxRoot, isVerbose) => {
63
62
  const start = new Date().getTime();
64
63
  const project = new ts_morph_1.Project({
65
64
  compilerOptions: {
@@ -104,6 +103,6 @@ const scrubMockFileContent = (fileContent, nxRoot, isVerbose) => tslib_1.__await
104
103
 
105
104
  ${mock.join("\n")}
106
105
  `;
107
- });
106
+ };
108
107
  exports.scrubMockFileContent = scrubMockFileContent;
109
108
  //# sourceMappingURL=scrubMockFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scrubMockFile.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/scrubMockFile.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,2CAAwC;AACxC,uCAAyD;AAEzD,8DAA8D;AAC9D,MAAM,oBAAoB,GAAG,CAAC,IAAS,EAAE,IAAY,EAAO,EAAE;IAC5D,aAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,wDAAwD;IACxD,MAAM,aAAa,G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,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC;;YAEhF,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;+BAChD,MAAM,CAAC,OAAO,EAAE;;MAEzC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;;;;;;IAML,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;GAChB,CAAC;AACJ,CAAC,CAAA,CAAC;AAnDW,QAAA,oBAAoB,wBAmD/B","sourcesContent":["/* eslint-disable no-console */\nimport { faker } from \"@faker-js/faker\";\nimport { Project, TypeAliasDeclaration } from \"ts-morph\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst generateMockFromType = (type: any, text: string): any => {\n faker.seed(123);\n // type aliases are not working well so using text here.\n const rightSideText = text.substring(text.indexOf(\":\") + 1).trim();\n if (rightSideText.startsWith(\"DateTimeISOString\")) {\n return \"2023-01-22T15:08:12.527Z\";\n }\n if (type.isStringLiteral()) {\n return type.compilerType.value; // Get the value of the string literal\n }\n if (type.isNumberLiteral()) {\n return parseFloat(type.compilerType.value);\n }\n if (type.isBooleanLiteral()) {\n return type.compilerType.value === \"true\";\n }\n\n if (type.getText() === \"string\") {\n return faker.lorem.word();\n }\n if (type.getText() === \"number\") {\n return faker.number.int();\n }\n if (type.getText() === \"Date\" || type.getText() === \"DateTime\") {\n return \"2023-01-22T15:08:12.527Z\";\n }\n\n if (type.isUnion()) {\n // We'll take the first type in the union for simplicity\n return generateMockFromType(type.getUnionTypes()[0], \"\");\n }\n if (type.isArray()) {\n return [generateMockFromType(type.getArrayElementTypeOrThrow(), \"\")];\n }\n if (type.isObject()) {\n const properties = type.getProperties();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const obj: any = {};\n for (const prop of properties) {\n const declaration = prop.getValueDeclarationOrThrow();\n const propType = declaration.getType();\n if (prop.getName() === \"__typename\") {\n obj[prop.getName()] = propType.getText().replace(/\"/g, \"\");\n } else {\n obj[prop.getName()] = generateMockFromType(propType, declaration.getText());\n }\n }\n return obj;\n }\n return null; // Default\n};\n\n/**\n * Generates React hooks from your graphql files.\n */\nexport const scrubMockFileContent = async (fileContent: string, nxRoot: string, isVerbose?: boolean) => {\n const start = new Date().getTime();\n\n const project = new Project({\n compilerOptions: {\n noUnusedLocals: true,\n noUnusedParameters: true,\n },\n });\n const generatedFile = project.createSourceFile(\"tmpMock.ts\", fileContent);\n const mockThese: TypeAliasDeclaration[] = [];\n\n generatedFile.insertStatements(0, \"/* eslint-disable @typescript-eslint/no-explicit-any */\");\n generatedFile.insertStatements(1, \"/* eslint-disable @typescript-eslint/array-type */\");\n\n generatedFile.getTypeAliases().forEach(node => {\n if (node.getName().endsWith(\"Query\") && node.getName().length > \"Query\".length) {\n mockThese.push(node);\n }\n if (node.getName().endsWith(\"Mutation\") && node.getName().length > \"Mutation\".length) {\n mockThese.push(node);\n }\n });\n\n if (isVerbose) {\n const end = new Date().getTime();\n const time = end - start;\n console.log(\"Mock Execution time: \" + time);\n }\n\n const mock = mockThese.map(mocker => {\n const postFix = (mocker.getName().includes(\"Query\") ? \"Query\" : \"Mutation\").length;\n return `\n \n export const mockFor${mocker.getName()} = (variables: gql.${mocker.getName()}Variables, data?: DeepPartialNullable<gql.${mocker.getName()}> ) => {\n return queryFor(gql.${mocker.getName().substring(0, mocker.getName().length - postFix)}Document, variables, \n mergeDeep(\n ${JSON.stringify(generateMockFromType(mocker.getType(), \"\"), null, 4)}\n , data || {}) as gql.${mocker.getName()}\n );\n }`;\n });\n\n return `\n import { OperationVariables } from \"@apollo/client\";\n import { mergeDeep } from \"@apollo/client/utilities\";\n import { queryFor, DeepPartialNullable } from \"@trackunit/react-core-contexts-test\";\n import * as gql from \"./graphql\";\n \n ${mock.join(\"\\n\")}\n `;\n};\n"]}
1
+ {"version":3,"file":"scrubMockFile.js","sourceRoot":"","sources":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CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC;QACnF,OAAO;;0BAEe,MAAM,CAAC,OAAO,EAAE,sBAAsB,MAAM,CAAC,OAAO,EAAE,6CAA6C,MAAM,CAAC,OAAO,EAAE;4BACjH,MAAM,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC;;YAEhF,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;+BAChD,MAAM,CAAC,OAAO,EAAE;;MAEzC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;;;;;;IAML,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;GAChB,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,oBAAoB,wBAmD/B","sourcesContent":["/* eslint-disable no-console */\nimport { faker } from \"@faker-js/faker\";\nimport { Project, TypeAliasDeclaration } from \"ts-morph\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst generateMockFromType = (type: any, text: string): any => {\n faker.seed(123);\n // type aliases are not working well so using text here.\n const rightSideText = text.substring(text.indexOf(\":\") + 1).trim();\n if (rightSideText.startsWith(\"DateTimeISOString\")) {\n return \"2023-01-22T15:08:12.527Z\";\n }\n if (type.isStringLiteral()) {\n return type.compilerType.value; // Get the value of the string literal\n }\n if (type.isNumberLiteral()) {\n return parseFloat(type.compilerType.value);\n }\n if (type.isBooleanLiteral()) {\n return type.compilerType.value === \"true\";\n }\n\n if (type.getText() === \"string\") {\n return faker.lorem.word();\n }\n if (type.getText() === \"number\") {\n return faker.number.int();\n }\n if (type.getText() === \"Date\" || type.getText() === \"DateTime\") {\n return \"2023-01-22T15:08:12.527Z\";\n }\n\n if (type.isUnion()) {\n // We'll take the first type in the union for simplicity\n return generateMockFromType(type.getUnionTypes()[0], \"\");\n }\n if (type.isArray()) {\n return [generateMockFromType(type.getArrayElementTypeOrThrow(), \"\")];\n }\n if (type.isObject()) {\n const properties = type.getProperties();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const obj: any = {};\n for (const prop of properties) {\n const declaration = prop.getValueDeclarationOrThrow();\n const propType = declaration.getType();\n if (prop.getName() === \"__typename\") {\n obj[prop.getName()] = propType.getText().replace(/\"/g, \"\");\n } else {\n obj[prop.getName()] = generateMockFromType(propType, declaration.getText());\n }\n }\n return obj;\n }\n return null; // Default\n};\n\n/**\n * Generates React hooks from your graphql files.\n */\nexport const scrubMockFileContent = async (fileContent: string, nxRoot: string, isVerbose?: boolean) => {\n const start = new Date().getTime();\n\n const project = new Project({\n compilerOptions: {\n noUnusedLocals: true,\n noUnusedParameters: true,\n },\n });\n const generatedFile = project.createSourceFile(\"tmpMock.ts\", fileContent);\n const mockThese: TypeAliasDeclaration[] = [];\n\n generatedFile.insertStatements(0, \"/* eslint-disable @typescript-eslint/no-explicit-any */\");\n generatedFile.insertStatements(1, \"/* eslint-disable @typescript-eslint/array-type */\");\n\n generatedFile.getTypeAliases().forEach(node => {\n if (node.getName().endsWith(\"Query\") && node.getName().length > \"Query\".length) {\n mockThese.push(node);\n }\n if (node.getName().endsWith(\"Mutation\") && node.getName().length > \"Mutation\".length) {\n mockThese.push(node);\n }\n });\n\n if (isVerbose) {\n const end = new Date().getTime();\n const time = end - start;\n console.log(\"Mock Execution time: \" + time);\n }\n\n const mock = mockThese.map(mocker => {\n const postFix = (mocker.getName().includes(\"Query\") ? \"Query\" : \"Mutation\").length;\n return `\n \n export const mockFor${mocker.getName()} = (variables: gql.${mocker.getName()}Variables, data?: DeepPartialNullable<gql.${mocker.getName()}> ) => {\n return queryFor(gql.${mocker.getName().substring(0, mocker.getName().length - postFix)}Document, variables, \n mergeDeep(\n ${JSON.stringify(generateMockFromType(mocker.getType(), \"\"), null, 4)}\n , data || {}) as gql.${mocker.getName()}\n );\n }`;\n });\n\n return `\n import { OperationVariables } from \"@apollo/client\";\n import { mergeDeep } from \"@apollo/client/utilities\";\n import { queryFor, DeepPartialNullable } from \"@trackunit/react-core-contexts-test\";\n import * as gql from \"./graphql\";\n \n ${mock.join(\"\\n\")}\n `;\n};\n"]}
@@ -80,10 +80,7 @@ const getPreservedTypes = (sourceFile, isVerbose) => {
80
80
  var _a;
81
81
  const variable = (_a = variableStatement
82
82
  .getFirstChildByKind(ts_morph_1.SyntaxKind.VariableDeclarationList)) === null || _a === void 0 ? void 0 : _a.getFirstChildByKind(ts_morph_1.SyntaxKind.VariableDeclaration);
83
- if (variable === null || variable === void 0 ? void 0 : variable.getName().endsWith("Document")) {
84
- queryAndMutations.push(variableStatement);
85
- }
86
- else if (variable === null || variable === void 0 ? void 0 : variable.getName().endsWith("FragmentDoc")) {
83
+ if ((variable === null || variable === void 0 ? void 0 : variable.getName().endsWith("Document")) || (variable === null || variable === void 0 ? void 0 : variable.getName().endsWith("FragmentDoc"))) {
87
84
  queryAndMutations.push(variableStatement);
88
85
  }
89
86
  });
@@ -103,23 +100,22 @@ const preserveTypes = (node, preservedTypes, sourceFile, isVerbose) => {
103
100
  const typeReferences = [];
104
101
  if (!node.getText().startsWith("export type Query") && !node.getText().startsWith("export type Mutation")) {
105
102
  node.forEachDescendant(descendant => {
106
- if (descendant.getKind() === ts_morph_1.SyntaxKind.TypeReference) {
107
- if (!descendant.getText().startsWith("Scalars") &&
108
- !descendant.getText().startsWith("Maybe<") &&
109
- !descendant.getText().startsWith("InputMaybe<") &&
110
- !descendant.getText().startsWith("Array<") &&
111
- !descendant.getText().startsWith("Exact<") &&
112
- !descendant.getText().includes("__typename")) {
113
- if (isVerbose) {
114
- // eslint-disable-next-line no-console
115
- console.log("ADDING", getFullPathUpOfNode(descendant), ":", descendant.getText(), descendant.getKindName());
116
- }
117
- if (!preservedTypes.includes(descendant.getText())) {
118
- const foundTypeAlias = sourceFile.getTypeAlias(descendant.getText());
119
- preservedTypes.push(descendant.getText());
120
- if (foundTypeAlias) {
121
- preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);
122
- }
103
+ if (descendant.getKind() === ts_morph_1.SyntaxKind.TypeReference &&
104
+ !descendant.getText().startsWith("Scalars") &&
105
+ !descendant.getText().startsWith("Maybe<") &&
106
+ !descendant.getText().startsWith("InputMaybe<") &&
107
+ !descendant.getText().startsWith("Array<") &&
108
+ !descendant.getText().startsWith("Exact<") &&
109
+ !descendant.getText().includes("__typename")) {
110
+ if (isVerbose) {
111
+ // eslint-disable-next-line no-console
112
+ console.log("ADDING", getFullPathUpOfNode(descendant), ":", descendant.getText(), descendant.getKindName());
113
+ }
114
+ if (!preservedTypes.includes(descendant.getText())) {
115
+ const foundTypeAlias = sourceFile.getTypeAlias(descendant.getText());
116
+ preservedTypes.push(descendant.getText());
117
+ if (foundTypeAlias) {
118
+ preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);
123
119
  }
124
120
  }
125
121
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/utils.ts"],"names":[],"mappings":";;;AAAA,uCAAwG;AAExG;;GAEG;AACI,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE;IACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB;AACF;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF;;GAEG;AACI,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,OAAO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,CAAC,OAAO,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,MAAM,oBAAoB,GAAG,CAAA,MAAA,QAAQ,CAAC,CAAC,CAAC,0CAAE,WAAW,EAAE,IAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,eAAe,GAAG,gBAAgB,oBAAoB,WAAW,UAAU,CAAC,IAAI,CACpF,OAAO,CACR,+BAA+B,QAAQ,aAAa,oBAAoB,iBAAiB,oBAAoB,IAAI,CAAC;IAEnH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAhBW,QAAA,wBAAwB,4BAgBnC;AAEF;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,EAAE;IACtD,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC;QAC1B,eAAe,EAAE;YACf,cAAc,EAAE,IAAI;YACpB,kBAAkB,EAAE,IAAI;SACzB;KACF,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B","sourcesContent":["import { EnumDeclaration, Node, Project, SourceFile, SyntaxKind, TypeAliasDeclaration } from \"ts-morph\";\n\n/**\n * Check if the name is a *Query\n */\nexport const isQuery = (name: string) => {\n return name.endsWith(\"Query\") && name.length > \"Query\".length;\n};\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isQueryVariables = (name: string) => {\n return name.endsWith(\"QueryVariables\");\n};\n\n/**\n * Check if the name is a Mutation\n */\nexport const isMutation = (name: string) => {\n return name.endsWith(\"Mutation\") && name.length > \"Mutation\".length;\n};\n\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isMutationVariables = (name: string) => {\n return name.endsWith(\"MutationVariables\");\n};\n\n/**\n * Check if the name is a *Fragment and not *_Fragment\n */\nexport const isFragment = (name: string) => {\n return name.endsWith(\"Fragment\") && !name.endsWith(\"_Fragment\");\n};\n\n/**\n * Debug where you are in the tree\n */\nconst getFullPathUpOfNode = (node: Node) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let currentNode: any | undefined = node;\n const paths = [];\n\n while (currentNode) {\n // You can customize what details to include for each node (e.g., kind, text)\n let name = currentNode.getName ? currentNode.getName() : currentNode.getKindName();\n if (node.getKind() === SyntaxKind.TypeLiteral) {\n const typeLiteral = node.asKindOrThrow(SyntaxKind.TypeLiteral);\n name = typeLiteral.getText();\n }\n\n paths.unshift(`${name}`);\n currentNode = currentNode.getParent();\n }\n\n return paths.join(\">>\");\n};\n\n/**\n * Get the types that should be preserved\n */\nexport const getPreservedTypes = (\n sourceFile: SourceFile,\n isVerbose?: boolean\n): {\n preservedTypes: string[];\n queryAndMutations: Node[];\n} => {\n const typeAliases = sourceFile.getTypeAliases();\n const queryAndMutations: Node[] = [];\n\n const preservedTypes: string[] = [];\n\n const variablesListToProcess: TypeAliasDeclaration[] = [];\n const queryMutationListToProcess: TypeAliasDeclaration[] = [];\n\n typeAliases.forEach(typeAlias => {\n const name = typeAlias.getName();\n if (isQueryVariables(name) || isMutationVariables(name) || isFragment(name)) {\n variablesListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n } else if (isQuery(name) || isMutation(name)) {\n queryMutationListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n }\n });\n\n sourceFile.getVariableStatements().forEach(variableStatement => {\n const variable = variableStatement\n .getFirstChildByKind(SyntaxKind.VariableDeclarationList)\n ?.getFirstChildByKind(SyntaxKind.VariableDeclaration);\n if (variable?.getName().endsWith(\"Document\")) {\n queryAndMutations.push(variableStatement);\n } else if (variable?.getName().endsWith(\"FragmentDoc\")) {\n queryAndMutations.push(variableStatement);\n }\n });\n\n // RUN VARAIABLES FIRST since it will force full props if nessasary\n\n // VARIABLES are input so force include all props\n variablesListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n // QUERY and MUTATION are dynamic so dont force props\n queryMutationListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n return { preservedTypes, queryAndMutations };\n};\n\nconst preserveTypes = (node: Node, preservedTypes: string[], sourceFile: SourceFile, isVerbose?: boolean): Node[] => {\n const typeReferences: Node[] = [];\n if (!node.getText().startsWith(\"export type Query\") && !node.getText().startsWith(\"export type Mutation\")) {\n node.forEachDescendant(descendant => {\n if (descendant.getKind() === SyntaxKind.TypeReference) {\n if (\n !descendant.getText().startsWith(\"Scalars\") &&\n !descendant.getText().startsWith(\"Maybe<\") &&\n !descendant.getText().startsWith(\"InputMaybe<\") &&\n !descendant.getText().startsWith(\"Array<\") &&\n !descendant.getText().startsWith(\"Exact<\") &&\n !descendant.getText().includes(\"__typename\")\n ) {\n if (isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"ADDING\", getFullPathUpOfNode(descendant), \":\", descendant.getText(), descendant.getKindName());\n }\n if (!preservedTypes.includes(descendant.getText())) {\n const foundTypeAlias = sourceFile.getTypeAlias(descendant.getText());\n preservedTypes.push(descendant.getText());\n if (foundTypeAlias) {\n preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);\n }\n }\n }\n }\n });\n }\n\n return typeReferences;\n};\n\n/**\n * Convert an enum to a const object and string literal type\n */\nexport const convertEnumToConstObject = (enumDeclaration: EnumDeclaration) => {\n const enumName = enumDeclaration.getName();\n const members = enumDeclaration.getMembers();\n\n const properties = members.map(member => {\n const name = member.getName();\n const value = member.getValue();\n return `${name}: '${value}'`;\n });\n\n const lowerCaseFirstLetter = enumName[0]?.toLowerCase() + enumName.slice(1);\n const constObjectText = `export const ${lowerCaseFirstLetter} = {\\n ${properties.join(\n \",\\n \"\n )},\\n} as const;\\nexport type ${enumName} = typeof ${lowerCaseFirstLetter}[keyof typeof ${lowerCaseFirstLetter}];`;\n\n return constObjectText;\n};\n\n/**\n * Create a source file from a string\n */\nexport const createSourceFile = (fileContent: string) => {\n const project = new Project({\n compilerOptions: {\n noUnusedLocals: true,\n noUnusedParameters: true,\n },\n });\n\n return project.createSourceFile(\"tmp.ts\", fileContent);\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/executors/createHooks/utils.ts"],"names":[],"mappings":";;;AAAA,uCAAwG;AAExG;;GAEG;AACI,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE;IACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB;AACF;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAEF;;GAEG;AACI,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;AACtE,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEF;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE;IAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAC5C,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEF;;GAEG;AACI,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AA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D,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC;QAC1B,eAAe,EAAE;YACf,cAAc,EAAE,IAAI;YACpB,kBAAkB,EAAE,IAAI;SACzB;KACF,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC,CAAC;AATW,QAAA,gBAAgB,oBAS3B","sourcesContent":["import { EnumDeclaration, Node, Project, SourceFile, SyntaxKind, TypeAliasDeclaration } from \"ts-morph\";\n\n/**\n * Check if the name is a *Query\n */\nexport const isQuery = (name: string) => {\n return name.endsWith(\"Query\") && name.length > \"Query\".length;\n};\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isQueryVariables = (name: string) => {\n return name.endsWith(\"QueryVariables\");\n};\n\n/**\n * Check if the name is a Mutation\n */\nexport const isMutation = (name: string) => {\n return name.endsWith(\"Mutation\") && name.length > \"Mutation\".length;\n};\n\n/**\n * Check if the name is a *QueryVariables\n */\nexport const isMutationVariables = (name: string) => {\n return name.endsWith(\"MutationVariables\");\n};\n\n/**\n * Check if the name is a *Fragment and not *_Fragment\n */\nexport const isFragment = (name: string) => {\n return name.endsWith(\"Fragment\") && !name.endsWith(\"_Fragment\");\n};\n\n/**\n * Debug where you are in the tree\n */\nconst getFullPathUpOfNode = (node: Node) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let currentNode: any | undefined = node;\n const paths = [];\n\n while (currentNode) {\n // You can customize what details to include for each node (e.g., kind, text)\n let name = currentNode.getName ? currentNode.getName() : currentNode.getKindName();\n if (node.getKind() === SyntaxKind.TypeLiteral) {\n const typeLiteral = node.asKindOrThrow(SyntaxKind.TypeLiteral);\n name = typeLiteral.getText();\n }\n\n paths.unshift(`${name}`);\n currentNode = currentNode.getParent();\n }\n\n return paths.join(\">>\");\n};\n\n/**\n * Get the types that should be preserved\n */\nexport const getPreservedTypes = (\n sourceFile: SourceFile,\n isVerbose?: boolean\n): {\n preservedTypes: string[];\n queryAndMutations: Node[];\n} => {\n const typeAliases = sourceFile.getTypeAliases();\n const queryAndMutations: Node[] = [];\n\n const preservedTypes: string[] = [];\n\n const variablesListToProcess: TypeAliasDeclaration[] = [];\n const queryMutationListToProcess: TypeAliasDeclaration[] = [];\n\n typeAliases.forEach(typeAlias => {\n const name = typeAlias.getName();\n if (isQueryVariables(name) || isMutationVariables(name) || isFragment(name)) {\n variablesListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n } else if (isQuery(name) || isMutation(name)) {\n queryMutationListToProcess.push(typeAlias);\n queryAndMutations.push(typeAlias);\n }\n });\n\n sourceFile.getVariableStatements().forEach(variableStatement => {\n const variable = variableStatement\n .getFirstChildByKind(SyntaxKind.VariableDeclarationList)\n ?.getFirstChildByKind(SyntaxKind.VariableDeclaration);\n if (variable?.getName().endsWith(\"Document\") || variable?.getName().endsWith(\"FragmentDoc\")) {\n queryAndMutations.push(variableStatement);\n }\n });\n\n // RUN VARAIABLES FIRST since it will force full props if nessasary\n\n // VARIABLES are input so force include all props\n variablesListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n // QUERY and MUTATION are dynamic so dont force props\n queryMutationListToProcess.forEach(typeAlias => {\n preserveTypes(typeAlias, preservedTypes, sourceFile, isVerbose);\n });\n\n return { preservedTypes, queryAndMutations };\n};\n\nconst preserveTypes = (node: Node, preservedTypes: string[], sourceFile: SourceFile, isVerbose?: boolean): Node[] => {\n const typeReferences: Node[] = [];\n if (!node.getText().startsWith(\"export type Query\") && !node.getText().startsWith(\"export type Mutation\")) {\n node.forEachDescendant(descendant => {\n if (descendant.getKind() === SyntaxKind.TypeReference &&\n !descendant.getText().startsWith(\"Scalars\") &&\n !descendant.getText().startsWith(\"Maybe<\") &&\n !descendant.getText().startsWith(\"InputMaybe<\") &&\n !descendant.getText().startsWith(\"Array<\") &&\n !descendant.getText().startsWith(\"Exact<\") &&\n !descendant.getText().includes(\"__typename\")\n ) {\n if (isVerbose) {\n // eslint-disable-next-line no-console\n console.log(\"ADDING\", getFullPathUpOfNode(descendant), \":\", descendant.getText(), descendant.getKindName());\n }\n if (!preservedTypes.includes(descendant.getText())) {\n const foundTypeAlias = sourceFile.getTypeAlias(descendant.getText());\n preservedTypes.push(descendant.getText());\n if (foundTypeAlias) {\n preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);\n }\n }\n }\n });\n }\n\n return typeReferences;\n};\n\n/**\n * Convert an enum to a const object and string literal type\n */\nexport const convertEnumToConstObject = (enumDeclaration: EnumDeclaration) => {\n const enumName = enumDeclaration.getName();\n const members = enumDeclaration.getMembers();\n\n const properties = members.map(member => {\n const name = member.getName();\n const value = member.getValue();\n return `${name}: '${value}'`;\n });\n\n const lowerCaseFirstLetter = enumName[0]?.toLowerCase() + enumName.slice(1);\n const constObjectText = `export const ${lowerCaseFirstLetter} = {\\n ${properties.join(\n \",\\n \"\n )},\\n} as const;\\nexport type ${enumName} = typeof ${lowerCaseFirstLetter}[keyof typeof ${lowerCaseFirstLetter}];`;\n\n return constObjectText;\n};\n\n/**\n * Create a source file from a string\n */\nexport const createSourceFile = (fileContent: string) => {\n const project = new Project({\n compilerOptions: {\n noUnusedLocals: true,\n noUnusedParameters: true,\n },\n });\n\n return project.createSourceFile(\"tmp.ts\", fileContent);\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addGraphqlGenerator = void 0;
3
+ exports.addGraphqlGenerator = addGraphqlGenerator;
4
4
  const tslib_1 = require("tslib");
5
5
  /* eslint-disable no-console */
6
6
  const devkit_1 = require("@nx/devkit");
@@ -8,32 +8,32 @@ const path = tslib_1.__importStar(require("path"));
8
8
  /**
9
9
  * Setting up Graphql tools for Iris App development
10
10
  */
11
- function addGraphqlGenerator(tree, options) {
12
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
- const workspaceRoot = "";
14
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
15
- const libraryRoot = projectConfig.root;
16
- if (!tree.exists("graphql.config.json") && !tree.exists("graphql.config.ts")) {
17
- (0, devkit_1.generateFiles)(tree, path.join(__dirname, "files", "root"), workspaceRoot, options);
18
- }
19
- else {
20
- console.log(`"graphql.config.json" already exist in your workspace root. \nPlease ensure that your "graphql.config.json" contains "schema": "https://iris.trackunit.com/api/graphql/".`);
21
- }
22
- if (!tree.exists(`${libraryRoot}/codegen.ts`)) {
23
- (0, devkit_1.generateFiles)(tree, path.join(__dirname, "files", "subDirectory"), libraryRoot, options);
24
- }
25
- else {
26
- console.log(`codegen.ts already exists in ${libraryRoot}`);
27
- }
28
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(libraryRoot, "project.json"), projectJSON => {
29
- projectJSON.targets = Object.assign(Object.assign({}, projectJSON.targets), { "graphql-hooks": {
30
- executor: "@trackunit/react-graphql-tools:createHooks",
31
- } });
32
- return projectJSON;
33
- });
34
- yield (0, devkit_1.formatFiles)(tree);
11
+ async function addGraphqlGenerator(tree, options) {
12
+ const workspaceRoot = "";
13
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
14
+ const libraryRoot = projectConfig.root;
15
+ if (!tree.exists("graphql.config.json") && !tree.exists("graphql.config.ts")) {
16
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, "files", "root"), workspaceRoot, options);
17
+ }
18
+ else {
19
+ console.log(`"graphql.config.json" already exist in your workspace root. \nPlease ensure that your "graphql.config.json" contains "schema": "https://iris.trackunit.com/api/graphql/".`);
20
+ }
21
+ if (!tree.exists(`${libraryRoot}/codegen.ts`)) {
22
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, "files", "subDirectory"), libraryRoot, options);
23
+ }
24
+ else {
25
+ console.log(`codegen.ts already exists in ${libraryRoot}`);
26
+ }
27
+ (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(libraryRoot, "project.json"), projectJSON => {
28
+ projectJSON.targets = {
29
+ ...projectJSON.targets,
30
+ "graphql-hooks": {
31
+ executor: "@trackunit/react-graphql-tools:createHooks",
32
+ },
33
+ };
34
+ return projectJSON;
35
35
  });
36
+ await (0, devkit_1.formatFiles)(tree);
36
37
  }
37
- exports.addGraphqlGenerator = addGraphqlGenerator;
38
38
  exports.default = addGraphqlGenerator;
39
39
  //# sourceMappingURL=generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/generators/add-graphql/generator.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,uCAAuH;AACvH,mDAA6B;AAG7B;;GAEG;AACH,SAAsB,mBAAmB,CAAC,IAAU,EAAE,OAAkC;;QACtF,MAAM,aAAa,GAAG,EAAE,CAAC;QACzB,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACtE,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC7E,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QACrF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CACT,2KAA2K,CAC5K,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,aAAa,CAAC,EAAE,CAAC;YAC9C,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3F,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,gCAAgC,WAAW,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,IAAA,mBAAU,EAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,WAAW,EAAE,cAAc,CAAC,EAAE,WAAW,CAAC,EAAE;YAC7E,WAAW,CAAC,OAAO,mCACd,WAAW,CAAC,OAAO,KACtB,eAAe,EAAE;oBACf,QAAQ,EAAE,4CAA4C;iBACvD,GACF,CAAC;YACF,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC,CAAC;QACH,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AA5BD,kDA4BC;AAED,kBAAe,mBAAmB,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport { formatFiles, generateFiles, joinPathFragments, readProjectConfiguration, Tree, updateJson } from \"@nx/devkit\";\nimport * as path from \"path\";\nimport { AddGraphqlGeneratorSchema } from \"./schema\";\n\n/**\n * Setting up Graphql tools for Iris App development\n */\nexport async function addGraphqlGenerator(tree: Tree, options: AddGraphqlGeneratorSchema) {\n const workspaceRoot = \"\";\n const projectConfig = readProjectConfiguration(tree, options.project);\n const libraryRoot = projectConfig.root;\n if (!tree.exists(\"graphql.config.json\") && !tree.exists(\"graphql.config.ts\")) {\n generateFiles(tree, path.join(__dirname, \"files\", \"root\"), workspaceRoot, options);\n } else {\n console.log(\n `\"graphql.config.json\" already exist in your workspace root. \\nPlease ensure that your \"graphql.config.json\" contains \"schema\": \"https://iris.trackunit.com/api/graphql/\".`\n );\n }\n\n if (!tree.exists(`${libraryRoot}/codegen.ts`)) {\n generateFiles(tree, path.join(__dirname, \"files\", \"subDirectory\"), libraryRoot, options);\n } else {\n console.log(`codegen.ts already exists in ${libraryRoot}`);\n }\n\n updateJson(tree, joinPathFragments(libraryRoot, \"project.json\"), projectJSON => {\n projectJSON.targets = {\n ...projectJSON.targets,\n \"graphql-hooks\": {\n executor: \"@trackunit/react-graphql-tools:createHooks\",\n },\n };\n return projectJSON;\n });\n await formatFiles(tree);\n}\n\nexport default addGraphqlGenerator;\n"]}
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/react/graphql-tools/src/generators/add-graphql/generator.ts"],"names":[],"mappings":";;AAQA,kDA4BC;;AApCD,+BAA+B;AAC/B,uCAAuH;AACvH,mDAA6B;AAG7B;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAC,IAAU,EAAE,OAAkC;IACtF,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC;IACvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC7E,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CACT,2KAA2K,CAC5K,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,WAAW,aAAa,CAAC,EAAE,CAAC;QAC9C,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAC3F,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,gCAAgC,WAAW,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,IAAA,mBAAU,EAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,WAAW,EAAE,cAAc,CAAC,EAAE,WAAW,CAAC,EAAE;QAC7E,WAAW,CAAC,OAAO,GAAG;YACpB,GAAG,WAAW,CAAC,OAAO;YACtB,eAAe,EAAE;gBACf,QAAQ,EAAE,4CAA4C;aACvD;SACF,CAAC;QACF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,kBAAe,mBAAmB,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport { formatFiles, generateFiles, joinPathFragments, readProjectConfiguration, Tree, updateJson } from \"@nx/devkit\";\nimport * as path from \"path\";\nimport { AddGraphqlGeneratorSchema } from \"./schema\";\n\n/**\n * Setting up Graphql tools for Iris App development\n */\nexport async function addGraphqlGenerator(tree: Tree, options: AddGraphqlGeneratorSchema) {\n const workspaceRoot = \"\";\n const projectConfig = readProjectConfiguration(tree, options.project);\n const libraryRoot = projectConfig.root;\n if (!tree.exists(\"graphql.config.json\") && !tree.exists(\"graphql.config.ts\")) {\n generateFiles(tree, path.join(__dirname, \"files\", \"root\"), workspaceRoot, options);\n } else {\n console.log(\n `\"graphql.config.json\" already exist in your workspace root. \\nPlease ensure that your \"graphql.config.json\" contains \"schema\": \"https://iris.trackunit.com/api/graphql/\".`\n );\n }\n\n if (!tree.exists(`${libraryRoot}/codegen.ts`)) {\n generateFiles(tree, path.join(__dirname, \"files\", \"subDirectory\"), libraryRoot, options);\n } else {\n console.log(`codegen.ts already exists in ${libraryRoot}`);\n }\n\n updateJson(tree, joinPathFragments(libraryRoot, \"project.json\"), projectJSON => {\n projectJSON.targets = {\n ...projectJSON.targets,\n \"graphql-hooks\": {\n executor: \"@trackunit/react-graphql-tools:createHooks\",\n },\n };\n return projectJSON;\n });\n await formatFiles(tree);\n}\n\nexport default addGraphqlGenerator;\n"]}