@shopify/shop-minis-cli 0.0.141 → 0.0.143
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/app/index.js +1 -1
- package/build/commands/app/index.js.map +1 -1
- package/build/commands/app/link.js +3 -1
- package/build/commands/app/link.js.map +1 -1
- package/build/commands/create-mini/index.js +49 -22
- package/build/commands/create-mini/index.js.map +1 -1
- package/build/commands/dev/utils/app-screens.js +6 -0
- package/build/commands/dev/utils/app-screens.js.map +1 -1
- package/build/commands/dev/utils/interactive-terminal.js +8 -2
- package/build/commands/dev/utils/interactive-terminal.js.map +1 -1
- package/build/commands/dev/utils/metro/metro-reporter.js +0 -1
- package/build/commands/dev/utils/metro/metro-reporter.js.map +1 -1
- package/build/commands/setup/index.js +86 -77
- package/build/commands/setup/index.js.map +1 -1
- package/build/data/get-linked-apps.d.ts +2 -2
- package/build/data/mini-create.d.ts +2 -5
- package/build/data/mini-create.js +4 -9
- package/build/data/mini-create.js.map +1 -1
- package/build/data/mini-link-app.d.ts +3 -2
- package/build/data/mini-link-app.js +8 -2
- package/build/data/mini-link-app.js.map +1 -1
- package/build/data/mini-unlink-app.d.ts +1 -1
- package/build/data/mini.d.ts +1 -1
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.d.ts +6 -6
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.js +2 -2
- package/build/data/types/autogenerated/shop-minis-admin-api/gql.js.map +1 -1
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.d.ts +25 -18
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js +25 -30
- package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/schemas/manifest.schema.json +3 -8
- package/build/utils/sync-manifest.d.ts +2 -2
- package/build/utils/sync-manifest.js +2 -1
- package/build/utils/sync-manifest.js.map +1 -1
- package/package.json +3 -3
- package/templates/__template_getting_started/src/manifest.json +7 -0
- package/templates/__template_getting_started/src/screens/HomeScreen.tsx +15 -21
- package/build/commands/setup/create.d.ts +0 -3
- package/build/commands/setup/create.js +0 -107
- package/build/commands/setup/create.js.map +0 -1
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.143",
|
|
8
8
|
"description": "Shop Minis CLI",
|
|
9
9
|
"main": "build/index.js",
|
|
10
10
|
"bin": {
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"json5": "^2.2.3",
|
|
83
83
|
"jsonschema": "^1.4.1",
|
|
84
84
|
"lodash": "^4.17.21",
|
|
85
|
-
"metro": "0.80.
|
|
86
|
-
"metro-config": "0.80.
|
|
85
|
+
"metro": "0.80.12",
|
|
86
|
+
"metro-config": "0.80.12",
|
|
87
87
|
"metro-core": "0.80.4",
|
|
88
88
|
"open": "^8.4.0",
|
|
89
89
|
"ora": "^5.4.1",
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
useTheme,
|
|
13
13
|
Button,
|
|
14
14
|
TextField,
|
|
15
|
-
|
|
15
|
+
RadioButton,
|
|
16
16
|
} from '@shopify/shop-minis-platform-sdk'
|
|
17
17
|
|
|
18
18
|
import {RootStackParamList} from '../types/screens'
|
|
@@ -32,7 +32,9 @@ export function HomeScreen() {
|
|
|
32
32
|
'gid://shopify/Shop/62104633599'
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
-
const [
|
|
35
|
+
const radioButtonOptions = ['Option A', 'Option B', 'Option C']
|
|
36
|
+
|
|
37
|
+
const [selectedOption, setSelectedOption] = useState(radioButtonOptions[0])
|
|
36
38
|
|
|
37
39
|
return (
|
|
38
40
|
<SafeAreaView
|
|
@@ -91,25 +93,17 @@ export function HomeScreen() {
|
|
|
91
93
|
<Box marginBottom="s">
|
|
92
94
|
<TextField placeholder="Text input" />
|
|
93
95
|
</Box>
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{label: 'Red', value: 'Red'},
|
|
106
|
-
{label: 'Green', value: 'Green'},
|
|
107
|
-
{label: 'Blue', value: 'Blue'},
|
|
108
|
-
]}
|
|
109
|
-
handleDismiss={() => setPickerVisible(false)}
|
|
110
|
-
headerText="Select a color"
|
|
111
|
-
/>
|
|
112
|
-
) : null}
|
|
96
|
+
<Text>Radio buttons</Text>
|
|
97
|
+
{radioButtonOptions.map(option => (
|
|
98
|
+
<Box key={option} marginVertical="xs">
|
|
99
|
+
<RadioButton
|
|
100
|
+
variant="tertiary"
|
|
101
|
+
text={option}
|
|
102
|
+
active={selectedOption === option}
|
|
103
|
+
onPress={() => setSelectedOption(option)}
|
|
104
|
+
/>
|
|
105
|
+
</Box>
|
|
106
|
+
))}
|
|
113
107
|
<Text marginBottom="s">
|
|
114
108
|
Ready for more? Let's explore native capabilities in the
|
|
115
109
|
screen.
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { renderSelectPrompt, renderSuccess, renderInfo, renderError, } from '@shopify/cli-kit/node/ui';
|
|
5
|
-
import { AbortError, handler as handleError } from '@shopify/cli-kit/node/error';
|
|
6
|
-
import _ from 'lodash';
|
|
7
|
-
import { fetchAllOrgs, fetchAppsForOrg, token, } from '../../data/partners/query.js';
|
|
8
|
-
import { miniCreate } from '../../data/mini-create.js';
|
|
9
|
-
import { getMiniManifest } from '../../utils/minis-manifest.js';
|
|
10
|
-
import { syncManifest } from '../../utils/sync-manifest.js';
|
|
11
|
-
export async function loginAndSetup() {
|
|
12
|
-
const envFilePath = path.join(process.cwd(), '.env');
|
|
13
|
-
let envFileContents = '';
|
|
14
|
-
if (fs.existsSync(envFilePath)) {
|
|
15
|
-
envFileContents = fs.readFileSync(envFilePath, 'utf-8');
|
|
16
|
-
// Prevent creating a new Mini if SHOP_MINIS_API_KEY is already set
|
|
17
|
-
if (envFileContents.includes('SHOP_MINIS_API_KEY')) {
|
|
18
|
-
console.error('SHOP_MINIS_API_KEY is already set in your .env file.');
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const { handle: miniHandle, name: miniName } = getMiniManifest();
|
|
23
|
-
// Select the organization
|
|
24
|
-
const organizations = await fetchAllOrgs();
|
|
25
|
-
const orgId = await renderSelectPrompt({
|
|
26
|
-
message: 'Select your organization',
|
|
27
|
-
choices: organizations.map(org => ({
|
|
28
|
-
label: org.businessName,
|
|
29
|
-
value: org.id,
|
|
30
|
-
})),
|
|
31
|
-
});
|
|
32
|
-
// Select the app
|
|
33
|
-
const apps = await fetchAppsForOrg(orgId);
|
|
34
|
-
if (apps.apps.length === 0) {
|
|
35
|
-
renderInfo({
|
|
36
|
-
body: 'No apps found in the selected organization. Please create a Shopify app by following this guide before continuing: https://shopify.dev/docs/apps/build/scaffold-app.',
|
|
37
|
-
});
|
|
38
|
-
process.exit(0);
|
|
39
|
-
}
|
|
40
|
-
const appId = await renderSelectPrompt({
|
|
41
|
-
message: 'Select your app',
|
|
42
|
-
choices: apps.apps.map(app => ({
|
|
43
|
-
label: app.title,
|
|
44
|
-
value: app.id,
|
|
45
|
-
})),
|
|
46
|
-
});
|
|
47
|
-
const selectedApp = apps.apps.find(app => app.id === appId);
|
|
48
|
-
const result = await miniCreate({
|
|
49
|
-
name: miniName,
|
|
50
|
-
handle: miniHandle ?? _.kebabCase(miniName),
|
|
51
|
-
appApiKey: selectedApp.apiKey,
|
|
52
|
-
partnersAccessToken: await token(),
|
|
53
|
-
});
|
|
54
|
-
if (result.userErrors.length > 0) {
|
|
55
|
-
if (result.userErrors.length === 1) {
|
|
56
|
-
if (result.userErrors[0].code === 'HANDLE_NOT_UNIQUE') {
|
|
57
|
-
renderError({
|
|
58
|
-
body: `A Shop Mini with the name "${miniName}" already exists. Please choose a different name by updating src/manifest.json.`,
|
|
59
|
-
});
|
|
60
|
-
process.exit(0);
|
|
61
|
-
}
|
|
62
|
-
else if (result.userErrors[0].code === 'APP_ALREADY_LINKED') {
|
|
63
|
-
renderError({
|
|
64
|
-
body: `Your Shopify app "${selectedApp.title}" has already been linked to a Shop Mini. Please create a new Shopify app to link to your mini by following this guide: https://shopify.dev/docs/apps/build/scaffold-app.`,
|
|
65
|
-
});
|
|
66
|
-
process.exit(0);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
throw new AbortError(result.userErrors[0].message);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
throw new AbortError(result.userErrors.map(({ message }) => message).join('\n'));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Append the new SHOP_MINIS_API_KEY to the .env file
|
|
77
|
-
envFileContents += `\nSHOP_MINIS_API_KEY=${result.token}`;
|
|
78
|
-
fs.writeFileSync(envFilePath, envFileContents, {
|
|
79
|
-
encoding: 'utf-8',
|
|
80
|
-
});
|
|
81
|
-
// Sync the manifest
|
|
82
|
-
if (result.mini) {
|
|
83
|
-
syncManifest(result.mini);
|
|
84
|
-
renderSuccess({
|
|
85
|
-
headline: 'Shop Mini created',
|
|
86
|
-
body: [
|
|
87
|
-
'Shop Mini with handle',
|
|
88
|
-
{
|
|
89
|
-
bold: result.mini.handle,
|
|
90
|
-
},
|
|
91
|
-
'has been created.',
|
|
92
|
-
],
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export const command = new Command()
|
|
97
|
-
.name('create')
|
|
98
|
-
.description('Create a new Shop Mini')
|
|
99
|
-
.action(async () => {
|
|
100
|
-
try {
|
|
101
|
-
await loginAndSetup();
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
handleError(error);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
//# sourceMappingURL=create.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/setup/create.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,MAAM,SAAS,CAAA;AAExB,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,WAAW,GACZ,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAC,UAAU,EAAE,OAAO,IAAI,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAC9E,OAAO,CAAC,MAAM,QAAQ,CAAA;AAEtB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,KAAK,GACN,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAA;AAEzD,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAA;IACpD,IAAI,eAAe,GAAG,EAAE,CAAA;IAExB,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAC9B,eAAe,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;QACvD,mEAAmE;QACnE,IAAI,eAAe,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE;YAClD,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAA;YACrE,OAAM;SACP;KACF;IAED,MAAM,EAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAC,GA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