Skip to content

Commit

Permalink
Merge pull request #1447 from contentstack/staging
Browse files Browse the repository at this point in the history
DX | 03-07-2024 | Release
  • Loading branch information
cs-raj authored Jul 4, 2024
2 parents a430b18 + c3f16b6 commit f821533
Show file tree
Hide file tree
Showing 71 changed files with 1,464 additions and 1,212 deletions.
606 changes: 316 additions & 290 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.6.2 darwin-arm64 node-v21.6.2
@contentstack/cli-audit/1.6.3 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -267,7 +267,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/index.ts)_

## `csdx plugins:add PLUGIN`

Expand All @@ -292,7 +292,7 @@ GLOBAL FLAGS
DESCRIPTION
Installs a plugin into csdx.
Uses bundled npm executable to install plugins into /Users/raj.pandey/.local/share/@contentstack/cli-audit
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Expand Down Expand Up @@ -341,7 +341,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand All @@ -366,7 +366,7 @@ GLOBAL FLAGS
DESCRIPTION
Installs a plugin into csdx.
Uses bundled npm executable to install plugins into /Users/raj.pandey/.local/share/@contentstack/cli-audit
Uses npm to install plugins.
Installation of a user-installed plugin will override a core plugin.
Expand All @@ -390,7 +390,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/install.ts)_

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -420,7 +420,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/link.ts)_

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -461,7 +461,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -489,7 +489,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/uninstall.ts)_

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -533,5 +533,5 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/update.ts)_
<!-- commandsstop -->
4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.6.2",
"version": "1.6.3",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -19,7 +19,7 @@
],
"dependencies": {
"@contentstack/cli-command": "~1.2.18",
"@contentstack/cli-utilities": "~1.6.2",
"@contentstack/cli-utilities": "~1.6.3",
"@oclif/plugin-help": "^5",
"@oclif/plugin-plugins": "^5.0.0",
"chalk": "^4.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-audit/src/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const auditFixMsg = {
EMPTY_FIX_MSG: 'Successfully removed the empty field/block found at {path} from the schema.',
AUDIT_FIX_CMD_DESCRIPTION: 'Perform audits and fix possible errors in the exported Contentstack data.',
WF_FIX_MSG: 'Successfully removed the workflow {uid} named {name}.',
ENTRY_MANDATORY_FIELD_FIX: `Removing the publish details from entry uid '{uid}' from locale '{locale}'`,
ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in select field of uid '{uid}'`
ENTRY_MANDATORY_FIELD_FIX: `Removing the publish details from the entry with UID '{uid}' in Locale '{locale}'...`,
ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in the select field of entry UID '{uid}'...`
};

const messages: typeof errors &
Expand Down
10 changes: 2 additions & 8 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default class Entries {
protected missingMandatoryFields: Record<string, any> = {};
public entryMetaData: Record<string, any>[] = [];
public moduleName: keyof typeof auditConfig.moduleConfig = 'entries';
public isEntryWithoutTitleField: boolean = false;

constructor({ log, fix, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam) {
this.log = log;
Expand Down Expand Up @@ -128,7 +127,7 @@ export default class Entries {
this.lookForReference([{ locale: code, uid, name: title }], ctSchema, this.entries[entryUid]);

const fields = this.missingMandatoryFields[uid];
const isPublished = entry.publish_details.length > 0;
const isPublished = entry.publish_details?.length > 0;
if ((this.fix && fields.length && isPublished) || (!this.fix && fields)) {
const fixStatus = this.fix ? 'Fixed' : '';
fields?.forEach((field: { isPublished: boolean; fixStatus?: string }) => {
Expand Down Expand Up @@ -1262,15 +1261,13 @@ export default class Entries {
let { title } = entries[entryUid];

if (entries[entryUid].hasOwnProperty('title') && !title) {
this.isEntryWithoutTitleField = true;
this.log(
`The 'title' field in Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' is empty.`,
`error`,
);
} else if (!title) {
this.isEntryWithoutTitleField = true;
this.log(
`Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' does not have a 'title' field.`,
`The 'title' field in Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' is empty.`,
`error`,
);
}
Expand All @@ -1279,8 +1276,5 @@ export default class Entries {
}
}
}
if (this.isEntryWithoutTitleField) {
// throw Error(`Entries found with missing 'title' field! Please make the data corrections and re-run the audit.`);
}
}
}
4 changes: 2 additions & 2 deletions packages/contentstack-audit/src/modules/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default class Extensions {

if (ctNotPresent?.length && ext.scope) {
ext.content_types = ctNotPresent;
ctNotPresent.forEach((ct) => this.missingCts.add(ct));
this.missingCtInExtensions.push(cloneDeep(ext));
ctNotPresent.forEach((ct) => this.missingCts?.add(ct));
this.missingCtInExtensions?.push(cloneDeep(ext));
}

this.log(
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-auth/1.3.18 darwin-arm64 node-v21.6.2
@contentstack/cli-auth/1.3.19 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-auth",
"description": "Contentstack CLI plugin for authentication activities",
"version": "1.3.18",
"version": "1.3.19",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"dependencies": {
"@contentstack/cli-command": "~1.2.18",
"@contentstack/cli-utilities": "~1.6.2",
"@contentstack/cli-utilities": "~1.6.3",
"chalk": "^4.0.0",
"debug": "^4.1.1",
"inquirer": "8.2.4",
Expand Down
5 changes: 4 additions & 1 deletion packages/contentstack-auth/test/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"IS_TS": true,
"UNIT_EXECUTION_ORDER": [],
"INTEGRATION_EXECUTION_ORDER": []
"INTEGRATION_EXECUTION_ORDER": [],
"password": "testpassword",
"invalidPassowrd": "invalidpassword",
"validAPIKey": "adasdfagsf"
}
4 changes: 2 additions & 2 deletions packages/contentstack-auth/test/integration/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { expect, test } from '@oclif/test';
// @ts-ignore
import { Helper } from './helper';
// @ts-ignore
import { PRINT_LOGS } from './config.json';
import { PRINT_LOGS, encryptionKey } from './config.json';
import { cliux as CliUx, messageHandler, NodeCrypto } from '@contentstack/cli-utilities';

const messageFilePath = path.join(__dirname, '..', '..', '..', 'contentstack-utilities', 'messages/auth.json');
const crypto = new NodeCrypto({
typeIdentifier: '◈',
algorithm: 'aes-192-cbc',
encryptionKey: process.env.ENCRYPTION_KEY || '***REMOVED***'
encryptionKey: process.env.ENCRYPTION_KEY || encryptionKey
});
const username = process.env.ENCRYPTION_KEY ? crypto.decrypt(process.env.USERNAME) : process.env.USERNAME
const password = process.env.ENCRYPTION_KEY ? crypto.decrypt(process.env.PASSWORD) : process.env.PASSWORD
Expand Down
3 changes: 2 additions & 1 deletion packages/contentstack-auth/test/integration/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"PRINT_LOGS": false
"PRINT_LOGS": false,
"encryptionKey": "***REMOVED***"
}
5 changes: 3 additions & 2 deletions packages/contentstack-auth/test/unit/auth-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import * as sinon from 'sinon';
import { authHandler, interactive } from '../../src/utils';
import { CLIError, cliux } from '@contentstack/cli-utilities';
import { User } from '../../src/interfaces';
import * as config from '../config.json';

const user: User = { email: '***REMOVED***', authtoken: 'testtoken' };
const credentials = { email: '***REMOVED***', password: 'testpassword' };
const invalidCredentials = { email: '***REMOVED***', password: 'invalidpassword' };
const credentials = { email: '***REMOVED***', password: config.password };
const invalidCredentials = { email: '***REMOVED***', password: config.invalidPassowrd };
let TFAEnabled = false;
let TFAChannel = 'authy';
const TFATestToken = '24563992';
Expand Down
5 changes: 3 additions & 2 deletions packages/contentstack-auth/test/unit/commands/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import * as sinon from 'sinon';
import LoginCommand from '../../../src/commands/auth/login';
import { authHandler, interactive } from '../../../src/utils';
import { configHandler, cliux } from '@contentstack/cli-utilities';
import * as conf from '../../config.json';

const config = configHandler;

const user = { email: '***REMOVED***', authtoken: 'testtoken' };
const credentials = { email: '***REMOVED***', password: 'testpassword' };
const invalidCredentials = { email: '***REMOVED***', password: 'invalidpassword' };
const credentials = { email: '***REMOVED***', password: conf.password };
const invalidCredentials = { email: '***REMOVED***', password: conf.invalidPassowrd };
const TFATestToken = '24563992';

describe('Login Command', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TokensAddCommand from '../../../src/commands/auth/tokens/add';
import { tokenValidation } from '../../../src/utils';
import { stub, assert } from 'sinon';
import { config as dotenvConfig } from 'dotenv';
import * as conf from '../../config.json';

dotenvConfig();

Expand All @@ -24,7 +25,7 @@ describe('Tokens Add Command', () => {
let managementTokenValidationStub;
let environmentTokenValidationStub;
let printStub;
const validAPIKey = 'adasdfagsf';
const validAPIKey = conf.validAPIKey;
const validDeliveryToken = '***REMOVED***';
const validmanagementToken = 'cmajhsd98939482';
const validEnvironment = 'textenv';
Expand Down
3 changes: 2 additions & 1 deletion packages/contentstack-auth/test/unit/interactive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from 'chai';
import * as sinon from 'sinon';
import { interactive } from '../../src/utils';
import { cliux } from '@contentstack/cli-utilities';
import * as config from '../config.json'

describe('Interactive', () => {
let inquireStub;
Expand Down Expand Up @@ -31,7 +32,7 @@ describe('Interactive', () => {
});

it('ask password', async function () {
const password = 'testpassword';
const password = config.password
inquireStub.callsFake(function () {
return Promise.resolve(password);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-bootstrap/1.9.3 darwin-arm64 node-v21.6.2
@contentstack/cli-cm-bootstrap/1.9.3 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~1.7.5",
"@contentstack/cli-cm-seed": "~1.7.6",
"@contentstack/cli-command": "~1.2.18",
"@contentstack/cli-utilities": "~1.6.2",
"@contentstack/cli-utilities": "~1.6.3",
"inquirer": "8.2.4",
"mkdirp": "^1.0.4",
"tar": "^6.2.1 "
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-branches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-branches/1.0.26 darwin-arm64 node-v21.6.2
@contentstack/cli-cm-branches/1.1.1 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-branches/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@contentstack/cli-cm-branches",
"description": "Contentstack CLI plugin to do branches operations",
"version": "1.1.0",
"version": "1.1.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.2.18",
"@contentstack/cli-utilities": "~1.6.2",
"@contentstack/cli-utilities": "~1.6.3",
"@oclif/core": "^3.26.5",
"async": "^3.2.4",
"big-json": "^3.2.0",
Expand All @@ -25,7 +25,7 @@
"winston": "^3.7.2"
},
"devDependencies": {
"@contentstack/cli-auth": "~1.3.18",
"@contentstack/cli-auth": "~1.3.19",
"@contentstack/cli-config": "~1.6.4",
"@contentstack/cli-dev-dependencies": "~1.2.4",
"@oclif/plugin-help": "^5.1.19",
Expand Down
18 changes: 8 additions & 10 deletions packages/contentstack-branches/src/utils/create-merge-scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { assetFolderCreateScript } from './asset-folder-create-script';

type CreateMergeScriptsProps = {
uid: string;
entry_merge_strategy: string;
entry_merge_strategy?: string;
type?: string;
status?: string;
};

export function generateMergeScripts(mergeSummary, mergeJobUID) {
Expand Down Expand Up @@ -43,11 +44,8 @@ export function generateMergeScripts(mergeSummary, mergeJobUID) {
cliux.print(`Info: Entries of ${messageType} content types selected for the migration`, { color: 'blue' });
}
};

processContentType(
{ type: 'assets', uid: '', entry_merge_strategy: '' },
mergeStrategies['asset_create_folder'],
);

processContentType({ type: 'assets', uid: '', entry_merge_strategy: '' }, mergeStrategies['asset_create_folder']);
processContentTypes(mergeSummary.modified, 'Modified');
processContentTypes(mergeSummary.added, 'New');

Expand Down Expand Up @@ -92,13 +90,13 @@ export function createMergeScripts(contentType: CreateMergeScriptsProps, mergeJo
fs.mkdirSync(fullPath);
}
let filePath: string;
let milliSeconds = date.getMilliseconds().toString().padStart(3, '0')
let milliSeconds = date.getMilliseconds().toString().padStart(3, '0');
if (contentType.type === 'assets') {
filePath = `${fullPath}/${fileCreatedAt}${milliSeconds}_create_assets_folder.js`;
} else {
filePath = `${fullPath}/${fileCreatedAt}${milliSeconds}_${getContentTypeMergeStatus(contentType.entry_merge_strategy)}_${
contentType.uid
}.js`;
filePath = `${fullPath}/${fileCreatedAt}${milliSeconds}_${getContentTypeMergeStatus(
contentType.entry_merge_strategy,
)}_${contentType.uid}.js`;
}
fs.writeFileSync(filePath, content, 'utf-8');
}
Expand Down
Loading

0 comments on commit f821533

Please sign in to comment.