diff --git a/packages/contentstack-auth/src/commands/auth/login.ts b/packages/contentstack-auth/src/commands/auth/login.ts index 73ff392398..5af919a995 100644 --- a/packages/contentstack-auth/src/commands/auth/login.ts +++ b/packages/contentstack-auth/src/commands/auth/login.ts @@ -55,12 +55,12 @@ export default class LoginCommand extends BaseCommand { log.debug('LoginCommand run method started', this.contextDetails); try { - log.debug('Initializing management API client', this.contextDetails); + log.debug('Initializing the Management API client.', this.contextDetails); const managementAPIClient = await managementSDKClient({ host: this.cmaHost, skipTokenValidity: true }); - log.debug('Management API client initialized successfully', this.contextDetails); + log.debug('Management API client initialized successfully.', this.contextDetails); const { flags: loginFlags } = await this.parse(LoginCommand); - log.debug('Token add flags parsed', { ...this.contextDetails, flags: loginFlags }); + log.debug('Token add flags parsed.', { ...this.contextDetails, flags: loginFlags }); authHandler.client = managementAPIClient; log.debug('Auth handler client set', this.contextDetails); @@ -86,7 +86,7 @@ export default class LoginCommand extends BaseCommand { await this.login(username, password); } } catch (error) { - log.debug('Login command failed', { + log.debug('Login failed.', { ...this.contextDetails, error, }); @@ -116,7 +116,7 @@ export default class LoginCommand extends BaseCommand { } const user: User = await authHandler.login(username, password, tfaToken); - log.debug('Auth handler login completed', { + log.debug('Auth handler login completed.', { ...this.contextDetails, hasUser: !!user, hasAuthToken: !!user?.authtoken, @@ -124,18 +124,18 @@ export default class LoginCommand extends BaseCommand { }); if (typeof user !== 'object' || !user.authtoken || !user.email) { - log.debug('Login failed - invalid user response', { ...this.contextDetails, user }); - throw new CLIError('Failed to login - invalid response'); + log.debug('Login failed: Invalid user response', { ...this.contextDetails, user }); + throw new CLIError('Login failed: Invalid response.'); } - log.debug('Setting config data for basic auth', this.contextDetails); + log.debug('Setting configuration data for basic authentication.', this.contextDetails); await oauthHandler.setConfigData('basicAuth', user); - log.debug('Config data set successfully', this.contextDetails); + log.debug('Configuration data set successfully.', this.contextDetails); log.success(messageHandler.parse('CLI_AUTH_LOGIN_SUCCESS'), this.contextDetails); - log.debug('Login process completed successfully', this.contextDetails); + log.debug('Login completed successfully.', this.contextDetails); } catch (error) { - log.debug('Login process failed', { ...this.contextDetails, error }); + log.debug('Login failed.', { ...this.contextDetails, error }); throw error; } } diff --git a/packages/contentstack-auth/src/commands/auth/logout.ts b/packages/contentstack-auth/src/commands/auth/logout.ts index 3140750a63..6f0a016ef2 100644 --- a/packages/contentstack-auth/src/commands/auth/logout.ts +++ b/packages/contentstack-auth/src/commands/auth/logout.ts @@ -61,7 +61,7 @@ export default class LogoutCommand extends BaseCommand { } try { - log.debug('Initializing management API client for logout', this.contextDetails); + log.debug('Initializing the Management API client for logout.', this.contextDetails); const managementAPIClient = await managementSDKClient({ host: this.cmaHost, skipTokenValidity: true }); log.debug('Management API client initialized successfully', this.contextDetails); @@ -75,9 +75,9 @@ export default class LogoutCommand extends BaseCommand { if (await oauthHandler.isAuthorisationTypeBasic()) { log.debug('Using basic authentication for logout', this.contextDetails); const authToken = configHandler.get('authtoken'); - log.debug('Retrieved auth token for logout', { ...this.contextDetails, hasAuthToken: !!authToken }); + log.debug('Authentication token retrieved for logout.', { ...this.contextDetails, hasAuthToken: !!authToken }); await authHandler.logout(authToken); - log.debug('Basic auth logout completed', this.contextDetails); + log.debug('Basic authentication logout completed.', this.contextDetails); } else if (await oauthHandler.isAuthorisationTypeOAuth()) { log.debug('Using OAuth authentication for logout', this.contextDetails); await oauthHandler.oauthLogout(); @@ -86,7 +86,7 @@ export default class LogoutCommand extends BaseCommand { cliux.loader(''); log.success(messageHandler.parse('CLI_AUTH_LOGOUT_SUCCESS'), this.contextDetails); - log.debug('Logout process completed successfully', this.contextDetails); + log.debug('Logout completed successfully.', this.contextDetails); } else { log.debug('User not confirmed or not authenticated, skipping logout', { ...this.contextDetails, @@ -96,14 +96,14 @@ export default class LogoutCommand extends BaseCommand { log.success(messageHandler.parse('CLI_AUTH_LOGOUT_ALREADY'), this.contextDetails); } } catch (error) { - log.debug('Logout command failed', { ...this.contextDetails, error: error.message }); + log.debug('Logout failed.', { ...this.contextDetails, error: error.message }); cliux.print('CLI_AUTH_LOGOUT_FAILED', { color: 'yellow' }); handleAndLogError(error, { ...this.contextDetails }); } finally { if (confirm === true) { - log.debug('Setting config data for logout', this.contextDetails); + log.debug('Setting configuration data for logout.', this.contextDetails); await oauthHandler.setConfigData('logout'); - log.debug('Config data set for logout', this.contextDetails); + log.debug('Configuration data set for logout.', this.contextDetails); } } } diff --git a/packages/contentstack-auth/src/commands/auth/tokens/add.ts b/packages/contentstack-auth/src/commands/auth/tokens/add.ts index 8ca4a46cbb..b95cb11b70 100644 --- a/packages/contentstack-auth/src/commands/auth/tokens/add.ts +++ b/packages/contentstack-auth/src/commands/auth/tokens/add.ts @@ -82,11 +82,11 @@ export default class TokensAddCommand extends BaseCommand] [--delivery] [--management] [-e ] [-k ] [-y] [--token ]'; async run(): Promise { - log.debug('TokensAddCommand run method started', this.contextDetails); + log.debug('TokensAddCommand run method started.', this.contextDetails); this.contextDetails.module = 'tokens-add'; const { flags: addTokenFlags } = await this.parse(TokensAddCommand); - log.debug('Token add flags parsed', { ...this.contextDetails, flags: addTokenFlags }); + log.debug('Token add flags parsed.', { ...this.contextDetails, flags: addTokenFlags }); let isAliasExist = false; const skipAliasReplaceConfirmation = addTokenFlags.force || addTokenFlags.yes; @@ -141,7 +141,7 @@ export default class TokensAddCommand extends BaseCommand { - log.debug('TokensListCommand run method started', this.contextDetails); + log.debug('TokensListCommand run method started.', this.contextDetails); this.contextDetails.module = 'tokens-list'; try { - log.debug('Retrieving tokens from configuration', this.contextDetails); + log.debug('Retrieving tokens from configuration.', this.contextDetails); const managementTokens = configHandler.get('tokens'); - log.debug('Tokens retrieved from configuration', {...this.contextDetails, tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 }); + log.debug('Tokens retrieved from configuration.', {...this.contextDetails, tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 }); const tokens: Record[] = []; if (managementTokens && Object.keys(managementTokens).length > 0) { - log.debug('Processing tokens for display', this.contextDetails); + log.debug('Processing tokens for display.', this.contextDetails); Object.keys(managementTokens).forEach(function (item) { tokens.push({ alias: item, @@ -46,7 +46,7 @@ export default class TokensListCommand extends BaseCommand = []; if (token || ignore) { - log.debug('Token found or ignore flag set, proceeding with removal', {...this.contextDetails, hasToken: !!token, ignore }); + log.debug('Token found, or ignore flag set.', {...this.contextDetails, hasToken: !!token, ignore }); configHandler.delete(`tokens.${alias}`); - log.debug('Token removed from configuration', {...this.contextDetails, alias }); + log.debug('Token removed from configuration.', {...this.contextDetails, alias }); return cliux.success(`CLI_AUTH_TOKENS_REMOVE_SUCCESS`); } if (tokens && Object.keys(tokens).length > 0) { - log.debug('Building token options for user selection', this.contextDetails); + log.debug('Building token options for user selection.', this.contextDetails); Object.keys(tokens).forEach(function (item) { const tokenOption = `${item}: ${tokens[item].token} : ${tokens[item].apiKey}${ tokens[item].environment ? ' : ' + tokens[item].environment + ' ' : '' @@ -48,11 +48,11 @@ export default class TokensRemoveCommand extends BaseCommand = await cliux.inquire({ name: 'selectedTokens', message: 'CLI_AUTH_TOKENS_REMOVE_SELECT_TOKEN', @@ -62,7 +62,7 @@ export default class TokensRemoveCommand extends BaseCommand { const selectedToken = element.split(':')[0]; log.debug(`Removing token: ${selectedToken}`, this.contextDetails); @@ -79,9 +79,9 @@ export default class TokensRemoveCommand extends BaseCommand { log.debug('WhoamiCommand run method started', this.contextDetails); try { - log.debug('Checking user email from context', { ...this.contextDetails, hasEmail: !!this.email }); + log.debug('Checking user email from context.', { ...this.contextDetails, hasEmail: !!this.email }); if (this.email) { log.debug('User email found, displaying user information', { ...this.contextDetails, email: this.email }); cliux.print('CLI_AUTH_WHOAMI_LOGGED_IN_AS', { color: 'white' }); cliux.print(this.email, { color: 'green' }); - log.debug('Whoami command completed successfully', this.contextDetails); + log.debug('whoami command completed successfully.', this.contextDetails); } else { - log.debug('No user email found in context', this.contextDetails); + log.debug('No user email found in context.', this.contextDetails); log.error(messageHandler.parse('CLI_AUTH_WHOAMI_FAILED'), this.contextDetails); } } catch (error) { - log.debug('Whoami command failed', { ...this.contextDetails, error }); + log.debug('whoami command failed.', { ...this.contextDetails, error }); cliux.print('CLI_AUTH_WHOAMI_FAILED', { color: 'yellow' }); handleAndLogError(error, { ...this.contextDetails }); } diff --git a/packages/contentstack-auth/src/utils/auth-handler.ts b/packages/contentstack-auth/src/utils/auth-handler.ts index 7ecdc26cd7..7d263ebaac 100644 --- a/packages/contentstack-auth/src/utils/auth-handler.ts +++ b/packages/contentstack-auth/src/utils/auth-handler.ts @@ -10,11 +10,11 @@ class AuthHandler { private _client; private _host; set client(contentStackClient) { - log.debug('Setting ContentStack client', { module: 'auth-handler' }); + log.debug('Setting Contentstack client.', { module: 'auth-handler' }); this._client = contentStackClient; } set host(contentStackHost) { - log.debug(`Setting ContentStack host: ${contentStackHost}`, { module: 'auth-handler' }); + log.debug(`Setting Contentstack host: ${contentStackHost}`, { module: 'auth-handler' }); this._host = contentStackHost; } @@ -68,13 +68,13 @@ class AuthHandler { * @throws CLIError if SMS request fails */ private async requestSMSOTP(loginPayload: any): Promise { - log.debug('Sending SMS OTP request', { module: 'auth-handler' }); + log.debug('Sending SMS OTP request.', { module: 'auth-handler' }); try { await this._client.axiosInstance.post('/user/request_token_sms', { user: loginPayload }); - log.debug('SMS OTP request successful', { module: 'auth-handler' }); + log.debug('SMS OTP request successful.', { module: 'auth-handler' }); cliux.print('CLI_AUTH_LOGIN_SECURITY_CODE_SEND_SUCCESS'); } catch (error) { - log.debug('SMS OTP request failed', { module: 'auth-handler', error }); + log.debug('SMS OTP request failed.', { module: 'auth-handler', error }); throw error; } } @@ -98,7 +98,7 @@ class AuthHandler { } = { email, password }; if (tfaToken) { loginPayload.tfa_token = tfaToken; - log.debug('Adding TFA token to login payload', { module: 'auth-handler' }); + log.debug('Adding TFA token to login payload.', { module: 'auth-handler' }); } log.debug('Making login API call', { @@ -124,17 +124,17 @@ class AuthHandler { try { resolve(await this.login(email, password, tfToken)); } catch (error) { - log.debug('Login with TFA token failed', { module: 'auth-handler', error }); + log.debug('Login with TFA token failed.', { module: 'auth-handler', error }); cliux.print('CLI_AUTH_2FA_FAILED', { color: 'red' }); reject(error); } } else { - log.debug('Login failed - no user found', { module: 'auth-handler', result }); + log.debug('Login failed: no user found.', { module: 'auth-handler', result }); reject(new Error(messageHandler.parse('CLI_AUTH_LOGIN_NO_USER'))); } }) .catch((error: any) => { - log.debug('Login API call failed', { module: 'auth-handler', error: error?.errorMessage || error }); + log.debug('Login API call failed.', { module: 'auth-handler', error: error?.errorMessage || error }); cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' }); handleAndLogError(error, { module: 'auth-handler' }); }); @@ -158,25 +158,25 @@ class AuthHandler { * @returns {Promise} Promise object returns response object from Contentstack */ async logout(authtoken: string): Promise { - log.debug('Starting logout process', { module: 'auth-handler', hasAuthToken: !!authtoken }); + log.debug('Starting logout process.', { module: 'auth-handler', hasAuthToken: !!authtoken }); return new Promise((resolve, reject) => { if (authtoken) { - log.debug('Making logout API call', { module: 'auth-handler' }); + log.debug('Making logout API call.', { module: 'auth-handler' }); this._client .logout(authtoken) .then(function (response: object) { - log.debug('Logout API call successful', { module: 'auth-handler', response }); + log.debug('Logout API call successful.', { module: 'auth-handler', response }); return resolve(response); }) .catch((error: Error) => { - log.debug('Logout API call failed', { module: 'auth-handler', error: error.message }); + log.debug('Logout API call failed.', { module: 'auth-handler', error: error.message }); cliux.print('CLI_AUTH_LOGOUT_FAILED', { color: 'yellow' }); reject(error); }); } else { - log.debug('Logout failed - no auth token provided', { module: 'auth-handler' }); + log.debug('Logout failed: no auth token provided.', { module: 'auth-handler' }); reject(new Error(messageHandler.parse('CLI_AUTH_LOGOUT_NO_TOKEN'))); } }); @@ -188,25 +188,25 @@ class AuthHandler { * @returns {Promise} Promise object returns response object from Contentstack */ async validateAuthtoken(authtoken: string): Promise { - log.debug('Starting token validation', { module: 'auth-handler', hasAuthToken: !!authtoken }); + log.debug('Starting token validation.', { module: 'auth-handler', hasAuthToken: !!authtoken }); return new Promise((resolve, reject) => { if (authtoken) { - log.debug('Making token validation API call', { module: 'auth-handler' }); + log.debug('Making token validation API call.', { module: 'auth-handler' }); this._client .getUser() .then((user: object) => { - log.debug('Token validation successful', { module: 'auth-handler', user }); + log.debug('Token validation successful.', { module: 'auth-handler', user }); resolve(user); }) .catch((error: Error) => { - log.debug('Token validation failed', { module: 'auth-handler', error: error.message }); + log.debug('Token validation failed.', { module: 'auth-handler', error: error.message }); cliux.print('CLI_AUTH_TOKEN_VALIDATION_FAILED', { color: 'yellow' }); handleAndLogError(error, { module: 'auth-handler' }); }); } else { - log.debug('Token validation failed - no auth token provided', { module: 'auth-handler' }); + log.debug('Token validation failed: no auth token provided.', { module: 'auth-handler' }); reject(new Error(messageHandler.parse('CLI_AUTH_TOKEN_VALIDATION_NO_TOKEN'))); } }); diff --git a/packages/contentstack-auth/src/utils/tokens-validation.ts b/packages/contentstack-auth/src/utils/tokens-validation.ts index 94ae7a7855..ab230dbf07 100644 --- a/packages/contentstack-auth/src/utils/tokens-validation.ts +++ b/packages/contentstack-auth/src/utils/tokens-validation.ts @@ -11,28 +11,28 @@ export const validateEnvironment = async ( apiKey: string, environment: string, ): Promise => { - log.debug('Starting environment validation', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided', environment }); + log.debug('Starting environment validation.', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided', environment }); let result: { valid: boolean; message: string }; try { - log.debug('Making environment validation API call', { module: 'tokens-validation', environment }); + log.debug('Making environment validation API call.', { module: 'tokens-validation', environment }); const validationResult = await contentStackClient.Stack({ api_key: apiKey }).environment(environment).fetch(); - log.debug('Environment validation API response received', { module: 'tokens-validation', validationResult }); + log.debug('Environment validation API response received.', { module: 'tokens-validation', validationResult }); if (validationResult.name === environment) { - log.debug('Environment validation successful', { module: 'tokens-validation', environment, validationResult }); + log.debug('Environment validation successful.', { module: 'tokens-validation', environment, validationResult }); result = { valid: true, message: validationResult }; } else { - log.debug('Environment validation failed - name mismatch', { module: 'tokens-validation', expected: environment, actual: validationResult.name }); + log.debug('Environment validation failed: name mismatch.', { module: 'tokens-validation', expected: environment, actual: validationResult.name }); result = { valid: false, message: messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_ENVIRONMENT_NAME') }; } } catch (error) { - log.debug('Environment validation API call failed', { module: 'tokens-validation', error: error.message, environment }); + log.debug('Environment validation API call failed.', { module: 'tokens-validation', error: error.message, environment }); handleAndLogError(error, { apiKey, environment }, ); result = { valid: false, message: 'CLI_AUTH_TOKENS_VALIDATION_INVALID_ENVIRONMENT_NAME' }; } - log.debug('Environment validation completed', { module: 'tokens-validation', result }); + log.debug('Environment validation completed.', { module: 'tokens-validation', result }); return result; }; @@ -43,27 +43,27 @@ export const validateEnvironment = async ( * @returns */ export const validateAPIKey = async (contentStackClient: any, apiKey: string): Promise => { - log.debug('Starting API key validation', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided' }); + log.debug('Starting API key validation.', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided' }); let result: { valid: boolean; message: string }; try { - log.debug('Making API key validation API call', { module: 'tokens-validation' }); + log.debug('Making API key validation API call.', { module: 'tokens-validation' }); const validateAPIKeyResult = await contentStackClient.stack({ api_key: apiKey }).fetch(); - log.debug('API key validation API response received', { module: 'tokens-validation', validateAPIKeyResult }); + log.debug('API key validation API response received.', { module: 'tokens-validation', validateAPIKeyResult }); if (validateAPIKeyResult.api_key === apiKey) { - log.debug('API key validation successful', { module: 'tokens-validation', apiKey: validateAPIKeyResult.api_key }); + log.debug('API key validation successful.', { module: 'tokens-validation', apiKey: validateAPIKeyResult.api_key }); result = { valid: true, message: validateAPIKeyResult }; } else { - log.debug('API key validation failed - key mismatch', { module: 'tokens-validation', expected: apiKey, actual: validateAPIKeyResult.api_key }); + log.debug('API key validation failed: key mismatch.', { module: 'tokens-validation', expected: apiKey, actual: validateAPIKeyResult.api_key }); result = { valid: false, message: messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_API_KEY') }; } } catch (error) { - log.debug('API key validation API call failed', { module: 'tokens-validation', error: error.message }); + log.debug('API key validation API call failed.', { module: 'tokens-validation', error: error.message }); handleAndLogError(error, { apiKey }, ); result = { valid: false, message: messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_API_KEY') }; } - log.debug('API key validation completed', { module: 'tokens-validation', result }); + log.debug('API key validation completed.', { module: 'tokens-validation', result }); return result; }; diff --git a/packages/contentstack-bootstrap/src/bootstrap/utils.ts b/packages/contentstack-bootstrap/src/bootstrap/utils.ts index 91575eb1d6..1266a3fd13 100644 --- a/packages/contentstack-bootstrap/src/bootstrap/utils.ts +++ b/packages/contentstack-bootstrap/src/bootstrap/utils.ts @@ -138,7 +138,7 @@ export const setupEnvironments = async ( cliux.print(messageHandler.parse('CLI_BOOTSTRAP_APP_FAILED_TO_CREATE_ENV_FILE_FOR_ENV', environment.name)); } } else { - cliux.print('No environments name found for the environment'); + cliux.print('No environment name found for the selected environment.'); } } } else { diff --git a/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts b/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts index 2a353d1d5d..8cf129cf30 100644 --- a/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts +++ b/packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts @@ -147,7 +147,7 @@ export default class BootstrapCommand extends Command { } else if (appType === 'starterapp') { selectedApp = await inquireApp(config.starterApps); } else { - this.error('Invalid app type provided ' + appType, { exit: 1 }); + this.error('Invalid app type provided: ' + appType, { exit: 1 }); } } diff --git a/packages/contentstack-branches/src/branch/merge-handler.ts b/packages/contentstack-branches/src/branch/merge-handler.ts index 67d0f0369d..0d27552152 100644 --- a/packages/contentstack-branches/src/branch/merge-handler.ts +++ b/packages/contentstack-branches/src/branch/merge-handler.ts @@ -280,7 +280,7 @@ export default class MergeHandler { mergeContent[module].deleted = moduleBranchCompareData.deleted; break; default: - cliux.error(`error: Invalid strategy ${strategy}`); + cliux.error(`Error: Invalid strategy '${strategy}'`); process.exit(1); } } diff --git a/packages/contentstack-branches/src/commands/cm/branches/delete.ts b/packages/contentstack-branches/src/commands/cm/branches/delete.ts index b6787b13cf..19eab092a7 100644 --- a/packages/contentstack-branches/src/commands/cm/branches/delete.ts +++ b/packages/contentstack-branches/src/commands/cm/branches/delete.ts @@ -47,7 +47,7 @@ export default class BranchDeleteCommand extends Command { if (!branchDeleteFlags.yes) { const confirmBranch = await interactive.askBranchNameConfirmation(); if (confirmBranch !== branchDeleteFlags.uid) { - cliux.error(`error: To delete the branch, enter a valid branch name '${branchDeleteFlags.uid}'`); + cliux.error(`Error: To delete the branch, enter a valid branch name '${branchDeleteFlags.uid}'`); process.exit(1); } } diff --git a/packages/contentstack-branches/src/utils/asset-folder-create-script.ts b/packages/contentstack-branches/src/utils/asset-folder-create-script.ts index a358c9e286..0a41c0a092 100644 --- a/packages/contentstack-branches/src/utils/asset-folder-create-script.ts +++ b/packages/contentstack-branches/src/utils/asset-folder-create-script.ts @@ -143,13 +143,13 @@ export function assetFolderCreateScript(contentType) { migration.addTask(createAssetTask()); } else { if (apiKey.length === 0) { - console.error('Please provide api key using --stack-api-key flag'); + console.error('Provide the API key using the --stack-api-key flag.'); } if (!compareBranch) { - console.error('Please provide compare branch through --config compare-branch: flag'); + console.error('Specify the compare branch using the --config compare-branch: flag.'); } if (branch.length === 0) { - console.error('Please provide branch name through --branch flag'); + console.error('Specify the branch name using the --branch flag.'); } } } diff --git a/packages/contentstack-branches/src/utils/entry-create-script.ts b/packages/contentstack-branches/src/utils/entry-create-script.ts index bfda436afc..dabd71ff9b 100644 --- a/packages/contentstack-branches/src/utils/entry-create-script.ts +++ b/packages/contentstack-branches/src/utils/entry-create-script.ts @@ -599,13 +599,13 @@ export function entryCreateScript(contentType) { migration.addTask(createEntryTask()); } else { if (apiKey.length === 0) { - console.error('Please provide api key using --stack-api-key flag'); + console.error('Provide the API key using the --stack-api-key flag.'); } if (!compareBranch) { - console.error('Please provide compare branch through --config compare-branch: flag'); + console.error('Specify the compare branch using the --config compare-branch: flag.'); } if (branch.length === 0) { - console.error('Please provide branch name through --branch flag'); + console.error('Specify the branch name using the --branch flag.'); } } }; diff --git a/packages/contentstack-branches/src/utils/entry-create-update-script.ts b/packages/contentstack-branches/src/utils/entry-create-update-script.ts index a47fcdb9b1..ac4ea205c1 100644 --- a/packages/contentstack-branches/src/utils/entry-create-update-script.ts +++ b/packages/contentstack-branches/src/utils/entry-create-update-script.ts @@ -669,13 +669,13 @@ export function entryCreateUpdateScript(contentType) { migration.addTask(updateEntryTask()); } else { if (apiKey.length === 0) { - console.error('Please provide api key using --stack-api-key flag'); + console.error('Provide the API key using the --stack-api-key flag.'); } if (!compareBranch) { - console.error('Please provide compare branch through --config compare-branch: flag'); + console.error('Specify the compare branch using the --config compare-branch: flag.'); } if (branch.length === 0) { - console.error('Please provide branch name through --branch flag'); + console.error('Specify the branch name using the --branch flag.'); } } };`; diff --git a/packages/contentstack-branches/src/utils/entry-update-script.ts b/packages/contentstack-branches/src/utils/entry-update-script.ts index 88ea7eb77c..8c1fa73f32 100644 --- a/packages/contentstack-branches/src/utils/entry-update-script.ts +++ b/packages/contentstack-branches/src/utils/entry-update-script.ts @@ -666,13 +666,13 @@ export function entryUpdateScript(contentType) { migration.addTask(updateEntryTask()); } else { if (apiKey.length === 0) { - console.error('Please provide api key using --stack-api-key flag'); + console.error('Provide the API key using the --stack-api-key flag.'); } if (!compareBranch) { - console.error('Please provide compare branch through --config compare-branch: flag'); + console.error('Specify the compare branch using the --config compare-branch: flag.'); } if (branch.length === 0) { - console.error('Please provide branch name through --branch flag'); + console.error('Specify the branch name using the --branch flag.'); } } };`; diff --git a/packages/contentstack-branches/src/utils/interactive.ts b/packages/contentstack-branches/src/utils/interactive.ts index 50b6bef4f8..dc8730fd6f 100644 --- a/packages/contentstack-branches/src/utils/interactive.ts +++ b/packages/contentstack-branches/src/utils/interactive.ts @@ -97,7 +97,7 @@ export async function selectMergeStrategy(): Promise { }) .then((name) => name as string) .catch((err) => { - cliux.error('Failed to collect the merge strategy'); + cliux.error('Failed to retrieve the merge strategy.'); process.exit(1); }); @@ -120,7 +120,7 @@ export async function selectMergeStrategySubOptions(): Promise { }) .then((name) => name as string) .catch((err) => { - cliux.error('Failed to collect the merge strategy'); + cliux.error('Failed to retrieve the merge strategy.'); process.exit(1); }); @@ -166,7 +166,7 @@ export async function selectContentMergePreference(): Promise { }) .then((name) => name as string) .catch((err) => { - cliux.error('Failed to collect the preference'); + cliux.error('Failed to retrieve the preference.'); process.exit(1); }); diff --git a/packages/contentstack-bulk-publish/src/commands/cm/assets/publish.js b/packages/contentstack-bulk-publish/src/commands/cm/assets/publish.js index f5baa17886..a032678c03 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/assets/publish.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/assets/publish.js @@ -50,7 +50,7 @@ class AssetsPublishCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } updatedFlags.bulkPublish = updatedFlags.bulkPublish === 'false' ? false : true; if (updatedFlags.folderUid === undefined) { @@ -104,10 +104,10 @@ class AssetsPublishCommand extends Command { this.error(message, { exit: 2 }); } } else { - this.error('Confirmation failed'); + this.error('Confirmation failed.'); } } else { - this.error('Validation failed'); + this.error('Validation failed.'); } } @@ -118,7 +118,7 @@ class AssetsPublishCommand extends Command { } if (sourceEnv && !deliveryToken) { - this.error('Specify source environment delivery token. Please check --help for more details', { exit: 2 }); + this.error('Specify the source environment delivery token. Run --help for more details.', { exit: 2 }); } if (!environments || environments.length === 0) { diff --git a/packages/contentstack-bulk-publish/src/commands/cm/assets/unpublish.js b/packages/contentstack-bulk-publish/src/commands/cm/assets/unpublish.js index d127464f34..75aa85d142 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/assets/unpublish.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/assets/unpublish.js @@ -53,7 +53,7 @@ class UnpublishCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } if (!updatedFlags.deliveryToken) { updatedFlags.deliveryToken = await cliux.prompt('Enter delivery token of your source environment'); @@ -62,7 +62,7 @@ class UnpublishCommand extends Command { stack = await getStack(config); } if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) { - this.error('Delivery Token is required for executing this command', { exit: 2 }); + this.error('A delivery token is required to execute this command.', { exit: 2 }); } if (await this.confirmFlags(updatedFlags)) { diff --git a/packages/contentstack-bulk-publish/src/commands/cm/bulk-publish/cross-publish.js b/packages/contentstack-bulk-publish/src/commands/cm/bulk-publish/cross-publish.js index 81f6ddb338..5ca4af0315 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/bulk-publish/cross-publish.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/bulk-publish/cross-publish.js @@ -41,7 +41,7 @@ class CrossPublishCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } if (!updatedFlags.deliveryToken) { updatedFlags.deliveryToken = await cliux.prompt('Enter delivery token of your source environment'); @@ -52,7 +52,7 @@ class CrossPublishCommand extends Command { } if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) { - this.error('Delivery Token is required for executing this command', { exit: 2 }); + this.error('A delivery token is required to execute this command.', { exit: 2 }); } if (await this.confirmFlags(updatedFlags)) { diff --git a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-modified.js b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-modified.js index 30c2decc63..7d93ffbd55 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-modified.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-modified.js @@ -51,7 +51,7 @@ class PublishModifiedCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } updatedFlags.bulkPublish = updatedFlags.bulkPublish !== 'false'; stack = await getStack(config); diff --git a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-non-localized-fields.js b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-non-localized-fields.js index 834abdeb4f..2551f75514 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-non-localized-fields.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-non-localized-fields.js @@ -60,7 +60,7 @@ class NonlocalizedFieldChangesCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } stack = await getStack(config); } diff --git a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-only-unpublished.js b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-only-unpublished.js index febfa9f96c..57577a68a2 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-only-unpublished.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish-only-unpublished.js @@ -8,7 +8,7 @@ class PublishOnlyUnpublished extends Command { try { await publishOnlyUnpublishedService.apply(this, [PublishOnlyUnpublished]); } catch (error) { - this.error(error, { exit: 2 }); + this.error(error?.message || error, { exit: 2 }); } } } diff --git a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish.js b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish.js index 92ec008a82..fc32da49ce 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/entries/publish.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/entries/publish.js @@ -64,7 +64,7 @@ class PublishEntriesCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } updatedFlags.bulkPublish = updatedFlags.bulkPublish !== 'false'; stack = await getStack(config); @@ -131,7 +131,7 @@ class PublishEntriesCommand extends Command { } if (sourceEnv && !deliveryToken) { - this.error('Specify source environment delivery token. Please check --help for more details', { exit: 2 }); + this.error('Specify the source environment delivery token. Run --help for more details.', { exit: 2 }); } if (publishAllContentTypes && contentTypes && contentTypes.length > 0) { diff --git a/packages/contentstack-bulk-publish/src/commands/cm/entries/unpublish.js b/packages/contentstack-bulk-publish/src/commands/cm/entries/unpublish.js index 8aa29a7d87..2402a4c193 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/entries/unpublish.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/entries/unpublish.js @@ -56,7 +56,7 @@ class UnpublishCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } if (!updatedFlags.deliveryToken) { updatedFlags.deliveryToken = await cliux.prompt('Enter delivery token of your source environment'); @@ -65,7 +65,7 @@ class UnpublishCommand extends Command { stack = await getStack(config); } if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) { - this.error('Delivery Token is required for executing this command', { exit: 2 }); + this.error('A delivery token is required to execute this command.', { exit: 2 }); } if (await this.confirmFlags(updatedFlags)) { diff --git a/packages/contentstack-bulk-publish/src/commands/cm/entries/update-and-publish.js b/packages/contentstack-bulk-publish/src/commands/cm/entries/update-and-publish.js index b60a99a021..ec36a1768b 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/entries/update-and-publish.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/entries/update-and-publish.js @@ -50,7 +50,7 @@ class UpdateAndPublishCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } updatedFlags.bulkPublish = updatedFlags.bulkPublish === 'false' ? false : true; diff --git a/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-clear-logs.js b/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-clear-logs.js index 018f308d22..7f36ef17ee 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-clear-logs.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-clear-logs.js @@ -37,7 +37,7 @@ class ClearCommand extends Command { } this.log('Log files have been cleared'); } else { - this.error(`The log directory doesn't exist.`); + this.error(`The log directory does not exist.`); } } catch (e) { return; @@ -50,7 +50,7 @@ class ClearCommand extends Command { this.log('Total number of log files - ', files.length); }); } else { - this.error(`The log directory doesn't exist.`); + this.error(`The log directory does not exist.`); } } } diff --git a/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-configure.js b/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-configure.js index 1a59d10674..e403e3d7e1 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-configure.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/stacks/publish-configure.js @@ -13,12 +13,12 @@ class ConfigureCommand extends Command { try { this.getToken(configureFlags.alias); } catch (error) { - this.error(`The configured management token alias ${configureFlags.alias} has not been added yet. Add it using 'csdx auth:tokens:add -a ${configureFlags.alias}'`, { exit: 2 }) + this.error(`The configured management token alias '${configureFlags.alias}' has not been added yet. Add it using 'csdx auth:tokens:add -a ${configureFlags.alias}'.`, { exit: 2 }) } } else if (configureFlags['stack-api-key']) { configureFlags.stackApiKey = configureFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } this.setConfig(configureFlags); diff --git a/packages/contentstack-bulk-publish/src/commands/cm/stacks/unpublish.js b/packages/contentstack-bulk-publish/src/commands/cm/stacks/unpublish.js index b2c867996f..2b24cea396 100644 --- a/packages/contentstack-bulk-publish/src/commands/cm/stacks/unpublish.js +++ b/packages/contentstack-bulk-publish/src/commands/cm/stacks/unpublish.js @@ -57,7 +57,7 @@ class UnpublishCommand extends Command { } else if (updatedFlags['stack-api-key']) { config.stackApiKey = updatedFlags['stack-api-key']; } else { - this.error('Please use `--alias` or `--stack-api-key` to proceed.', { exit: 2 }); + this.error('Use the `--alias` or `--stack-api-key` flag to proceed.', { exit: 2 }); } if (!updatedFlags.deliveryToken) { updatedFlags.deliveryToken = await cliux.prompt('Enter delivery token of your source environment'); @@ -66,7 +66,7 @@ class UnpublishCommand extends Command { stack = await getStack(config); } if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) { - this.error('Delivery Token is required for executing this command', { exit: 2 }); + this.error('A delivery token is required to execute this command.', { exit: 2 }); } if (await this.confirmFlags(updatedFlags)) { diff --git a/packages/contentstack-bulk-publish/src/consumer/publish.js b/packages/contentstack-bulk-publish/src/consumer/publish.js index e7b95649a5..5b9ddeab81 100644 --- a/packages/contentstack-bulk-publish/src/consumer/publish.js +++ b/packages/contentstack-bulk-publish/src/consumer/publish.js @@ -39,18 +39,18 @@ function displayEntriesDetails(sanitizedData, action, mapping = []) { if (Object.keys(mapping).includes(pd.environment)) { console.log( chalk.green( - `Entry UID '${entry.uid}' of CT '${entry.content_type}' in locale '${entry.locale}' version '${pd.version}' in environment '${pd.environment}'`, + `Entry UID: '${entry.uid}', Content Type: '${entry.content_type}', Locale: '${entry.locale}', Version: '${pd.version}', Environment: '${pd.environment}'`, ), ) } }); if(!Array.isArray(entry.publish_details)){ - console.log(chalk.green(`Entry UID '${entry.uid}' of CT '${entry.content_type}' in locale '${entry.locale}'`)); + console.log(chalk.green(`Entry UID: '${entry.uid}', Content Type: '${entry.content_type}', Locale: '${entry.locale}'`)); } }); } else if (action === 'bulk_unpublish') { sanitizedData.forEach((entry) => { - console.log(chalk.green(`Entry UID '${entry.uid}' of CT '${entry.content_type}' in locale '${entry.locale}'`)); + console.log(chalk.green(`Entry UID: '${entry.uid}', Content Type: '${entry.content_type}', Locale: '${entry.locale}'`)); }); } } @@ -62,9 +62,9 @@ function displayAssetsDetails(sanitizedData, action, mapping) { if (Object.keys(mapping).includes(pd.environment)) { console.log( chalk.green( - `Asset UID '${asset.uid}' ${pd.version ? `and version '${pd.version}'` : ''} ${ - asset.locale ? `in locale '${asset.locale}'` : '' - } in environment ${pd.environment}`, + `Asset UID: '${asset.uid}'${pd.version ? `, Version: '${pd.version}'` : ''}${ + asset.locale ? `, Locale: '${asset.locale}'` : '' + }, Environment: ${pd.environment}`, ), ); } @@ -74,8 +74,8 @@ function displayAssetsDetails(sanitizedData, action, mapping) { sanitizedData.forEach((asset) => { console.log( chalk.green( - `Asset UID '${asset.uid}' ${asset.version ? `and version '${asset.version}'` : ''} ${ - asset.locale ? `in locale '${asset.locale}'` : '' + `Asset UID: '${asset.uid}'${asset.version ? `, Version: '${asset.version}'` : ''}${ + asset.locale ? `, Locale: '${asset.locale}'` : '' }`, ), ); @@ -98,7 +98,7 @@ async function publishEntry(data, _config, queue) { if (!publishEntryResponse.error_message) { console.log( chalk.green( - `entry published with ContentType uid=${entryObj.content_type} Entry uid=${entryObj.entryUid} locale=${entryObj.locale}`, + `Entry published. Content Type UID: ${entryObj.content_type}, Entry UID: ${entryObj.entryUid}, Locale: ${entryObj.locale}`, ), ); delete entryObj.stack; @@ -119,9 +119,9 @@ async function publishEntry(data, _config, queue) { delete entryObj.stack; console.log( chalk.red( - `entry could not be published with ContentType uid=${entryObj.content_type} entry uid=${ + `Entry could not be published. Content Type UID: ${entryObj.content_type}, Entry UID: ${ entryObj.entryUid - } locale=${entryObj.locale} error=${formatError(error)}`, + }, Locale: ${entryObj.locale}, Error: ${formatError(error)}`, ), ); addLogs( @@ -147,7 +147,7 @@ async function publishAsset(data, _config, queue) { .publish({ publishDetails: { environments: assetobj.environments, locales: [assetobj.locale || 'en-us'] } }) .then((publishAssetResponse) => { if (!publishAssetResponse.error_message) { - console.log(chalk.green(`asset published with Asset uid=${assetobj.assetUid}, locale=${assetobj.locale}`)); + console.log(chalk.green(`Asset published. Asset UID: ${assetobj.assetUid}, Locale: ${assetobj.locale}`)); delete assetobj.stack; addLogs( logger, @@ -164,7 +164,7 @@ async function publishAsset(data, _config, queue) { queue.Enqueue(data); } else { delete assetobj.stack; - console.log(chalk.red(`Could not publish because of Error=${formatError(error)}`)); + console.log(chalk.red(`Could not publish. Error: ${formatError(error)}`)); addLogs( logger, { @@ -193,7 +193,7 @@ async function UnpublishEntry(data, _config, queue) { delete entryObj.stack; console.log( chalk.green( - `Entry unpublished with ContentType uid=${entryObj.content_type} Entry uid=${entryObj.entryUid} locale=${entryObj.locale}`, + `Entry unpublished. Content Type UID: ${entryObj.content_type}, Entry UID: ${entryObj.entryUid}, Locale: ${entryObj.locale}`, ), ); addLogs( @@ -213,9 +213,9 @@ async function UnpublishEntry(data, _config, queue) { delete entryObj.stack; console.log( chalk.red( - `Entry could not be unpublished with ContentType uid=${entryObj.content_type} Entry uid=${ + `Entry could not be unpublished. Content Type UID: ${entryObj.content_type}, Entry UID: ${ entryObj.entryUid - } locale=${entryObj.locale} error=${formatError(error)}`, + }, Locale: ${entryObj.locale}, Error: ${formatError(error)}`, ), ); addLogs( @@ -237,7 +237,7 @@ async function UnpublishAsset(data, _config, queue) { .then((unpublishAssetResponse) => { if (!unpublishAssetResponse.error_message) { delete assetobj.stack; - console.log(`Asset unpublished with Asset uid=${assetobj.assetUid}`); + console.log(`The asset with UID '${assetobj.assetUid}' has been unpublished.`); addLogs( logger, { options: assetobj, api_key: stack.stackHeaders.api_key, alias: stack.alias, host: stack.host }, @@ -253,7 +253,7 @@ async function UnpublishAsset(data, _config, queue) { queue.Enqueue(data); } else { delete assetobj.stack; - console.log(chalk.red(`Could not Unpublish because of error=${formatError(error)}`)); + console.log(chalk.red(`Could not unpublish. Error: ${formatError(error)}`)); addLogs( logger, { options: assetobj, api_key: stack.stackHeaders.api_key, alias: stack.alias, host: stack.host }, @@ -330,7 +330,7 @@ async function performBulkPublish(data, _config, queue) { queue.Enqueue(data); } else { delete bulkPublishObj.stack; - console.log(chalk.red(`Bulk entries failed to publish with error ${formatError(error)}`)); + console.log(chalk.red(`Bulk entries failed to publish. Error: ${formatError(error)}`)); displayEntriesDetails(bulkPublishObj.entries, 'bulk_publish', mapping); addLogs( logger, @@ -385,7 +385,7 @@ async function performBulkPublish(data, _config, queue) { queue.Enqueue(data); } else { delete bulkPublishObj.stack; - console.log(chalk.red(`Bulk assets failed to publish with error ${formatError(error)}`)); + console.log(chalk.red(`Bulk assets failed to publish. Error: ${formatError(error)}`)); displayAssetsDetails(sanitizedData, 'bulk_publish', mapping); addLogs( @@ -397,7 +397,7 @@ async function performBulkPublish(data, _config, queue) { }); break; default: - console.log('No such type'); + console.log('No such type found. If it is for a content type, use "No such content type found."'); } } @@ -455,7 +455,7 @@ async function performBulkUnPublish(data, _config, queue) { queue.Enqueue(data); } else { delete bulkUnPublishObj.stack; - console.log(chalk.red(`Bulk entries failed to Unpublish with error ${formatError(error)}`)); + console.log(chalk.red(`Bulk entries failed to unpublish. Error: ${formatError(error)}`)); displayEntriesDetails(bulkUnPublishObj.entries, 'bulk_unpublish'); addLogs( logger, @@ -510,7 +510,7 @@ async function performBulkUnPublish(data, _config, queue) { queue.Enqueue(data); } else { delete bulkUnPublishObj.stack; - console.log(chalk.red(`Bulk assets failed to Unpublish with error ${formatError(error)}`)); + console.log(chalk.red(`Bulk assets failed to unpublish. Error: ${formatError(error)}`)); displayAssetsDetails(bulkUnPublishObj.assets, 'bulk_unpublish'); addLogs( logger, @@ -643,7 +643,7 @@ async function publishUsingVersion(data, _config, queue) { } } - console.log(chalk.red(`Entry=${entry.uid} failed to publish with error ${formatError(error)}`)); + console.log(chalk.red(`Entry '${entry.uid}' failed to publish. Error: ${formatError(error)}`)); } }); }); diff --git a/packages/contentstack-bulk-publish/src/producer/add-fields.js b/packages/contentstack-bulk-publish/src/producer/add-fields.js index e3853dfb57..7f728c8cf1 100644 --- a/packages/contentstack-bulk-publish/src/producer/add-fields.js +++ b/packages/contentstack-bulk-publish/src/producer/add-fields.js @@ -256,10 +256,10 @@ async function getEntries( }); } } else { - console.log(`Update Failed for entryUid ${entries[index].uid} with contentType ${contentType}`); + console.log(`Update failed for entry UID '${entries[index].uid}' of content type '${contentType}'.`); } } else { - console.log(`No change Observed for contentType ${contentType} with entry ${entries[index].uid}`); + console.log(`No changes detected for content type '${contentType}' and entry UID '${entries[index].uid}'.`); } if (index === entriesResponse.items.length - 1 && bulkPublishSet.length > 0 && bulkPublishSet.length < bulkPublishLimit) { @@ -342,12 +342,12 @@ async function start( bulkPublishLimit ); } catch (err) { - console.log(`Failed to get Entries with contentType ${contentTypes[i]} and locale ${locales[j]}`); + console.log(`Failed to retrieve entries for content type '${contentTypes[i]}' and locale '${locales[j]}'.`); } } }) .catch((err) => { - console.log(`Failed to fetch schema${JSON.stringify(err)}`); + console.log(`Failed to fetch schema: ${JSON.stringify(err)}`); }); } } diff --git a/packages/contentstack-bulk-publish/src/producer/cross-publish.js b/packages/contentstack-bulk-publish/src/producer/cross-publish.js index 3a13f35ee4..f77f34b7f9 100644 --- a/packages/contentstack-bulk-publish/src/producer/cross-publish.js +++ b/packages/contentstack-bulk-publish/src/producer/cross-publish.js @@ -225,7 +225,7 @@ async function getSyncEntries( await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv, apiVersion, bulkPublishLimit, variantsFlag); } if (!entriesResponse.pagination_token) { - if (!changedFlag) console.log('No Entries/Assets Found published on specified environment'); + if (!changedFlag) console.log('No entries or assets found published in the specified environment.'); return resolve(); } setTimeout(async () => { diff --git a/packages/contentstack-bulk-publish/src/producer/publish-edits.js b/packages/contentstack-bulk-publish/src/producer/publish-edits.js index 83f31695fb..dfc57a15d5 100644 --- a/packages/contentstack-bulk-publish/src/producer/publish-edits.js +++ b/packages/contentstack-bulk-publish/src/producer/publish-edits.js @@ -107,7 +107,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis } if (responseEntries.count === skipCount) { if (!changedFlag) - console.log(`No Edits Were observed on specified Environment for contentType ${contentType}`); + console.log(`No edits were detected in the specified environment for content type ${contentType}`); bulkPublishSet = []; return resolve(); } diff --git a/packages/contentstack-bulk-publish/src/producer/publish-unpublished-env.js b/packages/contentstack-bulk-publish/src/producer/publish-unpublished-env.js index 0bcfcc89ff..7e2c4c0b62 100644 --- a/packages/contentstack-bulk-publish/src/producer/publish-unpublished-env.js +++ b/packages/contentstack-bulk-publish/src/producer/publish-unpublished-env.js @@ -122,7 +122,7 @@ async function getEntries(stack, contentType, environmentUid, locale, bulkPublis } } if (responseEntries.count === skipCount) { - if (!changedFlag) console.log(`No Draft Entries of contentType ${contentType} was found`); + if (!changedFlag) console.log(`No draft entries found for content type ${contentType}`); bulkPublishSet = []; return resolve(); } diff --git a/packages/contentstack-bulk-publish/src/producer/unpublish.js b/packages/contentstack-bulk-publish/src/producer/unpublish.js index e774a85cac..95b45b9786 100644 --- a/packages/contentstack-bulk-publish/src/producer/unpublish.js +++ b/packages/contentstack-bulk-publish/src/producer/unpublish.js @@ -229,7 +229,7 @@ async function getSyncEntries( await bulkAction(stack, entriesResponse.items, bulkUnpublish, environment, locale, apiVersion, bulkPublishLimit, false); } if (entriesResponse.items.length === 0 && !entriesResponse.pagination_token) { - if (!changedFlag) console.log('No Entries/Assets Found published on specified environment'); + if (!changedFlag) console.log('No entries or assets found published in the specified environment.'); return resolve(); } diff --git a/packages/contentstack-bulk-publish/src/util/index.js b/packages/contentstack-bulk-publish/src/util/index.js index 9651b8761d..ad067baaaf 100644 --- a/packages/contentstack-bulk-publish/src/util/index.js +++ b/packages/contentstack-bulk-publish/src/util/index.js @@ -2,7 +2,7 @@ const chalk = require('chalk'); const fs = require('fs'); function prettyPrint(data) { - console.log(chalk.yellow('Configuration to be used for executing this command:')); + console.log(chalk.yellow('Configuration to use for executing this command:')); Object.keys(data).forEach((key, _index) => { console.log(chalk.grey(`${key}: ${data[key]}`)); }); diff --git a/packages/contentstack-bulk-publish/src/util/logger.js b/packages/contentstack-bulk-publish/src/util/logger.js index 16434dd504..400f5ed1ae 100644 --- a/packages/contentstack-bulk-publish/src/util/logger.js +++ b/packages/contentstack-bulk-publish/src/util/logger.js @@ -47,7 +47,7 @@ module.exports.addLogs = (logger, data, Type) => { logger.info(data); break; default: - console.log('Unknown logging level'); + console.log('Unknown log level.'); } }; diff --git a/packages/contentstack-bulk-publish/src/util/store.js b/packages/contentstack-bulk-publish/src/util/store.js index cf745f6cf4..ad98bfc8f4 100644 --- a/packages/contentstack-bulk-publish/src/util/store.js +++ b/packages/contentstack-bulk-publish/src/util/store.js @@ -12,7 +12,7 @@ function save(key, data) { console.log(chalk.red(error)); return; } - console.log(chalk.green(`Configuration file has been successfully created at ${filePath}`)); + console.log(chalk.green(`Configuration file successfully created at '${filePath}'.`)); }); } @@ -53,7 +53,7 @@ function updateMissing(key, flags) { savedConfig = get(key, pathValidator(flags.config)); Object.keys(savedConfig).forEach((element) => { if (flags[element] === undefined) { - console.log(`Using ${element} from config file`); + console.log(`Using '${element}' from the configuration file.`); flags[element] = savedConfig[element]; } }); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/assets/publish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/assets/publish.test.js index 3201988118..fb42fdd299 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/assets/publish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/assets/publish.test.js @@ -57,7 +57,7 @@ describe('AssetsPublish', () => { it('Should fail when alias and stack api key flags are not passed', async () => { const args = ['--environments', environments[0], '--locales', locales[0], '--yes']; - const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; + const expectedError = 'Use the `--alias` or `--stack-api-key` flag to proceed.'; try { await AssetsPublish.run(args); } catch (error) { diff --git a/packages/contentstack-bulk-publish/test/unit/commands/assets/unpublish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/assets/unpublish.test.js index 42c8b62a50..157a768d91 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/assets/unpublish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/assets/unpublish.test.js @@ -90,7 +90,7 @@ describe('AssetsUnpublish Command', () => { try { await UnpublishCommand.run(['--environment', 'env', '--locale', 'en-us', '--yes']); } catch (error) { - expect(error.message).to.equal('Please use `--alias` or `--stack-api-key` to proceed.'); + expect(error.message).to.equal('Use the `--alias` or `--stack-api-key` flag to proceed.'); expect(runStub.called).to.be.false; } }); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/bulk-publish/cross-publish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/bulk-publish/cross-publish.test.js index 69f3b7a55e..f6337514b1 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/bulk-publish/cross-publish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/bulk-publish/cross-publish.test.js @@ -102,7 +102,7 @@ describe('CrossPublish', () => { 'token123', ]); } catch (error) { - expect(error.message).to.include('Please use `--alias` or `--stack-api-key` to proceed.'); + expect(error.message).to.include('Use the `--alias` or `--stack-api-key` flag to proceed.'); } }); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-modified.test.js b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-modified.test.js index 5ede06e909..c8a24b1a9e 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-modified.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-modified.test.js @@ -53,7 +53,7 @@ describe('EntriesPublishModified Command', () => { await EntriesPublishModified.run(args); } catch (error) { expect(error).to.be.an('error'); - expect(error.message).to.equal('Please use `--alias` or `--stack-api-key` to proceed.'); + expect(error.message).to.equal('Use the `--alias` or `--stack-api-key` flag to proceed.'); expect(runStub.calledOnce).to.be.true; } }); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-non-localized-fields.test.js b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-non-localized-fields.test.js index 83544a0fcb..c189faaa8f 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-non-localized-fields.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-non-localized-fields.test.js @@ -50,7 +50,7 @@ describe('EntriesPublishNonLocalizedFields', () => { environments[1], '--yes', ]; - const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; + const expectedError = 'Use the `--alias` or `--stack-api-key` flag to proceed.'; try { await EntriesPublishNonLocalizedFields.run(args); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-only-unpublished.test.js b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-only-unpublished.test.js index 1c88160cf2..eacbc7fcd9 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-only-unpublished.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish-only-unpublished.test.js @@ -50,7 +50,7 @@ describe('EntriesPublishOnlyUnpublished', () => { '--yes', ]; - const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; + const expectedError = 'Use the `--alias` or `--stack-api-key` flag to proceed.'; runStub = sinon.stub(EntriesPublishOnlyUnpublished.prototype, 'run').callsFake(function () { throw new Error(expectedError); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish.test.js index 212fd125db..e1fa2018d4 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/entries/publish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/entries/publish.test.js @@ -59,7 +59,7 @@ describe('EntriesPublish Command', () => { '--yes', ]; - const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; + const expectedError = 'Use the `--alias` or `--stack-api-key` flag to proceed.'; try { await EntriesPublish.run(args); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/entries/unpublish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/entries/unpublish.test.js index f17cb02817..8c29666cd0 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/entries/unpublish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/entries/unpublish.test.js @@ -90,7 +90,7 @@ describe('EntriesUnpublish Command', () => { try { await EntriesUnpublish.run(['--environment', 'env', '--locale', 'en-us', '--yes']); } catch (error) { - expect(error.message).to.equal('Please use `--alias` or `--stack-api-key` to proceed.'); + expect(error.message).to.equal('Use the `--alias` or `--stack-api-key` flag to proceed.'); expect(runStub.called).to.be.false; } }); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/entries/update-and-publish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/entries/update-and-publish.test.js index df7db33689..4af1e01c82 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/entries/update-and-publish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/entries/update-and-publish.test.js @@ -51,7 +51,7 @@ describe('EntriesUpdateAndPublish', () => { it('Should fail when alias and stack api key flags are not passed', async () => { const args = ['--content-types', contentTypes[0], '-e', environments[0], '--locales', locales[0], '--yes']; const entriesUpdateAndPublishSpy = sinon.spy(EntriesUpdateAndPublish.prototype, 'run'); - const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; + const expectedError = 'Use the `--alias` or `--stack-api-key` flag to proceed.'; try { await EntriesUpdateAndPublish.run(args); } catch (error) { diff --git a/packages/contentstack-bulk-publish/test/unit/commands/stacks/publish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/stacks/publish.test.js index 36237f663b..5ebdd2a86d 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/stacks/publish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/stacks/publish.test.js @@ -59,7 +59,7 @@ describe('StackPublish', () => { '--yes', ]; - const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; + const expectedError = 'Use the `--alias` or `--stack-api-key` flag to proceed.'; runStub = sinon.stub(StackPublish.prototype, 'run').callsFake(function () { throw new Error(expectedError); diff --git a/packages/contentstack-bulk-publish/test/unit/commands/stacks/unpublish.test.js b/packages/contentstack-bulk-publish/test/unit/commands/stacks/unpublish.test.js index ed25eb69b8..a26cf70487 100644 --- a/packages/contentstack-bulk-publish/test/unit/commands/stacks/unpublish.test.js +++ b/packages/contentstack-bulk-publish/test/unit/commands/stacks/unpublish.test.js @@ -76,7 +76,7 @@ describe('StackUnpublish', () => { '--yes', ]; - const expectedError = 'Please use `--alias` or `--stack-api-key` to proceed.'; + const expectedError = 'Use the `--alias` or `--stack-api-key` flag to proceed.'; runStub = sinon.stub(StackUnpublish.prototype, 'run').callsFake(function () { throw new Error(expectedError); diff --git a/packages/contentstack-clone/src/commands/cm/stacks/clone.js b/packages/contentstack-clone/src/commands/cm/stacks/clone.js index a1b5a44bcc..7f7d9f08b0 100644 --- a/packages/contentstack-clone/src/commands/cm/stacks/clone.js +++ b/packages/contentstack-clone/src/commands/cm/stacks/clone.js @@ -68,7 +68,7 @@ class StackCloneCommand extends Command { config.source_alias = sourceManagementTokenAlias; config.source_stack = listOfTokens[sourceManagementTokenAlias].apiKey; } else if (sourceManagementTokenAlias) { - console.log(`Provided source token alias (${sourceManagementTokenAlias}) not found in your config.!`); + console.log(`The source token alias '${sourceManagementTokenAlias}' was not found in your config.`); } if (destinationManagementTokenAlias && listOfTokens[destinationManagementTokenAlias]) { config.destination_alias = destinationManagementTokenAlias; @@ -103,7 +103,7 @@ class StackCloneCommand extends Command { if (isAuthenticated()) { handleClone(); } else { - console.log('Please login to execute this command, csdx auth:login'); + console.log('Log in to execute this command,csdx auth:login'); this.exit(1); } } else { @@ -151,7 +151,7 @@ class StackCloneCommand extends Command { } } catch (err) { if (err) { - console.log('\nCleaning up'); + console.log('\nCleaning up...'); const skipCodeArr = ['ENOENT', 'EBUSY', 'EPERM', 'EMFILE', 'ENOTEMPTY']; if (skipCodeArr.includes(err.code)) { @@ -168,10 +168,10 @@ class StackCloneCommand extends Command { const cleanUp = async (exitOrError) => { if (exitOrError) { // eslint-disable-next-line no-console - console.log('\nCleaning up'); + console.log('\nCleaning up...'); await this.cleanUp(pathDir); // eslint-disable-next-line no-console - console.log('done'); + console.log('Done.'); // eslint-disable-next-line no-process-exit if (exitOrError instanceof Promise) { diff --git a/packages/contentstack-command/src/index.ts b/packages/contentstack-command/src/index.ts index 77051b4283..977cf08243 100644 --- a/packages/contentstack-command/src/index.ts +++ b/packages/contentstack-command/src/index.ts @@ -21,7 +21,7 @@ abstract class ContentstackCommand extends Command { if (this._email) return this._email; this._email = configHandler.get('email'); if (this._email) return this._email; - throw new CLIError('You are not logged in. Please login with command $ csdx auth:login'); + throw new CLIError('You are not logged in. Run the command: $ csdx auth:login'); } get deliveryAPIClient() { diff --git a/packages/contentstack-config/src/commands/config/get/base-branch.ts b/packages/contentstack-config/src/commands/config/get/base-branch.ts index cf8dbdfe0d..71c4b05f4b 100644 --- a/packages/contentstack-config/src/commands/config/get/base-branch.ts +++ b/packages/contentstack-config/src/commands/config/get/base-branch.ts @@ -25,7 +25,7 @@ export default class BranchGetCommand extends Command { cliux.print(`error: ${messageHandler.parse('CLI_CONFIG_BRANCH_LIST_NO_BRANCHES')}`, { color: 'red' }); } } catch (error) { - cliux.error('error', error); + cliux.error('Error', error); } } } diff --git a/packages/contentstack-config/src/commands/config/get/early-access-header.ts b/packages/contentstack-config/src/commands/config/get/early-access-header.ts index 883cae1220..93c2bff299 100644 --- a/packages/contentstack-config/src/commands/config/get/early-access-header.ts +++ b/packages/contentstack-config/src/commands/config/get/early-access-header.ts @@ -24,7 +24,7 @@ export default class GetEarlyAccessHeaderCommand extends Command { ]; cliux.table(tableHeaders, tableData); } else { - cliux.print(`No Early Access header found!`, { color: 'red' }); + cliux.print(`Early Access header not found.`, { color: 'red' }); } } catch (error) { this.log('Unable to retrieve the Early Access header config', error instanceof Error ? error.message : error); diff --git a/packages/contentstack-config/src/commands/config/get/log.ts b/packages/contentstack-config/src/commands/config/get/log.ts index 8b2307a12c..6195bc3850 100644 --- a/packages/contentstack-config/src/commands/config/get/log.ts +++ b/packages/contentstack-config/src/commands/config/get/log.ts @@ -34,7 +34,7 @@ export default class LogGetCommand extends Command { color: 'dim', }); } catch (error) { - cliux.error('error', error); + cliux.error('Error', error); } } } diff --git a/packages/contentstack-config/src/commands/config/get/region.ts b/packages/contentstack-config/src/commands/config/get/region.ts index 5763ae9ac9..623264538a 100644 --- a/packages/contentstack-config/src/commands/config/get/region.ts +++ b/packages/contentstack-config/src/commands/config/get/region.ts @@ -10,18 +10,18 @@ export default class RegionGetCommand extends BaseCommand Number(u.trim())); if (utilizeValues.some((u: number) => isNaN(u) || u < 0 || u > 100)) { - cliux.error('Utilize percentages must be numbers between 0 and 100.'); + cliux.error('Utilization percentages must be numbers between 0 and 100.'); return; } if (limitName?.length > 0 && limitName[0]?.split(',')?.length !== utilizeValues.length) { - cliux.error('The number of utilization percentages must match the number of limit names provided.'); + cliux.error('The number of utilization percentages must match the number of limit names.'); return; } else { config.utilize = utilize.split(',').map((v: string) => v.trim()); @@ -85,7 +85,7 @@ export default class SetRateLimitCommand extends BaseCommand { it("Should execute 'config:set:region --AZURE-NA'", () => { const result = spawnSync('csdx', ['config:set:region', 'AZURE-NA'], { encoding: 'utf-8' }); const output = result.stdout + result.stderr; - expect(output).to.include('Region has been set to AZURE-NA'); - expect(output).to.include('CDA HOST: https://azure-na-cdn.contentstack.com'); - expect(output).to.include('CMA HOST: https://azure-na-api.contentstack.com'); + expect(output).to.include('CDA host: https://azure-na-cdn.contentstack.com'); + expect(output).to.include('CMA host: https://azure-na-api.contentstack.com'); }); it("Should execute 'config:get:region' and return the current region", () => { @@ -16,16 +15,15 @@ describe('ContentStack-Config Plugin Tests', () => { const output = result.stdout + result.stderr; expect(output).to.include('Currently using'); - expect(output).to.include('CDA HOST:'); - expect(output).to.include('CMA HOST:'); + expect(output).to.include('CDA host:'); + expect(output).to.include('CMA host:'); }); it("Should execute 'config:set:region AWS-NA' and set AWS-NA region", () => { const result = spawnSync('csdx', ['config:set:region', 'AWS-NA'], { encoding: 'utf-8' }); const output = result.stdout + result.stderr; - expect(output).to.include('Region has been set to AWS-NA'); - expect(output).to.include('CDA HOST: https://cdn.contentstack.io'); - expect(output).to.include('CMA HOST: https://api.contentstack.io'); + expect(output).to.include('CDA host: https://cdn.contentstack.io'); + expect(output).to.include('CMA host: https://api.contentstack.io'); }); }); diff --git a/packages/contentstack-config/test/unit/commands/rate-limit.test.ts b/packages/contentstack-config/test/unit/commands/rate-limit.test.ts index 429848964a..c1585b9213 100644 --- a/packages/contentstack-config/test/unit/commands/rate-limit.test.ts +++ b/packages/contentstack-config/test/unit/commands/rate-limit.test.ts @@ -59,7 +59,7 @@ describe('Rate Limit Commands', () => { const args = ['--org', 'test-org-id', '--utilize', '150', '--limit-name', 'getLimit']; await SetRateLimitCommand.run(args); - expect(errorMessage).to.equal('Utilize percentages must be numbers between 0 and 100.'); + expect(errorMessage).to.equal('Utilization percentages must be numbers between 0 and 100.'); expect(exitStub.calledWith(1)).to.be.true; @@ -74,7 +74,7 @@ describe('Rate Limit Commands', () => { await SetRateLimitCommand.run(args); expect(errorMessage).to.equal( - 'The number of utilization percentages must match the number of limit names provided.', + 'The number of utilization percentages must match the number of limit names.', ); expect(exitStub.calledWith(1)).to.be.true; @@ -90,7 +90,7 @@ describe('Rate Limit Commands', () => { await SetRateLimitCommand.run(args); expect(errorMessage).to.equal( - 'The number of utilization percentages must match the number of limit names provided.', + 'The number of utilization percentages must match the number of limit names.', ); expect(exitStub.calledWith(1)).to.be.true; diff --git a/packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.js b/packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.js index 2c98a30506..96461c8320 100644 --- a/packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.js +++ b/packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.js @@ -395,7 +395,7 @@ class ExportToCsvCommand extends Command { token: listOfTokens[managementTokenAlias].token, }; } else if (managementTokenAlias) { - this.error('Provided management token alias not found in your config.!'); + this.error('The provided management token alias was not found in your config.'); } return { apiClient, diff --git a/packages/contentstack-export-to-csv/src/util/index.js b/packages/contentstack-export-to-csv/src/util/index.js index e1b2cfc7c9..e2b8923605 100644 --- a/packages/contentstack-export-to-csv/src/util/index.js +++ b/packages/contentstack-export-to-csv/src/util/index.js @@ -378,7 +378,7 @@ function getContentTypeCount(stackAPIClient) { } function exitProgram() { - debug('Exiting'); + debug('Exiting...'); // eslint-disable-next-line no-undef process.exit(); } diff --git a/packages/contentstack-export/src/commands/cm/stacks/export.ts b/packages/contentstack-export/src/commands/cm/stacks/export.ts index 9a1539ad16..d397c51eb3 100644 --- a/packages/contentstack-export/src/commands/cm/stacks/export.ts +++ b/packages/contentstack-export/src/commands/cm/stacks/export.ts @@ -139,11 +139,11 @@ export default class ExportCommand extends Command { `The content of the stack ${exportConfig.apiKey} has been exported successfully!`, exportConfig.context, ); - log.info(`The exported content has been stored at '${exportDir}'`, exportConfig.context); - log.success(`The log has been stored at '${getLogPath()}'`, exportConfig.context); + log.info(`The exported content has been stored at '${exportDir}'.`, exportConfig.context); + log.success(`The log has been stored at '${getLogPath()}'.`, exportConfig.context); } catch (error) { handleAndLogError(error); - log.info(`The log has been stored at '${getLogPath()}'`); + log.info(`The log has been stored at '${getLogPath()}'.`); } } diff --git a/packages/contentstack-export/src/export/module-exporter.ts b/packages/contentstack-export/src/export/module-exporter.ts index dcf39ba515..dca694886b 100644 --- a/packages/contentstack-export/src/export/module-exporter.ts +++ b/packages/contentstack-export/src/export/module-exporter.ts @@ -51,7 +51,7 @@ class ModuleExporter { this.exportConfig.branchName = branch.uid; this.stackAPIClient.stackHeaders.branch = branch.uid; this.exportConfig.branchDir = path.join(this.exportConfig.exportDir, branch.uid); - log.info(`Exporting content from branch ${branch.uid}`, this.exportConfig.context); + log.info(`Exporting content from branch '${branch.uid}'...`, this.exportConfig.context); writeExportMetaFile(this.exportConfig, this.exportConfig.branchDir); await this.export(); log.success(`The content of branch ${branch.uid} has been exported successfully!`, this.exportConfig.context); @@ -76,7 +76,7 @@ class ModuleExporter { } async exportByModuleByName(moduleName: Modules) { - log.info(`Exporting module: ${moduleName}`, this.exportConfig.context); + log.info(`Exporting module: '${moduleName}'...`, this.exportConfig.context); // export the modules by name // calls the module runner which inturn calls the module itself let exportedModuleResponse; diff --git a/packages/contentstack-export/src/export/modules-js/assets.js b/packages/contentstack-export/src/export/modules-js/assets.js index 798e6320fd..6f029e99e4 100644 --- a/packages/contentstack-export/src/export/modules-js/assets.js +++ b/packages/contentstack-export/src/export/modules-js/assets.js @@ -277,7 +277,7 @@ module.exports = class ExportAssets { return new Promise((resolve, reject) => { if (self.assetDownloadRetry[uid + version] > self.assetDownloadRetryLimit) { - console.log('Reached max', self.assetDownloadRetry[uid + version]); + console.log('Reached the maximum limit.', self.assetDownloadRetry[uid + version]); return reject(new Error('Asset Max download retry limit exceeded! ' + uid)); } @@ -314,7 +314,7 @@ module.exports = class ExportAssets { log(self.config, error, 'error'); if (error.status === 408) { - console.log('retrying', uid); + console.log('Retrying...', uid); // retrying when timeout self.assetDownloadRetry[uid + version] ? ++self.assetDownloadRetry[uid + version] @@ -360,7 +360,7 @@ module.exports = class ExportAssets { length: assetStreamRequest.headers['content-length'], }); str.on('progress', (progressData) => { - console.log(`${asset.filename}: ${Math.round(progressData.percentage)}%`); + console.log(`${asset.filename}: ${Math.round(progressData.percentage)}% complete`); }); assetStreamRequest.pipe(str).pipe(assetFileStream); } diff --git a/packages/contentstack-export/src/export/modules/content-types.ts b/packages/contentstack-export/src/export/modules/content-types.ts index ace072ec53..ad571929d2 100644 --- a/packages/contentstack-export/src/export/modules/content-types.ts +++ b/packages/contentstack-export/src/export/modules/content-types.ts @@ -65,7 +65,7 @@ export default class ContentTypesExport extends BaseClass { try { log.debug('Starting content types export process...', this.exportConfig.context); await fsUtil.makeDirectory(this.contentTypesDirPath); - log.debug(`Created directory at path: ${this.contentTypesDirPath}`, this.exportConfig.context); + log.debug(`Created directory at: '${this.contentTypesDirPath}'.`, this.exportConfig.context); await this.getContentTypes(); await this.writeContentTypes(this.contentTypes); @@ -105,7 +105,7 @@ export default class ContentTypesExport extends BaseClass { } sanitizeAttribs(contentTypes: Record[]): Record[] { - log.debug(`Sanitizing ${contentTypes?.length} content types`, this.exportConfig.context); + log.debug(`Sanitizing ${contentTypes?.length} content types...`, this.exportConfig.context); const updatedContentTypes: Record[] = []; @@ -121,7 +121,7 @@ export default class ContentTypesExport extends BaseClass { } async writeContentTypes(contentTypes: Record[]) { - log.debug(`Writing ${contentTypes?.length} content types to disk`, this.exportConfig.context); + log.debug(`Writing ${contentTypes?.length} content types to disk...`, this.exportConfig.context); function write(contentType: Record) { return fsUtil.writeFile( diff --git a/packages/contentstack-export/src/export/modules/custom-roles.ts b/packages/contentstack-export/src/export/modules/custom-roles.ts index a88e4792c9..1d9d10529e 100644 --- a/packages/contentstack-export/src/export/modules/custom-roles.ts +++ b/packages/contentstack-export/src/export/modules/custom-roles.ts @@ -29,26 +29,26 @@ export default class ExportCustomRoles extends BaseClass { } async start(): Promise { - log.debug('Starting custom roles export process...', this.exportConfig.context); + log.debug('Starting export process for custom roles...', this.exportConfig.context); this.rolesFolderPath = pResolve( this.exportConfig.data, this.exportConfig.branchName || '', this.customRolesConfig.dirName, ); - log.debug(`Custom roles folder path: ${this.rolesFolderPath}`, this.exportConfig.context); + log.debug(`Custom roles folder path is: ${this.rolesFolderPath}`, this.exportConfig.context); await fsUtil.makeDirectory(this.rolesFolderPath); - log.debug('Created custom roles directory', this.exportConfig.context); + log.debug('Custom roles directory created.', this.exportConfig.context); this.customRolesLocalesFilepath = pResolve(this.rolesFolderPath, this.customRolesConfig.customRolesLocalesFileName); - log.debug(`Custom roles locales file path: ${this.customRolesLocalesFilepath}`, this.exportConfig.context); + log.debug(`Custom roles locales file path is: ${this.customRolesLocalesFilepath}`, this.exportConfig.context); await this.getCustomRoles(); await this.getLocales(); await this.getCustomRolesLocales(); - log.debug(`Custom roles export completed. Total custom roles: ${Object.keys(this.customRoles)?.length}`, this.exportConfig.context); + log.debug(`Custom roles export completed. Total custom roles: ${Object.keys(this.customRoles).length}`, this.exportConfig.context); } async getCustomRoles(): Promise { @@ -58,16 +58,16 @@ export default class ExportCustomRoles extends BaseClass { .role() .fetchAll({ include_rules: true, include_permissions: true }) .then((data: any) => { - log.debug(`Fetched ${data.items?.length || 0} total roles`, this.exportConfig.context); + log.debug(`Fetched ${data.items?.length || 0} roles from the stack.`, this.exportConfig.context); return data; }) .catch((err: any) => { - log.debug('Error occurred while fetching roles', this.exportConfig.context); + log.debug('An error occurred while fetching roles.', this.exportConfig.context); return handleAndLogError(err, { ...this.exportConfig.context }); }); const customRoles = roles.items.filter((role: any) => !this.existingRoles[role.name]); - log.debug(`Found ${customRoles.length} custom roles out of ${roles.items?.length || 0} total roles`, this.exportConfig.context); + log.debug(`Found ${customRoles.length} custom roles from ${roles.items?.length || 0} total roles.`, this.exportConfig.context); if (!customRoles.length) { log.info(messageHandler.parse('ROLES_NO_CUSTOM_ROLES'), this.exportConfig.context); @@ -81,7 +81,7 @@ export default class ExportCustomRoles extends BaseClass { }); const customRolesFilePath = pResolve(this.rolesFolderPath, this.customRolesConfig.fileName); - log.debug(`Writing custom roles to: ${customRolesFilePath}`, this.exportConfig.context); + log.debug(`Writing custom roles to: ${customRolesFilePath}.`, this.exportConfig.context); fsUtil.writeFile(customRolesFilePath, this.customRoles); } @@ -93,11 +93,11 @@ export default class ExportCustomRoles extends BaseClass { .query({}) .find() .then((data: any) => { - log.debug(`Fetched ${data?.items?.length || 0} locales`, this.exportConfig.context); + log.debug(`Fetched ${data?.items?.length || 0} locales.`, this.exportConfig.context); return data; }) .catch((err: any) => { - log.debug('Error occurred while fetching locales', this.exportConfig.context); + log.debug('An error occurred while fetching locales.', this.exportConfig.context); return handleAndLogError(err, { ...this.exportConfig.context }); }); @@ -106,7 +106,7 @@ export default class ExportCustomRoles extends BaseClass { this.sourceLocalesMap[locale.uid] = locale; } - log.debug(`Mapped ${Object.keys(this.sourceLocalesMap)?.length} locales`, this.exportConfig.context); + log.debug(`Mapped ${Object.keys(this.sourceLocalesMap).length} source locales.`, this.exportConfig.context); } async getCustomRolesLocales() { @@ -118,16 +118,16 @@ export default class ExportCustomRoles extends BaseClass { const rulesLocales = find(customRole.rules, (rule: any) => rule.module === 'locale'); if (rulesLocales?.locales?.length) { - log.debug(`Found ${rulesLocales.locales.length} locales for role: ${customRole?.name}`, this.exportConfig.context); + log.debug(`Found ${rulesLocales.locales.length} locales for the role: ${customRole?.name}.`, this.exportConfig.context); forEach(rulesLocales.locales, (locale: any) => { - log.debug(`Adding locale ${locale} to custom roles mapping`, this.exportConfig.context); + log.debug(`Adding locale ${locale} to the custom roles mapping.`, this.exportConfig.context); this.localesMap[locale] = 1; }); } } if (keys(this.localesMap)?.length) { - log.debug(`Processing ${keys(this.localesMap)?.length} custom role locales`, this.exportConfig.context); + log.debug(`Processing ${Object.keys(this.localesMap).length} mapped locales.`, this.exportConfig.context); for (const locale in this.localesMap) { if (this.sourceLocalesMap[locale] !== undefined) { @@ -138,10 +138,10 @@ export default class ExportCustomRoles extends BaseClass { this.localesMap[locale] = this.sourceLocalesMap[locale]; } - log.debug(`Writing custom roles locales to: ${this.customRolesLocalesFilepath}`, this.exportConfig.context); + log.debug(`Writing custom roles locales to: ${this.customRolesLocalesFilepath}.`, this.exportConfig.context); fsUtil.writeFile(this.customRolesLocalesFilepath, this.localesMap); } else { - log.debug('No custom role locales found to process', this.exportConfig.context); + log.debug('No custom role locales found to process.', this.exportConfig.context); } } } diff --git a/packages/contentstack-export/src/export/modules/entries.ts b/packages/contentstack-export/src/export/modules/entries.ts index 9bdf10784d..743b471ea1 100644 --- a/packages/contentstack-export/src/export/modules/entries.ts +++ b/packages/contentstack-export/src/export/modules/entries.ts @@ -208,18 +208,18 @@ export default class EntriesExport extends BaseClass { log.debug('Initialized FsUtility for writing entries', this.exportConfig.context); } - log.debug(`Writing ${entriesSearchResponse.items.length} entries to file`, this.exportConfig.context); + log.debug(`Writing ${entriesSearchResponse.items.length} entries to file...`, this.exportConfig.context); this.entriesFileHelper.writeIntoFile(entriesSearchResponse.items, { mapKeyVal: true }); if (this.entriesConfig.exportVersions) { - log.debug('Exporting entry versions is enabled', this.exportConfig.context); + log.debug('Exporting entry versions is enabled.', this.exportConfig.context); let versionedEntryPath = path.join( sanitizePath(this.entriesDirPath), sanitizePath(options.contentType), sanitizePath(options.locale), 'versions', ); - log.debug(`Creating versioned entries directory at: ${versionedEntryPath}`, this.exportConfig.context); + log.debug(`Creating versioned entries directory at: ${versionedEntryPath}.`, this.exportConfig.context); fsUtil.makeDirectory(versionedEntryPath); await this.fetchEntriesVersions(entriesSearchResponse.items, { locale: options.locale, @@ -255,7 +255,7 @@ export default class EntriesExport extends BaseClass { entries: any, options: { locale: string; contentType: string; versionedEntryPath: string }, ): Promise { - log.debug(`Fetching versions for ${entries.length} entries`, this.exportConfig.context); + log.debug(`Fetching versions for ${entries.length} entries...`, this.exportConfig.context); const onSuccess = ({ response, apiData: entry }: any) => { const versionFilePath = path.join(sanitizePath(options.versionedEntryPath), sanitizePath(`${entry.uid}.json`)); @@ -312,7 +312,7 @@ export default class EntriesExport extends BaseClass { return new Promise(async (resolve, reject) => { return await this.getEntryByVersion(apiParams.queryParam, entry) .then((response) => { - log.debug(`Successfully fetched versions for entry: ${entry.uid}`, this.exportConfig.context); + log.debug(`Successfully fetched versions for entry UID: ${entry.uid}`, this.exportConfig.context); apiParams.resolve({ response, apiData: entry, @@ -320,7 +320,7 @@ export default class EntriesExport extends BaseClass { resolve(true); }) .catch((error) => { - log.debug(`Failed to fetch versions for entry: ${entry.uid}`, this.exportConfig.context); + log.debug(`Failed to fetch versions for entry UID: ${entry.uid}`, this.exportConfig.context); apiParams.reject({ error, apiData: entry, @@ -343,7 +343,7 @@ export default class EntriesExport extends BaseClass { version: entry._version, }; - log.debug(`Fetching entry version ${entry._version} for uid: ${entry.uid}`, this.exportConfig.context); + log.debug(`Fetching entry version ${entry._version} for entry UID: '${entry.uid}'.`, this.exportConfig.context); const entryResponse = await this.stackAPIClient .contentType(options.contentType) diff --git a/packages/contentstack-export/src/export/modules/environments.ts b/packages/contentstack-export/src/export/modules/environments.ts index df7a0c5a47..85e9f8af3b 100644 --- a/packages/contentstack-export/src/export/modules/environments.ts +++ b/packages/contentstack-export/src/export/modules/environments.ts @@ -31,19 +31,19 @@ export default class ExportEnvironments extends BaseClass { this.exportConfig.branchName || '', this.environmentConfig.dirName, ); - log.debug(`Environments folder path: ${this.environmentsFolderPath}`, this.exportConfig.context); + log.debug(`Environments folder path is: ${this.environmentsFolderPath}`, this.exportConfig.context); await fsUtil.makeDirectory(this.environmentsFolderPath); - log.debug('Created environments directory', this.exportConfig.context); + log.debug('Environments directory created.', this.exportConfig.context); await this.getEnvironments(); - log.debug(`Retrieved ${Object.keys(this.environments).length} environments`, this.exportConfig.context); + log.debug(`Retrieved ${Object.keys(this.environments).length} environments.`, this.exportConfig.context); if (this.environments === undefined || isEmpty(this.environments)) { log.info(messageHandler.parse('ENVIRONMENT_NOT_FOUND'), this.exportConfig.context); } else { const environmentsFilePath = pResolve(this.environmentsFolderPath, this.environmentConfig.fileName); - log.debug(`Writing environments to: ${environmentsFilePath}`, this.exportConfig.context); + log.debug(`Writing environments to: ${environmentsFilePath}.`, this.exportConfig.context); fsUtil.writeFile(environmentsFilePath, this.environments); log.success( messageHandler.parse('ENVIRONMENT_EXPORT_COMPLETE', Object.keys(this.environments).length), @@ -55,9 +55,9 @@ export default class ExportEnvironments extends BaseClass { async getEnvironments(skip = 0): Promise { if (skip) { this.qs.skip = skip; - log.debug(`Fetching environments with skip: ${skip}`, this.exportConfig.context); + log.debug(`Fetching environments with skip value: ${skip}`, this.exportConfig.context); } else { - log.debug('Fetching environments with initial query', this.exportConfig.context); + log.debug('Fetching environments with initial query...', this.exportConfig.context); } log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context); @@ -68,30 +68,30 @@ export default class ExportEnvironments extends BaseClass { .find() .then(async (data: any) => { const { items, count } = data; - log.debug(`Fetched ${items?.length || 0} environments out of total ${count}`, this.exportConfig.context); + log.debug(`Fetched ${items?.length || 0} environments out of ${count} total.`, this.exportConfig.context); if (items?.length) { - log.debug(`Processing ${items.length} environments`, this.exportConfig.context); + log.debug(`Processing ${items.length} environments.`, this.exportConfig.context); this.sanitizeAttribs(items); skip += this.environmentConfig.limit || 100; if (skip >= count) { - log.debug('Completed fetching all environments', this.exportConfig.context); + log.debug('Completed fetching all environments.', this.exportConfig.context); return; } - log.debug(`Continuing to fetch environments with skip: ${skip}`, this.exportConfig.context); + log.debug(`Continuing environment fetch with skip value: ${skip}`, this.exportConfig.context); return await this.getEnvironments(skip); } else { - log.debug('No environments found to process', this.exportConfig.context); + log.debug('No environments found to process.', this.exportConfig.context); } }) .catch((error: any) => { - log.debug('Error occurred while fetching environments', this.exportConfig.context); + log.debug('An error occurred while fetching environments.', this.exportConfig.context); handleAndLogError(error, { ...this.exportConfig.context }); }); } sanitizeAttribs(environments: Record[]) { - log.debug(`Sanitizing ${environments.length} environments`, this.exportConfig.context); + log.debug(`Sanitizing ${environments.length} environments...`, this.exportConfig.context); for (let index = 0; index < environments?.length; index++) { const extUid = environments[index].uid; diff --git a/packages/contentstack-export/src/export/modules/extensions.ts b/packages/contentstack-export/src/export/modules/extensions.ts index beb50325ca..5da610ec29 100644 --- a/packages/contentstack-export/src/export/modules/extensions.ts +++ b/packages/contentstack-export/src/export/modules/extensions.ts @@ -33,19 +33,19 @@ export default class ExportExtensions extends BaseClass { this.exportConfig.branchName || '', this.extensionConfig.dirName, ); - log.debug(`Extensions folder path: ${this.extensionsFolderPath}`, this.exportConfig.context); + log.debug(`Extensions folder path is: ${this.extensionsFolderPath}`, this.exportConfig.context); await fsUtil.makeDirectory(this.extensionsFolderPath); - log.debug('Created extensions directory', this.exportConfig.context); + log.debug('Extensions directory created.', this.exportConfig.context); await this.getExtensions(); - log.debug(`Retrieved ${Object.keys(this.extensions).length} extensions`, this.exportConfig.context); + log.debug(`Retrieved ${Object.keys(this.extensions).length} extensions.`, this.exportConfig.context); if (this.extensions === undefined || isEmpty(this.extensions)) { log.info(messageHandler.parse('EXTENSION_NOT_FOUND'), this.exportConfig.context); } else { const extensionsFilePath = pResolve(this.extensionsFolderPath, this.extensionConfig.fileName); - log.debug(`Writing extensions to: ${extensionsFilePath}`, this.exportConfig.context); + log.debug(`Writing extensions to: ${extensionsFilePath}.`, this.exportConfig.context); fsUtil.writeFile(extensionsFilePath, this.extensions); log.success( messageHandler.parse('EXTENSION_EXPORT_COMPLETE', Object.keys(this.extensions).length ), @@ -57,12 +57,12 @@ export default class ExportExtensions extends BaseClass { async getExtensions(skip = 0): Promise { if (skip) { this.qs.skip = skip; - log.debug(`Fetching extensions with skip: ${skip}`, this.exportConfig.context); + log.debug(`Fetching extensions with skip value: ${skip}`, this.exportConfig.context); } else { - log.debug('Fetching extensions with initial query', this.exportConfig.context); + log.debug('Fetching extensions with initial query...', this.exportConfig.context); } - log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context); + log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context); await this.stack .extension() @@ -70,40 +70,40 @@ export default class ExportExtensions extends BaseClass { .find() .then(async (data: any) => { const { items, count } = data; - log.debug(`Fetched ${items?.length || 0} extensions out of total ${count}`, this.exportConfig.context); + log.debug(`Fetched ${items?.length || 0} extensions out of ${count}.`, this.exportConfig.context); if (items?.length) { - log.debug(`Processing ${items.length} extensions`, this.exportConfig.context); + log.debug(`Processing ${items.length} extensions...`, this.exportConfig.context); this.sanitizeAttribs(items); skip += this.extensionConfig.limit || 100; if (skip >= count) { - log.debug('Completed fetching all extensions', this.exportConfig.context); + log.debug('Completed fetching all extensions.', this.exportConfig.context); return; } - log.debug(`Continuing to fetch extensions with skip: ${skip}`, this.exportConfig.context); + log.debug(`Continuing to fetch extensions with skip: ${skip}.`, this.exportConfig.context); return await this.getExtensions(skip); } else { - log.debug('No extensions found to process', this.exportConfig.context); + log.debug('No extensions found to process.', this.exportConfig.context); } }) .catch((error: any) => { - log.debug('Error occurred while fetching extensions', this.exportConfig.context); + log.debug('An error occurred while fetching extensions.', this.exportConfig.context); handleAndLogError(error, { ...this.exportConfig.context }); }); } sanitizeAttribs(extensions: Record[]) { - log.debug(`Sanitizing ${extensions.length} extensions`, this.exportConfig.context); + log.debug(`Sanitizing ${extensions.length} extensions...`, this.exportConfig.context); for (let index = 0; index < extensions?.length; index++) { const extUid = extensions[index].uid; const extTitle = extensions[index]?.title; - log.debug(`Processing extension: ${extTitle} (${extUid})`, this.exportConfig.context); + log.debug(`Processing extension: '${extTitle}' (UID: ${extUid})...`, this.exportConfig.context); this.extensions[extUid] = omit(extensions[index], ['SYS_ACL']); log.info(messageHandler.parse('EXTENSION_EXPORT_SUCCESS', extTitle), this.exportConfig.context); } - log.debug(`Sanitization complete. Total extensions processed: ${Object.keys(this.extensions).length}`, this.exportConfig.context); + log.debug(`Sanitization complete. Total extensions processed: ${Object.keys(this.extensions).length}.`, this.exportConfig.context); } } diff --git a/packages/contentstack-export/src/export/modules/global-fields.ts b/packages/contentstack-export/src/export/modules/global-fields.ts index c7472e982d..421665cfcc 100644 --- a/packages/contentstack-export/src/export/modules/global-fields.ts +++ b/packages/contentstack-export/src/export/modules/global-fields.ts @@ -55,16 +55,16 @@ export default class GlobalFieldsExport extends BaseClass { async start() { try { - log.debug('Starting global fields export process...', this.exportConfig.context); - log.debug(`Global fields directory path: ${this.globalFieldsDirPath}`, this.exportConfig.context); + log.debug('Starting export process for global fields...', this.exportConfig.context); + log.debug(`Global fields directory path: '${this.globalFieldsDirPath}'`, this.exportConfig.context); await fsUtil.makeDirectory(this.globalFieldsDirPath); - log.debug('Created global fields directory', this.exportConfig.context); + log.debug('Created global fields directory.', this.exportConfig.context); await this.getGlobalFields(); - log.debug(`Retrieved ${this.globalFields.length} global fields`, this.exportConfig.context); + log.debug(`Retrieved ${this.globalFields.length} global fields.`, this.exportConfig.context); const globalFieldsFilePath = path.join(this.globalFieldsDirPath, this.globalFieldsConfig.fileName); - log.debug(`Writing global fields to: ${globalFieldsFilePath}`, this.exportConfig.context); + log.debug(`Writing global fields to: '${globalFieldsFilePath}'`, this.exportConfig.context); fsUtil.writeFile(globalFieldsFilePath, this.globalFields); log.success( @@ -72,7 +72,7 @@ export default class GlobalFieldsExport extends BaseClass { this.exportConfig.context, ); } catch (error) { - log.debug('Error occurred during global fields export', this.exportConfig.context); + log.debug('An error occurred during global fields export.', this.exportConfig.context); handleAndLogError(error, { ...this.exportConfig.context }); } } @@ -80,34 +80,34 @@ export default class GlobalFieldsExport extends BaseClass { async getGlobalFields(skip: number = 0): Promise { if (skip) { this.qs.skip = skip; - log.debug(`Fetching global fields with skip: ${skip}`, this.exportConfig.context); + log.debug(`Fetching global fields with skip: ${skip}.`, this.exportConfig.context); } - log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context); + log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context); let globalFieldsFetchResponse = await this.stackAPIClient.globalField({ api_version: '3.2' }).query(this.qs).find(); - log.debug(`Fetched ${globalFieldsFetchResponse.items?.length || 0} global fields out of total ${globalFieldsFetchResponse.count}`, this.exportConfig.context); + log.debug(`Fetched ${globalFieldsFetchResponse.items?.length || 0} global fields out of ${globalFieldsFetchResponse.count}.`, this.exportConfig.context); if (Array.isArray(globalFieldsFetchResponse.items) && globalFieldsFetchResponse.items.length > 0) { - log.debug(`Processing ${globalFieldsFetchResponse.items.length} global fields`, this.exportConfig.context); + log.debug(`Processing ${globalFieldsFetchResponse.items.length} global fields...`, this.exportConfig.context); this.sanitizeAttribs(globalFieldsFetchResponse.items); skip += this.globalFieldsConfig.limit || 100; if (skip >= globalFieldsFetchResponse.count) { - log.debug('Completed fetching all global fields', this.exportConfig.context); + log.debug('Completed fetching all global fields.', this.exportConfig.context); return; } - log.debug(`Continuing to fetch global fields with skip: ${skip}`, this.exportConfig.context); + log.debug(`Continuing to fetch global fields with skip: ${skip}.`, this.exportConfig.context); return await this.getGlobalFields(skip); } else { - log.debug('No global fields found to process', this.exportConfig.context); + log.debug('No global fields found to process.', this.exportConfig.context); } } sanitizeAttribs(globalFields: Record[]) { - log.debug(`Sanitizing ${globalFields.length} global fields`, this.exportConfig.context); + log.debug(`Sanitizing ${globalFields.length} global fields...`, this.exportConfig.context); globalFields.forEach((globalField: Record) => { - log.debug(`Processing global field: ${globalField.uid || 'unknown'}`, this.exportConfig.context); + log.debug(`Processing global field: '${globalField.uid || 'unknown'}'...`, this.exportConfig.context); for (let key in globalField) { if (this.globalFieldsConfig.validKeys.indexOf(key) === -1) { @@ -117,6 +117,6 @@ export default class GlobalFieldsExport extends BaseClass { this.globalFields.push(globalField); }); - log.debug(`Sanitization complete. Total global fields processed: ${this.globalFields.length}`, this.exportConfig.context); + log.debug(`Sanitization complete. Total global fields processed: ${this.globalFields.length}.`, this.exportConfig.context); } } diff --git a/packages/contentstack-export/src/export/modules/labels.ts b/packages/contentstack-export/src/export/modules/labels.ts index 194f2e124c..414f13077b 100644 --- a/packages/contentstack-export/src/export/modules/labels.ts +++ b/packages/contentstack-export/src/export/modules/labels.ts @@ -25,26 +25,26 @@ export default class ExportLabels extends BaseClass { } async start(): Promise { - log.debug('Starting labels export process...', this.exportConfig.context); + log.debug('Starting export process for labels...', this.exportConfig.context); this.labelsFolderPath = pResolve( this.exportConfig.data, this.exportConfig.branchName || '', this.labelConfig.dirName, ); - log.debug(`Labels folder path: ${this.labelsFolderPath}`, this.exportConfig.context); + log.debug(`Labels folder path: '${this.labelsFolderPath}'`, this.exportConfig.context); await fsUtil.makeDirectory(this.labelsFolderPath); - log.debug('Created labels directory', this.exportConfig.context); + log.debug('Created labels directory.', this.exportConfig.context); await this.getLabels(); - log.debug(`Retrieved ${Object.keys(this.labels).length} labels`, this.exportConfig.context); + log.debug(`Retrieved ${Object.keys(this.labels).length} labels.`, this.exportConfig.context); if (this.labels === undefined || isEmpty(this.labels)) { log.info(messageHandler.parse('LABELS_NOT_FOUND'), this.exportConfig.context); } else { const labelsFilePath = pResolve(this.labelsFolderPath, this.labelConfig.fileName); - log.debug(`Writing labels to: ${labelsFilePath}`, this.exportConfig.context); + log.debug(`Writing labels to: '${labelsFilePath}'.`, this.exportConfig.context); fsUtil.writeFile(labelsFilePath, this.labels); log.success( messageHandler.parse('LABELS_EXPORT_COMPLETE', Object.keys(this.labels).length), @@ -56,12 +56,12 @@ export default class ExportLabels extends BaseClass { async getLabels(skip = 0): Promise { if (skip) { this.qs.skip = skip; - log.debug(`Fetching labels with skip: ${skip}`, this.exportConfig.context); + log.debug(`Fetching labels with skip: ${skip}.`, this.exportConfig.context); } else { - log.debug('Fetching labels with initial query', this.exportConfig.context); + log.debug('Fetching labels with initial query...', this.exportConfig.context); } - log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context); + log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context); await this.stack .label() @@ -69,40 +69,40 @@ export default class ExportLabels extends BaseClass { .find() .then(async (data: any) => { const { items, count } = data; - log.debug(`Fetched ${items?.length || 0} labels out of total ${count}`, this.exportConfig.context); + log.debug(`Fetched ${items?.length || 0} labels out of ${count}.`, this.exportConfig.context); if (items?.length) { - log.debug(`Processing ${items.length} labels`, this.exportConfig.context); + log.debug(`Processing ${items.length} labels...`, this.exportConfig.context); this.sanitizeAttribs(items); skip += this.labelConfig.limit || 100; if (skip >= count) { - log.debug('Completed fetching all labels', this.exportConfig.context); + log.debug('Completed fetching all labels.', this.exportConfig.context); return; } - log.debug(`Continuing to fetch labels with skip: ${skip}`, this.exportConfig.context); + log.debug(`Continuing to fetch labels with skip: ${skip}.`, this.exportConfig.context); return await this.getLabels(skip); } else { - log.debug('No labels found to process', this.exportConfig.context); + log.debug('No labels found to process.', this.exportConfig.context); } }) .catch((error: any) => { - log.debug('Error occurred while fetching labels', this.exportConfig.context); + log.debug('An error occurred while fetching labels.', this.exportConfig.context); handleAndLogError(error, { ...this.exportConfig.context }); }); } sanitizeAttribs(labels: Record[]) { - log.debug(`Sanitizing ${labels.length} labels`, this.exportConfig.context); + log.debug(`Sanitizing ${labels.length} labels...`, this.exportConfig.context); for (let index = 0; index < labels?.length; index++) { const labelUid = labels[index].uid; const labelName = labels[index]?.name; - log.debug(`Processing label: ${labelName} (${labelUid})`, this.exportConfig.context); + log.debug(`Processing label: '${labelName}' (UID: ${labelUid})...`, this.exportConfig.context); this.labels[labelUid] = omit(labels[index], this.labelConfig.invalidKeys); log.info(messageHandler.parse('LABEL_EXPORT_SUCCESS', labelName), this.exportConfig.context); } - log.debug(`Sanitization complete. Total labels processed: ${Object.keys(this.labels).length}`, this.exportConfig.context); + log.debug(`Sanitization complete. Total labels processed: ${Object.keys(this.labels).length}.`, this.exportConfig.context); } } diff --git a/packages/contentstack-export/src/export/modules/locales.ts b/packages/contentstack-export/src/export/modules/locales.ts index c441285215..97f8d16fec 100644 --- a/packages/contentstack-export/src/export/modules/locales.ts +++ b/packages/contentstack-export/src/export/modules/locales.ts @@ -59,22 +59,22 @@ export default class LocaleExport extends BaseClass { async start() { try { - log.debug('Starting locales export process...', this.exportConfig.context); - log.debug(`Locales path: ${this.localesPath}`, this.exportConfig.context); + log.debug('Starting export process for locales...', this.exportConfig.context); + log.debug(`Locales path: '${this.localesPath}'`, this.exportConfig.context); await fsUtil.makeDirectory(this.localesPath); - log.debug('Created locales directory', this.exportConfig.context); + log.debug('Created locales directory.', this.exportConfig.context); await this.getLocales(); - log.debug(`Retrieved ${Object.keys(this.locales).length} locales and ${Object.keys(this.masterLocale).length} master locales`, this.exportConfig.context); + log.debug(`Retrieved ${Object.keys(this.locales).length} locales and ${Object.keys(this.masterLocale).length} master locales.`, this.exportConfig.context); const localesFilePath = path.join(this.localesPath, this.localeConfig.fileName); const masterLocaleFilePath = path.join(this.localesPath, this.masterLocaleConfig.fileName); - log.debug(`Writing locales to: ${localesFilePath}`, this.exportConfig.context); + log.debug(`Writing locales to: '${localesFilePath}'`, this.exportConfig.context); fsUtil.writeFile(localesFilePath, this.locales); - log.debug(`Writing master locale to: ${masterLocaleFilePath}`, this.exportConfig.context); + log.debug(`Writing master locale to: '${masterLocaleFilePath}'`, this.exportConfig.context); fsUtil.writeFile(masterLocaleFilePath, this.masterLocale); log.success( @@ -94,32 +94,32 @@ export default class LocaleExport extends BaseClass { async getLocales(skip: number = 0): Promise { if (skip) { this.qs.skip = skip; - log.debug(`Fetching locales with skip: ${skip}`, this.exportConfig.context); + log.debug(`Fetching locales with skip: ${skip}.`, this.exportConfig.context); } - log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context); + log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context); let localesFetchResponse = await this.stackAPIClient.locale().query(this.qs).find(); - log.debug(`Fetched ${localesFetchResponse.items?.length || 0} locales out of total ${localesFetchResponse.count}`, this.exportConfig.context); + log.debug(`Fetched ${localesFetchResponse.items?.length || 0} locales out of ${localesFetchResponse.count}.`, this.exportConfig.context); if (Array.isArray(localesFetchResponse.items) && localesFetchResponse.items.length > 0) { - log.debug(`Processing ${localesFetchResponse.items.length} locales`, this.exportConfig.context); + log.debug(`Processing ${localesFetchResponse.items.length} locales...`, this.exportConfig.context); this.sanitizeAttribs(localesFetchResponse.items); skip += this.localeConfig.limit || 100; if (skip > localesFetchResponse.count) { - log.debug('Completed fetching all locales', this.exportConfig.context); + log.debug('Completed fetching all locales.', this.exportConfig.context); return; } - log.debug(`Continuing to fetch locales with skip: ${skip}`, this.exportConfig.context); + log.debug(`Continuing to fetch locales with skip: ${skip}.`, this.exportConfig.context); return await this.getLocales(skip); } else { - log.debug('No locales found to process', this.exportConfig.context); + log.debug('No locales found to process.', this.exportConfig.context); } } sanitizeAttribs(locales: Record[]) { - log.debug(`Sanitizing ${locales.length} locales`, this.exportConfig.context); + log.debug(`Sanitizing ${locales.length} locales...`, this.exportConfig.context); locales.forEach((locale: Record) => { for (let key in locale) { @@ -129,14 +129,14 @@ export default class LocaleExport extends BaseClass { } if (locale?.code === this.exportConfig?.master_locale?.code) { - log.debug(`Adding locale ${locale.uid} to master locale`, this.exportConfig.context); + log.debug(`Adding locale UID '${locale.uid}' to master locale.`, this.exportConfig.context); this.masterLocale[locale.uid] = locale; } else { - log.debug(`Adding locale ${locale.uid} to regular locales`, this.exportConfig.context); + log.debug(`Adding locale UID '${locale.uid}' to regular locales.`, this.exportConfig.context); this.locales[locale.uid] = locale; } }); - log.debug(`Sanitization complete. Master locales: ${Object.keys(this.masterLocale).length}, Regular locales: ${Object.keys(this.locales).length}`, this.exportConfig.context); + log.debug(`Sanitization complete. Master locales: ${Object.keys(this.masterLocale).length}, Regular locales: ${Object.keys(this.locales).length}.`, this.exportConfig.context); } } diff --git a/packages/contentstack-export/src/export/modules/marketplace-apps.ts b/packages/contentstack-export/src/export/modules/marketplace-apps.ts index 1158fa29b6..094c05a227 100644 --- a/packages/contentstack-export/src/export/modules/marketplace-apps.ts +++ b/packages/contentstack-export/src/export/modules/marketplace-apps.ts @@ -38,7 +38,7 @@ export default class ExportMarketplaceApps { } async start(): Promise { - log.debug('Starting marketplace apps export process...', this.exportConfig.context); + log.debug('Starting export process for Marketplace Apps...', this.exportConfig.context); if (!isAuthenticated()) { cliux.print( @@ -53,25 +53,25 @@ export default class ExportMarketplaceApps { this.exportConfig.branchName || '', this.marketplaceAppConfig.dirName, ); - log.debug(`Marketplace apps folder path: ${this.marketplaceAppPath}`, this.exportConfig.context); + log.debug(`Marketplace apps folder path: '${this.marketplaceAppPath}'`, this.exportConfig.context); await fsUtil.makeDirectory(this.marketplaceAppPath); - log.debug('Created marketplace apps directory', this.exportConfig.context); + log.debug('Created Marketplace Apps directory.', this.exportConfig.context); this.developerHubBaseUrl = this.exportConfig.developerHubBaseUrl || (await getDeveloperHubUrl(this.exportConfig)); - log.debug(`Developer hub base URL: ${this.developerHubBaseUrl}`, this.exportConfig.context); + log.debug(`Developer Hub base URL: '${this.developerHubBaseUrl}'`, this.exportConfig.context); this.exportConfig.org_uid = await getOrgUid(this.exportConfig); this.query = { target_uids: this.exportConfig.source_stack }; - log.debug(`Organization UID: ${this.exportConfig.org_uid}`, this.exportConfig.context); + log.debug(`Organization UID: '${this.exportConfig.org_uid}'.`, this.exportConfig.context); // NOTE init marketplace app sdk const host = this.developerHubBaseUrl.split('://').pop(); - log.debug(`Initializing marketplace SDK with host: ${host}`, this.exportConfig.context); + log.debug(`Initializing Marketplace SDK with host: '${host}'...`, this.exportConfig.context); this.appSdk = await marketplaceSDKClient({ host }); await this.exportApps(); - log.debug('Marketplace apps export process completed', this.exportConfig.context); + log.debug('Marketplace apps export process completed.', this.exportConfig.context); } /** @@ -79,7 +79,7 @@ export default class ExportMarketplaceApps { * library if it is available. */ async exportApps(): Promise { - log.debug('Starting apps export process...', this.exportConfig.context); + log.debug('Starting export process for apps...', this.exportConfig.context); // currently support only app_uids or installation_uids const externalQuery = this.exportConfig.query?.modules['marketplace-apps']; if (externalQuery) { @@ -92,25 +92,25 @@ export default class ExportMarketplaceApps { } await this.getStackSpecificApps(); - log.debug(`Retrieved ${this.installedApps.length} stack-specific apps`, this.exportConfig.context); + log.debug(`Retrieved ${this.installedApps.length} stack-specific apps.`, this.exportConfig.context); await this.getAppManifestAndAppConfig(); - log.debug('Completed app manifest and configuration processing', this.exportConfig.context); + log.debug('Completed app manifest and configuration processing.', this.exportConfig.context); if (!this.nodeCrypto && find(this.installedApps, (app) => !isEmpty(app.configuration))) { - log.debug('Initializing NodeCrypto for app configuration encryption', this.exportConfig.context); + log.debug('Initializing NodeCrypto for app configuration encryption...', this.exportConfig.context); this.nodeCrypto = await createNodeCryptoInstance(this.exportConfig); } this.installedApps = map(this.installedApps, (app) => { if (has(app, 'configuration')) { - log.debug(`Encrypting configuration for app: ${app.manifest?.name || app.uid}`, this.exportConfig.context); + log.debug(`Encrypting configuration for app: '${app.manifest?.name || app.uid}'...`, this.exportConfig.context); app['configuration'] = this.nodeCrypto.encrypt(app.configuration); } return app; }); - log.debug(`Processed ${this.installedApps.length} total marketplace apps`, this.exportConfig.context); + log.debug(`Processed ${this.installedApps.length} Marketplace Apps.`, this.exportConfig.context); } /** @@ -121,22 +121,22 @@ export default class ExportMarketplaceApps { if (isEmpty(this.installedApps)) { log.info(messageHandler.parse('MARKETPLACE_APPS_NOT_FOUND'), this.exportConfig.context); } else { - log.debug(`Processing ${this.installedApps.length} installed apps`, this.exportConfig.context); + log.debug(`Processing ${this.installedApps.length} installed apps...`, this.exportConfig.context); for (const [index, app] of entries(this.installedApps)) { if (app.manifest.visibility === 'private') { - log.debug(`Processing private app manifest: ${app.manifest.name}`, this.exportConfig.context); + log.debug(`Processing private app manifest: '${app.manifest.name}'...`, this.exportConfig.context); await this.getPrivateAppsManifest(+index, app); } } for (const [index, app] of entries(this.installedApps)) { - log.debug(`Processing app configurations: ${app.manifest?.name || app.uid}`, this.exportConfig.context); + log.debug(`Processing app configurations for: '${app.manifest?.name || app.uid}'...`, this.exportConfig.context); await this.getAppConfigurations(+index, app); } const marketplaceAppsFilePath = pResolve(this.marketplaceAppPath, this.marketplaceAppConfig.fileName); - log.debug(`Writing marketplace apps to: ${marketplaceAppsFilePath}`, this.exportConfig.context); + log.debug(`Writing Marketplace Apps to: '${marketplaceAppsFilePath}'`, this.exportConfig.context); fsUtil.writeFile(marketplaceAppsFilePath, this.installedApps); log.success( @@ -156,14 +156,14 @@ export default class ExportMarketplaceApps { * app's manifest. */ async getPrivateAppsManifest(index: number, appInstallation: Installation) { - log.debug(`Fetching private app manifest for: ${appInstallation.manifest.name} (${appInstallation.manifest.uid})`, this.exportConfig.context); + log.debug(`Fetching private app manifest for: '${appInstallation.manifest.name}' (UID: ${appInstallation.manifest.uid})...`, this.exportConfig.context); const manifest = await this.appSdk .marketplace(this.exportConfig.org_uid) .app(appInstallation.manifest.uid) .fetch({ include_oauth: true }) .catch((error) => { - log.debug(`Failed to fetch private app manifest for: ${appInstallation.manifest.name}`, this.exportConfig.context); + log.debug(`Failed to fetch private app manifest for: '${appInstallation.manifest.name}'.`, this.exportConfig.context); handleAndLogError( error, { @@ -174,7 +174,7 @@ export default class ExportMarketplaceApps { }); if (manifest) { - log.debug(`Successfully fetched private app manifest for: ${appInstallation.manifest.name}`, this.exportConfig.context); + log.debug(`Successfully fetched private app manifest for: '${appInstallation.manifest.name}'.`, this.exportConfig.context); this.installedApps[index].manifest = manifest as unknown as Manifest; } } @@ -193,7 +193,7 @@ export default class ExportMarketplaceApps { const appName = appInstallation?.manifest?.name; const appUid = appInstallation?.manifest?.uid; const app = appName || appUid; - log.debug(`Fetching app configuration for: ${app}`, this.exportConfig.context); + log.debug(`Fetching app configuration for: '${app}'...`, this.exportConfig.context); log.info(messageHandler.parse('MARKETPLACE_APP_CONFIG_EXPORT', app), this.exportConfig.context); await this.appSdk @@ -204,27 +204,27 @@ export default class ExportMarketplaceApps { const { data, error } = result; if (has(data, 'server_configuration') || has(data, 'configuration')) { - log.debug(`Found configuration data for app: ${app}`, this.exportConfig.context); + log.debug(`Found configuration data for app: '${app}'.`, this.exportConfig.context); if (!this.nodeCrypto && (has(data, 'server_configuration') || has(data, 'configuration'))) { - log.debug(`Initializing NodeCrypto for app: ${app}`, this.exportConfig.context); + log.debug(`Initializing NodeCrypto for app: '${app}'...`, this.exportConfig.context); this.nodeCrypto = await createNodeCryptoInstance(this.exportConfig); } if (!isEmpty(data?.configuration)) { - log.debug(`Encrypting configuration for app: ${app}`, this.exportConfig.context); + log.debug(`Encrypting configuration for app: '${app}'...`, this.exportConfig.context); this.installedApps[index]['configuration'] = this.nodeCrypto.encrypt(data.configuration); } if (!isEmpty(data?.server_configuration)) { - log.debug(`Encrypting server configuration for app: ${app}`, this.exportConfig.context); + log.debug(`Encrypting server configuration for app: '${app}'...`, this.exportConfig.context); this.installedApps[index]['server_configuration'] = this.nodeCrypto.encrypt(data.server_configuration); log.success(messageHandler.parse('MARKETPLACE_APP_CONFIG_SUCCESS', app), this.exportConfig.context); } else { log.success(messageHandler.parse('MARKETPLACE_APP_EXPORT_SUCCESS', app), this.exportConfig.context); } } else if (error) { - log.debug(`Error in app configuration data for: ${app}`, this.exportConfig.context); + log.debug(`Error in app configuration data for: '${app}'.`, this.exportConfig.context); handleAndLogError( error, { @@ -235,7 +235,7 @@ export default class ExportMarketplaceApps { } }) .catch((error: any) => { - log.debug(`Failed to fetch app configuration for: ${app}`, this.exportConfig.context); + log.debug(`Failed to fetch app configuration for: '${app}'.`, this.exportConfig.context); handleAndLogError( error, { @@ -260,7 +260,7 @@ export default class ExportMarketplaceApps { .installation() .fetchAll({ ...this.query, skip }) .catch((error) => { - log.debug('Error occurred while fetching stack-specific apps', this.exportConfig.context); + log.debug('An error occurred while fetching stack-specific apps.', this.exportConfig.context); handleAndLogError(error, { ...this.exportConfig.context, }); @@ -268,7 +268,7 @@ export default class ExportMarketplaceApps { if (collection) { const { items: apps, count } = collection; - log.debug(`Fetched ${apps?.length || 0} apps out of total ${count}`, this.exportConfig.context); + log.debug(`Fetched ${apps?.length || 0} apps out of ${count}.`, this.exportConfig.context); // NOTE Remove all the chain functions const installation = map(apps, (app) => @@ -278,14 +278,14 @@ export default class ExportMarketplaceApps { }), ) as unknown as Installation[]; - log.debug(`Processed ${installation.length} app installations`, this.exportConfig.context); + log.debug(`Processed ${installation.length} app installations.`, this.exportConfig.context); this.installedApps = this.installedApps.concat(installation); if (count - (skip + 50) > 0) { - log.debug(`Continuing to fetch apps with skip: ${skip + 50}`, this.exportConfig.context); + log.debug(`Continuing to fetch apps with skip: ${skip + 50}.`, this.exportConfig.context); await this.getStackSpecificApps(skip + 50); } else { - log.debug('Completed fetching all stack-specific apps', this.exportConfig.context); + log.debug('Completed fetching all stack-specific apps.', this.exportConfig.context); } } } diff --git a/packages/contentstack-export/src/export/modules/personalize.ts b/packages/contentstack-export/src/export/modules/personalize.ts index c06ea02564..51656635cb 100644 --- a/packages/contentstack-export/src/export/modules/personalize.ts +++ b/packages/contentstack-export/src/export/modules/personalize.ts @@ -21,27 +21,27 @@ export default class ExportPersonalize { async start(): Promise { try { - log.debug('Starting personalize export process...', this.exportConfig.context); + log.debug('Starting export process for Personalize...', this.exportConfig.context); if (!this.personalizeConfig.baseURL[this.exportConfig.region.name]) { - log.debug(`Personalize URL not set for region: ${this.exportConfig.region.name}`, this.exportConfig.context); + log.debug(`Personalize URL not set for region: '${this.exportConfig.region.name}'.`, this.exportConfig.context); log.info(messageHandler.parse('PERSONALIZE_URL_NOT_SET'), this.exportConfig.context); this.exportConfig.personalizationEnabled = false; return; } if (this.exportConfig.management_token) { - log.debug('Management token detected, skipping personalize export', this.exportConfig.context); + log.debug('Management token detected, skipping personalize export.', this.exportConfig.context); log.info(messageHandler.parse('PERSONALIZE_SKIPPING_WITH_MANAGEMENT_TOKEN'), this.exportConfig.context); this.exportConfig.personalizationEnabled = false; return; } - log.debug('Starting projects export for personalization...', this.exportConfig.context); + log.debug('Starting export process for personalization projects...', this.exportConfig.context); await new ExportProjects(this.exportConfig).start(); if (this.exportConfig.personalizationEnabled) { - log.debug('Personalization is enabled, processing personalize modules...', this.exportConfig.context); + log.debug('Personalization is enabled, processing personalize modules... ' + this.exportConfig.modules.personalize.exportOrder.join(', '), this.exportConfig.context); const moduleMapper = { events: new ExportEvents(this.exportConfig), @@ -53,17 +53,17 @@ export default class ExportPersonalize { const order: (keyof typeof moduleMapper)[] = this.exportConfig.modules.personalize .exportOrder as (keyof typeof moduleMapper)[]; - log.debug(`Personalize export order: ${order.join(', ')}`, this.exportConfig.context); + log.debug(`Personalize export order: ${order.join(', ')}.`, this.exportConfig.context); for (const module of order) { - log.debug(`Processing personalize module: ${module}`, this.exportConfig.context); + log.debug(`Processing personalization module: '${module}'...`, this.exportConfig.context); if (moduleMapper[module]) { - log.debug(`Starting export for module: ${module}`, this.exportConfig.context); + log.debug(`Starting export for module: '${module}'...`, this.exportConfig.context); await moduleMapper[module].start(); - log.debug(`Completed export for module: ${module}`, this.exportConfig.context); + log.debug(`Completed export for module: '${module}'.`, this.exportConfig.context); } else { - log.debug(`Module not implemented: ${module}`, this.exportConfig.context); + log.debug(`Module not implemented: '${module}'.`, this.exportConfig.context); log.info( messageHandler.parse('PERSONALIZE_MODULE_NOT_IMPLEMENTED', module), this.exportConfig.context, @@ -71,16 +71,16 @@ export default class ExportPersonalize { } } - log.debug('Completed all personalize module exports', this.exportConfig.context); + log.debug('Completed all personalization module exports.', this.exportConfig.context); } else { - log.debug('Personalization is disabled, skipping personalize module exports', this.exportConfig.context); + log.debug('Personalization is disabled, skipping personalize module exports.', this.exportConfig.context); } } catch (error) { if (error === 'Forbidden') { - log.debug('Personalize access forbidden, personalization not enabled', this.exportConfig.context); + log.debug('Personalization access forbidden.', this.exportConfig.context); log.info(messageHandler.parse('PERSONALIZE_NOT_ENABLED'), this.exportConfig.context); } else { - log.debug('Error occurred during personalize export', this.exportConfig.context); + log.debug('An error occurred during personalization export.', this.exportConfig.context); handleAndLogError(error, { ...this.exportConfig.context }); } this.exportConfig.personalizationEnabled = false; diff --git a/packages/contentstack-export/src/export/modules/stack.ts b/packages/contentstack-export/src/export/modules/stack.ts index f8a843c920..cb1d75fb0d 100644 --- a/packages/contentstack-export/src/export/modules/stack.ts +++ b/packages/contentstack-export/src/export/modules/stack.ts @@ -30,18 +30,18 @@ export default class ExportStack extends BaseClass { log.debug('Starting stack export process...', this.exportConfig.context); if (isAuthenticated()) { - log.debug('User is authenticated, fetching stack data...', this.exportConfig.context); + log.debug('User authenticated.', this.exportConfig.context); const stackData = await this.getStack(); if (stackData?.org_uid) { - log.debug(`Found organization UID: ${stackData.org_uid}`, this.exportConfig.context); + log.debug(`Found organization UID: '${stackData.org_uid}'.`, this.exportConfig.context); this.exportConfig.org_uid = stackData.org_uid; this.exportConfig.sourceStackName = stackData.name; - log.debug(`Set source stack name: ${stackData.name}`, this.exportConfig.context); + log.debug(`Set source stack name: '${stackData.name}'.`, this.exportConfig.context); } else { - log.debug('No stack data found or missing org_uid', this.exportConfig.context); + log.debug('No stack data found or missing organization UID.', this.exportConfig.context); } } else { - log.debug('User is not authenticated, skipping stack data fetch', this.exportConfig.context); + log.debug('User is not authenticated.', this.exportConfig.context); } if (this.exportConfig.management_token) { @@ -60,28 +60,28 @@ export default class ExportStack extends BaseClass { //fetch master locale details return this.getLocales(); } else if (this.exportConfig.preserveStackVersion) { - log.debug('Preserve stack version is true, exporting stack...', this.exportConfig.context); + log.debug('Preserve stack version is set to true.', this.exportConfig.context); return this.exportStack(); } else { - log.debug('Master locale already set, skipping locale fetch', this.exportConfig.context); + log.debug('Master locale is already set.', this.exportConfig.context); } } async getStack(): Promise { - log.debug(`Fetching stack data for stack: ${this.exportConfig.source_stack}`, this.exportConfig.context); + log.debug(`Fetching stack data for: '${this.exportConfig.source_stack}'...`, this.exportConfig.context); const tempAPIClient = await managementSDKClient({ host: this.exportConfig.host }); - log.debug(`Created management SDK client with host: ${this.exportConfig.host}`, this.exportConfig.context); + log.debug(`Created Management SDK client with host: '${this.exportConfig.host}'.`, this.exportConfig.context); return await tempAPIClient .stack({ api_key: this.exportConfig.source_stack }) .fetch() .then((data: any) => { - log.debug(`Successfully fetched stack data for: ${this.exportConfig.source_stack}`, this.exportConfig.context); + log.debug(`Successfully fetched stack data for: '${this.exportConfig.source_stack}'.`, this.exportConfig.context); return data; }) .catch((error: any) => { - log.debug(`Failed to fetch stack data for: ${this.exportConfig.source_stack}`, this.exportConfig.context); + log.debug(`Failed to fetch stack data for: '${this.exportConfig.source_stack}'.`, this.exportConfig.context); return {}; }); } @@ -89,12 +89,12 @@ export default class ExportStack extends BaseClass { async getLocales(skip: number = 0) { if (skip) { this.qs.skip = skip; - log.debug(`Fetching locales with skip: ${skip}`, this.exportConfig.context); + log.debug(`Fetching locales with skip: ${skip}.`, this.exportConfig.context); } else { - log.debug('Fetching locales with initial query', this.exportConfig.context); + log.debug('Fetching locales with initial query...', this.exportConfig.context); } - log.debug(`Query parameters: ${JSON.stringify(this.qs)}`, this.exportConfig.context); + log.debug(`Query parameters: ${JSON.stringify(this.qs)}.`, this.exportConfig.context); return await this.stack .locale() @@ -102,26 +102,26 @@ export default class ExportStack extends BaseClass { .find() .then(async (data: any) => { const { items, count } = data; - log.debug(`Fetched ${items?.length || 0} locales out of total ${count}`, this.exportConfig.context); + log.debug(`Fetched ${items?.length || 0} locales out of ${count}.`, this.exportConfig.context); if (items?.length) { - log.debug(`Processing ${items.length} locales to find master locale`, this.exportConfig.context); + log.debug(`Processing ${items.length} locales to find the master locale...`, this.exportConfig.context); skip += this.stackConfig.limit || 100; const masterLocalObj = find(items, (locale: any) => { if (locale.fallback_locale === null) { - log.debug(`Found master locale: ${locale.name} (${locale.code})`, this.exportConfig.context); + log.debug(`Found master locale: '${locale.name}' (code: ${locale.code}).`, this.exportConfig.context); return locale; } }); if (masterLocalObj) { - log.debug(`Returning master locale: ${masterLocalObj.name}`, this.exportConfig.context); + log.debug(`Returning master locale: '${masterLocalObj.name}'.`, this.exportConfig.context); return masterLocalObj; } else if (skip >= count) { log.error( `Master locale not found in the stack ${this.exportConfig.source_stack}. Please ensure that the stack has a master locale.`, this.exportConfig.context, ); - log.debug('Completed searching all locales without finding master locale', this.exportConfig.context); + log.debug('Completed search. Master locale not found.', this.exportConfig.context); return; } else { log.debug( @@ -131,7 +131,7 @@ export default class ExportStack extends BaseClass { return await this.getLocales(skip); } } else { - log.debug('No locales found to process', this.exportConfig.context); + log.debug('No locales found to process.', this.exportConfig.context); } }) .catch((error: any) => { @@ -149,32 +149,32 @@ export default class ExportStack extends BaseClass { } async exportStack(): Promise { - log.debug(`Starting stack export for: ${this.exportConfig.source_stack}`, this.exportConfig.context); + log.debug(`Starting stack export for: '${this.exportConfig.source_stack}'...`, this.exportConfig.context); await fsUtil.makeDirectory(this.stackFolderPath); - log.debug(`Created stack directory at: ${this.stackFolderPath}`, this.exportConfig.context); + log.debug(`Created stack directory at: '${this.stackFolderPath}'`, this.exportConfig.context); return this.stack .fetch() .then((resp: any) => { const stackFilePath = pResolve(this.stackFolderPath, this.stackConfig.fileName); - log.debug(`Writing stack data to: ${stackFilePath}`, this.exportConfig.context); + log.debug(`Writing stack data to: '${stackFilePath}'`, this.exportConfig.context); fsUtil.writeFile(stackFilePath, resp); log.success( `Stack details exported successfully for stack ${this.exportConfig.source_stack}`, this.exportConfig.context, ); - log.debug('Stack export completed successfully', this.exportConfig.context); + log.debug('Stack export completed successfully.', this.exportConfig.context); return resp; }) .catch((error: any) => { - log.debug(`Error occurred while exporting stack: ${this.exportConfig.source_stack}`, this.exportConfig.context); + log.debug(`An error occurred while exporting stack: '${this.exportConfig.source_stack}'.`, this.exportConfig.context); handleAndLogError(error, { ...this.exportConfig.context }); }); } async exportStackSettings(): Promise { - log.info('Exporting stack settings', this.exportConfig.context); + log.info('Exporting stack settings...', this.exportConfig.context); await fsUtil.makeDirectory(this.stackFolderPath); return this.stack .settings() diff --git a/packages/contentstack-export/src/export/modules/taxonomies.ts b/packages/contentstack-export/src/export/modules/taxonomies.ts index b7369743db..69acea863f 100644 --- a/packages/contentstack-export/src/export/modules/taxonomies.ts +++ b/packages/contentstack-export/src/export/modules/taxonomies.ts @@ -44,18 +44,18 @@ export default class ExportTaxonomies extends BaseClass { } async start(): Promise { - log.debug('Starting taxonomies export process...', this.exportConfig.context); - + log.debug('Starting export process for taxonomies...', this.exportConfig.context); + //create taxonomies folder this.taxonomiesFolderPath = pResolve( this.exportConfig.data, this.exportConfig.branchName || '', this.taxonomiesConfig.dirName, ); - log.debug(`Taxonomies folder path: ${this.taxonomiesFolderPath}`, this.exportConfig.context); - + log.debug(`Taxonomies folder path: '${this.taxonomiesFolderPath}'`, this.exportConfig.context); + await fsUtil.makeDirectory(this.taxonomiesFolderPath); - log.debug('Created taxonomies directory', this.exportConfig.context); + log.debug('Created taxonomies directory.', this.exportConfig.context); const localesToExport = this.getLocalesToExport(); log.debug( diff --git a/packages/contentstack-export/src/utils/basic-login.ts b/packages/contentstack-export/src/utils/basic-login.ts index 60c730f445..650c12d40c 100644 --- a/packages/contentstack-export/src/utils/basic-login.ts +++ b/packages/contentstack-export/src/utils/basic-login.ts @@ -25,7 +25,7 @@ const login = async (config: ExternalConfig): Promise => { log.success(`Contentstack account authenticated successfully!`, config.context); return config; } else { - log.error(`Failed to login, Invalid credentials`, config.context); + log.error(`Failed to log in!`, config.context); process.exit(1); } } else if (!config.email && !config.password && config.source_stack && config.access_token) { diff --git a/packages/contentstack-export/src/utils/export-config-handler.ts b/packages/contentstack-export/src/utils/export-config-handler.ts index eb647a0028..c67b6c12bb 100644 --- a/packages/contentstack-export/src/utils/export-config-handler.ts +++ b/packages/contentstack-export/src/utils/export-config-handler.ts @@ -18,7 +18,7 @@ const setupConfig = async (exportCmdFlags: any): Promise => { // setup the config if (exportCmdFlags['config']) { - log.debug('Loading external configuration file', { configFile: exportCmdFlags['config'] }); + log.debug('Loading external configuration file...', { configFile: exportCmdFlags['config'] }); const externalConfig = await readFile(exportCmdFlags['config']); config = merge.recursive(config, externalConfig); } @@ -28,7 +28,7 @@ const setupConfig = async (exportCmdFlags: any): Promise => { const pattern = /[*$%#<>{}!&?]/g; if (pattern.test(config.exportDir)) { - cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, { + cliux.print(`\nPlease enter a directory path without any special characters: (*,&,{,},[,],$,%,<,>,?,!)`, { color: 'yellow', }); config.exportDir = sanitizePath(await askExportDir()); @@ -48,7 +48,7 @@ const setupConfig = async (exportCmdFlags: any): Promise => { config.apiKey = apiKey; authenticationMethod = 'Management Token'; if (!config.management_token) { - log.debug('Management token not found for alias', { alias: managementTokenAlias }); + log.debug('Management token not found for alias!', { alias: managementTokenAlias }); throw new Error(`No management token found on given alias ${managementTokenAlias}`); } @@ -82,7 +82,7 @@ const setupConfig = async (exportCmdFlags: any): Promise => { config.apiKey = exportCmdFlags['stack-uid'] || exportCmdFlags['stack-api-key'] || config.source_stack || (await askAPIKey()); if (typeof config.apiKey !== 'string') { - log.debug('Invalid API key received', { apiKey: config.apiKey }); + log.debug('Invalid API key received!', { apiKey: config.apiKey }); throw new Error('Invalid API key received'); } } @@ -135,7 +135,7 @@ const setupConfig = async (exportCmdFlags: any): Promise => { // Add authentication details to config for context tracking config.authenticationMethod = authenticationMethod; - log.debug('Export configuration setup completed', { ...config }); + log.debug('Export configuration setup completed.', { ...config }); return config; }; diff --git a/packages/contentstack-export/src/utils/file-helper.ts b/packages/contentstack-export/src/utils/file-helper.ts index 5afc464418..b96ee98c1e 100644 --- a/packages/contentstack-export/src/utils/file-helper.ts +++ b/packages/contentstack-export/src/utils/file-helper.ts @@ -47,7 +47,7 @@ export const readLargeFile = function (filePath: string, options: { type?: strin resolve(data); }); parseStream.on('error', (error: Error) => { - console.log('error', error); + console.log('Error', error); reject(error); }); readStream.pipe(parseStream); diff --git a/packages/contentstack-import-setup/src/utils/import-config-handler.ts b/packages/contentstack-import-setup/src/utils/import-config-handler.ts index 9949274beb..9cc6fca36d 100644 --- a/packages/contentstack-import-setup/src/utils/import-config-handler.ts +++ b/packages/contentstack-import-setup/src/utils/import-config-handler.ts @@ -23,7 +23,7 @@ const setupConfig = async (importCmdFlags: any): Promise => { config.contentDir = sanitizePath(importCmdFlags['data'] || importCmdFlags['data-dir'] || config.data || (await askContentDir())); const pattern = /[*$%#<>{}!&?]/g; if (pattern.test(config.contentDir)) { - cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, { + cliux.print(`\nPlease enter a directory path without special characters: (*,&,{,},[,],$,%,<,>,?,!)`, { color: 'yellow', }); config.contentDir = sanitizePath(await askContentDir()); diff --git a/packages/contentstack-import/src/commands/cm/stacks/import.ts b/packages/contentstack-import/src/commands/cm/stacks/import.ts index 00550f9809..f5ff636d08 100644 --- a/packages/contentstack-import/src/commands/cm/stacks/import.ts +++ b/packages/contentstack-import/src/commands/cm/stacks/import.ts @@ -157,7 +157,7 @@ export default class ImportCommand extends Command { // Prepare the context object const context = this.createImportContext(importConfig.apiKey, importConfig.authenticationMethod); importConfig.context = { ...context }; - //log.info(`Using Cli Version: ${this.context?.cliVersion}`, importConfig.context); + log.info(`Using CLI version: ${this.context?.cliVersion}`, importConfig.context); // Note setting host to create cma client importConfig.host = this.cmaHost; @@ -178,13 +178,13 @@ export default class ImportCommand extends Command { log.success(successMessage, importConfig.context); } - log.success(`The log has been stored at '${getLogPath()}'`, importConfig.context); - log.info(`The backup content has been stored at '${backupDir}'`, importConfig.context); + log.success(`The log has been stored at: ${getLogPath()}`, importConfig.context); + log.info(`The backup content has been stored at: ${backupDir}`, importConfig.context); } catch (error) { handleAndLogError(error); log.info(`The log has been stored at '${getLogPath()}'`); if (importConfig?.backupDir) { - log.info(`The backup content has been stored at '${importConfig?.backupDir}'`); + log.info(`The backup content has been stored at: ${importConfig?.backupDir}`); } else { log.info('No backup directory was created due to early termination'); } diff --git a/packages/contentstack-import/src/import/modules-js/entries.js b/packages/contentstack-import/src/import/modules-js/entries.js index 9583d447e7..813e7b99be 100755 --- a/packages/contentstack-import/src/import/modules-js/entries.js +++ b/packages/contentstack-import/src/import/modules-js/entries.js @@ -1155,7 +1155,7 @@ module.exports = class ImportEntries { addlogs(this.config, `Entries published successfully in '${ctUid}' content type`, 'info'); }) .catch((error) => { - console.log(error); + console.log('Error', error); addlogs( this.config, `failed to publish entry in content type '${ctUid}' ${formatError(error)}`, diff --git a/packages/contentstack-import/src/import/modules-js/marketplace-apps.js b/packages/contentstack-import/src/import/modules-js/marketplace-apps.js index e2cb4d60fa..eae45b3e77 100644 --- a/packages/contentstack-import/src/import/modules-js/marketplace-apps.js +++ b/packages/contentstack-import/src/import/modules-js/marketplace-apps.js @@ -93,7 +93,7 @@ module.exports = class ImportMarketplaceApps { .stack({ api_key: this.config.target_stack }) .fetch() .catch((error) => { - console.log(error); + console.log('Error', error); }); if (tempStackData?.org_uid) { @@ -493,7 +493,7 @@ module.exports = class ImportMarketplaceApps { } async confirmToCloseProcess(installation) { - cliux.print(`\nWARNING!!! ${formatError(installation.message)}\n`, { color: 'yellow' }); + cliux.print(`\nWARNING: ${formatError(installation.message)}\n`, { color: 'yellow' }); if (!this.config.forceStopMarketplaceAppsPrompt) { if ( diff --git a/packages/contentstack-import/src/import/modules/assets.ts b/packages/contentstack-import/src/import/modules/assets.ts index ffddbbb626..e78f97929c 100644 --- a/packages/contentstack-import/src/import/modules/assets.ts +++ b/packages/contentstack-import/src/import/modules/assets.ts @@ -55,27 +55,27 @@ export default class ImportAssets extends BaseClass { async start(): Promise { try { // NOTE Step 1: Import folders and create uid mapping file - log.debug('Starting folder import process', this.importConfig.context); + log.debug('Starting folder import process...', this.importConfig.context); await this.importFolders(); // NOTE Step 2: Import versioned assets and create it mapping files (uid, url) if (this.assetConfig.includeVersionedAssets) { const versionsPath = `${this.assetsPath}/versions`; if (existsSync(versionsPath)) { - log.debug('Starting versioned assets import', this.importConfig.context); + log.debug('Starting versioned assets import...', this.importConfig.context); await this.importAssets(true); } else { - log.info('No Versioned assets found to import', this.importConfig.context); + log.info('No versioned assets found to import.', this.importConfig.context); } } // NOTE Step 3: Import Assets and create it mapping files (uid, url) - log.debug('Starting assets import', this.importConfig.context); + log.debug('Starting assets import...', this.importConfig.context); await this.importAssets(); // NOTE Step 4: Publish assets if (!this.importConfig.skipAssetsPublish) { - log.debug('Starting assets publishing', this.importConfig.context); + log.debug('Starting assets publishing...', this.importConfig.context); await this.publish(); } @@ -95,22 +95,22 @@ export default class ImportAssets extends BaseClass { const folders = this.fs.readFile(foldersPath); if (isEmpty(folders)) { - log.info('No folders found to import', this.importConfig.context); + log.info('No folders found to import.', this.importConfig.context); return; } - log.debug(`Found ${folders.length} folders to import`, this.importConfig.context); + log.debug(`Found ${folders.length} folders to import.`, this.importConfig.context); const batches = this.constructFolderImportOrder(folders); - log.debug(`Organized folders into ${batches.length} batches for import`, this.importConfig.context); + log.debug(`Organized folders into ${batches.length} batches for import.`, this.importConfig.context); const onSuccess = ({ response, apiData: { uid, name } = { uid: null, name: '' } }: any) => { this.assetsFolderMap[uid] = response.uid; - log.debug(`Created folder: ${name} (Mapped ${uid} → ${response.uid})`, this.importConfig.context); + log.debug(`Created folder: ${name} (Mapped ${uid} → ${response.uid}).`, this.importConfig.context); log.success(`Created folder: '${name}'`, this.importConfig.context); }; const onReject = ({ error, apiData: { name } = { name: '' } }: any) => { - log.error(`${name} folder creation failed.!`, this.importConfig.context); + log.error(`${name} folder creation failed.`, this.importConfig.context); handleAndLogError(error, { ...this.importConfig.context, name }); }; @@ -127,7 +127,7 @@ export default class ImportAssets extends BaseClass { }; const batch = map(unionBy(batches, 'parent_uid'), 'parent_uid'); - log.debug(`Processing ${batch.length} folder batches`, this.importConfig.context); + log.debug(`Processing ${batch.length} folder batches.`, this.importConfig.context); for (const parent_uid of batch) { const currentBatch = filter(batches, { parent_uid }); @@ -187,7 +187,7 @@ export default class ImportAssets extends BaseClass { }; const onReject = ({ error, apiData: { title } = undefined }: any) => { - log.error(`${title} asset upload failed.!`, this.importConfig.context); + log.error(`${title} asset upload failed.`, this.importConfig.context); handleAndLogError(error, { ...this.importConfig.context, title }); }; @@ -204,7 +204,7 @@ export default class ImportAssets extends BaseClass { log.debug(`Processing ${apiContent.length} assets in chunk`, this.importConfig.context); if (isVersion && this.assetConfig.importSameStructure) { - log.debug('Processing version 1 assets first', this.importConfig.context); + log.debug('Processing version 1 assets first...', this.importConfig.context); const versionOneAssets = filter(apiContent, ({ _version }) => _version === 1); await this.makeConcurrentCall({ @@ -309,7 +309,7 @@ export default class ImportAssets extends BaseClass { async publish() { const fs = new FsUtility({ basePath: this.assetsPath, indexFileName: 'assets.json' }); if (isEmpty(this.assetsUidMap)) { - log.debug('Loading asset UID mappings from file', this.importConfig.context); + log.debug('Loading asset UID mappings from file...', this.importConfig.context); this.assetsUidMap = fs.readFile(this.assetUidMapperPath, true) as any; } @@ -338,7 +338,7 @@ export default class ImportAssets extends BaseClass { if (environments.length === 0 || locales.length === 0) { log.debug( - `Skipping publish for asset ${asset.uid} - no valid environments/locales`, + `Skipping publish for asset ${asset.uid}: no valid environments/locales`, this.importConfig.context, ); apiOptions.entity = undefined; @@ -354,7 +354,7 @@ export default class ImportAssets extends BaseClass { apiOptions.uid = this.assetsUidMap[asset.uid] as string; if (!apiOptions.uid) { - log.debug(`Skipping publish for asset ${asset.uid} - no UID mapping found`, this.importConfig.context); + log.debug(`Skipping publish for asset ${asset.uid}: no UID mapping found.`, this.importConfig.context); apiOptions.entity = undefined; } @@ -413,7 +413,7 @@ export default class ImportAssets extends BaseClass { } if (this.importConfig.replaceExisting) { - log.debug('Setting up root folder for import', this.importConfig.context); + log.debug('Setting up root folder for import...', this.importConfig.context); // Note: adds a root folder to distinguish latest asset uploads // Todo: This temporary approach should be updated with asset and folder overwrite strategy, which follows // folder overwrite @@ -437,7 +437,7 @@ export default class ImportAssets extends BaseClass { }); importOrder.unshift(this.rootFolder); - log.debug('Added root folder to import order', this.importConfig.context); + log.debug('Added root folder to import order.', this.importConfig.context); } return importOrder; } diff --git a/packages/contentstack-import/src/import/modules/content-types.ts b/packages/contentstack-import/src/import/modules/content-types.ts index 5b0f463f75..19b7ca51ea 100644 --- a/packages/contentstack-import/src/import/modules/content-types.ts +++ b/packages/contentstack-import/src/import/modules/content-types.ts @@ -105,13 +105,13 @@ export default class ContentTypesImport extends BaseClass { */ this.cTs = fsUtil.readFile(path.join(this.cTsFolderPath, 'schema.json')) as Record[]; if (!this.cTs || isEmpty(this.cTs)) { - log.info('No content type found to import', this.importConfig.context); + log.info('No content type found to import.', this.importConfig.context); return; } log.debug(`Found ${this.cTs.length} content types to import`, this.importConfig.context); await fsUtil.makeDirectory(this.cTsMapperPath); - log.debug('Created content types mapper directory', this.importConfig.context); + log.debug('Created content types mapper directory.', this.importConfig.context); this.installedExtensions = ( (fsUtil.readFile(this.marketplaceAppMapperPath) as any) || { extension_uid: {} } @@ -125,7 +125,7 @@ export default class ContentTypesImport extends BaseClass { const taxonomyCount = Object.keys(this.taxonomies || {}).length; log.debug(`Loaded ${taxonomyCount} taxonomy definitions`, this.importConfig.context); - log.info('Starting content types seeding process', this.importConfig.context); + log.info('Starting content types seeding process...', this.importConfig.context); await this.seedCTs(); if (this.createdCTs?.length) { fsUtil.writeFile(this.cTsSuccessPath, this.createdCTs); @@ -133,7 +133,7 @@ export default class ContentTypesImport extends BaseClass { } log.success('Created content types', this.importConfig.context); - log.info('Starting content types update process', this.importConfig.context); + log.info('Starting content types update process...', this.importConfig.context); await this.updateCTs(); log.success('Updated content types with references', this.importConfig.context); @@ -148,10 +148,10 @@ export default class ContentTypesImport extends BaseClass { log.success('Successfully updated the extensions.', this.importConfig.context); } - log.info('Starting pending global fields update', this.importConfig.context); + log.info('Starting pending global fields update...', this.importConfig.context); this.pendingGFs = fsUtil.readFile(this.gFsPendingPath) as any; if (!this.pendingGFs || isEmpty(this.pendingGFs)) { - log.info('No pending global fields found to update', this.importConfig.context); + log.info('No pending global fields found to update.', this.importConfig.context); return; } await this.updatePendingGFs().catch((error) => { @@ -169,7 +169,7 @@ export default class ContentTypesImport extends BaseClass { }; const onReject = ({ error, apiData: { content_type: { uid = null } = {} } = {} }: any) => { if (error.errorCode === 115 && (error.errors.uid || error.errors.title)) { - log.info(`${uid} content type already exist`, this.importConfig.context); + log.info(`${uid} content type already exists.`, this.importConfig.context); log.debug(`Skipping existing content type: ${uid}`, this.importConfig.context); } else { handleAndLogError(error, { ...this.importConfig.context, uid }, `Failed to seed content type ${uid}`); @@ -352,7 +352,7 @@ export default class ContentTypesImport extends BaseClass { if (!apiContent || apiContent?.length === 0) { log.info(`No extensions found to be updated.`, this.importConfig.context); - log.debug('Skipping extensions update - no pending extensions', this.importConfig.context); + log.debug('Skipping extensions update – no pending extensions.', this.importConfig.context); return; } @@ -376,7 +376,7 @@ export default class ContentTypesImport extends BaseClass { } }; - log.debug('Starting extensions update process', this.importConfig.context); + log.debug('Starting extensions update process...', this.importConfig.context); return await this.makeConcurrentCall( { apiContent, diff --git a/packages/contentstack-import/src/import/modules/custom-roles.ts b/packages/contentstack-import/src/import/modules/custom-roles.ts index 20bc8a3eae..fcb1611d4b 100644 --- a/packages/contentstack-import/src/import/modules/custom-roles.ts +++ b/packages/contentstack-import/src/import/modules/custom-roles.ts @@ -54,7 +54,7 @@ export default class ImportCustomRoles extends BaseClass { * @returns {Promise} Promise */ async start(): Promise { - log.debug('Checking for custom roles folder existence', this.importConfig.context); + log.debug('Checking for custom roles folder existence...', this.importConfig.context); //Step1 check folder exists or not if (fileHelper.fileExistsSync(this.customRolesFolderPath)) { @@ -63,25 +63,25 @@ export default class ImportCustomRoles extends BaseClass { this.customRoles = fsUtil.readFile(join(this.customRolesFolderPath, this.customRolesConfig.fileName),true) as Record; this.customRolesLocales = fsUtil.readFile(join(this.customRolesFolderPath, this.customRolesConfig.customRolesLocalesFileName),true) as Record; } else { - log.info(`No custom-rules are found - '${this.customRolesFolderPath}'`, this.importConfig.context); + log.info(`No custom roles found in: ${this.customRolesFolderPath}`, this.importConfig.context); return; } //create webhooks in mapper directory - log.debug('Creating custom roles mapper directory', this.importConfig.context); + log.debug('Creating custom roles mapper directory...', this.importConfig.context); await fsUtil.makeDirectory(this.customRolesMapperPath); - log.debug('Loading existing custom roles UID data', this.importConfig.context); + log.debug('Loading existing custom roles UID data...', this.importConfig.context); this.customRolesUidMapper = fileHelper.fileExistsSync(this.customRolesUidMapperPath) ? (fsUtil.readFile(join(this.customRolesUidMapperPath), true) as Record) || {} : {}; - log.debug('Loading environments UID data', this.importConfig.context); + log.debug('Loading environments UID data...', this.importConfig.context); this.environmentsUidMap = fileHelper.fileExistsSync(this.envUidMapperFolderPath) ? (fsUtil.readFile(join(this.envUidMapperFolderPath, 'uid-mapping.json'), true) as Record) || {} : {}; - log.debug('Loading entries UID data', this.importConfig.context); + log.debug('Loading entries UID data...', this.importConfig.context); this.entriesUidMap = fileHelper.fileExistsSync(this.entriesUidMapperFolderPath) ? (fsUtil.readFile(join(this.entriesUidMapperFolderPath, 'uid-mapping.json'), true) as Record) || {} : {}; @@ -90,31 +90,31 @@ export default class ImportCustomRoles extends BaseClass { const customRolesUidCount = Object.keys(this.customRolesUidMapper || {}).length; log.debug(`Loaded existing custom roles UID data: ${customRolesUidCount} items`, this.importConfig.context); } else { - log.debug('No existing custom roles UID data found', this.importConfig.context); + log.debug('No existing custom roles UID data found.', this.importConfig.context); } if (this.environmentsUidMap && Object.keys(this.environmentsUidMap || {})?.length > 0) { const envUidCount = Object.keys(this.environmentsUidMap || {}).length; log.debug(`Loaded environments UID data: ${envUidCount} items`, this.importConfig.context); } else { - log.debug('No environments UID data found', this.importConfig.context); + log.debug('No environments UID data found.', this.importConfig.context); } if (this.entriesUidMap && Object.keys(this.entriesUidMap || {}).length > 0) { const entriesUidCount = Object.keys(this.entriesUidMap || {}).length; log.debug(`Loaded entries UID data: ${entriesUidCount} items`, this.importConfig.context); } else { - log.debug('No entries UID data found', this.importConfig.context); + log.debug('No entries UID data found.', this.importConfig.context); } //source and target stack locale map - log.debug('Getting locales UID mapping', this.importConfig.context); + log.debug('Getting locales UID mapping...', this.importConfig.context); await this.getLocalesUidMap(); - log.debug('Starting custom roles import', this.importConfig.context); + log.debug('Starting custom roles import...', this.importConfig.context); await this.importCustomRoles(); - log.debug('Processing custom roles import results', this.importConfig.context); + log.debug('Processing custom roles import results...', this.importConfig.context); if (this.createdCustomRoles?.length) { fsUtil.writeFile(this.createdCustomRolesPath, this.createdCustomRoles); log.debug(`Written ${this.createdCustomRoles.length} successful custom roles to file`, this.importConfig.context); @@ -129,7 +129,7 @@ export default class ImportCustomRoles extends BaseClass { } async getLocalesUidMap(): Promise { - log.debug('Fetching target stack locales', this.importConfig.context); + log.debug('Fetching target stack locales...', this.importConfig.context); const { items } = await this.stack .locale() .query() @@ -139,25 +139,25 @@ export default class ImportCustomRoles extends BaseClass { return data; }) .catch((error) => { - log.debug('Error fetching target stack locales', this.importConfig.context); + log.debug('Error fetching target stack locales!', this.importConfig.context); handleAndLogError(error, { ...this.importConfig.context}); }); this.targetLocalesMap = {}; this.sourceLocalesMap = {}; - log.debug('Building target locales mapping', this.importConfig.context); + log.debug('Building target locales mapping...', this.importConfig.context); forEach(items, (locale: any) => { this.targetLocalesMap[locale.code] = locale.uid; }); - log.debug('Building source locales mapping', this.importConfig.context); + log.debug('Building source locales mapping...', this.importConfig.context); for (const key in this.customRolesLocales) { const sourceLocales = this.customRolesLocales[key] as Record; this.sourceLocalesMap[sourceLocales.code] = key; } - log.debug('Creating locale UID mapping', this.importConfig.context); + log.debug('Creating locale UID mapping...', this.importConfig.context); for (const key in this.sourceLocalesMap) { const sourceLocaleKey = this.sourceLocalesMap[key] as string; this.localesUidMap[sourceLocaleKey] = this.targetLocalesMap[key]; @@ -168,9 +168,9 @@ export default class ImportCustomRoles extends BaseClass { } async importCustomRoles() { - log.debug('Starting custom roles import process', this.importConfig.context); + log.debug('Starting custom roles import process...', this.importConfig.context); if (this.customRoles === undefined || isEmpty(this.customRoles)) { - log.info('No custom-roles found', this.importConfig.context); + log.info('No custom roles found', this.importConfig.context); return; } @@ -191,7 +191,7 @@ export default class ImportCustomRoles extends BaseClass { log.debug(`Custom role '${name}' import failed`, this.importConfig.context); if (err?.errors?.name) { - log.info(`custom-role '${name}' already exists`, this.importConfig.context); + log.info(`Custom role '${name}' already exists.`, this.importConfig.context); } else { this.failedCustomRoles.push(apiData); handleAndLogError(error, { ...this.importConfig.context, name }, `custom-role '${name}' failed to be import`); @@ -216,7 +216,7 @@ export default class ImportCustomRoles extends BaseClass { false, ); - log.debug('Custom roles import process completed', this.importConfig.context); + log.debug('Custom roles import process completed.', this.importConfig.context); } /** @@ -272,7 +272,7 @@ export default class ImportCustomRoles extends BaseClass { rule.environments = map(rule.environments, (env: any) => this.environmentsUidMap[env]); log.debug(`Transformed ${originalEnvs} environment UIDs for rule`, this.importConfig.context); } else { - log.debug('No environment UID mappings available for transformation', this.importConfig.context); + log.debug('No environment UID mappings available for transformation.', this.importConfig.context); } } else if (rule.module === 'locale') { if(!isEmpty(this.localesUidMap)){ @@ -280,7 +280,7 @@ export default class ImportCustomRoles extends BaseClass { rule.locales = map(rule.locales, (locale: any) => this.localesUidMap[locale]); log.debug(`Transformed ${originalLocales} locale UIDs for rule`, this.importConfig.context); } else { - log.debug('No locale UID mappings available for transformation', this.importConfig.context); + log.debug('No locale UID mappings available for transformation.', this.importConfig.context); } } else if (rule.module === 'entry') { if(!isEmpty(this.entriesUidMap)){ @@ -288,7 +288,7 @@ export default class ImportCustomRoles extends BaseClass { rule.entries = map(rule.entries, (entry: any) => this.entriesUidMap[entry]); log.debug(`Transformed ${originalEntries} entry UIDs for rule`, this.importConfig.context); } else { - log.debug('No entry UID mappings available for transformation', this.importConfig.context); + log.debug('No entry UID mappings available for transformation.', this.importConfig.context); } } return rule; diff --git a/packages/contentstack-import/src/import/modules/entries.ts b/packages/contentstack-import/src/import/modules/entries.ts index 789d3ffb8a..716448b5dd 100644 --- a/packages/contentstack-import/src/import/modules/entries.ts +++ b/packages/contentstack-import/src/import/modules/entries.ts @@ -120,24 +120,22 @@ export default class EntriesImport extends BaseClass { this.installedExtensions = ( (fsUtil.readFile(this.marketplaceAppMapperPath) as any) || { extension_uid: {} } ).extension_uid; - log.debug('Loaded installed extensions for entry processing', this.importConfig.context); + log.debug('Loaded installed extensions for entry processing.', this.importConfig.context); this.assetUidMapper = (fsUtil.readFile(this.assetUidMapperPath) as Record) || {}; this.assetUrlMapper = (fsUtil.readFile(this.assetUrlMapperPath) as Record) || {}; log.debug( - `Loaded asset mappings - UIDs: ${Object.keys(this.assetUidMapper).length}, URLs: ${ - Object.keys(this.assetUrlMapper).length - }`, + `Loaded asset mappings – UIDs: ${Object.keys(this.assetUidMapper).length}`, this.importConfig.context, ); this.taxonomies = (fsUtil.readFile(this.taxonomiesPath) || {}) as Record; - log.debug('Loaded taxonomy data for entry processing', this.importConfig.context); + log.debug('Loaded taxonomy data for entry processing.', this.importConfig.context); fsUtil.makeDirectory(this.entriesMapperPath); - log.debug('Created entries mapper directory', this.importConfig.context); + log.debug('Created entries mapper directory.', this.importConfig.context); - log.info('Preparing content types for entry import', this.importConfig.context); + log.info('Preparing content types for entry import...', this.importConfig.context); await this.disableMandatoryCTReferences(); this.locales = values((fsUtil.readFile(this.localesPath) || []) as Record[]); @@ -145,7 +143,7 @@ export default class EntriesImport extends BaseClass { log.debug(`Processing entries for ${values(this.locales).length} locales`, this.importConfig.context); //Create Entries - log.info('Starting entry creation process', this.importConfig.context); + log.info('Starting entry creation process...', this.importConfig.context); const entryRequestOptions = this.populateEntryCreatePayload(); log.debug(`Generated ${entryRequestOptions.length} entry creation tasks`, this.importConfig.context); @@ -156,7 +154,7 @@ export default class EntriesImport extends BaseClass { if (this.importConfig.replaceExisting) { // Note: Instead of using entryRequestOptions, we can prepare request options for replace, to avoid unnecessary operations - log.info('Starting entry replacement process', this.importConfig.context); + log.info('Starting entry replacement process...', this.importConfig.context); for (let entryRequestOption of entryRequestOptions) { await this.replaceEntries(entryRequestOption).catch((error) => { handleAndLogError( @@ -169,13 +167,13 @@ export default class EntriesImport extends BaseClass { log.success('Entry replacement process completed', this.importConfig.context); } - log.debug('Writing entry UID mappings to file', this.importConfig.context); + log.debug('Writing entry UID mappings to file...', this.importConfig.context); await fileHelper.writeLargeFile(path.join(this.entriesMapperPath, 'uid-mapping.json'), this.entriesUidMapper); // TBD: manages mapper in one file, should find an alternative fsUtil.writeFile(path.join(this.entriesMapperPath, 'failed-entries.json'), this.failedEntries); if (this.autoCreatedEntries?.length > 0) { log.info( - `Removing ${this.autoCreatedEntries.length} entries from master language which got created by default`, + `Removing ${this.autoCreatedEntries.length} auto-created entries from the master language...`, this.importConfig.context, ); await this.removeAutoCreatedEntries().catch((error) => { @@ -189,7 +187,7 @@ export default class EntriesImport extends BaseClass { } // Update entries with references - log.info('Starting entry references update process', this.importConfig.context); + log.info('Starting entry references update process...', this.importConfig.context); const entryUpdateRequestOptions = this.populateEntryUpdatePayload(); log.debug(`Generated ${entryUpdateRequestOptions.length} entry update tasks`, this.importConfig.context); @@ -209,14 +207,14 @@ export default class EntriesImport extends BaseClass { fsUtil.writeFile(path.join(this.entriesMapperPath, 'failed-entries.json'), this.failedEntries); log.success('Entry references update process completed', this.importConfig.context); - log.info('Restoring content type changes', this.importConfig.context); + log.info('Restoring content type changes...', this.importConfig.context); await this.enableMandatoryCTReferences().catch((error) => { handleAndLogError(error, { ...this.importConfig.context }, 'Error while updating content type references'); }); log.success('Content type references restored successfully', this.importConfig.context); // Update field rule of content types which are got removed earlier - log.info('Updating the field rules of content type', this.importConfig.context); + log.info('Updating field rules of content type...', this.importConfig.context); await this.updateFieldRules().catch((error) => { handleAndLogError(error, { ...this.importConfig.context }, 'Error while updating field rules of content type'); }); @@ -224,7 +222,7 @@ export default class EntriesImport extends BaseClass { // Publishing entries if (!this.importConfig.skipEntriesPublish) { - log.info('Starting entry publishing process', this.importConfig.context); + log.info('Starting entry publishing process...', this.importConfig.context); this.envs = fileHelper.readFileSync(this.envPath) || {}; if (Object.keys(this.envs).length === 0) { log.warn( @@ -233,7 +231,7 @@ export default class EntriesImport extends BaseClass { ); return; } else { - log.debug(`Loaded ${Object.keys(this.envs).length} environments for publishing`, this.importConfig.context); + log.debug(`Loaded ${Object.keys(this.envs).length} environments.`, this.importConfig.context); } for (let entryRequestOption of entryRequestOptions) { @@ -247,10 +245,10 @@ export default class EntriesImport extends BaseClass { } log.success('All the entries have been published successfully', this.importConfig.context); } else { - log.info('Skipping entry publishing as per configuration', this.importConfig.context); + log.info('Skipping entry publishing as per configuration...', this.importConfig.context); } - log.debug('Creating entry data for variant entries', this.importConfig.context); + log.debug('Creating entry data for variant entries...', this.importConfig.context); this.createEntryDataForVariantEntry(); } catch (error) { this.createEntryDataForVariantEntry(); @@ -999,7 +997,7 @@ export default class EntriesImport extends BaseClass { any >[]; if (!cTsWithFieldRules || cTsWithFieldRules?.length === 0) { - log.debug('No content types with field rules found to update', this.importConfig.context); + log.debug('No content types with field rules found to update.', this.importConfig.context); return; } log.debug(`Found ${cTsWithFieldRules.length} content types with field rules to update`, this.importConfig.context); @@ -1025,7 +1023,7 @@ export default class EntriesImport extends BaseClass { fieldDatatypeMap[field] = contentType.schema[i].data_type; } log.debug( - `Built field datatype map for ${Object.keys(fieldDatatypeMap).length} fields`, + `Built field datatype map for ${Object.keys(fieldDatatypeMap).length} fields.`, this.importConfig.context, ); diff --git a/packages/contentstack-import/src/import/modules/environments.ts b/packages/contentstack-import/src/import/modules/environments.ts index 6ff7cf1908..f8412fb056 100644 --- a/packages/contentstack-import/src/import/modules/environments.ts +++ b/packages/contentstack-import/src/import/modules/environments.ts @@ -38,7 +38,7 @@ export default class ImportEnvironments extends BaseClass { * @returns {Promise} Promise */ async start(): Promise { - log.debug('Checking for environments folder existence', this.importConfig.context); + log.debug('Checking if environments folder exists...', this.importConfig.context); //Step1 check folder exists or not if (fileHelper.fileExistsSync(this.environmentsFolderPath)) { @@ -50,13 +50,13 @@ export default class ImportEnvironments extends BaseClass { const envCount = Object.keys(this.environments || {}).length; log.debug(`Loaded ${envCount} environment items from file`, this.importConfig.context); } else { - log.info(`No Environments Found - '${this.environmentsFolderPath}'`, this.importConfig.context); + log.info(`No environments found: '${this.environmentsFolderPath}'`, this.importConfig.context); return; } - log.debug('Creating environments mapper directory', this.importConfig.context); + log.debug('Creating environments mapper directory...', this.importConfig.context); await fsUtil.makeDirectory(this.mapperDirPath); - log.debug('Loading existing environment UID mappings', this.importConfig.context); + log.debug('Loading existing environment UID mappings...', this.importConfig.context); this.envUidMapper = fileHelper.fileExistsSync(this.envUidMapperPath) ? (fsUtil.readFile(join(this.envUidMapperPath), true) as Record) : {}; @@ -65,13 +65,13 @@ export default class ImportEnvironments extends BaseClass { const envUidCount = Object.keys(this.envUidMapper || {}).length; log.debug(`Loaded existing environment UID data: ${envUidCount} items`, this.importConfig.context); } else { - log.debug('No existing environment UID mappings found', this.importConfig.context); + log.debug('No existing environment UID mappings found.', this.importConfig.context); } - log.debug('Starting environment import process', this.importConfig.context); + log.debug('Starting environment import process...', this.importConfig.context); await this.importEnvironments(); - log.debug('Processing environment import results', this.importConfig.context); + log.debug('Processing environment import results...', this.importConfig.context); if (this.envSuccess?.length) { fsUtil.writeFile(this.envSuccessPath, this.envSuccess); log.debug(`Written ${this.envSuccess.length} successful environments to file`, this.importConfig.context); @@ -86,9 +86,9 @@ export default class ImportEnvironments extends BaseClass { } async importEnvironments() { - log.debug('Validating environments data', this.importConfig.context); + log.debug('Validating environment data...', this.importConfig.context); if (this.environments === undefined || isEmpty(this.environments)) { - log.info('No Environment Found', this.importConfig.context); + log.info('No environment found.', this.importConfig.context); return; } @@ -139,7 +139,7 @@ export default class ImportEnvironments extends BaseClass { false, ); - log.debug('Environments import process completed', this.importConfig.context); + log.debug('Environment import process completed.', this.importConfig.context); } /** diff --git a/packages/contentstack-import/src/import/modules/extensions.ts b/packages/contentstack-import/src/import/modules/extensions.ts index 37bc1eb619..30dad1671e 100644 --- a/packages/contentstack-import/src/import/modules/extensions.ts +++ b/packages/contentstack-import/src/import/modules/extensions.ts @@ -45,7 +45,7 @@ export default class ImportExtensions extends BaseClass { * @returns {Promise} Promise */ async start(): Promise { - log.debug('Checking for extensions folder existence', this.importConfig.context); + log.debug('Checking if extensions folder exists...', this.importConfig.context); //Step1 check folder exists or not if (fileHelper.fileExistsSync(this.extensionsFolderPath)) { @@ -58,21 +58,21 @@ export default class ImportExtensions extends BaseClass { // Check if extensions file was read successfully if (!this.extensions) { - log.info(`No extensions found in file - '${join(this.extensionsFolderPath, 'extensions.json')}'`, this.importConfig.context); + log.info(`No extensions found in file: '${join(this.extensionsFolderPath, 'extensions.json')}'`, this.importConfig.context); return; } const extensionsCount = Object.keys(this.extensions || {}).length; log.debug(`Loaded ${extensionsCount} extension items from file`, this.importConfig.context); } else { - log.info(`No Extensions Found - '${this.extensionsFolderPath}'`, this.importConfig.context); + log.info(`No extensions found: '${this.extensionsFolderPath}'`, this.importConfig.context); return; } - log.debug('Creating extensions mapper directory', this.importConfig.context); + log.debug('Creating extensions mapper directory...', this.importConfig.context); await fsUtil.makeDirectory(this.mapperDirPath); - log.debug('Loading existing extensions UID data', this.importConfig.context); + log.debug('Loading existing extension UID data...', this.importConfig.context); this.extUidMapper = fileHelper.fileExistsSync(this.extUidMapperPath) ? (fsUtil.readFile(join(this.extUidMapperPath), true) as Record) || {} : {}; @@ -81,31 +81,31 @@ export default class ImportExtensions extends BaseClass { const extUidCount = Object.keys(this.extUidMapper || {}).length; log.debug(`Loaded existing extensions UID data: ${extUidCount} items`, this.importConfig.context); } else { - log.debug('No existing extensions UID data found', this.importConfig.context); + log.debug('No existing extension UID data found.', this.importConfig.context); } // Check whether the scope of an extension contains content-types in scope // Remove the scope and store the scope with uid in pending extensions - log.debug('Checking content types in extension scope', this.importConfig.context); + log.debug('Checking content types in extension scope...', this.importConfig.context); this.getContentTypesInScope(); - log.debug('Starting extensions import', this.importConfig.context); + log.debug('Starting extensions import...', this.importConfig.context); await this.importExtensions(); // Update the uid of the extension - log.debug('Updating extension UIDs', this.importConfig.context); + log.debug('Updating extension UIDs...', this.importConfig.context); this.updateUidExtension(); // Note: if any extensions present, then update it if (this.importConfig.replaceExisting && this.existingExtensions.length > 0) { log.debug(`Replacing ${this.existingExtensions.length} existing extensions`, this.importConfig.context); await this.replaceExtensions().catch((error: Error) => { - log.debug('Error replacing extensions', this.importConfig.context); + log.debug('Error replacing extensions!', this.importConfig.context); handleAndLogError(error, { ...this.importConfig.context}); }); } - log.debug('Processing extensions import results', this.importConfig.context); + log.debug('Processing extensions import results...', this.importConfig.context); if (this.extSuccess?.length) { fsUtil.writeFile(this.extSuccessPath, this.extSuccess); log.debug(`Written ${this.extSuccess.length} successful extensions to file`, this.importConfig.context); @@ -122,7 +122,7 @@ export default class ImportExtensions extends BaseClass { async importExtensions(): Promise { log.debug('Starting extensions import process', this.importConfig.context); if (this.extensions === undefined || isEmpty(this.extensions)) { - log.info('No Extensions Found', this.importConfig.context); + log.info('No extensions found.', this.importConfig.context); return; } @@ -172,7 +172,7 @@ export default class ImportExtensions extends BaseClass { false, ); - log.debug('Extensions import process completed', this.importConfig.context); + log.debug('Extensions import process completed.', this.importConfig.context); } async replaceExtensions(): Promise { @@ -208,7 +208,7 @@ export default class ImportExtensions extends BaseClass { this.replaceExtensionHandler.bind(this), ); - log.debug('Extensions replacement process completed', this.importConfig.context); + log.debug('Extensions replacement process completed.', this.importConfig.context); } async replaceExtensionHandler({ @@ -288,7 +288,7 @@ export default class ImportExtensions extends BaseClass { extension.forEach((ext: ExtensionType) => { let ct: any = ext?.scope?.content_types || []; if ((ct.length === 1 && ct[0] !== '$all') || ct?.length > 1) { - log.info(`Removing the content-types ${ct.join(',')} from the extension ${ext.title} ...`, this.importConfig.context); + log.info(`Removing content types: ${ct.join(', ')}...`, this.importConfig.context); log.debug(`Extension '${ext.title}' has ${ct.length} content types in scope`, this.importConfig.context); const { uid, scope } = ext; @@ -304,7 +304,7 @@ export default class ImportExtensions extends BaseClass { } updateUidExtension() { - log.debug('Updating extension UIDs in pending extensions', this.importConfig.context); + log.debug('Updating extension UIDs in pending extensions...', this.importConfig.context); let updatedCount = 0; for (let i in this.extensionObject) { diff --git a/packages/contentstack-import/src/import/modules/global-fields.ts b/packages/contentstack-import/src/import/modules/global-fields.ts index e7af748bf4..15249185fc 100644 --- a/packages/contentstack-import/src/import/modules/global-fields.ts +++ b/packages/contentstack-import/src/import/modules/global-fields.ts @@ -63,31 +63,31 @@ export default class ImportGlobalFields extends BaseClass { } async start(): Promise { - log.debug('Reading global fields from file', this.importConfig.context); + log.debug('Reading global fields from file...', this.importConfig.context); this.gFs = fsUtil.readFile(path.join(this.gFsFolderPath, this.gFsConfig.fileName)) as Record[]; if (!this.gFs || isEmpty(this.gFs)) { - log.info('No global fields found to import', this.importConfig.context); + log.info('No global fields found to import.', this.importConfig.context); return; } const gfsCount = Array.isArray(this.gFs) ? this.gFs.length : Object.keys(this.gFs).length; log.debug(`Loaded ${gfsCount} global field items from file`, this.importConfig.context); - log.debug('Creating global fields mapper directory', this.importConfig.context); + log.debug('Creating global fields mapper directory...', this.importConfig.context); await fsUtil.makeDirectory(this.gFsMapperPath); - log.debug('Loading existing global fields UID data', this.importConfig.context); + log.debug('Loading existing global fields UID data...', this.importConfig.context); if (fileHelper.fileExistsSync(this.gFsUidMapperPath)) { this.gFsUidMapper = (fsUtil.readFile(this.gFsUidMapperPath) || {}) as Record; const gfsUidCount = Object.keys(this.gFsUidMapper || {}).length; log.debug(`Loaded existing global fields UID data: ${gfsUidCount} items`, this.importConfig.context); } else { - log.debug('No existing global fields UID data found', this.importConfig.context); + log.debug('No existing global fields UID data found.', this.importConfig.context); } - log.debug('Loading installed extensions data', this.importConfig.context); + log.debug('Loading installed extensions data...', this.importConfig.context); this.installedExtensions = ( ((await fsUtil.readFile(this.marketplaceAppMapperPath)) as any) || { extension_uid: {} } ).extension_uid; @@ -113,12 +113,12 @@ export default class ImportGlobalFields extends BaseClass { if (this.importConfig.replaceExisting && this.existingGFs.length > 0) { log.debug(`Replacing ${this.existingGFs.length} existing global fields`, this.importConfig.context); await this.replaceGFs().catch((error: Error) => { - log.debug('Error replacing global fields', this.importConfig.context); + log.debug('Error replacing global fields!', this.importConfig.context); handleAndLogError(error, { ...this.importConfig.context}); }); } - log.debug('Processing global fields import results', this.importConfig.context); + log.debug('Processing global fields import results...', this.importConfig.context); if (this.createdGFs?.length) { fsUtil.writeFile(this.gFsSuccessPath, this.createdGFs); log.debug(`Written ${this.createdGFs.length} successful global fields to file`, this.importConfig.context); @@ -133,7 +133,7 @@ export default class ImportGlobalFields extends BaseClass { } async seedGFs(): Promise { - log.debug('Starting global fields seeding process', this.importConfig.context); + log.debug('Starting global fields seeding process...', this.importConfig.context); const gfsToSeed = Array.isArray(this.gFs) ? this.gFs.length : Object.keys(this.gFs).length; log.debug(`Seeding ${gfsToSeed} global fields`, this.importConfig.context); @@ -155,7 +155,7 @@ export default class ImportGlobalFields extends BaseClass { log.debug(`Global field '${uid}' marked for replacement`, this.importConfig.context); } if (!this.importConfig.skipExisting) { - log.info(`Global fields '${uid}' already exist`, this.importConfig.context); + log.info(`Global field '${uid}' already exists.`, this.importConfig.context); } } else { handleAndLogError(error, { ...this.importConfig.context, uid }, `Global fields '${uid}' failed to import`); @@ -177,7 +177,7 @@ export default class ImportGlobalFields extends BaseClass { concurrencyLimit: this.reqConcurrency, }); - log.debug('Global fields seeding process completed', this.importConfig.context); + log.debug('Global fields seeding process completed.', this.importConfig.context); return result; } @@ -200,7 +200,7 @@ export default class ImportGlobalFields extends BaseClass { } async updateGFs(): Promise { - log.debug('Starting global fields update process', this.importConfig.context); + log.debug('Starting global fields update process...', this.importConfig.context); const gfsToUpdate = Array.isArray(this.gFs) ? this.gFs.length : Object.keys(this.gFs).length; log.debug(`Updating ${gfsToUpdate} global fields`, this.importConfig.context); @@ -254,7 +254,7 @@ export default class ImportGlobalFields extends BaseClass { await removeReferenceFields(globalField.schema, flag, this.stack); if (flag.supressed) { - log.debug(`Global field '${globalField.uid}' has suppressed references, adding to pending`, this.importConfig.context); + log.debug(`Global field '${globalField.uid}' has suppressed reference fields.`, this.importConfig.context); this.pendingGFs.push(globalField.uid); log.info(`Global field '${globalField.uid}' will be updated later`, this.importConfig.context); return resolve(true); diff --git a/packages/contentstack-import/src/import/modules/labels.ts b/packages/contentstack-import/src/import/modules/labels.ts index dc6ac47cf9..294f17062f 100644 --- a/packages/contentstack-import/src/import/modules/labels.ts +++ b/packages/contentstack-import/src/import/modules/labels.ts @@ -40,7 +40,7 @@ export default class ImportLabels extends BaseClass { * @returns {Promise} Promise */ async start(): Promise { - log.debug('Checking for labels folder existence', this.importConfig.context); + log.debug('Checking if labels folder exists...', this.importConfig.context); //Step1 check folder exists or not if (fileHelper.fileExistsSync(this.labelsFolderPath)) { @@ -59,14 +59,14 @@ export default class ImportLabels extends BaseClass { const labelCount = Object.keys(this.labels || {}).length; log.debug(`Loaded ${labelCount} label items from file`, this.importConfig.context); } else { - log.info(`No labels found - '${this.labelsFolderPath}'`, this.importConfig.context); + log.info(`No labels found: '${this.labelsFolderPath}'`, this.importConfig.context); return; } //create labels in mapper directory - log.debug('Creating labels mapper directory', this.importConfig.context); + log.debug('Creating labels mapper directory...', this.importConfig.context); await fsUtil.makeDirectory(this.mapperDirPath); - log.debug('Loading existing label UID mappings', this.importConfig.context); + log.debug('Loading existing label UID mappings...', this.importConfig.context); this.labelUidMapper = fileHelper.fileExistsSync(this.labelUidMapperPath) ? (fsUtil.readFile(join(this.labelUidMapperPath), true) as Record) || {} : {}; @@ -75,16 +75,16 @@ export default class ImportLabels extends BaseClass { const labelUidCount = Object.keys(this.labelUidMapper || {}).length; log.debug(`Loaded existing label UID data: ${labelUidCount} items`, this.importConfig.context); } else { - log.debug('No existing label UID mappings found', this.importConfig.context); + log.debug('No existing label UID mappings found.', this.importConfig.context); } - log.debug('Starting labels import', this.importConfig.context); + log.debug('Starting labels import...', this.importConfig.context); await this.importLabels(); //update parent in created label log.debug('Starting labels update process', this.importConfig.context); await this.updateLabels(); - log.debug('Processing labels import results', this.importConfig.context); + log.debug('Processing labels import results...', this.importConfig.context); if (this.createdLabel?.length) { fsUtil.writeFile(this.createdLabelPath, this.createdLabel); log.debug(`Written ${this.createdLabel.length} successful labels to file`, this.importConfig.context); @@ -100,7 +100,7 @@ export default class ImportLabels extends BaseClass { async importLabels() { if (this.labels === undefined || isEmpty(this.labels)) { - log.info('No Labels Found', this.importConfig.context); + log.info('No labels found.', this.importConfig.context); return; } @@ -151,7 +151,7 @@ export default class ImportLabels extends BaseClass { log.debug(`Serializing label: ${label.name} (${label.uid})`, this.importConfig.context); if (this.labelUidMapper.hasOwnProperty(label.uid)) { - log.info(`Label '${label.name}' already exists. Skipping it to avoid duplicates!`, this.importConfig.context); + log.info(`Label '${label.name}' already exists. Skipping to avoid duplicates.`, this.importConfig.context); log.debug(`Skipping label serialization for: ${label.uid}`, this.importConfig.context); apiOptions.entity = undefined; } else { @@ -169,7 +169,7 @@ export default class ImportLabels extends BaseClass { } async updateLabels() { - log.debug('Starting labels update process', this.importConfig.context); + log.debug('Starting labels update process...', this.importConfig.context); if (!isEmpty(this.labels)) { const apiContent = values(this.labels); log.debug(`Updating ${apiContent.length} labels`, this.importConfig.context); @@ -210,10 +210,10 @@ export default class ImportLabels extends BaseClass { false, ); } else { - log.debug('No labels to update', this.importConfig.context); + log.debug('No labels to update.', this.importConfig.context); } - log.debug('Labels update process completed', this.importConfig.context); + log.debug('Labels update process completed.', this.importConfig.context); } /** diff --git a/packages/contentstack-import/src/import/modules/locales.ts b/packages/contentstack-import/src/import/modules/locales.ts index e504a216c2..8f2ea44002 100644 --- a/packages/contentstack-import/src/import/modules/locales.ts +++ b/packages/contentstack-import/src/import/modules/locales.ts @@ -58,35 +58,35 @@ export default class ImportLocales extends BaseClass { } async start(): Promise { - log.debug('Loading locales from file', this.config.context); + log.debug('Loading locales from file...', this.config.context); this.languages = fsUtil.readFile(path.join(this.langFolderPath, this.localeConfig.fileName)) as Record< string, unknown >[]; if (!this.languages || isEmpty(this.languages)) { - log.info('No languages found to import', this.config.context); + log.info('No languages found to import.', this.config.context); return; } log.debug(`Found ${values(this.languages).length} languages to import`, this.config.context); - log.debug('Loading source master language configuration', this.config.context); + log.debug('Loading source master language configuration...', this.config.context); this.sourceMasterLanguage = fsUtil.readFile( path.join(this.langFolderPath, this.masterLanguageConfig.fileName), ) as Record; - log.debug('Loaded source master language configuration', this.config.context); + log.debug('Loaded source master language configuration.', this.config.context); - log.debug('Creating languages mapper directory', this.config.context); + log.debug('Creating languages mapper directory...', this.config.context); await fileHelper.makeDirectory(this.langMapperPath); - log.debug('Created languages mapper directory', this.config.context); + log.debug('Created languages mapper directory.', this.config.context); - log.debug('Loading existing language UID mappings', this.config.context); + log.debug('Loading existing language UID mappings...', this.config.context); if (fileHelper.fileExistsSync(this.langUidMapperPath)) { this.langUidMapper = fsUtil.readFile(this.langUidMapperPath) || {}; const langUidCount = Object.keys(this.langUidMapper || {}).length; log.debug(`Loaded existing language UID data: ${langUidCount} items`, this.config.context); } else { - log.debug('No existing language UID mappings found', this.config.context); + log.debug('No existing language UID mappings found.', this.config.context); } log.debug('Checking and updating master locale', this.config.context); @@ -94,17 +94,17 @@ export default class ImportLocales extends BaseClass { handleAndLogError(error, { ...this.config.context }); }); - log.debug('Creating locales', this.config.context); + log.debug('Creating locales...', this.config.context); await this.createLocales().catch((error) => { handleAndLogError(error, { ...this.config.context }); Promise.reject('Failed to import locales'); }); - log.debug('Writing failed locales to file', this.config.context); + log.debug('Writing failed locales to file...', this.config.context); fsUtil.writeFile(this.langFailsPath, this.failedLocales); log.debug(`Written ${this.failedLocales.length} failed locales to file`, this.config.context); - log.debug('Updating locales', this.config.context); + log.debug('Updating locales...', this.config.context); await this.updateLocales().catch((error) => { handleAndLogError(error, { ...this.config.context }); Promise.reject('Failed to update locales'); @@ -122,12 +122,12 @@ export default class ImportLocales extends BaseClass { if (sourceMasterLangDetails?.[0]?.code === this.masterLanguage?.code) { log.debug(`Master locale code matches: ${this.masterLanguage?.code}`, this.config.context); - log.debug('Fetching current master language details from stack', this.config.context); + log.debug('Fetching current master language details from stack...', this.config.context); let masterLangDetails = await this.stackAPIClient .locale(this.masterLanguage['code']) .fetch() .catch((error: Error) => { - log.debug('Error fetching master language details', this.config.context); + log.debug('Error fetching master language details!', this.config.context); handleAndLogError(error, { ...this.config.context }); }); @@ -135,15 +135,15 @@ export default class ImportLocales extends BaseClass { masterLangDetails?.name?.toString().toUpperCase() !== sourceMasterLangDetails[0]['name']?.toString().toUpperCase() ) { - log.debug('Master language name differs between source and destination', this.config.context); + log.debug('Master language name differs between source and destination.', this.config.context); log.debug(`Current master language name: ${masterLangDetails['name']}`, this.config.context); log.debug(`Source master language name: ${sourceMasterLangDetails[0]['name']}`, this.config.context); cliux.print('WARNING!!! The master language name for the source and destination is different.', { color: 'yellow', }); - cliux.print(`Old Master language name: ${masterLangDetails['name']}`, { color: 'red' }); - cliux.print(`New Master language name: ${sourceMasterLangDetails[0]['name']}`, { color: 'green' }); + cliux.print(`Old master language name: ${masterLangDetails['name']}`, { color: 'red' }); + cliux.print(`New master language name: ${sourceMasterLangDetails[0]['name']}`, { color: 'green' }); const langUpdateConfirmation: boolean = await cliux.inquire({ type: 'confirm', @@ -152,7 +152,7 @@ export default class ImportLocales extends BaseClass { }); if (langUpdateConfirmation) { - log.debug('User confirmed master language name update', this.config.context); + log.debug('User confirmed master language name update.', this.config.context); let langUid = sourceMasterLangDetails[0] && sourceMasterLangDetails[0]['uid']; let sourceMasterLanguage = this.sourceMasterLanguage[langUid]; if (!sourceMasterLanguage) { @@ -164,18 +164,18 @@ export default class ImportLocales extends BaseClass { const langUpdateRequest = this.stackAPIClient.locale(sourceMasterLanguage.code); langUpdateRequest.name = sourceMasterLanguage.name; await langUpdateRequest.update().catch((error: Error) => { - log.debug('Error updating master language name', this.config.context); + log.debug('Error updating master language name!', this.config.context); handleAndLogError(error, { ...this.config.context }); }); log.success('Master Languages name have been updated successfully!', this.config.context); } else { - log.debug('User declined master language name update', this.config.context); + log.debug('User declined master language name update.', this.config.context); } } else { log.debug('Master language names match, no update needed', this.config.context); } } else { - log.debug('Master language codes do not match', this.config.context); + log.debug('Master language codes do not match.', this.config.context); } } @@ -219,7 +219,7 @@ export default class ImportLocales extends BaseClass { } async updateLocales(): Promise { - log.debug(`Updating ${values(this.languages).length} locales`, this.config.context); + log.debug(`Updating ${Object.values(this.languages).length} locales`, this.config.context); const onSuccess = ({ response = {}, apiData: { uid, code } = undefined }: any) => { log.info(`Updated locale: '${code}'`, this.config.context); diff --git a/packages/contentstack-import/src/import/modules/marketplace-apps.ts b/packages/contentstack-import/src/import/modules/marketplace-apps.ts index 7db4b024be..e00fc3f8ec 100644 --- a/packages/contentstack-import/src/import/modules/marketplace-apps.ts +++ b/packages/contentstack-import/src/import/modules/marketplace-apps.ts @@ -74,7 +74,7 @@ export default class ImportMarketplaceApps { * @returns The function `start()` returns a `Promise`. */ async start(): Promise { - log.debug('Checking for marketplace apps folder existence', this.importConfig.context); + log.debug('Checking if Marketplace apps folder exists...', this.importConfig.context); if (fileHelper.fileExistsSync(this.marketPlaceFolderPath)) { log.debug(`Found marketplace apps folder: ${this.marketPlaceFolderPath}`, this.importConfig.context); @@ -84,43 +84,43 @@ export default class ImportMarketplaceApps { ) as Installation[]; log.debug(`Found ${this.marketplaceApps?.length || 0} marketplace apps to import`, this.importConfig.context); } else { - log.info(`No Marketplace apps are found - '${this.marketPlaceFolderPath}'`, this.importConfig.context); + log.info(`No Marketplace apps found: '${this.marketPlaceFolderPath}'`, this.importConfig.context); return; } if (isEmpty(this.marketplaceApps)) { - log.debug('No marketplace apps found to import', this.importConfig.context); + log.debug('No Marketplace Apps found to import.', this.importConfig.context); return Promise.resolve(); } else if (!isAuthenticated()) { cliux.print( '\nWARNING!!! To import Marketplace apps, you must be logged in. Please check csdx auth:login --help to log in\n', { color: 'yellow' }, ); - log.info('Skipping marketplace apps import - user not authenticated', this.importConfig.context); + log.info('Skipping Marketplace Apps import: user not authenticated.', this.importConfig.context); return Promise.resolve(); } - log.debug('Creating marketplace apps mapper directory', this.importConfig.context); + log.debug('Creating Marketplace Apps mapper directory...', this.importConfig.context); await fsUtil.makeDirectory(this.mapperDirPath); - log.debug('Created marketplace apps mapper directory', this.importConfig.context); + log.debug('Created Marketplace Apps mapper directory.', this.importConfig.context); - log.debug('Getting developer hub base URL', this.importConfig.context); + log.debug('Getting Developer Hub base URL...', this.importConfig.context); this.developerHubBaseUrl = this.importConfig.developerHubBaseUrl || (await getDeveloperHubUrl(this.importConfig)); this.importConfig.developerHubBaseUrl = this.developerHubBaseUrl; - log.debug(`Using developer hub base URL: ${this.developerHubBaseUrl}`, this.importConfig.context); + log.debug(`Using Developer Hub base URL: ${this.developerHubBaseUrl}`, this.importConfig.context); // NOTE init marketplace app sdk - log.debug('Initializing marketplace SDK client', this.importConfig.context); + log.debug('Initializing Marketplace SDK client...', this.importConfig.context); const host = this.developerHubBaseUrl.split('://').pop(); this.appSdk = await marketplaceSDKClient({ host }); - log.debug('Initialized marketplace SDK client', this.importConfig.context); + log.debug('Initialized Marketplace SDK client.', this.importConfig.context); - log.debug('Getting organization UID', this.importConfig.context); + log.debug('Getting organization UID...', this.importConfig.context); this.importConfig.org_uid = await getOrgUid(this.importConfig); log.debug(`Using organization UID: ${this.importConfig.org_uid}`, this.importConfig.context); // NOTE start the marketplace import process - log.debug('Starting marketplace apps import process', this.importConfig.context); + log.debug('Starting Marketplace Apps import process...', this.importConfig.context); await this.importMarketplaceApps(); log.success('Marketplace apps have been imported successfully!', this.importConfig.context); @@ -131,38 +131,38 @@ export default class ImportMarketplaceApps { * validates app installation, and generates a UID mapper. */ async importMarketplaceApps(): Promise { - log.debug('Setting up security configuration for marketplace apps', this.importConfig.context); + log.debug('Setting up security configuration for Marketplace Apps...', this.importConfig.context); // NOTE set default encryptionKey const cryptoArgs = { encryptionKey: this.importConfig.marketplaceAppEncryptionKey }; if (this.importConfig.forceStopMarketplaceAppsPrompt) { - log.debug('Using forced security configuration without validation', this.importConfig.context); + log.debug('Using forced security configuration without validation.', this.importConfig.context); this.nodeCrypto = new NodeCrypto(cryptoArgs); } else { - log.debug('Validating security configuration', this.importConfig.context); + log.debug('Validating security configuration...', this.importConfig.context); await this.getAndValidateEncryptionKey(this.importConfig.marketplaceAppEncryptionKey); } // NOTE install all private apps which is not available for stack. - log.debug('Handling private apps creation process', this.importConfig.context); + log.debug('Handling private apps creation process...', this.importConfig.context); await this.handleAllPrivateAppsCreationProcess(); // NOTE getting all apps to validate if it's already installed in the stack to manage conflict - log.debug('Getting all stack-specific apps for validation', this.importConfig.context); + log.debug('Getting all stack-specific apps for validation...', this.importConfig.context); this.installedApps = await getAllStackSpecificApps(this.importConfig); log.debug(`Found ${this.installedApps?.length || 0} already installed apps`, this.importConfig.context); - log.info('Starting marketplace app installation', this.importConfig.context); + log.info('Starting Marketplace App installation...', this.importConfig.context); for (let app of this.marketplaceApps) { log.debug(`Processing app: ${app.manifest?.name || app.manifest?.uid}`, this.importConfig.context); await this.installApps(app); } - log.debug('Generating UID mapper', this.importConfig.context); + log.debug('Generating UID mapper...', this.importConfig.context); const uidMapper = await this.generateUidMapper(); - log.debug('Writing UID mappings to file', this.importConfig.context); + log.debug('Writing UID mappings to file...', this.importConfig.context); fsUtil.writeFile(this.marketPlaceUidMapperPath, { app_uid: this.appUidMapping, extension_uid: uidMapper || {}, @@ -183,24 +183,24 @@ export default class ImportMarketplaceApps { * unknown>`. */ async generateUidMapper(): Promise> { - log.debug('Generating UID mapper for extensions', this.importConfig.context); + log.debug('Generating UID mapper for extensions...', this.importConfig.context); const listOfNewMeta = []; const listOfOldMeta = []; const extensionUidMap: Record = {}; // NOTE After installation getting all apps to create mapper. - log.debug('Fetching updated list of installed apps', this.importConfig.context); + log.debug('Fetching updated list of installed apps...', this.importConfig.context); this.installedApps = (await getAllStackSpecificApps(this.importConfig)) || []; log.debug(`Found ${this.installedApps?.length || 0} installed apps after installation`, this.importConfig.context); - log.debug('Processing old metadata from marketplace apps', this.importConfig.context); + log.debug('Processing old metadata from Marketplace Apps...', this.importConfig.context); for (const app of this.marketplaceApps) { const appMeta = map(app?.ui_location?.locations, 'meta').flat(); listOfOldMeta.push(...appMeta); log.debug(`Added ${appMeta.length} meta entries from app: ${app.manifest?.name}`, this.importConfig.context); } - log.debug('Processing new metadata from installed apps', this.importConfig.context); + log.debug('Processing new metadata from installed apps...', this.importConfig.context); for (const app of this.installedApps) { const appMeta = map(app?.ui_location?.locations, 'meta').flat(); listOfNewMeta.push(...appMeta); @@ -249,7 +249,7 @@ export default class ImportMarketplaceApps { ); if (!appConfig) { - log.debug('No app configuration found requiring encryption', this.importConfig.context); + log.debug('No app configuration found requiring encryption.', this.importConfig.context); return defaultValue; } @@ -258,11 +258,11 @@ export default class ImportMarketplaceApps { try { appConfig = !isEmpty(appConfig.configuration) ? appConfig.configuration : appConfig.server_configuration; - log.debug('Creating NodeCrypto instance with security configuration', this.importConfig.context); + log.debug('Creating NodeCrypto instance with security configuration...', this.importConfig.context); this.nodeCrypto = new NodeCrypto({ encryptionKey }); - log.debug('Testing security configuration with app data', this.importConfig.context); + log.debug('Testing security configuration with app data...', this.importConfig.context); this.nodeCrypto.decrypt(appConfig); - log.debug('Security configuration validation successful', this.importConfig.context); + log.debug('Security configuration validation successful.', this.importConfig.context); } catch (error) { log.debug(`Security configuration validation failed: ${error.message}`, this.importConfig.context); if (retry < this.importConfig.getEncryptionKeyMaxRetry && error.code === 'ERR_OSSL_EVP_BAD_DECRYPT') { @@ -281,7 +281,7 @@ export default class ImportMarketplaceApps { `Maximum retry limit exceeded. Closing the process, please try again.! attempt(${retry}/${this.importConfig.getEncryptionKeyMaxRetry})`, { color: 'red' }, ); - log.debug('Maximum retry limit exceeded for encryption validation', this.importConfig.context); + log.debug('Maximum retry limit exceeded for encryption validation.', this.importConfig.context); process.exit(1); } } @@ -296,7 +296,7 @@ export default class ImportMarketplaceApps { * @returns a Promise that resolves to void. */ async handleAllPrivateAppsCreationProcess(): Promise { - log.debug('Filtering private apps from marketplace apps', this.importConfig.context); + log.debug('Filtering private apps from Marketplace Apps...', this.importConfig.context); const privateApps = filter(this.marketplaceApps, { manifest: { visibility: 'private' } }); log.debug(`Found ${privateApps.length} private apps to process`, this.importConfig.context); @@ -305,12 +305,12 @@ export default class ImportMarketplaceApps { return Promise.resolve(); } - log.debug('Getting confirmation to create private apps', this.importConfig.context); + log.debug('Getting confirmation to create private apps...', this.importConfig.context); let canCreatePrivateApp = await getConfirmationToCreateApps(privateApps, this.importConfig); this.importConfig.canCreatePrivateApp = canCreatePrivateApp; if (canCreatePrivateApp) { - log.info('Starting developer hub private apps re-creation', this.importConfig.context); + log.info('Starting Developer Hub private apps re-creation...', this.importConfig.context); log.debug(`Processing ${privateApps.length} private apps for creation`, this.importConfig.context); for (let app of privateApps) { @@ -318,7 +318,7 @@ export default class ImportMarketplaceApps { if (await this.isPrivateAppExistInDeveloperHub(app)) { // NOTE Found app already exist in the same org this.appUidMapping[app.uid] = app.uid; - cliux.print(`App '${app.manifest.name}' already exist. skipping app recreation.!`, { color: 'yellow' }); + cliux.print(`App '${app.manifest.name}' already exists. Skipping app recreation.`, { color: 'yellow' }); log.debug(`App '${app.manifest.name}' already exists, skipping recreation`, this.importConfig.context); continue; } @@ -346,7 +346,7 @@ export default class ImportMarketplaceApps { log.success(`Completed processing ${privateApps.length} private apps`, this.importConfig.context); } else { - log.info('Skipping private apps creation on Developer Hub...', this.importConfig.context); + log.info('Skipping private apps creation on Developer Hub…', this.importConfig.context); } this.appOriginalName = undefined; @@ -370,12 +370,12 @@ export default class ImportMarketplaceApps { .installation(app.uid) .fetch() .catch((): void => { - log.debug(`App ${app.manifest?.name} not found in developer hub`, this.importConfig.context); + log.debug(`App ${app.manifest?.name} not found in Developer Hub.`, this.importConfig.context); return undefined; }); // NOTE Keeping this to avoid Unhandled exception const exists = !isEmpty(installation); - log.debug(`Private app ${app.manifest?.name} exists in developer hub: ${exists}`, this.importConfig.context); + log.debug(`Private app ${app.manifest?.name} exists in Developer Hub: ${exists}`, this.importConfig.context); return exists; } @@ -398,7 +398,7 @@ export default class ImportMarketplaceApps { ); if (updateUiLocation && !isEmpty(app?.ui_location?.locations)) { - log.debug(`Updating UI locations for app: ${app.name}`, this.importConfig.context); + log.debug(`Updating UI locations for app: ${app.name}...`, this.importConfig.context); app.ui_location.locations = this.updateManifestUILocations(app?.ui_location?.locations, appSuffix); } @@ -505,7 +505,7 @@ export default class ImportMarketplaceApps { */ async appCreationCallback(app: any, response: any, appSuffix: number): Promise { const { statusText, message } = response || {}; - log.debug(`Processing app creation callback for: ${app.name} (suffix: ${appSuffix})`, this.importConfig.context); + log.debug(`Processing app creation callback for: ${app.name} (suffix: ${appSuffix})...`, this.importConfig.context); if (message) { log.debug(`App creation response has message: ${message}`, this.importConfig.context); @@ -530,10 +530,10 @@ export default class ImportMarketplaceApps { ), ) ) { - log.debug('User chose to proceed despite error', this.importConfig.context); + log.debug('User chose to proceed despite error.', this.importConfig.context); Promise.resolve(); } else { - log.debug('User chose to exit due to error', this.importConfig.context); + log.debug('User chose to exit due to error.', this.importConfig.context); process.exit(); } } @@ -566,7 +566,7 @@ export default class ImportMarketplaceApps { log.debug(`App not found in current stack, installing new app: ${app.manifest?.name}`, this.importConfig.context); // NOTE install new app if (app.manifest.visibility === 'private' && !this.importConfig.canCreatePrivateApp) { - log.info(`Skipping the installation of the private app ${app.manifest.name}...`, this.importConfig.context); + log.info(`Skipping installation of the private app: ${app.manifest.name}…`, this.importConfig.context); return Promise.resolve(); } @@ -585,7 +585,7 @@ export default class ImportMarketplaceApps { log.success(`${appName} app installed successfully.!`, this.importConfig.context); log.debug(`Installation UID: ${installation.installation_uid}`, this.importConfig.context); - log.debug(`Making redirect URL call for app: ${appName}`, this.importConfig.context); + log.debug(`Making redirect URL call for: ${appName}`, this.importConfig.context); await makeRedirectUrlCall(installation, appName, this.importConfig); this.installationUidMapping[app.uid] = installation.installation_uid; @@ -593,13 +593,13 @@ export default class ImportMarketplaceApps { updateParam = { manifest: app.manifest, ...installation, configuration, server_configuration }; } else if (installation.message) { log.info(formatError(installation.message), this.importConfig.context); - log.debug(`Installation failed for app: ${app.manifest?.name}`, this.importConfig.context); + log.debug(`Installation failed for: ${app.manifest?.name}`, this.importConfig.context); await confirmToCloseProcess(installation, this.importConfig); } } else if (!isEmpty(configuration) || !isEmpty(server_configuration)) { const appName = app.manifest.name || app.manifest.uid; - log.info(`${appName} is already installed`, this.importConfig.context); - log.debug(`Handling existing app configuration for: ${appName}`, this.importConfig.context); + log.info(`${appName} is already installed.`, this.importConfig.context); + log.debug(`Handling existing configuration for: ${appName}`, this.importConfig.context); updateParam = await ifAppAlreadyExist(app, currentStackApp, this.importConfig); } else { log.debug( @@ -621,7 +621,7 @@ export default class ImportMarketplaceApps { log.debug(`Updating app configuration for: ${app.manifest?.name}`, this.importConfig.context); await this.updateAppsConfig(updateParam); } else { - log.debug(`No configuration update needed for: ${app.manifest?.name}`, this.importConfig.context); + log.debug(`No update needed for configuration: ${app.manifest?.name}`, this.importConfig.context); } } @@ -634,10 +634,10 @@ export default class ImportMarketplaceApps { async updateAppsConfig(app: Installation): Promise { const { installation_uid, configuration, server_configuration } = app; const appName = app.manifest.name || app.manifest.uid; - log.debug(`Updating app configuration for: ${appName} (${installation_uid})`, this.importConfig.context); + log.debug(`Updating configuration for: ${appName} (${installation_uid})`, this.importConfig.context); if (!isEmpty(configuration)) { - log.debug(`Updating app configuration for: ${appName}`, this.importConfig.context); + log.debug(`Updating configuration for: ${appName}`, this.importConfig.context); await this.appSdk .marketplace(this.importConfig.org_uid) .installation(installation_uid) @@ -648,18 +648,18 @@ export default class ImportMarketplaceApps { log.info(formatError(data.message), this.importConfig.context); } else { log.success(`${appName} app config updated successfully.!`, this.importConfig.context); - log.debug(`Configuration update successful for: ${appName}`, this.importConfig.context); + log.debug(`Configuration update was successful for: ${appName}`, this.importConfig.context); } }) .catch((error: any) => { trace(error, 'error', true); log.error(formatError(error), this.importConfig.context); - log.debug(`Configuration update failed for: ${appName}`, this.importConfig.context); + log.debug(`Configuration update failed for: ${appName}.`, this.importConfig.context); }); } if (!isEmpty(server_configuration)) { - log.debug(`Updating server configuration for: ${appName}`, this.importConfig.context); + log.debug(`Updating server configuration for: ${appName}...`, this.importConfig.context); await this.appSdk .marketplace(this.importConfig.org_uid) .installation(installation_uid) @@ -670,13 +670,13 @@ export default class ImportMarketplaceApps { log.error(formatError(data.message), this.importConfig.context); } else { log.success(`${appName} app server config updated successfully.!`, this.importConfig.context); - log.debug(`Server configuration update successful for: ${appName}`, this.importConfig.context); + log.debug(`Server configuration update was successful for: ${appName}.`, this.importConfig.context); } }) .catch((error: any) => { trace(error, 'error', true); log.error(formatError(error), this.importConfig.context); - log.debug(`Server configuration update failed for: ${appName}`, this.importConfig.context); + log.debug(`Server configuration update failed for: ${appName}.`, this.importConfig.context); }); } } diff --git a/packages/contentstack-import/src/import/modules/personalize.ts b/packages/contentstack-import/src/import/modules/personalize.ts index 01295376a9..d1ba7e0646 100644 --- a/packages/contentstack-import/src/import/modules/personalize.ts +++ b/packages/contentstack-import/src/import/modules/personalize.ts @@ -27,17 +27,17 @@ export default class ImportPersonalize { if (this.config.management_token) { log.debug('Management token detected, skipping personalize import', this.config.context); - log.info('Skipping Personalize project import when using management token', this.config.context); + log.info('Skipping Personalize project import when using management token...', this.config.context); return; } - log.debug('Starting personalize project import', this.config.context); + log.debug('Starting Personalize project import...', this.config.context); log.debug(`Base URL: ${this.personalizeConfig.baseURL[this.config.region.name]}`, this.config.context); await new Import.Project(this.config).import(); - log.debug('Personalize project import completed', this.config.context); + log.debug('Personalize project import completed.', this.config.context); if (this.personalizeConfig.importData) { - log.debug('Personalize data import is enabled', this.config.context); + log.debug('Personalize data import is enabled.', this.config.context); const moduleMapper = { events: Import.Events, @@ -49,12 +49,12 @@ export default class ImportPersonalize { const order: (keyof typeof moduleMapper)[] = this.personalizeConfig .importOrder as (keyof typeof moduleMapper)[]; - log.debug(`Processing ${order.length} personalize modules in order: ${order.join(', ')}`, this.config.context); + log.debug(`Processing ${order.length} Personalize modules in order: ${order.join(', ')}`, this.config.context); const moduleTypes = Object.keys(moduleMapper || {}).join(', '); log.debug(`Available module types: ${moduleTypes}`, this.config.context); for (const module of order) { - log.debug(`Starting import for personalize module: ${module}`, this.config.context); + log.debug(`Starting import for Personalize module: ${module}`, this.config.context); const Module = moduleMapper[module]; if (!Module) { @@ -69,12 +69,12 @@ export default class ImportPersonalize { await moduleInstance.import(); log.success(`Successfully imported personalize module: ${module}`, this.config.context); - log.debug(`Completed import for personalize module: ${module}`, this.config.context); + log.debug(`Completed import for Personalize module: ${module}`, this.config.context); } - log.debug('All personalize modules imported successfully', this.config.context); + log.debug('All Personalize modules imported successfully.', this.config.context); } else { - log.debug('Personalize data import is disabled', this.config.context); + log.debug('Personalize data import is disabled.', this.config.context); } log.success('Personalize import completed successfully', this.config.context); @@ -82,8 +82,8 @@ export default class ImportPersonalize { this.personalizeConfig.importData = false; // Stop personalize import if project creation fails handleAndLogError(error, { ...this.config.context }); if (!this.personalizeConfig.importData) { - log.debug('Personalize import data flag set to false due to error', this.config.context); - log.info('Skipping personalize migration...', this.config.context); + log.debug('Personalize import data flag set to false due to error.', this.config.context); + log.info('Skipping Personalize migration…', this.config.context); } } } diff --git a/packages/contentstack-import/src/import/modules/taxonomies.ts b/packages/contentstack-import/src/import/modules/taxonomies.ts index 58f7513ddf..3a0ad7596d 100644 --- a/packages/contentstack-import/src/import/modules/taxonomies.ts +++ b/packages/contentstack-import/src/import/modules/taxonomies.ts @@ -47,27 +47,27 @@ export default class ImportTaxonomies extends BaseClass { * @returns {Promise} Promise */ async start(): Promise { - log.debug('Checking for taxonomies folder existence', this.importConfig.context); + log.debug('Checking for taxonomy folder existence…', this.importConfig.context); //Step1 check folder exists or not if (fileHelper.fileExistsSync(this.taxonomiesFolderPath)) { - log.debug(`Found taxonomies folder: ${this.taxonomiesFolderPath}`, this.importConfig.context); + log.debug(`Found taxonomy folder at: ${this.taxonomiesFolderPath}`, this.importConfig.context); this.taxonomies = fsUtil.readFile(join(this.taxonomiesFolderPath, 'taxonomies.json'), true) as Record< string, unknown >; const taxonomyCount = Object.keys(this.taxonomies || {}).length; - log.debug(`Loaded ${taxonomyCount} taxonomy items from file`, this.importConfig.context); + log.debug(`Loaded ${taxonomyCount} taxonomy items from file.`, this.importConfig.context); } else { - log.info(`No Taxonomies Found! - '${this.taxonomiesFolderPath}'`, this.importConfig.context); + log.info(`No taxonomies found at: '${this.taxonomiesFolderPath}'`, this.importConfig.context); return; } //Step 2 create taxonomies & terms mapper directory - log.debug('Creating mapper directories', this.importConfig.context); + log.debug('Creating mapper directories...', this.importConfig.context); await fsUtil.makeDirectory(this.taxonomiesMapperDirPath); await fsUtil.makeDirectory(this.termsMapperDirPath); - log.debug('Created taxonomies and terms mapper directories', this.importConfig.context); + log.debug('Created taxonomies and terms mapper directories.', this.importConfig.context); // Step 3: Check if locale-based structure exists and scan taxonomies by locale log.debug('Checking for locale-based folder structure', this.importConfig.context); @@ -76,7 +76,7 @@ export default class ImportTaxonomies extends BaseClass { // Step 4 import taxonomies if (this.isLocaleBasedStructure) { log.debug('Detected locale-based folder structure for taxonomies', this.importConfig.context); - log.debug('Starting taxonomies import', this.importConfig.context); + log.debug('Starting taxonomies import...', this.importConfig.context); await this.importTaxonomiesByLocale(); } else { log.debug('Starting taxonomies import', this.importConfig.context); @@ -85,7 +85,7 @@ export default class ImportTaxonomies extends BaseClass { } //Step 5 create taxonomy & related terms success & failure file - log.debug('Creating success and failure files', this.importConfig.context); + log.debug('Creating success and failure files...', this.importConfig.context); this.createSuccessAndFailedFile(); log.success('Taxonomies imported successfully!', this.importConfig.context); @@ -164,7 +164,7 @@ export default class ImportTaxonomies extends BaseClass { if (error?.status === 409 && error?.statusText === 'Conflict') { log.info( - `Taxonomy '${taxonomyUID}' already exists${locale ? ` for locale: ${locale}` : ''}!`, + `Taxonomy '${taxonomyUID}' already exists ${locale ? ` for locale: ${locale}` : ''}!`, this.importConfig.context, ); this.createdTaxonomies[taxonomyUID] = apiData?.taxonomy; @@ -312,7 +312,7 @@ export default class ImportTaxonomies extends BaseClass { * @method createSuccessAndFailedFile */ createSuccessAndFailedFile() { - log.debug('Creating success and failed files for taxonomies and terms', this.importConfig.context); + log.debug('Creating success and failed files for taxonomies and terms...', this.importConfig.context); const createdTaxCount = Object.keys(this.createdTaxonomies)?.length; const failedTaxCount = Object.keys(this.failedTaxonomies)?.length; diff --git a/packages/contentstack-import/src/utils/content-type-helper.ts b/packages/contentstack-import/src/utils/content-type-helper.ts index b1fa5fd194..942ddc8c59 100644 --- a/packages/contentstack-import/src/utils/content-type-helper.ts +++ b/packages/contentstack-import/src/utils/content-type-helper.ts @@ -132,7 +132,7 @@ export const removeReferenceFields = async function ( } catch (error) { // Else warn and modify the schema object. isContentTypeError = true; - log.warn(`Content-type ${schema[i].reference_to[j]} does not exist. Removing the field from schema`); + log.warn(`Content type ${schema[i].reference_to[j]} does not exist. Removing the field from schema...`); } } @@ -209,7 +209,7 @@ export const updateFieldRules = function (contentType: any) { fieldDataTypeMap[field.uid] = field.data_type; } - log.debug(`Created field data type mapping for ${Object.keys(fieldDataTypeMap).length} fields`); + log.debug(`Created field data type mapping for ${Object.keys(fieldDataTypeMap).length} fields.`); const fieldRules = [...contentType.field_rules]; let len = fieldRules.length; diff --git a/packages/contentstack-import/src/utils/file-helper.ts b/packages/contentstack-import/src/utils/file-helper.ts index e5c613b90d..225f5c49b5 100644 --- a/packages/contentstack-import/src/utils/file-helper.ts +++ b/packages/contentstack-import/src/utils/file-helper.ts @@ -53,7 +53,7 @@ export const readLargeFile = function (filePath: string, opts?: any): Promise => { ); const pattern = /[*$%#<>{}!&?]/g; if (pattern.test(config.contentDir)) { - cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, { + cliux.print(`\nPlease enter a directory path without any special characters: (*,&,{,},[,],$,%,<,>,?,!)`, { color: 'yellow', }); config.contentDir = sanitizePath(await askContentDir()); @@ -137,7 +137,7 @@ const setupConfig = async (importCmdFlags: any): Promise => { // Add authentication details to config for context tracking config.authenticationMethod = authenticationMethod; - log.debug('Import configuration setup completed', { ...config }); + log.debug('Import configuration setup completed.', { ...config }); return config; }; diff --git a/packages/contentstack-import/src/utils/login-handler.ts b/packages/contentstack-import/src/utils/login-handler.ts index c8cfa499c6..859a4bf594 100644 --- a/packages/contentstack-import/src/utils/login-handler.ts +++ b/packages/contentstack-import/src/utils/login-handler.ts @@ -49,7 +49,7 @@ const login = async (config: ImportConfig): Promise => { if (errorstack_key) { const keyError = errorstack_key[0]; - log.error(`Invalid stack API token: ${keyError} Please enter valid stack API token.`); + log.error(`Invalid stack API token: ${keyError}. Please enter a valid stack API token.`); throw error; } diff --git a/packages/contentstack-import/src/utils/marketplace-app-helper.ts b/packages/contentstack-import/src/utils/marketplace-app-helper.ts index 0e4454287a..295b5e22dc 100644 --- a/packages/contentstack-import/src/utils/marketplace-app-helper.ts +++ b/packages/contentstack-import/src/utils/marketplace-app-helper.ts @@ -122,7 +122,7 @@ export const getConfirmationToCreateApps = async (privateApps: any, config: Impo log.info('User confirmed to create private apps'); return Promise.resolve(true); } else { - log.debug('User declined to create private apps (second prompt)'); + log.debug('User declined to create private apps (second prompt).'); return Promise.resolve(false); } } diff --git a/packages/contentstack-import/src/utils/taxonomies-helper.ts b/packages/contentstack-import/src/utils/taxonomies-helper.ts index f102cecf5d..e94aaf7154 100644 --- a/packages/contentstack-import/src/utils/taxonomies-helper.ts +++ b/packages/contentstack-import/src/utils/taxonomies-helper.ts @@ -12,7 +12,7 @@ import { ImportConfig } from '../types'; * @param {ImportConfig} importConfig */ export const lookUpTaxonomy = function (importConfig: ImportConfig, schema: any, taxonomies: Record) { - log.debug(`Starting taxonomy lookup for schema with ${Object.keys(schema).length} fields`); + log.debug(`Starting taxonomy lookup for schema with ${Object.keys(schema).length} fields.`); for (let i in schema) { if (schema[i].data_type === 'taxonomy') { diff --git a/packages/contentstack-migrate-rte/src/commands/cm/entries/migrate-html-rte.js b/packages/contentstack-migrate-rte/src/commands/cm/entries/migrate-html-rte.js index 5a04309a1b..c366b40c02 100644 --- a/packages/contentstack-migrate-rte/src/commands/cm/entries/migrate-html-rte.js +++ b/packages/contentstack-migrate-rte/src/commands/cm/entries/migrate-html-rte.js @@ -56,7 +56,7 @@ class JsonMigrationCommand extends Command { } } } catch (error) { - this.error(error.message, { exit: 2 }); + this.error(`Error: ${error.message}`, { exit: 2 }); } } } diff --git a/packages/contentstack-migrate-rte/src/lib/util/index.js b/packages/contentstack-migrate-rte/src/lib/util/index.js index fef9df0159..4f87bd03ce 100644 --- a/packages/contentstack-migrate-rte/src/lib/util/index.js +++ b/packages/contentstack-migrate-rte/src/lib/util/index.js @@ -270,7 +270,7 @@ async function updateSingleContentTypeEntries(stack, contentTypeUid, config) { if (config.locale && isArray(config.locale) && config.locale.length > 0) { const locales = config.locale; for (const locale of locales) { - console.log(`\nMigrating entries for "${contentTypeUid}" Content-type in "${locale}" locale`); + console.log(`\nMigrating entries for "${contentTypeUid}" content type in "${locale}" locale.`); await updateEntriesInBatch(contentType, config, 0, 0, locale); await delay(config.delay || 1000); } @@ -290,7 +290,7 @@ async function updateSingleContentTypeEntriesWithGlobalField(contentType, config if (config.locale && isArray(config.locale) && config.locale.length > 0) { const locales = config.locale; for (const locale of locales) { - console.log(`\nMigrating entries for ${contentType.uid} in locale ${locale}`); + console.log(`\nMigrating entries for ${contentType.uid} in locale ${locale}.`); await updateEntriesInBatch(contentType, config, 0, 0, locale); await delay(config.delay || 1000); } diff --git a/packages/contentstack-migration/examples/01-transform-contenttype.js b/packages/contentstack-migration/examples/01-transform-contenttype.js index ee95904248..abf6d8e024 100644 --- a/packages/contentstack-migration/examples/01-transform-contenttype.js +++ b/packages/contentstack-migration/examples/01-transform-contenttype.js @@ -109,7 +109,7 @@ module.exports = async ({migration, stackSDKInstance}) => { entries.push(entryObj) } } catch (error) { - console.log(error) + console.log('Error', error) } }, } diff --git a/packages/contentstack-migration/examples/02-publishing-entries.js b/packages/contentstack-migration/examples/02-publishing-entries.js index 2eaf54749f..e21313cff7 100644 --- a/packages/contentstack-migration/examples/02-publishing-entries.js +++ b/packages/contentstack-migration/examples/02-publishing-entries.js @@ -23,7 +23,7 @@ module.exports = async ({migration, stackSDKInstance}) => { entry.publish({publishDetails, locale: 'en-us'}) } } catch (error) { - console.log(error) + console.log('Error', error) } }, } diff --git a/packages/contentstack-migration/examples/06-update-environment.js b/packages/contentstack-migration/examples/06-update-environment.js index 59d364d0fb..a622e6a437 100644 --- a/packages/contentstack-migration/examples/06-update-environment.js +++ b/packages/contentstack-migration/examples/06-update-environment.js @@ -16,7 +16,7 @@ module.exports = async ({ migration, config }) => { fs.accessSync(directory, fs.constants.W_OK); return true; } catch (err) { - console.log(`Permission Denied! You do not have the necessary write access for this directory.`); + console.log(`Permission denied. You do not have the necessary write access for this directory.`); return false; } } @@ -33,7 +33,7 @@ module.exports = async ({ migration, config }) => { if (!source || !destination) { throw new Error(`The Source or Destination Directory Path are not valid`); } else { - console.log(`You have permission to write to directory`); + console.log(`You have permission to write to the directory.`); } } catch (err) { console.log( @@ -63,7 +63,7 @@ module.exports = async ({ migration, config }) => { if (sourceUid && destUid) { envMapper[sourceUid] = destUid; } else { - console.log(`No Mapper Provided for the environment ${sourceName} or ${destName}`); + console.log(`No mapper provided for environment ${sourceName} or ${destName}`); } } } catch (err) { @@ -145,7 +145,7 @@ module.exports = async ({ migration, config }) => { ); }); } else { - console.log(`No Entries Exist for Content-type ${ct} in loclae ${locale}`); + console.log(`No entries exist for content type ${ct} in locale ${locale}`); } } } diff --git a/packages/contentstack-migration/examples/rename-field/01-rename-field.js b/packages/contentstack-migration/examples/rename-field/01-rename-field.js index 57f8fda237..72f461e882 100644 --- a/packages/contentstack-migration/examples/rename-field/01-rename-field.js +++ b/packages/contentstack-migration/examples/rename-field/01-rename-field.js @@ -89,7 +89,7 @@ module.exports = ({ migration, stackSDKInstance }) => { await entry.update() } } catch (error) { - console.log(error) + console.log('Error', error) } }, } diff --git a/packages/contentstack-migration/examples/rename-field/02-publishing-entries.js b/packages/contentstack-migration/examples/rename-field/02-publishing-entries.js index f17c3640a6..cbbe29a11e 100644 --- a/packages/contentstack-migration/examples/rename-field/02-publishing-entries.js +++ b/packages/contentstack-migration/examples/rename-field/02-publishing-entries.js @@ -24,7 +24,7 @@ module.exports = async ({migration, stackSDKInstance}) => { entry.publish({publishDetails, locale: 'en-us'}) } } catch (error) { - console.log(error) + console.log('Error', error) } }, } diff --git a/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js b/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js index 586224e3e0..71a2f42d74 100644 --- a/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js +++ b/packages/contentstack-migration/examples/taxonomies/import-taxonomies.js @@ -68,7 +68,7 @@ module.exports = ({ migration, stackSDKInstance, managementAPIClient, config }) await stack .taxonomy() .import({ taxonomy: filePath }, queryParam) - .then(() => console.log(`Taxonomy ${taxonomyUID} migrated successfully!`)) + .then(() => console.log(`Taxonomy ${taxonomyUID} migrated successfully.`)) .catch((err) => { handleErrorMsg(err); }); @@ -147,6 +147,6 @@ module.exports = ({ migration, stackSDKInstance, managementAPIClient, config }) if (config?.['data-dir']) { migration.addTask(createTaxonomyTask()); } else { - console.error('Please provide config using --config data-dir:""'); + console.error('Provide configuration using --config data-dir:""'); } }; diff --git a/packages/contentstack-migration/src/modules/parser.js b/packages/contentstack-migration/src/modules/parser.js index 444adeeb22..8fbc763a96 100644 --- a/packages/contentstack-migration/src/modules/parser.js +++ b/packages/contentstack-migration/src/modules/parser.js @@ -72,7 +72,7 @@ class Parser { base.dispatch(callsite, null, { typeErrors }, 'typeError'); } } else { - console.log(error); + console.log('Error', error); // eslint-disable-next-line const [, filename, line] = error.stack.match(/\/([\/\w-_\.]+\.js):(\d*):(\d*)/); const callsite = { diff --git a/packages/contentstack-migration/src/utils/error-helper.js b/packages/contentstack-migration/src/utils/error-helper.js index 4858a1eed5..f1d3e8b9be 100644 --- a/packages/contentstack-migration/src/utils/error-helper.js +++ b/packages/contentstack-migration/src/utils/error-helper.js @@ -95,7 +95,7 @@ module.exports = (errors, filePath) => { } if (isEmpty(messages) && errors !== undefined && isEmpty(errorsByFile)) { logger.log('error', { errors: errors }); - console.log(chalk`{bold.red Migration unsuccessful}`); + console.log(chalk`{bold.red migration unsuccessful}`); } else { logger.log('error', { error: messages.join('\n') }); } diff --git a/packages/contentstack-migration/src/utils/modules.js b/packages/contentstack-migration/src/utils/modules.js index 6af8df0212..758c8313e1 100644 --- a/packages/contentstack-migration/src/utils/modules.js +++ b/packages/contentstack-migration/src/utils/modules.js @@ -12,7 +12,7 @@ function checkWritePermissionToDirectory(directory) { fs.accessSync(directory, fs.constants.W_OK); return true; } catch (err) { - console.log(`Permission Denied! You do not have the necessary write access for this directory.`); + console.log(`Permission denied. You do not have the necessary write access for this directory.`); return false; } } diff --git a/packages/contentstack-seed/src/seed/github/client.ts b/packages/contentstack-seed/src/seed/github/client.ts index 3484c2f4ab..2bd9a70133 100644 --- a/packages/contentstack-seed/src/seed/github/client.ts +++ b/packages/contentstack-seed/src/seed/github/client.ts @@ -111,7 +111,7 @@ export default class GitHubClient { const response: Record = await this.makeHeadApiCall(repo); return response.statusCode === 200; } catch (error) { - console.log(error); + console.log('Error', error); // do nothing } diff --git a/packages/contentstack-utilities/src/auth-handler.ts b/packages/contentstack-utilities/src/auth-handler.ts index a7c2746a2e..c7157fd33e 100644 --- a/packages/contentstack-utilities/src/auth-handler.ts +++ b/packages/contentstack-utilities/src/auth-handler.ts @@ -137,7 +137,7 @@ class AuthHandler { await this.createHTTPServer(); await this.openOAuthURL(); } catch (error) { - this.logger.error('OAuth login failed', error.message); + this.logger.error('OAuth login failed!', error.message); throw error; } } @@ -148,7 +148,7 @@ class AuthHandler { const queryObject = url.parse(req.url, true).query; if (!queryObject.code) { - cliux.error('Error occoured while login with OAuth, please login with command - csdx auth:login --oauth'); + cliux.error('Error occurred while logging in with OAuth!'); return sendErrorResponse(res); } @@ -158,7 +158,7 @@ class AuthHandler { await this.getAccessToken(queryObject.code as string); await this.setOAuthBaseURL(); - cliux.print('Access token fetched using auth code successfully.'); + cliux.print('Access token successfully fetched using auth code.'); cliux.print( `You can review the access permissions on the page - ${this.OAuthBaseURL}/#!/marketplace/authorized-apps`, ); @@ -166,7 +166,7 @@ class AuthHandler { sendSuccessResponse(res); stopServer(); } catch (error) { - cliux.error('Error occoured while login with OAuth, please login with command - csdx auth:login --oauth'); + cliux.error('Error occurred while logging in with OAuth!'); cliux.error(error); sendErrorResponse(res); stopServer(); @@ -340,8 +340,8 @@ class AuthHandler { throw error; } } else { - cliux.error('Invalid/Empty access token.'); - throw new Error('Invalid/Empty access token'); + cliux.error('Invalid or empty access token.'); + throw new Error('Invalid or empty access token.'); } } @@ -394,7 +394,7 @@ class AuthHandler { const oauthValidUpto = new Date(); oauthValidUpto.setTime(oauthDate.getTime() + 59 * 60 * 1000); if (force) { - cliux.print('Force refreshing the token'); + cliux.print('Forcing token refresh...'); return this.refreshToken(); } else { if (oauthValidUpto > now) { @@ -418,7 +418,7 @@ class AuthHandler { } } } else { - cliux.print('No OAuth set'); + cliux.print('No OAuth configuration set.'); this.unsetConfigData(); } } diff --git a/packages/contentstack-utilities/src/config-handler.ts b/packages/contentstack-utilities/src/config-handler.ts index e32c79a355..45f24f49b4 100644 --- a/packages/contentstack-utilities/src/config-handler.ts +++ b/packages/contentstack-utilities/src/config-handler.ts @@ -52,7 +52,7 @@ class Config { this.removeOldConfigStoreFile(); } } catch (error) { - console.log('No data to be imported from Old config file'); + console.log('No data to import from old configuration file.'); } this.set(OLD_CONFIG_BACKUP_FLAG, true); diff --git a/packages/contentstack-utilities/src/flag-deprecation-check.ts b/packages/contentstack-utilities/src/flag-deprecation-check.ts index 4fe3fdf9c4..ce034703af 100644 --- a/packages/contentstack-utilities/src/flag-deprecation-check.ts +++ b/packages/contentstack-utilities/src/flag-deprecation-check.ts @@ -21,19 +21,19 @@ export default function (deprecatedFlags = [], suggestions = [], customMessage?: }); if (isCommandHasDeprecationFlag) { - let depreactionMessage = ''; + let deprecationMessage = ''; if (customMessage) { - depreactionMessage = customMessage; + deprecationMessage = customMessage; } else { - depreactionMessage = `WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (${deprecatedFlags.join( + deprecationMessage = `WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (${deprecatedFlags.join( ', ', )}).`; if (suggestions.length > 0) { - depreactionMessage += ` We recommend you to use the updated flags (${suggestions.join(', ')}).`; + deprecationMessage += ` We recommend you to use the updated flags (${suggestions.join(', ')}).`; } } - cliux.print(depreactionMessage, { color: 'yellow' }); + cliux.print(deprecationMessage, { color: 'yellow' }); } return input; diff --git a/packages/contentstack-utilities/src/logger.ts b/packages/contentstack-utilities/src/logger.ts index a38ca510ac..24d21f52e2 100644 --- a/packages/contentstack-utilities/src/logger.ts +++ b/packages/contentstack-utilities/src/logger.ts @@ -29,7 +29,7 @@ export class LoggerService { try { stringifiedParam = JSON.stringify(info.obj); } catch (error) { - console.log('warning: failed to log the result'); + console.log('Warning: Failed to log the result'); } // parse message info.message = messageHandler.parse(info.message as string); diff --git a/packages/contentstack-utilities/src/message-handler.ts b/packages/contentstack-utilities/src/message-handler.ts index 92c37bfe02..bbeb78a096 100644 --- a/packages/contentstack-utilities/src/message-handler.ts +++ b/packages/contentstack-utilities/src/message-handler.ts @@ -23,7 +23,7 @@ class Messages { if (error.code === 'ENOENT') { this.messages = {}; } else { - throw new CLIError(error.message); + throw new CLIError(`Error: ${error.message}`); } } } diff --git a/packages/contentstack-utilities/test/unit/auth-handler.test.ts b/packages/contentstack-utilities/test/unit/auth-handler.test.ts index de7e37279c..295da6f037 100644 --- a/packages/contentstack-utilities/test/unit/auth-handler.test.ts +++ b/packages/contentstack-utilities/test/unit/auth-handler.test.ts @@ -360,7 +360,7 @@ describe('Auth Handler', () => { throw new Error('Expected getUserDetails to throw'); // ensure failure if no error is thrown } catch (error) { expect(error).to.be.instanceOf(Error); - expect(error.message).to.equal('Invalid/Empty access token'); + expect(error.message).to.equal('Invalid or empty access token.'); } }); }); @@ -503,7 +503,7 @@ describe('Auth Handler', () => { await authHandler.compareOAuthExpiry(); } catch (error) { expect(error).to.be.undefined; - expect(cliuxPrintStub.calledOnceWithExactly('Force refreshing the token')).to.be.true; + expect(cliuxPrintStub.calledOnceWithExactly('Forcing token refresh...')).to.be.true; expect(refreshTokenStub.calledOnce).to.be.true; expect(unsetConfigDataStub.called).to.be.false; } diff --git a/packages/contentstack-variants/src/export/attributes.ts b/packages/contentstack-variants/src/export/attributes.ts index cd2124efb0..3a15e46cbe 100644 --- a/packages/contentstack-variants/src/export/attributes.ts +++ b/packages/contentstack-variants/src/export/attributes.ts @@ -47,7 +47,7 @@ export default class ExportAttributes extends PersonalizationAdapter { await fsUtil.makeDirectory(this.eventsFolderPath); log.debug('Events directory created successfully', this.exportConfig.context); - log.debug('Fetching events from personalization API...', this.exportConfig.context); + log.debug('Fetching events from Personalize API...', this.exportConfig.context); this.events = (await this.getEvents()) as EventStruct[]; log.debug(`Fetched ${this.events?.length || 0} events`, this.exportConfig.context); if (!this.events?.length) { log.debug('No events found, completing export', this.exportConfig.context); - log.info('No Events found with the given project!', this.exportConfig.context); + log.info('No events found for the given project.', this.exportConfig.context); return; } else { log.debug(`Processing ${this.events.length} events`, this.exportConfig.context); diff --git a/packages/contentstack-variants/src/export/experiences.ts b/packages/contentstack-variants/src/export/experiences.ts index 1eff955fd8..37b82a4bb5 100644 --- a/packages/contentstack-variants/src/export/experiences.ts +++ b/packages/contentstack-variants/src/export/experiences.ts @@ -55,7 +55,7 @@ export default class ExportExperiences extends PersonalizationAdapter if (!project || project?.length < 1) { log.debug('No projects found, disabling personalization', this.exportConfig.context); - log.info(`No Personalize Project connected with the given stack`, this.exportConfig.context); + log.info(`No Personalize project connected with the given stack.`, this.exportConfig.context); this.exportConfig.personalizationEnabled = false; return; } - log.debug(`Found ${project.length} projects, enabling personalization`, this.exportConfig.context); + log.debug(`Found ${project.length} projects`, this.exportConfig.context); this.exportConfig.personalizationEnabled = true; this.exportConfig.project_id = project[0]?.uid; log.debug(`Set project ID: ${project[0]?.uid}`, this.exportConfig.context); @@ -62,7 +62,7 @@ export default class ExportProjects extends PersonalizationAdapter } catch (error) { if (error !== 'Forbidden') { log.debug(`Error occurred during projects export: ${error}`, this.exportConfig.context); - log.error('Failed to export projects!', this.exportConfig.context); + log.error('Failed to export projects.', this.exportConfig.context); } else { log.debug('Projects export forbidden, likely due to permissions', this.exportConfig.context); } diff --git a/packages/contentstack-variants/src/import/audiences.ts b/packages/contentstack-variants/src/import/audiences.ts index aee1ebe69b..6be4f4d66e 100644 --- a/packages/contentstack-variants/src/import/audiences.ts +++ b/packages/contentstack-variants/src/import/audiences.ts @@ -65,7 +65,7 @@ export default class Audiences extends PersonalizationAdapter { log.info(`Found ${audiences.length} audiences to import`, this.config.context); const attributesUid = (fsUtil.readFile(this.attributesMapperPath, true) as Record) || {}; - log.debug(`Loaded ${Object.keys(attributesUid).length} attribute mappings for audience processing`, this.config.context); + log.debug(`Loaded ${Object.keys(attributesUid).length} attribute mappings`, this.config.context); for (const audience of audiences) { let { name, definition, description, uid } = audience; diff --git a/packages/contentstack-variants/src/import/events.ts b/packages/contentstack-variants/src/import/events.ts index 795838f791..f8e9472115 100644 --- a/packages/contentstack-variants/src/import/events.ts +++ b/packages/contentstack-variants/src/import/events.ts @@ -58,7 +58,7 @@ export default class Events extends PersonalizationAdapter { for (const event of events) { const { key, description, uid } = event; - log.debug(`Processing event: ${key} (${uid})`, this.config.context); + log.debug(`Processing event: ${key} (${uid})...`, this.config.context); try { log.debug(`Creating event: ${key}`, this.config.context); diff --git a/packages/contentstack-variants/src/import/experiences.ts b/packages/contentstack-variants/src/import/experiences.ts index 29c4db03da..3077b6f436 100644 --- a/packages/contentstack-variants/src/import/experiences.ts +++ b/packages/contentstack-variants/src/import/experiences.ts @@ -241,10 +241,10 @@ export default class Experiences extends PersonalizationAdapter { if (PAUSE) { if (latestVersionUsed) { - log.debug(`Creating new PAUSE version for: ${experience.uid}`, this.config.context); + log.debug(`Creating new PAUSED version for: ${experience.uid}`, this.config.context); await this.createExperienceVersion(experience.uid, PAUSE); } else { - log.debug(`Updating experience version to PAUSE for: ${experience.uid}`, this.config.context); + log.debug(`Updating experience version to PAUSED for: ${experience.uid}`, this.config.context); await this.updateExperienceVersion(experience.uid, experience.latestVersion, PAUSE); } } @@ -271,7 +271,7 @@ export default class Experiences extends PersonalizationAdapter { this.cmsVariantGroups[expUid] = expRes._cms?.variantGroup ?? {}; return expUid; // Return the expUid for filtering later } else { - log.debug(`Variants/variant group not ready for experience: ${expUid}`, this.config.context); + log.debug(`Variants or variant group not ready for experience: ${expUid}`, this.config.context); } }); @@ -288,7 +288,7 @@ export default class Experiences extends PersonalizationAdapter { ); return this.validateVariantGroupAndVariantsCreated(retryCount); } else { - log.error('Personalize job failed to create variants and variant groups', this.config.context); + log.error('Personalize job failed to create variants and variant groups.', this.config.context); log.error(`Failed experiences: ${this.pendingVariantAndVariantGrpForExperience.join(', ')}`, this.config.context); fsUtil.writeFile(this.failedCmsExpPath, this.pendingVariantAndVariantGrpForExperience); return false; @@ -310,7 +310,7 @@ export default class Experiences extends PersonalizationAdapter { // Read the created content types from the file this.createdCTs = fsUtil.readFile(this.cTsSuccessPath, true) as any; if (!this.createdCTs) { - log.debug('No Content types created, skipping following process', this.config.context); + log.warn('No content types created.', this.config.context); return; } diff --git a/packages/contentstack-variants/src/import/project.ts b/packages/contentstack-variants/src/import/project.ts index 5eb8811504..ae7a79d283 100644 --- a/packages/contentstack-variants/src/import/project.ts +++ b/packages/contentstack-variants/src/import/project.ts @@ -67,7 +67,7 @@ export default class Project extends PersonalizationAdapter { error.includes('personalization.PROJECTS.DUPLICATE_NAME') || error.includes('personalize.PROJECTS.DUPLICATE_NAME') ) { - log.warn(`Project name already exists, generating new name`, this.config.context); + log.warn(`Project name already exists, generating new name.`, this.config.context); const projectName = await askProjectName('Copy Of ' + (newName || project.name)); return await createProject(projectName); } diff --git a/packages/contentstack-variants/src/import/variant-entries.ts b/packages/contentstack-variants/src/import/variant-entries.ts index 8599921318..c4e474827c 100644 --- a/packages/contentstack-variants/src/import/variant-entries.ts +++ b/packages/contentstack-variants/src/import/variant-entries.ts @@ -85,7 +85,7 @@ export default class VariantEntries extends VariantAdapter 0) { log.debug(`Processing ${variantEntry.publish_details.length} publish details`, this.config.context); } else { - log.debug('No publish details found for variant entry', this.config.context); + log.debug('No publish details found for variant entry.', this.config.context); } if (variantEntry.publish_details && variantEntry.publish_details?.length > 0) { diff --git a/packages/contentstack-variants/src/utils/personalization-api-adapter.ts b/packages/contentstack-variants/src/utils/personalization-api-adapter.ts index ffe5814463..384ef23427 100644 --- a/packages/contentstack-variants/src/utils/personalization-api-adapter.ts +++ b/packages/contentstack-variants/src/utils/personalization-api-adapter.ts @@ -32,7 +32,7 @@ export class PersonalizationAdapter extends AdapterHelper impl constructor(options: APIConfig) { super(options); - log.debug('PersonalizationAdapter initialized', this.exportConfig?.context); + log.debug('Personalization adapter initialized.', this.exportConfig?.context); } async init(): Promise { @@ -42,21 +42,21 @@ export class PersonalizationAdapter extends AdapterHelper impl log.debug(`Authentication type: ${authenticationHandler.isOauthEnabled ? 'OAuth' : 'Token'}`, this.exportConfig?.context ); if (authenticationHandler.isOauthEnabled) { - log.debug('Setting OAuth authorization header', this.exportConfig?.context ); + log.debug('Setting OAuth authorization header...', this.exportConfig?.context ); this.apiClient.headers({ authorization: token }); if (this.adapterConfig.cmaConfig) { - log.debug('Setting OAuth authorization header for CMA client', this.exportConfig?.context ); + log.debug('Setting OAuth authorization header for CMA client...', this.exportConfig?.context ); this.cmaAPIClient?.headers({ authorization: token }); } } else { - log.debug('Setting authtoken header', this.exportConfig?.context ); + log.debug('Setting authtoken header...', this.exportConfig?.context ); this.apiClient.headers({ authtoken: token }); if (this.adapterConfig.cmaConfig) { - log.debug('Setting authtoken header for CMA client', this.exportConfig?.context ); + log.debug('Setting authtoken header for CMA client...', this.exportConfig?.context ); this.cmaAPIClient?.headers({ authtoken: token }); } } - log.debug('Personalization adapter initialization completed', this.exportConfig?.context ); + log.debug('Personalization adapter initialization completed.', this.exportConfig?.context ); } async projects(options: GetProjectsParams): Promise { @@ -106,7 +106,7 @@ export class PersonalizationAdapter extends AdapterHelper impl } async getExperiences(): Promise { - log.debug('Fetching experiences from personalization API', this.exportConfig?.context ); + log.debug('Fetching experiences from Personalize API...', this.exportConfig?.context ); const getExperiencesEndPoint = `/experiences`; const data = await this.apiClient.get(getExperiencesEndPoint); const result = (await this.handleVariantAPIRes(data)) as ExperienceStruct[]; @@ -179,7 +179,7 @@ export class PersonalizationAdapter extends AdapterHelper impl log.debug(`Variant group fetched successfully for experience: ${input?.experienceUid}`, this.exportConfig?.context ); return result; } else { - log.debug('CMA API client not available for variant group fetch', this.exportConfig?.context ); + log.debug('CMA API client not available for variant group fetch.', this.exportConfig?.context ); } } @@ -192,12 +192,12 @@ export class PersonalizationAdapter extends AdapterHelper impl log.debug(`Variant group updated successfully: ${input?.uid}`, this.exportConfig?.context ); return result; } else { - log.debug('CMA API client not available for variant group update', this.exportConfig?.context ); + log.debug('CMA API client not available for variant group update.', this.exportConfig?.context ); } } async getEvents(): Promise { - log.debug('Fetching events from personalization API', this.exportConfig?.context ); + log.debug('Fetching events from Personalize API...', this.exportConfig?.context ); const data = await this.apiClient.get('/events'); const result = (await this.handleVariantAPIRes(data)) as EventStruct[]; log.debug(`Fetched ${result?.length || 0} events`, this.exportConfig?.context ); @@ -213,7 +213,7 @@ export class PersonalizationAdapter extends AdapterHelper impl } async getAudiences(): Promise { - log.debug('Fetching audiences from personalization API', this.exportConfig?.context ); + log.debug('Fetching audiences from Personalize API...', this.exportConfig?.context ); const data = await this.apiClient.get('/audiences'); const result = (await this.handleVariantAPIRes(data)) as AudienceStruct[]; log.debug(`Fetched ${result?.length || 0} audiences`, this.exportConfig?.context ); @@ -221,7 +221,7 @@ export class PersonalizationAdapter extends AdapterHelper impl } async getAttributes(): Promise { - log.debug('Fetching attributes from personalization API', this.exportConfig?.context ); + log.debug('Fetching attributes from Personalize API...', this.exportConfig?.context ); const data = await this.apiClient.get('/attributes'); const result = (await this.handleVariantAPIRes(data)) as AttributeStruct[]; log.info(`Fetched ${result?.length || 0} attributes`, this.exportConfig?.context ); @@ -302,7 +302,7 @@ export class PersonalizationAdapter extends AdapterHelper impl log.debug(`API response status: ${status}`, this.exportConfig?.context ); if (status >= 200 && status < 300) { - log.debug('API request successful', this.exportConfig?.context ); + log.debug('API request successful.', this.exportConfig?.context ); return data; } diff --git a/packages/contentstack-variants/src/utils/variant-api-adapter.ts b/packages/contentstack-variants/src/utils/variant-api-adapter.ts index 79a478f8c9..a576fcfcf3 100644 --- a/packages/contentstack-variants/src/utils/variant-api-adapter.ts +++ b/packages/contentstack-variants/src/utils/variant-api-adapter.ts @@ -51,10 +51,10 @@ export class VariantHttpClient extends AdapterHelper implement this.exportConfig?.context, ); if (authenticationHandler.isOauthEnabled) { - log.debug('Setting OAuth authorization header', this.exportConfig?.context); + log.debug('Setting OAuth authorization header...', this.exportConfig?.context); this.apiClient.headers({ authorization: token }); } else { - log.debug('Setting authtoken header', this.exportConfig?.context); + log.debug('Setting authtoken header...', this.exportConfig?.context); this.apiClient.headers({ authtoken: token }); } } @@ -107,7 +107,7 @@ export class VariantHttpClient extends AdapterHelper implement ); if (variantConfig.serveMockData && callback) { - log.debug('Using mock data for variant entries', this.exportConfig?.context); + log.debug('Using mock data for variant entries...', this.exportConfig?.context); let data = [] as Record[]; if (existsSync(variantConfig.mockDataPath)) { @@ -172,10 +172,10 @@ export class VariantHttpClient extends AdapterHelper implement } if (callback) { - log.debug('Executing callback with variant entries', this.exportConfig?.context); + log.debug('Executing callback with variant entries...', this.exportConfig?.context); callback(response.entries); } else { - log.debug('Adding variant entries to collection', this.exportConfig?.context); + log.debug('Adding variant entries to collection...', this.exportConfig?.context); entries = entries.concat(response.entries); } @@ -198,7 +198,7 @@ export class VariantHttpClient extends AdapterHelper implement } if (returnResult) { - log.debug('Returning variant entries result', this.exportConfig?.context ); + log.debug('Returning variant entries result...', this.exportConfig?.context ); return { entries }; } } @@ -327,7 +327,7 @@ export class VariantHttpClient extends AdapterHelper implement log.debug(`API response status: ${status}`, this.exportConfig?.context); if (status >= 200 && status < 300) { - log.debug('API request successful', this.exportConfig?.context); + log.debug('API request successful.', this.exportConfig?.context); return data; } @@ -401,17 +401,17 @@ export class VariantAdapter { log.debug('Initializing VariantAdapter...', this.exportConfig?.context); if (config.httpClient) { - log.debug('Using HTTP client variant instance', this.exportConfig?.context); + log.debug('Using HTTP client variant instance.', this.exportConfig?.context); const { httpClient, Adapter, ...restConfig } = config; this.variantInstance = new Adapter(restConfig, options); } else { - log.debug('Using SDK variant instance', this.exportConfig?.context); + log.debug('Using SDK variant instance.', this.exportConfig?.context); const { Adapter, ...restConfig } = config; this.variantInstance = new Adapter(restConfig); } this.messages = messages; - log.debug('VariantAdapter initialized successfully', this.exportConfig?.context); + log.debug('VariantAdapter initialized successfully.', this.exportConfig?.context); } } diff --git a/packages/contentstack/src/hooks/prerun/auth-guard.ts b/packages/contentstack/src/hooks/prerun/auth-guard.ts index 6eef92a0b6..94898da40f 100644 --- a/packages/contentstack/src/hooks/prerun/auth-guard.ts +++ b/packages/contentstack/src/hooks/prerun/auth-guard.ts @@ -15,27 +15,27 @@ export default async function (opts): Promise { this.exit(); return; } - cliux.print(`\n Currently using ${region.name} region \n`, { color: 'grey' }); + cliux.print(`Currently using region: ${region.name}`, { color: 'grey' }); } // Auth guard if (protectedCommands[opts.Command.id]) { if (!isAuthenticated()) { - newLogger.error('No auth token found for command', opts.Command.id); - cliux.error('Please login to execute the command'); + newLogger.error('No auth token found for command.', opts.Command.id); + cliux.error('Please log in to execute the command'); this.exit(); } const client = await managementSDKClient({host: region.cma}) try { const result = await client.getUser(); if (!result) { - newLogger.error('error in auth validation'); - cliux.error('Please login to execute the command'); + newLogger.error('Error in auth validation'); + cliux.error('Please log in to execute the command'); this.exit(); } - newLogger.debug('logged in user', result.data); + newLogger.debug('Logged-in user', result.data); } catch (error) { - newLogger.error('error in auth validation', error); - cliux.error('Please login to execute the command'); + newLogger.error('Error in auth validation', error); + cliux.error('Please log in to execute the command'); process.exit(); } }