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

flex-dev-utils

Package Overview
Dependencies
Maintainers
8
Versions
330
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flex-dev-utils - npm Package Compare versions

Comparing version 3.15.0-beta.0 to 4.0.0-beta.0

dist/env.d.ts

1

dist/axios.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.MockAdapter = void 0;
var axios_1 = __importDefault(require("axios"));

@@ -8,0 +9,0 @@ var axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));

39

dist/boxen.d.ts

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

import boxen from 'boxen';
import { LogLevels } from './logger';
export default boxen;
/**
* Prints the message inside a box
*
* @param level the log level to display the message as
* @param msg the message
*/
export declare const print: (level: LogLevels, msg: string) => void;
/**
* Displays the message as a warning box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in a warning symbol
*/
export declare const warning: (msg: string, showSymbol?: boolean) => void;
/**
* Displays the message as an info box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in an info symbol
*/
export declare const info: (msg: string, showSymbol?: boolean) => void;
/**
* Displays the message as am error box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in an error symbol
*/
export declare const error: (msg: string, showSymbol?: boolean) => void;
/**
* Displays the message as a success box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in a success symbol
*/
export declare const success: (msg: string, showSymbol?: boolean) => void;
export { boxen as default } from 'flex-plugins-utils-logger';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var boxen_1 = __importDefault(require("boxen"));
var log_symbols_1 = __importDefault(require("log-symbols"));
var logger_1 = __importDefault(require("./logger"));
exports.default = boxen_1.default;
/**
* Prints the message inside a box
*
* @param level the log level to display the message as
* @param msg the message
*/
exports.print = function (level, msg) {
var boxed = boxen_1.default(msg, {
padding: 1,
margin: 1,
});
logger_1.default[level](boxed);
};
/**
* Displays the message as a warning box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in a warning symbol
*/
exports.warning = function (msg, showSymbol) {
if (showSymbol === void 0) { showSymbol = true; }
var sym = log_symbols_1.default.warning;
if (showSymbol) {
msg = sym + " " + msg + " " + sym;
}
exports.print('warning', msg);
};
/**
* Displays the message as an info box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in an info symbol
*/
exports.info = function (msg, showSymbol) {
if (showSymbol === void 0) { showSymbol = true; }
var sym = log_symbols_1.default.info;
if (showSymbol) {
msg = sym + " " + msg + " " + sym;
}
exports.print('info', msg);
};
/**
* Displays the message as am error box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in an error symbol
*/
exports.error = function (msg, showSymbol) {
if (showSymbol === void 0) { showSymbol = true; }
var sym = log_symbols_1.default.error;
if (showSymbol) {
msg = sym + " " + msg + " " + sym;
}
exports.print('error', msg);
};
/**
* Displays the message as a success box
*
* @param msg the message to display
* @param showSymbol whether wrap the message in a success symbol
*/
exports.success = function (msg, showSymbol) {
if (showSymbol === void 0) { showSymbol = true; }
var sym = log_symbols_1.default.success;
if (showSymbol) {
msg = sym + " " + msg + " " + sym;
}
exports.print('success', msg);
};
var flex_plugins_utils_logger_1 = require("flex-plugins-utils-logger");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return flex_plugins_utils_logger_1.boxen; } });
//# sourceMappingURL=boxen.js.map
export interface AuthConfig {
accountSid: string;
authToken: string;
username: string;
password: string;
}
interface Credential {
username: string;
password: string;
}
interface KeytarCredential {
account: string;

@@ -29,11 +33,11 @@ password: string;

*/
export declare const _getService: () => Promise<Credential[]>;
export declare const _getService: () => Promise<KeytarCredential[]>;
/**
* Saves the credential
*
* @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 +50,2 @@ * Keytar is required optionally and so may not exist.

export declare const _getKeytar: () => any;
export {};
export default getCredential;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -37,5 +38,6 @@ });

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports._getKeytar = exports._saveCredential = exports._getService = exports._findCredential = exports.clearCredentials = exports.getCredential = void 0;
var errors_1 = require("./errors");
var index_1 = require("./index");
var inquirer_1 = require("./inquirer");

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

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

@@ -74,10 +81,10 @@ var accountSidQuestion = {

*/
exports.getCredential = function () { return __awaiter(_this, void 0, void 0, function () {
var accountSid, authToken, missingCredentials, credential;
exports.getCredential = function () { return __awaiter(void 0, void 0, void 0, function () {
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 +97,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 }];
}

@@ -126,3 +141,3 @@ });

*/
exports.clearCredentials = function () { return __awaiter(_this, void 0, void 0, function () {
exports.clearCredentials = function () { return __awaiter(void 0, void 0, void 0, function () {
var credentials, promises;

@@ -152,7 +167,12 @@ return __generator(this, function (_a) {

*/
exports._findCredential = function (accountSid) { return __awaiter(_this, void 0, void 0, function () {
var credentials, match, accounts, selectedAccount;
exports._findCredential = function (accountSid) { return __awaiter(void 0, void 0, void 0, function () {
var convertCredential, credentials, match, accounts, selectedAccount;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, exports._getService()];
case 0:
convertCredential = function (credential) { return ({
username: credential.account,
password: credential.password,
}); };
return [4 /*yield*/, exports._getService()];
case 1:

@@ -163,3 +183,3 @@ credentials = _a.sent();

if (match) {
return [2 /*return*/, match];
return [2 /*return*/, convertCredential(match)];
}

@@ -169,3 +189,3 @@ }

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

@@ -175,3 +195,3 @@ return [2 /*return*/, null];

if (credentials.length === 1) {
return [2 /*return*/, credentials[0]];
return [2 /*return*/, convertCredential(credentials[0])];
}

@@ -183,3 +203,3 @@ if (accounts.length === 0) {

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

@@ -189,3 +209,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*/, convertCredential(credentials.find(function (cred) { return cred.account === selectedAccount; }))];
}

@@ -198,3 +218,3 @@ });

*/
exports._getService = function () { return __awaiter(_this, void 0, void 0, function () {
exports._getService = function () { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -214,7 +234,7 @@ switch (_a.label) {

*
* @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(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -224,3 +244,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:

@@ -246,2 +266,3 @@ _a.sent();

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

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

export default class FlexPluginError extends Error {
import { TwilioError } from 'flex-plugins-utils-exception';
export default class FlexPluginError extends TwilioError {
private readonly pkg;

@@ -3,0 +4,0 @@ constructor(msg?: string);

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

Object.defineProperty(exports, "__esModule", { value: true });
var flex_plugins_utils_exception_1 = require("flex-plugins-utils-exception");
var fs_1 = require("../fs");

@@ -25,3 +26,5 @@ var logger_1 = __importDefault(require("../logger"));

function FlexPluginError(msg) {
var _this = _super.call(this, msg) || this;
var _this =
/* istanbul ignore next */
_super.call(this, msg) || this;
_this.print = function () {

@@ -32,15 +35,21 @@ logger_1.default.error(_this.message);

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 = [
'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.readAppPackageJson();
}
catch (e) {
_this.pkg = null;
}
Object.setPrototypeOf(_this, FlexPluginError.prototype);

@@ -50,4 +59,4 @@ return _this;

return FlexPluginError;
}(Error));
}(flex_plugins_utils_exception_1.TwilioError));
exports.default = FlexPluginError;
//# sourceMappingURL=FlexPluginError.js.map
export { default as FlexPluginError } from './FlexPluginError';
export { default as ValidationError } from './ValidationError';
export { default as UserActionError } from './UserActionError';
export { TwilioError } from 'flex-plugins-utils-exception';
declare const _default: {};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FlexPluginError_1 = require("./FlexPluginError");
exports.FlexPluginError = FlexPluginError_1.default;
Object.defineProperty(exports, "FlexPluginError", { enumerable: true, get: function () { return FlexPluginError_1.default; } });
var ValidationError_1 = require("./ValidationError");
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return ValidationError_1.default; } });
var UserActionError_1 = require("./UserActionError");
Object.defineProperty(exports, "UserActionError", { enumerable: true, get: function () { return UserActionError_1.default; } });
var flex_plugins_utils_exception_1 = require("flex-plugins-utils-exception");
Object.defineProperty(exports, "TwilioError", { enumerable: true, get: function () { return flex_plugins_utils_exception_1.TwilioError; } });
exports.default = {};
//# sourceMappingURL=index.js.map

@@ -8,9 +8,26 @@ import fs from 'fs';

version: string;
dependencies: Record<string, string>;
}
export interface AppPackageJson extends PackageJson {
dependencies: {
'flex-plugin': string;
'flex-plugin-scripts': string;
'craco-config-flex-plugin': string;
};
}
export interface FlexConfigurationPlugin {
name: string;
dir: string;
port: number;
}
export interface CLIFlexConfiguration {
plugins: FlexConfigurationPlugin[];
}
export default fs;
export declare const _setRequirePaths: (requirePath: string) => void;
export declare const setCwd: (p: string) => void;
export declare const setCoreCwd: (p: string) => void;
export declare const getCwd: () => string;
export declare const readPluginsJson: () => CLIFlexConfiguration;
export declare const writeJSONFile: (pth: string, obj: object) => void;
export declare const getCoreCwd: () => string;
/**

@@ -31,12 +48,25 @@ * Checks the provided array of files exist

*/
export declare const updatePackageVersion: (version: string) => void;
export declare const updateAppVersion: (version: string) => void;
/**
* Reads package.json from the rootDir. This is the package.json of the service running the script.
* For example, if a plugin is using a method of flex-plugin-scripts which is calling this, then
* the plugin's package.json is returned
* Reads app package.json from the rootDir.
*/
export declare const readAppPackageJson: () => AppPackageJson;
/**
* Reads a JSON file
*
* @param pkgPath the package.json to read
* @param filePath the file path to read
*/
export declare const readPackageJson: (pkgPath?: string) => PackageJson;
export declare const readPackageJson: (filePath: string) => PackageJson;
/**
* Reads a JSON file (Templated)
*
* @param filePath the file path to read
*/
export declare const readJsonFile: <T>(filePath: string) => T;
/**
* Returns the package.json version field of the package
* @param name the package
*/
export declare const getPackageVersion: (name: string) => string;
/**
* Finds the closest up file relative to dir

@@ -73,2 +103,102 @@ *

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;
/**
* Builds path relative to cwd
* @param paths the paths
*/
export declare const resolveCwd: (...paths: string[]) => string;
/**
* Builds path relative to the given dir
* @param dir the dir
* @param paths the paths
*/
export declare const resolveRelative: (dir: string, ...paths: string[]) => string;
/**
* Finds globs in the src directory
* @param patterns the patterns
*/
export declare const findGlobs: (...patterns: string[]) => string[];
/**
* Touch ~/.twilio-cli/flex/plugins.json if it does not exist
* Check if this plugin is in this config file. If not, add it.
* @private
*/
export declare const checkPluginConfigurationExists: (name: string, dir: string) => Promise<void>;
/**
* Finds globs in any cwd directory
* @param dir the cwd to check for patterns
* @param patterns the patterns
*/
export declare const findGlobsIn: (dir: string, ...patterns: string[]) => string[];
/**
* Adds the node_modules to the app module.
* This is needed because we spawn different scripts when running start/build/test and so we lose
* the original cwd directory
*/
export declare const addCWDNodeModule: (...args: string[]) => void;
/**
* Returns the absolute path to the pkg if found
* @param pkg the package to lookup
*/
export declare const resolveModulePath: (pkg: string) => string | false;
/**
* This is an alias for require. Useful for mocking out in tests
* @param filePath the file to require
* @private
*/
export declare const _require: (filePath: string) => any;
export { DirResult as TmpDirResult } from 'tmp';
/**
* Gets the CLI paths. This is separated out from getPaths because create-flex-plugin also needs to read it,
* but that script will not have flex-plugin-scripts installed which would cause an exception to be thrown.
*/
export declare const getCliPaths: () => {
dir: string;
nodeModulesDir: string;
flexDir: string;
pluginsJsonPath: string;
};
export declare const getPaths: () => {
cwd: string;
scripts: {
dir: string;
devAssetsDir: string;
indexHTMLPath: string;
tsConfigPath: string;
};
cli: {
dir: string;
nodeModulesDir: string;
flexDir: string;
pluginsJsonPath: string;
};
app: {
dir: string;
name: string;
version: string;
pkgPath: string;
jestConfigPath: string;
webpackConfigPath: string;
devServerConfigPath: string;
tsConfigPath: string;
isTSProject: () => boolean;
setupTestsPaths: string[];
buildDir: string;
bundlePath: string;
sourceMapPath: string;
srcDir: string;
entryPath: string;
nodeModulesDir: string;
flexUIDir: string;
flexUIPkgPath: string;
publicDir: string;
appConfig: string;
};
assetBaseUrlTemplate: string;
extensions: string[];
};
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
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;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPaths = exports.getCliPaths = exports._require = exports.resolveModulePath = exports.addCWDNodeModule = exports.findGlobsIn = exports.checkPluginConfigurationExists = exports.findGlobs = exports.resolveRelative = exports.resolveCwd = exports.getDependencyVersion = exports.rmRfSync = exports.tmpDirSync = exports.copyTemplateDir = exports.mkdirpSync = exports.readFileSync = exports.findUp = exports.getPackageVersion = exports.readJsonFile = exports.readPackageJson = exports.readAppPackageJson = exports.updateAppVersion = exports.getPackageJsonPath = exports.checkFilesExist = exports.getCoreCwd = exports.writeJSONFile = exports.readPluginsJson = exports.getCwd = exports.setCoreCwd = exports.setCwd = exports._setRequirePaths = void 0;
var fs_1 = __importDefault(require("fs"));
var path = __importStar(require("path"));
var os_1 = __importDefault(require("os"));
var os_1 = __importStar(require("os"));
var util_1 = require("util");
var globby_1 = __importDefault(require("globby"));
var mkdirp_1 = __importDefault(require("mkdirp"));
var tmp_1 = __importDefault(require("tmp"));
var copy_template_dir_1 = __importDefault(require("copy-template-dir"));
var util_1 = require("util");
var rimraf_1 = __importDefault(require("rimraf"));
var app_module_path_1 = __importDefault(require("app-module-path"));
var inquirer_1 = require("./inquirer");
exports.default = fs_1.default;
// Working directory
var internalCwd = fs_1.default.realpathSync(process.cwd());
var internalCoreCwd = fs_1.default.realpathSync(process.cwd());
// Set working directory
exports._setRequirePaths = function (requirePath) {
app_module_path_1.default.addPath(requirePath);
// Now try to specifically set the node_modules path
var requirePaths = (require.main && require.main.paths) || [];
if (!requirePaths.includes(requirePath)) {
requirePaths.push(requirePath);
}
};
exports.setCwd = function (p) {
internalCwd = p;
exports._setRequirePaths(path.join(internalCwd, 'node_modules'));
};
exports.setCoreCwd = function (p) {
internalCoreCwd = p;
exports._setRequirePaths(path.join(internalCoreCwd, 'node_modules'));
};
// Get working directory
exports.getCwd = function () { return internalCwd; };
// Read plugins.json from Twilio CLI
exports.readPluginsJson = function () { return exports.readJsonFile(exports.getCliPaths().pluginsJsonPath); };
// Write to json file
exports.writeJSONFile = function (pth, obj) { return fs_1.default.writeFileSync(pth, JSON.stringify(obj, null, 2)); };
// The core cwd is the working directory of core packages such as flex-plugin-scripts and flex-plugin
exports.getCoreCwd = function () { return internalCoreCwd; };
// The OS root directory
var rootDir = os_1.default.platform() === 'win32' ? process.cwd().split(path.sep)[0] : '/';
// Promise version of {@link copyTempDir}
var promiseCopyTempDir = util_1.promisify(copy_template_dir_1.default);
var rootDir = os_1.default.platform() === 'win32' ? exports.getCwd().split(path.sep)[0] : '/';
/*
* Promise version of {@link copyTempDir}
*/
// tslint:disable-next-line
var promiseCopyTempDir = util_1.promisify(require('copy-template-dir'));
/**

@@ -36,5 +138,3 @@ * Checks the provided array of files exist

}
return files
.map(fs_1.default.existsSync)
.every(function (resp) { return resp; });
return files.map(fs_1.default.existsSync).every(function (resp) { return resp; });
};

@@ -46,3 +146,3 @@ /**

if (forModule === void 0) { forModule = false; }
return path.join(process.cwd(), 'package.json');
return path.join(exports.getCwd(), 'package.json');
};

@@ -54,4 +154,4 @@ /**

*/
exports.updatePackageVersion = function (version) {
var packageJson = exports.readPackageJson();
exports.updateAppVersion = function (version) {
var packageJson = exports.readAppPackageJson();
packageJson.version = version;

@@ -61,13 +161,33 @@ fs_1.default.writeFileSync(exports.getPackageJsonPath(), JSON.stringify(packageJson, null, 2));

/**
* Reads package.json from the rootDir. This is the package.json of the service running the script.
* For example, if a plugin is using a method of flex-plugin-scripts which is calling this, then
* the plugin's package.json is returned
* Reads app package.json from the rootDir.
*/
exports.readAppPackageJson = function () {
return exports.readPackageJson(exports.getPackageJsonPath());
};
/**
* Reads a JSON file
*
* @param pkgPath the package.json to read
* @param filePath the file path to read
*/
exports.readPackageJson = function (pkgPath) {
if (pkgPath === void 0) { pkgPath = exports.getPackageJsonPath(); }
return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
exports.readPackageJson = function (filePath) {
return JSON.parse(fs_1.default.readFileSync(filePath, 'utf8'));
};
/**
* Reads a JSON file (Templated)
*
* @param filePath the file path to read
*/
exports.readJsonFile = function (filePath) {
return JSON.parse(fs_1.default.readFileSync(filePath, 'utf8'));
};
/**
* Returns the package.json version field of the package
* @param name the package
*/
/* istanbul ignore next */
exports.getPackageVersion = function (name) {
var installedPath = exports.resolveRelative(exports.getPaths().app.nodeModulesDir, name, 'package.json');
return exports.readPackageJson(installedPath).version;
};
/**
* Finds the closest up file relative to dir

@@ -105,2 +225,3 @@ *

*/
/* istanbul ignore next */
exports.copyTemplateDir = function (source, target, variables) {

@@ -117,2 +238,241 @@ return promiseCopyTempDir(source, target, variables);

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(exports.resolveRelative(exports.getPaths().app.nodeModulesDir, pkgName, 'package.json')).version;
};
/**
* Builds path relative to cwd
* @param paths the paths
*/
exports.resolveCwd = function () {
var paths = [];
for (var _i = 0; _i < arguments.length; _i++) {
paths[_i] = arguments[_i];
}
return exports.resolveRelative.apply(void 0, __spread([exports.getCwd()], paths));
};
/**
* Builds path relative to the given dir
* @param dir the dir
* @param paths the paths
*/
exports.resolveRelative = function (dir) {
var paths = [];
for (var _i = 1; _i < arguments.length; _i++) {
paths[_i - 1] = arguments[_i];
}
if (paths.length === 0) {
return dir;
}
var lastElement = paths[paths.length - 1];
// Check if last element is an extension
if (lastElement.charAt(0) !== '.') {
return path.join.apply(path, __spread([dir], paths));
}
// Only one entry as extension
if (paths.length === 1) {
return path.join("" + dir + lastElement);
}
var secondLastElement = paths[paths.length - 2];
var remainder = paths.slice(0, paths.length - 2);
return path.join.apply(path, __spread([dir], __spread(remainder, ["" + secondLastElement + lastElement])));
};
/**
* Finds globs in the src directory
* @param patterns the patterns
*/
exports.findGlobs = function () {
var patterns = [];
for (var _i = 0; _i < arguments.length; _i++) {
patterns[_i] = arguments[_i];
}
// TODO: move paths from flex-plugin-scripts into here and use it here too
return exports.findGlobsIn.apply(void 0, __spread([path.join(exports.getCwd(), 'src')], patterns));
};
/**
* Touch ~/.twilio-cli/flex/plugins.json if it does not exist
* Check if this plugin is in this config file. If not, add it.
* @private
*/
exports.checkPluginConfigurationExists = function (name, dir) { return __awaiter(void 0, void 0, void 0, function () {
var cliPaths, config, plugin, answer;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cliPaths = exports.getCliPaths();
if (!exports.checkFilesExist(cliPaths.pluginsJsonPath)) {
exports.mkdirpSync(cliPaths.flexDir);
exports.writeJSONFile(cliPaths.pluginsJsonPath, { plugins: [] });
}
config = exports.readPluginsJson();
plugin = config.plugins.find(function (p) { return p.name === name; });
if (!plugin) {
config.plugins.push({ name: name, dir: dir, port: 0 });
exports.writeJSONFile(cliPaths.pluginsJsonPath, config);
return [2 /*return*/];
}
if (plugin.dir === dir) {
return [2 /*return*/];
}
return [4 /*yield*/, inquirer_1.confirm("You already have a plugin called " + plugin.name + " in the local Flex configuration file, but it is located at " + plugin.dir + ". Do you want to update the directory path to " + dir + "?", 'N')];
case 1:
answer = _a.sent();
if (answer) {
plugin.dir = dir;
exports.writeJSONFile(cliPaths.pluginsJsonPath, config);
}
return [2 /*return*/];
}
});
}); };
/**
* Finds globs in any cwd directory
* @param dir the cwd to check for patterns
* @param patterns the patterns
*/
exports.findGlobsIn = function (dir) {
var patterns = [];
for (var _i = 1; _i < arguments.length; _i++) {
patterns[_i - 1] = arguments[_i];
}
return globby_1.default.sync(patterns, { cwd: dir });
};
/**
* Adds the node_modules to the app module.
* This is needed because we spawn different scripts when running start/build/test and so we lose
* the original cwd directory
*/
exports.addCWDNodeModule = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var index = args.indexOf('--core-cwd');
if (index !== -1) {
var coreCwd = args[index + 1];
if (coreCwd) {
exports.setCoreCwd(coreCwd);
}
}
// This is to setup the app environment
exports.setCwd(exports.getCwd());
};
/**
* Returns the absolute path to the pkg if found
* @param pkg the package to lookup
*/
/* istanbul ignore next */
exports.resolveModulePath = function (pkg) {
try {
return require.resolve(pkg);
}
catch (e1) {
// Now try to specifically set the node_modules path
var requirePaths = (require.main && require.main.paths) || [];
try {
return require.resolve(pkg, { paths: requirePaths });
}
catch (e2) {
return false;
}
}
};
/**
* This is an alias for require. Useful for mocking out in tests
* @param filePath the file to require
* @private
*/
/* istanbul ignore next */
exports._require = function (filePath) { return require(filePath); };
/**
* Gets the CLI paths. This is separated out from getPaths because create-flex-plugin also needs to read it,
* but that script will not have flex-plugin-scripts installed which would cause an exception to be thrown.
*/
exports.getCliPaths = function () {
var coreCwd = exports.getCwd();
var coreNodeModulesDir = exports.resolveRelative(coreCwd, 'node_modules');
var homeDir = os_1.homedir();
var cliDir = exports.resolveRelative(homeDir, '/.twilio-cli');
var flexDir = exports.resolveRelative(cliDir, 'flex');
return {
dir: cliDir,
nodeModulesDir: coreNodeModulesDir,
flexDir: flexDir,
pluginsJsonPath: exports.resolveRelative(flexDir, 'plugins.json'),
};
};
exports.getPaths = function () {
var cwd = exports.getCwd();
var nodeModulesDir = exports.resolveCwd('node_modules');
var flexPluginScriptPath = exports.resolveModulePath('flex-plugin-scripts');
if (flexPluginScriptPath === false) {
throw new Error('Could not resolve flex-plugin-scripts');
}
var scriptsDir = path.join(path.dirname(flexPluginScriptPath), '..');
var devAssetsDir = exports.resolveRelative(scriptsDir, 'dev_assets');
var publicDir = exports.resolveCwd('public');
var buildDir = exports.resolveCwd('build');
var srcDir = exports.resolveCwd('src');
var flexUIDir = exports.resolveRelative(nodeModulesDir, '@twilio/flex-ui');
var tsConfigPath = exports.resolveCwd('tsconfig.json');
// package.json information
var pkgName = '';
var pkgVersion = '';
// This file can be required in locations that don't have package.json
try {
var pkg = exports.readAppPackageJson();
pkgName = pkg.name;
pkgVersion = pkg.version;
}
catch (e) {
// no-op
}
return {
cwd: cwd,
// flex-plugin-scripts paths
scripts: {
dir: scriptsDir,
devAssetsDir: devAssetsDir,
indexHTMLPath: exports.resolveRelative(devAssetsDir, 'index.html'),
tsConfigPath: exports.resolveRelative(devAssetsDir, 'tsconfig.json'),
},
// twilio-cli/flex/plugins.json paths
cli: exports.getCliPaths(),
// plugin-app (the customer app)
app: {
dir: cwd,
name: pkgName,
version: pkgVersion,
pkgPath: exports.resolveCwd('package.json'),
jestConfigPath: exports.resolveCwd('jest.config.js'),
webpackConfigPath: exports.resolveCwd('webpack.config.js'),
devServerConfigPath: exports.resolveCwd('webpack.dev.js'),
tsConfigPath: tsConfigPath,
isTSProject: function () { return exports.checkFilesExist(tsConfigPath); },
setupTestsPaths: [exports.resolveCwd('setupTests.js'), exports.resolveRelative(srcDir, 'setupTests.js')],
// build/*
buildDir: buildDir,
bundlePath: exports.resolveRelative(buildDir, pkgName, '.js'),
sourceMapPath: exports.resolveRelative(buildDir, pkgName, '.js.map'),
// src/*
srcDir: srcDir,
entryPath: exports.resolveRelative(srcDir, 'index'),
// node_modules/*,
nodeModulesDir: nodeModulesDir,
flexUIDir: flexUIDir,
flexUIPkgPath: exports.resolveRelative(flexUIDir, 'package.json'),
// public/*
publicDir: publicDir,
appConfig: exports.resolveRelative(publicDir, 'appConfig.js'),
},
// others
assetBaseUrlTemplate: "/plugins/" + pkgName + "/%PLUGIN_VERSION%",
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
};
};
//# sourceMappingURL=fs.js.map
export { default as fs } from './fs';
export { default as lodash } from './lodash';
export { default as updateNotifier } from './updateNotifier';
export { default as ora } from './ora';
export { default as progress } from './progress';
export { default as logger } from './logger';

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

export { default as errors } from './errors';
export { FlexPluginError } from './errors';
export { ValidationError } from './errors';
export { UserActionError } from './errors';
export { TwilioError } from './errors';
export { default as runner } from './runner';
export { default as urls } from './urls';
export { default as env } from './env';
export { getPaths as paths } from './fs';
export { default as semver } from './semver';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = require("./fs");
exports.fs = fs_1.default;
Object.defineProperty(exports, "fs", { enumerable: true, get: function () { return fs_1.default; } });
var lodash_1 = require("./lodash");
exports.lodash = lodash_1.default;
Object.defineProperty(exports, "lodash", { enumerable: true, get: function () { return lodash_1.default; } });
var updateNotifier_1 = require("./updateNotifier");
exports.updateNotifier = updateNotifier_1.default;
Object.defineProperty(exports, "updateNotifier", { enumerable: true, get: function () { return updateNotifier_1.default; } });
var progress_1 = require("./progress");
Object.defineProperty(exports, "progress", { enumerable: true, get: function () { return progress_1.default; } });
var logger_1 = require("./logger");
exports.logger = logger_1.default;
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.default; } });
var boxen_1 = require("./boxen");
exports.boxen = boxen_1.default;
Object.defineProperty(exports, "boxen", { enumerable: true, get: function () { return boxen_1.default; } });
var strings_1 = require("./strings");
exports.strings = strings_1.default;
Object.defineProperty(exports, "strings", { enumerable: true, get: function () { return strings_1.default; } });
var inquirer_1 = require("./inquirer");
exports.inquirer = inquirer_1.default;
Object.defineProperty(exports, "inquirer", { enumerable: true, get: function () { return inquirer_1.default; } });
var table_1 = require("./table");
exports.table = table_1.default;
Object.defineProperty(exports, "table", { enumerable: true, get: function () { return table_1.default; } });
var credentials_1 = require("./credentials");
exports.credentials = credentials_1.default;
Object.defineProperty(exports, "credentials", { enumerable: true, get: function () { return credentials_1.default; } });
var sids_1 = require("./sids");
exports.sids = sids_1.default;
Object.defineProperty(exports, "sids", { enumerable: true, get: function () { return sids_1.default; } });
var random_1 = require("./random");
exports.random = random_1.default;
Object.defineProperty(exports, "random", { enumerable: true, get: function () { return random_1.default; } });
var validators_1 = require("./validators");
exports.validators = validators_1.default;
Object.defineProperty(exports, "validators", { enumerable: true, get: function () { return validators_1.default; } });
var spawn_1 = require("./spawn");
exports.spawn = spawn_1.default;
Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return spawn_1.default; } });
var axios_1 = require("./axios");
exports.axios = axios_1.default;
Object.defineProperty(exports, "axios", { enumerable: true, get: function () { return axios_1.default; } });
var prints_1 = require("./prints");
exports.prints = prints_1.default;
Object.defineProperty(exports, "prints", { enumerable: true, get: function () { return prints_1.default; } });
var open_1 = require("./open");
exports.open = open_1.default;
Object.defineProperty(exports, "open", { enumerable: true, get: function () { return open_1.default; } });
var errors_1 = require("./errors");
exports.errors = errors_1.default;
Object.defineProperty(exports, "errors", { enumerable: true, get: function () { return errors_1.default; } });
var errors_2 = require("./errors");
Object.defineProperty(exports, "FlexPluginError", { enumerable: true, get: function () { return errors_2.FlexPluginError; } });
var errors_3 = require("./errors");
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return errors_3.ValidationError; } });
var errors_4 = require("./errors");
Object.defineProperty(exports, "UserActionError", { enumerable: true, get: function () { return errors_4.UserActionError; } });
var errors_5 = require("./errors");
Object.defineProperty(exports, "TwilioError", { enumerable: true, get: function () { return errors_5.TwilioError; } });
var runner_1 = require("./runner");
Object.defineProperty(exports, "runner", { enumerable: true, get: function () { return runner_1.default; } });
var urls_1 = require("./urls");
Object.defineProperty(exports, "urls", { enumerable: true, get: function () { return urls_1.default; } });
var env_1 = require("./env");
Object.defineProperty(exports, "env", { enumerable: true, get: function () { return env_1.default; } });
var fs_2 = require("./fs");
Object.defineProperty(exports, "paths", { enumerable: true, get: function () { return fs_2.getPaths; } });
var semver_1 = require("./semver");
Object.defineProperty(exports, "semver", { enumerable: true, get: function () { return semver_1.default; } });
//# sourceMappingURL=index.js.map

@@ -17,3 +17,3 @@ import inquirer from 'inquirer';

*/
export declare const prompt: (question: Question) => Promise<string>;
export declare const prompt: (question: Question) => Promise<Question['name']>;
/**

@@ -33,3 +33,3 @@ * Provides a confirmation prompt. The response is a Promise<boolean> with `true` resolving to

*/
export declare const choose: (question: Question, choices: string[]) => Promise<string>;
export declare const choose: (question: Question, choices: string[]) => Promise<Question['name']>;
export default inquirer;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -40,4 +41,4 @@ });

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports.choose = exports.confirm = exports.prompt = exports.acceptableAnswers = exports.negativeAnswers = exports.positiveAnswers = void 0;
var inquirer_1 = __importDefault(require("inquirer"));

@@ -53,3 +54,3 @@ var validators_1 = require("./validators");

*/
exports.prompt = function (question) { return __awaiter(_this, void 0, void 0, function () {
exports.prompt = function (question) { return __awaiter(void 0, void 0, void 0, function () {
var result, nameKey;

@@ -75,3 +76,3 @@ return __generator(this, function (_a) {

*/
exports.confirm = function (question, defaultAnswer) { return __awaiter(_this, void 0, void 0, function () {
exports.confirm = function (question, defaultAnswer) { return __awaiter(void 0, void 0, void 0, function () {
var suffix, q, answer;

@@ -112,3 +113,3 @@ return __generator(this, function (_a) {

*/
exports.choose = function (question, choices) { return __awaiter(_this, void 0, void 0, function () {
exports.choose = function (question, choices) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -115,0 +116,0 @@ question.type = 'list';

@@ -6,5 +6,5 @@ import * as lodash from 'lodash';

<TObject, TSource>(object: TObject, source: TSource): TObject & TSource;
<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TObject & TSource1 & TSource2;
<TObject, TSource1, TSource2, TSource3>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3): TObject & TSource1 & TSource2 & TSource3;
<TObject, TSource1, TSource2, TSource3, TSource4>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): TObject & TSource1 & TSource2 & TSource3 & TSource4;
<TObject_1, TSource1, TSource2>(object: TObject_1, source1: TSource1, source2: TSource2): TObject_1 & TSource1 & TSource2;
<TObject_2, TSource1_1, TSource2_1, TSource3>(object: TObject_2, source1: TSource1_1, source2: TSource2_1, source3: TSource3): TObject_2 & TSource1_1 & TSource2_1 & TSource3;
<TObject_3, TSource1_2, TSource2_2, TSource3_1, TSource4>(object: TObject_3, source1: TSource1_2, source2: TSource2_2, source3: TSource3_1, source4: TSource4): TObject_3 & TSource1_2 & TSource2_2 & TSource3_1 & TSource4;
(object: any, ...otherArgs: any[]): any;

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

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
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;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.clone = exports.merge = exports.upperFirst = exports.camelCase = void 0;
var lodash = __importStar(require("lodash"));

@@ -11,0 +24,0 @@ exports.camelCase = lodash.camelCase;

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

export declare type LogLevels = 'debug' | 'info' | 'warning' | 'error' | 'trace' | 'success';
/**
* debug level log
* @param args
*/
export declare const debug: (...args: any[]) => void;
/**
* trace level trace
* @param args
*/
export declare const trace: (...args: any[]) => void;
/**
* info level log
* @param args
*/
export declare const info: (...args: any[]) => void;
/**
* success level log
* @param args
*/
export declare const success: (...args: any[]) => void;
/**
* error level log
* @param args
*/
export declare const error: (...args: any[]) => void;
/**
* warning level log
* @param args
*/
export declare const warning: (...args: any[]) => void;
/**
* Appends new line
* @param lines the number of lines to append
*/
export declare const newline: (lines?: number) => void;
/**
* Word wrapping using ANSI escape codes
*
* @param input the string to wrap
* @param columns number of columns
* @param options options
*/
export declare const wrap: (input: string, columns: number, options?: {
hard: boolean;
}) => string;
declare const _default: {
debug: (...args: any[]) => void;
info: (...args: any[]) => void;
warning: (...args: any[]) => void;
error: (...args: any[]) => void;
trace: (...args: any[]) => void;
success: (...args: any[]) => void;
newline: (lines?: number) => void;
wrap: (input: string, columns: number, options?: {
hard: boolean;
}) => string;
colors: import("chalk").Chalk & {
supportsColor: import("chalk").ColorSupport;
};
coloredStrings: {
link: (str: string) => string;
headline: (str: string) => string;
name: (str: string) => string;
digit: (str: string) => string;
};
};
export default _default;
export { logger as default } from 'flex-plugins-utils-logger';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("util");
var chalk_1 = __importDefault(require("chalk"));
var wrap_ansi_1 = __importDefault(require("wrap-ansi"));
// The default option for wrap-ansi
var DefaultWrapOptions = { hard: true };
/**
* debug level log
* @param args
*/
exports.debug = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (process.env.VERBOSE) {
_log({ level: 'info', args: args });
}
};
/**
* trace level trace
* @param args
*/
exports.trace = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (process.env.DEBUG_TRACE) {
_log({ level: 'info', args: args });
}
};
/**
* info level log
* @param args
*/
exports.info = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
_log({ level: 'info', args: args });
};
/**
* success level log
* @param args
*/
exports.success = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
_log({ level: 'info', color: 'green', args: args });
};
/**
* error level log
* @param args
*/
exports.error = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
_log({ level: 'error', color: 'red', args: args });
};
/**
* warning level log
* @param args
*/
exports.warning = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
_log({ level: 'warn', color: 'yellow', args: args });
};
/**
* Appends new line
* @param lines the number of lines to append
*/
exports.newline = function (lines) {
if (lines === void 0) { lines = 1; }
for (var i = 0; i < lines; i++) {
exports.info();
}
};
/**
* Word wrapping using ANSI escape codes
*
* @param input the string to wrap
* @param columns number of columns
* @param options options
*/
exports.wrap = function (input, columns, options) {
if (options === void 0) { options = DefaultWrapOptions; }
return wrap_ansi_1.default(input, columns, options);
};
/**
* The internal logger method
* @param args
* @private
*/
var _log = function (args) {
var color = args.color ? chalk_1.default[args.color] : null;
var msg = util_1.format.apply({}, args.args);
console[args.level](color && color(msg) || msg);
};
exports.default = {
debug: exports.debug,
info: exports.info,
warning: exports.warning,
error: exports.error,
trace: exports.trace,
success: exports.success,
newline: exports.newline,
wrap: exports.wrap,
colors: chalk_1.default,
coloredStrings: {
link: function (str) { return chalk_1.default.blue(str); },
headline: function (str) { return chalk_1.default.bold.green(str); },
name: function (str) { return chalk_1.default.bold.whiteBright(str); },
digit: function (str) { return chalk_1.default.cyan(str); },
},
};
var flex_plugins_utils_logger_1 = require("flex-plugins-utils-logger");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return flex_plugins_utils_logger_1.logger; } });
//# sourceMappingURL=logger.js.map

@@ -5,10 +5,4 @@ "use strict";

};
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.render = void 0;
var marked_1 = __importDefault(require("marked"));

@@ -18,3 +12,3 @@ var marked_terminal_1 = __importDefault(require("marked-terminal"));

var fs_1 = require("./fs");
var logger = __importStar(require("./logger"));
var logger_1 = __importDefault(require("./logger"));
marked_1.default.setOptions({

@@ -28,4 +22,4 @@ renderer: new marked_terminal_1.default(),

*/
exports.render = function (filePath) { return pipe_compose_1.pipe(filePath, fs_1.readFileSync, marked_1.default, logger.info); };
exports.render = function (filePath) { return pipe_compose_1.pipe(filePath, fs_1.readFileSync, marked_1.default, logger_1.default.info); };
exports.default = marked_1.default;
//# sourceMappingURL=marked.js.map

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

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

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.printList = void 0;
var logger_1 = __importDefault(require("./logger"));

@@ -48,2 +49,3 @@ var strings_1 = require("./strings");

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

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

export declare const randomString: (length: number, list?: string[]) => string;
export default randomString;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.randomString = exports._randomGenerator = void 0;
/**

@@ -24,2 +25,3 @@ * Generates a random string

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

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

declare type Null = null | undefined;
/**

@@ -6,3 +7,3 @@ * Validates the string is a valid sid

*/
export declare const isValidSid: (sid: string | null | undefined) => boolean | "" | null | undefined;
export declare const isValidSid: (sid: string | Null) => boolean | "" | null | undefined;
/**

@@ -14,3 +15,3 @@ * Validates sid is of type prefix provided

*/
export declare const isSidOfType: (sid: string | null | undefined, prefix: string | null | undefined) => boolean | "" | null | undefined;
export declare const isSidOfType: (sid: string | Null, prefix: string | Null) => boolean | "" | null | undefined;
/**

@@ -21,2 +22,3 @@ * Prefix of Sids

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

@@ -34,2 +36,3 @@ EnvironmentSid: string;

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

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SidPrefix = exports.isSidOfType = exports.isValidSid = void 0;
/**

@@ -23,2 +24,3 @@ * Validates the string is a valid sid

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

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

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

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -52,4 +53,4 @@ });

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports.spawn = void 0;
var execa_1 = __importDefault(require("execa"));

@@ -68,3 +69,3 @@ var logger_1 = __importDefault(require("./logger"));

if (options === void 0) { options = DefaultOptions; }
return __awaiter(_this, void 0, void 0, function () {
return __awaiter(void 0, void 0, void 0, function () {
var spawnOptions, _a, signal, exitCode, exitCodeName, stdout, stderr, e_1;

@@ -71,0 +72,0 @@ return __generator(this, function (_b) {

@@ -1,16 +0,7 @@

/**
* Converts an array of arguments into a multiline string
*
* @param args the lines to print
*/
export declare const multilineString: (...args: string[]) => string;
/**
* Converts an array of string into a single lin
* @param args the lines to print
*/
export declare const singleLineString: (...args: string[]) => string;
import { multilineString, singleLineString } from 'flex-plugins-utils-logger';
export { singleLineString, multilineString, };
declare const _default: {
singleLineString: (...args: string[]) => string;
multilineString: (...args: string[]) => string;
singleLineString: (...args: string[]) => string;
};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Converts an array of arguments into a multiline string
*
* @param args the lines to print
*/
exports.multilineString = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return args.join('\r\n');
};
/**
* Converts an array of string into a single lin
* @param args the lines to print
*/
exports.singleLineString = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return args
.map(function (arg, index) { return index === 0 ? arg.trim() : " " + arg.trim(); })
.join('');
};
exports.multilineString = exports.singleLineString = void 0;
var flex_plugins_utils_logger_1 = require("flex-plugins-utils-logger");
Object.defineProperty(exports, "multilineString", { enumerable: true, get: function () { return flex_plugins_utils_logger_1.multilineString; } });
Object.defineProperty(exports, "singleLineString", { enumerable: true, get: function () { return flex_plugins_utils_logger_1.singleLineString; } });
exports.default = {
multilineString: exports.multilineString,
singleLineString: exports.singleLineString,
singleLineString: flex_plugins_utils_logger_1.singleLineString,
multilineString: flex_plugins_utils_logger_1.multilineString,
};
//# sourceMappingURL=strings.js.map

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

import { table } from 'table';
export default table;
/**
* Checks that the matrix's rows all have the same number of entries
*
* @param matrix
*/
export declare const isRegularMatrix: (matrix: string[][]) => boolean;
/**
* Prints the data in a table format with the provided headers
*
* @param header the header of the table
* @param data the data entry to print
*/
export declare const printArray: (header: string[], data: string[][]) => void;
/**
* Prints the data in a table format with the provided headers.
*
* @param data the data entry to print
*/
export declare const printObjectArray: (data: object[]) => void;
export { table as default } from 'flex-plugins-utils-logger';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var table_1 = require("table");
var logger_1 = __importDefault(require("./logger"));
exports.default = table_1.table;
var config = {
border: {
topBody: '─',
topJoin: '┬',
topLeft: '┌',
topRight: '┐',
bottomBody: '─',
bottomJoin: '┴',
bottomLeft: '└',
bottomRight: '┘',
bodyLeft: '│',
bodyRight: '│',
bodyJoin: '│',
joinBody: '─',
joinLeft: '├',
joinRight: '┤',
joinJoin: '┼',
},
};
/**
* Checks that the matrix's rows all have the same number of entries
*
* @param matrix
*/
exports.isRegularMatrix = function (matrix) { return matrix
&& matrix.length > 0
&& matrix[0].constructor === Array
&& matrix.every(function (r) { return r.length === matrix[0].length; }); };
/**
* Prints the data in a table format with the provided headers
*
* @param header the header of the table
* @param data the data entry to print
*/
exports.printArray = function (header, data) {
if (!exports.isRegularMatrix(data)) {
logger_1.default.warning('Table rows are not all the same length; this may produce an irregular tabular view.');
}
if (header.length !== Object.keys(data[0]).length) {
logger_1.default.warning('Header length does not match data row length; printing table without header.');
}
else {
data.unshift(header.map(function (h) { return h.toUpperCase(); }));
}
logger_1.default.info(table_1.table(data, config));
};
/**
* Prints the data in a table format with the provided headers.
*
* @param data the data entry to print
*/
exports.printObjectArray = function (data) {
if (data.length !== 0) {
var header = Object.keys(data[0]);
var rows = data.map(Object.values);
exports.printArray(header, rows);
}
};
var flex_plugins_utils_logger_1 = require("flex-plugins-utils-logger");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return flex_plugins_utils_logger_1.table; } });
//# sourceMappingURL=table.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.checkForUpdate = void 0;
var update_notifier_1 = __importDefault(require("update-notifier"));

@@ -17,5 +18,5 @@ var fs_1 = require("./fs");

? fs_1.readPackageJson(fs_1.findUp(module.parent.filename, 'package.json'))
: fs_1.readPackageJson();
: fs_1.readAppPackageJson();
update_notifier_1.default({ pkg: pkg }).notify();
};
//# sourceMappingURL=updateNotifier.js.map

@@ -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;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isGitHubUrl = exports.isValidUrl = exports.isValidPluginName = exports.validateConfirmation = exports.validateGitHubUrl = exports.validateApiKey = exports.validateAccountSid = exports.isInputNotEmpty = void 0;
var inquirer_1 = require("./inquirer");

@@ -29,2 +30,16 @@ var sids_1 = require("./sids");

/**
* 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 +96,3 @@ *

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

@@ -35,40 +35,42 @@ "keywords": [

"dependencies": {
"@k88/pipe-compose": "^2.1.1",
"@types/inquirer": "^6.5.0",
"axios": "^0.19.0",
"axios-mock-adapter": "^1.17.0",
"boxen": "^4.1.0",
"chalk": "^2.4.2",
"@k88/pipe-compose": "^2.1.2",
"address": "^1.1.2",
"app-module-path": "^2.2.0",
"axios": "^0.20.0",
"axios-mock-adapter": "^1.18.2",
"copy-template-dir": "^1.4.0",
"execa": "^2.1.0",
"inquirer": "7.0.0",
"lodash": "^4.17.15",
"log-symbols": "^3.0.0",
"marked": "^0.7.0",
"marked-terminal": "^3.3.0",
"mkdirp": "^0.5.1",
"open": "^6.4.0",
"ora": "^4.0.2",
"rimraf": "^3.0.0",
"table": "^5.4.6",
"tmp": "^0.1.0",
"update-notifier": "^3.0.1",
"util": "^0.12.1",
"wrap-ansi": "^4.0.0"
"flex-plugins-utils-exception": "^0.15.0",
"flex-plugins-utils-logger": "^0.15.0",
"globby": "^11.0.1",
"inquirer": "^7.3.3",
"lodash": "^4.17.20",
"marked": "^1.1.1",
"marked-terminal": "^4.1.0",
"mkdirp": "^1.0.4",
"net": "^1.0.2",
"open": "^7.2.1",
"rimraf": "^3.0.2",
"semver": "^7.3.2",
"tmp": "^0.2.1",
"update-notifier": "^4.1.1",
"url": "^0.11.0",
"util": "^0.12.3"
},
"devDependencies": {
"@types/lodash": "^4.14.144",
"@types/marked": "^0.6.5",
"@types/app-module-path": "^2.2.0",
"@types/inquirer": "^6.5.0",
"@types/lodash": "^4.14.161",
"@types/marked": "^1.1.0",
"@types/marked-terminal": "^3.1.1",
"@types/mkdirp": "^0.5.2",
"@types/rimraf": "^2.0.2",
"@types/table": "^4.0.7",
"@types/tmp": "^0.1.0",
"@types/update-notifier": "^2.5.0",
"@types/wrap-ansi": "^3.0.0"
"@types/mkdirp": "^1.0.1",
"@types/rimraf": "^3.0.0",
"@types/semver": "^7.3.3",
"@types/tmp": "^0.2.0",
"@types/update-notifier": "^4.1.1"
},
"optionalDependencies": {
"keytar": "^4.13.0"
"keytar": "^6.0.1"
},
"gitHead": "69170a84433b546aa312dc6818991dd9bf7e6dad"
"gitHead": "6a46ff328401af60e971d6bb3d2013dd0e9eb79d"
}

@@ -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

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

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