@shopify/shop-minis-cli 0.0.75 → 0.0.76
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/build/commands/codemod/releases/index.js +2 -0
- package/build/commands/codemod/releases/index.js.map +1 -1
- package/build/commands/codemod/releases/v0-0-75.js +1 -1
- package/build/commands/codemod/releases/v0-0-76.d.ts +3 -0
- package/build/commands/codemod/releases/v0-0-76.js +32 -0
- package/build/commands/codemod/releases/v0-0-76.js.map +1 -0
- package/build/commands/dev/index.js +11 -1
- package/build/commands/dev/index.js.map +1 -1
- package/build/commands/dev/utils/android.js +4 -4
- package/build/commands/dev/utils/android.js.map +1 -1
- package/build/commands/dev/utils/deeplink.js +2 -37
- package/build/commands/dev/utils/deeplink.js.map +1 -1
- package/build/commands/doctor/utils/diagnose-dependencies.d.ts +6 -0
- package/build/commands/doctor/utils/diagnose-dependencies.js +48 -21
- package/build/commands/doctor/utils/diagnose-dependencies.js.map +1 -1
- package/build/commands/submit/config.js +1 -1
- package/build/commands/submit/config.js.map +1 -1
- package/build/commands/submit/submit.js +9 -5
- package/build/commands/submit/submit.js.map +1 -1
- package/build/commands/submit/utils/request-entry-point-params.d.ts +1 -0
- package/build/commands/submit/utils/request-entry-point-params.js +41 -0
- package/build/commands/submit/utils/request-entry-point-params.js.map +1 -0
- package/build/commands/submit/validation.d.ts +1 -2
- package/build/commands/submit/validation.js +1 -4
- package/build/commands/submit/validation.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/schemas/contextual-image.schema.json +12 -0
- package/build/schemas/contextual-object.schema.json +11 -0
- package/build/schemas/manifest.schema.json +252 -0
- package/build/schemas/visibility.schema.json +11 -0
- package/build/utils/development-params.d.ts +13 -0
- package/build/utils/development-params.js +42 -0
- package/build/utils/development-params.js.map +1 -0
- package/build/utils/minis-manifest.d.ts +2 -0
- package/build/utils/minis-manifest.js +26 -9
- package/build/utils/minis-manifest.js.map +1 -1
- package/package.json +4 -2
- package/templates/__template_common/babel.config.js +2 -0
- package/build/schemas/contextual-image.schema.d.ts +0 -22
- package/build/schemas/contextual-image.schema.js +0 -23
- package/build/schemas/contextual-image.schema.js.map +0 -1
- package/build/schemas/contextual-object.schema.d.ts +0 -18
- package/build/schemas/contextual-object.schema.js +0 -19
- package/build/schemas/contextual-object.schema.js.map +0 -1
- package/build/schemas/manifest.schema.d.ts +0 -200
- package/build/schemas/manifest.schema.js +0 -328
- package/build/schemas/manifest.schema.js.map +0 -1
- package/build/schemas/visibility.schema.d.ts +0 -18
- package/build/schemas/visibility.schema.js +0 -19
- package/build/schemas/visibility.schema.js.map +0 -1
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/manifest.schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"title": "Shop Mini Manifest",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The name of the Mini",
|
|
11
|
+
"maxLength": 20
|
|
12
|
+
},
|
|
13
|
+
"handle": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "A unique identifier for the Mini",
|
|
16
|
+
"pattern": "^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"
|
|
17
|
+
},
|
|
18
|
+
"description": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The description of the Mini",
|
|
21
|
+
"maxLength": 100
|
|
22
|
+
},
|
|
23
|
+
"icon_url": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"title": "The icon of the Mini",
|
|
26
|
+
"description": "An absolute path to the image (e.g. https://example.com/icon.png)"
|
|
27
|
+
},
|
|
28
|
+
"partner_name": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "The name of the Shopify partner who built the Mini",
|
|
31
|
+
"maxLength": 20
|
|
32
|
+
},
|
|
33
|
+
"contact_email": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "An email address for receiving notifications.",
|
|
36
|
+
"format": "email"
|
|
37
|
+
},
|
|
38
|
+
"activation_subpath": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "A route on your Mini's Shopify app that will be used to activate (enable entry points) your Mini for the first time. This route path will be appended to the end of the admin URL of the Shopify app. For example, the value 'activate' will correspond to the URL https://admin.shopify.com/store/example-store/apps/my-handle/activate",
|
|
41
|
+
"pattern": "^(?:[a-z0-9~-]+/)*[a-z0-9~-]+$"
|
|
42
|
+
},
|
|
43
|
+
"shopify_apps": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"description": "The Shopify apps associated with the Mini",
|
|
46
|
+
"properties": {
|
|
47
|
+
"production": {
|
|
48
|
+
"type": "integer",
|
|
49
|
+
"minimum": 1,
|
|
50
|
+
"description": "The Shopify app ID for production",
|
|
51
|
+
"required": true
|
|
52
|
+
},
|
|
53
|
+
"development": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"description": "The Shopify app IDs for development",
|
|
56
|
+
"uniqueItems": true,
|
|
57
|
+
"items": { "type": "integer", "minimum": 1 }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"notification_topics": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"description": "Specifies the reason for communication and the scope for messages. An example of a topic could be live streaming related notifications related to a merchant",
|
|
64
|
+
"items": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"required": ["handle", "description", "scope"],
|
|
67
|
+
"properties": {
|
|
68
|
+
"handle": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "Text identifier of the topic"
|
|
71
|
+
},
|
|
72
|
+
"description": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "Reason for the communication using the topic"
|
|
75
|
+
},
|
|
76
|
+
"scope": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "The scope in which messages are processed for the topic. SHOP means each message will be processed in the scope of a specific merchant, PRODUCT means each message will be processed in the scope of a specific product",
|
|
79
|
+
"enum": ["SHOP", "PRODUCT"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"notification_templates": {
|
|
85
|
+
"type": "array",
|
|
86
|
+
"description": "Specify the message which will be sent to subscribers when notification is triggered by the mutation",
|
|
87
|
+
"items": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"required": [
|
|
90
|
+
"handle",
|
|
91
|
+
"topic_handle",
|
|
92
|
+
"title",
|
|
93
|
+
"body",
|
|
94
|
+
"cooldown_minutes"
|
|
95
|
+
],
|
|
96
|
+
"properties": {
|
|
97
|
+
"handle": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"description": "Text identifier of the template"
|
|
100
|
+
},
|
|
101
|
+
"topic_handle": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"description": "Reference to a notification topic"
|
|
104
|
+
},
|
|
105
|
+
"title": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"description": "Template of notification title, supports interpolation using the Liquid template language"
|
|
108
|
+
},
|
|
109
|
+
"body": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"description": "Template of notification body, supports interpolation using the Liquid template language"
|
|
112
|
+
},
|
|
113
|
+
"cooldown_minutes": {
|
|
114
|
+
"type": "number",
|
|
115
|
+
"description": "How often the template allowes to send the exact same message to the same user, in minutes"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"entry_points": {
|
|
121
|
+
"type": "array",
|
|
122
|
+
"description": "A list of entry points that the Mini supports",
|
|
123
|
+
"items": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"properties": {
|
|
126
|
+
"location": {
|
|
127
|
+
"type": "string",
|
|
128
|
+
"enum": [
|
|
129
|
+
"PRODUCT_PAGE",
|
|
130
|
+
"STORE_PAGE",
|
|
131
|
+
"PRODUCT_PAGE_CONTEXT_MENU",
|
|
132
|
+
"STORE_PAGE_CONTEXT_MENU",
|
|
133
|
+
"ORDER_CONFIRMATION_PAGE"
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
"type": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"enum": [
|
|
139
|
+
"CONTENT_CARD",
|
|
140
|
+
"ACTION_BUTTON",
|
|
141
|
+
"EVENT_CARD",
|
|
142
|
+
"LINK",
|
|
143
|
+
"DEFAULT_CARD",
|
|
144
|
+
"IMAGE_COLLECTION",
|
|
145
|
+
"VIDEO_COLLECTION",
|
|
146
|
+
"EVENT_CARD_V2",
|
|
147
|
+
"PRODUCT_OFFER_CARD"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"primary_text": { "$ref": "/contextual-object.schema.json" },
|
|
151
|
+
"call_to_action_text": { "$ref": "/contextual-object.schema.json" },
|
|
152
|
+
"images": { "$ref": "/contextual-image.schema.json" },
|
|
153
|
+
"visibility": { "$ref": "/visibility.schema.json" },
|
|
154
|
+
"visibility_rule": { "$ref": "/visibility.schema.json" },
|
|
155
|
+
"pre_active_images": {
|
|
156
|
+
"$ref": "/contextual-image.schema.json",
|
|
157
|
+
"description": "The images list used to render entry point in PRE_ACTIVE state"
|
|
158
|
+
},
|
|
159
|
+
"post_active_images": {
|
|
160
|
+
"$ref": "/contextual-image.schema.json",
|
|
161
|
+
"description": "(Optional) The images list used to render entry point in POST_ACTIVE state"
|
|
162
|
+
},
|
|
163
|
+
"notification_topic": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"description": "The notification topic handle which Shop users could subscribe to, must match one from the notification_topics manifest section"
|
|
166
|
+
},
|
|
167
|
+
"event_status": {
|
|
168
|
+
"type": "object",
|
|
169
|
+
"description": "The status of related event, affects how the user can interact with entry point",
|
|
170
|
+
"required": ["default_value"],
|
|
171
|
+
"properties": {
|
|
172
|
+
"namespace": { "type": "string" },
|
|
173
|
+
"key": { "type": "string" },
|
|
174
|
+
"default_value": {
|
|
175
|
+
"type": "string",
|
|
176
|
+
"enum": ["PRE_ACTIVE", "ACTIVE", "POST_ACTIVE"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"allOf": [
|
|
182
|
+
{
|
|
183
|
+
"if": { "properties": { "type": { "const": "CONTENT_CARD" } } },
|
|
184
|
+
"then": { "required": ["location", "type", "primary_text", "images"] }
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"if": { "properties": { "type": { "const": "ACTION_BUTTON" } } },
|
|
188
|
+
"then": { "required": ["location", "type", "call_to_action_text"] }
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"if": { "properties": { "type": { "const": "EVENT_CARD" } } },
|
|
192
|
+
"then": {
|
|
193
|
+
"required": [
|
|
194
|
+
"location",
|
|
195
|
+
"type",
|
|
196
|
+
"primary_text",
|
|
197
|
+
"images",
|
|
198
|
+
"notification_topic",
|
|
199
|
+
"pre_active_images"
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"if": { "properties": { "type": { "const": "LINK" } } },
|
|
205
|
+
"then": { "required": ["location"] }
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"if": { "properties": { "type": { "const": "DEFAULT_CARD" } } },
|
|
209
|
+
"then": { "required": ["location"] }
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"if": { "properties": { "type": { "const": "IMAGE_COLLECTION" } } },
|
|
213
|
+
"then": { "required": ["location"] }
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"if": { "properties": { "type": { "const": "VIDEO_COLLECTION" } } },
|
|
217
|
+
"then": { "required": ["location"] }
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"if": { "properties": { "type": { "const": "EVENT_CARD_V2" } } },
|
|
221
|
+
"then": { "required": ["location"] }
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"trusted_domains": {
|
|
227
|
+
"type": "array",
|
|
228
|
+
"description": "A list of domains that the minis uses to make requests and fetch information. Requests to domains that are not in this list will fail in production.",
|
|
229
|
+
"uniqueItems": true,
|
|
230
|
+
"items": {
|
|
231
|
+
"type": "string"
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"ios_app_store_url": {
|
|
235
|
+
"type": "string",
|
|
236
|
+
"description": "The URL to the Mini's publisher's app on the iOS App Store"
|
|
237
|
+
},
|
|
238
|
+
"android_play_store_url": {
|
|
239
|
+
"type": "string",
|
|
240
|
+
"description": "The URL to the Mini's publisher's app on the Android Play Store"
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
"required": [
|
|
244
|
+
"name",
|
|
245
|
+
"handle",
|
|
246
|
+
"icon_url",
|
|
247
|
+
"partner_name",
|
|
248
|
+
"shopify_apps",
|
|
249
|
+
"entry_points",
|
|
250
|
+
"contact_email"
|
|
251
|
+
]
|
|
252
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/visibility.schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"title": "Entry-point visibility schema",
|
|
6
|
+
"properties": {
|
|
7
|
+
"owner_type": { "type": "string" },
|
|
8
|
+
"namespace": { "type": "string" },
|
|
9
|
+
"key": { "type": "string" }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const ALLOWED_ENTRY_POINT_PARAMS: readonly ["product_id", "shop_id", "product_variant_id", "external_id", "shop_domain", "order_id"];
|
|
2
|
+
type DevelopmentEntryPointParams = {
|
|
3
|
+
[key in (typeof ALLOWED_ENTRY_POINT_PARAMS)[number]]?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Reads the content of the file entry-point-params.json in the rootpath of a Mini folder, which should be of the shape Record<string, string>.
|
|
7
|
+
* Then, formats the object as an URL query string and returns it.
|
|
8
|
+
*
|
|
9
|
+
* Returns empty string if the file does not exist or if the format of its content is incorrect.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getDevelopmentEntryPointParams(): DevelopmentEntryPointParams;
|
|
12
|
+
export declare function getDevelopmentEntryPointParamsQueryString(): string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
const ALLOWED_ENTRY_POINT_PARAMS = [
|
|
4
|
+
'product_id',
|
|
5
|
+
'shop_id',
|
|
6
|
+
'product_variant_id',
|
|
7
|
+
'external_id',
|
|
8
|
+
'shop_domain',
|
|
9
|
+
'order_id',
|
|
10
|
+
];
|
|
11
|
+
const DEVELOPMENT_PARAMS_FILE_NAME = 'entry-point-params.json';
|
|
12
|
+
const DEVELOPMENT_PARAMS_FILE_PATH = path.join(process.cwd(), DEVELOPMENT_PARAMS_FILE_NAME);
|
|
13
|
+
/**
|
|
14
|
+
* Reads the content of the file entry-point-params.json in the rootpath of a Mini folder, which should be of the shape Record<string, string>.
|
|
15
|
+
* Then, formats the object as an URL query string and returns it.
|
|
16
|
+
*
|
|
17
|
+
* Returns empty string if the file does not exist or if the format of its content is incorrect.
|
|
18
|
+
*/
|
|
19
|
+
export function getDevelopmentEntryPointParams() {
|
|
20
|
+
try {
|
|
21
|
+
const localRequire = createRequire(import.meta.url);
|
|
22
|
+
delete localRequire.cache[localRequire.resolve(DEVELOPMENT_PARAMS_FILE_PATH)];
|
|
23
|
+
const persistedParams = localRequire(DEVELOPMENT_PARAMS_FILE_PATH);
|
|
24
|
+
const paramsAsEntries = Object.entries(persistedParams).filter(([key, value]) => ALLOWED_ENTRY_POINT_PARAMS.includes(key) && Boolean(value));
|
|
25
|
+
return Object.fromEntries(paramsAsEntries);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (err?.code !== 'MODULE_NOT_FOUND' && err?.code !== 'ENOENT') {
|
|
29
|
+
console.log('\n ⚠️ Development entrypoints params ignored due to errors:\n');
|
|
30
|
+
console.log(err);
|
|
31
|
+
console.log('\n');
|
|
32
|
+
}
|
|
33
|
+
// do nothing, the development entrypoint params file is optional and might not exist.
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function getDevelopmentEntryPointParamsQueryString() {
|
|
38
|
+
const paramsObject = getDevelopmentEntryPointParams();
|
|
39
|
+
const paramsQueryString = new URLSearchParams(paramsObject).toString();
|
|
40
|
+
return paramsQueryString ? `?${paramsQueryString}` : '';
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=development-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"development-params.js","sourceRoot":"","sources":["../../src/utils/development-params.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,0BAA0B,GAAG;IACjC,YAAY;IACZ,SAAS;IACT,oBAAoB;IACpB,aAAa;IACb,aAAa;IACb,UAAU;CACF,CAAA;AAMV,MAAM,4BAA4B,GAAG,yBAAyB,CAAA;AAC9D,MAAM,4BAA4B,GAAG,IAAI,CAAC,IAAI,CAC5C,OAAO,CAAC,GAAG,EAAE,EACb,4BAA4B,CAC7B,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAC5C,IAAI;QACF,MAAM,YAAY,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACnD,OAAO,YAAY,CAAC,KAAK,CACvB,YAAY,CAAC,OAAO,CAAC,4BAA4B,CAAC,CACnD,CAAA;QACD,MAAM,eAAe,GAA2B,YAAY,CAC1D,4BAA4B,CAC7B,CAAA;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,MAAM,CAC5D,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,0BAA0B,CAAC,QAAQ,CACjC,GAAwC,CACzC,IAAI,OAAO,CAAC,KAAK,CAAC,CACtB,CAAA;QACD,OAAO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;KAC3C;IAAC,OAAO,GAAQ,EAAE;QACjB,IAAI,GAAG,EAAE,IAAI,KAAK,kBAAkB,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ,EAAE;YAC9D,OAAO,CAAC,GAAG,CACT,gEAAgE,CACjE,CAAA;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAChB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;SAClB;QACD,sFAAsF;QACtF,OAAO,EAAE,CAAA;KACV;AACH,CAAC;AAED,MAAM,UAAU,yCAAyC;IACvD,MAAM,YAAY,GAAG,8BAA8B,EAAE,CAAA;IACrD,MAAM,iBAAiB,GAAG,IAAI,eAAe,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAA;IAEtE,OAAO,iBAAiB,CAAC,CAAC,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACzD,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Validator } from 'jsonschema';
|
|
1
2
|
export declare const DEFAULT_MANIFEST_PATH: string;
|
|
2
3
|
export declare function getMiniManifest(manifestPath?: string): any;
|
|
4
|
+
export declare function getValidator(): Validator;
|
|
3
5
|
export declare function validateManifest(manifestPath?: string): {
|
|
4
6
|
valid: boolean;
|
|
5
7
|
errors: string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { Validator } from 'jsonschema';
|
|
4
|
-
import contextualImageSchema from '../schemas/contextual-image.schema.
|
|
5
|
-
import contextualObjectSchema from '../schemas/contextual-object.schema.
|
|
6
|
-
import visibilitySchema from '../schemas/visibility.schema.
|
|
7
|
-
import manifestSchema from '../schemas/manifest.schema.
|
|
4
|
+
import contextualImageSchema from '../schemas/contextual-image.schema.json' assert { type: 'json' };
|
|
5
|
+
import contextualObjectSchema from '../schemas/contextual-object.schema.json' assert { type: 'json' };
|
|
6
|
+
import visibilitySchema from '../schemas/visibility.schema.json' assert { type: 'json' };
|
|
7
|
+
import manifestSchema from '../schemas/manifest.schema.json' assert { type: 'json' };
|
|
8
8
|
const manifestRequire = createRequire(import.meta.url);
|
|
9
9
|
export const DEFAULT_MANIFEST_PATH = path.join('src', 'manifest.json');
|
|
10
10
|
export function getMiniManifest(manifestPath = DEFAULT_MANIFEST_PATH) {
|
|
@@ -13,7 +13,7 @@ export function getMiniManifest(manifestPath = DEFAULT_MANIFEST_PATH) {
|
|
|
13
13
|
try {
|
|
14
14
|
manifest = manifestRequire(fullManifestPath);
|
|
15
15
|
}
|
|
16
|
-
catch {
|
|
16
|
+
catch (err) {
|
|
17
17
|
const mockManifest = process.env.MOCK_MANIFEST;
|
|
18
18
|
if (mockManifest) {
|
|
19
19
|
try {
|
|
@@ -28,20 +28,37 @@ export function getMiniManifest(manifestPath = DEFAULT_MANIFEST_PATH) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
|
|
31
|
+
let errorMessage = `Failed to load manifest file from ${manifestPath}`;
|
|
32
|
+
if (err?.name === 'SyntaxError') {
|
|
33
|
+
errorMessage = `There are syntax errors in your manifest file (path: ${manifestPath})`;
|
|
34
|
+
}
|
|
35
|
+
else if (err?.code === 'MODULE_NOT_FOUND') {
|
|
36
|
+
errorMessage = `The manifest file of your mini does not exist. Create it in the path "${manifestPath}". Read more about the expected schema here: https://shop.app/minis/docs/reference/manifest/`;
|
|
37
|
+
}
|
|
38
|
+
throw new Error(errorMessage);
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
return manifest;
|
|
35
42
|
}
|
|
43
|
+
export function getValidator() {
|
|
44
|
+
const validator = new Validator();
|
|
45
|
+
// The filenames here seem to relate to the ones inside the files themselves
|
|
46
|
+
// rather than their exact filepath. We use `js` because at runtime they are
|
|
47
|
+
// compiled by ts and are imported from the `build` directory
|
|
48
|
+
validator.addSchema(contextualImageSchema, '/contextual-image.schema.json');
|
|
49
|
+
validator.addSchema(contextualObjectSchema, '/contextual-object.schema.json');
|
|
50
|
+
validator.addSchema(visibilitySchema, '/visibility.schema.json');
|
|
51
|
+
return validator;
|
|
52
|
+
}
|
|
36
53
|
export function validateManifest(manifestPath) {
|
|
37
54
|
const manifest = getMiniManifest(manifestPath);
|
|
38
55
|
const validator = new Validator();
|
|
39
56
|
// The filenames here seem to relate to the ones inside the files themselves
|
|
40
57
|
// rather than their exact filepath. We use `js` because at runtime they are
|
|
41
58
|
// compiled by ts and are imported from the `build` directory
|
|
42
|
-
validator.addSchema(contextualImageSchema, '/contextual-image.schema.
|
|
43
|
-
validator.addSchema(contextualObjectSchema, '/contextual-object.schema.
|
|
44
|
-
validator.addSchema(visibilitySchema, '/visibility.schema.
|
|
59
|
+
validator.addSchema(contextualImageSchema, '/contextual-image.schema.json');
|
|
60
|
+
validator.addSchema(contextualObjectSchema, '/contextual-object.schema.json');
|
|
61
|
+
validator.addSchema(visibilitySchema, '/visibility.schema.json');
|
|
45
62
|
const result = validator.validate(manifest, manifestSchema);
|
|
46
63
|
return {
|
|
47
64
|
valid: result.valid,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minis-manifest.js","sourceRoot":"","sources":["../../src/utils/minis-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAA;AAEpC,OAAO,qBAAqB,MAAM,
|
|
1
|
+
{"version":3,"file":"minis-manifest.js","sourceRoot":"","sources":["../../src/utils/minis-manifest.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,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;IAE3D,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;KACpE,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.76",
|
|
8
8
|
"description": "Shop Minis CLI",
|
|
9
9
|
"main": "build/index.js",
|
|
10
10
|
"bin": {
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@google-cloud/storage": "^6.9.0",
|
|
60
|
+
"@inquirer/editor": "^1.2.4",
|
|
60
61
|
"@react-native-community/cli": "^10.0.0",
|
|
61
62
|
"@react-native-community/cli-plugin-metro": "^10.0.0",
|
|
62
63
|
"@shopify/cli-kit": "^3.45.0",
|
|
@@ -88,7 +89,8 @@
|
|
|
88
89
|
"qrcode-terminal": "^0.12.0",
|
|
89
90
|
"replace-in-file": "^6.3.5",
|
|
90
91
|
"semver": "^7.3.8",
|
|
91
|
-
"serve-static": "^1.15.0"
|
|
92
|
+
"serve-static": "^1.15.0",
|
|
93
|
+
"suppress-experimental-warnings": "^1.1.17"
|
|
92
94
|
},
|
|
93
95
|
"resolutions": {
|
|
94
96
|
"@apollo/federation": "0.38.1"
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
+
// Changes to babel config are not supported by the mini platform.
|
|
3
|
+
// Custom configuration can introduce unexpected behaviour in your mini and could be a cause of rejection during the submission process.
|
|
2
4
|
presets: ['@shopify/shop-minis-runtime/babel-preset'],
|
|
3
5
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare const schema: {
|
|
2
|
-
$id: string;
|
|
3
|
-
$schema: string;
|
|
4
|
-
type: string;
|
|
5
|
-
title: string;
|
|
6
|
-
required: string[];
|
|
7
|
-
properties: {
|
|
8
|
-
namespace: {
|
|
9
|
-
type: string;
|
|
10
|
-
};
|
|
11
|
-
key: {
|
|
12
|
-
type: string;
|
|
13
|
-
};
|
|
14
|
-
default_value: {
|
|
15
|
-
type: string;
|
|
16
|
-
items: {
|
|
17
|
-
type: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export default schema;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const schema = {
|
|
2
|
-
$id: '/contextual-image.schema.js',
|
|
3
|
-
$schema: 'http://json-schema.org/draft-07/schema',
|
|
4
|
-
type: 'object',
|
|
5
|
-
title: 'Contextual image entry-point',
|
|
6
|
-
required: ['default_value'],
|
|
7
|
-
properties: {
|
|
8
|
-
namespace: {
|
|
9
|
-
type: 'string',
|
|
10
|
-
},
|
|
11
|
-
key: {
|
|
12
|
-
type: 'string',
|
|
13
|
-
},
|
|
14
|
-
default_value: {
|
|
15
|
-
type: 'array',
|
|
16
|
-
items: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
export default schema;
|
|
23
|
-
//# sourceMappingURL=contextual-image.schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contextual-image.schema.js","sourceRoot":"","sources":["../../src/schemas/contextual-image.schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,GAAG,EAAE,6BAA6B;IAClC,OAAO,EAAE,wCAAwC;IACjD,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,8BAA8B;IACrC,QAAQ,EAAE,CAAC,eAAe,CAAC;IAC3B,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;SACf;QACD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;SACf;QACD,aAAa,EAAE;YACb,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;aACf;SACF;KACF;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare const schema: {
|
|
2
|
-
$id: string;
|
|
3
|
-
$schema: string;
|
|
4
|
-
type: string;
|
|
5
|
-
title: string;
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: {
|
|
8
|
-
type: string;
|
|
9
|
-
};
|
|
10
|
-
key: {
|
|
11
|
-
type: string;
|
|
12
|
-
};
|
|
13
|
-
default_value: {
|
|
14
|
-
type: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export default schema;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const schema = {
|
|
2
|
-
$id: '/contextual-object.schema.js',
|
|
3
|
-
$schema: 'http://json-schema.org/draft-07/schema',
|
|
4
|
-
type: 'object',
|
|
5
|
-
title: 'Contextual entry-point',
|
|
6
|
-
properties: {
|
|
7
|
-
namespace: {
|
|
8
|
-
type: 'string',
|
|
9
|
-
},
|
|
10
|
-
key: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
},
|
|
13
|
-
default_value: {
|
|
14
|
-
type: 'string',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
export default schema;
|
|
19
|
-
//# sourceMappingURL=contextual-object.schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contextual-object.schema.js","sourceRoot":"","sources":["../../src/schemas/contextual-object.schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,GAAG,EAAE,8BAA8B;IACnC,OAAO,EAAE,wCAAwC;IACjD,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,wBAAwB;IAC/B,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;SACf;QACD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;SACf;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
|