trix-ui 0.2.8 → 0.2.10
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/__tests__/contracts/registry.test.d.ts +1 -0
- package/dist/__tests__/contracts/registry.test.js +42 -0
- package/dist/__tests__/contracts/registry.test.js.map +1 -0
- package/dist/__tests__/e2e/cli.test.d.ts +1 -0
- package/dist/__tests__/e2e/cli.test.js +67 -0
- package/dist/__tests__/e2e/cli.test.js.map +1 -0
- package/dist/__tests__/helpers/fs.d.ts +5 -0
- package/dist/__tests__/helpers/fs.js +26 -0
- package/dist/__tests__/helpers/fs.js.map +1 -0
- package/dist/__tests__/integration/commands.integration.test.d.ts +1 -0
- package/dist/__tests__/integration/commands.integration.test.js +184 -0
- package/dist/__tests__/integration/commands.integration.test.js.map +1 -0
- package/dist/commands/__tests__/add-composite.test.d.ts +2 -0
- package/dist/commands/__tests__/add-composite.test.js +171 -0
- package/dist/commands/__tests__/add-composite.test.js.map +1 -0
- package/dist/commands/__tests__/add-entry.mocks.d.ts +23 -0
- package/dist/commands/__tests__/add-entry.mocks.js +64 -0
- package/dist/commands/__tests__/add-entry.mocks.js.map +1 -0
- package/dist/commands/__tests__/add-section.test.d.ts +2 -0
- package/dist/commands/__tests__/add-section.test.js +191 -0
- package/dist/commands/__tests__/add-section.test.js.map +1 -0
- package/dist/commands/__tests__/add-wrapper.test.d.ts +2 -0
- package/dist/commands/__tests__/add-wrapper.test.js +171 -0
- package/dist/commands/__tests__/add-wrapper.test.js.map +1 -0
- package/dist/commands/__tests__/cli-mocks.d.ts +1 -0
- package/dist/commands/__tests__/cli-mocks.js +24 -0
- package/dist/commands/__tests__/cli-mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.mocks.d.ts +6 -0
- package/dist/commands/__tests__/doctor.mocks.js +20 -0
- package/dist/commands/__tests__/doctor.mocks.js.map +1 -0
- package/dist/commands/__tests__/doctor.test.d.ts +2 -0
- package/dist/commands/__tests__/doctor.test.js +80 -0
- package/dist/commands/__tests__/doctor.test.js.map +1 -0
- package/dist/commands/__tests__/list.mocks.d.ts +8 -0
- package/dist/commands/__tests__/list.mocks.js +20 -0
- package/dist/commands/__tests__/list.mocks.js.map +1 -0
- package/dist/commands/__tests__/list.test.d.ts +2 -0
- package/dist/commands/__tests__/list.test.js +60 -0
- package/dist/commands/__tests__/list.test.js.map +1 -0
- package/dist/commands/__tests__/remove.mocks.d.ts +9 -0
- package/dist/commands/__tests__/remove.mocks.js +26 -0
- package/dist/commands/__tests__/remove.mocks.js.map +1 -0
- package/dist/commands/__tests__/remove.test.d.ts +2 -0
- package/dist/commands/__tests__/remove.test.js +116 -0
- package/dist/commands/__tests__/remove.test.js.map +1 -0
- package/dist/commands/add/__tests__/add.mocks.d.ts +19 -19
- package/dist/commands/add/__tests__/add.mocks.js +59 -59
- package/dist/commands/add/__tests__/add.test.d.ts +2 -2
- package/dist/commands/add/__tests__/add.test.js +140 -140
- package/dist/commands/add/analysis.d.ts +4 -4
- package/dist/commands/add/analysis.js +56 -56
- package/dist/commands/add/command.d.ts +2 -2
- package/dist/commands/add/command.js +202 -202
- package/dist/commands/add/config.d.ts +2 -2
- package/dist/commands/add/config.js +11 -11
- package/dist/commands/add/install.d.ts +27 -27
- package/dist/commands/add/install.js +80 -80
- package/dist/commands/add/package-manager.d.ts +1 -1
- package/dist/commands/add/package-manager.js +4 -4
- package/dist/commands/add/project-files.d.ts +2 -2
- package/dist/commands/add/project-files.js +17 -17
- package/dist/commands/add/prompts.d.ts +3 -3
- package/dist/commands/add/prompts.js +28 -28
- package/dist/commands/add/registry.d.ts +4 -4
- package/dist/commands/add/registry.js +6 -6
- package/dist/commands/add/types.d.ts +33 -33
- package/dist/commands/add/types.js +1 -1
- package/dist/commands/add/ui.d.ts +4 -4
- package/dist/commands/add/ui.js +55 -55
- package/dist/commands/add/validation.d.ts +3 -3
- package/dist/commands/add/validation.js +30 -30
- package/dist/commands/add-collection.d.ts +1 -1
- package/dist/commands/add-collection.js +1 -1
- package/dist/commands/add-composite.d.ts +2 -2
- package/dist/commands/add-composite.js +201 -201
- package/dist/commands/add-section.d.ts +2 -2
- package/dist/commands/add-section.js +201 -201
- package/dist/commands/add-wrapper.d.ts +2 -2
- package/dist/commands/add-wrapper.js +201 -201
- package/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/build.d.ts +2 -2
- package/dist/commands/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +67 -67
- package/dist/commands/init/__tests__/init.mocks.d.ts +24 -0
- package/dist/commands/init/__tests__/init.mocks.js +84 -0
- package/dist/commands/init/__tests__/init.mocks.js.map +1 -0
- package/dist/commands/init/__tests__/init.test.d.ts +2 -0
- package/dist/commands/init/__tests__/init.test.js +283 -0
- package/dist/commands/init/__tests__/init.test.js.map +1 -0
- package/dist/commands/init/__tests__/tailwind.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tailwind.test.js +56 -0
- package/dist/commands/init/__tests__/tailwind.test.js.map +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.d.ts +1 -0
- package/dist/commands/init/__tests__/tsconfig.test.js +108 -0
- package/dist/commands/init/__tests__/tsconfig.test.js.map +1 -0
- package/dist/commands/init/__tests__/vite.test.d.ts +1 -0
- package/dist/commands/init/__tests__/vite.test.js +66 -0
- package/dist/commands/init/__tests__/vite.test.js.map +1 -0
- package/dist/commands/init/command.d.ts +2 -2
- package/dist/commands/init/command.js +114 -114
- package/dist/commands/init/config.d.ts +2 -2
- package/dist/commands/init/config.js +25 -25
- package/dist/commands/init/constants.d.ts +3 -3
- package/dist/commands/init/constants.js +105 -105
- package/dist/commands/init/dependencies.d.ts +5 -5
- package/dist/commands/init/dependencies.js +52 -52
- package/dist/commands/init/filesystem.d.ts +1 -1
- package/dist/commands/init/filesystem.js +10 -10
- package/dist/commands/init/lockfile.d.ts +1 -1
- package/dist/commands/init/lockfile.js +1 -1
- package/dist/commands/init/package-json.d.ts +6 -6
- package/dist/commands/init/package-json.js +18 -18
- package/dist/commands/init/project-files.d.ts +8 -0
- package/dist/commands/init/project-files.js +37 -0
- package/dist/commands/init/project-files.js.map +1 -0
- package/dist/commands/init/project.d.ts +3 -3
- package/dist/commands/init/project.js +97 -97
- package/dist/commands/init/style-imports.d.ts +9 -0
- package/dist/commands/init/style-imports.js +218 -0
- package/dist/commands/init/style-imports.js.map +1 -0
- package/dist/commands/init/tailwind.d.ts +3 -3
- package/dist/commands/init/tailwind.js +34 -34
- package/dist/commands/init/templates.d.ts +3 -3
- package/dist/commands/init/templates.js +15 -15
- package/dist/commands/init/tsconfig.d.ts +2 -2
- package/dist/commands/init/tsconfig.js +273 -273
- package/dist/commands/init/types.d.ts +33 -33
- package/dist/commands/init/types.js +1 -1
- package/dist/commands/init/ui.d.ts +3 -3
- package/dist/commands/init/ui.js +33 -33
- package/dist/commands/init/vite.d.ts +23 -0
- package/dist/commands/init/vite.js +347 -0
- package/dist/commands/init/vite.js.map +1 -0
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/list.d.ts +2 -2
- package/dist/commands/list.js +62 -62
- package/dist/commands/remove.d.ts +2 -2
- package/dist/commands/remove.js +93 -93
- package/dist/commands/shared/add-collection.d.ts +50 -50
- package/dist/commands/shared/add-collection.js +206 -206
- package/dist/commands/shared/list-entries.d.ts +6 -6
- package/dist/commands/shared/list-entries.js +12 -12
- package/dist/commands/shared/name-utils.d.ts +1 -1
- package/dist/commands/shared/name-utils.js +13 -13
- package/dist/commands/shared/remove-entries.d.ts +16 -16
- package/dist/commands/shared/remove-entries.js +41 -41
- package/dist/icons/index.d.ts +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/libraries.d.ts +37 -37
- package/dist/icons/libraries.js +34 -34
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -30
- package/dist/lib/__tests__/config.test.d.ts +1 -0
- package/dist/lib/__tests__/config.test.js +49 -0
- package/dist/lib/__tests__/config.test.js.map +1 -0
- package/dist/lib/__tests__/install.test.d.ts +1 -0
- package/dist/lib/__tests__/install.test.js +149 -0
- package/dist/lib/__tests__/install.test.js.map +1 -0
- package/dist/lib/__tests__/lockfile.test.d.ts +1 -0
- package/dist/lib/__tests__/lockfile.test.js +89 -0
- package/dist/lib/__tests__/lockfile.test.js.map +1 -0
- package/dist/lib/__tests__/paths.test.d.ts +1 -0
- package/dist/lib/__tests__/paths.test.js +39 -0
- package/dist/lib/__tests__/paths.test.js.map +1 -0
- package/dist/lib/__tests__/registry.test.d.ts +1 -0
- package/dist/lib/__tests__/registry.test.js +76 -0
- package/dist/lib/__tests__/registry.test.js.map +1 -0
- package/dist/lib/config.d.ts +45 -45
- package/dist/lib/config.js +97 -97
- package/dist/lib/fs.d.ts +76 -76
- package/dist/lib/fs.js +302 -302
- package/dist/lib/highlighter.d.ts +6 -6
- package/dist/lib/highlighter.js +7 -7
- package/dist/lib/install.d.ts +19 -19
- package/dist/lib/install.js +55 -55
- package/dist/lib/lockfile.d.ts +63 -63
- package/dist/lib/lockfile.js +173 -173
- package/dist/lib/logger.d.ts +8 -8
- package/dist/lib/logger.js +41 -41
- package/dist/lib/paths.d.ts +14 -14
- package/dist/lib/paths.js +31 -31
- package/dist/lib/registry.d.ts +35 -35
- package/dist/lib/registry.js +180 -180
- package/dist/schema/index.d.ts +1128 -1128
- package/dist/schema/index.js +238 -238
- package/dist/styles/create-style-map.d.ts +4 -4
- package/dist/styles/create-style-map.js +68 -68
- package/dist/styles/transform-style-map.d.ts +3 -3
- package/dist/styles/transform-style-map.js +428 -428
- package/dist/styles/transform.d.ts +10 -10
- package/dist/styles/transform.js +15 -15
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/index.js +5 -5
- package/dist/utils/transformers/transform-icons.d.ts +2 -2
- package/dist/utils/transformers/transform-icons.js +164 -164
- package/dist/utils/transformers/transform-menu.d.ts +2 -2
- package/dist/utils/transformers/transform-menu.js +39 -39
- package/dist/utils/transformers/transform-render.d.ts +2 -2
- package/dist/utils/transformers/transform-render.js +97 -97
- package/dist/utils/transformers/types.d.ts +14 -14
- package/dist/utils/transformers/types.js +1 -1
- package/package.json +1 -1
package/dist/lib/install.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { copyFileSafe, fileExists } from "./fs.js";
|
|
3
|
-
import { resolveTargetPath, resolveTemplatePath, toPosix } from "./paths.js";
|
|
4
|
-
import { resolveRegistrySource } from "./registry.js";
|
|
5
|
-
export async function installRegistryEntries(options) {
|
|
6
|
-
const { cwd, config, entries, names, lockEntries, force, itemLabel } = options;
|
|
7
|
-
const installed = [];
|
|
8
|
-
const skipped = [];
|
|
9
|
-
const npmDependencies = new Set();
|
|
10
|
-
const { templatesPath } = resolveRegistrySource(config, cwd);
|
|
11
|
-
const unique = [...new Set(names.map((name) => name.trim()))].filter(Boolean);
|
|
12
|
-
const entryMap = new Map(entries.map((entry) => [entry.name, entry]));
|
|
13
|
-
const missing = unique.filter((name) => !entryMap.has(name));
|
|
14
|
-
if (missing.length) {
|
|
15
|
-
throw new Error(`Unknown ${itemLabel}: ${missing.join(", ")}`);
|
|
16
|
-
}
|
|
17
|
-
for (const name of unique) {
|
|
18
|
-
const entry = entryMap.get(name);
|
|
19
|
-
if (!entry) {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if (lockEntries[name] && !force) {
|
|
23
|
-
skipped.push(name);
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const targetFiles = entry.files.map((file) => resolveTargetPath(cwd, file.target, config.paths));
|
|
27
|
-
if (!force) {
|
|
28
|
-
const alreadyExists = await Promise.all(targetFiles.map((target) => fileExists(target)));
|
|
29
|
-
if (alreadyExists.some(Boolean)) {
|
|
30
|
-
skipped.push(name);
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
for (const file of entry.files) {
|
|
35
|
-
const source = resolveTemplatePath(file.source, templatesPath);
|
|
36
|
-
const target = resolveTargetPath(cwd, file.target, config.paths);
|
|
37
|
-
await copyFileSafe(source, target, Boolean(force));
|
|
38
|
-
}
|
|
39
|
-
lockEntries[name] = {
|
|
40
|
-
version: "1",
|
|
41
|
-
files: normalizeLockFiles(cwd, targetFiles),
|
|
42
|
-
dependencies: entry.dependencies?.local,
|
|
43
|
-
installedAt: new Date().toISOString()
|
|
44
|
-
};
|
|
45
|
-
entry.dependencies?.npm?.forEach((dep) => npmDependencies.add(dep));
|
|
46
|
-
installed.push(name);
|
|
47
|
-
}
|
|
48
|
-
return { installed, skipped, npmDependencies };
|
|
49
|
-
}
|
|
50
|
-
function normalizeLockFiles(cwd, files) {
|
|
51
|
-
return files.map((filePath) => {
|
|
52
|
-
const relativePath = path.relative(cwd, filePath);
|
|
53
|
-
return toPosix(relativePath);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { copyFileSafe, fileExists } from "./fs.js";
|
|
3
|
+
import { resolveTargetPath, resolveTemplatePath, toPosix } from "./paths.js";
|
|
4
|
+
import { resolveRegistrySource } from "./registry.js";
|
|
5
|
+
export async function installRegistryEntries(options) {
|
|
6
|
+
const { cwd, config, entries, names, lockEntries, force, itemLabel } = options;
|
|
7
|
+
const installed = [];
|
|
8
|
+
const skipped = [];
|
|
9
|
+
const npmDependencies = new Set();
|
|
10
|
+
const { templatesPath } = resolveRegistrySource(config, cwd);
|
|
11
|
+
const unique = [...new Set(names.map((name) => name.trim()))].filter(Boolean);
|
|
12
|
+
const entryMap = new Map(entries.map((entry) => [entry.name, entry]));
|
|
13
|
+
const missing = unique.filter((name) => !entryMap.has(name));
|
|
14
|
+
if (missing.length) {
|
|
15
|
+
throw new Error(`Unknown ${itemLabel}: ${missing.join(", ")}`);
|
|
16
|
+
}
|
|
17
|
+
for (const name of unique) {
|
|
18
|
+
const entry = entryMap.get(name);
|
|
19
|
+
if (!entry) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (lockEntries[name] && !force) {
|
|
23
|
+
skipped.push(name);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const targetFiles = entry.files.map((file) => resolveTargetPath(cwd, file.target, config.paths));
|
|
27
|
+
if (!force) {
|
|
28
|
+
const alreadyExists = await Promise.all(targetFiles.map((target) => fileExists(target)));
|
|
29
|
+
if (alreadyExists.some(Boolean)) {
|
|
30
|
+
skipped.push(name);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const file of entry.files) {
|
|
35
|
+
const source = resolveTemplatePath(file.source, templatesPath);
|
|
36
|
+
const target = resolveTargetPath(cwd, file.target, config.paths);
|
|
37
|
+
await copyFileSafe(source, target, Boolean(force));
|
|
38
|
+
}
|
|
39
|
+
lockEntries[name] = {
|
|
40
|
+
version: "1",
|
|
41
|
+
files: normalizeLockFiles(cwd, targetFiles),
|
|
42
|
+
dependencies: entry.dependencies?.local,
|
|
43
|
+
installedAt: new Date().toISOString()
|
|
44
|
+
};
|
|
45
|
+
entry.dependencies?.npm?.forEach((dep) => npmDependencies.add(dep));
|
|
46
|
+
installed.push(name);
|
|
47
|
+
}
|
|
48
|
+
return { installed, skipped, npmDependencies };
|
|
49
|
+
}
|
|
50
|
+
function normalizeLockFiles(cwd, files) {
|
|
51
|
+
return files.map((filePath) => {
|
|
52
|
+
const relativePath = path.relative(cwd, filePath);
|
|
53
|
+
return toPosix(relativePath);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
56
|
//# sourceMappingURL=install.js.map
|
package/dist/lib/lockfile.d.ts
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { TrixUIConfig } from "./config.js";
|
|
2
|
-
export interface LockfileComponent {
|
|
3
|
-
version: string;
|
|
4
|
-
files: string[];
|
|
5
|
-
dependencies?: string[];
|
|
6
|
-
installedAt: string;
|
|
7
|
-
}
|
|
8
|
-
export interface Lockfile {
|
|
9
|
-
version: number;
|
|
10
|
-
components: Record<string, LockfileComponent>;
|
|
11
|
-
sections: Record<string, LockfileComponent>;
|
|
12
|
-
wrappers: Record<string, LockfileComponent>;
|
|
13
|
-
composites: Record<string, LockfileComponent>;
|
|
14
|
-
updatedAt?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get the lockfile path
|
|
18
|
-
*/
|
|
19
|
-
export declare function resolveLockfilePath(cwd: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Check if lockfile exists
|
|
22
|
-
*/
|
|
23
|
-
export declare function lockfileExists(cwd: string): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Create an empty lockfile
|
|
26
|
-
*/
|
|
27
|
-
export declare function createEmptyLockfile(): Lockfile;
|
|
28
|
-
/**
|
|
29
|
-
* Load lockfile from disk
|
|
30
|
-
*/
|
|
31
|
-
export declare function loadLockfile(cwd: string): Promise<Lockfile>;
|
|
32
|
-
/**
|
|
33
|
-
* Save lockfile to disk
|
|
34
|
-
*/
|
|
35
|
-
export declare function saveLockfile(cwd: string, lockfile: Lockfile): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Add component to lockfile
|
|
38
|
-
*/
|
|
39
|
-
export declare function addComponentToLockfile(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string, component: Omit<LockfileComponent, "installedAt">): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* Remove component from lockfile
|
|
42
|
-
*/
|
|
43
|
-
export declare function removeComponentFromLockfile(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Check if component is installed
|
|
46
|
-
*/
|
|
47
|
-
export declare function isComponentInstalled(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string): Promise<boolean>;
|
|
48
|
-
/**
|
|
49
|
-
* Get installed component info
|
|
50
|
-
*/
|
|
51
|
-
export declare function getInstalledComponent(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string): Promise<LockfileComponent | null>;
|
|
52
|
-
/**
|
|
53
|
-
* List all installed components
|
|
54
|
-
*/
|
|
55
|
-
export declare function listInstalledComponents(cwd: string, type?: "components" | "sections" | "wrappers" | "composites"): Promise<Record<string, LockfileComponent>>;
|
|
56
|
-
/**
|
|
57
|
-
* Validate lockfile integrity
|
|
58
|
-
*/
|
|
59
|
-
export declare function validateLockfile(cwd: string, config: TrixUIConfig): Promise<{
|
|
60
|
-
valid: boolean;
|
|
61
|
-
errors: string[];
|
|
62
|
-
warnings: string[];
|
|
63
|
-
}>;
|
|
1
|
+
import { TrixUIConfig } from "./config.js";
|
|
2
|
+
export interface LockfileComponent {
|
|
3
|
+
version: string;
|
|
4
|
+
files: string[];
|
|
5
|
+
dependencies?: string[];
|
|
6
|
+
installedAt: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Lockfile {
|
|
9
|
+
version: number;
|
|
10
|
+
components: Record<string, LockfileComponent>;
|
|
11
|
+
sections: Record<string, LockfileComponent>;
|
|
12
|
+
wrappers: Record<string, LockfileComponent>;
|
|
13
|
+
composites: Record<string, LockfileComponent>;
|
|
14
|
+
updatedAt?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the lockfile path
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveLockfilePath(cwd: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Check if lockfile exists
|
|
22
|
+
*/
|
|
23
|
+
export declare function lockfileExists(cwd: string): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Create an empty lockfile
|
|
26
|
+
*/
|
|
27
|
+
export declare function createEmptyLockfile(): Lockfile;
|
|
28
|
+
/**
|
|
29
|
+
* Load lockfile from disk
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadLockfile(cwd: string): Promise<Lockfile>;
|
|
32
|
+
/**
|
|
33
|
+
* Save lockfile to disk
|
|
34
|
+
*/
|
|
35
|
+
export declare function saveLockfile(cwd: string, lockfile: Lockfile): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Add component to lockfile
|
|
38
|
+
*/
|
|
39
|
+
export declare function addComponentToLockfile(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string, component: Omit<LockfileComponent, "installedAt">): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Remove component from lockfile
|
|
42
|
+
*/
|
|
43
|
+
export declare function removeComponentFromLockfile(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Check if component is installed
|
|
46
|
+
*/
|
|
47
|
+
export declare function isComponentInstalled(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Get installed component info
|
|
50
|
+
*/
|
|
51
|
+
export declare function getInstalledComponent(cwd: string, type: "components" | "sections" | "wrappers" | "composites", name: string): Promise<LockfileComponent | null>;
|
|
52
|
+
/**
|
|
53
|
+
* List all installed components
|
|
54
|
+
*/
|
|
55
|
+
export declare function listInstalledComponents(cwd: string, type?: "components" | "sections" | "wrappers" | "composites"): Promise<Record<string, LockfileComponent>>;
|
|
56
|
+
/**
|
|
57
|
+
* Validate lockfile integrity
|
|
58
|
+
*/
|
|
59
|
+
export declare function validateLockfile(cwd: string, config: TrixUIConfig): Promise<{
|
|
60
|
+
valid: boolean;
|
|
61
|
+
errors: string[];
|
|
62
|
+
warnings: string[];
|
|
63
|
+
}>;
|
package/dist/lib/lockfile.js
CHANGED
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileExists, readJsonFile, writeJsonFile } from "./fs.js";
|
|
3
|
-
const LOCKFILE_VERSION = 1;
|
|
4
|
-
const LOCKFILE_DIRNAME = ".ui";
|
|
5
|
-
const LOCKFILE_FILENAME = "lock.json";
|
|
6
|
-
const LEGACY_LOCKFILE_FILENAME = "trix-ui.lock.json";
|
|
7
|
-
/**
|
|
8
|
-
* Get the lockfile path
|
|
9
|
-
*/
|
|
10
|
-
export function resolveLockfilePath(cwd) {
|
|
11
|
-
return path.join(cwd, LOCKFILE_DIRNAME, LOCKFILE_FILENAME);
|
|
12
|
-
}
|
|
13
|
-
function resolveLegacyLockfilePath(cwd) {
|
|
14
|
-
return path.join(cwd, LEGACY_LOCKFILE_FILENAME);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Check if lockfile exists
|
|
18
|
-
*/
|
|
19
|
-
export async function lockfileExists(cwd) {
|
|
20
|
-
const currentPath = resolveLockfilePath(cwd);
|
|
21
|
-
if (await fileExists(currentPath)) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return fileExists(resolveLegacyLockfilePath(cwd));
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create an empty lockfile
|
|
28
|
-
*/
|
|
29
|
-
export function createEmptyLockfile() {
|
|
30
|
-
return {
|
|
31
|
-
version: LOCKFILE_VERSION,
|
|
32
|
-
components: {},
|
|
33
|
-
sections: {},
|
|
34
|
-
wrappers: {},
|
|
35
|
-
composites: {},
|
|
36
|
-
updatedAt: new Date().toISOString(),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Load lockfile from disk
|
|
41
|
-
*/
|
|
42
|
-
export async function loadLockfile(cwd) {
|
|
43
|
-
const lockfilePath = resolveLockfilePath(cwd);
|
|
44
|
-
let resolvedPath = lockfilePath;
|
|
45
|
-
if (!(await fileExists(lockfilePath))) {
|
|
46
|
-
const legacyPath = resolveLegacyLockfilePath(cwd);
|
|
47
|
-
if (await fileExists(legacyPath)) {
|
|
48
|
-
resolvedPath = legacyPath;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
// Return empty lockfile if it doesn't exist
|
|
52
|
-
return createEmptyLockfile();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const lockfile = await readJsonFile(resolvedPath);
|
|
57
|
-
// Validate lockfile structure
|
|
58
|
-
if (typeof lockfile.version !== "number") {
|
|
59
|
-
throw new Error("Invalid lockfile: missing or invalid 'version' field");
|
|
60
|
-
}
|
|
61
|
-
if (lockfile.version > LOCKFILE_VERSION) {
|
|
62
|
-
throw new Error(`Lockfile version ${lockfile.version} is not supported. ` +
|
|
63
|
-
`Please update trix-ui to the latest version.`);
|
|
64
|
-
}
|
|
65
|
-
// Ensure all required fields exist
|
|
66
|
-
return {
|
|
67
|
-
version: lockfile.version,
|
|
68
|
-
components: lockfile.components || {},
|
|
69
|
-
sections: lockfile.sections || {},
|
|
70
|
-
wrappers: lockfile.wrappers || {},
|
|
71
|
-
composites: lockfile.composites || {},
|
|
72
|
-
updatedAt: lockfile.updatedAt,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
throw new Error(`Failed to load lockfile: ${error.message}\n` +
|
|
77
|
-
`The lockfile may be corrupted. Try deleting ${LOCKFILE_DIRNAME}/${LOCKFILE_FILENAME} and running 'trix-ui init' again.`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Save lockfile to disk
|
|
82
|
-
*/
|
|
83
|
-
export async function saveLockfile(cwd, lockfile) {
|
|
84
|
-
const lockfilePath = resolveLockfilePath(cwd);
|
|
85
|
-
// Update timestamp
|
|
86
|
-
lockfile.updatedAt = new Date().toISOString();
|
|
87
|
-
try {
|
|
88
|
-
await writeJsonFile(lockfilePath, lockfile, true);
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
throw new Error(`Failed to save lockfile: ${error.message}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Add component to lockfile
|
|
96
|
-
*/
|
|
97
|
-
export async function addComponentToLockfile(cwd, type, name, component) {
|
|
98
|
-
const lockfile = await loadLockfile(cwd);
|
|
99
|
-
lockfile[type][name] = {
|
|
100
|
-
...component,
|
|
101
|
-
installedAt: new Date().toISOString(),
|
|
102
|
-
};
|
|
103
|
-
await saveLockfile(cwd, lockfile);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Remove component from lockfile
|
|
107
|
-
*/
|
|
108
|
-
export async function removeComponentFromLockfile(cwd, type, name) {
|
|
109
|
-
const lockfile = await loadLockfile(cwd);
|
|
110
|
-
delete lockfile[type][name];
|
|
111
|
-
await saveLockfile(cwd, lockfile);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Check if component is installed
|
|
115
|
-
*/
|
|
116
|
-
export async function isComponentInstalled(cwd, type, name) {
|
|
117
|
-
const lockfile = await loadLockfile(cwd);
|
|
118
|
-
return name in lockfile[type];
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Get installed component info
|
|
122
|
-
*/
|
|
123
|
-
export async function getInstalledComponent(cwd, type, name) {
|
|
124
|
-
const lockfile = await loadLockfile(cwd);
|
|
125
|
-
return lockfile[type][name] || null;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* List all installed components
|
|
129
|
-
*/
|
|
130
|
-
export async function listInstalledComponents(cwd, type) {
|
|
131
|
-
const lockfile = await loadLockfile(cwd);
|
|
132
|
-
if (type) {
|
|
133
|
-
return lockfile[type];
|
|
134
|
-
}
|
|
135
|
-
// Return all types combined
|
|
136
|
-
return {
|
|
137
|
-
...lockfile.components,
|
|
138
|
-
...lockfile.sections,
|
|
139
|
-
...lockfile.wrappers,
|
|
140
|
-
...lockfile.composites,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Validate lockfile integrity
|
|
145
|
-
*/
|
|
146
|
-
export async function validateLockfile(cwd, config) {
|
|
147
|
-
const errors = [];
|
|
148
|
-
const warnings = [];
|
|
149
|
-
try {
|
|
150
|
-
const lockfile = await loadLockfile(cwd);
|
|
151
|
-
// Check version compatibility
|
|
152
|
-
if (lockfile.version > LOCKFILE_VERSION) {
|
|
153
|
-
errors.push(`Lockfile version ${lockfile.version} is newer than supported version ${LOCKFILE_VERSION}`);
|
|
154
|
-
}
|
|
155
|
-
// Verify installed files exist
|
|
156
|
-
for (const [name, component] of Object.entries(lockfile.components)) {
|
|
157
|
-
for (const file of component.files || []) {
|
|
158
|
-
const filePath = path.join(cwd, config.paths.components, file);
|
|
159
|
-
if (!(await fileExists(filePath))) {
|
|
160
|
-
warnings.push(`Component '${name}' file missing: ${file}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
errors.push(error.message);
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
valid: errors.length === 0,
|
|
170
|
-
errors,
|
|
171
|
-
warnings,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileExists, readJsonFile, writeJsonFile } from "./fs.js";
|
|
3
|
+
const LOCKFILE_VERSION = 1;
|
|
4
|
+
const LOCKFILE_DIRNAME = ".ui";
|
|
5
|
+
const LOCKFILE_FILENAME = "lock.json";
|
|
6
|
+
const LEGACY_LOCKFILE_FILENAME = "trix-ui.lock.json";
|
|
7
|
+
/**
|
|
8
|
+
* Get the lockfile path
|
|
9
|
+
*/
|
|
10
|
+
export function resolveLockfilePath(cwd) {
|
|
11
|
+
return path.join(cwd, LOCKFILE_DIRNAME, LOCKFILE_FILENAME);
|
|
12
|
+
}
|
|
13
|
+
function resolveLegacyLockfilePath(cwd) {
|
|
14
|
+
return path.join(cwd, LEGACY_LOCKFILE_FILENAME);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if lockfile exists
|
|
18
|
+
*/
|
|
19
|
+
export async function lockfileExists(cwd) {
|
|
20
|
+
const currentPath = resolveLockfilePath(cwd);
|
|
21
|
+
if (await fileExists(currentPath)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return fileExists(resolveLegacyLockfilePath(cwd));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create an empty lockfile
|
|
28
|
+
*/
|
|
29
|
+
export function createEmptyLockfile() {
|
|
30
|
+
return {
|
|
31
|
+
version: LOCKFILE_VERSION,
|
|
32
|
+
components: {},
|
|
33
|
+
sections: {},
|
|
34
|
+
wrappers: {},
|
|
35
|
+
composites: {},
|
|
36
|
+
updatedAt: new Date().toISOString(),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Load lockfile from disk
|
|
41
|
+
*/
|
|
42
|
+
export async function loadLockfile(cwd) {
|
|
43
|
+
const lockfilePath = resolveLockfilePath(cwd);
|
|
44
|
+
let resolvedPath = lockfilePath;
|
|
45
|
+
if (!(await fileExists(lockfilePath))) {
|
|
46
|
+
const legacyPath = resolveLegacyLockfilePath(cwd);
|
|
47
|
+
if (await fileExists(legacyPath)) {
|
|
48
|
+
resolvedPath = legacyPath;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// Return empty lockfile if it doesn't exist
|
|
52
|
+
return createEmptyLockfile();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const lockfile = await readJsonFile(resolvedPath);
|
|
57
|
+
// Validate lockfile structure
|
|
58
|
+
if (typeof lockfile.version !== "number") {
|
|
59
|
+
throw new Error("Invalid lockfile: missing or invalid 'version' field");
|
|
60
|
+
}
|
|
61
|
+
if (lockfile.version > LOCKFILE_VERSION) {
|
|
62
|
+
throw new Error(`Lockfile version ${lockfile.version} is not supported. ` +
|
|
63
|
+
`Please update trix-ui to the latest version.`);
|
|
64
|
+
}
|
|
65
|
+
// Ensure all required fields exist
|
|
66
|
+
return {
|
|
67
|
+
version: lockfile.version,
|
|
68
|
+
components: lockfile.components || {},
|
|
69
|
+
sections: lockfile.sections || {},
|
|
70
|
+
wrappers: lockfile.wrappers || {},
|
|
71
|
+
composites: lockfile.composites || {},
|
|
72
|
+
updatedAt: lockfile.updatedAt,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw new Error(`Failed to load lockfile: ${error.message}\n` +
|
|
77
|
+
`The lockfile may be corrupted. Try deleting ${LOCKFILE_DIRNAME}/${LOCKFILE_FILENAME} and running 'trix-ui init' again.`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Save lockfile to disk
|
|
82
|
+
*/
|
|
83
|
+
export async function saveLockfile(cwd, lockfile) {
|
|
84
|
+
const lockfilePath = resolveLockfilePath(cwd);
|
|
85
|
+
// Update timestamp
|
|
86
|
+
lockfile.updatedAt = new Date().toISOString();
|
|
87
|
+
try {
|
|
88
|
+
await writeJsonFile(lockfilePath, lockfile, true);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
throw new Error(`Failed to save lockfile: ${error.message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Add component to lockfile
|
|
96
|
+
*/
|
|
97
|
+
export async function addComponentToLockfile(cwd, type, name, component) {
|
|
98
|
+
const lockfile = await loadLockfile(cwd);
|
|
99
|
+
lockfile[type][name] = {
|
|
100
|
+
...component,
|
|
101
|
+
installedAt: new Date().toISOString(),
|
|
102
|
+
};
|
|
103
|
+
await saveLockfile(cwd, lockfile);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Remove component from lockfile
|
|
107
|
+
*/
|
|
108
|
+
export async function removeComponentFromLockfile(cwd, type, name) {
|
|
109
|
+
const lockfile = await loadLockfile(cwd);
|
|
110
|
+
delete lockfile[type][name];
|
|
111
|
+
await saveLockfile(cwd, lockfile);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if component is installed
|
|
115
|
+
*/
|
|
116
|
+
export async function isComponentInstalled(cwd, type, name) {
|
|
117
|
+
const lockfile = await loadLockfile(cwd);
|
|
118
|
+
return name in lockfile[type];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get installed component info
|
|
122
|
+
*/
|
|
123
|
+
export async function getInstalledComponent(cwd, type, name) {
|
|
124
|
+
const lockfile = await loadLockfile(cwd);
|
|
125
|
+
return lockfile[type][name] || null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* List all installed components
|
|
129
|
+
*/
|
|
130
|
+
export async function listInstalledComponents(cwd, type) {
|
|
131
|
+
const lockfile = await loadLockfile(cwd);
|
|
132
|
+
if (type) {
|
|
133
|
+
return lockfile[type];
|
|
134
|
+
}
|
|
135
|
+
// Return all types combined
|
|
136
|
+
return {
|
|
137
|
+
...lockfile.components,
|
|
138
|
+
...lockfile.sections,
|
|
139
|
+
...lockfile.wrappers,
|
|
140
|
+
...lockfile.composites,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Validate lockfile integrity
|
|
145
|
+
*/
|
|
146
|
+
export async function validateLockfile(cwd, config) {
|
|
147
|
+
const errors = [];
|
|
148
|
+
const warnings = [];
|
|
149
|
+
try {
|
|
150
|
+
const lockfile = await loadLockfile(cwd);
|
|
151
|
+
// Check version compatibility
|
|
152
|
+
if (lockfile.version > LOCKFILE_VERSION) {
|
|
153
|
+
errors.push(`Lockfile version ${lockfile.version} is newer than supported version ${LOCKFILE_VERSION}`);
|
|
154
|
+
}
|
|
155
|
+
// Verify installed files exist
|
|
156
|
+
for (const [name, component] of Object.entries(lockfile.components)) {
|
|
157
|
+
for (const file of component.files || []) {
|
|
158
|
+
const filePath = path.join(cwd, config.paths.components, file);
|
|
159
|
+
if (!(await fileExists(filePath))) {
|
|
160
|
+
warnings.push(`Component '${name}' file missing: ${file}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
errors.push(error.message);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
valid: errors.length === 0,
|
|
170
|
+
errors,
|
|
171
|
+
warnings,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
174
|
//# sourceMappingURL=lockfile.js.map
|
package/dist/lib/logger.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const logger: {
|
|
2
|
-
error(...args: unknown[]): void;
|
|
3
|
-
warn(...args: unknown[]): void;
|
|
4
|
-
info(...args: unknown[]): void;
|
|
5
|
-
success(...args: unknown[]): void;
|
|
6
|
-
log(...args: unknown[]): void;
|
|
7
|
-
break(): void;
|
|
8
|
-
};
|
|
1
|
+
export declare const logger: {
|
|
2
|
+
error(...args: unknown[]): void;
|
|
3
|
+
warn(...args: unknown[]): void;
|
|
4
|
+
info(...args: unknown[]): void;
|
|
5
|
+
success(...args: unknown[]): void;
|
|
6
|
+
log(...args: unknown[]): void;
|
|
7
|
+
break(): void;
|
|
8
|
+
};
|