@shoper/cli 0.5.2 → 0.6.0
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/README.md +4 -2
- package/build/cli/auth/cli_auth_errors_factory.js +1 -1
- package/build/cli/auth/cli_auth_initializer.js +6 -1
- package/build/cli/auth/service/cli_auth_service.js +11 -2
- package/build/cli/auth/tokens/cli_auth_tokens_errors_factory.js +1 -1
- package/build/cli/auth/tokens/cli_auth_tokens_initalizer.js +6 -1
- package/build/cli/auth/tokens/service/cli_auth_tokens_service.js +8 -1
- package/build/cli/class/base_command.js +15 -1
- package/build/cli/class/cli_help.js +24 -0
- package/build/cli/class/errors/file_system_errors_factory.js +3 -3
- package/build/cli/class/errors/http/http_errors_factory.js +1 -1
- package/build/cli/commands/auth/cli_auth_add_token_command.js +5 -0
- package/build/cli/commands/auth/cli_auth_list_tokens_command.js +20 -11
- package/build/cli/commands/auth/cli_auth_logout_command.js +5 -0
- package/build/cli/commands/auth/cli_auth_remove_token_command.js +5 -0
- package/build/cli/commands/auth/cli_auth_switch_token_command.js +8 -0
- package/build/cli/commands/cli_update_command.js +5 -0
- package/build/cli/core/cli_setup.js +5 -13
- package/build/cli/features/execution_context/execution_context_service.js +2 -0
- package/build/cli/features/version/service/cli_version_service.js +2 -2
- package/build/cli/hooks/authorization/ensure_authorization_hook.js +9 -2
- package/build/cli/hooks/ensure_cli_initialized_hook.js +1 -6
- package/build/cli/hooks/ensure_logs_flushed_hook.js +7 -0
- package/build/cli/{features → utilities/features}/http_requester/http_client.js +2 -2
- package/build/cli/{features → utilities/features}/http_requester/http_requester_initializer.js +1 -1
- package/build/cli/utilities/features/logger/api/logger_api.js +28 -0
- package/build/cli/utilities/features/logger/logger_constants.js +7 -0
- package/build/cli/utilities/features/logger/logger_initializer.js +44 -0
- package/build/cli/utilities/features/logger/logs/app_error.js +14 -0
- package/build/cli/utilities/features/logger/logs/app_log.js +40 -0
- package/build/cli/{class/errors/app/app_error_constants.js → utilities/features/logger/logs/app_logs_constants.js} +1 -1
- package/build/cli/utilities/features/logger/service/logger_service.js +108 -0
- package/build/cli/utilities/features/logger/transports/log_object_map_transport.js +15 -0
- package/build/index.js +14 -2
- package/build/theme/class/archive/theme_archive.js +2 -1
- package/build/theme/class/archive/theme_archive_errors_factory.js +2 -2
- package/build/theme/class/checksums/theme_checksums.js +25 -5
- package/build/theme/class/checksums/theme_checksums_error_factory.js +3 -3
- package/build/theme/class/fetch_resources/fetch_resources.js +34 -4
- package/build/theme/class/fetch_resources/fetch_resources_errors_factory.js +1 -1
- package/build/theme/commands/delete/theme_delete_command.js +3 -2
- package/build/theme/commands/info/theme_info_command.js +3 -0
- package/build/theme/commands/init/theme_init_command.js +10 -1
- package/build/theme/commands/list/theme_list_command.js +22 -8
- package/build/theme/commands/publish/theme_publish_command.js +5 -1
- package/build/theme/commands/pull/theme_pull_command.js +17 -5
- package/build/theme/commands/push/theme_push_command.js +7 -1
- package/build/theme/commands/theme_verify_command.js +6 -1
- package/build/theme/commands/ui/theme_error.js +1 -1
- package/build/theme/features/theme/actions/service/theme_actions_service.js +42 -2
- package/build/theme/features/theme/actions/theme_actions_initializer.js +3 -1
- package/build/theme/features/theme/delete/service/theme_delete_service.js +12 -1
- package/build/theme/features/theme/delete/theme_delete_initalizer.js +6 -1
- package/build/theme/features/theme/fetch/service/theme_fetch_service.js +35 -6
- package/build/theme/features/theme/fetch/theme_fetch_initializer.js +3 -0
- package/build/theme/features/theme/init/service/theme_init_service.js +32 -6
- package/build/theme/features/theme/init/theme_init_initializer.js +4 -1
- package/build/theme/features/theme/merge/service/theme_merge_service.js +38 -4
- package/build/theme/features/theme/merge/theme_merge_initializer.js +3 -1
- package/build/theme/features/theme/push/service/theme_push_service.js +38 -10
- package/build/theme/features/theme/push/theme_push_errors_factory.js +2 -2
- package/build/theme/features/theme/push/theme_push_initializer.js +3 -1
- package/build/theme/features/theme/push/theme_push_utils.js +1 -1
- package/build/theme/features/theme/utils/files_structure/theme_file_structure_errors_factory.js +2 -3
- package/build/theme/features/theme/utils/hidden_directory/hidden_directory_utils.js +5 -2
- package/build/theme/features/theme/utils/meta_data/theme_meta_data_error_factory.js +1 -1
- package/build/theme/features/theme/utils/resources/theme_resources_with_id_directory_utils.js +5 -2
- package/build/theme/features/theme/verify/theme_verify_initializer.js +4 -3
- package/build/theme/features/theme/verify/verify/theme_verify_service.js +20 -2
- package/build/theme/features/theme/watch/api/theme_watch_api.js +11 -0
- package/build/theme/features/theme/watch/service/theme_watch_service.js +48 -0
- package/build/theme/features/theme/watch/theme_watch_constants.js +2 -0
- package/build/theme/features/theme/watch/theme_watch_initializer.js +20 -0
- package/build/theme/features/themes/list/services/themes_list_service.js +36 -5
- package/build/theme/features/themes/list/themes_list_initializer.js +3 -1
- package/build/theme/hooks/ensure_theme_meta_data_untouched_hook.js +4 -2
- package/build/theme/hooks/theme_checksums/ensure_theme_current_checksums_up_to_date_hook.js +7 -2
- package/build/theme/hooks/themes_actions/ensure_themes_actions_hook.js +2 -3
- package/build/ui/gradient.js +2 -0
- package/build/ui/hooks/stream_hook.js +26 -0
- package/build/utils/download_file/download_file_errors_factory.js +1 -1
- package/build/utils/download_file/download_file_utils.js +19 -1
- package/build/utils/fs/errors/stream_read_error.js +7 -5
- package/build/utils/fs/errors/stream_write_error.js +7 -5
- package/build/utils/get_api.js +9 -0
- package/build/utils/use_api.js +5 -0
- package/build/utils/zip/create_zip_utils.js +21 -9
- package/build/utils/zip/errors/create_zip_error.js +7 -5
- package/build/utils/zip/errors/open_zip_error.js +7 -5
- package/build/utils/zip/extract_zip_utils.js +90 -15
- package/oclif.config.js +3 -1
- package/package.json +13 -4
- package/build/cli/class/errors/app/app_error.js +0 -17
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A React hook that subscribes to a Readable stream and returns an array of data chunks.
|
|
4
|
+
* @param stream The readable stream to listen to.
|
|
5
|
+
* @returns An array of strings received from the stream.
|
|
6
|
+
*/
|
|
7
|
+
export function useStream(stream) {
|
|
8
|
+
const [data, setData] = useState([]);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
// Do nothing if the stream is not provided
|
|
11
|
+
if (!stream) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const handleData = (chunk) => {
|
|
15
|
+
// Append the new data chunk to the state
|
|
16
|
+
setData((prevData) => [...prevData, chunk.toString()]);
|
|
17
|
+
};
|
|
18
|
+
// Subscribe to the 'data' event
|
|
19
|
+
stream.on('data', handleData);
|
|
20
|
+
// Return a cleanup function to be called on component unmount
|
|
21
|
+
return () => {
|
|
22
|
+
stream.removeListener('data', handleData);
|
|
23
|
+
};
|
|
24
|
+
}, [stream]); // Re-run the effect if the stream instance changes
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
@@ -5,8 +5,13 @@ import { basename, extname, join, parse } from '../path_utils.js';
|
|
|
5
5
|
import { FileSystemErrorsFactory } from '../../cli/class/errors/file_system_errors_factory.js';
|
|
6
6
|
import { HttpErrorsFactory } from '../../cli/class/errors/http/http_errors_factory.js';
|
|
7
7
|
import { DownloadFileErrorsFactory } from './download_file_errors_factory.js';
|
|
8
|
-
export const downloadFile = async ({ dist, request }) => {
|
|
8
|
+
export const downloadFile = async ({ dist, request, logger }) => {
|
|
9
9
|
try {
|
|
10
|
+
logger.debug('Starting file download', {
|
|
11
|
+
details: {
|
|
12
|
+
dist
|
|
13
|
+
}
|
|
14
|
+
});
|
|
10
15
|
const resp = (await request);
|
|
11
16
|
if (!resp)
|
|
12
17
|
throw resp;
|
|
@@ -17,6 +22,12 @@ export const downloadFile = async ({ dist, request }) => {
|
|
|
17
22
|
resp.data.pipe(file);
|
|
18
23
|
return new Promise((resolve, reject) => {
|
|
19
24
|
file.on('finish', () => {
|
|
25
|
+
logger.debug('File download completed', {
|
|
26
|
+
details: {
|
|
27
|
+
dist,
|
|
28
|
+
filename
|
|
29
|
+
}
|
|
30
|
+
});
|
|
20
31
|
resolve({
|
|
21
32
|
filename,
|
|
22
33
|
ext: extname(filename),
|
|
@@ -24,6 +35,13 @@ export const downloadFile = async ({ dist, request }) => {
|
|
|
24
35
|
});
|
|
25
36
|
});
|
|
26
37
|
file.on('error', (err) => {
|
|
38
|
+
logger.error('Error downloading file', {
|
|
39
|
+
error: err,
|
|
40
|
+
details: {
|
|
41
|
+
dist,
|
|
42
|
+
filename
|
|
43
|
+
}
|
|
44
|
+
});
|
|
27
45
|
if (err.code === 'ENOSPC')
|
|
28
46
|
reject(FileSystemErrorsFactory.createDiskFullError());
|
|
29
47
|
reject(DownloadFileErrorsFactory.downloadError(err.response.status));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { AppError } from '../../../cli/
|
|
1
|
+
import { AppError } from '../../../cli/utilities/features/logger/logs/app_error.js';
|
|
2
2
|
export class StreamReadError extends AppError {
|
|
3
|
-
constructor({ filePath,
|
|
3
|
+
constructor({ filePath, error }) {
|
|
4
4
|
super({
|
|
5
5
|
code: 'STREAM_READ_ERROR',
|
|
6
|
-
message: `Error while reading stream for file
|
|
7
|
-
details
|
|
8
|
-
|
|
6
|
+
message: `Error while reading stream for file`,
|
|
7
|
+
details: {
|
|
8
|
+
filePath
|
|
9
|
+
},
|
|
10
|
+
error
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { AppError } from '../../../cli/
|
|
1
|
+
import { AppError } from '../../../cli/utilities/features/logger/logs/app_error.js';
|
|
2
2
|
export class StreamWriteError extends AppError {
|
|
3
|
-
constructor({ filePath,
|
|
3
|
+
constructor({ filePath, error }) {
|
|
4
4
|
super({
|
|
5
5
|
code: 'STREAM_WRITE_ERROR',
|
|
6
|
-
message: `Error while writing to stream for file
|
|
7
|
-
details
|
|
8
|
-
|
|
6
|
+
message: `Error while writing to stream for file`,
|
|
7
|
+
details: {
|
|
8
|
+
filePath
|
|
9
|
+
},
|
|
10
|
+
error
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { API_RESOLVER_QUERIES, AppError, getStarCoreEnvironment, QueryMessage } from '@dreamcommerce/star_core';
|
|
2
|
+
export const getApiSync = (apiName) => {
|
|
3
|
+
const { queryBus } = getStarCoreEnvironment();
|
|
4
|
+
const api = queryBus.executeSync(new QueryMessage(API_RESOLVER_QUERIES.getApiSync, apiName));
|
|
5
|
+
if (!api) {
|
|
6
|
+
throw new AppError(`${apiName} hasn't been registered`);
|
|
7
|
+
}
|
|
8
|
+
return api;
|
|
9
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { API_RESOLVER_QUERIES, getStarCoreEnvironment, QueryMessage } from '@dreamcommerce/star_core';
|
|
2
|
+
export function useApi(apiName) {
|
|
3
|
+
const { queryBus } = getStarCoreEnvironment();
|
|
4
|
+
return queryBus.executeSync(new QueryMessage(API_RESOLVER_QUERIES.getApiSync, apiName));
|
|
5
|
+
}
|
|
@@ -6,10 +6,17 @@ import { StreamReadError } from '../fs/errors/stream_read_error.js';
|
|
|
6
6
|
import { CreateZipError } from './errors/create_zip_error.js';
|
|
7
7
|
import { StreamWriteError } from '../fs/errors/stream_write_error.js';
|
|
8
8
|
import { join } from '../path_utils.js';
|
|
9
|
-
import { AppError } from '../../cli/
|
|
10
|
-
export const createZip = async ({ files, dist, baseDir = process.cwd() }) => {
|
|
9
|
+
import { AppError } from '../../cli/utilities/features/logger/logs/app_error.js';
|
|
10
|
+
export const createZip = async ({ files, dist, baseDir = process.cwd(), logger }) => {
|
|
11
11
|
const zipfile = new yazl.ZipFile();
|
|
12
12
|
let hasError = false;
|
|
13
|
+
logger.debug('Starting creation of zip file', {
|
|
14
|
+
details: {
|
|
15
|
+
filesCount: files.length,
|
|
16
|
+
dist,
|
|
17
|
+
baseDir
|
|
18
|
+
}
|
|
19
|
+
});
|
|
13
20
|
try {
|
|
14
21
|
for (let i = 0; i < files.length; ++i) {
|
|
15
22
|
const file = files[i];
|
|
@@ -23,56 +30,61 @@ export const createZip = async ({ files, dist, baseDir = process.cwd() }) => {
|
|
|
23
30
|
details: { file, baseDir }
|
|
24
31
|
});
|
|
25
32
|
if (await isDirectory(fullPath)) {
|
|
33
|
+
logger.debug('Adding empty directory to zip', { details: { directory: file } });
|
|
26
34
|
zipfile.addEmptyDirectory(file);
|
|
27
35
|
}
|
|
28
36
|
else {
|
|
37
|
+
logger.debug('Adding file to zip', { details: { file, fullPath } });
|
|
29
38
|
zipfile.addFile(fullPath, file, {
|
|
30
39
|
//TODO params
|
|
31
40
|
compress: true
|
|
32
41
|
});
|
|
33
42
|
}
|
|
34
43
|
}
|
|
44
|
+
logger.debug('Finished adding all files to zip object. Finalizing archive.');
|
|
35
45
|
zipfile.end();
|
|
36
46
|
}
|
|
37
|
-
catch (
|
|
47
|
+
catch (error) {
|
|
38
48
|
throw new AppError({
|
|
39
49
|
message: 'Error creating zip file',
|
|
40
50
|
code: 'ZIP_CREATION_ERROR',
|
|
41
51
|
details: { files, dist, baseDir },
|
|
42
|
-
|
|
52
|
+
error
|
|
43
53
|
});
|
|
44
54
|
}
|
|
45
55
|
return new Promise((resolve, reject) => {
|
|
46
56
|
const zipOutput = createWriteStream(dist);
|
|
47
57
|
zipOutput.on('error', (err) => {
|
|
48
58
|
hasError = true;
|
|
59
|
+
logger.debug('Write stream error while creating zip file. Cleaning up.', { details: { dist } });
|
|
49
60
|
removeFiles(files).then(() => {
|
|
50
61
|
reject(new StreamWriteError({
|
|
51
62
|
filePath: dist,
|
|
52
|
-
|
|
53
|
-
stack: err.stack
|
|
63
|
+
error: err
|
|
54
64
|
}));
|
|
55
65
|
});
|
|
56
66
|
});
|
|
57
67
|
zipfile.outputStream.pipe(zipOutput).on('close', () => {
|
|
58
68
|
if (hasError) {
|
|
69
|
+
logger.debug('Zip stream closed with error. Cleaning up.', { details: { dist } });
|
|
59
70
|
removeFiles(files).then(() => {
|
|
60
71
|
reject(new CreateZipError({
|
|
61
72
|
file: dist,
|
|
62
|
-
|
|
73
|
+
error: new Error()
|
|
63
74
|
}));
|
|
64
75
|
});
|
|
65
76
|
return;
|
|
66
77
|
}
|
|
78
|
+
logger.debug('Zip file created successfully.', { details: { dist } });
|
|
67
79
|
resolve();
|
|
68
80
|
});
|
|
69
81
|
zipfile.outputStream.on('error', (err) => {
|
|
70
82
|
hasError = true;
|
|
83
|
+
logger.debug('Read stream error while creating zip file. Cleaning up.', { details: { dist } });
|
|
71
84
|
removeFiles(files).then(() => {
|
|
72
85
|
reject(new StreamReadError({
|
|
73
86
|
filePath: dist,
|
|
74
|
-
|
|
75
|
-
stack: err.stack
|
|
87
|
+
error: err
|
|
76
88
|
}));
|
|
77
89
|
});
|
|
78
90
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { AppError } from '../../../cli/
|
|
1
|
+
import { AppError } from '../../../cli/utilities/features/logger/logs/app_error.js';
|
|
2
2
|
export class CreateZipError extends AppError {
|
|
3
|
-
constructor({
|
|
3
|
+
constructor({ error, file }) {
|
|
4
4
|
super({
|
|
5
5
|
code: 'ZIP_FILE_CREATE_ERROR',
|
|
6
|
-
message: `Error creating zip file
|
|
7
|
-
details
|
|
8
|
-
|
|
6
|
+
message: `Error creating zip file`,
|
|
7
|
+
details: {
|
|
8
|
+
file
|
|
9
|
+
},
|
|
10
|
+
error
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { AppError } from '../../../cli/
|
|
1
|
+
import { AppError } from '../../../cli/utilities/features/logger/logs/app_error.js';
|
|
2
2
|
export class OpenZipError extends AppError {
|
|
3
|
-
constructor({
|
|
3
|
+
constructor({ error, file }) {
|
|
4
4
|
super({
|
|
5
5
|
code: 'ZIP_FILE_OPEN_ERROR',
|
|
6
|
-
message: `Error opening zip file
|
|
7
|
-
details
|
|
8
|
-
|
|
6
|
+
message: `Error opening zip file`,
|
|
7
|
+
details: {
|
|
8
|
+
file
|
|
9
|
+
},
|
|
10
|
+
error
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -6,21 +6,44 @@ import { StreamWriteError } from '../fs/errors/stream_write_error.js';
|
|
|
6
6
|
import { StreamReadError } from '../fs/errors/stream_read_error.js';
|
|
7
7
|
import { OpenZipError } from './errors/open_zip_error.js';
|
|
8
8
|
import { pipeline } from 'node:stream/promises';
|
|
9
|
-
export const extractZip = async ({ source, dist, getTransforms = () => [] }) => {
|
|
9
|
+
export const extractZip = async ({ source, dist, logger, getTransforms = () => [] }) => {
|
|
10
10
|
let createdDirectory = false;
|
|
11
|
+
logger.debug('Starting extraction of zip file', {
|
|
12
|
+
details: {
|
|
13
|
+
source,
|
|
14
|
+
dist
|
|
15
|
+
}
|
|
16
|
+
});
|
|
11
17
|
if (!(await directoryExists(dist))) {
|
|
12
18
|
createdDirectory = true;
|
|
19
|
+
logger.debug('Destination directory does not exist. Creating.', {
|
|
20
|
+
details: {
|
|
21
|
+
directory: dist
|
|
22
|
+
}
|
|
23
|
+
});
|
|
13
24
|
await makeDirectory(dist, { recursive: true });
|
|
14
25
|
}
|
|
15
26
|
return new Promise((resolve, reject) => {
|
|
16
27
|
const processedFilesPath = [];
|
|
17
|
-
yauzl.open(source, { lazyEntries: true }, (
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
yauzl.open(source, { lazyEntries: true }, (error, zipfile) => {
|
|
29
|
+
logger.debug('Zip file opened for extraction', {
|
|
30
|
+
details: {
|
|
31
|
+
source,
|
|
32
|
+
dist
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (error) {
|
|
36
|
+
if (createdDirectory) {
|
|
37
|
+
logger.debug('Removing created directory due to an error.', {
|
|
38
|
+
details: {
|
|
39
|
+
directory: dist
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
removeDirectorySync(dist, { recursive: true });
|
|
43
|
+
}
|
|
20
44
|
return reject(new OpenZipError({
|
|
21
45
|
file: source,
|
|
22
|
-
|
|
23
|
-
stack: err.stack
|
|
46
|
+
error
|
|
24
47
|
}));
|
|
25
48
|
}
|
|
26
49
|
let activeEntries = 0;
|
|
@@ -31,16 +54,26 @@ export const extractZip = async ({ source, dist, getTransforms = () => [] }) =>
|
|
|
31
54
|
const filePath = join(dist, entry.fileName);
|
|
32
55
|
const dirPath = dirname(filePath);
|
|
33
56
|
processedFilesPath.push(filePath);
|
|
57
|
+
logger.debug('Extracting zip entry', {
|
|
58
|
+
details: {
|
|
59
|
+
entryName: entry.fileName,
|
|
60
|
+
filePath: filePath
|
|
61
|
+
}
|
|
62
|
+
});
|
|
34
63
|
if (!filePath.startsWith(dist)) {
|
|
35
64
|
return reject(new Error(`Invalid entry path: ${entry.fileName}`));
|
|
36
65
|
}
|
|
37
66
|
if (looksLikeDirectory(entry.fileName)) {
|
|
67
|
+
logger.debug('Entry looks like a directory, skipping file write.', {
|
|
68
|
+
details: {
|
|
69
|
+
entry: entry.fileName
|
|
70
|
+
}
|
|
71
|
+
});
|
|
38
72
|
zipfile.readEntry();
|
|
39
73
|
return;
|
|
40
74
|
}
|
|
41
|
-
if (extractedPaths.has(filePath))
|
|
75
|
+
if (extractedPaths.has(filePath))
|
|
42
76
|
return reject(new Error(`Duplicate entry path detected: ${filePath}`));
|
|
43
|
-
}
|
|
44
77
|
extractedPaths.add(filePath);
|
|
45
78
|
makeDirectory(dirPath, { recursive: true })
|
|
46
79
|
.then(() => {
|
|
@@ -50,31 +83,58 @@ export const extractZip = async ({ source, dist, getTransforms = () => [] }) =>
|
|
|
50
83
|
const writeStream = createWriteStream(filePath);
|
|
51
84
|
writeStream.on('finish', () => {
|
|
52
85
|
activeEntries--;
|
|
53
|
-
|
|
86
|
+
logger.debug('Finished writing file.', {
|
|
87
|
+
details: {
|
|
88
|
+
file: filePath,
|
|
89
|
+
activeEntries
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (activeEntries === 0 && doneReadingEntries) {
|
|
93
|
+
logger.debug('All entries processed and written.');
|
|
54
94
|
resolve();
|
|
95
|
+
}
|
|
55
96
|
zipfile.readEntry();
|
|
56
97
|
});
|
|
57
98
|
writeStream.on('error', async (err) => {
|
|
99
|
+
logger.debug('Write stream error. Removing file.', {
|
|
100
|
+
details: {
|
|
101
|
+
file: filePath
|
|
102
|
+
}
|
|
103
|
+
});
|
|
58
104
|
await removeFile(filePath);
|
|
59
105
|
reject(new StreamWriteError({
|
|
60
106
|
filePath,
|
|
61
|
-
|
|
62
|
-
stack: err.stack
|
|
107
|
+
error: err
|
|
63
108
|
}));
|
|
64
109
|
});
|
|
65
110
|
readStream.on('error', async (err) => {
|
|
111
|
+
logger.debug('Read stream error. Removing file.', {
|
|
112
|
+
details: {
|
|
113
|
+
file: filePath
|
|
114
|
+
}
|
|
115
|
+
});
|
|
66
116
|
await removeFile(filePath, { force: true });
|
|
67
117
|
reject(new StreamReadError({
|
|
68
118
|
filePath,
|
|
69
|
-
|
|
70
|
-
stack: err.stack
|
|
119
|
+
error: err
|
|
71
120
|
}));
|
|
72
121
|
});
|
|
73
122
|
const transforms = getTransforms(entry.fileName);
|
|
74
123
|
if (transforms.length) {
|
|
124
|
+
logger.debug('Applying transform(s) to entry.', {
|
|
125
|
+
details: {
|
|
126
|
+
transformsCount: transforms.length,
|
|
127
|
+
entry: entry.fileName
|
|
128
|
+
}
|
|
129
|
+
});
|
|
75
130
|
await pipeline(readStream, ...transforms, writeStream);
|
|
76
131
|
}
|
|
77
132
|
else {
|
|
133
|
+
logger.debug('No transforms for entry. Piping directly.', {
|
|
134
|
+
details: {
|
|
135
|
+
entry: entry.fileName
|
|
136
|
+
}
|
|
137
|
+
});
|
|
78
138
|
readStream.pipe(writeStream);
|
|
79
139
|
}
|
|
80
140
|
});
|
|
@@ -83,19 +143,34 @@ export const extractZip = async ({ source, dist, getTransforms = () => [] }) =>
|
|
|
83
143
|
});
|
|
84
144
|
zipfile.on('end', () => {
|
|
85
145
|
doneReadingEntries = true;
|
|
86
|
-
|
|
146
|
+
logger.debug('Finished reading all zip entries.');
|
|
147
|
+
if (activeEntries === 0) {
|
|
148
|
+
logger.debug('All entries were processed before zip file "end" event.');
|
|
87
149
|
resolve();
|
|
150
|
+
}
|
|
88
151
|
});
|
|
89
152
|
zipfile.on('error', async (err) => {
|
|
90
153
|
for (const filePath of processedFilesPath) {
|
|
91
154
|
try {
|
|
155
|
+
logger.debug('Cleaning up extracted file due to an error.', {
|
|
156
|
+
details: {
|
|
157
|
+
file: filePath
|
|
158
|
+
}
|
|
159
|
+
});
|
|
92
160
|
await removeFile(filePath, { force: true });
|
|
93
161
|
}
|
|
94
162
|
catch (removeErr) {
|
|
95
163
|
console.error(`Error removing file ${filePath}:`, removeErr);
|
|
96
164
|
}
|
|
97
165
|
}
|
|
98
|
-
|
|
166
|
+
if (createdDirectory) {
|
|
167
|
+
logger.debug('Cleaning up created directory due to an error.', {
|
|
168
|
+
details: {
|
|
169
|
+
directory: dist
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
await removeDirectory(dist, { recursive: true });
|
|
173
|
+
}
|
|
99
174
|
reject(err);
|
|
100
175
|
});
|
|
101
176
|
zipfile.readEntry();
|
package/oclif.config.js
CHANGED
|
@@ -3,6 +3,7 @@ export default {
|
|
|
3
3
|
scope: 'shoper',
|
|
4
4
|
dirname: 'shoper_cli',
|
|
5
5
|
plugins: ['@oclif/plugin-help', '@oclif/plugin-warn-if-update-available', '@oclif/plugin-version'],
|
|
6
|
+
helpClass: './build/cli/class/cli_help.js',
|
|
6
7
|
'warn-if-update-available': {
|
|
7
8
|
frequency: 1,
|
|
8
9
|
frequencyUnit: 'days',
|
|
@@ -21,7 +22,8 @@ export default {
|
|
|
21
22
|
'./build/theme/hooks/ensure_theme_meta_data_untouched_hook.js',
|
|
22
23
|
'./build/theme/hooks/theme_checksums/ensure_theme_current_checksums_up_to_date_hook.js',
|
|
23
24
|
'./build/theme/hooks/themes_actions/ensure_themes_actions_hook.js'
|
|
24
|
-
]
|
|
25
|
+
],
|
|
26
|
+
finally: ['./build/cli/hooks/ensure_logs_flushed_hook.js']
|
|
25
27
|
},
|
|
26
28
|
topicSeparator: ' ',
|
|
27
29
|
topics: {
|
package/package.json
CHANGED
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
"name": "@shoper/cli",
|
|
3
3
|
"packageManager": "yarn@3.2.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.6.0",
|
|
6
6
|
"description": "CLI tool for Shoper",
|
|
7
7
|
"author": "Joanna Firek",
|
|
8
8
|
"license": "MIT",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"shoper",
|
|
11
|
+
"shoper-cli",
|
|
12
|
+
"shoper-for-developers"
|
|
13
|
+
],
|
|
9
14
|
"bin": {
|
|
10
15
|
"shoper": "./bin/run.js"
|
|
11
16
|
},
|
|
@@ -39,7 +44,7 @@
|
|
|
39
44
|
"@oclif/plugin-help": "6.2.27",
|
|
40
45
|
"@oclif/plugin-version": "2.2.27",
|
|
41
46
|
"@oclif/plugin-warn-if-update-available": "3.1.38",
|
|
42
|
-
"axios": "1.
|
|
47
|
+
"axios": "1.13.1",
|
|
43
48
|
"chalk": "5.4.1",
|
|
44
49
|
"conf": "13.1.0",
|
|
45
50
|
"fast-glob": "3.3.3",
|
|
@@ -48,6 +53,7 @@
|
|
|
48
53
|
"fs-tree-diff": "2.0.1",
|
|
49
54
|
"ink": "6.0.1",
|
|
50
55
|
"ink-link": "4.1.0",
|
|
56
|
+
"ink-gradient": "3.0.0",
|
|
51
57
|
"inquirer": "12.5.2",
|
|
52
58
|
"inquirer-select-line": "1.1.3",
|
|
53
59
|
"is-hidden-file": "1.1.2",
|
|
@@ -57,6 +63,8 @@
|
|
|
57
63
|
"log-symbols": "7.0.1",
|
|
58
64
|
"memfs": "4.17.0",
|
|
59
65
|
"ora": "8.2.0",
|
|
66
|
+
"pino": "10.1.0",
|
|
67
|
+
"pino-pretty": "13.1.2",
|
|
60
68
|
"react": "19.1.0",
|
|
61
69
|
"reflect-metadata": "0.2.2",
|
|
62
70
|
"rxjs": "7.8.2",
|
|
@@ -66,7 +74,8 @@
|
|
|
66
74
|
"uuid": "11.1.0",
|
|
67
75
|
"walk-sync": "3.0.0",
|
|
68
76
|
"yauzl": "3.2.0",
|
|
69
|
-
"yazl": "3.3.1"
|
|
77
|
+
"yazl": "3.3.1",
|
|
78
|
+
"figlet": "1.9.4"
|
|
70
79
|
},
|
|
71
80
|
"devDependencies": {
|
|
72
81
|
"@babel/core": "7.27.1",
|
|
@@ -87,7 +96,7 @@
|
|
|
87
96
|
"@types/yazl": "2.4.6",
|
|
88
97
|
"@typescript-eslint/eslint-plugin": "8.29.1",
|
|
89
98
|
"babel-jest": "29.7.0",
|
|
90
|
-
"eslint": "9.
|
|
99
|
+
"eslint": "9.39.1",
|
|
91
100
|
"eslint-config-prettier": "10.1.1",
|
|
92
101
|
"eslint-plugin-prettier": "5.2.6",
|
|
93
102
|
"jest": "29.7.0",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { APP_ERRORS_LEVELS } from './app_error_constants.js';
|
|
2
|
-
//TODO errory do zaprojektownia
|
|
3
|
-
export class AppError extends Error {
|
|
4
|
-
code;
|
|
5
|
-
level;
|
|
6
|
-
tags;
|
|
7
|
-
details;
|
|
8
|
-
stack;
|
|
9
|
-
constructor({ code, details, message, level = APP_ERRORS_LEVELS.error, tags, stack }) {
|
|
10
|
-
super(message);
|
|
11
|
-
this.code = code;
|
|
12
|
-
this.details = details;
|
|
13
|
-
this.level = level;
|
|
14
|
-
this.tags = tags;
|
|
15
|
-
this.stack = stack;
|
|
16
|
-
}
|
|
17
|
-
}
|