Skip to content

Commit 8825e39

Browse files
committed
chore: resolve lint issues
1 parent 35e7028 commit 8825e39

File tree

9 files changed

+42
-46
lines changed

9 files changed

+42
-46
lines changed

cmd/assistant.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ are best done through the Vapi dashboard at https://dashboard.vapi.ai`,
201201
},
202202
}
203203

204+
// nolint:dupl // Delete commands follow a similar pattern across resources
204205
var deleteAssistantCmd = &cobra.Command{
205206
Use: "delete [assistant-id]",
206207
Short: "Delete an assistant",

cmd/campaign.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ var campaignGetCmd = &cobra.Command{
316316
fmt.Printf("Created: %s\n", campaign.CreatedAt.Format("2006-01-02 15:04:05"))
317317
fmt.Printf("Updated: %s\n", campaign.UpdatedAt.Format("2006-01-02 15:04:05"))
318318

319-
if campaign.Customers != nil && len(campaign.Customers) > 0 {
319+
if len(campaign.Customers) > 0 {
320320
fmt.Printf("\nCustomers: %d\n", len(campaign.Customers))
321321
}
322322

@@ -372,7 +372,7 @@ var campaignUpdateCmd = &cobra.Command{
372372
return nil
373373
}
374374

375-
fmt.Println("Campaign update cancelled.")
375+
fmt.Println("Campaign update canceled.")
376376
return nil
377377
}
378378

@@ -403,7 +403,7 @@ var campaignDeleteCmd = &cobra.Command{
403403
}
404404

405405
if !confirm {
406-
fmt.Println("Deletion cancelled.")
406+
fmt.Println("Deletion canceled.")
407407
return nil
408408
}
409409

cmd/workflow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ are best done through the Vapi dashboard at https://dashboard.vapi.ai`,
197197
},
198198
}
199199

200+
// nolint:dupl // Delete commands follow a similar pattern across resources
200201
var deleteWorkflowCmd = &cobra.Command{
201202
Use: "delete [workflow-id]",
202203
Short: "Delete a workflow",

pkg/auth/auth.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,14 @@ func generateRandomState() (string, error) {
280280
}
281281

282282
func openBrowser(targetURL string) error {
283-
var cmd string
284-
var args []string
285-
286283
switch runtime.GOOS {
287284
case "windows":
288-
cmd = "cmd"
289-
args = []string{"/c", "start", targetURL}
285+
return exec.Command("cmd", "/c", "start", targetURL).Start()
290286
case "darwin":
291-
cmd = "open"
292-
args = []string{targetURL}
287+
return exec.Command("open", targetURL).Start()
293288
default: // Linux and others
294-
cmd = "xdg-open"
295-
args = []string{targetURL}
289+
return exec.Command("xdg-open", targetURL).Start()
296290
}
297-
298-
return exec.Command(cmd, args...).Start()
299291
}
300292

301293
// Login performs the browser-based authentication flow

pkg/integrations/detector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ func DetectProject(projectPath string) (*ProjectInfo, error) {
9898
project.Framework = FrameworkGolang
9999
project.ProjectType = ProjectTypeBackend
100100
// Try to read Go version from go.mod
101-
if data, err := os.ReadFile(filepath.Join(projectPath, "go.mod")); err == nil {
101+
goModPath := filepath.Clean(filepath.Join(projectPath, "go.mod"))
102+
if data, err := os.ReadFile(goModPath); err == nil {
102103
// Simple version extraction (could be improved)
103104
content := string(data)
104105
if content != "" {
@@ -170,7 +171,7 @@ func DetectProject(projectPath string) (*ProjectInfo, error) {
170171
}
171172

172173
// If no backend/mobile markers found, check for Node.js/frontend projects
173-
packageJSONPath := filepath.Join(projectPath, "package.json")
174+
packageJSONPath := filepath.Clean(filepath.Join(projectPath, "package.json"))
174175
if _, err := os.Stat(packageJSONPath); err == nil {
175176
// Read and parse package.json
176177
data, err := os.ReadFile(packageJSONPath)

pkg/integrations/golang.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
func GenerateGoIntegration(projectPath string, info *ProjectInfo) error {
2929
// Create examples directory
3030
examplesDir := filepath.Join(projectPath, "examples", "vapi")
31-
if err := os.MkdirAll(examplesDir, 0o755); err != nil {
31+
if err := os.MkdirAll(examplesDir, 0o750); err != nil {
3232
return fmt.Errorf("failed to create examples directory: %w", err)
3333
}
3434

@@ -166,7 +166,7 @@ func makePhoneCall(client *vapi.Client, assistantID, phoneNumber string) {
166166
}
167167
`
168168

169-
return os.WriteFile(filepath.Join(dir, "basic_example.go"), []byte(content), 0o644)
169+
return os.WriteFile(filepath.Join(dir, "basic_example.go"), []byte(content), 0o600)
170170
}
171171

172172
func generateGoHTTPExample(dir string) error {
@@ -357,7 +357,7 @@ func handleVapiWebhook(w http.ResponseWriter, r *http.Request) {
357357
}
358358
`
359359

360-
return os.WriteFile(filepath.Join(dir, "http_example.go"), []byte(content), 0o644)
360+
return os.WriteFile(filepath.Join(dir, "http_example.go"), []byte(content), 0o600)
361361
}
362362

363363
func generateGoGinExample(dir string) error {
@@ -526,7 +526,7 @@ func handleHealth(c *gin.Context) {
526526
}
527527
`
528528

529-
return os.WriteFile(filepath.Join(dir, "gin_example.go"), []byte(content), 0o644)
529+
return os.WriteFile(filepath.Join(dir, "gin_example.go"), []byte(content), 0o600)
530530
}
531531

532532
func generateGoEnvTemplate(projectPath string) error {
@@ -539,5 +539,5 @@ VAPI_ASSISTANT_ID=your_assistant_id_here
539539
PORT=8080
540540
`
541541

542-
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o644)
542+
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o600)
543543
}

pkg/integrations/node.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
// GenerateNodeIntegration generates SDK examples and configuration for Node.js/TypeScript projects
2828
func GenerateNodeIntegration(projectPath string, info *ProjectInfo) error {
2929
examplesDir := filepath.Join(projectPath, "vapi-examples")
30-
if err := os.MkdirAll(examplesDir, 0o755); err != nil {
30+
if err := os.MkdirAll(examplesDir, 0o750); err != nil {
3131
return fmt.Errorf("failed to create examples directory: %w", err)
3232
}
3333

@@ -158,7 +158,7 @@ async function main() {
158158
main().catch(console.error);
159159
`
160160

161-
return os.WriteFile(filepath.Join(dir, "basic-example.js"), []byte(content), 0o644)
161+
return os.WriteFile(filepath.Join(dir, "basic-example.js"), []byte(content), 0o600)
162162
}
163163

164164
func generateNodeJSExpressExample(dir string) error {
@@ -299,7 +299,7 @@ app.listen(PORT, () => {
299299
});
300300
`
301301

302-
return os.WriteFile(filepath.Join(dir, "express-example.js"), []byte(content), 0o644)
302+
return os.WriteFile(filepath.Join(dir, "express-example.js"), []byte(content), 0o600)
303303
}
304304

305305
func generateNodeTSBasicExample(dir string) error {
@@ -402,7 +402,7 @@ async function main() {
402402
main().catch(console.error);
403403
`
404404

405-
return os.WriteFile(filepath.Join(dir, "basic-example.ts"), []byte(content), 0o644)
405+
return os.WriteFile(filepath.Join(dir, "basic-example.ts"), []byte(content), 0o600)
406406
}
407407

408408
func generateNodeTSExpressExample(dir string) error {
@@ -557,7 +557,7 @@ app.listen(PORT, () => {
557557
});
558558
`
559559

560-
return os.WriteFile(filepath.Join(dir, "express-example.ts"), []byte(content), 0o644)
560+
return os.WriteFile(filepath.Join(dir, "express-example.ts"), []byte(content), 0o600)
561561
}
562562

563563
func generateNodeTSFastifyExample(dir string) error {
@@ -724,7 +724,7 @@ const start = async () => {
724724
start();
725725
`
726726

727-
return os.WriteFile(filepath.Join(dir, "fastify-example.ts"), []byte(content), 0o644)
727+
return os.WriteFile(filepath.Join(dir, "fastify-example.ts"), []byte(content), 0o600)
728728
}
729729

730730
func generateNodeEnvTemplate(projectPath string) error {
@@ -740,5 +740,5 @@ PORT=3000
740740
VAPI_WEBHOOK_URL=https://your-domain.com/webhook/vapi
741741
`
742742

743-
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o644)
743+
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o600)
744744
}

pkg/integrations/python.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
// GeneratePythonIntegration generates SDK examples and configuration for Python projects
2828
func GeneratePythonIntegration(projectPath string, info *ProjectInfo) error {
2929
examplesDir := filepath.Join(projectPath, "vapi_examples")
30-
if err := os.MkdirAll(examplesDir, 0o755); err != nil {
30+
if err := os.MkdirAll(examplesDir, 0o750); err != nil {
3131
return fmt.Errorf("failed to create examples directory: %w", err)
3232
}
3333

@@ -151,7 +151,7 @@ if __name__ == "__main__":
151151
main()
152152
`
153153

154-
return os.WriteFile(filepath.Join(dir, "basic_example.py"), []byte(content), 0o644)
154+
return os.WriteFile(filepath.Join(dir, "basic_example.py"), []byte(content), 0o600)
155155
}
156156

157157
func generatePythonFlaskExample(dir string) error {
@@ -288,7 +288,7 @@ if __name__ == '__main__':
288288
app.run(debug=True, port=5000)
289289
`
290290

291-
return os.WriteFile(filepath.Join(dir, "flask_example.py"), []byte(content), 0o644)
291+
return os.WriteFile(filepath.Join(dir, "flask_example.py"), []byte(content), 0o600)
292292
}
293293

294294
func generatePythonFastAPIExample(dir string) error {
@@ -436,7 +436,7 @@ if __name__ == "__main__":
436436
uvicorn.run(app, host="0.0.0.0", port=8000)
437437
`
438438

439-
return os.WriteFile(filepath.Join(dir, "fastapi_example.py"), []byte(content), 0o644)
439+
return os.WriteFile(filepath.Join(dir, "fastapi_example.py"), []byte(content), 0o600)
440440
}
441441

442442
func generatePythonEnvTemplate(projectPath string) error {
@@ -449,7 +449,7 @@ VAPI_ASSISTANT_ID=your_assistant_id_here
449449
VAPI_WEBHOOK_URL=https://your-domain.com/webhook/vapi
450450
`
451451

452-
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o644)
452+
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o600)
453453
}
454454

455455
func generatePythonRequirements(projectPath string) error {
@@ -467,5 +467,5 @@ python-dotenv>=1.0.0
467467

468468
// Check if requirements.txt already exists
469469
reqPath := filepath.Join(projectPath, "requirements-vapi.txt")
470-
return os.WriteFile(reqPath, []byte(content), 0o644)
470+
return os.WriteFile(reqPath, []byte(content), 0o600)
471471
}

pkg/integrations/react.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func DetectReactProject(projectPath string) (*ReactProject, error) {
5050
}
5151

5252
// Read and parse package.json
53+
packageJSONPath = filepath.Clean(packageJSONPath)
5354
data, err := os.ReadFile(packageJSONPath)
5455
if err != nil {
5556
return nil, fmt.Errorf("failed to read package.json: %w", err)
@@ -172,7 +173,7 @@ func (rp *ReactProject) GenerateVapiComponents() error {
172173
}
173174

174175
componentsDir := filepath.Join(rp.Path, srcDir, "components", "vapi")
175-
if err := os.MkdirAll(componentsDir, 0o755); err != nil {
176+
if err := os.MkdirAll(componentsDir, 0o750); err != nil {
176177
return fmt.Errorf("failed to create components directory: %w", err)
177178
}
178179

@@ -186,7 +187,7 @@ func (rp *ReactProject) GenerateVapiComponents() error {
186187

187188
hookContent := rp.generateVapiHook()
188189
hookPath := filepath.Join(componentsDir, hookFile)
189-
if err := os.WriteFile(hookPath, []byte(hookContent), 0o644); err != nil {
190+
if err := os.WriteFile(hookPath, []byte(hookContent), 0o600); err != nil {
190191
return fmt.Errorf("failed to write Vapi hook: %w", err)
191192
}
192193

@@ -200,7 +201,7 @@ func (rp *ReactProject) GenerateVapiComponents() error {
200201

201202
componentContent := rp.generateVapiComponent()
202203
componentPath := filepath.Join(componentsDir, componentFile)
203-
if err := os.WriteFile(componentPath, []byte(componentContent), 0o644); err != nil {
204+
if err := os.WriteFile(componentPath, []byte(componentContent), 0o600); err != nil {
204205
return fmt.Errorf("failed to write Vapi component: %w", err)
205206
}
206207

@@ -214,7 +215,7 @@ func (rp *ReactProject) GenerateVapiComponents() error {
214215

215216
exampleContent := rp.generateVapiExample()
216217
examplePath := filepath.Join(componentsDir, exampleFile)
217-
if err := os.WriteFile(examplePath, []byte(exampleContent), 0o644); err != nil {
218+
if err := os.WriteFile(examplePath, []byte(exampleContent), 0o600); err != nil {
218219
return fmt.Errorf("failed to write Vapi example: %w", err)
219220
}
220221

@@ -244,7 +245,7 @@ NEXT_PUBLIC_VAPI_ASSISTANT_ID=your_assistant_id_here
244245
`
245246
}
246247

247-
if err := os.WriteFile(envPath, []byte(envContent), 0o644); err != nil {
248+
if err := os.WriteFile(envPath, []byte(envContent), 0o600); err != nil {
248249
return fmt.Errorf("failed to create .env.example: %w", err)
249250
}
250251

@@ -259,7 +260,7 @@ func (rp *ReactProject) savePackageJSON() error {
259260
}
260261

261262
packageJSONPath := filepath.Join(rp.Path, "package.json")
262-
return os.WriteFile(packageJSONPath, data, 0o644)
263+
return os.WriteFile(packageJSONPath, data, 0o600)
263264
}
264265

265266
func (rp *ReactProject) generateVapiHook() string {
@@ -760,10 +761,10 @@ func GenerateReactIntegration(projectPath string, info *ProjectInfo) error {
760761
}
761762

762763
// Create directories if they don't exist
763-
if err := os.MkdirAll(componentsDir, 0o755); err != nil {
764+
if err := os.MkdirAll(componentsDir, 0o750); err != nil {
764765
return fmt.Errorf("failed to create components directory: %w", err)
765766
}
766-
if err := os.MkdirAll(hooksDir, 0o755); err != nil {
767+
if err := os.MkdirAll(hooksDir, 0o750); err != nil {
767768
return fmt.Errorf("failed to create hooks directory: %w", err)
768769
}
769770

@@ -940,7 +941,7 @@ export const useVapi = (config) => {
940941
}
941942

942943
filename := fmt.Sprintf("useVapi.%s", ext)
943-
return os.WriteFile(filepath.Join(dir, filename), []byte(content), 0o644)
944+
return os.WriteFile(filepath.Join(dir, filename), []byte(content), 0o600)
944945
}
945946

946947
// generateVapiButton creates the VapiButton component
@@ -1149,7 +1150,7 @@ export const VapiButton = ({
11491150
}
11501151

11511152
filename := fmt.Sprintf("VapiButton.%s", ext)
1152-
return os.WriteFile(filepath.Join(dir, filename), []byte(content), 0o644)
1153+
return os.WriteFile(filepath.Join(dir, filename), []byte(content), 0o600)
11531154
}
11541155

11551156
// generateVapiExample creates an example component showing Vapi usage
@@ -1208,7 +1209,7 @@ export const VapiExample = () => {
12081209
}
12091210

12101211
filename := fmt.Sprintf("VapiExample.%s", ext)
1211-
return os.WriteFile(filepath.Join(dir, filename), []byte(content), 0o644)
1212+
return os.WriteFile(filepath.Join(dir, filename), []byte(content), 0o600)
12121213
}
12131214

12141215
// generateEnvTemplate creates environment template file
@@ -1229,5 +1230,5 @@ func generateEnvTemplate(projectPath string) error {
12291230
# %sVAPI_BASE_URL=https://api.vapi.ai
12301231
`, envPrefix, envPrefix, envPrefix)
12311232

1232-
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o644)
1233+
return os.WriteFile(filepath.Join(projectPath, ".env.example"), []byte(content), 0o600)
12331234
}

0 commit comments

Comments
 (0)