refactor: init cypress-cucumber-preprocessor install.

This commit is contained in:
2021-09-02 17:02:45 +02:00
parent 89ec2d42ac
commit 1aa57bbd0a
5000 changed files with 408119 additions and 231 deletions

196
node_modules/@babel/traverse/lib/path/lib/hoister.js generated vendored Normal file
View File

@@ -0,0 +1,196 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var t = require("@babel/types");
const referenceVisitor = {
ReferencedIdentifier(path, state) {
if (path.isJSXIdentifier() && t.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
return;
}
if (path.node.name === "this") {
let scope = path.scope;
do {
if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) {
break;
}
} while (scope = scope.parent);
if (scope) state.breakOnScopePaths.push(scope.path);
}
const binding = path.scope.getBinding(path.node.name);
if (!binding) return;
for (const violation of binding.constantViolations) {
if (violation.scope !== binding.path.scope) {
state.mutableBinding = true;
path.stop();
return;
}
}
if (binding !== state.scope.getBinding(path.node.name)) return;
state.bindings[path.node.name] = binding;
}
};
class PathHoister {
constructor(path, scope) {
this.breakOnScopePaths = void 0;
this.bindings = void 0;
this.mutableBinding = void 0;
this.scopes = void 0;
this.scope = void 0;
this.path = void 0;
this.attachAfter = void 0;
this.breakOnScopePaths = [];
this.bindings = {};
this.mutableBinding = false;
this.scopes = [];
this.scope = scope;
this.path = path;
this.attachAfter = false;
}
isCompatibleScope(scope) {
for (const key of Object.keys(this.bindings)) {
const binding = this.bindings[key];
if (!scope.bindingIdentifierEquals(key, binding.identifier)) {
return false;
}
}
return true;
}
getCompatibleScopes() {
let scope = this.path.scope;
do {
if (this.isCompatibleScope(scope)) {
this.scopes.push(scope);
} else {
break;
}
if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
break;
}
} while (scope = scope.parent);
}
getAttachmentPath() {
let path = this._getAttachmentPath();
if (!path) return;
let targetScope = path.scope;
if (targetScope.path === path) {
targetScope = path.scope.parent;
}
if (targetScope.path.isProgram() || targetScope.path.isFunction()) {
for (const name of Object.keys(this.bindings)) {
if (!targetScope.hasOwnBinding(name)) continue;
const binding = this.bindings[name];
if (binding.kind === "param" || binding.path.parentKey === "params") {
continue;
}
const bindingParentPath = this.getAttachmentParentForPath(binding.path);
if (bindingParentPath.key >= path.key) {
this.attachAfter = true;
path = binding.path;
for (const violationPath of binding.constantViolations) {
if (this.getAttachmentParentForPath(violationPath).key > path.key) {
path = violationPath;
}
}
}
}
}
return path;
}
_getAttachmentPath() {
const scopes = this.scopes;
const scope = scopes.pop();
if (!scope) return;
if (scope.path.isFunction()) {
if (this.hasOwnParamBindings(scope)) {
if (this.scope === scope) return;
const bodies = scope.path.get("body").get("body");
for (let i = 0; i < bodies.length; i++) {
if (bodies[i].node._blockHoist) continue;
return bodies[i];
}
} else {
return this.getNextScopeAttachmentParent();
}
} else if (scope.path.isProgram()) {
return this.getNextScopeAttachmentParent();
}
}
getNextScopeAttachmentParent() {
const scope = this.scopes.pop();
if (scope) return this.getAttachmentParentForPath(scope.path);
}
getAttachmentParentForPath(path) {
do {
if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
return path;
}
} while (path = path.parentPath);
}
hasOwnParamBindings(scope) {
for (const name of Object.keys(this.bindings)) {
if (!scope.hasOwnBinding(name)) continue;
const binding = this.bindings[name];
if (binding.kind === "param" && binding.constant) return true;
}
return false;
}
run() {
this.path.traverse(referenceVisitor, this);
if (this.mutableBinding) return;
this.getCompatibleScopes();
const attachTo = this.getAttachmentPath();
if (!attachTo) return;
if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
let uid = attachTo.scope.generateUidIdentifier("ref");
const declarator = t.variableDeclarator(uid, this.path.node);
const insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])]);
const parent = this.path.parentPath;
if (parent.isJSXElement() && this.path.container === parent.node.children) {
uid = t.jsxExpressionContainer(uid);
}
this.path.replaceWith(t.cloneNode(uid));
return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init");
}
}
exports.default = PathHoister;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hooks = void 0;
const hooks = [function (self, parent) {
const removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();
if (removeParent) {
parent.remove();
return true;
}
}, function (self, parent) {
if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {
parent.replaceWith(parent.node.expressions[0]);
return true;
}
}, function (self, parent) {
if (parent.isBinary()) {
if (self.key === "left") {
parent.replaceWith(parent.node.right);
} else {
parent.replaceWith(parent.node.left);
}
return true;
}
}, function (self, parent) {
if (parent.isIfStatement() && (self.key === "consequent" || self.key === "alternate") || self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) {
self.replaceWith({
type: "BlockStatement",
body: []
});
return true;
}
}];
exports.hooks = hooks;

View File

@@ -0,0 +1,206 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = void 0;
var t = require("@babel/types");
const ReferencedIdentifier = {
types: ["Identifier", "JSXIdentifier"],
checkPath(path, opts) {
const {
node,
parent
} = path;
if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) {
if (t.isJSXIdentifier(node, opts)) {
if (t.react.isCompatTag(node.name)) return false;
} else {
return false;
}
}
return t.isReferenced(node, parent, path.parentPath.parent);
}
};
exports.ReferencedIdentifier = ReferencedIdentifier;
const ReferencedMemberExpression = {
types: ["MemberExpression"],
checkPath({
node,
parent
}) {
return t.isMemberExpression(node) && t.isReferenced(node, parent);
}
};
exports.ReferencedMemberExpression = ReferencedMemberExpression;
const BindingIdentifier = {
types: ["Identifier"],
checkPath(path) {
const {
node,
parent
} = path;
const grandparent = path.parentPath.parent;
return t.isIdentifier(node) && t.isBinding(node, parent, grandparent);
}
};
exports.BindingIdentifier = BindingIdentifier;
const Statement = {
types: ["Statement"],
checkPath({
node,
parent
}) {
if (t.isStatement(node)) {
if (t.isVariableDeclaration(node)) {
if (t.isForXStatement(parent, {
left: node
})) return false;
if (t.isForStatement(parent, {
init: node
})) return false;
}
return true;
} else {
return false;
}
}
};
exports.Statement = Statement;
const Expression = {
types: ["Expression"],
checkPath(path) {
if (path.isIdentifier()) {
return path.isReferencedIdentifier();
} else {
return t.isExpression(path.node);
}
}
};
exports.Expression = Expression;
const Scope = {
types: ["Scopable", "Pattern"],
checkPath(path) {
return t.isScope(path.node, path.parent);
}
};
exports.Scope = Scope;
const Referenced = {
checkPath(path) {
return t.isReferenced(path.node, path.parent);
}
};
exports.Referenced = Referenced;
const BlockScoped = {
checkPath(path) {
return t.isBlockScoped(path.node);
}
};
exports.BlockScoped = BlockScoped;
const Var = {
types: ["VariableDeclaration"],
checkPath(path) {
return t.isVar(path.node);
}
};
exports.Var = Var;
const User = {
checkPath(path) {
return path.node && !!path.node.loc;
}
};
exports.User = User;
const Generated = {
checkPath(path) {
return !path.isUser();
}
};
exports.Generated = Generated;
const Pure = {
checkPath(path, opts) {
return path.scope.isPure(path.node, opts);
}
};
exports.Pure = Pure;
const Flow = {
types: ["Flow", "ImportDeclaration", "ExportDeclaration", "ImportSpecifier"],
checkPath({
node
}) {
if (t.isFlow(node)) {
return true;
} else if (t.isImportDeclaration(node)) {
return node.importKind === "type" || node.importKind === "typeof";
} else if (t.isExportDeclaration(node)) {
return node.exportKind === "type";
} else if (t.isImportSpecifier(node)) {
return node.importKind === "type" || node.importKind === "typeof";
} else {
return false;
}
}
};
exports.Flow = Flow;
const RestProperty = {
types: ["RestElement"],
checkPath(path) {
return path.parentPath && path.parentPath.isObjectPattern();
}
};
exports.RestProperty = RestProperty;
const SpreadProperty = {
types: ["RestElement"],
checkPath(path) {
return path.parentPath && path.parentPath.isObjectExpression();
}
};
exports.SpreadProperty = SpreadProperty;
const ExistentialTypeParam = {
types: ["ExistsTypeAnnotation"]
};
exports.ExistentialTypeParam = ExistentialTypeParam;
const NumericLiteralTypeAnnotation = {
types: ["NumberLiteralTypeAnnotation"]
};
exports.NumericLiteralTypeAnnotation = NumericLiteralTypeAnnotation;
const ForAwaitStatement = {
types: ["ForOfStatement"],
checkPath({
node
}) {
return node.await === true;
}
};
exports.ForAwaitStatement = ForAwaitStatement;