johankit 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -5
- package/Readme.md +56 -0
- package/dist/cli/commands/copy.js +3 -4
- package/dist/cli/commands/paste.js +19 -10
- package/dist/cli/commands/prompt.js +40 -8
- package/dist/cli/commands/sync.js +10 -6
- package/dist/cli/commands/three.js +106 -0
- package/dist/index.js +52 -34
- package/dist/services/JohankitService.js +59 -0
- package/dist/utils/cleanCodeBlock.js +12 -0
- package/dist/utils/createAsciiTree.js +46 -0
- package/johankit.yaml +2 -0
- package/package.json +5 -2
- package/src/cli/commands/copy.ts +3 -4
- package/src/cli/commands/paste.ts +16 -16
- package/src/cli/commands/prompt.ts +47 -9
- package/src/cli/commands/sync.ts +8 -6
- package/src/cli/commands/three.ts +117 -0
- package/src/core/scan.ts +1 -1
- package/src/index.ts +54 -37
- package/src/services/JohankitService.ts +70 -0
- package/src/types.ts +45 -0
- package/src/utils/cleanCodeBlock.ts +13 -0
- package/src/utils/createAsciiTree.ts +53 -0
- package/tsconfig.json +4 -0
- package/dist/tests/cli/commands/copy.test.js +0 -47
- package/dist/tests/cli/commands/paste.test.js +0 -41
- package/dist/tests/cli/commands/prompt.test.js +0 -37
- package/dist/tests/cli/commands/sync.test.js +0 -47
- package/dist/tests/core/clipboard.test.js +0 -20
- package/dist/tests/core/config.test.js +0 -23
- package/dist/tests/core/diff.test.js +0 -24
- package/dist/tests/core/git.test.js +0 -11
- package/dist/tests/core/scan.test.js +0 -16
- package/dist/tests/core/schema.test.js +0 -13
- package/dist/tests/core/validation.test.js +0 -13
- package/dist/tests/core/write.test.js +0 -41
- package/package-lock.json +0 -250
- package/src/tests/cli/commands/copy.test.ts +0 -26
- package/src/tests/cli/commands/paste.test.ts +0 -19
- package/src/tests/cli/commands/prompt.test.ts +0 -14
- package/src/tests/cli/commands/sync.test.ts +0 -26
- package/src/tests/core/clipboard.test.ts +0 -21
- package/src/tests/core/config.test.ts +0 -21
- package/src/tests/core/diff.test.ts +0 -22
- package/src/tests/core/git.test.ts +0 -11
- package/src/tests/core/scan.test.ts +0 -13
- package/src/tests/core/schema.test.ts +0 -13
- package/src/tests/core/validation.test.ts +0 -13
- package/src/tests/core/write.test.ts +0 -15
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { copyToClipboard, readClipboard } from '../../../core/clipboard';
|
|
2
|
-
import { spawn } from 'child_process';
|
|
3
|
-
|
|
4
|
-
jest.mock('child_process', () => ({
|
|
5
|
-
spawn: jest.fn(() => ({
|
|
6
|
-
stdin: { write: jest.fn(), end: jest.fn() },
|
|
7
|
-
stdout: { on: jest.fn() },
|
|
8
|
-
stderr: { on: jest.fn() },
|
|
9
|
-
on: jest.fn((event, cb) => { if (event === 'close') cb(0); })
|
|
10
|
-
}))
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
describe('clipboard', () => {
|
|
14
|
-
it('should copy to clipboard', async () => {
|
|
15
|
-
await expect(copyToClipboard('hi')).resolves.toBeUndefined();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should read from clipboard', async () => {
|
|
19
|
-
await expect(readClipboard()).resolves.toBe('');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { loadConfig } from '../../../core/config';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { load as yamlLoad } from 'js-yaml';
|
|
4
|
-
|
|
5
|
-
jest.mock('fs');
|
|
6
|
-
jest.mock('js-yaml');
|
|
7
|
-
|
|
8
|
-
describe('loadConfig', () => {
|
|
9
|
-
it('should return defaults if file missing', () => {
|
|
10
|
-
(fs.readFileSync as jest.Mock).mockImplementation(() => { throw { code: 'ENOENT' }; });
|
|
11
|
-
const config = loadConfig('.');
|
|
12
|
-
expect(config.ignore).toContain('.git');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should merge user ignore', () => {
|
|
16
|
-
(fs.readFileSync as jest.Mock).mockReturnValue('ignore:\n - test');
|
|
17
|
-
(yamlLoad as jest.Mock).mockReturnValue({ ignore: ['test'] });
|
|
18
|
-
const config = loadConfig('.');
|
|
19
|
-
expect(config.ignore).toContain('test');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { applyDiff, DiffPatch } from '../../../core/diff';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
|
|
4
|
-
jest.mock('fs');
|
|
5
|
-
|
|
6
|
-
describe('applyDiff', () => {
|
|
7
|
-
it('should handle create and modify', () => {
|
|
8
|
-
const patches: DiffPatch[] = [
|
|
9
|
-
{ type: 'create', path: 'a.txt', content: 'x' },
|
|
10
|
-
{ type: 'modify', path: 'b.txt', content: 'y' }
|
|
11
|
-
];
|
|
12
|
-
applyDiff('.', patches);
|
|
13
|
-
expect(fs.writeFileSync).toHaveBeenCalledTimes(2);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should handle delete', () => {
|
|
17
|
-
(fs.existsSync as jest.Mock).mockReturnValue(true);
|
|
18
|
-
const patches: DiffPatch[] = [{ type: 'delete', path: 'c.txt' }];
|
|
19
|
-
applyDiff('.', patches);
|
|
20
|
-
expect(fs.unlinkSync).toHaveBeenCalledWith('./c.txt');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ensureGitCommit } from '../../../core/git';
|
|
2
|
-
import { execSync } from 'child_process';
|
|
3
|
-
|
|
4
|
-
jest.mock('child_process');
|
|
5
|
-
|
|
6
|
-
describe('ensureGitCommit', () => {
|
|
7
|
-
it('should call git commands without crashing', () => {
|
|
8
|
-
(execSync as jest.Mock).mockImplementation(() => '');
|
|
9
|
-
expect(() => ensureGitCommit()).not.toThrow();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { scanDir } from '../../../core/scan';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
|
|
4
|
-
jest.mock('fs');
|
|
5
|
-
|
|
6
|
-
describe('scanDir', () => {
|
|
7
|
-
it('should scan files with default ignores', () => {
|
|
8
|
-
(fs.readdirSync as jest.Mock).mockReturnValue([{ name: 'a.txt', isDirectory: () => false }]);
|
|
9
|
-
(fs.readFileSync as jest.Mock).mockReturnValue('content');
|
|
10
|
-
const files = scanDir('.');
|
|
11
|
-
expect(files[0].path).toBe('a.txt');
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { validatePatches } from '../../../core/schema';
|
|
2
|
-
|
|
3
|
-
describe('validatePatches', () => {
|
|
4
|
-
it('should validate correct patches', () => {
|
|
5
|
-
const patches = [{ type: 'create', path: 'a.txt', content: 'x' }];
|
|
6
|
-
expect(validatePatches(patches)).toEqual(patches);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('should throw on invalid patches', () => {
|
|
10
|
-
const patches = [{ type: 'invalid', path: 'a.txt', content: 'x' }];
|
|
11
|
-
expect(() => validatePatches(patches)).toThrow();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { validatePatches } from '../../../core/validation';
|
|
2
|
-
|
|
3
|
-
describe('validation', () => {
|
|
4
|
-
it('validates correct array', () => {
|
|
5
|
-
const input = [{ type: 'create', path: 'a.txt', content: 'x' }];
|
|
6
|
-
expect(validatePatches(input)).toEqual(input);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('throws on missing content', () => {
|
|
10
|
-
const input = [{ type: 'create', path: 'a.txt' }];
|
|
11
|
-
expect(() => validatePatches(input)).toThrow();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { writeFiles } from '../../../core/write';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import * as git from '../../../core/git';
|
|
4
|
-
|
|
5
|
-
jest.mock('fs');
|
|
6
|
-
jest.mock('../../../core/git');
|
|
7
|
-
|
|
8
|
-
describe('writeFiles', () => {
|
|
9
|
-
it('should write files and commit', () => {
|
|
10
|
-
const files = [{ path: 'a.txt', content: 'x' }];
|
|
11
|
-
writeFiles('.', files, true);
|
|
12
|
-
expect(fs.writeFileSync).toHaveBeenCalledWith('./a.txt', 'x', 'utf8');
|
|
13
|
-
expect(git.ensureGitCommit).toHaveBeenCalled();
|
|
14
|
-
});
|
|
15
|
-
});
|