@eldrforge/kodrdriv 1.2.20 → 1.2.22
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/WORKFLOW-PRECHECK-IMPLEMENTATION.md +239 -0
- package/WORKFLOW-SKIP-SUMMARY.md +121 -0
- package/dist/application.js +6 -2
- package/dist/application.js.map +1 -1
- package/dist/arguments.js +2 -2
- package/dist/arguments.js.map +1 -1
- package/dist/commands/audio-commit.js +15 -6
- package/dist/commands/audio-commit.js.map +1 -1
- package/dist/commands/audio-review.js +31 -15
- package/dist/commands/audio-review.js.map +1 -1
- package/dist/commands/commit.js +31 -20
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/link.js +27 -27
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/publish.js +87 -34
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/release.js +32 -19
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/review.js +36 -30
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/select-audio.js +4 -4
- package/dist/commands/select-audio.js.map +1 -1
- package/dist/commands/tree.js +154 -38
- package/dist/commands/tree.js.map +1 -1
- package/dist/commands/unlink.js +13 -13
- package/dist/commands/unlink.js.map +1 -1
- package/dist/commands/updates.js +21 -0
- package/dist/commands/updates.js.map +1 -1
- package/dist/commands/versions.js +5 -5
- package/dist/commands/versions.js.map +1 -1
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/content/files.js +4 -4
- package/dist/content/files.js.map +1 -1
- package/dist/error/CommandErrors.js +1 -65
- package/dist/error/CommandErrors.js.map +1 -1
- package/dist/logging.js +3 -3
- package/dist/logging.js.map +1 -1
- package/dist/util/aiAdapter.js +28 -0
- package/dist/util/aiAdapter.js.map +1 -0
- package/dist/util/general.js +5 -5
- package/dist/util/general.js.map +1 -1
- package/dist/util/interactive.js +6 -437
- package/dist/util/interactive.js.map +1 -1
- package/dist/util/loggerAdapter.js +24 -0
- package/dist/util/loggerAdapter.js.map +1 -0
- package/dist/util/performance.js +4 -4
- package/dist/util/performance.js.map +1 -1
- package/dist/util/safety.js +4 -4
- package/dist/util/safety.js.map +1 -1
- package/dist/util/storage.js +2 -2
- package/dist/util/storage.js.map +1 -1
- package/dist/util/storageAdapter.js +25 -0
- package/dist/util/storageAdapter.js.map +1 -0
- package/package.json +6 -4
- package/test_output.txt +3 -3
- package/INTEGRATION-SUMMARY.md +0 -232
- package/TEST-STATUS.md +0 -168
- package/dist/content/issues.js +0 -331
- package/dist/content/issues.js.map +0 -1
- package/dist/content/releaseNotes.js +0 -90
- package/dist/content/releaseNotes.js.map +0 -1
- package/dist/prompt/commit.js +0 -76
- package/dist/prompt/commit.js.map +0 -1
- package/dist/prompt/instructions/commit.md +0 -133
- package/dist/prompt/instructions/release.md +0 -188
- package/dist/prompt/instructions/review.md +0 -169
- package/dist/prompt/personas/releaser.md +0 -24
- package/dist/prompt/personas/you.md +0 -55
- package/dist/prompt/release.js +0 -100
- package/dist/prompt/release.js.map +0 -1
- package/dist/prompt/review.js +0 -64
- package/dist/prompt/review.js.map +0 -1
- package/dist/util/github.js +0 -1071
- package/dist/util/github.js.map +0 -1
- package/dist/util/openai.js +0 -365
- package/dist/util/openai.js.map +0 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Workflow Precheck Implementation
|
|
2
|
+
|
|
3
|
+
## Problem Statement
|
|
4
|
+
|
|
5
|
+
The `kodrdriv publish` command was freezing when running in the getfjell/http-api repository during the `publish-tree` operation.
|
|
6
|
+
|
|
7
|
+
### Root Cause
|
|
8
|
+
|
|
9
|
+
The workflow file at `~/gitw/getfjell/http-api/.github/workflows/test.yml` is configured with:
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
branches:
|
|
15
|
+
- main
|
|
16
|
+
- working
|
|
17
|
+
- 'feature/**'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**The problem:** This workflow triggers on `push` events but **NOT on `pull_request` events**.
|
|
21
|
+
|
|
22
|
+
When `kodrdriv publish`:
|
|
23
|
+
1. Creates a new branch and pushes commits ✅
|
|
24
|
+
2. Creates a pull request ✅
|
|
25
|
+
3. Waits for PR checks to complete using `waitForPullRequestChecks()` ❌
|
|
26
|
+
|
|
27
|
+
The `waitForPullRequestChecks()` function queries the GitHub API for check runs associated with the PR. Because the workflow only triggers on `push` (not `pull_request`), GitHub doesn't associate those workflow runs with the PR, so the API returns no checks.
|
|
28
|
+
|
|
29
|
+
The function was designed to detect this after 1 minute (6 consecutive checks with no results), but in your case it was likely stuck in a detection loop or the command was running with `skipUserConfirmation: true` which caused it to wait for the full 1-hour timeout.
|
|
30
|
+
|
|
31
|
+
## Solution
|
|
32
|
+
|
|
33
|
+
I've implemented **two complementary improvements** to prevent this issue:
|
|
34
|
+
|
|
35
|
+
### 1. Workflow Validation Precheck (runs before PR creation)
|
|
36
|
+
### 2. Smart Wait Skipping (skips waiting if no PR workflows detected)
|
|
37
|
+
|
|
38
|
+
### Changes Made
|
|
39
|
+
|
|
40
|
+
#### 1. Workflow Validation Precheck
|
|
41
|
+
|
|
42
|
+
**New function** `checkWorkflowConfiguration()` in `@eldrforge/github-tools` that:
|
|
43
|
+
- Lists all workflows in the repository
|
|
44
|
+
- Analyzes each workflow file's YAML content
|
|
45
|
+
- Determines if workflows will be triggered by PRs to the target branch
|
|
46
|
+
- Returns detailed information about workflow configuration
|
|
47
|
+
|
|
48
|
+
**Location:** `~/gitw/calenvarek/github-tools/src/github.ts`
|
|
49
|
+
|
|
50
|
+
**Example output:**
|
|
51
|
+
```typescript
|
|
52
|
+
{
|
|
53
|
+
hasWorkflows: true,
|
|
54
|
+
workflowCount: 4,
|
|
55
|
+
hasPullRequestTriggers: false, // ⚠️ This is the warning
|
|
56
|
+
triggeredWorkflowNames: [],
|
|
57
|
+
warning: "4 workflow(s) are configured, but none appear to trigger on pull requests to main"
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### 2. Smart Wait Skipping
|
|
62
|
+
|
|
63
|
+
**After** the PR is created, the publish command now checks the workflow configuration again and **skips waiting entirely** if no workflows will trigger on the PR.
|
|
64
|
+
|
|
65
|
+
**Location:** `~/gitw/calenvarek/kodrdriv/src/commands/publish.ts` (lines 833-850)
|
|
66
|
+
|
|
67
|
+
**Output when skipping:**
|
|
68
|
+
```
|
|
69
|
+
Waiting for PR #75 checks to complete...
|
|
70
|
+
⏭️ Skipping check wait - no workflows configured to trigger on this PR
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This prevents the command from freezing when workflows exist but don't trigger on PRs.
|
|
74
|
+
|
|
75
|
+
#### 3. Improved Detection in `waitForPullRequestChecks`
|
|
76
|
+
|
|
77
|
+
Made the wait function smarter and faster:
|
|
78
|
+
- **Reduced wait time**: Now checks after 30 seconds instead of 1 minute
|
|
79
|
+
- **Better detection**: Distinguishes between "no workflow runs" vs "workflow runs exist on branch but aren't PR checks"
|
|
80
|
+
- **Explicit handling**: When workflows trigger on `push` but not `pull_request`, it detects this and proceeds without waiting
|
|
81
|
+
|
|
82
|
+
**Location:** `~/gitw/calenvarek/github-tools/src/github.ts`
|
|
83
|
+
|
|
84
|
+
**Key improvements:**
|
|
85
|
+
```typescript
|
|
86
|
+
// Changed from 6 checks (1 minute) to 3 checks (30 seconds)
|
|
87
|
+
const maxConsecutiveNoChecks = 3;
|
|
88
|
+
|
|
89
|
+
// New logic to detect workflows that trigger on push but not pull_request
|
|
90
|
+
logger.info(`Found workflow runs on the branch, but none appear as PR checks.`);
|
|
91
|
+
logger.info(`This usually means workflows trigger on 'push' but not 'pull_request'.`);
|
|
92
|
+
// ... proceeds without waiting in non-interactive mode
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### 4. Precheck Warning
|
|
96
|
+
|
|
97
|
+
Modified the `runPrechecks()` function to call `checkWorkflowConfiguration()` and warn users before creating the PR.
|
|
98
|
+
|
|
99
|
+
**Location:** `~/gitw/calenvarek/kodrdriv/src/commands/publish.ts` (lines 244-267)
|
|
100
|
+
|
|
101
|
+
**Output when workflows are missing:**
|
|
102
|
+
```
|
|
103
|
+
Checking GitHub Actions workflow configuration...
|
|
104
|
+
⚠️ Found 4 workflow(s), but none are triggered by PRs to main.
|
|
105
|
+
The publish process will create a PR but will not wait for any checks to complete.
|
|
106
|
+
Consider updating workflow triggers to include: on.pull_request.branches: [main]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### 5. Tests
|
|
110
|
+
|
|
111
|
+
Created comprehensive test suite with 8 test cases covering:
|
|
112
|
+
- No workflows configured
|
|
113
|
+
- Workflows with `pull_request` triggers
|
|
114
|
+
- Workflows without `pull_request` triggers
|
|
115
|
+
- Branch-specific triggers
|
|
116
|
+
- Wildcard patterns
|
|
117
|
+
- Multiple workflows with mixed configurations
|
|
118
|
+
- API error handling
|
|
119
|
+
|
|
120
|
+
**Location:** `~/gitw/calenvarek/github-tools/tests/checkWorkflowConfiguration.test.ts`
|
|
121
|
+
|
|
122
|
+
**Result:** All 8 tests passing ✅
|
|
123
|
+
|
|
124
|
+
## How to Fix the http-api Workflow
|
|
125
|
+
|
|
126
|
+
Update `~/gitw/getfjell/http-api/.github/workflows/test.yml`:
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
name: Run Tests
|
|
130
|
+
|
|
131
|
+
on:
|
|
132
|
+
push:
|
|
133
|
+
branches:
|
|
134
|
+
- main
|
|
135
|
+
- working
|
|
136
|
+
- 'feature/**'
|
|
137
|
+
pull_request: # ← ADD THIS
|
|
138
|
+
branches:
|
|
139
|
+
- main
|
|
140
|
+
|
|
141
|
+
permissions:
|
|
142
|
+
contents: read
|
|
143
|
+
statuses: write
|
|
144
|
+
|
|
145
|
+
jobs:
|
|
146
|
+
test:
|
|
147
|
+
runs-on: ubuntu-latest
|
|
148
|
+
steps:
|
|
149
|
+
- uses: actions/checkout@v4
|
|
150
|
+
- uses: actions/setup-node@v4
|
|
151
|
+
with:
|
|
152
|
+
node-version: 22
|
|
153
|
+
|
|
154
|
+
- run: npm ci
|
|
155
|
+
- run: npm run lint
|
|
156
|
+
- run: npm run build
|
|
157
|
+
- run: npm test
|
|
158
|
+
|
|
159
|
+
- uses: codecov/codecov-action@v5
|
|
160
|
+
with:
|
|
161
|
+
slug: getfjell/http-api
|
|
162
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**What this does:**
|
|
166
|
+
- Triggers the workflow when PRs are opened/updated targeting `main` branch
|
|
167
|
+
- GitHub will now associate the check runs with the PR
|
|
168
|
+
- `kodrdriv publish` will detect the checks and wait for them to complete
|
|
169
|
+
- The PR merge will only proceed after checks pass ✅
|
|
170
|
+
|
|
171
|
+
## Testing the Fix
|
|
172
|
+
|
|
173
|
+
After updating the workflow file and rebuilding:
|
|
174
|
+
|
|
175
|
+
1. **Test the precheck:**
|
|
176
|
+
```bash
|
|
177
|
+
cd ~/gitw/getfjell/http-api
|
|
178
|
+
kodrdriv publish --dry-run
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Before fix: Would warn about missing PR triggers
|
|
182
|
+
After fix: Should show workflow will run on PRs ✅
|
|
183
|
+
|
|
184
|
+
2. **Test actual publish:**
|
|
185
|
+
```bash
|
|
186
|
+
kodrdriv publish
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Should now:
|
|
190
|
+
- Create PR
|
|
191
|
+
- Detect workflow runs
|
|
192
|
+
- Wait for checks to complete
|
|
193
|
+
- Merge when checks pass
|
|
194
|
+
|
|
195
|
+
## Related Files Modified
|
|
196
|
+
|
|
197
|
+
### github-tools package:
|
|
198
|
+
- `~/gitw/calenvarek/github-tools/src/github.ts` - Added `checkWorkflowConfiguration()` and `isTriggeredByPullRequest()`
|
|
199
|
+
- `~/gitw/calenvarek/github-tools/src/index.ts` - Exported new function
|
|
200
|
+
- `~/gitw/calenvarek/github-tools/tests/checkWorkflowConfiguration.test.ts` - New test file
|
|
201
|
+
|
|
202
|
+
### kodrdriv package:
|
|
203
|
+
- `~/gitw/calenvarek/kodrdriv/src/commands/publish.ts` - Added workflow validation to prechecks
|
|
204
|
+
|
|
205
|
+
Both packages have been built and all tests pass.
|
|
206
|
+
|
|
207
|
+
## Future Improvements
|
|
208
|
+
|
|
209
|
+
Consider adding:
|
|
210
|
+
1. Configuration option to skip workflow validation if desired
|
|
211
|
+
2. Ability to specify minimum required workflows
|
|
212
|
+
3. Integration with workflow file templates for new projects
|
|
213
|
+
|
|
214
|
+
## Summary
|
|
215
|
+
|
|
216
|
+
**What was frozen:** The `kodrdriv publish` command waiting for PR checks that never appeared
|
|
217
|
+
|
|
218
|
+
**Why it happened:** The workflow triggers on `push` but not `pull_request`, so GitHub doesn't associate runs with the PR
|
|
219
|
+
|
|
220
|
+
**How we fixed it:**
|
|
221
|
+
1. ✅ **Precheck Warning**: Validates workflow configuration before creating the PR and warns about missing triggers
|
|
222
|
+
2. ✅ **Smart Wait Skipping**: Automatically skips waiting if no workflows will trigger on the PR (no more freezing!)
|
|
223
|
+
3. ✅ **Improved Detection**: Detects within 30 seconds when workflows exist on branch but aren't PR checks
|
|
224
|
+
|
|
225
|
+
**How to fix your workflow:** Add `pull_request` trigger to your workflow files (see above)
|
|
226
|
+
|
|
227
|
+
**Current state:**
|
|
228
|
+
- ✅ Precheck implemented and warns users
|
|
229
|
+
- ✅ Smart skip logic prevents freezing
|
|
230
|
+
- ✅ Faster detection (30s instead of 1 minute)
|
|
231
|
+
- ✅ Better error messages
|
|
232
|
+
- ✅ All tests passing (8/8)
|
|
233
|
+
- ✅ Both packages built
|
|
234
|
+
- ⚠️ http-api workflow needs updating for best experience (see above)
|
|
235
|
+
|
|
236
|
+
**Behavior now:**
|
|
237
|
+
- **Before fix**: Command would freeze for up to 1 hour waiting for checks
|
|
238
|
+
- **After fix**: Command detects the issue within 30 seconds and proceeds automatically in non-interactive mode, or prompts user in interactive mode
|
|
239
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Smart Workflow Wait Skipping - Implementation Summary
|
|
2
|
+
|
|
3
|
+
## The Problem You Asked About
|
|
4
|
+
|
|
5
|
+
> "If there is no action fired from a pull request workflow, can we just not wait for it to complete?"
|
|
6
|
+
|
|
7
|
+
**Answer: YES! ✅ Now implemented.**
|
|
8
|
+
|
|
9
|
+
## What I've Added
|
|
10
|
+
|
|
11
|
+
### 1. Pre-check Before Creating PR
|
|
12
|
+
The publish command now checks workflow configuration **before** creating the PR and warns you:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Checking GitHub Actions workflow configuration...
|
|
16
|
+
⚠️ Found 4 workflow(s), but none are triggered by PRs to main.
|
|
17
|
+
The publish process will create a PR but will not wait for any checks to complete.
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. **Smart Skip After Creating PR** ⭐ (This is what you asked for!)
|
|
21
|
+
After the PR is created, the command checks workflow configuration again and **skips waiting entirely**:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Waiting for PR #75 checks to complete...
|
|
25
|
+
⏭️ Skipping check wait - no workflows configured to trigger on this PR
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**No more freezing!** The command proceeds immediately instead of waiting.
|
|
29
|
+
|
|
30
|
+
### 3. Faster Detection When Checks Won't Appear
|
|
31
|
+
If we can't determine workflow configuration in advance, the wait logic now:
|
|
32
|
+
- Detects the issue in **30 seconds** instead of 1 minute
|
|
33
|
+
- Distinguishes between "no workflows" vs "workflows exist but don't trigger on PRs"
|
|
34
|
+
- Automatically proceeds in non-interactive mode (like in `publish-tree`)
|
|
35
|
+
|
|
36
|
+
## How It Works
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// In publish.ts - after PR is created
|
|
40
|
+
const workflowConfig = await GitHub.checkWorkflowConfiguration(targetBranch);
|
|
41
|
+
if (!workflowConfig.hasWorkflows || !workflowConfig.hasPullRequestTriggers) {
|
|
42
|
+
logger.info('⏭️ Skipping check wait - no workflows configured to trigger on this PR');
|
|
43
|
+
shouldSkipWait = true;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The command:
|
|
48
|
+
1. Checks if workflows are configured
|
|
49
|
+
2. Checks if any workflows will trigger on this PR
|
|
50
|
+
3. If NO → skips waiting entirely
|
|
51
|
+
4. If YES → waits for checks as normal
|
|
52
|
+
|
|
53
|
+
## Timeline Comparison
|
|
54
|
+
|
|
55
|
+
### Before These Changes:
|
|
56
|
+
```
|
|
57
|
+
Create PR ✓
|
|
58
|
+
Wait for checks...
|
|
59
|
+
[10s] No checks found
|
|
60
|
+
[20s] No checks found
|
|
61
|
+
[30s] No checks found
|
|
62
|
+
[40s] No checks found
|
|
63
|
+
[50s] No checks found
|
|
64
|
+
[60s] No checks found - checking workflows...
|
|
65
|
+
[70s] Workflows exist, checking if triggered for PR...
|
|
66
|
+
[80s] Found runs on branch...
|
|
67
|
+
... continues waiting or hangs ...
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### After These Changes:
|
|
71
|
+
```
|
|
72
|
+
Precheck: Workflows exist but don't trigger on PRs ⚠️
|
|
73
|
+
Create PR ✓
|
|
74
|
+
Check workflow config again...
|
|
75
|
+
⏭️ Skipping check wait - no workflows configured to trigger on this PR
|
|
76
|
+
Merge PR ✓
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Time saved per publish:** Up to 60 minutes (if you were hitting the timeout!)
|
|
80
|
+
|
|
81
|
+
## What Gets Detected
|
|
82
|
+
|
|
83
|
+
The smart skip detects:
|
|
84
|
+
- ❌ No workflows configured at all
|
|
85
|
+
- ❌ Workflows configured but none trigger on `pull_request` events
|
|
86
|
+
- ❌ Workflows trigger on PRs but not to your target branch (e.g., only to `develop`)
|
|
87
|
+
- ✅ Workflows will run on this PR → waits normally
|
|
88
|
+
|
|
89
|
+
## For Your http-api Repository
|
|
90
|
+
|
|
91
|
+
The command will now:
|
|
92
|
+
1. **Warn during precheck**: "4 workflow(s) configured, but none trigger on PRs to main"
|
|
93
|
+
2. **Skip waiting**: Proceeds immediately after creating the PR
|
|
94
|
+
3. **No freezing**: Command completes successfully
|
|
95
|
+
|
|
96
|
+
To get actual CI checks on your PRs (recommended), add to `test.yml`:
|
|
97
|
+
```yaml
|
|
98
|
+
on:
|
|
99
|
+
push:
|
|
100
|
+
branches: [main, working, 'feature/**']
|
|
101
|
+
pull_request: # ← Add this
|
|
102
|
+
branches: [main]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Testing
|
|
106
|
+
|
|
107
|
+
Run your `publish-tree` command again - it should now:
|
|
108
|
+
- Complete much faster (no 1-hour wait!)
|
|
109
|
+
- Show skip messages for repos without PR workflows
|
|
110
|
+
- Wait normally for repos with PR workflows
|
|
111
|
+
- Never freeze
|
|
112
|
+
|
|
113
|
+
## Files Modified
|
|
114
|
+
|
|
115
|
+
- `github-tools/src/github.ts` - Added `checkWorkflowConfiguration()`, improved `waitForPullRequestChecks()`
|
|
116
|
+
- `github-tools/src/index.ts` - Exported new function
|
|
117
|
+
- `kodrdriv/src/commands/publish.ts` - Added precheck + smart skip logic
|
|
118
|
+
- `github-tools/tests/checkWorkflowConfiguration.test.ts` - 8 comprehensive tests (all passing)
|
|
119
|
+
|
|
120
|
+
Both packages rebuilt and ready to use! ✅
|
|
121
|
+
|
package/dist/application.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as Cardigantime from '@theunwalked/cardigantime';
|
|
2
2
|
import 'dotenv/config';
|
|
3
|
+
import { setLogger } from '@eldrforge/git-tools';
|
|
4
|
+
import { setLogger as setLogger$1, setPromptFunction } from '@eldrforge/github-tools';
|
|
5
|
+
import { promptConfirmation } from './util/stdin.js';
|
|
3
6
|
import { configure } from './arguments.js';
|
|
4
7
|
import { execute as execute$1 } from './commands/audio-commit.js';
|
|
5
8
|
import { execute as execute$7 } from './commands/audio-review.js';
|
|
@@ -18,7 +21,6 @@ import { execute as execute$c } from './commands/versions.js';
|
|
|
18
21
|
import { DEFAULT_CONFIG_DIR, VERSION, COMMAND_CHECK_CONFIG, COMMAND_INIT_CONFIG, COMMAND_COMMIT, COMMAND_AUDIO_COMMIT, COMMAND_RELEASE, COMMAND_PUBLISH, COMMAND_TREE, COMMAND_LINK, COMMAND_UNLINK, COMMAND_AUDIO_REVIEW, COMMAND_CLEAN, COMMAND_REVIEW, COMMAND_SELECT_AUDIO, COMMAND_DEVELOPMENT, COMMAND_VERSIONS, COMMAND_UPDATES } from './constants.js';
|
|
19
22
|
import { UserCancellationError } from './error/CommandErrors.js';
|
|
20
23
|
import { getLogger, setLogLevel } from './logging.js';
|
|
21
|
-
import { setLogger } from '@eldrforge/git-tools';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* Print debug information about the command being executed when debug flag is enabled.
|
|
@@ -74,8 +76,10 @@ async function runApplication() {
|
|
|
74
76
|
}
|
|
75
77
|
const logger = getLogger();
|
|
76
78
|
cardigantime.setLogger(logger);
|
|
77
|
-
// Configure
|
|
79
|
+
// Configure external packages to use our logger and prompt
|
|
78
80
|
setLogger(logger);
|
|
81
|
+
setLogger$1(logger);
|
|
82
|
+
setPromptFunction(promptConfirmation);
|
|
79
83
|
// Display version information
|
|
80
84
|
logger.info('🚀 kodrdriv %s', VERSION);
|
|
81
85
|
// Handle check-config command first
|
package/dist/application.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sources":["../src/application.ts"],"sourcesContent":["import * as Cardigantime from '@theunwalked/cardigantime';\nimport 'dotenv/config';\nimport { CommandConfig } from 'types';\nimport * as Arguments from './arguments';\nimport * as AudioCommit from './commands/audio-commit';\nimport * as AudioReview from './commands/audio-review';\nimport * as Clean from './commands/clean';\nimport * as Commit from './commands/commit';\nimport * as Development from './commands/development';\nimport * as Link from './commands/link';\nimport * as Publish from './commands/publish';\nimport * as Release from './commands/release';\nimport * as Review from './commands/review';\nimport * as SelectAudio from './commands/select-audio';\nimport * as Tree from './commands/tree';\nimport * as Unlink from './commands/unlink';\nimport * as Updates from './commands/updates';\nimport * as Versions from './commands/versions';\nimport { COMMAND_AUDIO_COMMIT, COMMAND_AUDIO_REVIEW, COMMAND_CHECK_CONFIG, COMMAND_CLEAN, COMMAND_COMMIT, COMMAND_DEVELOPMENT, COMMAND_INIT_CONFIG, COMMAND_LINK, COMMAND_PUBLISH, COMMAND_RELEASE, COMMAND_REVIEW, COMMAND_SELECT_AUDIO, COMMAND_TREE, COMMAND_UNLINK, COMMAND_UPDATES, COMMAND_VERSIONS, DEFAULT_CONFIG_DIR, VERSION } from './constants';\nimport { UserCancellationError } from './error/CommandErrors';\nimport { getLogger, setLogLevel } from './logging';\nimport { Config, SecureConfig } from './types';\nimport { setLogger as setGitToolsLogger } from '@eldrforge/git-tools';\n\n/**\n * Print debug information about the command being executed when debug flag is enabled.\n */\nfunction printDebugCommandInfo(commandName: string, runConfig: Config): void {\n if (runConfig.debug) {\n const logger = getLogger();\n logger.info('=== KODRDRIV DEBUG INFO ===');\n logger.info('Command: %s', commandName);\n logger.info('Version: %s', VERSION);\n logger.info('===========================');\n }\n}\n\n/**\n * Configure early logging based on command line flags.\n *\n * Hey we need this because we need to be able to debug CardiganTime.\n * This method checks for --verbose and --debug flags early in the process\n * before CardiganTime is configured, allowing us to capture debug output\n * from the CardiganTime initialization itself.\n */\nexport function configureEarlyLogging(): void {\n const hasVerbose = process.argv.includes('--verbose');\n const hasDebug = process.argv.includes('--debug');\n\n // Set log level based on early flag detection\n if (hasDebug) {\n setLogLevel('debug');\n } else if (hasVerbose) {\n setLogLevel('verbose');\n }\n}\n\nexport async function runApplication(): Promise<void> {\n // Configure logging early, before CardiganTime initialization\n configureEarlyLogging();\n\n // Use proper typing for CardiganTime create function\n interface CardigantimeCreateParams {\n defaults?: any;\n features?: string[];\n configShape?: any;\n logger?: any;\n }\n\n interface CardigantimeInstance {\n read: (args: any) => Promise<any>;\n checkConfig: () => Promise<void>;\n generateConfig: (dir: string) => Promise<void>;\n setLogger: (logger: any) => void;\n }\n\n const cardigantimeModule = Cardigantime as any;\n const createCardigantime = cardigantimeModule.create as (params: CardigantimeCreateParams) => CardigantimeInstance;\n\n const cardigantime = createCardigantime({\n defaults: {\n configDirectory: DEFAULT_CONFIG_DIR,\n },\n features: ['config', 'hierarchical'],\n logger: getLogger(),\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [runConfig, secureConfig, commandConfig]: [Config, SecureConfig, CommandConfig] = await Arguments.configure(cardigantime); // Pass cardigantime instance\n\n // Set log level based on verbose flag\n if (runConfig.verbose) {\n setLogLevel('verbose');\n }\n if (runConfig.debug) {\n setLogLevel('debug');\n }\n\n const logger = getLogger();\n cardigantime.setLogger(logger);\n\n // Configure git-tools to use kodrdriv's logger\n setGitToolsLogger(logger);\n\n // Display version information\n logger.info('🚀 kodrdriv %s', VERSION);\n\n // Handle check-config command first\n if (commandConfig.commandName === COMMAND_CHECK_CONFIG) {\n // CardiganTime's checkConfig has already been called in Arguments.configure()\n // No additional processing needed here\n return;\n }\n\n // Handle init-config command\n if (commandConfig.commandName === COMMAND_INIT_CONFIG) {\n // CardiganTime's initConfig has already been called in Arguments.configure()\n // No additional processing needed here\n return;\n }\n\n // Get the command from Commander\n const command = process.argv[2];\n let commandName = commandConfig.commandName;\n\n // Handle special case for tree command with built-in command argument\n if (command === 'tree' && process.argv[3]) {\n const treeBuiltInCommand = process.argv[3];\n const supportedBuiltInCommands = ['commit', 'publish', 'link', 'unlink', 'development', 'updates'];\n if (supportedBuiltInCommands.includes(treeBuiltInCommand)) {\n // This is a tree command with built-in command, keep commandName as 'tree'\n commandName = 'tree';\n } else {\n // Unknown tree argument, let it fail naturally in tree.ts\n commandName = 'tree';\n }\n }\n // If we have a specific command argument, use that\n else if (command === 'commit' || command === 'audio-commit' || command === 'release' || command === 'publish' || command === 'tree' || command === 'link' || command === 'unlink' || command === 'audio-review' || command === 'clean' || command === 'review' || command === 'select-audio' || command === 'development' || command === 'versions' || command === 'updates') {\n commandName = command;\n }\n\n let summary: string = '';\n\n try {\n // Print debug info at the start of command execution\n if (commandName) {\n printDebugCommandInfo(commandName, runConfig);\n }\n\n if (commandName === COMMAND_COMMIT) {\n summary = await Commit.execute(runConfig);\n } else if (commandName === COMMAND_AUDIO_COMMIT) {\n summary = await AudioCommit.execute(runConfig);\n } else if (commandName === COMMAND_RELEASE) {\n const releaseSummary = await Release.execute(runConfig);\n summary = `${releaseSummary.title}\\n\\n${releaseSummary.body}`;\n } else if (commandName === COMMAND_PUBLISH) {\n await Publish.execute(runConfig);\n } else if (commandName === COMMAND_TREE) {\n // Handle tree directories mapping from command-specific arguments\n if (runConfig.audioReview?.directory && !runConfig.tree?.directories) {\n runConfig.tree = runConfig.tree || {};\n runConfig.tree.directories = [runConfig.audioReview.directory];\n }\n // Handle tree exclusion patterns - use global excludedPatterns for tree\n if (runConfig.excludedPatterns && !runConfig.tree?.exclude) {\n runConfig.tree = runConfig.tree || {};\n runConfig.tree.exclude = runConfig.excludedPatterns;\n }\n summary = await Tree.execute(runConfig);\n } else if (commandName === COMMAND_LINK) {\n summary = await Link.execute(runConfig);\n } else if (commandName === COMMAND_UNLINK) {\n summary = await Unlink.execute(runConfig);\n } else if (commandName === COMMAND_AUDIO_REVIEW) {\n summary = await AudioReview.execute(runConfig);\n } else if (commandName === COMMAND_CLEAN) {\n await Clean.execute(runConfig);\n summary = 'Output directory cleaned successfully.';\n } else if (commandName === COMMAND_REVIEW) {\n summary = await Review.execute(runConfig);\n } else if (commandName === COMMAND_SELECT_AUDIO) {\n await SelectAudio.execute(runConfig);\n summary = 'Audio selection completed successfully.';\n } else if (commandName === COMMAND_DEVELOPMENT) {\n summary = await Development.execute(runConfig);\n } else if (commandName === COMMAND_VERSIONS) {\n summary = await Versions.execute(runConfig);\n } else if (commandName === COMMAND_UPDATES) {\n summary = await Updates.execute(runConfig);\n }\n\n // eslint-disable-next-line no-console\n console.log(`\\n\\n${summary}\\n\\n`);\n } catch (error: any) {\n // Handle user cancellation gracefully\n if (error instanceof UserCancellationError) {\n logger.info(error.message);\n process.exit(0);\n }\n\n // Re-throw other errors to be handled by main.ts\n throw error;\n }\n}\n"],"names":["printDebugCommandInfo","commandName","runConfig","debug","logger","getLogger","info","VERSION","configureEarlyLogging","hasVerbose","process","argv","includes","hasDebug","setLogLevel","runApplication","cardigantimeModule","Cardigantime","createCardigantime","create","cardigantime","defaults","configDirectory","DEFAULT_CONFIG_DIR","features","secureConfig","commandConfig","Arguments","verbose","setLogger","setGitToolsLogger","COMMAND_CHECK_CONFIG","COMMAND_INIT_CONFIG","command","treeBuiltInCommand","supportedBuiltInCommands","summary","COMMAND_COMMIT","Commit","COMMAND_AUDIO_COMMIT","AudioCommit","COMMAND_RELEASE","releaseSummary","Release","title","body","COMMAND_PUBLISH","Publish","COMMAND_TREE","audioReview","directory","tree","directories","excludedPatterns","exclude","Tree","COMMAND_LINK","Link","COMMAND_UNLINK","Unlink","COMMAND_AUDIO_REVIEW","AudioReview","COMMAND_CLEAN","Clean","COMMAND_REVIEW","Review","COMMAND_SELECT_AUDIO","SelectAudio","COMMAND_DEVELOPMENT","Development","COMMAND_VERSIONS","Versions","COMMAND_UPDATES","Updates","console","log","error","UserCancellationError","message","exit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA;;AAEC,IACD,SAASA,qBAAAA,CAAsBC,WAAmB,EAAEC,SAAiB,EAAA;IACjE,IAAIA,SAAAA,CAAUC,KAAK,EAAE;AACjB,QAAA,MAAMC,MAAAA,GAASC,SAAAA,EAAAA;AACfD,QAAAA,MAAAA,CAAOE,IAAI,CAAC,6BAAA,CAAA;QACZF,MAAAA,CAAOE,IAAI,CAAC,aAAA,EAAeL,WAAAA,CAAAA;QAC3BG,MAAAA,CAAOE,IAAI,CAAC,aAAA,EAAeC,OAAAA,CAAAA;AAC3BH,QAAAA,MAAAA,CAAOE,IAAI,CAAC,6BAAA,CAAA;AAChB,IAAA;AACJ;AAEA;;;;;;;AAOC,IACM,SAAS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,EAAkB;YACzClC,OAAAA,GAAU,MAAMmC,SAAgB,CAACrE,SAAAA,CAAAA;QACrC,CAAA,MAAO,IAAID,gBAAgBuE,eAAAA,EAAiB;YACxCpC,OAAAA,GAAU,MAAMqC,SAAe,CAACvE,SAAAA,CAAAA;AACpC,QAAA;;AAGAwE,QAAAA,OAAAA,CAAQC,GAAG,CAAC,CAAC,IAAI,EAAEvC,OAAAA,CAAQ,IAAI,CAAC,CAAA;AACpC,IAAA,CAAA,CAAE,OAAOwC,KAAAA,EAAY;;AAEjB,QAAA,IAAIA,iBAAiBC,qBAAAA,EAAuB;YACxCzE,MAAAA,CAAOE,IAAI,CAACsE,KAAAA,CAAME,OAAO,CAAA;AACzBpE,YAAAA,OAAAA,CAAQqE,IAAI,CAAC,CAAA,CAAA;AACjB,QAAA;;QAGA,MAAMH,KAAAA;AACV,IAAA;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"application.js","sources":["../src/application.ts"],"sourcesContent":["import * as Cardigantime from '@theunwalked/cardigantime';\nimport 'dotenv/config';\nimport { setLogger as setGitLogger } from '@eldrforge/git-tools';\nimport { setLogger as setGitHubLogger, setPromptFunction } from '@eldrforge/github-tools';\nimport { promptConfirmation } from './util/stdin';\nimport { CommandConfig } from 'types';\nimport * as Arguments from './arguments';\nimport * as AudioCommit from './commands/audio-commit';\nimport * as AudioReview from './commands/audio-review';\nimport * as Clean from './commands/clean';\nimport * as Commit from './commands/commit';\nimport * as Development from './commands/development';\nimport * as Link from './commands/link';\nimport * as Publish from './commands/publish';\nimport * as Release from './commands/release';\nimport * as Review from './commands/review';\nimport * as SelectAudio from './commands/select-audio';\nimport * as Tree from './commands/tree';\nimport * as Unlink from './commands/unlink';\nimport * as Updates from './commands/updates';\nimport * as Versions from './commands/versions';\nimport { COMMAND_AUDIO_COMMIT, COMMAND_AUDIO_REVIEW, COMMAND_CHECK_CONFIG, COMMAND_CLEAN, COMMAND_COMMIT, COMMAND_DEVELOPMENT, COMMAND_INIT_CONFIG, COMMAND_LINK, COMMAND_PUBLISH, COMMAND_RELEASE, COMMAND_REVIEW, COMMAND_SELECT_AUDIO, COMMAND_TREE, COMMAND_UNLINK, COMMAND_UPDATES, COMMAND_VERSIONS, DEFAULT_CONFIG_DIR, VERSION } from './constants';\nimport { UserCancellationError } from './error/CommandErrors';\nimport { getLogger, setLogLevel } from './logging';\nimport { Config, SecureConfig } from './types';\n\n/**\n * Print debug information about the command being executed when debug flag is enabled.\n */\nfunction printDebugCommandInfo(commandName: string, runConfig: Config): void {\n if (runConfig.debug) {\n const logger = getLogger();\n logger.info('=== KODRDRIV DEBUG INFO ===');\n logger.info('Command: %s', commandName);\n logger.info('Version: %s', VERSION);\n logger.info('===========================');\n }\n}\n\n/**\n * Configure early logging based on command line flags.\n *\n * Hey we need this because we need to be able to debug CardiganTime.\n * This method checks for --verbose and --debug flags early in the process\n * before CardiganTime is configured, allowing us to capture debug output\n * from the CardiganTime initialization itself.\n */\nexport function configureEarlyLogging(): void {\n const hasVerbose = process.argv.includes('--verbose');\n const hasDebug = process.argv.includes('--debug');\n\n // Set log level based on early flag detection\n if (hasDebug) {\n setLogLevel('debug');\n } else if (hasVerbose) {\n setLogLevel('verbose');\n }\n}\n\nexport async function runApplication(): Promise<void> {\n // Configure logging early, before CardiganTime initialization\n configureEarlyLogging();\n\n // Use proper typing for CardiganTime create function\n interface CardigantimeCreateParams {\n defaults?: any;\n features?: string[];\n configShape?: any;\n logger?: any;\n }\n\n interface CardigantimeInstance {\n read: (args: any) => Promise<any>;\n checkConfig: () => Promise<void>;\n generateConfig: (dir: string) => Promise<void>;\n setLogger: (logger: any) => void;\n }\n\n const cardigantimeModule = Cardigantime as any;\n const createCardigantime = cardigantimeModule.create as (params: CardigantimeCreateParams) => CardigantimeInstance;\n\n const cardigantime = createCardigantime({\n defaults: {\n configDirectory: DEFAULT_CONFIG_DIR,\n },\n features: ['config', 'hierarchical'],\n logger: getLogger(),\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const [runConfig, secureConfig, commandConfig]: [Config, SecureConfig, CommandConfig] = await Arguments.configure(cardigantime); // Pass cardigantime instance\n\n // Set log level based on verbose flag\n if (runConfig.verbose) {\n setLogLevel('verbose');\n }\n if (runConfig.debug) {\n setLogLevel('debug');\n }\n\n const logger = getLogger();\n cardigantime.setLogger(logger);\n\n // Configure external packages to use our logger and prompt\n setGitLogger(logger);\n setGitHubLogger(logger);\n setPromptFunction(promptConfirmation);\n\n // Display version information\n logger.info('🚀 kodrdriv %s', VERSION);\n\n // Handle check-config command first\n if (commandConfig.commandName === COMMAND_CHECK_CONFIG) {\n // CardiganTime's checkConfig has already been called in Arguments.configure()\n // No additional processing needed here\n return;\n }\n\n // Handle init-config command\n if (commandConfig.commandName === COMMAND_INIT_CONFIG) {\n // CardiganTime's initConfig has already been called in Arguments.configure()\n // No additional processing needed here\n return;\n }\n\n // Get the command from Commander\n const command = process.argv[2];\n let commandName = commandConfig.commandName;\n\n // Handle special case for tree command with built-in command argument\n if (command === 'tree' && process.argv[3]) {\n const treeBuiltInCommand = process.argv[3];\n const supportedBuiltInCommands = ['commit', 'publish', 'link', 'unlink', 'development', 'updates'];\n if (supportedBuiltInCommands.includes(treeBuiltInCommand)) {\n // This is a tree command with built-in command, keep commandName as 'tree'\n commandName = 'tree';\n } else {\n // Unknown tree argument, let it fail naturally in tree.ts\n commandName = 'tree';\n }\n }\n // If we have a specific command argument, use that\n else if (command === 'commit' || command === 'audio-commit' || command === 'release' || command === 'publish' || command === 'tree' || command === 'link' || command === 'unlink' || command === 'audio-review' || command === 'clean' || command === 'review' || command === 'select-audio' || command === 'development' || command === 'versions' || command === 'updates') {\n commandName = command;\n }\n\n let summary: string = '';\n\n try {\n // Print debug info at the start of command execution\n if (commandName) {\n printDebugCommandInfo(commandName, runConfig);\n }\n\n if (commandName === COMMAND_COMMIT) {\n summary = await Commit.execute(runConfig);\n } else if (commandName === COMMAND_AUDIO_COMMIT) {\n summary = await AudioCommit.execute(runConfig);\n } else if (commandName === COMMAND_RELEASE) {\n const releaseSummary = await Release.execute(runConfig);\n summary = `${releaseSummary.title}\\n\\n${releaseSummary.body}`;\n } else if (commandName === COMMAND_PUBLISH) {\n await Publish.execute(runConfig);\n } else if (commandName === COMMAND_TREE) {\n // Handle tree directories mapping from command-specific arguments\n if (runConfig.audioReview?.directory && !runConfig.tree?.directories) {\n runConfig.tree = runConfig.tree || {};\n runConfig.tree.directories = [runConfig.audioReview.directory];\n }\n // Handle tree exclusion patterns - use global excludedPatterns for tree\n if (runConfig.excludedPatterns && !runConfig.tree?.exclude) {\n runConfig.tree = runConfig.tree || {};\n runConfig.tree.exclude = runConfig.excludedPatterns;\n }\n summary = await Tree.execute(runConfig);\n } else if (commandName === COMMAND_LINK) {\n summary = await Link.execute(runConfig);\n } else if (commandName === COMMAND_UNLINK) {\n summary = await Unlink.execute(runConfig);\n } else if (commandName === COMMAND_AUDIO_REVIEW) {\n summary = await AudioReview.execute(runConfig);\n } else if (commandName === COMMAND_CLEAN) {\n await Clean.execute(runConfig);\n summary = 'Output directory cleaned successfully.';\n } else if (commandName === COMMAND_REVIEW) {\n summary = await Review.execute(runConfig);\n } else if (commandName === COMMAND_SELECT_AUDIO) {\n await SelectAudio.execute(runConfig);\n summary = 'Audio selection completed successfully.';\n } else if (commandName === COMMAND_DEVELOPMENT) {\n summary = await Development.execute(runConfig);\n } else if (commandName === COMMAND_VERSIONS) {\n summary = await Versions.execute(runConfig);\n } else if (commandName === COMMAND_UPDATES) {\n summary = await Updates.execute(runConfig);\n }\n\n // eslint-disable-next-line no-console\n console.log(`\\n\\n${summary}\\n\\n`);\n } catch (error: any) {\n // Handle user cancellation gracefully\n if (error instanceof UserCancellationError) {\n logger.info(error.message);\n process.exit(0);\n }\n\n // Re-throw other errors to be handled by main.ts\n throw error;\n }\n}\n"],"names":["printDebugCommandInfo","commandName","runConfig","debug","logger","getLogger","info","VERSION","configureEarlyLogging","hasVerbose","process","argv","includes","hasDebug","setLogLevel","runApplication","cardigantimeModule","Cardigantime","createCardigantime","create","cardigantime","defaults","configDirectory","DEFAULT_CONFIG_DIR","features","secureConfig","commandConfig","Arguments","verbose","setLogger","setGitLogger","setGitHubLogger","setPromptFunction","promptConfirmation","COMMAND_CHECK_CONFIG","COMMAND_INIT_CONFIG","command","treeBuiltInCommand","supportedBuiltInCommands","summary","COMMAND_COMMIT","Commit","COMMAND_AUDIO_COMMIT","AudioCommit","COMMAND_RELEASE","releaseSummary","Release","title","body","COMMAND_PUBLISH","Publish","COMMAND_TREE","audioReview","directory","tree","directories","excludedPatterns","exclude","Tree","COMMAND_LINK","Link","COMMAND_UNLINK","Unlink","COMMAND_AUDIO_REVIEW","AudioReview","COMMAND_CLEAN","Clean","COMMAND_REVIEW","Review","COMMAND_SELECT_AUDIO","SelectAudio","COMMAND_DEVELOPMENT","Development","COMMAND_VERSIONS","Versions","COMMAND_UPDATES","Updates","console","log","error","UserCancellationError","message","exit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;AAEC,IACD,SAASA,qBAAAA,CAAsBC,WAAmB,EAAEC,SAAiB,EAAA;IACjE,IAAIA,SAAAA,CAAUC,KAAK,EAAE;AACjB,QAAA,MAAMC,MAAAA,GAASC,SAAAA,EAAAA;AACfD,QAAAA,MAAAA,CAAOE,IAAI,CAAC,6BAAA,CAAA;QACZF,MAAAA,CAAOE,IAAI,CAAC,aAAA,EAAeL,WAAAA,CAAAA;QAC3BG,MAAAA,CAAOE,IAAI,CAAC,aAAA,EAAeC,OAAAA,CAAAA;AAC3BH,QAAAA,MAAAA,CAAOE,IAAI,CAAC,6BAAA,CAAA;AAChB,IAAA;AACJ;AAEA;;;;;;;AAOC,IACM,SAASE,qBAAAA,GAAAA;AACZ,IAAA,MAAMC,UAAAA,GAAaC,OAAAA,CAAQC,IAAI,CAACC,QAAQ,CAAC,WAAA,CAAA;AACzC,IAAA,MAAMC,QAAAA,GAAWH,OAAAA,CAAQC,IAAI,CAACC,QAAQ,CAAC,SAAA,CAA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AiB;YACxCpC,OAAAA,GAAU,MAAMqC,SAAe,CAAC1E,SAAAA,CAAAA;AACpC,QAAA;;AAGA2E,QAAAA,OAAAA,CAAQC,GAAG,CAAC,CAAC,IAAI,EAAEvC,OAAAA,CAAQ,IAAI,CAAC,CAAA;AACpC,IAAA,CAAA,CAAE,OAAOwC,KAAAA,EAAY;;AAEjB,QAAA,IAAIA,iBAAiBC,qBAAAA,EAAuB;YACxC5E,MAAAA,CAAOE,IAAI,CAACyE,KAAAA,CAAME,OAAO,CAAA;AACzBvE,YAAAA,OAAAA,CAAQwE,IAAI,CAAC,CAAA,CAAA;AACjB,QAAA;;QAGA,MAAMH,KAAAA;AACV,IAAA;AACJ;;;;"}
|
package/dist/arguments.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import
|
|
2
|
+
import path from 'path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { PROGRAM_NAME, VERSION, KODRDRIV_DEFAULTS, ALLOWED_COMMANDS, DEFAULT_COMMAND } from './constants.js';
|
|
5
5
|
import { getLogger } from './logging.js';
|
|
@@ -364,7 +364,7 @@ const configure = async (cardigantime)=>{
|
|
|
364
364
|
const transformedCliArgs = transformCliArgs(cliArgs);
|
|
365
365
|
// Use CardiganTime's built-in generateConfig method
|
|
366
366
|
const configDir = transformedCliArgs.configDirectory || KODRDRIV_DEFAULTS.configDirectory;
|
|
367
|
-
const absoluteConfigDir =
|
|
367
|
+
const absoluteConfigDir = path.isAbsolute(configDir) ? configDir : path.resolve(process.cwd(), configDir);
|
|
368
368
|
await cardigantime.generateConfig(absoluteConfigDir);
|
|
369
369
|
// Return minimal config for consistency, but main processing is done
|
|
370
370
|
const config = await validateAndProcessOptions({});
|