Skip to content

Commit

Permalink
Merge pull request #1372 from contentstack/bugfix/CS-44008
Browse files Browse the repository at this point in the history
CS - 44008 - fixed the issue of logger path not setting up from env variable and version bump
  • Loading branch information
cs-raj authored Apr 16, 2024
2 parents f5ce57f + 810afa6 commit 03545a5
Show file tree
Hide file tree
Showing 18 changed files with 2,493 additions and 14,438 deletions.
16,841 changes: 2,442 additions & 14,399 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
"dependencies": {
"@colors/colors": "^1.5.0",
"@contentstack/cli-cm-export": "~1.11.1",
"@contentstack/cli-cm-import": "~1.15.1",
"@contentstack/cli-cm-export": "~1.11.2",
"@contentstack/cli-cm-import": "~1.15.2",
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.6.0",
"async": "^3.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export-to-csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
4 changes: 2 additions & 2 deletions packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-export",
"description": "Contentstack CLI plugin to export content from stack",
"version": "1.11.1",
"version": "1.11.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down Expand Up @@ -98,4 +98,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
10 changes: 7 additions & 3 deletions packages/contentstack-export/src/commands/cm/stacks/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
flags,
ContentstackClient,
FlagInput,
pathValidator
pathValidator,
} from '@contentstack/cli-utilities';
import { ModuleExporter } from '../../../export';
import { setupExportConfig, log, formatError, writeExportMetaFile } from '../../../utils';
Expand Down Expand Up @@ -105,15 +105,19 @@ export default class ExportCommand extends Command {
let exportConfig = await setupExportConfig(flags);
// Note setting host to create cma client
exportConfig.host = this.cmaHost;
exportDir = exportConfig.data || exportConfig.exportDir;
exportDir = exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir;
const managementAPIClient: ContentstackClient = await managementSDKClient(exportConfig);
const moduleExporter = new ModuleExporter(managementAPIClient, exportConfig);
await moduleExporter.start();
if (!exportConfig.branches?.length) {
writeExportMetaFile(exportConfig);
}
log(exportConfig, `The content of the stack ${exportConfig.apiKey} has been exported successfully!`, 'success');
log(exportConfig, `The log has been stored at '${pathValidator(path.join(exportDir, 'logs', 'export'))}'`, 'success');
log(
exportConfig,
`The log has been stored at '${pathValidator(path.join(exportDir, 'logs', 'export'))}'`,
'success',
);
} catch (error) {
log({ data: exportDir } as ExportConfig, `Failed to export stack content - ${formatError(error)}`, 'error');
log({ data: exportDir } as ExportConfig, `The log has been stored at ${exportDir}`, 'info');
Expand Down
3 changes: 2 additions & 1 deletion packages/contentstack-export/src/types/export-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Modules } from '.';
import DefaultConfig from './default-config';

export default interface ExportConfig extends DefaultConfig {
cliLogsPath: string;
exportDir: string;
data: string;
management_token?: string;
Expand All @@ -27,7 +28,7 @@ export default interface ExportConfig extends DefaultConfig {
access_token?: string;
org_uid?: string;
source_stack?: string;
sourceStackName?:string;
sourceStackName?: string;
}

type branch = {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function init(_logPath: string) {
}

export const log = async (config: ExportConfig, message: any, type: string) => {
const logsPath = config.data;
const logsPath = config.cliLogsPath || config.data;
// ignoring the type argument, as we are not using it to create a logfile anymore
if (type !== 'error') {
// removed type argument from init method
Expand Down
11 changes: 6 additions & 5 deletions packages/contentstack-import/example_config/auth_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"code": "en-us"
},
"data": "file path",
"target_stack":"bltXXXXXXXXXX",
"branchName":"example1",
"target_stack": "bltXXXXXXXXXX",
"branchName": "example1",
"moduleName": "content-types",
"concurrency": 1,
"importConcurrency": 5,
"fetchConcurrency": 5,
"writeConcurrency": 5,
"securedAssets":false,
"securedAssets": false,
"developerHubBaseUrl": "",
"createBackupDir": "./temp"
}
"createBackupDir": "./temp",
"cliLogsPath": "./tmp"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"code": "en-us"
},
"data": "file path",
"branchName":"example1",
"branchName": "example1",
"moduleName": "content-types",
"concurrency": 1,
"importConcurrency": 5,
"fetchConcurrency": 5,
"writeConcurrency": 5,
"securedAssets":false,
"developerHubBaseUrl": ""
}
"securedAssets": false,
"developerHubBaseUrl": "",
"cliLogsPath": "./tmp"
}
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.15.1",
"version": "1.15.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
12 changes: 8 additions & 4 deletions packages/contentstack-import/src/commands/cm/stacks/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
flags,
FlagInput,
ContentstackClient,
pathValidator
pathValidator,
} from '@contentstack/cli-utilities';

import { ImportConfig } from '../../../types';
Expand Down Expand Up @@ -126,7 +126,7 @@ export default class ImportCommand extends Command {
let importConfig = await setupImportConfig(flags);
// Note setting host to create cma client
importConfig.host = this.cmaHost;
backupDir = importConfig.backupDir;
backupDir = importConfig.cliLogsPath || importConfig.backupDir;

const managementAPIClient: ContentstackClient = await managementSDKClient(importConfig);
const moduleImporter = new ModuleImporter(managementAPIClient, importConfig);
Expand All @@ -144,7 +144,9 @@ export default class ImportCommand extends Command {

log(
importConfig,
`The log has been stored at '${pathValidator(path.join(importConfig.backupDir, 'logs', 'import'))}'`,
`The log has been stored at '${pathValidator(
path.join(importConfig.cliLogsPath || importConfig.backupDir, 'logs', 'import'),
)}'`,
'success',
);
} catch (error) {
Expand All @@ -156,7 +158,9 @@ export default class ImportCommand extends Command {
log(
{ data: backupDir } as ImportConfig,
`The log has been stored at ${
{ data: backupDir } ? pathValidator(path.join(backupDir || __dirname, 'logs', 'import')) : pathValidator(path.join(__dirname, 'logs'))
{ data: backupDir }
? pathValidator(path.join(backupDir || __dirname, 'logs', 'import'))
: pathValidator(path.join(__dirname, 'logs'))
}`,
'info',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/import/module-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ModuleImporter {
* fix available and the user confirms to proceed with the fix, otherwise it returns `false`.
*/
async auditImportData(logger: Logger) {
const basePath = resolve(this.importConfig.backupDir, 'logs', 'audit');
const basePath = resolve(this.importConfig.cliLogsPath || this.importConfig.backupDir, 'logs', 'audit');
const auditConfig = this.importConfig.auditConfig;
auditConfig.config.basePath = basePath;
auditConfig.config.branch = this.importConfig.branchName;
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-import/src/types/import-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ExternalConfig {
}

export default interface ImportConfig extends DefaultConfig, ExternalConfig {
cliLogsPath: string;
canCreatePrivateApp: boolean;
contentDir: string;
data: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function log(entryOrMessage: MessageType, logType?: LogsType, hidden?: bo

export function initLogger(config?: ImportConfig | undefined) {
if (!logger) {
const basePath = pathValidator(join(config?.data ?? process.cwd(), 'logs', 'import'));
const basePath = pathValidator(join(config?.cliLogsPath ?? process.cwd(), 'logs', 'import'));
logger = new Logger(Object.assign(config ?? {}, { basePath }));
}

Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack-import/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ function init(_logPath: string) {
}

export const log = async (config: ImportConfig, message: any, type: string) => {
config.data = config.data || path.join(__dirname, 'logs');
config.cliLogsPath = config.cliLogsPath || config.data || path.join(__dirname, 'logs');
// ignoring the type argument, as we are not using it to create a logfile anymore
if (type !== 'error') {
// removed type argument from init method
if (type === 'warn') init(config.data).warn(message); //logged warning message in log file
else init(config.data).log(message);
if (type === 'warn') init(config.cliLogsPath).warn(message); //logged warning message in log file
else init(config.cliLogsPath).log(message);
} else {
init(config.data).error(message);
init(config.cliLogsPath).error(message);
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~1.15.1",
"@contentstack/cli-cm-import": "~1.15.2",
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.6.0",
"inquirer": "8.2.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.17.2",
"version": "1.17.3",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run"
Expand All @@ -27,10 +27,10 @@
"@contentstack/cli-cm-bootstrap": "~1.9.0",
"@contentstack/cli-cm-branches": "~1.0.24",
"@contentstack/cli-cm-bulk-publish": "~1.4.4",
"@contentstack/cli-cm-export": "~1.11.1",
"@contentstack/cli-cm-export": "~1.11.2",
"@contentstack/cli-cm-clone": "~1.10.3",
"@contentstack/cli-cm-export-to-csv": "~1.7.0",
"@contentstack/cli-cm-import": "~1.15.1",
"@contentstack/cli-cm-import": "~1.15.2",
"@contentstack/cli-cm-migrate-rte": "~1.4.15",
"@contentstack/cli-cm-seed": "~1.7.3",
"@contentstack/cli-command": "~1.2.17",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 03545a5

Please sign in to comment.