components-differ 1.0.7 → 1.0.9
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/README.md +191 -16
- package/dist/components.d.ts +6 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +119 -0
- package/dist/components.js.map +1 -0
- package/dist/create-diff.d.ts +14 -0
- package/dist/create-diff.d.ts.map +1 -0
- package/dist/create-diff.js +61 -0
- package/dist/create-diff.js.map +1 -0
- package/dist/git.d.ts +5 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +120 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +132 -0
- package/dist/index.js.map +1 -0
- package/dist/parse-file-path.d.ts +3 -0
- package/dist/parse-file-path.d.ts.map +1 -0
- package/dist/parse-file-path.js +53 -0
- package/dist/parse-file-path.js.map +1 -0
- package/dist/registry.d.ts +3 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +112 -0
- package/dist/registry.js.map +1 -0
- package/dist/shadcn-init.d.ts +11 -0
- package/dist/shadcn-init.d.ts.map +1 -0
- package/dist/shadcn-init.js +208 -0
- package/dist/shadcn-init.js.map +1 -0
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +19 -8
- package/index.mjs +0 -114
- package/src/components.mjs +0 -98
- package/src/create-diff.mjs +0 -91
- package/src/git.mjs +0 -141
- package/src/parse-file-path.mjs +0 -32
- package/tests/fixtures/non-src-dir/app/page.tsx +0 -1
- package/tests/fixtures/non-src-dir/components/comp.tsx +0 -1
- package/tests/fixtures/non-src-dir/components/ui/new-ui-comp.tsx +0 -1
- package/tests/fixtures/non-src-dir/components/ui/select.tsx +0 -1
- package/tests/fixtures/non-src-dir/components.json +0 -20
- package/tests/fixtures/non-src-dir/hooks/hook.ts +0 -1
- package/tests/fixtures/non-src-dir/lib/lib.ts +0 -1
- package/tests/fixtures/non-src-dir/non-src-sub/test.ts +0 -1
- package/tests/fixtures/non-src-dir/package.json +0 -42
- package/tests/fixtures/src-dir/components.json +0 -20
- package/tests/fixtures/src-dir/non-src-sub/test.ts +0 -1
- package/tests/fixtures/src-dir/package.json +0 -42
- package/tests/fixtures/src-dir/src/app/page.tsx +0 -1
- package/tests/fixtures/src-dir/src/components/comp.tsx +0 -1
- package/tests/fixtures/src-dir/src/components/ui/new-ui-comp.tsx +0 -1
- package/tests/fixtures/src-dir/src/components/ui/select.tsx +0 -1
- package/tests/fixtures/src-dir/src/hooks/hook.ts +0 -1
- package/tests/fixtures/src-dir/src/lib/lib.ts +0 -1
- package/tests/tests/__snapshots__/test-fixtures.spec.mjs.snap +0 -129
- package/tests/tests/parse-file-path.spec.mjs +0 -105
- package/tests/tests/test-fixtures.spec.mjs +0 -86
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hook;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
lib;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`fixture tests > should diff a non-src directory project 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"cssVars": {},
|
|
6
|
-
"dependencies": [],
|
|
7
|
-
"devDependencies": [],
|
|
8
|
-
"files": [
|
|
9
|
-
{
|
|
10
|
-
"content": "example env;",
|
|
11
|
-
"path": "./.env.example",
|
|
12
|
-
"target": "~/.env.example",
|
|
13
|
-
"type": "registry:example",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"content": "page;
|
|
17
|
-
",
|
|
18
|
-
"path": "./app/page.tsx",
|
|
19
|
-
"target": "./app/page.tsx",
|
|
20
|
-
"type": "registry:example",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"content": "comp;
|
|
24
|
-
",
|
|
25
|
-
"path": "./components/comp.tsx",
|
|
26
|
-
"target": undefined,
|
|
27
|
-
"type": "registry:block",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"content": "new-ui-comp;",
|
|
31
|
-
"path": "./components/ui/new-ui-comp.tsx",
|
|
32
|
-
"target": undefined,
|
|
33
|
-
"type": "registry:ui",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"content": "hook;
|
|
37
|
-
",
|
|
38
|
-
"path": "./hooks/hook.ts",
|
|
39
|
-
"target": undefined,
|
|
40
|
-
"type": "registry:hook",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"content": "lib;
|
|
44
|
-
",
|
|
45
|
-
"path": "./lib/lib.ts",
|
|
46
|
-
"target": undefined,
|
|
47
|
-
"type": "registry:lib",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"content": "non - src - sub;
|
|
51
|
-
",
|
|
52
|
-
"path": "./non-src-sub/test.ts",
|
|
53
|
-
"target": "~/non-src-sub/test.ts",
|
|
54
|
-
"type": "registry:example",
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
"meta": {},
|
|
58
|
-
"name": "example",
|
|
59
|
-
"registryDependencies": [
|
|
60
|
-
"select",
|
|
61
|
-
],
|
|
62
|
-
"tailwind": {},
|
|
63
|
-
"type": "registry:block",
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
exports[`fixture tests > should diff a src directory project 1`] = `
|
|
68
|
-
{
|
|
69
|
-
"cssVars": {},
|
|
70
|
-
"dependencies": [],
|
|
71
|
-
"devDependencies": [],
|
|
72
|
-
"files": [
|
|
73
|
-
{
|
|
74
|
-
"content": "example env;",
|
|
75
|
-
"path": "./.env.example",
|
|
76
|
-
"target": "~/.env.example",
|
|
77
|
-
"type": "registry:example",
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"content": "non - src - sub;
|
|
81
|
-
",
|
|
82
|
-
"path": "./non-src-sub/test.ts",
|
|
83
|
-
"target": "~/non-src-sub/test.ts",
|
|
84
|
-
"type": "registry:example",
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"content": "page;
|
|
88
|
-
",
|
|
89
|
-
"path": "./app/page.tsx",
|
|
90
|
-
"target": "./app/page.tsx",
|
|
91
|
-
"type": "registry:example",
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"content": "comp;
|
|
95
|
-
",
|
|
96
|
-
"path": "./components/comp.tsx",
|
|
97
|
-
"target": undefined,
|
|
98
|
-
"type": "registry:block",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"content": "new-ui-comp;",
|
|
102
|
-
"path": "./components/ui/new-ui-comp.tsx",
|
|
103
|
-
"target": undefined,
|
|
104
|
-
"type": "registry:ui",
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"content": "hook;
|
|
108
|
-
",
|
|
109
|
-
"path": "./hooks/hook.ts",
|
|
110
|
-
"target": undefined,
|
|
111
|
-
"type": "registry:hook",
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
"content": "lib;
|
|
115
|
-
",
|
|
116
|
-
"path": "./lib/lib.ts",
|
|
117
|
-
"target": undefined,
|
|
118
|
-
"type": "registry:lib",
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
"meta": {},
|
|
122
|
-
"name": "example",
|
|
123
|
-
"registryDependencies": [
|
|
124
|
-
"select",
|
|
125
|
-
],
|
|
126
|
-
"tailwind": {},
|
|
127
|
-
"type": "registry:block",
|
|
128
|
-
}
|
|
129
|
-
`;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { parseFilePath } from "../../src/parse-file-path.mjs";
|
|
3
|
-
|
|
4
|
-
const CONFIG_IN_SRC = {
|
|
5
|
-
components: "@/components",
|
|
6
|
-
utils: "@/lib/utils",
|
|
7
|
-
ui: "@/components/ui",
|
|
8
|
-
lib: "@/lib",
|
|
9
|
-
hooks: "@/hooks",
|
|
10
|
-
isSrcDir: true,
|
|
11
|
-
};
|
|
12
|
-
const CONFIG = {
|
|
13
|
-
...CONFIG_IN_SRC,
|
|
14
|
-
isSrcDir: false,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const trim = ({ path, type, target }) => ({
|
|
18
|
-
path,
|
|
19
|
-
type,
|
|
20
|
-
target,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe("parseFilePath", () => {
|
|
24
|
-
test("should handle a new component in a src directory", () => {
|
|
25
|
-
expect(
|
|
26
|
-
trim(
|
|
27
|
-
parseFilePath(
|
|
28
|
-
true,
|
|
29
|
-
CONFIG_IN_SRC,
|
|
30
|
-
"./components/spinning-credit-card.tsx"
|
|
31
|
-
)
|
|
32
|
-
)
|
|
33
|
-
).toEqual({
|
|
34
|
-
type: "registry:block",
|
|
35
|
-
path: "./components/spinning-credit-card.tsx",
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("should handle a new component", () => {
|
|
40
|
-
expect(
|
|
41
|
-
trim(
|
|
42
|
-
parseFilePath(false, CONFIG, "./components/spinning-credit-card.tsx")
|
|
43
|
-
)
|
|
44
|
-
).toEqual({
|
|
45
|
-
type: "registry:block",
|
|
46
|
-
path: "./components/spinning-credit-card.tsx",
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("should handle a new page in a src directory", () => {
|
|
51
|
-
expect(trim(parseFilePath(true, CONFIG_IN_SRC, "./app/page.tsx"))).toEqual({
|
|
52
|
-
type: "registry:example",
|
|
53
|
-
target: "./app/page.tsx",
|
|
54
|
-
path: "./app/page.tsx",
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("should handle a new page in an app directory", () => {
|
|
59
|
-
expect(trim(parseFilePath(true, CONFIG, "./app/page.tsx"))).toEqual({
|
|
60
|
-
type: "registry:example",
|
|
61
|
-
target: "./app/page.tsx",
|
|
62
|
-
path: "./app/page.tsx",
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("should handle an environment file with a src directory", () => {
|
|
67
|
-
expect(trim(parseFilePath(false, CONFIG_IN_SRC, "./.env.example"))).toEqual(
|
|
68
|
-
{
|
|
69
|
-
type: "registry:example",
|
|
70
|
-
target: "~/.env.example",
|
|
71
|
-
path: "./.env.example",
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("should handle an environment file", () => {
|
|
77
|
-
expect(trim(parseFilePath(false, CONFIG, "./.env.example"))).toEqual({
|
|
78
|
-
type: "registry:example",
|
|
79
|
-
target: "~/.env.example",
|
|
80
|
-
path: "./.env.example",
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("should handle a new hook", () => {
|
|
85
|
-
expect(
|
|
86
|
-
trim(
|
|
87
|
-
parseFilePath(
|
|
88
|
-
false,
|
|
89
|
-
CONFIG_IN_SRC,
|
|
90
|
-
"./hooks/use-spinning-credit-card.ts"
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
).toEqual({
|
|
94
|
-
type: "registry:hook",
|
|
95
|
-
path: "./hooks/use-spinning-credit-card.ts",
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test("should handle a new library file", () => {
|
|
100
|
-
expect(trim(parseFilePath(true, CONFIG_IN_SRC, "./lib/utils.ts"))).toEqual({
|
|
101
|
-
type: "registry:lib",
|
|
102
|
-
path: "./lib/utils.ts",
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
import { scanForFiles, hasSrcDir } from "../../src/git.mjs";
|
|
6
|
-
import { readComponentsManifest } from "../../src/components.mjs";
|
|
7
|
-
import { createDiff } from "../../src/create-diff.mjs";
|
|
8
|
-
|
|
9
|
-
const EXPECTED_FILES = [
|
|
10
|
-
{
|
|
11
|
-
path: "./.env.example",
|
|
12
|
-
content: "example env;",
|
|
13
|
-
type: "registry:example",
|
|
14
|
-
target: "~/.env.example",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
path: "./non-src-sub/test.ts",
|
|
18
|
-
content: "non - src - sub;\n",
|
|
19
|
-
type: "registry:example",
|
|
20
|
-
target: "~/non-src-sub/test.ts",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
path: "./app/page.tsx",
|
|
24
|
-
content: "page;\n",
|
|
25
|
-
type: "registry:example",
|
|
26
|
-
target: "./app/page.tsx",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
path: "./components/comp.tsx",
|
|
30
|
-
content: "comp;\n",
|
|
31
|
-
type: "registry:block",
|
|
32
|
-
target: undefined,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
path: "./components/ui/new-ui-comp.tsx",
|
|
36
|
-
content: "new-ui-comp;",
|
|
37
|
-
type: "registry:ui",
|
|
38
|
-
target: undefined,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
path: "./hooks/hook.ts",
|
|
42
|
-
content: "hook;\n",
|
|
43
|
-
type: "registry:hook",
|
|
44
|
-
target: undefined,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
path: "./lib/lib.ts",
|
|
48
|
-
content: "lib;\n",
|
|
49
|
-
type: "registry:lib",
|
|
50
|
-
target: undefined,
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
function createDiffRequest(dir) {
|
|
55
|
-
const currentFiles = scanForFiles(dir);
|
|
56
|
-
|
|
57
|
-
const config = readComponentsManifest(dir);
|
|
58
|
-
config.isSrcDir = hasSrcDir(dir);
|
|
59
|
-
|
|
60
|
-
const specificFiles = {
|
|
61
|
-
"./package.json": fs.readFileSync(
|
|
62
|
-
path.join(dir, "./package.json"),
|
|
63
|
-
"utf-8"
|
|
64
|
-
),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
name: "example",
|
|
69
|
-
config,
|
|
70
|
-
alteredFiles: currentFiles,
|
|
71
|
-
specificFiles,
|
|
72
|
-
currentFiles,
|
|
73
|
-
currentPackageJson: specificFiles["./package.json"],
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
describe("fixture tests", () => {
|
|
78
|
-
test("should diff a src directory project", () => {
|
|
79
|
-
const diff = createDiff(createDiffRequest("./tests/fixtures/src-dir"));
|
|
80
|
-
expect(diff).toMatchSnapshot();
|
|
81
|
-
});
|
|
82
|
-
test("should diff a non-src directory project", () => {
|
|
83
|
-
const diff = createDiff(createDiffRequest("./tests/fixtures/non-src-dir"));
|
|
84
|
-
expect(diff).toMatchSnapshot();
|
|
85
|
-
});
|
|
86
|
-
});
|