@devvit/cli 0.11.10 → 0.11.11-next-2025-03-13-4455a4ebd.0
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/commands/bundle/actor.js +1 -1
- package/dist/templates/app-settings/package.json +3 -3
- package/dist/templates/blocks-post/package.json +2 -2
- package/dist/templates/blocks-post-pro/package.json +2 -2
- package/dist/templates/empty/package.json +2 -2
- package/dist/templates/forms/package.json +2 -2
- package/dist/templates/image-uploads/package.json +2 -2
- package/dist/templates/intro-to-devvit/package.json +2 -2
- package/dist/templates/menu-action/package.json +2 -2
- package/dist/templates/payments/package.json +3 -3
- package/dist/templates/payments-web-view/package.json +3 -3
- package/dist/templates/pen/package.json +2 -2
- package/dist/templates/redis/package.json +2 -2
- package/dist/templates/triggers/package.json +2 -2
- package/dist/templates/web-view-post/package.json +2 -2
- package/dist/util/AppVersionUploader.d.ts.map +1 -1
- package/dist/util/AppVersionUploader.js +1 -1
- package/dist/util/payments/paymentsConfig.d.ts +4 -3
- package/dist/util/payments/paymentsConfig.d.ts.map +1 -1
- package/dist/util/payments/paymentsConfig.js +8 -6
- package/dist/util/payments/paymentsConfig.test.js +54 -168
- package/package.json +8 -8
|
@@ -46,7 +46,7 @@ _BundleActor_instances = new WeakSet(), _BundleActor_makeBundles = async functio
|
|
|
46
46
|
type = '.client';
|
|
47
47
|
}
|
|
48
48
|
if (products) {
|
|
49
|
-
bundle.paymentsConfig =
|
|
49
|
+
bundle.paymentsConfig = getPaymentsConfig(bundle, products, false);
|
|
50
50
|
}
|
|
51
51
|
await writeFile(path.join(this.projectRoot, distDirFilename, `${actorSpec.name}.bundle${type}.json`), JSON.stringify(Bundle.toJSON(bundle)));
|
|
52
52
|
if (bundle.metafile) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "app-settings-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@devvit/tsconfig": "0.11.
|
|
11
|
+
"@devvit/tsconfig": "0.11.11-dev",
|
|
12
12
|
"typescript": "4.9.3"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "experience-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "experience-pro-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test:unit": "vitest --run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@devvit/public-api": "0.11.
|
|
12
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"typescript": "5.3.2",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "empty-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "forms-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "image-uploads-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "intro-to-devvit",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "menu-action-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "payment-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/payments": "0.11.
|
|
9
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/payments": "0.11.11-dev",
|
|
9
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"typescript": "5.3.2"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "payments-web-view-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/payments": "0.11.
|
|
9
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/payments": "0.11.11-dev",
|
|
9
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "pen-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "redis-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "triggers-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"name": "web-view-template",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.11-dev",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@devvit/public-api": "0.11.
|
|
8
|
+
"@devvit/public-api": "0.11.11-dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"typescript": "5.3.2"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppVersionUploader.d.ts","sourceRoot":"","sources":["../../src/util/AppVersionUploader.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,MAAM,EAEX,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"AppVersionUploader.d.ts","sourceRoot":"","sources":["../../src/util/AppVersionUploader.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,MAAM,EAEX,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAMrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,qBAAa,kBAAkB;;gBAMjB,GAAG,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE;IAK5D,aAAa,CACjB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,aAAa,CAAC;QACzB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,EACD,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,cAAc,CAAC;CAkF3B"}
|
|
@@ -49,7 +49,7 @@ export class AppVersionUploader {
|
|
|
49
49
|
bundle.assetIds = assetMap ?? {};
|
|
50
50
|
bundle.webviewAssetIds = webViewAssetMap ?? {};
|
|
51
51
|
if (products) {
|
|
52
|
-
bundle.paymentsConfig =
|
|
52
|
+
bundle.paymentsConfig = getPaymentsConfig(bundle, products);
|
|
53
53
|
}
|
|
54
54
|
}));
|
|
55
55
|
ux.action.start(`Uploading new version "${appInfo.appSemver.toString()}" to Reddit`);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Bundle, PaymentsConfig } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
2
2
|
import type { Product } from '@devvit/shared-types/payments/Product.js';
|
|
3
|
+
export type JSONProduct = Omit<Product, 'metadata'> & Partial<Pick<Product, 'metadata'>>;
|
|
3
4
|
/**
|
|
4
5
|
* Reads Products from src/products.json
|
|
5
6
|
* @throws if products.json is malformed
|
|
6
7
|
*/
|
|
7
|
-
export declare function readProducts(projectRoot: string): Promise<
|
|
8
|
+
export declare function readProducts(projectRoot: string): Promise<JSONProduct[] | undefined>;
|
|
8
9
|
/**
|
|
9
10
|
* Validates product config and returns a PaymentsConfig
|
|
10
11
|
*
|
|
@@ -12,7 +13,7 @@ export declare function readProducts(projectRoot: string): Promise<Product[] | u
|
|
|
12
13
|
* note: this method is intentionally called outside of `this.createVersion` because it includes
|
|
13
14
|
* validation steps that should exit early should errors be thrown
|
|
14
15
|
*/
|
|
15
|
-
export declare function getPaymentsConfig(bundle: Readonly<Bundle>, products:
|
|
16
|
-
export declare function makePaymentsConfig(products: Readonly<
|
|
16
|
+
export declare function getPaymentsConfig(bundle: Readonly<Bundle>, products: JSONProduct[], verifyProductImgAssets?: boolean): PaymentsConfig;
|
|
17
|
+
export declare function makePaymentsConfig(products: Readonly<JSONProduct[]>): PaymentsConfig;
|
|
17
18
|
export declare function validateProductIcon(assetPath: string): void;
|
|
18
19
|
//# sourceMappingURL=paymentsConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentsConfig.d.ts","sourceRoot":"","sources":["../../../src/util/payments/paymentsConfig.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EACf,MAAM,kEAAkE,CAAC;AAI1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"paymentsConfig.d.ts","sourceRoot":"","sources":["../../../src/util/payments/paymentsConfig.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EACf,MAAM,kEAAkE,CAAC;AAI1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0CAA0C,CAAC;AAUxE,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAEzF;;;GAGG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,CAU1F;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACxB,QAAQ,EAAE,WAAW,EAAE,EACvB,sBAAsB,GAAE,OAAc,GACrC,cAAc,CAGhB;AAkGD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,cAAc,CAkBpF;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAyB3D"}
|
|
@@ -29,7 +29,7 @@ export async function readProducts(projectRoot) {
|
|
|
29
29
|
* note: this method is intentionally called outside of `this.createVersion` because it includes
|
|
30
30
|
* validation steps that should exit early should errors be thrown
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export function getPaymentsConfig(bundle, products, verifyProductImgAssets = true) {
|
|
33
33
|
checkProductsConfig(products, bundle, verifyProductImgAssets);
|
|
34
34
|
return makePaymentsConfig(products);
|
|
35
35
|
}
|
|
@@ -49,11 +49,13 @@ function checkProductsConfig(products, bundle, verifyProductImgAssets = true) {
|
|
|
49
49
|
throw new Error('You have a `products.json` with products, but your app does not handle payment processing of those products. Please refer to https://developers.reddit.com/docs/capabilities/payments for documentation to enable the payments feature.');
|
|
50
50
|
}
|
|
51
51
|
for (const product of products) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
if (product.metadata) {
|
|
53
|
+
const invalidKeys = filterToReservedDevvitMetadataKeys(Object.keys(product.metadata));
|
|
54
|
+
// Enforced here on the CLI and also on the server. Server processing is done too late for error
|
|
55
|
+
// messages to reach the end user, so doing here prior to upload.
|
|
56
|
+
if (invalidKeys.length > 0) {
|
|
57
|
+
throw new Error(`Products metadata cannot start with "devvit-". Invalid keys: ${invalidKeys.join(', ')}`);
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
const missingAssets = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { access, readFile } from 'node:fs/promises';
|
|
2
|
-
import { PaymentProcessorDefinition
|
|
2
|
+
import { PaymentProcessorDefinition } from '@devvit/protos/payments.js';
|
|
3
3
|
import { Bundle } from '@devvit/protos/types/devvit/plugin/buildpack/buildpack_common.js';
|
|
4
4
|
import { AccountingType } from '@devvit/shared-types/payments/Product.js';
|
|
5
5
|
import path from 'path';
|
|
@@ -8,7 +8,6 @@ vi.mock('node:fs/promises', () => ({
|
|
|
8
8
|
access: vi.fn().mockResolvedValue(void 0),
|
|
9
9
|
readFile: vi.fn().mockResolvedValue(''),
|
|
10
10
|
}));
|
|
11
|
-
const PROJECT_ROOT = '/path/to/project';
|
|
12
11
|
const MOCK_PRODUCTS_JSON = {
|
|
13
12
|
products: [
|
|
14
13
|
{
|
|
@@ -20,125 +19,54 @@ const MOCK_PRODUCTS_JSON = {
|
|
|
20
19
|
},
|
|
21
20
|
],
|
|
22
21
|
};
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
const MOCK_BUNDLE = {
|
|
23
|
+
code: '',
|
|
24
|
+
dependencies: {
|
|
25
|
+
hostname: '',
|
|
26
|
+
provides: [
|
|
27
|
+
{
|
|
28
|
+
definition: {
|
|
29
|
+
fullName: PaymentProcessorDefinition.fullName,
|
|
30
|
+
methods: [],
|
|
31
|
+
name: '',
|
|
32
|
+
version: '',
|
|
33
|
+
},
|
|
34
|
+
partitionsBy: [],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
uses: [],
|
|
38
|
+
},
|
|
39
|
+
assetIds: {},
|
|
40
|
+
webviewAssetIds: {},
|
|
41
|
+
};
|
|
42
|
+
describe('Read product.json', () => {
|
|
43
|
+
const PROJECT_ROOT = '/path/to/project';
|
|
44
|
+
it('does not return any products if the files does not exist', async () => {
|
|
26
45
|
vi.mocked(access).mockRejectedValueOnce(new Error('not found'));
|
|
27
46
|
const products = await readProducts(PROJECT_ROOT);
|
|
28
47
|
expect(products).toBeUndefined();
|
|
29
48
|
});
|
|
30
49
|
it('throws an error if products.json is not formatted properly', async () => {
|
|
31
|
-
const bundle = { assetIds: {}, code: '', webviewAssetIds: {} };
|
|
32
50
|
const products = [{ ...MOCK_PRODUCTS_JSON.products[0], price: 'not a number' }];
|
|
33
51
|
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(products));
|
|
34
52
|
await expect(() => readProducts(PROJECT_ROOT)).rejects.toThrowError('products.json validation error');
|
|
35
|
-
expect(bundle.paymentsConfig).toBeUndefined();
|
|
36
53
|
});
|
|
37
|
-
|
|
54
|
+
});
|
|
55
|
+
describe('Get payments config', () => {
|
|
56
|
+
it('throws an error if the bundle does not provide a PaymentProcessor', () => {
|
|
38
57
|
const bundle = { assetIds: {}, code: '', webviewAssetIds: {} };
|
|
39
|
-
|
|
40
|
-
vi.mocked(readFile).mockResolvedValueOnce(MOCK_PRODUCTS_JSON_STRING);
|
|
41
|
-
await expect(async () => {
|
|
42
|
-
const products = await readProducts(PROJECT_ROOT);
|
|
43
|
-
if (products) {
|
|
44
|
-
bundle.paymentsConfig = await getPaymentsConfig(bundle, products);
|
|
45
|
-
}
|
|
46
|
-
}).rejects.toThrowError('your app does not handle payment processing');
|
|
47
|
-
expect(bundle.paymentsConfig).toBeUndefined();
|
|
58
|
+
expect(() => getPaymentsConfig(bundle, MOCK_PRODUCTS_JSON.products)).toThrowError(/You have a `products\.json` with products, but your app does not handle payment processing of those products./);
|
|
48
59
|
});
|
|
49
|
-
it('
|
|
60
|
+
it('throws an error if the product images are not included in the assets', () => {
|
|
50
61
|
const productImage = 'doesnotexist.jpg';
|
|
51
|
-
const products = {
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
const bundle = {
|
|
55
|
-
code: '',
|
|
56
|
-
dependencies: {
|
|
57
|
-
hostname: '',
|
|
58
|
-
provides: [
|
|
59
|
-
{
|
|
60
|
-
definition: {
|
|
61
|
-
fullName: PaymentProcessorDefinition.fullName,
|
|
62
|
-
methods: [],
|
|
63
|
-
name: '',
|
|
64
|
-
version: '',
|
|
65
|
-
},
|
|
66
|
-
partitionsBy: [],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
uses: [],
|
|
70
|
-
},
|
|
71
|
-
assetIds: {
|
|
72
|
-
'exists.jpg': 'abc123',
|
|
73
|
-
},
|
|
74
|
-
webviewAssetIds: {},
|
|
75
|
-
};
|
|
76
|
-
vi.mocked(access).mockResolvedValueOnce();
|
|
77
|
-
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(products));
|
|
78
|
-
await expect(async () => {
|
|
79
|
-
const products = await readProducts(PROJECT_ROOT);
|
|
80
|
-
if (products) {
|
|
81
|
-
bundle.paymentsConfig = await getPaymentsConfig(bundle, products);
|
|
82
|
-
}
|
|
83
|
-
}).rejects.toThrowError(`Product images ${productImage} are not included in the assets`);
|
|
84
|
-
expect(bundle.paymentsConfig).toBeUndefined();
|
|
62
|
+
const products = [{ ...MOCK_PRODUCTS_JSON.products[0], images: { icon: productImage } }];
|
|
63
|
+
const bundle = { ...MOCK_BUNDLE, assetIds: { 'exists.jpg': 'abc123' } };
|
|
64
|
+
expect(() => getPaymentsConfig(bundle, products)).toThrowError(`Product images ${productImage} are not included in the assets`);
|
|
85
65
|
});
|
|
86
|
-
it('
|
|
87
|
-
|
|
88
|
-
assetIds: {},
|
|
89
|
-
code: '',
|
|
90
|
-
dependencies: {
|
|
91
|
-
hostname: '',
|
|
92
|
-
provides: [],
|
|
93
|
-
uses: [
|
|
94
|
-
{
|
|
95
|
-
typeName: PaymentsServiceDefinition.fullName,
|
|
96
|
-
name: '',
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
webviewAssetIds: {},
|
|
101
|
-
};
|
|
102
|
-
vi.mocked(access).mockResolvedValueOnce();
|
|
103
|
-
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify({ products: [] }));
|
|
104
|
-
await expect(async () => {
|
|
105
|
-
const products = await readProducts(PROJECT_ROOT);
|
|
106
|
-
if (products) {
|
|
107
|
-
bundle.paymentsConfig = await getPaymentsConfig(bundle, products);
|
|
108
|
-
}
|
|
109
|
-
}).rejects.toThrowError('you must specify products in the `src/products.json` config file');
|
|
110
|
-
expect(bundle.paymentsConfig).toBeUndefined();
|
|
111
|
-
});
|
|
112
|
-
it('injects products into the bundle if products.json is found and formatted properly', async () => {
|
|
113
|
-
const bundle = {
|
|
114
|
-
assetIds: {},
|
|
115
|
-
code: '',
|
|
116
|
-
dependencies: {
|
|
117
|
-
hostname: '',
|
|
118
|
-
provides: [
|
|
119
|
-
{
|
|
120
|
-
definition: {
|
|
121
|
-
fullName: PaymentProcessorDefinition.fullName,
|
|
122
|
-
methods: [],
|
|
123
|
-
name: '',
|
|
124
|
-
version: '',
|
|
125
|
-
},
|
|
126
|
-
partitionsBy: [],
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
uses: [],
|
|
130
|
-
},
|
|
131
|
-
webviewAssetIds: {},
|
|
132
|
-
};
|
|
133
|
-
vi.mocked(access).mockResolvedValueOnce();
|
|
134
|
-
vi.mocked(readFile).mockResolvedValueOnce(MOCK_PRODUCTS_JSON_STRING);
|
|
135
|
-
const products = await readProducts(PROJECT_ROOT);
|
|
136
|
-
if (products) {
|
|
137
|
-
bundle.paymentsConfig = await getPaymentsConfig(bundle, products);
|
|
138
|
-
}
|
|
139
|
-
expect(bundle.paymentsConfig).toStrictEqual(makePaymentsConfig(MOCK_PRODUCTS_JSON.products));
|
|
66
|
+
it('throws an error if no products are found ', () => {
|
|
67
|
+
expect(() => getPaymentsConfig(MOCK_BUNDLE, [])).toThrowError('you must specify products in the `src/products.json` config file');
|
|
140
68
|
});
|
|
141
|
-
it('throws error if a product has metadata starting with "devvit-"',
|
|
69
|
+
it('throws error if a product has metadata starting with "devvit-"', () => {
|
|
142
70
|
const invalidProduct = {
|
|
143
71
|
sku: 'product-1',
|
|
144
72
|
displayName: 'Product 1',
|
|
@@ -148,77 +76,35 @@ describe('Read and inject Bundle Products', () => {
|
|
|
148
76
|
'devvit-invalid': 'this breaks upload',
|
|
149
77
|
},
|
|
150
78
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
methods: [],
|
|
163
|
-
name: '',
|
|
164
|
-
version: '',
|
|
165
|
-
},
|
|
166
|
-
partitionsBy: [],
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
uses: [],
|
|
170
|
-
},
|
|
171
|
-
assetIds: {
|
|
172
|
-
'exists.jpg': 'abc123',
|
|
173
|
-
},
|
|
174
|
-
webviewAssetIds: {},
|
|
79
|
+
expect(() => getPaymentsConfig(MOCK_BUNDLE, [invalidProduct])).toThrowError('Products metadata cannot start with "devvit-". Invalid keys: devvit-invalid');
|
|
80
|
+
});
|
|
81
|
+
it('creates payments config products.json is found and formatted properly', () => {
|
|
82
|
+
expect(getPaymentsConfig(MOCK_BUNDLE, MOCK_PRODUCTS_JSON.products)).toStrictEqual(makePaymentsConfig(MOCK_PRODUCTS_JSON.products));
|
|
83
|
+
});
|
|
84
|
+
it('handles products without metadata', () => {
|
|
85
|
+
const productWithoutMetadata = {
|
|
86
|
+
sku: 'product-1',
|
|
87
|
+
displayName: 'Product 1',
|
|
88
|
+
price: 25,
|
|
89
|
+
accountingType: AccountingType.INSTANT,
|
|
175
90
|
};
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const products = await readProducts(PROJECT_ROOT);
|
|
180
|
-
if (products) {
|
|
181
|
-
bundle.paymentsConfig = await getPaymentsConfig(bundle, products);
|
|
182
|
-
}
|
|
183
|
-
}).rejects.toThrowError('Products metadata cannot start with "devvit-". Invalid keys: devvit-invalid');
|
|
91
|
+
expect(getPaymentsConfig(MOCK_BUNDLE, [productWithoutMetadata])).toStrictEqual(
|
|
92
|
+
// The metadata gets added by makePaymentsConfig
|
|
93
|
+
makePaymentsConfig([{ ...productWithoutMetadata, metadata: {} }]));
|
|
184
94
|
});
|
|
185
|
-
it('ignores product image asset verification if option is set to false',
|
|
95
|
+
it('ignores product image asset verification if option is set to false', () => {
|
|
186
96
|
const productImage = 'doesnotexist.jpg';
|
|
187
|
-
const products = {
|
|
188
|
-
products: [{ ...MOCK_PRODUCTS_JSON.products[0], images: { icon: productImage } }],
|
|
189
|
-
};
|
|
97
|
+
const products = [{ ...MOCK_PRODUCTS_JSON.products[0], images: { icon: productImage } }];
|
|
190
98
|
const bundle = {
|
|
191
|
-
|
|
192
|
-
dependencies: {
|
|
193
|
-
hostname: '',
|
|
194
|
-
provides: [
|
|
195
|
-
{
|
|
196
|
-
definition: {
|
|
197
|
-
fullName: PaymentProcessorDefinition.fullName,
|
|
198
|
-
methods: [],
|
|
199
|
-
name: '',
|
|
200
|
-
version: '',
|
|
201
|
-
},
|
|
202
|
-
partitionsBy: [],
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
uses: [],
|
|
206
|
-
},
|
|
99
|
+
...MOCK_BUNDLE,
|
|
207
100
|
assetIds: {
|
|
208
101
|
'exists.jpg': 'abc123',
|
|
209
102
|
},
|
|
210
|
-
webviewAssetIds: {},
|
|
211
103
|
};
|
|
212
|
-
|
|
213
|
-
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(products));
|
|
214
|
-
const productsFromConfig = await readProducts(PROJECT_ROOT);
|
|
215
|
-
if (productsFromConfig) {
|
|
216
|
-
bundle.paymentsConfig = await getPaymentsConfig(bundle, productsFromConfig, false);
|
|
217
|
-
}
|
|
218
|
-
expect(bundle.paymentsConfig).toStrictEqual(makePaymentsConfig(products.products));
|
|
104
|
+
expect(getPaymentsConfig(bundle, products, false)).toStrictEqual(makePaymentsConfig(products));
|
|
219
105
|
});
|
|
220
106
|
});
|
|
221
|
-
describe(
|
|
107
|
+
describe('Validate product icon', () => {
|
|
222
108
|
const imgPath = (filename) => path.join(__dirname, 'test-images', filename);
|
|
223
109
|
it('rejects non-images', () => {
|
|
224
110
|
expect(() => validateProductIcon(imgPath('not-an-image.png'))).toThrowError('not a valid image');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11-next-2025-03-13-4455a4ebd.0",
|
|
4
4
|
"description": "Reddit's Dev Platform CLI Tool",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"author": "@reddit/dev-platform",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"types": "dist/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@devvit/build-pack": "0.11.
|
|
45
|
+
"@devvit/build-pack": "0.11.11-next-2025-03-13-4455a4ebd.0",
|
|
46
46
|
"@devvit/play": "0.0.43",
|
|
47
|
-
"@devvit/protos": "0.11.
|
|
48
|
-
"@devvit/public-api": "0.11.
|
|
49
|
-
"@devvit/shared-types": "0.11.
|
|
47
|
+
"@devvit/protos": "0.11.11-next-2025-03-13-4455a4ebd.0",
|
|
48
|
+
"@devvit/public-api": "0.11.11-next-2025-03-13-4455a4ebd.0",
|
|
49
|
+
"@devvit/shared-types": "0.11.11-next-2025-03-13-4455a4ebd.0",
|
|
50
50
|
"@improbable-eng/grpc-web": "0.15.0",
|
|
51
51
|
"@improbable-eng/grpc-web-node-http-transport": "0.15.0",
|
|
52
52
|
"@oclif/core": "2.9.4",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"ws": "8.18.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@devvit/repo-tools": "0.11.
|
|
82
|
-
"@devvit/tsconfig": "0.11.
|
|
81
|
+
"@devvit/repo-tools": "0.11.11-next-2025-03-13-4455a4ebd.0",
|
|
82
|
+
"@devvit/tsconfig": "0.11.11-next-2025-03-13-4455a4ebd.0",
|
|
83
83
|
"@types/file-type": "10.9.1",
|
|
84
84
|
"@types/inquirer": "9.0.3",
|
|
85
85
|
"@types/js-yaml": "4.0.5",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
]
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "03fded1e3c2ca36228f4d23e1276a6348f4e02c5"
|
|
124
124
|
}
|