Skip to content

Commit

Permalink
fix(listr-error): changes the types for the listrerror
Browse files Browse the repository at this point in the history
- updates the jest configuration where snapshots does not include the prototype names anymore

fix #653
  • Loading branch information
cenk1cenk2 committed Sep 5, 2022
1 parent 66e306e commit 306a304
Show file tree
Hide file tree
Showing 26 changed files with 1,533 additions and 1,497 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
node-version:
- 16.x
- 18.x
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -30,9 +30,9 @@ jobs:
strategy:
matrix:
node-version:
- 12.x
- 14.x
- 16.x
- 18.x
os:
- ubuntu-latest
steps:
Expand All @@ -49,7 +49,7 @@ jobs:
strategy:
matrix:
node-version:
- 16.x
- 18.x
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
dry_run: true
branches: |
[
"master",
"develop"
"*"
]
extra_plugins: |
@semantic-release/changelog
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/sync.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
"version": "0.2.0",
"configurations": [
{
"type": "node2",
"type": "node",
"name": "attach",
"port": 9229,
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"localRoot": "${workspaceFolder}",
"remoteRoot": "/data/app",
"sourceMaps": true
}
]
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,28 @@
},
"devDependencies": {
"@cenk1cenk2/cz-cc": "^1.5.3",
"@cenk1cenk2/eslint-config": "2.5.21",
"@cenk1cenk2/eslint-config": "2.5.26",
"@types/clone": "^2.1.1",
"@types/jest": "^28.1.6",
"@types/node": "^18.6.1",
"@types/jest": "^29.0.0",
"@types/node": "^18.7.15",
"@types/through": "^0.0.30",
"@types/wrap-ansi": "^3.0.0",
"delay": "^5.0.0",
"enquirer": "^2.3.6",
"eslint": "^8.21.0",
"jest": "^28.1.3",
"eslint": "^8.23.0",
"jest": "^29.0.2",
"jest-mock-process": "^2.0.0",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"simple-git-hooks": "^2.8.0",
"ts-jest": "^28.0.7",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.0.0",
"tsup": "6.2.1",
"typedoc": "^0.23.10",
"typedoc-plugin-markdown": "^3.13.4",
"typescript": "^4.7.4"
"tsconfig-paths": "^4.1.0",
"tsup": "6.2.3",
"typedoc": "^0.23.14",
"typedoc-plugin-markdown": "^3.13.6",
"typescript": "^4.8.2"
},
"peerDependencies": {
"enquirer": ">= 2.3.0 < 3"
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/listr-error.interface.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ListrContext } from './listr.interface'
import type { ListrRendererFactory } from './renderer.interface'
import type { Task } from '@lib/task'
import { cloneObject } from '@utils/general'

/** The internal error handling mechanism.. */
export class ListrError<Ctx extends Record<PropertyKey, any> = Record<PropertyKey, any>> extends Error {
export class ListrError<Ctx extends ListrContext = ListrContext> extends Error {
public path: string
public ctx: Ctx

Expand Down
4 changes: 2 additions & 2 deletions src/lib/task-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createPrompt, destroyPrompt } from '@utils/prompt'
import type { PromptOptions } from '@utils/prompt.interface'

/**
* Extend the task to have more functionality while accesing from the outside.
* Extend the task to have more functionality while accessing from the outside.
*/
export class TaskWrapper<Ctx, Renderer extends ListrRendererFactory> {
constructor (public task: Task<Ctx, ListrRendererFactory>, public errors: ListrError<Ctx>[], private options: ListrBaseClassOptions<Ctx, any, any>) {}
Expand Down Expand Up @@ -94,7 +94,7 @@ export class TaskWrapper<Ctx, Renderer extends ListrRendererFactory> {
* Pass stream of data to internal stdout.
*
* Since Listr2 takes control of process.stdout utilizing the default renderer, any data outputted to process.stdout
* will corupt its looks.
* will corrupt its looks.
*
* This returns a fake stream to pass any stream inside Listr as task data.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/listr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import { getRenderer } from '@utils/renderer'
/**
* Creates a new set of Listr2 task list.
*/
export class Listr<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> {
export class Listr<
Ctx extends ListrContext = ListrContext,
Renderer extends ListrRendererValue = ListrDefaultRendererValue,
FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue
> {
public tasks: Task<Ctx, ListrGetRendererClassFromValue<Renderer>>[] = []
public err: ListrError<Ctx>[] = []
public ctx: Ctx
Expand Down
2 changes: 1 addition & 1 deletion src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ListrGetRendererClassFromValue, ListrRendererValue } from '@interf
/**
* Creates a new Listr2 task manager.
*
* Useful for creating a single instace of Listr2 with pre-set settings.
* Useful for creating a single instance of Listr2 with pre-set settings.
*/
export class Manager<Ctx = ListrContext, Renderer extends ListrRendererValue = 'default', FallbackRenderer extends ListrRendererValue = 'verbose'> {
public err: ListrError[] = []
Expand Down
36 changes: 18 additions & 18 deletions src/utils/logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ describe('logger', () => {
testForAllExcept(instances, error, 1, {
onOne: () => {
expect(error.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[FAILED] test message",
],
]
Expand All @@ -70,8 +70,8 @@ describe('logger', () => {
testForAllExcept(instances, info, 1, {
onOne: () => {
expect(info.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[SKIPPED] test message",
],
]
Expand All @@ -88,8 +88,8 @@ describe('logger', () => {
testForAllExcept(instances, log, 1, {
onOne: () => {
expect(log.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[SUCCESS] test message",
],
]
Expand All @@ -106,8 +106,8 @@ describe('logger', () => {
testForAllExcept(instances, info, 1, {
onOne: () => {
expect(info.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[DATA] test message",
],
]
Expand All @@ -124,8 +124,8 @@ describe('logger', () => {
testForAllExcept(instances, log, 1, {
onOne: () => {
expect(log.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[STARTED] test message",
],
]
Expand All @@ -142,8 +142,8 @@ describe('logger', () => {
testForAllExcept(instances, info, 1, {
onOne: () => {
expect(info.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[TITLE] test message",
],
]
Expand All @@ -160,8 +160,8 @@ describe('logger', () => {
testForAllExcept(instances, warn, 1, {
onOne: () => {
expect(warn.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[ROLLBACK] test message",
],
]
Expand All @@ -178,8 +178,8 @@ describe('logger', () => {
testForAllExcept(instances, warn, 1, {
onOne: () => {
expect(warn.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[RETRY] test message",
],
]
Expand All @@ -200,8 +200,8 @@ describe('logger', () => {
testForAllExcept(instances, info, 1, {
onOne: () => {
expect(info.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
[
[
"[DATA] THIS IS A LONG LONG MESSAGE
[DATA] THIS IS A LONG LONG MESSAGE
[DATA] THIS IS A LONG LONG MESSAGE
Expand Down
32 changes: 16 additions & 16 deletions tests/__snapshots__/renderer-access-parent.e2e-spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`show subtasks should be able to change the title of parent from subtask: nvFwliir81dQSzoa7xPXaq0E1lauH674-err 1`] = `Array []`;
exports[`show subtasks should be able to change the title of parent from subtask: nvFwliir81dQSzoa7xPXaq0E1lauH674-err 1`] = `[]`;

exports[`show subtasks should be able to change the title of parent from subtask: nvFwliir81dQSzoa7xPXaq0E1lauH674-exit 1`] = `Array []`;
exports[`show subtasks should be able to change the title of parent from subtask: nvFwliir81dQSzoa7xPXaq0E1lauH674-exit 1`] = `[]`;

exports[`show subtasks should be able to change the title of parent from subtask: nvFwliir81dQSzoa7xPXaq0E1lauH674-out 1`] = `
Array [
Array [
[
[
"◼ This task will execute.
",
],
Array [
[
"❯ This task will execute.
",
],
Array [
[
"❯ This task will execute.
◼ This is a subtask.
",
],
Array [
[
"❯ This task will execute.
◼ This is a subtask.
◼ This is a subtask.
",
],
Array [
[
"❯ This task will execute.
❯ This is a subtask.
◼ This is a subtask.
",
],
Array [
[
"❯ Title changed from subtask.
❯ This is a subtask.
◼ This is a subtask.
",
],
Array [
[
"❯ Title changed from subtask.
✔ This is a subtask.
◼ This is a subtask.
",
],
Array [
[
"❯ Title changed from subtask.
✔ This is a subtask.
❯ This is a subtask.
",
],
Array [
[
"❯ Title changed from subtask.
✔ This is a subtask.
✔ This is a subtask.
",
],
Array [
[
"✔ Title changed from subtask.
",
],
Array [
[
"",
],
Array [
[
"✔ Title changed from subtask.
",
],
]
`;
`;

0 comments on commit 306a304

Please sign in to comment.