trix-ui 0.2.14 → 0.3.0
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/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 +205 -202
- package/dist/commands/add/command.js.map +1 -1
- 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 +205 -201
- package/dist/commands/add-composite.js.map +1 -1
- package/dist/commands/add-section.d.ts +2 -2
- package/dist/commands/add-section.js +205 -201
- package/dist/commands/add-section.js.map +1 -1
- package/dist/commands/add-wrapper.d.ts +2 -2
- package/dist/commands/add-wrapper.js +205 -201
- package/dist/commands/add-wrapper.js.map +1 -1
- 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/build.js +104 -104
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/doctor.d.ts +2 -2
- package/dist/commands/doctor.js +67 -67
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init/command.d.ts +8 -2
- package/dist/commands/init/command.js +186 -114
- package/dist/commands/init/command.js.map +1 -1
- package/dist/commands/init/config.d.ts +9 -2
- package/dist/commands/init/config.js +45 -25
- package/dist/commands/init/config.js.map +1 -1
- package/dist/commands/init/constants.d.ts +3 -3
- package/dist/commands/init/constants.js +105 -105
- package/dist/commands/init/dependencies.d.ts +22 -5
- package/dist/commands/init/dependencies.js +86 -52
- package/dist/commands/init/dependencies.js.map +1 -1
- package/dist/commands/init/filesystem.d.ts +7 -1
- package/dist/commands/init/filesystem.js +16 -10
- package/dist/commands/init/filesystem.js.map +1 -1
- 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 +17 -6
- package/dist/commands/init/package-json.js +28 -18
- package/dist/commands/init/package-json.js.map +1 -1
- package/dist/commands/init/project.d.ts +15 -3
- package/dist/commands/init/project.js +120 -97
- package/dist/commands/init/project.js.map +1 -1
- package/dist/commands/init/tailwind.d.ts +14 -3
- package/dist/commands/init/tailwind.js +141 -33
- package/dist/commands/init/tailwind.js.map +1 -1
- package/dist/commands/init/templates.d.ts +15 -3
- package/dist/commands/init/templates.js +27 -15
- package/dist/commands/init/templates.js.map +1 -1
- package/dist/commands/init/tsconfig.d.ts +14 -2
- package/dist/commands/init/tsconfig.js +561 -273
- package/dist/commands/init/tsconfig.js.map +1 -1
- package/dist/commands/init/types.d.ts +34 -33
- package/dist/commands/init/types.js +1 -1
- package/dist/commands/init/ui.d.ts +12 -3
- package/dist/commands/init/ui.js +45 -33
- package/dist/commands/init/ui.js.map +1 -1
- package/dist/commands/init/vite.d.ts +1 -1
- package/dist/commands/init/vite.js +17 -27
- package/dist/commands/init/vite.js.map +1 -1
- 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 +69 -62
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/remove.d.ts +2 -2
- package/dist/commands/remove.js +95 -93
- package/dist/commands/remove.js.map +1 -1
- 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 +1 -2
- package/dist/index.js +29 -30
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +45 -45
- package/dist/lib/config.js +97 -97
- package/dist/lib/fs.d.ts +82 -76
- package/dist/lib/fs.js +299 -302
- package/dist/lib/fs.js.map +1 -1
- 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 +101 -55
- package/dist/lib/install.js.map +1 -1
- package/dist/lib/lockfile.d.ts +63 -63
- package/dist/lib/lockfile.js +179 -173
- package/dist/lib/lockfile.js.map +1 -1
- package/dist/lib/logger.d.ts +8 -8
- package/dist/lib/logger.js +41 -41
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/paths.d.ts +14 -14
- package/dist/lib/paths.js +41 -31
- package/dist/lib/paths.js.map +1 -1
- 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 +237 -238
- package/dist/schema/index.js.map +1 -1
- 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 +69 -69
- package/dist/__tests__/contracts/registry.test.d.ts +0 -1
- package/dist/__tests__/contracts/registry.test.js +0 -42
- package/dist/__tests__/contracts/registry.test.js.map +0 -1
- package/dist/__tests__/e2e/cli.test.d.ts +0 -1
- package/dist/__tests__/e2e/cli.test.js +0 -67
- package/dist/__tests__/e2e/cli.test.js.map +0 -1
- package/dist/__tests__/helpers/fs.d.ts +0 -5
- package/dist/__tests__/helpers/fs.js +0 -26
- package/dist/__tests__/helpers/fs.js.map +0 -1
- package/dist/__tests__/integration/commands.integration.test.d.ts +0 -1
- package/dist/__tests__/integration/commands.integration.test.js +0 -184
- package/dist/__tests__/integration/commands.integration.test.js.map +0 -1
- package/dist/commands/__tests__/add-composite.test.d.ts +0 -2
- package/dist/commands/__tests__/add-composite.test.js +0 -171
- package/dist/commands/__tests__/add-composite.test.js.map +0 -1
- package/dist/commands/__tests__/add-entry.mocks.d.ts +0 -23
- package/dist/commands/__tests__/add-entry.mocks.js +0 -64
- package/dist/commands/__tests__/add-entry.mocks.js.map +0 -1
- package/dist/commands/__tests__/add-section.test.d.ts +0 -2
- package/dist/commands/__tests__/add-section.test.js +0 -191
- package/dist/commands/__tests__/add-section.test.js.map +0 -1
- package/dist/commands/__tests__/add-wrapper.test.d.ts +0 -2
- package/dist/commands/__tests__/add-wrapper.test.js +0 -171
- package/dist/commands/__tests__/add-wrapper.test.js.map +0 -1
- package/dist/commands/__tests__/cli-mocks.d.ts +0 -1
- package/dist/commands/__tests__/cli-mocks.js +0 -24
- package/dist/commands/__tests__/cli-mocks.js.map +0 -1
- package/dist/commands/__tests__/doctor.mocks.d.ts +0 -6
- package/dist/commands/__tests__/doctor.mocks.js +0 -20
- package/dist/commands/__tests__/doctor.mocks.js.map +0 -1
- package/dist/commands/__tests__/doctor.test.d.ts +0 -2
- package/dist/commands/__tests__/doctor.test.js +0 -80
- package/dist/commands/__tests__/doctor.test.js.map +0 -1
- package/dist/commands/__tests__/list.mocks.d.ts +0 -8
- package/dist/commands/__tests__/list.mocks.js +0 -20
- package/dist/commands/__tests__/list.mocks.js.map +0 -1
- package/dist/commands/__tests__/list.test.d.ts +0 -2
- package/dist/commands/__tests__/list.test.js +0 -60
- package/dist/commands/__tests__/list.test.js.map +0 -1
- package/dist/commands/__tests__/remove.mocks.d.ts +0 -9
- package/dist/commands/__tests__/remove.mocks.js +0 -26
- package/dist/commands/__tests__/remove.mocks.js.map +0 -1
- package/dist/commands/__tests__/remove.test.d.ts +0 -2
- package/dist/commands/__tests__/remove.test.js +0 -116
- package/dist/commands/__tests__/remove.test.js.map +0 -1
- package/dist/commands/add/__tests__/__mocks__/cli-mocks.d.ts +0 -1
- package/dist/commands/add/__tests__/__mocks__/cli-mocks.js +0 -21
- package/dist/commands/add/__tests__/__mocks__/cli-mocks.js.map +0 -1
- package/dist/commands/add/__tests__/add.mocks.d.ts +0 -19
- package/dist/commands/add/__tests__/add.mocks.js +0 -60
- package/dist/commands/add/__tests__/add.mocks.js.map +0 -1
- package/dist/commands/add/__tests__/add.test.d.ts +0 -2
- package/dist/commands/add/__tests__/add.test.js +0 -141
- package/dist/commands/add/__tests__/add.test.js.map +0 -1
- package/dist/commands/init/__tests__/init.mocks.d.ts +0 -24
- package/dist/commands/init/__tests__/init.mocks.js +0 -84
- package/dist/commands/init/__tests__/init.mocks.js.map +0 -1
- package/dist/commands/init/__tests__/init.test.d.ts +0 -2
- package/dist/commands/init/__tests__/init.test.js +0 -283
- package/dist/commands/init/__tests__/init.test.js.map +0 -1
- package/dist/commands/init/__tests__/tailwind.test.d.ts +0 -1
- package/dist/commands/init/__tests__/tailwind.test.js +0 -56
- package/dist/commands/init/__tests__/tailwind.test.js.map +0 -1
- package/dist/commands/init/__tests__/tsconfig.test.d.ts +0 -1
- package/dist/commands/init/__tests__/tsconfig.test.js +0 -108
- package/dist/commands/init/__tests__/tsconfig.test.js.map +0 -1
- package/dist/commands/init/__tests__/vite.test.d.ts +0 -1
- package/dist/commands/init/__tests__/vite.test.js +0 -66
- package/dist/commands/init/__tests__/vite.test.js.map +0 -1
- package/dist/commands/list-sections.d.ts +0 -2
- package/dist/commands/list-sections.js +0 -20
- package/dist/commands/list-sections.js.map +0 -1
- package/dist/commands/list-wrappers.d.ts +0 -2
- package/dist/commands/list-wrappers.js +0 -20
- package/dist/commands/list-wrappers.js.map +0 -1
- package/dist/commands/remove-section.d.ts +0 -2
- package/dist/commands/remove-section.js +0 -37
- package/dist/commands/remove-section.js.map +0 -1
- package/dist/commands/remove-wrapper.d.ts +0 -2
- package/dist/commands/remove-wrapper.js +0 -37
- package/dist/commands/remove-wrapper.js.map +0 -1
- package/dist/lib/__tests__/config.test.d.ts +0 -1
- package/dist/lib/__tests__/config.test.js +0 -49
- package/dist/lib/__tests__/config.test.js.map +0 -1
- package/dist/lib/__tests__/install.test.d.ts +0 -1
- package/dist/lib/__tests__/install.test.js +0 -149
- package/dist/lib/__tests__/install.test.js.map +0 -1
- package/dist/lib/__tests__/lockfile.test.d.ts +0 -1
- package/dist/lib/__tests__/lockfile.test.js +0 -89
- package/dist/lib/__tests__/lockfile.test.js.map +0 -1
- package/dist/lib/__tests__/paths.test.d.ts +0 -1
- package/dist/lib/__tests__/paths.test.js +0 -39
- package/dist/lib/__tests__/paths.test.js.map +0 -1
- package/dist/lib/__tests__/registry.test.d.ts +0 -1
- package/dist/lib/__tests__/registry.test.js +0 -76
- package/dist/lib/__tests__/registry.test.js.map +0 -1
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import { SyntaxKind } from "ts-morph";
|
|
2
|
-
export const transformRender = async ({ sourceFile, config }) => {
|
|
3
|
-
// Only run for base- styles.
|
|
4
|
-
if (!config.style?.startsWith("base-")) {
|
|
5
|
-
return sourceFile;
|
|
6
|
-
}
|
|
7
|
-
// Collect all transformations first, then apply them in reverse order.
|
|
8
|
-
// This prevents issues with invalidated nodes when modifying the tree.
|
|
9
|
-
const transformations = [];
|
|
10
|
-
// Find all JSX elements with render attribute.
|
|
11
|
-
const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxElement);
|
|
12
|
-
for (const jsxElement of jsxElements) {
|
|
13
|
-
const openingElement = jsxElement.getOpeningElement();
|
|
14
|
-
const renderAttr = openingElement.getAttribute("render");
|
|
15
|
-
if (!renderAttr) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
// Get the children of the parent element.
|
|
19
|
-
const children = jsxElement.getJsxChildren();
|
|
20
|
-
const childrenText = children
|
|
21
|
-
.map((c) => c.getText())
|
|
22
|
-
.join("")
|
|
23
|
-
.trim();
|
|
24
|
-
// If there are no children, nothing to transform.
|
|
25
|
-
if (!childrenText) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
// Get the render attribute value.
|
|
29
|
-
if (renderAttr.getKind() !== SyntaxKind.JsxAttribute) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
const jsxAttr = renderAttr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
33
|
-
const initializer = jsxAttr.getInitializer();
|
|
34
|
-
if (!initializer) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
// The render value should be a JSX expression like {<Button />}.
|
|
38
|
-
if (initializer.getKind() !== SyntaxKind.JsxExpression) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const jsxExpression = initializer.asKindOrThrow(SyntaxKind.JsxExpression);
|
|
42
|
-
const expression = jsxExpression.getExpression();
|
|
43
|
-
if (!expression) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
// Check if the expression is a self-closing JSX element.
|
|
47
|
-
if (expression.getKind() !== SyntaxKind.JsxSelfClosingElement) {
|
|
48
|
-
// If it's already a full JSX element with children, skip it.
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const selfClosingElement = expression.asKindOrThrow(SyntaxKind.JsxSelfClosingElement);
|
|
52
|
-
const tagName = selfClosingElement.getTagNameNode().getText();
|
|
53
|
-
const attributes = selfClosingElement
|
|
54
|
-
.getAttributes()
|
|
55
|
-
.map((attr) => attr.getText())
|
|
56
|
-
.join(" ");
|
|
57
|
-
// Build new render prop value with children moved inside.
|
|
58
|
-
const newRenderValue = attributes
|
|
59
|
-
? `{<${tagName} ${attributes}>${childrenText}</${tagName}>}`
|
|
60
|
-
: `{<${tagName}>${childrenText}</${tagName}>}`;
|
|
61
|
-
// Get the parent tag name and other attributes.
|
|
62
|
-
const parentTagName = openingElement.getTagNameNode().getText();
|
|
63
|
-
const otherAttrs = openingElement
|
|
64
|
-
.getAttributes()
|
|
65
|
-
.filter((attr) => {
|
|
66
|
-
if (attr.getKind() === SyntaxKind.JsxAttribute) {
|
|
67
|
-
const attrName = attr
|
|
68
|
-
.asKindOrThrow(SyntaxKind.JsxAttribute)
|
|
69
|
-
.getNameNode()
|
|
70
|
-
.getText();
|
|
71
|
-
return attrName !== "render";
|
|
72
|
-
}
|
|
73
|
-
return true;
|
|
74
|
-
})
|
|
75
|
-
.map((attr) => attr.getText())
|
|
76
|
-
.join(" ");
|
|
77
|
-
// Build new element text as self-closing since children are now in render.
|
|
78
|
-
const newAttrs = otherAttrs
|
|
79
|
-
? `${otherAttrs} render=${newRenderValue}`
|
|
80
|
-
: `render=${newRenderValue}`;
|
|
81
|
-
const newElementText = `<${parentTagName} ${newAttrs} />`;
|
|
82
|
-
transformations.push({
|
|
83
|
-
elementStart: jsxElement.getStart(),
|
|
84
|
-
elementEnd: jsxElement.getEnd(),
|
|
85
|
-
newText: newElementText,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
// Apply transformations in reverse order to preserve positions.
|
|
89
|
-
for (const info of transformations.reverse()) {
|
|
90
|
-
const fullText = sourceFile.getFullText();
|
|
91
|
-
const newFullText = fullText.substring(0, info.elementStart) +
|
|
92
|
-
info.newText +
|
|
93
|
-
fullText.substring(info.elementEnd);
|
|
94
|
-
sourceFile.replaceWithText(newFullText);
|
|
95
|
-
}
|
|
96
|
-
return sourceFile;
|
|
97
|
-
};
|
|
1
|
+
import { SyntaxKind } from "ts-morph";
|
|
2
|
+
export const transformRender = async ({ sourceFile, config }) => {
|
|
3
|
+
// Only run for base- styles.
|
|
4
|
+
if (!config.style?.startsWith("base-")) {
|
|
5
|
+
return sourceFile;
|
|
6
|
+
}
|
|
7
|
+
// Collect all transformations first, then apply them in reverse order.
|
|
8
|
+
// This prevents issues with invalidated nodes when modifying the tree.
|
|
9
|
+
const transformations = [];
|
|
10
|
+
// Find all JSX elements with render attribute.
|
|
11
|
+
const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxElement);
|
|
12
|
+
for (const jsxElement of jsxElements) {
|
|
13
|
+
const openingElement = jsxElement.getOpeningElement();
|
|
14
|
+
const renderAttr = openingElement.getAttribute("render");
|
|
15
|
+
if (!renderAttr) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
// Get the children of the parent element.
|
|
19
|
+
const children = jsxElement.getJsxChildren();
|
|
20
|
+
const childrenText = children
|
|
21
|
+
.map((c) => c.getText())
|
|
22
|
+
.join("")
|
|
23
|
+
.trim();
|
|
24
|
+
// If there are no children, nothing to transform.
|
|
25
|
+
if (!childrenText) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
// Get the render attribute value.
|
|
29
|
+
if (renderAttr.getKind() !== SyntaxKind.JsxAttribute) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const jsxAttr = renderAttr.asKindOrThrow(SyntaxKind.JsxAttribute);
|
|
33
|
+
const initializer = jsxAttr.getInitializer();
|
|
34
|
+
if (!initializer) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// The render value should be a JSX expression like {<Button />}.
|
|
38
|
+
if (initializer.getKind() !== SyntaxKind.JsxExpression) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const jsxExpression = initializer.asKindOrThrow(SyntaxKind.JsxExpression);
|
|
42
|
+
const expression = jsxExpression.getExpression();
|
|
43
|
+
if (!expression) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// Check if the expression is a self-closing JSX element.
|
|
47
|
+
if (expression.getKind() !== SyntaxKind.JsxSelfClosingElement) {
|
|
48
|
+
// If it's already a full JSX element with children, skip it.
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const selfClosingElement = expression.asKindOrThrow(SyntaxKind.JsxSelfClosingElement);
|
|
52
|
+
const tagName = selfClosingElement.getTagNameNode().getText();
|
|
53
|
+
const attributes = selfClosingElement
|
|
54
|
+
.getAttributes()
|
|
55
|
+
.map((attr) => attr.getText())
|
|
56
|
+
.join(" ");
|
|
57
|
+
// Build new render prop value with children moved inside.
|
|
58
|
+
const newRenderValue = attributes
|
|
59
|
+
? `{<${tagName} ${attributes}>${childrenText}</${tagName}>}`
|
|
60
|
+
: `{<${tagName}>${childrenText}</${tagName}>}`;
|
|
61
|
+
// Get the parent tag name and other attributes.
|
|
62
|
+
const parentTagName = openingElement.getTagNameNode().getText();
|
|
63
|
+
const otherAttrs = openingElement
|
|
64
|
+
.getAttributes()
|
|
65
|
+
.filter((attr) => {
|
|
66
|
+
if (attr.getKind() === SyntaxKind.JsxAttribute) {
|
|
67
|
+
const attrName = attr
|
|
68
|
+
.asKindOrThrow(SyntaxKind.JsxAttribute)
|
|
69
|
+
.getNameNode()
|
|
70
|
+
.getText();
|
|
71
|
+
return attrName !== "render";
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
})
|
|
75
|
+
.map((attr) => attr.getText())
|
|
76
|
+
.join(" ");
|
|
77
|
+
// Build new element text as self-closing since children are now in render.
|
|
78
|
+
const newAttrs = otherAttrs
|
|
79
|
+
? `${otherAttrs} render=${newRenderValue}`
|
|
80
|
+
: `render=${newRenderValue}`;
|
|
81
|
+
const newElementText = `<${parentTagName} ${newAttrs} />`;
|
|
82
|
+
transformations.push({
|
|
83
|
+
elementStart: jsxElement.getStart(),
|
|
84
|
+
elementEnd: jsxElement.getEnd(),
|
|
85
|
+
newText: newElementText,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// Apply transformations in reverse order to preserve positions.
|
|
89
|
+
for (const info of transformations.reverse()) {
|
|
90
|
+
const fullText = sourceFile.getFullText();
|
|
91
|
+
const newFullText = fullText.substring(0, info.elementStart) +
|
|
92
|
+
info.newText +
|
|
93
|
+
fullText.substring(info.elementEnd);
|
|
94
|
+
sourceFile.replaceWithText(newFullText);
|
|
95
|
+
}
|
|
96
|
+
return sourceFile;
|
|
97
|
+
};
|
|
98
98
|
//# sourceMappingURL=transform-render.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { SourceFile } from "ts-morph";
|
|
2
|
-
export type TransformConfig = {
|
|
3
|
-
iconLibrary?: string;
|
|
4
|
-
menuColor?: string;
|
|
5
|
-
style?: string;
|
|
6
|
-
};
|
|
7
|
-
export type TransformOpts = {
|
|
8
|
-
filename: string;
|
|
9
|
-
raw: string;
|
|
10
|
-
config: TransformConfig;
|
|
11
|
-
};
|
|
12
|
-
export type Transformer<Output = SourceFile> = (opts: TransformOpts & {
|
|
13
|
-
sourceFile: SourceFile;
|
|
14
|
-
}) => Promise<Output>;
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
export type TransformConfig = {
|
|
3
|
+
iconLibrary?: string;
|
|
4
|
+
menuColor?: string;
|
|
5
|
+
style?: string;
|
|
6
|
+
};
|
|
7
|
+
export type TransformOpts = {
|
|
8
|
+
filename: string;
|
|
9
|
+
raw: string;
|
|
10
|
+
config: TransformConfig;
|
|
11
|
+
};
|
|
12
|
+
export type Transformer<Output = SourceFile> = (opts: TransformOpts & {
|
|
13
|
+
sourceFile: SourceFile;
|
|
14
|
+
}) => Promise<Output>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "trix-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Lite UI CLI, registry tooling, and templates.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"default": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"./schema": {
|
|
13
|
-
"types": "./dist/schema/index.d.ts",
|
|
14
|
-
"default": "./dist/schema/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./icons": {
|
|
17
|
-
"types": "./dist/icons/index.d.ts",
|
|
18
|
-
"default": "./dist/icons/index.js"
|
|
19
|
-
},
|
|
20
|
-
"./utils": {
|
|
21
|
-
"types": "./dist/utils/index.d.ts",
|
|
22
|
-
"default": "./dist/utils/index.js"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"bin": {
|
|
26
|
-
"ui": "dist/index.js",
|
|
27
|
-
"trix-ui": "dist/index.js"
|
|
28
|
-
},
|
|
29
|
-
"files": [
|
|
30
|
-
"dist",
|
|
31
|
-
"registry",
|
|
32
|
-
"templates",
|
|
33
|
-
"tailwind.css",
|
|
34
|
-
"README.md"
|
|
35
|
-
],
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "trix-ui",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Lite UI CLI, registry tooling, and templates.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./schema": {
|
|
13
|
+
"types": "./dist/schema/index.d.ts",
|
|
14
|
+
"default": "./dist/schema/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./icons": {
|
|
17
|
+
"types": "./dist/icons/index.d.ts",
|
|
18
|
+
"default": "./dist/icons/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./utils": {
|
|
21
|
+
"types": "./dist/utils/index.d.ts",
|
|
22
|
+
"default": "./dist/utils/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"ui": "dist/index.js",
|
|
27
|
+
"trix-ui": "dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"registry",
|
|
32
|
+
"templates",
|
|
33
|
+
"tailwind.css",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"dev": "node --enable-source-maps --import tsx src/index.ts",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
40
|
+
"pub:beta": "pnpm build && pnpm publish --no-git-checks --access public --tag beta",
|
|
41
|
+
"pub:release": "pnpm build && pnpm publish --access public",
|
|
42
|
+
"test": "vitest",
|
|
43
|
+
"test:init": "pnpm dev init --cwd ../../../__test__/_react"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@antfu/ni": "^28.2.0",
|
|
47
|
+
"chalk": "^5.6.2",
|
|
48
|
+
"commander": "^14.0.2",
|
|
49
|
+
"eslint-plugin-tailwindcss": "3.18.2",
|
|
50
|
+
"execa": "^9.6.1",
|
|
51
|
+
"jsonc-parser": "^3.2.1",
|
|
52
|
+
"kleur": "^4.1.5",
|
|
53
|
+
"ora": "^9.1.0",
|
|
54
|
+
"pino": "^10.2.1",
|
|
55
|
+
"pino-pretty": "^13.1.3",
|
|
56
|
+
"postcss": "^8.5.6",
|
|
57
|
+
"postcss-selector-parser": "^7.1.1",
|
|
58
|
+
"prompts": "^2.4.2",
|
|
59
|
+
"ts-morph": "^27.0.2",
|
|
60
|
+
"zod": "^4.3.5"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
64
|
+
"@types/node": "^25.0.9",
|
|
65
|
+
"@types/prompts": "^2.4.9",
|
|
66
|
+
"tsx": "^4.21.0",
|
|
67
|
+
"typescript": "^5.9.3"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { createTempDir, pathExists, removeDir } from "../helpers/fs.js";
|
|
3
|
-
import { DEFAULT_CONFIG } from "../../lib/config.js";
|
|
4
|
-
import { getBundledTemplatesPath, resolveTargetPath, resolveTemplatePath } from "../../lib/paths.js";
|
|
5
|
-
import { loadBundledRegistry } from "../../lib/registry.js";
|
|
6
|
-
describe("registry contracts", () => {
|
|
7
|
-
it("registry entries map to existing templates and valid targets", async () => {
|
|
8
|
-
const cwd = await createTempDir("trix-ui-registry-");
|
|
9
|
-
try {
|
|
10
|
-
const registry = await loadBundledRegistry();
|
|
11
|
-
const templatesRoot = getBundledTemplatesPath();
|
|
12
|
-
const componentNames = new Set(registry.components.map((item) => item.name));
|
|
13
|
-
const collections = [
|
|
14
|
-
{ label: "component", items: registry.components },
|
|
15
|
-
{ label: "section", items: registry.sections ?? [] },
|
|
16
|
-
{ label: "wrapper", items: registry.wrappers ?? [] },
|
|
17
|
-
{ label: "composite", items: registry.composites ?? [] }
|
|
18
|
-
];
|
|
19
|
-
for (const collection of collections) {
|
|
20
|
-
const names = new Set();
|
|
21
|
-
for (const item of collection.items) {
|
|
22
|
-
expect(names.has(item.name)).toBe(false);
|
|
23
|
-
names.add(item.name);
|
|
24
|
-
for (const file of item.files) {
|
|
25
|
-
const sourcePath = resolveTemplatePath(file.source, templatesRoot);
|
|
26
|
-
expect(await pathExists(sourcePath)).toBe(true);
|
|
27
|
-
const targetPath = resolveTargetPath(cwd, file.target, DEFAULT_CONFIG.paths);
|
|
28
|
-
expect(targetPath.startsWith(cwd)).toBe(true);
|
|
29
|
-
}
|
|
30
|
-
const localDeps = item.dependencies?.local ?? [];
|
|
31
|
-
for (const dep of localDeps) {
|
|
32
|
-
expect(componentNames.has(dep)).toBe(true);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
await removeDir(cwd);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=registry.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.test.js","sourceRoot":"","sources":["../../../src/__tests__/contracts/registry.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACL,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,8DAA8D,EAAE,KAAK,IAAI,EAAE;QAC5E,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,mBAAmB,CAAC,CAAA;QACpD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,mBAAmB,EAAE,CAAA;YAC5C,MAAM,aAAa,GAAG,uBAAuB,EAAE,CAAA;YAC/C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAE5E,MAAM,WAAW,GAAG;gBAClB,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,UAAU,EAAE;gBAClD,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE;gBACpD,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE;gBACpD,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,UAAU,IAAI,EAAE,EAAE;aACzD,CAAA;YAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;gBAC/B,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;oBACpC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;oBACxC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;oBAEpB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;wBAC9B,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;wBAClE,MAAM,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;wBAE/C,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,CAAA;wBAC5E,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;oBAC/C,CAAC;oBAED,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE,CAAA;oBAChD,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;wBAC5B,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;oBAC5C,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,SAAS,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
import { execa } from "execa";
|
|
5
|
-
import { createTempDir, pathExists, removeDir, writeFile, writeJson } from "../helpers/fs.js";
|
|
6
|
-
async function setupLocalRegistry(cwd) {
|
|
7
|
-
await writeJson(path.join(cwd, "registry", "index.json"), {
|
|
8
|
-
version: 1,
|
|
9
|
-
components: [
|
|
10
|
-
{
|
|
11
|
-
name: "button",
|
|
12
|
-
description: "Button",
|
|
13
|
-
files: [
|
|
14
|
-
{
|
|
15
|
-
source: "components/ui/button.tsx",
|
|
16
|
-
target: "{{components}}/button.tsx"
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
});
|
|
22
|
-
await writeFile(path.join(cwd, "templates", "components", "ui", "button.tsx"), "export const Button = () => null;");
|
|
23
|
-
await writeFile(path.join(cwd, "templates", "lib", "utils.ts"), "export const cn = () => \"\";");
|
|
24
|
-
await writeFile(path.join(cwd, "templates", "styles", "globals.css"), ":root { --background: #fff; }");
|
|
25
|
-
}
|
|
26
|
-
describe("cli e2e", () => {
|
|
27
|
-
it("runs add command via node process", async () => {
|
|
28
|
-
const cwd = await createTempDir("trix-ui-e2e-");
|
|
29
|
-
try {
|
|
30
|
-
await setupLocalRegistry(cwd);
|
|
31
|
-
await writeJson(path.join(cwd, "trix-ui.json"), {
|
|
32
|
-
registry: {
|
|
33
|
-
type: "local",
|
|
34
|
-
path: "registry/index.json"
|
|
35
|
-
},
|
|
36
|
-
paths: {
|
|
37
|
-
components: "components/ui",
|
|
38
|
-
sections: "components/sections",
|
|
39
|
-
wrappers: "components/wrappers",
|
|
40
|
-
composites: "components/composites",
|
|
41
|
-
utils: "lib/utils.ts",
|
|
42
|
-
styles: "styles/globals.css"
|
|
43
|
-
},
|
|
44
|
-
barrel: false
|
|
45
|
-
});
|
|
46
|
-
const packageRoot = fileURLToPath(new URL("../../..", import.meta.url));
|
|
47
|
-
const cliPath = fileURLToPath(new URL("../../index.ts", import.meta.url));
|
|
48
|
-
const result = await execa(process.execPath, [
|
|
49
|
-
"--import",
|
|
50
|
-
"tsx",
|
|
51
|
-
cliPath,
|
|
52
|
-
"add",
|
|
53
|
-
"button",
|
|
54
|
-
"--cwd",
|
|
55
|
-
cwd,
|
|
56
|
-
"--yes",
|
|
57
|
-
"--skip-deps"
|
|
58
|
-
], { cwd: packageRoot });
|
|
59
|
-
expect(result.exitCode).toBe(0);
|
|
60
|
-
expect(await pathExists(path.join(cwd, "components", "ui", "button.tsx"))).toBe(true);
|
|
61
|
-
}
|
|
62
|
-
finally {
|
|
63
|
-
await removeDir(cwd);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=cli.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.test.js","sourceRoot":"","sources":["../../../src/__tests__/e2e/cli.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function createTempDir(prefix: string): Promise<string>;
|
|
2
|
-
export declare function removeDir(dirPath: string): Promise<void>;
|
|
3
|
-
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
4
|
-
export declare function writeJson(filePath: string, data: unknown): Promise<void>;
|
|
5
|
-
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
export async function createTempDir(prefix) {
|
|
5
|
-
return fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
|
6
|
-
}
|
|
7
|
-
export async function removeDir(dirPath) {
|
|
8
|
-
await fs.rm(dirPath, { recursive: true, force: true });
|
|
9
|
-
}
|
|
10
|
-
export async function writeFile(filePath, content) {
|
|
11
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
12
|
-
await fs.writeFile(filePath, content, "utf-8");
|
|
13
|
-
}
|
|
14
|
-
export async function writeJson(filePath, data) {
|
|
15
|
-
await writeFile(filePath, JSON.stringify(data, null, 2) + "\n");
|
|
16
|
-
}
|
|
17
|
-
export async function pathExists(filePath) {
|
|
18
|
-
try {
|
|
19
|
-
await fs.access(filePath);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=fs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/__tests__/helpers/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc;IAChD,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAe;IAC7C,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACxD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,QAAgB,EAChB,OAAe;IAEf,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3D,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,QAAgB,EAChB,IAAa;IAEb,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "../../commands/__tests__/cli-mocks.js";
|