Skip to content

Commit

Permalink
fix license keys
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwidlund committed Feb 7, 2025
1 parent 12b9610 commit 2aca3c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polar-migrate",
"version": "0.1.3",
"version": "0.1.4",
"license": "Apache-2.0",
"bin": "bin/cli.js",
"type": "module",
Expand All @@ -17,7 +17,7 @@
"dependencies": {
"@inkjs/ui": "^2.0.0",
"@lemonsqueezy/lemonsqueezy.js": "^4.0.0",
"@polar-sh/sdk": "^0.22.2",
"@polar-sh/sdk": "^0.24.0",
"@types/cross-spawn": "^6.0.6",
"cross-spawn": "^7.0.3",
"ink": "^4.4.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions src/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import type { Polar } from "@polar-sh/sdk";
import type { Timeframe } from "@polar-sh/sdk/models/components/benefitlicensekeyexpirationproperties.js";
import type { BenefitLicenseKeyExpirationProperties } from "@polar-sh/sdk/models/components/benefitlicensekeyexpirationproperties.js";
import type { Interval } from "@polar-sh/sdk/models/components/interval.js";
import type { FileRead } from "@polar-sh/sdk/models/components/listresourcefileread.js";
import type { Organization } from "@polar-sh/sdk/models/components/organization.js";
import type { Product } from "@polar-sh/sdk/models/components/product.js";
Expand All @@ -24,21 +23,18 @@ import type { ProductRecurringCreate } from "@polar-sh/sdk/models/components/pro
import mime from "mime-types";
import { uploadFailedMessage, uploadMessage } from "./ui/upload.js";
import { Upload } from "./upload.js";
import type { SubscriptionRecurringInterval } from "@polar-sh/sdk/models/components/subscriptionrecurringinterval.js";

const resolveInterval = (
interval: ListVariants["data"][number]["attributes"]["interval"],
): Interval => {
): SubscriptionRecurringInterval => {
switch (interval) {
case "day":
return "day";
case "week":
return "week";
case "month":
return "month";
case "year":
return "year";
default:
throw new Error(`Unknown interval: ${interval}`);
return "month";
}
};

Expand Down Expand Up @@ -161,12 +157,12 @@ export const createProduct = async (
expires: variant.attributes.is_license_length_unlimited
? undefined
: resolveLicenseKeyExpiration(variant),
activations: variant.attributes.license_activation_limit
? {
activations: variant.attributes.is_license_limit_unlimited
? undefined
: {
limit: variant.attributes.license_activation_limit,
enableCustomerAdmin: true,
}
: undefined,
},
},
organizationId: organization.id,
});
Expand Down

0 comments on commit 2aca3c8

Please sign in to comment.