@nikovirtala/projen-constructs 0.1.8 → 0.2.0
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/.jsii +622 -97
- package/API.md +769 -52
- package/README.md +37 -8
- package/lib/components/typedoc-config.d.ts +321 -0
- package/lib/components/typedoc-config.js +73 -1
- package/lib/components/typedoc.d.ts +19 -0
- package/lib/components/typedoc.js +10 -1
- package/lib/components/vitest.d.ts +197 -0
- package/lib/components/vitest.js +72 -2
- package/lib/config.d.ts +4 -4
- package/lib/errors.d.ts +16 -0
- package/lib/errors.js +26 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/project-generator.d.ts +87 -63
- package/lib/project-generator.js +344 -60
- package/lib/project-type.d.ts +78 -16
- package/lib/project-type.js +79 -17
- package/lib/projects/awscdk-construct-library.generated.js +4 -4
- package/lib/projects/awscdk-typescript-app.generated.js +4 -4
- package/lib/projects/jsii.generated.js +4 -4
- package/lib/projects/typescript.generated.js +4 -4
- package/lib/utils.d.ts +2 -2
- package/lib/utils.js +3 -3
- package/package.json +1 -1
- package/scripts/generate-project-types.ts +103 -0
|
@@ -1,59 +1,53 @@
|
|
|
1
|
-
import type { Property } from "@jsii/spec";
|
|
2
1
|
import type { Project, SourceCodeOptions } from "projen";
|
|
3
|
-
import
|
|
2
|
+
import * as projen from "projen";
|
|
4
3
|
import type { ProjectType } from "./project-type";
|
|
5
4
|
/**
|
|
6
5
|
* Configuration for a component to be integrated into a generated project
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const config: ComponentConfig = {
|
|
11
|
-
* component: Vitest,
|
|
12
|
-
* optionsProperty: "vitestOptions"
|
|
13
|
-
* };
|
|
14
|
-
* ```
|
|
15
6
|
*/
|
|
16
|
-
interface
|
|
7
|
+
export interface Component {
|
|
8
|
+
/**
|
|
9
|
+
* Component class reference
|
|
10
|
+
*
|
|
11
|
+
* @jsii ignore
|
|
12
|
+
*/
|
|
13
|
+
readonly componentClass: any;
|
|
17
14
|
/**
|
|
18
|
-
*
|
|
15
|
+
* Fully qualified name of the component class
|
|
16
|
+
*
|
|
17
|
+
* Optional - auto-detected by searching JSII manifests.
|
|
19
18
|
*/
|
|
20
|
-
readonly
|
|
19
|
+
readonly fqn?: string;
|
|
21
20
|
/**
|
|
22
21
|
* Options property configuration for the generated options interface
|
|
23
22
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
* Optional - auto-detected from component constructor.
|
|
24
|
+
* Set to false to disable options property generation.
|
|
25
|
+
* Set to string or object to customize the property name.
|
|
26
|
+
*/
|
|
27
|
+
readonly optionsProperty?: string | ComponentOptions | false;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options property configuration
|
|
31
|
+
*/
|
|
32
|
+
export interface ComponentOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Name of the options property
|
|
35
|
+
*/
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/**
|
|
38
|
+
* Fully qualified type name (optional, auto-detected from component constructor)
|
|
39
|
+
*/
|
|
40
|
+
readonly type?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Documentation summary (optional, auto-detected from component constructor)
|
|
43
|
+
*/
|
|
44
|
+
readonly docs?: string;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* Options for ProjectGenerator component
|
|
44
48
|
*
|
|
45
49
|
* Configures the generation of a TypeScript project class that extends a Projen base class
|
|
46
50
|
* with standard configuration and component integration.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* new ProjectGenerator(project, {
|
|
51
|
-
* name: "TypeScriptProject",
|
|
52
|
-
* baseClass: "typescript.TypeScriptProject",
|
|
53
|
-
* filePath: "src/projects/typescript.generated.ts",
|
|
54
|
-
* components: [{ component: Vitest, optionsProperty: "vitestOptions" }]
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
57
51
|
*/
|
|
58
52
|
export interface ProjectGeneratorOptions extends SourceCodeOptions {
|
|
59
53
|
/**
|
|
@@ -88,14 +82,16 @@ export interface ProjectGeneratorOptions extends SourceCodeOptions {
|
|
|
88
82
|
*
|
|
89
83
|
* @default [{ component: Mise }, { component: Vitest, optionsProperty: { name: "vitestOptions", type: "...", docs: "..." } }]
|
|
90
84
|
*/
|
|
91
|
-
readonly components?:
|
|
85
|
+
readonly components?: Component[];
|
|
92
86
|
/**
|
|
93
87
|
* Additional properties to add to the generated options interface
|
|
94
88
|
*
|
|
95
89
|
* Use this to extend the base options with custom properties specific to
|
|
96
90
|
* your project type.
|
|
91
|
+
*
|
|
92
|
+
* @jsii ignore
|
|
97
93
|
*/
|
|
98
|
-
readonly additionalOptions?:
|
|
94
|
+
readonly additionalOptions?: any[];
|
|
99
95
|
/**
|
|
100
96
|
* Property names to omit from the base options interface
|
|
101
97
|
*
|
|
@@ -108,29 +104,12 @@ export interface ProjectGeneratorOptions extends SourceCodeOptions {
|
|
|
108
104
|
* Projen component that generates TypeScript project classes with standard configuration
|
|
109
105
|
*
|
|
110
106
|
* This component automates the creation of project classes that extend Projen base classes
|
|
111
|
-
* with opinionated defaults and component integration.
|
|
112
|
-
* 1. An options interface (via ProjenStruct) that extends the base Projen options
|
|
113
|
-
* 2. A project class that applies default configuration and instantiates components
|
|
114
|
-
*
|
|
115
|
-
* The generated code follows a consistent pattern:
|
|
116
|
-
* - Imports required modules and components
|
|
117
|
-
* - Re-exports the generated options interface
|
|
118
|
-
* - Defines a class extending the Projen base class
|
|
119
|
-
* - Constructor merges defaults with user options and applies components
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* new ProjectGenerator(project, {
|
|
124
|
-
* name: "TypeScriptProject",
|
|
125
|
-
* baseClass: "typescript.TypeScriptProject",
|
|
126
|
-
* filePath: "src/projects/typescript.generated.ts",
|
|
127
|
-
* components: [{ component: Vitest, optionsProperty: "vitestOptions" }]
|
|
128
|
-
* });
|
|
129
|
-
* ```
|
|
107
|
+
* with opinionated defaults and component integration.
|
|
130
108
|
*/
|
|
131
|
-
export declare class ProjectGenerator extends Component {
|
|
109
|
+
export declare class ProjectGenerator extends projen.Component {
|
|
132
110
|
private readonly options;
|
|
133
111
|
private renderer;
|
|
112
|
+
private static enumGenerated;
|
|
134
113
|
/**
|
|
135
114
|
* @param project - Projen project instance
|
|
136
115
|
* @param options - Generator configuration
|
|
@@ -167,5 +146,50 @@ export declare class ProjectGenerator extends Component {
|
|
|
167
146
|
* The file is marked as readonly to prevent manual editing.
|
|
168
147
|
*/
|
|
169
148
|
preSynthesize(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Checks if an FQN is available in any JSII manifest
|
|
151
|
+
*/
|
|
152
|
+
private isFqnAvailable;
|
|
153
|
+
/**
|
|
154
|
+
* Resolves component options type from JSII manifest
|
|
155
|
+
*
|
|
156
|
+
* Auto-detects options from JSII manifest when optionsProperty is undefined.
|
|
157
|
+
* Returns null only when optionsProperty is explicitly set to false.
|
|
158
|
+
*/
|
|
159
|
+
private resolveComponentOptionsType;
|
|
160
|
+
/**
|
|
161
|
+
* Finds component FQN by searching all JSII manifests
|
|
162
|
+
*/
|
|
163
|
+
private findComponentFqn;
|
|
164
|
+
/**
|
|
165
|
+
* Finds all JSII packages in node_modules
|
|
166
|
+
*/
|
|
167
|
+
private findJsiiPackages;
|
|
168
|
+
/**
|
|
169
|
+
* Loads JSII manifest for a given FQN
|
|
170
|
+
*
|
|
171
|
+
* Extracts package name from FQN. For scoped packages like @scope/package.ClassName,
|
|
172
|
+
* the package name is everything before the first dot (i.e., @scope/package).
|
|
173
|
+
*/
|
|
174
|
+
private loadManifestForFqn;
|
|
175
|
+
/**
|
|
176
|
+
* Loads JSII manifest from a package directory
|
|
177
|
+
*/
|
|
178
|
+
private loadManifestFromPackage;
|
|
179
|
+
/**
|
|
180
|
+
* Loads this package's JSII manifest
|
|
181
|
+
*/
|
|
182
|
+
private loadOwnManifest;
|
|
183
|
+
/**
|
|
184
|
+
* Generates ProjectType enum from Projen's JSII manifest
|
|
185
|
+
*/
|
|
186
|
+
private generateProjectTypeEnum;
|
|
187
|
+
/**
|
|
188
|
+
* Discovers all project types that extend projen.Project
|
|
189
|
+
*/
|
|
190
|
+
private discoverProjectTypes;
|
|
191
|
+
/**
|
|
192
|
+
* Checks if a class extends the base class
|
|
193
|
+
*/
|
|
194
|
+
private extendsBase;
|
|
170
195
|
}
|
|
171
|
-
export {};
|