Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9adfb0b
chore: add clack prompts
luxass Jul 30, 2025
27db542
feat(cli): enhance CLI store command with version selection
luxass Jul 30, 2025
be5bd5e
refactor(cli): improve error handling and version selection in init c…
luxass Jul 30, 2025
4d5cfb2
refactor(ucd-store): reorganize error exports for clarity
luxass Jul 30, 2025
1cd8547
feat(store): add analyze method for version analysis
luxass Jul 30, 2025
9aea775
Merge branch 'main' into store-analyze
luxass Jul 30, 2025
b22886a
feat(cli): add analyze command for UCD store
luxass Jul 30, 2025
54af41b
fix(utils): ensure 'entries' is an array before processing
luxass Jul 30, 2025
a626eac
feat(ucd-store): implement #analyzeVersion method for version analysis
luxass Jul 30, 2025
c4eb539
feat(ucd-store): add getExpectedFilePaths function to retrieve file p…
luxass Jul 30, 2025
c7cbd15
Merge branch 'main' into store-analyze
luxass Jul 30, 2025
1b2dc8d
feat(ucd-store): enhance error handling in getExpectedFilePaths function
luxass Jul 30, 2025
3bd4c5f
chore: dump old test file
luxass Jul 31, 2025
d9a7aba
Merge branch 'main' into store-analyze
luxass Jul 31, 2025
a16bb19
Merge branch 'main' into store-analyze
luxass Jul 31, 2025
b342db2
Merge branch 'main' into store-analyze
luxass Jul 31, 2025
651babe
chore: add experimental decorators to compiler options
luxass Jul 31, 2025
508e1bd
fix(ucd-store): set default basePath to './' in createNodeUCDStore
luxass Jul 31, 2025
1aa8ea4
fix(cli): handle version selection more robustly
luxass Jul 31, 2025
8aacb20
feat(ucd-store): add support for versions in UCDStore constructor
luxass Jul 31, 2025
2dd1e82
fix(ucd-store): remove unused error import in files.test.ts
luxass Jul 31, 2025
2d85911
Merge branch 'main' into store-analyze
luxass Jul 31, 2025
ea3b7f7
Merge branch 'main' into store-analyze
luxass Jul 31, 2025
3d586c5
refactor(store): improve file path handling and analysis logic
luxass Jul 31, 2025
190846e
test: update custom store analyze operations and improve assertions
luxass Jul 31, 2025
1b539ab
test(ucd-store): integrate `memfs` for enhanced filesystem operations
luxass Jul 31, 2025
28c3338
chore(eslint): update `@luxass/eslint-config` to version 5.2.1
luxass Jul 31, 2025
defc116
test: remove unused import from `files.test.ts`
luxass Jul 31, 2025
ef9cf9a
chore: update build scripts to include custom TypeScript configuration
luxass Jul 31, 2025
51a6493
chore: fix test
luxass Jul 31, 2025
5f7ad53
chore: fix typo
luxass Jul 31, 2025
8404d3b
fix(analyze): correct log message for analyzing versions
luxass Jul 31, 2025
6a43284
chore: add changeset
luxass Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-mangos-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ucdjs/ucd-store": minor
---

implement analyze on ucd-store
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"node": ">=22.17"
},
"scripts": {
"build": "tsdown",
"build": "tsdown --tsconfig=./tsconfig.build.json",
"clean": "git clean -xdf dist node_modules",
"lint": "eslint .",
"typecheck": "tsc --noEmit"
Expand Down
115 changes: 115 additions & 0 deletions packages/cli/src/cmd/store/analyze.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/* eslint-disable no-console */
import type { Prettify } from "@luxass/utils";
import type { CLIArguments } from "../../cli-utils";
import type { CLIStoreCmdSharedFlags } from "./_shared";
import { UCDStoreUnsupportedFeature } from "@ucdjs/ucd-store";
import { green, red } from "farver/fast";
import { printHelp } from "../../cli-utils";
import { assertRemoteOrStoreDir, createStoreFromFlags, SHARED_FLAGS } from "./_shared";

export interface CLIStoreAnalyzeCmdOptions {
flags: CLIArguments<Prettify<CLIStoreCmdSharedFlags & {
json?: boolean;
checkOrphaned?: boolean;
}>>;
versions?: string[];
}

export async function runAnalyzeStore({ flags, versions }: CLIStoreAnalyzeCmdOptions) {
if (flags?.help || flags?.h) {
printHelp({
headline: "Analyze UCD Store",
commandName: "ucd store analyze",
usage: "[...versions] [...flags]",
tables: {
Flags: [
...SHARED_FLAGS,
["--check-orphaned", "Check for orphaned files in the store."],
["--json", "Output analyze information in JSON format."],
["--help (-h)", "See all available flags."],
],
},
});
return;
}

if (!versions || versions.length === 0) {
console.info("No specific versions provided. Analyzing all versions in the store.");
}

const {
storeDir,
json,
remote,
baseUrl,
patterns,
checkOrphaned,
} = flags;

try {
assertRemoteOrStoreDir(flags);

const store = await createStoreFromFlags({
baseUrl,
storeDir,
remote,
patterns,
});

if (store == null) {
console.error("Error: Failed to create UCD store.");
return;
}

const result = await store.analyze({
checkOrphaned: !!checkOrphaned,
versions: versions || [],
});

if (json) {
console.info(JSON.stringify(result, null, 2));
return;
}

for (const { version, fileCount, isComplete, missingFiles, orphanedFiles, totalFileCount } of result) {
console.info(`Version: ${version}`);
if (isComplete) {
console.info(` Status: ${green("complete")}`);
} else {
console.warn(` Status: ${red("incomplete")}`);
}
console.info(` Files: ${fileCount}`);
if (missingFiles && missingFiles.length > 0) {
console.warn(` Missing files: ${missingFiles.length}`);
}
if (orphanedFiles && orphanedFiles.length > 0) {
console.warn(` Orphaned files: ${orphanedFiles.length}`);
}

if (totalFileCount) {
console.info(` Total files expected: ${totalFileCount}`);
}
}
} catch (err) {
if (err instanceof UCDStoreUnsupportedFeature) {
console.error(red(`\n❌ Error: Unsupported feature:`));
console.error(` ${err.message}`);
console.error("");
console.error("This store does not support the analyze operation.");
console.error("Please check the store capabilities or use a different store type.");
return;
}

let message = "Unknown error";
if (err instanceof Error) {
message = err.message;
} else if (typeof err === "string") {
message = err;
}

console.error(red(`\n❌ Error analyzing store:`));
console.error(` ${message}`);
console.error("Please check the store configuration and try again.");
console.error("If you believe this is a bug, please report it at https://github.com/ucdjs/ucd/issues");
}
}
8 changes: 4 additions & 4 deletions packages/cli/src/cmd/store/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CODEGEN_SUBCOMMANDS = [
"init",
"repair",
"clean",
"status",
"analyze",
] as const;
export type Subcommand = (typeof CODEGEN_SUBCOMMANDS)[number];

Expand Down Expand Up @@ -70,9 +70,9 @@ export async function runStoreRoot(subcommand: string, { flags }: CLIStoreCmdOpt
return;
}

if (subcommand === "status") {
const { runStatusStore } = await import("./status");
await runStatusStore({ flags });
if (subcommand === "analyze") {
const { runAnalyzeStore } = await import("./analyze");
await runAnalyzeStore({ flags });
return;
}

Expand Down
79 changes: 0 additions & 79 deletions packages/cli/src/cmd/store/status.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"node": ">=22.17"
},
"scripts": {
"build": "tsdown",
"build": "tsdown --tsconfig=./tsconfig.build.json",
"dev": "tsdown --watch",
"clean": "git clean -xdf dist node_modules",
"lint": "eslint .",
Expand Down
2 changes: 1 addition & 1 deletion packages/fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"node": ">=22.17"
},
"scripts": {
"build": "tsdown",
"build": "tsdown --tsconfig=./tsconfig.build.json",
"dev": "tsdown --watch",
"clean": "git clean -xdf dist node_modules",
"lint": "eslint .",
Expand Down
4 changes: 2 additions & 2 deletions packages/fs-bridge/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @ts-check
import { luxass } from "@luxass/eslint-config";
import { GLOB_TESTS, luxass } from "@luxass/eslint-config";

export default luxass({
type: "lib",
pnpm: true,
}).append({
ignores: ["src/bridges/node.ts"],
ignores: ["src/bridges/node.ts", ...GLOB_TESTS],
rules: {
"no-restricted-imports": ["error", {
patterns: [
Expand Down
2 changes: 1 addition & 1 deletion packages/fs-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"node": ">=22.17"
},
"scripts": {
"build": "tsdown",
"build": "tsdown --tsconfig=./tsconfig.build.json",
"dev": "tsdown --watch",
"clean": "git clean -xdf dist node_modules",
"lint": "eslint .",
Expand Down
2 changes: 1 addition & 1 deletion packages/fs-bridge/src/bridges/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const HTTPFileSystemBridge = defineFileSystemBridge({
const entries: FSEntry[] = [];
for (const entry of data) {
if (entry.type === "directory") {
const children = await this.listdir(entry.path, true);
const children = await this.listdir(joinURL(path, entry.path), true);
entries.push({
type: "directory",
name: entry.name,
Expand Down
32 changes: 16 additions & 16 deletions packages/fs-bridge/test/bridges/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ describe("http fs-bridge", () => {
{
type: "file" as const,
name: "file1.txt",
path: "/dir/file1.txt",
path: "/file1.txt",
lastModified: Date.now(),
},
{
type: "file" as const,
name: "file2.txt",
path: "/dir/file2.txt",
path: "/file2.txt",
lastModified: Date.now(),
},
{
type: "directory" as const,
name: "subdir",
path: "/dir/subdir",
path: "/subdir",
lastModified: Date.now(),
},
] satisfies FileEntry[];
Expand All @@ -154,18 +154,18 @@ describe("http fs-bridge", () => {
expect(files).toEqual([
{
name: "file1.txt",
path: "/dir/file1.txt",
path: "/file1.txt",
type: "file",
},
{
name: "file2.txt",
path: "/dir/file2.txt",
path: "/file2.txt",
type: "file",
},
{
children: [],
name: "subdir",
path: "/dir/subdir",
path: "/subdir",
type: "directory",
},

Expand All @@ -177,7 +177,7 @@ describe("http fs-bridge", () => {
{
type: "file" as const,
name: "nested.txt",
path: "/dir/subdir/nested.txt",
path: "/nested.txt",
lastModified: Date.now(),
},
] satisfies FileEntry[];
Expand All @@ -199,14 +199,14 @@ describe("http fs-bridge", () => {

const files = await bridge.listdir("dir", true);
expect(files).toEqual([
{ type: "file", name: "file1.txt", path: "/dir/file1.txt" },
{ type: "file", name: "file2.txt", path: "/dir/file2.txt" },
{ type: "file", name: "file1.txt", path: "/file1.txt" },
{ type: "file", name: "file2.txt", path: "/file2.txt" },
{
type: "directory",
name: "subdir",
path: "/dir/subdir",
path: "/subdir",
children: [
{ type: "file", name: "nested.txt", path: "/dir/subdir/nested.txt" },
{ type: "file", name: "nested.txt", path: "/nested.txt" },
],
},
]);
Expand Down Expand Up @@ -260,13 +260,13 @@ describe("http fs-bridge", () => {
{
type: "file" as const,
name: "accessible.txt",
path: "/dir/accessible.txt",
path: "/accessible.txt",
lastModified: Date.now(),
},
{
type: "directory" as const,
name: "inaccessible",
path: "/dir/inaccessible",
path: "/inaccessible",
lastModified: Date.now(),
},
] satisfies FileEntry[]), {
Expand All @@ -290,10 +290,10 @@ describe("http fs-bridge", () => {

const files = await bridge.listdir("dir", true);
expect(files).toEqual([
{ type: "file", name: "accessible.txt", path: "/dir/accessible.txt" },
{ type: "directory", name: "inaccessible", path: "/dir/inaccessible", children: [] },
{ type: "file", name: "accessible.txt", path: "/accessible.txt" },
{ type: "directory", name: "inaccessible", path: "/inaccessible", children: [] },
]);
expect(flattenFilePaths(files)).not.toContain("/dir/inaccessible/another-file.txt");
expect(flattenFilePaths(files)).not.toContain("/inaccessible/another-file.txt");
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/schema-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"node": ">=22.17"
},
"scripts": {
"build": "tsdown",
"build": "tsdown --tsconfig=./tsconfig.build.json",
"dev": "tsdown --watch",
"clean": "git clean -xdf dist node_modules",
"lint": "eslint .",
Expand Down
Loading
Loading