@devvit/cli 0.11.5-next-2024-12-17-ab1724ce8.0 → 0.11.5
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/lib/playtest-lockfile.js +4 -4
- package/dist/templates/payments/src/main.tsx +1 -6
- package/dist/templates/web-view-post/src/createPost.tsx +1 -1
- package/dist/templates/web-view-post/src/main.tsx +16 -18
- package/dist/util/payments/paymentsConfig.d.ts.map +1 -1
- package/dist/util/payments/paymentsConfig.js +0 -9
- package/dist/util/payments/paymentsConfig.test.js +0 -39
- package/package.json +8 -8
|
@@ -40,14 +40,14 @@ Check if another playtest is already running in a different terminal and stop it
|
|
|
40
40
|
Otherwise, you can safely continue`,
|
|
41
41
|
type: 'list',
|
|
42
42
|
choices: [
|
|
43
|
-
{
|
|
44
|
-
name: 'Continue anyway',
|
|
45
|
-
value: 'continue',
|
|
46
|
-
},
|
|
47
43
|
{
|
|
48
44
|
name: 'Exit',
|
|
49
45
|
value: 'exit',
|
|
50
46
|
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Continue anyway',
|
|
49
|
+
value: 'continue',
|
|
50
|
+
},
|
|
51
51
|
],
|
|
52
52
|
},
|
|
53
53
|
]);
|
|
@@ -45,12 +45,7 @@ const App: Devvit.CustomPostComponent = (context) => {
|
|
|
45
45
|
return orders.orders.length;
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
const { products } = useProducts(context, {
|
|
50
|
-
metadata: {
|
|
51
|
-
category: 'powerup',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
48
|
+
const { products } = useProducts(context, {});
|
|
54
49
|
|
|
55
50
|
// Client side code invoked after a purchase is made. This should be used to update
|
|
56
51
|
// app state based on orders.
|
|
@@ -13,7 +13,7 @@ Devvit.addMenuItem({
|
|
|
13
13
|
const { reddit, ui } = context;
|
|
14
14
|
const subreddit = await reddit.getCurrentSubreddit();
|
|
15
15
|
const post = await reddit.submitPost({
|
|
16
|
-
title: '
|
|
16
|
+
title: 'Webview Example',
|
|
17
17
|
subredditName: subreddit.name,
|
|
18
18
|
// The preview appears while the post loads
|
|
19
19
|
preview: (
|
|
@@ -24,7 +24,7 @@ Devvit.configure({
|
|
|
24
24
|
|
|
25
25
|
// Add a custom post type to Devvit
|
|
26
26
|
Devvit.addCustomPostType({
|
|
27
|
-
name: '
|
|
27
|
+
name: 'Webview Example',
|
|
28
28
|
height: 'tall',
|
|
29
29
|
render: (context) => {
|
|
30
30
|
// Load username with `useAsync` hook
|
|
@@ -40,7 +40,7 @@ Devvit.addCustomPostType({
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
// Create a reactive state for web view visibility
|
|
43
|
-
const [
|
|
43
|
+
const [webviewVisible, setWebviewVisible] = useState(false);
|
|
44
44
|
|
|
45
45
|
// When the web view invokes `window.parent.postMessage` this function is called
|
|
46
46
|
const onMessage = async (msg: WebViewMessage) => {
|
|
@@ -65,8 +65,8 @@ Devvit.addCustomPostType({
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// When the button is clicked, send initial data to web view and show it
|
|
68
|
-
const
|
|
69
|
-
|
|
68
|
+
const onShowWebviewClick = () => {
|
|
69
|
+
setWebviewVisible(true);
|
|
70
70
|
context.ui.webView.postMessage('myWebView', {
|
|
71
71
|
type: 'initialData',
|
|
72
72
|
data: {
|
|
@@ -80,8 +80,8 @@ Devvit.addCustomPostType({
|
|
|
80
80
|
return (
|
|
81
81
|
<vstack grow padding="small">
|
|
82
82
|
<vstack
|
|
83
|
-
grow={!
|
|
84
|
-
height={
|
|
83
|
+
grow={!webviewVisible}
|
|
84
|
+
height={webviewVisible ? '0%' : '100%'}
|
|
85
85
|
alignment="middle center"
|
|
86
86
|
>
|
|
87
87
|
<text size="xlarge" weight="bold">
|
|
@@ -105,19 +105,17 @@ Devvit.addCustomPostType({
|
|
|
105
105
|
</hstack>
|
|
106
106
|
</vstack>
|
|
107
107
|
<spacer />
|
|
108
|
-
<button onPress={
|
|
108
|
+
<button onPress={onShowWebviewClick}>Launch App</button>
|
|
109
109
|
</vstack>
|
|
110
|
-
<vstack grow={
|
|
111
|
-
<vstack border="thick" borderColor="black" height={
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
/>
|
|
120
|
-
) : null}
|
|
110
|
+
<vstack grow={webviewVisible} height={webviewVisible ? '100%' : '0%'}>
|
|
111
|
+
<vstack border="thick" borderColor="black" height={webviewVisible ? '100%' : '0%'}>
|
|
112
|
+
<webview
|
|
113
|
+
id="myWebView"
|
|
114
|
+
url="page.html"
|
|
115
|
+
onMessage={(msg) => onMessage(msg as WebViewMessage)}
|
|
116
|
+
grow
|
|
117
|
+
height={webviewVisible ? '100%' : '0%'}
|
|
118
|
+
/>
|
|
121
119
|
</vstack>
|
|
122
120
|
</vstack>
|
|
123
121
|
</vstack>
|
|
@@ -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;
|
|
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;AAKxE;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,sBAAsB,GAAE,OAAc,GACrC,OAAO,CAAC,IAAI,CAAC,CAYf;AAiFD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,cAAc,CAkBhF;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAyB3D"}
|
|
@@ -3,7 +3,6 @@ import path from 'node:path';
|
|
|
3
3
|
import { Currency, Environment, PaymentProcessorDefinition, PaymentsServiceDefinition, } from '@devvit/protos/payments.js';
|
|
4
4
|
import { ASSET_DIRNAME } from '@devvit/shared-types/Assets.js';
|
|
5
5
|
import { ACTOR_SRC_DIR, PRODUCTS_JSON_FILE } from '@devvit/shared-types/constants.js';
|
|
6
|
-
import { filterToReservedDevvitMetadataKeys } from '@devvit/shared-types/filterToReservedDevvitMetadataKeys.js';
|
|
7
6
|
import { mapAccountingTypeToProto } from '@devvit/shared-types/payments/index.js';
|
|
8
7
|
import { validateProductsJSON } from '@devvit/shared-types/payments/productSchemaJSONValidator.js';
|
|
9
8
|
import { imageSize } from 'image-size';
|
|
@@ -36,14 +35,6 @@ function checkProductsConfig(products, bundle, verifyProductImgAssets = true) {
|
|
|
36
35
|
if (!providesPaymentProcessor) {
|
|
37
36
|
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.');
|
|
38
37
|
}
|
|
39
|
-
for (const product of products) {
|
|
40
|
-
const invalidKeys = filterToReservedDevvitMetadataKeys(Object.keys(product.metadata));
|
|
41
|
-
// Enforced here on the CLI and also on the server. Server processing is done too late for error
|
|
42
|
-
// messages to reach the end user, so doing here prior to upload.
|
|
43
|
-
if (invalidKeys.length > 0) {
|
|
44
|
-
throw new Error(`Products metadata cannot start with "devvit-". Invalid keys: ${invalidKeys.join(', ')}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
38
|
const missingAssets = [];
|
|
48
39
|
if (verifyProductImgAssets) {
|
|
49
40
|
// check that all product images are included in the assets
|
|
@@ -121,45 +121,6 @@ describe(readAndInjectBundleProducts.name, () => {
|
|
|
121
121
|
await readAndInjectBundleProducts(PROJECT_ROOT, bundle);
|
|
122
122
|
expect(bundle.paymentsConfig).toStrictEqual(makePaymentsConfig(MOCK_PRODUCTS_JSON.products));
|
|
123
123
|
});
|
|
124
|
-
it('throws error if a product has metadata starting with "devvit-"', async () => {
|
|
125
|
-
const invalidProduct = {
|
|
126
|
-
sku: 'product-1',
|
|
127
|
-
displayName: 'Product 1',
|
|
128
|
-
price: 25,
|
|
129
|
-
accountingType: AccountingType.INSTANT,
|
|
130
|
-
metadata: {
|
|
131
|
-
'devvit-invalid': 'this breaks upload',
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
const products = {
|
|
135
|
-
products: [{ ...invalidProduct }],
|
|
136
|
-
};
|
|
137
|
-
const bundle = {
|
|
138
|
-
code: '',
|
|
139
|
-
dependencies: {
|
|
140
|
-
hostname: '',
|
|
141
|
-
provides: [
|
|
142
|
-
{
|
|
143
|
-
definition: {
|
|
144
|
-
fullName: PaymentProcessorDefinition.fullName,
|
|
145
|
-
methods: [],
|
|
146
|
-
name: '',
|
|
147
|
-
version: '',
|
|
148
|
-
},
|
|
149
|
-
partitionsBy: [],
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
uses: [],
|
|
153
|
-
},
|
|
154
|
-
assetIds: {
|
|
155
|
-
'exists.jpg': 'abc123',
|
|
156
|
-
},
|
|
157
|
-
webviewAssetIds: {},
|
|
158
|
-
};
|
|
159
|
-
vi.mocked(access).mockResolvedValueOnce();
|
|
160
|
-
vi.mocked(readFile).mockResolvedValueOnce(JSON.stringify(products));
|
|
161
|
-
await expect(() => readAndInjectBundleProducts(PROJECT_ROOT, bundle)).rejects.toThrowError('Products metadata cannot start with "devvit-". Invalid keys: devvit-invalid');
|
|
162
|
-
});
|
|
163
124
|
it('ignores product image asset verification if option is set to false', async () => {
|
|
164
125
|
const productImage = 'doesnotexist.jpg';
|
|
165
126
|
const products = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/cli",
|
|
3
|
-
"version": "0.11.5
|
|
3
|
+
"version": "0.11.5",
|
|
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.5
|
|
45
|
+
"@devvit/build-pack": "0.11.5",
|
|
46
46
|
"@devvit/play": "0.0.43",
|
|
47
|
-
"@devvit/protos": "0.11.5
|
|
48
|
-
"@devvit/public-api": "0.11.5
|
|
49
|
-
"@devvit/shared-types": "0.11.5
|
|
47
|
+
"@devvit/protos": "0.11.5",
|
|
48
|
+
"@devvit/public-api": "0.11.5",
|
|
49
|
+
"@devvit/shared-types": "0.11.5",
|
|
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.5
|
|
82
|
-
"@devvit/tsconfig": "0.11.5
|
|
81
|
+
"@devvit/repo-tools": "0.11.5",
|
|
82
|
+
"@devvit/tsconfig": "0.11.5",
|
|
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": "dc2a4700695311711f4fe5bdb53fb12c9b35e938"
|
|
124
124
|
}
|