+5
-4
@@ -13,6 +13,11 @@ const config: Config = {
|
|||||||
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.ts'],
|
setupFilesAfterEnv: ['<rootDir>/test/jest-setup.ts'],
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testRegex: ['.*\\.test\\.ts$'],
|
testRegex: ['.*\\.test\\.ts$'],
|
||||||
|
// Tell Jest to ignore the specific duplicate package.json files
|
||||||
|
// that are causing Haste module naming collisions
|
||||||
|
modulePathIgnorePatterns: [
|
||||||
|
'<rootDir>/test/e2e/prompt-module/data/'
|
||||||
|
],
|
||||||
transformIgnorePatterns: [
|
transformIgnorePatterns: [
|
||||||
'node_modules/(?!(cli-testing-library|@clack|cleye)/.*)'
|
'node_modules/(?!(cli-testing-library|@clack|cleye)/.*)'
|
||||||
],
|
],
|
||||||
@@ -29,10 +34,6 @@ const config: Config = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// Fix Haste module naming collision
|
|
||||||
modulePathIgnorePatterns: [
|
|
||||||
'<rootDir>/test/e2e/prompt-module/data/'
|
|
||||||
],
|
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^(\\.{1,2}/.*)\\.js$': '$1'
|
'^(\\.{1,2}/.*)\\.js$': '$1'
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+29
-3
@@ -2128,6 +2128,17 @@
|
|||||||
"integrity": "sha512-AanzbulOHljrku1NGfafxdpTCfw2ENaWzH01N2vqQM+cUFbk868Cgh0xylz0JIM9BoKbfI++bdD6EYX0Q/UTEw==",
|
"integrity": "sha512-AanzbulOHljrku1NGfafxdpTCfw2ENaWzH01N2vqQM+cUFbk868Cgh0xylz0JIM9BoKbfI++bdD6EYX0Q/UTEw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@pkgjs/parseargs": {
|
||||||
|
"version": "0.11.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||||
|
"integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@sinclair/typebox": {
|
"node_modules/@sinclair/typebox": {
|
||||||
"version": "0.27.8",
|
"version": "0.27.8",
|
||||||
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz",
|
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz",
|
||||||
@@ -5422,12 +5433,15 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@isaacs/cliui": "^8.0.2"
|
"@isaacs/cliui": "^8.0.2"
|
||||||
},
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@pkgjs/parseargs": "^0.11.0"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22"
|
"node": "20 || >=22"
|
||||||
},
|
},
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/jake": {
|
"node_modules/jake": {
|
||||||
"version": "10.9.2",
|
"version": "10.9.2",
|
||||||
@@ -7521,6 +7535,7 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/path-scurry": {
|
"node_modules/path-scurry": {
|
||||||
|
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz",
|
||||||
"integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==",
|
"integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==",
|
||||||
@@ -7538,6 +7553,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/path-scurry/node_modules/lru-cache": {
|
"node_modules/path-scurry/node_modules/lru-cache": {
|
||||||
|
|
||||||
"version": "11.1.0",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.1.0.tgz",
|
||||||
"integrity": "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==",
|
"integrity": "sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==",
|
||||||
@@ -7546,6 +7562,7 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22"
|
"node": "20 || >=22"
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"node_modules/picocolors": {
|
"node_modules/picocolors": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
@@ -7928,6 +7945,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rimraf": {
|
"node_modules/rimraf": {
|
||||||
|
|
||||||
"version": "6.0.1",
|
"version": "6.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz",
|
||||||
"integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==",
|
"integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==",
|
||||||
@@ -7940,30 +7958,37 @@
|
|||||||
"bin": {
|
"bin": {
|
||||||
"rimraf": "dist/esm/bin.mjs"
|
"rimraf": "dist/esm/bin.mjs"
|
||||||
},
|
},
|
||||||
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22"
|
"node": "20 || >=22"
|
||||||
},
|
},
|
||||||
|
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rimraf/node_modules/glob": {
|
"node_modules/rimraf/node_modules/glob": {
|
||||||
|
|
||||||
"version": "11.0.1",
|
"version": "11.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-11.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-11.0.1.tgz",
|
||||||
"integrity": "sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==",
|
"integrity": "sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==",
|
||||||
|
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"foreground-child": "^3.1.0",
|
"foreground-child": "^3.1.0",
|
||||||
|
|
||||||
"jackspeak": "^4.0.1",
|
"jackspeak": "^4.0.1",
|
||||||
"minimatch": "^10.0.0",
|
"minimatch": "^10.0.0",
|
||||||
"minipass": "^7.1.2",
|
"minipass": "^7.1.2",
|
||||||
"package-json-from-dist": "^1.0.0",
|
"package-json-from-dist": "^1.0.0",
|
||||||
"path-scurry": "^2.0.0"
|
"path-scurry": "^2.0.0"
|
||||||
|
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"glob": "dist/esm/bin.mjs"
|
"glob": "dist/esm/bin.mjs"
|
||||||
},
|
},
|
||||||
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22"
|
"node": "20 || >=22"
|
||||||
},
|
},
|
||||||
@@ -7983,6 +8008,7 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22"
|
"node": "20 || >=22"
|
||||||
},
|
},
|
||||||
|
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@
|
|||||||
"ollama:start": "OCO_AI_PROVIDER='ollama' node ./out/cli.cjs",
|
"ollama:start": "OCO_AI_PROVIDER='ollama' node ./out/cli.cjs",
|
||||||
"dev": "ts-node ./src/cli.ts",
|
"dev": "ts-node ./src/cli.ts",
|
||||||
"dev:gemini": "OCO_AI_PROVIDER='gemini' ts-node ./src/cli.ts",
|
"dev:gemini": "OCO_AI_PROVIDER='gemini' ts-node ./src/cli.ts",
|
||||||
"build": "rimraf out && node esbuild.config.js",
|
"build": "npx rimraf out && node esbuild.config.js",
|
||||||
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
|
"build:push": "npm run build && git add . && git commit -m 'build' && git push",
|
||||||
"deploy": "npm publish --tag latest",
|
"deploy": "npm publish --tag latest",
|
||||||
"deploy:build": "npm run build:push && git push --tags && npm run deploy",
|
"deploy:build": "npm run build:push && git push --tags && npm run deploy",
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ describe('cli flow to push git branch', () => {
|
|||||||
await render('git', ['add index.ts'], { cwd: gitDir });
|
await render('git', ['add index.ts'], { cwd: gitDir });
|
||||||
|
|
||||||
const { queryByText, findByText, userEvent } = await render(
|
const { queryByText, findByText, userEvent } = await render(
|
||||||
`OCO_AI_PROVIDER='test' node`,
|
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
|
||||||
[resolve('./out/cli.cjs')],
|
[resolve('./out/cli.cjs')],
|
||||||
{ cwd: gitDir }
|
{ cwd: gitDir }
|
||||||
);
|
);
|
||||||
@@ -158,7 +158,7 @@ describe('cli flow to push git branch', () => {
|
|||||||
await render('git', ['add index.ts'], { cwd: gitDir });
|
await render('git', ['add index.ts'], { cwd: gitDir });
|
||||||
|
|
||||||
const { findByText, userEvent } = await render(
|
const { findByText, userEvent } = await render(
|
||||||
`OCO_AI_PROVIDER='test' node`,
|
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
|
||||||
[resolve('./out/cli.cjs')],
|
[resolve('./out/cli.cjs')],
|
||||||
{ cwd: gitDir }
|
{ cwd: gitDir }
|
||||||
);
|
);
|
||||||
@@ -186,7 +186,7 @@ describe('cli flow to push git branch', () => {
|
|||||||
await render('git', ['add index.ts'], { cwd: gitDir });
|
await render('git', ['add index.ts'], { cwd: gitDir });
|
||||||
|
|
||||||
const { findByText, userEvent } = await render(
|
const { findByText, userEvent } = await render(
|
||||||
`OCO_AI_PROVIDER='test' node`,
|
`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`,
|
||||||
[resolve('./out/cli.cjs')],
|
[resolve('./out/cli.cjs')],
|
||||||
{ cwd: gitDir }
|
{ cwd: gitDir }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ it('cli flow to generate commit message for 1 new file (staged)', async () => {
|
|||||||
await render('echo' ,[`'console.log("Hello World");' > index.ts`], { cwd: gitDir });
|
await render('echo' ,[`'console.log("Hello World");' > index.ts`], { cwd: gitDir });
|
||||||
await render('git' ,['add index.ts'], { cwd: gitDir });
|
await render('git' ,['add index.ts'], { cwd: gitDir });
|
||||||
|
|
||||||
const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
|
const { queryByText, findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
|
||||||
expect(await queryByText('No files are staged')).not.toBeInTheConsole();
|
expect(await queryByText('No files are staged')).not.toBeInTheConsole();
|
||||||
expect(await queryByText('Do you want to stage all files and generate commit message?')).not.toBeInTheConsole();
|
expect(await queryByText('Do you want to stage all files and generate commit message?')).not.toBeInTheConsole();
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ it('cli flow to generate commit message for 1 changed file (not staged)', async
|
|||||||
|
|
||||||
await render('echo' ,[`'console.log("Good night World");' >> index.ts`], { cwd: gitDir });
|
await render('echo' ,[`'console.log("Good night World");' >> index.ts`], { cwd: gitDir });
|
||||||
|
|
||||||
const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
|
const { findByText, userEvent } = await render(`OCO_AI_PROVIDER='test' OCO_GITPUSH='true' node`, [resolve('./out/cli.cjs')], { cwd: gitDir });
|
||||||
|
|
||||||
expect(await findByText('No files are staged')).toBeInTheConsole();
|
expect(await findByText('No files are staged')).toBeInTheConsole();
|
||||||
expect(await findByText('Do you want to stage all files and generate commit message?')).toBeInTheConsole();
|
expect(await findByText('Do you want to stage all files and generate commit message?')).toBeInTheConsole();
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import { prepareEnvironment, wait } from '../utils';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
function getAbsolutePath(relativePath: string) {
|
function getAbsolutePath(relativePath: string) {
|
||||||
const scriptDir = path.dirname(__filename);
|
// Use process.cwd() which should be the project root during test execution
|
||||||
return path.resolve(scriptDir, relativePath);
|
return path.resolve(process.cwd(), 'test/e2e/prompt-module', relativePath);
|
||||||
}
|
}
|
||||||
async function setupCommitlint(dir: string, ver: 9 | 18 | 19) {
|
async function setupCommitlint(dir: string, ver: 9 | 18 | 19) {
|
||||||
let packagePath, packageJsonPath, configPath;
|
let packagePath, packageJsonPath, configPath;
|
||||||
@@ -47,7 +47,7 @@ describe('cli flow to run "oco commitlint force"', () => {
|
|||||||
`
|
`
|
||||||
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
||||||
OCO_PROMPT_MODULE='@commitlint' \
|
OCO_PROMPT_MODULE='@commitlint' \
|
||||||
OCO_AI_PROVIDER='test' \
|
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
|
||||||
node ${resolve('./out/cli.cjs')} commitlint force \
|
node ${resolve('./out/cli.cjs')} commitlint force \
|
||||||
`,
|
`,
|
||||||
[],
|
[],
|
||||||
@@ -83,7 +83,7 @@ describe('cli flow to run "oco commitlint force"', () => {
|
|||||||
`
|
`
|
||||||
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
||||||
OCO_PROMPT_MODULE='@commitlint' \
|
OCO_PROMPT_MODULE='@commitlint' \
|
||||||
OCO_AI_PROVIDER='test' \
|
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
|
||||||
node ${resolve('./out/cli.cjs')} commitlint force \
|
node ${resolve('./out/cli.cjs')} commitlint force \
|
||||||
`,
|
`,
|
||||||
[],
|
[],
|
||||||
@@ -119,7 +119,7 @@ describe('cli flow to run "oco commitlint force"', () => {
|
|||||||
`
|
`
|
||||||
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
||||||
OCO_PROMPT_MODULE='@commitlint' \
|
OCO_PROMPT_MODULE='@commitlint' \
|
||||||
OCO_AI_PROVIDER='test' \
|
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
|
||||||
node ${resolve('./out/cli.cjs')} commitlint force \
|
node ${resolve('./out/cli.cjs')} commitlint force \
|
||||||
`,
|
`,
|
||||||
[],
|
[],
|
||||||
@@ -160,7 +160,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
|
|||||||
`
|
`
|
||||||
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
||||||
OCO_PROMPT_MODULE='@commitlint' \
|
OCO_PROMPT_MODULE='@commitlint' \
|
||||||
OCO_AI_PROVIDER='test' \
|
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
|
||||||
node ${resolve('./out/cli.cjs')} commitlint force \
|
node ${resolve('./out/cli.cjs')} commitlint force \
|
||||||
`,
|
`,
|
||||||
[],
|
[],
|
||||||
@@ -175,7 +175,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
|
|||||||
`
|
`
|
||||||
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
OCO_TEST_MOCK_TYPE='prompt-module-commitlint-config' \
|
||||||
OCO_PROMPT_MODULE='@commitlint' \
|
OCO_PROMPT_MODULE='@commitlint' \
|
||||||
OCO_AI_PROVIDER='test' \
|
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
|
||||||
node ${resolve('./out/cli.cjs')} commitlint get \
|
node ${resolve('./out/cli.cjs')} commitlint get \
|
||||||
`,
|
`,
|
||||||
[],
|
[],
|
||||||
@@ -193,7 +193,7 @@ describe('cli flow to generate commit message using @commitlint prompt-module',
|
|||||||
`
|
`
|
||||||
OCO_TEST_MOCK_TYPE='commit-message' \
|
OCO_TEST_MOCK_TYPE='commit-message' \
|
||||||
OCO_PROMPT_MODULE='@commitlint' \
|
OCO_PROMPT_MODULE='@commitlint' \
|
||||||
OCO_AI_PROVIDER='test' \
|
OCO_AI_PROVIDER='test' OCO_GITPUSH='true' \
|
||||||
node ${resolve('./out/cli.cjs')} \
|
node ${resolve('./out/cli.cjs')} \
|
||||||
`,
|
`,
|
||||||
[],
|
[],
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { jest } from '@jest/globals';
|
|||||||
import 'cli-testing-library/extend-expect';
|
import 'cli-testing-library/extend-expect';
|
||||||
import { configure } from 'cli-testing-library';
|
import { configure } from 'cli-testing-library';
|
||||||
|
|
||||||
|
// Make Jest available globally
|
||||||
global.jest = jest;
|
global.jest = jest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-2
@@ -3,10 +3,10 @@
|
|||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"lib": ["ES6", "ES2020"],
|
"lib": ["ES6", "ES2020"],
|
||||||
|
|
||||||
"module": "CommonJS",
|
"module": "NodeNext",
|
||||||
|
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "NodeNext",
|
||||||
|
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user