Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/hotfix #1500

Merged
merged 6 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
391 changes: 172 additions & 219 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ EXAMPLES
$ csdx plugins
```

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

## `csdx plugins:add 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.3.9/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -390,7 +390,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.9/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/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.3.9/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/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.3.9/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/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.3.9/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/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.3.9/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.2/src/commands/plugins/update.ts)_
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@colors/colors": "^1.5.0",
"@contentstack/cli-cm-export": "~1.11.6",
"@contentstack/cli-cm-import": "~1.16.3",
"@contentstack/cli-cm-import": "~1.16.4",
"@contentstack/cli-command": "~1.2.19",
"@contentstack/cli-utilities": "~1.7.0",
"async": "^3.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-cm-import/1.16.3 darwin-arm64 node-v22.2.0
@contentstack/cli-cm-import/1.16.4 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.16.3",
"version": "1.16.4",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
Expand Down
65 changes: 45 additions & 20 deletions packages/contentstack-import/src/import/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from '../../utils';
import { ModuleClassParams } from '../../types';
import BaseClass, { ApiOptions } from './base-class';

export default class EntriesImport extends BaseClass {
private assetUidMapperPath: string;
private assetUidMapper: Record<string, any>;
Expand Down Expand Up @@ -68,11 +67,25 @@ export default class EntriesImport extends BaseClass {
this.entriesUIDMapperPath = path.join(sanitizePath(this.entriesMapperPath), 'uid-mapping.json');
this.uniqueUidMapperPath = path.join(sanitizePath(this.entriesMapperPath), 'unique-mapping.json');
this.modifiedCTsPath = path.join(sanitizePath(this.entriesMapperPath), 'modified-schemas.json');
this.marketplaceAppMapperPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'marketplace_apps', 'uid-mapping.json');
this.taxonomiesPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'taxonomies', 'terms', 'success.json');
this.marketplaceAppMapperPath = path.join(
sanitizePath(this.importConfig.data),
'mapper',
'marketplace_apps',
'uid-mapping.json',
);
this.taxonomiesPath = path.join(
sanitizePath(this.importConfig.data),
'mapper',
'taxonomies',
'terms',
'success.json',
);
this.entriesConfig = importConfig.modules.entries;
this.entriesPath = path.resolve(sanitizePath(importConfig.data), sanitizePath(this.entriesConfig.dirName));
this.cTsPath = path.resolve(sanitizePath(importConfig.data), sanitizePath(importConfig.modules['content-types'].dirName));
this.cTsPath = path.resolve(
sanitizePath(importConfig.data),
sanitizePath(importConfig.modules['content-types'].dirName),
);
this.localesPath = path.resolve(
sanitizePath(importConfig.data),
sanitizePath(importConfig.modules.locales.dirName),
Expand Down Expand Up @@ -898,23 +911,35 @@ export default class EntriesImport extends BaseClass {

if (chunk) {
let apiContent = values(chunk as Record<string, any>[]);
await this.makeConcurrentCall({
apiContent,
processName,
indexerCount,
currentIndexer: +index,
apiParams: {
reject: onReject,
resolve: onSuccess,
entity: 'publish-entries',
includeParamOnCompletion: true,
serializeData: this.serializePublishEntries.bind(this),
additionalInfo: { contentType, locale, cTUid },
},
concurrencyLimit: this.importConcurrency,
}).then(() => {
log(this.importConfig, `Published entries for content type ${cTUid} in locale ${locale}`, 'success');
let apiContentDuplicate: any = [];
apiContent.forEach((content: Record<string, any>) => {
content?.publish_details?.forEach((publish: Record<string, any>) => {
let c2 = { ...content };
c2.locale = publish.locale;
c2.publish_details = [publish];
apiContentDuplicate.push(c2);
});
});
for (let i = 0; i < apiContentDuplicate.length; i++) {
let apiContent = [apiContentDuplicate[i]];
await this.makeConcurrentCall({
apiContent,
processName,
indexerCount,
currentIndexer: +index,
apiParams: {
reject: onReject,
resolve: onSuccess,
entity: 'publish-entries',
includeParamOnCompletion: true,
serializeData: this.serializePublishEntries.bind(this),
additionalInfo: { contentType, locale: apiContentDuplicate[i]?.locale, cTUid },
},
concurrencyLimit: this.importConcurrency,
}).then(() => {
log(this.importConfig, `Published entries for content type ${cTUid} in locale ${locale}`, 'success');
});
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-launch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-launch
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-launch/1.0.19 darwin-arm64 node-v22.2.0
@contentstack/cli-launch/1.1.0 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-launch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-launch",
"version": "1.0.19",
"version": "1.1.0",
"description": "Launch related operations",
"author": "Contentstack CLI",
"bin": {
Expand Down
146 changes: 82 additions & 64 deletions packages/contentstack-launch/src/adapters/base-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,19 @@ export default class BaseClass {
this.log(error, 'error');
this.exit(1);
})) || [];
this.config.selectedStack = await ux
.inquire({
name: 'stack',
type: 'search-list',
choices: listOfStacks,
message: 'Stack',
})
.then((name) => find(listOfStacks, { name }));

if (this.config.selectedStack) {
this.config.selectedStack = find(listOfStacks, { api_key: this.config.selectedStack });
} else {
this.config.selectedStack = await ux
.inquire({
name: 'stack',
type: 'search-list',
choices: listOfStacks,
message: 'Stack',
})
.then((name) => find(listOfStacks, { name }));
}
}

/**
Expand Down Expand Up @@ -299,16 +304,19 @@ export default class BaseClass {
this.exit(1);
})) || [];

this.config.deliveryToken = await ux
.inquire({
type: 'search-list',
name: 'deliveryToken',
choices: listOfDeliveryTokens,
message: 'Delivery token',
})
.then((name) => find(listOfDeliveryTokens, { name }) as Record<string, any>);

this.config.environment = this.config.deliveryToken.scope[0]?.environments[0]?.name;
if (this.config.deliveryToken) {
this.config.deliveryToken = find(listOfDeliveryTokens, { token: this.config.deliveryToken });
} else {
this.config.deliveryToken = await ux
.inquire({
type: 'search-list',
name: 'deliveryToken',
choices: listOfDeliveryTokens,
message: 'Delivery token',
})
.then((name) => find(listOfDeliveryTokens, { name }) as Record<string, any>);
}
this.config.environment = this.config.deliveryToken?.scope[0]?.environments[0]?.name;
}

/**
Expand All @@ -321,38 +329,51 @@ export default class BaseClass {
let addNew = true;
const envVariables = [];

do {
const variable = await ux
.inquire({
type: 'input',
name: 'variable',
message:
'Enter key and value with a colon between them, and use a comma(,) for the key-value pair. Format: <key1>:<value1>, <key2>:<value2> Ex: APP_ENV:prod, TEST_ENV:testVal',
})
.then((variable) => {
return map(split(variable as string, ','), (variable) => {
let [key, value] = split(variable as string, ':');
value = (value || '').trim();
key = (key || '').trim();

return { key, value };
}).filter(({ key }) => key);
});
if (!this.config.envVariables) {
do {
const variable = await ux
.inquire({
type: 'input',
name: 'variable',
message:
'Enter key and value with a colon between them, and use a comma(,) for the key-value pair. Format: <key1>:<value1>, <key2>:<value2> Ex: APP_ENV:prod, TEST_ENV:testVal',
})
.then((variable) => {
return map(split(variable as string, ','), (variable) => {
let [key, value] = split(variable as string, ':');
value = (value || '').trim();
key = (key || '').trim();

return { key, value };
}).filter(({ key }) => key);
});

envVariables.push(...variable);
envVariables.push(...variable);

if (
!(await ux.inquire({
type: 'confirm',
name: 'canImportFromStack',
message: 'Would you like to add more variables?',
}))
) {
addNew = false;
}
} while (addNew);
if (
!(await ux.inquire({
type: 'confirm',
name: 'canImportFromStack',
message: 'Would you like to add more variables?',
}))
) {
addNew = false;
}
} while (addNew);

this.envVariables.push(...envVariables);
} else {
if (typeof this.config.envVariables === 'string') {
const variable = map(split(this.config.envVariables as string, ','), (variable) => {
let [key, value] = split(variable as string, ':');
value = (value || '').trim();
key = (key || '').trim();

this.envVariables.push(...envVariables);
return { key, value };
});
this.envVariables.push(...variable);
}
}
}

/**
Expand Down Expand Up @@ -492,19 +513,16 @@ export default class BaseClass {
* @memberof BaseClass
*/
async handleEnvImportFlow(): Promise<void> {
const variablePreparationTypeOptions = [
'Import variables from a stack',
'Manually add custom variables to the list',
'Import variables from the local env file',
];
const variablePreparationType: Array<string> = await ux.inquire({
type: 'checkbox',
name: 'variablePreparationType',
default: this.config.framework,
choices: variablePreparationTypeOptions,
message: 'Import variables from a stack and/or manually add custom variables to the list',
// validate: this.inquireRequireValidation,
});
const variablePreparationType =
this.config.variableType ||
(await ux.inquire({
type: 'checkbox',
name: 'variablePreparationType',
default: this.config.framework,
choices: this.config.variablePreparationTypeOptions,
message: 'Import variables from a stack and/or manually add custom variables to the list',
// validate: this.inquireRequireValidation,
}));

if (includes(variablePreparationType, 'Import variables from a stack')) {
await this.importEnvFromStack();
Expand All @@ -519,8 +537,8 @@ export default class BaseClass {
if (this.envVariables.length) {
this.printAllVariables();
} else {
this.log('Import variables from a stack and/or manually add custom variables to the list', 'warn');
// this.exit(1);
this.log('Please provide env file!', 'error');
this.exit(1);
}
}

Expand All @@ -533,10 +551,10 @@ export default class BaseClass {
async importVariableFromLocalConfig(): Promise<void> {
const localEnv =
dotEnv.config({
path: this.config.projectBasePath,
path: `${this.config.projectBasePath}/.env.local`,
}).parsed ||
dotEnv.config({
path: `${this.config.projectBasePath}/.env.local`,
path: this.config.projectBasePath,
}).parsed;

if (!isEmpty(localEnv)) {
Expand Down
Loading
Loading