Skip to content

Commit e34cbe3

Browse files
committed
latest change
2 parents b830858 + 5a1d9a8 commit e34cbe3

File tree

57 files changed

+2186
-22912
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2186
-22912
lines changed

package-lock.json

Lines changed: 599 additions & 21414 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-audit/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
1919
$ csdx COMMAND
2020
running command...
2121
$ csdx (--version|-v)
22-
@contentstack/cli-audit/1.6.4 darwin-arm64 node-v22.2.0
22+
@contentstack/cli-audit/1.6.5 darwin-arm64 node-v22.2.0
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND
@@ -267,7 +267,7 @@ EXAMPLES
267267
$ csdx plugins
268268
```
269269

270-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.8/src/commands/plugins/index.ts)_
270+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/index.ts)_
271271

272272
## `csdx plugins:add PLUGIN`
273273

@@ -341,7 +341,7 @@ EXAMPLES
341341
$ csdx plugins:inspect myplugin
342342
```
343343

344-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.8/src/commands/plugins/inspect.ts)_
344+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/inspect.ts)_
345345

346346
## `csdx plugins:install PLUGIN`
347347

@@ -390,7 +390,7 @@ EXAMPLES
390390
$ csdx plugins:install someuser/someplugin
391391
```
392392

393-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.8/src/commands/plugins/install.ts)_
393+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/install.ts)_
394394

395395
## `csdx plugins:link PATH`
396396

@@ -420,7 +420,7 @@ EXAMPLES
420420
$ csdx plugins:link myplugin
421421
```
422422

423-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.8/src/commands/plugins/link.ts)_
423+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/link.ts)_
424424

425425
## `csdx plugins:remove [PLUGIN]`
426426

@@ -461,7 +461,7 @@ FLAGS
461461
--reinstall Reinstall all plugins after uninstalling.
462462
```
463463

464-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.8/src/commands/plugins/reset.ts)_
464+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/reset.ts)_
465465

466466
## `csdx plugins:uninstall [PLUGIN]`
467467

@@ -489,7 +489,7 @@ EXAMPLES
489489
$ csdx plugins:uninstall myplugin
490490
```
491491

492-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.8/src/commands/plugins/uninstall.ts)_
492+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/uninstall.ts)_
493493

494494
## `csdx plugins:unlink [PLUGIN]`
495495

@@ -533,5 +533,5 @@ DESCRIPTION
533533
Update installed plugins.
534534
```
535535

536-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.8/src/commands/plugins/update.ts)_
536+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/update.ts)_
537537
<!-- commandsstop -->

packages/contentstack-audit/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-audit",
3-
"version": "1.6.4",
3+
"version": "1.6.5",
44
"description": "Contentstack audit plugin",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/cli",
@@ -19,7 +19,7 @@
1919
],
2020
"dependencies": {
2121
"@contentstack/cli-command": "~1.2.19",
22-
"@contentstack/cli-utilities": "~1.7.0",
22+
"@contentstack/cli-utilities": "~1.7.1",
2323
"@oclif/plugin-help": "^5",
2424
"@oclif/plugin-plugins": "^5.0.0",
2525
"chalk": "^4.1.2",
@@ -86,4 +86,4 @@
8686
"keywords": [
8787
"oclif"
8888
]
89-
}
89+
}

packages/contentstack-audit/src/messages/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import memoize from 'lodash/memoize';
2-
import { escapeRegExp, validateRegex } from '@contentstack/cli-utilities';
32

43
const errors = {};
54

@@ -47,7 +46,7 @@ const auditFixMsg = {
4746
AUDIT_FIX_CMD_DESCRIPTION: 'Perform audits and fix possible errors in the exported Contentstack data.',
4847
WF_FIX_MSG: 'Successfully removed the workflow {uid} named {name}.',
4948
ENTRY_MANDATORY_FIELD_FIX: `Removing the publish details from the entry with UID '{uid}' in Locale '{locale}'...`,
50-
ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in the select field of entry UID '{uid}'...`
49+
ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in the select field of entry UID '{uid}'...`,
5150
};
5251

5352
const messages: typeof errors &
@@ -76,13 +75,9 @@ function $t(msg: string, args: Record<string, string>): string {
7675
if (!msg) return '';
7776

7877
for (const key of Object.keys(args)) {
79-
const escapedKey = escapeRegExp(key);
80-
const escapedKeyRegex = new RegExp(`{${escapedKey}}`, 'g');
81-
let { status } = validateRegex(escapedKeyRegex)
82-
if (status === 'safe') {
83-
const sanitizedValue = args[key] ? escapeRegExp(args[key]) : '';
84-
msg = msg.replace(escapedKeyRegex, sanitizedValue || escapedKey);
85-
}
78+
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
79+
const placeholder = `{${escapedKey}}`;
80+
msg = msg.split(placeholder).join(args[key]);
8681
}
8782

8883
return msg;

packages/contentstack-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"dependencies": {
2525
"@contentstack/cli-command": "~1.2.19",
26-
"@contentstack/cli-utilities": "~1.7.0",
26+
"@contentstack/cli-utilities": "~1.7.1",
2727
"chalk": "^4.0.0",
2828
"debug": "^4.1.1",
2929
"inquirer": "8.2.4",

packages/contentstack-bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
1515
$ csdx COMMAND
1616
running command...
1717
$ csdx (--version)
18-
@contentstack/cli-cm-bootstrap/1.9.4 darwin-arm64 node-v22.2.0
18+
@contentstack/cli-cm-bootstrap/1.10.0 darwin-arm64 node-v22.2.0
1919
$ csdx --help [COMMAND]
2020
USAGE
2121
$ csdx COMMAND

packages/contentstack-bootstrap/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-bootstrap",
33
"description": "Bootstrap contentstack apps",
4-
"version": "1.9.4",
4+
"version": "1.10.0",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {
@@ -19,7 +19,7 @@
1919
"dependencies": {
2020
"@contentstack/cli-cm-seed": "~1.7.6",
2121
"@contentstack/cli-command": "~1.2.19",
22-
"@contentstack/cli-utilities": "~1.7.0",
22+
"@contentstack/cli-utilities": "~1.7.1",
2323
"inquirer": "8.2.4",
2424
"mkdirp": "^1.0.4",
2525
"tar": "^6.2.1 "

packages/contentstack-bootstrap/src/bootstrap/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface BootstrapOptions {
1919
accessToken?: string;
2020
appType: string;
2121
livePreviewEnabled?: boolean;
22+
master_locale: any;
2223
}
2324

2425
export interface SeedParams {
@@ -97,6 +98,9 @@ export default class Bootstrap {
9798
if (this.options.seedParams.managementTokenAlias) {
9899
cmd.push('--alias', this.options.seedParams.managementTokenAlias);
99100
}
101+
if (this.options.master_locale) {
102+
cmd.push('--locale', this.options.master_locale);
103+
}
100104

101105
const result = await ContentStackSeed.run(cmd);
102106
if (result && result.api_key) {
@@ -127,4 +131,4 @@ export default class Bootstrap {
127131
cliux.error(messageHandler.parse('CLI_BOOTSTRAP_STACK_CREATION_FAILED', this.appConfig.stack));
128132
}
129133
}
130-
}
134+
}

packages/contentstack-bootstrap/src/bootstrap/utils.ts

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface EnviornmentVariables {
1919
* Create delivery token
2020
* Create enviroment
2121
*/
22-
22+
let managementTokenResult: any;
2323
export const setupEnvironments = async (
2424
managementAPIClient: any,
2525
api_key: string,
@@ -34,6 +34,51 @@ export const setupEnvironments = async (
3434
.environment()
3535
.query()
3636
.find();
37+
38+
//create management token if not present
39+
if(!managementToken){
40+
const managementBody = {
41+
"token":{
42+
"name":"sample app",
43+
"description":"This is a sample management token.",
44+
"scope":[
45+
{
46+
"module":"content_type",
47+
"acl":{
48+
"read":true,
49+
"write":true
50+
}
51+
},
52+
{
53+
"module":"branch",
54+
"branches":[
55+
"main"
56+
],
57+
"acl":{
58+
"read":true
59+
}
60+
}
61+
],
62+
"expires_on": "3000-01-01",
63+
"is_email_notification_enabled":false
64+
}
65+
}
66+
managementTokenResult = await managementAPIClient
67+
.stack({ api_key: api_key })
68+
.managementToken()
69+
.create(managementBody);
70+
if(!managementTokenResult.uid){
71+
cliux.print(
72+
`Info: Failed to generate a management token.\nNote: Management token is not available in your plan. Please contact the admin for support.`,
73+
{
74+
color: 'yellow',
75+
},
76+
);
77+
if ((await continueBootstrapCommand()) === 'no') {
78+
return;
79+
}
80+
}
81+
}
3782
if (Array.isArray(environmentResult.items) && environmentResult.items.length > 0) {
3883
for (const environment of environmentResult.items) {
3984
if (environment.name) {
@@ -144,6 +189,7 @@ const envFileHandler = async (
144189
const managementAPIHost = region?.cma?.substring('8');
145190
const regionName = region && region.name && region.name.toLowerCase();
146191
previewHost = region?.uiHost?.substring(8)?.replace('app', 'rest-preview');
192+
const cdnHost = region?.cda?.substring('8');
147193
appHost = region?.uiHost?.substring(8);
148194
const isUSRegion = regionName === 'us' || regionName === 'na';
149195
if (regionName !== 'eu' && !isUSRegion) {
@@ -194,19 +240,20 @@ const envFileHandler = async (
194240
filePath = pathValidator(path.join(sanitizePath(clonedDirectory), sanitizePath(fileName)));
195241
content = `CONTENTSTACK_API_KEY=${environmentVariables.api_key}\nCONTENTSTACK_DELIVERY_TOKEN=${
196242
environmentVariables.deliveryToken
197-
}\n${
243+
}\nCONTENTSTACK_BRANCH=main${
198244
livePreviewEnabled
199245
? `\nCONTENTSTACK_PREVIEW_TOKEN=${
200246
environmentVariables.preview_token || `''`
201-
}\nCONTENTSTACK_PREVIEW_HOST=${previewHost}\nCONTENTSTACK_APP_HOST=${appHost}\n`
247+
}\nCONTENTSTACK_PREVIEW_HOST=${previewHost}\n`
202248
: '\n'
203-
}CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}\nCONTENTSTACK_API_HOST=${
249+
}CONTENTSTACK_ENVIRONMENT=${environmentVariables.environment}${
250+
!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
251+
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false\nCONTENTSTACK_API_HOST=${
204252
customHost ? customHost : managementAPIHost
205253
}${
206254
!isUSRegion && !customHost ? '\nCONTENTSTACK_REGION=' + region.name : ''
207-
}\nCONTENTSTACK_LIVE_PREVIEW=${livePreviewEnabled}\nCONTENTSTACK_LIVE_EDIT_TAGS=false`;
255+
}\nCONTENTSTACK_APP_HOST=${appHost}\nCONTENTSTACK_MANAGEMENT_TOKEN=${managementTokenResult.uid}\nCONTENTSTACK_HOST=${cdnHost}`;
208256
result = await writeEnvFile(content, filePath);
209-
break;
210257
case 'gatsby':
211258
case 'gatsby-starter':
212259
fileName = `.env.${environmentVariables.environment}`;

packages/contentstack-bootstrap/src/commands/cm/bootstrap.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import config, { getAppLevelConfigByName, AppConfig } from '../../config';
1919
import messageHandler from '../../messages';
2020

21+
export const DEFAULT_MASTER_LOCALE = 'en-us';
2122
export default class BootstrapCommand extends Command {
2223
private bootstrapManagementAPIClient: any;
2324

@@ -152,6 +153,8 @@ export default class BootstrapCommand extends Command {
152153
const yes = bootstrapCommandFlags.yes as string;
153154

154155
const appConfig: AppConfig = getAppLevelConfigByName(selectedAppName || selectedApp.configKey);
156+
157+
let master_locale = appConfig.master_locale || DEFAULT_MASTER_LOCALE;
155158

156159
let cloneDirectory =
157160
(bootstrapCommandFlags.directory as string) || (bootstrapCommandFlags['project-dir'] as string);
@@ -187,11 +190,12 @@ export default class BootstrapCommand extends Command {
187190
region: this.region,
188191
appType,
189192
livePreviewEnabled,
193+
master_locale,
190194
};
191195
const bootstrap = new Bootstrap(options);
192196
await bootstrap.run();
193197
} catch (error: any) {
194198
this.error(error, { exit: 1, suggestions: error.suggestions });
195199
}
196200
}
197-
}
201+
}

0 commit comments

Comments
 (0)