@equinor/fusion-framework-cli 11.1.4 → 11.3.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/README.md +18 -0
  3. package/bin/build/cli.mjs +3 -3
  4. package/dist/esm/lib/utils/assert.js +70 -15
  5. package/dist/esm/lib/utils/assert.js.map +1 -1
  6. package/dist/esm/lib/utils/is-git-dir.js +19 -0
  7. package/dist/esm/lib/utils/is-git-dir.js.map +1 -0
  8. package/dist/esm/lib/utils/package-info.js +135 -0
  9. package/dist/esm/lib/utils/package-info.js.map +1 -0
  10. package/dist/esm/lib/utils/path-security.js +56 -0
  11. package/dist/esm/lib/utils/path-security.js.map +1 -0
  12. package/dist/esm/version.js +1 -1
  13. package/dist/types/bin/helpers/ProjectTemplate.d.ts +61 -0
  14. package/dist/types/bin/helpers/ProjectTemplateRepository.d.ts +113 -0
  15. package/dist/types/bin/helpers/install-package-dependencies.d.ts +11 -0
  16. package/dist/types/bin/helpers/project-templates.schema.d.ts +301 -0
  17. package/dist/types/cli/commands/create/_helpers/check-target-directory.d.ts +12 -0
  18. package/dist/types/cli/commands/create/_helpers/cleanup-template-files.d.ts +15 -0
  19. package/dist/types/cli/commands/create/_helpers/install-dependencies.d.ts +14 -0
  20. package/dist/types/cli/commands/create/_helpers/open-in-ide.d.ts +15 -0
  21. package/dist/types/cli/commands/create/_helpers/resolve-workspace-dependencies.d.ts +27 -0
  22. package/dist/types/cli/commands/create/_helpers/select-template.d.ts +24 -0
  23. package/dist/types/cli/commands/create/_helpers/setup-repository.d.ts +23 -0
  24. package/dist/types/cli/commands/create/_helpers/start-dev-server.d.ts +17 -0
  25. package/dist/types/cli/commands/create/_helpers/update-package-json.d.ts +41 -0
  26. package/dist/types/cli/commands/create/app.d.ts +28 -0
  27. package/dist/types/cli/commands/create/index.d.ts +2 -0
  28. package/dist/types/lib/utils/assert.d.ts +61 -13
  29. package/dist/types/lib/utils/is-git-dir.d.ts +9 -0
  30. package/dist/types/lib/utils/package-info.d.ts +106 -0
  31. package/dist/types/lib/utils/path-security.d.ts +36 -0
  32. package/dist/types/version.d.ts +1 -1
  33. package/docs/creating-apps.md +275 -0
  34. package/docs/dev-server.md +367 -0
  35. package/docs/migration-v10-to-v11.md +13 -0
  36. package/package.json +14 -5
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Package information from npm registry
3
+ */
4
+ export interface PackageInfo {
5
+ /** Package name */
6
+ name: string;
7
+ /** Latest version from dist-tags */
8
+ latest: string;
9
+ /** All available versions */
10
+ versions: string[];
11
+ /** Distribution tags */
12
+ 'dist-tags': Record<string, string>;
13
+ /** Package description */
14
+ description?: string;
15
+ /** Package homepage */
16
+ homepage?: string;
17
+ /** Package repository */
18
+ repository?: {
19
+ type: string;
20
+ url: string;
21
+ };
22
+ /** Package author */
23
+ author?: string | {
24
+ name: string;
25
+ email?: string;
26
+ url?: string;
27
+ };
28
+ /** Package license */
29
+ license?: string;
30
+ /** Package keywords */
31
+ keywords?: string[];
32
+ /** Package dependencies */
33
+ dependencies?: Record<string, string>;
34
+ /** Package dev dependencies */
35
+ devDependencies?: Record<string, string>;
36
+ /** Package peer dependencies */
37
+ peerDependencies?: Record<string, string>;
38
+ }
39
+ /**
40
+ * Fetches complete package information from npm registry.
41
+ *
42
+ * This function retrieves all available metadata for a package including
43
+ * version information, dependencies, and package details. It performs
44
+ * validation to ensure the package exists and has a valid latest version.
45
+ *
46
+ * @param packageName - The name of the package to fetch (e.g., "@equinor/fusion-framework")
47
+ * @param registry - The npm registry URL (defaults to https://registry.npmjs.org)
48
+ * @returns Promise resolving to complete package information
49
+ * @throws {Error} If the package cannot be found, fetched, or has invalid data
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Fetch package info for a scoped package
54
+ * const info = await fetchPackageInfo('@equinor/fusion-framework');
55
+ * console.log(`Latest version: ${info.latest}`);
56
+ *
57
+ * // Fetch from custom registry
58
+ * const info = await fetchPackageInfo('my-package', 'https://my-registry.com');
59
+ * ```
60
+ */
61
+ export declare function fetchPackageInfo(packageName: string, registry?: string): Promise<PackageInfo>;
62
+ /**
63
+ * Fetches only the latest version of a package from npm registry.
64
+ *
65
+ * This is a convenience function that retrieves only the latest version
66
+ * string without the overhead of fetching complete package metadata.
67
+ * Useful for simple version checks and dependency resolution.
68
+ *
69
+ * @param packageName - The name of the package to fetch (e.g., "@equinor/fusion-framework")
70
+ * @param registry - The npm registry URL (defaults to https://registry.npmjs.org)
71
+ * @returns Promise resolving to the latest version string (e.g., "1.0.0")
72
+ * @throws {Error} If the package cannot be found or fetched
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // Get latest version for dependency resolution
77
+ * const version = await fetchLatestVersion('@equinor/fusion-framework');
78
+ * console.log(`Latest version: ${version}`);
79
+ * ```
80
+ */
81
+ export declare function fetchLatestVersion(packageName: string, registry?: string): Promise<string>;
82
+ /**
83
+ * Fetches multiple packages' information in parallel for better performance.
84
+ *
85
+ * This function efficiently retrieves package information for multiple packages
86
+ * simultaneously, using Promise.allSettled to handle individual failures gracefully.
87
+ * Failed packages are silently excluded from the results.
88
+ *
89
+ * @param packageNames - Array of package names to fetch (e.g., ["@equinor/fusion-framework", "react"])
90
+ * @param registry - The npm registry URL (defaults to https://registry.npmjs.org)
91
+ * @returns Promise resolving to a map of package names to their information
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * // Fetch multiple packages for dependency analysis
96
+ * const packages = await fetchMultiplePackageInfo([
97
+ * '@equinor/fusion-framework',
98
+ * 'react',
99
+ * 'typescript'
100
+ * ]);
101
+ *
102
+ * // Check which packages were successfully fetched
103
+ * console.log(`Fetched ${Object.keys(packages).length} packages`);
104
+ * ```
105
+ */
106
+ export declare function fetchMultiplePackageInfo(packageNames: string[], registry?: string): Promise<Record<string, PackageInfo>>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Validates that a target path is safe for file system operations.
3
+ *
4
+ * Uses the well-established `is-path-inside` library to prevent path traversal attacks
5
+ * by ensuring the target path is within expected bounds.
6
+ *
7
+ * @param targetPath - The path to validate
8
+ * @param baseDir - The base directory that the target path should be within (optional)
9
+ * @returns The resolved, validated path
10
+ * @throws {Error} If the path is invalid or potentially dangerous
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Validate a user-provided path within a specific directory
15
+ * const safePath = validateSafePath(userInput, '/path/to/base/directory');
16
+ *
17
+ * // Validate a path without base directory constraint
18
+ * const safePath = validateSafePath('/tmp/safe-directory');
19
+ * ```
20
+ */
21
+ export declare function validateSafePath(targetPath: string, baseDir?: string): string;
22
+ /**
23
+ * Safely removes a directory with path traversal protection.
24
+ *
25
+ * This function validates the target path before performing the removal
26
+ * operation to prevent accidental deletion of unintended directories.
27
+ *
28
+ * @param targetPath - The path to remove
29
+ * @param options - rmSync options
30
+ * @param baseDir - Optional base directory constraint
31
+ * @throws {Error} If path validation fails or removal operation fails
32
+ */
33
+ export declare function safeRmSync(targetPath: string, options: {
34
+ recursive: boolean;
35
+ force: boolean;
36
+ }, baseDir?: string): void;
@@ -1 +1 @@
1
- export declare const version = "11.1.4";
1
+ export declare const version = "11.3.0";
@@ -0,0 +1,275 @@
1
+ # 🚀 Create Amazing Apps in Seconds!
2
+
3
+ Ready to build something awesome? The Fusion Framework CLI makes it ridiculously easy to create production-ready applications with just one command!
4
+
5
+ ## ⚡ Get Started in 30 Seconds
6
+
7
+ ```bash
8
+ # Create your app (we'll guide you through everything!)
9
+ ffc create app my-awesome-app
10
+
11
+ # Or pick a template right away
12
+ ffc create app my-awesome-app --template basic
13
+ ```
14
+ That's it! We'll handle the rest and have you coding in no time. 🎉
15
+
16
+
17
+ > [!NOTE]
18
+ > You can also get started by using the [GitHub template](https://github.com/new?owner=equinor&template_name=fusion-app-template&template_owner=equinor) or see the [source code](https://github.com/equinor/fusion-app-template) directly.
19
+
20
+
21
+ ## 🎉 What You Get
22
+
23
+ Your new app will have everything you need to build the next big thing:
24
+
25
+ - **👍🏻 One command** - `fusion create app` and you're off!
26
+ - **🎯 Guided setup** - We walk you through every step
27
+ - **🚀 Production-ready** - Templates that actually work in the real world
28
+ - **🧠 Smart features** - Context management, navigation, and more built-in
29
+ - **💪 TypeScript power** - Full type safety from day one
30
+ - **🐛 Debug when needed** - Tools to help when things get tricky
31
+
32
+ **What are you waiting for? Let's create something awesome! 🚀**
33
+
34
+ ## Command Reference
35
+
36
+ ### Basic Usage
37
+
38
+ ```bash
39
+ ffc create app <name> [options]
40
+ # or
41
+ fusion-framework-cli create app <name> [options]
42
+ ```
43
+
44
+ **Arguments:**
45
+ - `<name>` - Name of the application to create (required)
46
+
47
+ **Options:**
48
+ - `-t, --template <type>` - Template type to use (will prompt if not specified)
49
+ - `-d, --directory <path>` - Directory to create the app in (default: ".")
50
+ - `--branch <branch>` - Git branch to checkout (default: "main")
51
+ - `--clean` - Clean the repository directory before cloning
52
+ - `--debug` - Enable debug mode for verbose logging
53
+ - `-h, --help` - Display help information
54
+
55
+ ## Examples
56
+
57
+ ### Create a Basic App
58
+
59
+ ```bash
60
+ # Create an app in the current directory
61
+ ffc create app my-awesome-app
62
+
63
+ # Create an app in a specific directory
64
+ ffc create app my-awesome-app --directory ./projects
65
+ ```
66
+
67
+ ### Create with Specific Template
68
+
69
+ ```bash
70
+ # Create a basic template app
71
+ ffc create app my-basic-app --template basic
72
+
73
+ # Create a bare template app
74
+ ffc create app my-bare-app --template bare
75
+ ```
76
+
77
+ ### Advanced Usage
78
+
79
+ ```bash
80
+ # Create with debug logging and clean setup
81
+ ffc create app my-app --debug --clean
82
+
83
+ # Create in a specific directory with custom branch
84
+ ffc create app my-app --directory ./apps --branch develop
85
+
86
+ # Create with template selection and debug
87
+ ffc create app my-app --template basic --debug
88
+ ```
89
+
90
+ ## What Happens When You Create an App
91
+
92
+ We'll walk you through everything step by step:
93
+
94
+ 1. **✅ Check your app name** - Make sure everything looks good
95
+ 2. **📁 Find the perfect spot** - We'll create your app in the right place
96
+ 3. **🤔 Handle any conflicts** - If something's already there, we'll ask what to do
97
+ 4. **📥 Grab the latest templates** - Download the best templates from our repo
98
+ 5. **🎨 Pick your style** - Choose between basic (full-featured) or bare (minimal)
99
+ 6. **💾 Copy everything over** - Set up your project structure
100
+ 7. **🧹 Clean up** - Remove temporary files (your choice)
101
+ 8. **💻 Open in your IDE** - We'll launch your favorite editor
102
+ 9. **📦 Install dependencies** - Get all the packages you need
103
+ 10. **🌈 Start coding!** - Fire up the dev server and you're ready to go
104
+
105
+ No stress, no confusion - just smooth sailing!
106
+
107
+ ## Choose Your Template
108
+
109
+ Pick the perfect starting point for your project:
110
+
111
+ ### Basic Template
112
+ **Perfect for most projects!**
113
+ - Full React app with everything you need
114
+ - Context management & navigation built-in
115
+ - EDS components ready to go
116
+ - TypeScript from day one
117
+
118
+ ### Bare Template
119
+ **Minimal and clean!**
120
+ - Just the essentials
121
+ - Perfect for learning or custom builds
122
+ - Lightweight and fast
123
+
124
+ Both templates are production-ready and come with all the Fusion Framework magic! ✨
125
+
126
+
127
+
128
+ ## Troubleshooting
129
+
130
+ ### Common Issues
131
+
132
+ **Directory Already Exists**
133
+ ```bash
134
+ # Use --clean to remove existing directory
135
+ ffc create app my-app --clean
136
+
137
+ # Or specify a different directory
138
+ ffc create app my-app --directory ./new-location
139
+ ```
140
+
141
+ **Template Not Found**
142
+ ```bash
143
+ # List available templates
144
+ ffc create app my-app --help
145
+
146
+ # Use interactive selection
147
+ ffc create app my-app
148
+ ```
149
+
150
+ **Permission Issues**
151
+ ```bash
152
+ # Ensure you have write permissions to the target directory
153
+ chmod 755 ./target-directory
154
+ ```
155
+
156
+ ### Debug Mode
157
+
158
+ Enable debug mode for detailed logging:
159
+
160
+ ```bash
161
+ ffc create app my-app --debug
162
+ ```
163
+
164
+ This will show:
165
+ - Target directory resolution details
166
+ - Repository cloning and setup operations
167
+ - Template selection and copying process
168
+ - Dependency installation progress
169
+ - Development server startup details
170
+
171
+ ## Best Practices
172
+
173
+ ### Naming Conventions
174
+
175
+ - Use kebab-case for app names: `my-awesome-app`
176
+ - Avoid spaces and special characters
177
+ - Keep names descriptive but concise
178
+
179
+ ### Directory Organization
180
+
181
+ ```bash
182
+ # Organize apps in a dedicated directory
183
+ mkdir ~/fusion-apps
184
+ cd ~/fusion-apps
185
+ ffc create app my-app
186
+ ```
187
+
188
+ ### Template Selection
189
+
190
+ - Choose templates based on your specific needs
191
+ - Start with basic templates and add features incrementally
192
+ - Use `--template` flag for automated workflows
193
+
194
+ ### Version Control
195
+
196
+ ```bash
197
+ # Initialize git repository after creation
198
+ cd my-new-app
199
+ git init
200
+ git add .
201
+ git commit -m "Initial commit"
202
+ ```
203
+
204
+ ## Integration with Development Workflow
205
+
206
+ ### IDE Integration
207
+
208
+ The CLI automatically detects and opens your project in supported IDEs:
209
+
210
+ - **Automatic Detection** - Detects common IDEs and opens the project automatically
211
+ - **Manual Opening** - Provides instructions for IDEs that aren't automatically detected
212
+ - **Step 9** - IDE integration happens after template copying and before dependency installation
213
+
214
+ ### Development Server
215
+
216
+ After creation, you can start the development server. See the [Development Server guide](./application.md#start-the-development-server) for detailed information.
217
+
218
+ ### Building for Production
219
+
220
+ See the [Build guide](./application.md#build) for detailed information about building your application.
221
+
222
+ ## Advanced Configuration
223
+
224
+ ### App Configuration
225
+
226
+ See the [Configuration guide](./application.md#configuration) for detailed information about configuring your application.
227
+
228
+ ### Custom Templates
229
+
230
+ You can create custom templates by:
231
+
232
+ 1. Forking the [fusion-app-template](https://github.com/equinor/fusion-app-template) repository
233
+ 2. Modifying the template structure
234
+ 3. Using your custom template with the CLI
235
+
236
+ ### Environment-Specific Configuration
237
+
238
+ ```bash
239
+ # Create app with specific environment
240
+ ffc create app my-app --template basic --directory ./apps/prod
241
+ ```
242
+
243
+ ## Getting Help
244
+
245
+ ### Command Help
246
+
247
+ ```bash
248
+ # General help
249
+ ffc --help
250
+ # or
251
+ fusion-framework-cli --help
252
+
253
+ # Create command help
254
+ ffc create --help
255
+ # or
256
+ fusion-framework-cli create --help
257
+
258
+ # Specific create app help
259
+ ffc create app --help
260
+ # or
261
+ fusion-framework-cli create app --help
262
+ ```
263
+
264
+ ### Additional Resources
265
+
266
+ - [Fusion Framework Documentation](https://github.com/equinor/fusion-framework)
267
+ - [Template Repository](https://github.com/equinor/fusion-app-template)
268
+ - [GitHub Template](https://github.com/new?owner=equinor&template_name=fusion-app-template&template_owner=equinor) - Create from template directly
269
+ - [CLI Issues](https://github.com/equinor/fusion-framework/issues)
270
+
271
+ ## Ready to Build Something Amazing?
272
+
273
+ Your new app will have context management, navigation, API integration, and EDS components - everything you need to build the next big thing!
274
+
275
+ **What are you waiting for? Let's create something awesome! 🚀**