flex-plugin-e2e-tests
Advanced tools
Comparing version 4.7.2-dev.202104212248 to 4.7.3-betabeta.0
@@ -7,2 +7,3 @@ export interface TestParams { | ||
name: string; | ||
dir: string; | ||
}; | ||
@@ -9,0 +10,0 @@ } |
@@ -53,2 +53,3 @@ "use strict"; | ||
exports.homeDir = process.env.HOME + "/.local"; | ||
var pluginName = 'flex-e2e-tester-plugin'; | ||
var testParams = { | ||
@@ -59,5 +60,10 @@ packageVersion: process.env.PACKAGE_VERSION, | ||
plugin: { | ||
name: 'flex-e2e-tester-plugin', | ||
name: pluginName, | ||
dir: exports.homeDir + "/" + pluginName, | ||
}, | ||
}; | ||
var getArg = function (flag) { | ||
var index = process.argv.indexOf(flag); | ||
return process.argv[index + 1]; | ||
}; | ||
(function () { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -68,4 +74,8 @@ var i; | ||
case 0: | ||
if (!fs_1.existsSync(exports.homeDir)) { | ||
fs_1.mkdirSync(exports.homeDir); | ||
} | ||
flex_plugins_utils_logger_1.logger.info("Running Plugins E2E Test with parameters:"); | ||
Object.keys(testParams).forEach(function (key) { return flex_plugins_utils_logger_1.logger.info("- " + key + ": " + JSON.stringify(testParams[key])); }); | ||
if (!!process.argv.includes('--step')) return [3 /*break*/, 5]; | ||
i = 0; | ||
@@ -83,2 +93,6 @@ _a.label = 1; | ||
case 4: return [2 /*return*/]; | ||
case 5: return [4 /*yield*/, require(__dirname + "/tests/step" + getArg('--step')).default(testParams)]; | ||
case 6: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
@@ -85,0 +99,0 @@ }); |
@@ -49,7 +49,10 @@ "use strict"; | ||
flex_plugins_utils_logger_1.logger.info('Step 001 - Installing Twilio CLI and Plugins CLI'); | ||
return [4 /*yield*/, utils_1.spawn('npm', 'install', "--prefix=" + params.homeDir, '-g', 'twilio-cli')]; | ||
return [4 /*yield*/, utils_1.spawn('npm', ['install', "--prefix=" + params.homeDir, '-g', 'twilio-cli'])]; | ||
case 1: | ||
twilioCliResult = _a.sent(); | ||
utils_1.logResult(twilioCliResult); | ||
return [4 /*yield*/, utils_1.spawn('twilio', 'plugins:install', "@twilio-labs/plugin-flex@" + params.packageVersion)]; | ||
return [4 /*yield*/, utils_1.spawn('twilio', [ | ||
'plugins:install', | ||
"@twilio-labs/plugin-flex@" + params.packageVersion, | ||
])]; | ||
case 2: | ||
@@ -56,0 +59,0 @@ pluginsCliResult = _a.sent(); |
@@ -44,3 +44,3 @@ "use strict"; | ||
var testSuite = function (params) { return __awaiter(void 0, void 0, void 0, function () { | ||
var twilioCliResult, dir; | ||
var twilioCliResult; | ||
return __generator(this, function (_a) { | ||
@@ -50,23 +50,24 @@ switch (_a.label) { | ||
flex_plugins_utils_logger_1.logger.info('Step 002 - Creating a Plugin'); | ||
return [4 /*yield*/, utils_1.spawn('twilio', 'flex:plugins:create', params.plugin.name)]; | ||
return [4 /*yield*/, utils_1.spawn('twilio', ['flex:plugins:create', params.plugin.name])]; | ||
case 1: | ||
twilioCliResult = _a.sent(); | ||
utils_1.logResult(twilioCliResult); | ||
dir = params.homeDir + "/" + params.plugin.name; | ||
// Assert files/directories exist | ||
utils_1.assertion.fileExists([dir], 'Plugin directory does not exist'); | ||
utils_1.assertion.fileExists([dir, 'src']); | ||
utils_1.assertion.fileExists([dir, 'public']); | ||
utils_1.assertion.fileExists([dir, 'package.json']); | ||
utils_1.assertion.fileExists([dir, 'webpack.config.js']); | ||
utils_1.assertion.fileExists([dir, 'webpack.dev.js']); | ||
utils_1.assertion.fileExists([dir, 'jest.config.js']); | ||
utils_1.assertion.fileExists([dir, 'public', 'appConfig.js']); | ||
utils_1.assertion.fileExists([dir, 'public', 'appConfig.example.js']); | ||
utils_1.assertion.not.fileExists([dir, 'public', 'plugins.json']); | ||
utils_1.assertion.fileExists([params.plugin.dir], 'Plugin directory does not exist'); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'src']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'src', 'components']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'src', 'components', '__tests__']); | ||
utils_1.assertion.not.dirIsEmpty([params.plugin.dir, 'src', 'components', '__tests__']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'public']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'package.json']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'webpack.config.js']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'webpack.dev.js']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'jest.config.js']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'public', 'appConfig.js']); | ||
utils_1.assertion.fileExists([params.plugin.dir, 'public', 'appConfig.example.js']); | ||
// Assert package.json | ||
utils_1.assertion.jsonFileContains([dir, 'package.json'], "dependencies['flex-plugin-scripts']", "^" + params.packageVersion); | ||
utils_1.assertion.jsonFileContains([dir, 'package.json'], "dependencies['react']", "16.5.2"); | ||
utils_1.assertion.jsonFileContains([dir, 'package.json'], "dependencies['react-dom']", "16.5.2"); | ||
utils_1.assertion.jsonFileContains([dir, 'package.json'], "devDependencies['react-test-renderer']", "16.5.2"); | ||
utils_1.assertion.jsonFileContains([params.plugin.dir, 'package.json'], "dependencies['flex-plugin-scripts']", "^" + params.packageVersion); | ||
utils_1.assertion.jsonFileContains([params.plugin.dir, 'package.json'], "dependencies['react']", "16.5.2"); | ||
utils_1.assertion.jsonFileContains([params.plugin.dir, 'package.json'], "dependencies['react-dom']", "16.5.2"); | ||
utils_1.assertion.jsonFileContains([params.plugin.dir, 'package.json'], "devDependencies['react-test-renderer']", "16.5.2"); | ||
return [2 /*return*/]; | ||
@@ -73,0 +74,0 @@ } |
@@ -7,5 +7,9 @@ /// <reference types="node" /> | ||
jsonFileContains: <T>(paths: string[], key: string, value: T, msg?: string | undefined) => void; | ||
fileContains: (paths: string[], value: string, msg?: string | undefined) => void; | ||
dirIsEmpty: (paths: string[], msg?: string | undefined) => void; | ||
not: { | ||
fileExists: (paths: string[], msg?: string | undefined) => void; | ||
jsonFileContains: <T>(paths: string[], key: string, value: T, msg?: string | undefined) => void; | ||
fileContains: (paths: string[], value: string, msg?: string | undefined) => void; | ||
dirIsEmpty: (paths: string[], msg?: string | undefined) => void; | ||
equal: typeof notStrictEqual; | ||
@@ -12,0 +16,0 @@ }; |
@@ -56,8 +56,29 @@ "use strict"; | ||
}; | ||
/** | ||
* Checks whether a file/directory exists | ||
*/ | ||
var fileExists = function (doesEqual) { return function (paths, msg) { | ||
_strictEqual(doesEqual, true, fs.existsSync(path.join.apply(path, __spreadArray([], __read(paths)))), msg); | ||
}; }; | ||
/** | ||
* Checks whether the JSON file contains the given key:value pair | ||
*/ | ||
var jsonFileContains = function (doesEqual) { return function (paths, key, value, msg) { | ||
_strictEqual(doesEqual, value, lodash_1.get(JSON.parse(fs.readFileSync(path.join.apply(path, __spreadArray([], __read(paths))), 'utf-8')), key), msg); | ||
}; }; | ||
/** | ||
* Checks whether the file contains the given string | ||
*/ | ||
var fileContains = function (doesEqual) { return function (paths, value, msg) { | ||
var file = path.join.apply(path, __spreadArray([], __read(paths))); | ||
var not = doesEqual ? ' not ' : ' '; | ||
msg = msg || file + " does" + not + "contain " + value; | ||
_strictEqual(doesEqual, true, fs.readFileSync(file, 'utf-8').includes(value), msg); | ||
}; }; | ||
/** | ||
* Checks whether the directory is empty | ||
*/ | ||
var dirIsEmpty = function (doesEqual) { return function (paths, msg) { | ||
_strictEqual(doesEqual, 0, fs.readdirSync(path.join.apply(path, __spreadArray([], __read(paths)))).length, msg); | ||
}; }; | ||
exports.default = { | ||
@@ -67,5 +88,9 @@ equal: assert_1.strictEqual, | ||
jsonFileContains: jsonFileContains(true), | ||
fileContains: fileContains(true), | ||
dirIsEmpty: dirIsEmpty(true), | ||
not: { | ||
fileExists: fileExists(false), | ||
jsonFileContains: jsonFileContains(false), | ||
fileContains: fileContains(false), | ||
dirIsEmpty: dirIsEmpty(false), | ||
equal: assert_1.notStrictEqual, | ||
@@ -72,0 +97,0 @@ }, |
export { default as spawn, logResult } from './spawn'; | ||
export { default as assertion } from './assertion'; | ||
export { join as joinPath } from 'path'; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.assertion = exports.logResult = exports.spawn = void 0; | ||
exports.joinPath = exports.assertion = exports.logResult = exports.spawn = void 0; | ||
var spawn_1 = require("./spawn"); | ||
@@ -13,2 +13,4 @@ Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return __importDefault(spawn_1).default; } }); | ||
Object.defineProperty(exports, "assertion", { enumerable: true, get: function () { return __importDefault(assertion_1).default; } }); | ||
var path_1 = require("path"); | ||
Object.defineProperty(exports, "joinPath", { enumerable: true, get: function () { return path_1.join; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
import { SpawnOptionsWithoutStdio } from 'child_process'; | ||
interface SpawnResult { | ||
@@ -5,3 +7,3 @@ stdout: string; | ||
} | ||
declare const _default: (cmd: string, ...args: string[]) => Promise<SpawnResult>; | ||
declare const _default: (cmd: string, args: string[], options?: SpawnOptionsWithoutStdio | undefined) => Promise<SpawnResult>; | ||
/** | ||
@@ -11,2 +13,3 @@ * Promisified spawn | ||
* @param args the args to that command | ||
* @param options spawn options to run | ||
*/ | ||
@@ -13,0 +16,0 @@ export default _default; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -47,55 +58,53 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
* @param args the args to that command | ||
* @param options spawn options to run | ||
*/ | ||
exports.default = (function (cmd) { | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
flex_plugins_utils_logger_1.logger.info("Running spawn command: **" + cmd + " " + args.join(' ') + "**"); | ||
var child = child_process_1.spawn(cmd, args, { | ||
cwd: __1.homeDir, | ||
env: { | ||
PATH: process.env.PATH + ":/" + __1.homeDir + "/bin", | ||
}, | ||
}); | ||
var stdoutArr = []; | ||
var stderrArr = []; | ||
// errors | ||
child.on('error', reject); | ||
child.stdin.on('error', reject); | ||
child.stdout.on('error', reject); | ||
child.stderr.setEncoding('utf8'); | ||
child.stderr.on('error', reject); | ||
child.stderr.on('data', function (data) { | ||
if (typeof data === 'string') { | ||
stderrArr.push(Buffer.from(data, 'utf-8')); | ||
} | ||
else { | ||
stderrArr.push(data); | ||
} | ||
}); | ||
// data | ||
child.stdout.on('data', function (data) { | ||
if (typeof data === 'string') { | ||
stdoutArr.push(Buffer.from(data, 'utf-8')); | ||
} | ||
else { | ||
stdoutArr.push(data); | ||
} | ||
}); | ||
child.on('close', function (code) { | ||
var stdout = Buffer.concat(stdoutArr).toString(); | ||
var stderr = Buffer.concat(stderrArr).toString(); | ||
if (code === 0) { | ||
return resolve({ stdout: stdout, stderr: stderr }); | ||
} | ||
return reject(new Error("Command exited with code " + code + " and message " + stdout + ": " + stderr)); | ||
}); | ||
})]; | ||
}); | ||
exports.default = (function (cmd, args, options) { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
var defaultOptions = { | ||
cwd: __1.homeDir, | ||
env: { | ||
PATH: process.env.PATH + ":/" + __1.homeDir + "/bin", | ||
}, | ||
}; | ||
var spawnOptions = __assign(__assign({}, defaultOptions), options); | ||
flex_plugins_utils_logger_1.logger.info("Running spawn command: **" + cmd + " " + args.join(' ') + "**"); | ||
flex_plugins_utils_logger_1.logger.debug("Spawn options are **" + JSON.stringify(options) + "**"); | ||
var child = child_process_1.spawn(cmd, args, spawnOptions); | ||
var stdoutArr = []; | ||
var stderrArr = []; | ||
// errors | ||
child.on('error', reject); | ||
child.stdin.on('error', reject); | ||
child.stdout.on('error', reject); | ||
child.stderr.setEncoding('utf8'); | ||
child.stderr.on('error', reject); | ||
child.stderr.on('data', function (data) { | ||
if (typeof data === 'string') { | ||
stderrArr.push(Buffer.from(data, 'utf-8')); | ||
} | ||
else { | ||
stderrArr.push(data); | ||
} | ||
}); | ||
// data | ||
child.stdout.on('data', function (data) { | ||
if (typeof data === 'string') { | ||
stdoutArr.push(Buffer.from(data, 'utf-8')); | ||
} | ||
else { | ||
stdoutArr.push(data); | ||
} | ||
}); | ||
child.on('close', function (code) { | ||
var stdout = Buffer.concat(stdoutArr).toString(); | ||
var stderr = Buffer.concat(stderrArr).toString(); | ||
if (code === 0) { | ||
return resolve({ stdout: stdout, stderr: stderr }); | ||
} | ||
return reject(new Error("Command exited with code " + code + " and message " + stdout + ": " + stderr)); | ||
}); | ||
})]; | ||
}); | ||
}); | ||
}); }); | ||
/** | ||
@@ -102,0 +111,0 @@ * Helper for logging the result from a spawn |
{ | ||
"name": "flex-plugin-e2e-tests", | ||
"version": "4.7.2-dev.202104212248", | ||
"version": "4.7.3-betabeta.0", | ||
"description": "Flex Plugin E2E Tests framework", | ||
@@ -37,4 +37,5 @@ "keywords": [ | ||
"dependencies": { | ||
"flex-plugins-utils-logger": "^4.7.2-dev.202104212248", | ||
"lodash": "4.17.21" | ||
"flex-plugins-utils-logger": "^4.7.3-betabeta.0", | ||
"lodash": "4.17.21", | ||
"replace-in-file": "^6.2.0" | ||
}, | ||
@@ -47,3 +48,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "d157663970cbee240efcec00d15f30fb474d0f08" | ||
"gitHead": "7786cc80f131315883f72f7e6ee843853bd6f4c8" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53140
30
724
3
9
+ Addedreplace-in-file@^6.2.0
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedflex-plugins-utils-env@4.7.3-dev.202104220025(transitive)
+ Addedflex-plugins-utils-logger@4.7.3-dev.202104220025(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedreplace-in-file@6.3.5(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removedflex-plugins-utils-env@4.7.2-dev.202104212248(transitive)
- Removedflex-plugins-utils-logger@4.7.2-dev.202104212248(transitive)