needware-cli 1.5.23 → 1.5.26

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
37
  secret_names: [placeholder],
40
- requires_approval: true,
41
- message: '密钥等待用户提供值',
42
- instructions: `请在 Supabase 项目设置中添加此密钥,或使用 Supabase CLI: supabase secrets set ${placeholder}=your_value_here`
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,aAAa,CAAC,KAAK,E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
1
  {
2
2
  "name": "needware-cli",
3
- "version": "1.5.23",
3
+ "version": "1.5.26",
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
 
@@ -31,9 +30,18 @@ Check if Supabase is already integrated:
31
30
  - Suggest: "Please enable Supabase first by saying 'Enable Cloud' or use the supabase-integration skill."
32
31
  - Do NOT proceed with Resend setup until Supabase is properly configured
33
32
 
34
- **Step 3: Verify Edge Functions Support**
33
+ **Step 3: Add Resend API Key Secret**
35
34
 
36
- Once Supabase is confirmed:
35
+ Once Supabase is confirmed integrated:
36
+ 1. Call `add-secret` tool to add the Resend API key
37
+ 2. The tool will prompt user to add the `RESEND_API_KEY` secret
38
+ 3. Wait for user confirmation: `needware tool use: Approved`
39
+ 4. Proceed to next step only after Approved
40
+
41
+
42
+ **Step 4: Verify Edge Functions Support**
43
+
44
+ Once Supabase is confirmed and Resend API key secret is added:
37
45
  - Check if `supabase/functions/` directory exists
38
46
  - If not, create the directory structure
39
47
  - Proceed with Resend Edge Function creation
@@ -85,15 +93,7 @@ import { Resend } from "https://esm.sh/resend@2.0.0";
85
93
  const resend = new Resend(Deno.env.get("RESEND_API_KEY"));
86
94
  ```
87
95
 
88
- **Step 2: Configure Environment Variables**
89
-
90
- Add to `/supabase/.env.local`:
91
-
92
- ```env
93
- RESEND_API_KEY=re_your_api_key_here
94
- ```
95
-
96
- **Step 3: CORS Headers Setup**
96
+ **Step 2: CORS Headers Setup**
97
97
 
98
98
  Always include CORS headers for client-side invocation:
99
99
 
@@ -561,80 +561,6 @@ for (let i = 0; i < recipients.length; i += batchSize) {
561
561
  - Include sensitive data in emails
562
562
  - Allow arbitrary email sending
563
563
 
564
- ## Debugging
565
-
566
- ### Common Issues
567
-
568
- **1. Email not received**:
569
- - Check spam/junk folder
570
- - Verify recipient email address
571
- - Check Resend Dashboard for delivery status
572
- - Verify sender domain configuration
573
-
574
- **2. API Key errors**:
575
- - Verify `RESEND_API_KEY` in environment variables
576
- - Check API key is active in Resend Dashboard
577
- - Ensure proper Deno.env.get() usage
578
-
579
- **3. CORS errors**:
580
- - Verify CORS headers are included
581
- - Handle OPTIONS requests
582
- - Check browser console for specific errors
583
-
584
- **4. Function timeout**:
585
- - Reduce batch size
586
- - Optimize email sending logic
587
- - Check for blocking operations
588
-
589
- ### Logging
590
-
591
- Add comprehensive logging:
592
-
593
- ```typescript
594
- console.log("Sending email to:", recipient.email);
595
- console.log("Email response:", emailResponse);
596
- console.error("Error sending email:", error);
597
- ```
598
-
599
- ### Testing
600
-
601
- Test Edge Function locally:
602
-
603
- ```bash
604
- supabase functions serve send-email --env-file supabase/.env.local
605
- ```
606
-
607
- Test with curl:
608
-
609
- ```bash
610
- curl -i --location --request POST 'http://localhost:54321/functions/v1/send-email' \
611
- --header 'Authorization: Bearer YOUR_ANON_KEY' \
612
- --header 'Content-Type: application/json' \
613
- --data '{"to":"test@example.com","subject":"Test","message":"Hello"}'
614
- ```
615
-
616
- ## Project Structure
617
-
618
- ```
619
- project-root/
620
- ├── supabase/
621
- │ ├── functions/
622
- │ │ ├── send-email/
623
- │ │ │ └── index.ts # Basic email sending
624
- │ │ ├── send-alert-email/
625
- │ │ │ └── index.ts # Alert emails
626
- │ │ ├── send-welcome-email/
627
- │ │ │ └── index.ts # Welcome emails
628
- │ │ └── send-notification/
629
- │ │ └── index.ts # Notification emails
630
- │ └── .env.local # RESEND_API_KEY
631
- ├── src/
632
- │ ├── lib/
633
- │ │ └── supabase.ts # Supabase Client
634
- │ └── components/
635
- │ └── EmailForm.tsx # Email sending UI
636
- └── .env # Frontend env vars
637
- ```
638
564
 
639
565
  ## Additional Resources
640
566
 
@@ -642,16 +568,3 @@ project-root/
642
568
  - [Resend API Reference](https://resend.com/docs/api-reference)
643
569
  - [Email Templates Best Practices](https://resend.com/docs/send-with-react)
644
570
  - [Supabase Edge Functions Guide](https://supabase.com/docs/guides/functions)
645
-
646
- ## Migration Checklist
647
-
648
- When moving to production:
649
-
650
- - [ ] Register custom domain in Resend Dashboard
651
- - [ ] Update sender email from `onboarding@resend.dev` to custom domain
652
- - [ ] Configure SPF, DKIM, and DMARC records
653
- - [ ] Update `RESEND_API_KEY` with production key
654
- - [ ] Test all email flows
655
- - [ ] Set up email delivery monitoring
656
- - [ ] Implement unsubscribe functionality (if needed)
657
- - [ ] Add email preference management