icaruspcb-cli 1.0.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/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/api/client.d.ts +66 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +94 -0
- package/dist/api/client.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +154 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +107 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +64 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +196 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +15 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/simulate.d.ts +3 -0
- package/dist/commands/simulate.d.ts.map +1 -0
- package/dist/commands/simulate.js +139 -0
- package/dist/commands/simulate.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +40 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +175 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +45 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config/store.d.ts +23 -0
- package/dist/config/store.d.ts.map +1 -0
- package/dist/config/store.js +98 -0
- package/dist/config/store.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/detect.d.ts +9 -0
- package/dist/utils/detect.d.ts.map +1 -0
- package/dist/utils/detect.js +152 -0
- package/dist/utils/detect.js.map +1 -0
- package/dist/utils/output.d.ts +8 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +41 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/spinner.d.ts +4 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +24 -0
- package/dist/utils/spinner.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 IcarusPCB
|
|
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
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# IcarusPCB CLI
|
|
2
|
+
|
|
3
|
+
Command-line tool for IcarusPCB — simulate, generate, and validate embedded hardware configurations using Renode.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g icaruspcb-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Authenticate
|
|
15
|
+
icaruspcb login
|
|
16
|
+
|
|
17
|
+
# Initialize a project
|
|
18
|
+
icaruspcb init
|
|
19
|
+
|
|
20
|
+
# Generate Renode scripts
|
|
21
|
+
icaruspcb generate --mcu STM32F407VG --sensors BME280,MPU6050
|
|
22
|
+
|
|
23
|
+
# Validate generated scripts
|
|
24
|
+
icaruspcb validate ./renode/stm32f407vg.repl
|
|
25
|
+
|
|
26
|
+
# Run a simulation
|
|
27
|
+
icaruspcb simulate --mcu STM32F407VG --firmware main.elf
|
|
28
|
+
|
|
29
|
+
# Check API status
|
|
30
|
+
icaruspcb status
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Commands
|
|
34
|
+
|
|
35
|
+
| Command | Description |
|
|
36
|
+
|---------|-------------|
|
|
37
|
+
| `icaruspcb init` | Interactive project setup — select MCU, sensors, create `.icaruspcb.json` |
|
|
38
|
+
| `icaruspcb simulate` | Submit simulation to API, poll for results |
|
|
39
|
+
| `icaruspcb generate` | Generate `.repl` and `.resc` Renode scripts |
|
|
40
|
+
| `icaruspcb validate <file>` | Offline validation of `.repl`/`.resc` files |
|
|
41
|
+
| `icaruspcb login` | Authenticate with API key |
|
|
42
|
+
| `icaruspcb status` | Check API health and usage |
|
|
43
|
+
| `icaruspcb list mcus` | List supported MCU families |
|
|
44
|
+
| `icaruspcb list sensors` | List supported sensors |
|
|
45
|
+
|
|
46
|
+
## Configuration
|
|
47
|
+
|
|
48
|
+
### API Key
|
|
49
|
+
|
|
50
|
+
Set via one of:
|
|
51
|
+
- `icaruspcb login` (saves to `~/.icaruspcb/config.json`)
|
|
52
|
+
- Environment variable: `ICARUSPCB_API_KEY`
|
|
53
|
+
|
|
54
|
+
### Project Config
|
|
55
|
+
|
|
56
|
+
Create `.icaruspcb.json` in your project root (or run `icaruspcb init`):
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"mcu": "STM32F407VG",
|
|
61
|
+
"sensors": ["BME280", "MPU6050"],
|
|
62
|
+
"firmware": "./build/main.elf",
|
|
63
|
+
"outputDir": "./renode"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Global Options
|
|
68
|
+
|
|
69
|
+
- `--json` — Machine-readable JSON output on all commands
|
|
70
|
+
- `--help` — Show help for any command
|
|
71
|
+
- `--version` — Show CLI version
|
|
72
|
+
|
|
73
|
+
## Development
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git clone <repo>
|
|
77
|
+
cd icaruspcb-cli
|
|
78
|
+
npm install
|
|
79
|
+
npm run build
|
|
80
|
+
npm link
|
|
81
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare class ApiError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
constructor(statusCode: number, message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class ApiClient {
|
|
6
|
+
private baseUrl;
|
|
7
|
+
private apiKey;
|
|
8
|
+
constructor();
|
|
9
|
+
private headers;
|
|
10
|
+
private request;
|
|
11
|
+
get<T>(path: string): Promise<T>;
|
|
12
|
+
post<T>(path: string, body: unknown): Promise<T>;
|
|
13
|
+
healthCheck(): Promise<{
|
|
14
|
+
status: string;
|
|
15
|
+
version?: string;
|
|
16
|
+
}>;
|
|
17
|
+
getUsage(): Promise<{
|
|
18
|
+
simulations: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
billingPeriod: string;
|
|
21
|
+
}>;
|
|
22
|
+
listMcus(): Promise<Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
family: string;
|
|
26
|
+
cores: number;
|
|
27
|
+
}>>;
|
|
28
|
+
listSensors(): Promise<Array<{
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
type: string;
|
|
32
|
+
interface: string;
|
|
33
|
+
}>>;
|
|
34
|
+
submitSimulation(params: {
|
|
35
|
+
mcu: string;
|
|
36
|
+
firmware?: string;
|
|
37
|
+
sensors?: string[];
|
|
38
|
+
replScript?: string;
|
|
39
|
+
rescScript?: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
jobId: string;
|
|
42
|
+
status: string;
|
|
43
|
+
}>;
|
|
44
|
+
getSimulationStatus(jobId: string): Promise<{
|
|
45
|
+
jobId: string;
|
|
46
|
+
status: 'queued' | 'running' | 'completed' | 'failed';
|
|
47
|
+
result?: unknown;
|
|
48
|
+
error?: string;
|
|
49
|
+
}>;
|
|
50
|
+
generateScripts(params: {
|
|
51
|
+
prompt: string;
|
|
52
|
+
mcuFamily: string;
|
|
53
|
+
mcu: string;
|
|
54
|
+
sensors: string[];
|
|
55
|
+
topologyId?: string;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
repl: string;
|
|
58
|
+
resc: string;
|
|
59
|
+
}>;
|
|
60
|
+
validateKey(): Promise<{
|
|
61
|
+
valid: boolean;
|
|
62
|
+
email?: string;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
export declare function createClient(): ApiClient;
|
|
66
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAGA,qBAAa,QAAS,SAAQ,KAAK;IACd,UAAU,EAAE,MAAM;gBAAlB,U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C,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAIxC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAChD,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;QACtD,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IAII,eAAe,CAAC,MAAM,EAAE;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAIrC,WAAW,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAGjE;AAED,wBAAgB,YAAY,IAAI,SAAS,CAExC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ApiClient = exports.ApiError = void 0;
|
|
7
|
+
exports.createClient = createClient;
|
|
8
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
|
+
const store_1 = require("../config/store");
|
|
10
|
+
class ApiError extends Error {
|
|
11
|
+
constructor(statusCode, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.statusCode = statusCode;
|
|
14
|
+
this.name = 'ApiError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ApiError = ApiError;
|
|
18
|
+
class ApiClient {
|
|
19
|
+
constructor() {
|
|
20
|
+
const key = (0, store_1.getApiKey)();
|
|
21
|
+
if (!key) {
|
|
22
|
+
throw new Error('No API key configured. Run `icaruspcb login` or set ICARUSPCB_API_KEY.');
|
|
23
|
+
}
|
|
24
|
+
this.apiKey = key;
|
|
25
|
+
this.baseUrl = (0, store_1.getServerUrl)();
|
|
26
|
+
}
|
|
27
|
+
headers() {
|
|
28
|
+
return {
|
|
29
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'User-Agent': `icaruspcb-cli/${require('../../package.json').version}`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async request(method, path, body) {
|
|
35
|
+
const url = `${this.baseUrl}/api/v1${path}`;
|
|
36
|
+
const res = await (0, node_fetch_1.default)(url, {
|
|
37
|
+
method,
|
|
38
|
+
headers: this.headers(),
|
|
39
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
40
|
+
});
|
|
41
|
+
if (!res.ok) {
|
|
42
|
+
const text = await res.text();
|
|
43
|
+
// Clean up raw HTML responses
|
|
44
|
+
const isHtml = text.trimStart().startsWith('<') || (res.headers.get('content-type') || '').includes('text/html');
|
|
45
|
+
const message = isHtml
|
|
46
|
+
? `API unavailable (HTTP ${res.status})`
|
|
47
|
+
: `API ${method} ${path} failed (${res.status}): ${text}`;
|
|
48
|
+
throw new ApiError(res.status, message);
|
|
49
|
+
}
|
|
50
|
+
const contentType = res.headers.get('content-type') || '';
|
|
51
|
+
if (!contentType.includes('application/json')) {
|
|
52
|
+
const text = await res.text();
|
|
53
|
+
if (text.trimStart().startsWith('<')) {
|
|
54
|
+
throw new ApiError(res.status, `API unavailable — unexpected HTML response`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return res.json();
|
|
58
|
+
}
|
|
59
|
+
async get(path) {
|
|
60
|
+
return this.request('GET', path);
|
|
61
|
+
}
|
|
62
|
+
async post(path, body) {
|
|
63
|
+
return this.request('POST', path, body);
|
|
64
|
+
}
|
|
65
|
+
async healthCheck() {
|
|
66
|
+
return this.get('/health');
|
|
67
|
+
}
|
|
68
|
+
async getUsage() {
|
|
69
|
+
return this.get('/usage');
|
|
70
|
+
}
|
|
71
|
+
async listMcus() {
|
|
72
|
+
return this.get('/mcus');
|
|
73
|
+
}
|
|
74
|
+
async listSensors() {
|
|
75
|
+
return this.get('/sensors');
|
|
76
|
+
}
|
|
77
|
+
async submitSimulation(params) {
|
|
78
|
+
return this.post('/simulations', params);
|
|
79
|
+
}
|
|
80
|
+
async getSimulationStatus(jobId) {
|
|
81
|
+
return this.get(`/simulations/${jobId}`);
|
|
82
|
+
}
|
|
83
|
+
async generateScripts(params) {
|
|
84
|
+
return this.post('/generate', params);
|
|
85
|
+
}
|
|
86
|
+
async validateKey() {
|
|
87
|
+
return this.get('/auth/validate');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ApiClient = ApiClient;
|
|
91
|
+
function createClient() {
|
|
92
|
+
return new ApiClient();
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;;;;AAmHA,oCAEC;AArHD,4DAA+B;AAC/B,2CAA0D;AAE1D,MAAa,QAAS,SAAQ,KAAK;IACjC,YAAmB,UAAkB,EAAE,OAAe;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,eAAU,GAAV,UAAU,CAAQ;QAEnC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AALD,4BAKC;AAED,MAAa,SAAS;IAIpB;QACE,MAAM,GAAG,GAAG,IAAA,iBAAS,GAAE,CAAC;QACxB,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;QAC5F,CAAC;QACD,IAAI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AMrC,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAMrB;QACC,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACpC,CAAC;CACF;AAvGD,8BAuGC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAI,SAAS,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+G9D"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.registerGenerateCommand = registerGenerateCommand;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
43
|
+
const client_1 = require("../api/client");
|
|
44
|
+
const store_1 = require("../config/store");
|
|
45
|
+
const output_1 = require("../utils/output");
|
|
46
|
+
const spinner_1 = require("../utils/spinner");
|
|
47
|
+
function registerGenerateCommand(program) {
|
|
48
|
+
program
|
|
49
|
+
.command('generate')
|
|
50
|
+
.description('Generate Renode .repl and .resc scripts')
|
|
51
|
+
.option('--prompt <prompt>', 'Generation prompt describing your requirements')
|
|
52
|
+
.option('--mcu-family <family>', 'MCU family (e.g., STM32F4, ESP32, nRF52)')
|
|
53
|
+
.option('--mcu <mcu>', 'MCU identifier')
|
|
54
|
+
.option('--sensors <list>', 'Comma-separated sensor list')
|
|
55
|
+
.option('--topology-id <id>', 'Topology ID for advanced routing')
|
|
56
|
+
.option('-o, --output <dir>', 'Output directory', './renode')
|
|
57
|
+
.option('--json', 'Output as JSON')
|
|
58
|
+
.action(async (opts) => {
|
|
59
|
+
try {
|
|
60
|
+
const project = (0, store_1.readProjectConfig)();
|
|
61
|
+
// Collect required parameters
|
|
62
|
+
let prompt = opts.prompt;
|
|
63
|
+
let mcuFamily = opts.mcuFamily;
|
|
64
|
+
let mcu = opts.mcu || project?.mcu;
|
|
65
|
+
let sensors = opts.sensors?.split(',') || project?.sensors || [];
|
|
66
|
+
const topologyId = opts.topologyId;
|
|
67
|
+
// Interactive prompts if missing required fields
|
|
68
|
+
if (!prompt || !mcuFamily || !mcu) {
|
|
69
|
+
if (opts.json) {
|
|
70
|
+
const missing = [];
|
|
71
|
+
if (!prompt)
|
|
72
|
+
missing.push('prompt');
|
|
73
|
+
if (!mcuFamily)
|
|
74
|
+
missing.push('mcu-family');
|
|
75
|
+
if (!mcu)
|
|
76
|
+
missing.push('mcu');
|
|
77
|
+
(0, output_1.printJsonError)(`Missing required parameters: ${missing.join(', ')}`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
const answers = await inquirer_1.default.prompt([
|
|
81
|
+
{
|
|
82
|
+
type: 'input',
|
|
83
|
+
name: 'prompt',
|
|
84
|
+
message: 'Describe what you want to generate:',
|
|
85
|
+
when: !prompt,
|
|
86
|
+
validate: (v) => v.trim().length > 0 || 'Prompt is required',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'list',
|
|
90
|
+
name: 'mcuFamily',
|
|
91
|
+
message: 'Select MCU family:',
|
|
92
|
+
when: !mcuFamily,
|
|
93
|
+
choices: ['STM32F4', 'STM32F1', 'STM32F7', 'STM32H7', 'STM32L4', 'ESP32', 'nRF52', 'ATSAMD', 'RP2040', 'Other'],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'input',
|
|
97
|
+
name: 'mcuFamilyCustom',
|
|
98
|
+
message: 'Enter MCU family:',
|
|
99
|
+
when: (a) => !mcuFamily && a.mcuFamily === 'Other',
|
|
100
|
+
validate: (v) => v.trim().length > 0 || 'MCU family is required',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'input',
|
|
104
|
+
name: 'mcu',
|
|
105
|
+
message: 'Enter MCU identifier:',
|
|
106
|
+
when: !mcu,
|
|
107
|
+
validate: (v) => v.trim().length > 0 || 'MCU identifier is required',
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
110
|
+
prompt = prompt || answers.prompt;
|
|
111
|
+
mcuFamily = mcuFamily || answers.mcuFamilyCustom || answers.mcuFamily;
|
|
112
|
+
mcu = mcu || answers.mcu;
|
|
113
|
+
}
|
|
114
|
+
const outputDir = opts.output || project?.outputDir || './renode';
|
|
115
|
+
const client = (0, client_1.createClient)();
|
|
116
|
+
const result = await (0, spinner_1.withSpinner)('Generating Renode scripts...', () => client.generateScripts({
|
|
117
|
+
prompt: prompt,
|
|
118
|
+
mcuFamily: mcuFamily,
|
|
119
|
+
mcu: mcu,
|
|
120
|
+
sensors,
|
|
121
|
+
topologyId
|
|
122
|
+
}));
|
|
123
|
+
if (opts.json) {
|
|
124
|
+
(0, output_1.printJson)(result);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// Write files
|
|
128
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
129
|
+
const replPath = path.join(outputDir, `${mcu.toLowerCase()}.repl`);
|
|
130
|
+
const rescPath = path.join(outputDir, `${mcu.toLowerCase()}.resc`);
|
|
131
|
+
fs.writeFileSync(replPath, result.repl);
|
|
132
|
+
fs.writeFileSync(rescPath, result.resc);
|
|
133
|
+
(0, output_1.printSuccess)(`Generated ${replPath}`);
|
|
134
|
+
(0, output_1.printSuccess)(`Generated ${rescPath}`);
|
|
135
|
+
(0, output_1.printInfo)(`Output directory: ${path.resolve(outputDir)}`);
|
|
136
|
+
(0, output_1.printInfo)(`Prompt: "${prompt}"`);
|
|
137
|
+
(0, output_1.printInfo)(`MCU Family: ${mcuFamily}`);
|
|
138
|
+
(0, output_1.printInfo)(`MCU: ${mcu}`);
|
|
139
|
+
if (sensors.length > 0) {
|
|
140
|
+
(0, output_1.printInfo)(`Sensors: ${sensors.join(', ')}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
if (opts.json) {
|
|
145
|
+
(0, output_1.printJsonError)(err.message);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
(0, output_1.printError)(err.message);
|
|
149
|
+
}
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,0DA+GC;AAxHD,uCAAyB;AACzB,2CAA6B;AAE7B,wDAAgC;AAChC,0CAA6C;AAC7C,2CAAoD;AACpD,4CAAiG;AACjG,8CAA+C;AAE/C,SAAgB,uBAAuB,CAAC,OAAgB;IACtD,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,mBAAmB,EAAE,gDAAgD,CAAC;SAC7E,MAAM,CAAC,uBAAuB,EAAE,0CAA0C,CAAC;SAC3E,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC;SACvC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC;SACzD,MAAM,CAAC,oBAAoB,EAAE,kCAAkC,CAAC;SAChE,MAAM,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,UAAU,CAAC;SAC5D,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAA,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AAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBAAC,IAAA,uBAAc,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAAC,CAAC;iBAAM,CAAC;gBAAC,IAAA,mBAAU,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAAC,CAAC;YACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkF1D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerInitCommand = registerInitCommand;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
const store_1 = require("../config/store");
|
|
9
|
+
const detect_1 = require("../utils/detect");
|
|
10
|
+
const output_1 = require("../utils/output");
|
|
11
|
+
const POPULAR_MCUS = [
|
|
12
|
+
'STM32F407VG', 'STM32F103C8', 'STM32F746ZG', 'STM32H743ZI', 'STM32L476RG',
|
|
13
|
+
'nRF52840', 'nRF52832', 'ESP32', 'ESP32-S3', 'RP2040',
|
|
14
|
+
'ATSAMD21G18', 'ATSAMD51J19', 'ATmega328P', 'LPC1768', 'EFR32MG12',
|
|
15
|
+
];
|
|
16
|
+
const POPULAR_SENSORS = [
|
|
17
|
+
'BME280', 'BMP280', 'BME680', 'SHT31', 'HDC1080',
|
|
18
|
+
'MPU6050', 'LSM6DSO', 'ADXL345', 'LIS3DH', 'BNO055',
|
|
19
|
+
'MAX30102', 'TSL2591', 'VEML7700', 'APDS9960',
|
|
20
|
+
'INA219', 'ADS1115', 'MCP3008',
|
|
21
|
+
'SI7021', 'DHT22', 'DS18B20',
|
|
22
|
+
'VL53L0X', 'HC-SR04',
|
|
23
|
+
'CCS811', 'SGP30', 'SCD30',
|
|
24
|
+
'NEO-6M', 'HMC5883L', 'QMC5883L',
|
|
25
|
+
'SD card (SPI)', 'W25Q128 (Flash)',
|
|
26
|
+
];
|
|
27
|
+
function registerInitCommand(program) {
|
|
28
|
+
program
|
|
29
|
+
.command('init')
|
|
30
|
+
.description('Initialize an IcarusPCB project configuration')
|
|
31
|
+
.option('--json', 'Output as JSON')
|
|
32
|
+
.action(async (opts) => {
|
|
33
|
+
try {
|
|
34
|
+
const detected = (0, detect_1.detectMcu)();
|
|
35
|
+
if (detected.mcu) {
|
|
36
|
+
(0, output_1.printInfo)(`Auto-detected MCU: ${detected.mcu} (from ${detected.source})`);
|
|
37
|
+
}
|
|
38
|
+
if (detected.ide) {
|
|
39
|
+
(0, output_1.printInfo)(`Detected IDE: ${detected.ide === 'vscode' ? 'VS Code' : 'STM32CubeIDE'} (${detected.ideWorkspace})`);
|
|
40
|
+
}
|
|
41
|
+
const answers = await inquirer_1.default.prompt([
|
|
42
|
+
{
|
|
43
|
+
type: 'list',
|
|
44
|
+
name: 'mcu',
|
|
45
|
+
message: 'Select your MCU:',
|
|
46
|
+
choices: [...POPULAR_MCUS, new inquirer_1.default.Separator(), 'Other (enter manually)'],
|
|
47
|
+
default: detected.mcu || 'STM32F407VG',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: 'input',
|
|
51
|
+
name: 'mcuCustom',
|
|
52
|
+
message: 'Enter MCU identifier:',
|
|
53
|
+
when: (a) => a.mcu === 'Other (enter manually)',
|
|
54
|
+
validate: (v) => v.length > 0 || 'MCU identifier required',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'checkbox',
|
|
58
|
+
name: 'sensors',
|
|
59
|
+
message: 'Select sensors to include:',
|
|
60
|
+
choices: POPULAR_SENSORS,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'input',
|
|
64
|
+
name: 'firmware',
|
|
65
|
+
message: 'Firmware file path (optional):',
|
|
66
|
+
default: '',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'input',
|
|
70
|
+
name: 'outputDir',
|
|
71
|
+
message: 'Output directory for generated scripts:',
|
|
72
|
+
default: './renode',
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
75
|
+
const config = {
|
|
76
|
+
mcu: answers.mcuCustom || answers.mcu,
|
|
77
|
+
sensors: answers.sensors,
|
|
78
|
+
firmware: answers.firmware || undefined,
|
|
79
|
+
outputDir: answers.outputDir,
|
|
80
|
+
};
|
|
81
|
+
(0, store_1.writeProjectConfig)(config);
|
|
82
|
+
if (opts.json) {
|
|
83
|
+
console.log(JSON.stringify(config, null, 2));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
(0, output_1.printSuccess)('Created .icaruspcb.json');
|
|
87
|
+
// Provide IDE-specific suggestions
|
|
88
|
+
if (detected.ide === 'vscode') {
|
|
89
|
+
(0, output_1.printInfo)('VS Code detected! Install the IcarusPCB extension for integrated features.');
|
|
90
|
+
(0, output_1.printInfo)('Run: code --install-extension icaruspcb.icaruspcb-vscode');
|
|
91
|
+
}
|
|
92
|
+
else if (detected.ide === 'stm32cubeide') {
|
|
93
|
+
(0, output_1.printInfo)('STM32CubeIDE detected! Consider using VS Code with IcarusPCB extension for enhanced features.');
|
|
94
|
+
}
|
|
95
|
+
(0, output_1.printInfo)('Next steps:');
|
|
96
|
+
(0, output_1.printInfo)(' 1. Run `icaruspcb login` to authenticate');
|
|
97
|
+
(0, output_1.printInfo)(' 2. Run `icaruspcb generate` to create Renode scripts');
|
|
98
|
+
(0, output_1.printInfo)(' 3. Run `icaruspcb simulate` to test your configuration');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
(0, output_1.printError)(err.message);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";;;;;AAwBA,kDAkFC;AAzGD,wDAAgC;AAChC,2CAAqD;AACrD,4CAA4C;AAC5C,4CAAsE;AAEtE,MAAM,YAAY,GAAG;IACnB,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa;IACzE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ;IACrD,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW;CACnE,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS;IAChD,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ;IACnD,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU;IAC7C,QAAQ,EAAE,SAAS,EAAE,SAAS;IAC9B,QAAQ,EAAE,OAAO,EAAE,SAAS;IAC5B,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,OAAO,EAAE,OAAO;IAC1B,QAAQ,EAAE,UAAU,EAAE,UAAU;IAChC,eAAe,EAAE,iBAAiB;CACnC,CAAC;AAEF,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,+CAA+C,CAAC;SAC5D,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE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AC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwD1D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerListCommand = registerListCommand;
|
|
4
|
+
const client_1 = require("../api/client");
|
|
5
|
+
const output_1 = require("../utils/output");
|
|
6
|
+
const spinner_1 = require("../utils/spinner");
|
|
7
|
+
function registerListCommand(program) {
|
|
8
|
+
const list = program
|
|
9
|
+
.command('list')
|
|
10
|
+
.description('List supported hardware')
|
|
11
|
+
.action(() => {
|
|
12
|
+
list.outputHelp();
|
|
13
|
+
process.exit(0);
|
|
14
|
+
});
|
|
15
|
+
list
|
|
16
|
+
.command('mcus')
|
|
17
|
+
.description('List supported MCU families')
|
|
18
|
+
.option('--json', 'Output as JSON')
|
|
19
|
+
.action(async (opts) => {
|
|
20
|
+
try {
|
|
21
|
+
const client = (0, client_1.createClient)();
|
|
22
|
+
const mcus = await (0, spinner_1.withSpinner)('Fetching MCU list...', () => client.listMcus());
|
|
23
|
+
if (opts.json) {
|
|
24
|
+
(0, output_1.printJson)(mcus);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
(0, output_1.printTable)(['ID', 'Name', 'Family', 'Cores'], mcus.map(m => [m.id, m.name, m.family, String(m.cores)]));
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (opts.json) {
|
|
31
|
+
(0, output_1.printJsonError)(err.message);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
(0, output_1.printError)(err.message);
|
|
35
|
+
}
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
list
|
|
40
|
+
.command('sensors')
|
|
41
|
+
.description('List supported sensors')
|
|
42
|
+
.option('--json', 'Output as JSON')
|
|
43
|
+
.action(async (opts) => {
|
|
44
|
+
try {
|
|
45
|
+
const client = (0, client_1.createClient)();
|
|
46
|
+
const sensors = await (0, spinner_1.withSpinner)('Fetching sensor list...', () => client.listSensors());
|
|
47
|
+
if (opts.json) {
|
|
48
|
+
(0, output_1.printJson)(sensors);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
(0, output_1.printTable)(['ID', 'Name', 'Type', 'Interface'], sensors.map(s => [s.id, s.name, s.type, s.interface]));
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
if (opts.json) {
|
|
55
|
+
(0, output_1.printJsonError)(err.message);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(0, output_1.printError)(err.message);
|
|
59
|
+
}
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";;AAKA,kDAwDC;AA5DD,0CAA6C;AAC7C,4CAAoF;AACpF,8CAA+C;AAE/C,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,MAAM,IAAI,GAAG,OAAO;SACjB,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,yBAAyB,CAAC;SACtC,MAAM,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEL,IAAI;SACD,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MA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