@bigcommerce/stencil-cli 7.1.1 → 7.1.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.
- package/lib/stencil-pull.js +1 -0
- package/lib/stencil-pull.utils.js +31 -5
- package/package.json +1 -1
package/lib/stencil-pull.js
CHANGED
|
@@ -12,6 +12,7 @@ function stencilPull(options = {}, callback) {
|
|
|
12
12
|
stencilPushUtils.promptUserForChannel,
|
|
13
13
|
stencilPullUtils.getChannelActiveTheme,
|
|
14
14
|
stencilPullUtils.getThemeConfiguration,
|
|
15
|
+
stencilPullUtils.getCurrentVariation,
|
|
15
16
|
stencilPullUtils.mergeThemeConfiguration,
|
|
16
17
|
],
|
|
17
18
|
callback,
|
|
@@ -26,6 +26,28 @@ utils.getChannelActiveTheme = async (options) => {
|
|
|
26
26
|
return { ...options, activeTheme };
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
utils.getCurrentVariation = async (options) => {
|
|
30
|
+
const {
|
|
31
|
+
config: { accessToken },
|
|
32
|
+
storeHash,
|
|
33
|
+
activeTheme,
|
|
34
|
+
saved,
|
|
35
|
+
remoteThemeConfiguration,
|
|
36
|
+
} = options;
|
|
37
|
+
const apiHost = options.apiHost || options.config.apiHost;
|
|
38
|
+
const themeId = activeTheme.active_theme_uuid;
|
|
39
|
+
const variations = await themeApiClient.getVariationsByThemeId({
|
|
40
|
+
accessToken,
|
|
41
|
+
apiHost,
|
|
42
|
+
storeHash,
|
|
43
|
+
themeId,
|
|
44
|
+
});
|
|
45
|
+
const variation = variations.find((v) => v.uuid === remoteThemeConfiguration.variation_uuid);
|
|
46
|
+
|
|
47
|
+
console.log('ok'.green + ` -- Fetched ${saved ? 'saved' : 'active'} variation name`);
|
|
48
|
+
return { ...options, variation };
|
|
49
|
+
};
|
|
50
|
+
|
|
29
51
|
utils.getThemeConfiguration = async (options) => {
|
|
30
52
|
const {
|
|
31
53
|
config: { accessToken },
|
|
@@ -59,6 +81,7 @@ utils.mergeThemeConfiguration = async (options) => {
|
|
|
59
81
|
const { remoteThemeConfiguration } = options;
|
|
60
82
|
|
|
61
83
|
const localConfig = await parseJsonFile('config.json');
|
|
84
|
+
const variation = localConfig.variations.find((v) => v.name === options.variation.name);
|
|
62
85
|
let diffDetected = false;
|
|
63
86
|
|
|
64
87
|
// For any keys the remote configuration has in common with the local configuration,
|
|
@@ -67,19 +90,22 @@ utils.mergeThemeConfiguration = async (options) => {
|
|
|
67
90
|
if (!(key in localConfig.settings)) {
|
|
68
91
|
continue;
|
|
69
92
|
}
|
|
70
|
-
const
|
|
93
|
+
const defaultVal = localConfig.settings[key];
|
|
71
94
|
|
|
72
95
|
// Check for different types, and throw an error if they are found
|
|
73
|
-
if (typeof
|
|
96
|
+
if (typeof defaultVal !== typeof remoteVal) {
|
|
74
97
|
throw new Error(
|
|
75
98
|
`Theme configuration key "${key}" cannot be merged because it is not of the same type. ` +
|
|
76
|
-
`Remote configuration is of type ${typeof remoteVal} while local configuration is of type ${typeof
|
|
99
|
+
`Remote configuration is of type ${typeof remoteVal} while local configuration is of type ${typeof defaultVal}.`,
|
|
77
100
|
);
|
|
78
101
|
}
|
|
79
102
|
|
|
80
103
|
// If a different value is found, overwrite the local config
|
|
81
|
-
if (!_.isEqual(
|
|
82
|
-
|
|
104
|
+
if (!_.isEqual(defaultVal, remoteVal)) {
|
|
105
|
+
if (!variation.settings) {
|
|
106
|
+
variation.settings = {};
|
|
107
|
+
}
|
|
108
|
+
variation.settings[key] = remoteVal;
|
|
83
109
|
diffDetected = true;
|
|
84
110
|
}
|
|
85
111
|
}
|