Skip to content

Commit

Permalink
build: run local integrity check
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed Sep 15, 2021
1 parent 7956d18 commit 0ab9086
Show file tree
Hide file tree
Showing 74 changed files with 1,613 additions and 1,728 deletions.
Empty file added __mocks__/.gitkeep
Empty file.
Empty file added __tests__/__fixtures__/.gitkeep
Empty file.
6 changes: 0 additions & 6 deletions __tests__/__fixtures__/error.fixture.ts

This file was deleted.

25 changes: 0 additions & 25 deletions __tests__/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
import type { GitSemverTagsOptions } from '@grease/types'
import semver from '@grease/utils/semver.util'
import TAGS from '@tests/fixtures/git-tags.fixture'

/**
* @file Test Utilities
* @module tests/utils
*/

/**
* Returns an array of mock Git tags.
*
* @param {GitSemverTagsOptions} [opts] - Tag options
* @param {boolean} [opts.lernaTags] - Extract Lerna style tags
* @param {string} [opts.package] - Name of package using lerna style tags
* @return {string[]} Array of mock tags
* @throws {Error}
*/
export const mockGitTags = (opts: GitSemverTagsOptions = {}): string[] => {
const { lernaTags, package: pkg } = opts

if (pkg && !lernaTags) {
const msg = 'opts.package should only be used when running in lerna mode'
throw new Error(msg)
}

if (!lernaTags) return Object.assign([], TAGS)
return TAGS.map(tag => `${pkg}@${semver.clean(tag)}`)
}

/**
* Compares two string values.
*
Expand Down
46 changes: 1 addition & 45 deletions __tests__/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
/**
* @file Test Utilities - Type Definitions
* @module tests/types
* @module tests/utils/types
*/

/**
* Names of custom validation options for the `IsBranch` decorator.
*/
export type IsBranchOption = 'dir' | 'remote'

/**
* Names of custom validation options for the `IsCommit` decorator.
*/
export type IsCommitOption = 'dir'

/**
* Names of custom validation options for the `IsPath` decorator.
*/
export type IsPathOption = 'cwd' | 'exists' | 'gh'

/**
* Names of custom validation options for the `IsSemVer` decorator.
*/
export type IsSemVerOption =
| 'clean'
| 'cmp'
| 'coerce'
| 'git'
| 'negit'
| 'satisfies'

/**
* Names of custom validation options for the `IsTargetBranch` decorator.
*/
export type IsTargetBranchOption = IsBranchOption | 'sha'

/**
* Represents a test case.
*
Expand Down Expand Up @@ -80,16 +49,3 @@ export interface Testcase<Expected extends any = any> {
export interface TestcaseCalled extends Testcase<number> {
call: 'call' | 'not call'
}

/**
* Represents a decorator or decorator constraint test case.
*
* @template Expected - Type of expected value
* @template Option - Option names
*/
export interface TestcaseDecorator<
Expected extends any = any,
Option extends string | never = never
> extends Testcase<Expected> {
option: 'no options' | (Option extends never ? never : `options.${Option}`)
}
14 changes: 8 additions & 6 deletions jest.config.base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Config } from '@jest/types'
import { jsWithTsESM as preset } from 'ts-jest/presets'
import { pathsToModuleNameMapper } from 'ts-jest/utils'
import NODE_MODULES from './scripts/nm-string'
import { compilerOptions } from './tsconfig.json'

/**
Expand All @@ -17,19 +18,20 @@ const config: Config.InitialOptions = {
clearMocks: true,
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.test.json'
tsconfig: '<rootDir>/tsconfig.test.json',
useESM: true
}
},
moduleDirectories: ['node_modules'],
moduleDirectories: [NODE_MODULES],
moduleFileExtensions: ['node', 'js', 'json', 'ts'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix }),
prettierPath: `${prefix}/node_modules/prettier`,
prettierPath: `<rootDir>/${NODE_MODULES}/prettier`,
rootDir: '../..',
roots: [`${prefix}/__mocks__`, `${prefix}/packages`],
setupFiles: [`${prefix}/__tests__/config/setup.ts`],
roots: ['<rootDir>/__mocks__', '<rootDir>/packages'],
setupFiles: ['<rootDir>/__tests__/config/setup.ts'],
setupFilesAfterEnv: [
'jest-mock-console/dist/setupTestFramework.js',
`${prefix}/__tests__/config/setupAfterEnv.ts`
'<rootDir>/__tests__/config/setupAfterEnv.ts'
],
testRegex: `(/__tests__/)(spec/(${TYPE}))?(.*)(${TYPE})?.spec.ts$`,
verbose: true
Expand Down
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Config } from '@jest/types'
import merge from 'lodash/merge'
import omit from 'lodash/omit'
import merge from 'lodash.merge'
import omit from 'lodash.omit'
import baseConfig from './jest.config.base'
import pkg from './package.json'

Expand Down
61 changes: 35 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
},
"author": {
"name": "Lexus Drumgold",
"email": "lex@flexdevlopment.llc",
"email": "unicornware@flexdevlopment.llc",
"url": "https://flexdevelopment.llc"
},
"scripts": {
"clean:modules": "rimraf ./node_modules packages/*/node_modules",
"clean:yarn": "rimraf .yarn/cache .yarn/*.gz",
"clean": "yarn clean:yarn && yarn clean:modules",
"prepare": "yarn workspaces foreach -itv run prepare",
"postinstall": "husky-run install",
"bootstrap": "yarn; yarn prepare",
"prepack": "yarn workspaces foreach -iv --topological-dev run prepack",
"bootstrap": "yarn && yarn prepack",
"check:format": "prettier --check .",
"check:install": "yarn dlx @yarnpkg/doctor .",
"check:style": "eslint . --ext md,js,ts",
Expand All @@ -33,22 +33,29 @@
"devDependencies": {
"@babel/core": "7.15.4",
"@babel/eslint-parser": "7.15.4",
"@commitlint/cli": "13.0.0",
"@commitlint/config-conventional": "13.0.0",
"@commitlint/format": "13.0.0",
"@types/faker": "5.5.6",
"@types/fs-extra": "9.0.11",
"@types/jest": "26.0.23",
"@commitlint/cli": "13.1.0",
"@commitlint/config-conventional": "13.1.0",
"@commitlint/format": "13.1.0",
"@commitlint/types": "13.1.0",
"@flex-development/exceptions": "2.0.1",
"@grease/index": "link:packages/grease/src/index.ts",
"@grease/interfaces": "link:packages/grease/src/interfaces",
"@grease/utils": "link:packages/grease/src/utils",
"@jest/types": "27.1.1",
"@types/fs-extra": "9.0.12",
"@types/jest": "27.0.1",
"@types/lodash.join": "4.0.6",
"@types/lodash.merge": "4.6.6",
"@types/lodash.omit": "4.5.6",
"@types/lodash.pick": "4.4.6",
"@types/mvdan-sh": "0.5.0",
"@types/node": "15.12.5",
"@types/node": "16.9.1",
"@types/rimraf": "2.0.4",
"@types/shelljs": "0.8.8",
"@typescript-eslint/eslint-plugin": "4.28.0",
"@typescript-eslint/parser": "4.28.0",
"@zerollup/ts-transform-paths": "1.7.18",
"chalk-cli": "4.1.0",
"@typescript-eslint/eslint-plugin": "4.31.1",
"@typescript-eslint/parser": "4.31.1",
"chalk": "4.1.2",
"class-validator": "0.13.1",
"copyfiles": "2.4.1",
"dotenv-cli": "4.0.0",
"eslint": "7.32.0",
Expand All @@ -63,36 +70,37 @@
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-spellcheck": "0.0.19",
"eslint-plugin-tree-shaking": "1.9.2",
"faker": "5.5.3",
"figures": "3.2.0",
"fs-extra": "10.0.0",
"husky": "4.3.8",
"jest": "27.0.6",
"jest": "27.1.0",
"jest-extended": "0.11.5",
"jest-mock-console": "1.1.0",
"lint-staged": "11.0.0",
"lodash.join": "4.0.1",
"lodash.merge": "4.6.2",
"lodash.omit": "4.5.0",
"lodash.pick": "4.4.0",
"mkdirp": "0.5.5",
"npm": "7.19.0",
"npm": "7.22.0",
"npm-run-all": "4.1.5",
"prettier": "2.3.2",
"prettier-plugin-sh": "0.7.0",
"read-pkg": "5.2.0",
"reflect-metadata": "0.1.13",
"replace-in-file": "6.2.0",
"rimraf": "3.0.2",
"ts-jest": "27.0.4",
"ts-node": "10.1.0",
"tsconfig-paths": "3.9.0",
"ttypescript": "1.5.12",
"typescript": "4.3.4"
"shelljs": "0.8.4",
"ts-jest": "27.0.5",
"ts-node": "10.2.1",
"tsconfig-paths": "3.11.0",
"typescript": "4.4.2",
"yargs": "17.1.1"
},
"engines": {
"node": ">=15.0.0",
"npm": "use-yarn",
"yarn": "3.0.2"
},
"resolutions": {
"read-pkg": "5.2.0"
},
"env": {
"optional": [
"DEBUG",
Expand All @@ -101,6 +109,7 @@
"TS_NODE_PROJECT"
],
"required": [
"INIT_CWD",
"NODE_OPTIONS",
"NPM_TOKEN_FLDV",
"PAT_GPR_FLDV",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - anymatch
* @module mocks/anymatch
* @module grease/tests/mocks/anymatch
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/micromatch/anymatch
*/
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/chalk.ts → packages/grease/__mocks__/chalk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - chalk
* @module mocks/chalk
* @module grease/tests/mocks/chalk
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/chalk/chalk
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as item from 'class-validator'

/**
* @file Node Module Mock - class-validator
* @module mocks/class-validator
* @module grease/tests/mocks/class-validator
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/typestack/class-validator
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { mockGitTags } from '@grease/tests/utils'
import type {
GitSemverTagsCallback as Callback,
GitSemverTagsOptions as Options
} from '@grease/types'
import semver from '@grease/utils/semver.util'
import { mockGitTags } from '@tests/utils'

/**
* @file Node Module Mock - git-semver-tags
* @module mocks/git-semver-tags
* @module grease/tests/mocks/git-semver-tags
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/git-semver-tags
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import BRANCHES from '@tests/fixtures/git-branches.fixture'
import COMMITS from '@tests/fixtures/git-commit-shas.fixture'
import BRANCHES from '@grease/tests/fixtures/git-branches.fixture'
import COMMITS from '@grease/tests/fixtures/git-commit-shas.fixture'
import fs from 'fs'

/**
* @file Node Module Mock - isomorphic-git
* @module mocks/isomorphic-git
* @module grease/tests/mocks/isomorphic-git
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/isomorphic-git/isomorphic-git
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - lodash/merge
* @module mocks/lodash/merge
* @module grease/tests/mocks/lodash/merge
* @see https://jestjs.io/docs/next/manual-mocks#mocking-node-modules
* @see https://github.com/lodash/lodash
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - shelljs
* @module mocks/shelljs
* @module grease/tests/mocks/shelljs
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/shelljs/shelljs
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - checkpoint
* @module mocks/standard-version/lib/checkpoint
* @module grease/tests/mocks/standard-version/lib/checkpoint
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - latestSemverTag
* @module mocks/standard-version/lib/latest-semver-tag
* @module grease/tests/mocks/standard-version/lib/latest-semver-tag
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - lifecycles/bump
* @module mocks/standard-version/lib/lifecycles/bump
* @module grease/tests/mocks/standard-version/lib/lifecycles/bump
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - lifecycles/changelog
* @module mocks/standard-version/lib/lifecycles/changelog
* @module grease/tests/mocks/standard-version/lib/lifecycles/changelog
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - lifecycles/commit
* @module mocks/standard-version/lib/lifecycles/commit
* @module grease/tests/mocks/standard-version/lib/lifecycles/commit
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - lifecycles/tag
* @module mocks/standard-version/lib/lifecycles/tag
* @module grease/tests/mocks/standard-version/lib/lifecycles/tag
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - runLifecycleScript
* @module mocks/standard-version/lib/run-lifecycle-script
* @module grease/tests/mocks/standard-version/lib/run-lifecycle-script
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @file Node Module Mock - updaters
* @module mocks/standard-version/lib/updaters
* @module grease/tests/mocks/standard-version/lib/updaters
* @see https://jestjs.io/docs/manual-mocks#mocking-node-modules
* @see https://github.com/conventional-changelog/standard-version
*/
Expand Down
File renamed without changes.
Loading

0 comments on commit 0ab9086

Please sign in to comment.