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

@commercelayer/cli-plugin-imports

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 4.1.1 to 4.1.2

3

lib/chunk.d.ts

@@ -19,5 +19,6 @@ import type { ImportCreate } from '@commercelayer/sdk';

};
declare const splitImports: (imp: ImportCreate, format: 'csv' | 'json', size?: number) => Chunk[];
type InputFormat = 'csv' | 'json';
declare const splitImports: (imp: ImportCreate, format: InputFormat, size?: number) => Chunk[];
declare const splitChunks: (chunks: Chunk[], size: number) => Batch[];
export { splitImports, splitChunks };
export type { Chunk, Batch };

@@ -10,6 +10,9 @@ "use strict";

const chunkSize = size || cli_core_1.clConfig.imports.max_size;
const header = (format === 'csv') ? imp.inputs.shift() : undefined;
const header = (format === 'csv') ? imp.inputs.shift() : undefined; // Extract file header
const allInputs = imp.inputs;
const totalItems = imp.inputs.length;
const groupId = generateGroupUID();
console.log(header);
console.log(allInputs);
console.log(totalItems);
let chunkNum = 0;

@@ -20,3 +23,3 @@ while (allInputs.length > 0) {

if ((format === 'csv') && header)
inputs.unshift(header);
inputs.unshift(header); // CSV inputs must have an header
chunks.push({

@@ -41,3 +44,3 @@ format,

c.start_item = ((c.chunk_number - 1) * chunkSize) + 1;
c.end_item = (c.start_item + c.inputs.length) - 1;
c.end_item = (c.start_item + c.items_count) - 1;
c.total_chunks = chunks.length;

@@ -44,0 +47,0 @@ // c.items_count = c.inputs.length

@@ -13,3 +13,2 @@ import Command from '../../base';

csv: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
delimiter: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
blind: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;

@@ -16,0 +15,0 @@ quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;

@@ -74,9 +74,11 @@ "use strict";

}),
delimiter: base_1.Flags.string({
char: 'D',
description: 'the delimiter character used in the CSV input file (one of \',\', \';\', \'|\', TAB)',
options: [',', ';', '|', 'TAB'],
dependsOn: ['csv'],
multiple: false
/*
delimiter: Flags.string({
char: 'D',
description: 'the delimiter character used in the CSV input file (one of \',\', \';\', \'|\', TAB)',
options: [',', ';', '|', 'TAB'],
dependsOn: ['csv'],
multiple: false
}),
*/
blind: base_1.Flags.boolean({

@@ -83,0 +85,0 @@ char: 'b',

@@ -6,6 +6,9 @@ "use strict";

const cli_core_1 = require("@commercelayer/cli-core");
const node_os_1 = require("node:os");
const generateInputsCSV = async (filePath) => {
try {
const data = (0, node_fs_1.readFileSync)(filePath, { encoding: 'utf-8' });
const csv = data.split('\n');
const data = (0, node_fs_1.readFileSync)(filePath, { encoding: 'utf-8' }).trim();
if (data.startsWith('{') || data.startsWith('['))
throw new Error('The imported file is not a valid CSV file');
const csv = data.split(node_os_1.EOL);
return Promise.resolve(csv);

@@ -19,3 +22,5 @@ }

try {
const data = (0, node_fs_1.readFileSync)(filePath, { encoding: 'utf-8' });
const data = (0, node_fs_1.readFileSync)(filePath, { encoding: 'utf-8' }).trim();
if (!data.startsWith('{') && !data.startsWith('['))
throw new Error('The imported file is not a valid JSON file');
const json = JSON.parse(data);

@@ -22,0 +27,0 @@ if (!Array.isArray(json))

@@ -76,3 +76,3 @@ "use strict";

updPayload.status = this.statusStyle(payload.status.replace(/_/, ' '), payload.processed);
updPayload.tbp = String(bar.getTotal() - updCount).padStart(maxImportLength, ' ');
updPayload.tbp = String(Math.max(0, bar.getTotal() - updCount)).padStart(maxImportLength, ' ');
if (bar)

@@ -79,0 +79,0 @@ bar.update(updCount, updPayload);

@@ -109,19 +109,2 @@ {

},
"delimiter": {
"char": "D",
"dependsOn": [
"csv"
],
"description": "the delimiter character used in the CSV input file (one of ',', ';', '|', TAB)",
"name": "delimiter",
"hasDynamicHelp": false,
"multiple": false,
"options": [
",",
";",
"|",
"TAB"
],
"type": "option"
},
"blind": {

@@ -760,3 +743,3 @@ "char": "b",

},
"version": "4.1.1"
"version": "4.1.2"
}
{
"name": "@commercelayer/cli-plugin-imports",
"description": "Commerce Layer CLI Imports plugin",
"version": "4.1.1",
"version": "4.1.2",
"author": "Pierluigi Viti <pierluigi@commercelayer.io>",

@@ -44,5 +44,15 @@ "homepage": "https://github.com/commercelayer/commercelayer-cli-plugin-imports",

},
"scripts": {
"build": "rm -rf lib && tsc -b",
"prepack": "pnpm build && oclif manifest && pnpm readme",
"postpack": "rm -f oclif.manifest.json",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"posttest": "eslint . --ext .ts --config .eslintrc",
"readme": "cl-cli-dev readme --plugin --bin=commercelayer && git add README.md",
"lint": "eslint src --ext .ts --config .eslintrc",
"lint:fix": "eslint src --fix"
},
"types": "lib/index.d.ts",
"devDependencies": {
"@commercelayer/cli-dev": "^3.0.3",
"@commercelayer/cli-dev": "^3.0.5",
"@commercelayer/eslint-config-ts": "^1.4.5",

@@ -61,5 +71,5 @@ "@oclif/plugin-help": "^6.0.22",

"nyc": "^15.1.0",
"oclif": "^4.10.11",
"oclif": "^4.10.15",
"semantic-release": "^23.1.1",
"tsx": "^4.10.4",
"tsx": "^4.10.5",
"typescript": "^5.4.5"

@@ -69,6 +79,6 @@ },

"@commercelayer/cli-core": "^5.0.2",
"@commercelayer/sdk": "^6.0.2",
"@commercelayer/sdk": "^6.1.0",
"@fast-csv/parse": "^4.3.6",
"@oclif/core": "^3.26.6",
"axios": "^1.6.8",
"axios": "^1.7.0",
"cli-progress": "^3.12.0",

@@ -81,11 +91,3 @@ "cli-table3": "^0.6.5",

"access": "public"
},
"scripts": {
"build": "rm -rf lib && tsc -b",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"posttest": "eslint . --ext .ts --config .eslintrc",
"readme": "cl-cli-dev readme --plugin --bin=commercelayer && git add README.md",
"lint": "eslint src --ext .ts --config .eslintrc",
"lint:fix": "eslint src --fix"
}
}
}

@@ -79,9 +79,6 @@ # cli-plugin-imports

ne_items|line_item_options|orders|price_tiers|prices|shipping_categories|sku_lists|sku_list_items|sku_options|skus|s
tock_items|stock_transfers|tags|tax_categories [-p <value>] [-D ,|;|||TAB (-C -i <value>)] [-b | -q | ]
tock_items|stock_transfers|tags|tax_categories [-p <value>] (-C -i <value>) [-b | -q | ]
FLAGS
-C, --csv accept input file in CSV format
-D, --delimiter=<option> the delimiter character used in the CSV input file (one
of ',', ';', '|', TAB)
<options: ,|;|||TAB>
-b, --blind execute in blind mode without showing the progress

@@ -88,0 +85,0 @@ monitor

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