@lumenflow/cli 1.6.0 → 2.1.0
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 +19 -0
- package/dist/__tests__/backlog-prune.test.js +478 -0
- package/dist/__tests__/deps-operations.test.js +206 -0
- package/dist/__tests__/file-operations.test.js +906 -0
- package/dist/__tests__/git-operations.test.js +668 -0
- package/dist/__tests__/guards-validation.test.js +416 -0
- package/dist/__tests__/init-plan.test.js +340 -0
- package/dist/__tests__/lumenflow-upgrade.test.js +107 -0
- package/dist/__tests__/metrics-cli.test.js +619 -0
- package/dist/__tests__/rotate-progress.test.js +127 -0
- package/dist/__tests__/session-coordinator.test.js +109 -0
- package/dist/__tests__/state-bootstrap.test.js +432 -0
- package/dist/__tests__/trace-gen.test.js +115 -0
- package/dist/backlog-prune.js +299 -0
- package/dist/deps-add.js +215 -0
- package/dist/deps-remove.js +94 -0
- package/dist/docs-sync.js +72 -326
- package/dist/file-delete.js +236 -0
- package/dist/file-edit.js +247 -0
- package/dist/file-read.js +197 -0
- package/dist/file-write.js +220 -0
- package/dist/git-branch.js +187 -0
- package/dist/git-diff.js +177 -0
- package/dist/git-log.js +230 -0
- package/dist/git-status.js +208 -0
- package/dist/guard-locked.js +169 -0
- package/dist/guard-main-branch.js +202 -0
- package/dist/guard-worktree-commit.js +160 -0
- package/dist/init-plan.js +337 -0
- package/dist/lumenflow-upgrade.js +178 -0
- package/dist/metrics-cli.js +433 -0
- package/dist/rotate-progress.js +247 -0
- package/dist/session-coordinator.js +300 -0
- package/dist/state-bootstrap.js +307 -0
- package/dist/sync-templates.js +212 -0
- package/dist/trace-gen.js +331 -0
- package/dist/validate-agent-skills.js +218 -0
- package/dist/validate-agent-sync.js +148 -0
- package/dist/validate-backlog-sync.js +152 -0
- package/dist/validate-skills-spec.js +206 -0
- package/dist/validate.js +230 -0
- package/package.json +37 -7
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Tests for deps-add and deps-remove CLI commands
|
|
4
|
+
*
|
|
5
|
+
* WU-1112: INIT-003 Phase 6 - Migrate remaining Tier 1 tools
|
|
6
|
+
*
|
|
7
|
+
* These commands provide safe wrappers for pnpm add/remove that enforce
|
|
8
|
+
* worktree discipline - dependencies can only be modified in worktrees,
|
|
9
|
+
* not on the main checkout.
|
|
10
|
+
*/
|
|
11
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
12
|
+
// Import functions under test
|
|
13
|
+
import { parseDepsAddArgs, parseDepsRemoveArgs, validateWorktreeContext, buildPnpmAddCommand, buildPnpmRemoveCommand, } from '../deps-add.js';
|
|
14
|
+
describe('deps-add', () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
vi.clearAllMocks();
|
|
17
|
+
});
|
|
18
|
+
describe('parseDepsAddArgs', () => {
|
|
19
|
+
it('should parse package name from positional argument', () => {
|
|
20
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', 'react']);
|
|
21
|
+
expect(args.packages).toEqual(['react']);
|
|
22
|
+
});
|
|
23
|
+
it('should parse multiple packages', () => {
|
|
24
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', 'react', 'react-dom', 'typescript']);
|
|
25
|
+
expect(args.packages).toEqual(['react', 'react-dom', 'typescript']);
|
|
26
|
+
});
|
|
27
|
+
it('should parse --dev flag', () => {
|
|
28
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', 'vitest', '--dev']);
|
|
29
|
+
expect(args.dev).toBe(true);
|
|
30
|
+
expect(args.packages).toEqual(['vitest']);
|
|
31
|
+
});
|
|
32
|
+
it('should parse -D flag as dev dependency', () => {
|
|
33
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', '-D', 'vitest']);
|
|
34
|
+
expect(args.dev).toBe(true);
|
|
35
|
+
expect(args.packages).toEqual(['vitest']);
|
|
36
|
+
});
|
|
37
|
+
it('should parse --filter flag', () => {
|
|
38
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', '--filter', '@lumenflow/cli', 'chalk']);
|
|
39
|
+
expect(args.filter).toBe('@lumenflow/cli');
|
|
40
|
+
expect(args.packages).toEqual(['chalk']);
|
|
41
|
+
});
|
|
42
|
+
it('should parse --exact flag', () => {
|
|
43
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', '--exact', 'react@18.2.0']);
|
|
44
|
+
expect(args.exact).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
it('should set help flag', () => {
|
|
47
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', '--help']);
|
|
48
|
+
expect(args.help).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
it('should return empty packages array when no packages specified', () => {
|
|
51
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js']);
|
|
52
|
+
expect(args.packages).toEqual([]);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('validateWorktreeContext', () => {
|
|
56
|
+
it('should return valid when cwd contains worktrees/', () => {
|
|
57
|
+
const result = validateWorktreeContext('/home/user/project/worktrees/framework-cli-wu-1112');
|
|
58
|
+
expect(result.valid).toBe(true);
|
|
59
|
+
expect(result.error).toBeUndefined();
|
|
60
|
+
});
|
|
61
|
+
it('should return invalid when cwd is main checkout', () => {
|
|
62
|
+
const result = validateWorktreeContext('/home/user/project');
|
|
63
|
+
expect(result.valid).toBe(false);
|
|
64
|
+
expect(result.error).toContain('main checkout');
|
|
65
|
+
});
|
|
66
|
+
it('should provide fix command when invalid', () => {
|
|
67
|
+
const result = validateWorktreeContext('/home/user/project');
|
|
68
|
+
expect(result.fixCommand).toBeDefined();
|
|
69
|
+
expect(result.fixCommand).toContain('wu:claim');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('buildPnpmAddCommand', () => {
|
|
73
|
+
it('should build basic add command', () => {
|
|
74
|
+
const args = { packages: ['react'] };
|
|
75
|
+
const cmd = buildPnpmAddCommand(args);
|
|
76
|
+
expect(cmd).toBe('pnpm add react');
|
|
77
|
+
});
|
|
78
|
+
it('should add --save-dev for dev dependencies', () => {
|
|
79
|
+
const args = { packages: ['vitest'], dev: true };
|
|
80
|
+
const cmd = buildPnpmAddCommand(args);
|
|
81
|
+
expect(cmd).toBe('pnpm add --save-dev vitest');
|
|
82
|
+
});
|
|
83
|
+
it('should add --filter for workspace packages', () => {
|
|
84
|
+
const args = { packages: ['chalk'], filter: '@lumenflow/cli' };
|
|
85
|
+
const cmd = buildPnpmAddCommand(args);
|
|
86
|
+
expect(cmd).toBe('pnpm add --filter @lumenflow/cli chalk');
|
|
87
|
+
});
|
|
88
|
+
it('should add --save-exact for exact versions', () => {
|
|
89
|
+
const args = { packages: ['react@18.2.0'], exact: true };
|
|
90
|
+
const cmd = buildPnpmAddCommand(args);
|
|
91
|
+
expect(cmd).toBe('pnpm add --save-exact react@18.2.0');
|
|
92
|
+
});
|
|
93
|
+
it('should combine multiple flags', () => {
|
|
94
|
+
const args = {
|
|
95
|
+
packages: ['vitest'],
|
|
96
|
+
dev: true,
|
|
97
|
+
filter: '@lumenflow/cli',
|
|
98
|
+
exact: true,
|
|
99
|
+
};
|
|
100
|
+
const cmd = buildPnpmAddCommand(args);
|
|
101
|
+
expect(cmd).toContain('--save-dev');
|
|
102
|
+
expect(cmd).toContain('--filter @lumenflow/cli');
|
|
103
|
+
expect(cmd).toContain('--save-exact');
|
|
104
|
+
expect(cmd).toContain('vitest');
|
|
105
|
+
});
|
|
106
|
+
it('should handle multiple packages', () => {
|
|
107
|
+
const args = { packages: ['react', 'react-dom'] };
|
|
108
|
+
const cmd = buildPnpmAddCommand(args);
|
|
109
|
+
expect(cmd).toBe('pnpm add react react-dom');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('deps-remove', () => {
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
vi.clearAllMocks();
|
|
116
|
+
});
|
|
117
|
+
describe('parseDepsRemoveArgs', () => {
|
|
118
|
+
it('should parse package name from positional argument', () => {
|
|
119
|
+
const args = parseDepsRemoveArgs(['node', 'deps-remove.js', 'lodash']);
|
|
120
|
+
expect(args.packages).toEqual(['lodash']);
|
|
121
|
+
});
|
|
122
|
+
it('should parse multiple packages', () => {
|
|
123
|
+
const args = parseDepsRemoveArgs(['node', 'deps-remove.js', 'lodash', 'moment']);
|
|
124
|
+
expect(args.packages).toEqual(['lodash', 'moment']);
|
|
125
|
+
});
|
|
126
|
+
it('should parse --filter flag', () => {
|
|
127
|
+
const args = parseDepsRemoveArgs([
|
|
128
|
+
'node',
|
|
129
|
+
'deps-remove.js',
|
|
130
|
+
'--filter',
|
|
131
|
+
'@lumenflow/core',
|
|
132
|
+
'lodash',
|
|
133
|
+
]);
|
|
134
|
+
expect(args.filter).toBe('@lumenflow/core');
|
|
135
|
+
expect(args.packages).toEqual(['lodash']);
|
|
136
|
+
});
|
|
137
|
+
it('should set help flag', () => {
|
|
138
|
+
const args = parseDepsRemoveArgs(['node', 'deps-remove.js', '--help']);
|
|
139
|
+
expect(args.help).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('buildPnpmRemoveCommand', () => {
|
|
143
|
+
it('should build basic remove command', () => {
|
|
144
|
+
const args = { packages: ['lodash'] };
|
|
145
|
+
const cmd = buildPnpmRemoveCommand(args);
|
|
146
|
+
expect(cmd).toBe('pnpm remove lodash');
|
|
147
|
+
});
|
|
148
|
+
it('should add --filter for workspace packages', () => {
|
|
149
|
+
const args = { packages: ['lodash'], filter: '@lumenflow/core' };
|
|
150
|
+
const cmd = buildPnpmRemoveCommand(args);
|
|
151
|
+
expect(cmd).toBe('pnpm remove --filter @lumenflow/core lodash');
|
|
152
|
+
});
|
|
153
|
+
it('should handle multiple packages', () => {
|
|
154
|
+
const args = { packages: ['lodash', 'moment'] };
|
|
155
|
+
const cmd = buildPnpmRemoveCommand(args);
|
|
156
|
+
expect(cmd).toBe('pnpm remove lodash moment');
|
|
157
|
+
});
|
|
158
|
+
it('should handle empty packages array', () => {
|
|
159
|
+
const args = { packages: [] };
|
|
160
|
+
const cmd = buildPnpmRemoveCommand(args);
|
|
161
|
+
expect(cmd).toBe('pnpm remove');
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
describe('parseDepsAddArgs edge cases', () => {
|
|
165
|
+
it('should handle -h flag', () => {
|
|
166
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', '-h']);
|
|
167
|
+
expect(args.help).toBe(true);
|
|
168
|
+
});
|
|
169
|
+
it('should handle -E flag for exact', () => {
|
|
170
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', '-E', 'react']);
|
|
171
|
+
expect(args.exact).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
it('should handle -F flag for filter', () => {
|
|
174
|
+
const args = parseDepsAddArgs(['node', 'deps-add.js', '-F', '@lumenflow/cli', 'chalk']);
|
|
175
|
+
expect(args.filter).toBe('@lumenflow/cli');
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
describe('parseDepsRemoveArgs edge cases', () => {
|
|
179
|
+
it('should handle -h flag', () => {
|
|
180
|
+
const args = parseDepsRemoveArgs(['node', 'deps-remove.js', '-h']);
|
|
181
|
+
expect(args.help).toBe(true);
|
|
182
|
+
});
|
|
183
|
+
it('should handle -F flag for filter', () => {
|
|
184
|
+
const args = parseDepsRemoveArgs([
|
|
185
|
+
'node',
|
|
186
|
+
'deps-remove.js',
|
|
187
|
+
'-F',
|
|
188
|
+
'@lumenflow/cli',
|
|
189
|
+
'lodash',
|
|
190
|
+
]);
|
|
191
|
+
expect(args.filter).toBe('@lumenflow/cli');
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
describe('buildPnpmAddCommand edge cases', () => {
|
|
195
|
+
it('should handle empty packages array', () => {
|
|
196
|
+
const args = { packages: [] };
|
|
197
|
+
const cmd = buildPnpmAddCommand(args);
|
|
198
|
+
expect(cmd).toBe('pnpm add');
|
|
199
|
+
});
|
|
200
|
+
it('should handle undefined packages', () => {
|
|
201
|
+
const args = {};
|
|
202
|
+
const cmd = buildPnpmAddCommand(args);
|
|
203
|
+
expect(cmd).toBe('pnpm add');
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|