@absolutejs/absolute 0.19.0-beta.1116 → 0.19.0-beta.1118
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/dist/cli/index.js
CHANGED
|
@@ -1158,6 +1158,356 @@ var init_devCert = __esm(() => {
|
|
|
1158
1158
|
KEY_PATH = join5(CERT_DIR, "key.pem");
|
|
1159
1159
|
});
|
|
1160
1160
|
|
|
1161
|
+
// src/cli/scripts/eslint.ts
|
|
1162
|
+
import { createHash } from "crypto";
|
|
1163
|
+
import {
|
|
1164
|
+
existsSync as existsSync6,
|
|
1165
|
+
mkdirSync as mkdirSync5,
|
|
1166
|
+
readFileSync as readFileSync8,
|
|
1167
|
+
renameSync,
|
|
1168
|
+
rmSync as rmSync3,
|
|
1169
|
+
writeFileSync as writeFileSync5
|
|
1170
|
+
} from "fs";
|
|
1171
|
+
import { dirname as dirname3, resolve as resolve4 } from "path";
|
|
1172
|
+
var DEFAULT_CACHE_LOCATION = ".absolutejs/eslint-cache", CACHE_CONTRACT_VERSION = "1", CACHE_FINGERPRINT_SUFFIX = ".fingerprint", flagValue = (args, flag) => {
|
|
1173
|
+
const assignment = args.find((arg) => arg.startsWith(`${flag}=`));
|
|
1174
|
+
if (assignment)
|
|
1175
|
+
return assignment.slice(flag.length + 1);
|
|
1176
|
+
const index = args.indexOf(flag);
|
|
1177
|
+
return index < 0 ? undefined : args[index + 1];
|
|
1178
|
+
}, getCacheLocation = (args) => flagValue(args, "--cache-location")?.trim() || process.env.ABSOLUTE_ESLINT_CACHE?.trim() || DEFAULT_CACHE_LOCATION, CONFIG_CANDIDATES, FLAG_VALUE_FLAGS, hasUserPositional = (args) => {
|
|
1179
|
+
for (let index = 0;index < args.length; index++) {
|
|
1180
|
+
const arg = args[index];
|
|
1181
|
+
if (arg === undefined)
|
|
1182
|
+
continue;
|
|
1183
|
+
if (arg.startsWith("-")) {
|
|
1184
|
+
if (arg.includes("="))
|
|
1185
|
+
continue;
|
|
1186
|
+
if (FLAG_VALUE_FLAGS.has(arg))
|
|
1187
|
+
index++;
|
|
1188
|
+
continue;
|
|
1189
|
+
}
|
|
1190
|
+
return true;
|
|
1191
|
+
}
|
|
1192
|
+
return false;
|
|
1193
|
+
}, findConfigPath = (cwd = process.cwd()) => {
|
|
1194
|
+
for (const name of CONFIG_CANDIDATES) {
|
|
1195
|
+
const candidate = resolve4(cwd, name);
|
|
1196
|
+
if (existsSync6(candidate))
|
|
1197
|
+
return candidate;
|
|
1198
|
+
}
|
|
1199
|
+
return null;
|
|
1200
|
+
}, fingerprintLocation = (cacheLocation, cwd) => {
|
|
1201
|
+
const absolute = resolve4(cwd, cacheLocation);
|
|
1202
|
+
return /[\\/]$/.test(cacheLocation) ? resolve4(absolute, CACHE_FINGERPRINT_SUFFIX.slice(1)) : `${absolute}${CACHE_FINGERPRINT_SUFFIX}`;
|
|
1203
|
+
}, addFileToFingerprint = (hash, path, label) => {
|
|
1204
|
+
if (!existsSync6(path))
|
|
1205
|
+
return;
|
|
1206
|
+
hash.update(label);
|
|
1207
|
+
hash.update("\x00");
|
|
1208
|
+
hash.update(readFileSync8(path));
|
|
1209
|
+
hash.update("\x00");
|
|
1210
|
+
}, packageNameFor = (specifier) => {
|
|
1211
|
+
if (specifier.startsWith("@"))
|
|
1212
|
+
return specifier.split("/").slice(0, 2).join("/");
|
|
1213
|
+
const [name = specifier] = specifier.split("/");
|
|
1214
|
+
return name;
|
|
1215
|
+
}, configPackageNames = (configPath2) => {
|
|
1216
|
+
if (!configPath2)
|
|
1217
|
+
return [];
|
|
1218
|
+
const source = readFileSync8(configPath2, "utf-8");
|
|
1219
|
+
const names = new Set;
|
|
1220
|
+
for (const match of source.matchAll(/(?:from\s+|import\s*(?:\(\s*)?|require\s*\(\s*)(['"])([^'".][^'"]*)\1/g)) {
|
|
1221
|
+
const [, , specifier] = match;
|
|
1222
|
+
if (specifier)
|
|
1223
|
+
names.add(packageNameFor(specifier));
|
|
1224
|
+
}
|
|
1225
|
+
return [...names];
|
|
1226
|
+
}, manifestDependencyNames = (manifest) => {
|
|
1227
|
+
if (manifest === null || typeof manifest !== "object")
|
|
1228
|
+
return [];
|
|
1229
|
+
return Object.entries(manifest).flatMap(([key, value]) => {
|
|
1230
|
+
if (key !== "dependencies" && key !== "devDependencies")
|
|
1231
|
+
return [];
|
|
1232
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
1233
|
+
return [];
|
|
1234
|
+
return Object.keys(value);
|
|
1235
|
+
});
|
|
1236
|
+
}, lintDependencyNames = (cwd, configPath2) => {
|
|
1237
|
+
const manifestPath = resolve4(cwd, "package.json");
|
|
1238
|
+
if (!existsSync6(manifestPath))
|
|
1239
|
+
return configPackageNames(configPath2);
|
|
1240
|
+
try {
|
|
1241
|
+
const manifest = JSON.parse(readFileSync8(manifestPath, "utf-8"));
|
|
1242
|
+
const lintPackages = manifestDependencyNames(manifest).filter((name) => /eslint|typescript/.test(name));
|
|
1243
|
+
return [
|
|
1244
|
+
...new Set([...lintPackages, ...configPackageNames(configPath2)])
|
|
1245
|
+
];
|
|
1246
|
+
} catch {
|
|
1247
|
+
return configPackageNames(configPath2);
|
|
1248
|
+
}
|
|
1249
|
+
}, findInstalledManifest = (cwd, dependency) => {
|
|
1250
|
+
let directory = cwd;
|
|
1251
|
+
while (true) {
|
|
1252
|
+
const candidate = resolve4(directory, "node_modules", dependency, "package.json");
|
|
1253
|
+
if (existsSync6(candidate))
|
|
1254
|
+
return candidate;
|
|
1255
|
+
const parent = dirname3(directory);
|
|
1256
|
+
if (parent === directory)
|
|
1257
|
+
return null;
|
|
1258
|
+
directory = parent;
|
|
1259
|
+
}
|
|
1260
|
+
}, createEslintCacheFingerprint = (cwd = process.cwd()) => {
|
|
1261
|
+
const hash = createHash("sha256");
|
|
1262
|
+
hash.update(`absolute-eslint-cache:${CACHE_CONTRACT_VERSION}\x00`);
|
|
1263
|
+
const configPath2 = findConfigPath(cwd);
|
|
1264
|
+
if (configPath2)
|
|
1265
|
+
addFileToFingerprint(hash, configPath2, configPath2);
|
|
1266
|
+
for (const dependency of lintDependencyNames(cwd, configPath2).sort()) {
|
|
1267
|
+
const manifestPath = findInstalledManifest(cwd, dependency);
|
|
1268
|
+
if (manifestPath)
|
|
1269
|
+
addFileToFingerprint(hash, manifestPath, dependency);
|
|
1270
|
+
}
|
|
1271
|
+
return hash.digest("hex");
|
|
1272
|
+
}, writeFingerprint = (path, fingerprint) => {
|
|
1273
|
+
mkdirSync5(dirname3(path), { recursive: true });
|
|
1274
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
1275
|
+
writeFileSync5(temporary, `${fingerprint}
|
|
1276
|
+
`);
|
|
1277
|
+
renameSync(temporary, path);
|
|
1278
|
+
}, prepareEslintCache = (options) => {
|
|
1279
|
+
const cwd = options.cwd ?? process.cwd();
|
|
1280
|
+
const cachePath = resolve4(cwd, options.cacheLocation);
|
|
1281
|
+
const metadataPath = fingerprintLocation(options.cacheLocation, cwd);
|
|
1282
|
+
const fingerprint = options.fingerprint ?? createEslintCacheFingerprint(cwd);
|
|
1283
|
+
const prior = existsSync6(metadataPath) ? readFileSync8(metadataPath, "utf-8").trim() : null;
|
|
1284
|
+
if (prior === fingerprint)
|
|
1285
|
+
return false;
|
|
1286
|
+
rmSync3(cachePath, { force: true, recursive: true });
|
|
1287
|
+
if (metadataPath !== cachePath)
|
|
1288
|
+
rmSync3(metadataPath, { force: true, recursive: true });
|
|
1289
|
+
writeFingerprint(metadataPath, fingerprint);
|
|
1290
|
+
return true;
|
|
1291
|
+
}, hasKey = (objectLiteralSource, key) => {
|
|
1292
|
+
const pattern = new RegExp(`(^|[\\s,{])${key}\\s*:`, "m");
|
|
1293
|
+
return pattern.test(objectLiteralSource);
|
|
1294
|
+
}, NON_GLOBAL_IGNORE_KEYS, isGlobalIgnoresBlock = (block) => {
|
|
1295
|
+
if (!hasKey(block, "ignores"))
|
|
1296
|
+
return false;
|
|
1297
|
+
return !NON_GLOBAL_IGNORE_KEYS.some((key) => hasKey(block, key));
|
|
1298
|
+
}, extractTopLevelObjectLiterals = (source) => {
|
|
1299
|
+
const arrayStart = source.search(/defineConfig\s*\(\s*\[|export\s+default\s*\[/);
|
|
1300
|
+
if (arrayStart === -1)
|
|
1301
|
+
return [];
|
|
1302
|
+
const fromArray = source.slice(arrayStart);
|
|
1303
|
+
const openBracket = fromArray.indexOf("[");
|
|
1304
|
+
if (openBracket === -1)
|
|
1305
|
+
return [];
|
|
1306
|
+
const blocks = [];
|
|
1307
|
+
let depth = 0;
|
|
1308
|
+
let blockStart = -1;
|
|
1309
|
+
let inString = null;
|
|
1310
|
+
let inLineComment = false;
|
|
1311
|
+
let inBlockComment = false;
|
|
1312
|
+
for (let i = openBracket;i < fromArray.length; i++) {
|
|
1313
|
+
const char = fromArray[i];
|
|
1314
|
+
const next = fromArray[i + 1];
|
|
1315
|
+
if (inLineComment) {
|
|
1316
|
+
if (char === `
|
|
1317
|
+
`)
|
|
1318
|
+
inLineComment = false;
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
if (inBlockComment) {
|
|
1322
|
+
if (char === "*" && next === "/") {
|
|
1323
|
+
inBlockComment = false;
|
|
1324
|
+
i++;
|
|
1325
|
+
}
|
|
1326
|
+
continue;
|
|
1327
|
+
}
|
|
1328
|
+
if (inString) {
|
|
1329
|
+
if (char === "\\") {
|
|
1330
|
+
i++;
|
|
1331
|
+
continue;
|
|
1332
|
+
}
|
|
1333
|
+
if (char === inString)
|
|
1334
|
+
inString = null;
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
if (char === "/" && next === "/") {
|
|
1338
|
+
inLineComment = true;
|
|
1339
|
+
continue;
|
|
1340
|
+
}
|
|
1341
|
+
if (char === "/" && next === "*") {
|
|
1342
|
+
inBlockComment = true;
|
|
1343
|
+
i++;
|
|
1344
|
+
continue;
|
|
1345
|
+
}
|
|
1346
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
1347
|
+
inString = char;
|
|
1348
|
+
continue;
|
|
1349
|
+
}
|
|
1350
|
+
if (char === "{") {
|
|
1351
|
+
if (depth === 0)
|
|
1352
|
+
blockStart = i;
|
|
1353
|
+
depth++;
|
|
1354
|
+
} else if (char === "}") {
|
|
1355
|
+
depth--;
|
|
1356
|
+
if (depth === 0 && blockStart !== -1) {
|
|
1357
|
+
blocks.push(fromArray.slice(blockStart, i + 1));
|
|
1358
|
+
blockStart = -1;
|
|
1359
|
+
}
|
|
1360
|
+
} else if (char === "]" && depth === 0) {
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
return blocks;
|
|
1365
|
+
}, checkForMisplacedIgnores = () => {
|
|
1366
|
+
const configPath2 = findConfigPath();
|
|
1367
|
+
if (!configPath2)
|
|
1368
|
+
return;
|
|
1369
|
+
let source;
|
|
1370
|
+
try {
|
|
1371
|
+
source = readFileSync8(configPath2, "utf-8");
|
|
1372
|
+
} catch {
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
const blocks = extractTopLevelObjectLiterals(source);
|
|
1376
|
+
if (blocks.some(isGlobalIgnoresBlock))
|
|
1377
|
+
return;
|
|
1378
|
+
let offenderCount = 0;
|
|
1379
|
+
for (const block of blocks) {
|
|
1380
|
+
if (hasKey(block, "ignores") && hasKey(block, "files")) {
|
|
1381
|
+
offenderCount++;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
if (offenderCount === 0)
|
|
1385
|
+
return;
|
|
1386
|
+
const yellow = "\x1B[33m";
|
|
1387
|
+
const reset = "\x1B[0m";
|
|
1388
|
+
const bold = "\x1B[1m";
|
|
1389
|
+
console.warn(`${yellow}${bold}\u26A0 ESLint flat-config warning${reset}${yellow}: found ${offenderCount} config block(s) where \`ignores\` lives alongside \`files\`. In ESLint v9, \`ignores\` is only a *global* ignore when it's the sole key in its config object \u2014 otherwise it just suppresses that block's own rules and ESLint still walks every other directory (including node_modules), making lint extremely slow.
|
|
1390
|
+
|
|
1391
|
+
Move ignores into a standalone block at the top of your config:
|
|
1392
|
+
|
|
1393
|
+
export default defineConfig([
|
|
1394
|
+
{ ignores: ['node_modules/**', 'dist/**', 'build/**', '.absolutejs/**'] },
|
|
1395
|
+
pluginJs.configs.recommended,
|
|
1396
|
+
...
|
|
1397
|
+
]);
|
|
1398
|
+
|
|
1399
|
+
Detected at: ${configPath2}${reset}`);
|
|
1400
|
+
}, formatDuration = (durationMs) => {
|
|
1401
|
+
if (durationMs < 1000)
|
|
1402
|
+
return `${durationMs}ms`;
|
|
1403
|
+
if (durationMs < 60000)
|
|
1404
|
+
return `${(durationMs / 1000).toFixed(2)}s`;
|
|
1405
|
+
const minutes = Math.floor(durationMs / 60000);
|
|
1406
|
+
const seconds = Math.round(durationMs % 60000 / 1000);
|
|
1407
|
+
return `${minutes}m ${seconds}s`;
|
|
1408
|
+
}, handleClearCache = (cacheLocation, cwd = process.cwd()) => {
|
|
1409
|
+
try {
|
|
1410
|
+
const cachePath = resolve4(cwd, cacheLocation);
|
|
1411
|
+
const metadataPath = fingerprintLocation(cacheLocation, cwd);
|
|
1412
|
+
rmSync3(cachePath, { force: true, recursive: true });
|
|
1413
|
+
rmSync3(metadataPath, { force: true, recursive: true });
|
|
1414
|
+
console.log(`\x1B[32m\u2713\x1B[0m Cleared cache: ${cacheLocation}`);
|
|
1415
|
+
} catch (err) {
|
|
1416
|
+
console.error(`\x1B[31m\u2717\x1B[0m Failed to clear cache at ${cacheLocation}:`, err);
|
|
1417
|
+
process.exit(1);
|
|
1418
|
+
}
|
|
1419
|
+
}, buildEslintCommand = (args, cacheLocation) => {
|
|
1420
|
+
const cacheEnabled = !args.includes("--no-cache");
|
|
1421
|
+
const hasCacheLocation = args.some((arg) => arg === "--cache-location" || arg.startsWith("--cache-location="));
|
|
1422
|
+
const hasCacheStrategy = args.some((arg) => arg === "--cache-strategy" || arg.startsWith("--cache-strategy="));
|
|
1423
|
+
return [
|
|
1424
|
+
"bun",
|
|
1425
|
+
"eslint",
|
|
1426
|
+
...cacheEnabled ? ["--cache"] : [],
|
|
1427
|
+
...cacheEnabled && !hasCacheLocation ? ["--cache-location", cacheLocation] : [],
|
|
1428
|
+
...cacheEnabled && !hasCacheStrategy ? ["--cache-strategy", "content"] : [],
|
|
1429
|
+
...args,
|
|
1430
|
+
...hasUserPositional(args) ? [] : ["."]
|
|
1431
|
+
];
|
|
1432
|
+
}, eslint = async (args) => {
|
|
1433
|
+
const cacheLocation = getCacheLocation(args);
|
|
1434
|
+
if (args.includes("--clear-cache")) {
|
|
1435
|
+
handleClearCache(cacheLocation);
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
if (!existsSync6(resolve4("node_modules", ".bin", "eslint"))) {
|
|
1439
|
+
console.error("\x1B[31m\u2717\x1B[0m ESLint is not installed in this project. Add it (and a flat `eslint.config.*`): bun add -d eslint");
|
|
1440
|
+
process.exit(1);
|
|
1441
|
+
}
|
|
1442
|
+
checkForMisplacedIgnores();
|
|
1443
|
+
const cacheEnabled = !args.includes("--no-cache");
|
|
1444
|
+
if (cacheEnabled)
|
|
1445
|
+
prepareEslintCache({ cacheLocation });
|
|
1446
|
+
const command = buildEslintCommand(args, cacheLocation);
|
|
1447
|
+
const dim = "\x1B[2m";
|
|
1448
|
+
const reset = "\x1B[0m";
|
|
1449
|
+
console.log(cacheEnabled ? `${dim}cache: ${cacheLocation} (content-aware; lint-tool changes invalidate automatically)${reset}` : `${dim}cache: disabled${reset}`);
|
|
1450
|
+
const startedAt = Date.now();
|
|
1451
|
+
const proc = Bun.spawn(command, {
|
|
1452
|
+
stderr: "inherit",
|
|
1453
|
+
stdout: "inherit"
|
|
1454
|
+
});
|
|
1455
|
+
const exitCode = await proc.exited;
|
|
1456
|
+
const elapsed = formatDuration(Date.now() - startedAt);
|
|
1457
|
+
if (exitCode !== 0) {
|
|
1458
|
+
console.log(`${dim}elapsed: ${elapsed}${reset}`);
|
|
1459
|
+
process.exit(exitCode);
|
|
1460
|
+
}
|
|
1461
|
+
console.log(`\x1B[32m\u2713\x1B[0m Passed ${dim}(${elapsed})${reset}`);
|
|
1462
|
+
};
|
|
1463
|
+
var init_eslint = __esm(() => {
|
|
1464
|
+
CONFIG_CANDIDATES = [
|
|
1465
|
+
"eslint.config.js",
|
|
1466
|
+
"eslint.config.mjs",
|
|
1467
|
+
"eslint.config.cjs",
|
|
1468
|
+
"eslint.config.ts",
|
|
1469
|
+
"eslint.config.mts",
|
|
1470
|
+
"eslint.config.cts"
|
|
1471
|
+
];
|
|
1472
|
+
FLAG_VALUE_FLAGS = new Set([
|
|
1473
|
+
"-c",
|
|
1474
|
+
"--config",
|
|
1475
|
+
"--cache-location",
|
|
1476
|
+
"--cache-strategy",
|
|
1477
|
+
"--ignore-path",
|
|
1478
|
+
"--ignore-pattern",
|
|
1479
|
+
"--rule",
|
|
1480
|
+
"--rulesdir",
|
|
1481
|
+
"--ext",
|
|
1482
|
+
"-f",
|
|
1483
|
+
"--format",
|
|
1484
|
+
"--max-warnings",
|
|
1485
|
+
"--parser",
|
|
1486
|
+
"--parser-options",
|
|
1487
|
+
"--plugin",
|
|
1488
|
+
"--global",
|
|
1489
|
+
"--env",
|
|
1490
|
+
"--report-unused-disable-directives-severity",
|
|
1491
|
+
"--resolve-plugins-relative-to",
|
|
1492
|
+
"-o",
|
|
1493
|
+
"--output-file",
|
|
1494
|
+
"--flag",
|
|
1495
|
+
"--inspect-config",
|
|
1496
|
+
"--stats",
|
|
1497
|
+
"--concurrency"
|
|
1498
|
+
]);
|
|
1499
|
+
NON_GLOBAL_IGNORE_KEYS = [
|
|
1500
|
+
"files",
|
|
1501
|
+
"rules",
|
|
1502
|
+
"plugins",
|
|
1503
|
+
"languageOptions",
|
|
1504
|
+
"linterOptions",
|
|
1505
|
+
"processor",
|
|
1506
|
+
"settings",
|
|
1507
|
+
"extends"
|
|
1508
|
+
];
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1161
1511
|
// src/utils/stripStringsAndComments.ts
|
|
1162
1512
|
var stripStringsAndComments = (source) => {
|
|
1163
1513
|
const { length } = source;
|
|
@@ -171289,10 +171639,198 @@ var init_build = __esm(() => {
|
|
|
171289
171639
|
FRAMEWORK_KEYS = ["react", "vue", "svelte", "angular", "html", "htmx"];
|
|
171290
171640
|
});
|
|
171291
171641
|
|
|
171642
|
+
// src/cli/scripts/lintProof.ts
|
|
171643
|
+
var exports_lintProof = {};
|
|
171644
|
+
__export(exports_lintProof, {
|
|
171645
|
+
writeLintProof: () => writeLintProof,
|
|
171646
|
+
verifyLintProof: () => verifyLintProof,
|
|
171647
|
+
runLintProof: () => runLintProof,
|
|
171648
|
+
createLintSourceTree: () => createLintSourceTree,
|
|
171649
|
+
createLintProof: () => createLintProof
|
|
171650
|
+
});
|
|
171651
|
+
import { createHash as createHash2 } from "crypto";
|
|
171652
|
+
import {
|
|
171653
|
+
existsSync as existsSync11,
|
|
171654
|
+
lstatSync,
|
|
171655
|
+
mkdirSync as mkdirSync8,
|
|
171656
|
+
mkdtempSync,
|
|
171657
|
+
readFileSync as readFileSync14,
|
|
171658
|
+
renameSync as renameSync2,
|
|
171659
|
+
rmSync as rmSync5,
|
|
171660
|
+
writeFileSync as writeFileSync7
|
|
171661
|
+
} from "fs";
|
|
171662
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
171663
|
+
import { delimiter, dirname as dirname5, relative as relative2, resolve as resolve11 } from "path";
|
|
171664
|
+
var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSION = 1, runGit = (args, options) => {
|
|
171665
|
+
const proc = Bun.spawnSync(["git", ...args], {
|
|
171666
|
+
cwd: options.cwd,
|
|
171667
|
+
env: { ...process.env, ...options.env },
|
|
171668
|
+
stderr: "pipe",
|
|
171669
|
+
stdout: "pipe"
|
|
171670
|
+
});
|
|
171671
|
+
if (proc.exitCode !== 0) {
|
|
171672
|
+
const detail = proc.stderr.toString().trim();
|
|
171673
|
+
throw new Error(detail || `git ${args.join(" ")} failed`);
|
|
171674
|
+
}
|
|
171675
|
+
return proc.stdout.toString().trim();
|
|
171676
|
+
}, gitRoot = (cwd) => resolve11(runGit(["rev-parse", "--show-toplevel"], { cwd })), createLintSourceTree = (cwd = process.cwd(), proofLocation = DEFAULT_PROOF_LOCATION) => {
|
|
171677
|
+
const root = gitRoot(cwd);
|
|
171678
|
+
const proofPath = resolve11(cwd, proofLocation);
|
|
171679
|
+
const proofRelative = relative2(root, proofPath).replaceAll("\\", "/");
|
|
171680
|
+
if (proofRelative === ".." || proofRelative.startsWith("../") || proofRelative === "") {
|
|
171681
|
+
throw new Error("lint proof must live inside the Git working tree");
|
|
171682
|
+
}
|
|
171683
|
+
const temporaryDirectory = mkdtempSync(resolve11(tmpdir2(), "absolute-lint-proof-"));
|
|
171684
|
+
const temporaryIndex = resolve11(temporaryDirectory, "index");
|
|
171685
|
+
const temporaryObjects = resolve11(temporaryDirectory, "objects");
|
|
171686
|
+
mkdirSync8(temporaryObjects, { recursive: true });
|
|
171687
|
+
const repositoryObjectsPath = runGit(["rev-parse", "--git-path", "objects"], { cwd: root });
|
|
171688
|
+
const repositoryObjects = resolve11(root, repositoryObjectsPath);
|
|
171689
|
+
const existingAlternates = process.env.GIT_ALTERNATE_OBJECT_DIRECTORIES?.trim();
|
|
171690
|
+
const env3 = {
|
|
171691
|
+
GIT_ALTERNATE_OBJECT_DIRECTORIES: [
|
|
171692
|
+
repositoryObjects,
|
|
171693
|
+
...existingAlternates ? [existingAlternates] : []
|
|
171694
|
+
].join(delimiter),
|
|
171695
|
+
GIT_INDEX_FILE: temporaryIndex,
|
|
171696
|
+
GIT_OBJECT_DIRECTORY: temporaryObjects
|
|
171697
|
+
};
|
|
171698
|
+
try {
|
|
171699
|
+
runGit(["read-tree", "--empty"], { cwd: root, env: env3 });
|
|
171700
|
+
const files = runGit(["ls-files", "--cached", "--others", "--exclude-standard", "-z"], { cwd: root }).split("\x00").filter((path) => {
|
|
171701
|
+
if (!path || path === proofRelative)
|
|
171702
|
+
return false;
|
|
171703
|
+
try {
|
|
171704
|
+
lstatSync(resolve11(root, path));
|
|
171705
|
+
return true;
|
|
171706
|
+
} catch {
|
|
171707
|
+
return false;
|
|
171708
|
+
}
|
|
171709
|
+
});
|
|
171710
|
+
for (let index = 0;index < files.length; index += 200) {
|
|
171711
|
+
runGit(["add", "-f", "--", ...files.slice(index, index + 200)], {
|
|
171712
|
+
cwd: root,
|
|
171713
|
+
env: env3
|
|
171714
|
+
});
|
|
171715
|
+
}
|
|
171716
|
+
return runGit(["write-tree"], { cwd: root, env: env3 });
|
|
171717
|
+
} finally {
|
|
171718
|
+
rmSync5(temporaryDirectory, { force: true, recursive: true });
|
|
171719
|
+
}
|
|
171720
|
+
}, proofFingerprint = (cwd) => createHash2("sha256").update(`absolute-lint-proof:${PROOF_CONTRACT_VERSION}\x00`).update(createEslintCacheFingerprint(cwd)).digest("hex"), createLintProof = (command, options = {}) => {
|
|
171721
|
+
const cwd = options.cwd ?? process.cwd();
|
|
171722
|
+
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
171723
|
+
return {
|
|
171724
|
+
command,
|
|
171725
|
+
contractVersion: PROOF_CONTRACT_VERSION,
|
|
171726
|
+
createdAt: new Date().toISOString(),
|
|
171727
|
+
lintFingerprint: proofFingerprint(cwd),
|
|
171728
|
+
sourceTree: createLintSourceTree(cwd, proofLocation)
|
|
171729
|
+
};
|
|
171730
|
+
}, writeLintProof = (command, options = {}) => {
|
|
171731
|
+
const cwd = options.cwd ?? process.cwd();
|
|
171732
|
+
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
171733
|
+
const path = resolve11(cwd, proofLocation);
|
|
171734
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
171735
|
+
const proof = createLintProof(command, { cwd, proofLocation });
|
|
171736
|
+
mkdirSync8(dirname5(path), { recursive: true });
|
|
171737
|
+
writeFileSync7(temporary, `${JSON.stringify(proof, null, 2)}
|
|
171738
|
+
`);
|
|
171739
|
+
renameSync2(temporary, path);
|
|
171740
|
+
return proof;
|
|
171741
|
+
}, isLintProof = (value) => {
|
|
171742
|
+
if (value === null || typeof value !== "object")
|
|
171743
|
+
return false;
|
|
171744
|
+
const proof = value;
|
|
171745
|
+
return proof.contractVersion === PROOF_CONTRACT_VERSION && Array.isArray(proof.command) && proof.command.every((part) => typeof part === "string") && typeof proof.createdAt === "string" && typeof proof.lintFingerprint === "string" && typeof proof.sourceTree === "string";
|
|
171746
|
+
}, verifyLintProof = (command, options = {}) => {
|
|
171747
|
+
const cwd = options.cwd ?? process.cwd();
|
|
171748
|
+
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
171749
|
+
const path = resolve11(cwd, proofLocation);
|
|
171750
|
+
if (!existsSync11(path))
|
|
171751
|
+
return { reason: `missing lint proof: ${proofLocation}`, valid: false };
|
|
171752
|
+
let proof;
|
|
171753
|
+
try {
|
|
171754
|
+
proof = JSON.parse(readFileSync14(path, "utf-8"));
|
|
171755
|
+
} catch {
|
|
171756
|
+
return { reason: `invalid lint proof: ${proofLocation}`, valid: false };
|
|
171757
|
+
}
|
|
171758
|
+
if (!isLintProof(proof))
|
|
171759
|
+
return { reason: "unsupported lint proof contract", valid: false };
|
|
171760
|
+
if (JSON.stringify(proof.command) !== JSON.stringify(command))
|
|
171761
|
+
return {
|
|
171762
|
+
reason: "lint command differs from the recorded command",
|
|
171763
|
+
valid: false
|
|
171764
|
+
};
|
|
171765
|
+
if (proof.lintFingerprint !== proofFingerprint(cwd))
|
|
171766
|
+
return {
|
|
171767
|
+
reason: "ESLint configuration or toolchain changed",
|
|
171768
|
+
valid: false
|
|
171769
|
+
};
|
|
171770
|
+
if (proof.sourceTree !== createLintSourceTree(cwd, proofLocation))
|
|
171771
|
+
return {
|
|
171772
|
+
reason: "source tree changed since lint passed",
|
|
171773
|
+
valid: false
|
|
171774
|
+
};
|
|
171775
|
+
return { proof, valid: true };
|
|
171776
|
+
}, parseArgs = (args) => {
|
|
171777
|
+
const separator = args.indexOf("--");
|
|
171778
|
+
const controlArgs = separator === -1 ? args : args.slice(0, separator);
|
|
171779
|
+
const command = separator === -1 ? [] : args.slice(separator + 1);
|
|
171780
|
+
const proofFlag = controlArgs.indexOf("--proof");
|
|
171781
|
+
const proofLocation = proofFlag === -1 ? DEFAULT_PROOF_LOCATION : controlArgs[proofFlag + 1];
|
|
171782
|
+
if (!proofLocation)
|
|
171783
|
+
throw new Error("--proof requires a path");
|
|
171784
|
+
return { command, proofLocation };
|
|
171785
|
+
}, runLintProof = async (args) => {
|
|
171786
|
+
const [operation] = args;
|
|
171787
|
+
if (operation !== "run" && operation !== "verify") {
|
|
171788
|
+
console.error("Usage: absolute lint-proof <run|verify> [--proof path] -- <lint command>");
|
|
171789
|
+
return 2;
|
|
171790
|
+
}
|
|
171791
|
+
let parsed;
|
|
171792
|
+
try {
|
|
171793
|
+
parsed = parseArgs(args.slice(1));
|
|
171794
|
+
} catch (error) {
|
|
171795
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
171796
|
+
return 2;
|
|
171797
|
+
}
|
|
171798
|
+
if (parsed.command.length === 0) {
|
|
171799
|
+
console.error("A lint command is required after --");
|
|
171800
|
+
return 2;
|
|
171801
|
+
}
|
|
171802
|
+
if (operation === "verify") {
|
|
171803
|
+
const result = verifyLintProof(parsed.command, {
|
|
171804
|
+
proofLocation: parsed.proofLocation
|
|
171805
|
+
});
|
|
171806
|
+
if (!result.valid) {
|
|
171807
|
+
console.error(`\x1B[31m\u2717\x1B[0m ${result.reason}`);
|
|
171808
|
+
return 1;
|
|
171809
|
+
}
|
|
171810
|
+
console.log(`\x1B[32m\u2713\x1B[0m Lint proof matches the source tree, command, and lint toolchain`);
|
|
171811
|
+
return 0;
|
|
171812
|
+
}
|
|
171813
|
+
const proc = Bun.spawn(parsed.command, {
|
|
171814
|
+
stderr: "inherit",
|
|
171815
|
+
stdout: "inherit"
|
|
171816
|
+
});
|
|
171817
|
+
const exitCode = await proc.exited;
|
|
171818
|
+
if (exitCode !== 0) {
|
|
171819
|
+
console.error("\x1B[31m\u2717\x1B[0m Lint failed; proof was not updated");
|
|
171820
|
+
return exitCode;
|
|
171821
|
+
}
|
|
171822
|
+
writeLintProof(parsed.command, { proofLocation: parsed.proofLocation });
|
|
171823
|
+
console.log(`\x1B[32m\u2713\x1B[0m Wrote exact-source lint proof: ${parsed.proofLocation}`);
|
|
171824
|
+
return 0;
|
|
171825
|
+
};
|
|
171826
|
+
var init_lintProof = __esm(() => {
|
|
171827
|
+
init_eslint();
|
|
171828
|
+
});
|
|
171829
|
+
|
|
171292
171830
|
// src/build/scanConventions.ts
|
|
171293
171831
|
import { basename as basename4 } from "path";
|
|
171294
171832
|
var {Glob: Glob2 } = globalThis.Bun;
|
|
171295
|
-
import { existsSync as
|
|
171833
|
+
import { existsSync as existsSync12 } from "fs";
|
|
171296
171834
|
var CONVENTION_RE, classifyFile = (file, pageFiles, defaults, pages) => {
|
|
171297
171835
|
const fileName = basename4(file);
|
|
171298
171836
|
const match = CONVENTION_RE.exec(fileName);
|
|
@@ -171317,7 +171855,7 @@ var CONVENTION_RE, classifyFile = (file, pageFiles, defaults, pages) => {
|
|
|
171317
171855
|
else if (kind === "loading")
|
|
171318
171856
|
pages[pageName].loading = file;
|
|
171319
171857
|
}, scanConventions = async (pagesDir, pattern) => {
|
|
171320
|
-
if (!
|
|
171858
|
+
if (!existsSync12(pagesDir)) {
|
|
171321
171859
|
const pageFiles2 = [];
|
|
171322
171860
|
return { conventions: undefined, pageFiles: pageFiles2 };
|
|
171323
171861
|
}
|
|
@@ -171352,8 +171890,8 @@ var exports_ls = {};
|
|
|
171352
171890
|
__export(exports_ls, {
|
|
171353
171891
|
runLs: () => runLs
|
|
171354
171892
|
});
|
|
171355
|
-
import { existsSync as
|
|
171356
|
-
import { basename as basename5, extname as extname2, join as join13, relative as
|
|
171893
|
+
import { existsSync as existsSync13, readFileSync as readFileSync15, statSync } from "fs";
|
|
171894
|
+
import { basename as basename5, extname as extname2, join as join13, relative as relative3 } from "path";
|
|
171357
171895
|
var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELDS, readStringField = (source, key) => {
|
|
171358
171896
|
const value = Reflect.get(source, key);
|
|
171359
171897
|
return typeof value === "string" ? value : undefined;
|
|
@@ -171368,7 +171906,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
171368
171906
|
} catch {
|
|
171369
171907
|
return null;
|
|
171370
171908
|
}
|
|
171371
|
-
}, relativeOrSelf = (target) =>
|
|
171909
|
+
}, relativeOrSelf = (target) => relative3(process.cwd(), target) || target, configCandidates = (raw) => isWorkspaceConfig(raw) ? Object.values(raw).map((service) => ({
|
|
171372
171910
|
baseDir: readStringField(service, "cwd") ?? ".",
|
|
171373
171911
|
source: service
|
|
171374
171912
|
})) : [{ baseDir: ".", source: raw }], specsFor = (source, baseDir) => FRAMEWORK_FIELDS.flatMap((framework) => {
|
|
@@ -171403,10 +171941,10 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
171403
171941
|
return pages ? [{ label, pages: sortPages(pages) }] : [];
|
|
171404
171942
|
});
|
|
171405
171943
|
}, resolveDiskPath = (buildDir, value) => {
|
|
171406
|
-
if (
|
|
171944
|
+
if (existsSync13(value))
|
|
171407
171945
|
return value;
|
|
171408
171946
|
const underBuild = join13(buildDir, value);
|
|
171409
|
-
if (
|
|
171947
|
+
if (existsSync13(underBuild))
|
|
171410
171948
|
return underBuild;
|
|
171411
171949
|
return join13(process.cwd(), value);
|
|
171412
171950
|
}, fileSize = (diskPath) => {
|
|
@@ -171416,7 +171954,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
171416
171954
|
return 0;
|
|
171417
171955
|
}
|
|
171418
171956
|
}, readManifestSizes = (manifestDir) => {
|
|
171419
|
-
const manifest = JSON.parse(
|
|
171957
|
+
const manifest = JSON.parse(readFileSync15(join13(manifestDir, "manifest.json"), "utf-8"));
|
|
171420
171958
|
const sizes = new Map;
|
|
171421
171959
|
Object.entries(manifest).forEach(([key, value]) => {
|
|
171422
171960
|
sizes.set(key, fileSize(resolveDiskPath(manifestDir, value)));
|
|
@@ -171534,7 +172072,7 @@ ${colors.dim}${frameworkCount} ${frameworkCount === 1 ? "framework" : "framework
|
|
|
171534
172072
|
}
|
|
171535
172073
|
const sizesDir = resolveSizesDir(args, candidates);
|
|
171536
172074
|
const manifestPath = join13(sizesDir, "manifest.json");
|
|
171537
|
-
if (!
|
|
172075
|
+
if (!existsSync13(manifestPath)) {
|
|
171538
172076
|
printDim(`No build at ${relativeOrSelf(manifestPath)}. Run \`absolute build\` first, or pass \`--outdir <dir>\`.`);
|
|
171539
172077
|
return;
|
|
171540
172078
|
}
|
|
@@ -171658,21 +172196,21 @@ var init_discoverInstances = __esm(() => {
|
|
|
171658
172196
|
import { createConnection as createConnection2 } from "net";
|
|
171659
172197
|
var {$: $4 } = globalThis.Bun;
|
|
171660
172198
|
var displayHost = (host) => host === "0.0.0.0" || host === "::" ? "localhost" : host, probePort = (host, port) => {
|
|
171661
|
-
const { promise, resolve:
|
|
172199
|
+
const { promise, resolve: resolve12 } = Promise.withResolvers();
|
|
171662
172200
|
const socket = createConnection2({ host: displayHost(host), port });
|
|
171663
172201
|
const timeout = setTimeout(() => {
|
|
171664
172202
|
socket.destroy();
|
|
171665
|
-
|
|
172203
|
+
resolve12(false);
|
|
171666
172204
|
}, INSTANCE_PROBE_TIMEOUT_MS);
|
|
171667
172205
|
socket.once("connect", () => {
|
|
171668
172206
|
clearTimeout(timeout);
|
|
171669
172207
|
socket.end();
|
|
171670
|
-
|
|
172208
|
+
resolve12(true);
|
|
171671
172209
|
});
|
|
171672
172210
|
socket.once("error", () => {
|
|
171673
172211
|
clearTimeout(timeout);
|
|
171674
172212
|
socket.destroy();
|
|
171675
|
-
|
|
172213
|
+
resolve12(false);
|
|
171676
172214
|
});
|
|
171677
172215
|
return promise;
|
|
171678
172216
|
}, probeStatus = async (record) => {
|
|
@@ -172384,9 +172922,9 @@ var exports_heapDiff = {};
|
|
|
172384
172922
|
__export(exports_heapDiff, {
|
|
172385
172923
|
runHeapDiff: () => runHeapDiff
|
|
172386
172924
|
});
|
|
172387
|
-
import { existsSync as
|
|
172925
|
+
import { existsSync as existsSync14, readFileSync as readFileSync16 } from "fs";
|
|
172388
172926
|
var TOP = 15, STRING_TYPES, aggregate = (path) => {
|
|
172389
|
-
const data = JSON.parse(
|
|
172927
|
+
const data = JSON.parse(readFileSync16(path, "utf-8"));
|
|
172390
172928
|
const { nodes, strings } = data;
|
|
172391
172929
|
const { node_fields: fields, node_types: nodeTypes } = data.snapshot.meta;
|
|
172392
172930
|
const [typeNames] = nodeTypes;
|
|
@@ -172415,7 +172953,7 @@ var TOP = 15, STRING_TYPES, aggregate = (path) => {
|
|
|
172415
172953
|
return;
|
|
172416
172954
|
}
|
|
172417
172955
|
for (const path of [beforePath, afterPath]) {
|
|
172418
|
-
if (
|
|
172956
|
+
if (existsSync14(path))
|
|
172419
172957
|
continue;
|
|
172420
172958
|
process.stdout.write(`${colors.red}No such file: ${path}${colors.reset}
|
|
172421
172959
|
`);
|
|
@@ -172535,16 +173073,16 @@ var isRecord3 = (value) => typeof value === "object" && value !== null && !Array
|
|
|
172535
173073
|
|
|
172536
173074
|
// src/cli/config/schema/fromType.ts
|
|
172537
173075
|
import {
|
|
172538
|
-
existsSync as
|
|
172539
|
-
mkdirSync as
|
|
172540
|
-
readFileSync as
|
|
173076
|
+
existsSync as existsSync15,
|
|
173077
|
+
mkdirSync as mkdirSync9,
|
|
173078
|
+
readFileSync as readFileSync17,
|
|
172541
173079
|
statSync as statSync2,
|
|
172542
|
-
writeFileSync as
|
|
173080
|
+
writeFileSync as writeFileSync8
|
|
172543
173081
|
} from "fs";
|
|
172544
|
-
import { resolve as
|
|
173082
|
+
import { resolve as resolve12 } from "path";
|
|
172545
173083
|
var import_typescript3, VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFrameworkRepo = (cwd) => {
|
|
172546
173084
|
try {
|
|
172547
|
-
const pkg = JSON.parse(
|
|
173085
|
+
const pkg = JSON.parse(readFileSync17(resolve12(cwd, "package.json"), "utf-8"));
|
|
172548
173086
|
return pkg?.name === "@absolutejs/absolute";
|
|
172549
173087
|
} catch {
|
|
172550
173088
|
return false;
|
|
@@ -172565,14 +173103,14 @@ var import_typescript3, VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DE
|
|
|
172565
173103
|
};
|
|
172566
173104
|
}, SCHEMA_VERSION = 1, packageVersion = (cwd, specifier) => {
|
|
172567
173105
|
const candidates = specifier === "@absolutejs/absolute" ? [
|
|
172568
|
-
|
|
172569
|
-
|
|
173106
|
+
resolve12(cwd, "node_modules", "@absolutejs", "absolute", "package.json"),
|
|
173107
|
+
resolve12(cwd, "package.json")
|
|
172570
173108
|
] : [
|
|
172571
|
-
|
|
173109
|
+
resolve12(cwd, "node_modules", ...specifier.split("/"), "package.json")
|
|
172572
173110
|
];
|
|
172573
173111
|
for (const candidate of candidates) {
|
|
172574
173112
|
try {
|
|
172575
|
-
const { version: version2 } = JSON.parse(
|
|
173113
|
+
const { version: version2 } = JSON.parse(readFileSync17(candidate, "utf-8"));
|
|
172576
173114
|
if (typeof version2 === "string")
|
|
172577
173115
|
return version2;
|
|
172578
173116
|
} catch {}
|
|
@@ -172583,16 +173121,16 @@ var import_typescript3, VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DE
|
|
|
172583
173121
|
if (local) {
|
|
172584
173122
|
const file = typeName === "PackageJson" ? "packageJson.ts" : "build.ts";
|
|
172585
173123
|
try {
|
|
172586
|
-
signature += `:${statSync2(
|
|
173124
|
+
signature += `:${statSync2(resolve12(cwd, "types", file)).mtimeMs}`;
|
|
172587
173125
|
} catch {}
|
|
172588
173126
|
}
|
|
172589
173127
|
return signature;
|
|
172590
173128
|
}, cacheSlug = (specifier) => specifier.replace("@", "").split("/").join("-"), cacheFile = (cwd, typeName, specifier) => {
|
|
172591
173129
|
const name = specifier === "@absolutejs/absolute" ? typeName : `${typeName}.${cacheSlug(specifier)}`;
|
|
172592
|
-
return
|
|
173130
|
+
return resolve12(cwd, ".absolutejs", "config-schema", `${name}.json`);
|
|
172593
173131
|
}, readDiskCache = (cwd, typeName, signature, specifier) => {
|
|
172594
173132
|
try {
|
|
172595
|
-
const cached = JSON.parse(
|
|
173133
|
+
const cached = JSON.parse(readFileSync17(cacheFile(cwd, typeName, specifier), "utf-8"));
|
|
172596
173134
|
if (isRecord3(cached) && cached.signature === signature && Array.isArray(cached.fields)) {
|
|
172597
173135
|
return cached.fields;
|
|
172598
173136
|
}
|
|
@@ -172600,10 +173138,10 @@ var import_typescript3, VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DE
|
|
|
172600
173138
|
return null;
|
|
172601
173139
|
}, writeDiskCache = (cwd, typeName, signature, fields, specifier) => {
|
|
172602
173140
|
try {
|
|
172603
|
-
|
|
173141
|
+
mkdirSync9(resolve12(cwd, ".absolutejs", "config-schema"), {
|
|
172604
173142
|
recursive: true
|
|
172605
173143
|
});
|
|
172606
|
-
|
|
173144
|
+
writeFileSync8(cacheFile(cwd, typeName, specifier), JSON.stringify({ fields, signature }));
|
|
172607
173145
|
} catch {}
|
|
172608
173146
|
}, docOf = (symbol, checker) => import_typescript3.default.displayPartsToString(symbol.getDocumentationComment(checker)).trim(), typeOfSymbol = (symbol, checker) => {
|
|
172609
173147
|
const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
@@ -172687,7 +173225,7 @@ var import_typescript3, VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DE
|
|
|
172687
173225
|
}
|
|
172688
173226
|
return opaque();
|
|
172689
173227
|
}, introspectFrom = (cwd, specifier, typeName, options, exclude) => {
|
|
172690
|
-
const virtualPath =
|
|
173228
|
+
const virtualPath = resolve12(cwd, VIRTUAL_NAME);
|
|
172691
173229
|
const source = `import type { ${typeName} } from '${specifier}';
|
|
172692
173230
|
declare const value: ${typeName};
|
|
172693
173231
|
export { value };
|
|
@@ -172730,7 +173268,7 @@ export { value };
|
|
|
172730
173268
|
const cached = cache.get(cacheKey);
|
|
172731
173269
|
if (cached)
|
|
172732
173270
|
return cached;
|
|
172733
|
-
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) &&
|
|
173271
|
+
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) && existsSync15(resolve12(cwd, "types/index.ts"));
|
|
172734
173272
|
const signature = cacheSignature(cwd, typeName, local, specifier);
|
|
172735
173273
|
const fromDisk = readDiskCache(cwd, typeName, signature, specifier);
|
|
172736
173274
|
if (fromDisk) {
|
|
@@ -172758,16 +173296,16 @@ var init_fromType = __esm(() => {
|
|
|
172758
173296
|
});
|
|
172759
173297
|
|
|
172760
173298
|
// src/cli/config/absolute/resolveAbsoluteConfig.ts
|
|
172761
|
-
import { existsSync as
|
|
172762
|
-
import { resolve as
|
|
173299
|
+
import { existsSync as existsSync16, readFileSync as readFileSync18 } from "fs";
|
|
173300
|
+
import { resolve as resolve13 } from "path";
|
|
172763
173301
|
var import_typescript4, CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath2 = (cwd, override) => {
|
|
172764
173302
|
if (override) {
|
|
172765
|
-
const resolved =
|
|
172766
|
-
return
|
|
173303
|
+
const resolved = resolve13(cwd, override);
|
|
173304
|
+
return existsSync16(resolved) ? resolved : null;
|
|
172767
173305
|
}
|
|
172768
173306
|
for (const name of CONFIG_CANDIDATES2) {
|
|
172769
|
-
const candidate =
|
|
172770
|
-
if (
|
|
173307
|
+
const candidate = resolve13(cwd, name);
|
|
173308
|
+
if (existsSync16(candidate))
|
|
172771
173309
|
return candidate;
|
|
172772
173310
|
}
|
|
172773
173311
|
return null;
|
|
@@ -172788,7 +173326,7 @@ var import_typescript4, CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath2 = (c
|
|
|
172788
173326
|
}
|
|
172789
173327
|
return null;
|
|
172790
173328
|
}, parseConfigObject = (configPath2) => {
|
|
172791
|
-
const text =
|
|
173329
|
+
const text = readFileSync18(configPath2, "utf-8");
|
|
172792
173330
|
return { object: findConfigObject(parseSource(configPath2, text)), text };
|
|
172793
173331
|
}, evalLiteral = (node) => {
|
|
172794
173332
|
if (import_typescript4.default.isStringLiteralLike(node)) {
|
|
@@ -173000,8 +173538,8 @@ var init_frameworks = __esm(() => {
|
|
|
173000
173538
|
});
|
|
173001
173539
|
|
|
173002
173540
|
// src/cli/generate/context.ts
|
|
173003
|
-
import { dirname as
|
|
173004
|
-
var asString = (value) => typeof value === "string" ? value : undefined, isRecord4 = (value) => typeof value === "object" && value !== null, resolveDir = (cwd, value) => isAbsolute(value) ? value :
|
|
173541
|
+
import { dirname as dirname6, isAbsolute, join as join14, relative as relative4, resolve as resolve14 } from "path";
|
|
173542
|
+
var asString = (value) => typeof value === "string" ? value : undefined, isRecord4 = (value) => typeof value === "object" && value !== null, resolveDir = (cwd, value) => isAbsolute(value) ? value : resolve14(cwd, value), resolveStylesDir = (cwd, config) => {
|
|
173005
173543
|
const styles = config.stylesConfig;
|
|
173006
173544
|
if (typeof styles === "string")
|
|
173007
173545
|
return resolveDir(cwd, styles);
|
|
@@ -173010,10 +173548,10 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
173010
173548
|
if (indexes)
|
|
173011
173549
|
return resolveDir(cwd, indexes);
|
|
173012
173550
|
}
|
|
173013
|
-
return
|
|
173551
|
+
return resolve14(cwd, "src/frontend/styles/indexes");
|
|
173014
173552
|
}, configuredFrameworks = (project) => FRAMEWORK_KEYS2.filter((key) => project.frameworkDirs[key] !== undefined), frontendRootFor = (project, framework) => {
|
|
173015
173553
|
const dir = project.frameworkDirs[framework];
|
|
173016
|
-
return dir ?
|
|
173554
|
+
return dir ? dirname6(dir) : resolve14(project.cwd, "src/frontend");
|
|
173017
173555
|
}, resolveProject = async (cwd, configOverride) => {
|
|
173018
173556
|
const loaded = await loadConfig(configOverride);
|
|
173019
173557
|
const config = isRecord4(loaded) ? loaded : {};
|
|
@@ -173064,7 +173602,7 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
173064
173602
|
ok: false
|
|
173065
173603
|
};
|
|
173066
173604
|
}, sharedDirFor = (project, framework) => join14(frontendRootFor(project, framework), "shared"), toModuleSpecifier = (fromDir, toFileNoExt) => {
|
|
173067
|
-
const rel =
|
|
173605
|
+
const rel = relative4(fromDir, toFileNoExt).split("\\").join("/");
|
|
173068
173606
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
173069
173607
|
};
|
|
173070
173608
|
var init_context = __esm(() => {
|
|
@@ -173091,8 +173629,8 @@ var emptyOutcome = () => ({
|
|
|
173091
173629
|
});
|
|
173092
173630
|
|
|
173093
173631
|
// src/cli/generate/routeWiring.ts
|
|
173094
|
-
import { existsSync as
|
|
173095
|
-
import { dirname as
|
|
173632
|
+
import { existsSync as existsSync17, readFileSync as readFileSync19, readdirSync as readdirSync4, writeFileSync as writeFileSync9 } from "fs";
|
|
173633
|
+
import { dirname as dirname7, join as join15 } from "path";
|
|
173096
173634
|
var import_typescript5, DEFAULT_SEPARATOR = `
|
|
173097
173635
|
`, BOUNDARY_USE, applyEdits = (text, edits) => {
|
|
173098
173636
|
const ordered = [...edits].sort((first, second) => second.start - first.start);
|
|
@@ -173240,13 +173778,13 @@ ${newLines.join(`
|
|
|
173240
173778
|
return lines.join(`
|
|
173241
173779
|
`);
|
|
173242
173780
|
}, hasChain = (path) => {
|
|
173243
|
-
if (!
|
|
173781
|
+
if (!existsSync17(path))
|
|
173244
173782
|
return false;
|
|
173245
|
-
const sourceFile = parse2(path,
|
|
173783
|
+
const sourceFile = parse2(path, readFileSync19(path, "utf-8"));
|
|
173246
173784
|
const found = findElysiaNew(sourceFile);
|
|
173247
173785
|
return found !== null;
|
|
173248
173786
|
}, firstChainFile = (pluginsDir) => {
|
|
173249
|
-
if (!
|
|
173787
|
+
if (!existsSync17(pluginsDir))
|
|
173250
173788
|
return null;
|
|
173251
173789
|
for (const name of readdirSync4(pluginsDir)) {
|
|
173252
173790
|
if (!name.endsWith(".ts"))
|
|
@@ -173257,7 +173795,7 @@ ${newLines.join(`
|
|
|
173257
173795
|
}
|
|
173258
173796
|
return null;
|
|
173259
173797
|
}, findRoutingFile = (serverEntry) => {
|
|
173260
|
-
const pluginsDir = join15(
|
|
173798
|
+
const pluginsDir = join15(dirname7(serverEntry), "plugins");
|
|
173261
173799
|
const preferred = join15(pluginsDir, "pagesPlugin.ts");
|
|
173262
173800
|
if (hasChain(preferred))
|
|
173263
173801
|
return preferred;
|
|
@@ -173268,7 +173806,7 @@ ${newLines.join(`
|
|
|
173268
173806
|
return serverEntry;
|
|
173269
173807
|
return null;
|
|
173270
173808
|
}, buildRouteContext = (input, routingFile) => {
|
|
173271
|
-
const specifier = `${toModuleSpecifier(
|
|
173809
|
+
const specifier = `${toModuleSpecifier(dirname7(routingFile), stripExtension(input.pageFileAbs))}${input.def.pageImportExtension ?? ""}`;
|
|
173272
173810
|
return {
|
|
173273
173811
|
cssAssetKey: input.cssAssetKey,
|
|
173274
173812
|
indexKey: input.indexKey,
|
|
@@ -173291,7 +173829,7 @@ ${newLines.join(`
|
|
|
173291
173829
|
};
|
|
173292
173830
|
if (!hasChain(serverEntry))
|
|
173293
173831
|
return fallback;
|
|
173294
|
-
const text =
|
|
173832
|
+
const text = readFileSync19(serverEntry, "utf-8");
|
|
173295
173833
|
const sourceFile = parse2(serverEntry, text);
|
|
173296
173834
|
const newExpr = findElysiaNew(sourceFile);
|
|
173297
173835
|
if (!newExpr)
|
|
@@ -173304,7 +173842,7 @@ ${newLines.join(`
|
|
|
173304
173842
|
start: offset,
|
|
173305
173843
|
text: `${separator}.use(${pluginName})`
|
|
173306
173844
|
});
|
|
173307
|
-
|
|
173845
|
+
writeFileSync9(serverEntry, applyEdits(text, edits), "utf-8");
|
|
173308
173846
|
return { kind: "edited", routingFile: serverEntry };
|
|
173309
173847
|
}, wireRoute = (input) => {
|
|
173310
173848
|
const routingFile = findRoutingFile(input.serverEntry);
|
|
@@ -173320,7 +173858,7 @@ ${newLines.join(`
|
|
|
173320
173858
|
${routeExpr}`
|
|
173321
173859
|
};
|
|
173322
173860
|
}
|
|
173323
|
-
const text =
|
|
173861
|
+
const text = readFileSync19(routingFile, "utf-8");
|
|
173324
173862
|
const sourceFile = parse2(routingFile, text);
|
|
173325
173863
|
const newExpr = findElysiaNew(sourceFile);
|
|
173326
173864
|
if (!newExpr) {
|
|
@@ -173340,7 +173878,7 @@ ${routeExpr}`
|
|
|
173340
173878
|
start: offset,
|
|
173341
173879
|
text: `${separator}${routeExpr}`
|
|
173342
173880
|
});
|
|
173343
|
-
|
|
173881
|
+
writeFileSync9(routingFile, applyEdits(text, edits), "utf-8");
|
|
173344
173882
|
return { kind: "edited", routingFile };
|
|
173345
173883
|
};
|
|
173346
173884
|
var init_routeWiring = __esm(() => {
|
|
@@ -173350,8 +173888,8 @@ var init_routeWiring = __esm(() => {
|
|
|
173350
173888
|
});
|
|
173351
173889
|
|
|
173352
173890
|
// src/cli/generate/generateApi.ts
|
|
173353
|
-
import { existsSync as
|
|
173354
|
-
import { dirname as
|
|
173891
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
173892
|
+
import { dirname as dirname8, join as join16 } from "path";
|
|
173355
173893
|
var apiPluginTemplate = (pluginName, base) => `import { Elysia } from 'elysia';
|
|
173356
173894
|
|
|
173357
173895
|
export const ${pluginName} = new Elysia()
|
|
@@ -173363,16 +173901,16 @@ export const ${pluginName} = new Elysia()
|
|
|
173363
173901
|
const pluginName = `${camel}Plugin`;
|
|
173364
173902
|
const base = `/api/${kebab}`;
|
|
173365
173903
|
const outcome = { ...emptyOutcome(), route: base };
|
|
173366
|
-
const pluginsDir = join16(
|
|
173904
|
+
const pluginsDir = join16(dirname8(project.serverEntry), "plugins");
|
|
173367
173905
|
const fileAbs = join16(pluginsDir, `${pluginName}.ts`);
|
|
173368
|
-
if (
|
|
173906
|
+
if (existsSync18(fileAbs)) {
|
|
173369
173907
|
outcome.notes.push(`${pluginName} already exists at ${fileAbs} \u2014 skipped.`);
|
|
173370
173908
|
return outcome;
|
|
173371
173909
|
}
|
|
173372
|
-
|
|
173373
|
-
|
|
173910
|
+
mkdirSync10(pluginsDir, { recursive: true });
|
|
173911
|
+
writeFileSync10(fileAbs, apiPluginTemplate(pluginName, base), "utf-8");
|
|
173374
173912
|
outcome.created.push(fileAbs);
|
|
173375
|
-
const specifier = toModuleSpecifier(
|
|
173913
|
+
const specifier = toModuleSpecifier(dirname8(project.serverEntry), fileAbs.replace(/\.ts$/, ""));
|
|
173376
173914
|
const wired = wirePluginUse(project.serverEntry, pluginName, specifier);
|
|
173377
173915
|
if (wired.kind === "edited")
|
|
173378
173916
|
outcome.updated.push(wired.routingFile);
|
|
@@ -173438,8 +173976,8 @@ var init_componentTemplates = __esm(() => {
|
|
|
173438
173976
|
});
|
|
173439
173977
|
|
|
173440
173978
|
// src/cli/generate/generateComponent.ts
|
|
173441
|
-
import { existsSync as
|
|
173442
|
-
import { dirname as
|
|
173979
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
|
|
173980
|
+
import { dirname as dirname9, join as join17 } from "path";
|
|
173443
173981
|
var generateComponent = (project, framework, rawName) => {
|
|
173444
173982
|
const def = frameworks2[framework];
|
|
173445
173983
|
const pascal = toPascalCase(rawName);
|
|
@@ -173451,12 +173989,12 @@ var generateComponent = (project, framework, rawName) => {
|
|
|
173451
173989
|
return outcome;
|
|
173452
173990
|
}
|
|
173453
173991
|
const fileAbs = join17(frameworkDir, "components", def.componentFile({ kebab, pascal }));
|
|
173454
|
-
if (
|
|
173992
|
+
if (existsSync19(fileAbs)) {
|
|
173455
173993
|
outcome.notes.push(`${pascal} already exists at ${fileAbs} \u2014 skipped.`);
|
|
173456
173994
|
return outcome;
|
|
173457
173995
|
}
|
|
173458
|
-
|
|
173459
|
-
|
|
173996
|
+
mkdirSync11(dirname9(fileAbs), { recursive: true });
|
|
173997
|
+
writeFileSync11(fileAbs, componentTemplates[framework]({
|
|
173460
173998
|
kebab,
|
|
173461
173999
|
pascal,
|
|
173462
174000
|
title: toTitleCase(rawName)
|
|
@@ -173470,7 +174008,7 @@ var init_generateComponent = __esm(() => {
|
|
|
173470
174008
|
});
|
|
173471
174009
|
|
|
173472
174010
|
// src/cli/generate/cssStrategy.ts
|
|
173473
|
-
import { existsSync as
|
|
174011
|
+
import { existsSync as existsSync20 } from "fs";
|
|
173474
174012
|
import { join as join18 } from "path";
|
|
173475
174013
|
var import_typescript6, CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
173476
174014
|
margin: 0 auto;
|
|
@@ -173518,7 +174056,7 @@ var import_typescript6, CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `
|
|
|
173518
174056
|
return {
|
|
173519
174057
|
assetKey: sharedKey,
|
|
173520
174058
|
contents: DEFAULT_CSS,
|
|
173521
|
-
create: !
|
|
174059
|
+
create: !existsSync20(cssFileAbs2),
|
|
173522
174060
|
cssFileAbs: cssFileAbs2,
|
|
173523
174061
|
shared: true
|
|
173524
174062
|
};
|
|
@@ -173527,7 +174065,7 @@ var import_typescript6, CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `
|
|
|
173527
174065
|
return {
|
|
173528
174066
|
assetKey: `${pascal}${CSS_SUFFIX}`,
|
|
173529
174067
|
contents: DEFAULT_CSS,
|
|
173530
|
-
create: !
|
|
174068
|
+
create: !existsSync20(cssFileAbs),
|
|
173531
174069
|
cssFileAbs,
|
|
173532
174070
|
shared: false
|
|
173533
174071
|
};
|
|
@@ -173537,8 +174075,8 @@ var init_cssStrategy = __esm(() => {
|
|
|
173537
174075
|
});
|
|
173538
174076
|
|
|
173539
174077
|
// src/cli/generate/navData.ts
|
|
173540
|
-
import { existsSync as
|
|
173541
|
-
import { dirname as
|
|
174078
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync12, readFileSync as readFileSync20, writeFileSync as writeFileSync12 } from "fs";
|
|
174079
|
+
import { dirname as dirname10 } from "path";
|
|
173542
174080
|
var import_typescript7, NAV_DATA_TEMPLATE = `type NavItem = {
|
|
173543
174081
|
href: string;
|
|
173544
174082
|
label: string;
|
|
@@ -173576,9 +174114,9 @@ export const navData: NavItem[] = [];
|
|
|
173576
174114
|
}
|
|
173577
174115
|
return items;
|
|
173578
174116
|
}, readNavItems = (navDataPath) => {
|
|
173579
|
-
if (!
|
|
174117
|
+
if (!existsSync21(navDataPath))
|
|
173580
174118
|
return [];
|
|
173581
|
-
const text =
|
|
174119
|
+
const text = readFileSync20(navDataPath, "utf-8");
|
|
173582
174120
|
const sourceFile = import_typescript7.default.createSourceFile(navDataPath, text, import_typescript7.default.ScriptTarget.Latest, true);
|
|
173583
174121
|
const array = findNavArray(sourceFile);
|
|
173584
174122
|
return array ? parseNavItems(array) : [];
|
|
@@ -173613,22 +174151,22 @@ ${indentOf(text, array.getStart(sourceFile))}`;
|
|
|
173613
174151
|
${indent}${entry}`;
|
|
173614
174152
|
return text.slice(0, insertAt) + insertion + text.slice(insertAt);
|
|
173615
174153
|
}, upsertNavItem = (navDataPath, item) => {
|
|
173616
|
-
const created = !
|
|
174154
|
+
const created = !existsSync21(navDataPath);
|
|
173617
174155
|
if (created) {
|
|
173618
|
-
|
|
173619
|
-
|
|
174156
|
+
mkdirSync12(dirname10(navDataPath), { recursive: true });
|
|
174157
|
+
writeFileSync12(navDataPath, NAV_DATA_TEMPLATE, "utf-8");
|
|
173620
174158
|
}
|
|
173621
174159
|
const existing = readNavItems(navDataPath);
|
|
173622
174160
|
if (existing.some((candidate) => candidate.href === item.href)) {
|
|
173623
174161
|
return { changed: created, created, items: existing };
|
|
173624
174162
|
}
|
|
173625
|
-
const text =
|
|
174163
|
+
const text = readFileSync20(navDataPath, "utf-8");
|
|
173626
174164
|
const sourceFile = import_typescript7.default.createSourceFile(navDataPath, text, import_typescript7.default.ScriptTarget.Latest, true);
|
|
173627
174165
|
const array = findNavArray(sourceFile);
|
|
173628
174166
|
if (!array)
|
|
173629
174167
|
return { changed: created, created, items: existing };
|
|
173630
174168
|
const entry = `{ href: '${item.href}', label: '${item.label}' }`;
|
|
173631
|
-
|
|
174169
|
+
writeFileSync12(navDataPath, insertElement(text, array, sourceFile, entry), "utf-8");
|
|
173632
174170
|
return { changed: true, created, items: [...existing, item] };
|
|
173633
174171
|
};
|
|
173634
174172
|
var init_navData = __esm(() => {
|
|
@@ -173781,25 +174319,25 @@ var init_pageTemplates = __esm(() => {
|
|
|
173781
174319
|
|
|
173782
174320
|
// src/cli/generate/generatePage.ts
|
|
173783
174321
|
import {
|
|
173784
|
-
existsSync as
|
|
173785
|
-
mkdirSync as
|
|
173786
|
-
readFileSync as
|
|
174322
|
+
existsSync as existsSync22,
|
|
174323
|
+
mkdirSync as mkdirSync13,
|
|
174324
|
+
readFileSync as readFileSync21,
|
|
173787
174325
|
readdirSync as readdirSync5,
|
|
173788
|
-
writeFileSync as
|
|
174326
|
+
writeFileSync as writeFileSync13
|
|
173789
174327
|
} from "fs";
|
|
173790
|
-
import { dirname as
|
|
174328
|
+
import { dirname as dirname11, join as join19, relative as relative5 } from "path";
|
|
173791
174329
|
var writeNew = (path, contents) => {
|
|
173792
|
-
|
|
173793
|
-
|
|
174330
|
+
mkdirSync13(dirname11(path), { recursive: true });
|
|
174331
|
+
writeFileSync13(path, contents, "utf-8");
|
|
173794
174332
|
}, toHref = (fromDir, toFile) => {
|
|
173795
|
-
const rel =
|
|
174333
|
+
const rel = relative5(fromDir, toFile).split("\\").join("/");
|
|
173796
174334
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
173797
|
-
}, staticPageFiles = (project) => ["html", "htmx"].map((key) => project.frameworkDirs[key]).map((dir) => dir ? join19(dir, "pages") : null).filter((pagesDir) => pagesDir !== null &&
|
|
173798
|
-
const html =
|
|
174335
|
+
}, staticPageFiles = (project) => ["html", "htmx"].map((key) => project.frameworkDirs[key]).map((dir) => dir ? join19(dir, "pages") : null).filter((pagesDir) => pagesDir !== null && existsSync22(pagesDir)).flatMap((pagesDir) => readdirSync5(pagesDir).filter((name) => name.endsWith(".html")).map((name) => join19(pagesDir, name))), resyncPage = (file, items) => {
|
|
174336
|
+
const html = readFileSync21(file, "utf-8");
|
|
173799
174337
|
const synced = syncStaticNav(html, items);
|
|
173800
174338
|
if (synced === null || synced === html)
|
|
173801
174339
|
return false;
|
|
173802
|
-
|
|
174340
|
+
writeFileSync13(file, synced, "utf-8");
|
|
173803
174341
|
return true;
|
|
173804
174342
|
}, resyncStaticPages = (project, items, skipFile) => {
|
|
173805
174343
|
const updated = [];
|
|
@@ -173823,18 +174361,18 @@ var writeNew = (path, contents) => {
|
|
|
173823
174361
|
return outcome;
|
|
173824
174362
|
}
|
|
173825
174363
|
const pageFileAbs = join19(frameworkDir, "pages", def.pageFile({ kebab, pascal }));
|
|
173826
|
-
if (
|
|
174364
|
+
if (existsSync22(pageFileAbs)) {
|
|
173827
174365
|
outcome.notes.push(`${pascal} already exists at ${pageFileAbs} \u2014 skipped.`);
|
|
173828
174366
|
return outcome;
|
|
173829
174367
|
}
|
|
173830
174368
|
const routingFile = findRoutingFile(project.serverEntry);
|
|
173831
|
-
const routingText = routingFile ?
|
|
174369
|
+
const routingText = routingFile ? readFileSync21(routingFile, "utf-8") : "";
|
|
173832
174370
|
const css = planCss(routingText, project.stylesDir, pascal, kebab);
|
|
173833
174371
|
const navDataPath = join19(sharedDirFor(project, framework), "navData.ts");
|
|
173834
174372
|
const nav = upsertNavItem(navDataPath, { href: route, label: title });
|
|
173835
|
-
const navImportPath = toModuleSpecifier(
|
|
174373
|
+
const navImportPath = toModuleSpecifier(dirname11(pageFileAbs), navDataPath.replace(/\.ts$/, ""));
|
|
173836
174374
|
writeNew(pageFileAbs, pageTemplates[framework]({
|
|
173837
|
-
cssHref: toHref(
|
|
174375
|
+
cssHref: toHref(dirname11(pageFileAbs), css.cssFileAbs),
|
|
173838
174376
|
kebab,
|
|
173839
174377
|
navImportPath,
|
|
173840
174378
|
navItems: nav.items,
|
|
@@ -173884,7 +174422,7 @@ var exports_generate = {};
|
|
|
173884
174422
|
__export(exports_generate, {
|
|
173885
174423
|
runGenerate: () => runGenerate
|
|
173886
174424
|
});
|
|
173887
|
-
import { relative as
|
|
174425
|
+
import { relative as relative6 } from "path";
|
|
173888
174426
|
var SUBCOMMANDS, write = (text) => process.stdout.write(`${text}
|
|
173889
174427
|
`), fail = (message) => {
|
|
173890
174428
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
@@ -173916,7 +174454,7 @@ var SUBCOMMANDS, write = (text) => process.stdout.write(`${text}
|
|
|
173916
174454
|
return;
|
|
173917
174455
|
write(` ${colors.dim}${label}${colors.reset}`);
|
|
173918
174456
|
for (const path of paths)
|
|
173919
|
-
write(` ${
|
|
174457
|
+
write(` ${relative6(cwd, path)}`);
|
|
173920
174458
|
}, printSummary = (title, outcome, cwd) => {
|
|
173921
174459
|
for (const note of outcome.notes) {
|
|
173922
174460
|
write(`${colors.yellow}!${colors.reset} ${note}`);
|
|
@@ -174016,7 +174554,7 @@ ${indent.repeat(level)}}`;
|
|
|
174016
174554
|
var init_serialize = () => {};
|
|
174017
174555
|
|
|
174018
174556
|
// src/cli/config/absolute/editAbsoluteConfig.ts
|
|
174019
|
-
import { readFileSync as
|
|
174557
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "fs";
|
|
174020
174558
|
var import_typescript8, lineStartOffset = (text, position) => {
|
|
174021
174559
|
let index = position;
|
|
174022
174560
|
while (index > 0 && text[index - 1] !== `
|
|
@@ -174025,7 +174563,7 @@ var import_typescript8, lineStartOffset = (text, position) => {
|
|
|
174025
174563
|
return index;
|
|
174026
174564
|
}, indentBefore2 = (text, position) => text.slice(lineStartOffset(text, position), position), findProperty = (object, name) => object.properties.find((property) => import_typescript8.default.isPropertyAssignment(property) && (import_typescript8.default.isIdentifier(property.name) || import_typescript8.default.isStringLiteral(property.name)) && property.name.text === name), applyAbsoluteConfigEdit = (configPath2, request) => {
|
|
174027
174565
|
try {
|
|
174028
|
-
const text =
|
|
174566
|
+
const text = readFileSync22(configPath2, "utf-8");
|
|
174029
174567
|
const sourceFile = import_typescript8.default.createSourceFile(configPath2, text, import_typescript8.default.ScriptTarget.Latest, true);
|
|
174030
174568
|
const object = findConfigObject(sourceFile);
|
|
174031
174569
|
if (!object) {
|
|
@@ -174045,14 +174583,14 @@ var import_typescript8, lineStartOffset = (text, position) => {
|
|
|
174045
174583
|
if (text[end] === `
|
|
174046
174584
|
`)
|
|
174047
174585
|
end += 1;
|
|
174048
|
-
|
|
174586
|
+
writeFileSync14(configPath2, text.slice(0, start2) + text.slice(end), "utf-8");
|
|
174049
174587
|
return { message: `Removed ${request.name}`, ok: true };
|
|
174050
174588
|
}
|
|
174051
174589
|
const valueText = serializeValue(request.value);
|
|
174052
174590
|
if (existing) {
|
|
174053
174591
|
const start2 = existing.initializer.getStart(sourceFile);
|
|
174054
174592
|
const end = existing.initializer.getEnd();
|
|
174055
|
-
|
|
174593
|
+
writeFileSync14(configPath2, text.slice(0, start2) + valueText + text.slice(end), "utf-8");
|
|
174056
174594
|
return { message: `Updated ${request.name}`, ok: true };
|
|
174057
174595
|
}
|
|
174058
174596
|
const { properties } = object;
|
|
@@ -174072,14 +174610,14 @@ var import_typescript8, lineStartOffset = (text, position) => {
|
|
|
174072
174610
|
insertionIndex += 1;
|
|
174073
174611
|
const insertion = `${hasComma ? "" : ","}
|
|
174074
174612
|
${indent}${entry}`;
|
|
174075
|
-
|
|
174613
|
+
writeFileSync14(configPath2, text.slice(0, insertionIndex) + insertion + text.slice(insertionIndex), "utf-8");
|
|
174076
174614
|
} else {
|
|
174077
174615
|
const insertionIndex = object.getStart(sourceFile) + 1;
|
|
174078
174616
|
const indent = `${indentBefore2(text, object.getStart(sourceFile))} `;
|
|
174079
174617
|
const insertion = `
|
|
174080
174618
|
${indent}${entry}
|
|
174081
174619
|
${indentBefore2(text, object.getStart(sourceFile))}`;
|
|
174082
|
-
|
|
174620
|
+
writeFileSync14(configPath2, text.slice(0, insertionIndex) + insertion + text.slice(insertionIndex), "utf-8");
|
|
174083
174621
|
}
|
|
174084
174622
|
return { message: `Updated ${request.name}`, ok: true };
|
|
174085
174623
|
} catch (error) {
|
|
@@ -174209,14 +174747,14 @@ var init_catalog = __esm(() => {
|
|
|
174209
174747
|
});
|
|
174210
174748
|
|
|
174211
174749
|
// src/cli/integrations/addPlugin.ts
|
|
174212
|
-
import { existsSync as
|
|
174750
|
+
import { existsSync as existsSync23, readFileSync as readFileSync23 } from "fs";
|
|
174213
174751
|
import { join as join20 } from "path";
|
|
174214
174752
|
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), readPackageJson = (cwd) => {
|
|
174215
174753
|
const path = join20(cwd, "package.json");
|
|
174216
|
-
if (!
|
|
174754
|
+
if (!existsSync23(path))
|
|
174217
174755
|
return null;
|
|
174218
174756
|
try {
|
|
174219
|
-
const parsed = JSON.parse(
|
|
174757
|
+
const parsed = JSON.parse(readFileSync23(path, "utf-8"));
|
|
174220
174758
|
return isRecord5(parsed) ? parsed : null;
|
|
174221
174759
|
} catch {
|
|
174222
174760
|
return null;
|
|
@@ -174707,16 +175245,16 @@ var init_authCatalog = __esm(() => {
|
|
|
174707
175245
|
});
|
|
174708
175246
|
|
|
174709
175247
|
// src/cli/config/auth/resolveAuthSettings.ts
|
|
174710
|
-
import { existsSync as
|
|
174711
|
-
import { resolve as
|
|
175248
|
+
import { existsSync as existsSync24, readFileSync as readFileSync24 } from "fs";
|
|
175249
|
+
import { resolve as resolve15 } from "path";
|
|
174712
175250
|
var import_typescript9, AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath = (cwd, override) => {
|
|
174713
175251
|
if (override) {
|
|
174714
|
-
const resolved =
|
|
174715
|
-
return
|
|
175252
|
+
const resolved = resolve15(cwd, override);
|
|
175253
|
+
return existsSync24(resolved) ? resolved : null;
|
|
174716
175254
|
}
|
|
174717
175255
|
for (const name of CONFIG_CANDIDATES3) {
|
|
174718
|
-
const candidate =
|
|
174719
|
-
if (
|
|
175256
|
+
const candidate = resolve15(cwd, name);
|
|
175257
|
+
if (existsSync24(candidate))
|
|
174720
175258
|
return candidate;
|
|
174721
175259
|
}
|
|
174722
175260
|
return null;
|
|
@@ -174737,7 +175275,7 @@ var import_typescript9, AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, f
|
|
|
174737
175275
|
}
|
|
174738
175276
|
return null;
|
|
174739
175277
|
}, parseAuthSettingsObject = (configPath2) => {
|
|
174740
|
-
const text =
|
|
175278
|
+
const text = readFileSync24(configPath2, "utf-8");
|
|
174741
175279
|
return {
|
|
174742
175280
|
object: findAuthSettingsObject(parseSource2(configPath2, text)),
|
|
174743
175281
|
text
|
|
@@ -174812,13 +175350,13 @@ var init_resolveAuthSettings = __esm(() => {
|
|
|
174812
175350
|
});
|
|
174813
175351
|
|
|
174814
175352
|
// src/cli/config/auth/resolveAuthState.ts
|
|
174815
|
-
import { existsSync as
|
|
174816
|
-
import { join as join21, relative as
|
|
175353
|
+
import { existsSync as existsSync25, readdirSync as readdirSync6, readFileSync as readFileSync25 } from "fs";
|
|
175354
|
+
import { join as join21, relative as relative7, resolve as resolve16 } from "path";
|
|
174817
175355
|
var import_typescript10, AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutejs/absolute-auth", NPM_URL = "https://www.npmjs.com/package/@absolutejs/auth", SKIP_DIRS, MAX_FILES = 4000, SETUP_EXPORTS, isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), readJson = (path) => {
|
|
174818
|
-
if (!
|
|
175356
|
+
if (!existsSync25(path))
|
|
174819
175357
|
return null;
|
|
174820
175358
|
try {
|
|
174821
|
-
const parsed = JSON.parse(
|
|
175359
|
+
const parsed = JSON.parse(readFileSync25(path, "utf-8"));
|
|
174822
175360
|
return isRecord6(parsed) ? parsed : null;
|
|
174823
175361
|
} catch {
|
|
174824
175362
|
return null;
|
|
@@ -174911,7 +175449,7 @@ var import_typescript10, AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https:/
|
|
|
174911
175449
|
return { keys: new Set, providerCount: null, usesSpread: true };
|
|
174912
175450
|
}, readFileOrNull = (path) => {
|
|
174913
175451
|
try {
|
|
174914
|
-
return
|
|
175452
|
+
return readFileSync25(path, "utf-8");
|
|
174915
175453
|
} catch {
|
|
174916
175454
|
return null;
|
|
174917
175455
|
}
|
|
@@ -174944,7 +175482,7 @@ var import_typescript10, AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https:/
|
|
|
174944
175482
|
scaffoldable: isScaffoldableFeature(feature.id)
|
|
174945
175483
|
})), resolveAuthState = (cwd) => {
|
|
174946
175484
|
const installedVersion = installedVersionFor(cwd);
|
|
174947
|
-
const root =
|
|
175485
|
+
const root = existsSync25(join21(cwd, "src")) ? join21(cwd, "src") : cwd;
|
|
174948
175486
|
let match = null;
|
|
174949
175487
|
let setupPath = null;
|
|
174950
175488
|
for (const file of candidateFiles(root)) {
|
|
@@ -174952,7 +175490,7 @@ var import_typescript10, AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https:/
|
|
|
174952
175490
|
if (found === null)
|
|
174953
175491
|
continue;
|
|
174954
175492
|
match = found;
|
|
174955
|
-
setupPath =
|
|
175493
|
+
setupPath = relative7(cwd, resolve16(file));
|
|
174956
175494
|
break;
|
|
174957
175495
|
}
|
|
174958
175496
|
const keys = match?.keys ?? new Set;
|
|
@@ -174990,8 +175528,8 @@ var init_resolveAuthState = __esm(() => {
|
|
|
174990
175528
|
});
|
|
174991
175529
|
|
|
174992
175530
|
// src/cli/config/auth/scaffoldAuthFeature.ts
|
|
174993
|
-
import { existsSync as
|
|
174994
|
-
import { dirname as
|
|
175531
|
+
import { existsSync as existsSync26, writeFileSync as writeFileSync15 } from "fs";
|
|
175532
|
+
import { dirname as dirname12, join as join22, relative as relative8, resolve as resolve17 } from "path";
|
|
174995
175533
|
var renderScaffold = (scaffold) => {
|
|
174996
175534
|
const importNames = [...scaffold.imports, `type ${scaffold.typeName}`];
|
|
174997
175535
|
const importLine = `import { ${importNames.join(", ")} } from '@absolutejs/auth';`;
|
|
@@ -175016,9 +175554,9 @@ ${body}
|
|
|
175016
175554
|
}, targetDir = (cwd) => {
|
|
175017
175555
|
const { setupPath } = resolveAuthState(cwd);
|
|
175018
175556
|
if (setupPath)
|
|
175019
|
-
return
|
|
175557
|
+
return dirname12(resolve17(cwd, setupPath));
|
|
175020
175558
|
const src = join22(cwd, "src");
|
|
175021
|
-
return
|
|
175559
|
+
return existsSync26(src) ? src : cwd;
|
|
175022
175560
|
}, spreadFor = (scaffold) => `import { ${scaffold.exportName} } from './${scaffold.exportName}';
|
|
175023
175561
|
// add to your auth() call:
|
|
175024
175562
|
${scaffold.configKey}: ${scaffold.exportName}`, failure2 = (message) => ({
|
|
@@ -175032,8 +175570,8 @@ ${scaffold.configKey}: ${scaffold.exportName}`, failure2 = (message) => ({
|
|
|
175032
175570
|
if (!scaffold)
|
|
175033
175571
|
return failure2(`Unknown auth feature "${id}".`);
|
|
175034
175572
|
const filePath = join22(targetDir(cwd), `${scaffold.exportName}.ts`);
|
|
175035
|
-
const relPath =
|
|
175036
|
-
if (
|
|
175573
|
+
const relPath = relative8(cwd, filePath);
|
|
175574
|
+
if (existsSync26(filePath)) {
|
|
175037
175575
|
return {
|
|
175038
175576
|
created: null,
|
|
175039
175577
|
installed: false,
|
|
@@ -175044,7 +175582,7 @@ ${scaffold.configKey}: ${scaffold.exportName}`, failure2 = (message) => ({
|
|
|
175044
175582
|
}
|
|
175045
175583
|
const install = options.install ?? true;
|
|
175046
175584
|
const installOk = install && scaffold.packages.length > 0 ? installPackages(cwd, scaffold.packages) : true;
|
|
175047
|
-
|
|
175585
|
+
writeFileSync15(filePath, renderScaffold(scaffold));
|
|
175048
175586
|
return {
|
|
175049
175587
|
created: relPath,
|
|
175050
175588
|
installed: installOk,
|
|
@@ -175060,13 +175598,13 @@ var init_scaffoldAuthFeature = __esm(() => {
|
|
|
175060
175598
|
});
|
|
175061
175599
|
|
|
175062
175600
|
// src/cli/htmx/install.ts
|
|
175063
|
-
import { existsSync as
|
|
175601
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync14, readFileSync as readFileSync26, writeFileSync as writeFileSync16 } from "fs";
|
|
175064
175602
|
import { join as join23 } from "path";
|
|
175065
175603
|
var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
175066
175604
|
join23(import.meta.dir, "htmx.min.js"),
|
|
175067
175605
|
join23(import.meta.dir, "htmx", "htmx.min.js"),
|
|
175068
175606
|
join23(import.meta.dir, "..", "htmx", "htmx.min.js")
|
|
175069
|
-
].find((path) =>
|
|
175607
|
+
].find((path) => existsSync27(path)) ?? null, detectHtmxVersion = (content) => {
|
|
175070
175608
|
const match = content.match(/version:"([0-9.]+)"/);
|
|
175071
175609
|
return match ? match[1] : null;
|
|
175072
175610
|
}, fetchHtmx = async (version2) => {
|
|
@@ -175078,16 +175616,16 @@ var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
|
175078
175616
|
return response.text();
|
|
175079
175617
|
}, installedHtmxVersion = (htmxDir) => {
|
|
175080
175618
|
const file = join23(htmxDir, "htmx.min.js");
|
|
175081
|
-
if (!
|
|
175619
|
+
if (!existsSync27(file))
|
|
175082
175620
|
return null;
|
|
175083
|
-
return detectHtmxVersion(
|
|
175621
|
+
return detectHtmxVersion(readFileSync26(file, "utf-8"));
|
|
175084
175622
|
}, readVendoredHtmx = () => {
|
|
175085
175623
|
const file = vendoredHtmxFile();
|
|
175086
|
-
return file ?
|
|
175624
|
+
return file ? readFileSync26(file, "utf-8") : null;
|
|
175087
175625
|
}, writeHtmx = (htmxDir, content) => {
|
|
175088
|
-
|
|
175626
|
+
mkdirSync14(htmxDir, { recursive: true });
|
|
175089
175627
|
const file = join23(htmxDir, "htmx.min.js");
|
|
175090
|
-
|
|
175628
|
+
writeFileSync16(file, content, "utf-8");
|
|
175091
175629
|
return file;
|
|
175092
175630
|
};
|
|
175093
175631
|
var init_install = () => {};
|
|
@@ -175097,7 +175635,7 @@ var exports_add = {};
|
|
|
175097
175635
|
__export(exports_add, {
|
|
175098
175636
|
runAdd: () => runAdd
|
|
175099
175637
|
});
|
|
175100
|
-
import { dirname as
|
|
175638
|
+
import { dirname as dirname13, join as join24, relative as relative9 } from "path";
|
|
175101
175639
|
var write2 = (text) => process.stdout.write(`${text}
|
|
175102
175640
|
`), fail2 = (message) => {
|
|
175103
175641
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
@@ -175108,11 +175646,11 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
175108
175646
|
return;
|
|
175109
175647
|
write2(` ${colors.dim}${label}${colors.reset}`);
|
|
175110
175648
|
for (const path of paths)
|
|
175111
|
-
write2(` ${
|
|
175649
|
+
write2(` ${relative9(cwd, path)}`);
|
|
175112
175650
|
}, frontendRoot = (project, cwd) => {
|
|
175113
175651
|
const [firstKey] = configuredFrameworks(project);
|
|
175114
175652
|
const firstDir = firstKey ? project.frameworkDirs[firstKey] : undefined;
|
|
175115
|
-
return firstDir ?
|
|
175653
|
+
return firstDir ? dirname13(firstDir) : join24(cwd, "src", "frontend");
|
|
175116
175654
|
}, addIntegrationCli = (id, install) => {
|
|
175117
175655
|
const result = addIntegration(process.cwd(), id, { install });
|
|
175118
175656
|
if (!result.ok) {
|
|
@@ -175177,7 +175715,7 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
175177
175715
|
return;
|
|
175178
175716
|
}
|
|
175179
175717
|
const dirAbs = join24(frontendRoot(project, cwd), framework);
|
|
175180
|
-
const dirRel = `./${
|
|
175718
|
+
const dirRel = `./${relative9(cwd, dirAbs).split("\\").join("/")}`;
|
|
175181
175719
|
let depNote = "Skipped dependency install (--no-install).";
|
|
175182
175720
|
if (!noInstall) {
|
|
175183
175721
|
write2(`${colors.dim}Installing ${frameworks2[framework].label} dependencies\u2026${colors.reset}`);
|
|
@@ -175246,8 +175784,8 @@ var exports_analyze = {};
|
|
|
175246
175784
|
__export(exports_analyze, {
|
|
175247
175785
|
runAnalyze: () => runAnalyze
|
|
175248
175786
|
});
|
|
175249
|
-
import { existsSync as
|
|
175250
|
-
import { join as join25, resolve as
|
|
175787
|
+
import { existsSync as existsSync28, readFileSync as readFileSync27, statSync as statSync3, writeFileSync as writeFileSync17 } from "fs";
|
|
175788
|
+
import { join as join25, resolve as resolve18 } from "path";
|
|
175251
175789
|
var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_WIDTH = 16, SIZE_WIDTH = 12, CHANGE_WIDTH = 10, CATEGORY_ORDER, categoryOf = (key) => {
|
|
175252
175790
|
if (key.startsWith("Island"))
|
|
175253
175791
|
return "Islands";
|
|
@@ -175268,9 +175806,9 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
175268
175806
|
}
|
|
175269
175807
|
}, readSizes = (manifestDir) => {
|
|
175270
175808
|
const manifestPath = join25(manifestDir, "manifest.json");
|
|
175271
|
-
if (!
|
|
175809
|
+
if (!existsSync28(manifestPath))
|
|
175272
175810
|
return null;
|
|
175273
|
-
const manifest = JSON.parse(
|
|
175811
|
+
const manifest = JSON.parse(readFileSync27(manifestPath, "utf-8"));
|
|
175274
175812
|
const sizes = {};
|
|
175275
175813
|
for (const [key, value] of Object.entries(manifest)) {
|
|
175276
175814
|
sizes[key] = fileSize2(join25(manifestDir, value.replace(/^\//, "")));
|
|
@@ -175278,10 +175816,10 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
175278
175816
|
return sizes;
|
|
175279
175817
|
}, readBaseline = (cwd) => {
|
|
175280
175818
|
const path = join25(cwd, BASELINE_FILE);
|
|
175281
|
-
if (!
|
|
175819
|
+
if (!existsSync28(path))
|
|
175282
175820
|
return null;
|
|
175283
175821
|
try {
|
|
175284
|
-
const parsed = JSON.parse(
|
|
175822
|
+
const parsed = JSON.parse(readFileSync27(path, "utf-8"));
|
|
175285
175823
|
return parsed;
|
|
175286
175824
|
} catch {
|
|
175287
175825
|
return null;
|
|
@@ -175359,14 +175897,14 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
175359
175897
|
const config = await loadConfig(configIndex >= 0 ? args[configIndex + 1] : undefined);
|
|
175360
175898
|
const outdirIndex = args.indexOf("--outdir");
|
|
175361
175899
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
175362
|
-
const sizes = readSizes(
|
|
175900
|
+
const sizes = readSizes(resolve18(cwd, outdir ?? "build"));
|
|
175363
175901
|
if (sizes === null) {
|
|
175364
175902
|
process.stdout.write(`${colors.dim}No build found. Run \`absolute build\` first.${colors.reset}
|
|
175365
175903
|
`);
|
|
175366
175904
|
return;
|
|
175367
175905
|
}
|
|
175368
175906
|
if (args.includes("--save")) {
|
|
175369
|
-
|
|
175907
|
+
writeFileSync17(join25(cwd, BASELINE_FILE), `${JSON.stringify(sizes, null, 2)}
|
|
175370
175908
|
`);
|
|
175371
175909
|
process.stdout.write(`${colors.green}\u2713${colors.reset} Saved size baseline (${Object.keys(sizes).length} entries) to ${BASELINE_FILE}
|
|
175372
175910
|
`);
|
|
@@ -175612,8 +176150,8 @@ var exports_remove = {};
|
|
|
175612
176150
|
__export(exports_remove, {
|
|
175613
176151
|
runRemove: () => runRemove
|
|
175614
176152
|
});
|
|
175615
|
-
import { existsSync as
|
|
175616
|
-
import { relative as
|
|
176153
|
+
import { existsSync as existsSync29, readFileSync as readFileSync28 } from "fs";
|
|
176154
|
+
import { relative as relative10 } from "path";
|
|
175617
176155
|
var write3 = (text) => process.stdout.write(`${text}
|
|
175618
176156
|
`), fail3 = (message) => {
|
|
175619
176157
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
@@ -175623,10 +176161,10 @@ var write3 = (text) => process.stdout.write(`${text}
|
|
|
175623
176161
|
const candidates = [findRoutingFile(serverEntry), serverEntry];
|
|
175624
176162
|
const seen = new Set;
|
|
175625
176163
|
return candidates.filter((file) => {
|
|
175626
|
-
if (file === null || seen.has(file) || !
|
|
176164
|
+
if (file === null || seen.has(file) || !existsSync29(file))
|
|
175627
176165
|
return false;
|
|
175628
176166
|
seen.add(file);
|
|
175629
|
-
return
|
|
176167
|
+
return readFileSync28(file, "utf-8").includes(handler);
|
|
175630
176168
|
});
|
|
175631
176169
|
}, runRemove = async (args) => {
|
|
175632
176170
|
const [framework] = args.filter((arg) => !arg.startsWith("--"));
|
|
@@ -175662,10 +176200,10 @@ var write3 = (text) => process.stdout.write(`${text}
|
|
|
175662
176200
|
}
|
|
175663
176201
|
write3(`${colors.green}\u2713${colors.reset} Removed ${framework}Directory from absolute.config.ts
|
|
175664
176202
|
`);
|
|
175665
|
-
write3(` ${colors.dim}Kept${colors.reset} ${
|
|
176203
|
+
write3(` ${colors.dim}Kept${colors.reset} ${relative10(cwd, frameworkDir)} \u2014 delete its source manually if no longer needed.`);
|
|
175666
176204
|
const refs = referencingFiles(project.serverEntry, HANDLER_NAME[framework]);
|
|
175667
176205
|
for (const file of refs) {
|
|
175668
|
-
write3(` ${colors.yellow}Still references${colors.reset} ${
|
|
176206
|
+
write3(` ${colors.yellow}Still references${colors.reset} ${relative10(cwd, file)} (calls ${HANDLER_NAME[framework]})`);
|
|
175669
176207
|
}
|
|
175670
176208
|
const deps = frameworkDependencyNames(framework);
|
|
175671
176209
|
if (prune && deps.length > 0) {
|
|
@@ -175753,15 +176291,15 @@ __export(exports_env, {
|
|
|
175753
176291
|
runEnv: () => runEnv,
|
|
175754
176292
|
collectEnvVars: () => collectEnvVars
|
|
175755
176293
|
});
|
|
175756
|
-
import { existsSync as
|
|
176294
|
+
import { existsSync as existsSync30, readFileSync as readFileSync29 } from "fs";
|
|
175757
176295
|
import { join as join26 } from "path";
|
|
175758
176296
|
var {env: env3, Glob: Glob3 } = globalThis.Bun;
|
|
175759
|
-
var EXTENSIONS = "ts,tsx,js,jsx,mjs,cjs,svelte,vue", STATUS_WIDTH2, keysInFile = (text) => [...text.matchAll(/getEnv\(\s*['"]([^'"]+)['"]\s*\)/g)].map((match) => match[1]).filter((key) => key !== undefined), scanPatterns = () =>
|
|
176297
|
+
var EXTENSIONS = "ts,tsx,js,jsx,mjs,cjs,svelte,vue", STATUS_WIDTH2, keysInFile = (text) => [...text.matchAll(/getEnv\(\s*['"]([^'"]+)['"]\s*\)/g)].map((match) => match[1]).filter((key) => key !== undefined), scanPatterns = () => existsSync30(join26(process.cwd(), "src")) ? [`src/**/*.{${EXTENSIONS}}`] : [`*.{${EXTENSIONS}}`], scanEnvUsage = async () => {
|
|
175760
176298
|
const scans = scanPatterns().map((pattern) => Array.fromAsync(new Glob3(pattern).scan({ cwd: process.cwd() })));
|
|
175761
176299
|
const files = (await Promise.all(scans)).flat();
|
|
175762
176300
|
const usage = new Map;
|
|
175763
176301
|
files.forEach((file) => {
|
|
175764
|
-
keysInFile(
|
|
176302
|
+
keysInFile(readFileSync29(file, "utf-8")).forEach((key) => {
|
|
175765
176303
|
usage.set(key, [...usage.get(key) ?? [], file]);
|
|
175766
176304
|
});
|
|
175767
176305
|
});
|
|
@@ -175822,7 +176360,7 @@ __export(exports_db, {
|
|
|
175822
176360
|
conflictClause: () => conflictClause,
|
|
175823
176361
|
chunkRows: () => chunkRows
|
|
175824
176362
|
});
|
|
175825
|
-
import { existsSync as
|
|
176363
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync15, readFileSync as readFileSync30, writeFileSync as writeFileSync18 } from "fs";
|
|
175826
176364
|
import { join as join27 } from "path";
|
|
175827
176365
|
var {env: env4, spawn: spawn2, SQL } = globalThis.Bun;
|
|
175828
176366
|
var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA_TYPES, SEED_CANDIDATES, VALUE_FLAGS, paint = (text, color) => `${color}${text}${colors.reset}`, chunkRows = (items, size) => Array.from({ length: Math.ceil(items.length / size) }, (_, idx) => items.slice(idx * size, idx * size + size)), quoteIdent = (name) => `"${name.replace(/"/g, '""')}"`, resolveUrl = (explicit) => {
|
|
@@ -175934,18 +176472,18 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
175934
176472
|
v: BACKUP_FORMAT_VERSION
|
|
175935
176473
|
};
|
|
175936
176474
|
const dir = options.out ?? join27(process.cwd(), "backups");
|
|
175937
|
-
|
|
176475
|
+
mkdirSync15(dir, { recursive: true });
|
|
175938
176476
|
const json = JSON.stringify(payload, (_, value) => typeof value === "bigint" ? value.toString() : value);
|
|
175939
176477
|
const file = join27(dir, `backup-${payload.at.replace(/[:.]/g, "-")}.json`);
|
|
175940
|
-
|
|
175941
|
-
|
|
176478
|
+
writeFileSync18(file, json);
|
|
176479
|
+
writeFileSync18(join27(dir, "latest.json"), json);
|
|
175942
176480
|
const total = chosen.reduce((sum, name) => sum + (tables[name]?.length ?? 0), 0);
|
|
175943
176481
|
console.log(paint(`\u2713 backup \u2192 ${file}`, colors.green));
|
|
175944
176482
|
console.log(paint(` ${chosen.length} tables, ${total} rows`, colors.dim));
|
|
175945
176483
|
}, runRestore = async (file, options) => {
|
|
175946
|
-
if (!
|
|
176484
|
+
if (!existsSync31(file))
|
|
175947
176485
|
throw new Error(`Backup not found: ${file}`);
|
|
175948
|
-
const payload = JSON.parse(
|
|
176486
|
+
const payload = JSON.parse(readFileSync30(file, "utf-8"));
|
|
175949
176487
|
const names = Object.keys(payload.tables).filter((name) => keepTable(name, options));
|
|
175950
176488
|
const sql = new SQL(options.url);
|
|
175951
176489
|
const order = dependencyOrder(names, await foreignLinks(sql));
|
|
@@ -175967,7 +176505,7 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
175967
176505
|
const total = order.reduce((sum, name) => sum + (payload.tables[name]?.length ?? 0), 0);
|
|
175968
176506
|
console.log(paint(`\u2713 restored ${order.length} tables, ${total} rows (idempotent upsert by primary key)`, colors.green));
|
|
175969
176507
|
}, runSeed = async (entry) => {
|
|
175970
|
-
const target = entry ?? SEED_CANDIDATES.find((candidate) =>
|
|
176508
|
+
const target = entry ?? SEED_CANDIDATES.find((candidate) => existsSync31(join27(process.cwd(), candidate)));
|
|
175971
176509
|
if (target === undefined)
|
|
175972
176510
|
throw new Error(`No seed script found (looked for ${SEED_CANDIDATES.join(", ")}). Pass a path: absolute db seed <file>.`);
|
|
175973
176511
|
console.log(paint(`seeding via ${target}\u2026`, colors.cyan));
|
|
@@ -176028,7 +176566,7 @@ __export(exports_logs, {
|
|
|
176028
176566
|
});
|
|
176029
176567
|
import {
|
|
176030
176568
|
closeSync as closeSync2,
|
|
176031
|
-
existsSync as
|
|
176569
|
+
existsSync as existsSync32,
|
|
176032
176570
|
openSync as openSync4,
|
|
176033
176571
|
readSync as readSync2,
|
|
176034
176572
|
statSync as statSync4,
|
|
@@ -176095,7 +176633,7 @@ var DEFAULT_LINES = 40, POLL_MS = 250, LINES_FLAG_SPAN = 2, readFrom = (path, st
|
|
|
176095
176633
|
printAvailable(instances);
|
|
176096
176634
|
return;
|
|
176097
176635
|
}
|
|
176098
|
-
if (match.logFile === null || !
|
|
176636
|
+
if (match.logFile === null || !existsSync32(match.logFile)) {
|
|
176099
176637
|
printDim3(`"${name}" has no captured log (untracked, or started outside the CLI).`);
|
|
176100
176638
|
return;
|
|
176101
176639
|
}
|
|
@@ -176115,17 +176653,17 @@ var init_logs = __esm(() => {
|
|
|
176115
176653
|
|
|
176116
176654
|
// src/cli/typeGraphCoherence.ts
|
|
176117
176655
|
import {
|
|
176118
|
-
existsSync as
|
|
176119
|
-
readFileSync as
|
|
176656
|
+
existsSync as existsSync33,
|
|
176657
|
+
readFileSync as readFileSync31,
|
|
176120
176658
|
realpathSync,
|
|
176121
|
-
rmSync as
|
|
176122
|
-
writeFileSync as
|
|
176659
|
+
rmSync as rmSync6,
|
|
176660
|
+
writeFileSync as writeFileSync19
|
|
176123
176661
|
} from "fs";
|
|
176124
176662
|
import { createRequire } from "module";
|
|
176125
|
-
import { dirname as
|
|
176663
|
+
import { dirname as dirname14, join as join28, resolve as resolve19, sep } from "path";
|
|
176126
176664
|
var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
176127
176665
|
try {
|
|
176128
|
-
const parsed = JSON.parse(
|
|
176666
|
+
const parsed = JSON.parse(readFileSync31(path, "utf-8"));
|
|
176129
176667
|
return isRecord3(parsed) ? parsed : null;
|
|
176130
176668
|
} catch {
|
|
176131
176669
|
return null;
|
|
@@ -176142,13 +176680,13 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
176142
176680
|
const version2 = Reflect.get(manifest, "version");
|
|
176143
176681
|
return typeof version2 === "string" ? version2 : "unknown";
|
|
176144
176682
|
}, packageJsonFromEntry = (entry, expectedName) => {
|
|
176145
|
-
let directory =
|
|
176683
|
+
let directory = dirname14(entry);
|
|
176146
176684
|
for (;; ) {
|
|
176147
176685
|
const candidate = join28(directory, "package.json");
|
|
176148
176686
|
const manifest = readManifest(candidate);
|
|
176149
176687
|
if (manifest && manifestName(manifest, "") === expectedName)
|
|
176150
176688
|
return candidate;
|
|
176151
|
-
const parent =
|
|
176689
|
+
const parent = dirname14(directory);
|
|
176152
176690
|
if (parent === directory)
|
|
176153
176691
|
return null;
|
|
176154
176692
|
directory = parent;
|
|
@@ -176164,25 +176702,25 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
176164
176702
|
}
|
|
176165
176703
|
}
|
|
176166
176704
|
}, findInstallRoot = (cwd) => {
|
|
176167
|
-
let directory =
|
|
176705
|
+
let directory = resolve19(cwd);
|
|
176168
176706
|
for (;; ) {
|
|
176169
|
-
if (
|
|
176707
|
+
if (existsSync33(join28(directory, "bun.lock")) || existsSync33(join28(directory, "bun.lockb"))) {
|
|
176170
176708
|
return directory;
|
|
176171
176709
|
}
|
|
176172
|
-
const parent =
|
|
176710
|
+
const parent = dirname14(directory);
|
|
176173
176711
|
if (parent === directory)
|
|
176174
|
-
return
|
|
176712
|
+
return resolve19(cwd);
|
|
176175
176713
|
directory = parent;
|
|
176176
176714
|
}
|
|
176177
176715
|
}, findProjectManifest = (cwd, installRoot) => {
|
|
176178
|
-
let directory =
|
|
176716
|
+
let directory = resolve19(cwd);
|
|
176179
176717
|
for (;; ) {
|
|
176180
176718
|
const candidate = join28(directory, "package.json");
|
|
176181
|
-
if (
|
|
176719
|
+
if (existsSync33(candidate))
|
|
176182
176720
|
return candidate;
|
|
176183
176721
|
if (directory === installRoot)
|
|
176184
176722
|
return join28(installRoot, "package.json");
|
|
176185
|
-
const parent =
|
|
176723
|
+
const parent = dirname14(directory);
|
|
176186
176724
|
if (parent === directory)
|
|
176187
176725
|
return join28(installRoot, "package.json");
|
|
176188
176726
|
directory = parent;
|
|
@@ -176275,7 +176813,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
176275
176813
|
}
|
|
176276
176814
|
if (changes.length > 0) {
|
|
176277
176815
|
Reflect.set(manifest, "overrides", overrides);
|
|
176278
|
-
|
|
176816
|
+
writeFileSync19(manifestPath, `${JSON.stringify(manifest, null, "\t")}
|
|
176279
176817
|
`);
|
|
176280
176818
|
}
|
|
176281
176819
|
return changes;
|
|
@@ -176292,7 +176830,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
176292
176830
|
for (const stalePath of stalePaths) {
|
|
176293
176831
|
if (!stalePath.startsWith(installPrefix) || !stalePath.includes(nodeModulesSegment))
|
|
176294
176832
|
continue;
|
|
176295
|
-
|
|
176833
|
+
rmSync6(dirname14(stalePath), { force: true, recursive: true });
|
|
176296
176834
|
removed.push(stalePath);
|
|
176297
176835
|
}
|
|
176298
176836
|
return removed;
|
|
@@ -176319,7 +176857,7 @@ var exports_doctor = {};
|
|
|
176319
176857
|
__export(exports_doctor, {
|
|
176320
176858
|
runDoctor: () => runDoctor
|
|
176321
176859
|
});
|
|
176322
|
-
import { existsSync as
|
|
176860
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync16, readFileSync as readFileSync32, writeFileSync as writeFileSync20 } from "fs";
|
|
176323
176861
|
import { createRequire as createRequire2 } from "module";
|
|
176324
176862
|
import { arch as arch4, platform as platform5 } from "os";
|
|
176325
176863
|
import { join as join29 } from "path";
|
|
@@ -176357,7 +176895,7 @@ var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
|
|
|
176357
176895
|
return [];
|
|
176358
176896
|
const label = `${field.replace("Directory", "")} pages`;
|
|
176359
176897
|
return [
|
|
176360
|
-
|
|
176898
|
+
existsSync34(join29(process.cwd(), dir)) ? check("ok", label, dir) : check("fail", label, `${dir} (missing)`)
|
|
176361
176899
|
];
|
|
176362
176900
|
}), envCheck = async () => {
|
|
176363
176901
|
const vars = await collectEnvVars();
|
|
@@ -176419,9 +176957,9 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
176419
176957
|
const fixes = [];
|
|
176420
176958
|
for (const field of FRAMEWORK_FIELDS2) {
|
|
176421
176959
|
const dir = readString(config, field);
|
|
176422
|
-
if (dir === undefined ||
|
|
176960
|
+
if (dir === undefined || existsSync34(join29(cwd, dir)))
|
|
176423
176961
|
continue;
|
|
176424
|
-
|
|
176962
|
+
mkdirSync16(join29(cwd, dir, "pages"), { recursive: true });
|
|
176425
176963
|
fixes.push(`created ${dir}/pages`);
|
|
176426
176964
|
}
|
|
176427
176965
|
return fixes;
|
|
@@ -176430,7 +176968,7 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
176430
176968
|
if (missing.length === 0)
|
|
176431
176969
|
return null;
|
|
176432
176970
|
const envExample = join29(cwd, ".env.example");
|
|
176433
|
-
const existing =
|
|
176971
|
+
const existing = existsSync34(envExample) ? readFileSync32(envExample, "utf-8") : "";
|
|
176434
176972
|
const existingKeys = new Set(existing.split(`
|
|
176435
176973
|
`).map((line) => line.split("=")[0]?.trim()));
|
|
176436
176974
|
const toAdd = missing.filter((entry) => !existingKeys.has(entry.key));
|
|
@@ -176439,7 +176977,7 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
176439
176977
|
const prefix = existing === "" || existing.endsWith(`
|
|
176440
176978
|
`) ? existing : `${existing}
|
|
176441
176979
|
`;
|
|
176442
|
-
|
|
176980
|
+
writeFileSync20(envExample, `${prefix}${toAdd.map((entry) => `${entry.key}=`).join(`
|
|
176443
176981
|
`)}
|
|
176444
176982
|
`);
|
|
176445
176983
|
return `added ${toAdd.length} key(s) to .env.example`;
|
|
@@ -176804,10 +177342,10 @@ var init_inspect = __esm(() => {
|
|
|
176804
177342
|
});
|
|
176805
177343
|
|
|
176806
177344
|
// src/build/scanEntryPoints.ts
|
|
176807
|
-
import { existsSync as
|
|
177345
|
+
import { existsSync as existsSync35 } from "fs";
|
|
176808
177346
|
var {Glob: Glob4 } = globalThis.Bun;
|
|
176809
177347
|
var scanEntryPoints = async (dir, pattern) => {
|
|
176810
|
-
if (!
|
|
177348
|
+
if (!existsSync35(dir))
|
|
176811
177349
|
return [];
|
|
176812
177350
|
const entryPaths = [];
|
|
176813
177351
|
const glob = new Glob4(pattern);
|
|
@@ -176889,8 +177427,8 @@ var init_sourceMetadata = __esm(() => {
|
|
|
176889
177427
|
});
|
|
176890
177428
|
|
|
176891
177429
|
// src/islands/pageMetadata.ts
|
|
176892
|
-
import { readFileSync as
|
|
176893
|
-
import { dirname as
|
|
177430
|
+
import { readFileSync as readFileSync33 } from "fs";
|
|
177431
|
+
import { dirname as dirname15, resolve as resolve20 } from "path";
|
|
176894
177432
|
var pagePatterns, getPageDirs = (config) => [
|
|
176895
177433
|
{ dir: config.angularDirectory, framework: "angular" },
|
|
176896
177434
|
{ dir: config.emberDirectory, framework: "ember" },
|
|
@@ -176910,8 +177448,8 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
176910
177448
|
const source = definition.buildReference?.source;
|
|
176911
177449
|
if (!source)
|
|
176912
177450
|
continue;
|
|
176913
|
-
const resolvedSource = source.startsWith("file://") ? new URL(source).pathname :
|
|
176914
|
-
lookup.set(`${definition.framework}:${definition.component}`,
|
|
177451
|
+
const resolvedSource = source.startsWith("file://") ? new URL(source).pathname : resolve20(dirname15(buildInfo.resolvedRegistryPath), source);
|
|
177452
|
+
lookup.set(`${definition.framework}:${definition.component}`, resolve20(resolvedSource));
|
|
176915
177453
|
}
|
|
176916
177454
|
return lookup;
|
|
176917
177455
|
}, resolveIslandUsages = (islands, islandSourceLookup) => islands.map((usage2) => {
|
|
@@ -176924,13 +177462,13 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
176924
177462
|
const pattern = pagePatterns[entry.framework];
|
|
176925
177463
|
if (!pattern)
|
|
176926
177464
|
return;
|
|
176927
|
-
const files = await scanEntryPoints(
|
|
177465
|
+
const files = await scanEntryPoints(resolve20(entry.dir), pattern);
|
|
176928
177466
|
for (const filePath of files) {
|
|
176929
|
-
const source =
|
|
177467
|
+
const source = readFileSync33(filePath, "utf-8");
|
|
176930
177468
|
const islands = extractIslandUsagesFromSource(source);
|
|
176931
|
-
pageMetadata.set(
|
|
177469
|
+
pageMetadata.set(resolve20(filePath), {
|
|
176932
177470
|
islands: resolveIslandUsages(islands, islandSourceLookup),
|
|
176933
|
-
pagePath:
|
|
177471
|
+
pagePath: resolve20(filePath)
|
|
176934
177472
|
});
|
|
176935
177473
|
}
|
|
176936
177474
|
}, loadPageIslandMetadata = async (config) => {
|
|
@@ -176959,14 +177497,14 @@ var exports_islands = {};
|
|
|
176959
177497
|
__export(exports_islands, {
|
|
176960
177498
|
runIslands: () => runIslands
|
|
176961
177499
|
});
|
|
176962
|
-
import { existsSync as
|
|
176963
|
-
import { join as join30, relative as
|
|
177500
|
+
import { existsSync as existsSync36, readFileSync as readFileSync34, statSync as statSync5 } from "fs";
|
|
177501
|
+
import { join as join30, relative as relative11, resolve as resolve21 } from "path";
|
|
176964
177502
|
var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.write(`${colors.dim}${message}${colors.reset}
|
|
176965
177503
|
`), hostFrameworkOf = (pagePath, cwd, config) => {
|
|
176966
|
-
const resolved =
|
|
177504
|
+
const resolved = resolve21(cwd, pagePath);
|
|
176967
177505
|
for (const [framework, key] of Object.entries(FRAMEWORK_DIR_KEY)) {
|
|
176968
177506
|
const dir = config[key];
|
|
176969
|
-
if (typeof dir === "string" && resolved.startsWith(
|
|
177507
|
+
if (typeof dir === "string" && resolved.startsWith(resolve21(cwd, dir))) {
|
|
176970
177508
|
return framework;
|
|
176971
177509
|
}
|
|
176972
177510
|
}
|
|
@@ -176979,9 +177517,9 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
176979
177517
|
}
|
|
176980
177518
|
}, readManifestSizes2 = (manifestDir) => {
|
|
176981
177519
|
const manifestPath = join30(manifestDir, "manifest.json");
|
|
176982
|
-
if (!
|
|
177520
|
+
if (!existsSync36(manifestPath))
|
|
176983
177521
|
return null;
|
|
176984
|
-
const manifest = JSON.parse(
|
|
177522
|
+
const manifest = JSON.parse(readFileSync34(manifestPath, "utf-8"));
|
|
176985
177523
|
const sizes = new Map;
|
|
176986
177524
|
for (const [key, value] of Object.entries(manifest)) {
|
|
176987
177525
|
sizes.set(key, fileSize3(join30(manifestDir, value.replace(/^\//, ""))));
|
|
@@ -176991,7 +177529,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
176991
177529
|
const registryPath = config.islands?.registry;
|
|
176992
177530
|
if (typeof registryPath !== "string")
|
|
176993
177531
|
return null;
|
|
176994
|
-
const buildInfo = await loadIslandRegistryBuildInfo(
|
|
177532
|
+
const buildInfo = await loadIslandRegistryBuildInfo(resolve21(cwd, registryPath));
|
|
176995
177533
|
const pageMetadata = await loadPageIslandMetadata(config);
|
|
176996
177534
|
const usages = [...pageMetadata.values()].flatMap((meta) => meta.islands.map((island) => ({ ...island, page: meta.pagePath })));
|
|
176997
177535
|
return buildInfo.definitions.map((definition) => {
|
|
@@ -177001,7 +177539,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
177001
177539
|
crossFramework: hostFramework !== null && hostFramework !== definition.framework,
|
|
177002
177540
|
hostFramework,
|
|
177003
177541
|
hydrate: usage2.hydrate ?? "load",
|
|
177004
|
-
page:
|
|
177542
|
+
page: relative11(cwd, resolve21(cwd, usage2.page))
|
|
177005
177543
|
};
|
|
177006
177544
|
});
|
|
177007
177545
|
const key = getIslandManifestKey(definition.framework, definition.component);
|
|
@@ -177040,7 +177578,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
177040
177578
|
` ${color}\u2B21${colors.reset} ${colors.bold}${island.component}${colors.reset} ${meta}${sizeText}`
|
|
177041
177579
|
];
|
|
177042
177580
|
if (island.source) {
|
|
177043
|
-
lines.push(` ${colors.dim}${
|
|
177581
|
+
lines.push(` ${colors.dim}${relative11(cwd, island.source)}${colors.reset}`);
|
|
177044
177582
|
}
|
|
177045
177583
|
if (pages.length === 0) {
|
|
177046
177584
|
lines.push(` ${colors.dim}(registered but not mounted on any page)${colors.reset}`);
|
|
@@ -177070,7 +177608,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
177070
177608
|
}
|
|
177071
177609
|
const outdirIndex = args.indexOf("--outdir");
|
|
177072
177610
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
177073
|
-
const sizes = args.includes("--sizes") ? readManifestSizes2(
|
|
177611
|
+
const sizes = args.includes("--sizes") ? readManifestSizes2(resolve21(cwd, outdir ?? "build")) : null;
|
|
177074
177612
|
const islands = await collectIslands(cwd, config, sizes);
|
|
177075
177613
|
if (islands === null) {
|
|
177076
177614
|
printDim6('No island registry configured. Set `islands: { registry: "..." }` in absolute.config.ts.');
|
|
@@ -177119,13 +177657,13 @@ var init_islands2 = __esm(() => {
|
|
|
177119
177657
|
});
|
|
177120
177658
|
|
|
177121
177659
|
// src/build/externalAssetPlugin.ts
|
|
177122
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
177123
|
-
import { basename as basename6, dirname as
|
|
177660
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync37, mkdirSync as mkdirSync17, statSync as statSync6 } from "fs";
|
|
177661
|
+
import { basename as basename6, dirname as dirname16, join as join31, resolve as resolve22 } from "path";
|
|
177124
177662
|
var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
177125
177663
|
name: "absolute-external-asset",
|
|
177126
177664
|
setup(bld) {
|
|
177127
177665
|
const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
|
|
177128
|
-
const skipRoots = userSourceRoots.map((root) =>
|
|
177666
|
+
const skipRoots = userSourceRoots.map((root) => resolve22(root));
|
|
177129
177667
|
const isUserSource = (path) => skipRoots.some((root) => path.startsWith(`${root}/`));
|
|
177130
177668
|
bld.onLoad({ filter: /\.[mc]?[jt]sx?$/ }, async (args) => {
|
|
177131
177669
|
if (isUserSource(args.path))
|
|
@@ -177135,20 +177673,20 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
|
177135
177673
|
return;
|
|
177136
177674
|
urlPattern.lastIndex = 0;
|
|
177137
177675
|
let match;
|
|
177138
|
-
const sourceDir =
|
|
177676
|
+
const sourceDir = dirname16(args.path);
|
|
177139
177677
|
while ((match = urlPattern.exec(source)) !== null) {
|
|
177140
177678
|
const relPath = match[1];
|
|
177141
177679
|
if (!relPath)
|
|
177142
177680
|
continue;
|
|
177143
|
-
const assetPath =
|
|
177144
|
-
if (!
|
|
177681
|
+
const assetPath = resolve22(sourceDir, relPath);
|
|
177682
|
+
if (!existsSync37(assetPath))
|
|
177145
177683
|
continue;
|
|
177146
177684
|
if (!statSync6(assetPath).isFile())
|
|
177147
177685
|
continue;
|
|
177148
177686
|
const targetPath = join31(outDir, basename6(assetPath));
|
|
177149
|
-
if (
|
|
177687
|
+
if (existsSync37(targetPath))
|
|
177150
177688
|
continue;
|
|
177151
|
-
|
|
177689
|
+
mkdirSync17(dirname16(targetPath), { recursive: true });
|
|
177152
177690
|
copyFileSync2(assetPath, targetPath);
|
|
177153
177691
|
}
|
|
177154
177692
|
return;
|
|
@@ -177166,23 +177704,23 @@ __export(exports_compile, {
|
|
|
177166
177704
|
var {env: env5 } = globalThis.Bun;
|
|
177167
177705
|
import {
|
|
177168
177706
|
cpSync,
|
|
177169
|
-
existsSync as
|
|
177170
|
-
mkdirSync as
|
|
177707
|
+
existsSync as existsSync38,
|
|
177708
|
+
mkdirSync as mkdirSync18,
|
|
177171
177709
|
readdirSync as readdirSync7,
|
|
177172
|
-
readFileSync as
|
|
177173
|
-
rmSync as
|
|
177710
|
+
readFileSync as readFileSync35,
|
|
177711
|
+
rmSync as rmSync7,
|
|
177174
177712
|
statSync as statSync7,
|
|
177175
177713
|
unlinkSync as unlinkSync4,
|
|
177176
|
-
writeFileSync as
|
|
177714
|
+
writeFileSync as writeFileSync21
|
|
177177
177715
|
} from "fs";
|
|
177178
177716
|
import { createRequire as createRequire3 } from "module";
|
|
177179
177717
|
import {
|
|
177180
177718
|
basename as basename7,
|
|
177181
|
-
dirname as
|
|
177719
|
+
dirname as dirname17,
|
|
177182
177720
|
isAbsolute as isAbsolute2,
|
|
177183
177721
|
join as join32,
|
|
177184
|
-
relative as
|
|
177185
|
-
resolve as
|
|
177722
|
+
relative as relative12,
|
|
177723
|
+
resolve as resolve23
|
|
177186
177724
|
} from "path";
|
|
177187
177725
|
var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
|
|
177188
177726
|
const resolvedVersion = version2 || "unknown";
|
|
@@ -177204,7 +177742,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177204
177742
|
}
|
|
177205
177743
|
return result;
|
|
177206
177744
|
}, INLINE_SOURCE_MAP_RE, rebaseInlineSourceMap = (filePath) => {
|
|
177207
|
-
const source =
|
|
177745
|
+
const source = readFileSync35(filePath, "utf-8");
|
|
177208
177746
|
const match = source.match(INLINE_SOURCE_MAP_RE);
|
|
177209
177747
|
const encoded = match?.[1];
|
|
177210
177748
|
if (!encoded)
|
|
@@ -177215,7 +177753,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177215
177753
|
if (!Array.isArray(map.sources))
|
|
177216
177754
|
return;
|
|
177217
177755
|
const sourceRoot = typeof map.sourceRoot === "string" ? map.sourceRoot : "";
|
|
177218
|
-
const bundleDirectory =
|
|
177756
|
+
const bundleDirectory = dirname17(filePath);
|
|
177219
177757
|
map.sources = map.sources.map((entry) => {
|
|
177220
177758
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(entry))
|
|
177221
177759
|
return entry;
|
|
@@ -177224,11 +177762,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177224
177762
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(sourceRoot)) {
|
|
177225
177763
|
return new URL(entry, sourceRoot).href;
|
|
177226
177764
|
}
|
|
177227
|
-
return
|
|
177765
|
+
return resolve23(bundleDirectory, sourceRoot, entry);
|
|
177228
177766
|
});
|
|
177229
177767
|
delete map.sourceRoot;
|
|
177230
177768
|
const rebased = Buffer.from(JSON.stringify(map)).toString("base64");
|
|
177231
|
-
|
|
177769
|
+
writeFileSync21(filePath, source.replace(encoded, rebased));
|
|
177232
177770
|
}, SERVER_RUNTIME_ASSET_RE, SERVER_RUNTIME_IMPORT_META_DIR_JOIN_RE, SERVER_RUNTIME_STRING_ARG_RE, SERVER_RUNTIME_SOURCE_EXTENSIONS, SERVER_RUNTIME_SCAN_SKIP_DIRS, hasSourceExtension = (filePath) => SERVER_RUNTIME_SOURCE_EXTENSIONS.has(filePath.slice(filePath.lastIndexOf("."))), normalizeServerRuntimeAssetPath = (parts) => {
|
|
177233
177771
|
if (parts.length === 0)
|
|
177234
177772
|
return null;
|
|
@@ -177254,22 +177792,22 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177254
177792
|
return result;
|
|
177255
177793
|
}, copyServerRuntimeAssetReferences = (outdir) => {
|
|
177256
177794
|
const copied = new Set;
|
|
177257
|
-
const normalizedOutdir =
|
|
177795
|
+
const normalizedOutdir = resolve23(outdir);
|
|
177258
177796
|
const copyReference = (filePath, relPath) => {
|
|
177259
|
-
const assetSource =
|
|
177260
|
-
if (!
|
|
177797
|
+
const assetSource = resolve23(dirname17(filePath), relPath);
|
|
177798
|
+
if (!existsSync38(assetSource) || !statSync7(assetSource).isFile())
|
|
177261
177799
|
return;
|
|
177262
|
-
const assetTarget =
|
|
177800
|
+
const assetTarget = resolve23(normalizedOutdir, relPath.replace(/^\.\//, ""));
|
|
177263
177801
|
if (assetTarget !== normalizedOutdir && !assetTarget.startsWith(`${normalizedOutdir}/`))
|
|
177264
177802
|
return;
|
|
177265
177803
|
if (copied.has(assetTarget))
|
|
177266
177804
|
return;
|
|
177267
177805
|
copied.add(assetTarget);
|
|
177268
|
-
|
|
177806
|
+
mkdirSync18(dirname17(assetTarget), { recursive: true });
|
|
177269
177807
|
cpSync(assetSource, assetTarget, { force: true });
|
|
177270
177808
|
};
|
|
177271
177809
|
for (const filePath of collectProjectSourceFiles(process.cwd())) {
|
|
177272
|
-
const source =
|
|
177810
|
+
const source = readFileSync35(filePath, "utf-8");
|
|
177273
177811
|
SERVER_RUNTIME_ASSET_RE.lastIndex = 0;
|
|
177274
177812
|
let match;
|
|
177275
177813
|
while ((match = SERVER_RUNTIME_ASSET_RE.exec(source)) !== null) {
|
|
@@ -177298,7 +177836,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177298
177836
|
}
|
|
177299
177837
|
}, readPackageVersion4 = (candidate) => {
|
|
177300
177838
|
try {
|
|
177301
|
-
const pkg = JSON.parse(
|
|
177839
|
+
const pkg = JSON.parse(readFileSync35(candidate, "utf-8"));
|
|
177302
177840
|
if (pkg.name !== "@absolutejs/absolute")
|
|
177303
177841
|
return null;
|
|
177304
177842
|
const ver = pkg.version;
|
|
@@ -177333,18 +177871,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177333
177871
|
return resolveBuildModule3(remaining);
|
|
177334
177872
|
}, resolveJsxDevRuntimeCompatPath2 = () => {
|
|
177335
177873
|
const candidates = [
|
|
177336
|
-
|
|
177337
|
-
|
|
177338
|
-
|
|
177339
|
-
|
|
177340
|
-
|
|
177341
|
-
|
|
177874
|
+
resolve23(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
177875
|
+
resolve23(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
177876
|
+
resolve23(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
|
|
177877
|
+
resolve23(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
177878
|
+
resolve23(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
177879
|
+
resolve23(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
177342
177880
|
];
|
|
177343
177881
|
for (const candidate of candidates) {
|
|
177344
|
-
if (
|
|
177882
|
+
if (existsSync38(candidate))
|
|
177345
177883
|
return candidate;
|
|
177346
177884
|
}
|
|
177347
|
-
return
|
|
177885
|
+
return resolve23(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
177348
177886
|
}, jsxDevRuntimeCompatPath2, shouldEmbedCompiledAsset = (relativePath, skip = new Set) => {
|
|
177349
177887
|
if (skip.has(relativePath))
|
|
177350
177888
|
return false;
|
|
@@ -177369,7 +177907,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177369
177907
|
return true;
|
|
177370
177908
|
}), requireForCompile, resolveNativeAssetForRuntime = (specifier) => {
|
|
177371
177909
|
if (specifier.startsWith("."))
|
|
177372
|
-
return
|
|
177910
|
+
return resolve23(process.cwd(), specifier);
|
|
177373
177911
|
if (specifier.startsWith("/"))
|
|
177374
177912
|
return specifier;
|
|
177375
177913
|
return requireForCompile.resolve(specifier, { paths: [process.cwd()] });
|
|
@@ -177381,11 +177919,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177381
177919
|
return nativeAssetEnv;
|
|
177382
177920
|
}, tryReadNodePackageJson = (packageDir) => {
|
|
177383
177921
|
try {
|
|
177384
|
-
return JSON.parse(
|
|
177922
|
+
return JSON.parse(readFileSync35(join32(packageDir, "package.json"), "utf-8"));
|
|
177385
177923
|
} catch {
|
|
177386
177924
|
return null;
|
|
177387
177925
|
}
|
|
177388
|
-
}, resolveProjectPackageDir = (specifier) =>
|
|
177926
|
+
}, resolveProjectPackageDir = (specifier) => resolve23(process.cwd(), "node_modules", ...specifier.split("/")), copyPackageToBuild = (specifier, outdir, seen) => {
|
|
177389
177927
|
if (seen.has(specifier))
|
|
177390
177928
|
return;
|
|
177391
177929
|
const srcDir = resolveProjectPackageDir(specifier);
|
|
@@ -177394,12 +177932,12 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177394
177932
|
return;
|
|
177395
177933
|
seen.add(specifier);
|
|
177396
177934
|
const destDir = join32(outdir, "node_modules", ...specifier.split("/"));
|
|
177397
|
-
|
|
177935
|
+
rmSync7(destDir, { force: true, recursive: true });
|
|
177398
177936
|
cpSync(srcDir, destDir, {
|
|
177399
177937
|
force: true,
|
|
177400
177938
|
recursive: true,
|
|
177401
177939
|
filter(source) {
|
|
177402
|
-
const rel =
|
|
177940
|
+
const rel = relative12(srcDir, source);
|
|
177403
177941
|
const [firstSegment] = rel.split(/[\\/]/);
|
|
177404
177942
|
return firstSegment !== "node_modules" && firstSegment !== ".git";
|
|
177405
177943
|
}
|
|
@@ -177415,8 +177953,8 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177415
177953
|
}, copyAngularRuntimePackages = (buildConfig, outdir) => {
|
|
177416
177954
|
if (!buildConfig.angularDirectory)
|
|
177417
177955
|
return;
|
|
177418
|
-
const angularScopeDir =
|
|
177419
|
-
const angularPackages =
|
|
177956
|
+
const angularScopeDir = resolve23(process.cwd(), "node_modules", "@angular");
|
|
177957
|
+
const angularPackages = existsSync38(angularScopeDir) ? readdirSync7(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
|
|
177420
177958
|
const roots = new Set([...angularPackages, "rxjs", "tslib", "typescript"]);
|
|
177421
177959
|
const seen = new Set;
|
|
177422
177960
|
for (const specifier of roots) {
|
|
@@ -177435,7 +177973,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177435
177973
|
copyChunkReferencedPackages(outdir, seen);
|
|
177436
177974
|
}, collectRuntimePackageSpecifiers = (distDir) => {
|
|
177437
177975
|
const nodeModulesDir = join32(distDir, "node_modules");
|
|
177438
|
-
if (!
|
|
177976
|
+
if (!existsSync38(nodeModulesDir))
|
|
177439
177977
|
return [];
|
|
177440
177978
|
const specifiers = [];
|
|
177441
177979
|
for (const entry of readdirSync7(nodeModulesDir, { withFileTypes: true })) {
|
|
@@ -177456,7 +177994,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177456
177994
|
}
|
|
177457
177995
|
return specifiers.sort((firstSpecifier, secondSpecifier) => secondSpecifier.length - firstSpecifier.length);
|
|
177458
177996
|
}, ensureRelativeModuleSpecifier = (fromFile, toFile) => {
|
|
177459
|
-
const rel =
|
|
177997
|
+
const rel = relative12(dirname17(fromFile), toFile).replace(/\\/g, "/");
|
|
177460
177998
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
177461
177999
|
}, pickExportEntry = (value) => {
|
|
177462
178000
|
if (typeof value === "string")
|
|
@@ -177476,11 +178014,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177476
178014
|
const packageDir = join32(distDir, "node_modules", ...packageSpecifier.split("/"));
|
|
177477
178015
|
const subpath = specifier.slice(packageSpecifier.length);
|
|
177478
178016
|
const subPackageDir = subpath ? join32(packageDir, ...subpath.slice(1).split("/")) : null;
|
|
177479
|
-
const resolvedPackageDir = subPackageDir &&
|
|
178017
|
+
const resolvedPackageDir = subPackageDir && existsSync38(join32(subPackageDir, "package.json")) ? subPackageDir : packageDir;
|
|
177480
178018
|
const packageJsonPath = join32(resolvedPackageDir, "package.json");
|
|
177481
|
-
if (!
|
|
178019
|
+
if (!existsSync38(packageJsonPath))
|
|
177482
178020
|
return null;
|
|
177483
|
-
const pkg = JSON.parse(
|
|
178021
|
+
const pkg = JSON.parse(readFileSync35(packageJsonPath, "utf-8"));
|
|
177484
178022
|
const exportKey = resolvedPackageDir !== subPackageDir && subpath ? `.${subpath}` : ".";
|
|
177485
178023
|
const rootExport = pkg.exports?.[exportKey];
|
|
177486
178024
|
const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
|
|
@@ -177501,12 +178039,12 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177501
178039
|
];
|
|
177502
178040
|
return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
|
|
177503
178041
|
}, findContainingRuntimePackageDir = (filePath) => {
|
|
177504
|
-
let dir =
|
|
177505
|
-
while (dir !==
|
|
177506
|
-
if (isNodeModulesPath(dir) &&
|
|
178042
|
+
let dir = dirname17(filePath);
|
|
178043
|
+
while (dir !== dirname17(dir)) {
|
|
178044
|
+
if (isNodeModulesPath(dir) && existsSync38(join32(dir, "package.json"))) {
|
|
177507
178045
|
return dir;
|
|
177508
178046
|
}
|
|
177509
|
-
dir =
|
|
178047
|
+
dir = dirname17(dir);
|
|
177510
178048
|
}
|
|
177511
178049
|
return null;
|
|
177512
178050
|
}, resolvePackageImportEntryFile = (fromFile, specifier) => {
|
|
@@ -177521,11 +178059,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177521
178059
|
return null;
|
|
177522
178060
|
return join32(packageDir, entry);
|
|
177523
178061
|
}, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), toTopLevelPackage = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/"), FRAMEWORK_PACKAGE_NAME = "@absolutejs/absolute", copyChunkReferencedPackages = (distDir, seen) => {
|
|
177524
|
-
const distRoot =
|
|
178062
|
+
const distRoot = resolve23(distDir);
|
|
177525
178063
|
for (const filePath of collectRuntimeRewriteRoots(distDir)) {
|
|
177526
|
-
if (
|
|
178064
|
+
if (resolve23(dirname17(filePath)) === distRoot)
|
|
177527
178065
|
continue;
|
|
177528
|
-
const source =
|
|
178066
|
+
const source = readFileSync35(filePath, "utf-8");
|
|
177529
178067
|
for (const match of source.matchAll(MODULE_SPECIFIER_RE)) {
|
|
177530
178068
|
const [, , , specifier] = match;
|
|
177531
178069
|
if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("node:") || specifier.startsWith("bun:")) {
|
|
@@ -177555,11 +178093,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177555
178093
|
if (!filePath || seen.has(filePath))
|
|
177556
178094
|
continue;
|
|
177557
178095
|
seen.add(filePath);
|
|
177558
|
-
const source =
|
|
178096
|
+
const source = readFileSync35(filePath, "utf-8");
|
|
177559
178097
|
const { masked, restore } = maskLiterals(source);
|
|
177560
178098
|
const rewrittenMasked = masked.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
|
|
177561
178099
|
if (typeof specifier === "string" && specifier.startsWith(".")) {
|
|
177562
|
-
enqueue(resolveRuntimeJsFile(
|
|
178100
|
+
enqueue(resolveRuntimeJsFile(resolve23(dirname17(filePath), specifier)));
|
|
177563
178101
|
return match;
|
|
177564
178102
|
}
|
|
177565
178103
|
const packageImportTarget = resolveRuntimeJsFile(resolvePackageImportEntryFile(filePath, specifier) ?? "");
|
|
@@ -177575,7 +178113,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177575
178113
|
});
|
|
177576
178114
|
const rewritten = restore(rewrittenMasked);
|
|
177577
178115
|
if (rewritten !== source) {
|
|
177578
|
-
|
|
178116
|
+
writeFileSync21(filePath, rewritten);
|
|
177579
178117
|
}
|
|
177580
178118
|
}
|
|
177581
178119
|
}, generateEntrypoint = (distDir, serverEntry, prerenderMap, version2, buildConfig) => {
|
|
@@ -177588,12 +178126,12 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177588
178126
|
"_compile_entrypoint.ts"
|
|
177589
178127
|
]);
|
|
177590
178128
|
const embeddedFiles = allFiles.filter((file) => {
|
|
177591
|
-
const rel =
|
|
178129
|
+
const rel = relative12(distDir, file);
|
|
177592
178130
|
if (embeddedSkip.has(rel))
|
|
177593
178131
|
return false;
|
|
177594
178132
|
return true;
|
|
177595
178133
|
});
|
|
177596
|
-
const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(
|
|
178134
|
+
const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(relative12(distDir, file), assetSkip));
|
|
177597
178135
|
const imports = [];
|
|
177598
178136
|
const nativeImports = [];
|
|
177599
178137
|
const nativeMappings = [];
|
|
@@ -177603,19 +178141,19 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177603
178141
|
const nativeAssets = resolveCompileNativeAssets(buildConfig);
|
|
177604
178142
|
nativeAssets.forEach((asset, idx) => {
|
|
177605
178143
|
const varName = `__native${idx}`;
|
|
177606
|
-
const importSpecifier = asset.import.startsWith(".") ?
|
|
178144
|
+
const importSpecifier = asset.import.startsWith(".") ? resolve23(process.cwd(), asset.import) : asset.import;
|
|
177607
178145
|
nativeImports.push(`import ${varName} from ${JSON.stringify(importSpecifier)} with { type: "file" };`);
|
|
177608
178146
|
nativeMappings.push(` [${JSON.stringify(asset.env)}, resolveNativeAssetPath(${varName})],`);
|
|
177609
178147
|
});
|
|
177610
178148
|
embeddedFiles.forEach((filePath, idx) => {
|
|
177611
|
-
const rel =
|
|
178149
|
+
const rel = relative12(distDir, filePath).replace(/\\/g, "/");
|
|
177612
178150
|
const varName = `__a${idx}`;
|
|
177613
178151
|
embeddedVarMap.set(rel, varName);
|
|
177614
178152
|
imports.push(`import ${varName} from "./${rel}" with { type: "file" };`);
|
|
177615
178153
|
embeddedMappings.push(` ["${rel}", ${varName}],`);
|
|
177616
178154
|
});
|
|
177617
178155
|
clientFiles.forEach((filePath) => {
|
|
177618
|
-
const rel =
|
|
178156
|
+
const rel = relative12(distDir, filePath).replace(/\\/g, "/");
|
|
177619
178157
|
const varName = embeddedVarMap.get(rel);
|
|
177620
178158
|
if (!varName)
|
|
177621
178159
|
return;
|
|
@@ -177629,7 +178167,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
177629
178167
|
const pageVarMap = new Map;
|
|
177630
178168
|
const prerenderEntries = Array.from(prerenderMap.entries());
|
|
177631
178169
|
prerenderEntries.forEach(([route, filePath]) => {
|
|
177632
|
-
const rel =
|
|
178170
|
+
const rel = relative12(distDir, filePath).replace(/\\/g, "/");
|
|
177633
178171
|
const varName = embeddedVarMap.get(rel);
|
|
177634
178172
|
if (varName)
|
|
177635
178173
|
pageVarMap.set(route, varName);
|
|
@@ -177662,7 +178200,7 @@ import { websocket as elysiaWebsocket } from "elysia/ws";
|
|
|
177662
178200
|
const SERVER_MODULE = (runtimeDir: string) => import(pathToFileURL(join(runtimeDir, ${JSON.stringify(serverBundleName)})).href);
|
|
177663
178201
|
const RUNTIME_BUILD_ID = ${JSON.stringify(runtimeBuildId)};
|
|
177664
178202
|
const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
|
|
177665
|
-
const ORIGINAL_BUILD_DIR = ${JSON.stringify(
|
|
178203
|
+
const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve23(distDir))};
|
|
177666
178204
|
const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
|
|
177667
178205
|
|
|
177668
178206
|
const resolveNativeAssetPath = (assetPath: string) => {
|
|
@@ -178094,16 +178632,16 @@ console.log(\`
|
|
|
178094
178632
|
}),
|
|
178095
178633
|
...collectUserServerExternals(buildConfig)
|
|
178096
178634
|
], compile = async (serverEntry, outdir, outfile, configPath2) => {
|
|
178097
|
-
const resolvedOutdir =
|
|
178635
|
+
const resolvedOutdir = resolve23(outdir ?? "dist");
|
|
178098
178636
|
await withBuildDirectoryLock(resolvedOutdir, () => compileUnlocked(serverEntry, resolvedOutdir, outfile, configPath2));
|
|
178099
178637
|
}, compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath2) => {
|
|
178100
178638
|
const prerenderPort = Number(env5.COMPILE_PORT) || Number(env5.PORT) || findFreePort();
|
|
178101
178639
|
killStaleProcesses(prerenderPort);
|
|
178102
178640
|
const entryName = basename7(serverEntry).replace(/\.[^.]+$/, "");
|
|
178103
|
-
const resolvedOutfile =
|
|
178641
|
+
const resolvedOutfile = resolve23(outfile ?? "compiled-server");
|
|
178104
178642
|
const absoluteVersion = resolvePackageVersion3([
|
|
178105
|
-
|
|
178106
|
-
|
|
178643
|
+
resolve23(import.meta.dir, "..", "..", "..", "package.json"),
|
|
178644
|
+
resolve23(import.meta.dir, "..", "..", "package.json")
|
|
178107
178645
|
]);
|
|
178108
178646
|
compileBanner(absoluteVersion);
|
|
178109
178647
|
const totalStart = performance.now();
|
|
@@ -178114,8 +178652,8 @@ console.log(\`
|
|
|
178114
178652
|
buildConfig.mode = "production";
|
|
178115
178653
|
try {
|
|
178116
178654
|
const build2 = await resolveBuildModule3([
|
|
178117
|
-
|
|
178118
|
-
|
|
178655
|
+
resolve23(import.meta.dir, "..", "..", "core", "build"),
|
|
178656
|
+
resolve23(import.meta.dir, "..", "build")
|
|
178119
178657
|
]);
|
|
178120
178658
|
if (!build2)
|
|
178121
178659
|
throw new Error("Could not locate build module");
|
|
@@ -178137,10 +178675,10 @@ console.log(\`
|
|
|
178137
178675
|
buildConfig.htmxDirectory
|
|
178138
178676
|
].filter((dir) => Boolean(dir));
|
|
178139
178677
|
const islandRegistrySpec = buildConfig.islands?.registry;
|
|
178140
|
-
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(
|
|
178678
|
+
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve23(islandRegistrySpec))) : undefined;
|
|
178141
178679
|
const serverBundle = await Bun.build({
|
|
178142
178680
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
178143
|
-
entrypoints: [
|
|
178681
|
+
entrypoints: [resolve23(serverEntry)],
|
|
178144
178682
|
external: resolveServerBundleExternals(buildConfig),
|
|
178145
178683
|
outdir: resolvedOutdir,
|
|
178146
178684
|
plugins: [
|
|
@@ -178163,13 +178701,13 @@ console.log(\`
|
|
|
178163
178701
|
console.error(cliTag4("\x1B[31m", "Server bundle failed."));
|
|
178164
178702
|
process.exit(1);
|
|
178165
178703
|
}
|
|
178166
|
-
const outputPath =
|
|
178167
|
-
if (!
|
|
178704
|
+
const outputPath = resolve23(resolvedOutdir, `${entryName}.js`);
|
|
178705
|
+
if (!existsSync38(outputPath)) {
|
|
178168
178706
|
console.error(cliTag4("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
178169
178707
|
process.exit(1);
|
|
178170
178708
|
}
|
|
178171
|
-
if (
|
|
178172
|
-
const vendorDir =
|
|
178709
|
+
if (existsSync38(resolve23(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
178710
|
+
const vendorDir = resolve23(resolvedOutdir, "angular", "vendor", "server");
|
|
178173
178711
|
const vendorEntries = readdirSync7(vendorDir).filter((fileName) => fileName.endsWith(".js"));
|
|
178174
178712
|
const angularServerVendorPaths = {};
|
|
178175
178713
|
for (const file of vendorEntries) {
|
|
@@ -178178,7 +178716,7 @@ console.log(\`
|
|
|
178178
178716
|
if (scope !== "angular" || rest.length === 0)
|
|
178179
178717
|
continue;
|
|
178180
178718
|
const specifier = `@angular/${rest.join("/")}`;
|
|
178181
|
-
const relPath =
|
|
178719
|
+
const relPath = relative12(dirname17(outputPath), resolve23(vendorDir, file));
|
|
178182
178720
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
178183
178721
|
}
|
|
178184
178722
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -178190,7 +178728,7 @@ console.log(\`
|
|
|
178190
178728
|
copyServerRuntimeAssetReferences(resolvedOutdir);
|
|
178191
178729
|
const prerenderStart = performance.now();
|
|
178192
178730
|
process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
|
|
178193
|
-
|
|
178731
|
+
rmSync7(join32(resolvedOutdir, "_prerendered"), {
|
|
178194
178732
|
force: true,
|
|
178195
178733
|
recursive: true
|
|
178196
178734
|
});
|
|
@@ -178213,7 +178751,7 @@ console.log(\`
|
|
|
178213
178751
|
const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
|
|
178214
178752
|
const entrypointPath = join32(resolvedOutdir, "_compile_entrypoint.ts");
|
|
178215
178753
|
await Bun.write(entrypointPath, entrypointCode);
|
|
178216
|
-
|
|
178754
|
+
mkdirSync18(dirname17(resolvedOutfile), { recursive: true });
|
|
178217
178755
|
const result = await Bun.build({
|
|
178218
178756
|
compile: { outfile: resolvedOutfile },
|
|
178219
178757
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
@@ -178311,11 +178849,11 @@ var exports_typecheck = {};
|
|
|
178311
178849
|
__export(exports_typecheck, {
|
|
178312
178850
|
typecheck: () => typecheck
|
|
178313
178851
|
});
|
|
178314
|
-
import { resolve as
|
|
178315
|
-
import { existsSync as
|
|
178852
|
+
import { resolve as resolve24, join as join33 } from "path";
|
|
178853
|
+
import { existsSync as existsSync39, readFileSync as readFileSync36 } from "fs";
|
|
178316
178854
|
import { mkdir as mkdir2, writeFile } from "fs/promises";
|
|
178317
|
-
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) =>
|
|
178318
|
-
if (!
|
|
178855
|
+
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) => resolve24(configPath2 ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts"), getTypecheckTargets = async (configPath2) => {
|
|
178856
|
+
if (!existsSync39(resolveConfigPath(configPath2))) {
|
|
178319
178857
|
const defaultService = {};
|
|
178320
178858
|
return [defaultService];
|
|
178321
178859
|
}
|
|
@@ -178336,8 +178874,8 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
|
|
|
178336
178874
|
const exitCode = await proc.exited;
|
|
178337
178875
|
return { exitCode, name, output: (stdout + stderr).trim() };
|
|
178338
178876
|
}, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
|
|
178339
|
-
const local =
|
|
178340
|
-
return
|
|
178877
|
+
const local = resolve24("node_modules", ".bin", name);
|
|
178878
|
+
return existsSync39(local) ? local : null;
|
|
178341
178879
|
}, ANSI_COLOR_REGEX, ANSI_PURPLE_REGEX, ANSI_CYAN_REGEX, ANSI_TOKEN_END_REGEX, stripAnsi3 = (str) => str.replace(ANSI_COLOR_REGEX, ""), formatSvelteOutput = (output) => {
|
|
178342
178880
|
const cwd = `${process.cwd()}/`;
|
|
178343
178881
|
const summaryMatch = stripAnsi3(output).match(/svelte-check found (\d+) error/);
|
|
@@ -178384,15 +178922,15 @@ Found ${errorCount} error${suffix}.`;
|
|
|
178384
178922
|
return formatted;
|
|
178385
178923
|
}, ABSOLUTE_INTERNAL_EXCLUDES, resolveAbsoluteTypeFile = (fileName) => {
|
|
178386
178924
|
const candidates = [
|
|
178387
|
-
|
|
178388
|
-
|
|
178389
|
-
|
|
178390
|
-
|
|
178925
|
+
resolve24("node_modules/@absolutejs/absolute/dist/types", fileName),
|
|
178926
|
+
resolve24(import.meta.dir, "../types", fileName),
|
|
178927
|
+
resolve24(import.meta.dir, "../../types", fileName),
|
|
178928
|
+
resolve24(import.meta.dir, "../../../types", fileName)
|
|
178391
178929
|
];
|
|
178392
|
-
return candidates.find((candidate) =>
|
|
178930
|
+
return candidates.find((candidate) => existsSync39(candidate)) ?? candidates[0];
|
|
178393
178931
|
}, ABSOLUTE_TYPECHECK_FILES, readProjectTsconfig = () => {
|
|
178394
178932
|
try {
|
|
178395
|
-
return JSON.parse(
|
|
178933
|
+
return JSON.parse(readFileSync36(resolve24("tsconfig.json"), "utf-8"));
|
|
178396
178934
|
} catch {
|
|
178397
178935
|
return {};
|
|
178398
178936
|
}
|
|
@@ -178426,13 +178964,13 @@ Found ${errorCount} error${suffix}.`;
|
|
|
178426
178964
|
rootDir: ".."
|
|
178427
178965
|
},
|
|
178428
178966
|
exclude: getProjectTypecheckExcludes(),
|
|
178429
|
-
extends:
|
|
178967
|
+
extends: resolve24("tsconfig.json"),
|
|
178430
178968
|
include: getProjectTypecheckIncludes()
|
|
178431
178969
|
}, null, "\t")).then(() => run("vue-tsc", [
|
|
178432
178970
|
vueTscBin,
|
|
178433
178971
|
"--noEmit",
|
|
178434
178972
|
"--project",
|
|
178435
|
-
|
|
178973
|
+
resolve24(vueTsconfigPath),
|
|
178436
178974
|
"--incremental",
|
|
178437
178975
|
"--tsBuildInfoFile",
|
|
178438
178976
|
join33(cacheDir, "vue-tsc.tsbuildinfo"),
|
|
@@ -178454,10 +178992,10 @@ Found ${errorCount} error${suffix}.`;
|
|
|
178454
178992
|
rootDir: ".."
|
|
178455
178993
|
},
|
|
178456
178994
|
exclude: ABSOLUTE_INTERNAL_EXCLUDES.map(toGeneratedConfigPath),
|
|
178457
|
-
extends:
|
|
178995
|
+
extends: resolve24("tsconfig.json"),
|
|
178458
178996
|
include: [`../${angularDir}/**/*`]
|
|
178459
178997
|
}, null, "\t"));
|
|
178460
|
-
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(
|
|
178998
|
+
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve24(angularTsconfigPath))}`);
|
|
178461
178999
|
}, buildTscCheck = (cacheDir) => {
|
|
178462
179000
|
const tscBin = findBin("tsc");
|
|
178463
179001
|
if (!tscBin) {
|
|
@@ -178470,13 +179008,13 @@ Found ${errorCount} error${suffix}.`;
|
|
|
178470
179008
|
rootDir: ".."
|
|
178471
179009
|
},
|
|
178472
179010
|
exclude: getProjectTypecheckExcludes(),
|
|
178473
|
-
extends:
|
|
179011
|
+
extends: resolve24("tsconfig.json"),
|
|
178474
179012
|
include: getProjectTypecheckIncludes()
|
|
178475
179013
|
}, null, "\t")).then(() => run("tsc", [
|
|
178476
179014
|
tscBin,
|
|
178477
179015
|
"--noEmit",
|
|
178478
179016
|
"--project",
|
|
178479
|
-
|
|
179017
|
+
resolve24(tscConfigPath),
|
|
178480
179018
|
"--incremental",
|
|
178481
179019
|
"--tsBuildInfoFile",
|
|
178482
179020
|
join33(cacheDir, "tsc.tsbuildinfo"),
|
|
@@ -178490,14 +179028,14 @@ Found ${errorCount} error${suffix}.`;
|
|
|
178490
179028
|
}
|
|
178491
179029
|
const svelteTsconfigPath = join33(cacheDir, "tsconfig.svelte-check.json");
|
|
178492
179030
|
await writeFile(svelteTsconfigPath, JSON.stringify({
|
|
178493
|
-
extends:
|
|
179031
|
+
extends: resolve24("tsconfig.json"),
|
|
178494
179032
|
files: ABSOLUTE_TYPECHECK_FILES,
|
|
178495
179033
|
include: [`../${svelteDir}/**/*`]
|
|
178496
179034
|
}, null, "\t"));
|
|
178497
179035
|
return run("svelte-check", [
|
|
178498
179036
|
svelteBin,
|
|
178499
179037
|
"--tsconfig",
|
|
178500
|
-
|
|
179038
|
+
resolve24(svelteTsconfigPath),
|
|
178501
179039
|
"--threshold",
|
|
178502
179040
|
"error",
|
|
178503
179041
|
"--compiler-warnings",
|
|
@@ -178691,11 +179229,11 @@ var DEFAULT_RELAY_PORT = 8787, DEFAULT_REQUEST_TIMEOUT_MS = 30000, headersToObje
|
|
|
178691
179229
|
url: url.pathname + url.search,
|
|
178692
179230
|
...bodyBytes && bodyBytes.length > 0 ? { bodyBase64: Buffer.from(bodyBytes).toString("base64") } : {}
|
|
178693
179231
|
};
|
|
178694
|
-
const responsePromise = new Promise((
|
|
178695
|
-
pending.set(id,
|
|
179232
|
+
const responsePromise = new Promise((resolve25) => {
|
|
179233
|
+
pending.set(id, resolve25);
|
|
178696
179234
|
});
|
|
178697
179235
|
client.send(encodeTunnelMessage(message));
|
|
178698
|
-
const timeout = new Promise((
|
|
179236
|
+
const timeout = new Promise((resolve25) => setTimeout(() => resolve25({ id, message: "timeout", type: "error" }), requestTimeoutMs));
|
|
178699
179237
|
const result = await Promise.race([responsePromise, timeout]);
|
|
178700
179238
|
pending.delete(id);
|
|
178701
179239
|
if (result.type === "error") {
|
|
@@ -179990,377 +180528,8 @@ var dev = async (serverEntry, configPath2) => {
|
|
|
179990
180528
|
await monitorServer();
|
|
179991
180529
|
};
|
|
179992
180530
|
|
|
179993
|
-
// src/cli/
|
|
179994
|
-
|
|
179995
|
-
import {
|
|
179996
|
-
existsSync as existsSync6,
|
|
179997
|
-
mkdirSync as mkdirSync5,
|
|
179998
|
-
readFileSync as readFileSync8,
|
|
179999
|
-
renameSync,
|
|
180000
|
-
rmSync as rmSync3,
|
|
180001
|
-
writeFileSync as writeFileSync5
|
|
180002
|
-
} from "fs";
|
|
180003
|
-
import { dirname as dirname3, resolve as resolve4 } from "path";
|
|
180004
|
-
var DEFAULT_CACHE_LOCATION = ".absolutejs/eslint-cache";
|
|
180005
|
-
var CACHE_CONTRACT_VERSION = "1";
|
|
180006
|
-
var CACHE_FINGERPRINT_SUFFIX = ".fingerprint";
|
|
180007
|
-
var flagValue = (args, flag) => {
|
|
180008
|
-
const assignment = args.find((arg) => arg.startsWith(`${flag}=`));
|
|
180009
|
-
if (assignment)
|
|
180010
|
-
return assignment.slice(flag.length + 1);
|
|
180011
|
-
const index = args.indexOf(flag);
|
|
180012
|
-
return index < 0 ? undefined : args[index + 1];
|
|
180013
|
-
};
|
|
180014
|
-
var getCacheLocation = (args) => flagValue(args, "--cache-location")?.trim() || process.env.ABSOLUTE_ESLINT_CACHE?.trim() || DEFAULT_CACHE_LOCATION;
|
|
180015
|
-
var CONFIG_CANDIDATES = [
|
|
180016
|
-
"eslint.config.js",
|
|
180017
|
-
"eslint.config.mjs",
|
|
180018
|
-
"eslint.config.cjs",
|
|
180019
|
-
"eslint.config.ts",
|
|
180020
|
-
"eslint.config.mts",
|
|
180021
|
-
"eslint.config.cts"
|
|
180022
|
-
];
|
|
180023
|
-
var FLAG_VALUE_FLAGS = new Set([
|
|
180024
|
-
"-c",
|
|
180025
|
-
"--config",
|
|
180026
|
-
"--cache-location",
|
|
180027
|
-
"--cache-strategy",
|
|
180028
|
-
"--ignore-path",
|
|
180029
|
-
"--ignore-pattern",
|
|
180030
|
-
"--rule",
|
|
180031
|
-
"--rulesdir",
|
|
180032
|
-
"--ext",
|
|
180033
|
-
"-f",
|
|
180034
|
-
"--format",
|
|
180035
|
-
"--max-warnings",
|
|
180036
|
-
"--parser",
|
|
180037
|
-
"--parser-options",
|
|
180038
|
-
"--plugin",
|
|
180039
|
-
"--global",
|
|
180040
|
-
"--env",
|
|
180041
|
-
"--report-unused-disable-directives-severity",
|
|
180042
|
-
"--resolve-plugins-relative-to",
|
|
180043
|
-
"-o",
|
|
180044
|
-
"--output-file",
|
|
180045
|
-
"--flag",
|
|
180046
|
-
"--inspect-config",
|
|
180047
|
-
"--stats",
|
|
180048
|
-
"--concurrency"
|
|
180049
|
-
]);
|
|
180050
|
-
var hasUserPositional = (args) => {
|
|
180051
|
-
for (let index = 0;index < args.length; index++) {
|
|
180052
|
-
const arg = args[index];
|
|
180053
|
-
if (arg === undefined)
|
|
180054
|
-
continue;
|
|
180055
|
-
if (arg.startsWith("-")) {
|
|
180056
|
-
if (arg.includes("="))
|
|
180057
|
-
continue;
|
|
180058
|
-
if (FLAG_VALUE_FLAGS.has(arg))
|
|
180059
|
-
index++;
|
|
180060
|
-
continue;
|
|
180061
|
-
}
|
|
180062
|
-
return true;
|
|
180063
|
-
}
|
|
180064
|
-
return false;
|
|
180065
|
-
};
|
|
180066
|
-
var findConfigPath = (cwd = process.cwd()) => {
|
|
180067
|
-
for (const name of CONFIG_CANDIDATES) {
|
|
180068
|
-
const candidate = resolve4(cwd, name);
|
|
180069
|
-
if (existsSync6(candidate))
|
|
180070
|
-
return candidate;
|
|
180071
|
-
}
|
|
180072
|
-
return null;
|
|
180073
|
-
};
|
|
180074
|
-
var fingerprintLocation = (cacheLocation, cwd) => {
|
|
180075
|
-
const absolute = resolve4(cwd, cacheLocation);
|
|
180076
|
-
return /[\\/]$/.test(cacheLocation) ? resolve4(absolute, CACHE_FINGERPRINT_SUFFIX.slice(1)) : `${absolute}${CACHE_FINGERPRINT_SUFFIX}`;
|
|
180077
|
-
};
|
|
180078
|
-
var addFileToFingerprint = (hash, path, label) => {
|
|
180079
|
-
if (!existsSync6(path))
|
|
180080
|
-
return;
|
|
180081
|
-
hash.update(label);
|
|
180082
|
-
hash.update("\x00");
|
|
180083
|
-
hash.update(readFileSync8(path));
|
|
180084
|
-
hash.update("\x00");
|
|
180085
|
-
};
|
|
180086
|
-
var packageNameFor = (specifier) => {
|
|
180087
|
-
if (specifier.startsWith("@"))
|
|
180088
|
-
return specifier.split("/").slice(0, 2).join("/");
|
|
180089
|
-
const [name = specifier] = specifier.split("/");
|
|
180090
|
-
return name;
|
|
180091
|
-
};
|
|
180092
|
-
var configPackageNames = (configPath2) => {
|
|
180093
|
-
if (!configPath2)
|
|
180094
|
-
return [];
|
|
180095
|
-
const source = readFileSync8(configPath2, "utf-8");
|
|
180096
|
-
const names = new Set;
|
|
180097
|
-
for (const match of source.matchAll(/(?:from\s+|import\s*(?:\(\s*)?|require\s*\(\s*)(['"])([^'".][^'"]*)\1/g)) {
|
|
180098
|
-
const [, , specifier] = match;
|
|
180099
|
-
if (specifier)
|
|
180100
|
-
names.add(packageNameFor(specifier));
|
|
180101
|
-
}
|
|
180102
|
-
return [...names];
|
|
180103
|
-
};
|
|
180104
|
-
var manifestDependencyNames = (manifest) => {
|
|
180105
|
-
if (manifest === null || typeof manifest !== "object")
|
|
180106
|
-
return [];
|
|
180107
|
-
return Object.entries(manifest).flatMap(([key, value]) => {
|
|
180108
|
-
if (key !== "dependencies" && key !== "devDependencies")
|
|
180109
|
-
return [];
|
|
180110
|
-
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
180111
|
-
return [];
|
|
180112
|
-
return Object.keys(value);
|
|
180113
|
-
});
|
|
180114
|
-
};
|
|
180115
|
-
var lintDependencyNames = (cwd, configPath2) => {
|
|
180116
|
-
const manifestPath = resolve4(cwd, "package.json");
|
|
180117
|
-
if (!existsSync6(manifestPath))
|
|
180118
|
-
return configPackageNames(configPath2);
|
|
180119
|
-
try {
|
|
180120
|
-
const manifest = JSON.parse(readFileSync8(manifestPath, "utf-8"));
|
|
180121
|
-
const lintPackages = manifestDependencyNames(manifest).filter((name) => /eslint|typescript/.test(name));
|
|
180122
|
-
return [
|
|
180123
|
-
...new Set([...lintPackages, ...configPackageNames(configPath2)])
|
|
180124
|
-
];
|
|
180125
|
-
} catch {
|
|
180126
|
-
return configPackageNames(configPath2);
|
|
180127
|
-
}
|
|
180128
|
-
};
|
|
180129
|
-
var findInstalledManifest = (cwd, dependency) => {
|
|
180130
|
-
let directory = cwd;
|
|
180131
|
-
while (true) {
|
|
180132
|
-
const candidate = resolve4(directory, "node_modules", dependency, "package.json");
|
|
180133
|
-
if (existsSync6(candidate))
|
|
180134
|
-
return candidate;
|
|
180135
|
-
const parent = dirname3(directory);
|
|
180136
|
-
if (parent === directory)
|
|
180137
|
-
return null;
|
|
180138
|
-
directory = parent;
|
|
180139
|
-
}
|
|
180140
|
-
};
|
|
180141
|
-
var createEslintCacheFingerprint = (cwd = process.cwd()) => {
|
|
180142
|
-
const hash = createHash("sha256");
|
|
180143
|
-
hash.update(`absolute-eslint-cache:${CACHE_CONTRACT_VERSION}\x00`);
|
|
180144
|
-
const configPath2 = findConfigPath(cwd);
|
|
180145
|
-
if (configPath2)
|
|
180146
|
-
addFileToFingerprint(hash, configPath2, configPath2);
|
|
180147
|
-
for (const dependency of lintDependencyNames(cwd, configPath2).sort()) {
|
|
180148
|
-
const manifestPath = findInstalledManifest(cwd, dependency);
|
|
180149
|
-
if (manifestPath)
|
|
180150
|
-
addFileToFingerprint(hash, manifestPath, dependency);
|
|
180151
|
-
}
|
|
180152
|
-
return hash.digest("hex");
|
|
180153
|
-
};
|
|
180154
|
-
var writeFingerprint = (path, fingerprint) => {
|
|
180155
|
-
mkdirSync5(dirname3(path), { recursive: true });
|
|
180156
|
-
const temporary = `${path}.${process.pid}.tmp`;
|
|
180157
|
-
writeFileSync5(temporary, `${fingerprint}
|
|
180158
|
-
`);
|
|
180159
|
-
renameSync(temporary, path);
|
|
180160
|
-
};
|
|
180161
|
-
var prepareEslintCache = (options) => {
|
|
180162
|
-
const cwd = options.cwd ?? process.cwd();
|
|
180163
|
-
const cachePath = resolve4(cwd, options.cacheLocation);
|
|
180164
|
-
const metadataPath = fingerprintLocation(options.cacheLocation, cwd);
|
|
180165
|
-
const fingerprint = options.fingerprint ?? createEslintCacheFingerprint(cwd);
|
|
180166
|
-
const prior = existsSync6(metadataPath) ? readFileSync8(metadataPath, "utf-8").trim() : null;
|
|
180167
|
-
if (prior === fingerprint)
|
|
180168
|
-
return false;
|
|
180169
|
-
rmSync3(cachePath, { force: true, recursive: true });
|
|
180170
|
-
if (metadataPath !== cachePath)
|
|
180171
|
-
rmSync3(metadataPath, { force: true, recursive: true });
|
|
180172
|
-
writeFingerprint(metadataPath, fingerprint);
|
|
180173
|
-
return true;
|
|
180174
|
-
};
|
|
180175
|
-
var hasKey = (objectLiteralSource, key) => {
|
|
180176
|
-
const pattern = new RegExp(`(^|[\\s,{])${key}\\s*:`, "m");
|
|
180177
|
-
return pattern.test(objectLiteralSource);
|
|
180178
|
-
};
|
|
180179
|
-
var NON_GLOBAL_IGNORE_KEYS = [
|
|
180180
|
-
"files",
|
|
180181
|
-
"rules",
|
|
180182
|
-
"plugins",
|
|
180183
|
-
"languageOptions",
|
|
180184
|
-
"linterOptions",
|
|
180185
|
-
"processor",
|
|
180186
|
-
"settings",
|
|
180187
|
-
"extends"
|
|
180188
|
-
];
|
|
180189
|
-
var isGlobalIgnoresBlock = (block) => {
|
|
180190
|
-
if (!hasKey(block, "ignores"))
|
|
180191
|
-
return false;
|
|
180192
|
-
return !NON_GLOBAL_IGNORE_KEYS.some((key) => hasKey(block, key));
|
|
180193
|
-
};
|
|
180194
|
-
var extractTopLevelObjectLiterals = (source) => {
|
|
180195
|
-
const arrayStart = source.search(/defineConfig\s*\(\s*\[|export\s+default\s*\[/);
|
|
180196
|
-
if (arrayStart === -1)
|
|
180197
|
-
return [];
|
|
180198
|
-
const fromArray = source.slice(arrayStart);
|
|
180199
|
-
const openBracket = fromArray.indexOf("[");
|
|
180200
|
-
if (openBracket === -1)
|
|
180201
|
-
return [];
|
|
180202
|
-
const blocks = [];
|
|
180203
|
-
let depth = 0;
|
|
180204
|
-
let blockStart = -1;
|
|
180205
|
-
let inString = null;
|
|
180206
|
-
let inLineComment = false;
|
|
180207
|
-
let inBlockComment = false;
|
|
180208
|
-
for (let i = openBracket;i < fromArray.length; i++) {
|
|
180209
|
-
const char = fromArray[i];
|
|
180210
|
-
const next = fromArray[i + 1];
|
|
180211
|
-
if (inLineComment) {
|
|
180212
|
-
if (char === `
|
|
180213
|
-
`)
|
|
180214
|
-
inLineComment = false;
|
|
180215
|
-
continue;
|
|
180216
|
-
}
|
|
180217
|
-
if (inBlockComment) {
|
|
180218
|
-
if (char === "*" && next === "/") {
|
|
180219
|
-
inBlockComment = false;
|
|
180220
|
-
i++;
|
|
180221
|
-
}
|
|
180222
|
-
continue;
|
|
180223
|
-
}
|
|
180224
|
-
if (inString) {
|
|
180225
|
-
if (char === "\\") {
|
|
180226
|
-
i++;
|
|
180227
|
-
continue;
|
|
180228
|
-
}
|
|
180229
|
-
if (char === inString)
|
|
180230
|
-
inString = null;
|
|
180231
|
-
continue;
|
|
180232
|
-
}
|
|
180233
|
-
if (char === "/" && next === "/") {
|
|
180234
|
-
inLineComment = true;
|
|
180235
|
-
continue;
|
|
180236
|
-
}
|
|
180237
|
-
if (char === "/" && next === "*") {
|
|
180238
|
-
inBlockComment = true;
|
|
180239
|
-
i++;
|
|
180240
|
-
continue;
|
|
180241
|
-
}
|
|
180242
|
-
if (char === '"' || char === "'" || char === "`") {
|
|
180243
|
-
inString = char;
|
|
180244
|
-
continue;
|
|
180245
|
-
}
|
|
180246
|
-
if (char === "{") {
|
|
180247
|
-
if (depth === 0)
|
|
180248
|
-
blockStart = i;
|
|
180249
|
-
depth++;
|
|
180250
|
-
} else if (char === "}") {
|
|
180251
|
-
depth--;
|
|
180252
|
-
if (depth === 0 && blockStart !== -1) {
|
|
180253
|
-
blocks.push(fromArray.slice(blockStart, i + 1));
|
|
180254
|
-
blockStart = -1;
|
|
180255
|
-
}
|
|
180256
|
-
} else if (char === "]" && depth === 0) {
|
|
180257
|
-
break;
|
|
180258
|
-
}
|
|
180259
|
-
}
|
|
180260
|
-
return blocks;
|
|
180261
|
-
};
|
|
180262
|
-
var checkForMisplacedIgnores = () => {
|
|
180263
|
-
const configPath2 = findConfigPath();
|
|
180264
|
-
if (!configPath2)
|
|
180265
|
-
return;
|
|
180266
|
-
let source;
|
|
180267
|
-
try {
|
|
180268
|
-
source = readFileSync8(configPath2, "utf-8");
|
|
180269
|
-
} catch {
|
|
180270
|
-
return;
|
|
180271
|
-
}
|
|
180272
|
-
const blocks = extractTopLevelObjectLiterals(source);
|
|
180273
|
-
if (blocks.some(isGlobalIgnoresBlock))
|
|
180274
|
-
return;
|
|
180275
|
-
let offenderCount = 0;
|
|
180276
|
-
for (const block of blocks) {
|
|
180277
|
-
if (hasKey(block, "ignores") && hasKey(block, "files")) {
|
|
180278
|
-
offenderCount++;
|
|
180279
|
-
}
|
|
180280
|
-
}
|
|
180281
|
-
if (offenderCount === 0)
|
|
180282
|
-
return;
|
|
180283
|
-
const yellow = "\x1B[33m";
|
|
180284
|
-
const reset = "\x1B[0m";
|
|
180285
|
-
const bold = "\x1B[1m";
|
|
180286
|
-
console.warn(`${yellow}${bold}\u26A0 ESLint flat-config warning${reset}${yellow}: found ${offenderCount} config block(s) where \`ignores\` lives alongside \`files\`. In ESLint v9, \`ignores\` is only a *global* ignore when it's the sole key in its config object \u2014 otherwise it just suppresses that block's own rules and ESLint still walks every other directory (including node_modules), making lint extremely slow.
|
|
180287
|
-
|
|
180288
|
-
Move ignores into a standalone block at the top of your config:
|
|
180289
|
-
|
|
180290
|
-
export default defineConfig([
|
|
180291
|
-
{ ignores: ['node_modules/**', 'dist/**', 'build/**', '.absolutejs/**'] },
|
|
180292
|
-
pluginJs.configs.recommended,
|
|
180293
|
-
...
|
|
180294
|
-
]);
|
|
180295
|
-
|
|
180296
|
-
Detected at: ${configPath2}${reset}`);
|
|
180297
|
-
};
|
|
180298
|
-
var formatDuration = (durationMs) => {
|
|
180299
|
-
if (durationMs < 1000)
|
|
180300
|
-
return `${durationMs}ms`;
|
|
180301
|
-
if (durationMs < 60000)
|
|
180302
|
-
return `${(durationMs / 1000).toFixed(2)}s`;
|
|
180303
|
-
const minutes = Math.floor(durationMs / 60000);
|
|
180304
|
-
const seconds = Math.round(durationMs % 60000 / 1000);
|
|
180305
|
-
return `${minutes}m ${seconds}s`;
|
|
180306
|
-
};
|
|
180307
|
-
var handleClearCache = (cacheLocation, cwd = process.cwd()) => {
|
|
180308
|
-
try {
|
|
180309
|
-
const cachePath = resolve4(cwd, cacheLocation);
|
|
180310
|
-
const metadataPath = fingerprintLocation(cacheLocation, cwd);
|
|
180311
|
-
rmSync3(cachePath, { force: true, recursive: true });
|
|
180312
|
-
rmSync3(metadataPath, { force: true, recursive: true });
|
|
180313
|
-
console.log(`\x1B[32m\u2713\x1B[0m Cleared cache: ${cacheLocation}`);
|
|
180314
|
-
} catch (err) {
|
|
180315
|
-
console.error(`\x1B[31m\u2717\x1B[0m Failed to clear cache at ${cacheLocation}:`, err);
|
|
180316
|
-
process.exit(1);
|
|
180317
|
-
}
|
|
180318
|
-
};
|
|
180319
|
-
var buildEslintCommand = (args, cacheLocation) => {
|
|
180320
|
-
const cacheEnabled = !args.includes("--no-cache");
|
|
180321
|
-
const hasCacheLocation = args.some((arg) => arg === "--cache-location" || arg.startsWith("--cache-location="));
|
|
180322
|
-
const hasCacheStrategy = args.some((arg) => arg === "--cache-strategy" || arg.startsWith("--cache-strategy="));
|
|
180323
|
-
return [
|
|
180324
|
-
"bun",
|
|
180325
|
-
"eslint",
|
|
180326
|
-
...cacheEnabled ? ["--cache"] : [],
|
|
180327
|
-
...cacheEnabled && !hasCacheLocation ? ["--cache-location", cacheLocation] : [],
|
|
180328
|
-
...cacheEnabled && !hasCacheStrategy ? ["--cache-strategy", "content"] : [],
|
|
180329
|
-
...args,
|
|
180330
|
-
...hasUserPositional(args) ? [] : ["."]
|
|
180331
|
-
];
|
|
180332
|
-
};
|
|
180333
|
-
var eslint = async (args) => {
|
|
180334
|
-
const cacheLocation = getCacheLocation(args);
|
|
180335
|
-
if (args.includes("--clear-cache")) {
|
|
180336
|
-
handleClearCache(cacheLocation);
|
|
180337
|
-
return;
|
|
180338
|
-
}
|
|
180339
|
-
if (!existsSync6(resolve4("node_modules", ".bin", "eslint"))) {
|
|
180340
|
-
console.error("\x1B[31m\u2717\x1B[0m ESLint is not installed in this project. Add it (and a flat `eslint.config.*`): bun add -d eslint");
|
|
180341
|
-
process.exit(1);
|
|
180342
|
-
}
|
|
180343
|
-
checkForMisplacedIgnores();
|
|
180344
|
-
const cacheEnabled = !args.includes("--no-cache");
|
|
180345
|
-
if (cacheEnabled)
|
|
180346
|
-
prepareEslintCache({ cacheLocation });
|
|
180347
|
-
const command = buildEslintCommand(args, cacheLocation);
|
|
180348
|
-
const dim = "\x1B[2m";
|
|
180349
|
-
const reset = "\x1B[0m";
|
|
180350
|
-
console.log(cacheEnabled ? `${dim}cache: ${cacheLocation} (content-aware; lint-tool changes invalidate automatically)${reset}` : `${dim}cache: disabled${reset}`);
|
|
180351
|
-
const startedAt = Date.now();
|
|
180352
|
-
const proc = Bun.spawn(command, {
|
|
180353
|
-
stderr: "inherit",
|
|
180354
|
-
stdout: "inherit"
|
|
180355
|
-
});
|
|
180356
|
-
const exitCode = await proc.exited;
|
|
180357
|
-
const elapsed = formatDuration(Date.now() - startedAt);
|
|
180358
|
-
if (exitCode !== 0) {
|
|
180359
|
-
console.log(`${dim}elapsed: ${elapsed}${reset}`);
|
|
180360
|
-
process.exit(exitCode);
|
|
180361
|
-
}
|
|
180362
|
-
console.log(`\x1B[32m\u2713\x1B[0m Passed ${dim}(${elapsed})${reset}`);
|
|
180363
|
-
};
|
|
180531
|
+
// src/cli/index.ts
|
|
180532
|
+
init_eslint();
|
|
180364
180533
|
|
|
180365
180534
|
// src/cli/scripts/info.ts
|
|
180366
180535
|
init_constants();
|
|
@@ -182470,6 +182639,10 @@ if (command === "dev") {
|
|
|
182470
182639
|
} else if (command === "eslint") {
|
|
182471
182640
|
sendTelemetryEvent("cli:command", { command });
|
|
182472
182641
|
await eslint(args);
|
|
182642
|
+
} else if (command === "lint-proof") {
|
|
182643
|
+
sendTelemetryEvent("cli:command", { command });
|
|
182644
|
+
const { runLintProof: runLintProof2 } = await Promise.resolve().then(() => (init_lintProof(), exports_lintProof));
|
|
182645
|
+
process.exitCode = await runLintProof2(args);
|
|
182473
182646
|
} else if (command === "prettier") {
|
|
182474
182647
|
sendTelemetryEvent("cli:command", { command });
|
|
182475
182648
|
await prettier(args);
|
|
@@ -182585,6 +182758,7 @@ if (command === "dev") {
|
|
|
182585
182758
|
console.error(" analyze [--save] [--json] Bundle size breakdown + diff vs a saved baseline");
|
|
182586
182759
|
console.error(" api [--open] [--json] Show the API surface or open the OpenAPI UI (@elysiajs/openapi)");
|
|
182587
182760
|
console.error(" eslint Run ESLint (cached)");
|
|
182761
|
+
console.error(" lint-proof <run|verify> -- <command> Record or verify an exact-source local lint pass");
|
|
182588
182762
|
console.error(" generate <page|api|component> <name> [--framework <fw>] Scaffold a page, API plugin, or component");
|
|
182589
182763
|
console.error(" htmx [version] Self-host htmx \u2014 report or install/upgrade the pinned copy");
|
|
182590
182764
|
console.error(" info Print system info for bug reports");
|