@toptal/davinci-graphql-codegen 0.4.2-alpha-fx-3227-migrate-graphql-codegen-to-esm-b0005a16.21 → 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
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import cliEngine from '@toptal/davinci-cli-shared'
3
2
 
4
- import codegenGenerateSchemaCreator from '../src/commands/generate-schema.js'
5
- import codegenGenerateOperationsCreator from '../src/commands/generate-operations.js'
3
+ const cliEngine = require('@toptal/davinci-cli-shared')
4
+
5
+ const codegenGenerateSchemaCreator = require('../src/commands/generate-schema')
6
+ const codegenGenerateOperationsCreator = require('../src/commands/generate-operations')
6
7
 
7
8
  cliEngine.loadCommands(
8
9
  [codegenGenerateSchemaCreator, codegenGenerateOperationsCreator],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-graphql-codegen",
3
- "version": "0.4.2-alpha-fx-3227-migrate-graphql-codegen-to-esm-b0005a16.21+b0005a16",
3
+ "version": "0.4.2",
4
4
  "description": "Codegen",
5
5
  "author": "Toptal",
6
6
  "license": "ISC",
@@ -11,12 +11,14 @@
11
11
  "bin": {
12
12
  "davinci-graphql-codegen": "./bin/davinci-graphql-codegen.js"
13
13
  },
14
- "type": "module",
15
- "exports": "./index.js",
14
+ "main": "src/index.js",
15
+ "files": [
16
+ "src",
17
+ "bin",
18
+ "CHANGELOG.md"
19
+ ],
16
20
  "scripts": {
17
- "build:package": "../../bin/build-package.js",
18
- "prepublishOnly": "../../bin/prepublish.js",
19
- "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' yarn jest"
21
+ "test": "echo \"Error: no test specified\" && exit 1"
20
22
  },
21
23
  "sideEffects": false,
22
24
  "dependencies": {
@@ -30,19 +32,15 @@
30
32
  "@graphql-codegen/typescript-operations": "^2.3.5",
31
33
  "@graphql-codegen/typescript-resolvers": "^2.2.1",
32
34
  "@graphql-typed-document-node/core": "^3.1.0",
33
- "@toptal/davinci-cli-shared": "1.10.2-alpha-fx-3227-migrate-graphql-codegen-to-esm-b0005a16.21+b0005a16",
34
- "@toptal/davinci-monorepo": "6.8.8-alpha-fx-3227-migrate-graphql-codegen-to-esm-b0005a16.21+b0005a16",
35
+ "@toptal/davinci-cli-shared": "^1.10.2",
36
+ "@toptal/davinci-monorepo": "6.8.8",
35
37
  "chalk": "^4.1.2",
36
38
  "deepmerge": "^4.2.2",
37
- "fs-extra": "^10.1.0",
38
- "graphql": "^15.7.1"
39
+ "graphql": "^15.7.1",
40
+ "prettier": "^2.6.2",
41
+ "fs-extra": "^10.1.0"
39
42
  },
40
43
  "peerDependencies": {
41
44
  "prettier": "^2.6.2"
42
- },
43
- "devDependencies": {
44
- "@jest/globals": "^29.3.1",
45
- "prettier": "^2.6.2"
46
- },
47
- "gitHead": "b0005a1651c57d39a2a20fc68fb19d2908470c09"
45
+ }
48
46
  }
@@ -1,7 +1,7 @@
1
- import chalk from 'chalk'
1
+ const chalk = require('chalk')
2
2
 
3
- import { generateOperations } from '../generate/index.js'
4
- import readConfig from '../read-config/index.js'
3
+ const { generateOperations } = require('../generate')
4
+ const readConfig = require('../read-config')
5
5
 
6
6
  const codegenGenerateOperations = async ({ config, extension = '.ts' }) => {
7
7
  const codegen = await readConfig(config)
@@ -40,4 +40,4 @@ const codegenGenerateOperationsCreator = {
40
40
  },
41
41
  }
42
42
 
43
- export default codegenGenerateOperationsCreator
43
+ module.exports = codegenGenerateOperationsCreator
@@ -1,7 +1,7 @@
1
- import chalk from 'chalk'
1
+ const chalk = require('chalk')
2
2
 
3
- import { generateSchema } from '../generate/index.js'
4
- import readConfig from '../read-config/index.js'
3
+ const { generateSchema } = require('../generate')
4
+ const readConfig = require('../read-config')
5
5
 
6
6
  const codegenGenerateSchema = async ({ projectId = 'toptal-hub', config }) => {
7
7
  const codegen = await readConfig(config)
@@ -36,4 +36,4 @@ const codegenGenerateSchemaCreator = {
36
36
  },
37
37
  }
38
38
 
39
- export default codegenGenerateSchemaCreator
39
+ module.exports = codegenGenerateSchemaCreator
@@ -23,7 +23,7 @@ const commonTypesConfig = {
23
23
  },
24
24
  }
25
25
 
26
- export const commonSchemaTypesConfig = {
26
+ const commonSchemaTypesConfig = {
27
27
  ...commonTypesConfig,
28
28
  resolverTypeWrapperSignature:
29
29
  '(parent: unknown, args: any) => ({ [K in keyof Partial<T>]: TypeOrMockList<T[K]> }) | null',
@@ -33,17 +33,17 @@ export const commonSchemaTypesConfig = {
33
33
  optionalResolveType: true,
34
34
  }
35
35
 
36
- export const commonOperationTypesConfig = {
36
+ const commonOperationTypesConfig = {
37
37
  ...commonTypesConfig,
38
38
  dedupeFragments: true,
39
39
  }
40
40
 
41
- export const autoGenerationComments = [
41
+ const autoGenerationComments = [
42
42
  '/* eslint-disable */',
43
43
  '/* ⚠️ THIS IS AN AUTOGENERATED FILE, DO NOT EDIT ⚠️ */',
44
44
  ]
45
45
 
46
- export default {
46
+ module.exports = {
47
47
  commonOperationTypesConfig,
48
48
  commonSchemaTypesConfig,
49
49
  autoGenerationComments,
@@ -1,3 +1,3 @@
1
- import config from './config.js'
1
+ const config = require('./config')
2
2
 
3
- export default config
3
+ module.exports = config
@@ -1,5 +1,4 @@
1
- import generateOperations from './operations.js'
2
- import generateSchema from './schema.js'
1
+ const generateOperations = require('./operations')
2
+ const generateSchema = require('./schema')
3
3
 
4
- export { generateOperations, generateSchema }
5
- export default { generateOperations, generateSchema }
4
+ module.exports = { generateOperations, generateSchema }
@@ -1,18 +1,16 @@
1
- import chalk from 'chalk'
2
- import { generate } from '@graphql-codegen/cli'
3
- import fs from 'fs-extra'
4
- import prettier from 'prettier'
5
- import { dirname } from 'path'
6
- import merge from 'deepmerge'
1
+ const chalk = require('chalk')
2
+ const { generate } = require('@graphql-codegen/cli')
3
+ const { readFileSync, writeFileSync } = require('fs-extra')
4
+ const prettier = require('prettier')
5
+ const { dirname } = require('path')
6
+ const merge = require('deepmerge')
7
7
 
8
- import {
8
+ const {
9
9
  commonOperationTypesConfig,
10
10
  autoGenerationComments,
11
- } from '../config/config.js'
12
- import getSchemaPath from '../services/get-schema-path.js'
13
- import getRelativeFilePath from '../utils/get-relative-file-path.js'
14
-
15
- const { readFileSync, writeFileSync } = fs
11
+ } = require('../config/config')
12
+ const getSchemaPath = require('../services/get-schema-path')
13
+ const getRelativeFilePath = require('../utils/get-relative-file-path')
16
14
 
17
15
  const generateOperations = async ({ schema, documents, extension, config }) => {
18
16
  const docsPath = getRelativeFilePath(documents)
@@ -67,4 +65,4 @@ const generateOperations = async ({ schema, documents, extension, config }) => {
67
65
  )
68
66
  }
69
67
 
70
- export default generateOperations
68
+ module.exports = generateOperations
@@ -1,18 +1,15 @@
1
- import { generate } from '@graphql-codegen/cli'
2
- import chalk from 'chalk'
3
- import { createRequire } from 'module'
4
- import { readFileSync, writeFileSync } from 'fs'
5
- import prettier from 'prettier'
6
- import { dirname } from 'path'
1
+ const { generate } = require('@graphql-codegen/cli')
2
+ const chalk = require('chalk')
3
+ const { readFileSync, writeFileSync } = require('fs')
4
+ const prettier = require('prettier')
5
+ const { dirname } = require('path')
7
6
 
8
- import {
7
+ const {
9
8
  commonSchemaTypesConfig,
10
9
  autoGenerationComments,
11
- } from '../config/config.js'
12
- import schemaLoader from '../services/schema-loader.js'
13
- import { isSchemaFromHttp } from '../utils/detect-schema-source.js'
14
-
15
- const localRequire = createRequire(import.meta.url)
10
+ } = require('../config/config')
11
+ const schemaLoader = require('../services/schema-loader')
12
+ const { isSchemaFromHttp } = require('../utils/detect-schema-source')
16
13
 
17
14
  const generateSchema = async ({ schema, target, projectId }) => {
18
15
  const { schema: schemaPath, destination: destinationPathTs } =
@@ -30,7 +27,7 @@ const generateSchema = async ({ schema, target, projectId }) => {
30
27
  [destinationPathTs]: {
31
28
  schema: isSchemaFromHttp(schema)
32
29
  ? schema
33
- : localRequire.resolve(schemaPath),
30
+ : require.resolve(schemaPath),
34
31
  plugins: [
35
32
  'typescript',
36
33
  'typescript-resolvers',
@@ -67,4 +64,4 @@ const generateSchema = async ({ schema, target, projectId }) => {
67
64
  )
68
65
  }
69
66
 
70
- export default generateSchema
67
+ module.exports = generateSchema
package/src/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import codegenGenerateSchemaCreator from './commands/generate-schema.js'
2
- import codegenGenerateOperationsCreator from './commands/generate-operations.js'
3
- import config from './config'
1
+ const codegenGenerateSchemaCreator = require('./commands/generate-schema')
2
+ const codegenGenerateOperationsCreator = require('./commands/generate-operations')
3
+ const config = require('./config')
4
4
 
5
- export default {
5
+ module.exports = {
6
6
  commands: [codegenGenerateSchemaCreator, codegenGenerateOperationsCreator],
7
7
  config,
8
8
  }
@@ -1,3 +1,3 @@
1
- import readConfig from './read-config.js'
1
+ const readConfig = require('./read-config')
2
2
 
3
- export default readConfig
3
+ module.exports = readConfig
@@ -1,32 +1,13 @@
1
- import chalk from 'chalk'
2
- import { createRequire } from 'module'
1
+ const chalk = require('chalk')
3
2
 
4
- import getRelativeFilePath from '../utils/get-relative-file-path.js'
5
- import toArray from '../utils/to-array.js'
6
-
7
- const importCodgenConfig = async path => {
8
- try {
9
- const localRequire = createRequire(import.meta.url)
10
-
11
- return localRequire(path)
12
- } catch (err) {
13
- if (err.code === 'ERR_REQUIRE_ESM') {
14
- const result = await import(path)
15
-
16
- if (!result.default) {
17
- throw Error('codegen has no default export')
18
- }
19
-
20
- return result.default
21
- }
22
- }
23
- }
3
+ const getRelativeFilePath = require('../utils/get-relative-file-path')
4
+ const toArray = require('../utils/to-array')
24
5
 
25
6
  const readConfig = async config => {
26
- const configFileName = config ? config.split('/').pop() : 'codegen.json'
27
-
28
7
  let codegenPath
29
8
 
9
+ const configFileName = config ? config.split('/').pop() : 'codegen.json'
10
+
30
11
  if (config) {
31
12
  console.log(
32
13
  `🔍 Searching for ${chalk.bold(
@@ -38,13 +19,15 @@ const readConfig = async config => {
38
19
  console.log(`🔍 Searching for ${chalk.bold(configFileName)} file`)
39
20
  codegenPath = getRelativeFilePath(configFileName)
40
21
  }
22
+ let codegenConfig
41
23
 
42
24
  try {
43
- return toArray(await importCodgenConfig(codegenPath))
25
+ codegenConfig = require(codegenPath)
44
26
  } catch (error) {
45
- console.log(error)
46
27
  throw new Error(`❌ There is no ${chalk.bold(configFileName)} file`)
47
28
  }
29
+
30
+ return toArray(codegenConfig)
48
31
  }
49
32
 
50
- export default readConfig
33
+ module.exports = readConfig
@@ -1,15 +1,11 @@
1
- import getRelativeFilePath from '../utils/get-relative-file-path.js'
1
+ const getRelativeFilePath = require('../utils/get-relative-file-path')
2
2
 
3
- export const createGetMonolithSchemaPathResolver =
4
- relativeFilePathResolver => schemaPath => {
5
- const schemaPathResolution = relativeFilePathResolver(
6
- `${schemaPath}/schema.graphql`
7
- )
3
+ const getMonolithSchemaPath = schemaPath => {
4
+ const schemaPathResolution = getRelativeFilePath(
5
+ `${schemaPath}/schema.graphql`
6
+ )
8
7
 
9
- return { target: schemaPath, schemaPath, schemaPathResolution }
10
- }
8
+ return { target: schemaPath, schemaPath, schemaPathResolution }
9
+ }
11
10
 
12
- const getMonolithSchemaPath =
13
- createGetMonolithSchemaPathResolver(getRelativeFilePath)
14
-
15
- export default getMonolithSchemaPath
11
+ module.exports = getMonolithSchemaPath
@@ -1,22 +1,14 @@
1
- import { createRequire } from 'module'
2
-
3
- const localRequire = createRequire(import.meta.url)
4
-
5
- export const createGetMonorepoSchemaPathResolver = pathResolver => schema => {
1
+ const getMonorepoSchemaPath = schema => {
6
2
  // @toptal/modularity-template-graphql/talent -> talent
7
3
  const target = schema.split('/').pop()
8
4
  // @toptal/modularity-template-graphql/talent -> @toptal/modularity-template-graphql
9
5
  const schemaPath = schema.split('/').slice(0, 2).join('/')
10
6
 
11
- const schemaPathResolution = pathResolver(
7
+ const schemaPathResolution = require.resolve(
12
8
  `${schemaPath}/${target}/schema.graphql`
13
9
  )
14
10
 
15
11
  return { target, schemaPath, schemaPathResolution }
16
12
  }
17
13
 
18
- const getMonorepoSchemaPath = createGetMonorepoSchemaPathResolver(
19
- localRequire.resolve
20
- )
21
-
22
- export default getMonorepoSchemaPath
14
+ module.exports = getMonorepoSchemaPath
@@ -1,16 +1,14 @@
1
- import monorepo from '@toptal/davinci-monorepo'
1
+ const {
2
+ utils: { checkIfMonorepo },
3
+ } = require('@toptal/davinci-monorepo')
2
4
 
3
- import getMonorepoSchemaPath from './get-monorepo-schema-path.js'
4
- import getMonolithSchemaPath from './get-monolith-schema-path.js'
5
-
6
- const { checkIfMonorepo } = monorepo.utils
5
+ const getMonorepoSchemaPath = require('./get-monorepo-schema-path')
6
+ const getMonolithSchemaPath = require('./get-monolith-schema-path')
7
7
 
8
8
  const getSchemaPath = schema => {
9
- if (checkIfMonorepo({ considerYarnWorkspaces: true })) {
10
- return getMonorepoSchemaPath(schema)
11
- }
12
-
13
- return getMonolithSchemaPath(schema)
9
+ return checkIfMonorepo({ considerYarnWorkspaces: true })
10
+ ? getMonorepoSchemaPath(schema)
11
+ : getMonolithSchemaPath(schema)
14
12
  }
15
13
 
16
- export default getSchemaPath
14
+ module.exports = getSchemaPath
@@ -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
+ })
@@ -1,7 +1,7 @@
1
- import { Storage } from '@google-cloud/storage'
1
+ const { Storage } = require('@google-cloud/storage')
2
2
 
3
- import getRelativeFilePath from '../utils/get-relative-file-path.js'
4
- import parseGSURI from '../utils/parse-gs-uri.js'
3
+ const getRelativeFilePath = require('../utils/get-relative-file-path')
4
+ const parseGSURI = require('../utils/parse-gs-uri')
5
5
 
6
6
  const gsSchemaLoader = async (projectId, source, destination) => {
7
7
  // Creates a Google Storage Client
@@ -17,4 +17,4 @@ const gsSchemaLoader = async (projectId, source, destination) => {
17
17
  })
18
18
  }
19
19
 
20
- export default gsSchemaLoader
20
+ module.exports = gsSchemaLoader
@@ -1,15 +1,15 @@
1
- import chalk from 'chalk'
2
- import { existsSync, copyFileSync, mkdirSync } from 'fs'
1
+ const chalk = require('chalk')
2
+ const { existsSync, copyFileSync, mkdirSync } = require('fs')
3
3
 
4
- import gsSchemaLoader from './gs-schema-loader.js'
5
- import getRelativeFilePath from '../utils/get-relative-file-path.js'
6
- import {
4
+ const gsSchemaLoader = require('./gs-schema-loader')
5
+ const getRelativeFilePath = require('../utils/get-relative-file-path')
6
+ const {
7
7
  isSchemaFromBucket,
8
8
  isLocalSchema,
9
9
  isSchemaFromHttp,
10
- } from '../utils/detect-schema-source.js'
10
+ } = require('../utils/detect-schema-source')
11
11
 
12
- export default async (schema, target, projectId) => {
12
+ module.exports = async (schema, target, projectId) => {
13
13
  if (!existsSync(target)) {
14
14
  console.log("📁 Destination target doesn't exist, creating one for you...")
15
15
  mkdirSync(target)
@@ -1,16 +1,16 @@
1
- export const isSchemaFromBucket = schema => {
1
+ const isSchemaFromBucket = schema => {
2
2
  return schema.startsWith('gs://')
3
3
  }
4
4
 
5
- export const isSchemaFromHttp = schema => {
5
+ const isSchemaFromHttp = schema => {
6
6
  return schema.startsWith('https://')
7
7
  }
8
8
 
9
- export const isLocalSchema = schema => {
9
+ const isLocalSchema = schema => {
10
10
  return !isSchemaFromBucket(schema) && !isSchemaFromHttp(schema)
11
11
  }
12
12
 
13
- export default {
13
+ module.exports = {
14
14
  isSchemaFromBucket,
15
15
  isSchemaFromHttp,
16
16
  isLocalSchema,
@@ -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
+ })
@@ -2,4 +2,4 @@ const getRelativeFilePath = file => {
2
2
  return `${process.cwd()}/${file}`
3
3
  }
4
4
 
5
- export default getRelativeFilePath
5
+ module.exports = getRelativeFilePath
@@ -13,4 +13,4 @@ const parseGSURI = source => {
13
13
  }
14
14
  }
15
15
 
16
- export default parseGSURI
16
+ module.exports = parseGSURI
@@ -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
+ })
@@ -19,4 +19,4 @@ const processArgs = args => {
19
19
  return obj
20
20
  }
21
21
 
22
- export default processArgs
22
+ module.exports = processArgs
@@ -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
+ })
@@ -6,4 +6,4 @@ const toArray = value => {
6
6
  return [value]
7
7
  }
8
8
 
9
- export default toArray
9
+ module.exports = toArray
@@ -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
- import esbuild from 'esbuild'
2
- // Automatically exclude all node_modules from the bundled version
3
- import { nodeExternalsPlugin } from '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/jest.config.js DELETED
@@ -1,3 +0,0 @@
1
- export default {
2
- transform: {},
3
- }
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
- }