@rife/cli 0.0.6-beta.8 → 0.0.6-beta.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.
@@ -1,223 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
-
3
- import { compareObject, parseVersion, testCompareObject, testReadPackage } from '../pnpmfile';
4
-
5
- describe('解析版本号', () => {
6
- test('范围版本号', () => {
7
- expect(parseVersion('^1.0.0')).toBe('001.000.000.000');
8
- expect(parseVersion('1.10.0')).toBe('001.010.000.000');
9
- });
10
-
11
- test('beta 版本号', () => {
12
- expect(parseVersion('1.0.0-beta.1')).toBe('001.000.000.001');
13
- });
14
- });
15
-
16
- describe('直接依赖提升', () => {
17
- test('提升 dependencies', () => {
18
- const root = {
19
- name: '@rife/root',
20
- dependencies: {
21
- '@rife/a': 'workspace:*',
22
- root: '^1.0.0',
23
- },
24
- };
25
- const a = {
26
- name: '@rife/a',
27
- dependencies: {
28
- a1: '^1.0.0',
29
- },
30
- rife: {
31
- hostDependencies: {
32
- a1: true,
33
- },
34
- },
35
- };
36
- const z = {
37
- name: '@rife/root',
38
- dependencies: {
39
- '@rife/a': 'workspace:*',
40
- root: '^1.0.0',
41
- a1: '^1.0.0',
42
- },
43
- };
44
- expect(testReadPackage([root, a])).toStrictEqual(z);
45
- });
46
-
47
- test('提升 devDependencies', () => {
48
- const root = {
49
- name: '@rife/root',
50
- dependencies: {
51
- '@rife/a': 'workspace:*',
52
- root: '^1.0.0',
53
- },
54
- };
55
- const a = {
56
- name: '@rife/a',
57
- devDependencies: {
58
- a1: '^1.0.0',
59
- },
60
- rife: {
61
- hostDependencies: {
62
- a1: true,
63
- },
64
- },
65
- };
66
- const z = {
67
- name: '@rife/root',
68
- dependencies: {
69
- '@rife/a': 'workspace:*',
70
- root: '^1.0.0',
71
- },
72
- devDependencies: {
73
- a1: '^1.0.0',
74
- },
75
- };
76
- expect(testReadPackage([root, a])).toStrictEqual(z);
77
- });
78
-
79
- test('同时提升 dependencies 和 devDependencies', () => {
80
- const root = {
81
- name: '@rife/root',
82
- dependencies: {
83
- '@rife/a': 'workspace:*',
84
- root: '^1.0.0',
85
- },
86
- };
87
- const a = {
88
- name: '@rife/a',
89
- dependencies: {
90
- a1: '^1.0.0',
91
- },
92
- devDependencies: {
93
- a2: '^1.0.0',
94
- },
95
- rife: {
96
- hostDependencies: {
97
- a1: true,
98
- a2: true,
99
- },
100
- },
101
- };
102
- const z = {
103
- name: '@rife/root',
104
- dependencies: {
105
- '@rife/a': 'workspace:*',
106
- root: '^1.0.0',
107
- a1: '^1.0.0',
108
- },
109
- devDependencies: {
110
- a2: '^1.0.0',
111
- },
112
- };
113
- expect(testReadPackage([root, a])).toStrictEqual(z);
114
- });
115
-
116
- test('提升不能覆盖现有版本号', () => {
117
- const root = {
118
- name: '@rife/root',
119
- dependencies: {
120
- '@rife/a': 'workspace:*',
121
- root: '^1.0.0',
122
- a1: '^1.0.0',
123
- },
124
- devDependencies: {
125
- a2: '^1.0.0',
126
- },
127
- };
128
- const a = {
129
- name: '@rife/a',
130
- dependencies: {
131
- a1: '^1.0.1',
132
- },
133
- devDependencies: {
134
- a2: '^1.0.1',
135
- },
136
- rife: {
137
- hostDependencies: {
138
- a1: true,
139
- a2: true,
140
- },
141
- },
142
- };
143
- const z = {
144
- name: '@rife/root',
145
- dependencies: {
146
- '@rife/a': 'workspace:*',
147
- root: '^1.0.0',
148
- a1: '^1.0.0',
149
- },
150
- devDependencies: {
151
- a2: '^1.0.0',
152
- },
153
- };
154
- expect(testReadPackage([root, a])).toStrictEqual(z);
155
- });
156
- });
157
-
158
- describe('依赖同一个依赖的多个版本', () => {
159
- test('总是提升最新版本', () => {
160
- const root = {
161
- name: '@rife/root',
162
- dependencies: {
163
- '@rife/a': 'workspace:*',
164
- root: '^1.0.0',
165
- },
166
- };
167
- const a = {
168
- name: '@rife/a',
169
- dependencies: {
170
- a1: '^1.0.0',
171
- },
172
- rife: {
173
- hostDependencies: {
174
- a1: true,
175
- },
176
- },
177
- };
178
- const b = {
179
- name: '@rife/b',
180
- dependencies: {
181
- a1: '^1.0.1',
182
- b1: '^1.0.0',
183
- },
184
- rife: {
185
- hostDependencies: {
186
- a1: true,
187
- b1: true,
188
- },
189
- },
190
- };
191
- const z = {
192
- name: '@rife/root',
193
- dependencies: {
194
- '@rife/a': 'workspace:*',
195
- root: '^1.0.0',
196
- a1: '^1.0.1',
197
- b1: '^1.0.0',
198
- },
199
- };
200
- expect(testReadPackage([root, a, b])).toStrictEqual(z);
201
- });
202
- });
203
-
204
- describe('比较差异', () => {
205
- test('相同', () => {
206
- expect(testCompareObject({}, {})).toStrictEqual({ more: [], less: [] });
207
- });
208
-
209
- test('多了', () => {
210
- expect(testCompareObject({ a: 1 }, {})).toStrictEqual({ more: [{ name: 'a', version: 1 }], less: [] });
211
- });
212
-
213
- test('少了', () => {
214
- expect(testCompareObject({}, { a: 1 })).toStrictEqual({ more: [], less: [{ name: 'a', version: 1 }] });
215
- });
216
-
217
- test('差异', () => {
218
- expect(testCompareObject({ b: 2 }, { a: 1 })).toStrictEqual({
219
- more: [{ name: 'b', version: 2 }],
220
- less: [{ name: 'a', version: 1 }],
221
- });
222
- });
223
- });