@shoper/cli 0.5.2-0 → 0.5.2-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.
|
@@ -25,6 +25,7 @@ import { ThemeError } from '../ui/theme_error.js';
|
|
|
25
25
|
import { mapToPermissionsTree } from '../../utils/directory_validator/directory_validator_utils.js';
|
|
26
26
|
import { mapChecksumToTree } from '../../../utils/checksums/checksums_utils.js';
|
|
27
27
|
import { ThemeUnpermittedActionsError } from './ui/theme_unpermitted_actions_error.js';
|
|
28
|
+
import { promptConfirmation } from '../../../ui/prompts/prompt_confirmation.js';
|
|
28
29
|
export class ThemePushCommand extends BaseThemeCommand {
|
|
29
30
|
static summary = 'Uploads your local theme files to the store and overwrites the current version of the theme in your store.';
|
|
30
31
|
static description = 'Check your local changes before pushing.\n\nYou must run this command from a specific theme directory (ID not needed).';
|
|
@@ -111,10 +112,12 @@ export class ThemePushCommand extends BaseThemeCommand {
|
|
|
111
112
|
themeFilesUploadApi
|
|
112
113
|
});
|
|
113
114
|
spinner.stop();
|
|
115
|
+
await promptConfirmation('Confirm');
|
|
114
116
|
renderOnce(React.createElement(ThemePushedSuccess, { themeName: await ThemeInfoUtils.getThemeName(executionContext.themeRootDir) }));
|
|
115
117
|
}
|
|
116
118
|
catch (err) {
|
|
117
119
|
spinner?.stop();
|
|
120
|
+
await promptConfirmation('Confirm');
|
|
118
121
|
renderOnce(React.createElement(ThemeError, { err: err, executionContext: executionContext }));
|
|
119
122
|
}
|
|
120
123
|
}
|
|
@@ -19,8 +19,8 @@ export const ThemeError = ({ err, executionContext }) => {
|
|
|
19
19
|
return React.createElement(ThemeWorkUrlMismatch, { command: "verify" });
|
|
20
20
|
}
|
|
21
21
|
if (err?.code === THEME_FILES_UPLOAD_ERROR) {
|
|
22
|
-
return (React.createElement(Error, { header: "Uploading theme files to the shop failed
|
|
23
|
-
React.createElement(Text, null, "
|
|
22
|
+
return (React.createElement(Error, { header: "Uploading theme files to the shop failed." },
|
|
23
|
+
React.createElement(Text, null, "Please ensure that the files are not corrupted and that the file extensions are supported.")));
|
|
24
24
|
}
|
|
25
25
|
if (err?.message) {
|
|
26
26
|
return React.createElement(ValidationErrors, { errors: err.message });
|
|
@@ -43,7 +43,9 @@ export class ThemePushService {
|
|
|
43
43
|
themeRootDir,
|
|
44
44
|
themeFilesUploadApi
|
|
45
45
|
});
|
|
46
|
-
|
|
46
|
+
if (!uploadData.isSuccess)
|
|
47
|
+
throw ThemePushErrorsFactory.createErrorWhileUploadingThemeFiles(credentials.shopUrl);
|
|
48
|
+
localFileNameToUploaded = uploadData.localFileNameToUploadedMap;
|
|
47
49
|
}
|
|
48
50
|
const themeArchivePath = join(tmpDir, `${uuid()}.zip`);
|
|
49
51
|
const filesInArchive = await ThemeActionsUtils.getFilesThatMatchesAction({
|
|
@@ -91,18 +93,19 @@ export class ThemePushService {
|
|
|
91
93
|
await themeChecksums.updateAllChecksums();
|
|
92
94
|
}
|
|
93
95
|
catch (err) {
|
|
94
|
-
console.log('err', err);
|
|
95
96
|
await ThemeFilesUtils.removeAFilesListFile(themeRootDir);
|
|
96
97
|
throw err;
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
async _uploadThemeFiles({ filesToUpload, themeRootDir, credentials, themeFilesUploadApi }) {
|
|
100
101
|
try {
|
|
101
|
-
const { uploadedImageData } = await themeFilesUploadApi.uploadFiles(filesToUpload);
|
|
102
|
+
const { uploadedImageData, rejectedImageData } = await themeFilesUploadApi.uploadFiles(filesToUpload);
|
|
102
103
|
if (uploadedImageData.length)
|
|
103
104
|
await ThemeImagesUtils.removeUploadedOriginalFiles(themeRootDir, uploadedImageData);
|
|
104
105
|
return {
|
|
105
|
-
|
|
106
|
+
isSuccess: rejectedImageData.length === 0,
|
|
107
|
+
rejectedImageData,
|
|
108
|
+
localFileNameToUploadedMap: uploadedImageData.reduce((acc, { originalFilename, uploadedFilename }) => {
|
|
106
109
|
return {
|
|
107
110
|
...acc,
|
|
108
111
|
[originalFilename]: uploadedFilename ?? originalFilename
|
|
@@ -137,7 +140,10 @@ export class ThemePushService {
|
|
|
137
140
|
return uniq(withSettingsFiles);
|
|
138
141
|
}
|
|
139
142
|
async _getAllModulesIds(themeRootDir) {
|
|
140
|
-
const
|
|
143
|
+
const modulesPath = join(themeRootDir, MODULES_DIRECTORY_NAME);
|
|
144
|
+
if (!(await fileExists(modulesPath)))
|
|
145
|
+
return [];
|
|
146
|
+
const moduleDirs = await getAllDirectoriesNamesInside(modulesPath);
|
|
141
147
|
const modulesIds = [];
|
|
142
148
|
for (const moduleDir of moduleDirs) {
|
|
143
149
|
const moduleSettingsPath = join(themeRootDir, MODULES_DIRECTORY_NAME, moduleDir, THEME_MODULE_SETTINGS_FILE_NAME);
|