ui8kit 1.3.0 → 1.3.5
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 +48 -20
- package/dist/index.js.map +1 -1
- package/package.json +26 -23
package/dist/index.js
CHANGED
|
@@ -466,6 +466,15 @@ function setCachedInMemory(registryType, index) {
|
|
|
466
466
|
const cache = getRegistryCache(registryType);
|
|
467
467
|
cache.registryIndex = index;
|
|
468
468
|
}
|
|
469
|
+
function resetCache(registryType) {
|
|
470
|
+
if (registryType) {
|
|
471
|
+
registryCache.delete(registryType);
|
|
472
|
+
logger.debug(`Cache reset for ${registryType} - will rediscover working CDN`);
|
|
473
|
+
} else {
|
|
474
|
+
registryCache.clear();
|
|
475
|
+
logger.debug(`All registry caches reset - will rediscover working CDNs`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
469
478
|
|
|
470
479
|
// src/utils/project.ts
|
|
471
480
|
import fs2 from "fs-extra";
|
|
@@ -1794,6 +1803,7 @@ import fs8 from "fs-extra";
|
|
|
1794
1803
|
import path9 from "path";
|
|
1795
1804
|
import chalk7 from "chalk";
|
|
1796
1805
|
import ora5 from "ora";
|
|
1806
|
+
import * as ts2 from "typescript";
|
|
1797
1807
|
|
|
1798
1808
|
// src/registry/build-schema.ts
|
|
1799
1809
|
import { z as z2 } from "zod";
|
|
@@ -2025,6 +2035,8 @@ async function buildCommand(registryPath = "./src/registry.json", options = {})
|
|
|
2025
2035
|
};
|
|
2026
2036
|
console.log(chalk7.blue(CLI_MESSAGES.info.building));
|
|
2027
2037
|
try {
|
|
2038
|
+
await clearCache();
|
|
2039
|
+
resetCache();
|
|
2028
2040
|
const registryContent = await fs8.readFile(buildOptions.registryFile, "utf-8");
|
|
2029
2041
|
const registryData = JSON.parse(registryContent);
|
|
2030
2042
|
const registry = registrySchema.parse(registryData);
|
|
@@ -2120,8 +2132,8 @@ async function ensureVariantsIndexItem(registry, cwd) {
|
|
|
2120
2132
|
const dependencies = extractFileDependencies(sourceContent);
|
|
2121
2133
|
const exportedModules = extractExportedModules(sourceContent);
|
|
2122
2134
|
const indexItem = {
|
|
2123
|
-
name: "index",
|
|
2124
2135
|
type: "registry:variants",
|
|
2136
|
+
name: "index",
|
|
2125
2137
|
description: exportedModules.length > 0 ? `Variant exports: ${exportedModules.join(", ")}` : "Variants export index",
|
|
2126
2138
|
dependencies,
|
|
2127
2139
|
devDependencies: [],
|
|
@@ -2133,7 +2145,7 @@ async function ensureVariantsIndexItem(registry, cwd) {
|
|
|
2133
2145
|
};
|
|
2134
2146
|
const items = Array.isArray(registry.items) ? registry.items : [];
|
|
2135
2147
|
const existingIndexIdx = items.findIndex(
|
|
2136
|
-
(item) => item && item.name ===
|
|
2148
|
+
(item) => item && item.type === indexItem.type && item.name === indexItem.name
|
|
2137
2149
|
);
|
|
2138
2150
|
if (existingIndexIdx >= 0) {
|
|
2139
2151
|
items[existingIndexIdx] = {
|
|
@@ -2159,14 +2171,20 @@ function extractExportedModules(content) {
|
|
|
2159
2171
|
}
|
|
2160
2172
|
function extractFileDependencies(content) {
|
|
2161
2173
|
const dependencies = /* @__PURE__ */ new Set();
|
|
2162
|
-
const
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2174
|
+
const sourceFile = ts2.createSourceFile("index.ts", content, ts2.ScriptTarget.Latest, true);
|
|
2175
|
+
function visit(node) {
|
|
2176
|
+
if (ts2.isImportDeclaration(node)) {
|
|
2177
|
+
const moduleSpecifier = node.moduleSpecifier;
|
|
2178
|
+
if (ts2.isStringLiteral(moduleSpecifier)) {
|
|
2179
|
+
const moduleName = moduleSpecifier.text;
|
|
2180
|
+
if (isExternalDependency(moduleName)) {
|
|
2181
|
+
dependencies.add(moduleName);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2168
2184
|
}
|
|
2185
|
+
ts2.forEachChild(node, visit);
|
|
2169
2186
|
}
|
|
2187
|
+
visit(sourceFile);
|
|
2170
2188
|
return [...dependencies];
|
|
2171
2189
|
}
|
|
2172
2190
|
|
|
@@ -2176,7 +2194,7 @@ import path10 from "path";
|
|
|
2176
2194
|
import chalk8 from "chalk";
|
|
2177
2195
|
import ora6 from "ora";
|
|
2178
2196
|
import { glob } from "glob";
|
|
2179
|
-
import * as
|
|
2197
|
+
import * as ts3 from "typescript";
|
|
2180
2198
|
var DEV_PATTERNS = [
|
|
2181
2199
|
"@types/",
|
|
2182
2200
|
"eslint",
|
|
@@ -2397,7 +2415,17 @@ function extractDescription(content) {
|
|
|
2397
2415
|
return "";
|
|
2398
2416
|
}
|
|
2399
2417
|
function hasValidExports(content) {
|
|
2400
|
-
|
|
2418
|
+
const sourceFile = ts3.createSourceFile("index.ts", content, ts3.ScriptTarget.Latest, true);
|
|
2419
|
+
let hasExports = false;
|
|
2420
|
+
function visit(node) {
|
|
2421
|
+
if (ts3.isExportDeclaration(node) || ts3.isExportAssignment(node) || hasExportModifier(node)) {
|
|
2422
|
+
hasExports = true;
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2425
|
+
ts3.forEachChild(node, visit);
|
|
2426
|
+
}
|
|
2427
|
+
visit(sourceFile);
|
|
2428
|
+
return hasExports;
|
|
2401
2429
|
}
|
|
2402
2430
|
async function analyzeComponentDependencies(files, cwd) {
|
|
2403
2431
|
const allDependencies = /* @__PURE__ */ new Set();
|
|
@@ -2407,10 +2435,10 @@ async function analyzeComponentDependencies(files, cwd) {
|
|
|
2407
2435
|
try {
|
|
2408
2436
|
const filePath = path10.resolve(cwd, file.path);
|
|
2409
2437
|
const content = await fs9.readFile(filePath, "utf-8");
|
|
2410
|
-
const sourceFile =
|
|
2438
|
+
const sourceFile = ts3.createSourceFile(
|
|
2411
2439
|
file.path,
|
|
2412
2440
|
content,
|
|
2413
|
-
|
|
2441
|
+
ts3.ScriptTarget.Latest,
|
|
2414
2442
|
true
|
|
2415
2443
|
);
|
|
2416
2444
|
const analysis = analyzeAST(sourceFile);
|
|
@@ -2435,9 +2463,9 @@ function analyzeAST(sourceFile) {
|
|
|
2435
2463
|
let description;
|
|
2436
2464
|
let hasExports = false;
|
|
2437
2465
|
function visit(node) {
|
|
2438
|
-
if (
|
|
2466
|
+
if (ts3.isImportDeclaration(node)) {
|
|
2439
2467
|
const moduleSpecifier = node.moduleSpecifier;
|
|
2440
|
-
if (
|
|
2468
|
+
if (ts3.isStringLiteral(moduleSpecifier)) {
|
|
2441
2469
|
const moduleName = moduleSpecifier.text;
|
|
2442
2470
|
if (isExternalDependency(moduleName)) {
|
|
2443
2471
|
if (isDevDependency(moduleName)) {
|
|
@@ -2448,9 +2476,9 @@ function analyzeAST(sourceFile) {
|
|
|
2448
2476
|
}
|
|
2449
2477
|
}
|
|
2450
2478
|
}
|
|
2451
|
-
if (
|
|
2479
|
+
if (ts3.isExportDeclaration(node)) {
|
|
2452
2480
|
hasExports = true;
|
|
2453
|
-
} else if (
|
|
2481
|
+
} else if (ts3.isExportAssignment(node)) {
|
|
2454
2482
|
hasExports = true;
|
|
2455
2483
|
} else if (hasExportModifier(node)) {
|
|
2456
2484
|
hasExports = true;
|
|
@@ -2459,7 +2487,7 @@ function analyzeAST(sourceFile) {
|
|
|
2459
2487
|
if (jsDocComment && !description) {
|
|
2460
2488
|
description = jsDocComment;
|
|
2461
2489
|
}
|
|
2462
|
-
|
|
2490
|
+
ts3.forEachChild(node, visit);
|
|
2463
2491
|
}
|
|
2464
2492
|
visit(sourceFile);
|
|
2465
2493
|
return {
|
|
@@ -2475,16 +2503,16 @@ function isDevDependency(moduleName) {
|
|
|
2475
2503
|
function hasExportModifier(node) {
|
|
2476
2504
|
if ("modifiers" in node && node.modifiers) {
|
|
2477
2505
|
return node.modifiers.some(
|
|
2478
|
-
(mod) => mod.kind ===
|
|
2506
|
+
(mod) => mod.kind === ts3.SyntaxKind.ExportKeyword
|
|
2479
2507
|
);
|
|
2480
2508
|
}
|
|
2481
2509
|
return false;
|
|
2482
2510
|
}
|
|
2483
2511
|
function getJSDocComment(node) {
|
|
2484
2512
|
try {
|
|
2485
|
-
const jsDocTags =
|
|
2513
|
+
const jsDocTags = ts3.getJSDocCommentsAndTags(node);
|
|
2486
2514
|
for (const tag of jsDocTags) {
|
|
2487
|
-
if (
|
|
2515
|
+
if (ts3.isJSDoc(tag) && tag.comment) {
|
|
2488
2516
|
if (typeof tag.comment === "string") {
|
|
2489
2517
|
return tag.comment.trim();
|
|
2490
2518
|
} else if (Array.isArray(tag.comment)) {
|