@tanstack/cta-engine 0.25.0 → 0.25.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.
@@ -45,6 +45,10 @@ export function createTemplateFile(environment, options) {
45
45
  return acc;
46
46
  }, {});
47
47
  return async function templateFile(file, content) {
48
+ const localRelativePath = (path, stripExtension = false) => relativePath(file, path, stripExtension);
49
+ const integrationImportContent = (integration) => integration.import ||
50
+ `import ${integration.jsName} from '${localRelativePath(integration.path || '')}'`;
51
+ const integrationImportCode = (integration) => integration.code || integration.jsName;
48
52
  const templateValues = {
49
53
  packageManager: options.packageManager,
50
54
  projectName: options.projectName,
@@ -61,6 +65,8 @@ export function createTemplateFile(environment, options) {
61
65
  getPackageManagerAddScript,
62
66
  getPackageManagerRunScript,
63
67
  relativePath: (path, stripExtension = false) => relativePath(file, path, stripExtension),
68
+ integrationImportContent,
69
+ integrationImportCode,
64
70
  ignoreFile: () => {
65
71
  throw new IgnoreFileError();
66
72
  },
@@ -46,9 +46,11 @@ export declare function generateProject(persistedOptions: PersistedOptions): Pro
46
46
  createSpecialSteps?: string[] | undefined;
47
47
  default?: boolean | undefined;
48
48
  integrations?: {
49
- type: string;
50
- path: string;
51
- jsName: string;
49
+ type?: string | undefined;
50
+ code?: string | undefined;
51
+ path?: string | undefined;
52
+ jsName?: string | undefined;
53
+ import?: string | undefined;
52
54
  }[] | undefined;
53
55
  readme?: string | undefined;
54
56
  };
@@ -404,17 +404,23 @@ export declare const StarterCompiledSchema: z.ZodObject<{
404
404
  banner?: string | undefined;
405
405
  }>;
406
406
  export declare const IntegrationSchema: z.ZodObject<{
407
- type: z.ZodString;
408
- path: z.ZodString;
409
- jsName: z.ZodString;
407
+ type: z.ZodOptional<z.ZodString>;
408
+ path: z.ZodOptional<z.ZodString>;
409
+ jsName: z.ZodOptional<z.ZodString>;
410
+ import: z.ZodOptional<z.ZodString>;
411
+ code: z.ZodOptional<z.ZodString>;
410
412
  }, "strip", z.ZodTypeAny, {
411
- type: string;
412
- path: string;
413
- jsName: string;
413
+ type?: string | undefined;
414
+ code?: string | undefined;
415
+ path?: string | undefined;
416
+ jsName?: string | undefined;
417
+ import?: string | undefined;
414
418
  }, {
415
- type: string;
416
- path: string;
417
- jsName: string;
419
+ type?: string | undefined;
420
+ code?: string | undefined;
421
+ path?: string | undefined;
422
+ jsName?: string | undefined;
423
+ import?: string | undefined;
418
424
  }>;
419
425
  export declare const AddOnInfoSchema: z.ZodObject<{
420
426
  id: z.ZodString;
@@ -475,17 +481,23 @@ export declare const AddOnInfoSchema: z.ZodObject<{
475
481
  } & {
476
482
  modes: z.ZodArray<z.ZodString, "many">;
477
483
  integrations: z.ZodOptional<z.ZodArray<z.ZodObject<{
478
- type: z.ZodString;
479
- path: z.ZodString;
480
- jsName: z.ZodString;
484
+ type: z.ZodOptional<z.ZodString>;
485
+ path: z.ZodOptional<z.ZodString>;
486
+ jsName: z.ZodOptional<z.ZodString>;
487
+ import: z.ZodOptional<z.ZodString>;
488
+ code: z.ZodOptional<z.ZodString>;
481
489
  }, "strip", z.ZodTypeAny, {
482
- type: string;
483
- path: string;
484
- jsName: string;
490
+ type?: string | undefined;
491
+ code?: string | undefined;
492
+ path?: string | undefined;
493
+ jsName?: string | undefined;
494
+ import?: string | undefined;
485
495
  }, {
486
- type: string;
487
- path: string;
488
- jsName: string;
496
+ type?: string | undefined;
497
+ code?: string | undefined;
498
+ path?: string | undefined;
499
+ jsName?: string | undefined;
500
+ import?: string | undefined;
489
501
  }>, "many">>;
490
502
  phase: z.ZodEnum<["setup", "add-on"]>;
491
503
  readme: z.ZodOptional<z.ZodString>;
@@ -524,9 +536,11 @@ export declare const AddOnInfoSchema: z.ZodObject<{
524
536
  createSpecialSteps?: string[] | undefined;
525
537
  default?: boolean | undefined;
526
538
  integrations?: {
527
- type: string;
528
- path: string;
529
- jsName: string;
539
+ type?: string | undefined;
540
+ code?: string | undefined;
541
+ path?: string | undefined;
542
+ jsName?: string | undefined;
543
+ import?: string | undefined;
530
544
  }[] | undefined;
531
545
  readme?: string | undefined;
532
546
  }, {
@@ -564,9 +578,11 @@ export declare const AddOnInfoSchema: z.ZodObject<{
564
578
  createSpecialSteps?: string[] | undefined;
565
579
  default?: boolean | undefined;
566
580
  integrations?: {
567
- type: string;
568
- path: string;
569
- jsName: string;
581
+ type?: string | undefined;
582
+ code?: string | undefined;
583
+ path?: string | undefined;
584
+ jsName?: string | undefined;
585
+ import?: string | undefined;
570
586
  }[] | undefined;
571
587
  readme?: string | undefined;
572
588
  }>;
@@ -629,17 +645,23 @@ export declare const AddOnCompiledSchema: z.ZodObject<{
629
645
  } & {
630
646
  modes: z.ZodArray<z.ZodString, "many">;
631
647
  integrations: z.ZodOptional<z.ZodArray<z.ZodObject<{
632
- type: z.ZodString;
633
- path: z.ZodString;
634
- jsName: z.ZodString;
648
+ type: z.ZodOptional<z.ZodString>;
649
+ path: z.ZodOptional<z.ZodString>;
650
+ jsName: z.ZodOptional<z.ZodString>;
651
+ import: z.ZodOptional<z.ZodString>;
652
+ code: z.ZodOptional<z.ZodString>;
635
653
  }, "strip", z.ZodTypeAny, {
636
- type: string;
637
- path: string;
638
- jsName: string;
654
+ type?: string | undefined;
655
+ code?: string | undefined;
656
+ path?: string | undefined;
657
+ jsName?: string | undefined;
658
+ import?: string | undefined;
639
659
  }, {
640
- type: string;
641
- path: string;
642
- jsName: string;
660
+ type?: string | undefined;
661
+ code?: string | undefined;
662
+ path?: string | undefined;
663
+ jsName?: string | undefined;
664
+ import?: string | undefined;
643
665
  }>, "many">>;
644
666
  phase: z.ZodEnum<["setup", "add-on"]>;
645
667
  readme: z.ZodOptional<z.ZodString>;
@@ -683,9 +705,11 @@ export declare const AddOnCompiledSchema: z.ZodObject<{
683
705
  createSpecialSteps?: string[] | undefined;
684
706
  default?: boolean | undefined;
685
707
  integrations?: {
686
- type: string;
687
- path: string;
688
- jsName: string;
708
+ type?: string | undefined;
709
+ code?: string | undefined;
710
+ path?: string | undefined;
711
+ jsName?: string | undefined;
712
+ import?: string | undefined;
689
713
  }[] | undefined;
690
714
  readme?: string | undefined;
691
715
  }, {
@@ -725,9 +749,11 @@ export declare const AddOnCompiledSchema: z.ZodObject<{
725
749
  createSpecialSteps?: string[] | undefined;
726
750
  default?: boolean | undefined;
727
751
  integrations?: {
728
- type: string;
729
- path: string;
730
- jsName: string;
752
+ type?: string | undefined;
753
+ code?: string | undefined;
754
+ path?: string | undefined;
755
+ jsName?: string | undefined;
756
+ import?: string | undefined;
731
757
  }[] | undefined;
732
758
  readme?: string | undefined;
733
759
  }>;
package/dist/types.js CHANGED
@@ -50,9 +50,11 @@ export const StarterCompiledSchema = StarterSchema.extend({
50
50
  deletedFiles: z.array(z.string()),
51
51
  });
52
52
  export const IntegrationSchema = z.object({
53
- type: z.string(),
54
- path: z.string(),
55
- jsName: z.string(),
53
+ type: z.string().optional(),
54
+ path: z.string().optional(),
55
+ jsName: z.string().optional(),
56
+ import: z.string().optional(),
57
+ code: z.string().optional(),
56
58
  });
57
59
  export const AddOnInfoSchema = AddOnBaseSchema.extend({
58
60
  modes: z.array(z.string()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/cta-engine",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "Tanstack Application Builder Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,7 +9,7 @@ import {
9
9
  } from './package-manager.js'
10
10
  import { relativePath } from './file-helpers.js'
11
11
 
12
- import type { AddOn, Environment, Options } from './types.js'
12
+ import type { AddOn, Environment, Integration, Options } from './types.js'
13
13
 
14
14
  function convertDotFilesAndPaths(path: string) {
15
15
  return path
@@ -75,6 +75,16 @@ export function createTemplateFile(environment: Environment, options: Options) {
75
75
  )
76
76
 
77
77
  return async function templateFile(file: string, content: string) {
78
+ const localRelativePath = (path: string, stripExtension: boolean = false) =>
79
+ relativePath(file, path, stripExtension)
80
+
81
+ const integrationImportContent = (integration: Integration) =>
82
+ integration.import ||
83
+ `import ${integration.jsName} from '${localRelativePath(integration.path || '')}'`
84
+
85
+ const integrationImportCode = (integration: Integration) =>
86
+ integration.code || integration.jsName
87
+
78
88
  const templateValues = {
79
89
  packageManager: options.packageManager,
80
90
  projectName: options.projectName,
@@ -95,6 +105,9 @@ export function createTemplateFile(environment: Environment, options: Options) {
95
105
  relativePath: (path: string, stripExtension: boolean = false) =>
96
106
  relativePath(file, path, stripExtension),
97
107
 
108
+ integrationImportContent,
109
+ integrationImportCode,
110
+
98
111
  ignoreFile: () => {
99
112
  throw new IgnoreFileError()
100
113
  },
package/src/types.ts CHANGED
@@ -65,9 +65,11 @@ export const StarterCompiledSchema = StarterSchema.extend({
65
65
  })
66
66
 
67
67
  export const IntegrationSchema = z.object({
68
- type: z.string(),
69
- path: z.string(),
70
- jsName: z.string(),
68
+ type: z.string().optional(),
69
+ path: z.string().optional(),
70
+ jsName: z.string().optional(),
71
+ import: z.string().optional(),
72
+ code: z.string().optional(),
71
73
  })
72
74
 
73
75
  export const AddOnInfoSchema = AddOnBaseSchema.extend({