@involvex/msix-packager-cli 1.4.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/README.md ADDED
@@ -0,0 +1,360 @@
1
+ # Node- 📦 Generate MSIX packages from Node.js applications
2
+
3
+ - ⚡ Single Executable Application (SEA) bundling using @vercel/ncc and postject
4
+ - 🔐 Code signing support with certificate store integration
5
+ - ⚙️ Configurable manifest generation
6
+ - 🖥️ CLI and programmatic API
7
+ - 📁 Asset bundling for static files, views, and configurations
8
+ - 🛡️ Automatic fallback to PKG-based executables if SEA failsackager
9
+
10
+ A utility to create and sign MSIX packages from Node.js applications for Windows deployment.
11
+
12
+ ## Features
13
+
14
+ - 📦 Generate MSIX packages from Node.js applications
15
+ - � Single Executable Application (SEA) bundling using Node.js native technology
16
+ - �🔐 Code signing support with certificate store integration
17
+ - ⚙️ Configurable manifest generation
18
+ - 🖥️ CLI and programmatic API
19
+ - 📁 Asset bundling for static files, views, and configurations
20
+ - � Automatic fallback to traditional Node.js launchers if SEA fails
21
+
22
+ ## Single Executable Application (SEA) Support
23
+
24
+ This packager uses Node.js's official **Single Executable Application** technology with modern bundling:
25
+
26
+ ### SEA Implementation:
27
+
28
+ - **@vercel/ncc**: Bundles your application and all dependencies into a single JavaScript file
29
+ - **Node.js SEA Config**: Uses `--experimental-sea-config` to create preparation blobs
30
+ - **postject**: Injects the application blob into a Node.js binary using official SEA markers
31
+ - **Smart Entry Point**: Detects SEA vs development mode and handles paths correctly
32
+
33
+ ### SEA Benefits:
34
+
35
+ - **Self-contained**: No need for separate Node.js runtime installation
36
+ - **Optimized**: NCC creates highly optimized bundles with tree-shaking
37
+ - **Fast startup**: Embedded code loads faster than file-based modules
38
+ - **Security**: Bundled code is embedded within the executable binary
39
+ - **Portability**: Single .exe file contains everything needed
40
+ - **Official**: Uses Node.js's official SEA implementation (not third-party solutions)
41
+
42
+ ### TypeScript Support:
43
+
44
+ - **Built-in TypeScript**: @vercel/ncc automatically handles TypeScript transpilation
45
+ - **No Build Step**: TypeScript files are processed directly by NCC
46
+ - **Type Safety**: Full TypeScript development experience with production SEA builds
47
+ - **tsconfig.json**: Automatically uses your existing TypeScript configuration
48
+ - **Auto-detection**: Automatically detects .ts files and TypeScript projects
49
+ - **All Features**: Supports interfaces, generics, decorators, and advanced TypeScript features
50
+
51
+ ### Fallback Strategy:
52
+
53
+ If SEA creation fails, the packager automatically falls back to PKG-based executable creation, ensuring your application can still be packaged.
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ npm install -g @involvex/msix-packager-cli
59
+ ```
60
+
61
+ ## Quick Start
62
+
63
+ ### CLI Usage
64
+
65
+ ```bash
66
+ node-msix package --input ./my-app --name "My App" --publisher "CN=My Publisher" --output ./dist
67
+ ```
68
+
69
+ ### Programmatic Usage
70
+
71
+ ```javascript
72
+ const { createMsixPackage } = require("node-msix-packager");
73
+
74
+ await createMsixPackage({
75
+ inputPath: "./my-app",
76
+ outputPath: "./dist",
77
+ appName: "My App",
78
+ packageName: "MyApp",
79
+ publisher: "CN=My Publisher",
80
+ version: "1.0.0.0",
81
+ });
82
+ ```
83
+
84
+ ## Configuration Options
85
+
86
+ | Parameter | Type | Required | Description |
87
+ | ----------------------- | ------ | -------- | ------------------------------------------------- |
88
+ | `inputPath` | string | Yes | Path to your Node.js application |
89
+ | `outputPath` | string | No | Output directory for MSIX package |
90
+ | `appName` | string | Yes | Application name |
91
+ | `publisher` | string | Yes | Publisher certificate name (e.g., "CN=MyCompany") |
92
+ | `version` | string | No | App version (4-part: x.x.x.x) |
93
+ | `packageName` | string | No | Unique package identifier |
94
+ | `architecture` | string | No | Target architecture (x64, x86) |
95
+ | `certificateThumbprint` | string | No | Certificate thumbprint for signing |
96
+
97
+ ## Code Signing
98
+
99
+ To sign your MSIX package, provide a certificate:
100
+
101
+ ```javascript
102
+ await createMsixPackage({
103
+ // ... other options
104
+ certificateThumbprint: "YOUR_CERT_THUMBPRINT",
105
+ });
106
+ ```
107
+
108
+ ## Requirements
109
+
110
+ - Windows 10/11
111
+ - Node.js 14+
112
+ - Windows SDK (for makeappx.exe)
113
+
114
+ ## License
115
+
116
+ MIT
117
+
118
+ ```bash
119
+ # Package a Node.js application
120
+ node-msix package --input ./my-node-app --output ./dist --name "My App" --publisher "CN=MyCompany"
121
+
122
+ # Using makeappx-only mode (requires Windows SDK)
123
+ node-msix package --input ./my-node-app --name "My App" --publisher "CN=MyCompany" --makeappx-only
124
+
125
+ # Using configuration file
126
+ node-msix package --config ./msix-config.json
127
+ ```
128
+
129
+ ### CLI Usage (Local Installation)
130
+
131
+ ```bash
132
+ # Package a Node.js application
133
+ npx node-msix package --input ./my-node-app --output ./dist --name "My App" --publisher "CN=MyCompany"
134
+ ```
135
+
136
+ ### Programmatic Usage
137
+
138
+ ```javascript
139
+ const {
140
+ createMsixPackage,
141
+ createMsixPackageWithMakeAppxOnly,
142
+ } = require("node-msix-packager");
143
+
144
+ const config = {
145
+ inputPath: "./my-node-app",
146
+ outputPath: "./dist",
147
+ appName: "My Application",
148
+ publisher: "CN=MyCompany",
149
+ version: "1.0.0.0",
150
+ description: "My awesome Node.js application",
151
+ executable: "node.exe",
152
+ arguments: "app.js",
153
+ architecture: "x64",
154
+ displayName: "My Application",
155
+ packageName: "MyCompany.MyApplication",
156
+ capabilities: ["internetClient", "privateNetworkClientServer"],
157
+ };
158
+
159
+ // Standard packaging (with fallbacks)
160
+ createMsixPackage(config)
161
+ .then(() => console.log("MSIX package created successfully!"))
162
+ .catch((error) => console.error("Error creating package:", error));
163
+
164
+ // MakeAppx-only packaging (requires Windows SDK)
165
+ createMsixPackageWithMakeAppxOnly(config)
166
+ .then(() => console.log("MSIX package created with makeappx!"))
167
+ .catch((error) => console.error("Error creating package:", error));
168
+ ```
169
+
170
+ ## Configuration Options
171
+
172
+ ### Using Configuration File
173
+
174
+ Create a `msix-config.json` file in your project root:
175
+
176
+ ```json
177
+ {
178
+ "appName": "My Node Application",
179
+ "publisher": "CN=MyCompany",
180
+ "version": "1.0.0.0",
181
+ "description": "My awesome Node.js application",
182
+ "displayName": "My App",
183
+ "packageName": "MyCompany.MyApp",
184
+ "architecture": "x64",
185
+ "capabilities": ["internetClient", "privateNetworkClientServer"],
186
+ "executable": "node.exe",
187
+ "arguments": "app.js",
188
+ "icon": "./assets/icon.png"
189
+ }
190
+ ```
191
+
192
+ ### Configuration Parameters
193
+
194
+ | Parameter | Type | Required | Default | Description |
195
+ | ---------------- | ------- | -------- | -------------------- | ------------------------------------------------- |
196
+ | `inputPath` | string | Yes | - | Path to your Node.js application |
197
+ | `outputPath` | string | No | `./dist` | Output directory for MSIX package |
198
+ | `appName` | string | Yes | - | Application name |
199
+ | `publisher` | string | Yes | - | Publisher certificate name (e.g., "CN=MyCompany") |
200
+ | `version` | string | No | `1.0.0.0` | App version (must be 4-part: x.x.x.x) |
201
+ | `description` | string | No | - | Application description |
202
+ | `displayName` | string | No | `appName` | Display name shown to users |
203
+ | `packageName` | string | No | Generated | Unique package identifier |
204
+ | `architecture` | string | No | `x64` | Target architecture (`x64`, `x86`) |
205
+ | `executable` | string | No | `node.exe` | Main executable file |
206
+ | `arguments` | string | No | `app.js` | Command line arguments |
207
+ | `icon` | string | No | - | Path to application icon |
208
+ | `capabilities` | array | No | `["internetClient"]` | App capabilities |
209
+ | `skipBuild` | boolean | No | `false` | Skip running bun build script |
210
+ | `installDevDeps` | boolean | No | `true` | Install dev dependencies for build |
211
+ | `makeappxOnly` | boolean | No | `false` | Use only makeappx.exe (no fallbacks) |
212
+
213
+ ### Available Capabilities
214
+
215
+ - `internetClient` - Access to internet and public networks
216
+ - `internetClientServer` - Inbound/outbound access to internet
217
+ - `privateNetworkClientServer` - Access to home/work networks
218
+ - `documentsLibrary` - Access to Documents library
219
+ - `picturesLibrary` - Access to Pictures library
220
+ - `videosLibrary` - Access to Videos library
221
+ - `musicLibrary` - Access to Music library
222
+ "version": "1.0.0.0",
223
+ "description": "My Node.js application packaged as MSIX",
224
+ "displayName": "My App",
225
+ "packageName": "MyCompany.MyApp",
226
+ "architecture": "x64",
227
+ "capabilities": ["internetClient"],
228
+ "executable": "node.exe",
229
+ "arguments": "app.js",
230
+ "icon": "./assets/icon.png"
231
+ }
232
+
233
+ ```
234
+
235
+ ## Requirements
236
+
237
+ - Windows 10/11
238
+ - Windows SDK (for makeappx.exe)
239
+ - Node.js runtime
240
+ - PowerShell 5.0+
241
+
242
+ **Note**: The packager automatically uses Node.js Single Executable Application (SEA) technology to bundle your Node.js application into a single executable, providing optimal performance, security, and compatibility.
243
+
244
+ ## Directory Structure
245
+
246
+ ```
247
+
248
+ your-node-app/
249
+ ├── package.json
250
+ ├── app.js (or main entry point)
251
+ ├── node_modules/
252
+ ├── assets/
253
+ │ └── icon.png
254
+ └── msix-config.json
255
+
256
+ ````
257
+
258
+ ## Examples
259
+
260
+ See the `examples/` directory for sample applications and configurations:
261
+
262
+ - **`examples/sample-app/`** - Basic JavaScript Node.js application with Express server
263
+ - **`examples/typescript-app/`** - Full TypeScript application demonstrating SEA with NCC bundling
264
+
265
+ ### TypeScript Example
266
+
267
+ For TypeScript projects, NCC automatically handles transpilation:
268
+
269
+ ```typescript
270
+ // src/index.ts
271
+ import express, { Application } from 'express';
272
+
273
+ class TypeScriptSEAApp {
274
+ private app: Application;
275
+
276
+ constructor() {
277
+ this.app = express();
278
+ this.setupRoutes();
279
+ }
280
+
281
+ private setupRoutes(): void {
282
+ this.app.get('/api/status', (req, res) => {
283
+ res.json({
284
+ status: 'success',
285
+ message: 'TypeScript SEA is running!',
286
+ timestamp: new Date().toISOString()
287
+ });
288
+ });
289
+ }
290
+ }
291
+
292
+ export default TypeScriptSEAApp;
293
+ ````
294
+
295
+ Package it with:
296
+
297
+ ```bash
298
+ node-msix package --input ./typescript-app --name "TypeScript SEA Demo" --publisher "CN=Demo"
299
+ ```
300
+
301
+ The packager automatically:
302
+
303
+ 1. Detects TypeScript files and `tsconfig.json`
304
+ 2. Uses NCC to bundle and transpile TypeScript code
305
+ 3. Creates a single executable with embedded TypeScript application
306
+ 4. Packages everything into an MSIX for distribution
307
+
308
+ For detailed documentation on makeappx-only packaging, see [`docs/makeappx-only.md`](docs/makeappx-only.md).
309
+
310
+ ## Troubleshooting
311
+
312
+ ### TypeScript Build Errors
313
+
314
+ If you get errors like `'tsc' is not recognized as an internal or external command`, you have several options:
315
+
316
+ 1. **Install dev dependencies** (Recommended): Set `installDevDeps: true` in your config:
317
+
318
+ ```json
319
+ {
320
+ "installDevDeps": true
321
+ }
322
+ ```
323
+
324
+ 2. **Skip the build step**: If your code is already compiled:
325
+
326
+ ```json
327
+ {
328
+ "skipBuild": true
329
+ }
330
+ ```
331
+
332
+ 3. **Pre-build your application** before packaging:
333
+ ```bash
334
+ bun run build
335
+ node-msix package --config config.json --skipBuild
336
+ ```
337
+
338
+ ### Common Build Issues
339
+
340
+ - **Missing TypeScript**: The packager will automatically try to install TypeScript if it detects a tsc build failure
341
+ - **Build takes too long**: Use `skipBuild: true` if you've already built your application
342
+ - **Memory issues**: Try building your app separately first, then package with `skipBuild: true`
343
+ - **SEA creation fails**: The packager will fall back to traditional Node.js launcher approach
344
+ - **Executable creation**: Uses Node.js Single Executable Application (SEA) for reliable bundling and optimal performance
345
+
346
+ ### Command Line Options
347
+
348
+ You can also control build behavior via CLI:
349
+
350
+ ```bash
351
+ # Skip build step
352
+ node-msix package --config config.json --skip-build
353
+
354
+ # Force install dev dependencies
355
+ node-msix package --config config.json --install-dev-deps
356
+ ```
357
+
358
+ ## License
359
+
360
+ MIT
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@involvex/msix-packager-cli",
3
+ "author": {
4
+ "name": "involvex"
5
+ },
6
+ "version": "1.4.1",
7
+ "description": "A utility to create MSIX packages from Node.js applications with MCP server support, Node.js Single Executable Application (SEA) bundling using @vercel/ncc and postject, and enhanced build options",
8
+ "main": "src/index.js",
9
+ "files": [
10
+ "src/",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "engines": {
15
+ "node": ">=14.0.0"
16
+ },
17
+ "os": [
18
+ "win32"
19
+ ],
20
+ "scripts": {
21
+ "dev": "bun run src/cli.js",
22
+ "start": "bun run src/cli.js",
23
+ "build": "bun build src/cli.js --outdir dist --target node",
24
+ "prepublishOnly": "echo 'Ready to publish'"
25
+ },
26
+ "keywords": [
27
+ "msix",
28
+ "node",
29
+ "packaging",
30
+ "windows",
31
+ "electron",
32
+ "uwp",
33
+ "windows-store",
34
+ "deployment",
35
+ "mcp",
36
+ "model-context-protocol",
37
+ "sea",
38
+ "single-executable-applications",
39
+ "ncc",
40
+ "vercel",
41
+ "postject",
42
+ "bundling",
43
+ "executable"
44
+ ],
45
+ "license": "MIT",
46
+ "dependencies": {
47
+ "@vercel/ncc": "^0.38.4",
48
+ "chalk": "4.1.2",
49
+ "commander": "^14.0.3",
50
+ "express": "^5.2.1",
51
+ "fs-extra": "^11.3.3",
52
+ "postject": "^1.0.0-alpha.6"
53
+ },
54
+ "bin": {
55
+ "msix-packager-cli": "src/cli.js"
56
+ }
57
+ }