Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
"@types/react-dom": "^19.0.6",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@typescript-eslint/parser": "^8.19.0",
"@vitest/coverage-v8": "2.1.8",
"@vitest/coverage-v8": "^4.1.11",
"eslint": "^9.17.0",
"jsdom": "^26.0.0",
"typescript": "^5.7.3",
"vitest": "^2.1.8"
"vite": "^7",
"vitest": "^4.1.11"
},
"dependencies": {
"fuse.js": "^7.1.0",
Expand All @@ -61,9 +62,17 @@
"ts-morph": "^28.0.0"
},
"peerDependenciesMeta": {
"@inquirer/prompts": { "optional": true },
"chalk": { "optional": true },
"commander": { "optional": true },
"ts-morph": { "optional": true }
"@inquirer/prompts": {
"optional": true
},
"chalk": {
"optional": true
},
"commander": {
"optional": true
},
"ts-morph": {
"optional": true
}
}
}
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/add-learning.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { addLearningCommand } from '../add-learning.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -7,7 +8,10 @@ vi.mock('@inquirer/prompts', () => ({
select: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -20,7 +24,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('addLearningCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project', 'other-project'])
})

Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/add-post.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { addPostCommand } from '../add-post.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -6,7 +7,10 @@ vi.mock('@inquirer/prompts', () => ({
input: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', () => ({
addPost: vi.fn(),
Expand All @@ -18,7 +22,7 @@ vi.mock('../../lib/config-editor.js', () => ({

describe('addPostCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project', 'other-project'])
})

Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/add-project.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { addProjectCommand } from '../add-project.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -8,7 +9,10 @@ vi.mock('@inquirer/prompts', () => ({
confirm: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -21,7 +25,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('addProjectCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
})

describe('non-interactive mode', () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/add-timeline.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { addTimelineCommand } from '../add-timeline.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -6,7 +7,10 @@ vi.mock('@inquirer/prompts', () => ({
input: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', () => ({
addTimelineEntry: vi.fn(),
Expand All @@ -18,7 +22,7 @@ vi.mock('../../lib/config-editor.js', () => ({

describe('addTimelineCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project', 'other-project'])
})

Expand Down
21 changes: 18 additions & 3 deletions packages/core/src/commands/__tests__/add.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { add } from '../add'
import * as prompts from '@inquirer/prompts'

vi.mock('@inquirer/prompts', async () => ({
confirm: vi.fn()
}))
vi.mock('node:fs/promises')
vi.mock('node:fs')
vi.mock('node:child_process')
vi.mock('node:fs/promises', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs/promises')>()),
mkdir: vi.fn(),
access: vi.fn(),
copyFile: vi.fn(),
readdir: vi.fn(),
readFile: vi.fn(),
writeFile: vi.fn(),
}))
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))
vi.mock('node:child_process', async (importOriginal) => ({
...(await importOriginal<typeof import('node:child_process')>()),
execSync: vi.fn(),
}))

describe('add command', () => {
beforeEach(() => {
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/edit-project.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { editProjectCommand } from '../edit-project.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -8,7 +9,10 @@ vi.mock('@inquirer/prompts', () => ({
confirm: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -26,7 +30,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('editProjectCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project', 'other-project'])
vi.mocked(configEditor.getProjectSummaries).mockReturnValue([
{ id: 'my-project', type: 'github', status: 'active', featured: true, name: 'My Project' },
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/list-projects.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { listProjectsCommand } from '../list-projects.js'
import * as configEditor from '../../lib/config-editor.js'

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -14,7 +18,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('listProjectsCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
})

it('should display table with projects', async () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/remove-learning.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { removeLearningCommand } from '../remove-learning.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -6,7 +7,10 @@ vi.mock('@inquirer/prompts', () => ({
select: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -24,7 +28,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('removeLearningCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project'])
vi.mocked(configEditor.getLearningEntries).mockReturnValue([
{ index: 0, type: 'challenge', text: 'test entry 1' },
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/remove-post.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { removePostCommand } from '../remove-post.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -6,7 +7,10 @@ vi.mock('@inquirer/prompts', () => ({
select: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -22,7 +26,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('removePostCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project'])
vi.mocked(configEditor.getPostEntries).mockReturnValue([
{ index: 0, title: 'Test Post', date: '2024-01-15' },
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/remove-project.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { removeProjectCommand } from '../remove-project.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -6,7 +7,10 @@ vi.mock('@inquirer/prompts', () => ({
confirm: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -19,7 +23,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('removeProjectCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project', 'other-project'])
})

Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/commands/__tests__/remove-timeline.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { removeTimelineCommand } from '../remove-timeline.js'
import * as configEditor from '../../lib/config-editor.js'
Expand All @@ -6,7 +7,10 @@ vi.mock('@inquirer/prompts', () => ({
select: vi.fn(),
}))

vi.mock('node:fs')
vi.mock('node:fs', async (importOriginal) => ({
...(await importOriginal<typeof import('node:fs')>()),
existsSync: vi.fn(),
}))

vi.mock('../../lib/config-editor.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../lib/config-editor.js')>()
Expand All @@ -23,7 +27,7 @@ vi.mock('../../lib/config-editor.js', async (importOriginal) => {

describe('removeTimelineCommand', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.resetAllMocks()
vi.mocked(configEditor.getProjectIds).mockReturnValue(['my-project'])
vi.mocked(configEditor.getTimelineEntries).mockReturnValue([
{ index: 0, date: '2024-01-15', note: 'test note' },
Expand Down
Loading
Loading