unpeek 1.2.0 → 1.5.0
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/README.md +20 -9
- package/README.tr.md +20 -9
- package/assets/banner-dark.svg +22 -0
- package/assets/banner-light.svg +22 -0
- package/assets/banner.svg +39 -0
- package/dist/ast/index.cjs +79 -20
- package/dist/ast/index.cjs.map +1 -1
- package/dist/ast/index.js +79 -20
- package/dist/ast/index.js.map +1 -1
- package/dist/browser.cjs +79 -20
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.js +79 -20
- package/dist/browser.js.map +1 -1
- package/dist/bundler/unplugin.cjs +79 -20
- package/dist/bundler/unplugin.cjs.map +1 -1
- package/dist/bundler/unplugin.js +79 -20
- package/dist/bundler/unplugin.js.map +1 -1
- package/dist/cli/index.cjs +185 -63
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +185 -63
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/protect.cjs +79 -20
- package/dist/cli/protect.cjs.map +1 -1
- package/dist/cli/protect.js +79 -20
- package/dist/cli/protect.js.map +1 -1
- package/dist/esbuild.cjs +79 -20
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.js +79 -20
- package/dist/esbuild.js.map +1 -1
- package/dist/index.cjs +185 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +185 -63
- package/dist/index.js.map +1 -1
- package/dist/rollup.cjs +79 -20
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.js +79 -20
- package/dist/rollup.js.map +1 -1
- package/dist/runtime/index.cjs +3 -1
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/vite.cjs +79 -20
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +79 -20
- package/dist/vite.js.map +1 -1
- package/dist/webpack.cjs +79 -20
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.js +79 -20
- package/dist/webpack.js.map +1 -1
- package/package.json +2 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -453,6 +453,8 @@ function isPascalCaseComponent(name) {
|
|
|
453
453
|
function analyzeAstHotPaths(ast) {
|
|
454
454
|
const hotFunctionNodes = /* @__PURE__ */ new WeakSet();
|
|
455
455
|
const coldFunctionNodes = /* @__PURE__ */ new WeakSet();
|
|
456
|
+
const hotExemptNodes = /* @__PURE__ */ new WeakSet();
|
|
457
|
+
const directHotNodes = /* @__PURE__ */ new Set();
|
|
456
458
|
const allFunctions = [];
|
|
457
459
|
const fnByName = /* @__PURE__ */ new Map();
|
|
458
460
|
const callerToCallees = /* @__PURE__ */ new Map();
|
|
@@ -463,6 +465,7 @@ function analyzeAstHotPaths(ast) {
|
|
|
463
465
|
fnByName.set(name, node);
|
|
464
466
|
if (isPascalCaseComponent(name)) {
|
|
465
467
|
hotFunctionNodes.add(node);
|
|
468
|
+
directHotNodes.add(node);
|
|
466
469
|
}
|
|
467
470
|
},
|
|
468
471
|
FunctionExpression(node, _state, ancestors) {
|
|
@@ -471,6 +474,7 @@ function analyzeAstHotPaths(ast) {
|
|
|
471
474
|
fnByName.set(name, node);
|
|
472
475
|
if (isPascalCaseComponent(name)) {
|
|
473
476
|
hotFunctionNodes.add(node);
|
|
477
|
+
directHotNodes.add(node);
|
|
474
478
|
}
|
|
475
479
|
},
|
|
476
480
|
ArrowFunctionExpression(node, _state, ancestors) {
|
|
@@ -479,6 +483,7 @@ function analyzeAstHotPaths(ast) {
|
|
|
479
483
|
fnByName.set(name, node);
|
|
480
484
|
if (isPascalCaseComponent(name)) {
|
|
481
485
|
hotFunctionNodes.add(node);
|
|
486
|
+
directHotNodes.add(node);
|
|
482
487
|
}
|
|
483
488
|
},
|
|
484
489
|
CallExpression(node, _state, ancestors) {
|
|
@@ -505,6 +510,8 @@ function analyzeAstHotPaths(ast) {
|
|
|
505
510
|
for (const arg of node.arguments || []) {
|
|
506
511
|
if (FUNCTION_NODE_TYPES.has(arg.type)) {
|
|
507
512
|
hotFunctionNodes.add(arg);
|
|
513
|
+
directHotNodes.add(arg);
|
|
514
|
+
hotExemptNodes.add(arg);
|
|
508
515
|
}
|
|
509
516
|
}
|
|
510
517
|
}
|
|
@@ -512,27 +519,51 @@ function analyzeAstHotPaths(ast) {
|
|
|
512
519
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
513
520
|
if (FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
|
|
514
521
|
hotFunctionNodes.add(ancestors[i]);
|
|
522
|
+
directHotNodes.add(ancestors[i]);
|
|
515
523
|
break;
|
|
516
524
|
}
|
|
517
525
|
}
|
|
518
526
|
}
|
|
519
527
|
},
|
|
520
|
-
ForStatement(
|
|
521
|
-
|
|
528
|
+
ForStatement(node, _state, ancestors) {
|
|
529
|
+
hotExemptNodes.add(node);
|
|
530
|
+
markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
|
|
522
531
|
},
|
|
523
|
-
ForInStatement(
|
|
524
|
-
|
|
532
|
+
ForInStatement(node, _state, ancestors) {
|
|
533
|
+
hotExemptNodes.add(node);
|
|
534
|
+
markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
|
|
525
535
|
},
|
|
526
|
-
ForOfStatement(
|
|
527
|
-
|
|
536
|
+
ForOfStatement(node, _state, ancestors) {
|
|
537
|
+
hotExemptNodes.add(node);
|
|
538
|
+
markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
|
|
528
539
|
},
|
|
529
|
-
WhileStatement(
|
|
530
|
-
|
|
540
|
+
WhileStatement(node, _state, ancestors) {
|
|
541
|
+
hotExemptNodes.add(node);
|
|
542
|
+
markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
|
|
531
543
|
},
|
|
532
|
-
DoWhileStatement(
|
|
533
|
-
|
|
544
|
+
DoWhileStatement(node, _state, ancestors) {
|
|
545
|
+
hotExemptNodes.add(node);
|
|
546
|
+
markEnclosingFunctionHot(ancestors, hotFunctionNodes, directHotNodes);
|
|
534
547
|
}
|
|
535
548
|
});
|
|
549
|
+
const forwardHotSet = new Set(directHotNodes);
|
|
550
|
+
let forwardChanged = true;
|
|
551
|
+
while (forwardChanged) {
|
|
552
|
+
forwardChanged = false;
|
|
553
|
+
for (const callerNode of Array.from(forwardHotSet)) {
|
|
554
|
+
const calleeNames = callerToCallees.get(callerNode);
|
|
555
|
+
if (!calleeNames) continue;
|
|
556
|
+
for (const cName of calleeNames) {
|
|
557
|
+
const targetNode = fnByName.get(cName);
|
|
558
|
+
if (targetNode && !forwardHotSet.has(targetNode)) {
|
|
559
|
+
forwardHotSet.add(targetNode);
|
|
560
|
+
hotFunctionNodes.add(targetNode);
|
|
561
|
+
hotExemptNodes.add(targetNode);
|
|
562
|
+
forwardChanged = true;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
536
567
|
let changed = true;
|
|
537
568
|
while (changed) {
|
|
538
569
|
changed = false;
|
|
@@ -565,13 +596,17 @@ function analyzeAstHotPaths(ast) {
|
|
|
565
596
|
coldFunctionsProtected
|
|
566
597
|
},
|
|
567
598
|
hotFunctionNodes,
|
|
568
|
-
coldFunctionNodes
|
|
599
|
+
coldFunctionNodes,
|
|
600
|
+
hotExemptNodes
|
|
569
601
|
};
|
|
570
602
|
}
|
|
571
|
-
function markEnclosingFunctionHot(ancestors, hotSet) {
|
|
603
|
+
function markEnclosingFunctionHot(ancestors, hotSet, directHotSet) {
|
|
572
604
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
573
605
|
if (FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
|
|
574
606
|
hotSet.add(ancestors[i]);
|
|
607
|
+
if (directHotSet) {
|
|
608
|
+
directHotSet.add(ancestors[i]);
|
|
609
|
+
}
|
|
575
610
|
break;
|
|
576
611
|
}
|
|
577
612
|
}
|
|
@@ -590,7 +625,7 @@ var HELPER_TEMPLATE = acorn2.parse(
|
|
|
590
625
|
`const _ = [].map(function(a) {
|
|
591
626
|
var s = "";
|
|
592
627
|
for (var j = 0; j < a.length; j++) {
|
|
593
|
-
s += String.fromCharCode(a.charCodeAt(j) ^ (((0 ^ ((j & 1) * 0)) & 30) | 1));
|
|
628
|
+
s += String.fromCharCode(a.charCodeAt(j) ^ (((0 ^ (a._u | ((j & 1) * 0))) & 30) | 1));
|
|
594
629
|
}
|
|
595
630
|
return s;
|
|
596
631
|
});`,
|
|
@@ -611,8 +646,8 @@ function createVaultHelperAst(cacheVarName, encryptedPayloads, mask, step) {
|
|
|
611
646
|
const innerLeft = binaryXor.right.left.left;
|
|
612
647
|
innerLeft.left.value = mask;
|
|
613
648
|
innerLeft.left.raw = String(mask);
|
|
614
|
-
innerLeft.right.right.value = step;
|
|
615
|
-
innerLeft.right.right.raw = String(step);
|
|
649
|
+
innerLeft.right.right.right.value = step;
|
|
650
|
+
innerLeft.right.right.right.raw = String(step);
|
|
616
651
|
return node;
|
|
617
652
|
}
|
|
618
653
|
function computeFnv1aHash(input, seed = 2166136261) {
|
|
@@ -632,7 +667,7 @@ function encodeStringWithSeed(str, mask, step) {
|
|
|
632
667
|
}
|
|
633
668
|
return out;
|
|
634
669
|
}
|
|
635
|
-
function applyStringVault(ast, seed = 2654435769, minStringLength = 4) {
|
|
670
|
+
function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes) {
|
|
636
671
|
const suffix = ((seed >>> 0) % 255).toString(36);
|
|
637
672
|
const cacheVarName = `_uC${suffix}`;
|
|
638
673
|
const mask = seed >>> 0 & 30 | 3;
|
|
@@ -646,6 +681,13 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4) {
|
|
|
646
681
|
const val = node.value;
|
|
647
682
|
if (val.length < minStringLength) return;
|
|
648
683
|
if (DIRECTIVE_STRINGS.has(val)) return;
|
|
684
|
+
if (hotExemptNodes) {
|
|
685
|
+
for (let i = ancestors.length - 2; i >= 0; i--) {
|
|
686
|
+
if (hotExemptNodes.has(ancestors[i])) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
649
691
|
const parent = ancestors[ancestors.length - 2];
|
|
650
692
|
if (!parent) return;
|
|
651
693
|
if (parent.type === "ExpressionStatement" && parent.directive) return;
|
|
@@ -978,7 +1020,17 @@ function createOpaqueGuardStatement(seed, fnIndex) {
|
|
|
978
1020
|
type: "BinaryExpression",
|
|
979
1021
|
operator: "^",
|
|
980
1022
|
left: { type: "Literal", value: a, raw: String(a) },
|
|
981
|
-
right: {
|
|
1023
|
+
right: {
|
|
1024
|
+
type: "BinaryExpression",
|
|
1025
|
+
operator: "|",
|
|
1026
|
+
left: { type: "Literal", value: b, raw: String(b) },
|
|
1027
|
+
right: {
|
|
1028
|
+
type: "UnaryExpression",
|
|
1029
|
+
operator: "!",
|
|
1030
|
+
prefix: true,
|
|
1031
|
+
argument: { type: "Identifier", name: "String" }
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
982
1034
|
},
|
|
983
1035
|
right: { type: "Literal", value: 7, raw: "7" }
|
|
984
1036
|
},
|
|
@@ -1035,6 +1087,7 @@ function deriveLocalVar(label, seed) {
|
|
|
1035
1087
|
}
|
|
1036
1088
|
function createDeterrentSnippet(config) {
|
|
1037
1089
|
const seed = config.seed >>> 0;
|
|
1090
|
+
const expectedToken = (config.expectedIntegrityHash ?? seed) >>> 0;
|
|
1038
1091
|
const deterrentMode = config.deterrentMode ?? "passive";
|
|
1039
1092
|
const fnName = deriveIntegrityFnName(seed);
|
|
1040
1093
|
const strVar = deriveLocalVar("s", seed);
|
|
@@ -1043,9 +1096,10 @@ function createDeterrentSnippet(config) {
|
|
|
1043
1096
|
const methodsVar = deriveLocalVar("m", seed);
|
|
1044
1097
|
const idxVar = deriveLocalVar("i", seed);
|
|
1045
1098
|
const errVar = deriveLocalVar("e", seed);
|
|
1099
|
+
const tokenBit = expectedToken & 1;
|
|
1046
1100
|
const gradualConsoleSilence = deterrentMode === "gradual" ? `if(typeof console!=='undefined'){var ${noopVar}=function(){},${methodsVar}=['log','debug','info','table','dir'];for(var ${idxVar}=0;${idxVar}<${methodsVar}.length;${idxVar}++){try{console[${methodsVar}[${idxVar}]]=${noopVar};}catch(${errVar}){}}}` : "";
|
|
1047
1101
|
const tamperDispatch = `if(typeof window.dispatchEvent==='function'&&typeof CustomEvent==='function'){try{window.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(${errVar}){}}`;
|
|
1048
|
-
return `(function ${fnName}(){if(typeof window!=='undefined'){try{var ${strVar}=Function.prototype.toString,${tamperVar}=${strVar}.call(${strVar}).indexOf('[native code]')
|
|
1102
|
+
return `(function ${fnName}(){if(typeof window!=='undefined'){try{var ${strVar}=Function.prototype.toString,${tamperVar}=${strVar}.call(${strVar}).indexOf('[native code]')<${tokenBit - 1}||${strVar}.call(${fnName}).indexOf('\\n')!==-1||${strVar}.call(${fnName}).indexOf('\\r')!==-1;if(${tamperVar}){window.__unpeek_tampered=!0;String.prototype._u=14;${tamperDispatch}${gradualConsoleSilence}}}catch(${errVar}){}}})();`;
|
|
1049
1103
|
}
|
|
1050
1104
|
|
|
1051
1105
|
// src/runtime/index.ts
|
|
@@ -1091,13 +1145,18 @@ function transformJavaScript(code, options = {}) {
|
|
|
1091
1145
|
integrityToken: computeFnv1aHash(code, seed)
|
|
1092
1146
|
};
|
|
1093
1147
|
}
|
|
1094
|
-
const {
|
|
1148
|
+
const {
|
|
1149
|
+
report: hotPathReport,
|
|
1150
|
+
coldFunctionNodes,
|
|
1151
|
+
hotExemptNodes
|
|
1152
|
+
} = analyzeAstHotPaths(ast);
|
|
1095
1153
|
applyColdFlowGuard(ast, coldFunctionNodes, seed);
|
|
1096
1154
|
const mangledSymbolsCount = applyPolymorphicMangler(ast, seed);
|
|
1097
1155
|
const { encryptedStringsCount, integrityToken } = applyStringVault(
|
|
1098
1156
|
ast,
|
|
1099
1157
|
seed,
|
|
1100
|
-
minStringLength
|
|
1158
|
+
minStringLength,
|
|
1159
|
+
hotExemptNodes
|
|
1101
1160
|
);
|
|
1102
1161
|
const outputCode = (0, import_astring.generate)(ast, { indent: "", lineEnd: "" });
|
|
1103
1162
|
let finalCode = outputCode;
|
|
@@ -1224,7 +1283,7 @@ ${finalCode}`;
|
|
|
1224
1283
|
}
|
|
1225
1284
|
|
|
1226
1285
|
// src/cli/index.ts
|
|
1227
|
-
var VERSION = "1.
|
|
1286
|
+
var VERSION = "1.5.0";
|
|
1228
1287
|
function getPackageVersion() {
|
|
1229
1288
|
try {
|
|
1230
1289
|
const pkgUrl = new URL("../../package.json", importMetaUrl);
|
|
@@ -1236,25 +1295,52 @@ function getPackageVersion() {
|
|
|
1236
1295
|
}
|
|
1237
1296
|
}
|
|
1238
1297
|
var RUNTIME_VERSION = getPackageVersion();
|
|
1298
|
+
var MARK_TOP = " \u259B\u2580\u2580\u259C";
|
|
1299
|
+
var MARK_BOTTOM = " \u2599\u2584\u2584\u259F";
|
|
1300
|
+
var RULE = "\u2500";
|
|
1301
|
+
var LABEL_WIDTH = 19;
|
|
1302
|
+
function colorEnabled() {
|
|
1303
|
+
if (process.env.NO_COLOR) return false;
|
|
1304
|
+
if (process.env.TERM === "dumb") return false;
|
|
1305
|
+
return Boolean(process.stdout.isTTY);
|
|
1306
|
+
}
|
|
1307
|
+
function paint(code, text) {
|
|
1308
|
+
return colorEnabled() ? `\x1B[${code}m${text}\x1B[0m` : text;
|
|
1309
|
+
}
|
|
1310
|
+
function dim(text) {
|
|
1311
|
+
return paint("2", text);
|
|
1312
|
+
}
|
|
1313
|
+
function brandBlock() {
|
|
1314
|
+
return [
|
|
1315
|
+
`${MARK_TOP} ${paint("1", `unpeek ${RUNTIME_VERSION}`)}`,
|
|
1316
|
+
`${MARK_BOTTOM} ${dim("client bundle protection")}`
|
|
1317
|
+
].join("\n");
|
|
1318
|
+
}
|
|
1319
|
+
function sectionBlock(title, rows) {
|
|
1320
|
+
const fill = Math.max(2, 46 - title.length);
|
|
1321
|
+
const header = ` ${dim(title)} ${dim(RULE.repeat(fill))}`;
|
|
1322
|
+
const body = rows.map(([label, value]) => ` ${dim(label.padEnd(LABEL_WIDTH))} ${value}`);
|
|
1323
|
+
return [header, ...body].join("\n");
|
|
1324
|
+
}
|
|
1239
1325
|
function printHelp() {
|
|
1240
|
-
const helpText =
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
Usage:
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
Options:
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1326
|
+
const helpText = [
|
|
1327
|
+
brandBlock(),
|
|
1328
|
+
"",
|
|
1329
|
+
" Usage:",
|
|
1330
|
+
" unpeek init [--dry-run] wire postbuild and the .unpeek-maps/ vault",
|
|
1331
|
+
" unpeek protect [options] protect client bundles in place",
|
|
1332
|
+
"",
|
|
1333
|
+
" Options:",
|
|
1334
|
+
" --out-dir <dir> explicit client output directory",
|
|
1335
|
+
" --seed <number> deterministic polymorphic seed",
|
|
1336
|
+
" --passive passive deterrent mode instead of gradual",
|
|
1337
|
+
" --no-maps delete .map files instead of vaulting them",
|
|
1338
|
+
" --min-string-length <num> minimum string length for the vault (default: 4)",
|
|
1339
|
+
" --private-maps-dir <dir> vault directory (default: .unpeek-maps)",
|
|
1340
|
+
" --no-shield skip the runtime anti-tamper shield",
|
|
1341
|
+
" -h, --help show help",
|
|
1342
|
+
" -v, --version show version"
|
|
1343
|
+
].join("\n");
|
|
1258
1344
|
console.log(helpText);
|
|
1259
1345
|
}
|
|
1260
1346
|
function formatBytes(bytes) {
|
|
@@ -1263,30 +1349,66 @@ function formatBytes(bytes) {
|
|
|
1263
1349
|
}
|
|
1264
1350
|
function printSummaryTable(summary) {
|
|
1265
1351
|
const sign = summary.gzipDeltaPercent > 0 ? "+" : "";
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
]
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
console.log("
|
|
1285
|
-
console.log(
|
|
1286
|
-
|
|
1287
|
-
|
|
1352
|
+
const gzip = `${formatBytes(summary.originalGzipBytes)} -> ${formatBytes(summary.protectedGzipBytes)} ${sign}${summary.gzipDeltaPercent}%`;
|
|
1353
|
+
console.log("");
|
|
1354
|
+
console.log(brandBlock());
|
|
1355
|
+
console.log("");
|
|
1356
|
+
console.log(
|
|
1357
|
+
sectionBlock("PROJECT", [
|
|
1358
|
+
["framework", summary.framework],
|
|
1359
|
+
["output", summary.outDir],
|
|
1360
|
+
["bundles", String(summary.processedFiles)]
|
|
1361
|
+
])
|
|
1362
|
+
);
|
|
1363
|
+
console.log("");
|
|
1364
|
+
console.log(
|
|
1365
|
+
sectionBlock("CALL GRAPH", [
|
|
1366
|
+
["hot path exempt", `${summary.totalHotFunctionsSkipped} ${dim("0% tax")}`],
|
|
1367
|
+
["cold path protected", String(summary.totalColdFunctionsProtected)]
|
|
1368
|
+
])
|
|
1369
|
+
);
|
|
1370
|
+
console.log("");
|
|
1371
|
+
console.log(
|
|
1372
|
+
sectionBlock("TRANSFORM", [
|
|
1373
|
+
["string vault", `${summary.totalEncryptedStrings} literals ${dim("O(1) memo")}`],
|
|
1374
|
+
["symbol mangling", `${summary.totalMangledSymbols} bindings`]
|
|
1375
|
+
])
|
|
1376
|
+
);
|
|
1377
|
+
console.log("");
|
|
1378
|
+
console.log(
|
|
1379
|
+
sectionBlock("OUTPUT", [
|
|
1380
|
+
["source maps", `${summary.movedSourceMaps} moved -> .unpeek-maps/`],
|
|
1381
|
+
["gzip", gzip],
|
|
1382
|
+
["elapsed", `${summary.elapsedMs} ms`]
|
|
1383
|
+
])
|
|
1384
|
+
);
|
|
1385
|
+
console.log("");
|
|
1386
|
+
console.log(` ${dim("done. maps are private. hot path untouched.")}`);
|
|
1387
|
+
}
|
|
1388
|
+
function printInitResult(result, dryRun) {
|
|
1389
|
+
const postbuild = result.updatedPackageJson ? dryRun ? "would be added" : "unpeek protect (added)" : "already configured";
|
|
1390
|
+
const vault = result.updatedGitignore ? dryRun ? "would be ignored" : ".unpeek-maps/ (added)" : "already ignored";
|
|
1391
|
+
console.log("");
|
|
1392
|
+
console.log(brandBlock());
|
|
1393
|
+
console.log("");
|
|
1394
|
+
console.log(
|
|
1395
|
+
sectionBlock("PROJECT", [
|
|
1396
|
+
["framework", result.framework ?? "unknown"],
|
|
1397
|
+
["postbuild", postbuild],
|
|
1398
|
+
["vault", vault]
|
|
1399
|
+
])
|
|
1400
|
+
);
|
|
1401
|
+
console.log("");
|
|
1402
|
+
if (dryRun) {
|
|
1403
|
+
console.log(` ${dim(result.message)}`);
|
|
1404
|
+
} else if (result.updatedPackageJson || result.updatedGitignore) {
|
|
1405
|
+
console.log(` ${dim("postbuild wired. maps stay private from the first build.")}`);
|
|
1406
|
+
} else {
|
|
1407
|
+
console.log(` ${dim(result.message)}`);
|
|
1408
|
+
}
|
|
1409
|
+
if (!dryRun) {
|
|
1410
|
+
console.log(` ${dim("run your build to protect the first bundle.")}`);
|
|
1288
1411
|
}
|
|
1289
|
-
console.log(divider);
|
|
1290
1412
|
}
|
|
1291
1413
|
async function runCli(args) {
|
|
1292
1414
|
if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
@@ -1301,7 +1423,7 @@ async function runCli(args) {
|
|
|
1301
1423
|
if (command === "init") {
|
|
1302
1424
|
const dryRun = args.includes("--dry-run");
|
|
1303
1425
|
const res = initProject(process.cwd(), { dryRun });
|
|
1304
|
-
|
|
1426
|
+
printInitResult(res, dryRun);
|
|
1305
1427
|
return;
|
|
1306
1428
|
}
|
|
1307
1429
|
if (command === "protect" || args.length > 0 && args[0].startsWith("-")) {
|