@shoper/cli 0.9.6-0 → 0.9.6-1

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.
@@ -1,7 +1,6 @@
1
1
  import { copyFile, fileExists, readJSONFile, readJSONFileSync, removeFile } from '../../../utils/fs/fs_utils.js';
2
2
  import { ThemeChecksumsUtils } from './theme_checksums_utils.js';
3
- import { isWindowsOs } from '../../../utils/platform_utils.js';
4
- import { join, mapKeysPathsToWindowPlatform, toCurrentPlatformPath } from '../../../utils/path_utils.js';
3
+ import { join, normalizeObjectPathKeys, toCurrentPlatformPath } from '../../../utils/path_utils.js';
5
4
  import { createWriteStream } from 'node:fs';
6
5
  import { JSON_FILE_INDENT } from '../../../cli/cli_constants.js';
7
6
  import { ThemeChecksumsErrorFactory } from './theme_checksums_error_factory.js';
@@ -204,15 +203,11 @@ export class ThemeChecksums {
204
203
  }
205
204
  async _getChecksums(path) {
206
205
  const checksums = await readJSONFile(path);
207
- if (!isWindowsOs())
208
- return checksums;
209
- return mapKeysPathsToWindowPlatform(checksums);
206
+ return normalizeObjectPathKeys(checksums);
210
207
  }
211
208
  _getChecksumsSync(path) {
212
209
  const checksums = readJSONFileSync(path);
213
- if (!isWindowsOs())
214
- return checksums;
215
- return mapKeysPathsToWindowPlatform(checksums);
210
+ return normalizeObjectPathKeys(checksums);
216
211
  }
217
212
  async _createThemeChecksumVerifyFile(checksumFilePath, checksumVerifyFullPath) {
218
213
  this.#loggerApi?.debug('Creating checksum verification file.', { details: { path: checksumVerifyFullPath } });
@@ -1,8 +1,7 @@
1
1
  import { fileExists, isDirectory, readJSONFile, removeFile, writeJSONFile } from '../../../../../utils/fs/fs_utils.js';
2
- import { join, looksLikeDirectory, mapKeysPathsToWindowPlatform, toUnixPath } from '../../../../../utils/path_utils.js';
2
+ import { join, looksLikeDirectory, normalizeObjectPathKeys, toUnixPath } from '../../../../../utils/path_utils.js';
3
3
  import { SHOPER_THEME_METADATA_DIR } from '../../../../constants/directory_contstants.js';
4
4
  import { THEME_CURRENT_CHECKSUMS_FILE_NAME, THEME_CURRENT_CHECKSUMS_VERITY_FILE_NAME, THEME_FILES_STRUCTURE_FILE_NAME, THEME_INITIAL_CHECKSUMS_FILE_NAME, THEME_INITIAL_CHECKSUMS_VERITY_FILE_NAME } from '../../theme_constants.js';
5
- import { isWindowsOs } from '../../../../../utils/platform_utils.js';
6
5
  import { validateDirectory } from '../../../../utils/directory_validator/directory_validator_utils.js';
7
6
  import path from 'node:path';
8
7
  import { THEME_FILES_LIST_FILE_NAME } from '../../push/theme_push_constants.js';
@@ -12,9 +11,7 @@ import { loadShoperIgnore } from '../../../../utils/shoperignore/shoperignore_ut
12
11
  export class ThemeFilesUtils {
13
12
  static async getThemeFilesStructure(themeDirectory) {
14
13
  const filesStructure = await readJSONFile(join(themeDirectory, SHOPER_THEME_METADATA_DIR, THEME_FILES_STRUCTURE_FILE_NAME));
15
- if (!isWindowsOs())
16
- return filesStructure;
17
- return mapKeysPathsToWindowPlatform(filesStructure);
14
+ return normalizeObjectPathKeys(filesStructure);
18
15
  }
19
16
  static async writeThemeFilesStructure(themeDirectory, filesStructure) {
20
17
  const filePath = join(themeDirectory, SHOPER_THEME_METADATA_DIR, THEME_FILES_STRUCTURE_FILE_NAME);
@@ -51,12 +51,12 @@ export const isUnixPath = (path) => {
51
51
  return !path.includes('\\') && (path.startsWith('/') || path.includes('/'));
52
52
  };
53
53
  export const platformSeparator = sep;
54
- export const mapKeysPathsToWindowPlatform = (paths) => {
55
- return Object.entries(paths).reduce((acc, [path, value]) => {
56
- return {
57
- ...acc,
58
- [toWinowsPath(path)]: value
59
- };
54
+ export const normalizeObjectPathKeys = (obj) => {
55
+ if (!obj)
56
+ return {};
57
+ return Object.entries(obj).reduce((acc, [key, value]) => {
58
+ acc[key.replace(/[\\/]/g, sep)] = value;
59
+ return acc;
60
60
  }, {});
61
61
  };
62
62
  export const toCurrentPlatformPath = (path) => (isWindowsOs() ? toWinowsPath(path) : toUnixPath(path));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shoper/cli",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "0.9.6-0",
5
+ "version": "0.9.6-1",
6
6
  "description": "CLI tool for Shoper",
7
7
  "author": "Joanna Firek",
8
8
  "license": "MIT",