@dtapline/cli 0.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 ADDED
@@ -0,0 +1,250 @@
1
+ # Dtapline CLI
2
+
3
+ Command-line tool for reporting deployment information to Dtapline API server. Designed for CI/CD integration with Azure Pipelines, GitHub Actions, and other automation tools.
4
+
5
+ ## Installation
6
+
7
+ ### Local Development
8
+
9
+ ```bash
10
+ # From the monorepo root
11
+ pnpm install
12
+ cd packages/cli
13
+ pnpm build
14
+
15
+ # Link globally (optional)
16
+ npm link
17
+ ```
18
+
19
+ ### Production
20
+
21
+ ```bash
22
+ npm install -g @dtapline/cli
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Basic Deployment Report
28
+
29
+ ```bash
30
+ dtapline deploy <environment> <service> <commitSha> \
31
+ --api-key YOUR_API_KEY \
32
+ --server-url https://api.dtapline.io
33
+ ```
34
+
35
+ ### With All Options
36
+
37
+ ```bash
38
+ dtapline deploy production my-api abc123def \
39
+ --api-key cm_xxxxxxxxxxxxx \
40
+ --server-url https://dtapline.mycompany.com \
41
+ --git-tag v1.2.3 \
42
+ --pr-url https://github.com/org/repo/pull/123 \
43
+ --deployed-by "Azure DevOps" \
44
+ --status success \
45
+ --build-url https://dev.azure.com/org/project/_build/results?buildId=456 \
46
+ --release-notes "Fixed critical bug in payment processing"
47
+ ```
48
+
49
+ ### Using Environment Variable for API Key
50
+
51
+ ```bash
52
+ export DTAPLINE_API_KEY=cm_xxxxxxxxxxxxx
53
+
54
+ dtapline deploy staging web-frontend def456ghi \
55
+ --git-tag v2.0.0-rc1
56
+ ```
57
+
58
+ ## Azure Pipelines Integration
59
+
60
+ Add this step to your `azure-pipelines.yml`:
61
+
62
+ ```yaml
63
+ trigger:
64
+ - main
65
+
66
+ pool:
67
+ vmImage: 'ubuntu-latest'
68
+
69
+ variables:
70
+ - group: dtapline-secrets # Contains DTAPLINE_API_KEY
71
+
72
+ stages:
73
+ - stage: Build
74
+ jobs:
75
+ - job: BuildAndDeploy
76
+ steps:
77
+ - task: NodeTool@0
78
+ inputs:
79
+ versionSpec: '20.x'
80
+
81
+ # Your build steps here...
82
+
83
+ - script: |
84
+ npm install -g @dtapline/cli
85
+ displayName: 'Install Dtapline CLI'
86
+
87
+ - script: |
88
+ dtapline deploy \
89
+ $(ENVIRONMENT) \
90
+ $(SERVICE_NAME) \
91
+ $(Build.SourceVersion) \
92
+ --api-key $(DTAPLINE_API_KEY) \
93
+ --server-url $(DTAPLINE_SERVER_URL) \
94
+ --git-tag $(Build.SourceBranchName) \
95
+ --deployed-by "Azure DevOps" \
96
+ --build-url $(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId) \
97
+ --status success
98
+ displayName: 'Report Deployment to dtapline'
99
+ condition: succeeded()
100
+ ```
101
+
102
+ ## GitHub Actions Integration
103
+
104
+ Add this to your `.github/workflows/deploy.yml`:
105
+
106
+ ```yaml
107
+ name: Deploy
108
+
109
+ on:
110
+ push:
111
+ branches: [main]
112
+
113
+ jobs:
114
+ deploy:
115
+ runs-on: ubuntu-latest
116
+
117
+ steps:
118
+ - uses: actions/checkout@v3
119
+
120
+ # Your build/deploy steps...
121
+
122
+ - name: Report to Dtapline
123
+ env:
124
+ DTAPLINE_API_KEY: ${{ secrets.DTAPLINE_API_KEY }}
125
+ run: |
126
+ npm install -g @dtapline/cli
127
+
128
+ dtapline deploy \
129
+ production \
130
+ my-service \
131
+ ${{ github.sha }} \
132
+ --server-url https://api.dtapline.io \
133
+ --git-tag ${{ github.ref_name }} \
134
+ --pr-url ${{ github.event.pull_request.html_url }} \
135
+ --deployed-by "GitHub Actions" \
136
+ --build-url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
137
+ ```
138
+
139
+ ## Command Reference
140
+
141
+ ### `dtapline deploy`
142
+
143
+ Report a deployment to Dtapline API server.
144
+
145
+ **Arguments:**
146
+ - `environment` - The deployment environment (e.g., dev, staging, production)
147
+ - `service` - The service name being deployed
148
+ - `commitSha` - Git commit SHA being deployed
149
+
150
+ **Options:**
151
+ - `--api-key <key>` - Dtapline API key (or set DTAPLINE_API_KEY env var)
152
+ - `--server-url <url>` - Dtapline API server URL (default: http://localhost:3000)
153
+ - `--git-tag <tag>` - Git tag for this deployment (e.g., v1.2.3)
154
+ - `--pr-url <url>` - Pull request URL
155
+ - `--deployed-by <who>` - Who/what triggered the deployment
156
+ - `--status <status>` - Deployment status: success, failed, in_progress, rolled_back (default: success)
157
+ - `--build-url <url>` - Build/CI pipeline URL
158
+ - `--release-notes <notes>` - Release notes or changelog
159
+
160
+ **Global Options:**
161
+ - `--help` - Show help
162
+ - `--version` - Show version
163
+ - `--wizard` - Interactive mode
164
+
165
+ ## API Key Management
166
+
167
+ Get your API key from the Dtapline dashboard:
168
+
169
+ 1. Navigate to your project settings
170
+ 2. Go to "API Keys" tab
171
+ 3. Click "Generate New Key"
172
+ 4. Copy the key (it will only be shown once!)
173
+ 5. Store it securely in your CI/CD secrets
174
+
175
+ API keys should have `deployments:write` scope.
176
+
177
+ ## Examples
178
+
179
+ ### Successful Deployment
180
+
181
+ ```bash
182
+ dtapline deploy production api-gateway a1b2c3d \
183
+ --api-key cm_xxxxxxxxxxxxx \
184
+ --git-tag v1.5.0 \
185
+ --deployed-by "Jenkins" \
186
+ --status success
187
+ ```
188
+
189
+ ### Failed Deployment
190
+
191
+ ```bash
192
+ dtapline deploy staging frontend e4f5g6h \
193
+ --api-key cm_xxxxxxxxxxxxx \
194
+ --status failed \
195
+ --build-url https://jenkins.company.com/job/frontend/123
196
+ ```
197
+
198
+ ### Rollback
199
+
200
+ ```bash
201
+ dtapline deploy production database i7j8k9l \
202
+ --api-key cm_xxxxxxxxxxxxx \
203
+ --git-tag v1.4.9 \
204
+ --status rolled_back \
205
+ --release-notes "Rolling back due to performance issues"
206
+ ```
207
+
208
+ ## Troubleshooting
209
+
210
+ ### "API key is required"
211
+
212
+ Make sure you either:
213
+ - Pass `--api-key` flag
214
+ - Set `DTAPLINE_API_KEY` environment variable
215
+
216
+ ### "Failed to report deployment"
217
+
218
+ Check:
219
+ - API key is valid and not expired
220
+ - API key has `deployments:write` scope
221
+ - Server URL is correct
222
+ - Network connectivity to Dtapline API server
223
+ - Project exists in Dtapline
224
+
225
+ ### View detailed errors
226
+
227
+ The CLI automatically logs errors to stderr. Check your CI/CD logs for details.
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ # Install dependencies
233
+ pnpm install
234
+
235
+ # Build
236
+ pnpm build
237
+
238
+ # Type check
239
+ pnpm check
240
+
241
+ # Run locally
242
+ pnpm dev deploy production test-service abc123 --api-key test
243
+
244
+ # Or after building
245
+ node bin/dtapline.js deploy production test-service abc123 --api-key test
246
+ ```
247
+
248
+ ## License
249
+
250
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/index.js"