@mochabug/adaptkit 1.0.0-rc.2 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +21 -172
- package/bin/index.js.map +3 -3
- package/package.json +3 -8
package/bin/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// <define:__PACKAGE_JSON__>
|
|
4
|
-
var define_PACKAGE_JSON_default = { name: "@mochabug/adaptkit", version: "1.0.0-rc.
|
|
4
|
+
var define_PACKAGE_JSON_default = { name: "@mochabug/adaptkit", version: "1.0.0-rc.4" };
|
|
5
5
|
|
|
6
6
|
// node_modules/@bufbuild/protobuf/dist/esm/is-message.js
|
|
7
7
|
function isMessage(arg, schema) {
|
|
@@ -2041,11 +2041,11 @@ function unescapeBytesDefaultValue(str) {
|
|
|
2041
2041
|
case "6":
|
|
2042
2042
|
case "7": {
|
|
2043
2043
|
const s = input3.c;
|
|
2044
|
-
const
|
|
2045
|
-
if (
|
|
2044
|
+
const t = input3.take(2);
|
|
2045
|
+
if (t === false) {
|
|
2046
2046
|
return false;
|
|
2047
2047
|
}
|
|
2048
|
-
const n = parseInt(s +
|
|
2048
|
+
const n = parseInt(s + t, 8);
|
|
2049
2049
|
if (isNaN(n)) {
|
|
2050
2050
|
return false;
|
|
2051
2051
|
}
|
|
@@ -2054,11 +2054,11 @@ function unescapeBytesDefaultValue(str) {
|
|
|
2054
2054
|
}
|
|
2055
2055
|
case "x": {
|
|
2056
2056
|
const s = input3.c;
|
|
2057
|
-
const
|
|
2058
|
-
if (
|
|
2057
|
+
const t = input3.take(2);
|
|
2058
|
+
if (t === false) {
|
|
2059
2059
|
return false;
|
|
2060
2060
|
}
|
|
2061
|
-
const n = parseInt(s +
|
|
2061
|
+
const n = parseInt(s + t, 16);
|
|
2062
2062
|
if (isNaN(n)) {
|
|
2063
2063
|
return false;
|
|
2064
2064
|
}
|
|
@@ -2067,11 +2067,11 @@ function unescapeBytesDefaultValue(str) {
|
|
|
2067
2067
|
}
|
|
2068
2068
|
case "u": {
|
|
2069
2069
|
const s = input3.c;
|
|
2070
|
-
const
|
|
2071
|
-
if (
|
|
2070
|
+
const t = input3.take(4);
|
|
2071
|
+
if (t === false) {
|
|
2072
2072
|
return false;
|
|
2073
2073
|
}
|
|
2074
|
-
const n = parseInt(s +
|
|
2074
|
+
const n = parseInt(s + t, 16);
|
|
2075
2075
|
if (isNaN(n)) {
|
|
2076
2076
|
return false;
|
|
2077
2077
|
}
|
|
@@ -2083,11 +2083,11 @@ function unescapeBytesDefaultValue(str) {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
case "U": {
|
|
2085
2085
|
const s = input3.c;
|
|
2086
|
-
const
|
|
2087
|
-
if (
|
|
2086
|
+
const t = input3.take(8);
|
|
2087
|
+
if (t === false) {
|
|
2088
2088
|
return false;
|
|
2089
2089
|
}
|
|
2090
|
-
const tc = protoInt64.uEnc(s +
|
|
2090
|
+
const tc = protoInt64.uEnc(s + t);
|
|
2091
2091
|
const chunk = new Uint8Array(8);
|
|
2092
2092
|
const view = new DataView(chunk.buffer);
|
|
2093
2093
|
view.setInt32(0, tc.lo, true);
|
|
@@ -2223,24 +2223,24 @@ function createBaseRegistry() {
|
|
|
2223
2223
|
return files.get(fileName);
|
|
2224
2224
|
},
|
|
2225
2225
|
getMessage(typeName) {
|
|
2226
|
-
const
|
|
2227
|
-
return (
|
|
2226
|
+
const t = types.get(typeName);
|
|
2227
|
+
return (t === null || t === void 0 ? void 0 : t.kind) == "message" ? t : void 0;
|
|
2228
2228
|
},
|
|
2229
2229
|
getEnum(typeName) {
|
|
2230
|
-
const
|
|
2231
|
-
return (
|
|
2230
|
+
const t = types.get(typeName);
|
|
2231
|
+
return (t === null || t === void 0 ? void 0 : t.kind) == "enum" ? t : void 0;
|
|
2232
2232
|
},
|
|
2233
2233
|
getExtension(typeName) {
|
|
2234
|
-
const
|
|
2235
|
-
return (
|
|
2234
|
+
const t = types.get(typeName);
|
|
2235
|
+
return (t === null || t === void 0 ? void 0 : t.kind) == "extension" ? t : void 0;
|
|
2236
2236
|
},
|
|
2237
2237
|
getExtensionFor(extendee, no) {
|
|
2238
2238
|
var _a;
|
|
2239
2239
|
return (_a = extendees.get(extendee.typeName)) === null || _a === void 0 ? void 0 : _a.get(no);
|
|
2240
2240
|
},
|
|
2241
2241
|
getService(typeName) {
|
|
2242
|
-
const
|
|
2243
|
-
return (
|
|
2242
|
+
const t = types.get(typeName);
|
|
2243
|
+
return (t === null || t === void 0 ? void 0 : t.kind) == "service" ? t : void 0;
|
|
2244
2244
|
}
|
|
2245
2245
|
};
|
|
2246
2246
|
}
|
|
@@ -5399,9 +5399,6 @@ async function waitForConsent(issuerUrl, errorUrl, clientId) {
|
|
|
5399
5399
|
}
|
|
5400
5400
|
|
|
5401
5401
|
// src/publish.ts
|
|
5402
|
-
import { parse } from "@babel/parser";
|
|
5403
|
-
import babelTraverse from "@babel/traverse";
|
|
5404
|
-
import * as t from "@babel/types";
|
|
5405
5402
|
import { ConnectError, createClient } from "@connectrpc/connect";
|
|
5406
5403
|
import { createGrpcTransport } from "@connectrpc/connect-node";
|
|
5407
5404
|
import chalk5 from "chalk";
|
|
@@ -5428,7 +5425,6 @@ var UploadPluginRequestSchema = /* @__PURE__ */ messageDesc(file_mochabugapis_ad
|
|
|
5428
5425
|
var PluginService = /* @__PURE__ */ serviceDesc(file_mochabugapis_adapt_plugins_v1_plugins, 0);
|
|
5429
5426
|
|
|
5430
5427
|
// src/publish.ts
|
|
5431
|
-
var traverse = babelTraverse.default || babelTraverse;
|
|
5432
5428
|
async function resize(filepath, height, width) {
|
|
5433
5429
|
const extname = path4.extname(filepath);
|
|
5434
5430
|
switch (extname) {
|
|
@@ -5456,154 +5452,7 @@ function isPathSafe(filePath) {
|
|
|
5456
5452
|
const absoluteFilePath = path4.resolve(filePath);
|
|
5457
5453
|
return absoluteFilePath.startsWith(currentWorkingDir);
|
|
5458
5454
|
}
|
|
5459
|
-
function resolveBindingValue(node, scope, depth = 0) {
|
|
5460
|
-
if (!node) return null;
|
|
5461
|
-
if (depth > 20) return node;
|
|
5462
|
-
if (t.isIdentifier(node)) {
|
|
5463
|
-
const binding = scope.getBinding(node.name);
|
|
5464
|
-
if (binding && binding.path.node.type === "VariableDeclarator") {
|
|
5465
|
-
return resolveBindingValue(
|
|
5466
|
-
binding.path.node.init,
|
|
5467
|
-
binding.path.scope,
|
|
5468
|
-
depth + 1
|
|
5469
|
-
);
|
|
5470
|
-
}
|
|
5471
|
-
return node;
|
|
5472
|
-
}
|
|
5473
|
-
return node;
|
|
5474
|
-
}
|
|
5475
|
-
function getPropertyKeyName(prop) {
|
|
5476
|
-
if (prop.computed) {
|
|
5477
|
-
if (t.isStringLiteral(prop.key)) return prop.key.value;
|
|
5478
|
-
return null;
|
|
5479
|
-
}
|
|
5480
|
-
if (t.isIdentifier(prop.key)) return prop.key.name;
|
|
5481
|
-
if (t.isStringLiteral(prop.key)) return prop.key.value;
|
|
5482
|
-
return null;
|
|
5483
|
-
}
|
|
5484
|
-
function validateObjectExpression(objectExpression) {
|
|
5485
|
-
for (const prop of objectExpression.properties) {
|
|
5486
|
-
if (t.isObjectMethod(prop) || t.isObjectProperty(prop)) {
|
|
5487
|
-
const keyName = getPropertyKeyName(prop);
|
|
5488
|
-
if (keyName === "fetch") {
|
|
5489
|
-
if (t.isObjectMethod(prop)) {
|
|
5490
|
-
return true;
|
|
5491
|
-
}
|
|
5492
|
-
if (t.isObjectProperty(prop)) {
|
|
5493
|
-
if (t.isFunctionExpression(prop.value) || t.isArrowFunctionExpression(prop.value)) {
|
|
5494
|
-
return true;
|
|
5495
|
-
}
|
|
5496
|
-
}
|
|
5497
|
-
}
|
|
5498
|
-
}
|
|
5499
|
-
}
|
|
5500
|
-
return false;
|
|
5501
|
-
}
|
|
5502
|
-
async function validateEsmModules(manifest) {
|
|
5503
|
-
async function validateModule(modulePath) {
|
|
5504
|
-
let code;
|
|
5505
|
-
try {
|
|
5506
|
-
code = fs5.readFileSync(modulePath, "utf8");
|
|
5507
|
-
} catch (err) {
|
|
5508
|
-
throw new Error(`Failed to read module at ${modulePath}: ${err.message}`);
|
|
5509
|
-
}
|
|
5510
|
-
let ast;
|
|
5511
|
-
try {
|
|
5512
|
-
ast = parse(code, {
|
|
5513
|
-
sourceType: "module",
|
|
5514
|
-
plugins: [
|
|
5515
|
-
"jsx",
|
|
5516
|
-
"classProperties",
|
|
5517
|
-
"optionalChaining",
|
|
5518
|
-
"nullishCoalescingOperator"
|
|
5519
|
-
]
|
|
5520
|
-
});
|
|
5521
|
-
} catch (err) {
|
|
5522
|
-
throw new Error(
|
|
5523
|
-
`The file at ${modulePath} is not valid JavaScript: ${err.message}`
|
|
5524
|
-
);
|
|
5525
|
-
}
|
|
5526
|
-
let defaultExportFound = false;
|
|
5527
|
-
let defaultExportValid = false;
|
|
5528
|
-
traverse(ast, {
|
|
5529
|
-
// Handle direct export default declarations.
|
|
5530
|
-
ExportDefaultDeclaration(path6) {
|
|
5531
|
-
defaultExportFound = true;
|
|
5532
|
-
const declaration = path6.node.declaration;
|
|
5533
|
-
let objectExpression = null;
|
|
5534
|
-
if (t.isObjectExpression(declaration)) {
|
|
5535
|
-
objectExpression = declaration;
|
|
5536
|
-
} else if (t.isParenthesizedExpression(declaration) && t.isObjectExpression(declaration.expression)) {
|
|
5537
|
-
objectExpression = declaration.expression;
|
|
5538
|
-
} else if (t.isIdentifier(declaration)) {
|
|
5539
|
-
const resolved = resolveBindingValue(declaration, path6.scope);
|
|
5540
|
-
if (resolved && t.isObjectExpression(resolved)) {
|
|
5541
|
-
objectExpression = resolved;
|
|
5542
|
-
} else if (resolved && t.isParenthesizedExpression(resolved) && t.isObjectExpression(resolved.expression)) {
|
|
5543
|
-
objectExpression = resolved.expression;
|
|
5544
|
-
}
|
|
5545
|
-
}
|
|
5546
|
-
if (objectExpression && validateObjectExpression(objectExpression)) {
|
|
5547
|
-
defaultExportValid = true;
|
|
5548
|
-
}
|
|
5549
|
-
path6.stop();
|
|
5550
|
-
},
|
|
5551
|
-
// Handle export lists like: export { something as default }
|
|
5552
|
-
ExportNamedDeclaration(path6) {
|
|
5553
|
-
if (path6.node.specifiers && path6.node.specifiers.length > 0) {
|
|
5554
|
-
for (const specifier of path6.node.specifiers) {
|
|
5555
|
-
if (t.isExportSpecifier(specifier)) {
|
|
5556
|
-
if (t.isIdentifier(specifier.exported, { name: "default" })) {
|
|
5557
|
-
defaultExportFound = true;
|
|
5558
|
-
const localName = specifier.local.name;
|
|
5559
|
-
const binding = path6.scope.getBinding(localName);
|
|
5560
|
-
if (binding && binding.path.node.type === "VariableDeclarator") {
|
|
5561
|
-
let init2 = binding.path.node.init;
|
|
5562
|
-
init2 = init2 ? resolveBindingValue(init2, binding.path.scope) : null;
|
|
5563
|
-
let objectExpression = null;
|
|
5564
|
-
if (init2 && t.isObjectExpression(init2)) {
|
|
5565
|
-
objectExpression = init2;
|
|
5566
|
-
} else if (init2 && t.isParenthesizedExpression(init2) && t.isObjectExpression(init2.expression)) {
|
|
5567
|
-
objectExpression = init2.expression;
|
|
5568
|
-
}
|
|
5569
|
-
if (objectExpression && validateObjectExpression(objectExpression)) {
|
|
5570
|
-
defaultExportValid = true;
|
|
5571
|
-
}
|
|
5572
|
-
}
|
|
5573
|
-
path6.stop();
|
|
5574
|
-
break;
|
|
5575
|
-
}
|
|
5576
|
-
}
|
|
5577
|
-
}
|
|
5578
|
-
}
|
|
5579
|
-
}
|
|
5580
|
-
});
|
|
5581
|
-
if (!defaultExportFound) {
|
|
5582
|
-
throw new Error(`Module ${modulePath} does not have a default export.`);
|
|
5583
|
-
}
|
|
5584
|
-
if (!defaultExportValid) {
|
|
5585
|
-
throw new Error(
|
|
5586
|
-
`Module ${modulePath} default export does not have a valid fetch() function.`
|
|
5587
|
-
);
|
|
5588
|
-
}
|
|
5589
|
-
}
|
|
5590
|
-
if (!isPathSafe(manifest.executors)) {
|
|
5591
|
-
throw new Error(
|
|
5592
|
-
`The file path is not safe: ${manifest.executors}. It must be contained inside the manifest folder. Invalid manifest`
|
|
5593
|
-
);
|
|
5594
|
-
}
|
|
5595
|
-
await validateModule(manifest.executors);
|
|
5596
|
-
if (manifest.configurators) {
|
|
5597
|
-
if (!isPathSafe(manifest.configurators)) {
|
|
5598
|
-
throw new Error(
|
|
5599
|
-
`The file path is not safe: ${manifest.configurators}. It must be contained inside the manifest folder. Invalid manifest`
|
|
5600
|
-
);
|
|
5601
|
-
}
|
|
5602
|
-
await validateModule(manifest.configurators);
|
|
5603
|
-
}
|
|
5604
|
-
}
|
|
5605
5455
|
async function sendPlugin(manifest, client, reqHeaders) {
|
|
5606
|
-
await validateEsmModules(manifest);
|
|
5607
5456
|
const lookup = {};
|
|
5608
5457
|
async function createFileRequest(filePath, imgOpts) {
|
|
5609
5458
|
if (!filePath || lookup[filePath]) {
|