sitevision-cli 0.1.0 → 0.1.2
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/dist/utils/webpack-runner.d.ts +1 -9
- package/dist/utils/webpack-runner.js +1 -28
- package/package.json +2 -2
- package/readme.md +8 -65
|
@@ -4,16 +4,8 @@
|
|
|
4
4
|
* Handles webpack compilation for Sitevision apps.
|
|
5
5
|
* Dynamically loads webpack from the target project's node_modules.
|
|
6
6
|
*/
|
|
7
|
-
import { EventEmitter } from 'events';
|
|
8
7
|
import type { BuildOptions, BuildResult } from '../types/index.js';
|
|
9
|
-
|
|
10
|
-
* Events emitted by WebpackRunner:
|
|
11
|
-
* - 'compile': Emitted when compilation starts
|
|
12
|
-
* - 'done': Emitted when compilation completes successfully
|
|
13
|
-
* - 'error': Emitted when compilation fails
|
|
14
|
-
* - 'warning': Emitted when compilation has warnings
|
|
15
|
-
*/
|
|
16
|
-
export declare class WebpackRunner extends EventEmitter {
|
|
8
|
+
export declare class WebpackRunner {
|
|
17
9
|
private projectRoot;
|
|
18
10
|
private options;
|
|
19
11
|
private webpack;
|
|
@@ -7,21 +7,12 @@
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import fs from 'fs';
|
|
9
9
|
import { createRequire } from 'module';
|
|
10
|
-
import { EventEmitter } from 'events';
|
|
11
10
|
import { copyChunksToResources } from './zip.js';
|
|
12
11
|
// =============================================================================
|
|
13
12
|
// WEBPACK RUNNER CLASS
|
|
14
13
|
// =============================================================================
|
|
15
|
-
|
|
16
|
-
* Events emitted by WebpackRunner:
|
|
17
|
-
* - 'compile': Emitted when compilation starts
|
|
18
|
-
* - 'done': Emitted when compilation completes successfully
|
|
19
|
-
* - 'error': Emitted when compilation fails
|
|
20
|
-
* - 'warning': Emitted when compilation has warnings
|
|
21
|
-
*/
|
|
22
|
-
export class WebpackRunner extends EventEmitter {
|
|
14
|
+
export class WebpackRunner {
|
|
23
15
|
constructor(projectRoot, options) {
|
|
24
|
-
super();
|
|
25
16
|
Object.defineProperty(this, "projectRoot", {
|
|
26
17
|
enumerable: true,
|
|
27
18
|
configurable: true,
|
|
@@ -151,17 +142,14 @@ export class WebpackRunner extends EventEmitter {
|
|
|
151
142
|
throw new Error('Webpack not initialized');
|
|
152
143
|
}
|
|
153
144
|
return new Promise((resolve, reject) => {
|
|
154
|
-
this.emit('compile');
|
|
155
145
|
this.compiler = this.webpack(this.config);
|
|
156
146
|
this.compiler.run((err, stats) => {
|
|
157
147
|
if (err) {
|
|
158
|
-
this.emit('error', err);
|
|
159
148
|
reject(err);
|
|
160
149
|
return;
|
|
161
150
|
}
|
|
162
151
|
if (!stats) {
|
|
163
152
|
const error = new Error('No stats returned from webpack');
|
|
164
|
-
this.emit('error', error);
|
|
165
153
|
reject(error);
|
|
166
154
|
return;
|
|
167
155
|
}
|
|
@@ -176,13 +164,6 @@ export class WebpackRunner extends EventEmitter {
|
|
|
176
164
|
console.warn('Warning: Failed to copy chunks:', chunkError);
|
|
177
165
|
}
|
|
178
166
|
}
|
|
179
|
-
if (stats.hasErrors()) {
|
|
180
|
-
this.emit('error', new Error(stats.toString({ colors: false })));
|
|
181
|
-
}
|
|
182
|
-
else if (stats.hasWarnings()) {
|
|
183
|
-
this.emit('warning', stats.toString({ colors: false }));
|
|
184
|
-
}
|
|
185
|
-
this.emit('done', result);
|
|
186
167
|
resolve(result);
|
|
187
168
|
});
|
|
188
169
|
});
|
|
@@ -204,7 +185,6 @@ export class WebpackRunner extends EventEmitter {
|
|
|
204
185
|
ignored: ['**/dist/**', '**/build/**', '**/node_modules/**'],
|
|
205
186
|
}, (err, stats) => {
|
|
206
187
|
if (err) {
|
|
207
|
-
this.emit('error', err);
|
|
208
188
|
callback?.({
|
|
209
189
|
success: false,
|
|
210
190
|
errors: [err.message],
|
|
@@ -224,13 +204,6 @@ export class WebpackRunner extends EventEmitter {
|
|
|
224
204
|
console.warn('Warning: Failed to copy chunks:', chunkError);
|
|
225
205
|
}
|
|
226
206
|
}
|
|
227
|
-
if (stats.hasErrors()) {
|
|
228
|
-
this.emit('error', new Error(stats.toString({ colors: false })));
|
|
229
|
-
}
|
|
230
|
-
else if (stats.hasWarnings()) {
|
|
231
|
-
this.emit('warning', stats.toString({ colors: false }));
|
|
232
|
-
}
|
|
233
|
-
this.emit('done', result);
|
|
234
207
|
callback?.(result);
|
|
235
208
|
});
|
|
236
209
|
// Resolve immediately - watch continues in background
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -10,9 +10,6 @@ However, these scripts have some limitations:
|
|
|
10
10
|
|
|
11
11
|
- **Interactive Menu** - Full-screen TUI with arrow key navigation
|
|
12
12
|
- **Project Detection** - Automatically detects Sitevision projects
|
|
13
|
-
- **Webpack Integration** - Built-in webpack bundling for development and production
|
|
14
|
-
- **App Signing** - Sign apps via developer.sitevision.se for production deployment
|
|
15
|
-
- **Live Feedback** - Real-time status updates and progress indicators
|
|
16
13
|
- **Two Modes** - Interactive menu OR direct command execution
|
|
17
14
|
- **Automatic Setup** - Guided setup for dev properties and signing credentials
|
|
18
15
|
- **Secure Credentials** - Passwords can be entered per-session (not stored on disk)
|
|
@@ -20,7 +17,7 @@ However, these scripts have some limitations:
|
|
|
20
17
|
## Install
|
|
21
18
|
|
|
22
19
|
```bash
|
|
23
|
-
npm install --global
|
|
20
|
+
npm install --global sitevision-cli
|
|
24
21
|
```
|
|
25
22
|
|
|
26
23
|
## Usage
|
|
@@ -38,17 +35,18 @@ svc
|
|
|
38
35
|
On first run (or if setup is incomplete), the CLI will:
|
|
39
36
|
1. Check if `node_modules` exists and offer to run `npm install` if missing
|
|
40
37
|
2. Check if dev properties are configured and offer to set them up if missing
|
|
41
|
-
3.
|
|
42
|
-
4.
|
|
38
|
+
3. Check if you have setup signing credentials and offer to do so if missing
|
|
39
|
+
4. Display project information
|
|
40
|
+
5. Show the main menu
|
|
43
41
|
|
|
44
42
|
Use arrow keys to navigate and Enter to select:
|
|
45
43
|
- **Dev** - Start development server with watch mode
|
|
46
44
|
- **Dev (Signed)** - Development with automatic signing before each deploy
|
|
47
|
-
- **Build** - Build
|
|
48
|
-
- **Sign** - Sign
|
|
49
|
-
- **Deploy** - Deploy to
|
|
45
|
+
- **Build** - Build a dist bundle
|
|
46
|
+
- **Sign** - Sign built dist bundle
|
|
47
|
+
- **Deploy** - Deploy to configured development environment
|
|
50
48
|
- **Deploy (Force)** - Force deploy (overwrite existing)
|
|
51
|
-
- **Deploy Production** - Deploy signed app to production
|
|
49
|
+
- **Deploy Production** - Deploy signed app to configured production environment
|
|
52
50
|
- **Info** - Show project info
|
|
53
51
|
- **Exit**
|
|
54
52
|
|
|
@@ -136,61 +134,6 @@ Signing credentials are used to sign apps via developer.sitevision.se:
|
|
|
136
134
|
|
|
137
135
|
The signing password is never stored on disk - it's prompted for each session.
|
|
138
136
|
|
|
139
|
-
## Architecture
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
### Directory Structure
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
source/
|
|
149
|
-
├── cli.tsx # CLI entry point and argument parsing
|
|
150
|
-
├── app.tsx # Main app component and state management
|
|
151
|
-
├── commands/ # Command implementations
|
|
152
|
-
│ ├── types.ts # Command type definitions
|
|
153
|
-
│ ├── index.ts # Command exports
|
|
154
|
-
│ ├── dev.tsx # Development server with watch mode
|
|
155
|
-
│ ├── build.tsx # Production build
|
|
156
|
-
│ ├── deploy.tsx # Deployment to dev/production
|
|
157
|
-
│ ├── sign.tsx # App signing
|
|
158
|
-
│ ├── setup-signing.tsx # Signing credentials setup
|
|
159
|
-
│ └── info.tsx # Project info display
|
|
160
|
-
├── components/ # Reusable UI components
|
|
161
|
-
│ ├── MainMenu.tsx # Interactive main menu
|
|
162
|
-
│ ├── SetupFlow.tsx # Initial setup wizard
|
|
163
|
-
│ ├── DevPropertiesForm.tsx # Dev properties configuration
|
|
164
|
-
│ ├── SigningPropertiesForm.tsx # Signing setup form
|
|
165
|
-
│ ├── PasswordInput.tsx # Secure password input
|
|
166
|
-
│ ├── TextInput.tsx # Text input component
|
|
167
|
-
│ ├── InfoScreen.tsx # Project info display
|
|
168
|
-
│ ├── StatusIndicator.tsx # Status/progress indicator
|
|
169
|
-
│ └── ProcessOutput.tsx # Process output display
|
|
170
|
-
├── types/ # TypeScript type definitions
|
|
171
|
-
│ └── index.ts # Shared types
|
|
172
|
-
└── utils/ # Utility modules
|
|
173
|
-
├── project-detection.ts # Project validation and paths
|
|
174
|
-
├── sitevision-api.ts # Sitevision REST API client
|
|
175
|
-
├── webpack-runner.ts # Webpack integration
|
|
176
|
-
├── zip.ts # Zip file utilities
|
|
177
|
-
├── process-runner.ts # Process spawning
|
|
178
|
-
└── password-prompt.ts # Password prompting
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Development
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
# Install dependencies
|
|
185
|
-
npm install
|
|
186
|
-
|
|
187
|
-
# Build
|
|
188
|
-
npm run build
|
|
189
|
-
|
|
190
|
-
# Watch mode
|
|
191
|
-
npm run dev
|
|
192
|
-
```
|
|
193
|
-
|
|
194
137
|
## License
|
|
195
138
|
|
|
196
139
|
MIT
|