mirror of
https://github.com/strapi/strapi.git
synced 2026-01-07 20:58:16 +00:00
Fix file structure
This commit is contained in:
parent
16d62df76a
commit
39c8a80339
@ -17,7 +17,7 @@ const {
|
||||
buildTransferTable,
|
||||
DEFAULT_IGNORED_CONTENT_TYPES,
|
||||
createStrapiInstance,
|
||||
formatDiagnosticErrors,
|
||||
formatDiagnostic,
|
||||
} = require('./utils');
|
||||
|
||||
/**
|
||||
@ -78,7 +78,7 @@ module.exports = async (opts) => {
|
||||
},
|
||||
});
|
||||
|
||||
engine.diagnostics.onDiagnostic(formatDiagnosticErrors);
|
||||
engine.diagnostics.onDiagnostic(formatDiagnostic);
|
||||
|
||||
const progress = engine.progress.stream;
|
||||
|
||||
|
||||
@ -16,11 +16,7 @@ const { isObject } = require('lodash/fp');
|
||||
const path = require('path');
|
||||
|
||||
const strapi = require('../../index');
|
||||
const {
|
||||
buildTransferTable,
|
||||
DEFAULT_IGNORED_CONTENT_TYPES,
|
||||
formatDiagnosticErrors,
|
||||
} = require('./utils');
|
||||
const { buildTransferTable, DEFAULT_IGNORED_CONTENT_TYPES, formatDiagnostic } = require('./utils');
|
||||
|
||||
/**
|
||||
* @typedef {import('@strapi/data-transfer').ILocalFileSourceProviderOptions} ILocalFileSourceProviderOptions
|
||||
@ -88,7 +84,7 @@ module.exports = async (opts) => {
|
||||
|
||||
const engine = createTransferEngine(source, destination, engineOptions);
|
||||
|
||||
engine.diagnostics.onDiagnostic(formatDiagnosticErrors);
|
||||
engine.diagnostics.onDiagnostic(formatDiagnostic);
|
||||
|
||||
const progress = engine.progress.stream;
|
||||
const getTelemetryPayload = () => {
|
||||
|
||||
@ -15,8 +15,8 @@ const {
|
||||
buildTransferTable,
|
||||
createStrapiInstance,
|
||||
DEFAULT_IGNORED_CONTENT_TYPES,
|
||||
formatDiagnostic,
|
||||
} = require('./utils');
|
||||
const formatDiagnosticErrors = require('./utils');
|
||||
|
||||
const logger = console;
|
||||
|
||||
@ -110,7 +110,7 @@ module.exports = async (opts) => {
|
||||
},
|
||||
});
|
||||
|
||||
engine.diagnostics.onDiagnostic(formatDiagnosticErrors);
|
||||
engine.diagnostics.onDiagnostic(formatDiagnostic);
|
||||
|
||||
try {
|
||||
logger.log(`Starting transfer...`);
|
||||
|
||||
@ -4,10 +4,11 @@ const chalk = require('chalk');
|
||||
const Table = require('cli-table3');
|
||||
const { Option } = require('commander');
|
||||
const { TransferGroupPresets } = require('@strapi/data-transfer/lib/engine');
|
||||
|
||||
const {
|
||||
config: { createOutputFileConfiguration },
|
||||
configs: { createOutputFileConfiguration },
|
||||
createLogger,
|
||||
} = require('@strapi/logger');
|
||||
} = require('@strapi/logger/lib');
|
||||
const { readableBytes, exitWith } = require('../utils/helpers');
|
||||
const strapi = require('../../index');
|
||||
const { getParseListWithChoices } = require('../utils/commander');
|
||||
@ -179,5 +180,5 @@ module.exports = {
|
||||
excludeOption,
|
||||
onlyOption,
|
||||
validateExcludeOnly,
|
||||
formatDiagnosticErrors: formatDiagnostic,
|
||||
formatDiagnostic,
|
||||
};
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { transports, format } = require('winston');
|
||||
const { LEVEL_LABEL, LEVELS } = require('../constants');
|
||||
const { prettyPrint } = require('../formats');
|
||||
|
||||
/**
|
||||
* This will remove the chalk color codes from the message provided.
|
||||
* It's used to log plain text in the log file
|
||||
*/
|
||||
const getPlainText = format.printf(({ message }) => {
|
||||
return message.replace(
|
||||
// eslint-disable-next-line no-control-regex
|
||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
||||
''
|
||||
);
|
||||
});
|
||||
|
||||
const createOutputFileConfiguration = (filename) => {
|
||||
return {
|
||||
level: LEVEL_LABEL,
|
||||
levels: LEVELS,
|
||||
format: prettyPrint(),
|
||||
transports: [
|
||||
new transports.Console(),
|
||||
new transports.File({ level: 'error', filename, format: getPlainText }),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = createOutputFileConfiguration;
|
||||
9
packages/utils/logger/lib/configs/index.js
Normal file
9
packages/utils/logger/lib/configs/index.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const createDefaultConfiguration = require('./default-configuration');
|
||||
const createOutputFileConfiguration = require('./output-file-configuration');
|
||||
|
||||
module.exports = {
|
||||
createDefaultConfiguration,
|
||||
createOutputFileConfiguration,
|
||||
};
|
||||
@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const { transports } = require('winston');
|
||||
const { LEVEL_LABEL, LEVELS } = require('../constants');
|
||||
const { prettyPrint } = require('../formats');
|
||||
const excludeColors = require('../formats/exclude-colors');
|
||||
|
||||
const createOutputFileConfiguration = (filename) => {
|
||||
return {
|
||||
level: LEVEL_LABEL,
|
||||
levels: LEVELS,
|
||||
format: prettyPrint(),
|
||||
transports: [
|
||||
new transports.Console(),
|
||||
new transports.File({ level: 'error', filename, format: excludeColors }),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = createOutputFileConfiguration;
|
||||
17
packages/utils/logger/lib/formats/exclude-colors.js
Normal file
17
packages/utils/logger/lib/formats/exclude-colors.js
Normal file
@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const { format } = require('winston');
|
||||
|
||||
/**
|
||||
* This will remove the chalk color codes from the message provided.
|
||||
* It's used to log plain text in the log file
|
||||
*/
|
||||
const excludeColors = format.printf(({ message }) => {
|
||||
return message.replace(
|
||||
// eslint-disable-next-line no-control-regex
|
||||
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
||||
''
|
||||
);
|
||||
});
|
||||
|
||||
module.exports = excludeColors;
|
||||
@ -3,11 +3,10 @@
|
||||
const winston = require('winston');
|
||||
|
||||
const formats = require('./formats');
|
||||
const createDefaultConfiguration = require('./config/default-configuration');
|
||||
const createOutputFileConfiguration = require('./config/output-file-configuration');
|
||||
const configs = require('./configs');
|
||||
|
||||
const createLogger = (userConfiguration = {}) => {
|
||||
const configuration = createDefaultConfiguration();
|
||||
const configuration = configs.createDefaultConfiguration();
|
||||
|
||||
Object.assign(configuration, userConfiguration);
|
||||
|
||||
@ -18,5 +17,5 @@ module.exports = {
|
||||
createLogger,
|
||||
winston,
|
||||
formats,
|
||||
config: { createDefaultConfiguration, createOutputFileConfiguration },
|
||||
configs,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user