@shoper/cli 0.6.3 → 0.6.4-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/build/theme/class/checksums/theme_checksums.js +3 -0
- package/build/theme/features/theme/utils/hidden_directory/hidden_directory_utils.js +1 -0
- package/build/utils/checksums/checksums_utils.js +2 -0
- package/package.json +1 -1
- package/build/theme/features/theme/watch/api/theme_watch_api.js +0 -11
- package/build/theme/features/theme/watch/service/theme_watch_service.js +0 -48
- package/build/theme/features/theme/watch/theme_watch_constants.js +0 -2
- package/build/theme/features/theme/watch/theme_watch_initializer.js +0 -20
|
@@ -80,8 +80,11 @@ export class ThemeChecksums {
|
|
|
80
80
|
async verify() {
|
|
81
81
|
const initialChecksumFilePath = this.#initialChecksumsFilePath;
|
|
82
82
|
const initialChecksumVerifyFilePath = this.#initialChecksumsVerificationFilePath;
|
|
83
|
+
console.log('Verifying theme checksums:', { initialChecksumFilePath, initialChecksumVerifyFilePath });
|
|
83
84
|
const initialChecksum = await computeFileChecksum(initialChecksumFilePath);
|
|
84
85
|
const initialChecksumVerify = await readJSONFile(initialChecksumVerifyFilePath);
|
|
86
|
+
console.log('initialChecksum current:', initialChecksum);
|
|
87
|
+
console.log('initialChecksumVerify:', initialChecksumVerify);
|
|
85
88
|
return initialChecksum === initialChecksumVerify;
|
|
86
89
|
}
|
|
87
90
|
async updateAllChecksums() {
|
|
@@ -7,6 +7,7 @@ import { ThemeChecksums } from '../../../../class/checksums/theme_checksums.js';
|
|
|
7
7
|
export class HiddenDirectoryUtils {
|
|
8
8
|
static async ensureFilesInsideThemeMetaDataDirectoryUntouched(themeDirectory, logger) {
|
|
9
9
|
const themeMetadataPath = this.getThemeHiddenDirectoryPath(themeDirectory);
|
|
10
|
+
console.log('themeMetadataPath', themeMetadataPath);
|
|
10
11
|
const themeChecksums = new ThemeChecksums({
|
|
11
12
|
themeDir: themeDirectory,
|
|
12
13
|
loggerApi: logger
|
|
@@ -12,6 +12,8 @@ export const computeFileChecksum = async (filePath, algorithm = 'md5') => {
|
|
|
12
12
|
const hash = createHash(algorithm);
|
|
13
13
|
const stream = createReadStream(filePath);
|
|
14
14
|
stream.on('data', (data) => {
|
|
15
|
+
console.log('data chunk received for hashing');
|
|
16
|
+
console.log('data', data);
|
|
15
17
|
hash.update(data);
|
|
16
18
|
});
|
|
17
19
|
stream.on('close', () => {
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { FeatureApi } from '@dreamcommerce/star_core';
|
|
2
|
-
export class ThemeWatchApi extends FeatureApi {
|
|
3
|
-
#service;
|
|
4
|
-
constructor(service) {
|
|
5
|
-
super();
|
|
6
|
-
this.#service = service;
|
|
7
|
-
}
|
|
8
|
-
async watchTheme(props) {
|
|
9
|
-
return this.#service.watchTheme(props);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// import chokidar from 'chokidar';
|
|
2
|
-
import { relative } from '../../../../../utils/path_utils.js';
|
|
3
|
-
export class ThemeWatchService {
|
|
4
|
-
#themePushApi;
|
|
5
|
-
constructor({ themePushApi }) {
|
|
6
|
-
this.#themePushApi = themePushApi;
|
|
7
|
-
}
|
|
8
|
-
async watchTheme({ themeChecksums, executionContext, onChange, credentials, themeFilesUploadApi, filesStructure, action }) {
|
|
9
|
-
const themePath = executionContext.themeRootDir;
|
|
10
|
-
console.log(`[watch] Watching for changes in: ${themePath}`);
|
|
11
|
-
// const watcher = chokidar.watch(themePath, {
|
|
12
|
-
// ignored: /(^|[\/\\])\../, // ignore dotfiles
|
|
13
|
-
// persistent: true,
|
|
14
|
-
// ignoreInitial: true // Don't trigger on initial scan
|
|
15
|
-
// });
|
|
16
|
-
const handleFileChange = async (filePath) => {
|
|
17
|
-
const relativePath = relative(themePath, filePath);
|
|
18
|
-
console.log(`[watch] Detected change in: ${relativePath}. Pushing theme...`);
|
|
19
|
-
try {
|
|
20
|
-
// Assuming pushTheme handles the logic of pushing the entire theme
|
|
21
|
-
return;
|
|
22
|
-
//@ts-ignore
|
|
23
|
-
await this.#themePushApi.partialPush({
|
|
24
|
-
credentials,
|
|
25
|
-
filesStructure,
|
|
26
|
-
action,
|
|
27
|
-
executionContext,
|
|
28
|
-
themeChecksums,
|
|
29
|
-
themeFilesUploadApi
|
|
30
|
-
});
|
|
31
|
-
console.log(`[watch] Theme pushed successfully.`);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.error(`[watch] Error pushing theme:`, error);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
//
|
|
38
|
-
// watcher
|
|
39
|
-
// .on('add', handleFileChange)
|
|
40
|
-
// .on('change', handleFileChange)
|
|
41
|
-
// .on('unlink', handleFileChange)
|
|
42
|
-
// //@ts-ignore
|
|
43
|
-
// .on('error', (error) => console.error(`[watch] Watcher error: ${error}`))
|
|
44
|
-
// .on('ready', () => console.log('[watch] Initial scan complete. Ready for changes.'));
|
|
45
|
-
// Keep the process alive while watching
|
|
46
|
-
return new Promise(() => { });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FEATURE_CORES_TYPES, SyncFeatureInitializer } from '@dreamcommerce/star_core';
|
|
2
|
-
import { THEME_WATCH_FEATURE_NAME } from './theme_watch_constants.js';
|
|
3
|
-
import { ThemeWatchService } from './service/theme_watch_service.js';
|
|
4
|
-
import { THEME_PUSH_API_NAME } from '../push/theme_push_constants.js';
|
|
5
|
-
import { ThemeWatchApi } from './api/theme_watch_api.js';
|
|
6
|
-
export class ThemeWatchInitializer extends SyncFeatureInitializer {
|
|
7
|
-
static featureName = THEME_WATCH_FEATURE_NAME;
|
|
8
|
-
init() {
|
|
9
|
-
const themePushApi = this.getApiSync(THEME_PUSH_API_NAME);
|
|
10
|
-
const service = new ThemeWatchService({ themePushApi });
|
|
11
|
-
return {
|
|
12
|
-
cores: [
|
|
13
|
-
{
|
|
14
|
-
type: FEATURE_CORES_TYPES.api,
|
|
15
|
-
instance: new ThemeWatchApi(service)
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
}
|