@devvit/cli 0.11.5 → 0.11.6-next-2024-12-19-5fb90c390.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.
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "app-settings-template",
4
- "version": "0.11.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-dev"
9
9
  },
10
10
  "devDependencies": {
11
- "@devvit/tsconfig": "0.11.5-dev",
11
+ "@devvit/tsconfig": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-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.5-dev"
12
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/payments": "0.11.5-dev",
9
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/payments": "0.11.6-dev",
9
+ "@devvit/public-api": "0.11.6-dev"
10
10
  },
11
11
  "devDependencies": {
12
12
  "typescript": "5.3.2"
@@ -45,7 +45,12 @@ const App: Devvit.CustomPostComponent = (context) => {
45
45
  return orders.orders.length;
46
46
  });
47
47
 
48
- const { products } = useProducts(context, {});
48
+ // Only grab products with the category "powerup".
49
+ const { products } = useProducts(context, {
50
+ metadata: {
51
+ category: 'powerup',
52
+ },
53
+ });
49
54
 
50
55
  // Client side code invoked after a purchase is made. This should be used to update
51
56
  // app state based on orders.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "pen-template",
4
- "version": "0.11.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-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.5-dev",
4
+ "version": "0.11.6-dev",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@devvit/public-api": "0.11.5-dev"
8
+ "@devvit/public-api": "0.11.6-dev"
9
9
  },
10
10
  "devDependencies": {
11
11
  "typescript": "5.3.2"
@@ -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: 'Webview Example',
16
+ title: 'Web View 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: 'Webview Example',
27
+ name: 'Web View 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 [webviewVisible, setWebviewVisible] = useState(false);
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 onShowWebviewClick = () => {
69
- setWebviewVisible(true);
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={!webviewVisible}
84
- height={webviewVisible ? '0%' : '100%'}
83
+ grow={!webViewVisible}
84
+ height={webViewVisible ? '0%' : '100%'}
85
85
  alignment="middle center"
86
86
  >
87
87
  <text size="xlarge" weight="bold">
@@ -105,17 +105,19 @@ Devvit.addCustomPostType({
105
105
  </hstack>
106
106
  </vstack>
107
107
  <spacer />
108
- <button onPress={onShowWebviewClick}>Launch App</button>
108
+ <button onPress={onShowWebViewClick}>Launch App</button>
109
109
  </vstack>
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
- />
110
+ <vstack grow={webViewVisible} height={webViewVisible ? '100%' : '0%'}>
111
+ <vstack border="thick" borderColor="black" height={webViewVisible ? '100%' : '0%'}>
112
+ {webViewVisible ? (
113
+ <webview
114
+ id="myWebView"
115
+ url="page.html"
116
+ onMessage={(msg) => onMessage(msg as WebViewMessage)}
117
+ grow
118
+ height={webViewVisible ? '100%' : '0%'}
119
+ />
120
+ ) : null}
119
121
  </vstack>
120
122
  </vstack>
121
123
  </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;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"}
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;AAMxE;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,sBAAsB,GAAE,OAAc,GACrC,OAAO,CAAC,IAAI,CAAC,CAYf;AA6FD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,cAAc,CAkBhF;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAyB3D"}
@@ -5,6 +5,7 @@ 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
6
  import { mapAccountingTypeToProto } from '@devvit/shared-types/payments/index.js';
7
7
  import { validateProductsJSON } from '@devvit/shared-types/payments/productSchemaJSONValidator.js';
8
+ import { filterToReservedDevvitMetadataKeys } from '@devvit/shared-types/reservedDevvitMetadataKeys.js';
8
9
  import { imageSize } from 'image-size';
9
10
  /**
10
11
  * reads src/products.json and injects products into bundle. Will throw an error if
@@ -35,6 +36,14 @@ function checkProductsConfig(products, bundle, verifyProductImgAssets = true) {
35
36
  if (!providesPaymentProcessor) {
36
37
  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.');
37
38
  }
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
+ }
38
47
  const missingAssets = [];
39
48
  if (verifyProductImgAssets) {
40
49
  // check that all product images are included in the assets
@@ -121,6 +121,45 @@ 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
+ });
124
163
  it('ignores product image asset verification if option is set to false', async () => {
125
164
  const productImage = 'doesnotexist.jpg';
126
165
  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.6-next-2024-12-19-5fb90c390.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.5",
45
+ "@devvit/build-pack": "0.11.6-next-2024-12-19-5fb90c390.0",
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.6-next-2024-12-19-5fb90c390.0",
48
+ "@devvit/public-api": "0.11.6-next-2024-12-19-5fb90c390.0",
49
+ "@devvit/shared-types": "0.11.6-next-2024-12-19-5fb90c390.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.5",
82
- "@devvit/tsconfig": "0.11.5",
81
+ "@devvit/repo-tools": "0.11.6-next-2024-12-19-5fb90c390.0",
82
+ "@devvit/tsconfig": "0.11.6-next-2024-12-19-5fb90c390.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": "dc2a4700695311711f4fe5bdb53fb12c9b35e938"
123
+ "gitHead": "4bebb6d4f5c73718d92691ca1cf53a0d5d810eed"
124
124
  }