Skip to content

Commit b83f3a1

Browse files
authored
Merge pull request #2238 from contentstack/feat/dx-3728
Removed deprecated code from Migrate RTE plugin
2 parents 71bb9d6 + 6e7d478 commit b83f3a1

File tree

8 files changed

+36
-322
lines changed

8 files changed

+36
-322
lines changed

.talismanrc

Lines changed: 2 additions & 204 deletions
Large diffs are not rendered by default.

packages/contentstack-auth/src/commands/auth/tokens/add.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
9191

9292
if (!isDelivery && !isManagement && !Boolean(environment)) {
9393
log.debug('No token type specified, requesting user input', this.contextDetails);
94-
let tokenType = await askTokenType();
94+
const tokenType = await askTokenType();
9595
isDelivery = tokenType === 'delivery';
9696
isManagement = tokenType === 'management';
9797
log.debug(`Token type selected: ${tokenType}`, this.contextDetails);

packages/contentstack-migrate-rte/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-migrate-rte
1616
$ csdx COMMAND
1717
running command...
1818
$ csdx (--version)
19-
@contentstack/cli-cm-migrate-rte/1.6.2 darwin-arm64 node-v22.14.0
19+
@contentstack/cli-cm-migrate-rte/2.0.0-beta.1 darwin-arm64 node-v24.11.1
2020
$ csdx --help [COMMAND]
2121
USAGE
2222
$ csdx COMMAND

packages/contentstack-migrate-rte/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-migrate-rte",
33
"description": "Contentstack CLI plugin to migrate HTML RTE to JSON RTE",
4-
"version": "1.6.2",
4+
"version": "2.0.0-beta.1",
55
"author": "contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {
@@ -58,12 +58,8 @@
5858
"clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo"
5959
},
6060
"csdxConfig": {
61-
"expiredCommands": {
62-
"cm:migrate-rte": "csdx cm:entries:migrate-html-rte"
63-
},
6461
"shortCommandName": {
65-
"cm:entries:migrate-html-rte": "MGRTRTE",
66-
"cm:migrate-rte": "O-MGRTRTE"
62+
"cm:entries:migrate-html-rte": "MGRTRTE"
6763
}
6864
}
6965
}

packages/contentstack-migrate-rte/src/commands/cm/entries/migrate-html-rte.js

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { Command } = require('@contentstack/cli-command');
2-
const { printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
2+
const { flags } = require('@contentstack/cli-utilities');
33
const { isEmpty } = require('lodash');
44
const chalk = require('chalk');
55
let {
@@ -22,10 +22,10 @@ class JsonMigrationCommand extends Command {
2222
}
2323
const stackOptions = { host: this.cmaHost };
2424
if (config.alias) {
25-
stackOptions.token = getToken(config.alias)
25+
stackOptions.token = getToken(config.alias);
2626
}
2727
if (config['stack-api-key']) {
28-
stackOptions.stackApiKey = config['stack-api-key']
28+
stackOptions.stackApiKey = config['stack-api-key'];
2929
}
3030
if (config.branch) stackOptions.branch = config.branch;
3131
let stack = await getStack(stackOptions);
@@ -83,7 +83,8 @@ JsonMigrationCommand.flags = {
8383
required: false,
8484
}),
8585
'global-field': flags.boolean({
86-
description: 'Checks whether the specified UID belongs to a content type or a global field. This flag is set to false by default.',
86+
description:
87+
'Checks whether the specified UID belongs to a content type or a global field. This flag is set to false by default.',
8788
default: false,
8889
required: false,
8990
}),
@@ -108,7 +109,8 @@ JsonMigrationCommand.flags = {
108109
required: false,
109110
}),
110111
delay: flags.integer({
111-
description: 'To set the interval time between the migration of HTML RTE to JSON RTE in subsequent entries of a content type. The default value is 1,000 milliseconds.',
112+
description:
113+
'To set the interval time between the migration of HTML RTE to JSON RTE in subsequent entries of a content type. The default value is 1,000 milliseconds.',
112114
default: 1000,
113115
required: false,
114116
}),
@@ -120,37 +122,6 @@ JsonMigrationCommand.flags = {
120122
description: 'Provide batch limit for updating entries (default: 50).',
121123
default: 50,
122124
}),
123-
124-
// To be deprecated
125-
configPath: flags.string({
126-
char: 'p',
127-
description: 'Path to the config file',
128-
hidden: true,
129-
parse: printFlagDeprecation(['-p', '--configPath'], ['-c', '--config-path']),
130-
}),
131-
content_type: flags.string({
132-
description: 'The content-type from which entries need to be migrated',
133-
hidden: true,
134-
parse: printFlagDeprecation(['-c', '--content_type'], ['--content-type']),
135-
}),
136-
isGlobalField: flags.boolean({
137-
char: 'g',
138-
description: 'Indicates that the current content type is a global field (default: false)',
139-
hidden: true,
140-
parse: printFlagDeprecation(['-g', '--isGlobalField'], ['--global-field']),
141-
}),
142-
htmlPath: flags.string({
143-
char: 'h',
144-
description: 'Provide the path of HTML RTE to migrate',
145-
hidden: true,
146-
parse: printFlagDeprecation(['-h', '--htmlPath'], ['--html-path']),
147-
}),
148-
jsonPath: flags.string({
149-
char: 'j',
150-
description: 'Provide the path of JSON RTE to migrate',
151-
hidden: true,
152-
parse: printFlagDeprecation(['-j', '--jsonPath'], ['--json-path']),
153-
}),
154125
};
155126

156127
JsonMigrationCommand.examples = [

packages/contentstack-migrate-rte/test/commands/json-migration.test.js

Lines changed: 20 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('Migration Config validation', () => {
5656
.stub(cliux, 'confirm', () => true)
5757
.stub(command, 'getToken', getTokenCallback)
5858
.it('throw error on Empty paths', async () => {
59-
const {error} = await runCommand(
59+
const { error } = await runCommand(
6060
['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configWithEmptyPath.json', '--yes'],
6161
{ root: process.cwd() },
6262
);
@@ -67,7 +67,7 @@ describe('Migration Config validation', () => {
6767
.stub(cliux, 'confirm', () => true)
6868
.stub(command, 'getToken', getTokenCallback)
6969
.it('throw error on invalid config type', async () => {
70-
const {error} = await runCommand(
70+
const { error } = await runCommand(
7171
['cm:entries:migrate-html-rte', '--config-path', '../test/dummy/config/invalidConfig.json', '--yes'],
7272
{ root: process.cwd() },
7373
);
@@ -354,20 +354,23 @@ describe('Content Type with Single RTE Field of Single Type', function () {
354354
.stub(cliux, 'confirm', () => 'yes')
355355
.stub(command, 'getToken', getTokenCallback)
356356
.it('throw error on invalid html rte path', async () => {
357-
const { error } = await runCommand([
358-
'cm:entries:migrate-html-rte',
359-
'--alias',
360-
'test1',
361-
'--content-type',
362-
'contenttypewithsinglerte',
363-
'--html-path',
364-
'rich_text_editor.invalidPath',
365-
'--json-path',
366-
'supercharged_rte',
367-
'--yes',
368-
'--delay',
369-
'50',
370-
],{ root: process.cwd() });
357+
const { error } = await runCommand(
358+
[
359+
'cm:entries:migrate-html-rte',
360+
'--alias',
361+
'test1',
362+
'--content-type',
363+
'contenttypewithsinglerte',
364+
'--html-path',
365+
'rich_text_editor.invalidPath',
366+
'--json-path',
367+
'supercharged_rte',
368+
'--yes',
369+
'--delay',
370+
'50',
371+
],
372+
{ root: process.cwd() },
373+
);
371374
expect(error.message).to.contain('The specified path to invalidPath HTML RTE does not exist.');
372375
});
373376

@@ -748,7 +751,7 @@ describe('Content Type with single rte of multiple type', () => {
748751
.stub(cliux, 'confirm', () => 'yes')
749752
.stub(command, 'getToken', getTokenCallback)
750753
.it('execute using config file', async () => {
751-
const {stdout} = await runCommand(
754+
const { stdout } = await runCommand(
752755
['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configForMultipleRte.json', '--yes'],
753756
{ root: process.cwd() },
754757
);
@@ -884,57 +887,3 @@ describe('Content Type with multiple file field', () => {
884887
expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)');
885888
});
886889
});
887-
888-
describe('Migration with old flags and command', () => {
889-
const getTokenCallback = sinon.stub();
890-
getTokenCallback.withArgs('test1').returns({
891-
token: 'testManagementToken',
892-
apiKey: 'testApiKey',
893-
type: 'management',
894-
});
895-
896-
fancy
897-
.stub(cliux, 'confirm', () => 'yes')
898-
.stub(command, 'getToken', getTokenCallback)
899-
.it('execute using config file w/o locale', async (ctx) => {
900-
const { stdout } = await runCommand(
901-
['cm:migrate-rte', '--configPath', './test/dummy/config/config.json', '--yes'],
902-
{ root: process.cwd() },
903-
);
904-
expect(stdout).to.contain(
905-
`WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-p, --configPath). We recommend you to use the updated flags (-c, --config-path).`,
906-
);
907-
});
908-
909-
fancy
910-
.stub(cliux, 'confirm', () => 'yes')
911-
.stub(command, 'getToken', getTokenCallback)
912-
.it('execute using flags (w/o locale)', async () => {
913-
const { stdout } = await runCommand(
914-
[
915-
'cm:entries:migrate-html-rte',
916-
'--alias',
917-
'test1',
918-
'--content_type',
919-
'contenttypewithsinglerte',
920-
'--htmlPath',
921-
'rich_text_editor',
922-
'--jsonPath',
923-
'supercharged_rte',
924-
'--delay',
925-
'50',
926-
],
927-
{ root: process.cwd() },
928-
);
929-
930-
expect(stdout).to.contain(
931-
`WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-c, --content_type). We recommend you to use the updated flags (--content-type).`,
932-
);
933-
expect(stdout).to.contain(
934-
`WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-h, --htmlPath). We recommend you to use the updated flags (--html-path)`,
935-
);
936-
expect(stdout).to.contain(
937-
`WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-j, --jsonPath). We recommend you to use the updated flags (--json-path).`,
938-
);
939-
});
940-
});

packages/contentstack/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,7 @@ EXAMPLES
25662566
25672567
$ csdx cm:migration --config-file <path/to/json/config/file> --file-path <migration/script/file/path>
25682568
2569-
$ csdx cm:migration --multiple --file-path <migration/scripts/dir/path>
2569+
$ csdx cm:migration --multiple --file-path <migration/scripts/dir/path>
25702570
25712571
$ csdx cm:migration --alias --file-path <migration/script/file/path> -k <api-key>
25722572
```
@@ -3029,7 +3029,7 @@ EXAMPLES
30293029
30303030
$ csdx cm:migration --config-file <path/to/json/config/file> --file-path <migration/script/file/path>
30313031
3032-
$ csdx cm:migration --multiple --file-path <migration/scripts/dir/path>
3032+
$ csdx cm:migration --multiple --file-path <migration/scripts/dir/path>
30333033
30343034
$ csdx cm:migration --alias --file-path <migration/script/file/path> -k <api-key>
30353035
```

packages/contentstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@contentstack/cli-cm-export-to-csv": "~1.10.0",
3333
"@contentstack/cli-cm-import": "~2.0.0-beta.2",
3434
"@contentstack/cli-cm-import-setup": "1.7.0",
35-
"@contentstack/cli-cm-migrate-rte": "~1.6.2",
35+
"@contentstack/cli-cm-migrate-rte": "~2.0.0-beta.1",
3636
"@contentstack/cli-cm-seed": "~2.0.0-beta.2",
3737
"@contentstack/cli-command": "~1.6.2",
3838
"@contentstack/cli-config": "~1.15.3",

0 commit comments

Comments
 (0)