@khanacademy/graphql-flow 3.0.0 → 3.0.1

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
@@ -1,5 +1,11 @@
1
1
  # @khanacademy/graphql-flow
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - c6be76f: Search through untracked files for graphql-tag. Don't error out on files that can't be found.
8
+
3
9
  ## 3.0.0
4
10
 
5
11
  ### Major Changes
package/dist/cli/run.js CHANGED
@@ -42,7 +42,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
42
42
 
43
43
  /** Step (1) */
44
44
  const findGraphqlTagReferences = root => {
45
- const response = (0, _child_process.execSync)("git grep -I --word-regexp --name-only --fixed-strings 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'", {
45
+ // NOTE(john): We want to include untracked files here so that we can
46
+ // generate types for them. This is useful for when we have a new file
47
+ // that we want to generate types for, but we haven't committed it yet.
48
+ const response = (0, _child_process.execSync)("git grep -I --word-regexp --name-only --fixed-strings --untracked 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'", {
46
49
  encoding: 'utf8',
47
50
  cwd: root
48
51
  });
@@ -35,7 +35,10 @@ const listExternalReferences = file => {
35
35
  if (v.type === 'import') {
36
36
  if (followImports) {
37
37
  const absPath = (0, _utils.getPathWithExtension)(v.path);
38
- paths[absPath] = true;
38
+
39
+ if (absPath) {
40
+ paths[absPath] = true;
41
+ }
39
42
  }
40
43
  } else {
41
44
  v.source.expressions.forEach(expr => add(expr, true));
@@ -28,9 +28,13 @@ const getPathWithExtension = pathWithoutExtension => {
28
28
 
29
29
  if (_fs.default.existsSync(pathWithoutExtension + '.ts')) {
30
30
  return pathWithoutExtension + '.ts';
31
- }
31
+ } // NOTE(john): This is a bit of a hack, but it's necessary for when we
32
+ // have a file that doesn't exist. This will happen when we delete all of
33
+ // the type files before re-running graphql-flow again. We want to ensure
34
+ // that we don't error out in this case.
35
+
32
36
 
33
- throw new Error("Can't find file at " + pathWithoutExtension);
37
+ return "";
34
38
  };
35
39
 
36
40
  exports.getPathWithExtension = getPathWithExtension;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/graphql-flow",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "bin": {
5
5
  "graphql-flow": "./dist/cli/run.js"
6
6
  },
package/src/cli/run.ts CHANGED
@@ -32,8 +32,11 @@ import {dirname} from 'path';
32
32
  /** Step (1) */
33
33
 
34
34
  const findGraphqlTagReferences = (root: string): Array<string> => {
35
+ // NOTE(john): We want to include untracked files here so that we can
36
+ // generate types for them. This is useful for when we have a new file
37
+ // that we want to generate types for, but we haven't committed it yet.
35
38
  const response = execSync(
36
- "git grep -I --word-regexp --name-only --fixed-strings 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'",
39
+ "git grep -I --word-regexp --name-only --fixed-strings --untracked 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'",
37
40
  {
38
41
  encoding: 'utf8',
39
42
  cwd: root,
@@ -105,7 +105,9 @@ const listExternalReferences = (file: FileResult): Array<string> => {
105
105
  if (v.type === 'import') {
106
106
  if (followImports) {
107
107
  const absPath = getPathWithExtension(v.path);
108
- paths[absPath] = true;
108
+ if (absPath) {
109
+ paths[absPath] = true;
110
+ }
109
111
  }
110
112
  } else {
111
113
  v.source.expressions.forEach((expr) => add(expr, true));
@@ -20,5 +20,9 @@ export const getPathWithExtension = (pathWithoutExtension: string): string => {
20
20
  if (fs.existsSync(pathWithoutExtension + '.ts')) {
21
21
  return pathWithoutExtension + '.ts';
22
22
  }
23
- throw new Error("Can't find file at " + pathWithoutExtension);
23
+ // NOTE(john): This is a bit of a hack, but it's necessary for when we
24
+ // have a file that doesn't exist. This will happen when we delete all of
25
+ // the type files before re-running graphql-flow again. We want to ensure
26
+ // that we don't error out in this case.
27
+ return "";
24
28
  };