@toptal/davinci-graphql-codegen 0.4.2-alpha-fix-wrong-data-structure-in-analytics-e998b099.7 → 0.4.2

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,13 @@
1
1
  # @toptal/davinci-graphql-codegen
2
2
 
3
+ ## 0.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`1457314e`](https://github.com/toptal/davinci/commit/1457314e7f449146077753dcc467565e6ce4d3d2)]:
8
+ - @toptal/davinci-cli-shared@1.10.2
9
+ - @toptal/davinci-monorepo@6.8.8
10
+
3
11
  ## 0.4.1
4
12
 
5
13
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-graphql-codegen",
3
- "version": "0.4.2-alpha-fix-wrong-data-structure-in-analytics-e998b099.7+e998b099",
3
+ "version": "0.4.2",
4
4
  "description": "Codegen",
5
5
  "author": "Toptal",
6
6
  "license": "ISC",
@@ -11,10 +11,13 @@
11
11
  "bin": {
12
12
  "davinci-graphql-codegen": "./bin/davinci-graphql-codegen.js"
13
13
  },
14
- "main": "./src/index.js",
14
+ "main": "src/index.js",
15
+ "files": [
16
+ "src",
17
+ "bin",
18
+ "CHANGELOG.md"
19
+ ],
15
20
  "scripts": {
16
- "build:package": "../../bin/build-package.js",
17
- "prepublishOnly": "../../bin/prepublish.js",
18
21
  "test": "echo \"Error: no test specified\" && exit 1"
19
22
  },
20
23
  "sideEffects": false,
@@ -29,16 +32,15 @@
29
32
  "@graphql-codegen/typescript-operations": "^2.3.5",
30
33
  "@graphql-codegen/typescript-resolvers": "^2.2.1",
31
34
  "@graphql-typed-document-node/core": "^3.1.0",
32
- "@toptal/davinci-cli-shared": "1.10.2-alpha-fix-wrong-data-structure-in-analytics-e998b099.7+e998b099",
33
- "@toptal/davinci-monorepo": "6.8.8-alpha-fix-wrong-data-structure-in-analytics-e998b099.7+e998b099",
35
+ "@toptal/davinci-cli-shared": "^1.10.2",
36
+ "@toptal/davinci-monorepo": "6.8.8",
34
37
  "chalk": "^4.1.2",
35
38
  "deepmerge": "^4.2.2",
36
- "fs-extra": "^10.1.0",
37
39
  "graphql": "^15.7.1",
38
- "prettier": "^2.6.2"
40
+ "prettier": "^2.6.2",
41
+ "fs-extra": "^10.1.0"
39
42
  },
40
43
  "peerDependencies": {
41
44
  "prettier": "^2.6.2"
42
- },
43
- "gitHead": "e998b09949b7b22fd1305544729bb6665fcfe092"
45
+ }
44
46
  }
@@ -0,0 +1,71 @@
1
+ jest.mock('@toptal/davinci-monorepo', () => ({
2
+ commands: [],
3
+ utils: { checkIfMonorepo: jest.fn() },
4
+ }))
5
+
6
+ jest.mock('./get-monorepo-schema-path', () =>
7
+ jest.fn(() => ({
8
+ target: 'talent',
9
+ schemaPath: '@toptal/modularity-template-graphql',
10
+ schemaPathResolution:
11
+ 'home/users/alexvcasillas/toptal/libs/graphql/schema.graphql',
12
+ }))
13
+ )
14
+
15
+ jest.mock('./get-monolith-schema-path', () =>
16
+ jest.fn(() => ({
17
+ target: 'src/modules/graphql',
18
+ schemaPath: 'src/modules/graphql',
19
+ schemaPathResolution:
20
+ 'home/users/alexvcasillas/toptal/screening-wizard/src/modules/graphql/schema.graphql',
21
+ }))
22
+ )
23
+
24
+ const {
25
+ utils: { checkIfMonorepo },
26
+ } = require('@toptal/davinci-monorepo')
27
+
28
+ const getSchemaPath = require('./get-schema-path')
29
+
30
+ const monorepoSchema = '@toptal/modularity-template-graphql/talent'
31
+ const monolithSchema = 'src/modules/graphql'
32
+
33
+ describe('getSchemaPath', () => {
34
+ beforeEach(() => {
35
+ checkIfMonorepo.mockReset()
36
+ })
37
+
38
+ it('returns target, schemaPath and schemaPathResolution for monorepo', () => {
39
+ checkIfMonorepo.mockReturnValue(() => true)
40
+
41
+ const { target, schemaPath, schemaPathResolution } =
42
+ getSchemaPath(monorepoSchema)
43
+
44
+ expect(checkIfMonorepo).toHaveBeenCalledTimes(1)
45
+ expect(checkIfMonorepo).toHaveBeenCalledWith({
46
+ considerYarnWorkspaces: true,
47
+ })
48
+ expect(target).toBe('talent')
49
+ expect(schemaPath).toBe('@toptal/modularity-template-graphql')
50
+ expect(schemaPathResolution).toBe(
51
+ 'home/users/alexvcasillas/toptal/libs/graphql/schema.graphql'
52
+ )
53
+ })
54
+
55
+ it('returns target, schemaPath and schemaPathResolution for monolith', () => {
56
+ checkIfMonorepo.mockReturnValue(false)
57
+
58
+ const { target, schemaPath, schemaPathResolution } =
59
+ getSchemaPath(monolithSchema)
60
+
61
+ expect(checkIfMonorepo).toHaveBeenCalledTimes(1)
62
+ expect(checkIfMonorepo).toHaveBeenCalledWith({
63
+ considerYarnWorkspaces: true,
64
+ })
65
+ expect(target).toBe('src/modules/graphql')
66
+ expect(schemaPath).toBe('src/modules/graphql')
67
+ expect(schemaPathResolution).toBe(
68
+ 'home/users/alexvcasillas/toptal/screening-wizard/src/modules/graphql/schema.graphql'
69
+ )
70
+ })
71
+ })
@@ -0,0 +1,29 @@
1
+ const {
2
+ isSchemaFromBucket,
3
+ isSchemaFromHttp,
4
+ isLocalSchema,
5
+ } = require('./detect-schema-source')
6
+
7
+ const gsBucketSchema = 'gs://toptal.net/gateway/graphql/talent'
8
+ const httpSchema = 'https://toptal.net/gateway/graphql/talent'
9
+ const localSchema = '../../graphql/talent'
10
+
11
+ describe('Detect Schema Sources', () => {
12
+ it('detects that schema is from GS Bucket', () => {
13
+ expect(isSchemaFromBucket(gsBucketSchema)).toBe(true)
14
+ expect(isSchemaFromHttp(gsBucketSchema)).toBe(false)
15
+ expect(isLocalSchema(gsBucketSchema)).toBe(false)
16
+ })
17
+
18
+ it('detects that schema is from http', () => {
19
+ expect(isSchemaFromBucket(httpSchema)).toBe(false)
20
+ expect(isSchemaFromHttp(httpSchema)).toBe(true)
21
+ expect(isLocalSchema(httpSchema)).toBe(false)
22
+ })
23
+
24
+ it('detects that schema is from local folder', () => {
25
+ expect(isSchemaFromBucket(localSchema)).toBe(false)
26
+ expect(isSchemaFromHttp(localSchema)).toBe(false)
27
+ expect(isLocalSchema(localSchema)).toBe(true)
28
+ })
29
+ })
@@ -0,0 +1,12 @@
1
+ const parseGSURI = require('./parse-gs-uri')
2
+
3
+ const bucketURI = 'gs://gqlgw-introspection/staging_talent_schema.graphql'
4
+
5
+ describe('Parse Google Storage Bucket URI', () => {
6
+ it('parses a Google Storage Bucket URI correctly', () => {
7
+ const { bucketName, fileName } = parseGSURI(bucketURI)
8
+
9
+ expect(bucketName).toBe('gqlgw-introspection')
10
+ expect(fileName).toBe('staging_talent_schema.graphql')
11
+ })
12
+ })
@@ -0,0 +1,10 @@
1
+ const processArgs = require('./process-args')
2
+
3
+ describe('Argument processor', () => {
4
+ it('process arguments correctly', () => {
5
+ const args = processArgs(['generate-operations', '--projectId=toptal'])
6
+
7
+ expect(args.operation).toBe('generate-operations')
8
+ expect(args.projectId).toBe('toptal')
9
+ })
10
+ })
@@ -0,0 +1,15 @@
1
+ const toArray = require('./to-array')
2
+
3
+ describe('toArray', () => {
4
+ it("converts a value into an array if it's not one", () => {
5
+ const asArray = toArray('hello')
6
+
7
+ expect(Array.isArray(asArray)).toBe(true)
8
+ })
9
+
10
+ it("returns the array as is if it's an array", () => {
11
+ const asArray = toArray(['hello', 'there'])
12
+
13
+ expect(Array.isArray(asArray)).toBe(true)
14
+ })
15
+ })
package/esbuild.js DELETED
@@ -1,16 +0,0 @@
1
- const esbuild = require('esbuild')
2
- // Automatically exclude all node_modules from the bundled version
3
- const { nodeExternalsPlugin } = require('esbuild-node-externals')
4
-
5
- esbuild
6
- .build({
7
- entryPoints: ['./bin/davinci-graphql-codegen.ts'],
8
- outdir: 'dist-package',
9
- bundle: true,
10
- minify: false,
11
- platform: 'node',
12
- sourcemap: true,
13
- target: 'node14',
14
- plugins: [nodeExternalsPlugin()],
15
- })
16
- .catch(() => process.exit(1))
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist-package",
5
- "noEmit": false,
6
- "paths": {}
7
- }
8
- }