Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@commercelayer/cli-plugin-exports

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercelayer/cli-plugin-exports - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

2

lib/base.d.ts

@@ -14,3 +14,3 @@ import { KeyValRel, KeyValString } from '@commercelayer/cli-core';

protected whereFlag(flag: string[] | undefined): KeyValString;
protected saveOutput(exp: Export, flags: any): Promise<void>;
protected saveOutput(exp: Export, flags: any): Promise<string | undefined>;
private getExportedFile;

@@ -17,0 +17,0 @@ protected checkApplication(accessToken: string, kinds: string[]): boolean;

@@ -67,6 +67,7 @@ "use strict";

const fileExport = await this.getExportedFile(exp.attachment_url, flags);
(0, promises_1.writeFile)(filePath, fileExport)
return (0, promises_1.writeFile)(filePath, fileExport)
.then(() => {
if ((0, fs_1.existsSync)(filePath))
this.log(`Exported file saved to ${cli_core_1.clColor.style.path(filePath)}\n`);
return filePath;
})

@@ -73,0 +74,0 @@ .catch(() => this.error(`Unable to save export file ${cli_core_1.clColor.style.path(filePath)}`, { suggestions: ['Please check you have the right file system permissions'] }));

import Command from '../../base';
import { CommerceLayerClient } from '@commercelayer/sdk';
export declare const notify: (message: string) => void;
export declare const computeDelay: () => number;
export default class ExportsCreate extends Command {

@@ -18,3 +20,4 @@ static description: string;

blind: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
pretty: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
prettify: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
open: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
};

@@ -21,0 +24,0 @@ checkAccessToken(jwtData: any, flags: any, client: CommerceLayerClient): Promise<any>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeDelay = exports.notify = void 0;
const tslib_1 = require("tslib");
/* eslint-disable no-await-in-loop */
/* eslint-disable max-depth */
/* eslint-disable complexity */
const base_1 = tslib_1.__importStar(require("../../base"));
const cli_core_1 = require("@commercelayer/cli-core");
const node_notifier_1 = tslib_1.__importDefault(require("node-notifier"));
const open_1 = tslib_1.__importDefault(require("open"));
const securityInterval = 2;

@@ -18,2 +17,3 @@ const notify = (message) => {

};
exports.notify = notify;
const computeDelay = () => {

@@ -25,2 +25,3 @@ const delayBurst = cli_core_1.clConfig.api.requests_max_secs_burst / cli_core_1.clConfig.api.requests_max_num_burst;

};
exports.computeDelay = computeDelay;
class ExportsCreate extends base_1.default {

@@ -53,3 +54,3 @@ async checkAccessToken(jwtData, flags, client) {

this.error('Undefined output file path');
if (flags.pretty && ((flags.format === 'csv') || flags.csv))
if (flags.prettify && ((flags.format === 'csv') || flags.csv))
this.error(`Flag ${cli_core_1.clColor.cli.flag('Pretty')} can only be used with ${cli_core_1.clColor.cli.value('JSON')} format`);

@@ -86,12 +87,13 @@ const resType = flags.type;

let jwtData = cli_core_1.clToken.decodeAccessToken(accessToken);
const delay = computeDelay();
const delay = (0, exports.computeDelay)();
if (!blindMode)
base_1.cliux.action.start(`Exporting ${resDesc}`, exp.status?.replace(/_/g, ' ') || 'waiting');
base_1.cliux.action.start(`Exporting ${resDesc}`, this.exportStatus(exp.status?.replace(/_/g, ' ') || 'waiting'));
while (!['completed', 'interrupted'].includes(exp.status || '')) {
jwtData = await this.checkAccessToken(jwtData, flags, cl);
exp = await cl.exports.retrieve(exp.id);
base_1.cliux.action.status = this.exportStatus(exp.status?.replace(/_/g, ' ') || 'waiting');
await base_1.cliux.wait(delay);
}
if (!blindMode)
base_1.cliux.action.stop((exp.status === 'completed' ? cli_core_1.clColor.style.success : cli_core_1.clColor.style.error)(exp.status));
base_1.cliux.action.stop(this.exportStatus(exp.status));
if (exp.status === 'completed')

@@ -101,3 +103,3 @@ this.log(`\nExported ${cli_core_1.clColor.yellowBright(exp.records_count || 0)} ${resDesc}`);

this.error(`Export ${exp?.id} ended with errors`);
await this.saveOutput(exp, flags);
const outputFile = await this.saveOutput(exp, flags);
// Notification

@@ -107,4 +109,8 @@ const finishMessage = `Export of ${exp.records_count} ${resDesc} is finished!`;

this.log(finishMessage);
else if (notification)
notify(finishMessage);
else {
if (notification)
(0, exports.notify)(finishMessage);
if (flags.open && outputFile)
await (0, open_1.default)(outputFile);
}
}

@@ -160,3 +166,3 @@ catch (error) {

char: 'F',
description: 'export file format [csv|json]',
description: 'export file format',
options: ['csv', 'json'],

@@ -193,7 +199,11 @@ default: 'json',

}),
pretty: base_1.Flags.boolean({
prettify: base_1.Flags.boolean({
char: 'P',
description: 'prettify json output format',
exclusive: ['csv']
}),
open: base_1.Flags.boolean({
char: 'O',
description: 'open automatically the file after a successful export'
})
};
{
"version": "0.1.1",
"version": "1.0.0",
"commands": {

@@ -108,3 +108,3 @@ "exports:create": {

"char": "F",
"description": "export file format [csv|json]",
"description": "export file format",
"multiple": false,

@@ -170,4 +170,4 @@ "options": [

},
"pretty": {
"name": "pretty",
"prettify": {
"name": "prettify",
"type": "boolean",

@@ -180,2 +180,9 @@ "char": "P",

]
},
"open": {
"name": "open",
"type": "boolean",
"char": "O",
"description": "open automatically the file after a successful export",
"allowNo": false
}

@@ -182,0 +189,0 @@ },

{
"name": "@commercelayer/cli-plugin-exports",
"description": "Commerce Layer CLI Exports plugin",
"version": "0.1.1",
"version": "1.0.0",
"author": "Pierluigi Viti <pierluigi@commercelayer.io>",

@@ -49,7 +49,7 @@ "bugs": "https://github.com/commercelayer/commercelayer-cli-plugin-exports/issues",

"@oclif/plugin-help": "^5.2.8",
"@oclif/test": "^2.3.10",
"@oclif/test": "^2.3.13",
"@types/chai": "^4.3.4",
"@types/cli-progress": "^3.11.0",
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.3",
"@types/node": "^18.15.10",
"@types/node-notifier": "^8.0.2",

@@ -64,6 +64,6 @@ "chai": "^4.3.7",

"dependencies": {
"@commercelayer/cli-core": "^3.3.6",
"@commercelayer/cli-core": "^3.4.0",
"@commercelayer/js-auth": "^2.3.0",
"@commercelayer/sdk": "^4.25.0",
"@oclif/core": "^2.6.3",
"@commercelayer/sdk": "^4.27.0",
"@oclif/core": "^2.7.1",
"axios": "^1.3.4",

@@ -70,0 +70,0 @@ "cli-progress": "^3.12.0",

@@ -42,3 +42,3 @@ # @commercelayer/cli-plugin-exporter

gories|transactions|authorizations|captures|voids|refunds [-i <value>] [-w <value>] [-D] [-F csv|json | -C | ] [-x
<value> | -X <value>] [-b | | ] [-P | ]
<value> | -X <value>] [-b | | ] [-P | ] [-O]

@@ -48,5 +48,6 @@ FLAGS

-D, --dry-data skip redundant attributes
-F, --format=<option> [default: json] export file format [csv|json]
-F, --format=<option> [default: json] export file format
<options: csv|json>
-P, --pretty prettify json output format
-O, --open open automatically the file after a successful export
-P, --prettify prettify json output format
-X, --save-path=<value> save command output to file and create missing path

@@ -53,0 +54,0 @@ directories

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc