Skip to content

Commit

Permalink
refactor(log): add subdomain
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Oct 17, 2023
1 parent d1629b9 commit 8d2859b
Show file tree
Hide file tree
Showing 124 changed files with 3,906 additions and 2,104 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ component_management:
name: git
paths:
- src/subdomains/git/**/*.ts
- component_id: log
name: log
paths:
- src/subdomains/log/**/*.ts
- component_id: models
name: models
paths:
Expand Down
1 change: 1 addition & 0 deletions .commitlintrc.cts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const config: UserConfig = {
'config',
'git',
'grease',
'log',
'nestjs',
'options'
])
Expand Down
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const config = {
rules: {
'promise/prefer-await-to-callbacks': 0
}
},
{
files: ['src/subdomains/log/enums/log-level.ts'],
rules: {
'@typescript-eslint/prefer-literal-enum-member': 0
}
}
],
root: true
Expand Down
891 changes: 0 additions & 891 deletions .yarn/releases/yarn-4.0.0-rc.50.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.0-rc.53.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ npmScopes:

patchFolder: ./patches

yarnPath: .yarn/releases/yarn-4.0.0-rc.50.cjs
yarnPath: .yarn/releases/yarn-4.0.0-rc.53.cjs
2 changes: 1 addition & 1 deletion __fixtures__/git.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
*/

import GitService from '#src/git/providers/git.service'
import LoggerService from '#src/providers/logger.service'
import LoggerService from '#src/log/providers/logger.service'

export default new GitService(new LoggerService())
2 changes: 1 addition & 1 deletion __fixtures__/pkg/invalid/.greaserc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
cwd: __fixtures__/pkg/invalid
debug: true
level: debug
tagprefix: pkg-invalid@
2 changes: 1 addition & 1 deletion __fixtures__/pkg/major/.grease.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

export default {
cwd: '__fixtures__/pkg/major',
debug: true,
level: 'debug',
tagprefix: 'pkg-major@'
}
2 changes: 1 addition & 1 deletion __fixtures__/pkg/minor/.greaserc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "../../../grease.schema.json",
"cwd": "__fixtures__/pkg/minor",
"debug": true,
"level": "debug",
"tagprefix": "pkg-minor@"
}
2 changes: 1 addition & 1 deletion __fixtures__/pkg/patch/grease.config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// https://github.com/flex-development/grease
{
cwd: '__fixtures__/pkg/patch',
debug: true,
level: 'debug',
tagprefix: 'pkg-patch@'
}
2 changes: 1 addition & 1 deletion __fixtures__/pkg/premajor/.grease.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
{
"$schema": "../../../grease.schema.json",
"cwd": "__fixtures__/pkg/premajor",
"debug": true,
"level": "debug",
"tagprefix": "pkg-premajor@"
}
2 changes: 1 addition & 1 deletion __fixtures__/pkg/preminor/.greaserc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

export default {
cwd: '__fixtures__/pkg/preminor',
debug: true,
level: 'debug',
tagprefix: 'pkg-preminor@'
}
2 changes: 1 addition & 1 deletion __fixtures__/pkg/prepatch/grease.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { IGreaseConfig } from '@flex-development/grease'
*/
const config: IGreaseConfig = {
cwd: '__fixtures__/pkg/prepatch',
debug: true,
level: 'debug',
tagprefix: 'pkg-prepatch@'
}

Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/pkg/prerelease/.grease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { IGreaseConfig } from '@flex-development/grease'
*/
const config: IGreaseConfig = {
cwd: '__fixtures__/pkg/prerelease',
debug: true,
level: 'debug',
tagprefix: 'pkg-prerelease@'
}

Expand Down
3 changes: 1 addition & 2 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { defineBuildConfig, type Config } from '@flex-development/mkbuild'
import pathe from '@flex-development/pathe'
import { at } from '@flex-development/tutils'
import pkg from './package.json' assert { type: 'json' }
import tsconfig from './tsconfig.build.json' assert { type: 'json' }
Expand All @@ -29,6 +28,7 @@ const config: Config = defineBuildConfig({
'**/options/*',
'**/providers/*',
'**/queries/*',
'**/reporters/*',
'*.ts',
'subdomains/**/*.ts'
],
Expand Down Expand Up @@ -60,7 +60,6 @@ const config: Config = defineBuildConfig({
keepNames: true,
minifySyntax: true,
platform: 'node',
sourceRoot: 'file' + pathe.delimiter + pathe.sep.repeat(2),
target: [
'node' + at(/([\d.]+)/.exec(pkg.engines.node), 0, ''),
tsconfig.compilerOptions.target
Expand Down
31 changes: 21 additions & 10 deletions grease.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
},
"type": "object"
},
"colors": {
"color": {
"default": true,
"description": "enable colorized output",
"type": "boolean"
Expand All @@ -113,15 +113,21 @@
"description": "path to current working directory",
"type": "string"
},
"debug": {
"default": false,
"description": "enable verbose output",
"type": "boolean"
},
"quiet": {
"default": false,
"description": "disable logs",
"type": "boolean"
"level": {
"default": "log",
"description": "log level",
"enum": [
"debug",
"error",
"fatal",
"info",
"log",
"silent",
"trace",
"verbose",
"warn"
],
"type": "string"
},
"tag": {
"additionalProperties": false,
Expand Down Expand Up @@ -168,6 +174,11 @@
"default": "",
"description": "tag prefix to consider when creating and listing tags",
"type": "string"
},
"unstable": {
"default": true,
"description": "allow prereleases",
"type": "boolean"
}
},
"title": "grease",
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,20 @@
"@flex-development/tutils": "6.0.0-alpha.25",
"@nestjs/common": "10.2.7",
"@nestjs/cqrs": "10.2.6",
"@types/node": "20.8.6",
"@types/semver": "7.5.0",
"class-validator": "0.14.0",
"consola": "3.2.3",
"esbuild": "0.19.4",
"fast-glob": "3.3.1",
"is-unicode-supported": "1.3.0",
"json5": "2.2.3",
"node-emoji": "2.1.0",
"reflect-metadata": "0.1.13",
"rxjs": "7.8.1",
"semver": "7.5.4"
"semver": "7.5.4",
"string-width": "6.1.0",
"tinyrainbow": "1.1.1",
"word-wrap": "1.2.5"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.12.1",
Expand All @@ -128,7 +132,6 @@
"@types/envinfo": "7.8.1",
"@types/eslint": "8.44.2",
"@types/is-ci": "3.0.0",
"@types/node": "20.6.0",
"@types/node-notifier": "8.0.2",
"@types/prettier": "3.0.0",
"@typescript-eslint/eslint-plugin": "6.7.5",
Expand Down Expand Up @@ -184,7 +187,7 @@
"node": ">=16.20.0 <20.6.0 || >20.6.0",
"yarn": "4.0.0-rc.50"
},
"packageManager": "[email protected].50",
"packageManager": "[email protected].53",
"readme": "README.md",
"sideEffects": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ index v1.0.0-alpha.1..v1.0.0-alpha.1 100644
+ return method.handler.bind(metadata.instance)(value, previous)
+ });
+ command.addOption(option);
@@ -81,1 +81,1 @@
- return metadata.instance.run.bind(metadata.instance), metadata.instance.run(this.args, this.opts());
+ return metadata.instance.run.bind(metadata.instance), metadata.instance.run(this.args, this.optsWithGlobals());
5 changes: 2 additions & 3 deletions src/__snapshots__/grease.service.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ RecommendedBump {

exports[`unit:GreaseService > #tag > should return executed tag operation 1`] = `
TagOperation {
"colors": true,
"color": true,
"config": true,
"cwd": "$PWD",
"debug": false,
"force": false,
"level": "warn",
"message": "",
"object": "HEAD",
"push": false,
"quiet": false,
"remote": "origin",
"sign": true,
"tag": "[email protected]",
Expand Down
12 changes: 9 additions & 3 deletions src/__tests__/grease.service.functional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { BumpModule } from '#src/bump'
import { ConfigModule, ConfigService } from '#src/config'
import { GitModule } from '#src/git'
import { LoggerService, ValidationService } from '#src/providers'
import { LogModule } from '#src/log'
import type { Mock } from '#tests/interfaces'
import pathe from '@flex-development/pathe'
import { CqrsModule } from '@nestjs/cqrs'
Expand All @@ -18,8 +18,14 @@ describe('functional:GreaseService', () => {

beforeAll(async () => {
subject = (await (await Test.createTestingModule({
imports: [BumpModule, ConfigModule, CqrsModule, GitModule],
providers: [LoggerService, TestSubject, ValidationService]
imports: [
BumpModule,
ConfigModule,
CqrsModule,
GitModule,
LogModule.forRoot({ tag: TestSubject.NAME })
],
providers: [TestSubject]
}).compile()).init()).get(TestSubject)
})

Expand Down
15 changes: 8 additions & 7 deletions src/__tests__/grease.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
import { ConfigModule } from '#src/config'
import { ReleaseType } from '#src/enums'
import { GitModule, GitService, TagOperation } from '#src/git'
import { LogModule } from '#src/log'
import { PackageManifest } from '#src/models'
import { LoggerService, ValidationService } from '#src/providers'
import { set } from '@flex-development/tutils'
import { CqrsModule } from '@nestjs/cqrs'
import { Test } from '@nestjs/testing'
Expand All @@ -28,8 +28,8 @@ import tempfile from 'tempfile'
import TestSubject from '../grease.service'

describe('unit:GreaseService', () => {
let raw_tags: string
let subject: TestSubject
let tags: string

beforeAll(async () => {
subject = (await (await Test.createTestingModule({
Expand All @@ -38,12 +38,13 @@ describe('unit:GreaseService', () => {
ChangelogModule,
ConfigModule,
CqrsModule,
GitModule
GitModule,
LogModule.forRoot({ tag: TestSubject.NAME })
],
providers: [LoggerService, TestSubject, ValidationService]
providers: [TestSubject]
}).compile()).init()).get(TestSubject)

raw_tags = '__fixtures__/git/grease/tags.txt'
tags = '__fixtures__/git/grease/tags.txt'
})

describe('#bump', () => {
Expand Down Expand Up @@ -92,7 +93,7 @@ describe('unit:GreaseService', () => {
describe('#recommend', () => {
beforeEach(() => {
vi.spyOn(GitService.prototype, 'tag').mockImplementation(async () => {
return fs.readFile(raw_tags, 'utf8')
return fs.readFile(tags, 'utf8')
})
})

Expand Down Expand Up @@ -131,7 +132,7 @@ describe('unit:GreaseService', () => {
describe('#tags', () => {
beforeEach(() => {
vi.spyOn(GitService.prototype, 'tag').mockImplementation(async () => {
return fs.readFile(raw_tags, 'utf8')
return fs.readFile(tags, 'utf8')
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/cli/__tests__/program.module.functional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @module grease/cli/tests/functional/ProgramModule
*/

import { LoggerService } from '#src/providers'
import { LoggerService } from '#src/log'
import type { Spy } from '#tests/interfaces'
import { CommanderError } from '@flex-development/nest-commander/commander'
import TestSubject from '../program.module'
Expand Down
6 changes: 0 additions & 6 deletions src/cli/commands/__tests__/bump.command.functional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ describe('functional:cli/commands/BumpCommand', () => {
let command: TestingModule
let recommend: Mock<GreaseService['recommend']>

afterAll(() => {
vi.unstubAllEnvs()
})

beforeAll(() => {
args = ['bump', ReleaseType.PREMAJOR]
})
Expand All @@ -40,8 +36,6 @@ describe('functional:cli/commands/BumpCommand', () => {
}
]
})

vi.stubEnv('GREASE_CONFIG', '0')
})

describe('--preid <id>', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ describe('functional:cli/commands/ChangelogCommand', () => {
}
]
})

vi.stubEnv('GREASE_CONFIG', '0')
})

describe('--infile, -i <path>', () => {
Expand Down
Loading

0 comments on commit 8d2859b

Please sign in to comment.