cleo-dev 0.1.3 → 0.1.4

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/dist/cli.js CHANGED
@@ -55718,7 +55718,7 @@ var {
55718
55718
  } = import_index.default;
55719
55719
 
55720
55720
  // package.json
55721
- var version = "0.1.3";
55721
+ var version = "0.1.4";
55722
55722
 
55723
55723
  // src/commands/init.ts
55724
55724
  init_cjs_shims();
@@ -131403,14 +131403,29 @@ async function startDevServer(options) {
131403
131403
  const { name: name16, email: email5 } = req.body || {};
131404
131404
  debug.log(`[Autumn Sync] Syncing customer ${userId.slice(0, 10)}... name: ${name16}, email: ${email5}`);
131405
131405
  try {
131406
- await Autumn.attach({
131407
- customer_id: userId,
131408
- product_id: "free",
131409
- customer_data: {
131410
- ...name16 && { name: name16 },
131411
- ...email5 && { email: email5 }
131412
- }
131413
- });
131406
+ let customerExists = false;
131407
+ let hasProducts = false;
131408
+ try {
131409
+ const customer = await Autumn.customers.get(userId);
131410
+ customerExists = !!customer.data;
131411
+ hasProducts = customer.data?.products?.some(
131412
+ (p) => p.status === "active" || p.status === "scheduled"
131413
+ ) ?? false;
131414
+ debug.log(`[Autumn Sync] Customer exists: ${customerExists}, has products: ${hasProducts}`);
131415
+ } catch {
131416
+ debug.log(`[Autumn Sync] Customer doesn't exist yet`);
131417
+ }
131418
+ if (!customerExists || !hasProducts) {
131419
+ debug.log(`[Autumn Sync] Attaching free plan for new customer`);
131420
+ await Autumn.attach({
131421
+ customer_id: userId,
131422
+ product_id: "free",
131423
+ customer_data: {
131424
+ ...name16 && { name: name16 },
131425
+ ...email5 && { email: email5 }
131426
+ }
131427
+ });
131428
+ }
131414
131429
  if (name16 || email5) {
131415
131430
  try {
131416
131431
  await Autumn.customers.update(userId, {
package/dist/index.js CHANGED
@@ -123010,14 +123010,29 @@ async function startDevServer(options) {
123010
123010
  const { name: name16, email: email5 } = req.body || {};
123011
123011
  debug.log(`[Autumn Sync] Syncing customer ${userId.slice(0, 10)}... name: ${name16}, email: ${email5}`);
123012
123012
  try {
123013
- await Autumn.attach({
123014
- customer_id: userId,
123015
- product_id: "free",
123016
- customer_data: {
123017
- ...name16 && { name: name16 },
123018
- ...email5 && { email: email5 }
123019
- }
123020
- });
123013
+ let customerExists = false;
123014
+ let hasProducts = false;
123015
+ try {
123016
+ const customer = await Autumn.customers.get(userId);
123017
+ customerExists = !!customer.data;
123018
+ hasProducts = customer.data?.products?.some(
123019
+ (p) => p.status === "active" || p.status === "scheduled"
123020
+ ) ?? false;
123021
+ debug.log(`[Autumn Sync] Customer exists: ${customerExists}, has products: ${hasProducts}`);
123022
+ } catch {
123023
+ debug.log(`[Autumn Sync] Customer doesn't exist yet`);
123024
+ }
123025
+ if (!customerExists || !hasProducts) {
123026
+ debug.log(`[Autumn Sync] Attaching free plan for new customer`);
123027
+ await Autumn.attach({
123028
+ customer_id: userId,
123029
+ product_id: "free",
123030
+ customer_data: {
123031
+ ...name16 && { name: name16 },
123032
+ ...email5 && { email: email5 }
123033
+ }
123034
+ });
123035
+ }
123021
123036
  if (name16 || email5) {
123022
123037
  try {
123023
123038
  await Autumn.customers.update(userId, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cleo-dev",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "The AI developer tool for React",
5
5
  "preferGlobal": true,
6
6
  "main": "dist/index.js",