@equinor/fusion-framework-cli 11.2.0 → 11.3.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.
- package/CHANGELOG.md +172 -0
- package/README.md +17 -0
- package/bin/build/bin.mjs +1 -1
- package/bin/build/cli.mjs +3 -3
- package/dist/esm/lib/utils/assert.js +70 -15
- package/dist/esm/lib/utils/assert.js.map +1 -1
- package/dist/esm/lib/utils/is-git-dir.js +19 -0
- package/dist/esm/lib/utils/is-git-dir.js.map +1 -0
- package/dist/esm/lib/utils/package-info.js +135 -0
- package/dist/esm/lib/utils/package-info.js.map +1 -0
- package/dist/esm/lib/utils/path-security.js +56 -0
- package/dist/esm/lib/utils/path-security.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/bin/app-tag.d.ts +1 -1
- package/dist/types/bin/helpers/ProjectTemplate.d.ts +61 -0
- package/dist/types/bin/helpers/ProjectTemplateRepository.d.ts +113 -0
- package/dist/types/bin/helpers/install-package-dependencies.d.ts +11 -0
- package/dist/types/bin/helpers/project-templates.schema.d.ts +301 -0
- package/dist/types/cli/commands/create/_helpers/check-target-directory.d.ts +12 -0
- package/dist/types/cli/commands/create/_helpers/cleanup-template-files.d.ts +15 -0
- package/dist/types/cli/commands/create/_helpers/install-dependencies.d.ts +14 -0
- package/dist/types/cli/commands/create/_helpers/open-in-ide.d.ts +15 -0
- package/dist/types/cli/commands/create/_helpers/resolve-workspace-dependencies.d.ts +27 -0
- package/dist/types/cli/commands/create/_helpers/select-template.d.ts +24 -0
- package/dist/types/cli/commands/create/_helpers/setup-repository.d.ts +23 -0
- package/dist/types/cli/commands/create/_helpers/start-dev-server.d.ts +17 -0
- package/dist/types/cli/commands/create/_helpers/update-package-json.d.ts +41 -0
- package/dist/types/cli/commands/create/app.d.ts +28 -0
- package/dist/types/cli/commands/create/index.d.ts +2 -0
- package/dist/types/lib/utils/assert.d.ts +61 -13
- package/dist/types/lib/utils/is-git-dir.d.ts +9 -0
- package/dist/types/lib/utils/package-info.d.ts +106 -0
- package/dist/types/lib/utils/path-security.d.ts +36 -0
- package/dist/types/version.d.ts +1 -1
- package/docs/creating-apps.md +275 -0
- package/package.json +19 -10
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema for template resource files.
|
|
4
|
+
* Defines the structure for individual files in a project template.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TemplateResourceFileSchema: z.ZodObject<{
|
|
7
|
+
type: z.ZodLiteral<"file">;
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
target: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
path: string;
|
|
12
|
+
type: "file";
|
|
13
|
+
target?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
path: string;
|
|
16
|
+
type: "file";
|
|
17
|
+
target?: string | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Zod schema for template resource directories.
|
|
21
|
+
* Defines the structure for directories in a project template.
|
|
22
|
+
*/
|
|
23
|
+
export declare const TemplateResourceDirSchema: z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"dir">;
|
|
25
|
+
path: z.ZodString;
|
|
26
|
+
target: z.ZodOptional<z.ZodString>;
|
|
27
|
+
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
path: string;
|
|
30
|
+
type: "dir";
|
|
31
|
+
target?: string | undefined;
|
|
32
|
+
recursive?: boolean | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
path: string;
|
|
35
|
+
type: "dir";
|
|
36
|
+
target?: string | undefined;
|
|
37
|
+
recursive?: boolean | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Union schema for all template resource types.
|
|
41
|
+
* Supports both file and directory resources with discriminated union.
|
|
42
|
+
*/
|
|
43
|
+
export declare const TemplateResourceSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"file">;
|
|
45
|
+
path: z.ZodString;
|
|
46
|
+
target: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
path: string;
|
|
49
|
+
type: "file";
|
|
50
|
+
target?: string | undefined;
|
|
51
|
+
}, {
|
|
52
|
+
path: string;
|
|
53
|
+
type: "file";
|
|
54
|
+
target?: string | undefined;
|
|
55
|
+
}>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"dir">;
|
|
57
|
+
path: z.ZodString;
|
|
58
|
+
target: z.ZodOptional<z.ZodString>;
|
|
59
|
+
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
path: string;
|
|
62
|
+
type: "dir";
|
|
63
|
+
target?: string | undefined;
|
|
64
|
+
recursive?: boolean | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
path: string;
|
|
67
|
+
type: "dir";
|
|
68
|
+
target?: string | undefined;
|
|
69
|
+
recursive?: boolean | undefined;
|
|
70
|
+
}>]>;
|
|
71
|
+
/**
|
|
72
|
+
* Zod schema for a single template item.
|
|
73
|
+
* Defines the structure of individual project templates.
|
|
74
|
+
*/
|
|
75
|
+
export declare const TemplateItemSchema: z.ZodObject<{
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
description: z.ZodString;
|
|
78
|
+
resources: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"file">;
|
|
80
|
+
path: z.ZodString;
|
|
81
|
+
target: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
path: string;
|
|
84
|
+
type: "file";
|
|
85
|
+
target?: string | undefined;
|
|
86
|
+
}, {
|
|
87
|
+
path: string;
|
|
88
|
+
type: "file";
|
|
89
|
+
target?: string | undefined;
|
|
90
|
+
}>, z.ZodObject<{
|
|
91
|
+
type: z.ZodLiteral<"dir">;
|
|
92
|
+
path: z.ZodString;
|
|
93
|
+
target: z.ZodOptional<z.ZodString>;
|
|
94
|
+
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
path: string;
|
|
97
|
+
type: "dir";
|
|
98
|
+
target?: string | undefined;
|
|
99
|
+
recursive?: boolean | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
path: string;
|
|
102
|
+
type: "dir";
|
|
103
|
+
target?: string | undefined;
|
|
104
|
+
recursive?: boolean | undefined;
|
|
105
|
+
}>]>, "many">;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
resources: ({
|
|
108
|
+
path: string;
|
|
109
|
+
type: "file";
|
|
110
|
+
target?: string | undefined;
|
|
111
|
+
} | {
|
|
112
|
+
path: string;
|
|
113
|
+
type: "dir";
|
|
114
|
+
target?: string | undefined;
|
|
115
|
+
recursive?: boolean | undefined;
|
|
116
|
+
})[];
|
|
117
|
+
name: string;
|
|
118
|
+
description: string;
|
|
119
|
+
}, {
|
|
120
|
+
resources: ({
|
|
121
|
+
path: string;
|
|
122
|
+
type: "file";
|
|
123
|
+
target?: string | undefined;
|
|
124
|
+
} | {
|
|
125
|
+
path: string;
|
|
126
|
+
type: "dir";
|
|
127
|
+
target?: string | undefined;
|
|
128
|
+
recursive?: boolean | undefined;
|
|
129
|
+
})[];
|
|
130
|
+
name: string;
|
|
131
|
+
description: string;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Zod schema for the complete templates manifest.
|
|
135
|
+
* Defines the structure of the templates.json file.
|
|
136
|
+
*/
|
|
137
|
+
export declare const TemplatesManifestSchema: z.ZodObject<{
|
|
138
|
+
templates: z.ZodArray<z.ZodObject<{
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
description: z.ZodString;
|
|
141
|
+
resources: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
142
|
+
type: z.ZodLiteral<"file">;
|
|
143
|
+
path: z.ZodString;
|
|
144
|
+
target: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
path: string;
|
|
147
|
+
type: "file";
|
|
148
|
+
target?: string | undefined;
|
|
149
|
+
}, {
|
|
150
|
+
path: string;
|
|
151
|
+
type: "file";
|
|
152
|
+
target?: string | undefined;
|
|
153
|
+
}>, z.ZodObject<{
|
|
154
|
+
type: z.ZodLiteral<"dir">;
|
|
155
|
+
path: z.ZodString;
|
|
156
|
+
target: z.ZodOptional<z.ZodString>;
|
|
157
|
+
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
path: string;
|
|
160
|
+
type: "dir";
|
|
161
|
+
target?: string | undefined;
|
|
162
|
+
recursive?: boolean | undefined;
|
|
163
|
+
}, {
|
|
164
|
+
path: string;
|
|
165
|
+
type: "dir";
|
|
166
|
+
target?: string | undefined;
|
|
167
|
+
recursive?: boolean | undefined;
|
|
168
|
+
}>]>, "many">;
|
|
169
|
+
}, "strip", z.ZodTypeAny, {
|
|
170
|
+
resources: ({
|
|
171
|
+
path: string;
|
|
172
|
+
type: "file";
|
|
173
|
+
target?: string | undefined;
|
|
174
|
+
} | {
|
|
175
|
+
path: string;
|
|
176
|
+
type: "dir";
|
|
177
|
+
target?: string | undefined;
|
|
178
|
+
recursive?: boolean | undefined;
|
|
179
|
+
})[];
|
|
180
|
+
name: string;
|
|
181
|
+
description: string;
|
|
182
|
+
}, {
|
|
183
|
+
resources: ({
|
|
184
|
+
path: string;
|
|
185
|
+
type: "file";
|
|
186
|
+
target?: string | undefined;
|
|
187
|
+
} | {
|
|
188
|
+
path: string;
|
|
189
|
+
type: "dir";
|
|
190
|
+
target?: string | undefined;
|
|
191
|
+
recursive?: boolean | undefined;
|
|
192
|
+
})[];
|
|
193
|
+
name: string;
|
|
194
|
+
description: string;
|
|
195
|
+
}>, "many">;
|
|
196
|
+
resources: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
197
|
+
type: z.ZodLiteral<"file">;
|
|
198
|
+
path: z.ZodString;
|
|
199
|
+
target: z.ZodOptional<z.ZodString>;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
path: string;
|
|
202
|
+
type: "file";
|
|
203
|
+
target?: string | undefined;
|
|
204
|
+
}, {
|
|
205
|
+
path: string;
|
|
206
|
+
type: "file";
|
|
207
|
+
target?: string | undefined;
|
|
208
|
+
}>, z.ZodObject<{
|
|
209
|
+
type: z.ZodLiteral<"dir">;
|
|
210
|
+
path: z.ZodString;
|
|
211
|
+
target: z.ZodOptional<z.ZodString>;
|
|
212
|
+
recursive: z.ZodOptional<z.ZodBoolean>;
|
|
213
|
+
}, "strip", z.ZodTypeAny, {
|
|
214
|
+
path: string;
|
|
215
|
+
type: "dir";
|
|
216
|
+
target?: string | undefined;
|
|
217
|
+
recursive?: boolean | undefined;
|
|
218
|
+
}, {
|
|
219
|
+
path: string;
|
|
220
|
+
type: "dir";
|
|
221
|
+
target?: string | undefined;
|
|
222
|
+
recursive?: boolean | undefined;
|
|
223
|
+
}>]>, "many">>;
|
|
224
|
+
}, "strip", z.ZodTypeAny, {
|
|
225
|
+
templates: {
|
|
226
|
+
resources: ({
|
|
227
|
+
path: string;
|
|
228
|
+
type: "file";
|
|
229
|
+
target?: string | undefined;
|
|
230
|
+
} | {
|
|
231
|
+
path: string;
|
|
232
|
+
type: "dir";
|
|
233
|
+
target?: string | undefined;
|
|
234
|
+
recursive?: boolean | undefined;
|
|
235
|
+
})[];
|
|
236
|
+
name: string;
|
|
237
|
+
description: string;
|
|
238
|
+
}[];
|
|
239
|
+
resources?: ({
|
|
240
|
+
path: string;
|
|
241
|
+
type: "file";
|
|
242
|
+
target?: string | undefined;
|
|
243
|
+
} | {
|
|
244
|
+
path: string;
|
|
245
|
+
type: "dir";
|
|
246
|
+
target?: string | undefined;
|
|
247
|
+
recursive?: boolean | undefined;
|
|
248
|
+
})[] | undefined;
|
|
249
|
+
}, {
|
|
250
|
+
templates: {
|
|
251
|
+
resources: ({
|
|
252
|
+
path: string;
|
|
253
|
+
type: "file";
|
|
254
|
+
target?: string | undefined;
|
|
255
|
+
} | {
|
|
256
|
+
path: string;
|
|
257
|
+
type: "dir";
|
|
258
|
+
target?: string | undefined;
|
|
259
|
+
recursive?: boolean | undefined;
|
|
260
|
+
})[];
|
|
261
|
+
name: string;
|
|
262
|
+
description: string;
|
|
263
|
+
}[];
|
|
264
|
+
resources?: ({
|
|
265
|
+
path: string;
|
|
266
|
+
type: "file";
|
|
267
|
+
target?: string | undefined;
|
|
268
|
+
} | {
|
|
269
|
+
path: string;
|
|
270
|
+
type: "dir";
|
|
271
|
+
target?: string | undefined;
|
|
272
|
+
recursive?: boolean | undefined;
|
|
273
|
+
})[] | undefined;
|
|
274
|
+
}>;
|
|
275
|
+
/**
|
|
276
|
+
* Type definitions derived from schemas
|
|
277
|
+
*/
|
|
278
|
+
export type TemplateResourceFile = z.infer<typeof TemplateResourceFileSchema>;
|
|
279
|
+
export type TemplateResourceDir = z.infer<typeof TemplateResourceDirSchema>;
|
|
280
|
+
export type TemplateResource = z.infer<typeof TemplateResourceSchema>;
|
|
281
|
+
export type TemplateItem = z.infer<typeof TemplateItemSchema>;
|
|
282
|
+
export type TemplatesManifest = z.infer<typeof TemplatesManifestSchema>;
|
|
283
|
+
/**
|
|
284
|
+
* Validates and parses a template manifest JSON string.
|
|
285
|
+
*
|
|
286
|
+
* This function takes a JSON string containing template definitions and validates
|
|
287
|
+
* it against the TemplatesManifestSchema. It provides detailed error messages
|
|
288
|
+
* for both JSON parsing errors and schema validation failures.
|
|
289
|
+
*
|
|
290
|
+
* @param jsonString - The JSON string to validate and parse
|
|
291
|
+
* @returns Parsed and validated template manifest object
|
|
292
|
+
* @throws {Error} If JSON parsing fails or schema validation fails
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* const manifestJson = readFileSync('templates.json', 'utf8');
|
|
297
|
+
* const manifest = parseTemplatesManifest(manifestJson);
|
|
298
|
+
* console.log(`Found ${manifest.templates.length} templates`);
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
export declare function parseTemplatesManifest(jsonString: string): TemplatesManifest;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
2
|
+
/**
|
|
3
|
+
* Check if target directory exists and has content, then prompt user for action.
|
|
4
|
+
*
|
|
5
|
+
* @param targetDir - Directory to check
|
|
6
|
+
* @param logger - Logger instance for output
|
|
7
|
+
* @param clean - If true, automatically clean the directory without prompting
|
|
8
|
+
* @param baseDir - Base directory for path validation (defaults to process.cwd())
|
|
9
|
+
* @returns Promise resolving to true if should continue, false if should abort
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkTargetDirectory(targetDir: string, logger: ConsoleLogger, clean?: boolean, baseDir?: string): Promise<boolean>;
|
|
12
|
+
export default checkTargetDirectory;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
2
|
+
import type { ProjectTemplateRepository } from '../../../../bin/helpers/ProjectTemplateRepository.js';
|
|
3
|
+
/**
|
|
4
|
+
* Prompts the user to clean up temporary template files after project creation.
|
|
5
|
+
*
|
|
6
|
+
* Offers the user the option to remove the cloned template repository and
|
|
7
|
+
* temporary files to free up disk space. If the user declines, the files
|
|
8
|
+
* remain available for future use.
|
|
9
|
+
*
|
|
10
|
+
* @param repo - ProjectTemplateRepository instance containing temporary files
|
|
11
|
+
* @param logger - Console logger for displaying prompts and cleanup status
|
|
12
|
+
* @returns Promise that resolves when the cleanup process is complete
|
|
13
|
+
*/
|
|
14
|
+
export declare function cleanupTemplateFiles(repo: ProjectTemplateRepository, logger: ConsoleLogger): Promise<void>;
|
|
15
|
+
export default cleanupTemplateFiles;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
2
|
+
/**
|
|
3
|
+
* Prompt user to install dependencies and execute the installation.
|
|
4
|
+
* Returns whether dependencies were actually installed and the package manager used.
|
|
5
|
+
*
|
|
6
|
+
* @param targetDir - Directory path where dependencies should be installed
|
|
7
|
+
* @param logger - Logger instance for output
|
|
8
|
+
* @returns Promise resolving to object with installed status and package manager
|
|
9
|
+
*/
|
|
10
|
+
export declare function installDependencies(targetDir: string, logger: ConsoleLogger): Promise<{
|
|
11
|
+
installed: boolean;
|
|
12
|
+
packageManager?: string;
|
|
13
|
+
}>;
|
|
14
|
+
export default installDependencies;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
2
|
+
/**
|
|
3
|
+
* Prompts the user to open the newly created project in their preferred IDE.
|
|
4
|
+
*
|
|
5
|
+
* Displays a selection menu with supported IDEs (VS Code, Cursor) and executes
|
|
6
|
+
* the appropriate command to open the project directory. The IDE runs detached
|
|
7
|
+
* and independently of the CLI process. If the user chooses not to open an IDE,
|
|
8
|
+
* the function completes without action.
|
|
9
|
+
*
|
|
10
|
+
* @param targetDir - Absolute path to the project directory to open
|
|
11
|
+
* @param logger - Console logger for displaying prompts and instructions
|
|
12
|
+
* @returns Promise that resolves when the IDE selection process is complete
|
|
13
|
+
*/
|
|
14
|
+
export declare function openInIDE(targetDir: string, logger: ConsoleLogger): Promise<void>;
|
|
15
|
+
export default openInIDE;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PackageJson } from 'type-fest';
|
|
2
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves workspace dependencies in a package.json object to their latest npm versions.
|
|
5
|
+
*
|
|
6
|
+
* This function processes all dependency types (dependencies, devDependencies, peerDependencies)
|
|
7
|
+
* and replaces workspace dependencies (e.g., "workspace:^") with their latest available versions
|
|
8
|
+
* from the npm registry. It processes all dependency types in parallel for optimal performance.
|
|
9
|
+
*
|
|
10
|
+
* @param packageJson - The package.json object to modify (modified in place)
|
|
11
|
+
* @param logger - Optional logger for progress feedback and debugging
|
|
12
|
+
* @throws {Error} If version resolution fails for critical dependencies
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const packageJson = {
|
|
17
|
+
* dependencies: {
|
|
18
|
+
* "@equinor/fusion-framework": "workspace:^",
|
|
19
|
+
* "react": "^18.0.0"
|
|
20
|
+
* }
|
|
21
|
+
* };
|
|
22
|
+
*
|
|
23
|
+
* await resolvePackageJsonWorkspaceDependencies(packageJson, logger);
|
|
24
|
+
* // packageJson.dependencies["@equinor/fusion-framework"] is now "1.0.0"
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolvePackageJsonWorkspaceDependencies(packageJson: PackageJson, logger?: ConsoleLogger): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
2
|
+
import type { ProjectTemplate } from '../../../../bin/helpers/ProjectTemplate.js';
|
|
3
|
+
/**
|
|
4
|
+
* Selects a template from the available templates with intelligent fallback logic.
|
|
5
|
+
*
|
|
6
|
+
* This function handles three scenarios:
|
|
7
|
+
* 1. Pre-selected template: Returns the specified template if valid
|
|
8
|
+
* 2. Single template: Automatically selects if only one template is available
|
|
9
|
+
* 3. Multiple templates: Prompts user to choose from a list
|
|
10
|
+
*
|
|
11
|
+
* @param templates - Array of available project templates
|
|
12
|
+
* @param preSelectedTemplate - Optional pre-selected template name from CLI option
|
|
13
|
+
* @param logger - Optional logger instance for debug output
|
|
14
|
+
* @returns Promise resolving to the selected template
|
|
15
|
+
* @throws {AssertionError} If templates array is empty or pre-selected template is invalid
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const templates = await repo.getAvailableTemplates();
|
|
20
|
+
* const selected = await selectTemplate(templates, 'react-app', logger);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectTemplate(templates: ProjectTemplate[], preSelectedTemplate?: string, logger?: ConsoleLogger): Promise<ProjectTemplate>;
|
|
24
|
+
export default selectTemplate;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
2
|
+
import { ProjectTemplateRepository } from '../../../../bin/helpers/ProjectTemplateRepository.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sets up and initializes a project template repository for template access.
|
|
5
|
+
*
|
|
6
|
+
* This function creates a ProjectTemplateRepository instance and handles
|
|
7
|
+
* the complete initialization process, including optional cleanup of existing
|
|
8
|
+
* repository directories.
|
|
9
|
+
*
|
|
10
|
+
* @param templateRepoName - Name of the template repository (e.g., 'equinor/fusion-app-template')
|
|
11
|
+
* @param clean - Whether to clean the repo directory before cloning (removes existing directory)
|
|
12
|
+
* @param branch - Git branch to checkout (defaults to 'main')
|
|
13
|
+
* @param logger - Logger instance for output and debugging
|
|
14
|
+
* @returns Promise resolving to the initialized repository ready for template access
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const repo = await setupRepository('equinor/fusion-app-template', true, 'main', logger);
|
|
19
|
+
* const templates = await repo.getAvailableTemplates();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function setupRepository(templateRepoName: string, clean: boolean, branch: string, logger: ConsoleLogger): Promise<ProjectTemplateRepository>;
|
|
23
|
+
export default setupRepository;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
2
|
+
/**
|
|
3
|
+
* Prompts the user to start the development server after project creation.
|
|
4
|
+
*
|
|
5
|
+
* Offers the user the option to immediately start the development server
|
|
6
|
+
* using their selected package manager. The server runs in the foreground
|
|
7
|
+
* and can be stopped with Ctrl+C. When persistent mode is enabled, the server
|
|
8
|
+
* will run indefinitely until manually terminated by the user.
|
|
9
|
+
*
|
|
10
|
+
* @param targetDir - Absolute path to the project directory where dev server should start
|
|
11
|
+
* @param packageManager - Package manager command to use (e.g., 'pnpm', 'npm')
|
|
12
|
+
* @param logger - Console logger for displaying prompts and server status
|
|
13
|
+
* @param persistent - If true, runs the dev server indefinitely without timeout (default: false)
|
|
14
|
+
* @returns Promise resolving to true if dev server was started, false if user skipped
|
|
15
|
+
*/
|
|
16
|
+
export declare function startDevServer(targetDir: string, packageManager: string, logger: ConsoleLogger, persistent?: boolean): Promise<boolean>;
|
|
17
|
+
export default startDevServer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PackageJson } from 'type-fest';
|
|
2
|
+
import type { ConsoleLogger } from '@equinor/fusion-framework-cli/bin';
|
|
3
|
+
/**
|
|
4
|
+
* Options for updating package.json
|
|
5
|
+
*/
|
|
6
|
+
interface UpdatePackageJsonOptions {
|
|
7
|
+
/** Whether to resolve workspace dependencies to npm versions */
|
|
8
|
+
resolveWorkspaceDependencies?: boolean;
|
|
9
|
+
/** Properties to update in package.json */
|
|
10
|
+
updates?: Partial<PackageJson>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Updates the package.json file with the provided properties and resolves workspace dependencies.
|
|
14
|
+
*
|
|
15
|
+
* This function reads the package.json file from the target directory, optionally resolves
|
|
16
|
+
* workspace dependencies to their latest npm versions, applies property updates, and writes
|
|
17
|
+
* the updated content back to the file. It preserves the original formatting and structure.
|
|
18
|
+
*
|
|
19
|
+
* @param targetDir - The target directory containing the package.json file
|
|
20
|
+
* @param options - Configuration options for the update operation
|
|
21
|
+
* @param options.resolveWorkspaceDependencies - Whether to resolve workspace dependencies to npm versions
|
|
22
|
+
* @param options.updates - Properties to update in package.json
|
|
23
|
+
* @param logger - Optional logger for progress feedback and debugging
|
|
24
|
+
* @throws {Error} If package.json cannot be read, parsed, or written
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Update just the name
|
|
29
|
+
* await updatePackageJson('/path/to/project', {
|
|
30
|
+
* updates: { name: 'my-new-app' }
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Update multiple properties and resolve workspace deps
|
|
34
|
+
* await updatePackageJson('/path/to/project', {
|
|
35
|
+
* updates: { name: 'my-new-app', version: '1.0.0' },
|
|
36
|
+
* resolveWorkspaceDependencies: true
|
|
37
|
+
* }, logger);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const updatePackageJson: (targetDir: string, options?: UpdatePackageJsonOptions, logger?: ConsoleLogger) => Promise<void>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command for creating new Fusion Framework applications from templates.
|
|
3
|
+
*
|
|
4
|
+
* This command provides a comprehensive interactive workflow for:
|
|
5
|
+
* - Validating input and resolving directory conflicts
|
|
6
|
+
* - Selecting from available project templates (React, vanilla, etc.)
|
|
7
|
+
* - Setting up complete local development environment
|
|
8
|
+
* - Resolving workspace dependencies to npm versions
|
|
9
|
+
* - Installing dependencies and starting development servers
|
|
10
|
+
* - Opening projects in the user's preferred IDE
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```bash
|
|
14
|
+
* # Create a new React app with interactive template selection
|
|
15
|
+
* ffc create app my-new-app
|
|
16
|
+
*
|
|
17
|
+
* # Create with a specific template
|
|
18
|
+
* ffc create app my-app --template react-app
|
|
19
|
+
*
|
|
20
|
+
* # Create in a specific directory with debug logging
|
|
21
|
+
* ffc create app my-app --directory ./projects --debug
|
|
22
|
+
*
|
|
23
|
+
* # Create with clean directory and specific branch
|
|
24
|
+
* ffc create app my-app --clean --branch develop
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const createAppCommand: (name: string) => import("commander").Command;
|
|
28
|
+
export default createAppCommand;
|
|
@@ -1,34 +1,65 @@
|
|
|
1
1
|
import assert, { AssertionError } from 'node:assert';
|
|
2
2
|
/**
|
|
3
3
|
* Re-exports the core Node.js assert function and AssertionError class.
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* This provides consistent assertion handling throughout the codebase
|
|
6
|
+
* with proper TypeScript type narrowing support.
|
|
5
7
|
*/
|
|
6
8
|
export { assert, AssertionError };
|
|
7
9
|
/**
|
|
8
10
|
* Asserts that the provided value is a valid number (not NaN).
|
|
9
|
-
* Throws an AssertionError if the value is not a number.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* This function checks that the value is not NaN, which is useful for
|
|
13
|
+
* validating numeric inputs that might be strings or other types that
|
|
14
|
+
* could convert to NaN.
|
|
15
|
+
*
|
|
16
|
+
* @param value - The value to check for being a valid number
|
|
17
|
+
* @param message - Optional custom error message for assertion failure
|
|
18
|
+
* @throws {AssertionError} If value is NaN
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* assertNumber(42); // ✅ Passes
|
|
23
|
+
* assertNumber('42'); // ✅ Passes (string converts to number)
|
|
24
|
+
* assertNumber(NaN); // ❌ Throws AssertionError
|
|
25
|
+
* assertNumber('invalid'); // ❌ Throws AssertionError
|
|
26
|
+
* ```
|
|
14
27
|
*/
|
|
15
28
|
export declare function assertNumber(value: unknown, message?: string): asserts value;
|
|
16
29
|
/**
|
|
17
30
|
* Asserts that a file exists at the given path.
|
|
18
|
-
* Throws an error if the file does not exist.
|
|
19
31
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
32
|
+
* This function uses the fileExists utility to check for file presence
|
|
33
|
+
* and throws an AssertionError if the file is not found.
|
|
34
|
+
*
|
|
35
|
+
* @param value - The file path to check
|
|
36
|
+
* @param message - Optional custom error message for assertion failure
|
|
37
|
+
* @throws {AssertionError} If the file does not exist
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* assertFileExists('/path/to/file.txt'); // ✅ Passes if file exists
|
|
42
|
+
* assertFileExists('/nonexistent/file.txt'); // ❌ Throws AssertionError
|
|
43
|
+
* ```
|
|
23
44
|
*/
|
|
24
45
|
export declare const assertFileExists: (value: unknown, message?: string) => asserts value;
|
|
25
46
|
/**
|
|
26
47
|
* Asserts that the provided value is an object.
|
|
27
|
-
* Throws an error if the value is not an object.
|
|
28
48
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
49
|
+
* This function checks that the value has type 'object'. Note that
|
|
50
|
+
* typeof null is 'object' in JavaScript, so null values will pass this check.
|
|
51
|
+
*
|
|
52
|
+
* @param value - The value to check for being an object
|
|
53
|
+
* @param message - Optional custom error message or Error instance
|
|
54
|
+
* @throws {AssertionError} If value is not an object
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* assertObject({}); // ✅ Passes
|
|
59
|
+
* assertObject([]); // ✅ Passes
|
|
60
|
+
* assertObject(null); // ✅ Passes (typeof null === 'object')
|
|
61
|
+
* assertObject('string'); // ❌ Throws AssertionError
|
|
62
|
+
* ```
|
|
32
63
|
*/
|
|
33
64
|
export declare function assertObject(value: object, message?: string | Error): asserts value;
|
|
34
65
|
/**
|
|
@@ -56,3 +87,20 @@ export declare function assertObjectEntries<T extends object, P extends Array<ke
|
|
|
56
87
|
assertion?: typeof assertObjectEntryValue;
|
|
57
88
|
preMessage?: string;
|
|
58
89
|
}): asserts value;
|
|
90
|
+
/**
|
|
91
|
+
* Asserts that a directory exists and is a valid git repository.
|
|
92
|
+
*
|
|
93
|
+
* This function checks if the specified directory contains a valid
|
|
94
|
+
* git repository by looking for the .git directory or file.
|
|
95
|
+
*
|
|
96
|
+
* @param dir - Directory path to check for git repository
|
|
97
|
+
* @param message - Optional custom error message for assertion failure
|
|
98
|
+
* @throws {AssertionError} If the directory is not a git repository
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* assertGitRepository('/path/to/git/repo'); // ✅ Passes if .git exists
|
|
103
|
+
* assertGitRepository('/path/to/regular/dir'); // ❌ Throws AssertionError
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function assertGitRepository(dir: string, message?: string): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a directory exists and is a valid git repository.
|
|
3
|
+
*
|
|
4
|
+
* @param dir - Directory path to check.
|
|
5
|
+
* @returns True if the directory exists and is a git repository, false otherwise.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function isGitDir(dir: string): boolean;
|
|
9
|
+
export default isGitDir;
|