msfs-layout-generator 0.3.2 → 0.3.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/README.MD CHANGED
@@ -55,13 +55,77 @@ Use your manager (npm, yarn, bun etc.) to install the package:
55
55
  ```bash
56
56
  npm install msfs-layout-generator
57
57
  ```
58
- Import the generator in your TypeScript / JavaScript projects:
58
+
59
+ ### Simple Usage
60
+
59
61
  ```ts
60
62
  import { generateLayout } from 'msfs-layout-generator';
61
63
 
62
- // Process a single package
64
+ // Process a single package (throws on errors, uses default options)
63
65
  await generateLayout("F:\\fs20\\Community\\my-package");
64
66
  ```
67
+
68
+ ### Advanced Usage with Options
69
+
70
+ ```ts
71
+ import { processLayout } from 'msfs-layout-generator';
72
+ import type { ProcessOptions, ProcessResult } from 'msfs-layout-generator';
73
+
74
+ // Overwrite existing layout.json silently
75
+ await processLayout("./my-package", { force: true, quiet: true });
76
+
77
+ // Get a result object instead of throwing on errors
78
+ const result = await processLayout("./my-package", {
79
+ returnResult: true,
80
+ force: true
81
+ });
82
+
83
+ if (result.success) {
84
+ console.log(`Processed ${result.fileCount} files (${result.totalSize} bytes)`);
85
+ } else {
86
+ console.error(result.message);
87
+ }
88
+
89
+ // Generate layout without requiring or updating manifest.json
90
+ await processLayout("./my-package", {
91
+ force: true,
92
+ checkManifest: false,
93
+ skipManifestUpdate: true
94
+ });
95
+ ```
96
+
97
+ ### Exports
98
+
99
+ | Export | Type | Description |
100
+ |---|---|---|
101
+ | `generateLayout(dir)` | `(dir: string) => Promise<void>` | Simple wrapper — processes a package directory with default options. Throws on errors. |
102
+ | `processLayout(dir, options?)` | `(dir: string, options?: ProcessOptions) => Promise<void \| ProcessResult>` | Full-featured function with configurable options. |
103
+
104
+ ### `ProcessOptions`
105
+
106
+ | Option | Type | Default | Description |
107
+ |---|---|---|---|
108
+ | `force` | `boolean` | `false` | Overwrite existing `layout.json` |
109
+ | `quiet` | `boolean` | `false` | Suppress all console output |
110
+ | `debug` | `boolean` | `false` | Enable verbose debug logging |
111
+ | `checkManifest` | `boolean` | `true` | Require `manifest.json` to exist in the package directory |
112
+ | `skipManifestUpdate` | `boolean` | `false` | Skip updating `total_package_size` in `manifest.json` |
113
+ | `returnResult` | `boolean` | `false` | Return a `ProcessResult` object instead of `void`. When `true`, errors are returned in the result instead of thrown. |
114
+
115
+ ### `ProcessResult`
116
+
117
+ Returned when `returnResult` is `true`:
118
+
119
+ | Field | Type | Description |
120
+ |---|---|---|
121
+ | `success` | `boolean` | Whether the operation completed successfully |
122
+ | `fileCount` | `number` | Number of files included in `layout.json` |
123
+ | `totalSize` | `number` | Total package size in bytes |
124
+ | `layoutPath` | `string` | Absolute path to the generated `layout.json` |
125
+ | `manifestPath` | `string` | Absolute path to `manifest.json` |
126
+ | `skippedFiles` | `number` | Number of files that were excluded |
127
+ | `message` | `string?` | Error message (when `success` is `false`) |
128
+
65
129
  ---
66
130
 
67
131
  **Happy Flying! ✈️**
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { processLayout } from "./utils/processLayout";
1
2
  /**
2
- * Process an MSFS package directory to generate/update layout.json
3
+ * Process an MSFS package directory to generate/update layout.json (simple API).
3
4
  *
4
- * This function scans all files in the package directory, creates a layout.json
5
- * with file metadata, and updates the total_package_size in manifest.json.
5
+ * This is a convenience wrapper around {@link processLayout} that uses default
6
+ * options and throws on errors. For more control, use {@link processLayout} directly.
6
7
  *
7
8
  * @param packageDir - Path to the MSFS package directory (must contain manifest.json)
8
9
  * @returns Promise that resolves when layout.json has been generated
@@ -12,7 +13,7 @@
12
13
  *
13
14
  * @example
14
15
  * // Basic usage
15
- * await doProcessLayoutFile("F:\\fs20\\Community\\my-package");
16
+ * await generateLayout("F:\\fs20\\Community\\my-package");
16
17
  *
17
18
  * @example
18
19
  * // With error handling
@@ -24,4 +25,5 @@
24
25
  * }
25
26
  */
26
27
  export declare const generateLayout: (layoutPath: string) => Promise<void>;
28
+ export { processLayout };
27
29
  export type { Content, Layout, Manifest, ProcessOptions, ProcessResult } from "./types";
package/dist/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateLayout = void 0;
3
+ exports.processLayout = exports.generateLayout = void 0;
4
4
  const processLayout_1 = require("./utils/processLayout");
5
+ Object.defineProperty(exports, "processLayout", { enumerable: true, get: function () { return processLayout_1.processLayout; } });
5
6
  /**
6
- * Process an MSFS package directory to generate/update layout.json
7
+ * Process an MSFS package directory to generate/update layout.json (simple API).
7
8
  *
8
- * This function scans all files in the package directory, creates a layout.json
9
- * with file metadata, and updates the total_package_size in manifest.json.
9
+ * This is a convenience wrapper around {@link processLayout} that uses default
10
+ * options and throws on errors. For more control, use {@link processLayout} directly.
10
11
  *
11
12
  * @param packageDir - Path to the MSFS package directory (must contain manifest.json)
12
13
  * @returns Promise that resolves when layout.json has been generated
@@ -16,7 +17,7 @@ const processLayout_1 = require("./utils/processLayout");
16
17
  *
17
18
  * @example
18
19
  * // Basic usage
19
- * await doProcessLayoutFile("F:\\fs20\\Community\\my-package");
20
+ * await generateLayout("F:\\fs20\\Community\\my-package");
20
21
  *
21
22
  * @example
22
23
  * // With error handling
@@ -1,11 +1,45 @@
1
1
  import { ProcessOptions, ProcessResult } from "../types";
2
2
  /**
3
- * Unified function to process layout files for MSFS packages
4
- * Can be used both programmatically and via CLI
3
+ * Process layout files for MSFS packages with full control over behavior.
5
4
  *
6
- * @param packageDir - Path to MSFS package directory
7
- * @param options - Processing options
8
- * @returns Promise<void> if returnResult=false, Promise<ProcessResult> if returnResult=true
5
+ * Scans all files in the package directory, generates a `layout.json` with
6
+ * file metadata (path, size, date), and optionally updates `total_package_size`
7
+ * in `manifest.json`.
8
+ *
9
+ * @param packageDir - Absolute or relative path to the MSFS package directory
10
+ * @param options - Processing options to control behavior
11
+ * @param options.force - Overwrite existing layout.json (default: `false`)
12
+ * @param options.quiet - Suppress all console output (default: `false`)
13
+ * @param options.debug - Enable verbose debug logging (default: `false`)
14
+ * @param options.checkManifest - Require manifest.json to exist (default: `true`)
15
+ * @param options.skipManifestUpdate - Skip updating total_package_size in manifest.json (default: `false`)
16
+ * @param options.returnResult - Return a {@link ProcessResult} object instead of throwing on errors (default: `false`)
17
+ * @returns `Promise<void>` when `returnResult` is `false`; `Promise<ProcessResult>` when `returnResult` is `true`
18
+ *
19
+ * @throws {Error} If directory doesn't exist (when `returnResult` is `false`)
20
+ * @throws {Error} If manifest.json is missing and `checkManifest` is `true` (when `returnResult` is `false`)
21
+ * @throws {Error} If no valid files are found (when `returnResult` is `false`)
22
+ *
23
+ * @example
24
+ * // Overwrite existing layout.json silently
25
+ * await processLayout("./my-package", { force: true, quiet: true });
26
+ *
27
+ * @example
28
+ * // Get a result object instead of throwing
29
+ * const result = await processLayout("./my-package", { returnResult: true, force: true });
30
+ * if (result.success) {
31
+ * console.log(`Processed ${result.fileCount} files (${result.totalSize} bytes)`);
32
+ * } else {
33
+ * console.error(result.message);
34
+ * }
35
+ *
36
+ * @example
37
+ * // Generate layout without requiring or updating manifest.json
38
+ * await processLayout("./my-package", {
39
+ * force: true,
40
+ * checkManifest: false,
41
+ * skipManifestUpdate: true
42
+ * });
9
43
  */
10
44
  export declare const processLayout: (packageDir: string, options?: ProcessOptions) => Promise<void | ProcessResult>;
11
45
  export declare const doProcessLayoutFile: (layoutPath: string) => Promise<void>;
@@ -41,12 +41,46 @@ const promises_1 = require("fs/promises");
41
41
  const getWindowsFileTime_1 = require("./getWindowsFileTime");
42
42
  const doUpdateManifest_1 = require("./doUpdateManifest");
43
43
  /**
44
- * Unified function to process layout files for MSFS packages
45
- * Can be used both programmatically and via CLI
44
+ * Process layout files for MSFS packages with full control over behavior.
46
45
  *
47
- * @param packageDir - Path to MSFS package directory
48
- * @param options - Processing options
49
- * @returns Promise<void> if returnResult=false, Promise<ProcessResult> if returnResult=true
46
+ * Scans all files in the package directory, generates a `layout.json` with
47
+ * file metadata (path, size, date), and optionally updates `total_package_size`
48
+ * in `manifest.json`.
49
+ *
50
+ * @param packageDir - Absolute or relative path to the MSFS package directory
51
+ * @param options - Processing options to control behavior
52
+ * @param options.force - Overwrite existing layout.json (default: `false`)
53
+ * @param options.quiet - Suppress all console output (default: `false`)
54
+ * @param options.debug - Enable verbose debug logging (default: `false`)
55
+ * @param options.checkManifest - Require manifest.json to exist (default: `true`)
56
+ * @param options.skipManifestUpdate - Skip updating total_package_size in manifest.json (default: `false`)
57
+ * @param options.returnResult - Return a {@link ProcessResult} object instead of throwing on errors (default: `false`)
58
+ * @returns `Promise<void>` when `returnResult` is `false`; `Promise<ProcessResult>` when `returnResult` is `true`
59
+ *
60
+ * @throws {Error} If directory doesn't exist (when `returnResult` is `false`)
61
+ * @throws {Error} If manifest.json is missing and `checkManifest` is `true` (when `returnResult` is `false`)
62
+ * @throws {Error} If no valid files are found (when `returnResult` is `false`)
63
+ *
64
+ * @example
65
+ * // Overwrite existing layout.json silently
66
+ * await processLayout("./my-package", { force: true, quiet: true });
67
+ *
68
+ * @example
69
+ * // Get a result object instead of throwing
70
+ * const result = await processLayout("./my-package", { returnResult: true, force: true });
71
+ * if (result.success) {
72
+ * console.log(`Processed ${result.fileCount} files (${result.totalSize} bytes)`);
73
+ * } else {
74
+ * console.error(result.message);
75
+ * }
76
+ *
77
+ * @example
78
+ * // Generate layout without requiring or updating manifest.json
79
+ * await processLayout("./my-package", {
80
+ * force: true,
81
+ * checkManifest: false,
82
+ * skipManifestUpdate: true
83
+ * });
50
84
  */
51
85
  const processLayout = async (packageDir, options = {}) => {
52
86
  const { force = false, quiet = false, debug = false, checkManifest = true, skipManifestUpdate = false, returnResult = false // Default: behave like old doProcessLayoutFile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msfs-layout-generator",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Generate layout.json for MSFS community packages",
5
5
  "repository": {
6
6
  "type": "git",