components-differ 1.2.0 → 1.2.1

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.
@@ -10,24 +10,33 @@ const WHITELISTED_COMPONENTS = [
10
10
  "badge",
11
11
  "breadcrumb",
12
12
  "button",
13
+ "button-group",
13
14
  "calendar",
14
15
  "card",
15
16
  "carousel",
16
17
  "chart",
17
18
  "checkbox",
18
19
  "collapsible",
20
+ "combobox",
19
21
  "command",
20
22
  "context-menu",
21
- "table",
23
+ "data-table",
24
+ "date-picker",
22
25
  "dialog",
23
26
  "drawer",
24
27
  "dropdown-menu",
28
+ "empty",
29
+ "field",
25
30
  "form",
26
31
  "hover-card",
27
32
  "input",
33
+ "input-group",
28
34
  "input-otp",
35
+ "item",
36
+ "kbd",
29
37
  "label",
30
38
  "menubar",
39
+ "native-select",
31
40
  "navigation-menu",
32
41
  "pagination",
33
42
  "popover",
@@ -38,16 +47,20 @@ const WHITELISTED_COMPONENTS = [
38
47
  "select",
39
48
  "separator",
40
49
  "sheet",
50
+ "sidebar",
41
51
  "skeleton",
42
52
  "slider",
43
53
  "sonner",
54
+ "spinner",
44
55
  "switch",
56
+ "table",
45
57
  "tabs",
46
58
  "textarea",
47
59
  "toast",
48
60
  "toggle",
49
61
  "toggle-group",
50
62
  "tooltip",
63
+ "typography",
51
64
  ];
52
65
 
53
66
  export function findComponentFiles(config, originalFiles) {
@@ -1,13 +1,28 @@
1
+ import path from "node:path";
2
+
1
3
  function fixAlias(alias) {
2
4
  return alias.replace("@", ".");
3
5
  }
4
6
 
5
7
  export function parseFilePath(wasInSrcDir, config, filePath, content) {
8
+ const normalizedPath = filePath.replace(/^\.\//, "");
9
+ const extension = path.extname(normalizedPath);
10
+ const baseName = path.basename(normalizedPath);
11
+
12
+ const styleExtensions = new Set([".css", ".scss", ".sass", ".less", ".pcss"]);
13
+ const fileExtensions = new Set([".json", ".yaml", ".yml", ".md", ".mdx", ".txt"]);
14
+ const themePattern = /(\/|^)(theme|.*-theme)(\.[a-z0-9]+)?$/i;
15
+
16
+ const sanitizedTargetPath = normalizedPath.replace(/^src\//, "");
17
+ const defaultTarget = wasInSrcDir
18
+ ? filePath
19
+ : `~/${normalizedPath}`;
20
+
6
21
  const out = {
7
22
  path: filePath,
8
23
  content,
9
24
  type: "registry:example",
10
- target: wasInSrcDir ? filePath : `~/${filePath.replace("./", "")}`,
25
+ target: defaultTarget,
11
26
  };
12
27
 
13
28
  if (filePath.startsWith(fixAlias(config.ui))) {
@@ -22,6 +37,23 @@ export function parseFilePath(wasInSrcDir, config, filePath, content) {
22
37
  } else if (filePath.startsWith(fixAlias(config.lib))) {
23
38
  out.type = "registry:lib";
24
39
  out.target = undefined;
40
+ } else if (normalizedPath.startsWith("app/")) {
41
+ out.type = "registry:page";
42
+ out.target = `./${sanitizedTargetPath}`;
43
+ } else if (themePattern.test(normalizedPath)) {
44
+ out.type = "registry:theme";
45
+ out.target = undefined;
46
+ } else if (styleExtensions.has(extension)) {
47
+ out.type = "registry:style";
48
+ } else if (baseName.startsWith(".env") || fileExtensions.has(extension)) {
49
+ out.type = "registry:file";
50
+ out.target = `~/${sanitizedTargetPath}`;
51
+ } else if (extension === ".tsx" || extension === ".jsx") {
52
+ out.type = "registry:component";
53
+ out.target = undefined;
54
+ } else {
55
+ out.type = "registry:item";
56
+ out.target = undefined;
25
57
  }
26
58
 
27
59
  if (out.type === "registry:example") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "components-differ",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Simple CLI to create Shadcn components from project",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",