espcli 0.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +183 -0
  3. package/dist/index.js +185 -0
  4. package/package.json +50 -0
  5. package/src/core/constants.ts +107 -0
  6. package/src/core/emitter.ts +48 -0
  7. package/src/core/operations/build.ts +70 -0
  8. package/src/core/operations/clean.ts +42 -0
  9. package/src/core/operations/devices.ts +11 -0
  10. package/src/core/operations/flash.ts +49 -0
  11. package/src/core/operations/init.ts +39 -0
  12. package/src/core/operations/install.ts +99 -0
  13. package/src/core/operations/monitor.ts +67 -0
  14. package/src/core/services/health.ts +214 -0
  15. package/src/core/services/idf.ts +98 -0
  16. package/src/core/services/ports.ts +172 -0
  17. package/src/core/services/process.ts +144 -0
  18. package/src/core/services/shell.ts +74 -0
  19. package/src/core/templates/files.ts +78 -0
  20. package/src/core/templates/index.ts +52 -0
  21. package/src/core/types.ts +128 -0
  22. package/src/index.ts +5 -0
  23. package/src/serve.ts +8 -0
  24. package/src/server/index.ts +105 -0
  25. package/src/server/routes.ts +175 -0
  26. package/src/server/schema.ts +81 -0
  27. package/src/tui/commands/build.ts +48 -0
  28. package/src/tui/commands/clean.ts +36 -0
  29. package/src/tui/commands/devices.ts +18 -0
  30. package/src/tui/commands/doctor.ts +70 -0
  31. package/src/tui/commands/flash.ts +61 -0
  32. package/src/tui/commands/init.ts +59 -0
  33. package/src/tui/commands/install.ts +89 -0
  34. package/src/tui/commands/monitor.ts +63 -0
  35. package/src/tui/commands/run.ts +99 -0
  36. package/src/tui/display.ts +96 -0
  37. package/src/tui/index.ts +96 -0
  38. package/src/tui/logger.ts +35 -0
  39. package/src/tui/prompts.ts +99 -0
@@ -0,0 +1,35 @@
1
+ import pc from 'picocolors';
2
+
3
+ export function info(message: string): void {
4
+ console.log(pc.blue('ℹ'), message);
5
+ }
6
+
7
+ export function success(message: string): void {
8
+ console.log(pc.green('✔'), message);
9
+ }
10
+
11
+ export function warn(message: string): void {
12
+ console.log(pc.yellow('⚠'), message);
13
+ }
14
+
15
+ export function error(message: string): void {
16
+ console.log(pc.red('✖'), message);
17
+ }
18
+
19
+ export function step(message: string): void {
20
+ console.log(pc.cyan('→'), message);
21
+ }
22
+
23
+ export function dim(message: string): void {
24
+ console.log(pc.dim(message));
25
+ }
26
+
27
+ export function output(text: string): void {
28
+ process.stdout.write(text);
29
+ }
30
+
31
+ export function newline(): void {
32
+ console.log();
33
+ }
34
+
35
+ export const logger = { info, success, warn, error, step, dim, output, newline };
@@ -0,0 +1,99 @@
1
+ import * as p from '@clack/prompts';
2
+ import pc from 'picocolors';
3
+ import type { SerialDevice } from '@/core/types';
4
+ import { ESP_TARGETS } from '@/core/constants';
5
+
6
+ export async function confirm(message: string, initial = true): Promise<boolean> {
7
+ const result = await p.confirm({ message, initialValue: initial });
8
+ if (p.isCancel(result)) {
9
+ p.cancel('Operation cancelled');
10
+ process.exit(0);
11
+ }
12
+ return result;
13
+ }
14
+
15
+ export async function text(message: string, placeholder?: string, initial?: string): Promise<string> {
16
+ const result = await p.text({
17
+ message,
18
+ placeholder,
19
+ initialValue: initial,
20
+ });
21
+ if (p.isCancel(result)) {
22
+ p.cancel('Operation cancelled');
23
+ process.exit(0);
24
+ }
25
+ return result;
26
+ }
27
+
28
+ export async function select<T extends string>(
29
+ message: string,
30
+ options: { value: T; label: string; hint?: string }[]
31
+ ): Promise<T> {
32
+ const mappedOptions = options.map((o) => ({
33
+ value: o.value,
34
+ label: o.label,
35
+ ...(o.hint && { hint: o.hint }),
36
+ }));
37
+
38
+ const result = await p.select({ message, options: mappedOptions as Parameters<typeof p.select>[0]['options'] });
39
+
40
+ if (p.isCancel(result)) {
41
+ p.cancel('Operation cancelled');
42
+ process.exit(0);
43
+ }
44
+ return result as T;
45
+ }
46
+
47
+ export async function selectTarget(): Promise<string> {
48
+ return select(
49
+ 'Select target chip',
50
+ ESP_TARGETS.map((t) => ({
51
+ value: t.id,
52
+ label: t.name,
53
+ hint: t.description + (t.stable ? '' : ' (preview)'),
54
+ }))
55
+ );
56
+ }
57
+
58
+ export async function selectLanguage(): Promise<'c' | 'cpp'> {
59
+ return select('Select language', [
60
+ { value: 'c' as const, label: 'C', hint: 'Standard C project' },
61
+ { value: 'cpp' as const, label: 'C++', hint: 'C++ with extern "C" linkage' },
62
+ ]);
63
+ }
64
+
65
+ export async function selectDevice(devices: SerialDevice[]): Promise<string> {
66
+ if (devices.length === 0) {
67
+ p.cancel('No devices found');
68
+ process.exit(1);
69
+ }
70
+
71
+ return select(
72
+ 'Select device',
73
+ devices.map((d) => ({
74
+ value: d.port,
75
+ label: d.port,
76
+ hint: d.chip || d.manufacturer,
77
+ }))
78
+ );
79
+ }
80
+
81
+ export function spinner() {
82
+ return p.spinner();
83
+ }
84
+
85
+ export function intro(title: string): void {
86
+ p.intro(pc.inverse(` ${title} `));
87
+ }
88
+
89
+ export function outro(message: string): void {
90
+ p.outro(message);
91
+ }
92
+
93
+ export function cancel(message: string): void {
94
+ p.cancel(message);
95
+ }
96
+
97
+ export function note(message: string, title?: string): void {
98
+ p.note(message, title);
99
+ }