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

@commercelayer/cli

Package Overview
Dependencies
Maintainers
3
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercelayer/cli - npm Package Compare versions

Comparing version 2.3.2 to 3.0.0-alpha.0

lib/commands/applications/add.d.ts

8

lib/commands/applications/current.d.ts

@@ -1,2 +0,3 @@

import { Command, flags } from '@oclif/command';
import { Command } from '@oclif/command';
import { AppInfo } from '../../config';
export default class ApplicationsCurrent extends Command {

@@ -7,8 +8,7 @@ static description: string;

static flags: {
organization: flags.IOptionFlag<string | undefined>;
live: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
domain: flags.IOptionFlag<string | undefined>;
info: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
json: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
};
run(): Promise<void>;
}
export declare const printCurrent: (app: AppInfo) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printCurrent = void 0;
const tslib_1 = require("tslib");
const command_1 = require("@oclif/command");
const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
const config_1 = (0, tslib_1.__importStar)(require("../../config"));
const common_1 = require("../../common");
const config_1 = require("../../config");
const util_1 = require("util");

@@ -12,57 +12,24 @@ class ApplicationsCurrent extends command_1.Command {

const { flags } = this.parse(ApplicationsCurrent);
if (flags.organization) {
const app = {
key: (0, common_1.appKey)(flags.organization, flags.domain),
mode: (0, common_1.execMode)(flags.live),
};
if ((0, config_1.configFileExists)(this.config, app))
config_1.default.set(config_1.ConfigParams.currentApplication, { key: app.key, mode: app.mode });
else
this.error(`Unable to find ${chalk_1.default.italic.bold(app.mode)} configuration file for application ${chalk_1.default.italic.bold(app.key)}`, {
suggestions: [`Execute ${chalk_1.default.italic('login')} command to access and operate on ${chalk_1.default.bold(flags.organization)} organization`],
});
}
const stored = (0, config_1.configParam)(config_1.ConfigParams.currentApplication);
if (stored) {
const none = (stored.key === undefined) || (stored.key === '');
const current = none ? 'none' : `${stored.key}.${stored.mode}`;
const color = none ? chalk_1.default.italic.dim : chalk_1.default.bold.yellowBright;
this.log(`\nCurrent application: ${color(current)}\n`);
const info = (0, config_1.readConfigFile)(this.config, stored);
this.log(`\nCurrent application: ${(0, exports.printCurrent)(info)}\n`);
if (flags.info) {
this.log(chalk_1.default.blueBright('-= Application Info =-'));
this.log(flags.json ? JSON.stringify(info, null, 4) : (0, util_1.inspect)(info, false, null, true));
this.log();
}
}
else
this.warn(chalk_1.default.italic('No current application defined'));
if (flags.info) {
const info = (0, config_1.readConfigFile)(this.config, stored);
this.log(chalk_1.default.blueBright('-= Application Info =-'));
// this.log(JSON.stringify(info, null, 4))
this.log((0, util_1.inspect)(info, false, null, true));
this.log();
}
this.warn(chalk_1.default.italic('\nNo current application defined\n'));
}
}
exports.default = ApplicationsCurrent;
ApplicationsCurrent.description = 'set or show the current CLI application';
ApplicationsCurrent.description = 'show the current application';
ApplicationsCurrent.aliases = ['app:current'];
ApplicationsCurrent.examples = [
'$ commercelayer applications:current',
'$ commercelayer app:current -o <organizationSlug> --live',
'$ commercelayer app:current --info',
];
ApplicationsCurrent.flags = {
// help: flags.help({ char: 'h' }),
organization: command_1.flags.string({
char: 'o',
description: 'organization slug',
required: false,
}),
live: command_1.flags.boolean({
description: 'live execution mode',
dependsOn: ['organization'],
}),
domain: command_1.flags.string({
char: 'd',
description: 'api domain',
required: false,
hidden: true,
dependsOn: ['organization'],
}),
info: command_1.flags.boolean({

@@ -72,2 +39,13 @@ hidden: true,

}),
json: command_1.flags.boolean({
char: 'j',
dependsOn: ['info'],
}),
};
const printCurrent = (app) => {
if (!app.key || (app.key === ''))
return chalk_1.default.italic.dim('No current application');
const mode = `${((app.mode === 'live') ? chalk_1.default.greenBright : chalk_1.default.yellowBright)(app.mode)}`;
return `${chalk_1.default.bold.yellowBright(app.name)} [ ${app.organization} | ${mode} ]`;
};
exports.printCurrent = printCurrent;

@@ -1,2 +0,2 @@

import { Command } from '@oclif/command';
import { Command, flags } from '@oclif/command';
export default class ApplicationsIndex extends Command {

@@ -6,5 +6,8 @@ static description: string;

static examples: string[];
static flags: {};
static flags: {
kind: flags.IOptionFlag<string | undefined>;
mode: flags.IOptionFlag<string | undefined>;
};
static args: never[];
run(): Promise<void>;
}

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

async run() {
this.parse(ApplicationsIndex);
const { flags } = this.parse(ApplicationsIndex);
let configData;
try {
const configFiles = fs_1.default.readdirSync(this.config.configDir).filter(f => f.endsWith('.config.json'));
const configFiles = fs_1.default.readdirSync(this.config.configDir).filter(f => f.endsWith('.config.json') && (f.split('.').length === 5));
configData = configFiles.map(cf => {

@@ -22,2 +22,6 @@ const appConfig = fs_1.default.readFileSync(path_1.default.join(this.config.configDir, cf), { encoding: 'utf-8' });

});
if (flags.kind)
configData = configData.filter(a => a.kind === flags.kind);
if (flags.mode)
configData = configData.filter(a => a.mode === flags.mode);
}

@@ -29,19 +33,23 @@ catch (error) {

this.log();
cli_ux_1.default.table(configData, {
key: { header: 'APPLICATION (KEY)', minWidth: 20, get: row => (current && (current.key === row.key) && (current.mode === row.mode)) ? chalk_1.default.magentaBright(`${row.key} *`) : chalk_1.default.blueBright(row.key) },
// slug: { header: ' SLUG ', get: row => ` ${row.slug} ` },
name: { header: 'NAME', get: row => `${row.name}` },
organization: { header: 'ORGANIZATION', get: row => `${row.organization}` },
type: { header: 'TYPE' },
scope: { header: 'SCOPE', minWidth: 10, get: row => printScope(row.scope) },
customer: { header: 'PWD', get: row => (row.email && row.password) ? chalk_1.default.cyanBright((0, common_1.center)('\u25C9', 'PWD'.length)) : '' },
mode: { header: 'MODE', get: row => `${(row.mode === 'live') ? chalk_1.default.greenBright(row.mode) : chalk_1.default.yellowBright(row.mode)}` },
}, {
printLine: this.log,
});
if (configData.length > 0) {
cli_ux_1.default.table(configData, {
current: { header: '[*]', minWidth: 3, get: row => (0, common_1.appKeyMatch)(current, row) ? chalk_1.default.magentaBright(' * ') : ' ' },
organization: { header: 'ORGANIZATION', get: row => currentColor(row, current)(row.organization) },
name: { header: 'APPLICATION', get: row => currentColor(row, current)(row.name) },
kind: { header: 'KIND', get: row => currentColor(row, current)(row.kind) },
scope: { header: 'SCOPE', minWidth: 10, get: row => currentColor(row, current)(printScope(row.scope)) },
customer: { header: 'PWD', get: row => (row.email && row.password) ? chalk_1.default.cyanBright((0, common_1.center)('\u25C9', 'PWD'.length)) : '' },
key: { header: 'SLUG', get: row => currentColor(row, current)(row.key) },
id: { header: 'ID', get: row => currentColor(row, current)(row.id) },
mode: { header: 'MODE', get: row => `${((row.mode === 'live') ? chalk_1.default.greenBright : chalk_1.default.yellowBright)(row.mode)}` },
alias: { header: 'ALIAS', get: row => chalk_1.default.cyanBright(row.alias || '') },
}, {
printLine: this.log,
});
if (current)
this.log(chalk_1.default.italic.magentaBright('\n(*) Current application'));
}
else
this.log(chalk_1.default.italic('No application found'));
this.log();
if (current) {
this.log(chalk_1.default.italic.magentaBright('(*) Current application'));
this.log();
}
}

@@ -57,5 +65,17 @@ }

ApplicationsIndex.flags = {
// help: flags.help({char: 'h'}),
kind: command_1.flags.string({
char: 'k',
description: 'application kind',
options: (0, config_1.configParam)(config_1.ConfigParams.applicationTypeCheck),
}),
mode: command_1.flags.string({
char: 'm',
description: 'execution mode',
options: ['test', 'live'],
}),
};
ApplicationsIndex.args = [];
const currentColor = (app, current) => {
return ((0, common_1.appKeyMatch)(current, app) ? chalk_1.default.magentaBright : chalk_1.default.visible);
};
const printScope = (scope) => {

@@ -62,0 +82,0 @@ if (scope) {

import { Command, flags } from '@oclif/command';
import { AppAuth } from '../../config';
import { AppInfo, AppAuth } from '../../config';
import { AuthReturnType, AuthScope } from '@commercelayer/js-auth/dist/typings';
export default class ApplicationsLogin extends Command {

@@ -15,5 +16,8 @@ static description: string;

password: flags.IOptionFlag<string | undefined>;
alias: flags.IOptionFlag<string>;
};
run(): Promise<void>;
}
export declare const getAccessToken: (auth: AppAuth) => Promise<any>;
export declare const getAccessToken: (auth: AppAuth) => AuthReturnType;
export declare const getApplicationInfo: (auth: AppAuth, accessToken: string) => Promise<AppInfo>;
export declare const checkScope: (scopes: string[]) => AuthScope;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccessToken = void 0;
exports.checkScope = exports.getApplicationInfo = exports.getAccessToken = void 0;
const tslib_1 = require("tslib");

@@ -13,2 +13,3 @@ const command_1 = require("@oclif/command");

const token_1 = require("./token");
const current_1 = require("./current");
class ApplicationsLogin extends command_1.Command {

@@ -19,3 +20,3 @@ async run() {

this.error(`You must provide one of the arguments ${chalk_1.default.italic('clientSecret')} and ${chalk_1.default.italic('scope')}`);
const scope = checkScope(flags.scope);
const scope = (0, exports.checkScope)(flags.scope);
const config = {

@@ -32,9 +33,10 @@ clientId: flags.clientId,

const token = await (0, exports.getAccessToken)(config);
const app = await getApplicationInfo(config, (token === null || token === void 0 ? void 0 : token.accessToken) || '');
const app = await (0, exports.getApplicationInfo)(config, (token === null || token === void 0 ? void 0 : token.accessToken) || '');
const typeCheck = (0, config_1.configParam)(config_1.ConfigParams.applicationTypeCheck);
if (typeCheck) {
if (!typeCheck.includes(app.type))
this.error(`The credentials provided are associated to an application of type ${chalk_1.default.red.italic(app.type)} while the only allowed types are: ${chalk_1.default.green.italic(typeCheck.join(','))}`, { suggestions: [`Double check your credentials or access the online dashboard of ${chalk_1.default.bold(app.organization)} and create a new valid application `] });
if (!typeCheck.includes(app.kind))
this.error(`The credentials provided are associated to an application of type ${chalk_1.default.red.italic(app.kind)} while the only allowed types are: ${chalk_1.default.green.italic(typeCheck.join(','))}`, { suggestions: [`Double check your credentials or access the online dashboard of ${chalk_1.default.bold(app.organization)} and create a new valid application `] });
}
app.key = (0, common_1.appKey)(app.slug, flags.domain);
app.alias = flags.alias || '';
(0, config_1.createConfigDir)(this.config);

@@ -44,6 +46,5 @@ const overwrite = (0, config_1.configFileExists)(this.config, app);

(0, config_1.writeTokenFile)(this.config, app, token === null || token === void 0 ? void 0 : token.data);
config_1.default.set(config_1.ConfigParams.currentApplication, { key: app.key, mode: app.mode });
config_1.default.set(config_1.ConfigParams.currentApplication, { key: app.key, mode: app.mode, id: app.id });
const current = (0, config_1.configParam)(config_1.ConfigParams.currentApplication);
this.log(`\nCurrent application: ${chalk_1.default.bold.yellowBright(current.key + '.' + current.mode)}`);
// this.log(`\n${chalk.bold.greenBright('Login successful!')} ${chalk.bold(app.mode)} configuration and access token have been locally ${overwrite ? 'overwritten' : 'saved'} for application ${chalk.italic.bold(app.name)} of organization ${chalk.italic.bold(app.organization)}\n`)
this.log(`\nCurrent application: ${(0, current_1.printCurrent)((0, common_1.appKeyMatch)(current, app) ? app : current)}`);
this.log(`\n${chalk_1.default.bold.greenBright('Login successful!')} Your configuration has been stored locally${overwrite ? ' (overwriting the existing one)' : ''}. You can now interact with ${chalk_1.default.italic.bold(app.organization)} organization\n`);

@@ -61,6 +62,6 @@ }

exports.default = ApplicationsLogin;
ApplicationsLogin.description = 'execute login to a CLI Commerce Layer application';
ApplicationsLogin.aliases = ['app:login', 'app:add', 'applications:add'];
ApplicationsLogin.description = 'execute login to a Commerce Layer application';
ApplicationsLogin.aliases = ['app:login'];
ApplicationsLogin.examples = [
'$ commercelayer applications:login -o <organizationSlug> -i <clientId> -s <clientSecret>',
'$ commercelayer applications:login -o <organizationSlug> -i <clientId> -s <clientSecret> -a <applicationAlias>',
];

@@ -76,3 +77,3 @@ ApplicationsLogin.flags = {

char: 'i',
description: 'organization client_id',
description: 'application client_id',
required: true,

@@ -82,3 +83,3 @@ }),

char: 's',
description: 'organization client_secret',
description: 'application client_secret',
required: false,

@@ -106,5 +107,11 @@ }),

char: 'p',
description: 'secret password',
description: 'customer secret password',
dependsOn: ['email'],
}),
alias: command_1.flags.string({
char: 'a',
description: 'the alias you want to associate to the application',
multiple: false,
required: true,
}),
};

@@ -149,5 +156,6 @@ const getAccessToken = async (auth) => {

mode: mode,
type: app.kind || '',
kind: app.kind || '',
name: app.name || '',
baseUrl: (0, common_1.baseURL)(auth.slug, auth.domain),
id: app.id,
}, auth);

@@ -157,2 +165,3 @@ // if (Array.isArray(appInfo.scope) && (appInfo.scope.length === 0)) appInfo.scope = undefined

};
exports.getApplicationInfo = getApplicationInfo;
const checkScope = (scopes) => {

@@ -173,1 +182,2 @@ const scope = [];

};
exports.checkScope = checkScope;

@@ -9,2 +9,3 @@ import { Command, flags } from '@oclif/command';

domain: flags.IOptionFlag<string | undefined>;
id: flags.IOptionFlag<string>;
revoke: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;

@@ -11,0 +12,0 @@ };

@@ -16,4 +16,6 @@ "use strict";

mode: (0, common_1.execMode)(flags.live),
id: flags.id,
};
if ((0, config_1.configFileExists)(this.config, app)) {
this.log();
const ok = await cli_ux_1.default.confirm(`>> Do you really want to remove this application from CLI configuration? ${chalk_1.default.dim('[Yy/Nn]')}`);

@@ -30,3 +32,4 @@ if (ok) {

(0, config_1.deleteTokenFile)(this.config, app);
config_1.default.delete(config_1.ConfigParams.currentApplication);
if ((0, common_1.appKeyMatch)(app, (0, config_1.configParam)(config_1.ConfigParams.currentApplication)))
config_1.default.delete(config_1.ConfigParams.currentApplication);
}

@@ -63,2 +66,6 @@ (0, config_1.deleteConfigFile)(this.config, app);

}),
id: command_1.flags.string({
description: 'application id',
required: true,
}),
revoke: command_1.flags.boolean({

@@ -65,0 +72,0 @@ char: 'r',

@@ -13,2 +13,3 @@ import { Command, flags } from '@oclif/command';

domain: flags.IOptionFlag<string | undefined>;
id: flags.IOptionFlag<string | undefined>;
save: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;

@@ -15,0 +16,0 @@ info: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;

@@ -18,2 +18,3 @@ "use strict";

let mode = (0, common_1.execMode)(flags.live);
let id = flags.id;
if (!organization) {

@@ -23,2 +24,3 @@ const current = (0, config_1.currentApplication)();

mode = (current === null || current === void 0 ? void 0 : current.mode) || 'test';
id = current === null || current === void 0 ? void 0 : current.id;
}

@@ -28,2 +30,3 @@ const app = {

mode,
id: id || '',
};

@@ -50,3 +53,3 @@ if (!(0, config_1.configFileExists)(this.config, app))

if (accessToken) {
this.log(`\nAccess token for application ${chalk_1.default.bold.yellowBright(`${app.key}.${app.mode}`)}`);
this.log(`\nAccess token for application ${chalk_1.default.bold.yellowBright(`${app.key}.${app.mode} - ${app.id}`)}`);
this.log(`\n${chalk_1.default.blueBright(accessToken)}\n`);

@@ -102,2 +105,7 @@ if (flags.shared && expMinutes) {

}),
id: command_1.flags.string({
char: 'k',
description: 'application id',
dependsOn: ['organization'],
}),
save: command_1.flags.boolean({

@@ -104,0 +112,0 @@ char: 's',

@@ -0,1 +1,2 @@

import { AppKey } from './config';
declare type ApiMode = 'test' | 'live';

@@ -6,2 +7,4 @@ export type { ApiMode };

declare const appKey: (slug: string, domain: string | undefined) => string;
declare const appKeyValid: (appKey: AppKey) => boolean;
declare const appKeyMatch: (app1: AppKey, app2: AppKey) => boolean;
declare const sleep: (ms: number) => Promise<unknown>;

@@ -11,2 +14,3 @@ declare const extractDomain: (baseUrl: string) => string | undefined;

declare const center: (str: string, width: number) => string;
export { baseURL, execMode, appKey, sleep, extractDomain, print, center };
declare const maxLength: (values: any[], field: string) => number;
export { baseURL, execMode, appKey, appKeyValid, appKeyMatch, sleep, extractDomain, print, center, maxLength };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.center = exports.print = exports.extractDomain = exports.sleep = exports.appKey = exports.execMode = exports.baseURL = void 0;
exports.maxLength = exports.center = exports.print = exports.extractDomain = exports.sleep = exports.appKeyMatch = exports.appKeyValid = exports.appKey = exports.execMode = exports.baseURL = void 0;
const tslib_1 = require("tslib");

@@ -19,2 +19,10 @@ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));

exports.appKey = appKey;
const appKeyValid = (appKey) => {
return (appKey.key !== '') && (appKey.id !== '');
};
exports.appKeyValid = appKeyValid;
const appKeyMatch = (app1, app2) => {
return app1 && app2 && (app1.key === app2.key) && (app1.mode === app2.mode) && (app1.id === app2.id);
};
exports.appKeyMatch = appKeyMatch;
const sleep = async (ms) => {

@@ -45,1 +53,7 @@ return new Promise(resolve => setTimeout(resolve, ms));

exports.center = center;
const maxLength = (values, field) => {
return values.reduce((ml, v) => {
return Math.max(ml, v[field].length);
}, 0);
};
exports.maxLength = maxLength;

@@ -10,2 +10,4 @@ import Configstore from 'configstore';

mode: ApiMode;
id: string;
alias?: string;
}

@@ -23,3 +25,3 @@ interface AppAuth {

organization: string;
type: string;
kind: string;
name: string;

@@ -30,4 +32,4 @@ baseUrl?: string;

declare const createConfigDir: (config: Config.IConfig) => void;
declare const configFilePath: (config: Config.IConfig, { key, mode }: AppKey) => string;
declare const tokenFilePath: (config: Config.IConfig, { key, mode }: AppKey) => string;
declare const configFilePath: (config: Config.IConfig, { key, mode, id }: AppKey) => string;
declare const tokenFilePath: (config: Config.IConfig, { key, mode, id }: AppKey) => string;
declare const configFileExists: (config: Config.IConfig, app: AppKey) => boolean;

@@ -41,6 +43,12 @@ declare const tokenFileExists: (config: Config.IConfig, app: AppKey) => boolean;

declare const deleteTokenFile: (config: Config.IConfig, app: AppKey) => boolean;
declare const readConfigDir: (config: Config.IConfig, filter: {
key?: string;
mode?: string;
id?: string;
}) => AppInfo[];
export { createConfigDir };
export { configFilePath, configFileExists, writeConfigFile, readConfigFile, deleteConfigFile };
export { tokenFilePath, tokenFileExists, writeTokenFile, readTokenFile, deleteTokenFile };
declare const currentApplication: () => AppKey | undefined;
export { readConfigDir };
declare const currentApplication: () => AppInfo | undefined;
declare const currentOrganization: () => string | undefined;

@@ -47,0 +55,0 @@ declare const currentModeLive: () => boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.paramDefault = exports.paramExists = exports.paramEditable = exports.configParam = exports.ConfigParamsEditable = exports.ConfigParams = exports.currentModeLive = exports.currentOrganization = exports.currentApplication = exports.deleteTokenFile = exports.readTokenFile = exports.writeTokenFile = exports.tokenFileExists = exports.tokenFilePath = exports.deleteConfigFile = exports.readConfigFile = exports.writeConfigFile = exports.configFileExists = exports.configFilePath = exports.createConfigDir = void 0;
exports.paramDefault = exports.paramExists = exports.paramEditable = exports.configParam = exports.ConfigParamsEditable = exports.ConfigParams = exports.currentModeLive = exports.currentOrganization = exports.currentApplication = exports.readConfigDir = exports.deleteTokenFile = exports.readTokenFile = exports.writeTokenFile = exports.tokenFileExists = exports.tokenFilePath = exports.deleteConfigFile = exports.readConfigFile = exports.writeConfigFile = exports.configFileExists = exports.configFilePath = exports.createConfigDir = void 0;
const tslib_1 = require("tslib");

@@ -15,8 +15,8 @@ const configstore_1 = (0, tslib_1.__importDefault)(require("configstore"));

exports.createConfigDir = createConfigDir;
const configFilePath = (config, { key, mode }) => {
return path_1.default.join(config.configDir, `${key}.${mode}.config.json`);
const configFilePath = (config, { key, mode, id }) => {
return path_1.default.join(config.configDir, `${key}.${id}.${mode}.config.json`);
};
exports.configFilePath = configFilePath;
const tokenFilePath = (config, { key, mode }) => {
return path_1.default.join(config.configDir, `${key}.${mode}.token.json`);
const tokenFilePath = (config, { key, mode, id }) => {
return path_1.default.join(config.configDir, `${key}.${id}.${mode}.token.json`);
};

@@ -68,2 +68,29 @@ exports.tokenFilePath = tokenFilePath;

exports.deleteTokenFile = deleteTokenFile;
const readConfigDir = (config, filter) => {
const files = fs_1.default.readdirSync(config.configDir).map(f => {
const fc = f.split('.');
const key = fc[0];
const id = fc[1];
const mode = fc[2];
const type = fc[3];
const ext = fc[4];
if (fc.length < 5)
return undefined;
if (filter.key && (key !== filter.key))
return undefined;
if (filter.id && (id !== filter.id))
return undefined;
if (filter.mode && (mode !== filter.mode))
return undefined;
if (type !== 'config')
return undefined;
if (ext !== 'json')
return undefined;
return { key, id, mode };
}).filter(f => f);
return files.map(f => {
return readConfigFile(config, f);
});
};
exports.readConfigDir = readConfigDir;
const currentApplication = () => {

@@ -70,0 +97,0 @@ return clicfg.get(ConfigParams.currentApplication);

@@ -34,5 +34,6 @@ "use strict";

organization: command_1.flags.string({ char: 'o', hidden: true }),
live: command_1.flags.boolean({ hidden: true, dependsOn: ['organization'] }),
live: command_1.flags.boolean({ hidden: true /* , dependsOn: ['organization'] */ }),
domain: command_1.flags.string({ char: 'd', hidden: true, dependsOn: ['organization'] }),
accessToken: command_1.flags.string({ hidden: true }),
id: command_1.flags.string({ char: 'k', hidden: true, dependsOn: ['organization'] }),
};

@@ -43,6 +44,7 @@ const { flags } = (0, parser_1.parse)(opts.argv, { strict: false, flags: flagConfig });

mode: (0, common_1.execMode)(flags.live),
id: flags.id || '',
};
let configData;
// No organization and domain passed on command line, looking for saved current application
if (app.key === '') {
if (!(0, common_1.appKeyValid)(app)) {
const current = (0, config_1.configParam)(config_1.ConfigParams.currentApplication);

@@ -54,4 +56,4 @@ if (current !== undefined) {

if (typeCheck) {
if (!typeCheck.includes(configData.type))
this.error(`The current application (${chalk_1.default.redBright(configData.key)}) has an invalid type: ${chalk_1.default.red.italic(configData.type)}, while the only accepted type are ${chalk_1.default.green.italic(typeCheck.join(','))}\nPlease use a correct one or access the online dashboard of ${configData.organization} and create a new valid application`);
if (!typeCheck.includes(configData.kind))
this.error(`The current application (${chalk_1.default.redBright(configData.key)}) has an invalid type: ${chalk_1.default.red.italic(configData.kind)}, while the only accepted type are ${chalk_1.default.green.italic(typeCheck.join(','))}\nPlease use a correct one or access the online dashboard of ${configData.organization} and create a new valid application`);
}

@@ -66,3 +68,3 @@ opts.argv.push('--organization=' + configData.slug);

// No current application saved in configuration
if (app.key === '')
if (!(0, common_1.appKeyValid)(app))
return;

@@ -101,3 +103,6 @@ // if accessToken flag has not ben passed in command line

opts.argv.splice(opts.argv.indexOf('--live'), 1);
// If present remove application id flag option
if (opts.argv.includes('--id'))
opts.argv.splice(opts.argv.indexOf('--id'), 2);
};
exports.default = hook;

@@ -1,1 +0,1 @@

{"version":"2.3.2","commands":{"noc":{"id":"noc","pluginName":"@commercelayer/cli","pluginType":"core","hidden":true,"aliases":[],"flags":{"organization":{"name":"organization","type":"option","hidden":true,"required":false},"accessToken":{"name":"accessToken","type":"option","hidden":true,"required":false}},"args":[]},"applications:current":{"id":"applications:current","description":"set or show the current CLI application","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:current"],"examples":["$ commercelayer applications:current","$ commercelayer app:current -o <organizationSlug> --live"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":false},"live":{"name":"live","type":"boolean","description":"live execution mode","allowNo":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"info":{"name":"info","type":"boolean","hidden":true,"allowNo":false}},"args":[]},"applications":{"id":"applications","description":"show a list of all (logged in) available CLI applications","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:list","applications:list","app:available","applications:available","apps"],"examples":["$ commercelayer applications","$ cl applications"],"flags":{},"args":[]},"applications:login":{"id":"applications:login","description":"execute login to a CLI Commerce Layer application","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:login","app:add","applications:add"],"examples":["$ commercelayer applications:login -o <organizationSlug> -i <clientId> -s <clientSecret>"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":true},"clientId":{"name":"clientId","type":"option","char":"i","description":"organization client_id","required":true},"clientSecret":{"name":"clientSecret","type":"option","char":"s","description":"organization client_secret","required":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"scope":{"name":"scope","type":"option","char":"S","description":"access token scope (market, stock location)","required":false},"email":{"name":"email","type":"option","char":"e","description":"customer email"},"password":{"name":"password","type":"option","char":"p","description":"secret password"}},"args":[]},"applications:logout":{"id":"applications:logout","description":"remove an application from CLI local configuration","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:logout","app:remove","applications:remove"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":true},"live":{"name":"live","type":"boolean","description":"live execution mode","allowNo":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"revoke":{"name":"revoke","type":"boolean","char":"r","description":"revoke current access token","allowNo":false}},"args":[]},"applications:token":{"id":"applications:token","description":"get a new access token from Commerce Layer API","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:token"],"examples":["$ commercelayer applications:token","$ commercelayer app:token -o <organizationSlug> --live --save"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":false},"live":{"name":"live","type":"boolean","description":"live execution mode","allowNo":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"save":{"name":"save","type":"boolean","char":"s","description":"save access token","allowNo":false},"info":{"name":"info","type":"boolean","char":"i","description":"show token info","allowNo":false},"shared":{"name":"shared","type":"option","char":"S","description":"organization shared secret","hidden":true},"minutes":{"name":"minutes","type":"option","char":"M","description":"minutes to token expiration [2, 120]","hidden":true}},"args":[]},"config:default":{"id":"config:default","description":"reset CLI configuration to default values","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"F","description":"mandatory flag to avoid unintentional config changes","hidden":true,"required":false,"allowNo":false}},"args":[]},"config:del":{"id":"config:del","description":"delete a CLI configuration parameter","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"F","description":"mandatory flag to avoid unintentional config changes","hidden":true,"required":false,"allowNo":false}},"args":[{"name":"param","description":"configuration parameter name","required":true}]},"config:get":{"id":"config:get","description":"get a CLI configuration parameter","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"param","description":"configuration parameter name","required":true}]},"config:set":{"id":"config:set","description":"set a CLI configuration parameter","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"F","description":"mandatory flag to avoid unintentional config changes","hidden":true,"required":false,"allowNo":false}},"args":[{"name":"param","description":"configuration parameter name","required":true},{"name":"value","description":"value to be saved in configuration file","required":true}]},"config:show":{"id":"config:show","description":"show current CLI configuration","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"plugins:available":{"id":"plugins:available","description":"show all available Commerce Layer CLI plugins","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"examples":["$ commercelayer plugins:available"],"flags":{"hidden":{"name":"hidden","type":"boolean","char":"H","description":"show also enabled but hidden plugins","hidden":true,"allowNo":false}},"args":[]},"util:jwt":{"id":"util:jwt","description":"decode a Commerce Layer JWT","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["jwt"],"flags":{},"args":[{"name":"token","description":"the token to decode","required":true}]}}}
{"version":"3.0.0-alpha.0","commands":{"noc":{"id":"noc","pluginName":"@commercelayer/cli","pluginType":"core","hidden":true,"aliases":[],"flags":{"organization":{"name":"organization","type":"option","hidden":true,"required":false},"accessToken":{"name":"accessToken","type":"option","hidden":true,"required":false}},"args":[]},"applications:add":{"id":"applications:add","description":"add a new Commerce Layer application to CLI config","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:add"],"examples":["$ commercelayer applications:add -o <organizationSlug> -i <clientId> -s <clientSecret> -a <applicationAlias>"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":true},"clientId":{"name":"clientId","type":"option","char":"i","description":"application client_id","required":true},"clientSecret":{"name":"clientSecret","type":"option","char":"s","description":"application client_secret","required":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"scope":{"name":"scope","type":"option","char":"S","description":"access token scope (market, stock location)","required":false},"email":{"name":"email","type":"option","char":"e","description":"customer email"},"password":{"name":"password","type":"option","char":"p","description":"customer secret password"},"alias":{"name":"alias","type":"option","char":"a","description":"the alias you want to associate to the application","required":true}},"args":[]},"applications:current":{"id":"applications:current","description":"show the current application","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:current"],"examples":["$ commercelayer applications:current","$ commercelayer app:current --info"],"flags":{"info":{"name":"info","type":"boolean","hidden":true,"allowNo":false},"json":{"name":"json","type":"boolean","char":"j","allowNo":false}},"args":[]},"applications":{"id":"applications","description":"show a list of all (logged in) available CLI applications","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:list","applications:list","app:available","applications:available","apps"],"examples":["$ commercelayer applications","$ cl applications"],"flags":{"kind":{"name":"kind","type":"option","char":"k","description":"application kind","options":["cli","sales_channel","integration"]},"mode":{"name":"mode","type":"option","char":"m","description":"execution mode","options":["test","live"]}},"args":[]},"applications:info":{"id":"applications:info","description":"show application details","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:info"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"id":{"name":"id","type":"option","description":"application id","required":true},"json":{"name":"json","type":"boolean","char":"j","allowNo":false}},"args":[]},"applications:login":{"id":"applications:login","description":"execute login to a Commerce Layer application","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:login"],"examples":["$ commercelayer applications:login -o <organizationSlug> -i <clientId> -s <clientSecret> -a <applicationAlias>"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":true},"clientId":{"name":"clientId","type":"option","char":"i","description":"application client_id","required":true},"clientSecret":{"name":"clientSecret","type":"option","char":"s","description":"application client_secret","required":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"scope":{"name":"scope","type":"option","char":"S","description":"access token scope (market, stock location)","required":false},"email":{"name":"email","type":"option","char":"e","description":"customer email"},"password":{"name":"password","type":"option","char":"p","description":"customer secret password"},"alias":{"name":"alias","type":"option","char":"a","description":"the alias you want to associate to the application","required":true}},"args":[]},"applications:logout":{"id":"applications:logout","description":"remove an application from CLI local configuration","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:logout","app:remove","applications:remove"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":true},"live":{"name":"live","type":"boolean","description":"live execution mode","allowNo":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"id":{"name":"id","type":"option","description":"application id","required":true},"revoke":{"name":"revoke","type":"boolean","char":"r","description":"revoke current access token","allowNo":false}},"args":[]},"applications:switch":{"id":"applications:switch","description":"switch applications","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:switch"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":false},"live":{"name":"live","type":"boolean","description":"live execution mode","allowNo":false},"mode":{"name":"mode","type":"option","char":"m","description":"execution mode","options":["test","live"]},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"id":{"name":"id","type":"option","description":"application id"},"kind":{"name":"kind","type":"option","char":"k","description":"application kind","options":["cli","sales_channel","integration"]},"alias":{"name":"alias","type":"option","char":"a","description":"the alias associated to the application"}},"args":[]},"applications:token":{"id":"applications:token","description":"get a new access token from Commerce Layer API","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["app:token"],"examples":["$ commercelayer applications:token","$ commercelayer app:token -o <organizationSlug> --live --save"],"flags":{"organization":{"name":"organization","type":"option","char":"o","description":"organization slug","required":false},"live":{"name":"live","type":"boolean","description":"live execution mode","allowNo":false},"domain":{"name":"domain","type":"option","char":"d","description":"api domain","hidden":true,"required":false},"id":{"name":"id","type":"option","char":"k","description":"application id"},"save":{"name":"save","type":"boolean","char":"s","description":"save access token","allowNo":false},"info":{"name":"info","type":"boolean","char":"i","description":"show token info","allowNo":false},"shared":{"name":"shared","type":"option","char":"S","description":"organization shared secret","hidden":true},"minutes":{"name":"minutes","type":"option","char":"M","description":"minutes to token expiration [2, 120]","hidden":true}},"args":[]},"config:default":{"id":"config:default","description":"reset CLI configuration to default values","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"F","description":"mandatory flag to avoid unintentional config changes","hidden":true,"required":false,"allowNo":false}},"args":[]},"config:del":{"id":"config:del","description":"delete a CLI configuration parameter","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"F","description":"mandatory flag to avoid unintentional config changes","hidden":true,"required":false,"allowNo":false}},"args":[{"name":"param","description":"configuration parameter name","required":true}]},"config:get":{"id":"config:get","description":"get a CLI configuration parameter","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"param","description":"configuration parameter name","required":true}]},"config:set":{"id":"config:set","description":"set a CLI configuration parameter","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","char":"F","description":"mandatory flag to avoid unintentional config changes","hidden":true,"required":false,"allowNo":false}},"args":[{"name":"param","description":"configuration parameter name","required":true},{"name":"value","description":"value to be saved in configuration file","required":true}]},"config:show":{"id":"config:show","description":"show current CLI configuration","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"plugins:available":{"id":"plugins:available","description":"show all available Commerce Layer CLI plugins","pluginName":"@commercelayer/cli","pluginType":"core","aliases":[],"examples":["$ commercelayer plugins:available"],"flags":{"hidden":{"name":"hidden","type":"boolean","char":"H","description":"show also enabled but hidden plugins","hidden":true,"allowNo":false}},"args":[]},"util:jwt":{"id":"util:jwt","description":"decode a Commerce Layer JWT","pluginName":"@commercelayer/cli","pluginType":"core","aliases":["jwt"],"flags":{},"args":[{"name":"token","description":"the token to decode","required":true}]}}}
{
"name": "@commercelayer/cli",
"description": "Commerce Layer CLI",
"version": "2.3.2",
"version": "3.0.0-alpha.0",
"author": "Pierluigi Viti <pierluigi@commercelayer.io>",

@@ -17,2 +17,3 @@ "bin": {

"@types/configstore": "^4.0.0",
"@types/inquirer": "^8.1.3",
"@types/jsonwebtoken": "^8.5.1",

@@ -107,2 +108,3 @@ "@types/mocha": "^5.2.7",

"configstore": "^5.0.1",
"inquirer": "^8.2.0",
"jsonwebtoken": "^8.5.1",

@@ -109,0 +111,0 @@ "lodash": "^4.17.21",

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