@ni-kismet/sl-webapp-nipkg 0.1.0 → 0.2.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.
Files changed (3) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +517 -518
  3. package/package.json +77 -77
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 National Instruments Corporation
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 National Instruments Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,518 +1,517 @@
1
- # SL WebApp NIPKG
2
-
3
- [![npm version](https://badge.fury.io/js/sl-webapp-nipkg.svg)](https://badge.fury.io/js/sl-webapp-nipkg)
4
- [![Tests](https://github.com/ni/sl-webapp-nipkg/actions/workflows/ci.yml/badge.svg)](https://github.com/ni/sl-webapp-nipkg/actions)
5
- ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/ni/sl-webapp-nipkg?style=flat-square)
6
- [![license](https://img.shields.io/github/license/ni/sl-webapp-nipkg.svg)](LICENSE)
7
-
8
- A flexible tool for packaging web applications into SystemLink WebApp `.nipkg` format for National Instruments Package Manager. Works with any web application framework including Node.js (React, Angular, Vue), Python (Pyodide), .NET (Blazor), and static HTML sites.
9
-
10
- ## Features
11
-
12
- - 🚀 **Easy Integration**: Works seamlessly with any web application
13
- - 📦 **Automated Packaging**: Builds and packages your app in one command
14
- - ⚙️ **Flexible Configuration**: Optional config files - use CLI flags or JSON config
15
- - 🎯 **TypeScript Support**: Written in TypeScript with full type definitions
16
- - 🌈 **Beautiful CLI**: Colorful, informative command-line interface
17
- - 🔧 **CI/CD Ready**: Easy integration with build pipelines
18
- - 🌍 **Cross-Platform**: Works on Windows, macOS, and Linux without external dependencies
19
- - 🔌 **Framework Agnostic**: Works with React, Angular, Vue, Blazor, Pyodide, static HTML, and more
20
- - 🎨 **Zero Config**: No config files required - just point to your build directory
21
-
22
- ## Prerequisites
23
-
24
- - Node.js 16 or higher (only to run the packaging tool)
25
-
26
- ## Installation
27
-
28
- ### Global Installation (Recommended)
29
-
30
- ```bash
31
- npm install -g @ni-kismet/sl-webapp-nipkg
32
- ```
33
-
34
- ### Project-specific Installation
35
-
36
- ```bash
37
- # As a dev dependency in your project
38
- npm install --save-dev @ni-kismet/sl-webapp-nipkg
39
- ```
40
-
41
- ## Quick Start
42
-
43
- ### Option 1: Minimal Usage (No Config Files)
44
-
45
- ```bash
46
- # Package any web application - just point to the build directory
47
- sl-webapp-nipkg build --build-dir ./dist --name my-app
48
-
49
- # With full metadata
50
- sl-webapp-nipkg build \
51
- --build-dir ./dist \
52
- --name "My WebApp" \
53
- --version "1.0.0" \
54
- --maintainer "Your Name <name@example.com>"
55
- ```
56
-
57
- ### Option 2: With Configuration File (Recommended for Node.js projects)
58
-
59
- 1. **Navigate to your project**:
60
-
61
- ```bash
62
- cd my-webapp-project
63
- ```
64
-
65
- 2. **Initialize configuration** (optional):
66
-
67
- ```bash
68
- sl-webapp-nipkg init
69
- ```
70
-
71
- 3. **Edit the generated `nipkg.config.json`** (all fields optional):
72
-
73
- ```json
74
- {
75
- "maintainer": "John Doe <john.doe@company.com>",
76
- "displayName": "My WebApp",
77
- "buildDir": "dist",
78
- "buildCommand": "npm run build",
79
- "userVisible": true
80
- }
81
- ```
82
-
83
- **Note:** The `name`, `version`, and `description` are auto-detected from your `package.json` if present.
84
-
85
- 4. **Build and package**:
86
-
87
- ```bash
88
- sl-webapp-nipkg build --build
89
- ```
90
-
91
- ## CLI Commands
92
-
93
- ### `sl-webapp-nipkg build`
94
-
95
- Build and package your web application.
96
-
97
- #### Options
98
-
99
- **Core Options:**
100
-
101
- - `--build-dir <path>` - Build output directory to package (required if not in config)
102
- - `--name <name>` - Package name (auto-detected from package.json or directory name)
103
- - `--version <version>` - Package version (auto-detected from package.json or defaults to 1.0.0)
104
- - `--description <description>` - Package description (optional)
105
- - `--maintainer <maintainer>` - Maintainer info (defaults to 'Unknown')
106
- - `--output-dir <path>` - Output directory for nipkg files (default: dist/nipkg)
107
-
108
- **Build Options:**
109
-
110
- - `-b, --build [command]` - Run build command before packaging (optionally specify custom command to override config)
111
- - `-v, --verbose` - Enable verbose output
112
- - `--skip-cleanup` - Skip cleanup of existing packages
113
- - `--build-suffix <suffix>` - Add a suffix to the package name (e.g., build ID for CI/CD)
114
- - `--config <path>` - Custom config file path (default: 'nipkg.config.json')
115
-
116
- **Note:** CLI options override config file values, which override package.json values.
117
-
118
- #### Examples
119
-
120
- **Node.js Projects:**
121
-
122
- ```bash
123
- # Build and package (runs buildCommand from config)
124
- sl-webapp-nipkg build --build
125
-
126
- # Build with custom command (overrides config)
127
- sl-webapp-nipkg build --build "npm run build:production"
128
-
129
- # Use existing build output (no build step)
130
- sl-webapp-nipkg build
131
-
132
- # Build with build ID suffix for CI/CD
133
- sl-webapp-nipkg build --build --build-suffix "${BUILD_ID}"
134
-
135
- # Verbose output with custom config
136
- sl-webapp-nipkg build --build --verbose --config my-nipkg.config.json
137
- ```
138
-
139
- **Non-Node.js Projects (Python, Blazor, Static Sites):**
140
-
141
- ```bash
142
- # Python Pyodide webapp
143
- sl-webapp-nipkg build --build-dir ./public --name my-pyodide-app
144
-
145
- # .NET Blazor webapp
146
- sl-webapp-nipkg build \
147
- --build-dir ./bin/Release/net8.0/publish \
148
- --name "My Blazor App" \
149
- --version "2.0.0"
150
-
151
- # Static HTML site
152
- sl-webapp-nipkg build --build-dir ./dist --name my-static-site --version 1.0.0
153
-
154
- # With full metadata
155
- sl-webapp-nipkg build \
156
- --build-dir ./output \
157
- --name "My WebApp" \
158
- --version "1.5.0" \
159
- --description "My awesome webapp" \
160
- --maintainer "Team <team@company.com>"
161
- ```
162
-
163
- ### `sl-webapp-nipkg init`
164
-
165
- Initialize a `nipkg.config.json` file in the current directory.
166
-
167
- ## Configuration
168
-
169
- ### Configuration File (`nipkg.config.json`)
170
-
171
- **All fields are optional.** CLI options override config file values. Config file values override package.json auto-detection.
172
-
173
- | Property | Type | Required | Description |
174
- | -------- | ---- | -------- | ----------- |
175
- | `name` | string | ❌ | Package name (auto-detected from package.json or directory name) |
176
- | `version` | string | ❌ | Package version (auto-detected from package.json, defaults to 1.0.0) |
177
- | `description` | string | ❌ | Package description (auto-detected from package.json, defaults to empty) |
178
- | `maintainer` | string | ❌ | Maintainer information (defaults to 'Unknown') |
179
- | `architecture` | string | ❌ | Target architecture (default: 'all') |
180
- | `displayName` | string | | Display name for the package |
181
- | `buildDir` | string | ❌* | Build output directory (e.g., 'dist', 'build') - *Required if not provided via CLI |
182
- | `buildCommand` | string | ❌ | Custom build command (default: 'npm run build') |
183
- | `outputDir` | string | ❌ | Custom nipkg output directory (default: 'dist/nipkg') |
184
- | `buildSuffix` | string | ❌ | Optional suffix for package filename (e.g., build ID for CI/CD) |
185
- | `depends` | string[] | ❌ | Package dependencies |
186
- | `userVisible` | boolean | ❌ | Whether package is user visible |
187
-
188
- ### Example Configuration
189
-
190
- ```json
191
- {
192
- "name": "my-webapp",
193
- "version": "1.2.3",
194
- "description": "A SystemLink WebApp for National Instruments",
195
- "maintainer": "John Doe <john.doe@company.com>",
196
- "architecture": "all",
197
- "displayName": "My WebApp",
198
- "buildDir": "dist",
199
- "buildCommand": "npm run build",
200
- "userVisible": true,
201
- "depends": [
202
- "ni-systemlink-server >= 2023.1"
203
- ],
204
- "outputDir": "packages"
205
- }
206
- ```
207
-
208
- ## Framework Examples
209
-
210
- ### Non-Node.js Projects
211
-
212
- **Python Pyodide:**
213
-
214
- ```bash
215
- # No config file needed
216
- sl-webapp-nipkg build \
217
- --build-dir ./public \
218
- --name my-pyodide-app \
219
- --version 1.0.0 \
220
- --maintainer "Python Team <team@example.com>"
221
- ```
222
-
223
- **.NET Blazor:**
224
-
225
- ```bash
226
- # Package Blazor WebAssembly output
227
- sl-webapp-nipkg build \
228
- --build-dir ./bin/Release/net8.0/publish/wwwroot \
229
- --name my-blazor-app \
230
- --version 2.0.0
231
- ```
232
-
233
- **Static HTML:**
234
-
235
- ```bash
236
- # Package any static web content
237
- sl-webapp-nipkg build --build-dir ./dist --name my-static-site
238
- ```
239
-
240
- ### Node.js Projects
241
-
242
- **React:**
243
-
244
- ```json
245
- {
246
- "maintainer": "Your Name <your.email@company.com>",
247
- "buildDir": "build",
248
- "buildCommand": "npm run build"
249
- }
250
- ```
251
-
252
- ### Vue
253
-
254
- ```json
255
- {
256
- "maintainer": "Your Name <your.email@company.com>",
257
- "buildDir": "dist",
258
- "buildCommand": "npm run build"
259
- }
260
- ```
261
-
262
- ### Angular
263
-
264
- ```json
265
- {
266
- "maintainer": "Your Name <your.email@company.com>",
267
- "buildDir": "dist/my-app/browser",
268
- "buildCommand": "npm run build"
269
- }
270
- ```
271
-
272
- **Note:** For Angular projects, specify the build configuration in `buildCommand`: `"buildCommand": "ng build --configuration production"` or use an npm script like `"build": "ng build --configuration production"` and let the default `npm run build` work.
273
-
274
- ### Next.js
275
-
276
- ```json
277
- {
278
- "maintainer": "Your Name <your.email@company.com>",
279
- "buildDir": "out",
280
- "buildCommand": "npm run build && npm run export"
281
- }
282
- ```
283
-
284
- ## Integration with Node.js Projects
285
-
286
- ### Add to package.json Scripts
287
-
288
- ```json
289
- {
290
- "scripts": {
291
- "start": "npm run dev",
292
- "dev": "vite",
293
- "build": "vite build",
294
- "build:nipkg": "sl-webapp-nipkg build --build",
295
- "package:nipkg": "sl-webapp-nipkg build"
296
- }
297
- }
298
- ```
299
-
300
- ### Use in npm Scripts
301
-
302
- ```bash
303
- # Build and package for production
304
- npm run build:nipkg
305
-
306
- # Package existing build
307
- npm run package:nipkg
308
- ```
309
-
310
- ## Programmatic Usage
311
-
312
- ```typescript
313
- import { SystemLinkNipkgBuilder, NipkgConfig, BuildOptions } from '@ni-kismet/sl-webapp-nipkg';
314
-
315
- const config: NipkgConfig = {
316
- name: 'my-app',
317
- version: '1.0.0',
318
- description: 'My SystemLink WebApp',
319
- maintainer: 'John Doe <john@example.com>',
320
- buildDir: 'dist',
321
- userVisible: true
322
- };
323
-
324
- const options: BuildOptions = {
325
- build: true,
326
- verbose: true
327
- };
328
-
329
- const builder = new SystemLinkNipkgBuilder(config, options);
330
- await builder.build();
331
- ```
332
-
333
- ## CI/CD Integration
334
-
335
- The `--build-suffix` option allows you to create unique package names for PR/branch builds while keeping clean names for production releases.
336
-
337
- **Output examples:**
338
-
339
- - PR builds: `my-app_1.0.0_12345_all.nipkg` (includes build ID)
340
- - Main/production: `my-app_1.0.0_all.nipkg` (standard naming)
341
-
342
- ### GitHub Actions
343
-
344
- ```yaml
345
- name: Build and Package
346
-
347
- on:
348
- push:
349
- branches: [ main ]
350
- pull_request:
351
- branches: [ main ]
352
-
353
- jobs:
354
- build:
355
- runs-on: windows-latest
356
-
357
- steps:
358
- - uses: actions/checkout@v3
359
-
360
- - name: Setup Node.js
361
- uses: actions/setup-node@v3
362
- with:
363
- node-version: '18'
364
- cache: 'npm'
365
-
366
- - name: Install dependencies
367
- run: npm ci
368
-
369
- - name: Build and Package (PR)
370
- if: github.event_name == 'pull_request'
371
- run: sl-webapp-nipkg build --build --build-suffix "${{ github.run_number }}"
372
-
373
- - name: Build and Package (Main)
374
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
375
- run: sl-webapp-nipkg build --build
376
-
377
- - name: Upload Package
378
- uses: actions/upload-artifact@v3
379
- with:
380
- name: nipkg-package
381
- path: dist/nipkg/*.nipkg
382
- ```
383
-
384
- ### Azure DevOps
385
-
386
- ```yaml
387
- trigger:
388
- - main
389
-
390
- pool:
391
- vmImage: 'windows-latest'
392
-
393
- steps:
394
- - task: NodeTool@0
395
- inputs:
396
- versionSpec: '18.x'
397
-
398
- - script: npm ci
399
- displayName: 'Install dependencies'
400
-
401
- - script: |
402
- if [ "$(Build.SourceBranch)" = "refs/heads/main" ]; then
403
- npm run build
404
- sl-webapp-nipkg build
405
- else
406
- npm run build
407
- sl-webapp-nipkg build --build-suffix "$(Build.BuildId)"
408
- fi
409
- displayName: 'Build and package'
410
-
411
- - task: PublishBuildArtifacts@1
412
- inputs:
413
- PathtoPublish: 'dist/nipkg'
414
- ArtifactName: 'nipkg-package'
415
- ```
416
-
417
- ## Package Structure
418
-
419
- After packaging, your project will have this structure:
420
-
421
- ```text
422
- your-webapp-project/
423
- ├── dist/ # Your build output
424
- │ ├── index.html
425
- ├── assets/
426
- │ └── ...
427
- ├── dist/nipkg/ # NIPKG packaging
428
- ├── your-app_1.0.0_all.nipkg # Final package
429
- │ └── temp-source/ # Temporary (auto-cleaned)
430
- ├── nipkg.config.json # Package configuration
431
- └── package.json # NPM scripts
432
- ```
433
-
434
- ## Requirements
435
-
436
- - Node.js 16+
437
- - National Instruments Package Manager (nipkg)
438
-
439
- ## Development
440
-
441
- ### Building from Source
442
-
443
- ```bash
444
- git clone https://github.com/ni/sl-webapp-nipkg.git
445
- cd sl-webapp-nipkg
446
- npm install
447
- npm run build
448
- ```
449
-
450
- ### Running Tests
451
-
452
- ```bash
453
- # Run all tests
454
- npm test
455
-
456
- # Run tests with coverage
457
- npm run test:coverage
458
-
459
- # Run tests in watch mode
460
- npm run test:watch
461
- ```
462
-
463
- ### Local Development
464
-
465
- ```bash
466
- # Link globally for testing
467
- npm link
468
-
469
- # Use in any Node.js project
470
- cd /path/to/your/project
471
- sl-webapp-nipkg --help
472
- ```
473
-
474
- ## Troubleshooting
475
-
476
- ### Common Issues
477
-
478
- #### "Build directory not found"
479
-
480
- - Provide build directory via CLI: `--build-dir ./dist`
481
- - Or run with `--build` flag to build before packaging
482
- - Check that your build command runs successfully
483
- - Verify `buildDir` in nipkg.config.json points to the correct directory
484
-
485
- #### "buildDir is required"
486
-
487
- - Provide via CLI: `sl-webapp-nipkg build --build-dir ./dist`
488
- - Or add to nipkg.config.json: `"buildDir": "dist"`
489
-
490
- #### Package dependencies missing
491
-
492
- - Add required NI runtime dependencies to `depends` array in config
493
- - Example: `"depends": ["ni-systemlink-server >= 2023.1"]`
494
-
495
- ## Contributing
496
-
497
- 1. Fork the repository
498
- 2. Create a feature branch: `git checkout -b feature/amazing-feature`
499
- 3. Make your changes
500
- 4. Add tests for your changes
501
- 5. Ensure tests pass: `npm test`
502
- 6. Commit your changes: `git commit -m 'Add amazing feature'`
503
- 7. Push to the branch: `git push origin feature/amazing-feature`
504
- 8. Submit a pull request
505
-
506
- ## License
507
-
508
- MIT © National Instruments
509
-
510
- ## Support
511
-
512
- - 📚 [Documentation](https://github.com/ni/sl-webapp-nipkg/wiki)
513
- - 🐛 [Report Issues](https://github.com/ni/sl-webapp-nipkg/issues)
514
- - 💬 [Discussions](https://github.com/ni/sl-webapp-nipkg/discussions)
515
-
516
- ---
517
-
518
- *Made with ❤️ for the National Instruments community*
1
+ # SL WebApp NIPKG
2
+
3
+ [![JFrog Registry](https://img.shields.io/badge/registry-JFrog-green)](https://pull.artifacts.ni.com/ui/repos/tree/General/npm-remote-cache/.npm/@ni-kismet/sl-webapp-nipkg)
4
+ [![Tests](https://github.com/ni/sl-webapp-nipkg/actions/workflows/ci.yml/badge.svg)](https://github.com/ni/sl-webapp-nipkg/actions)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+
7
+ A flexible tool for packaging web applications into SystemLink WebApp `.nipkg` format for National Instruments Package Manager. Works with any web application framework including Node.js (React, Angular, Vue), Python (Pyodide), .NET (Blazor), and static HTML sites.
8
+
9
+ ## Features
10
+
11
+ - 🚀 **Easy Integration**: Works seamlessly with any web application
12
+ - 📦 **Automated Packaging**: Builds and packages your app in one command
13
+ - ⚙️ **Flexible Configuration**: Optional config files - use CLI flags or JSON config
14
+ - 🎯 **TypeScript Support**: Written in TypeScript with full type definitions
15
+ - 🌈 **Beautiful CLI**: Colorful, informative command-line interface
16
+ - 🔧 **CI/CD Ready**: Easy integration with build pipelines
17
+ - 🌍 **Cross-Platform**: Works on Windows, macOS, and Linux without external dependencies
18
+ - 🔌 **Framework Agnostic**: Works with React, Angular, Vue, Blazor, Pyodide, static HTML, and more
19
+ - 🎨 **Zero Config**: No config files required - just point to your build directory
20
+
21
+ ## Prerequisites
22
+
23
+ - Node.js 16 or higher (only to run the packaging tool)
24
+
25
+ ## Installation
26
+
27
+ ### Global Installation (Recommended)
28
+
29
+ ```bash
30
+ npm install -g @ni-kismet/sl-webapp-nipkg
31
+ ```
32
+
33
+ ### Project-specific Installation
34
+
35
+ ```bash
36
+ # As a dev dependency in your project
37
+ npm install --save-dev @ni-kismet/sl-webapp-nipkg
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### Option 1: Minimal Usage (No Config Files)
43
+
44
+ ```bash
45
+ # Package any web application - just point to the build directory
46
+ sl-webapp-nipkg build --build-dir ./dist --name my-app
47
+
48
+ # With full metadata
49
+ sl-webapp-nipkg build \
50
+ --build-dir ./dist \
51
+ --name "My WebApp" \
52
+ --version "1.0.0" \
53
+ --maintainer "Your Name <name@example.com>"
54
+ ```
55
+
56
+ ### Option 2: With Configuration File (Recommended for Node.js projects)
57
+
58
+ 1. **Navigate to your project**:
59
+
60
+ ```bash
61
+ cd my-webapp-project
62
+ ```
63
+
64
+ 2. **Initialize configuration** (optional):
65
+
66
+ ```bash
67
+ sl-webapp-nipkg init
68
+ ```
69
+
70
+ 3. **Edit the generated `nipkg.config.json`** (all fields optional):
71
+
72
+ ```json
73
+ {
74
+ "maintainer": "John Doe <john.doe@company.com>",
75
+ "displayName": "My WebApp",
76
+ "buildDir": "dist",
77
+ "buildCommand": "npm run build",
78
+ "userVisible": true
79
+ }
80
+ ```
81
+
82
+ **Note:** The `name`, `version`, and `description` are auto-detected from your `package.json` if present.
83
+
84
+ 4. **Build and package**:
85
+
86
+ ```bash
87
+ sl-webapp-nipkg build --build
88
+ ```
89
+
90
+ ## CLI Commands
91
+
92
+ ### `sl-webapp-nipkg build`
93
+
94
+ Build and package your web application.
95
+
96
+ #### Options
97
+
98
+ **Core Options:**
99
+
100
+ - `--build-dir <path>` - Build output directory to package (required if not in config)
101
+ - `--name <name>` - Package name (auto-detected from package.json or directory name)
102
+ - `--version <version>` - Package version (auto-detected from package.json or defaults to 1.0.0)
103
+ - `--description <description>` - Package description (optional)
104
+ - `--maintainer <maintainer>` - Maintainer info (defaults to 'Unknown')
105
+ - `--output-dir <path>` - Output directory for nipkg files (default: dist/nipkg)
106
+
107
+ **Build Options:**
108
+
109
+ - `-b, --build [command]` - Run build command before packaging (optionally specify custom command to override config)
110
+ - `-v, --verbose` - Enable verbose output
111
+ - `--skip-cleanup` - Skip cleanup of existing packages
112
+ - `--build-suffix <suffix>` - Add a suffix to the package name (e.g., build ID for CI/CD)
113
+ - `--config <path>` - Custom config file path (default: 'nipkg.config.json')
114
+
115
+ **Note:** CLI options override config file values, which override package.json values.
116
+
117
+ #### Examples
118
+
119
+ **Node.js Projects:**
120
+
121
+ ```bash
122
+ # Build and package (runs buildCommand from config)
123
+ sl-webapp-nipkg build --build
124
+
125
+ # Build with custom command (overrides config)
126
+ sl-webapp-nipkg build --build "npm run build:production"
127
+
128
+ # Use existing build output (no build step)
129
+ sl-webapp-nipkg build
130
+
131
+ # Build with build ID suffix for CI/CD
132
+ sl-webapp-nipkg build --build --build-suffix "${BUILD_ID}"
133
+
134
+ # Verbose output with custom config
135
+ sl-webapp-nipkg build --build --verbose --config my-nipkg.config.json
136
+ ```
137
+
138
+ **Non-Node.js Projects (Python, Blazor, Static Sites):**
139
+
140
+ ```bash
141
+ # Python Pyodide webapp
142
+ sl-webapp-nipkg build --build-dir ./public --name my-pyodide-app
143
+
144
+ # .NET Blazor webapp
145
+ sl-webapp-nipkg build \
146
+ --build-dir ./bin/Release/net8.0/publish \
147
+ --name "My Blazor App" \
148
+ --version "2.0.0"
149
+
150
+ # Static HTML site
151
+ sl-webapp-nipkg build --build-dir ./dist --name my-static-site --version 1.0.0
152
+
153
+ # With full metadata
154
+ sl-webapp-nipkg build \
155
+ --build-dir ./output \
156
+ --name "My WebApp" \
157
+ --version "1.5.0" \
158
+ --description "My awesome webapp" \
159
+ --maintainer "Team <team@company.com>"
160
+ ```
161
+
162
+ ### `sl-webapp-nipkg init`
163
+
164
+ Initialize a `nipkg.config.json` file in the current directory.
165
+
166
+ ## Configuration
167
+
168
+ ### Configuration File (`nipkg.config.json`)
169
+
170
+ **All fields are optional.** CLI options override config file values. Config file values override package.json auto-detection.
171
+
172
+ | Property | Type | Required | Description |
173
+ | -------- | ---- | -------- | ----------- |
174
+ | `name` | string | | Package name (auto-detected from package.json or directory name) |
175
+ | `version` | string | ❌ | Package version (auto-detected from package.json, defaults to 1.0.0) |
176
+ | `description` | string | ❌ | Package description (auto-detected from package.json, defaults to empty) |
177
+ | `maintainer` | string | ❌ | Maintainer information (defaults to 'Unknown') |
178
+ | `architecture` | string | ❌ | Target architecture (default: 'all') |
179
+ | `displayName` | string | ❌ | Display name for the package |
180
+ | `buildDir` | string | ❌* | Build output directory (e.g., 'dist', 'build') - *Required if not provided via CLI |
181
+ | `buildCommand` | string | | Custom build command (default: 'npm run build') |
182
+ | `outputDir` | string | ❌ | Custom nipkg output directory (default: 'dist/nipkg') |
183
+ | `buildSuffix` | string | ❌ | Optional suffix for package filename (e.g., build ID for CI/CD) |
184
+ | `depends` | string[] | ❌ | Package dependencies |
185
+ | `userVisible` | boolean | ❌ | Whether package is user visible |
186
+
187
+ ### Example Configuration
188
+
189
+ ```json
190
+ {
191
+ "name": "my-webapp",
192
+ "version": "1.2.3",
193
+ "description": "A SystemLink WebApp for National Instruments",
194
+ "maintainer": "John Doe <john.doe@company.com>",
195
+ "architecture": "all",
196
+ "displayName": "My WebApp",
197
+ "buildDir": "dist",
198
+ "buildCommand": "npm run build",
199
+ "userVisible": true,
200
+ "depends": [
201
+ "ni-systemlink-server >= 2023.1"
202
+ ],
203
+ "outputDir": "packages"
204
+ }
205
+ ```
206
+
207
+ ## Framework Examples
208
+
209
+ ### Non-Node.js Projects
210
+
211
+ **Python Pyodide:**
212
+
213
+ ```bash
214
+ # No config file needed
215
+ sl-webapp-nipkg build \
216
+ --build-dir ./public \
217
+ --name my-pyodide-app \
218
+ --version 1.0.0 \
219
+ --maintainer "Python Team <team@example.com>"
220
+ ```
221
+
222
+ **.NET Blazor:**
223
+
224
+ ```bash
225
+ # Package Blazor WebAssembly output
226
+ sl-webapp-nipkg build \
227
+ --build-dir ./bin/Release/net8.0/publish/wwwroot \
228
+ --name my-blazor-app \
229
+ --version 2.0.0
230
+ ```
231
+
232
+ **Static HTML:**
233
+
234
+ ```bash
235
+ # Package any static web content
236
+ sl-webapp-nipkg build --build-dir ./dist --name my-static-site
237
+ ```
238
+
239
+ ### Node.js Projects
240
+
241
+ **React:**
242
+
243
+ ```json
244
+ {
245
+ "maintainer": "Your Name <your.email@company.com>",
246
+ "buildDir": "build",
247
+ "buildCommand": "npm run build"
248
+ }
249
+ ```
250
+
251
+ ### Vue
252
+
253
+ ```json
254
+ {
255
+ "maintainer": "Your Name <your.email@company.com>",
256
+ "buildDir": "dist",
257
+ "buildCommand": "npm run build"
258
+ }
259
+ ```
260
+
261
+ ### Angular
262
+
263
+ ```json
264
+ {
265
+ "maintainer": "Your Name <your.email@company.com>",
266
+ "buildDir": "dist/my-app/browser",
267
+ "buildCommand": "npm run build"
268
+ }
269
+ ```
270
+
271
+ **Note:** For Angular projects, specify the build configuration in `buildCommand`: `"buildCommand": "ng build --configuration production"` or use an npm script like `"build": "ng build --configuration production"` and let the default `npm run build` work.
272
+
273
+ ### Next.js
274
+
275
+ ```json
276
+ {
277
+ "maintainer": "Your Name <your.email@company.com>",
278
+ "buildDir": "out",
279
+ "buildCommand": "npm run build && npm run export"
280
+ }
281
+ ```
282
+
283
+ ## Integration with Node.js Projects
284
+
285
+ ### Add to package.json Scripts
286
+
287
+ ```json
288
+ {
289
+ "scripts": {
290
+ "start": "npm run dev",
291
+ "dev": "vite",
292
+ "build": "vite build",
293
+ "build:nipkg": "sl-webapp-nipkg build --build",
294
+ "package:nipkg": "sl-webapp-nipkg build"
295
+ }
296
+ }
297
+ ```
298
+
299
+ ### Use in npm Scripts
300
+
301
+ ```bash
302
+ # Build and package for production
303
+ npm run build:nipkg
304
+
305
+ # Package existing build
306
+ npm run package:nipkg
307
+ ```
308
+
309
+ ## Programmatic Usage
310
+
311
+ ```typescript
312
+ import { SystemLinkNipkgBuilder, NipkgConfig, BuildOptions } from '@ni-kismet/sl-webapp-nipkg';
313
+
314
+ const config: NipkgConfig = {
315
+ name: 'my-app',
316
+ version: '1.0.0',
317
+ description: 'My SystemLink WebApp',
318
+ maintainer: 'John Doe <john@example.com>',
319
+ buildDir: 'dist',
320
+ userVisible: true
321
+ };
322
+
323
+ const options: BuildOptions = {
324
+ build: true,
325
+ verbose: true
326
+ };
327
+
328
+ const builder = new SystemLinkNipkgBuilder(config, options);
329
+ await builder.build();
330
+ ```
331
+
332
+ ## CI/CD Integration
333
+
334
+ The `--build-suffix` option allows you to create unique package names for PR/branch builds while keeping clean names for production releases.
335
+
336
+ **Output examples:**
337
+
338
+ - PR builds: `my-app_1.0.0_12345_all.nipkg` (includes build ID)
339
+ - Main/production: `my-app_1.0.0_all.nipkg` (standard naming)
340
+
341
+ ### GitHub Actions
342
+
343
+ ```yaml
344
+ name: Build and Package
345
+
346
+ on:
347
+ push:
348
+ branches: [ main ]
349
+ pull_request:
350
+ branches: [ main ]
351
+
352
+ jobs:
353
+ build:
354
+ runs-on: windows-latest
355
+
356
+ steps:
357
+ - uses: actions/checkout@v3
358
+
359
+ - name: Setup Node.js
360
+ uses: actions/setup-node@v3
361
+ with:
362
+ node-version: '18'
363
+ cache: 'npm'
364
+
365
+ - name: Install dependencies
366
+ run: npm ci
367
+
368
+ - name: Build and Package (PR)
369
+ if: github.event_name == 'pull_request'
370
+ run: sl-webapp-nipkg build --build --build-suffix "${{ github.run_number }}"
371
+
372
+ - name: Build and Package (Main)
373
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
374
+ run: sl-webapp-nipkg build --build
375
+
376
+ - name: Upload Package
377
+ uses: actions/upload-artifact@v3
378
+ with:
379
+ name: nipkg-package
380
+ path: dist/nipkg/*.nipkg
381
+ ```
382
+
383
+ ### Azure DevOps
384
+
385
+ ```yaml
386
+ trigger:
387
+ - main
388
+
389
+ pool:
390
+ vmImage: 'windows-latest'
391
+
392
+ steps:
393
+ - task: NodeTool@0
394
+ inputs:
395
+ versionSpec: '18.x'
396
+
397
+ - script: npm ci
398
+ displayName: 'Install dependencies'
399
+
400
+ - script: |
401
+ if [ "$(Build.SourceBranch)" = "refs/heads/main" ]; then
402
+ npm run build
403
+ sl-webapp-nipkg build
404
+ else
405
+ npm run build
406
+ sl-webapp-nipkg build --build-suffix "$(Build.BuildId)"
407
+ fi
408
+ displayName: 'Build and package'
409
+
410
+ - task: PublishBuildArtifacts@1
411
+ inputs:
412
+ PathtoPublish: 'dist/nipkg'
413
+ ArtifactName: 'nipkg-package'
414
+ ```
415
+
416
+ ## Package Structure
417
+
418
+ After packaging, your project will have this structure:
419
+
420
+ ```text
421
+ your-webapp-project/
422
+ ├── dist/ # Your build output
423
+ ├── index.html
424
+ │ ├── assets/
425
+ └── ...
426
+ ├── dist/nipkg/ # NIPKG packaging
427
+ ├── your-app_1.0.0_all.nipkg # Final package
428
+ └── temp-source/ # Temporary (auto-cleaned)
429
+ ├── nipkg.config.json # Package configuration
430
+ └── package.json # NPM scripts
431
+ ```
432
+
433
+ ## Requirements
434
+
435
+ - Node.js 16+
436
+ - National Instruments Package Manager (nipkg)
437
+
438
+ ## Development
439
+
440
+ ### Building from Source
441
+
442
+ ```bash
443
+ git clone https://github.com/ni/sl-webapp-nipkg.git
444
+ cd sl-webapp-nipkg
445
+ npm install
446
+ npm run build
447
+ ```
448
+
449
+ ### Running Tests
450
+
451
+ ```bash
452
+ # Run all tests
453
+ npm test
454
+
455
+ # Run tests with coverage
456
+ npm run test:coverage
457
+
458
+ # Run tests in watch mode
459
+ npm run test:watch
460
+ ```
461
+
462
+ ### Local Development
463
+
464
+ ```bash
465
+ # Link globally for testing
466
+ npm link
467
+
468
+ # Use in any Node.js project
469
+ cd /path/to/your/project
470
+ sl-webapp-nipkg --help
471
+ ```
472
+
473
+ ## Troubleshooting
474
+
475
+ ### Common Issues
476
+
477
+ #### "Build directory not found"
478
+
479
+ - Provide build directory via CLI: `--build-dir ./dist`
480
+ - Or run with `--build` flag to build before packaging
481
+ - Check that your build command runs successfully
482
+ - Verify `buildDir` in nipkg.config.json points to the correct directory
483
+
484
+ #### "buildDir is required"
485
+
486
+ - Provide via CLI: `sl-webapp-nipkg build --build-dir ./dist`
487
+ - Or add to nipkg.config.json: `"buildDir": "dist"`
488
+
489
+ #### Package dependencies missing
490
+
491
+ - Add required NI runtime dependencies to `depends` array in config
492
+ - Example: `"depends": ["ni-systemlink-server >= 2023.1"]`
493
+
494
+ ## Contributing
495
+
496
+ 1. Fork the repository
497
+ 2. Create a feature branch: `git checkout -b feature/amazing-feature`
498
+ 3. Make your changes
499
+ 4. Add tests for your changes
500
+ 5. Ensure tests pass: `npm test`
501
+ 6. Commit your changes: `git commit -m 'Add amazing feature'`
502
+ 7. Push to the branch: `git push origin feature/amazing-feature`
503
+ 8. Submit a pull request
504
+
505
+ ## License
506
+
507
+ MIT © National Instruments
508
+
509
+ ## Support
510
+
511
+ - 📚 [Documentation](https://github.com/ni/sl-webapp-nipkg/wiki)
512
+ - 🐛 [Report Issues](https://github.com/ni/sl-webapp-nipkg/issues)
513
+ - 💬 [Discussions](https://github.com/ni/sl-webapp-nipkg/discussions)
514
+
515
+ ---
516
+
517
+ *Made with ❤️ for the National Instruments community*
package/package.json CHANGED
@@ -1,77 +1,77 @@
1
- {
2
- "name": "@ni-kismet/sl-webapp-nipkg",
3
- "version": "0.1.0",
4
- "description": "Build tool for packaging web applications into SystemLink WebApp .nipkg format. Supports Node.js, Python, .NET Blazor, and static sites.",
5
- "type": "module",
6
- "exports": {
7
- "./package.json": "./package.json",
8
- ".": {
9
- "types": "./dist/esm/index.d.ts",
10
- "import": "./dist/esm/index.js"
11
- },
12
- "./*": {
13
- "types": "./dist/esm/*.d.ts",
14
- "import": "./dist/esm/*/index.js"
15
- }
16
- },
17
- "typesVersions": {
18
- "*": {
19
- "*": [
20
- "dist/esm/*",
21
- "dist/esm/*/index.d.ts"
22
- ]
23
- }
24
- },
25
- "bin": {
26
- "sl-webapp-nipkg": "dist/cli.js"
27
- },
28
- "scripts": {
29
- "build": "tsc",
30
- "dev": "tsc --watch",
31
- "lint": "eslint .",
32
- "lint:fix": "eslint . --fix",
33
- "change": "beachball change",
34
- "check": "beachball check --changehint \"Run 'npm run change' to generate a change file\"",
35
- "sync": "beachball sync",
36
- "invoke-publish": "beachball publish --yes --access public --message \"applying package updates [skip ci]\""
37
- },
38
- "keywords": [
39
- "systemlink",
40
- "nipkg",
41
- "national-instruments",
42
- "packaging",
43
- "webapp",
44
- "nodejs"
45
- ],
46
- "repository": {
47
- "type": "git",
48
- "url": "git+https://github.com/ni/sl-webapp-nipkg.git"
49
- },
50
- "publishConfig": {
51
- "access": "public"
52
- },
53
- "author": {
54
- "name": "National Instruments"
55
- },
56
- "license": "MIT",
57
- "bugs": {
58
- "url": "https://github.com/ni/sl-webapp-nipkg/issues"
59
- },
60
- "homepage": "https://github.com/ni/sl-webapp-nipkg#readme",
61
- "dependencies": {
62
- "chalk": "^5.6.2",
63
- "commander": "^14.0.3",
64
- "deboa": "^1.2.0",
65
- "fs-extra": "^11.3.3"
66
- },
67
- "devDependencies": {
68
- "@ni/eslint-config-javascript": "^5.1.4",
69
- "@ni/eslint-config-typescript": "^5.0.5",
70
- "@types/fs-extra": "^11.0.4",
71
- "@types/node": "^25.2.1",
72
- "beachball": "^2.63.0",
73
- "eslint": "^9.39.2",
74
- "eslint-plugin-tsdoc": "^0.5.0",
75
- "typescript": "^5.9.3"
76
- }
77
- }
1
+ {
2
+ "name": "@ni-kismet/sl-webapp-nipkg",
3
+ "version": "0.2.1",
4
+ "description": "Build tool for packaging web applications into SystemLink WebApp .nipkg format. Supports Node.js, Python, .NET Blazor, and static sites.",
5
+ "type": "module",
6
+ "exports": {
7
+ "./package.json": "./package.json",
8
+ ".": {
9
+ "types": "./dist/esm/index.d.ts",
10
+ "import": "./dist/esm/index.js"
11
+ },
12
+ "./*": {
13
+ "types": "./dist/esm/*.d.ts",
14
+ "import": "./dist/esm/*/index.js"
15
+ }
16
+ },
17
+ "typesVersions": {
18
+ "*": {
19
+ "*": [
20
+ "dist/esm/*",
21
+ "dist/esm/*/index.d.ts"
22
+ ]
23
+ }
24
+ },
25
+ "bin": {
26
+ "sl-webapp-nipkg": "dist/cli.js"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "lint": "eslint .",
32
+ "lint:fix": "eslint . --fix",
33
+ "change": "beachball change",
34
+ "check": "beachball check --changehint \"Run 'npm run change' to generate a change file\"",
35
+ "sync": "beachball sync",
36
+ "invoke-publish": "beachball publish --yes --access public --message \"applying package updates [skip ci]\""
37
+ },
38
+ "keywords": [
39
+ "systemlink",
40
+ "nipkg",
41
+ "national-instruments",
42
+ "packaging",
43
+ "webapp",
44
+ "nodejs"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/ni/sl-webapp-nipkg.git"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "author": {
54
+ "name": "National Instruments"
55
+ },
56
+ "license": "MIT",
57
+ "bugs": {
58
+ "url": "https://github.com/ni/sl-webapp-nipkg/issues"
59
+ },
60
+ "homepage": "https://github.com/ni/sl-webapp-nipkg#readme",
61
+ "dependencies": {
62
+ "chalk": "^5.6.2",
63
+ "commander": "^14.0.3",
64
+ "deboa": "^1.2.0",
65
+ "fs-extra": "^11.3.3"
66
+ },
67
+ "devDependencies": {
68
+ "@ni/eslint-config-javascript": "^5.1.4",
69
+ "@ni/eslint-config-typescript": "^5.0.5",
70
+ "@types/fs-extra": "^11.0.4",
71
+ "@types/node": "^25.3.0",
72
+ "beachball": "^2.63.0",
73
+ "eslint": "^9.39.3",
74
+ "eslint-plugin-tsdoc": "^0.5.0",
75
+ "typescript": "^5.9.3"
76
+ }
77
+ }