@axis-ds/cli 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/chunk-YYSEFWYD.js +473 -0
- package/dist/index.js +219 -382
- package/dist/monet.d.ts +6 -1
- package/dist/monet.js +5 -3
- package/dist/registry/index.json +2 -2
- package/dist/registry/registry.json +2 -2
- package/dist/registry/select.json +1 -1
- package/package.json +1 -1
- package/dist/chunk-LVMDBOXD.js +0 -192
package/dist/index.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
GLOBAL_CSS_CANDIDATES,
|
|
4
|
+
MonetClient,
|
|
5
|
+
ROOT_LAYOUT_FILES,
|
|
6
|
+
addCommandFor,
|
|
7
|
+
addCommandPrefix,
|
|
8
|
+
compareExactVersions,
|
|
9
|
+
declaredDependency,
|
|
10
|
+
detectInstallCommand,
|
|
11
|
+
detectProjectPaths,
|
|
12
|
+
findInstalledPackage,
|
|
13
|
+
hasDependency,
|
|
14
|
+
isPlainObject,
|
|
15
|
+
isPnpProject,
|
|
16
|
+
projectFileExists,
|
|
17
|
+
resolveBaseDir,
|
|
18
|
+
runScriptCommand,
|
|
19
|
+
workspaceRootPackage,
|
|
20
|
+
workspaceRunCommand
|
|
21
|
+
} from "./chunk-YYSEFWYD.js";
|
|
5
22
|
import {
|
|
6
23
|
V0Client
|
|
7
24
|
} from "./chunk-2PNCUPCG.js";
|
|
@@ -489,11 +506,11 @@ var ShadcnCollector = class extends BaseCollector {
|
|
|
489
506
|
/**
|
|
490
507
|
* 파일 타입 추론
|
|
491
508
|
*/
|
|
492
|
-
getFileType(
|
|
493
|
-
if (
|
|
494
|
-
if (
|
|
495
|
-
if (
|
|
496
|
-
if (
|
|
509
|
+
getFileType(path17) {
|
|
510
|
+
if (path17.includes("hook") || path17.startsWith("use")) return "hook";
|
|
511
|
+
if (path17.includes("util") || path17.includes("lib")) return "util";
|
|
512
|
+
if (path17.endsWith(".css")) return "style";
|
|
513
|
+
if (path17.endsWith(".d.ts") || path17.includes("types")) return "type";
|
|
497
514
|
return "component";
|
|
498
515
|
}
|
|
499
516
|
};
|
|
@@ -1810,7 +1827,7 @@ import ora5 from "ora";
|
|
|
1810
1827
|
|
|
1811
1828
|
// src/template/template-apply.ts
|
|
1812
1829
|
import fs8 from "fs-extra";
|
|
1813
|
-
import
|
|
1830
|
+
import path8 from "path";
|
|
1814
1831
|
import chalk5 from "chalk";
|
|
1815
1832
|
import ora3 from "ora";
|
|
1816
1833
|
|
|
@@ -1907,189 +1924,10 @@ async function readAxisConfig(baseDir) {
|
|
|
1907
1924
|
}
|
|
1908
1925
|
|
|
1909
1926
|
// ../axis-registry-core/src/template/tailwind-core.ts
|
|
1910
|
-
import { existsSync
|
|
1927
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync } from "fs";
|
|
1911
1928
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "path";
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
import { existsSync, readFileSync, statSync } from "fs";
|
|
1915
|
-
import path8 from "path";
|
|
1916
|
-
var LOCKFILE_COMMANDS = [
|
|
1917
|
-
["pnpm-lock.yaml", "pnpm install"],
|
|
1918
|
-
["yarn.lock", "yarn install"],
|
|
1919
|
-
["package-lock.json", "npm install"]
|
|
1920
|
-
];
|
|
1921
|
-
function lockfileCommandAt(dir) {
|
|
1922
|
-
return LOCKFILE_COMMANDS.find(([file]) => existsSync(path8.join(dir, file)))?.[1];
|
|
1923
|
-
}
|
|
1924
|
-
function isWorkspaceRootDir(dir) {
|
|
1925
|
-
if (isFile(path8.join(dir, "pnpm-workspace.yaml"))) return true;
|
|
1926
|
-
let parsed;
|
|
1927
|
-
try {
|
|
1928
|
-
parsed = JSON.parse(readFileSync(path8.join(dir, "package.json"), "utf8"));
|
|
1929
|
-
} catch {
|
|
1930
|
-
return false;
|
|
1931
|
-
}
|
|
1932
|
-
if (!isPlainObject(parsed)) return false;
|
|
1933
|
-
const ws = parsed.workspaces;
|
|
1934
|
-
return Array.isArray(ws) || isPlainObject(ws) && Array.isArray(ws.packages);
|
|
1935
|
-
}
|
|
1936
|
-
function findWorkspaceRoot(baseDirInput) {
|
|
1937
|
-
let dir = path8.resolve(baseDirInput);
|
|
1938
|
-
for (; ; ) {
|
|
1939
|
-
if (isWorkspaceRootDir(dir)) return dir;
|
|
1940
|
-
if (existsSync(path8.join(dir, ".git"))) return void 0;
|
|
1941
|
-
const parent = path8.dirname(dir);
|
|
1942
|
-
if (parent === dir) return void 0;
|
|
1943
|
-
dir = parent;
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
function detectInstallCommand(baseDirInput) {
|
|
1947
|
-
const baseDir = path8.resolve(baseDirInput);
|
|
1948
|
-
const own = lockfileCommandAt(baseDir);
|
|
1949
|
-
if (own !== void 0) return own;
|
|
1950
|
-
const root = findWorkspaceRoot(baseDir);
|
|
1951
|
-
if (root !== void 0 && root !== baseDir) {
|
|
1952
|
-
const fromRoot = lockfileCommandAt(root);
|
|
1953
|
-
if (fromRoot !== void 0) return fromRoot;
|
|
1954
|
-
}
|
|
1955
|
-
return "pnpm install";
|
|
1956
|
-
}
|
|
1957
|
-
function hasDependency(pkg, name) {
|
|
1958
|
-
for (const field of ["dependencies", "devDependencies"]) {
|
|
1959
|
-
const deps = pkg[field];
|
|
1960
|
-
if (typeof deps === "object" && deps !== null && name in deps) {
|
|
1961
|
-
return String(deps[name]);
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
return void 0;
|
|
1965
|
-
}
|
|
1966
|
-
function isPlainObject(value) {
|
|
1967
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1968
|
-
}
|
|
1969
|
-
function addCommandFor(installCommand, deps) {
|
|
1970
|
-
const specs = Object.entries(deps).map(([name, range]) => `"${name}@${range}"`).join(" ");
|
|
1971
|
-
if (installCommand.startsWith("yarn")) return `yarn add ${specs}`;
|
|
1972
|
-
if (installCommand.startsWith("npm")) return `npm install ${specs}`;
|
|
1973
|
-
return `pnpm add ${specs}`;
|
|
1974
|
-
}
|
|
1975
|
-
var GLOBAL_CSS_CANDIDATES = [
|
|
1976
|
-
"app/globals.css",
|
|
1977
|
-
"src/app/globals.css",
|
|
1978
|
-
"styles/globals.css",
|
|
1979
|
-
"src/styles/globals.css",
|
|
1980
|
-
"globals.css"
|
|
1981
|
-
];
|
|
1982
|
-
var TAILWIND_CONFIG_CANDIDATES = [
|
|
1983
|
-
"tailwind.config.ts",
|
|
1984
|
-
"tailwind.config.js",
|
|
1985
|
-
"tailwind.config.mjs",
|
|
1986
|
-
"tailwind.config.cjs"
|
|
1987
|
-
];
|
|
1988
|
-
function isFile(file) {
|
|
1989
|
-
try {
|
|
1990
|
-
return statSync(file).isFile();
|
|
1991
|
-
} catch {
|
|
1992
|
-
return false;
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
function isDirectory(dir) {
|
|
1996
|
-
try {
|
|
1997
|
-
return statSync(dir).isDirectory();
|
|
1998
|
-
} catch {
|
|
1999
|
-
return false;
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
function findFirstFile(baseDir, candidates) {
|
|
2003
|
-
return candidates.find((c) => isFile(path8.join(baseDir, c)));
|
|
2004
|
-
}
|
|
2005
|
-
function detectProjectPaths(baseDirInput) {
|
|
2006
|
-
const baseDir = path8.resolve(baseDirInput);
|
|
2007
|
-
const hasSrc = isDirectory(path8.join(baseDir, "src"));
|
|
2008
|
-
const css = findFirstFile(baseDir, GLOBAL_CSS_CANDIDATES);
|
|
2009
|
-
const tw = findFirstFile(baseDir, TAILWIND_CONFIG_CANDIDATES);
|
|
2010
|
-
return {
|
|
2011
|
-
componentsDir: hasSrc ? "./src/components/ui" : "./components/ui",
|
|
2012
|
-
globalCss: css !== void 0 ? `./${css}` : hasSrc ? "./src/app/globals.css" : "./app/globals.css",
|
|
2013
|
-
globalCssSource: css !== void 0 ? "found" : "default",
|
|
2014
|
-
tailwindConfig: tw !== void 0 ? `./${tw}` : "./tailwind.config.ts",
|
|
2015
|
-
tailwindConfigSource: tw !== void 0 ? "found" : "default"
|
|
2016
|
-
};
|
|
2017
|
-
}
|
|
2018
|
-
function projectFileExists(baseDir, relPath) {
|
|
2019
|
-
return isFile(path8.resolve(baseDir, relPath));
|
|
2020
|
-
}
|
|
2021
|
-
var ROOT_LAYOUT_FILES = [
|
|
2022
|
-
"app/layout.tsx",
|
|
2023
|
-
"app/layout.jsx",
|
|
2024
|
-
"app/layout.js",
|
|
2025
|
-
"src/app/layout.tsx",
|
|
2026
|
-
"src/app/layout.jsx",
|
|
2027
|
-
"src/app/layout.js",
|
|
2028
|
-
"pages/_app.tsx",
|
|
2029
|
-
"pages/_app.jsx",
|
|
2030
|
-
"pages/_document.tsx",
|
|
2031
|
-
"pages/_document.jsx",
|
|
2032
|
-
"src/pages/_app.tsx",
|
|
2033
|
-
"src/pages/_app.jsx",
|
|
2034
|
-
"src/pages/_document.tsx",
|
|
2035
|
-
"src/pages/_document.jsx"
|
|
2036
|
-
];
|
|
2037
|
-
function exactVersionOf(version) {
|
|
2038
|
-
if (typeof version !== "string") return void 0;
|
|
2039
|
-
const v = version.trim();
|
|
2040
|
-
if (!/^v?\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(v) || /^v?0\.0\.0-/.test(v)) return void 0;
|
|
2041
|
-
return v;
|
|
2042
|
-
}
|
|
2043
|
-
function findInstalledPackage(baseDirInput, name) {
|
|
2044
|
-
let dir = path8.resolve(baseDirInput);
|
|
2045
|
-
for (; ; ) {
|
|
2046
|
-
const pkgDir = path8.join(dir, "node_modules", ...name.split("/"));
|
|
2047
|
-
const file = path8.join(pkgDir, "package.json");
|
|
2048
|
-
if (isFile(file)) {
|
|
2049
|
-
let version;
|
|
2050
|
-
try {
|
|
2051
|
-
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
2052
|
-
version = isPlainObject(parsed) ? exactVersionOf(parsed.version) : void 0;
|
|
2053
|
-
} catch {
|
|
2054
|
-
version = void 0;
|
|
2055
|
-
}
|
|
2056
|
-
return { dir: pkgDir, version };
|
|
2057
|
-
}
|
|
2058
|
-
const parent = path8.dirname(dir);
|
|
2059
|
-
if (parent === dir) return void 0;
|
|
2060
|
-
dir = parent;
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
function isPnpProject(baseDirInput) {
|
|
2064
|
-
let dir = path8.resolve(baseDirInput);
|
|
2065
|
-
for (; ; ) {
|
|
2066
|
-
if (isFile(path8.join(dir, ".pnp.cjs")) || isFile(path8.join(dir, ".pnp.js"))) return true;
|
|
2067
|
-
const parent = path8.dirname(dir);
|
|
2068
|
-
if (parent === dir) return false;
|
|
2069
|
-
dir = parent;
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
function compareExactVersions(a, b) {
|
|
2073
|
-
const parse = (v) => {
|
|
2074
|
-
const m = /^v?(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?/.exec(v.trim());
|
|
2075
|
-
return m ? { core: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] !== void 0 } : void 0;
|
|
2076
|
-
};
|
|
2077
|
-
const x = parse(a);
|
|
2078
|
-
const y = parse(b);
|
|
2079
|
-
if (!x || !y) return void 0;
|
|
2080
|
-
for (let i = 0; i < 3; i++) if (x.core[i] !== y.core[i]) return x.core[i] - y.core[i];
|
|
2081
|
-
return Number(y.pre) - Number(x.pre);
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
// ../axis-registry-core/src/template/tailwind-core.ts
|
|
2085
|
-
function hasDependency2(pkg, name) {
|
|
2086
|
-
for (const field of ["dependencies", "devDependencies"]) {
|
|
2087
|
-
const deps = pkg[field];
|
|
2088
|
-
if (typeof deps === "object" && deps !== null && name in deps) {
|
|
2089
|
-
return String(deps[name]);
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
return void 0;
|
|
1929
|
+
function declaredRange(baseDir, pkg, name) {
|
|
1930
|
+
return declaredDependency(baseDir, pkg, name)?.range;
|
|
2093
1931
|
}
|
|
2094
1932
|
function isPlainObject2(value) {
|
|
2095
1933
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -2165,8 +2003,8 @@ function majorFromVersion(version) {
|
|
|
2165
2003
|
return Number(m[1]);
|
|
2166
2004
|
}
|
|
2167
2005
|
function detectTailwind(baseDirInput, pkg) {
|
|
2168
|
-
const baseDir =
|
|
2169
|
-
const declared = pkg ?
|
|
2006
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2007
|
+
const declared = pkg ? declaredRange(baseDir, pkg, "tailwindcss") : void 0;
|
|
2170
2008
|
const bounds = declared !== void 0 ? tailwindMajorBounds(declared) : void 0;
|
|
2171
2009
|
const declaredMajor = bounds?.lower;
|
|
2172
2010
|
const version = isPnpProject(baseDir) ? void 0 : findInstalledPackage(baseDir, "tailwindcss")?.version;
|
|
@@ -2217,13 +2055,13 @@ function findTokensCssImport(css) {
|
|
|
2217
2055
|
var TOKENS_CSS_JS_IMPORT = /(?:\bimport\s+|\bfrom\s+|\brequire\s*\(\s*)(["'])(@axis-ds\/tokens\/css(?:\/shadcn|\/tailwind4)?)\1/;
|
|
2218
2056
|
var AXIS_VARIABLE_DEFINITION = /(?<![\w-])--axis-[\w-]+\s*:/;
|
|
2219
2057
|
function findLayoutTokensCssImport(baseDirInput) {
|
|
2220
|
-
const baseDir =
|
|
2058
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2221
2059
|
for (const candidate of ROOT_LAYOUT_FILES) {
|
|
2222
2060
|
const file = join(baseDir, candidate);
|
|
2223
|
-
if (!
|
|
2061
|
+
if (!existsSync(file)) continue;
|
|
2224
2062
|
let text;
|
|
2225
2063
|
try {
|
|
2226
|
-
text =
|
|
2064
|
+
text = readFileSync(file, "utf8");
|
|
2227
2065
|
} catch {
|
|
2228
2066
|
continue;
|
|
2229
2067
|
}
|
|
@@ -2233,11 +2071,11 @@ function findLayoutTokensCssImport(baseDirInput) {
|
|
|
2233
2071
|
return void 0;
|
|
2234
2072
|
}
|
|
2235
2073
|
function checkGlobalsCss(baseDirInput) {
|
|
2236
|
-
const baseDir =
|
|
2074
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2237
2075
|
for (const candidate of TAILWIND_CSS_CANDIDATES) {
|
|
2238
2076
|
const file = join(baseDir, candidate);
|
|
2239
|
-
if (!
|
|
2240
|
-
const content =
|
|
2077
|
+
if (!existsSync(file)) continue;
|
|
2078
|
+
const content = readFileSync(file, "utf8");
|
|
2241
2079
|
const css = stripCssComments(content);
|
|
2242
2080
|
const imported = findTokensCssImport(content);
|
|
2243
2081
|
let pass;
|
|
@@ -2325,11 +2163,11 @@ function installedAxisVersion(baseDir, name) {
|
|
|
2325
2163
|
}
|
|
2326
2164
|
function axisPackagesBelowTailwind4(pkg, baseDirInput) {
|
|
2327
2165
|
if (!pkg) return [];
|
|
2328
|
-
const baseDir = baseDirInput !== void 0 ?
|
|
2166
|
+
const baseDir = baseDirInput !== void 0 ? resolveBaseDir(baseDirInput) : void 0;
|
|
2329
2167
|
const out = [];
|
|
2330
2168
|
const min = lowerOf(TAILWIND4_MIN_AXIS_VERSION);
|
|
2331
2169
|
for (const name of TAILWIND4_AXIS_PACKAGES) {
|
|
2332
|
-
const range =
|
|
2170
|
+
const range = baseDir !== void 0 ? declaredRange(baseDir, pkg, name) : hasDependency(pkg, name);
|
|
2333
2171
|
if (range === void 0 || range.trim().startsWith("workspace:")) continue;
|
|
2334
2172
|
const installed = baseDir !== void 0 ? installedAxisVersion(baseDir, name) : void 0;
|
|
2335
2173
|
const installedLower = installed !== void 0 ? lowerOf(installed) : void 0;
|
|
@@ -2469,7 +2307,7 @@ function isCommonJsConfig(file, source) {
|
|
|
2469
2307
|
return extname(file) === ".cjs" || /\bmodule\.exports\b/.test(source);
|
|
2470
2308
|
}
|
|
2471
2309
|
function packageVersionGate(baseDirInput, pkg, name, min) {
|
|
2472
|
-
const baseDir =
|
|
2310
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2473
2311
|
if (!isPnpProject(baseDir)) {
|
|
2474
2312
|
const installed = findInstalledPackage(baseDir, name)?.version;
|
|
2475
2313
|
if (installed !== void 0) {
|
|
@@ -2477,7 +2315,7 @@ function packageVersionGate(baseDirInput, pkg, name, min) {
|
|
|
2477
2315
|
if (cmp !== void 0) return { status: cmp >= 0 ? "ok" : "below", source: "installed", value: installed };
|
|
2478
2316
|
}
|
|
2479
2317
|
}
|
|
2480
|
-
const declared = pkg ?
|
|
2318
|
+
const declared = pkg ? declaredRange(baseDir, pkg, name) : void 0;
|
|
2481
2319
|
if (declared !== void 0) {
|
|
2482
2320
|
const atLeast = rangeLowerAtLeast(declared, min);
|
|
2483
2321
|
if (atLeast !== void 0) return { status: atLeast ? "ok" : "below", source: "declared", value: declared };
|
|
@@ -2492,18 +2330,18 @@ function versionGateLabel(gate) {
|
|
|
2492
2330
|
}
|
|
2493
2331
|
function readPackageJson(baseDir) {
|
|
2494
2332
|
try {
|
|
2495
|
-
const parsed = JSON.parse(
|
|
2333
|
+
const parsed = JSON.parse(readFileSync(join(baseDir, "package.json"), "utf8"));
|
|
2496
2334
|
return isPlainObject2(parsed) ? parsed : void 0;
|
|
2497
2335
|
} catch {
|
|
2498
2336
|
return void 0;
|
|
2499
2337
|
}
|
|
2500
2338
|
}
|
|
2501
|
-
function tailwind4Issues(css, pkg, versions) {
|
|
2339
|
+
function tailwind4Issues(css, pkg, versions, baseDir) {
|
|
2502
2340
|
const issues = [];
|
|
2503
2341
|
const hasEntry = hasTokensTailwind4Import(css);
|
|
2504
2342
|
if (!hasEntry) issues.push(`AXIS \uD1A0\uD070 \uC9C4\uC785\uC810\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2192 ${TOKENS_TAILWIND4_IMPORT_LINE}`);
|
|
2505
2343
|
const missing = TAILWIND4_COMPONENT_PACKAGES.filter(
|
|
2506
|
-
(name) =>
|
|
2344
|
+
(name) => declaredRange(baseDir, pkg, name) !== void 0 && !hasComponentTailwindImport(css, name) && !hasComponentSource(css, name)
|
|
2507
2345
|
);
|
|
2508
2346
|
if (missing.length > 0) {
|
|
2509
2347
|
issues.push(`\uCEF4\uD3EC\uB10C\uD2B8 \uC2A4\uCE94 \uACBD\uB85C(tailwind.css)\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4 \u2192 ${missing.map(componentTailwindImportLine).join(" ")}`);
|
|
@@ -2523,15 +2361,15 @@ function tailwind4Issues(css, pkg, versions) {
|
|
|
2523
2361
|
return issues;
|
|
2524
2362
|
}
|
|
2525
2363
|
function checkTailwindSetup(baseDirInput) {
|
|
2526
|
-
const baseDir =
|
|
2364
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2527
2365
|
const pkg = readPackageJson(baseDir);
|
|
2528
2366
|
const tailwind = detectTailwind(baseDir, pkg);
|
|
2529
2367
|
if (tailwind.major !== void 0 && tailwind.major >= 4) {
|
|
2530
2368
|
const label = `Tailwind ${tailwind.major}`;
|
|
2531
2369
|
for (const candidate of TAILWIND_CSS_CANDIDATES) {
|
|
2532
2370
|
const file = join(baseDir, candidate);
|
|
2533
|
-
if (!
|
|
2534
|
-
const css =
|
|
2371
|
+
if (!existsSync(file)) continue;
|
|
2372
|
+
const css = readFileSync(file, "utf8");
|
|
2535
2373
|
if (!hasTailwindImport(css)) {
|
|
2536
2374
|
return {
|
|
2537
2375
|
name: "tailwind.config",
|
|
@@ -2540,7 +2378,7 @@ function checkTailwindSetup(baseDirInput) {
|
|
|
2540
2378
|
};
|
|
2541
2379
|
}
|
|
2542
2380
|
const versions = axisPackagesBelowTailwind4(pkg, baseDir);
|
|
2543
|
-
const issues = tailwind4Issues(css, pkg, versions);
|
|
2381
|
+
const issues = tailwind4Issues(css, pkg, versions, baseDir);
|
|
2544
2382
|
if (issues.length > 0) {
|
|
2545
2383
|
return {
|
|
2546
2384
|
name: "tailwind.config",
|
|
@@ -2561,9 +2399,9 @@ function checkTailwindSetup(baseDirInput) {
|
|
|
2561
2399
|
};
|
|
2562
2400
|
}
|
|
2563
2401
|
for (const file of TAILWIND_CONFIG_FILES) {
|
|
2564
|
-
const
|
|
2565
|
-
if (!
|
|
2566
|
-
const content =
|
|
2402
|
+
const path17 = join(baseDir, file);
|
|
2403
|
+
if (!existsSync(path17)) continue;
|
|
2404
|
+
const content = readFileSync(path17, "utf8");
|
|
2567
2405
|
if (hasTokensPresetReference(content)) {
|
|
2568
2406
|
const code = stripJsComments(content);
|
|
2569
2407
|
if (isCommonJsConfig(file, code) && hasBareCjsPresetRequire(code)) {
|
|
@@ -2590,7 +2428,7 @@ function checkTailwindSetup(baseDirInput) {
|
|
|
2590
2428
|
}
|
|
2591
2429
|
function readAxisConfigLike(baseDir) {
|
|
2592
2430
|
try {
|
|
2593
|
-
const parsed = JSON.parse(
|
|
2431
|
+
const parsed = JSON.parse(readFileSync(join(baseDir, "axis.config.json"), "utf8"));
|
|
2594
2432
|
return isPlainObject2(parsed) ? parsed : void 0;
|
|
2595
2433
|
} catch {
|
|
2596
2434
|
return void 0;
|
|
@@ -2699,7 +2537,8 @@ function contentGlobBranchCovers(glob, sample, baseDir) {
|
|
|
2699
2537
|
}
|
|
2700
2538
|
return leadingParentSegments(glob) === leadingParentSegments(sample) && contentGlobToRegExp(glob).test(sample);
|
|
2701
2539
|
}
|
|
2702
|
-
function contentGlobCovers(glob, sample,
|
|
2540
|
+
function contentGlobCovers(glob, sample, baseDirInput) {
|
|
2541
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2703
2542
|
const branches = expandBraces(glob.trim()) ?? [glob];
|
|
2704
2543
|
return branches.some((b) => contentGlobBranchCovers(b, sample, baseDir));
|
|
2705
2544
|
}
|
|
@@ -2760,11 +2599,11 @@ function normalizeRel(p) {
|
|
|
2760
2599
|
return s;
|
|
2761
2600
|
}
|
|
2762
2601
|
function inspectTailwindContent(baseDirInput) {
|
|
2763
|
-
const baseDir =
|
|
2602
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2764
2603
|
const pkg = readPackageJson(baseDir);
|
|
2765
2604
|
const tailwind = detectTailwind(baseDir, pkg);
|
|
2766
2605
|
if (tailwind.major !== void 0 && tailwind.major >= 4) return null;
|
|
2767
|
-
const configFile = TAILWIND_CONFIG_FILES.find((f) =>
|
|
2606
|
+
const configFile = TAILWIND_CONFIG_FILES.find((f) => existsSync(join(baseDir, f)));
|
|
2768
2607
|
if (configFile === void 0) return null;
|
|
2769
2608
|
const targets = [];
|
|
2770
2609
|
const componentsDir = readAxisConfigLike(baseDir)?.componentsDir;
|
|
@@ -2773,12 +2612,12 @@ function inspectTailwindContent(baseDirInput) {
|
|
|
2773
2612
|
targets.push({ label: `componentsDir(${componentsDir})`, sample: `${rel3}/button.tsx`, suggest: `./${rel3}/**/*.{ts,tsx}` });
|
|
2774
2613
|
}
|
|
2775
2614
|
for (const name of TAILWIND4_COMPONENT_PACKAGES) {
|
|
2776
|
-
if (
|
|
2615
|
+
if (declaredRange(baseDir, pkg, name) !== void 0) {
|
|
2777
2616
|
targets.push({ label: name, ...packageContentTarget(baseDir, name) });
|
|
2778
2617
|
}
|
|
2779
2618
|
}
|
|
2780
2619
|
if (targets.length === 0) return null;
|
|
2781
|
-
const read = readTailwindContent(
|
|
2620
|
+
const read = readTailwindContent(readFileSync(join(baseDir, configFile), "utf8"));
|
|
2782
2621
|
const globs = (read?.globs ?? []).filter((g) => !g.trim().startsWith("!"));
|
|
2783
2622
|
return {
|
|
2784
2623
|
configFile,
|
|
@@ -2844,24 +2683,24 @@ function componentsUseAnimation(baseDir, componentsDir) {
|
|
|
2844
2683
|
if (st.isDirectory()) {
|
|
2845
2684
|
if (name !== "node_modules" && depth < ANIMATION_SCAN_DEPTH_LIMIT) stack.push([p, depth + 1]);
|
|
2846
2685
|
} else if (st.isFile() && st.size <= ANIMATION_SCAN_FILE_BYTES && /\.(tsx|ts|jsx|js)$/.test(name)) {
|
|
2847
|
-
if (/\banimate-(?:in|out)\b/.test(
|
|
2686
|
+
if (/\banimate-(?:in|out)\b/.test(readFileSync(p, "utf8"))) return true;
|
|
2848
2687
|
}
|
|
2849
2688
|
}
|
|
2850
2689
|
}
|
|
2851
2690
|
return false;
|
|
2852
2691
|
}
|
|
2853
2692
|
function checkAnimationPlugin(baseDirInput) {
|
|
2854
|
-
const baseDir =
|
|
2693
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
2855
2694
|
const pkg = readPackageJson(baseDir);
|
|
2856
2695
|
const config = readAxisConfigLike(baseDir);
|
|
2857
|
-
const declared =
|
|
2696
|
+
const declared = declaredRange(baseDir, pkg, "@axis-ds/ui-react") !== void 0;
|
|
2858
2697
|
const copied = typeof config?.componentsDir === "string" && componentsUseAnimation(baseDir, config.componentsDir);
|
|
2859
2698
|
if (!declared && !copied) return null;
|
|
2860
2699
|
const by = declared ? "@axis-ds/ui-react \uC120\uC5B8" : "componentsDir \uC758 animate-in \uB958 \uD074\uB798\uC2A4";
|
|
2861
2700
|
const tailwind = detectTailwind(baseDir, pkg);
|
|
2862
2701
|
if (tailwind.major !== void 0 && tailwind.major >= 4) {
|
|
2863
|
-
const file = TAILWIND_CSS_CANDIDATES.find((c) =>
|
|
2864
|
-
const css = file !== void 0 ? stripCssComments(
|
|
2702
|
+
const file = TAILWIND_CSS_CANDIDATES.find((c) => existsSync(join(baseDir, c)));
|
|
2703
|
+
const css = file !== void 0 ? stripCssComments(readFileSync(join(baseDir, file), "utf8")) : "";
|
|
2865
2704
|
const ok = new RegExp(`@import\\s+(?:url\\(\\s*)?["']${ANIMATION_PLUGIN_TAILWIND4}["']`).test(css) || new RegExp(`@plugin\\s+["']${ANIMATION_PLUGIN_TAILWIND3}["']`).test(css);
|
|
2866
2705
|
return ok ? { name: "animation", severity: "pass", message: `${file}\uC5D0 \uC560\uB2C8\uBA54\uC774\uC158 \uD50C\uB7EC\uADF8\uC778\uC774 \uC788\uC2B5\uB2C8\uB2E4` } : {
|
|
2867
2706
|
name: "animation",
|
|
@@ -2869,10 +2708,10 @@ function checkAnimationPlugin(baseDirInput) {
|
|
|
2869
2708
|
message: `\uC560\uB2C8\uBA54\uC774\uC158 \uD50C\uB7EC\uADF8\uC778\uC774 \uC5C6\uC2B5\uB2C8\uB2E4(${by}): Dialog \xB7 Select \uB4F1\uC758 \uC5F4\uACE0 \uB2EB\uB294 \uC560\uB2C8\uBA54\uC774\uC158\uC774 \uB3D9\uC791\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4 \u2192 ${ANIMATION_PLUGIN_TAILWIND4} \uC124\uCE58 \uB4A4 @import "${ANIMATION_PLUGIN_TAILWIND4}";`
|
|
2870
2709
|
};
|
|
2871
2710
|
}
|
|
2872
|
-
const configFile = TAILWIND_CONFIG_FILES.find((f) =>
|
|
2873
|
-
const source = configFile !== void 0 ? stripJsComments(
|
|
2711
|
+
const configFile = TAILWIND_CONFIG_FILES.find((f) => existsSync(join(baseDir, f)));
|
|
2712
|
+
const source = configFile !== void 0 ? stripJsComments(readFileSync(join(baseDir, configFile), "utf8")) : "";
|
|
2874
2713
|
const plugins = configFile !== void 0 ? readAnimationPluginUse(source) : "absent";
|
|
2875
|
-
const pluginDeclared =
|
|
2714
|
+
const pluginDeclared = declaredRange(baseDir, pkg, ANIMATION_PLUGIN_TAILWIND3) !== void 0;
|
|
2876
2715
|
const pluginInstalled = pluginDeclared && (isPnpProject(baseDir) || findInstalledPackage(baseDir, ANIMATION_PLUGIN_TAILWIND3) !== void 0);
|
|
2877
2716
|
if (plugins === "found" && pluginDeclared && pluginInstalled) {
|
|
2878
2717
|
return { name: "animation", severity: "pass", message: `${configFile}\uC758 plugins \uC5D0 ${ANIMATION_PLUGIN_TAILWIND3} \uAC00 \uC788\uC2B5\uB2C8\uB2E4` };
|
|
@@ -2951,9 +2790,21 @@ function splitTopLevel(body) {
|
|
|
2951
2790
|
}
|
|
2952
2791
|
|
|
2953
2792
|
// src/template/template-apply.ts
|
|
2793
|
+
function templateDependencyCommands(installCommand, detail) {
|
|
2794
|
+
const lines = [];
|
|
2795
|
+
const deps = detail.dependencies ?? {};
|
|
2796
|
+
const devDeps = detail.devDependencies ?? {};
|
|
2797
|
+
if (Object.keys(deps).length > 0) lines.push(addCommandFor(installCommand, deps));
|
|
2798
|
+
if (Object.keys(devDeps).length > 0) lines.push(addCommandFor(installCommand, devDeps, { dev: true }));
|
|
2799
|
+
return lines;
|
|
2800
|
+
}
|
|
2801
|
+
function templateInitNextSteps(projectDir) {
|
|
2802
|
+
const installCommand = detectInstallCommand(projectDir);
|
|
2803
|
+
return [installCommand, runScriptCommand(installCommand, "dev")];
|
|
2804
|
+
}
|
|
2954
2805
|
async function templateApplyWarnings(baseDir, detail) {
|
|
2955
2806
|
const warnings = [];
|
|
2956
|
-
const pkgPath =
|
|
2807
|
+
const pkgPath = path8.join(baseDir, "package.json");
|
|
2957
2808
|
const templateRange = detail.devDependencies?.tailwindcss ?? detail.dependencies?.tailwindcss;
|
|
2958
2809
|
const templateMajor = templateRange !== void 0 ? tailwindMajorFromRange(templateRange) : void 0;
|
|
2959
2810
|
if (templateMajor !== void 0 && await fs8.pathExists(pkgPath)) {
|
|
@@ -2971,7 +2822,7 @@ async function templateApplyWarnings(baseDir, detail) {
|
|
|
2971
2822
|
}
|
|
2972
2823
|
}
|
|
2973
2824
|
const usesRootApp = detail.files.some((f) => f.path.startsWith("app/"));
|
|
2974
|
-
if (usesRootApp && await fs8.pathExists(
|
|
2825
|
+
if (usesRootApp && await fs8.pathExists(path8.join(baseDir, "src", "app"))) {
|
|
2975
2826
|
warnings.push(
|
|
2976
2827
|
"src/app \uC774 \uC788\uB294\uB370 \uD15C\uD50C\uB9BF\uC740 \uB8E8\uD2B8 app/ \uC744 \uC501\uB2C8\uB2E4. Next.js \uB294 \uB8E8\uD2B8 app/ \uC774 \uC788\uC73C\uBA74 src/app \uC744 \uC4F0\uC9C0 \uC54A\uC544 \uAE30\uC874 \uB77C\uC6B0\uD2B8\uAC00 \uBE60\uC9D1\uB2C8\uB2E4."
|
|
2977
2828
|
);
|
|
@@ -2988,13 +2839,14 @@ async function applyTemplate(slug, options) {
|
|
|
2988
2839
|
spinner.fail(err.message);
|
|
2989
2840
|
process.exit(1);
|
|
2990
2841
|
}
|
|
2991
|
-
const baseDir =
|
|
2842
|
+
const baseDir = path8.resolve(options.dir || ".");
|
|
2843
|
+
const installCommand = detectInstallCommand(baseDir);
|
|
2992
2844
|
for (const w of await templateApplyWarnings(baseDir, detail)) {
|
|
2993
2845
|
console.log(chalk5.yellow(`! ${w}`));
|
|
2994
2846
|
}
|
|
2995
2847
|
const conflicts = [];
|
|
2996
2848
|
for (const file of detail.files) {
|
|
2997
|
-
const dest =
|
|
2849
|
+
const dest = path8.join(baseDir, file.path);
|
|
2998
2850
|
if (await fs8.pathExists(dest)) {
|
|
2999
2851
|
conflicts.push(file.path);
|
|
3000
2852
|
}
|
|
@@ -3030,7 +2882,7 @@ async function applyTemplate(slug, options) {
|
|
|
3030
2882
|
if (options.dryRun) {
|
|
3031
2883
|
console.log(chalk5.blue("\n[\uBBF8\uB9AC\uBCF4\uAE30] \uC0DD\uC131\uB420 \uD30C\uC77C:"));
|
|
3032
2884
|
for (const file of detail.files) {
|
|
3033
|
-
const dest =
|
|
2885
|
+
const dest = path8.join(baseDir, file.path);
|
|
3034
2886
|
const exists = conflicts.includes(file.path);
|
|
3035
2887
|
const label = exists ? chalk5.yellow("\uB36E\uC5B4\uC4F0\uAE30") : chalk5.green("\uC0DD\uC131");
|
|
3036
2888
|
console.log(` ${label} ${dest}`);
|
|
@@ -3045,8 +2897,8 @@ async function applyTemplate(slug, options) {
|
|
|
3045
2897
|
}
|
|
3046
2898
|
const writeSpinner = ora3("\uD30C\uC77C \uC0DD\uC131 \uC911...").start();
|
|
3047
2899
|
for (const file of detail.files) {
|
|
3048
|
-
const dest =
|
|
3049
|
-
await fs8.ensureDir(
|
|
2900
|
+
const dest = path8.join(baseDir, file.path);
|
|
2901
|
+
await fs8.ensureDir(path8.dirname(dest));
|
|
3050
2902
|
await fs8.writeFile(dest, file.content);
|
|
3051
2903
|
}
|
|
3052
2904
|
writeSpinner.succeed(`${detail.files.length}\uAC1C \uD30C\uC77C \uC0DD\uC131 \uC644\uB8CC`);
|
|
@@ -3055,18 +2907,10 @@ async function applyTemplate(slug, options) {
|
|
|
3055
2907
|
await runPostInstall(detail.postInstall, baseDir);
|
|
3056
2908
|
}
|
|
3057
2909
|
if (!options.skipDeps) {
|
|
3058
|
-
const
|
|
3059
|
-
|
|
3060
|
-
if (depList.length > 0) {
|
|
2910
|
+
const commands = templateDependencyCommands(installCommand, detail);
|
|
2911
|
+
if (commands.length > 0) {
|
|
3061
2912
|
console.log(chalk5.yellow("\n\uD544\uC694\uD55C \uC758\uC874\uC131:"));
|
|
3062
|
-
const
|
|
3063
|
-
const devDeps = Object.entries(detail.devDependencies || {}).map(([k, v]) => `${k}@${v}`).join(" ");
|
|
3064
|
-
if (deps) {
|
|
3065
|
-
console.log(chalk5.cyan(` pnpm add ${deps}`));
|
|
3066
|
-
}
|
|
3067
|
-
if (devDeps) {
|
|
3068
|
-
console.log(chalk5.cyan(` pnpm add -D ${devDeps}`));
|
|
3069
|
-
}
|
|
2913
|
+
for (const command of commands) console.log(chalk5.cyan(` ${command}`));
|
|
3070
2914
|
}
|
|
3071
2915
|
}
|
|
3072
2916
|
console.log(chalk5.green(`
|
|
@@ -3127,7 +2971,7 @@ async function initTemplate(slug, options) {
|
|
|
3127
2971
|
}
|
|
3128
2972
|
targetDir = dir;
|
|
3129
2973
|
}
|
|
3130
|
-
const resolved =
|
|
2974
|
+
const resolved = path8.resolve(targetDir);
|
|
3131
2975
|
if (await fs8.pathExists(resolved)) {
|
|
3132
2976
|
const entries = await fs8.readdir(resolved);
|
|
3133
2977
|
if (entries.length > 0) {
|
|
@@ -3155,8 +2999,9 @@ async function initTemplate(slug, options) {
|
|
|
3155
2999
|
} else {
|
|
3156
3000
|
await fs8.ensureDir(resolved);
|
|
3157
3001
|
}
|
|
3002
|
+
const nextSteps = templateInitNextSteps(resolved);
|
|
3158
3003
|
await applyTemplate(selectedSlug, { dir: targetDir, yes: true });
|
|
3159
|
-
const configPath =
|
|
3004
|
+
const configPath = path8.join(resolved, "axis.config.json");
|
|
3160
3005
|
if (!await fs8.pathExists(configPath)) {
|
|
3161
3006
|
const axisConfig = createTemplateConfig(selectedSlug);
|
|
3162
3007
|
await fs8.writeJSON(configPath, axisConfig, { spaces: 2 });
|
|
@@ -3165,13 +3010,12 @@ async function initTemplate(slug, options) {
|
|
|
3165
3010
|
console.log(chalk5.blue(`
|
|
3166
3011
|
\uB2E4\uC74C \uB2E8\uACC4:`));
|
|
3167
3012
|
console.log(chalk5.cyan(` cd ${targetDir}`));
|
|
3168
|
-
console.log(chalk5.cyan(`
|
|
3169
|
-
console.log(chalk5.cyan(` pnpm dev`));
|
|
3013
|
+
for (const command of nextSteps) console.log(chalk5.cyan(` ${command}`));
|
|
3170
3014
|
}
|
|
3171
3015
|
|
|
3172
3016
|
// src/template/template-diff.ts
|
|
3173
3017
|
import fs9 from "fs-extra";
|
|
3174
|
-
import
|
|
3018
|
+
import path9 from "path";
|
|
3175
3019
|
import chalk6 from "chalk";
|
|
3176
3020
|
import ora4 from "ora";
|
|
3177
3021
|
async function diffTemplate(slug, options) {
|
|
@@ -3184,10 +3028,10 @@ async function diffTemplate(slug, options) {
|
|
|
3184
3028
|
spinner.fail(err.message);
|
|
3185
3029
|
process.exit(1);
|
|
3186
3030
|
}
|
|
3187
|
-
const baseDir =
|
|
3031
|
+
const baseDir = path9.resolve(options.dir || ".");
|
|
3188
3032
|
const entries = [];
|
|
3189
3033
|
for (const file of detail.files) {
|
|
3190
|
-
const localPath =
|
|
3034
|
+
const localPath = path9.join(baseDir, file.path);
|
|
3191
3035
|
if (!await fs9.pathExists(localPath)) {
|
|
3192
3036
|
entries.push({ path: file.path, status: "added" });
|
|
3193
3037
|
continue;
|
|
@@ -3268,12 +3112,12 @@ async function collectLocalFiles(dir, base) {
|
|
|
3268
3112
|
}
|
|
3269
3113
|
for (const entry of entries) {
|
|
3270
3114
|
if (ignore.has(entry.name)) continue;
|
|
3271
|
-
const fullPath =
|
|
3115
|
+
const fullPath = path9.join(dir, entry.name);
|
|
3272
3116
|
if (entry.isDirectory()) {
|
|
3273
3117
|
const nested = await collectLocalFiles(fullPath, root);
|
|
3274
3118
|
results.push(...nested);
|
|
3275
3119
|
} else {
|
|
3276
|
-
results.push(
|
|
3120
|
+
results.push(path9.relative(root, fullPath).replace(/\\/g, "/"));
|
|
3277
3121
|
}
|
|
3278
3122
|
}
|
|
3279
3123
|
return results;
|
|
@@ -3281,11 +3125,11 @@ async function collectLocalFiles(dir, base) {
|
|
|
3281
3125
|
|
|
3282
3126
|
// src/template/template-check.ts
|
|
3283
3127
|
import fs10 from "fs-extra";
|
|
3284
|
-
import
|
|
3128
|
+
import path10 from "path";
|
|
3285
3129
|
import chalk7 from "chalk";
|
|
3286
3130
|
|
|
3287
3131
|
// src/theme/brand-core.ts
|
|
3288
|
-
import { existsSync as
|
|
3132
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "fs";
|
|
3289
3133
|
import { createRequire } from "module";
|
|
3290
3134
|
import { dirname as dirname2, join as join2, relative as relative2, resolve as resolve2, sep as sep2 } from "path";
|
|
3291
3135
|
var TOKENS_PACKAGE = "@axis-ds/tokens";
|
|
@@ -3308,7 +3152,7 @@ var KEY_TOKENS = [
|
|
|
3308
3152
|
];
|
|
3309
3153
|
var BRAND_ADJUSTMENT_REFERENCE = "WI-0025 PRD \uBD80\uB85D B (docs/workitems/WI-0025-brand-theme/prd.md)";
|
|
3310
3154
|
function readJsonFile(file) {
|
|
3311
|
-
return JSON.parse(
|
|
3155
|
+
return JSON.parse(readFileSync2(file, "utf8"));
|
|
3312
3156
|
}
|
|
3313
3157
|
function errorCode(err) {
|
|
3314
3158
|
return typeof err === "object" && err !== null && "code" in err ? String(err.code) : void 0;
|
|
@@ -3317,7 +3161,7 @@ function findTokensPackageJson(baseDir) {
|
|
|
3317
3161
|
let dir = resolve2(baseDir);
|
|
3318
3162
|
for (; ; ) {
|
|
3319
3163
|
const candidate = join2(dir, "node_modules", TOKENS_PACKAGE, "package.json");
|
|
3320
|
-
if (
|
|
3164
|
+
if (existsSync2(candidate)) return candidate;
|
|
3321
3165
|
const parent = dirname2(dir);
|
|
3322
3166
|
if (parent === dir) return void 0;
|
|
3323
3167
|
dir = parent;
|
|
@@ -3347,9 +3191,9 @@ function resolveTokens(baseDir) {
|
|
|
3347
3191
|
function brandImportPath(entry) {
|
|
3348
3192
|
return tokensSpecifier(entry.css);
|
|
3349
3193
|
}
|
|
3350
|
-
function
|
|
3194
|
+
function isFile(file) {
|
|
3351
3195
|
try {
|
|
3352
|
-
return
|
|
3196
|
+
return statSync(file).isFile();
|
|
3353
3197
|
} catch {
|
|
3354
3198
|
return false;
|
|
3355
3199
|
}
|
|
@@ -3360,12 +3204,12 @@ function findGlobalCss(baseDir, config) {
|
|
|
3360
3204
|
const configured = config?.globalCss;
|
|
3361
3205
|
if (typeof configured === "string" && configured.trim() !== "") {
|
|
3362
3206
|
const file = resolve2(root, configured);
|
|
3363
|
-
if (
|
|
3207
|
+
if (isFile(file)) return { path: file };
|
|
3364
3208
|
result.configuredMissing = configured;
|
|
3365
3209
|
}
|
|
3366
3210
|
for (const candidate of GLOBAL_CSS_CANDIDATES) {
|
|
3367
3211
|
const file = join2(root, candidate);
|
|
3368
|
-
if (
|
|
3212
|
+
if (isFile(file)) {
|
|
3369
3213
|
result.path = file;
|
|
3370
3214
|
break;
|
|
3371
3215
|
}
|
|
@@ -3384,7 +3228,7 @@ var AXIS_CONFIG_FILE_NAME = "axis.config.json";
|
|
|
3384
3228
|
function readBrandConfig(baseDir) {
|
|
3385
3229
|
let parsed;
|
|
3386
3230
|
try {
|
|
3387
|
-
parsed = JSON.parse(
|
|
3231
|
+
parsed = JSON.parse(readFileSync2(join2(resolve2(baseDir), AXIS_CONFIG_FILE_NAME), "utf8"));
|
|
3388
3232
|
} catch {
|
|
3389
3233
|
return null;
|
|
3390
3234
|
}
|
|
@@ -3403,7 +3247,7 @@ function inspectBrandImport(baseDir) {
|
|
|
3403
3247
|
return { ...base, state: "css-missing", imports: [] };
|
|
3404
3248
|
}
|
|
3405
3249
|
const cssFile = relative2(root, location.path).split(sep2).join("/");
|
|
3406
|
-
const imports = [...new Set(findBrandImports(
|
|
3250
|
+
const imports = [...new Set(findBrandImports(readFileSync2(location.path, "utf8")))];
|
|
3407
3251
|
let state;
|
|
3408
3252
|
if (imports.includes(brand)) state = "match";
|
|
3409
3253
|
else if (imports.length === 0) state = "import-missing";
|
|
@@ -3512,15 +3356,15 @@ function findBrandActivation(baseDir) {
|
|
|
3512
3356
|
const layoutFiles = [];
|
|
3513
3357
|
for (const candidate of BRAND_ACTIVATION_FILES) {
|
|
3514
3358
|
const file = join2(root, candidate);
|
|
3515
|
-
if (!
|
|
3359
|
+
if (!isFile(file)) continue;
|
|
3516
3360
|
layoutFiles.push(candidate);
|
|
3517
|
-
const text = stripJsLikeComments(
|
|
3361
|
+
const text = stripJsLikeComments(readFileSync2(file, "utf8"));
|
|
3518
3362
|
const providerTexts = [];
|
|
3519
3363
|
for (const m of text.matchAll(/from\s+["']\.\/(providers?)["']/g)) {
|
|
3520
3364
|
for (const ext of [".tsx", ".jsx", ".ts", ".js"]) {
|
|
3521
3365
|
const rel3 = `${dirname2(candidate)}/${m[1]}${ext}`;
|
|
3522
3366
|
const p = join2(root, rel3);
|
|
3523
|
-
if (
|
|
3367
|
+
if (isFile(p)) providerTexts.push({ rel: rel3, text: stripJsLikeComments(readFileSync2(p, "utf8")) });
|
|
3524
3368
|
}
|
|
3525
3369
|
}
|
|
3526
3370
|
const all = [text, ...providerTexts.map((x) => x.text)];
|
|
@@ -3547,7 +3391,7 @@ function inspectBrandActivation(baseDir) {
|
|
|
3547
3391
|
var THEME_PACKAGE = "@axis-ds/theme";
|
|
3548
3392
|
function readProjectPackageJson(baseDir) {
|
|
3549
3393
|
try {
|
|
3550
|
-
const parsed = JSON.parse(
|
|
3394
|
+
const parsed = JSON.parse(readFileSync2(join2(resolve2(baseDir), "package.json"), "utf8"));
|
|
3551
3395
|
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
3552
3396
|
} catch {
|
|
3553
3397
|
return void 0;
|
|
@@ -3569,7 +3413,7 @@ function getBrand(baseDir, name) {
|
|
|
3569
3413
|
try {
|
|
3570
3414
|
summary = readSummary(baseDir, entry);
|
|
3571
3415
|
const cssPath = projectRequire(baseDir).resolve(summary.importPath);
|
|
3572
|
-
parsed = parseBrandCss(
|
|
3416
|
+
parsed = parseBrandCss(readFileSync2(cssPath, "utf8"), name);
|
|
3573
3417
|
} catch (err) {
|
|
3574
3418
|
if (isMissingBuildFile(err)) return { status: "not-built", version: tokens.version, brand: null, available: [] };
|
|
3575
3419
|
throw err;
|
|
@@ -3588,8 +3432,8 @@ function getBrand(baseDir, name) {
|
|
|
3588
3432
|
}
|
|
3589
3433
|
|
|
3590
3434
|
// ../axis-registry-core/src/template/dependencies-core.ts
|
|
3591
|
-
import { readFileSync as
|
|
3592
|
-
import { join as join3
|
|
3435
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
3436
|
+
import { join as join3 } from "path";
|
|
3593
3437
|
var REQUIRED_DEPENDENCIES = ["tailwindcss"];
|
|
3594
3438
|
var RECOMMENDED_DEPENDENCIES = ["clsx", "tailwind-merge"];
|
|
3595
3439
|
function declaredAxisPackages(pkg) {
|
|
@@ -3601,21 +3445,11 @@ function declaredAxisPackages(pkg) {
|
|
|
3601
3445
|
}
|
|
3602
3446
|
return out;
|
|
3603
3447
|
}
|
|
3604
|
-
function workspaceRootPackage(baseDir) {
|
|
3605
|
-
const root = findWorkspaceRoot(baseDir);
|
|
3606
|
-
if (root === void 0 || root === baseDir) return void 0;
|
|
3607
|
-
try {
|
|
3608
|
-
const parsed = JSON.parse(readFileSync4(join3(root, "package.json"), "utf8"));
|
|
3609
|
-
return isPlainObject(parsed) ? parsed : void 0;
|
|
3610
|
-
} catch {
|
|
3611
|
-
return void 0;
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
3448
|
function checkDependencies(baseDirInput) {
|
|
3615
|
-
const baseDir =
|
|
3449
|
+
const baseDir = resolveBaseDir(baseDirInput);
|
|
3616
3450
|
let pkg;
|
|
3617
3451
|
try {
|
|
3618
|
-
const parsed = JSON.parse(
|
|
3452
|
+
const parsed = JSON.parse(readFileSync3(join3(baseDir, "package.json"), "utf8"));
|
|
3619
3453
|
if (!isPlainObject(parsed)) throw new Error("not object");
|
|
3620
3454
|
pkg = parsed;
|
|
3621
3455
|
} catch (err) {
|
|
@@ -3624,17 +3458,18 @@ function checkDependencies(baseDirInput) {
|
|
|
3624
3458
|
}
|
|
3625
3459
|
return { name: "dependencies", severity: "fail", message: "package.json \uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4(JSON \uD655\uC778)" };
|
|
3626
3460
|
}
|
|
3627
|
-
const rootPkg = workspaceRootPackage(baseDir);
|
|
3628
|
-
const
|
|
3629
|
-
const
|
|
3461
|
+
const rootPkg = workspaceRootPackage(baseDir) ?? null;
|
|
3462
|
+
const declared = (d) => declaredDependency(baseDir, pkg, d, rootPkg);
|
|
3463
|
+
const fromRoot = (d) => declared(d)?.source === "root";
|
|
3464
|
+
const missingRequired = REQUIRED_DEPENDENCIES.filter((d) => declared(d) === void 0);
|
|
3630
3465
|
if (missingRequired.length > 0) {
|
|
3631
3466
|
return { name: "dependencies", severity: "fail", message: `\uD544\uC218 \uC758\uC874\uC131 \uB204\uB77D: ${missingRequired.join(", ")}` };
|
|
3632
3467
|
}
|
|
3633
|
-
const missingRecommended = RECOMMENDED_DEPENDENCIES.filter((d) =>
|
|
3468
|
+
const missingRecommended = RECOMMENDED_DEPENDENCIES.filter((d) => declared(d) === void 0);
|
|
3634
3469
|
const rootDeclared = [...REQUIRED_DEPENDENCIES, ...RECOMMENDED_DEPENDENCIES].filter((d) => fromRoot(d));
|
|
3635
3470
|
const rootNote = rootDeclared.length > 0 ? `\uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4 \uB8E8\uD2B8\uC5D0 \uC120\uC5B8: ${rootDeclared.join(", ")}` : void 0;
|
|
3636
3471
|
const targets = [
|
|
3637
|
-
...[...REQUIRED_DEPENDENCIES, ...RECOMMENDED_DEPENDENCIES].filter((d) =>
|
|
3472
|
+
...[...REQUIRED_DEPENDENCIES, ...RECOMMENDED_DEPENDENCIES].filter((d) => declared(d) !== void 0),
|
|
3638
3473
|
...declaredAxisPackages(pkg)
|
|
3639
3474
|
];
|
|
3640
3475
|
const pnp = isPnpProject(baseDir);
|
|
@@ -3662,7 +3497,7 @@ var SEVERITY_ICON = {
|
|
|
3662
3497
|
fail: chalk7.red("FAIL")
|
|
3663
3498
|
};
|
|
3664
3499
|
async function collectCheckResults(dir) {
|
|
3665
|
-
const baseDir =
|
|
3500
|
+
const baseDir = path10.resolve(dir || ".");
|
|
3666
3501
|
const results = [];
|
|
3667
3502
|
results.push(await checkFileExists(baseDir, "axis.config.json", "axis.config.json"));
|
|
3668
3503
|
results.push(checkTailwindSetup(baseDir));
|
|
@@ -3713,7 +3548,7 @@ async function runCheck(dir) {
|
|
|
3713
3548
|
return { pass: passCount, warn: warnCount, fail: failCount };
|
|
3714
3549
|
}
|
|
3715
3550
|
async function checkFileExists(baseDir, fileName, label) {
|
|
3716
|
-
const exists = await fs10.pathExists(
|
|
3551
|
+
const exists = await fs10.pathExists(path10.join(baseDir, fileName));
|
|
3717
3552
|
return {
|
|
3718
3553
|
name: label,
|
|
3719
3554
|
severity: exists ? "pass" : "fail",
|
|
@@ -3729,7 +3564,7 @@ async function checkUtils(baseDir) {
|
|
|
3729
3564
|
"utils.ts"
|
|
3730
3565
|
];
|
|
3731
3566
|
for (const candidate of candidates) {
|
|
3732
|
-
const fullPath =
|
|
3567
|
+
const fullPath = path10.join(baseDir, candidate);
|
|
3733
3568
|
if (await fs10.pathExists(fullPath)) {
|
|
3734
3569
|
const content = await fs10.readFile(fullPath, "utf-8");
|
|
3735
3570
|
const hasCn = content.includes("function cn");
|
|
@@ -3911,16 +3746,16 @@ function registerCheckCommand(program2) {
|
|
|
3911
3746
|
|
|
3912
3747
|
// src/theme/index.ts
|
|
3913
3748
|
import chalk9 from "chalk";
|
|
3914
|
-
import
|
|
3749
|
+
import path12 from "path";
|
|
3915
3750
|
|
|
3916
3751
|
// src/theme/theme-add.ts
|
|
3917
|
-
import { accessSync, constants, existsSync as
|
|
3918
|
-
import
|
|
3752
|
+
import { accessSync, constants, existsSync as existsSync3, readFileSync as readFileSync4, realpathSync as realpathSync2, unlinkSync, writeFileSync } from "fs";
|
|
3753
|
+
import path11 from "path";
|
|
3919
3754
|
var TOKENS_DEPENDENCY_RANGE = `^${TOKENS_DEPENDENCY_MIN_VERSION}`;
|
|
3920
3755
|
var TAILWIND3_BASE_IMPORTS = [`${TOKENS_PACKAGE}/css`, `${TOKENS_PACKAGE}/css/shadcn`];
|
|
3921
3756
|
var THEME_MIN_VERSION = "1.3.0";
|
|
3922
3757
|
function readText(file) {
|
|
3923
|
-
return
|
|
3758
|
+
return existsSync3(file) ? readFileSync4(file, "utf8") : null;
|
|
3924
3759
|
}
|
|
3925
3760
|
function eolOf(text) {
|
|
3926
3761
|
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
@@ -4013,15 +3848,15 @@ function compareVersions(a, b) {
|
|
|
4013
3848
|
function realPathInside(baseDir, file) {
|
|
4014
3849
|
const realBase = realpathSync2(baseDir);
|
|
4015
3850
|
const realPath = realpathSync2(file);
|
|
4016
|
-
const relPath =
|
|
4017
|
-
const inside = relPath !== "" && !relPath.startsWith("..") && !
|
|
3851
|
+
const relPath = path11.relative(realBase, realPath);
|
|
3852
|
+
const inside = relPath !== "" && !relPath.startsWith("..") && !path11.isAbsolute(relPath);
|
|
4018
3853
|
return { inside, realPath };
|
|
4019
3854
|
}
|
|
4020
3855
|
function isStylesheet(realPath) {
|
|
4021
|
-
return
|
|
3856
|
+
return path11.extname(realPath).toLowerCase() === ".css";
|
|
4022
3857
|
}
|
|
4023
3858
|
function planThemeAdd(baseDirInput, brand) {
|
|
4024
|
-
const baseDir =
|
|
3859
|
+
const baseDir = path11.resolve(baseDirInput);
|
|
4025
3860
|
const plan = {
|
|
4026
3861
|
baseDir,
|
|
4027
3862
|
brand,
|
|
@@ -4033,7 +3868,7 @@ function planThemeAdd(baseDirInput, brand) {
|
|
|
4033
3868
|
installCommand: detectInstallCommand(baseDir),
|
|
4034
3869
|
writes: []
|
|
4035
3870
|
};
|
|
4036
|
-
const configFile =
|
|
3871
|
+
const configFile = path11.join(baseDir, AXIS_CONFIG_FILE);
|
|
4037
3872
|
const configText = readText(configFile);
|
|
4038
3873
|
if (configText === null) {
|
|
4039
3874
|
plan.errors.push({ kind: "no-config" });
|
|
@@ -4054,7 +3889,7 @@ function planThemeAdd(baseDirInput, brand) {
|
|
|
4054
3889
|
}
|
|
4055
3890
|
plan.tokens = resolveTokens(baseDir);
|
|
4056
3891
|
if (plan.tokens.status === "ok" && plan.tokens.indexPath) {
|
|
4057
|
-
const data = JSON.parse(
|
|
3892
|
+
const data = JSON.parse(readFileSync4(plan.tokens.indexPath, "utf8"));
|
|
4058
3893
|
const entries = Array.isArray(data.brands) ? data.brands : [];
|
|
4059
3894
|
const entry = entries.find((e) => e.name === brand);
|
|
4060
3895
|
if (!entry) {
|
|
@@ -4070,7 +3905,7 @@ function planThemeAdd(baseDirInput, brand) {
|
|
|
4070
3905
|
} else {
|
|
4071
3906
|
plan.unverifiedBrand = true;
|
|
4072
3907
|
}
|
|
4073
|
-
const pkgFile =
|
|
3908
|
+
const pkgFile = path11.join(baseDir, "package.json");
|
|
4074
3909
|
const pkgText = readText(pkgFile);
|
|
4075
3910
|
let pkg;
|
|
4076
3911
|
if (pkgText !== null) {
|
|
@@ -4105,7 +3940,7 @@ function planThemeAdd(baseDirInput, brand) {
|
|
|
4105
3940
|
plan.writes = [];
|
|
4106
3941
|
return plan;
|
|
4107
3942
|
}
|
|
4108
|
-
const before =
|
|
3943
|
+
const before = readFileSync4(location.path, "utf8");
|
|
4109
3944
|
const imported = findBrandImports(before);
|
|
4110
3945
|
const otherBrands = [...new Set(imported.filter((n) => n !== brand))];
|
|
4111
3946
|
const brandAdded = !imported.includes(brand);
|
|
@@ -4138,11 +3973,11 @@ function planThemeAdd(baseDirInput, brand) {
|
|
|
4138
3973
|
};
|
|
4139
3974
|
}
|
|
4140
3975
|
if (!tailwind4) {
|
|
4141
|
-
const configFile2 = TAILWIND_CONFIG_FILES.find((f) =>
|
|
3976
|
+
const configFile2 = TAILWIND_CONFIG_FILES.find((f) => existsSync3(path11.join(baseDir, f)));
|
|
4142
3977
|
const content = inspectTailwindContent(baseDir);
|
|
4143
3978
|
plan.tailwindConfig = {
|
|
4144
3979
|
configFile: configFile2,
|
|
4145
|
-
presetMissing: configFile2 === void 0 || !hasTokensPresetReference(
|
|
3980
|
+
presetMissing: configFile2 === void 0 || !hasTokensPresetReference(readFileSync4(path11.join(baseDir, configFile2), "utf8")),
|
|
4146
3981
|
contentMissing: content?.targets.filter((t) => !t.covered) ?? [],
|
|
4147
3982
|
contentUnknown: content !== null && (content.unreadable || content.dynamic)
|
|
4148
3983
|
};
|
|
@@ -4198,8 +4033,8 @@ function applyThemeAdd(plan) {
|
|
|
4198
4033
|
if (current !== w.before) {
|
|
4199
4034
|
throw new Error(`${w.file} \uC774 \uACC4\uD68D \uB4A4\uC5D0 \uBC14\uB00C\uC5C8\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.`);
|
|
4200
4035
|
}
|
|
4201
|
-
const where = realPathInside(plan.baseDir, w.before === null ?
|
|
4202
|
-
if (!where.inside && !(w.before === null &&
|
|
4036
|
+
const where = realPathInside(plan.baseDir, w.before === null ? path11.dirname(w.file) : w.file);
|
|
4037
|
+
if (!where.inside && !(w.before === null && path11.dirname(w.file) === plan.baseDir)) {
|
|
4203
4038
|
throw new Error(`${w.file} \uC758 \uC2E4\uC81C \uC704\uCE58(${where.realPath})\uAC00 \uD504\uB85C\uC81D\uD2B8 \uB514\uB809\uD130\uB9AC \uBC16\uC785\uB2C8\uB2E4. \uC544\uBB34\uAC83\uB3C4 \uC4F0\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4.`);
|
|
4204
4039
|
}
|
|
4205
4040
|
if (!w.file.endsWith(".json") && !isStylesheet(where.realPath)) {
|
|
@@ -4211,7 +4046,7 @@ function applyThemeAdd(plan) {
|
|
|
4211
4046
|
throw new Error(`${w.file}: \uBE0C\uB79C\uB4DC import \uAC00 \uC815\uD655\uD788 1\uC904\uC774 \uC544\uB2D9\uB2C8\uB2E4`);
|
|
4212
4047
|
}
|
|
4213
4048
|
try {
|
|
4214
|
-
accessSync(w.before === null ?
|
|
4049
|
+
accessSync(w.before === null ? path11.dirname(w.file) : w.file, constants.W_OK);
|
|
4215
4050
|
} catch (err) {
|
|
4216
4051
|
throw new Error(`${w.file} \uC5D0 \uC4F8 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4(${errorMessage(err)}).`);
|
|
4217
4052
|
}
|
|
@@ -4287,7 +4122,7 @@ function tokensStatusGuide(status, version, installCommand = TOKENS_INSTALL_COMM
|
|
|
4287
4122
|
chalk9.yellow(
|
|
4288
4123
|
`${TOKENS_PACKAGE}${version ? ` ${version}` : ""} \uB294 \uC788\uC9C0\uB9CC \uBE4C\uB4DC \uC0B0\uCD9C\uBB3C\uC774 \uC5C6\uC5B4 \uBE0C\uB79C\uB4DC\uB97C \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.`
|
|
4289
4124
|
),
|
|
4290
|
-
` \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uBA74 ${chalk9.cyan(
|
|
4125
|
+
` \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uBA74 ${chalk9.cyan(workspaceRunCommand(installCommand, TOKENS_PACKAGE, "build"))}, \uC544\uB2C8\uBA74 \uC7AC\uC124\uCE58: ${chalk9.cyan(installCommand)}`
|
|
4291
4126
|
];
|
|
4292
4127
|
}
|
|
4293
4128
|
}
|
|
@@ -4384,7 +4219,7 @@ function renderThemeInfo(result, name, installCommand) {
|
|
|
4384
4219
|
return { lines, exitCode: 0 };
|
|
4385
4220
|
}
|
|
4386
4221
|
function rel(plan, file) {
|
|
4387
|
-
return
|
|
4222
|
+
return path12.relative(plan.baseDir, file) || file;
|
|
4388
4223
|
}
|
|
4389
4224
|
function renderThemeAdd(plan, written) {
|
|
4390
4225
|
const error = plan.errors[0];
|
|
@@ -4579,15 +4414,15 @@ function print(output) {
|
|
|
4579
4414
|
function registerThemeCommand(program2) {
|
|
4580
4415
|
const themeCmd = program2.command("theme").description("\uBE0C\uB79C\uB4DC \uD14C\uB9C8 (@axis-ds/tokens \uBE0C\uB79C\uB4DC)");
|
|
4581
4416
|
themeCmd.command("list").alias("ls").description("\uC124\uCE58\uB41C @axis-ds/tokens \uC758 \uBE0C\uB79C\uB4DC \uBAA9\uB85D").option("-d, --dir <path>", "\uB300\uC0C1 \uB514\uB809\uD1A0\uB9AC").action((options) => {
|
|
4582
|
-
const baseDir =
|
|
4417
|
+
const baseDir = path12.resolve(options.dir || ".");
|
|
4583
4418
|
print(renderThemeList(listBrands(baseDir), tokensInstallCommand(baseDir)));
|
|
4584
4419
|
});
|
|
4585
4420
|
themeCmd.command("info <brand>").description("\uBE0C\uB79C\uB4DC \uC0C1\uC138: import \uACBD\uB85C \xB7 Provider \uC608\uC2DC \xB7 \uC8FC\uC694 \uD1A0\uD070 \xB7 \uBCF4\uC815 \uB0B4\uC5ED").option("-d, --dir <path>", "\uB300\uC0C1 \uB514\uB809\uD1A0\uB9AC").action((name, options) => {
|
|
4586
|
-
const baseDir =
|
|
4421
|
+
const baseDir = path12.resolve(options.dir || ".");
|
|
4587
4422
|
print(renderThemeInfo(getBrand(baseDir, name), name, tokensInstallCommand(baseDir)));
|
|
4588
4423
|
});
|
|
4589
4424
|
themeCmd.command("add <brand>").description("\uBE0C\uB79C\uB4DC \uC801\uC6A9: CSS import \xB7 package.json \uC758\uC874\uC131 \xB7 axis.config.json brand (\uC124\uCE58\uB294 \uC548\uB0B4\uB9CC)").option("-d, --dir <path>", "\uB300\uC0C1 \uB514\uB809\uD1A0\uB9AC").action((name, options) => {
|
|
4590
|
-
const baseDir =
|
|
4425
|
+
const baseDir = path12.resolve(options.dir || ".");
|
|
4591
4426
|
const plan = planThemeAdd(baseDir, name);
|
|
4592
4427
|
let written = [];
|
|
4593
4428
|
if (plan.errors.length === 0) {
|
|
@@ -4906,14 +4741,14 @@ async function fetchRegistryJson(url, options = {}) {
|
|
|
4906
4741
|
}
|
|
4907
4742
|
|
|
4908
4743
|
// src/init/init.ts
|
|
4909
|
-
import { accessSync as accessSync2, constants as constants2, existsSync as
|
|
4910
|
-
import
|
|
4744
|
+
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync5, lstatSync as lstatSync3, readFileSync as readFileSync5, realpathSync as realpathSync4, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
4745
|
+
import path14 from "path";
|
|
4911
4746
|
import chalk10 from "chalk";
|
|
4912
4747
|
import fs12 from "fs-extra";
|
|
4913
4748
|
|
|
4914
4749
|
// ../axis-registry-core/src/add/safe-write.ts
|
|
4915
|
-
import { constants as fsConstants, existsSync as
|
|
4916
|
-
import
|
|
4750
|
+
import { constants as fsConstants, existsSync as existsSync4, lstatSync as lstatSync2, realpathSync as realpathSync3, statSync as statSync2 } from "fs";
|
|
4751
|
+
import path13 from "path";
|
|
4917
4752
|
import fs11 from "fs-extra";
|
|
4918
4753
|
var NEW_FILE_FLAGS = fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL | (fsConstants.O_NOFOLLOW ?? 0);
|
|
4919
4754
|
var OVERWRITE_FLAGS = fsConstants.O_WRONLY | (fsConstants.O_NOFOLLOW ?? 0);
|
|
@@ -4924,15 +4759,15 @@ function codedError(code, message) {
|
|
|
4924
4759
|
e.code = code;
|
|
4925
4760
|
return e;
|
|
4926
4761
|
}
|
|
4927
|
-
function isSameOrInside(parent, child, impl =
|
|
4762
|
+
function isSameOrInside(parent, child, impl = path13) {
|
|
4928
4763
|
const rel3 = impl.relative(parent, child);
|
|
4929
4764
|
if (rel3 === "") return true;
|
|
4930
4765
|
return !(rel3 === ".." || rel3.startsWith(`..${impl.sep}`) || impl.isAbsolute(rel3));
|
|
4931
4766
|
}
|
|
4932
4767
|
function nearestExisting(p) {
|
|
4933
4768
|
let cur = p;
|
|
4934
|
-
while (!
|
|
4935
|
-
const up =
|
|
4769
|
+
while (!existsSync4(cur)) {
|
|
4770
|
+
const up = path13.dirname(cur);
|
|
4936
4771
|
if (up === cur) return cur;
|
|
4937
4772
|
cur = up;
|
|
4938
4773
|
}
|
|
@@ -4940,10 +4775,10 @@ function nearestExisting(p) {
|
|
|
4940
4775
|
}
|
|
4941
4776
|
function escapeReason(root, target, options = {}) {
|
|
4942
4777
|
const realRoot = realpathSync3(root);
|
|
4943
|
-
if (!isSameOrInside(
|
|
4778
|
+
if (!isSameOrInside(path13.resolve(root), path13.resolve(target)) || path13.resolve(target) === path13.resolve(root)) {
|
|
4944
4779
|
return `\uACBD\uB85C\uAC00 \uD504\uB85C\uC81D\uD2B8 \uB514\uB809\uD130\uB9AC \uBC16\uC785\uB2C8\uB2E4(${target})`;
|
|
4945
4780
|
}
|
|
4946
|
-
const anchor = nearestExisting(
|
|
4781
|
+
const anchor = nearestExisting(path13.dirname(target));
|
|
4947
4782
|
const realAnchor = realpathSync3(anchor);
|
|
4948
4783
|
if (!isSameOrInside(realRoot, realAnchor)) {
|
|
4949
4784
|
return `\uC0C1\uC704 \uB514\uB809\uD130\uB9AC\uC758 \uC2E4\uC81C \uC704\uCE58(${realAnchor})\uAC00 \uD504\uB85C\uC81D\uD2B8 \uB514\uB809\uD130\uB9AC \uBC16\uC785\uB2C8\uB2E4`;
|
|
@@ -4956,7 +4791,7 @@ function escapeReason(root, target, options = {}) {
|
|
|
4956
4791
|
}
|
|
4957
4792
|
if (st) {
|
|
4958
4793
|
if (st.isDirectory()) return `\uAC19\uC740 \uC774\uB984\uC758 \uB514\uB809\uD130\uB9AC\uAC00 \uC788\uC2B5\uB2C8\uB2E4(${target})`;
|
|
4959
|
-
const shown =
|
|
4794
|
+
const shown = path13.relative(path13.resolve(root), path13.resolve(target)).split(path13.sep).join("/");
|
|
4960
4795
|
let realTarget;
|
|
4961
4796
|
try {
|
|
4962
4797
|
realTarget = realpathSync3(target);
|
|
@@ -4968,7 +4803,7 @@ function escapeReason(root, target, options = {}) {
|
|
|
4968
4803
|
}
|
|
4969
4804
|
let followed;
|
|
4970
4805
|
try {
|
|
4971
|
-
followed =
|
|
4806
|
+
followed = statSync2(realTarget);
|
|
4972
4807
|
} catch {
|
|
4973
4808
|
return `\uAE30\uC874 \uD30C\uC77C \uC815\uBCF4\uB97C \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4(${target})`;
|
|
4974
4809
|
}
|
|
@@ -5060,7 +4895,7 @@ async function overwriteFollowingLinks(target, content) {
|
|
|
5060
4895
|
}
|
|
5061
4896
|
function checkParentInside(root, target) {
|
|
5062
4897
|
const realRoot = realpathSync3(root);
|
|
5063
|
-
const realParent = realpathSync3(
|
|
4898
|
+
const realParent = realpathSync3(path13.dirname(target));
|
|
5064
4899
|
if (!isSameOrInside(realRoot, realParent)) {
|
|
5065
4900
|
return `\uBD80\uBAA8 \uB514\uB809\uD130\uB9AC\uC758 \uC2E4\uC81C \uC704\uCE58(${realParent})\uAC00 \uD504\uB85C\uC81D\uD2B8 \uB514\uB809\uD130\uB9AC \uBC16\uC785\uB2C8\uB2E4`;
|
|
5066
4901
|
}
|
|
@@ -5132,7 +4967,7 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
5132
4967
|
}
|
|
5133
4968
|
`;
|
|
5134
4969
|
async function resolveInitAnswers(baseDirInput, tailwind4) {
|
|
5135
|
-
const baseDir =
|
|
4970
|
+
const baseDir = path14.resolve(baseDirInput);
|
|
5136
4971
|
const tw4 = tailwind4 ?? isTailwind4(planUtilsDependencies(baseDir).tailwind);
|
|
5137
4972
|
const current = await existingConfig(baseDir);
|
|
5138
4973
|
const found = detectProjectPaths(baseDir);
|
|
@@ -5178,7 +5013,7 @@ var TAILWIND4_TOKENS_VERSION = TAILWIND4_MIN_AXIS_VERSION;
|
|
|
5178
5013
|
var TAILWIND4_CONFLICT_LINE = " ! create-next-app \uAE30\uBCF8 globals.css \uC758 :root \xB7 @theme inline \xB7 @media (prefers-color-scheme: dark) \xB7 body \uBE14\uB85D\uC740 AXIS \uC640 \uAC19\uC740 \uC774\uB984(--background \xB7 --foreground \xB7 --color-background \xB7 --font-sans \xB7 --font-mono)\uC744 \uB2E4\uB978 \uAC12\uC73C\uB85C \uC815\uC758\uD569\uB2C8\uB2E4. \uC774 \uBE14\uB85D\uB4E4\uC744 \uC9C0\uC6B0\uC138\uC694.";
|
|
5179
5014
|
function readPackageJsonSafe(baseDir) {
|
|
5180
5015
|
try {
|
|
5181
|
-
const text =
|
|
5016
|
+
const text = readFileSync5(path14.join(baseDir, "package.json"), "utf8");
|
|
5182
5017
|
const parsed = JSON.parse(text.startsWith(BOM) ? text.slice(1) : text);
|
|
5183
5018
|
return isPlainObject(parsed) ? parsed : void 0;
|
|
5184
5019
|
} catch {
|
|
@@ -5186,7 +5021,8 @@ function readPackageJsonSafe(baseDir) {
|
|
|
5186
5021
|
}
|
|
5187
5022
|
}
|
|
5188
5023
|
function tailwind4GuideLines(pkg, installCommand, globalCss, baseDir) {
|
|
5189
|
-
const
|
|
5024
|
+
const declared = (name) => pkg !== void 0 && (baseDir !== void 0 ? declaredDependency(baseDir, pkg, name) : hasDependency(pkg, name)) !== void 0;
|
|
5025
|
+
const used = TAILWIND4_COMPONENT_PACKAGES.filter((name) => declared(name));
|
|
5190
5026
|
const lines = [
|
|
5191
5027
|
`Tailwind 4: \uC804\uC5ED CSS(${globalCss}) \uB9E8 \uC704\uC5D0 \uB2E4\uC74C \uC904\uC744 \uB123\uC73C\uC138\uC694(\uD30C\uC77C\uC740 \uACE0\uCE58\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4).`,
|
|
5192
5028
|
' @import "tailwindcss";',
|
|
@@ -5199,7 +5035,7 @@ function tailwind4GuideLines(pkg, installCommand, globalCss, baseDir) {
|
|
|
5199
5035
|
);
|
|
5200
5036
|
}
|
|
5201
5037
|
lines.push(TAILWIND4_CONFLICT_LINE);
|
|
5202
|
-
if (
|
|
5038
|
+
if (!declared(TOKENS_PACKAGE)) {
|
|
5203
5039
|
const add = addCommandFor(installCommand, { [TOKENS_PACKAGE]: `^${TAILWIND4_TOKENS_VERSION}` });
|
|
5204
5040
|
lines.push(` ${TOKENS_PACKAGE} \uC124\uCE58: ${add}`);
|
|
5205
5041
|
}
|
|
@@ -5237,7 +5073,7 @@ function tailwind4GuideLines(pkg, installCommand, globalCss, baseDir) {
|
|
|
5237
5073
|
}
|
|
5238
5074
|
var BOM = "\uFEFF";
|
|
5239
5075
|
function planUtilsDependencies(baseDirInput) {
|
|
5240
|
-
const baseDir =
|
|
5076
|
+
const baseDir = path14.resolve(baseDirInput);
|
|
5241
5077
|
const installCommand = detectInstallCommand(baseDir);
|
|
5242
5078
|
const tailwind0 = detectTailwind(baseDir);
|
|
5243
5079
|
const ranges0 = selectUtilsDependencies(tailwind0);
|
|
@@ -5250,8 +5086,8 @@ function planUtilsDependencies(baseDirInput) {
|
|
|
5250
5086
|
installCommand,
|
|
5251
5087
|
addCommand: addCommandFor(installCommand, ranges0)
|
|
5252
5088
|
};
|
|
5253
|
-
const pkgFile =
|
|
5254
|
-
if (!
|
|
5089
|
+
const pkgFile = path14.join(baseDir, "package.json");
|
|
5090
|
+
if (!existsSync5(pkgFile)) return plan;
|
|
5255
5091
|
const unwritable = (reason) => ({ ...plan, action: "unwritable", reason });
|
|
5256
5092
|
let where;
|
|
5257
5093
|
try {
|
|
@@ -5262,7 +5098,7 @@ function planUtilsDependencies(baseDirInput) {
|
|
|
5262
5098
|
if (!where.inside) return unwritable(`\uC2E4\uC81C \uC704\uCE58(${where.realPath})\uAC00 \uD504\uB85C\uC81D\uD2B8 \uB514\uB809\uD130\uB9AC \uBC16\uC785\uB2C8\uB2E4`);
|
|
5263
5099
|
let text;
|
|
5264
5100
|
try {
|
|
5265
|
-
text =
|
|
5101
|
+
text = readFileSync5(pkgFile, "utf8");
|
|
5266
5102
|
} catch (err) {
|
|
5267
5103
|
return unwritable(err.message);
|
|
5268
5104
|
}
|
|
@@ -5281,8 +5117,8 @@ function planUtilsDependencies(baseDirInput) {
|
|
|
5281
5117
|
plan.addCommand = addCommandFor(installCommand, plan.ranges);
|
|
5282
5118
|
const missing = {};
|
|
5283
5119
|
for (const [name, range] of Object.entries(plan.ranges)) {
|
|
5284
|
-
const declared =
|
|
5285
|
-
if (declared !== void 0) plan.present.push({ name, range: declared });
|
|
5120
|
+
const declared = declaredDependency(baseDir, pkg, name);
|
|
5121
|
+
if (declared !== void 0) plan.present.push({ name, range: declared.range, source: declared.source });
|
|
5286
5122
|
else missing[name] = range;
|
|
5287
5123
|
}
|
|
5288
5124
|
plan.added = Object.keys(missing);
|
|
@@ -5304,8 +5140,8 @@ var defaultWriteFile = (file, data) => writeFileSync2(file, data);
|
|
|
5304
5140
|
function applyUtilsDependencies(baseDirInput, plan, writeFile = defaultWriteFile) {
|
|
5305
5141
|
const w = plan.write;
|
|
5306
5142
|
if (plan.action !== "add" || !w) return false;
|
|
5307
|
-
const baseDir =
|
|
5308
|
-
const current =
|
|
5143
|
+
const baseDir = path14.resolve(baseDirInput);
|
|
5144
|
+
const current = existsSync5(w.file) ? readFileSync5(w.file, "utf8") : null;
|
|
5309
5145
|
if (current !== w.before) {
|
|
5310
5146
|
throw new Error(`${w.file} \uC774 \uACC4\uD68D \uB4A4\uC5D0 \uBC14\uB00C\uC5C8\uC2B5\uB2C8\uB2E4. \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.`);
|
|
5311
5147
|
}
|
|
@@ -5321,7 +5157,7 @@ function applyUtilsDependencies(baseDirInput, plan, writeFile = defaultWriteFile
|
|
|
5321
5157
|
let restored;
|
|
5322
5158
|
try {
|
|
5323
5159
|
writeFile(w.file, w.before);
|
|
5324
|
-
if (
|
|
5160
|
+
if (readFileSync5(w.file, "utf8") !== w.before) throw new Error("\uB418\uB3CC\uB9B0 \uB0B4\uC6A9\uC774 \uC6D0\uB798 \uB0B4\uC6A9\uACFC \uB2E4\uB985\uB2C8\uB2E4");
|
|
5325
5161
|
restored = "\uC6D0\uB798 \uB0B4\uC6A9\uC73C\uB85C \uB418\uB3CC\uB838\uC2B5\uB2C8\uB2E4";
|
|
5326
5162
|
} catch (restoreErr) {
|
|
5327
5163
|
restored = `\uC6D0\uB798 \uB0B4\uC6A9\uC73C\uB85C \uB418\uB3CC\uB9AC\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4(${restoreErr.message}). \uD30C\uC77C\uC774 \uC798\uB838\uAC70\uB098 \uBE44\uC5C8\uC744 \uC218 \uC788\uC73C\uB2C8 \uBC84\uC804 \uAD00\uB9AC \uB3C4\uAD6C \uB4F1\uC73C\uB85C \uBCF5\uAD6C\uD558\uC138\uC694`;
|
|
@@ -5332,6 +5168,8 @@ function applyUtilsDependencies(baseDirInput, plan, writeFile = defaultWriteFile
|
|
|
5332
5168
|
}
|
|
5333
5169
|
function reportDependencies(plan, log) {
|
|
5334
5170
|
const presentText = plan.present.map((p) => `${p.name} (${p.range})`).join(", ");
|
|
5171
|
+
const rootPresent = plan.present.filter((p) => p.source === "root").map((p) => p.name);
|
|
5172
|
+
const rootNote = rootPresent.length > 0 ? ` (\uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4 \uB8E8\uD2B8\uC5D0 \uC120\uC5B8: ${rootPresent.join(", ")})` : "";
|
|
5335
5173
|
const basis = ` tailwind-merge \uBC94\uC704 \uAE30\uC900: ${describeTailwindBasis(plan.tailwind)}`;
|
|
5336
5174
|
const logBasis = () => {
|
|
5337
5175
|
log(chalk10.gray(basis));
|
|
@@ -5340,11 +5178,11 @@ function reportDependencies(plan, log) {
|
|
|
5340
5178
|
if (plan.action === "add") {
|
|
5341
5179
|
const addedText = plan.added.map((n) => `${n}@${plan.ranges[n]}`).join(", ");
|
|
5342
5180
|
log(chalk10.green(`\u2713 package.json dependencies \uC5D0 \uCD94\uAC00: ${addedText}`));
|
|
5343
|
-
if (plan.present.length > 0) log(chalk10.gray(` \uC774\uBBF8 \uC788\uC74C(\uBC84\uC804 \uC720\uC9C0): ${presentText}`));
|
|
5181
|
+
if (plan.present.length > 0) log(chalk10.gray(` \uC774\uBBF8 \uC788\uC74C(\uBC84\uC804 \uC720\uC9C0): ${presentText}${rootNote}`));
|
|
5344
5182
|
if (plan.added.includes("tailwind-merge")) logBasis();
|
|
5345
5183
|
log(chalk10.yellow(` \uC124\uCE58\uB294 \uC2E4\uD589\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \uC124\uCE58: ${chalk10.cyan(plan.installCommand)}`));
|
|
5346
5184
|
} else if (plan.action === "present") {
|
|
5347
|
-
log(chalk10.green(`\u2713 utils.ts \uC758\uC874\uC131\uC774 package.json \uC5D0 \uC774\uBBF8 \uC788\uC2B5\uB2C8\uB2E4(\uBC84\uC804 \uC720\uC9C0): ${presentText}`));
|
|
5185
|
+
log(chalk10.green(`\u2713 utils.ts \uC758\uC874\uC131\uC774 package.json \uC5D0 \uC774\uBBF8 \uC788\uC2B5\uB2C8\uB2E4(\uBC84\uC804 \uC720\uC9C0): ${presentText}${rootNote}`));
|
|
5348
5186
|
log(chalk10.yellow(` \uC124\uCE58\uB294 \uC2E4\uD589\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. \uC124\uCE58: ${chalk10.cyan(plan.installCommand)}`));
|
|
5349
5187
|
} else if (plan.action === "no-package-json") {
|
|
5350
5188
|
log(chalk10.yellow("! package.json \uC774 \uC5C6\uC5B4 utils.ts \uC758\uC874\uC131(clsx, tailwind-merge)\uC744 \uCD94\uAC00\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."));
|
|
@@ -5400,8 +5238,8 @@ function errCode(e) {
|
|
|
5400
5238
|
return e.code ?? e.message;
|
|
5401
5239
|
}
|
|
5402
5240
|
function planUtilsWrite(baseDirInput, utilsPath) {
|
|
5403
|
-
const baseDir =
|
|
5404
|
-
const shown =
|
|
5241
|
+
const baseDir = path14.resolve(baseDirInput);
|
|
5242
|
+
const shown = path14.relative(baseDir, utilsPath).split(path14.sep).join("/") || utilsPath;
|
|
5405
5243
|
let st;
|
|
5406
5244
|
try {
|
|
5407
5245
|
st = lstatSync3(utilsPath);
|
|
@@ -5424,7 +5262,7 @@ function planUtilsWrite(baseDirInput, utilsPath) {
|
|
|
5424
5262
|
}
|
|
5425
5263
|
let target;
|
|
5426
5264
|
try {
|
|
5427
|
-
target =
|
|
5265
|
+
target = statSync3(real);
|
|
5428
5266
|
} catch (e) {
|
|
5429
5267
|
return { action: "reject", reason: `${shown} \uB9C1\uD06C \uB300\uC0C1(${real})\uC758 \uC815\uBCF4\uB97C \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4(${errCode(e)})` };
|
|
5430
5268
|
}
|
|
@@ -5432,7 +5270,7 @@ function planUtilsWrite(baseDirInput, utilsPath) {
|
|
|
5432
5270
|
if (!target.isFile()) return { action: "reject", reason: `${shown} \uB9C1\uD06C \uB300\uC0C1(${real})\uC774 \uC77C\uBC18 \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4` };
|
|
5433
5271
|
let content2;
|
|
5434
5272
|
try {
|
|
5435
|
-
content2 =
|
|
5273
|
+
content2 = readFileSync5(utilsPath, "utf8");
|
|
5436
5274
|
} catch (e) {
|
|
5437
5275
|
return { action: "reject", reason: `${shown} \uB9C1\uD06C \uB300\uC0C1(${real})\uC744 \uC77D\uC9C0 \uBABB\uD574 \uBE44\uAD50\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4(${errCode(e)})` };
|
|
5438
5276
|
}
|
|
@@ -5447,7 +5285,7 @@ function planUtilsWrite(baseDirInput, utilsPath) {
|
|
|
5447
5285
|
if (!st.isFile()) return { action: "reject", reason: `${shown} \uC774 \uC77C\uBC18 \uD30C\uC77C\uC774 \uC544\uB2C8\uB77C \uC4F0\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4` };
|
|
5448
5286
|
let content;
|
|
5449
5287
|
try {
|
|
5450
|
-
content =
|
|
5288
|
+
content = readFileSync5(utilsPath, "utf8");
|
|
5451
5289
|
} catch (e) {
|
|
5452
5290
|
return { action: "reject", reason: `\uAE30\uC874 ${shown} \uC744 \uC77D\uC9C0 \uBABB\uD574 \uBE44\uAD50\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4(${errCode(e)})` };
|
|
5453
5291
|
}
|
|
@@ -5462,7 +5300,7 @@ function planUtilsWrite(baseDirInput, utilsPath) {
|
|
|
5462
5300
|
return { action: "overwrite" };
|
|
5463
5301
|
}
|
|
5464
5302
|
async function runInit(baseDirInput, answers, registryUrl, log = console.log, options = {}) {
|
|
5465
|
-
const baseDir =
|
|
5303
|
+
const baseDir = path14.resolve(baseDirInput);
|
|
5466
5304
|
const current = await existingConfig(baseDir);
|
|
5467
5305
|
const existingRegistry = nonEmptyString(current?.registry);
|
|
5468
5306
|
const migratedRegistry = existingRegistry !== void 0 && isLegacyDefaultRegistryUrl(existingRegistry);
|
|
@@ -5479,7 +5317,7 @@ async function runInit(baseDirInput, answers, registryUrl, log = console.log, op
|
|
|
5479
5317
|
},
|
|
5480
5318
|
registry
|
|
5481
5319
|
);
|
|
5482
|
-
const configPath =
|
|
5320
|
+
const configPath = path14.join(baseDir, "axis.config.json");
|
|
5483
5321
|
const rejects = [];
|
|
5484
5322
|
let previousText = null;
|
|
5485
5323
|
try {
|
|
@@ -5500,16 +5338,16 @@ async function runInit(baseDirInput, answers, registryUrl, log = console.log, op
|
|
|
5500
5338
|
}
|
|
5501
5339
|
if (previousText !== null && previousText !== nextText) {
|
|
5502
5340
|
try {
|
|
5503
|
-
const st =
|
|
5341
|
+
const st = statSync3(configPath);
|
|
5504
5342
|
if (st.isFile() && st.nlink >= 2) rejects.push(hardLinkMessage("axis.config.json", st.nlink));
|
|
5505
5343
|
} catch {
|
|
5506
5344
|
}
|
|
5507
5345
|
}
|
|
5508
|
-
const utilsPath =
|
|
5346
|
+
const utilsPath = path14.resolve(baseDir, answers.componentsDir, "utils.ts");
|
|
5509
5347
|
const utilsPlan = planUtilsWrite(baseDir, utilsPath);
|
|
5510
5348
|
if (utilsPlan.action === "reject") rejects.push(utilsPlan.reason);
|
|
5511
5349
|
if (utilsPlan.action === "overwrite" && options.allowOverwrite === false) {
|
|
5512
|
-
const shown =
|
|
5350
|
+
const shown = path14.relative(baseDir, utilsPath).split(path14.sep).join("/") || utilsPath;
|
|
5513
5351
|
rejects.push(
|
|
5514
5352
|
`\uBE44\uB300\uD654\uD615 \uC2E4\uD589\uC774\uB77C \uB0B4\uC6A9\uC774 \uB2E4\uB978 \uAE30\uC874 ${shown} \uB97C \uB36E\uC5B4\uC4F0\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uB36E\uC5B4\uC368\uB3C4 \uB418\uBA74 axis init -y \uB85C \uB2E4\uC2DC \uC2E4\uD589\uD558\uAC70\uB098 \uB300\uD654\uD615 \uD130\uBBF8\uB110\uC5D0\uC11C \uC2E4\uD589\uD558\uC138\uC694`
|
|
5515
5353
|
);
|
|
@@ -5568,7 +5406,7 @@ async function runInit(baseDirInput, answers, registryUrl, log = console.log, op
|
|
|
5568
5406
|
} else {
|
|
5569
5407
|
let actual;
|
|
5570
5408
|
try {
|
|
5571
|
-
await fs12.ensureDir(
|
|
5409
|
+
await fs12.ensureDir(path14.dirname(utilsPath));
|
|
5572
5410
|
actual = await writeNoFollow(utilsPath, UTILS_TS_CONTENT, utilsPlan.action === "create" ? "new" : "overwrite");
|
|
5573
5411
|
} catch (err) {
|
|
5574
5412
|
const code = err.code;
|
|
@@ -5659,26 +5497,26 @@ function registerInitCommand(program2, registryUrl = DEFAULT_REGISTRY_URL, deps
|
|
|
5659
5497
|
import chalk12 from "chalk";
|
|
5660
5498
|
|
|
5661
5499
|
// ../axis-registry-core/src/add/add.ts
|
|
5662
|
-
import { existsSync as
|
|
5663
|
-
import
|
|
5500
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, statSync as statSync4 } from "fs";
|
|
5501
|
+
import path16 from "path";
|
|
5664
5502
|
import fs13 from "fs-extra";
|
|
5665
5503
|
|
|
5666
5504
|
// ../axis-registry-core/src/registry/bundled.ts
|
|
5667
|
-
import { existsSync as
|
|
5668
|
-
import
|
|
5505
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6 } from "fs";
|
|
5506
|
+
import path15 from "path";
|
|
5669
5507
|
import { fileURLToPath } from "url";
|
|
5670
5508
|
function findBundledRegistryDir(moduleUrl = import.meta.url) {
|
|
5671
|
-
const here =
|
|
5672
|
-
for (const dir of [
|
|
5673
|
-
if (
|
|
5509
|
+
const here = path15.dirname(fileURLToPath(moduleUrl));
|
|
5510
|
+
for (const dir of [path15.join(here, "registry"), path15.join(here, "..", "registry")]) {
|
|
5511
|
+
if (existsSync6(path15.join(dir, "index.json"))) return dir;
|
|
5674
5512
|
}
|
|
5675
5513
|
return null;
|
|
5676
5514
|
}
|
|
5677
5515
|
function readBundledJson(dir, fileName) {
|
|
5678
|
-
const file =
|
|
5516
|
+
const file = path15.join(dir, fileName);
|
|
5679
5517
|
let text;
|
|
5680
5518
|
try {
|
|
5681
|
-
text =
|
|
5519
|
+
text = readFileSync6(file, "utf8");
|
|
5682
5520
|
} catch {
|
|
5683
5521
|
throw new Error(`\uB3D9\uBD09 \uB808\uC9C0\uC2A4\uD2B8\uB9AC\uC5D0 ${fileName} \uAC00 \uC5C6\uC2B5\uB2C8\uB2E4(${dir})`);
|
|
5684
5522
|
}
|
|
@@ -5866,7 +5704,7 @@ function createPinnedFetch(options = {}) {
|
|
|
5866
5704
|
const judge = options.judge ?? blockedAddressReason;
|
|
5867
5705
|
const send = options.request ?? httpsRequest;
|
|
5868
5706
|
const maxBytes = options.maxBytes ?? PINNED_FETCH_MAX_BYTES;
|
|
5869
|
-
return (input, init) => new Promise((
|
|
5707
|
+
return (input, init) => new Promise((resolve3, reject) => {
|
|
5870
5708
|
let url;
|
|
5871
5709
|
try {
|
|
5872
5710
|
url = new URL(input);
|
|
@@ -5907,7 +5745,7 @@ function createPinnedFetch(options = {}) {
|
|
|
5907
5745
|
if (failed) return;
|
|
5908
5746
|
const body = Buffer.concat(chunks).toString("utf8");
|
|
5909
5747
|
const status = res.statusCode ?? 0;
|
|
5910
|
-
|
|
5748
|
+
resolve3({ ok: status >= 200 && status < 300, status, text: async () => body });
|
|
5911
5749
|
});
|
|
5912
5750
|
}
|
|
5913
5751
|
);
|
|
@@ -6170,10 +6008,10 @@ function layoutFromConfig(root, config) {
|
|
|
6170
6008
|
throw new Error("axis.config.json \uC758 agenticDir \uAC00 \uBB38\uC790\uC5F4\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
6171
6009
|
}
|
|
6172
6010
|
const componentsDir = componentsRaw.replace(/\\/g, "/");
|
|
6173
|
-
const agenticDir = typeof agenticRaw === "string" ? agenticRaw.replace(/\\/g, "/") :
|
|
6174
|
-
return { root:
|
|
6011
|
+
const agenticDir = typeof agenticRaw === "string" ? agenticRaw.replace(/\\/g, "/") : path16.posix.join(path16.posix.dirname(componentsDir), "agentic");
|
|
6012
|
+
return { root: path16.resolve(root), componentsDir, agenticDir };
|
|
6175
6013
|
}
|
|
6176
|
-
function toPosix(p, impl =
|
|
6014
|
+
function toPosix(p, impl = path16) {
|
|
6177
6015
|
return p.split(impl.sep).join("/");
|
|
6178
6016
|
}
|
|
6179
6017
|
function itemKind(item) {
|
|
@@ -6195,12 +6033,12 @@ function placeFile(layout, item, filePath, target) {
|
|
|
6195
6033
|
const problem = registryPathProblem(p);
|
|
6196
6034
|
if (problem) throw new Error(`${item.name}: \uD30C\uC77C \uACBD\uB85C\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4(${JSON.stringify(p)}, ${problem})`);
|
|
6197
6035
|
}
|
|
6198
|
-
const base =
|
|
6036
|
+
const base = path16.posix.basename(filePath);
|
|
6199
6037
|
if (!INSTALL_FILE_NAME_PATTERN.test(base)) {
|
|
6200
6038
|
throw new Error(`${item.name}: \uD30C\uC77C \uACBD\uB85C\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4(${JSON.stringify(filePath)}, \uD30C\uC77C \uC774\uB984\uC740 .ts \xB7 .tsx \uB9CC \uC124\uCE58\uD569\uB2C8\uB2E4)`);
|
|
6201
6039
|
}
|
|
6202
6040
|
const dir = itemKind(item) === "agentic" ? layout.agenticDir : layout.componentsDir;
|
|
6203
|
-
return
|
|
6041
|
+
return path16.resolve(layout.root, dir, base);
|
|
6204
6042
|
}
|
|
6205
6043
|
function stripExt(p) {
|
|
6206
6044
|
return p.replace(/\.(?:tsx?|jsx?|mjs|cjs)$/, "");
|
|
@@ -6211,7 +6049,7 @@ function buildImportTargets(entries) {
|
|
|
6211
6049
|
for (const { item, file, target } of entries) {
|
|
6212
6050
|
const rel3 = stripExt(file.path.replace(/\\/g, "/").replace(/^\.?\//, ""));
|
|
6213
6051
|
exact.set(`@/${rel3}`, target);
|
|
6214
|
-
if (itemKind(item) === "lib") lib.set(
|
|
6052
|
+
if (itemKind(item) === "lib") lib.set(path16.posix.basename(rel3), target);
|
|
6215
6053
|
}
|
|
6216
6054
|
return { exact, lib };
|
|
6217
6055
|
}
|
|
@@ -6287,7 +6125,7 @@ function insideRanges(ranges, at) {
|
|
|
6287
6125
|
}
|
|
6288
6126
|
var SPECIFIER_PATTERN = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)(["'])(@\/[^"'\n]+)\2/g;
|
|
6289
6127
|
var STANDARD_LIB_PATTERN = /^@\/registry\/[^/]+\/lib\/(.+)$/;
|
|
6290
|
-
function relativeSpecifier(fromFile, toFile, impl =
|
|
6128
|
+
function relativeSpecifier(fromFile, toFile, impl = path16) {
|
|
6291
6129
|
let rel3 = toPosix(impl.relative(impl.dirname(fromFile), stripExt(toFile)), impl);
|
|
6292
6130
|
if (!rel3.startsWith(".")) rel3 = `./${rel3}`;
|
|
6293
6131
|
return rel3;
|
|
@@ -6315,10 +6153,10 @@ function rewriteImports(content, fileTarget, targets) {
|
|
|
6315
6153
|
}
|
|
6316
6154
|
var RESOLVE_EXTS = ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", "/index.ts", "/index.tsx", "/index.js"];
|
|
6317
6155
|
function relativeSpecifierResolves(fromFile, spec) {
|
|
6318
|
-
const base =
|
|
6156
|
+
const base = path16.resolve(path16.dirname(fromFile), spec);
|
|
6319
6157
|
return RESOLVE_EXTS.some((ext) => {
|
|
6320
6158
|
try {
|
|
6321
|
-
return
|
|
6159
|
+
return statSync4(base + ext).isFile();
|
|
6322
6160
|
} catch {
|
|
6323
6161
|
return false;
|
|
6324
6162
|
}
|
|
@@ -6367,7 +6205,7 @@ function planFiles(layout, items) {
|
|
|
6367
6205
|
}
|
|
6368
6206
|
const prev = byTarget.get(target);
|
|
6369
6207
|
if (prev !== void 0) {
|
|
6370
|
-
errors.push(`${item.name}: ${toPosix(
|
|
6208
|
+
errors.push(`${item.name}: ${toPosix(path16.relative(layout.root, target))} \uB97C ${prev} \uC640 \uD568\uAED8 \uC501\uB2C8\uB2E4(\uAC19\uC740 \uC704\uCE58)`);
|
|
6371
6209
|
continue;
|
|
6372
6210
|
}
|
|
6373
6211
|
byTarget.set(target, item.name);
|
|
@@ -6393,18 +6231,19 @@ function missingDependencies(root, items) {
|
|
|
6393
6231
|
const installCommand = detectInstallCommand(root);
|
|
6394
6232
|
let pkg;
|
|
6395
6233
|
try {
|
|
6396
|
-
const text =
|
|
6234
|
+
const text = readFileSync7(path16.join(root, "package.json"), "utf8").replace(/^\uFEFF/, "");
|
|
6397
6235
|
const parsed = JSON.parse(text);
|
|
6398
6236
|
pkg = isPlainObject(parsed) ? parsed : void 0;
|
|
6399
6237
|
} catch {
|
|
6400
6238
|
pkg = void 0;
|
|
6401
6239
|
}
|
|
6402
6240
|
const ranges = selectUtilsDependencies(detectTailwind(root, pkg));
|
|
6241
|
+
const rootPkg = pkg !== void 0 ? workspaceRootPackage(root) ?? null : null;
|
|
6403
6242
|
const specs = {};
|
|
6404
6243
|
for (const item of items) {
|
|
6405
6244
|
for (const dep of item.dependencies) {
|
|
6406
6245
|
const name = dependencyName(dep);
|
|
6407
|
-
if (
|
|
6246
|
+
if (declaredDependency(root, pkg, name, rootPkg) !== void 0) continue;
|
|
6408
6247
|
if (name in specs) continue;
|
|
6409
6248
|
const explicit = dep.length > name.length ? dep.slice(name.length + 1) : void 0;
|
|
6410
6249
|
specs[name] = explicit ?? ranges[name];
|
|
@@ -6420,18 +6259,16 @@ function dependencyName(spec) {
|
|
|
6420
6259
|
}
|
|
6421
6260
|
function addCommandForSpecs(installCommand, specs) {
|
|
6422
6261
|
const args = Object.entries(specs).map(([name, range]) => range ? `"${name}@${range}"` : name).join(" ");
|
|
6423
|
-
|
|
6424
|
-
if (installCommand.startsWith("npm")) return `npm install ${args}`;
|
|
6425
|
-
return `pnpm add ${args}`;
|
|
6262
|
+
return `${addCommandPrefix(installCommand)} ${args}`;
|
|
6426
6263
|
}
|
|
6427
6264
|
function rel2(root, p) {
|
|
6428
|
-
return toPosix(
|
|
6265
|
+
return toPosix(path16.relative(root, p));
|
|
6429
6266
|
}
|
|
6430
6267
|
async function runAdd(cwd, requested, options, ctx) {
|
|
6431
6268
|
const log = ctx.log ?? console.log;
|
|
6432
6269
|
const error = ctx.error ?? console.error;
|
|
6433
6270
|
const hints = { ...CLI_ADD_HINTS, ...ctx.hints };
|
|
6434
|
-
const root =
|
|
6271
|
+
const root = path16.resolve(cwd);
|
|
6435
6272
|
const result = { exitCode: 1, written: [], overwritten: [], unchanged: [], skipped: [] };
|
|
6436
6273
|
if (requested.length === 0) {
|
|
6437
6274
|
error(`\uCD94\uAC00\uD560 \uCEF4\uD3EC\uB10C\uD2B8 \uC774\uB984\uC744 \uD558\uB098 \uC774\uC0C1 \uC801\uC73C\uC138\uC694. \uBAA9\uB85D: ${hints.listCommand}`);
|
|
@@ -6509,12 +6346,12 @@ async function runAdd(cwd, requested, options, ctx) {
|
|
|
6509
6346
|
const existing = /* @__PURE__ */ new Map();
|
|
6510
6347
|
const readErrors = [];
|
|
6511
6348
|
for (const file of plan.files) {
|
|
6512
|
-
if (!
|
|
6349
|
+
if (!existsSync7(file.target)) {
|
|
6513
6350
|
existing.set(file, null);
|
|
6514
6351
|
continue;
|
|
6515
6352
|
}
|
|
6516
6353
|
try {
|
|
6517
|
-
existing.set(file,
|
|
6354
|
+
existing.set(file, readFileSync7(file.target, "utf8"));
|
|
6518
6355
|
} catch (e) {
|
|
6519
6356
|
readErrors.push(
|
|
6520
6357
|
`${file.item.name}: \uAE30\uC874 \uD30C\uC77C ${rel2(root, file.target)} \uC744 \uC77D\uC9C0 \uBABB\uD574 \uBE44\uAD50\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4(${e.code ?? e.message})`
|
|
@@ -6588,7 +6425,7 @@ async function runAdd(cwd, requested, options, ctx) {
|
|
|
6588
6425
|
try {
|
|
6589
6426
|
const before = escapeReason(root, d.file.target);
|
|
6590
6427
|
if (before) return stopWriting(p, before);
|
|
6591
|
-
await fs13.ensureDir(
|
|
6428
|
+
await fs13.ensureDir(path16.dirname(d.file.target));
|
|
6592
6429
|
const after = checkParentInside(root, d.file.target);
|
|
6593
6430
|
if (after) return stopWriting(p, after);
|
|
6594
6431
|
actual = await writeNoFollow(d.file.target, d.file.content, actual);
|
|
@@ -6675,7 +6512,7 @@ async function createClientFor(cwd, notify, env = process.env, clientOptions = {
|
|
|
6675
6512
|
const { guardConfigRegistry, ...options } = clientOptions;
|
|
6676
6513
|
let config = null;
|
|
6677
6514
|
try {
|
|
6678
|
-
config = await readAxisConfig(
|
|
6515
|
+
config = await readAxisConfig(path16.resolve(cwd));
|
|
6679
6516
|
} catch {
|
|
6680
6517
|
config = null;
|
|
6681
6518
|
}
|