kitstore-cli 1.0.0 → 1.0.1
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/dist/config.js +20 -4
- package/package.json +5 -1
- package/.env.test +0 -4
- package/.eslintrc.js +0 -29
- package/e2e/install.e2e.test.ts +0 -237
- package/e2e/integration.e2e.test.ts +0 -346
- package/e2e/login.e2e.test.ts +0 -188
- package/jest.config.js +0 -24
- package/openapitools.json +0 -7
- package/src/__tests__/commands/init.test.ts +0 -52
- package/src/__tests__/commands/install.test.ts +0 -449
- package/src/__tests__/commands/list.test.ts +0 -164
- package/src/__tests__/commands/login.test.ts +0 -293
- package/src/__tests__/commands/rule-check.test.ts +0 -52
- package/src/__tests__/commands/search.test.ts +0 -168
- package/src/__tests__/commands/upload.test.ts +0 -404
- package/src/__tests__/config.test.ts +0 -181
- package/src/__tests__/setup.ts +0 -11
- package/src/api/client.ts +0 -20
- package/src/api/generated/.openapi-generator/FILES +0 -17
- package/src/api/generated/.openapi-generator/VERSION +0 -1
- package/src/api/generated/.openapi-generator-ignore +0 -23
- package/src/api/generated/api.ts +0 -1171
- package/src/api/generated/base.ts +0 -62
- package/src/api/generated/common.ts +0 -113
- package/src/api/generated/configuration.ts +0 -121
- package/src/api/generated/docs/AuthApi.md +0 -158
- package/src/api/generated/docs/AuthResponseDto.md +0 -22
- package/src/api/generated/docs/AuthUserDto.md +0 -24
- package/src/api/generated/docs/HealthApi.md +0 -183
- package/src/api/generated/docs/LoginDto.md +0 -22
- package/src/api/generated/docs/RegisterDto.md +0 -24
- package/src/api/generated/docs/RuleAuthorDto.md +0 -22
- package/src/api/generated/docs/RuleResponseDto.md +0 -36
- package/src/api/generated/docs/RulesApi.md +0 -289
- package/src/api/generated/git_push.sh +0 -57
- package/src/api/generated/index.ts +0 -18
- package/src/commands/init.ts +0 -46
- package/src/commands/install.ts +0 -129
- package/src/commands/list.ts +0 -71
- package/src/commands/login.ts +0 -65
- package/src/commands/rule-check.ts +0 -49
- package/src/commands/search.ts +0 -66
- package/src/commands/upload.ts +0 -117
- package/src/config.ts +0 -66
- package/src/index.ts +0 -79
- package/test-cli-config.js +0 -118
- package/tsconfig.json +0 -24
package/e2e/login.e2e.test.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
2
|
-
import { existsSync, unlinkSync, readFileSync } from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
|
|
5
|
-
// TC-E2E-CLI-001: Complete login flow
|
|
6
|
-
// TC-E2E-CLI-009: Error handling (auth error)
|
|
7
|
-
// TC-E2E-CLI-010: Interactive login flow
|
|
8
|
-
describe('CLI Login E2E Tests', () => {
|
|
9
|
-
const tempHome = path.join(process.cwd(), 'temp-home-login');
|
|
10
|
-
const configDir = path.join(tempHome, '.kitstore');
|
|
11
|
-
const configPath = path.join(configDir, 'config.json');
|
|
12
|
-
const cliPath = path.join(process.cwd(), 'dist', 'index.js');
|
|
13
|
-
|
|
14
|
-
beforeAll(() => {
|
|
15
|
-
if (!existsSync(tempHome)) {
|
|
16
|
-
require('fs').mkdirSync(tempHome, { recursive: true });
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
// Clean up config file
|
|
22
|
-
if (existsSync(configPath)) {
|
|
23
|
-
unlinkSync(configPath);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
afterAll(() => {
|
|
28
|
-
// Clean up temp home
|
|
29
|
-
if (existsSync(tempHome)) {
|
|
30
|
-
require('fs-extra').removeSync(tempHome);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
afterEach(() => {
|
|
35
|
-
// Clean up after tests
|
|
36
|
-
if (existsSync(configPath)) {
|
|
37
|
-
unlinkSync(configPath);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// TC-E2E-CLI-001: Complete login flow
|
|
42
|
-
test('should login successfully and save token', () => {
|
|
43
|
-
// Skip if CLI is not built
|
|
44
|
-
if (!existsSync(cliPath)) {
|
|
45
|
-
console.warn('Skipping test: CLI not built');
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
// Run login command with test credentials
|
|
51
|
-
const result = execSync(
|
|
52
|
-
`node ${cliPath} login --email test@example.com --password testpassword123`,
|
|
53
|
-
{
|
|
54
|
-
encoding: 'utf8',
|
|
55
|
-
timeout: 10000,
|
|
56
|
-
env: {
|
|
57
|
-
...process.env,
|
|
58
|
-
NODE_ENV: 'test',
|
|
59
|
-
AGENTKIT_CONFIG_DIR: configDir,
|
|
60
|
-
HOME: tempHome,
|
|
61
|
-
USERPROFILE: tempHome,
|
|
62
|
-
HOMEDRIVE: tempHome.substring(0, 2),
|
|
63
|
-
HOMEPATH: tempHome.substring(2)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// Check if login was successful
|
|
69
|
-
expect(result).toContain('✅ Logged in');
|
|
70
|
-
|
|
71
|
-
// Check if config file was created
|
|
72
|
-
expect(existsSync(configPath)).toBe(true);
|
|
73
|
-
|
|
74
|
-
// Verify config contains token
|
|
75
|
-
const config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
76
|
-
expect(config.token).toBeDefined();
|
|
77
|
-
expect(config.user).toBeDefined();
|
|
78
|
-
expect(config.user.username).toBe('testuser');
|
|
79
|
-
|
|
80
|
-
} catch (error: any) {
|
|
81
|
-
const output = (error.stdout || '') + (error.stderr || '');
|
|
82
|
-
if (
|
|
83
|
-
output.includes('ECONNREFUSED') ||
|
|
84
|
-
output.includes('ENOTFOUND') ||
|
|
85
|
-
output.includes('Login failed: Error') ||
|
|
86
|
-
output.includes('Unauthorized') ||
|
|
87
|
-
output.includes('status code 401')
|
|
88
|
-
) {
|
|
89
|
-
console.warn('Skipping test: Backend server not running or unauthorized');
|
|
90
|
-
return;
|
|
91
|
-
} else {
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// TC-E2E-CLI-009: Error handling (auth error)
|
|
98
|
-
test('should handle authentication error', () => {
|
|
99
|
-
// Skip if CLI is not built
|
|
100
|
-
if (!existsSync(cliPath)) {
|
|
101
|
-
console.warn('Skipping test: CLI not built');
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
// Run login command with invalid credentials
|
|
107
|
-
execSync(
|
|
108
|
-
`node ${cliPath} login --email invalid@example.com --password wrongpassword`,
|
|
109
|
-
{
|
|
110
|
-
encoding: 'utf8',
|
|
111
|
-
timeout: 10000,
|
|
112
|
-
env: {
|
|
113
|
-
...process.env,
|
|
114
|
-
NODE_ENV: 'test',
|
|
115
|
-
AGENTKIT_CONFIG_DIR: configDir,
|
|
116
|
-
HOME: tempHome,
|
|
117
|
-
USERPROFILE: tempHome,
|
|
118
|
-
HOMEDRIVE: tempHome.substring(0, 2),
|
|
119
|
-
HOMEPATH: tempHome.substring(2)
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// Should not reach here - command should exit with error
|
|
125
|
-
fail('Expected login command to fail with invalid credentials');
|
|
126
|
-
} catch (error: any) {
|
|
127
|
-
// Expected to fail
|
|
128
|
-
expect(error.status).toBe(1);
|
|
129
|
-
expect(error.stderr || error.stdout).toContain('❌ Login failed');
|
|
130
|
-
|
|
131
|
-
// Config file should not be created
|
|
132
|
-
expect(existsSync(configPath)).toBe(false);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// TC-E2E-CLI-010: Login with custom server
|
|
137
|
-
test('should login with custom server URL', () => {
|
|
138
|
-
// Skip if CLI is not built
|
|
139
|
-
if (!existsSync(cliPath)) {
|
|
140
|
-
console.warn('Skipping test: CLI not built');
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
// Run login command with custom server
|
|
146
|
-
const result = execSync(
|
|
147
|
-
`node ${cliPath} login --email test@example.com --password testpassword123 --server http://localhost:3000`,
|
|
148
|
-
{
|
|
149
|
-
encoding: 'utf8',
|
|
150
|
-
timeout: 10000,
|
|
151
|
-
env: {
|
|
152
|
-
...process.env,
|
|
153
|
-
NODE_ENV: 'test',
|
|
154
|
-
AGENTKIT_CONFIG_DIR: configDir,
|
|
155
|
-
HOME: tempHome,
|
|
156
|
-
USERPROFILE: tempHome,
|
|
157
|
-
HOMEDRIVE: tempHome.substring(0, 2),
|
|
158
|
-
HOMEPATH: tempHome.substring(2)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
expect(result).toContain('✅ Logged in');
|
|
164
|
-
|
|
165
|
-
// Verify config contains custom server
|
|
166
|
-
const config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
167
|
-
expect(config.server).toBe('http://localhost:3000');
|
|
168
|
-
|
|
169
|
-
} catch (error: any) {
|
|
170
|
-
const output = (error.stdout || '') + (error.stderr || '');
|
|
171
|
-
if (
|
|
172
|
-
output.includes('ECONNREFUSED') ||
|
|
173
|
-
output.includes('ENOTFOUND') ||
|
|
174
|
-
output.includes('Login failed: Error') ||
|
|
175
|
-
output.includes('Unauthorized') ||
|
|
176
|
-
output.includes('status code 401')
|
|
177
|
-
) {
|
|
178
|
-
console.warn('Skipping test: Backend server not running or unauthorized');
|
|
179
|
-
return;
|
|
180
|
-
} else {
|
|
181
|
-
throw error;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
package/jest.config.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: 'ts-jest',
|
|
3
|
-
testEnvironment: 'node',
|
|
4
|
-
roots: ['<rootDir>/src', '<rootDir>/e2e'],
|
|
5
|
-
testMatch: ['**/__tests__/**/*.test.ts', '**/*.e2e.test.ts'],
|
|
6
|
-
collectCoverageFrom: [
|
|
7
|
-
'src/**/*.ts',
|
|
8
|
-
'!src/**/*.d.ts',
|
|
9
|
-
'!src/index.ts',
|
|
10
|
-
'!src/api/generated/**',
|
|
11
|
-
],
|
|
12
|
-
coverageDirectory: 'coverage',
|
|
13
|
-
moduleNameMapper: {
|
|
14
|
-
'^@/(.*)$': '<rootDir>/src/$1',
|
|
15
|
-
},
|
|
16
|
-
transform: {
|
|
17
|
-
'^.+\\.ts$': ['ts-jest', {
|
|
18
|
-
useESM: false,
|
|
19
|
-
}],
|
|
20
|
-
},
|
|
21
|
-
extensionsToTreatAsEsm: [],
|
|
22
|
-
setupFilesAfterEnv: ['<rootDir>/src/__tests__/setup.ts'],
|
|
23
|
-
};
|
|
24
|
-
|
package/openapitools.json
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { initCommand } from '../../commands/init';
|
|
2
|
-
import * as fs from 'fs-extra';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import inquirer from 'inquirer';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
|
|
7
|
-
jest.mock('fs-extra');
|
|
8
|
-
jest.mock('inquirer');
|
|
9
|
-
|
|
10
|
-
describe('Init Command', () => {
|
|
11
|
-
const cwd = process.cwd();
|
|
12
|
-
const cursorDir = path.join(cwd, '.cursor');
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
jest.clearAllMocks();
|
|
16
|
-
jest.spyOn(console, 'log').mockImplementation();
|
|
17
|
-
jest.spyOn(console, 'error').mockImplementation();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should initialize cursor kit directories', async () => {
|
|
21
|
-
(fs.pathExists as unknown as jest.Mock).mockResolvedValue(false);
|
|
22
|
-
(fs.ensureDir as unknown as jest.Mock).mockResolvedValue(undefined);
|
|
23
|
-
|
|
24
|
-
await initCommand();
|
|
25
|
-
|
|
26
|
-
expect(fs.ensureDir).toHaveBeenCalledWith(path.join(cursorDir, 'rules'));
|
|
27
|
-
expect(fs.ensureDir).toHaveBeenCalledWith(path.join(cursorDir, 'commands'));
|
|
28
|
-
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Successfully initialized Cursor Kit!'));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should ask for confirmation if .cursor exists', async () => {
|
|
32
|
-
(fs.pathExists as unknown as jest.Mock).mockResolvedValue(true);
|
|
33
|
-
(inquirer.prompt as unknown as jest.Mock).mockResolvedValue({ overwrite: true });
|
|
34
|
-
(fs.ensureDir as unknown as jest.Mock).mockResolvedValue(undefined);
|
|
35
|
-
|
|
36
|
-
await initCommand();
|
|
37
|
-
|
|
38
|
-
expect(inquirer.prompt).toHaveBeenCalled();
|
|
39
|
-
expect(fs.ensureDir).toHaveBeenCalled();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should cancel if user chooses not to overwrite', async () => {
|
|
43
|
-
(fs.pathExists as unknown as jest.Mock).mockResolvedValue(true);
|
|
44
|
-
(inquirer.prompt as unknown as jest.Mock).mockResolvedValue({ overwrite: false });
|
|
45
|
-
|
|
46
|
-
await initCommand();
|
|
47
|
-
|
|
48
|
-
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('Initialization cancelled.'));
|
|
49
|
-
expect(fs.ensureDir).not.toHaveBeenCalled();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|