Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bb80a6c
fix invalid environment error while importing asset
Nov 18, 2024
7c8dc36
Merge branch 'development' into fix/DX-1656
Nov 18, 2024
a53b8ed
Merge pull request #1686 from contentstack/staging
aman19K Nov 20, 2024
ad337c8
[DX-648] - implemented a warning if the user is using older versions …
Nov 21, 2024
534ee1e
[DX-648] - removed static date
Nov 21, 2024
4567e3d
[DX-648]-moved interfaces to inteface index file
Nov 21, 2024
8df65ca
[DX-648]- updated intialization of logger service
Nov 21, 2024
937c6ef
[DX-648]- added fallback in case of version is not fetched
Nov 21, 2024
a7a4abe
[DX-648]- updated logger intialisation
Nov 21, 2024
94e6a79
[DX-648] - updated the commented code
Nov 22, 2024
3b3fdd7
[DX-648] - updated the package version
Nov 22, 2024
cc3d033
[DX-648] - updated the cli version 1.31.0 -> 1.32.0
Nov 22, 2024
be9f5ea
[DX-648] - added semver in dependencies
Nov 22, 2024
2e04cc3
fix: UnhandledPromiseRejection in variant plugin
aman19K Nov 25, 2024
3584d48
reverted failedVariantEntries condition check
aman19K Nov 25, 2024
addb9c0
Merge pull request #1688 from contentstack/fix/Dx-1790-unhandled-error
aman19K Nov 25, 2024
8768bd9
Merge branch 'development' into feat/DX-648
Nov 25, 2024
06f678f
Merge pull request #1687 from contentstack/feat/DX-648
naman-contentstack Nov 26, 2024
315d7dd
Merge branch 'development' into fix/DX-1656
Nov 26, 2024
1ed5dbf
Merge pull request #1681 from contentstack/fix/DX-1656
naman-contentstack Nov 26, 2024
cc965c7
version bump
cs-raj Nov 28, 2024
b40ca1b
Merge pull request #1689 from contentstack/fix/dev4
cs-raj Nov 28, 2024
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
940 changes: 433 additions & 507 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 @@ -269,7 +269,7 @@ EXAMPLES
$ csdx plugins
```

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

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -343,7 +343,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

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

## `csdx plugins:install PLUGIN`

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

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

## `csdx plugins:link PATH`

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

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

## `csdx plugins:remove [PLUGIN]`

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

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

## `csdx plugins:uninstall [PLUGIN]`

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

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

## `csdx plugins:unlink [PLUGIN]`

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

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/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.6.0",
"@contentstack/cli-cm-export": "~1.14.1",
"@contentstack/cli-cm-import": "~1.19.2",
"@contentstack/cli-cm-import": "~1.19.3",
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-utilities": "~1.8.0",
"async": "^3.2.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-variants": "~1.1.2",
"@contentstack/cli-variants": "~1.1.3",
"@contentstack/cli-utilities": "~1.8.0",
"@oclif/core": "^3.27.0",
"async": "^3.2.6",
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.19.2 darwin-arm64 node-v22.8.0
@contentstack/cli-cm-import/1.19.3 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.19.2",
"version": "1.19.3",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-audit": "~1.7.3",
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-utilities": "~1.8.0",
"@contentstack/management": "~1.18.3",
"@contentstack/cli-variants": "~1.1.2",
"@contentstack/cli-variants": "~1.1.3",
"@oclif/core": "^3.27.0",
"big-json": "^3.2.0",
"bluebird": "^3.7.2",
Expand Down
18 changes: 12 additions & 6 deletions packages/contentstack-import/src/import/modules/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,21 @@ export default class ImportAssets extends BaseClass {
const serializeData = (apiOptions: ApiOptions) => {
const { apiData: asset } = apiOptions;
const publishDetails = filter(asset.publish_details, ({ environment }) => {
return this.environments.hasOwnProperty(environment);
return this.environments?.hasOwnProperty(environment);
});
const environments = uniq(map(publishDetails, ({ environment }) => this.environments[environment].name));
const locales = uniq(map(publishDetails, 'locale'));
if (publishDetails.length) {
const environments = uniq(map(publishDetails, ({ environment }) => this.environments[environment].name));
const locales = uniq(map(publishDetails, 'locale'));
if (environments.length === 0 || locales.length === 0) {
apiOptions.entity = undefined
return apiOptions;
}
asset.locales = locales;
asset.environments = environments;
apiOptions.apiData.publishDetails = { locales, environments };
}

asset.locales = locales;
asset.environments = environments;
apiOptions.uid = this.assetsUidMap[asset.uid] as string;
apiOptions.apiData.publishDetails = { locales, environments };

if (!apiOptions.uid) apiOptions.entity = undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~1.19.2",
"@contentstack/cli-cm-import": "~1.19.3",
"@contentstack/cli-command": "~1.3.2",
"@contentstack/cli-utilities": "~1.8.0",
"@contentstack/management": "~1.18.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-variants/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-variants",
"version": "1.1.2",
"version": "1.1.3",
"description": "Variants plugin",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
try {
this.apiClient.headers({ api_version: undefined });
const res = await this.apiClient.put<VariantEntryStruct>(endpoint, { entry: input });
const data = this.handleVariantAPIRes(res);
const data = await this.handleVariantAPIRes(res);

if (res.status >= 200 && res.status < 300) {
onSuccess(data);
Expand Down Expand Up @@ -238,7 +238,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
try {
this.apiClient.headers({ api_version: 3.2 });
const res = await this.apiClient.post<any>(endpoint, input);
const data = this.handleVariantAPIRes(res);
const data = await this.handleVariantAPIRes(res);

if (res.status >= 200 && res.status < 300) {
onSuccess(data);
Expand Down
16 changes: 8 additions & 8 deletions packages/contentstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli/1.31.0 darwin-arm64 node-v22.8.0
@contentstack/cli/1.32.0 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -3812,7 +3812,7 @@ EXAMPLES
$ csdx plugins
```

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

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -3886,7 +3886,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

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

## `csdx plugins:install PLUGIN`

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

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

## `csdx plugins:link PATH`

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

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

## `csdx plugins:remove [PLUGIN]`

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

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

## `csdx plugins:uninstall [PLUGIN]`

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

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

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -4079,7 +4079,7 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.15/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.17/src/commands/plugins/update.ts)_

## `csdx tokens`

Expand Down
11 changes: 7 additions & 4 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.31.0",
"version": "1.32.0",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run.js"
Expand Down Expand Up @@ -30,7 +30,7 @@
"@contentstack/cli-cm-export": "~1.14.1",
"@contentstack/cli-cm-clone": "~1.13.0",
"@contentstack/cli-cm-export-to-csv": "~1.7.3",
"@contentstack/cli-cm-import": "~1.19.2",
"@contentstack/cli-cm-import": "~1.19.3",
"@contentstack/cli-cm-migrate-rte": "~1.4.20",
"@contentstack/cli-cm-seed": "~1.10.0",
"@contentstack/cli-command": "~1.3.2",
Expand All @@ -39,7 +39,7 @@
"@contentstack/cli-migration": "~1.6.4",
"@contentstack/cli-utilities": "~1.8.0",
"@contentstack/management": "~1.18.3",
"@contentstack/cli-variants": "~1.1.2",
"@contentstack/cli-variants": "~1.1.3",
"@oclif/core": "^3.27.0",
"@oclif/plugin-help": "^5",
"@oclif/plugin-not-found": "^2.4.3",
Expand All @@ -50,6 +50,7 @@
"inquirer": "8.2.6",
"node-machine-id": "^1.1.12",
"open": "^8.4.2",
"semver": "^7.6.3",
"short-uuid": "^4.2.2",
"uuid": "^9.0.1",
"winston": "^3.17.0"
Expand All @@ -61,6 +62,7 @@
"@types/mkdirp": "^1.0.2",
"@types/mocha": "^8.2.3",
"@types/node": "^14.18.63",
"@types/semver": "^7.5.8",
"@types/sinon": "^10.0.20",
"chai": "^4.5.0",
"eslint": "^8.57.1",
Expand Down Expand Up @@ -153,7 +155,8 @@
"hooks": {
"prerun": [
"./lib/hooks/prerun/command-deprecation-check",
"./lib/hooks/prerun/default-rate-limit-check"
"./lib/hooks/prerun/default-rate-limit-check",
"./lib/hooks/prerun/latest-version-warning"
],
"init": [
"./lib/hooks/init/context-init",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { cliux, configHandler, HttpClient, LoggerService } from '@contentstack/cli-utilities';
import * as semver from 'semver';
import { IVersionUpgradeCache, IVersionUpgradeWarningFrequency } from '../../interfaces';

const versionUpgradeWarningFrequency: IVersionUpgradeWarningFrequency = {
versionSyncDuration: 3 * 24 * 60 * 60 * 1000,
};
export default async function (_opts): Promise<void> {
const now = Date.now();
const today = new Date().toISOString().split('T')[0];
const logger: LoggerService = new LoggerService(process.env.CS_CLI_LOG_PATH || process.cwd(), 'cli-log');
let cache: IVersionUpgradeCache = { lastChecked: 0, lastWarnedDate: '', latestVersion: '' };

if (!configHandler.get('versionUpgradeWarningFrequency')) {
configHandler.set('versionUpgradeWarningFrequency', versionUpgradeWarningFrequency);
}
const versionUpgradeWarningFrequencyConfig: IVersionUpgradeWarningFrequency = configHandler.get(
'versionUpgradeWarningFrequency',
);

// Load cache if it exists
if (configHandler.get('versionUpgradeWarningCache')) {
cache = configHandler.get('versionUpgradeWarningCache');
}

// Perform update check if needed
const httpClient = new HttpClient();

if (now - cache.lastChecked > versionUpgradeWarningFrequencyConfig.versionSyncDuration) {
try {
const latestVersion = (await httpClient.get(`https://registry.npmjs.org/@contentstack/cli/latest`))?.data
?.version;
if (!latestVersion) {
logger.error('Failed to retrieve the latest version from the registry.');
return;
}
cache.latestVersion = latestVersion;
cache.lastChecked = now;

// Save updated cache
configHandler.set('versionUpgradeWarningCache', cache);
} catch (error) {
logger.error('Failed to check the latest version', error);
return;
}
}

// Show warning if an update is available and last warning was yesterday
if (semver.gt(cache.latestVersion, this.config.version) && cache.lastWarnedDate !== today) {
cliux.print(
`You are using version ${this.config.version}, but the latest version is ${cache.latestVersion}. Please update your CLI for the best experience.`,
{ color: 'yellow' },
);
// Update the last warned timestamp
cache.lastWarnedDate = today;
configHandler.set('versionUpgradeWarningCache', cache);
}
}
9 changes: 9 additions & 0 deletions packages/contentstack/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ export interface Context {
export interface CLIConfig extends Config {
context: Context;
}

export interface IVersionUpgradeCache {
lastChecked: number;
lastWarnedDate: string;
latestVersion: string;
}
export interface IVersionUpgradeWarningFrequency {
versionSyncDuration: number;
}
Loading
Loading