needware-cli 1.5.25 → 1.5.27

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.
@@ -1 +1 @@
1
- {"version":3,"file":"add-secret-tool.d.ts","sourceRoot":"","sources":["../../src/tools/add-secret-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,aAAc,SAAQ,QAAQ;IACzC,UAAU,EAAE,cAAc,CAaxB;IAEF,YAAY;;;IAMN,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CA4B/D"}
1
+ {"version":3,"file":"add-secret-tool.d.ts","sourceRoot":"","sources":["../../src/tools/add-secret-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,aAAc,SAAQ,QAAQ;IACzC,UAAU,EAAE,cAAc,CAaxB;IAEF,YAAY;;;IAMN,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CAqB/D"}
@@ -30,21 +30,17 @@ export class AddSecretTool extends BaseTool {
30
30
  // 验证输入参数
31
31
  this.validateInput(input, ['placeholder']);
32
32
  const { placeholder } = input;
33
- console.log(chalk.blue(`\n🔐 准备添加密钥: ${placeholder}...\n`));
34
- console.log(chalk.green(`\n✓ 密钥 "${placeholder}" 准备就绪\n`));
35
33
  // 构建返回的 JSON 数据
36
34
  const resultData = {
37
35
  placeholder: placeholder,
38
36
  secret_added: false,
39
- secret_names: [placeholder],
40
- requires_approval: true,
41
- message: '密钥等待用户提供值',
42
- instructions: `请在 Supabase 项目设置中添加此密钥,或使用 Supabase CLI: supabase secrets set ${placeholder}=your_value_here`
37
+ secret_name: placeholder,
38
+ requires_approval: false,
43
39
  };
44
40
  return this.successWithContent(JSON.stringify(resultData, null, 2));
45
41
  }
46
42
  catch (error) {
47
- const message = error instanceof Error ? error.message : '生成密钥请求失败';
43
+ const message = error instanceof Error ? error.message : 'Add secret request failed';
48
44
  console.log(chalk.red(`\n✖ ${message}\n`));
49
45
  return this.errorWithContent(message);
50
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"add-secret-tool.js","sourceRoot":"","sources":["../../src/tools/add-secret-tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACzC,UAAU,GAAmB;QAC3B,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,uFAAuF;QACpG,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,4EAA4E;iBAC1F;aACF;YACD,QAAQ,EAAE,CAAC,aAAa,CAAC;SAC1B;KACF,CAAC;IAEF,YAAY;QACV,OAAO;YACL,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sDAAsD,CAAC;SAChG,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAA0B;QACtC,IAAI,CAAC;YACH,SAAS;YACT,IAAI,CAAC,aAA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
1
1
  {
2
2
  "name": "needware-cli",
3
- "version": "1.5.25",
3
+ "version": "1.5.27",
4
4
  "description": "一个功能强大的 Node.js 命令行工具",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,6 @@ Check if Supabase is already integrated:
17
17
  - `VITE_SUPABASE_PROJECT_ID`
18
18
  - `VITE_SUPABASE_PUBLISHABLE_KEY`
19
19
  - `VITE_SUPABASE_URL`
20
- - Check for `supabase/functions/` directory
21
20
 
22
21
  **Step 2: Handle Based on Status**
23
22
 
@@ -34,11 +33,10 @@ Check if Supabase is already integrated:
34
33
  **Step 3: Add Resend API Key Secret**
35
34
 
36
35
  Once Supabase is confirmed integrated:
37
- 1. Call `add-secret` tool to add the Resend API key to Supabase secrets
36
+ 1. Call `add-secret` tool to add the Resend API key
38
37
  2. The tool will prompt user to add the `RESEND_API_KEY` secret
39
38
  3. Wait for user confirmation: `needware tool use: Approved`
40
- 4. After approval, the secret will be added to Supabase Edge Functions environment
41
- 5. Proceed to next step only after successful secret addition
39
+ 4. Proceed to next step only after Approved
42
40
 
43
41
 
44
42
  **Step 4: Verify Edge Functions Support**
@@ -95,15 +93,7 @@ import { Resend } from "https://esm.sh/resend@2.0.0";
95
93
  const resend = new Resend(Deno.env.get("RESEND_API_KEY"));
96
94
  ```
97
95
 
98
- **Step 2: Configure Environment Variables**
99
-
100
- Add to `/supabase/.env.local`:
101
-
102
- ```env
103
- RESEND_API_KEY=re_your_api_key_here
104
- ```
105
-
106
- **Step 3: CORS Headers Setup**
96
+ **Step 2: CORS Headers Setup**
107
97
 
108
98
  Always include CORS headers for client-side invocation:
109
99
 
@@ -571,80 +561,6 @@ for (let i = 0; i < recipients.length; i += batchSize) {
571
561
  - Include sensitive data in emails
572
562
  - Allow arbitrary email sending
573
563
 
574
- ## Debugging
575
-
576
- ### Common Issues
577
-
578
- **1. Email not received**:
579
- - Check spam/junk folder
580
- - Verify recipient email address
581
- - Check Resend Dashboard for delivery status
582
- - Verify sender domain configuration
583
-
584
- **2. API Key errors**:
585
- - Verify `RESEND_API_KEY` in environment variables
586
- - Check API key is active in Resend Dashboard
587
- - Ensure proper Deno.env.get() usage
588
-
589
- **3. CORS errors**:
590
- - Verify CORS headers are included
591
- - Handle OPTIONS requests
592
- - Check browser console for specific errors
593
-
594
- **4. Function timeout**:
595
- - Reduce batch size
596
- - Optimize email sending logic
597
- - Check for blocking operations
598
-
599
- ### Logging
600
-
601
- Add comprehensive logging:
602
-
603
- ```typescript
604
- console.log("Sending email to:", recipient.email);
605
- console.log("Email response:", emailResponse);
606
- console.error("Error sending email:", error);
607
- ```
608
-
609
- ### Testing
610
-
611
- Test Edge Function locally:
612
-
613
- ```bash
614
- supabase functions serve send-email --env-file supabase/.env.local
615
- ```
616
-
617
- Test with curl:
618
-
619
- ```bash
620
- curl -i --location --request POST 'http://localhost:54321/functions/v1/send-email' \
621
- --header 'Authorization: Bearer YOUR_ANON_KEY' \
622
- --header 'Content-Type: application/json' \
623
- --data '{"to":"test@example.com","subject":"Test","message":"Hello"}'
624
- ```
625
-
626
- ## Project Structure
627
-
628
- ```
629
- project-root/
630
- ├── supabase/
631
- │ ├── functions/
632
- │ │ ├── send-email/
633
- │ │ │ └── index.ts # Basic email sending
634
- │ │ ├── send-alert-email/
635
- │ │ │ └── index.ts # Alert emails
636
- │ │ ├── send-welcome-email/
637
- │ │ │ └── index.ts # Welcome emails
638
- │ │ └── send-notification/
639
- │ │ └── index.ts # Notification emails
640
- │ └── .env.local # RESEND_API_KEY
641
- ├── src/
642
- │ ├── lib/
643
- │ │ └── supabase.ts # Supabase Client
644
- │ └── components/
645
- │ └── EmailForm.tsx # Email sending UI
646
- └── .env # Frontend env vars
647
- ```
648
564
 
649
565
  ## Additional Resources
650
566
 
@@ -652,16 +568,3 @@ project-root/
652
568
  - [Resend API Reference](https://resend.com/docs/api-reference)
653
569
  - [Email Templates Best Practices](https://resend.com/docs/send-with-react)
654
570
  - [Supabase Edge Functions Guide](https://supabase.com/docs/guides/functions)
655
-
656
- ## Migration Checklist
657
-
658
- When moving to production:
659
-
660
- - [ ] Register custom domain in Resend Dashboard
661
- - [ ] Update sender email from `onboarding@resend.dev` to custom domain
662
- - [ ] Configure SPF, DKIM, and DMARC records
663
- - [ ] Update `RESEND_API_KEY` with production key
664
- - [ ] Test all email flows
665
- - [ ] Set up email delivery monitoring
666
- - [ ] Implement unsubscribe functionality (if needed)
667
- - [ ] Add email preference management