@stepzen/transpiler 0.0.33 → 0.0.36

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.
Files changed (66) hide show
  1. package/LICENSE +1 -1
  2. package/lib/actions/configure.js +15 -14
  3. package/lib/actions/configure.js.map +1 -0
  4. package/lib/actions/lint.js +6 -5
  5. package/lib/actions/lint.js.map +1 -0
  6. package/lib/actions/merge.d.ts +2 -0
  7. package/lib/actions/merge.js +80 -70
  8. package/lib/actions/merge.js.map +1 -0
  9. package/lib/actions/print.d.ts +1 -1
  10. package/lib/actions/print.js +2 -1
  11. package/lib/actions/print.js.map +1 -0
  12. package/lib/actions/stitch.js +14 -13
  13. package/lib/actions/stitch.js.map +1 -0
  14. package/lib/actions/transpile.js +7 -6
  15. package/lib/actions/transpile.js.map +1 -0
  16. package/lib/actions/validate.js +4 -3
  17. package/lib/actions/validate.js.map +1 -0
  18. package/lib/index.d.ts +7 -1
  19. package/lib/index.js +16 -16
  20. package/lib/index.js.map +1 -0
  21. package/lib/mutations/config/envvars.js +3 -2
  22. package/lib/mutations/config/envvars.js.map +1 -0
  23. package/lib/mutations/config/index.js +1 -0
  24. package/lib/mutations/config/index.js.map +1 -0
  25. package/lib/utils/constants.js +2 -1
  26. package/lib/utils/constants.js.map +1 -0
  27. package/lib/utils/dedupe-query-and-mutation-types.js +7 -6
  28. package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -0
  29. package/lib/utils/ensure-query-and-mutation-types.d.ts +1 -1
  30. package/lib/utils/ensure-query-and-mutation-types.js +7 -6
  31. package/lib/utils/ensure-query-and-mutation-types.js.map +1 -0
  32. package/lib/utils/graphql-helpers.js +1 -0
  33. package/lib/utils/graphql-helpers.js.map +1 -0
  34. package/lib/utils/merge-helpers.d.ts +2 -1
  35. package/lib/utils/merge-helpers.js +16 -5
  36. package/lib/utils/merge-helpers.js.map +1 -0
  37. package/lib/utils/set-files-in-sdl.js +9 -8
  38. package/lib/utils/set-files-in-sdl.js.map +1 -0
  39. package/lib/utils/strip-empty-queries-and-mutations.d.ts +1 -1
  40. package/lib/utils/strip-empty-queries-and-mutations.js +7 -6
  41. package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -0
  42. package/lib/validators/config-exists/index.d.ts +1 -1
  43. package/lib/validators/config-exists/index.js +11 -10
  44. package/lib/validators/config-exists/index.js.map +1 -0
  45. package/lib/validators/index.js +1 -0
  46. package/lib/validators/index.js.map +1 -0
  47. package/package.json +24 -16
  48. package/src/actions/configure.ts +120 -0
  49. package/src/actions/lint.ts +45 -0
  50. package/src/actions/merge.ts +202 -0
  51. package/src/actions/print.ts +8 -0
  52. package/src/actions/stitch.ts +105 -0
  53. package/src/actions/transpile.ts +70 -0
  54. package/src/actions/validate.ts +54 -0
  55. package/src/index.ts +7 -0
  56. package/src/mutations/config/envvars.ts +17 -0
  57. package/src/mutations/config/index.ts +3 -0
  58. package/src/utils/constants.ts +16 -0
  59. package/src/utils/dedupe-query-and-mutation-types.ts +74 -0
  60. package/src/utils/ensure-query-and-mutation-types.ts +52 -0
  61. package/src/utils/graphql-helpers.ts +3 -0
  62. package/src/utils/merge-helpers.ts +187 -0
  63. package/src/utils/set-files-in-sdl.ts +40 -0
  64. package/src/utils/strip-empty-queries-and-mutations.ts +43 -0
  65. package/src/validators/config-exists/index.ts +54 -0
  66. package/src/validators/index.ts +3 -0
@@ -12,11 +12,11 @@ exports.default = (schema) => {
12
12
  ast = graphql_1.visit(ast, {
13
13
  ObjectTypeDefinition: {
14
14
  enter(node) {
15
- if (node.name.kind === "Name" && node.name.value === "Query") {
15
+ if (node.name.kind === 'Name' && node.name.value === 'Query') {
16
16
  queries = queries.concat(node.fields);
17
17
  return null;
18
18
  }
19
- if (node.name.kind === "Name" && node.name.value === "Mutation") {
19
+ if (node.name.kind === 'Name' && node.name.value === 'Mutation') {
20
20
  mutations = mutations.concat(node.fields);
21
21
  return null;
22
22
  }
@@ -25,18 +25,18 @@ exports.default = (schema) => {
25
25
  });
26
26
  // This is the template for the new Query type
27
27
  const queryTemplate = {
28
- kind: "ObjectTypeDefinition",
28
+ kind: 'ObjectTypeDefinition',
29
29
  description: undefined,
30
- name: { kind: "Name", value: "Query" },
30
+ name: { kind: 'Name', value: 'Query' },
31
31
  interfaces: [],
32
32
  directives: [],
33
33
  fields: [],
34
34
  };
35
35
  // This is the template for the new Mutation type
36
36
  const mutationTemplate = {
37
- kind: "ObjectTypeDefinition",
37
+ kind: 'ObjectTypeDefinition',
38
38
  description: undefined,
39
- name: { kind: "Name", value: "Mutation" },
39
+ name: { kind: 'Name', value: 'Mutation' },
40
40
  interfaces: [],
41
41
  directives: [],
42
42
  fields: [],
@@ -59,3 +59,4 @@ exports.default = (schema) => {
59
59
  }
60
60
  return graphql_1.print(ast);
61
61
  };
62
+ //# sourceMappingURL=dedupe-query-and-mutation-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupe-query-and-mutation-types.js","sourceRoot":"","sources":["../../src/utils/dedupe-query-and-mutation-types.ts"],"names":[],"mappings":";;AAAA,qCAAyD;AAEzD,8DAAkD;AAElD,kBAAe,CAAC,MAAc,EAAU,EAAE;IACxC,IAAI,GAAG,GAAiB,eAAK,CAAC,MAAM,CAAC,CAAA;IAErC,IAAI,OAAO,GAAQ,EAAE,CAAA;IACrB,IAAI,SAAS,GAAQ,EAAE,CAAA;IAEvB,0DAA0D;IAC1D,sBAAsB;IACtB,yCAAyC;IACzC,GAAG,GAAG,eAAK,CAAC,GAAG,EAAE;QACf,oBAAoB,EAAE;YACpB,KAAK,CAAC,IAAI;gBACR,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;oBAC5D,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;oBACrC,OAAO,IAAI,CAAA;iBACZ;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAA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KAAK,CAAC,CAAA;QAC/B,GAAG,GAAG,OAAO,CAAA;KACd;IAED,OAAO,eAAK,CAAC,GAAG,CAAC,CAAA;AACnB,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
- import { DocumentNode } from "graphql";
1
+ import { DocumentNode } from 'graphql';
2
2
  declare const _default: (ast: DocumentNode) => DocumentNode;
3
3
  export default _default;
@@ -9,10 +9,10 @@ exports.default = (ast) => {
9
9
  ast = graphql_1.visit(ast, {
10
10
  ObjectTypeDefinition: {
11
11
  enter(node) {
12
- if (node.name.kind === "Name" && node.name.value === "Query") {
12
+ if (node.name.kind === 'Name' && node.name.value === 'Query') {
13
13
  queries = queries.concat(node.fields);
14
14
  }
15
- if (node.name.kind === "Name" && node.name.value === "Mutation") {
15
+ if (node.name.kind === 'Name' && node.name.value === 'Mutation') {
16
16
  mutations = mutations.concat(node.fields);
17
17
  }
18
18
  },
@@ -22,9 +22,9 @@ exports.default = (ast) => {
22
22
  if (queries.length === 0) {
23
23
  const mutated = graphql_helpers_1.cloneDeep(ast);
24
24
  mutated.definitions.push({
25
- kind: "ObjectTypeDefinition",
25
+ kind: 'ObjectTypeDefinition',
26
26
  description: undefined,
27
- name: { kind: "Name", value: "Query" },
27
+ name: { kind: 'Name', value: 'Query' },
28
28
  interfaces: [],
29
29
  directives: [],
30
30
  fields: [],
@@ -35,9 +35,9 @@ exports.default = (ast) => {
35
35
  if (mutations.length === 0) {
36
36
  const mutated = graphql_helpers_1.cloneDeep(ast);
37
37
  mutated.definitions.push({
38
- kind: "ObjectTypeDefinition",
38
+ kind: 'ObjectTypeDefinition',
39
39
  description: undefined,
40
- name: { kind: "Name", value: "Mutation" },
40
+ name: { kind: 'Name', value: 'Mutation' },
41
41
  interfaces: [],
42
42
  directives: [],
43
43
  fields: [],
@@ -46,3 +46,4 @@ exports.default = (ast) => {
46
46
  }
47
47
  return ast;
48
48
  };
49
+ //# sourceMappingURL=ensure-query-and-mutation-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-query-and-mutation-types.js","sourceRoot":"","sources":["../../src/utils/ensure-query-and-mutation-types.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAE3C,8DAAkD;AAElD,kBAAe,CAAC,GAAiB,EAAgB,EAAE;IACjD,IAAI,OAAO,GAAQ,EAAE,CAAA;IACrB,IAAI,SAAS,GAAQ,EAAE,CAAA;IAEvB,0DAA0D;IAC1D,GAAG,GAAG,eAAK,CAAC,GAAG,EAAE;QACf,oBAAoB,EAAE;YACpB,KAAK,CAAC,IAAI;gBACR,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;oBAC5D,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;iBACtC;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE;oBAC/D,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;iBAC1C;YACH,CAAC;SACF;KACF,CAAC,CAAA;IAEF,yDAAyD;IACzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,MAAM,OAAO,GAAQ,2BAAS,CAAC,GAAG,CAAC,CAAA;QACnC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;YACvB,IAAI,EAAE,sBAAsB;YAC5B,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAC;YACpC,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;SACX,CAAC,CAAA;QACF,GAAG,GAAG,OAAO,CAAA;KACd;IAED,2DAA2D;IAC3D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,MAAM,OAAO,GAAQ,2BAAS,CAAC,GAAG,CAAC,CAAA;QACnC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;YACvB,IAAI,EAAE,sBAAsB;YAC5B,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAC;YACvC,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;SACX,CAAC,CAAA;QACF,GAAG,GAAG,OAAO,CAAA;KACd;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
@@ -5,3 +5,4 @@ const cloneDeep = (obj) => {
5
5
  return JSON.parse(JSON.stringify(obj));
6
6
  };
7
7
  exports.cloneDeep = cloneDeep;
8
+ //# sourceMappingURL=graphql-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-helpers.js","sourceRoot":"","sources":["../../src/utils/graphql-helpers.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,EAAE;IACpC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;AACxC,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB"}
@@ -1,5 +1,6 @@
1
- import { GraphQLSchema } from "graphql";
1
+ import { GraphQLSchema } from 'graphql';
2
2
  export declare const dedupeTempFolder: (dirpath: string) => string;
3
+ export declare const findNextAvailableSubfolder: (folder: string, name: string) => string;
3
4
  export declare const findQueryMutationInSchema: (name: string, files: any) => Boolean;
4
5
  export declare const findTypeInSchema: (name: string, files: any) => Boolean;
5
6
  export declare const getConfiguration: (directories: string[], silent?: boolean, answers?: any) => Promise<string | boolean>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeTypeFromSchema = exports.removeQueryMutationFromSchema = exports.mergeTypeIntoSchema = exports.mergeQueryMutationIntoSchema = exports.getSchema = exports.getExtensions = exports.getConfiguration = exports.findTypeInSchema = exports.findQueryMutationInSchema = exports.dedupeTempFolder = void 0;
3
+ exports.removeTypeFromSchema = exports.removeQueryMutationFromSchema = exports.mergeTypeIntoSchema = exports.mergeQueryMutationIntoSchema = exports.getSchema = exports.getExtensions = exports.getConfiguration = exports.findTypeInSchema = exports.findQueryMutationInSchema = exports.findNextAvailableSubfolder = exports.dedupeTempFolder = void 0;
4
4
  const graphql_1 = require("graphql");
5
5
  const utilities_1 = require("graphql/utilities");
6
6
  const node_fetch_1 = require("node-fetch");
@@ -21,6 +21,16 @@ const dedupeTempFolder = (dirpath) => {
21
21
  return dirpath;
22
22
  };
23
23
  exports.dedupeTempFolder = dedupeTempFolder;
24
+ const findNextAvailableSubfolder = (folder, name) => {
25
+ let subfolder = name;
26
+ let counter = 1;
27
+ while (fs.existsSync(path.join(folder, subfolder))) {
28
+ const suffix = `${counter++}`.padStart(2, '0');
29
+ subfolder = `${name}-${suffix}`;
30
+ }
31
+ return subfolder;
32
+ };
33
+ exports.findNextAvailableSubfolder = findNextAvailableSubfolder;
24
34
  const findQueryMutationInSchema = (name, files) => {
25
35
  for (const file of files) {
26
36
  let found = false;
@@ -60,14 +70,14 @@ const getConfiguration = async (directories, silent = false, answers = {}) => {
60
70
  fs.ensureDirSync(tmp);
61
71
  for (const directory of directories) {
62
72
  const configs = [
63
- ...glob.sync("**/config.yaml", { cwd: directory }),
64
- ...glob.sync("**/stepzen.config.json", { cwd: directory }),
73
+ ...glob.sync('**/config.yaml', { cwd: directory }),
74
+ ...glob.sync('**/stepzen.config.json', { cwd: directory }),
65
75
  ];
66
76
  for (const config of configs) {
67
77
  const configFolder = path.join(directory, config);
68
78
  let writeFolder = path.join(tmp, directory, config);
69
79
  writeFolder = exports.dedupeTempFolder(writeFolder);
70
- const content = fs.readFileSync(configFolder, "utf8");
80
+ const content = fs.readFileSync(configFolder, 'utf8');
71
81
  fs.ensureFileSync(writeFolder);
72
82
  fs.writeFileSync(writeFolder, content);
73
83
  }
@@ -78,7 +88,7 @@ const getConfiguration = async (directories, silent = false, answers = {}) => {
78
88
  };
79
89
  exports.getConfiguration = getConfiguration;
80
90
  const getExtensions = async () => {
81
- const domain = constants_1.STEPZEN_DOMAIN.replace(".io", ".net");
91
+ const domain = constants_1.STEPZEN_DOMAIN.replace('.io', '.net');
82
92
  const response = await node_fetch_1.default(`https://www.${domain}/directives.graphql`);
83
93
  const text = await response.text();
84
94
  return text;
@@ -150,3 +160,4 @@ const removeTypeFromSchema = (name, files) => {
150
160
  return files;
151
161
  };
152
162
  exports.removeTypeFromSchema = removeTypeFromSchema;
163
+ //# sourceMappingURL=merge-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-helpers.js","sourceRoot":"","sources":["../../src/utils/merge-helpers.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,iDAA6C;AAC7C,2CAA8B;AAC9B,+BAA8B;AAC9B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,mCAA8B;AAE9B,8DAAkD;AAClD,2CAA0C;AAE1C,oDAA4C;AAC5C,oDAA4C;AAErC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE;IAClD,GAAG;QACD,OAAO,GAAG,gBAAO,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;KAC5C,QAAQ,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAC;IAEvC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAA;IAEzC,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AARY,QAAA,gBAAgB,oBAQ5B;AAEM,MAAM,0BAA0B,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;IACzE,IAAI,SAAS,GAAG,IAAI,CAAA;IACpB,IAAI,OAAO,GAAG,CAAC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AA6B,iCAczC;AAEM,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,KAAU,EAAE,EAAE;IAC/D,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE;QAC9B,uCACK,IAAI,KACP,GAAG,EAAE,eAAK,CAAC,IAAI,CAAC,GAAG,EAAE;gBACnB,oBAAoB,CAAC,IAAI;oBACvB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE;wBAC5B,OAAO,IAAI,CAAA;qBACZ;gBACH,CAAC;aACF,CAAC,IACH;IACH,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAdY,QAAA,oBAAoB,wBAchC"}
@@ -8,19 +8,19 @@ const graphql_helpers_1 = require("./graphql-helpers");
8
8
  const print_1 = require("../actions/print");
9
9
  exports.default = (source) => {
10
10
  const files = glob
11
- .sync("**/*.graphql", { cwd: source })
12
- .filter((file) => file !== "index.graphql");
13
- const output = path.join(source, "index.graphql");
14
- const index = fs.readFileSync(output, "utf8");
11
+ .sync('**/*.graphql', { cwd: source })
12
+ .filter(file => file !== 'index.graphql');
13
+ const output = path.join(source, 'index.graphql');
14
+ const index = fs.readFileSync(output, 'utf8');
15
15
  let ast = graphql_1.parse(index);
16
16
  ast = graphql_1.visit(ast, {
17
17
  Directive(node) {
18
- if (node.name.value === "sdl") {
18
+ if (node.name.value === 'sdl') {
19
19
  const mutated = graphql_helpers_1.cloneDeep(node);
20
20
  mutated.arguments = mutated.arguments.map((arg) => {
21
- if (arg.name.value === "files") {
22
- arg.value.values = files.map((file) => ({
23
- kind: "StringValue",
21
+ if (arg.name.value === 'files') {
22
+ arg.value.values = files.map(file => ({
23
+ kind: 'StringValue',
24
24
  value: file,
25
25
  }));
26
26
  }
@@ -32,3 +32,4 @@ exports.default = (source) => {
32
32
  });
33
33
  fs.writeFileSync(output, print_1.default(ast));
34
34
  };
35
+ //# sourceMappingURL=set-files-in-sdl.js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,CAAC,CAAA;IAEF,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,eAAK,CAAC,GAAG,CAAC,CAAC,CAAA;AACtC,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
- import { DocumentNode } from "graphql";
1
+ import { DocumentNode } from 'graphql';
2
2
  declare const _default: (ast: DocumentNode) => DocumentNode;
3
3
  export default _default;
@@ -7,17 +7,17 @@ exports.default = (ast) => {
7
7
  ast = graphql_1.visit(ast, {
8
8
  ObjectTypeDefinition: {
9
9
  enter(node) {
10
- if (node.name.kind === "Name" && node.name.value === "Query") {
10
+ if (node.name.kind === 'Name' && node.name.value === 'Query') {
11
11
  const mutated = graphql_helpers_1.cloneDeep(node);
12
12
  mutated.fields = mutated.fields.filter((field) => {
13
- return field.name.value !== "__query";
13
+ return field.name.value !== '__query';
14
14
  });
15
15
  return mutated;
16
16
  }
17
- if (node.name.kind === "Name" && node.name.value === "Mutation") {
17
+ if (node.name.kind === 'Name' && node.name.value === 'Mutation') {
18
18
  const mutated = graphql_helpers_1.cloneDeep(node);
19
19
  mutated.fields = mutated.fields.filter((field) => {
20
- return field.name.value !== "__mutated";
20
+ return field.name.value !== '__mutated';
21
21
  });
22
22
  return mutated;
23
23
  }
@@ -29,11 +29,11 @@ exports.default = (ast) => {
29
29
  ObjectTypeDefinition: {
30
30
  enter(node) {
31
31
  var _a, _b;
32
- if (node.name.kind === "Name" && node.name.value === "Query") {
32
+ if (node.name.kind === 'Name' && node.name.value === 'Query') {
33
33
  if (((_a = node.fields) === null || _a === void 0 ? void 0 : _a.length) === 0)
34
34
  return null;
35
35
  }
36
- if (node.name.kind === "Name" && node.name.value === "Mutation") {
36
+ if (node.name.kind === 'Name' && node.name.value === 'Mutation') {
37
37
  if (((_b = node.fields) === null || _b === void 0 ? void 0 : _b.length) === 0)
38
38
  return null;
39
39
  }
@@ -42,3 +42,4 @@ exports.default = (ast) => {
42
42
  });
43
43
  return ast;
44
44
  };
45
+ //# sourceMappingURL=strip-empty-queries-and-mutations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-empty-queries-and-mutations.js","sourceRoot":"","sources":["../../src/utils/strip-empty-queries-and-mutations.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAE3C,uDAA2C;AAE3C,kBAAe,CAAC,GAAiB,EAAgB,EAAE;IACjD,iEAAiE;IACjE,GAAG,GAAG,eAAK,CAAC,GAAG,EAAE;QACf,oBAAoB,EAAE;YACpB,KAAK,CAAC,IAAI;gBACR,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;oBAC5D,MAAM,OAAO,GAAQ,2BAAS,CAAC,IAAI,CAAC,CAAA;oBACpC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE;wBACpD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAA;oBACvC,CAAC,CAAC,CAAA;oBACF,OAAO,OAAO,CAAA;iBACf;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE;oBAC/D,MAAM,OAAO,GAAQ,2BAAS,CAAC,IAAI,CAAC,CAAA;oBACpC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE;wBACpD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,WAAW,CAAA;oBACzC,CAAC,CAAC,CAAA;oBACF,OAAO,OAAO,CAAA;iBACf;YACH,CAAC;SACF;KACF,CAAC,CAAA;IAEF,gDAAgD;IAChD,GAAG,GAAG,eAAK,CAAC,GAAG,EAAE;QACf,oBAAoB,EAAE;YACpB,KAAK,CAAC,IAAI;;gBACR,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE;oBAC5D,IAAI,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,MAAM,MAAK,CAAC;wBAAE,OAAO,IAAI,CAAA;iBAC3C;gBACD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE;oBAC/D,IAAI,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,MAAM,MAAK,CAAC;wBAAE,OAAO,IAAI,CAAA;iBAC3C;YACH,CAAC;SACF;KACF,CAAC,CAAA;IAEF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
- import { DocumentNode } from "graphql";
1
+ import { DocumentNode } from 'graphql';
2
2
  declare const _default: (ast: DocumentNode, source: string) => boolean;
3
3
  export default _default;
@@ -6,11 +6,11 @@ const fs = require("fs");
6
6
  const path = require("path");
7
7
  const yaml = require("yaml");
8
8
  const STEPZEN_DEFAULTS = [
9
- "fedex_default",
10
- "holidayapi_default",
11
- "ipapi_default",
12
- "owm_default",
13
- "ups_default",
9
+ 'fedex_default',
10
+ 'holidayapi_default',
11
+ 'ipapi_default',
12
+ 'owm_default',
13
+ 'ups_default',
14
14
  ];
15
15
  exports.default = (ast, source) => {
16
16
  var _a;
@@ -20,19 +20,19 @@ exports.default = (ast, source) => {
20
20
  var _a, _b;
21
21
  const name = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value;
22
22
  const value = (_b = node.value) === null || _b === void 0 ? void 0 : _b.value;
23
- if (name === "configuration") {
23
+ if (name === 'configuration') {
24
24
  configs = configs.concat(value);
25
25
  }
26
26
  },
27
27
  });
28
28
  configs = lodash_1.uniq(configs);
29
- configs = lodash_1.filter(configs, (config) => !STEPZEN_DEFAULTS.includes(config));
29
+ configs = lodash_1.filter(configs, config => !STEPZEN_DEFAULTS.includes(config));
30
30
  if (configs.length > 0) {
31
- const sourceConfig = path.join(source, "config.yaml");
31
+ const sourceConfig = path.join(source, 'config.yaml');
32
32
  if (!fs.existsSync(sourceConfig)) {
33
- throw new Error("No config.yaml found");
33
+ throw new Error('No config.yaml found');
34
34
  }
35
- const content = fs.readFileSync(sourceConfig, "utf8");
35
+ const content = fs.readFileSync(sourceConfig, 'utf8');
36
36
  const asYaml = yaml.parse(content);
37
37
  for (const config of configs) {
38
38
  const found = (_a = asYaml === null || asYaml === void 0 ? void 0 : asYaml.configurationset) === null || _a === void 0 ? void 0 : _a.find((c) => {
@@ -46,3 +46,4 @@ exports.default = (ast, source) => {
46
46
  }
47
47
  return true;
48
48
  };
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/validators/config-exists/index.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAC3C,mCAAmC;AACnC,yBAAwB;AACxB,6BAA4B;AAC5B,6BAA4B;AAE5B,MAAM,gBAAgB,GAAG;IACvB,eAAe;IACf,oBAAoB;IACpB,eAAe;IACf,aAAa;IACb,aAAa;CACd,CAAA;AAED,kBAAe,CAAC,GAAiB,EAAE,MAAc,EAAE,EAAE;;IACnD,IAAI,OAAO,GAAQ,EAAE,CAAA;IAErB,eAAK,CAAC,GAAG,EAAE;QACT,QAAQ,CAAC,IAAS;;YAChB,MAAM,IAAI,GAAG,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAA;YAC7B,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,CAAA;YAE/B,IAAI,IAAI,KAAK,eAAe,EAAE;gBAC5B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;aAChC;QACH,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,GAAG,aAAI,CAAC,OAAO,CAAC,CAAA;IACvB,OAAO,GAAG,eAAM,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IAEvE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;QAErD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;SACxC;QAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAElC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,MAAM,KAAK,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,0CAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE;;gBACtD,OAAO,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,aAAa,0CAAE,IAAI,MAAK,MAAM,CAAA;YAC1C,CAAC,CAAC,CAAA;YAEF,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,0CAA0C,MAAM,GAAG,CAAC,CAAA;aACrE;SACF;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -2,3 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config_exists_1 = require("./config-exists");
4
4
  exports.default = [config_exists_1.default];
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":";;AAAA,mDAA0C;AAE1C,kBAAe,CAAC,uBAAY,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,53 +1,61 @@
1
1
  {
2
2
  "name": "@stepzen/transpiler",
3
3
  "description": "The StepZen transpiler",
4
- "version": "0.0.33",
4
+ "version": "0.0.36",
5
5
  "author": "Darren Waddell <darren@stepzen.com>",
6
6
  "license": "MIT",
7
7
  "files": [
8
- "lib/**/*"
8
+ "lib/**/*",
9
+ "src/**/*"
9
10
  ],
10
11
  "main": "lib/index.js",
12
+ "types": "lib/index.d.ts",
11
13
  "engines": {
12
14
  "node": ">=14.0.1",
13
15
  "npm": ">=6.14"
14
16
  },
15
17
  "scripts": {
16
- "test": "rm -rf lib && tsc -b && nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\""
18
+ "prepare": "husky install",
19
+ "test": "rm -rf lib && tsc -b && nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
20
+ "posttest": "prettier . --check"
17
21
  },
18
22
  "dependencies": {
19
- "@graphql-tools/merge": "^6.2.13",
20
- "debug": "^4.3.1",
23
+ "@graphql-tools/merge": "^6.2.17",
24
+ "debug": "^4.3.3",
21
25
  "dotenv": "^10.0.0",
22
26
  "fs-extra": "^9.1.0",
23
- "glob": "^7.1.6",
24
- "graphql": "^15.5.0",
25
- "has-flag": "^5.0.0",
26
- "inquirer": "^8.0.0",
27
+ "glob": "^7.2.0",
28
+ "graphql": "^15.8.0",
29
+ "inquirer": "^8.2.0",
27
30
  "lodash": "^4.17.21",
28
- "node-fetch": "^2.6.1",
29
- "prettier": "^2.2.1",
30
- "shelljs": "^0.8.4",
31
+ "node-fetch": "^2.6.7",
32
+ "prettier": "^2.5.1",
33
+ "shelljs": "^0.8.5",
31
34
  "yaml": "^1.10.2"
32
35
  },
33
36
  "devDependencies": {
34
- "@types/debug": "^4.1.5",
37
+ "@types/debug": "^4.1.7",
35
38
  "@types/fs-extra": "^9.0.11",
36
- "@types/glob": "^7.1.3",
39
+ "@types/glob": "^7.2.0",
37
40
  "@types/inquirer": "^7.3.1",
38
41
  "@types/lodash": "^4.14.168",
39
42
  "@types/mocha": "^8.2.2",
40
43
  "@types/mock-fs": "^4.13.0",
41
- "@types/node-fetch": "^2.5.10",
42
- "@types/prettier": "^2.2.3",
44
+ "@types/node-fetch": "^2.6.1",
45
+ "@types/prettier": "^2.4.4",
43
46
  "@types/shelljs": "^0.8.9",
44
47
  "chai": "^4.3.4",
45
48
  "fancy-test": "^1.4.10",
49
+ "husky": "^7.0.4",
50
+ "lint-staged": "^12.3.4",
46
51
  "mocha": "^9.0.1",
47
52
  "mock-fs": "^4.13.0",
48
53
  "node-ts": "^5.1.1",
49
54
  "nyc": "^14.1.1",
50
55
  "ts-node": "^9.1.1",
51
56
  "typescript": "^4.2.4"
57
+ },
58
+ "lint-staged": {
59
+ "*.{ts,js,css,md,yaml,json}": "prettier --write"
52
60
  }
53
61
  }
@@ -0,0 +1,120 @@
1
+ import * as debug from 'debug'
2
+ import * as fs from 'fs-extra'
3
+ import * as glob from 'glob'
4
+ import * as inquirer from 'inquirer'
5
+ import * as path from 'path'
6
+ import * as yaml from 'yaml'
7
+
8
+ export default async (source: string, silent = false, answers: any = {}) => {
9
+ let config: any = {
10
+ configurationset: [],
11
+ ruleset: [],
12
+ }
13
+
14
+ // Now let's parse and add any config.yamls
15
+ for (const y of glob.sync('**/config.yaml', {cwd: source})) {
16
+ const filePath = path.join(source, y)
17
+
18
+ const file = fs.readFileSync(filePath, 'utf8')
19
+ const asYAML = yaml.parse(file)
20
+
21
+ debug('stepzen:transpiler')(`Adding config.yaml ${filePath}`)
22
+ debug('stepzen:transpiler')(`Contents: ${JSON.stringify(asYAML, null, 2)}`)
23
+
24
+ if (asYAML.configurationset) {
25
+ config.configurationset = config.configurationset.concat(
26
+ asYAML.configurationset,
27
+ )
28
+ }
29
+
30
+ if (asYAML.ruleset) {
31
+ config.ruleset = config.ruleset.concat(asYAML.ruleset)
32
+ }
33
+ }
34
+
35
+ // Now let's build configs from questions
36
+ for await (const j of glob.sync('**/stepzen.config.json', {
37
+ cwd: source,
38
+ })) {
39
+ const filePath = path.join(source, j)
40
+
41
+ const file = fs.readFileSync(filePath, 'utf8')
42
+ const asJSON = JSON.parse(file)
43
+
44
+ debug('stepzen:transpiler')(`Adding stepzen.config.json ${filePath}`)
45
+ debug('stepzen:transpiler')(`Contents: ${JSON.stringify(asJSON, null, 2)}`)
46
+
47
+ if (asJSON.config?.questions) {
48
+ for await (const question of asJSON.config?.questions) {
49
+ const [name, key] = question.name.split('.')
50
+
51
+ let answer: any = {}
52
+
53
+ if (silent) {
54
+ answer = {
55
+ [name]: {[key]: answers[name]?.[key] ? answers[name]?.[key] : ''},
56
+ }
57
+ } else {
58
+ answer = await inquirer.prompt({
59
+ type: 'password',
60
+ ...question,
61
+ })
62
+ }
63
+
64
+ const configset = {
65
+ configuration: {
66
+ name,
67
+ [key]: answer[name][key],
68
+ },
69
+ }
70
+
71
+ debug('stepzen:transpiler')(
72
+ `Question: ${JSON.stringify(question, null, 2)}`,
73
+ )
74
+ debug('stepzen:transpiler')(
75
+ `Answer: ${JSON.stringify(configset, null, 2)}`,
76
+ )
77
+
78
+ config.configurationset.push({...configset})
79
+ }
80
+ }
81
+ }
82
+
83
+ debug('stepzen:transpiler')(
84
+ `Configuration: ${JSON.stringify(config, null, 2)}`,
85
+ )
86
+
87
+ // OK now let's collate everything into shared configurations
88
+ const obj: any = {}
89
+ for (const c of config.configurationset) {
90
+ const name = c.configuration.name
91
+ if (!obj[name]) obj[name] = {}
92
+ for (const [key, value] of Object.entries(c.configuration)) {
93
+ if (key === name) continue
94
+ obj[name][key] = value
95
+ }
96
+ }
97
+
98
+ // Now convert back into StepZen format
99
+ const structured: any = {
100
+ configurationset: [],
101
+ ruleset: [],
102
+ }
103
+ for (const configuration of Object.keys(obj)) {
104
+ structured.configurationset.push({
105
+ configuration: {...obj[configuration]},
106
+ })
107
+ }
108
+ structured.ruleset = [...config.ruleset]
109
+
110
+ // Return YAML, if appropriate
111
+ if (structured.configurationset.length === 0)
112
+ delete structured.configurationset
113
+ if (structured.ruleset.length === 0) delete structured.ruleset
114
+
115
+ if (structured.configurationset || structured.ruleset) {
116
+ return yaml.stringify(structured)
117
+ }
118
+
119
+ return false
120
+ }
@@ -0,0 +1,45 @@
1
+ import fetch from 'node-fetch'
2
+ import * as fs from 'fs-extra'
3
+ import * as os from 'os'
4
+ import * as path from 'path'
5
+ import * as shell from 'shelljs'
6
+
7
+ import stitch from '../actions/stitch'
8
+
9
+ export default async (
10
+ source: string,
11
+ options: {
12
+ extensions: string
13
+ } = {
14
+ extensions: '',
15
+ },
16
+ ) => {
17
+ if (!fs.existsSync(source)) {
18
+ throw new Error(`Cannot find source directory ${source}`)
19
+ }
20
+
21
+ let extensions = options.extensions
22
+
23
+ if (!extensions) {
24
+ const response = await fetch('https://www.steprz.net/directives.graphql')
25
+ extensions = await response.text()
26
+ }
27
+
28
+ const stitched = stitch(source)
29
+ const index = path.join(stitched, 'index.graphql')
30
+ const graphql = fs.readFileSync(index, 'utf8')
31
+
32
+ const tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`)
33
+ fs.ensureDirSync(tmp)
34
+ const lintFile = path.join(tmp, 'index.graphql')
35
+ fs.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`)
36
+
37
+ shell.exec(
38
+ `npx graphql-schema-linter ${lintFile}`,
39
+ {silent: true},
40
+ (code, stdout, stderr) => {
41
+ console.log(stdout)
42
+ fs.removeSync(tmp)
43
+ },
44
+ )
45
+ }