Skip to content

Commit b1dbcca

Browse files
authored
refactor(devs-infra): rename util dir to utils dir (#1910)
1 parent ac88cd6 commit b1dbcca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+92
-92
lines changed

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
'!<rootDir>/src/**/*.spec.ts',
1414
'!<rootDir>/src/**/*.test.ts',
1515
'!<rootDir>/src/**/__*__/*',
16-
'!<rootDir>/src/util/testing.ts',
16+
'!<rootDir>/src/utils/testing.ts',
1717
],
1818
snapshotSerializers: ['<rootDir>/src/__serializers__/processed-source.ts'],
1919
cacheDirectory: '<rootDir>/.cache/unit',

src/__helpers__/fakers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { resolve } from 'path'
44
import { createCompilerInstance } from '../compiler/instance'
55
import { ConfigSet } from '../config/config-set'
66
import type { BabelConfig, TsCompiler, TsJestConfig, TsJestGlobalOptions } from '../types'
7-
import type { ImportReasons } from '../util/messages'
7+
import type { ImportReasons } from '../utils/messages'
88

99
export function filePath(relPath: string): string {
1010
return resolve(__dirname, '..', '..', relPath)

src/__helpers__/mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { testing } from 'bs-logger'
22

3-
import { rootLogger } from '../util/logger'
3+
import { rootLogger } from '../utils/logger'
44

55
export const logTargetMock = (): testing.LogTargetMock => (rootLogger as testing.LoggerMock).target
66

src/__helpers__/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jest.mock('../util/logger')
1+
jest.mock('../utils/logger')

src/cli/cli.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as _fs from 'fs'
22
import { normalize, resolve } from 'path'
33

4-
import { mocked } from '../../utils'
4+
import { mocked } from '../utils'
55
import { logTargetMock, mockObject, mockWriteStream } from '../__helpers__/mocks'
66

77
import { processArgv } from '.'

src/cli/config/migrate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { basename, resolve } from 'path'
77
import type { Arguments } from 'yargs'
88

99
import type { CliCommand } from '..'
10-
import { backportJestConfig } from '../../util/backports'
10+
import { backportJestConfig } from '../../utils/backports'
1111
import { JestPresetNames, TsJestPresetDescriptor, allPresets, defaults } from '../helpers/presets'
1212

1313
/**

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LogContexts, Logger } from 'bs-logger'
22
import type { Arguments } from 'yargs'
33
import * as yargsParser from 'yargs-parser'
44

5-
import { rootLogger } from '../util/logger'
5+
import { rootLogger } from '../utils/logger'
66

77
const VALID_COMMANDS = ['help', 'config:migrate', 'config:init']
88

src/compiler/instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { CompileFn, CompilerInstance, TsCompiler } from '../types'
55

66
import { initializeLanguageServiceInstance } from './language-service'
77
import { initializeTranspilerInstance } from './transpiler'
8-
import { stringify } from '../util/json'
8+
import { stringify } from '../utils/json'
99

1010
/**
1111
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.

src/compiler/language-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import type * as _ts from 'typescript'
88
import type { ConfigSet } from '../config/config-set'
99
import { LINE_FEED } from '../constants'
1010
import type { CompilerInstance, SourceOutput } from '../types'
11-
import { Errors, interpolate } from '../util/messages'
11+
import { Errors, interpolate } from '../utils/messages'
1212

13-
import { parse, stringify } from '../util/json'
14-
import { sha1 } from '../util/sha1'
13+
import { parse, stringify } from '../utils/json'
14+
import { sha1 } from '../utils/sha1'
1515

1616
/** where key is filepath */
1717
type TSFiles = Map<string, TSFile>

src/config/config-set.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import * as _myModule from '..'
88
import { logTargetMock } from '../__helpers__/mocks'
99
import { createConfigSet, defaultResolve } from '../__helpers__/fakers'
1010
import type { TsJestGlobalOptions } from '../types'
11-
import * as _backports from '../util/backports'
12-
import { getPackageVersion } from '../util/get-package-version'
13-
import { normalizeSlashes } from '../util/normalize-slashes'
14-
import { mocked } from '../util'
11+
import * as _backports from '../utils/backports'
12+
import { getPackageVersion } from '../utils/get-package-version'
13+
import { normalizeSlashes } from '../utils/normalize-slashes'
14+
import { mocked } from '../utils'
1515

1616
import { IGNORE_DIAGNOSTIC_CODES, MATCH_NOTHING, TS_JEST_OUT_DIR } from './config-set'
1717
// eslint-disable-next-line no-duplicate-imports
1818
import type { ConfigSet } from './config-set'
19-
import { Deprecations } from '../util/messages'
19+
import { Deprecations } from '../utils/messages'
2020

21-
jest.mock('../util/backports')
21+
jest.mock('../utils/backports')
2222
jest.mock('../index')
23-
jest.mock('../util/get-package-version')
23+
jest.mock('../utils/get-package-version')
2424

2525
const backports = mocked(_backports)
2626
const myModule = mocked(_myModule)

src/config/config-set.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ import type {
4242
TsJestHooksMap,
4343
TTypeScript,
4444
} from '../types'
45-
import { backportJestConfig } from '../util/backports'
46-
import { getPackageVersion } from '../util/get-package-version'
47-
import { importer } from '../util/importer'
48-
import { stringify } from '../util/json'
49-
import { JsonableValue } from '../util/jsonable-value'
50-
import { rootLogger } from '../util/logger'
51-
import { Memoize } from '../util/memoize'
52-
import { Deprecations, Errors, ImportReasons, interpolate } from '../util/messages'
53-
import { normalizeSlashes } from '../util/normalize-slashes'
54-
import { sha1 } from '../util/sha1'
55-
import { TSError } from '../util/ts-error'
45+
import { backportJestConfig } from '../utils/backports'
46+
import { getPackageVersion } from '../utils/get-package-version'
47+
import { importer } from '../utils/importer'
48+
import { stringify } from '../utils/json'
49+
import { JsonableValue } from '../utils/jsonable-value'
50+
import { rootLogger } from '../utils/logger'
51+
import { Memoize } from '../utils/memoize'
52+
import { Deprecations, Errors, ImportReasons, interpolate } from '../utils/messages'
53+
import { normalizeSlashes } from '../utils/normalize-slashes'
54+
import { sha1 } from '../utils/sha1'
55+
import { TSError } from '../utils/ts-error'
5656

5757
const logger = rootLogger.child({ namespace: 'config' })
5858

src/config/create-jest-preset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Config } from '@jest/types'
22

3-
import { rootLogger } from '../util/logger'
3+
import { rootLogger } from '../utils/logger'
44

55
const logger = rootLogger.child({ namespace: 'jest-preset' })
66

src/config/paths-to-module-name-mapper.spec.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { logTargetMock } from '../__helpers__/mocks'
33
import { pathsToModuleNameMapper } from './paths-to-module-name-mapper'
44

55
const tsconfigMap = {
6-
log: ['src/util/log'],
6+
log: ['src/utils/log'],
77
server: ['src/server'],
88
client: ['src/client', 'src/client/index'],
9-
'util/*': ['src/util/*'],
9+
'util/*': ['src/utils/*'],
1010
'api/*': ['src/api/*'],
1111
'test/*': ['test/*'],
1212
'mocks/*': ['test/mocks/*'],
@@ -16,44 +16,44 @@ const tsconfigMap = {
1616
describe('pathsToModuleNameMapper', () => {
1717
it('should convert tsconfig mapping', () => {
1818
expect(pathsToModuleNameMapper(tsconfigMap)).toMatchInlineSnapshot(`
19-
Object {
20-
"^api/(.*)$": "src/api/$1",
21-
"^client$": Array [
22-
"src/client",
23-
"src/client/index",
24-
],
25-
"^log$": "src/util/log",
26-
"^mocks/(.*)$": "test/mocks/$1",
27-
"^server$": "src/server",
28-
"^test/(.*)$": "test/$1",
29-
"^test/(.*)/mock$": Array [
30-
"test/mocks/$1",
31-
"test/__mocks__/$1",
32-
],
33-
"^util/(.*)$": "src/util/$1",
34-
}
35-
`)
19+
Object {
20+
"^api/(.*)$": "src/api/$1",
21+
"^client$": Array [
22+
"src/client",
23+
"src/client/index",
24+
],
25+
"^log$": "src/utils/log",
26+
"^mocks/(.*)$": "test/mocks/$1",
27+
"^server$": "src/server",
28+
"^test/(.*)$": "test/$1",
29+
"^test/(.*)/mock$": Array [
30+
"test/mocks/$1",
31+
"test/__mocks__/$1",
32+
],
33+
"^util/(.*)$": "src/utils/$1",
34+
}
35+
`)
3636
})
3737

3838
it('should use the given prefix', () => {
3939
expect(pathsToModuleNameMapper(tsconfigMap, { prefix: '<rootDir>/' })).toMatchInlineSnapshot(`
40-
Object {
41-
"^api/(.*)$": "<rootDir>/src/api/$1",
42-
"^client$": Array [
43-
"<rootDir>/src/client",
44-
"<rootDir>/src/client/index",
45-
],
46-
"^log$": "<rootDir>/src/util/log",
47-
"^mocks/(.*)$": "<rootDir>/test/mocks/$1",
48-
"^server$": "<rootDir>/src/server",
49-
"^test/(.*)$": "<rootDir>/test/$1",
50-
"^test/(.*)/mock$": Array [
51-
"<rootDir>/test/mocks/$1",
52-
"<rootDir>/test/__mocks__/$1",
53-
],
54-
"^util/(.*)$": "<rootDir>/src/util/$1",
55-
}
56-
`)
40+
Object {
41+
"^api/(.*)$": "<rootDir>/src/api/$1",
42+
"^client$": Array [
43+
"<rootDir>/src/client",
44+
"<rootDir>/src/client/index",
45+
],
46+
"^log$": "<rootDir>/src/utils/log",
47+
"^mocks/(.*)$": "<rootDir>/test/mocks/$1",
48+
"^server$": "<rootDir>/src/server",
49+
"^test/(.*)$": "<rootDir>/test/$1",
50+
"^test/(.*)/mock$": Array [
51+
"<rootDir>/test/mocks/$1",
52+
"<rootDir>/test/__mocks__/$1",
53+
],
54+
"^util/(.*)$": "<rootDir>/src/utils/$1",
55+
}
56+
`)
5757
})
5858

5959
it('should warn about mapping it cannot handle', () => {
@@ -66,17 +66,17 @@ Object {
6666
'too/*/many/*/stars': ['to/*/many/*/stars'],
6767
}),
6868
).toMatchInlineSnapshot(`
69-
Object {
70-
"^kept$": "src/kept",
71-
}
72-
`)
69+
Object {
70+
"^kept$": "src/kept",
71+
}
72+
`)
7373
expect(log.lines.warn).toMatchInlineSnapshot(`
74-
Array [
75-
"[level:40] Not mapping \\"no-target\\" because it has no target.
76-
",
77-
"[level:40] Not mapping \\"too/*/many/*/stars\\" because it has more than one star (\`*\`).
78-
",
79-
]
80-
`)
74+
Array [
75+
"[level:40] Not mapping \\"no-target\\" because it has no target.
76+
",
77+
"[level:40] Not mapping \\"too/*/many/*/stars\\" because it has more than one star (\`*\`).
78+
",
79+
]
80+
`)
8181
})
8282
})

src/config/paths-to-module-name-mapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { Config } from '@jest/types'
22
import { LogContexts } from 'bs-logger'
33
import type { CompilerOptions } from 'typescript'
44

5-
import { rootLogger } from '../util/logger'
6-
import { Errors, interpolate } from '../util/messages'
5+
import { rootLogger } from '../utils/logger'
6+
import { Errors, interpolate } from '../utils/messages'
77

88
type TsPathMapping = Exclude<CompilerOptions['paths'], undefined>
99
type JestPathMapping = Config.InitialOptions['moduleNameMapper']

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { createJestPreset as createJestPresetCore } from './config/create-jest-p
66
import { pathsToModuleNameMapper as pathsToModuleNameMapperCore } from './config/paths-to-module-name-mapper'
77
import { TsJestTransformer } from './ts-jest-transformer'
88
import type { TsJestGlobalOptions } from './types'
9-
import { rootLogger } from './util/logger'
10-
import { Deprecations, interpolate } from './util/messages'
11-
import { mocked as mockedCore } from './util/testing'
12-
import { VersionCheckers } from './util/version-checkers'
9+
import { rootLogger } from './utils/logger'
10+
import { Deprecations, interpolate } from './utils/messages'
11+
import { mocked as mockedCore } from './utils/testing'
12+
import { VersionCheckers } from './utils/version-checkers'
1313

1414
declare module '@jest/types' {
1515
// eslint-disable-next-line @typescript-eslint/no-namespace

src/ts-jest-transformer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { inspect } from 'util'
66
import { ConfigSet } from './config/config-set'
77
import { JS_JSX_REGEX, TS_TSX_REGEX } from './constants'
88
import type { TsJestGlobalOptions } from './types'
9-
import { stringify } from './util/json'
10-
import { JsonableValue } from './util/jsonable-value'
11-
import { rootLogger } from './util/logger'
12-
import { Errors, interpolate } from './util/messages'
13-
import { sha1 } from './util/sha1'
9+
import { stringify } from './utils/json'
10+
import { JsonableValue } from './utils/jsonable-value'
11+
import { rootLogger } from './utils/logger'
12+
import { Errors, interpolate } from './utils/messages'
13+
import { sha1 } from './utils/sha1'
1414

1515
const INSPECT_CUSTOM = inspect.custom || 'inspect'
1616

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/util/jsonable-value.spec.ts renamed to src/utils/jsonable-value.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mocked } from '../../utils'
1+
import { mocked } from './'
22

33
import * as _json from './json'
44
import { JsonableValue } from './jsonable-value'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/util/version-checkers.spec.ts renamed to src/utils/version-checkers.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mocked } from '../../utils'
1+
import { mocked } from './'
22
import { logTargetMock } from '../__helpers__/mocks'
33

44
import * as _pv from './get-package-version'
File renamed without changes.

utils/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from '../dist/util'
1+
export * from '../dist/utils'

utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('../dist/util')
1+
module.exports = require('../dist/utils')

0 commit comments

Comments
 (0)