@axis-ds/mcp 1.2.0 → 1.2.1
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/index.js +173 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2313,6 +2313,178 @@ function getBrand(baseDir, name) {
|
|
|
2313
2313
|
};
|
|
2314
2314
|
}
|
|
2315
2315
|
|
|
2316
|
+
// src/tools/tailwind-core.ts
|
|
2317
|
+
import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
|
|
2318
|
+
import { join as join5, resolve as resolve3 } from "path";
|
|
2319
|
+
function hasDependency(pkg, name) {
|
|
2320
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
2321
|
+
const deps = pkg[field];
|
|
2322
|
+
if (typeof deps === "object" && deps !== null && name in deps) {
|
|
2323
|
+
return String(deps[name]);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
return void 0;
|
|
2327
|
+
}
|
|
2328
|
+
function isPlainObject(value) {
|
|
2329
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2330
|
+
}
|
|
2331
|
+
var VERSION = String.raw`v?(\d+)(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
|
|
2332
|
+
function versionParts(token) {
|
|
2333
|
+
const m = new RegExp(`^${VERSION}$`).exec(token);
|
|
2334
|
+
if (!m) return void 0;
|
|
2335
|
+
if (/^v?0\.0\.0-/.test(token)) return void 0;
|
|
2336
|
+
return { major: Number(m[1]), minor: m[2], patch: m[3] };
|
|
2337
|
+
}
|
|
2338
|
+
var isWild = (part) => part === void 0 || /^[xX*]$/.test(part);
|
|
2339
|
+
function comparatorBounds(op, v) {
|
|
2340
|
+
switch (op) {
|
|
2341
|
+
case ">=":
|
|
2342
|
+
return { lower: v.major };
|
|
2343
|
+
case ">":
|
|
2344
|
+
return { lower: isWild(v.minor) ? v.major + 1 : v.major };
|
|
2345
|
+
case "<=":
|
|
2346
|
+
return { upper: v.major };
|
|
2347
|
+
case "<": {
|
|
2348
|
+
const zeroOrWild = (part) => isWild(part) || Number(part) === 0;
|
|
2349
|
+
return { upper: zeroOrWild(v.minor) && zeroOrWild(v.patch) ? v.major - 1 : v.major };
|
|
2350
|
+
}
|
|
2351
|
+
default:
|
|
2352
|
+
return { lower: v.major, upper: v.major };
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
function tailwindMajorBounds(range) {
|
|
2356
|
+
const r = range.trim();
|
|
2357
|
+
if (r === "" || r.includes("||")) return void 0;
|
|
2358
|
+
const simple = new RegExp(`^(?:\\^|~|=)?\\s*(${VERSION})$`).exec(r);
|
|
2359
|
+
if (simple) {
|
|
2360
|
+
const v = versionParts(simple[1]);
|
|
2361
|
+
return v ? { lower: v.major, upper: v.major } : void 0;
|
|
2362
|
+
}
|
|
2363
|
+
const hyphen = new RegExp(`^(${VERSION})\\s+-\\s+(${VERSION})$`).exec(r);
|
|
2364
|
+
if (hyphen) {
|
|
2365
|
+
const tokens2 = r.split(/\s+-\s+/);
|
|
2366
|
+
const a = versionParts(tokens2[0]);
|
|
2367
|
+
const b = versionParts(tokens2[1]);
|
|
2368
|
+
return a && b && a.major <= b.major ? { lower: a.major, upper: b.major } : void 0;
|
|
2369
|
+
}
|
|
2370
|
+
const tokens = r.replace(/(>=|<=|>|<|=)\s+/g, "$1").split(/\s+/);
|
|
2371
|
+
const lowers = [];
|
|
2372
|
+
const uppers = [];
|
|
2373
|
+
for (const t of tokens) {
|
|
2374
|
+
const c = /^(>=|<=|>|<|=)(.+)$/.exec(t);
|
|
2375
|
+
if (!c) return void 0;
|
|
2376
|
+
const v = versionParts(c[2]);
|
|
2377
|
+
if (v === void 0) return void 0;
|
|
2378
|
+
const b = comparatorBounds(c[1], v);
|
|
2379
|
+
if (b.lower !== void 0) lowers.push(b.lower);
|
|
2380
|
+
if (b.upper !== void 0) uppers.push(b.upper);
|
|
2381
|
+
}
|
|
2382
|
+
if (lowers.length === 0) return void 0;
|
|
2383
|
+
const lower = Math.max(...lowers);
|
|
2384
|
+
const upper = uppers.length > 0 ? Math.min(...uppers) : void 0;
|
|
2385
|
+
if (upper !== void 0 && upper < lower) return void 0;
|
|
2386
|
+
return upper !== void 0 ? { lower, upper } : { lower };
|
|
2387
|
+
}
|
|
2388
|
+
function majorWithin(major, bounds) {
|
|
2389
|
+
return major >= bounds.lower && (bounds.upper === void 0 || major <= bounds.upper);
|
|
2390
|
+
}
|
|
2391
|
+
function majorFromVersion(version) {
|
|
2392
|
+
if (typeof version !== "string") return void 0;
|
|
2393
|
+
const v = version.trim();
|
|
2394
|
+
const m = /^v?(\d+)\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]*)?$/.exec(v);
|
|
2395
|
+
if (!m || /^v?0\.0\.0-/.test(v)) return void 0;
|
|
2396
|
+
return Number(m[1]);
|
|
2397
|
+
}
|
|
2398
|
+
function detectTailwind(baseDirInput, pkg) {
|
|
2399
|
+
const baseDir = resolve3(baseDirInput);
|
|
2400
|
+
const installedFile = join5(baseDir, "node_modules", "tailwindcss", "package.json");
|
|
2401
|
+
const declared = pkg ? hasDependency(pkg, "tailwindcss") : void 0;
|
|
2402
|
+
const bounds = declared !== void 0 ? tailwindMajorBounds(declared) : void 0;
|
|
2403
|
+
const declaredMajor = bounds?.lower;
|
|
2404
|
+
try {
|
|
2405
|
+
const installed = JSON.parse(readFileSync6(installedFile, "utf8"));
|
|
2406
|
+
const version = isPlainObject(installed) ? installed.version : void 0;
|
|
2407
|
+
const major = majorFromVersion(version);
|
|
2408
|
+
if (major !== void 0) {
|
|
2409
|
+
const found = { major, source: "installed", value: String(version) };
|
|
2410
|
+
if (declared !== void 0 && bounds !== void 0 && !majorWithin(major, bounds)) {
|
|
2411
|
+
found.mismatch = { declared, declaredMajor: bounds.lower };
|
|
2412
|
+
}
|
|
2413
|
+
return found;
|
|
2414
|
+
}
|
|
2415
|
+
} catch {
|
|
2416
|
+
}
|
|
2417
|
+
if (declared !== void 0) {
|
|
2418
|
+
if (declaredMajor !== void 0) return { major: declaredMajor, source: "declared", value: declared };
|
|
2419
|
+
return { source: "none", value: declared };
|
|
2420
|
+
}
|
|
2421
|
+
return { source: "none" };
|
|
2422
|
+
}
|
|
2423
|
+
var TAILWIND_CONFIG_FILES = [
|
|
2424
|
+
"tailwind.config.ts",
|
|
2425
|
+
"tailwind.config.js",
|
|
2426
|
+
"tailwind.config.mjs",
|
|
2427
|
+
"tailwind.config.cjs"
|
|
2428
|
+
];
|
|
2429
|
+
var TAILWIND_CSS_CANDIDATES = [
|
|
2430
|
+
"globals.css",
|
|
2431
|
+
"app/globals.css",
|
|
2432
|
+
"src/app/globals.css",
|
|
2433
|
+
"src/globals.css",
|
|
2434
|
+
"styles/globals.css"
|
|
2435
|
+
];
|
|
2436
|
+
var TAILWIND_IMPORT = /@import\s+(?:url\(\s*)?["']tailwindcss["']/;
|
|
2437
|
+
function hasTailwindImport(css) {
|
|
2438
|
+
return TAILWIND_IMPORT.test(css.replace(/\/\*[\s\S]*?\*\//g, ""));
|
|
2439
|
+
}
|
|
2440
|
+
function readPackageJson(baseDir) {
|
|
2441
|
+
try {
|
|
2442
|
+
const parsed = JSON.parse(readFileSync6(join5(baseDir, "package.json"), "utf8"));
|
|
2443
|
+
return isPlainObject(parsed) ? parsed : void 0;
|
|
2444
|
+
} catch {
|
|
2445
|
+
return void 0;
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
function checkTailwindSetup(baseDirInput) {
|
|
2449
|
+
const baseDir = resolve3(baseDirInput);
|
|
2450
|
+
const tailwind = detectTailwind(baseDir, readPackageJson(baseDir));
|
|
2451
|
+
if (tailwind.major !== void 0 && tailwind.major >= 4) {
|
|
2452
|
+
const label = `Tailwind ${tailwind.major}`;
|
|
2453
|
+
for (const candidate of TAILWIND_CSS_CANDIDATES) {
|
|
2454
|
+
const file = join5(baseDir, candidate);
|
|
2455
|
+
if (!existsSync5(file)) continue;
|
|
2456
|
+
const found = hasTailwindImport(readFileSync6(file, "utf8"));
|
|
2457
|
+
return {
|
|
2458
|
+
name: "tailwind.config",
|
|
2459
|
+
severity: found ? "pass" : "warn",
|
|
2460
|
+
message: found ? `${label}: ${candidate}\uC5D0 @import "tailwindcss" \uAC00 \uC788\uC2B5\uB2C8\uB2E4` : `${label}: ${candidate}\uC5D0 @import "tailwindcss" \uAC00 \uC5C6\uC2B5\uB2C8\uB2E4`
|
|
2461
|
+
};
|
|
2462
|
+
}
|
|
2463
|
+
return {
|
|
2464
|
+
name: "tailwind.config",
|
|
2465
|
+
severity: "warn",
|
|
2466
|
+
message: `${label}: @import "tailwindcss" \uB97C \uD655\uC778\uD560 CSS \uD30C\uC77C\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`
|
|
2467
|
+
};
|
|
2468
|
+
}
|
|
2469
|
+
const [tsFile, ...otherFiles] = TAILWIND_CONFIG_FILES;
|
|
2470
|
+
const tsPath = join5(baseDir, tsFile);
|
|
2471
|
+
if (existsSync5(tsPath)) {
|
|
2472
|
+
const content = readFileSync6(tsPath, "utf8");
|
|
2473
|
+
const hasTokens = content.includes("--background") || content.includes("hsl(var(");
|
|
2474
|
+
return {
|
|
2475
|
+
name: "tailwind.config",
|
|
2476
|
+
severity: hasTokens ? "pass" : "warn",
|
|
2477
|
+
message: hasTokens ? "tailwind.config.ts\uC5D0 AXIS \uD1A0\uD070\uC774 \uC124\uC815\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4" : "tailwind.config.ts\uC5D0 AXIS \uD1A0\uD070 \uC124\uC815\uC774 \uC5C6\uC2B5\uB2C8\uB2E4"
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
for (const file of otherFiles) {
|
|
2481
|
+
if (existsSync5(join5(baseDir, file))) {
|
|
2482
|
+
return { name: "tailwind.config", severity: "warn", message: `${file} \uC874\uC7AC (TypeScript \uAD8C\uC7A5)` };
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
return { name: "tailwind.config", severity: "fail", message: "tailwind.config \uD30C\uC77C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4" };
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2316
2488
|
// src/tools/template.ts
|
|
2317
2489
|
var TEMPLATE_REGISTRY_URL = process.env.AXIS_TEMPLATE_URL || "https://axis.minu.best/templates";
|
|
2318
2490
|
async function fetchTemplateIndex() {
|
|
@@ -2473,29 +2645,7 @@ async function handleCheckProject(params) {
|
|
|
2473
2645
|
severity: configExists ? "pass" : "fail",
|
|
2474
2646
|
message: configExists ? "axis.config.json \uD30C\uC77C\uC774 \uC874\uC7AC\uD569\uB2C8\uB2E4" : "axis.config.json \uD30C\uC77C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2192 'axis init'\uC744 \uC2E4\uD589\uD558\uC138\uC694"
|
|
2475
2647
|
});
|
|
2476
|
-
|
|
2477
|
-
const twJs = path3.join(baseDir, "tailwind.config.js");
|
|
2478
|
-
if (await fs3.pathExists(twTs)) {
|
|
2479
|
-
const content = await fs3.readFile(twTs, "utf-8");
|
|
2480
|
-
const hasTokens = content.includes("--background") || content.includes("hsl(var(");
|
|
2481
|
-
results.push({
|
|
2482
|
-
name: "tailwind.config",
|
|
2483
|
-
severity: hasTokens ? "pass" : "warn",
|
|
2484
|
-
message: hasTokens ? "tailwind.config.ts\uC5D0 AXIS \uD1A0\uD070\uC774 \uC124\uC815\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4" : "tailwind.config.ts\uC5D0 AXIS \uD1A0\uD070 \uC124\uC815\uC774 \uC5C6\uC2B5\uB2C8\uB2E4"
|
|
2485
|
-
});
|
|
2486
|
-
} else if (await fs3.pathExists(twJs)) {
|
|
2487
|
-
results.push({
|
|
2488
|
-
name: "tailwind.config",
|
|
2489
|
-
severity: "warn",
|
|
2490
|
-
message: "tailwind.config.js \uC874\uC7AC (TypeScript \uAD8C\uC7A5)"
|
|
2491
|
-
});
|
|
2492
|
-
} else {
|
|
2493
|
-
results.push({
|
|
2494
|
-
name: "tailwind.config",
|
|
2495
|
-
severity: "fail",
|
|
2496
|
-
message: "tailwind.config \uD30C\uC77C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4"
|
|
2497
|
-
});
|
|
2498
|
-
}
|
|
2648
|
+
results.push(checkTailwindSetup(baseDir));
|
|
2499
2649
|
const cssCandidates = [
|
|
2500
2650
|
"globals.css",
|
|
2501
2651
|
"app/globals.css",
|