@shopify/cli-hydrogen 13.0.1 → 13.0.2
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.
|
@@ -3,7 +3,7 @@ import Command from '@shopify/cli-kit/node/base-command';
|
|
|
3
3
|
import { basename } from '@shopify/cli-kit/node/path';
|
|
4
4
|
import { renderSuccess, renderConfirmationPrompt, renderWarning, renderTextPrompt, renderTasks } from '@shopify/cli-kit/node/ui';
|
|
5
5
|
import { AbortError } from '@shopify/cli-kit/node/error';
|
|
6
|
-
import { commonFlags } from '../../lib/flags.js';
|
|
6
|
+
import { commonFlags, flagsToCamelObject } from '../../lib/flags.js';
|
|
7
7
|
import { getStorefronts } from '../../lib/graphql/admin/link-storefront.js';
|
|
8
8
|
import { setStorefront } from '../../lib/shopify-config.js';
|
|
9
9
|
import { createStorefront } from '../../lib/graphql/admin/create-storefront.js';
|
|
@@ -23,28 +23,45 @@ class Link extends Command {
|
|
|
23
23
|
static flags = {
|
|
24
24
|
...commonFlags.force,
|
|
25
25
|
...commonFlags.path,
|
|
26
|
+
...commonFlags.shop,
|
|
26
27
|
storefront: Flags.string({
|
|
27
28
|
description: `The name of a Hydrogen Storefront (e.g. "Jane's Apparel")`,
|
|
28
|
-
env: "SHOPIFY_HYDROGEN_STOREFRONT"
|
|
29
|
+
env: "SHOPIFY_HYDROGEN_STOREFRONT",
|
|
30
|
+
exclusive: ["create-storefront", "name"]
|
|
31
|
+
}),
|
|
32
|
+
"create-storefront": Flags.boolean({
|
|
33
|
+
description: "Create a new Hydrogen storefront.",
|
|
34
|
+
env: "SHOPIFY_HYDROGEN_FLAG_CREATE_STOREFRONT",
|
|
35
|
+
exclusive: ["storefront"]
|
|
36
|
+
}),
|
|
37
|
+
name: Flags.string({
|
|
38
|
+
description: "The name to use when creating a new Hydrogen storefront.",
|
|
39
|
+
env: "SHOPIFY_HYDROGEN_FLAG_NAME",
|
|
40
|
+
exclusive: ["storefront"]
|
|
29
41
|
})
|
|
30
42
|
};
|
|
31
43
|
async run() {
|
|
32
44
|
const { flags } = await this.parse(Link);
|
|
33
|
-
await runLink(flags);
|
|
45
|
+
await runLink(flagsToCamelObject(flags));
|
|
34
46
|
}
|
|
35
47
|
}
|
|
36
48
|
async function runLink({
|
|
49
|
+
createStorefront: flagCreateStorefront,
|
|
37
50
|
force,
|
|
38
51
|
path: root = process.cwd(),
|
|
39
|
-
|
|
52
|
+
shop,
|
|
53
|
+
storefront: flagStorefront,
|
|
54
|
+
name
|
|
40
55
|
}) {
|
|
41
56
|
const [{ session, config }, cliCommand] = await Promise.all([
|
|
42
|
-
login(root),
|
|
57
|
+
login(root, shop),
|
|
43
58
|
getCliCommand()
|
|
44
59
|
]);
|
|
45
60
|
const linkedStore = await linkStorefront(root, session, config, {
|
|
46
61
|
force,
|
|
62
|
+
flagCreateStorefront,
|
|
47
63
|
flagStorefront,
|
|
64
|
+
storefrontName: name,
|
|
48
65
|
cliCommand
|
|
49
66
|
});
|
|
50
67
|
if (!linkedStore) return;
|
|
@@ -61,10 +78,19 @@ async function runLink({
|
|
|
61
78
|
}
|
|
62
79
|
async function linkStorefront(root, session, config, {
|
|
63
80
|
force = false,
|
|
81
|
+
flagCreateStorefront,
|
|
64
82
|
flagStorefront,
|
|
83
|
+
storefrontName,
|
|
65
84
|
cliCommand,
|
|
66
85
|
storefronts
|
|
67
86
|
}) {
|
|
87
|
+
storefrontName = storefrontName?.trim() || void 0;
|
|
88
|
+
if (flagStorefront && (flagCreateStorefront || storefrontName)) {
|
|
89
|
+
throw new AbortError(
|
|
90
|
+
"`--storefront` cannot be used with storefront creation flags.",
|
|
91
|
+
"Use `--storefront` to link an existing storefront or `--name` to create a new one."
|
|
92
|
+
);
|
|
93
|
+
}
|
|
68
94
|
if (!config.shop) {
|
|
69
95
|
throw new AbortError("No shop found in local config, login first.");
|
|
70
96
|
}
|
|
@@ -100,6 +126,13 @@ async function linkStorefront(root, session, config, {
|
|
|
100
126
|
});
|
|
101
127
|
return;
|
|
102
128
|
}
|
|
129
|
+
} else if (flagCreateStorefront || storefrontName) {
|
|
130
|
+
selectedStorefront = await createNewStorefront(
|
|
131
|
+
root,
|
|
132
|
+
session,
|
|
133
|
+
storefronts,
|
|
134
|
+
storefrontName
|
|
135
|
+
);
|
|
103
136
|
} else {
|
|
104
137
|
selectedStorefront = await handleStorefrontSelection(storefronts);
|
|
105
138
|
if (!selectedStorefront) {
|
|
@@ -113,7 +146,7 @@ async function linkStorefront(root, session, config, {
|
|
|
113
146
|
await setStorefront(root, selectedStorefront);
|
|
114
147
|
return selectedStorefront;
|
|
115
148
|
}
|
|
116
|
-
async function createNewStorefront(root, session, storefronts) {
|
|
149
|
+
async function createNewStorefront(root, session, storefronts, storefrontName) {
|
|
117
150
|
const projectDirectory = basename(root);
|
|
118
151
|
let defaultProjectName = titleize(projectDirectory);
|
|
119
152
|
const nameAlreadyUsed = storefronts.some(
|
|
@@ -122,7 +155,7 @@ async function createNewStorefront(root, session, storefronts) {
|
|
|
122
155
|
if (nameAlreadyUsed) {
|
|
123
156
|
defaultProjectName = generateRandomName();
|
|
124
157
|
}
|
|
125
|
-
const projectName = await renderTextPrompt({
|
|
158
|
+
const projectName = storefrontName ?? await renderTextPrompt({
|
|
126
159
|
message: "New storefront name",
|
|
127
160
|
defaultValue: defaultProjectName
|
|
128
161
|
});
|
|
@@ -49,7 +49,7 @@ let CACHED_CHANGELOG = null;
|
|
|
49
49
|
async function runUpgrade({
|
|
50
50
|
appPath,
|
|
51
51
|
version: targetVersion,
|
|
52
|
-
force
|
|
52
|
+
force = false
|
|
53
53
|
}) {
|
|
54
54
|
if (targetVersion === "next") {
|
|
55
55
|
const isInTests = process.env.SHOPIFY_UNIT_TEST === "1";
|
|
@@ -115,7 +115,7 @@ async function runUpgrade({
|
|
|
115
115
|
currentDependencies,
|
|
116
116
|
selectedRelease
|
|
117
117
|
});
|
|
118
|
-
confirmed = await displayConfirmation({
|
|
118
|
+
confirmed = force || await displayConfirmation({
|
|
119
119
|
cumulativeRelease,
|
|
120
120
|
selectedRelease,
|
|
121
121
|
targetVersion
|
|
@@ -125,7 +125,8 @@ async function runUpgrade({
|
|
|
125
125
|
appPath,
|
|
126
126
|
cumulativeRelease,
|
|
127
127
|
currentVersion,
|
|
128
|
-
selectedRelease
|
|
128
|
+
selectedRelease,
|
|
129
|
+
force
|
|
129
130
|
});
|
|
130
131
|
await upgradeNodeModules({
|
|
131
132
|
appPath,
|
|
@@ -880,7 +881,8 @@ async function generateUpgradeInstructionsFile({
|
|
|
880
881
|
appPath,
|
|
881
882
|
cumulativeRelease,
|
|
882
883
|
currentVersion,
|
|
883
|
-
selectedRelease
|
|
884
|
+
selectedRelease,
|
|
885
|
+
force = false
|
|
884
886
|
}) {
|
|
885
887
|
let filename = "";
|
|
886
888
|
const { featuresMd, breakingChangesMd } = cumulativeRelease.features.filter((feature) => feature.steps).reduce(
|
|
@@ -955,7 +957,7 @@ The following packages have been removed as part of this upgrade:
|
|
|
955
957
|
if (!await fileExists(filePath)) {
|
|
956
958
|
await touchFile(filePath);
|
|
957
959
|
} else {
|
|
958
|
-
const overwriteMdFile = await renderConfirmationPrompt({
|
|
960
|
+
const overwriteMdFile = force || await renderConfirmationPrompt({
|
|
959
961
|
message: `A previous upgrade instructions file already exists for this version.
|
|
960
962
|
Do you want to overwrite it?`,
|
|
961
963
|
defaultValue: false
|
package/dist/index.d.ts
CHANGED
|
@@ -177,6 +177,9 @@ declare class Link extends Command {
|
|
|
177
177
|
static description: string;
|
|
178
178
|
static flags: {
|
|
179
179
|
storefront: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
180
|
+
'create-storefront': _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
181
|
+
name: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
182
|
+
shop: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
180
183
|
path: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
181
184
|
force: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
182
185
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1150,13 +1150,47 @@
|
|
|
1150
1150
|
"multiple": false,
|
|
1151
1151
|
"type": "option"
|
|
1152
1152
|
},
|
|
1153
|
+
"shop": {
|
|
1154
|
+
"char": "s",
|
|
1155
|
+
"description": "Shop URL. It can be the shop prefix (janes-apparel) or the full myshopify.com URL (janes-apparel.myshopify.com, https://janes-apparel.myshopify.com).",
|
|
1156
|
+
"env": "SHOPIFY_SHOP",
|
|
1157
|
+
"name": "shop",
|
|
1158
|
+
"hasDynamicHelp": false,
|
|
1159
|
+
"multiple": false,
|
|
1160
|
+
"type": "option"
|
|
1161
|
+
},
|
|
1153
1162
|
"storefront": {
|
|
1154
1163
|
"description": "The name of a Hydrogen Storefront (e.g. \"Jane's Apparel\")",
|
|
1155
1164
|
"env": "SHOPIFY_HYDROGEN_STOREFRONT",
|
|
1165
|
+
"exclusive": [
|
|
1166
|
+
"create-storefront",
|
|
1167
|
+
"name"
|
|
1168
|
+
],
|
|
1156
1169
|
"name": "storefront",
|
|
1157
1170
|
"hasDynamicHelp": false,
|
|
1158
1171
|
"multiple": false,
|
|
1159
1172
|
"type": "option"
|
|
1173
|
+
},
|
|
1174
|
+
"create-storefront": {
|
|
1175
|
+
"description": "Create a new Hydrogen storefront.",
|
|
1176
|
+
"env": "SHOPIFY_HYDROGEN_FLAG_CREATE_STOREFRONT",
|
|
1177
|
+
"exclusive": [
|
|
1178
|
+
"storefront"
|
|
1179
|
+
],
|
|
1180
|
+
"name": "create-storefront",
|
|
1181
|
+
"allowNo": false,
|
|
1182
|
+
"type": "boolean"
|
|
1183
|
+
},
|
|
1184
|
+
"name": {
|
|
1185
|
+
"description": "The name to use when creating a new Hydrogen storefront.",
|
|
1186
|
+
"env": "SHOPIFY_HYDROGEN_FLAG_NAME",
|
|
1187
|
+
"exclusive": [
|
|
1188
|
+
"storefront"
|
|
1189
|
+
],
|
|
1190
|
+
"name": "name",
|
|
1191
|
+
"hasDynamicHelp": false,
|
|
1192
|
+
"multiple": false,
|
|
1193
|
+
"type": "option"
|
|
1160
1194
|
}
|
|
1161
1195
|
},
|
|
1162
1196
|
"hasDynamicHelp": false,
|
|
@@ -1711,5 +1745,5 @@
|
|
|
1711
1745
|
]
|
|
1712
1746
|
}
|
|
1713
1747
|
},
|
|
1714
|
-
"version": "13.0.
|
|
1748
|
+
"version": "13.0.2"
|
|
1715
1749
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
7
|
-
"version": "13.0.
|
|
7
|
+
"version": "13.0.2",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"repository": {
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@react-router/dev": "~7.16.0",
|
|
59
59
|
"graphql-config": "^5.0.3",
|
|
60
60
|
"vite": "^5.1.0 || ^6.2.0 || ^7.0.0 || ^8.0.0",
|
|
61
|
-
"@shopify/
|
|
62
|
-
"@shopify/
|
|
61
|
+
"@shopify/mini-oxygen": "4.2.0",
|
|
62
|
+
"@shopify/hydrogen-codegen": "0.3.3"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"@graphql-codegen/cli": {
|