Skip to content

Commit

Permalink
refactor: use import/export type typescript feature (#791)
Browse files Browse the repository at this point in the history
  • Loading branch information
scolladon authored Feb 22, 2024
1 parent abe8932 commit cfcc6d2
Show file tree
Hide file tree
Showing 56 changed files with 796 additions and 709 deletions.
2 changes: 1 addition & 1 deletion __tests__/__utils__/globalTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getDefinition,
getLatestSupportedVersion,
} from '../../src/metadata/metadataManager'
import { Work } from '../../src/types/work'
import type { Work } from '../../src/types/work'

require('ts-node/register')

Expand Down
2 changes: 1 addition & 1 deletion __tests__/integration/services.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../src/constant/gitConstants'
import { MetadataRepository } from '../../src/metadata/MetadataRepository'
import TypeHandlerFactory from '../../src/service/typeHandlerFactory'
import { Work } from '../../src/types/work'
import type { Work } from '../../src/types/work'
import { readPathFromGit } from '../../src/utils/fsHelper'
import { getGlobalMetadata } from '../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/adapter/GitAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import GitAdapter, {
filePathWalker,
iterate,
} from '../../../../src/adapter/GitAdapter'
import { Config } from '../../../../src/types/config'
import type { Config } from '../../../../src/types/config'
import {
getLFSObjectContentPath,
isLFS,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/metadata/MetadataRepositoryImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import { MetadataRepositoryImpl } from '../../../../src/metadata/MetadataRepositoryImpl'
import { Metadata } from '../../../../src/types/metadata'
import type { Metadata } from '../../../../src/types/metadata'

describe('MetadataRepositoryImpl', () => {
let sut: MetadataRepository
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/metadata/metadataManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getSharedFolderMetadata,
isVersionSupported,
} from '../../../../src/metadata/metadataManager'
import { Metadata } from '../../../../src/types/metadata'
import type { Metadata } from '../../../../src/types/metadata'

describe(`test if metadata`, () => {
it('provide latest when apiVersion does not exist', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/post-processor/baseProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { beforeAll, expect, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import BaseProcessor from '../../../../src/post-processor/baseProcessor'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

describe('BaseProcessor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../../../src/constant/metadataConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import FlowTranslationProcessor from '../../../../src/post-processor/flowTranslationProcessor'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { writeFile, readDir } from '../../../../src/utils/fsHelper'
import { isSubDir, readFile, treatPathSep } from '../../../../src/utils/fsUtils'
import { parseXmlFileToJson } from '../../../../src/utils/fxpHelper'
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/post-processor/includeProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import IncludeProcessor from '../../../../src/post-processor/includeProcessor'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import {
IgnoreHelper,
buildIncludeHelper,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/post-processor/packageGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fse from 'fs-extra'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import PackageGenerator from '../../../../src/post-processor/packageGenerator'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

jest.mock('fs-extra')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import BaseProcessor from '../../../../src/post-processor/baseProcessor'
import PostProcessorManager, {
getPostProcessors,
} from '../../../../src/post-processor/postProcessorManager'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

const processSpy = jest.fn()
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/botHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import BotHandler from '../../../../src/service/botHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { copyFiles } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/customObjectHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, jest, describe, it } from '@jest/globals'
import { MASTER_DETAIL_TAG } from '../../../../src/constant/metadataConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import CustomObjectHandler from '../../../../src/service/customObjectHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import {
copyFiles,
pathExists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import DiffLineInterpreter from '../../../../src/service/diffLineInterpreter'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

jest.mock('os', () => ({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/diffLineInterpreter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import DiffLineInterpreter from '../../../../src/service/diffLineInterpreter'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

const mockHandle = jest.fn()
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/inBundleHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import InBundleHandler from '../../../../src/service/inBundleHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

const objectType = 'digitalExperiences'
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/inFileHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import InFileHandler from '../../../../src/service/inFileHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { writeFile } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/inFolderHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, jest, describe, it } from '@jest/globals'
import { METAFILE_SUFFIX } from '../../../../src/constant/metadataConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import InFolder from '../../../../src/service/inFolderHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { copyFiles, readDir } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/inResourceHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, jest, describe, it } from '@jest/globals'
import { METAFILE_SUFFIX } from '../../../../src/constant/metadataConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import InResourceHandler from '../../../../src/service/inResourceHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { copyFiles, pathExists, readDir } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/lwcHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../../../src/constant/gitConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import LwcHandler from '../../../../src/service/lwcHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { copyFiles } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import ObjectTranslation from '../../../../src/service/objectTranslationHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { writeFile, copyFiles } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/sharedFolderHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, jest, describe, it } from '@jest/globals'
import { METAFILE_SUFFIX } from '../../../../src/constant/metadataConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import SharedFolderHandler from '../../../../src/service/sharedFolderHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { copyFiles } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/standardHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { METAFILE_SUFFIX } from '../../../../src/constant/metadataConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import StandardHandler from '../../../../src/service/standardHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { copyFiles } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/subCustomObjectHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect, jest, describe, it } from '@jest/globals'
import { MASTER_DETAIL_TAG } from '../../../../src/constant/metadataConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import SubCustomObjectHandler from '../../../../src/service/subCustomObjectHandler'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { readPathFromGit, copyFiles } from '../../../../src/utils/fsHelper'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/service/typeHandlerFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SharedFolder from '../../../../src/service/sharedFolderHandler'
import Standard from '../../../../src/service/standardHandler'
import SubCustomObject from '../../../../src/service/subCustomObjectHandler'
import TypeHandlerFactory from '../../../../src/service/typeHandlerFactory'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import { getGlobalMetadata, getWork } from '../../../__utils__/globalTestHelper'

describe('the type handler factory', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/utils/cliHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expect, jest, describe, it } from '@jest/globals'

import messages from '../../../../src/locales/en'
import { getLatestSupportedVersion } from '../../../../src/metadata/metadataManager'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import CLIHelper from '../../../../src/utils/cliHelper'
import {
readFile,
Expand Down
4 changes: 2 additions & 2 deletions __tests__/unit/lib/utils/fsHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { expect, jest, describe, it } from '@jest/globals'
import { outputFile } from 'fs-extra'
import { Ignore } from 'ignore'

import { Config } from '../../../../src/types/config'
import { Work } from '../../../../src/types/work'
import type { Config } from '../../../../src/types/config'
import type { Work } from '../../../../src/types/work'
import {
copyFiles,
pathExists,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/utils/fxpHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
import { expect, jest, describe, it } from '@jest/globals'

import { Config } from '../../../../src/types/config'
import type { Config } from '../../../../src/types/config'
import { readPathFromGit } from '../../../../src/utils/fsHelper'
import {
asArray,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/utils/ignoreHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MODIFICATION,
DELETION,
} from '../../../../src/constant/gitConstants'
import { Config } from '../../../../src/types/config'
import type { Config } from '../../../../src/types/config'
import { readFile } from '../../../../src/utils/fsUtils'
import {
IgnoreHelper,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/utils/metadataDiff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { expect, jest, describe, it } from '@jest/globals'

import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import { Work } from '../../../../src/types/work'
import type { Work } from '../../../../src/types/work'
import {
parseXmlFileToJson,
convertJsonToXml,
Expand Down
4 changes: 2 additions & 2 deletions __tests__/unit/lib/utils/packageHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'
import { expect, describe, it } from '@jest/globals'

import { Config } from '../../../../src/types/config'
import { Manifest } from '../../../../src/types/work'
import type { Config } from '../../../../src/types/config'
import type { Manifest } from '../../../../src/types/work'
import PackageBuilder, {
fillPackageWithParameter,
} from '../../../../src/utils/packageHelper'
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/utils/repoGitDiff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
MODIFICATION,
} from '../../../../src/constant/gitConstants'
import { MetadataRepository } from '../../../../src/metadata/MetadataRepository'
import { Config } from '../../../../src/types/config'
import type { Config } from '../../../../src/types/config'
import RepoGitDiff from '../../../../src/utils/repoGitDiff'
import { getGlobalMetadata } from '../../../__utils__/globalTestHelper'

Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"fast-xml-parser": "^4.3.4",
"fs-extra": "^11.2.0",
"ignore": "^5.3.1",
"isomorphic-git": "^1.25.3",
"isomorphic-git": "^1.25.6",
"lodash": "^4.17.21",
"simple-git": "^3.22.0",
"xmlbuilder2": "^3.1.1"
Expand Down Expand Up @@ -170,35 +170,35 @@
}
},
"devDependencies": {
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@jest/globals": "^29.7.0",
"@oclif/dev-cli": "^1.26.10",
"@salesforce/cli-plugins-testkit": "^5.1.8",
"@salesforce/cli-plugins-testkit": "^5.1.9",
"@salesforce/dev-config": "^4.1.0",
"@salesforce/ts-sinon": "^1.4.19",
"@stryker-mutator/core": "^8.2.2",
"@stryker-mutator/jest-runner": "^8.2.2",
"@swc/core": "^1.3.107",
"@stryker-mutator/core": "^8.2.5",
"@stryker-mutator/jest-runner": "^8.2.5",
"@swc/core": "^1.4.2",
"@types/async": "^3.2.24",
"@types/jest": "^29.5.11",
"@types/jest": "^29.5.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.15",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"benchmark": "^2.1.4",
"chai": "^4.3.10",
"depcheck": "^1.4.7",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.7",
"husky": "^9.0.11",
"jest": "^29.7.0",
"lint-staged": "^15.2.1",
"mocha": "^10.2.0",
"lint-staged": "^15.2.2",
"mocha": "^10.3.0",
"nyc": "^15.1.0",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"shx": "^0.3.4",
"sinon": "^17.0.1",
"ts-jest": "^29.1.2",
Expand Down
4 changes: 2 additions & 2 deletions src/adapter/GitAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
DELETION,
MODIFICATION,
} from '../constant/gitConstants'
import { Config } from '../types/config'
import { FileGitRef } from '../types/git'
import type { Config } from '../types/config'
import type { FileGitRef } from '../types/git'
import { SOURCE_DEFAULT_VALUE } from '../utils/cliConstants'
import { dirExists, fileExists, treatPathSep } from '../utils/fsUtils'
import { getLFSObjectContentPath, isLFS } from '../utils/gitLfsHelper'
Expand Down
4 changes: 2 additions & 2 deletions src/commands/sgd/source/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { flags, SfdxCommand } from '@salesforce/command'
import { Messages } from '@salesforce/core'

import sgd from '../../../main'
import { Config } from '../../../types/config'
import { Output } from '../../../types/output'
import type { Config } from '../../../types/config'
import type { Output } from '../../../types/output'
import {
TO_DEFAULT_VALUE,
REPO_DEFAULT_VALUE,
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { MetadataRepository } from './metadata/MetadataRepository'
import { getDefinition } from './metadata/metadataManager'
import { getPostProcessors } from './post-processor/postProcessorManager'
import DiffLineInterpreter from './service/diffLineInterpreter'
import { Config } from './types/config'
import { Work } from './types/work'
import type { Config } from './types/config'
import type { Work } from './types/work'
import CLIHelper from './utils/cliHelper'
import RepoGitDiff from './utils/repoGitDiff'

Expand Down
2 changes: 1 addition & 1 deletion src/metadata/MetadataRepository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { Metadata } from '../types/metadata'
import type { Metadata } from '../types/metadata'

export interface MetadataRepository {
has(path: string): boolean
Expand Down
2 changes: 1 addition & 1 deletion src/metadata/MetadataRepositoryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SUB_OBJECT_TYPES,
TERRITORY_MODEL_TYPE,
} from '../constant/metadataConstants'
import { Metadata } from '../types/metadata'
import type { Metadata } from '../types/metadata'

import { MetadataRepository } from './MetadataRepository'

Expand Down
Loading

0 comments on commit cfcc6d2

Please sign in to comment.