@eldrforge/kodrdriv 1.2.134 → 1.2.137

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.
Files changed (73) hide show
  1. package/.cursor/rules/no-local-dependencies.md +6 -0
  2. package/README.md +1 -0
  3. package/dist/application.js +32 -42
  4. package/dist/application.js.map +1 -1
  5. package/dist/arguments.js +3 -3
  6. package/dist/arguments.js.map +1 -1
  7. package/dist/constants.js +5 -7
  8. package/dist/constants.js.map +1 -1
  9. package/dist/logging.js +4 -32
  10. package/dist/logging.js.map +1 -1
  11. package/dist/types.js +1 -0
  12. package/dist/types.js.map +1 -1
  13. package/package.json +13 -8
  14. package/dist/commands/audio-commit.js +0 -152
  15. package/dist/commands/audio-commit.js.map +0 -1
  16. package/dist/commands/audio-review.js +0 -274
  17. package/dist/commands/audio-review.js.map +0 -1
  18. package/dist/commands/clean.js +0 -49
  19. package/dist/commands/clean.js.map +0 -1
  20. package/dist/commands/commit.js +0 -680
  21. package/dist/commands/commit.js.map +0 -1
  22. package/dist/commands/development.js +0 -467
  23. package/dist/commands/development.js.map +0 -1
  24. package/dist/commands/link.js +0 -646
  25. package/dist/commands/link.js.map +0 -1
  26. package/dist/commands/precommit.js +0 -99
  27. package/dist/commands/precommit.js.map +0 -1
  28. package/dist/commands/publish.js +0 -1432
  29. package/dist/commands/publish.js.map +0 -1
  30. package/dist/commands/release.js +0 -376
  31. package/dist/commands/release.js.map +0 -1
  32. package/dist/commands/review.js +0 -733
  33. package/dist/commands/review.js.map +0 -1
  34. package/dist/commands/select-audio.js +0 -46
  35. package/dist/commands/select-audio.js.map +0 -1
  36. package/dist/commands/tree.js +0 -2363
  37. package/dist/commands/tree.js.map +0 -1
  38. package/dist/commands/unlink.js +0 -537
  39. package/dist/commands/unlink.js.map +0 -1
  40. package/dist/commands/updates.js +0 -211
  41. package/dist/commands/updates.js.map +0 -1
  42. package/dist/commands/versions.js +0 -221
  43. package/dist/commands/versions.js.map +0 -1
  44. package/dist/content/diff.js +0 -346
  45. package/dist/content/diff.js.map +0 -1
  46. package/dist/content/files.js +0 -190
  47. package/dist/content/files.js.map +0 -1
  48. package/dist/content/log.js +0 -72
  49. package/dist/content/log.js.map +0 -1
  50. package/dist/util/aiAdapter.js +0 -28
  51. package/dist/util/aiAdapter.js.map +0 -1
  52. package/dist/util/fileLock.js +0 -241
  53. package/dist/util/fileLock.js.map +0 -1
  54. package/dist/util/general.js +0 -379
  55. package/dist/util/general.js.map +0 -1
  56. package/dist/util/gitMutex.js +0 -161
  57. package/dist/util/gitMutex.js.map +0 -1
  58. package/dist/util/interactive.js +0 -32
  59. package/dist/util/interactive.js.map +0 -1
  60. package/dist/util/loggerAdapter.js +0 -41
  61. package/dist/util/loggerAdapter.js.map +0 -1
  62. package/dist/util/performance.js +0 -134
  63. package/dist/util/performance.js.map +0 -1
  64. package/dist/util/precommitOptimizations.js +0 -310
  65. package/dist/util/precommitOptimizations.js.map +0 -1
  66. package/dist/util/stopContext.js +0 -146
  67. package/dist/util/stopContext.js.map +0 -1
  68. package/dist/util/storageAdapter.js +0 -31
  69. package/dist/util/storageAdapter.js.map +0 -1
  70. package/dist/util/validation.js +0 -45
  71. package/dist/util/validation.js.map +0 -1
  72. package/dist/utils/branchState.js +0 -700
  73. package/dist/utils/branchState.js.map +0 -1
@@ -1,467 +0,0 @@
1
- #!/usr/bin/env node
2
- import { getDryRunLogger } from '../logging.js';
3
- import { getCurrentBranch, run, localBranchExists } from '@eldrforge/git-tools';
4
- import { findDevelopmentBranch } from '../util/general.js';
5
- import { KODRDRIV_DEFAULTS } from '../constants.js';
6
-
7
- /**
8
- * Create retroactive working branch tags for past releases
9
- * Scans git history for X.X.X-dev.0 commits and tags them
10
- */ async function createRetroactiveTags(workingBranch, isDryRun, logger, tagPrefix = 'working/') {
11
- logger.info('');
12
- logger.info('DEV_TAG_SCAN_STARTING: Scanning git history for past release points | Purpose: Create retroactive tags | Pattern: X.X.X-dev.0 version bumps');
13
- logger.info('DEV_TAG_SCAN_PATTERN: Looking for development version bump commits | Version Format: X.X.X-dev.0 | Purpose: Identify release points');
14
- logger.info('');
15
- try {
16
- // Get all commits on working branch with oneline format
17
- const { stdout } = await run(`git log ${workingBranch} --oneline --all`);
18
- const commits = stdout.trim().split('\n');
19
- // Find commits that are version bumps to -dev.0 (these mark release points)
20
- const devCommits = commits.filter((line)=>{
21
- // Match patterns like: "4.4.52-dev.0" or "chore: bump version to 4.4.52-dev.0"
22
- return /\b\d+\.\d+\.\d+-dev\.0\b/.test(line);
23
- });
24
- logger.info(`DEV_TAG_COMMITS_FOUND: Found potential development version commits | Count: ${devCommits.length} | Status: Analyzing for tag creation`);
25
- const tagsCreated = [];
26
- const tagsSkipped = [];
27
- for (const commitLine of devCommits){
28
- const [sha, ...messageParts] = commitLine.split(' ');
29
- const message = messageParts.join(' ');
30
- // Extract version from message (e.g., "4.4.52-dev.0" → "4.4.52")
31
- const versionMatch = message.match(/(\d+\.\d+\.\d+)-dev\.0/);
32
- if (!versionMatch) continue;
33
- const releaseVersion = versionMatch[1]; // e.g., "4.4.52"
34
- const workingTagName = `${tagPrefix}v${releaseVersion}`;
35
- // Check if tag already exists
36
- const tagExistsResult = await run(`git tag -l "${workingTagName}"`);
37
- const tagExists = tagExistsResult.stdout.trim() !== '';
38
- if (tagExists) {
39
- tagsSkipped.push(workingTagName);
40
- logger.verbose(` Skip: ${workingTagName} (already exists)`);
41
- continue;
42
- }
43
- if (!isDryRun) {
44
- // Tag the commit that represents the dev version bump
45
- // This is the commit AFTER the release, which marks the starting point
46
- logger.verbose(` Create: ${workingTagName} at ${sha.substring(0, 7)}`);
47
- await run(`git tag ${workingTagName} ${sha}`);
48
- tagsCreated.push(workingTagName);
49
- } else {
50
- logger.info(`DEV_TAG_DRY_RUN: Would create retroactive tag | Mode: dry-run | Tag: ${workingTagName} | Commit: ${sha.substring(0, 7)}`);
51
- tagsCreated.push(workingTagName);
52
- }
53
- }
54
- logger.info('');
55
- if (tagsCreated.length > 0 && !isDryRun) {
56
- logger.info(`DEV_TAG_PUSHING: Pushing retroactive tags to remote | Count: ${tagsCreated.length} | Remote: origin | Command: git push origin --tags`);
57
- await run('git push origin --tags');
58
- logger.info('');
59
- logger.info(`DEV_TAG_PUSH_SUCCESS: Successfully created and pushed retroactive tags | Count: ${tagsCreated.length} | Remote: origin | Status: completed`);
60
- tagsCreated.forEach((tag)=>logger.info(`DEV_TAG_CREATED: Retroactive tag created | Tag: ${tag} | Status: pushed`));
61
- } else if (tagsCreated.length > 0 && isDryRun) {
62
- logger.info(`DEV_TAG_DRY_RUN_SUMMARY: Would create and push retroactive tags | Mode: dry-run | Count: ${tagsCreated.length}`);
63
- tagsCreated.forEach((tag)=>logger.info(`DEV_TAG_DRY_RUN_TAG: Would create tag | Tag: ${tag} | Mode: dry-run`));
64
- }
65
- if (tagsSkipped.length > 0) {
66
- logger.verbose('');
67
- logger.verbose(`Skipped ${tagsSkipped.length} existing tags:`);
68
- tagsSkipped.forEach((tag)=>logger.verbose(` - ${tag}`));
69
- }
70
- if (tagsCreated.length === 0 && tagsSkipped.length === 0) {
71
- logger.info('DEV_TAG_NO_COMMITS: No development version commits found in history | Pattern: X.X.X-dev.0 | Status: Nothing to tag | Action: No retroactive tags created');
72
- }
73
- logger.info('');
74
- } catch (error) {
75
- logger.warn(`DEV_TAG_CREATION_FAILED: Unable to create retroactive tags | Error: ${error.message} | Impact: Past releases not tagged | Alternative: Manual tagging available`);
76
- logger.warn('DEV_TAG_MANUAL_OPTION: Manual tagging option available | Action: Use git tag manually for past releases | Purpose: Tag historical releases');
77
- // Don't throw - retroactive tagging is optional
78
- }
79
- }
80
- /**
81
- * Execute the development command
82
- */ const execute = async (runConfig)=>{
83
- const isDryRun = runConfig.dryRun || false;
84
- const logger = getDryRunLogger(isDryRun);
85
- logger.info('DEV_BRANCH_NAVIGATION: Navigating to working branch for development | Purpose: Start development cycle | Next: Version bump and sync');
86
- try {
87
- var _runConfig_development, _runConfig_development1, _runConfig_development2;
88
- // Get current branch
89
- const currentBranch = isDryRun ? 'mock-branch' : await getCurrentBranch();
90
- logger.info(`DEV_CURRENT_BRANCH: Current branch identified | Branch: ${currentBranch} | Action: Determine working branch`);
91
- // Find the working/development branch from configuration
92
- let workingBranch = 'working'; // Default fallback
93
- if (runConfig.branches) {
94
- const configuredDevBranch = findDevelopmentBranch(runConfig.branches);
95
- if (configuredDevBranch) {
96
- workingBranch = configuredDevBranch;
97
- logger.info(`DEV_WORKING_BRANCH_CONFIGURED: Using configured working branch | Branch: ${workingBranch} | Source: config | Current: ${currentBranch}`);
98
- } else {
99
- logger.info(`DEV_WORKING_BRANCH_DEFAULT: No working branch configured | Branch: ${workingBranch} | Source: default | Current: ${currentBranch}`);
100
- }
101
- } else {
102
- logger.info(`DEV_WORKING_BRANCH_NO_CONFIG: No branch configuration found | Branch: ${workingBranch} | Source: default | Current: ${currentBranch}`);
103
- }
104
- // Track what actions are taken to determine the appropriate return message
105
- let branchCreated = false;
106
- let branchUpdated = false;
107
- let alreadyOnBranch = false;
108
- let mergedDevelopmentIntoWorking = false;
109
- // Determine prerelease tag and increment level from configuration
110
- const allBranchConfig = runConfig.branches || KODRDRIV_DEFAULTS.branches;
111
- let prereleaseTag = 'dev'; // Default
112
- let incrementLevel = 'patch'; // Default
113
- // Check for development command specific targetVersion override
114
- if ((_runConfig_development = runConfig.development) === null || _runConfig_development === void 0 ? void 0 : _runConfig_development.targetVersion) {
115
- const targetVersion = runConfig.development.targetVersion;
116
- // Validate targetVersion
117
- if (![
118
- 'patch',
119
- 'minor',
120
- 'major'
121
- ].includes(targetVersion) && !/^\d+\.\d+\.\d+$/.test(targetVersion.replace(/^v/, ''))) {
122
- throw new Error(`Invalid target version: ${targetVersion}. Expected "patch", "minor", "major", or a valid version string like "2.1.0"`);
123
- }
124
- incrementLevel = targetVersion;
125
- } else if (allBranchConfig && allBranchConfig[workingBranch]) {
126
- const workingBranchConfig = allBranchConfig[workingBranch];
127
- if (workingBranchConfig.version) {
128
- if (workingBranchConfig.version.tag) {
129
- prereleaseTag = workingBranchConfig.version.tag;
130
- }
131
- if (workingBranchConfig.version.incrementLevel) {
132
- incrementLevel = workingBranchConfig.version.incrementLevel;
133
- }
134
- }
135
- }
136
- logger.info(`DEV_VERSION_CONFIG: Development version configuration | Prerelease Tag: ${prereleaseTag} | Increment Level: ${incrementLevel}`);
137
- logger.info(`DEV_VERSION_STRATEGY: Version increment strategy | Level: ${incrementLevel} | Tag: ${prereleaseTag} | Purpose: Development version management`);
138
- // Step 1: Fetch latest remote information
139
- if (!isDryRun) {
140
- logger.info('DEV_GIT_FETCH: Fetching latest remote information | Remote: origin | Purpose: Ensure sync before branch operations');
141
- try {
142
- await run('git fetch origin');
143
- logger.info('DEV_GIT_FETCH_SUCCESS: Successfully fetched remote information | Remote: origin | Status: up-to-date');
144
- } catch (error) {
145
- logger.warn(`DEV_GIT_FETCH_FAILED: Unable to fetch remote | Remote: origin | Error: ${error.message} | Impact: May have stale branch info`);
146
- }
147
- } else {
148
- logger.info('DEV_GIT_FETCH_DRY_RUN: Would fetch latest remote information | Mode: dry-run | Remote: origin');
149
- }
150
- // Special case: If currently on development branch, merge development into working
151
- if (currentBranch === 'development') {
152
- if (!isDryRun) {
153
- logger.info('DEV_MERGE_STARTING: Currently on development branch, merging into working | Source: development | Target: working | Purpose: Sync branches before development');
154
- await run(`git checkout ${workingBranch}`);
155
- await run(`git merge development --no-ff -m "Merge development into working for continued development"`);
156
- await run('npm install');
157
- // Check if npm install created any changes and commit them
158
- const gitStatus = await run('git status --porcelain');
159
- if (gitStatus.stdout.trim()) {
160
- await run('git add -A');
161
- await run('git commit -m "chore: update package-lock.json after merge"');
162
- }
163
- // Stay on working branch for development (removed checkout development)
164
- mergedDevelopmentIntoWorking = true;
165
- } else {
166
- logger.info('DEV_MERGE_DRY_RUN: Would merge development into working | Mode: dry-run | Source: development | Target: working');
167
- mergedDevelopmentIntoWorking = true;
168
- }
169
- }
170
- // Step 2: Switch to working branch (create if needed) - skip if we handled development branch case
171
- if (!isDryRun && !mergedDevelopmentIntoWorking) {
172
- const workingBranchExists = await localBranchExists(workingBranch);
173
- if (!workingBranchExists) {
174
- logger.info(`DEV_BRANCH_CREATING: Working branch does not exist, creating now | Branch: ${workingBranch} | Action: Create and checkout | Source: current HEAD`);
175
- await run(`git checkout -b ${workingBranch}`);
176
- logger.info(`DEV_BRANCH_CREATED: Successfully created and switched to branch | Branch: ${workingBranch} | Status: checked-out`);
177
- branchCreated = true;
178
- } else if (currentBranch !== workingBranch) {
179
- logger.info(`DEV_BRANCH_SWITCHING: Switching to working branch | Branch: ${workingBranch} | Action: checkout | Previous: ${currentBranch}`);
180
- await run(`git checkout ${workingBranch}`);
181
- logger.info(`DEV_BRANCH_SWITCHED: Successfully switched to branch | Branch: ${workingBranch} | Status: checked-out`);
182
- branchUpdated = true;
183
- } else {
184
- logger.info(`DEV_BRANCH_CURRENT: Already on working branch | Branch: ${workingBranch} | Status: no-switch-needed`);
185
- alreadyOnBranch = true;
186
- }
187
- } else if (!mergedDevelopmentIntoWorking) {
188
- // For dry run, we need to mock the logic
189
- const workingBranchExists = await localBranchExists(workingBranch);
190
- if (!workingBranchExists) {
191
- branchCreated = true;
192
- } else if (currentBranch !== workingBranch) {
193
- branchUpdated = true;
194
- } else {
195
- alreadyOnBranch = true;
196
- }
197
- logger.info(`DEV_BRANCH_DRY_RUN: Would switch to working branch | Mode: dry-run | Branch: ${workingBranch} | Action: Create if needed`);
198
- logger.info(`DEV_SYNC_DRY_RUN: Would sync branch with remote | Mode: dry-run | Branch: ${workingBranch} | Purpose: Avoid conflicts`);
199
- }
200
- // Step 2.1: Sync with remote working branch to avoid conflicts
201
- if (!isDryRun) {
202
- try {
203
- logger.info(`DEV_BRANCH_SYNCING: Synchronizing working branch with remote | Branch: ${workingBranch} | Remote: origin/${workingBranch} | Purpose: Avoid conflicts`);
204
- const remoteExists = await run(`git ls-remote --exit-code --heads origin ${workingBranch}`).then(()=>true).catch(()=>false);
205
- if (remoteExists) {
206
- // Use explicit fetch+merge instead of pull to avoid git config conflicts
207
- await run(`git fetch origin ${workingBranch}`);
208
- await run(`git merge origin/${workingBranch} --no-edit`);
209
- logger.info(`DEV_BRANCH_SYNCED: Successfully synchronized with remote | Branch: ${workingBranch} | Remote: origin/${workingBranch} | Status: in-sync`);
210
- } else {
211
- logger.info(`DEV_REMOTE_BRANCH_NOT_FOUND: No remote branch exists | Branch: ${workingBranch} | Remote: origin | Action: Will be created on first push`);
212
- }
213
- } catch (error) {
214
- if (error.message && error.message.includes('CONFLICT')) {
215
- logger.error(`DEV_MERGE_CONFLICTS: Merge conflicts detected when syncing with remote | Branch: ${workingBranch} | Remote: origin | Status: conflicts-detected`);
216
- logger.error(`DEV_CONFLICT_RESOLUTION: Manual conflict resolution required:`);
217
- logger.error(` Step 1: Resolve conflicts in the files`);
218
- logger.error(` Step 2: Stage resolved files | Command: git add <resolved-files>`);
219
- logger.error(` Step 3: Complete merge | Command: git commit`);
220
- logger.error(` Step 4: Resume development | Command: kodrdriv development`);
221
- throw new Error(`Merge conflicts detected when syncing ${workingBranch} with remote. Please resolve conflicts manually.`);
222
- } else {
223
- logger.warn(`DEV_SYNC_FAILED: Could not sync with remote | Branch: ${workingBranch} | Remote: origin | Error: ${error.message}`);
224
- }
225
- }
226
- }
227
- // Step 2.5: Sync with target branch (main) if it exists
228
- // This is a safety net for when publish fails or user ends up on target branch
229
- if (!isDryRun) {
230
- var _allBranchConfig_workingBranch;
231
- // Determine target branch from config
232
- const targetBranch = allBranchConfig && ((_allBranchConfig_workingBranch = allBranchConfig[workingBranch]) === null || _allBranchConfig_workingBranch === void 0 ? void 0 : _allBranchConfig_workingBranch.targetBranch) || 'main';
233
- const targetBranchExists = await localBranchExists(targetBranch);
234
- if (targetBranchExists) {
235
- logger.info(`DEV_TARGET_SYNC: Syncing working branch with target branch | Working: ${workingBranch} | Target: ${targetBranch} | Strategy: fast-forward`);
236
- try {
237
- await run(`git merge ${targetBranch} --ff-only`);
238
- logger.info(`DEV_TARGET_MERGED_FF: Fast-forward merged target into working | Target: ${targetBranch} | Working: ${workingBranch} | Status: merged`);
239
- } catch (error) {
240
- // Fast-forward failed, might need regular merge
241
- if (error.message && error.message.includes('Not possible to fast-forward')) {
242
- logger.warn(`DEV_NO_FAST_FORWARD: Cannot fast-forward merge | Target: ${targetBranch} | Working: ${workingBranch} | Reason: Divergent history`);
243
- logger.info(`DEV_REGULAR_MERGE_ATTEMPTING: Attempting regular merge | Strategy: fast-forward preferred | Purpose: Sync branches`);
244
- try {
245
- await run(`git merge ${targetBranch} -m "Merge ${targetBranch} into ${workingBranch} for sync"`);
246
- logger.info(`DEV_TARGET_MERGED: Merged target into working | Target: ${targetBranch} | Working: ${workingBranch} | Status: merged`);
247
- // Run npm install after merge
248
- logger.info('DEV_POST_MERGE_INSTALL: Running npm install after merge | Command: npm install | Purpose: Update dependencies');
249
- await run('npm install');
250
- // Check if npm install created changes
251
- const gitStatus = await run('git status --porcelain');
252
- if (gitStatus.stdout.trim()) {
253
- logger.info('DEV_POST_MERGE_COMMIT: Committing changes from npm install | Files: package-lock.json | Purpose: Finalize merge');
254
- await run('git add -A');
255
- await run('git commit -m "chore: update package-lock.json after merge"');
256
- }
257
- } catch (mergeError) {
258
- if (mergeError.message && mergeError.message.includes('CONFLICT')) {
259
- logger.error(`DEV_MERGE_CONFLICTS: Merge conflicts detected | Target: ${targetBranch} | Working: ${workingBranch} | Status: conflicts-detected`);
260
- logger.error(`DEV_CONFLICT_RESOLUTION: Manual conflict resolution required:`);
261
- logger.error(` Step 1: Resolve conflicts in the files`);
262
- logger.error(` Step 2: Stage resolved files | Command: git add <resolved-files>`);
263
- logger.error(` Step 3: Complete merge | Command: git commit`);
264
- logger.error(` Step 4: Update dependencies | Command: npm install`);
265
- logger.error(` Step 5: Resume development | Command: kodrdriv development`);
266
- throw new Error(`Merge conflicts detected when merging ${targetBranch} into ${workingBranch}. Please resolve conflicts manually.`);
267
- } else {
268
- throw mergeError;
269
- }
270
- }
271
- } else {
272
- logger.warn(`DEV_TARGET_MERGE_FAILED: Could not merge target into working | Target: ${targetBranch} | Working: ${workingBranch} | Error: ${error.message}`);
273
- }
274
- }
275
- } else {
276
- logger.info(`DEV_TARGET_NOT_EXISTS: Target branch does not exist | Branch: ${targetBranch} | Action: Skipping target sync | Status: no-target-branch`);
277
- }
278
- } else {
279
- logger.info('Would sync working branch with target branch (main) if it exists');
280
- }
281
- // Step 3: Merge latest changes from development branch if it exists
282
- if (!isDryRun) {
283
- const developmentBranchExists = await localBranchExists('development');
284
- if (mergedDevelopmentIntoWorking) {
285
- logger.info('DEV_ALREADY_MERGED: Already merged from development | Reason: Was on development branch | Action: Skipping');
286
- } else if (developmentBranchExists) {
287
- logger.info('DEV_DEVELOPMENT_MERGE: Merging latest changes from development branch | Source: development | Target: ' + workingBranch + ' | Purpose: Sync development changes');
288
- try {
289
- await run(`git merge development --no-ff -m "Merge latest development changes into ${workingBranch}"`);
290
- logger.info('DEV_DEVELOPMENT_MERGED: Successfully merged development changes | Source: development | Target: ' + workingBranch + ' | Status: merged');
291
- // Run npm install after merge to update dependencies
292
- logger.info('DEV_DEVELOPMENT_INSTALL: Running npm install after merge | Command: npm install | Purpose: Update dependencies');
293
- await run('npm install');
294
- // Check if npm install created any changes (e.g., package-lock.json)
295
- const gitStatus = await run('git status --porcelain');
296
- if (gitStatus.stdout.trim()) {
297
- logger.info('DEV_POST_MERGE_COMMIT: Committing changes from npm install | Files: package-lock.json | Purpose: Finalize merge');
298
- await run('git add -A');
299
- await run(`git commit -m "chore: update package-lock.json after merge"`);
300
- logger.info('DEV_CHANGES_COMMITTED: Changes committed successfully | Files: package-lock.json | Status: committed');
301
- }
302
- } catch (error) {
303
- if (error.message && error.message.includes('CONFLICT')) {
304
- logger.error(`DEV_DEV_MERGE_CONFLICTS: Merge conflicts detected | Source: development | Target: ${workingBranch} | Status: conflicts-detected`);
305
- logger.error(`DEV_DEV_CONFLICT_RESOLUTION: Manual conflict resolution required:`);
306
- logger.error(` Step 1: Resolve conflicts in the files`);
307
- logger.error(` Step 2: Stage resolved files | Command: git add <resolved-files>`);
308
- logger.error(` Step 3: Complete merge | Command: git commit`);
309
- logger.error(` Step 4: Update dependencies | Command: npm install`);
310
- logger.error(` Step 5: Bump version | Command: npm version pre${incrementLevel} --preid=${prereleaseTag}`);
311
- throw new Error(`Merge conflicts detected when merging development into ${workingBranch}. Please resolve conflicts manually.`);
312
- } else {
313
- logger.error(`DEV_DEV_MERGE_FAILED: Failed to merge development branch | Source: development | Target: ${workingBranch} | Error: ${error.message}`);
314
- throw error;
315
- }
316
- }
317
- } else {
318
- logger.info('DEV_NO_DEV_BRANCH: Development branch does not exist | Branch: development | Action: Skipping merge step | Status: not-found');
319
- }
320
- } else {
321
- logger.info('DEV_DEV_MERGE_DRY_RUN: Would merge development if exists | Mode: dry-run | Source: development | Target: working');
322
- logger.info('DEV_INSTALL_DRY_RUN: Would run npm install after merge | Mode: dry-run | Command: npm install');
323
- logger.info('DEV_COMMIT_DRY_RUN: Would commit npm install changes | Mode: dry-run | Files: package-lock.json');
324
- }
325
- // Step 4.5: Create retroactive tags if requested (one-time operation)
326
- if ((_runConfig_development1 = runConfig.development) === null || _runConfig_development1 === void 0 ? void 0 : _runConfig_development1.createRetroactiveTags) {
327
- var _runConfig_development3;
328
- const tagPrefix = ((_runConfig_development3 = runConfig.development) === null || _runConfig_development3 === void 0 ? void 0 : _runConfig_development3.workingTagPrefix) || 'working/';
329
- await createRetroactiveTags(workingBranch, isDryRun, logger, tagPrefix);
330
- }
331
- // Step 5: Check if we already have a proper development version
332
- if (alreadyOnBranch && !mergedDevelopmentIntoWorking) {
333
- // Check if current version is already a development version with the right tag
334
- const fs = await import('fs/promises');
335
- try {
336
- const packageJson = JSON.parse(await fs.readFile('package.json', 'utf-8'));
337
- const currentVersion = packageJson.version;
338
- // If current version already has the dev tag, we're done
339
- if (currentVersion.includes(`-${prereleaseTag}.`)) {
340
- logger.info(`DEV_ALREADY_DEV_VERSION: Already on working branch with development version | Branch: ${workingBranch} | Version: ${currentVersion} | Status: no-bump-needed`);
341
- return 'Already on working branch with development version';
342
- }
343
- } catch {
344
- logger.debug('Could not check current version, proceeding with version bump');
345
- }
346
- }
347
- // Step 5.5: Tag working branch with current release version BEFORE bumping
348
- if (((_runConfig_development2 = runConfig.development) === null || _runConfig_development2 === void 0 ? void 0 : _runConfig_development2.tagWorkingBranch) !== false) {
349
- try {
350
- const fs = await import('fs/promises');
351
- const packageJson = JSON.parse(await fs.readFile('package.json', 'utf-8'));
352
- const currentVersion = packageJson.version;
353
- // Only tag if current version is a release version (not already a dev version)
354
- const isReleaseVersion = currentVersion && !currentVersion.includes('-dev.') && !currentVersion.includes('-alpha.') && !currentVersion.includes('-beta.') && !currentVersion.includes('-rc.');
355
- if (isReleaseVersion) {
356
- var _runConfig_development4;
357
- const tagPrefix = ((_runConfig_development4 = runConfig.development) === null || _runConfig_development4 === void 0 ? void 0 : _runConfig_development4.workingTagPrefix) || 'working/';
358
- const workingTagName = `${tagPrefix}v${currentVersion}`;
359
- if (!isDryRun) {
360
- logger.info(`DEV_TAG_RELEASE_VERSION: Current version is release version | Version: ${currentVersion} | Type: release | Action: Will tag before bump`);
361
- logger.verbose(`Checking if tag ${workingTagName} exists...`);
362
- // Check if tag already exists
363
- const tagExistsResult = await run(`git tag -l "${workingTagName}"`);
364
- const tagExists = tagExistsResult.stdout.trim() !== '';
365
- if (tagExists) {
366
- logger.info(`DEV_TAG_EXISTS: Tag already exists | Tag: ${workingTagName} | Action: Skipping tag creation | Status: already-tagged`);
367
- } else {
368
- // Create tag on current commit (working branch at release version)
369
- logger.verbose(`Creating tag ${workingTagName} at current HEAD...`);
370
- await run(`git tag ${workingTagName}`);
371
- // Push tag to remote
372
- logger.verbose(`Pushing tag ${workingTagName} to origin...`);
373
- await run(`git push origin ${workingTagName}`);
374
- logger.info(`DEV_TAG_CREATED: Tagged working branch | Tag: ${workingTagName} | Version: ${currentVersion} | Status: tagged-and-pushed`);
375
- logger.info(`DEV_TAG_RELEASE_NOTES_HINT: Release notes can be generated | Version: v${currentVersion} | Command: kodrdriv release --from {previous-tag} --to ${workingTagName}`);
376
- }
377
- } else {
378
- logger.info(`DEV_TAG_DRY_RUN: Would tag working branch | Mode: dry-run | Tag: ${workingTagName} | Version: ${currentVersion}`);
379
- }
380
- } else if (currentVersion) {
381
- logger.verbose(`Current version is ${currentVersion} (prerelease), skipping tag creation`);
382
- } else {
383
- logger.debug('Could not determine current version, skipping tag creation');
384
- }
385
- } catch (error) {
386
- if (!isDryRun) {
387
- logger.warn(`DEV_TAG_FAILED: Could not tag working branch | Error: ${error.message} | Impact: Not critical | Alternative: Manual tagging`);
388
- logger.warn('DEV_TAG_MANUAL: Manual tagging option available | Action: Tag manually later | Purpose: Mark release point');
389
- } else {
390
- logger.info('Would tag working branch with current release version if applicable');
391
- }
392
- // Don't throw - tagging is optional, continue with version bump
393
- }
394
- } else if (isDryRun) {
395
- logger.info('Tagging disabled (--no-tag-working-branch)');
396
- }
397
- // Step 6: Run npm version to bump version with increment level
398
- let versionCommand;
399
- if ([
400
- 'patch',
401
- 'minor',
402
- 'major'
403
- ].includes(incrementLevel)) {
404
- versionCommand = `pre${incrementLevel}`;
405
- logger.info(`DEV_VERSION_BUMPING: Bumping version with prerelease tag | Level: ${incrementLevel} | Tag: ${prereleaseTag} | Command: npm version`);
406
- } else {
407
- // Explicit version like "3.5.0"
408
- const cleanVersion = incrementLevel.replace(/^v/, '');
409
- versionCommand = `${cleanVersion}-${prereleaseTag}.0`;
410
- logger.info(`DEV_VERSION_EXPLICIT: Setting explicit version | Version: ${versionCommand} | Type: explicit`);
411
- }
412
- if (!isDryRun) {
413
- try {
414
- const versionResult = [
415
- 'patch',
416
- 'minor',
417
- 'major'
418
- ].includes(incrementLevel) ? await run(`npm version ${versionCommand} --preid=${prereleaseTag}`) : await run(`npm version ${versionCommand}`);
419
- const newVersion = versionResult.stdout.trim();
420
- logger.info(`DEV_VERSION_BUMPED: Version bumped successfully | New Version: ${newVersion} | Status: completed`);
421
- // Return appropriate message based on what actions were taken
422
- if (mergedDevelopmentIntoWorking) {
423
- return 'Merged development into working and ready for development';
424
- } else if (branchCreated) {
425
- return 'Created working branch with development version';
426
- } else if (branchUpdated) {
427
- return 'Updated working branch with development version';
428
- } else if (alreadyOnBranch) {
429
- return 'Already on working branch with development version';
430
- } else {
431
- return `Ready for development on ${workingBranch} with version ${newVersion}`;
432
- }
433
- } catch (error) {
434
- logger.error(`DEV_VERSION_BUMP_FAILED: Failed to bump version | Error: ${error.message} | Impact: Version not updated`);
435
- throw new Error(`Failed to bump ${incrementLevel} version: ${error.message}`);
436
- }
437
- } else {
438
- if ([
439
- 'patch',
440
- 'minor',
441
- 'major'
442
- ].includes(incrementLevel)) {
443
- logger.info(`Would run: npm version ${versionCommand} --preid=${prereleaseTag}`);
444
- } else {
445
- logger.info(`Would run: npm version ${versionCommand}`);
446
- }
447
- // Return appropriate message based on what actions were taken
448
- if (mergedDevelopmentIntoWorking) {
449
- return 'Merged development into working and ready for development';
450
- } else if (branchCreated) {
451
- return 'Created working branch with development version';
452
- } else if (branchUpdated) {
453
- return 'Updated working branch with development version';
454
- } else if (alreadyOnBranch) {
455
- return 'Already on working branch with development version';
456
- } else {
457
- return `Ready for development on ${workingBranch} (dry run)`;
458
- }
459
- }
460
- } catch (error) {
461
- logger.error('Failed to prepare working branch for development:', error.message);
462
- throw error;
463
- }
464
- };
465
-
466
- export { execute };
467
- //# sourceMappingURL=development.js.map