New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

flex-dev-utils

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flex-dev-utils - npm Package Compare versions

Comparing version

to
3.12.0

export interface AuthConfig {
accountSid: string;
authToken: string;
username: string;
password: string;
}
interface Credential {
account: string;
username: string;
password: string;

@@ -33,7 +33,7 @@ }

*
* @param account the account name
* @param username the username
* @param password the password
* @private
*/
export declare const _saveCredential: (account: string, password: string) => Promise<void>;
export declare const _saveCredential: (username: string, password: string) => Promise<void>;
/**

@@ -46,2 +46,2 @@ * Keytar is required optionally and so may not exist.

export declare const _getKeytar: () => any;
export {};
export default getCredential;

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

var errors_1 = require("./errors");
var index_1 = require("./index");
var inquirer_1 = require("./inquirer");

@@ -50,3 +51,7 @@ var validators_1 = require("./validators");

}
catch (e) { /* no-op */ }
catch (e) {
if (!process.env.CI) {
index_1.logger.debug('Failed to require keytar', e);
}
}
var SERVICE_NAME = 'com.twilio.flex.plugins.builder';

@@ -75,9 +80,9 @@ var accountSidQuestion = {

exports.getCredential = function () { return __awaiter(_this, void 0, void 0, function () {
var accountSid, authToken, missingCredentials, credential;
var username, password, missingCredentials, credential;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
missingCredentials = !process.env.TWILIO_ACCOUNT_SID || !process.env.TWILIO_AUTH_TOKEN;
missingCredentials = !((process.env.TWILIO_ACCOUNT_SID && process.env.TWILIO_AUTH_TOKEN) || (process.env.TWILIO_API_KEY && !process.env.TWILIO_API_SECRET));
if (process.env.CI && missingCredentials) {
throw new errors_1.FlexPluginError('❌ Running script in CI, but no AccountSid and/or AuthToken was provided');
throw new errors_1.FlexPluginError('❌. Running script in CI, but no AccountSid/AuthToken or API Key/Secret was provided');
}

@@ -90,31 +95,39 @@ if (!(process.env.TWILIO_ACCOUNT_SID && process.env.TWILIO_AUTH_TOKEN)) return [3 /*break*/, 2];

}
accountSid = process.env.TWILIO_ACCOUNT_SID;
authToken = process.env.TWILIO_AUTH_TOKEN;
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, exports._findCredential(process.env.TWILIO_ACCOUNT_SID)];
username = process.env.TWILIO_ACCOUNT_SID;
password = process.env.TWILIO_AUTH_TOKEN;
return [3 /*break*/, 6];
case 2:
if (!(process.env.TWILIO_API_KEY && process.env.TWILIO_API_SECRET)) return [3 /*break*/, 4];
return [4 /*yield*/, validators_1.validateApiKey(process.env.TWILIO_API_KEY)];
case 3:
if (!(_a.sent())) {
throw new errors_1.FlexPluginError('API Key is not valid.');
}
username = process.env.TWILIO_API_KEY;
password = process.env.TWILIO_API_SECRET;
return [3 /*break*/, 6];
case 4: return [4 /*yield*/, exports._findCredential(process.env.TWILIO_ACCOUNT_SID)];
case 5:
credential = _a.sent();
if (credential) {
accountSid = credential.account;
authToken = credential.password;
username = credential.username;
password = credential.password;
}
_a.label = 4;
case 4:
if (!(!accountSid || !authToken)) return [3 /*break*/, 7];
_a.label = 6;
case 6:
if (!(!username || !password)) return [3 /*break*/, 9];
return [4 /*yield*/, inquirer_1.prompt(accountSidQuestion)];
case 5:
accountSid = _a.sent();
case 7:
username = _a.sent();
return [4 /*yield*/, inquirer_1.prompt(authTokenQuestion)];
case 6:
authToken = _a.sent();
_a.label = 7;
case 7:
process.env.TWILIO_ACCOUNT_SID = accountSid;
process.env.TWILIO_AUTH_TOKEN = authToken;
// Save the credential
return [4 /*yield*/, exports._saveCredential(accountSid, authToken)];
case 8:
password = _a.sent();
_a.label = 9;
case 9:
// Save the credential
return [4 /*yield*/, exports._saveCredential(username, password)];
case 10:
// Save the credential
_a.sent();
return [2 /*return*/, { accountSid: accountSid, authToken: authToken }];
return [2 /*return*/, { username: username, password: password }];
}

@@ -137,3 +150,3 @@ });

credentials = _a.sent();
promises = credentials.map(function (cred) { return exports._getKeytar().deletePassword(SERVICE_NAME, cred.account); });
promises = credentials.map(function (cred) { return exports._getKeytar().deletePassword(SERVICE_NAME, cred.username); });
return [4 /*yield*/, Promise.all(promises)];

@@ -160,3 +173,3 @@ case 2:

if (accountSid) {
match = credentials.find(function (cred) { return cred.account === accountSid; });
match = credentials.find(function (cred) { return cred.username === accountSid; });
if (match) {

@@ -167,3 +180,3 @@ return [2 /*return*/, match];

accounts = credentials
.map(function (cred) { return cred.account; })
.map(function (cred) { return cred.username; })
.filter(function (acc) { return acc.substr(0, 2).toLowerCase() === 'ac' && acc.length === 34; });

@@ -181,3 +194,3 @@ if (credentials.length === 0) {

if (accounts.length === 1) {
return [2 /*return*/, credentials.find(function (cred) { return cred.account === accounts[0]; })];
return [2 /*return*/, credentials.find(function (cred) { return cred.username === accounts[0]; })];
}

@@ -187,3 +200,3 @@ return [4 /*yield*/, inquirer_1.choose(chooseAccount, accounts)];

selectedAccount = _a.sent();
return [2 /*return*/, credentials.find(function (cred) { return cred.account === selectedAccount; })];
return [2 /*return*/, credentials.find(function (cred) { return cred.username === selectedAccount; })];
}

@@ -211,7 +224,7 @@ });

*
* @param account the account name
* @param username the username
* @param password the password
* @private
*/
exports._saveCredential = function (account, password) { return __awaiter(_this, void 0, void 0, function () {
exports._saveCredential = function (username, password) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -221,3 +234,3 @@ switch (_a.label) {

if (!(!process.env.CI && !process.env.SKIP_CREDENTIALS_SAVING)) return [3 /*break*/, 2];
return [4 /*yield*/, exports._getKeytar().setPassword(SERVICE_NAME, account, password)];
return [4 /*yield*/, exports._getKeytar().setPassword(SERVICE_NAME, username, password)];
case 1:

@@ -243,2 +256,3 @@ _a.sent();

};
exports.default = exports.getCredential;
//# sourceMappingURL=credentials.js.map

@@ -30,15 +30,22 @@ "use strict";

var headline = logger_1.default.coloredStrings.headline;
var deps = _this.pkg.dependencies;
var names = [
'craco-config-flex-plugin',
'flex-plugin',
'flex-plugin-scripts',
];
logger_1.default.newline();
logger_1.default.info("Your plugin " + _this.pkg.name + " is using the following versions:");
logger_1.default.newline();
names.forEach(function (name) { return logger_1.default.info("\t " + headline("\"" + name + "\": \"" + deps[name] + "\"")); });
logger_1.default.newline();
if (_this.pkg) {
var deps_1 = _this.pkg.dependencies;
var names = [
'craco-config-flex-plugin',
'flex-plugin',
'flex-plugin-scripts',
];
logger_1.default.newline();
logger_1.default.info("Your plugin " + _this.pkg.name + " is using the following versions:");
logger_1.default.newline();
names.forEach(function (name) { return logger_1.default.info("\t " + headline("\"" + name + "\": \"" + deps_1[name] + "\"")); });
logger_1.default.newline();
}
};
_this.pkg = fs_1.readPackageJson();
try {
_this.pkg = fs_1.readPackageJson();
}
catch (e) {
_this.pkg = null;
}
Object.setPrototypeOf(_this, FlexPluginError.prototype);

@@ -45,0 +52,0 @@ return _this;

export { default as FlexPluginError } from './FlexPluginError';
export { default as ValidationError } from './ValidationError';
export { default as UserActionError } from './UserActionError';
declare const _default: {};
export default _default;

@@ -5,2 +5,7 @@ "use strict";

exports.FlexPluginError = FlexPluginError_1.default;
var ValidationError_1 = require("./ValidationError");
exports.ValidationError = ValidationError_1.default;
var UserActionError_1 = require("./UserActionError");
exports.UserActionError = UserActionError_1.default;
exports.default = {};
//# sourceMappingURL=index.js.map

@@ -71,2 +71,8 @@ import fs from 'fs';

export declare const rmRfSync: typeof rimRaf.sync;
/**
* Returns the version of the dependency that is installed in node_modules
* @param pkgName the package name
* @return the version of the package installed
*/
export declare const getDependencyVersion: (pkgName: string) => any;
export { DirResult as TmpDirResult } from 'tmp';

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

var fs_1 = __importDefault(require("fs"));
var path_1 = require("path");
var path = __importStar(require("path"));

@@ -27,2 +28,4 @@ var os_1 = __importDefault(require("os"));

var promiseCopyTempDir = util_1.promisify(copy_template_dir_1.default);
// Node directory
var nodeModulesPath = path_1.join(process.cwd(), 'node_modules');
/**

@@ -114,2 +117,11 @@ * Checks the provided array of files exist

exports.rmRfSync = rimraf_1.default.sync;
/**
* Returns the version of the dependency that is installed in node_modules
* @param pkgName the package name
* @return the version of the package installed
*/
/* istanbul ignore next */
exports.getDependencyVersion = function (pkgName) {
return require(path_1.join(nodeModulesPath, pkgName, 'package.json')).version;
};
//# sourceMappingURL=fs.js.map

@@ -19,1 +19,3 @@ export { default as fs } from './fs';

export { default as errors } from './errors';
export { default as runner } from './runner';
export { default as semver } from './semver';

@@ -9,4 +9,2 @@ "use strict";

exports.updateNotifier = updateNotifier_1.default;
var ora_1 = require("./ora");
exports.ora = ora_1.default;
var logger_1 = require("./logger");

@@ -40,2 +38,6 @@ exports.logger = logger_1.default;

exports.errors = errors_1.default;
var runner_1 = require("./runner");
exports.runner = runner_1.default;
var semver_1 = require("./semver");
exports.semver = semver_1.default;
//# sourceMappingURL=index.js.map

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

question.type = question.type || 'input';
return [4 /*yield*/, inquirer_1.default.prompt(question)];
return [4 /*yield*/, inquirer_1.default.prompt([question])];
case 1:

@@ -61,0 +61,0 @@ result = _a.sent();

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

}
if (process.env.VERBOSE) {
if (process.env.DEBUG || process.env.TRACE) {
_log({ level: 'info', args: args });

@@ -34,3 +34,3 @@ }

}
if (process.env.DEBUG_TRACE) {
if (process.env.TRACE) {
_log({ level: 'info', args: args });

@@ -127,3 +127,3 @@ }

headline: function (str) { return chalk_1.default.bold.green(str); },
name: function (str) { return chalk_1.default.bold.whiteBright(str); },
name: function (str) { return chalk_1.default.bold.magenta(str); },
digit: function (str) { return chalk_1.default.cyan(str); },

@@ -130,0 +130,0 @@ },

@@ -7,3 +7,4 @@ "use strict";

var open_1 = __importDefault(require("open"));
/* istanbul ignore next */
exports.default = open_1.default;
//# sourceMappingURL=open.js.map

@@ -1,5 +0,14 @@

import ora from 'ora';
export default ora;
import * as ora from 'ora';
declare const _default: {
(options?: string | ora.Options | undefined): ora.Ora;
promise(action: PromiseLike<unknown>, options?: string | ora.Options | undefined): ora.Ora;
};
export default _default;
export declare type OraCallback<T, R> = (arg: T) => R;
/**
* Added for testing purposes
* @param title
*/
export declare const _getSpinner: (text: string) => ora.Ora;
/**
* Am {@link ora} progress wrapper

@@ -6,0 +15,0 @@ *

@@ -37,10 +37,26 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var ora_1 = __importDefault(require("ora"));
exports.default = ora_1.default;
var ora = __importStar(require("ora"));
exports.default = ora.default;
/**
* Added for testing purposes
* @param title
*/
/* istanbul ignore next */
exports._getSpinner = function (text) {
var options = { text: text };
if (process.env.DEBUG || process.env.TRACE) {
options.isEnabled = false;
}
return ora.default(options);
};
/**
* Am {@link ora} progress wrapper

@@ -56,3 +72,3 @@ *

case 0:
spinner = ora_1.default(title);
spinner = exports._getSpinner(title);
_a.label = 1;

@@ -59,0 +75,0 @@ case 1:

@@ -10,1 +10,3 @@ /**

export declare const printList: (...lines: string[]) => void;
declare const _default: {};
export default _default;

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

};
exports.default = {};
//# sourceMappingURL=prints.js.map

@@ -15,1 +15,2 @@ /**

export declare const randomString: (length: number, list?: string[]) => string;
export default randomString;

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

};
exports.default = exports.randomString;
//# sourceMappingURL=random.js.map

@@ -19,2 +19,3 @@ /**

AccountSid: string;
ApiKey: string;
ServiceSid: string;

@@ -32,2 +33,3 @@ EnvironmentSid: string;

AccountSid: string;
ApiKey: string;
ServiceSid: string;

@@ -34,0 +36,0 @@ EnvironmentSid: string;

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

AccountSid: 'AC',
ApiKey: 'SK',
ServiceSid: 'ZS',

@@ -25,0 +26,0 @@ EnvironmentSid: 'ZE',

@@ -14,2 +14,8 @@ /**

/**
* Validates that the apiKey is valid
*
* @param str the apiKey
*/
export declare const validateApiKey: (str: string) => boolean | "Invalid Account Sid was provided";
/**
* Validates that the URL is a GitHub URL

@@ -48,1 +54,3 @@ *

export declare const isGitHubUrl: (url: string) => boolean;
declare const _default: {};
export default _default;

@@ -29,2 +29,16 @@ "use strict";

/**
* Validates that the apiKey is valid
*
* @param str the apiKey
*/
exports.validateApiKey = function (str) {
if (!exports.isInputNotEmpty(str)) {
return false;
}
if (!sids_1.isSidOfType(str, sids_1.SidPrefix.ApiKey)) {
return 'Invalid Account Sid was provided';
}
return true;
};
/**
* Validates that the URL is a GitHub URL

@@ -81,2 +95,3 @@ *

exports.isGitHubUrl = function (url) { return GITHUB_REGEX.test(url); };
exports.default = {};
//# sourceMappingURL=validators.js.map
{
"name": "flex-dev-utils",
"version": "3.12.0-beta.0",
"version": "3.12.0",
"description": "Common development utility for creating a Flex plugin",

@@ -36,2 +36,4 @@ "keywords": [

"@k88/pipe-compose": "^2.1.1",
"@types/inquirer": "^6.5.0",
"app-module-path": "^2.2.0",
"axios": "^0.19.0",

@@ -42,21 +44,22 @@ "axios-mock-adapter": "^1.17.0",

"copy-template-dir": "^1.4.0",
"execa": "^2.0.4",
"inquirer": "6.3.1",
"execa": "^2.1.0",
"inquirer": "7.0.0",
"lodash": "^4.17.15",
"log-symbols": "^3.0.0",
"marked": "^0.7.0",
"marked-terminal": "^3.2.0",
"marked-terminal": "^3.3.0",
"mkdirp": "^0.5.1",
"open": "^6.4.0",
"ora": "^3.4.0",
"ora": "^4.0.2",
"rimraf": "^3.0.0",
"table": "^5.4.1",
"semver": "^7.3.2",
"table": "^5.4.6",
"tmp": "^0.1.0",
"update-notifier": "^3.0.0",
"util": "^0.12.0",
"update-notifier": "^3.0.1",
"util": "^0.12.1",
"wrap-ansi": "^4.0.0"
},
"devDependencies": {
"@types/inquirer": "6.0.3",
"@types/lodash": "^4.14.136",
"@types/app-module-path": "^2.2.0",
"@types/lodash": "^4.14.144",
"@types/marked": "^0.6.5",

@@ -66,3 +69,4 @@ "@types/marked-terminal": "^3.1.1",

"@types/rimraf": "^2.0.2",
"@types/table": "^4.0.5",
"@types/semver": "^7.1.0",
"@types/table": "^4.0.7",
"@types/tmp": "^0.1.0",

@@ -73,5 +77,5 @@ "@types/update-notifier": "^2.5.0",

"optionalDependencies": {
"keytar": "^4.10.0"
"keytar": "^4.13.0"
},
"gitHead": "3f4e62fcf53c492d55540223f1200232634f9f87"
"gitHead": "df38a5877ab36ef6876377f3568b495d213e5df1"
}

@@ -38,1 +38,2 @@ ![npm](https://img.shields.io/npm/v/flex-dev-utils.svg?style=flat-square)

[MIT](../../LICENSE)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet