@tanstack/cta-engine 0.32.3 → 0.33.3
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/add-ons.js +8 -1
- package/dist/create-app.js +1 -1
- package/dist/types/custom-add-ons/add-on.d.ts +1 -0
- package/dist/types/types.d.ts +15 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
- package/src/add-ons.ts +11 -4
- package/src/create-app.ts +1 -1
- package/src/types.ts +1 -0
- package/tests/add-ons.test.ts +73 -0
package/dist/add-ons.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { loadRemoteAddOn } from './custom-add-ons/add-on.js';
|
|
2
2
|
export function getAllAddOns(framework, mode) {
|
|
3
|
-
return framework
|
|
3
|
+
return framework
|
|
4
|
+
.getAddOns()
|
|
5
|
+
.filter((a) => a.modes.includes(mode))
|
|
6
|
+
.sort((a, b) => {
|
|
7
|
+
const aPriority = a.priority ?? 0;
|
|
8
|
+
const bPriority = b.priority ?? 0;
|
|
9
|
+
return bPriority - aPriority; // Higher priority first
|
|
10
|
+
});
|
|
4
11
|
}
|
|
5
12
|
// Turn the list of chosen add-on IDs into a final list of add-ons by resolving dependencies
|
|
6
13
|
export async function finalizeAddOns(framework, mode, chosenAddOnIDs) {
|
package/dist/create-app.js
CHANGED
|
@@ -182,7 +182,7 @@ Use the following commands to start your app:
|
|
|
182
182
|
% cd ${options.projectName}
|
|
183
183
|
% ${formatCommand(getPackageManagerScriptCommand(options.packageManager, ['dev']))}
|
|
184
184
|
|
|
185
|
-
Please
|
|
185
|
+
Please check the README.md for information on testing, styling, adding routes, etc.${errorStatement}`);
|
|
186
186
|
}
|
|
187
187
|
export async function createApp(environment, options) {
|
|
188
188
|
environment.startRun();
|
package/dist/types/types.d.ts
CHANGED
|
@@ -113,6 +113,7 @@ export declare const AddOnBaseSchema: z.ZodObject<{
|
|
|
113
113
|
license: z.ZodOptional<z.ZodString>;
|
|
114
114
|
warning: z.ZodOptional<z.ZodString>;
|
|
115
115
|
type: z.ZodEnum<["add-on", "example", "starter", "toolchain", "host"]>;
|
|
116
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
116
117
|
command: z.ZodOptional<z.ZodObject<{
|
|
117
118
|
command: z.ZodString;
|
|
118
119
|
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -219,6 +220,7 @@ export declare const AddOnBaseSchema: z.ZodObject<{
|
|
|
219
220
|
link?: string | undefined;
|
|
220
221
|
license?: string | undefined;
|
|
221
222
|
warning?: string | undefined;
|
|
223
|
+
priority?: number | undefined;
|
|
222
224
|
routes?: {
|
|
223
225
|
path: string;
|
|
224
226
|
jsName: string;
|
|
@@ -262,6 +264,7 @@ export declare const AddOnBaseSchema: z.ZodObject<{
|
|
|
262
264
|
link?: string | undefined;
|
|
263
265
|
license?: string | undefined;
|
|
264
266
|
warning?: string | undefined;
|
|
267
|
+
priority?: number | undefined;
|
|
265
268
|
routes?: {
|
|
266
269
|
path: string;
|
|
267
270
|
jsName: string;
|
|
@@ -291,6 +294,7 @@ export declare const StarterSchema: z.ZodObject<{
|
|
|
291
294
|
license: z.ZodOptional<z.ZodString>;
|
|
292
295
|
warning: z.ZodOptional<z.ZodString>;
|
|
293
296
|
type: z.ZodEnum<["add-on", "example", "starter", "toolchain", "host"]>;
|
|
297
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
294
298
|
command: z.ZodOptional<z.ZodObject<{
|
|
295
299
|
command: z.ZodString;
|
|
296
300
|
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -407,6 +411,7 @@ export declare const StarterSchema: z.ZodObject<{
|
|
|
407
411
|
link?: string | undefined;
|
|
408
412
|
license?: string | undefined;
|
|
409
413
|
warning?: string | undefined;
|
|
414
|
+
priority?: number | undefined;
|
|
410
415
|
routes?: {
|
|
411
416
|
path: string;
|
|
412
417
|
jsName: string;
|
|
@@ -455,6 +460,7 @@ export declare const StarterSchema: z.ZodObject<{
|
|
|
455
460
|
link?: string | undefined;
|
|
456
461
|
license?: string | undefined;
|
|
457
462
|
warning?: string | undefined;
|
|
463
|
+
priority?: number | undefined;
|
|
458
464
|
routes?: {
|
|
459
465
|
path: string;
|
|
460
466
|
jsName: string;
|
|
@@ -485,6 +491,7 @@ export declare const StarterCompiledSchema: z.ZodObject<{
|
|
|
485
491
|
license: z.ZodOptional<z.ZodString>;
|
|
486
492
|
warning: z.ZodOptional<z.ZodString>;
|
|
487
493
|
type: z.ZodEnum<["add-on", "example", "starter", "toolchain", "host"]>;
|
|
494
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
488
495
|
command: z.ZodOptional<z.ZodObject<{
|
|
489
496
|
command: z.ZodString;
|
|
490
497
|
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -606,6 +613,7 @@ export declare const StarterCompiledSchema: z.ZodObject<{
|
|
|
606
613
|
link?: string | undefined;
|
|
607
614
|
license?: string | undefined;
|
|
608
615
|
warning?: string | undefined;
|
|
616
|
+
priority?: number | undefined;
|
|
609
617
|
routes?: {
|
|
610
618
|
path: string;
|
|
611
619
|
jsName: string;
|
|
@@ -656,6 +664,7 @@ export declare const StarterCompiledSchema: z.ZodObject<{
|
|
|
656
664
|
link?: string | undefined;
|
|
657
665
|
license?: string | undefined;
|
|
658
666
|
warning?: string | undefined;
|
|
667
|
+
priority?: number | undefined;
|
|
659
668
|
routes?: {
|
|
660
669
|
path: string;
|
|
661
670
|
jsName: string;
|
|
@@ -705,6 +714,7 @@ export declare const AddOnInfoSchema: z.ZodObject<{
|
|
|
705
714
|
license: z.ZodOptional<z.ZodString>;
|
|
706
715
|
warning: z.ZodOptional<z.ZodString>;
|
|
707
716
|
type: z.ZodEnum<["add-on", "example", "starter", "toolchain", "host"]>;
|
|
717
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
708
718
|
command: z.ZodOptional<z.ZodObject<{
|
|
709
719
|
command: z.ZodString;
|
|
710
720
|
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -836,6 +846,7 @@ export declare const AddOnInfoSchema: z.ZodObject<{
|
|
|
836
846
|
link?: string | undefined;
|
|
837
847
|
license?: string | undefined;
|
|
838
848
|
warning?: string | undefined;
|
|
849
|
+
priority?: number | undefined;
|
|
839
850
|
routes?: {
|
|
840
851
|
path: string;
|
|
841
852
|
jsName: string;
|
|
@@ -889,6 +900,7 @@ export declare const AddOnInfoSchema: z.ZodObject<{
|
|
|
889
900
|
link?: string | undefined;
|
|
890
901
|
license?: string | undefined;
|
|
891
902
|
warning?: string | undefined;
|
|
903
|
+
priority?: number | undefined;
|
|
892
904
|
routes?: {
|
|
893
905
|
path: string;
|
|
894
906
|
jsName: string;
|
|
@@ -926,6 +938,7 @@ export declare const AddOnCompiledSchema: z.ZodObject<{
|
|
|
926
938
|
license: z.ZodOptional<z.ZodString>;
|
|
927
939
|
warning: z.ZodOptional<z.ZodString>;
|
|
928
940
|
type: z.ZodEnum<["add-on", "example", "starter", "toolchain", "host"]>;
|
|
941
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
929
942
|
command: z.ZodOptional<z.ZodObject<{
|
|
930
943
|
command: z.ZodString;
|
|
931
944
|
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -1063,6 +1076,7 @@ export declare const AddOnCompiledSchema: z.ZodObject<{
|
|
|
1063
1076
|
link?: string | undefined;
|
|
1064
1077
|
license?: string | undefined;
|
|
1065
1078
|
warning?: string | undefined;
|
|
1079
|
+
priority?: number | undefined;
|
|
1066
1080
|
routes?: {
|
|
1067
1081
|
path: string;
|
|
1068
1082
|
jsName: string;
|
|
@@ -1119,6 +1133,7 @@ export declare const AddOnCompiledSchema: z.ZodObject<{
|
|
|
1119
1133
|
link?: string | undefined;
|
|
1120
1134
|
license?: string | undefined;
|
|
1121
1135
|
warning?: string | undefined;
|
|
1136
|
+
priority?: number | undefined;
|
|
1122
1137
|
routes?: {
|
|
1123
1138
|
path: string;
|
|
1124
1139
|
jsName: string;
|
package/dist/types.js
CHANGED
|
@@ -23,6 +23,7 @@ export const AddOnBaseSchema = z.object({
|
|
|
23
23
|
license: z.string().optional(),
|
|
24
24
|
warning: z.string().optional(),
|
|
25
25
|
type: z.enum(['add-on', 'example', 'starter', 'toolchain', 'host']),
|
|
26
|
+
priority: z.number().optional(),
|
|
26
27
|
command: z
|
|
27
28
|
.object({
|
|
28
29
|
command: z.string(),
|
package/package.json
CHANGED
package/src/add-ons.ts
CHANGED
|
@@ -3,7 +3,14 @@ import { loadRemoteAddOn } from './custom-add-ons/add-on.js'
|
|
|
3
3
|
import type { AddOn, Framework } from './types.js'
|
|
4
4
|
|
|
5
5
|
export function getAllAddOns(framework: Framework, mode: string): Array<AddOn> {
|
|
6
|
-
return framework
|
|
6
|
+
return framework
|
|
7
|
+
.getAddOns()
|
|
8
|
+
.filter((a) => a.modes.includes(mode))
|
|
9
|
+
.sort((a, b) => {
|
|
10
|
+
const aPriority = a.priority ?? 0
|
|
11
|
+
const bPriority = b.priority ?? 0
|
|
12
|
+
return bPriority - aPriority // Higher priority first
|
|
13
|
+
})
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
// Turn the list of chosen add-on IDs into a final list of add-ons by resolving dependencies
|
|
@@ -49,10 +56,10 @@ function loadAddOn(addOn: AddOn): AddOn {
|
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
export function populateAddOnOptionsDefaults(
|
|
52
|
-
chosenAddOns: Array<AddOn
|
|
59
|
+
chosenAddOns: Array<AddOn>,
|
|
53
60
|
): Record<string, Record<string, any>> {
|
|
54
61
|
const addOnOptions: Record<string, Record<string, any>> = {}
|
|
55
|
-
|
|
62
|
+
|
|
56
63
|
for (const addOn of chosenAddOns) {
|
|
57
64
|
if (addOn.options) {
|
|
58
65
|
const defaults: Record<string, any> = {}
|
|
@@ -62,6 +69,6 @@ export function populateAddOnOptionsDefaults(
|
|
|
62
69
|
addOnOptions[addOn.id] = defaults
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
|
-
|
|
72
|
+
|
|
66
73
|
return addOnOptions
|
|
67
74
|
}
|
package/src/create-app.ts
CHANGED
|
@@ -251,7 +251,7 @@ Use the following commands to start your app:
|
|
|
251
251
|
getPackageManagerScriptCommand(options.packageManager, ['dev']),
|
|
252
252
|
)}
|
|
253
253
|
|
|
254
|
-
Please
|
|
254
|
+
Please check the README.md for information on testing, styling, adding routes, etc.${errorStatement}`,
|
|
255
255
|
)
|
|
256
256
|
}
|
|
257
257
|
|
package/src/types.ts
CHANGED
|
@@ -38,6 +38,7 @@ export const AddOnBaseSchema = z.object({
|
|
|
38
38
|
license: z.string().optional(),
|
|
39
39
|
warning: z.string().optional(),
|
|
40
40
|
type: z.enum(['add-on', 'example', 'starter', 'toolchain', 'host']),
|
|
41
|
+
priority: z.number().optional(),
|
|
41
42
|
command: z
|
|
42
43
|
.object({
|
|
43
44
|
command: z.string(),
|
package/tests/add-ons.test.ts
CHANGED
|
@@ -28,6 +28,79 @@ describe('getAllAddOns', () => {
|
|
|
28
28
|
expect(addOns.length).toEqual(1)
|
|
29
29
|
expect(addOns[0].id).toEqual('add-on-1')
|
|
30
30
|
})
|
|
31
|
+
|
|
32
|
+
it('should sort add-ons by priority (higher priority first)', () => {
|
|
33
|
+
const addOns = getAllAddOns(
|
|
34
|
+
{
|
|
35
|
+
id: 'react-cra',
|
|
36
|
+
getAddOns: () => [
|
|
37
|
+
{
|
|
38
|
+
id: 'low-priority',
|
|
39
|
+
description: 'Low Priority',
|
|
40
|
+
modes: ['file-router'],
|
|
41
|
+
priority: 10,
|
|
42
|
+
} as AddOn,
|
|
43
|
+
{
|
|
44
|
+
id: 'high-priority',
|
|
45
|
+
description: 'High Priority',
|
|
46
|
+
modes: ['file-router'],
|
|
47
|
+
priority: 100,
|
|
48
|
+
} as AddOn,
|
|
49
|
+
{
|
|
50
|
+
id: 'no-priority',
|
|
51
|
+
description: 'No Priority (defaults to 0)',
|
|
52
|
+
modes: ['file-router'],
|
|
53
|
+
} as AddOn,
|
|
54
|
+
{
|
|
55
|
+
id: 'medium-priority',
|
|
56
|
+
description: 'Medium Priority',
|
|
57
|
+
modes: ['file-router'],
|
|
58
|
+
priority: 50,
|
|
59
|
+
} as AddOn,
|
|
60
|
+
],
|
|
61
|
+
} as Framework,
|
|
62
|
+
'file-router',
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
expect(addOns.length).toEqual(4)
|
|
66
|
+
expect(addOns[0].id).toEqual('high-priority')
|
|
67
|
+
expect(addOns[1].id).toEqual('medium-priority')
|
|
68
|
+
expect(addOns[2].id).toEqual('low-priority')
|
|
69
|
+
expect(addOns[3].id).toEqual('no-priority')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should filter by mode and then sort by priority', () => {
|
|
73
|
+
const addOns = getAllAddOns(
|
|
74
|
+
{
|
|
75
|
+
id: 'react-cra',
|
|
76
|
+
getAddOns: () => [
|
|
77
|
+
{
|
|
78
|
+
id: 'file-router-low',
|
|
79
|
+
description: 'File Router Low',
|
|
80
|
+
modes: ['file-router'],
|
|
81
|
+
priority: 20,
|
|
82
|
+
} as AddOn,
|
|
83
|
+
{
|
|
84
|
+
id: 'code-router-high',
|
|
85
|
+
description: 'Code Router High (should be filtered out)',
|
|
86
|
+
modes: ['code-router'],
|
|
87
|
+
priority: 200,
|
|
88
|
+
} as AddOn,
|
|
89
|
+
{
|
|
90
|
+
id: 'file-router-high',
|
|
91
|
+
description: 'File Router High',
|
|
92
|
+
modes: ['file-router'],
|
|
93
|
+
priority: 100,
|
|
94
|
+
} as AddOn,
|
|
95
|
+
],
|
|
96
|
+
} as Framework,
|
|
97
|
+
'file-router',
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
expect(addOns.length).toEqual(2)
|
|
101
|
+
expect(addOns[0].id).toEqual('file-router-high')
|
|
102
|
+
expect(addOns[1].id).toEqual('file-router-low')
|
|
103
|
+
})
|
|
31
104
|
})
|
|
32
105
|
|
|
33
106
|
describe('finalizeAddOns', () => {
|