@y4wee/nupo 0.1.0

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 (63) hide show
  1. package/dist/App.d.ts +8 -0
  2. package/dist/App.js +109 -0
  3. package/dist/__tests__/checks.test.d.ts +1 -0
  4. package/dist/__tests__/checks.test.js +68 -0
  5. package/dist/__tests__/config.test.d.ts +1 -0
  6. package/dist/__tests__/config.test.js +61 -0
  7. package/dist/components/ConfirmExit.d.ts +9 -0
  8. package/dist/components/ConfirmExit.js +12 -0
  9. package/dist/components/ErrorPanel.d.ts +7 -0
  10. package/dist/components/ErrorPanel.js +12 -0
  11. package/dist/components/Header.d.ts +10 -0
  12. package/dist/components/Header.js +17 -0
  13. package/dist/components/LeftPanel.d.ts +9 -0
  14. package/dist/components/LeftPanel.js +31 -0
  15. package/dist/components/OptionsPanel.d.ts +11 -0
  16. package/dist/components/OptionsPanel.js +18 -0
  17. package/dist/components/PathInput.d.ts +10 -0
  18. package/dist/components/PathInput.js +133 -0
  19. package/dist/components/ProgressBar.d.ts +5 -0
  20. package/dist/components/ProgressBar.js +21 -0
  21. package/dist/components/StepsPanel.d.ts +8 -0
  22. package/dist/components/StepsPanel.js +24 -0
  23. package/dist/hooks/useConfig.d.ts +8 -0
  24. package/dist/hooks/useConfig.js +26 -0
  25. package/dist/hooks/useTerminalSize.d.ts +4 -0
  26. package/dist/hooks/useTerminalSize.js +18 -0
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.js +169 -0
  29. package/dist/screens/ConfigScreen.d.ts +10 -0
  30. package/dist/screens/ConfigScreen.js +182 -0
  31. package/dist/screens/ConfigureServiceScreen.d.ts +11 -0
  32. package/dist/screens/ConfigureServiceScreen.js +499 -0
  33. package/dist/screens/HomeScreen.d.ts +14 -0
  34. package/dist/screens/HomeScreen.js +24 -0
  35. package/dist/screens/IdeScreen.d.ts +9 -0
  36. package/dist/screens/IdeScreen.js +101 -0
  37. package/dist/screens/InitScreen.d.ts +9 -0
  38. package/dist/screens/InitScreen.js +182 -0
  39. package/dist/screens/InstallVersionScreen.d.ts +10 -0
  40. package/dist/screens/InstallVersionScreen.js +495 -0
  41. package/dist/screens/OdooScreen.d.ts +13 -0
  42. package/dist/screens/OdooScreen.js +76 -0
  43. package/dist/screens/OdooServiceScreen.d.ts +10 -0
  44. package/dist/screens/OdooServiceScreen.js +51 -0
  45. package/dist/screens/StartServiceScreen.d.ts +12 -0
  46. package/dist/screens/StartServiceScreen.js +386 -0
  47. package/dist/screens/UpgradeVersionScreen.d.ts +9 -0
  48. package/dist/screens/UpgradeVersionScreen.js +259 -0
  49. package/dist/services/checks.d.ts +8 -0
  50. package/dist/services/checks.js +48 -0
  51. package/dist/services/config.d.ts +11 -0
  52. package/dist/services/config.js +146 -0
  53. package/dist/services/git.d.ts +35 -0
  54. package/dist/services/git.js +173 -0
  55. package/dist/services/ide.d.ts +10 -0
  56. package/dist/services/ide.js +126 -0
  57. package/dist/services/python.d.ts +14 -0
  58. package/dist/services/python.js +81 -0
  59. package/dist/services/system.d.ts +2 -0
  60. package/dist/services/system.js +22 -0
  61. package/dist/types/index.d.ts +82 -0
  62. package/dist/types/index.js +26 -0
  63. package/package.json +37 -0
@@ -0,0 +1,182 @@
1
+ import React, { useReducer, useEffect, useState, useCallback, useRef } from 'react';
2
+ import { Box, Text } from 'ink';
3
+ import { PathInput } from '../components/PathInput.js';
4
+ import { access } from 'fs/promises';
5
+ import { getPrimaryColor, getSecondaryColor, getTextColor } from '../types/index.js';
6
+ import { checkPython, checkPip, checkVenv } from '../services/checks.js';
7
+ import { patchConfig } from '../services/config.js';
8
+ import { LeftPanel } from '../components/LeftPanel.js';
9
+ import { StepsPanel } from '../components/StepsPanel.js';
10
+ import { ErrorPanel } from '../components/ErrorPanel.js';
11
+ function stepsReducer(state, action) {
12
+ switch (action.type) {
13
+ case 'INIT':
14
+ return action.steps;
15
+ case 'SET_STATUS':
16
+ return state.map(s => s.id === action.id ? { ...s, status: action.status, errorMessage: action.errorMessage } : s);
17
+ default:
18
+ return state;
19
+ }
20
+ }
21
+ const STEP_DEFS = [
22
+ { id: 'python', label: 'Vérification de Python' },
23
+ { id: 'pip', label: 'Vérification de pip' },
24
+ { id: 'venv', label: 'Vérification de python venv' },
25
+ { id: 'odoo_path', label: 'Chemin du dépôt Odoo' },
26
+ ];
27
+ function findStartIndex(config) {
28
+ if (!config)
29
+ return 0;
30
+ if (!config.python_installed)
31
+ return 0;
32
+ if (!config.pip_installed)
33
+ return 1;
34
+ if (!config.venv_installed)
35
+ return 2;
36
+ if (!config.odoo_path_repo)
37
+ return 3;
38
+ return 4;
39
+ }
40
+ function buildInitialSteps(startIndex) {
41
+ return STEP_DEFS.map((def, i) => ({
42
+ ...def,
43
+ status: (i < startIndex ? 'success' : 'pending'),
44
+ }));
45
+ }
46
+ export function InitScreen({ config, leftWidth, onComplete }) {
47
+ const textColor = getTextColor(config);
48
+ const startIndex = findStartIndex(config);
49
+ const [steps, dispatch] = useReducer(stepsReducer, buildInitialSteps(startIndex));
50
+ const [currentStepIndex, setCurrentStepIndex] = useState(startIndex);
51
+ const [odooPath, setOdooPath] = useState('');
52
+ const [waitingInput, setWaitingInput] = useState(false);
53
+ const [done, setDone] = useState(startIndex >= 4);
54
+ const dispatchRef = useRef(dispatch);
55
+ dispatchRef.current = dispatch;
56
+ const onCompleteRef = useRef(onComplete);
57
+ onCompleteRef.current = onComplete;
58
+ const runPython = useCallback(async () => {
59
+ dispatchRef.current({ type: 'SET_STATUS', id: 'python', status: 'running' });
60
+ const result = await checkPython();
61
+ if (result.ok) {
62
+ dispatchRef.current({
63
+ type: 'SET_STATUS',
64
+ id: 'python',
65
+ status: 'success',
66
+ errorMessage: result.version,
67
+ });
68
+ await patchConfig({ python_installed: true });
69
+ setCurrentStepIndex(1);
70
+ }
71
+ else {
72
+ dispatchRef.current({
73
+ type: 'SET_STATUS',
74
+ id: 'python',
75
+ status: 'error',
76
+ errorMessage: result.error,
77
+ });
78
+ }
79
+ }, []);
80
+ const runPip = useCallback(async () => {
81
+ dispatchRef.current({ type: 'SET_STATUS', id: 'pip', status: 'running' });
82
+ const result = await checkPip();
83
+ if (result.ok) {
84
+ dispatchRef.current({
85
+ type: 'SET_STATUS',
86
+ id: 'pip',
87
+ status: 'success',
88
+ errorMessage: result.version,
89
+ });
90
+ await patchConfig({ pip_installed: true });
91
+ setCurrentStepIndex(2);
92
+ }
93
+ else {
94
+ dispatchRef.current({
95
+ type: 'SET_STATUS',
96
+ id: 'pip',
97
+ status: 'error',
98
+ errorMessage: result.error,
99
+ });
100
+ }
101
+ }, []);
102
+ const runVenv = useCallback(async () => {
103
+ dispatchRef.current({ type: 'SET_STATUS', id: 'venv', status: 'running' });
104
+ const result = await checkVenv();
105
+ if (result.ok) {
106
+ dispatchRef.current({ type: 'SET_STATUS', id: 'venv', status: 'success', errorMessage: 'disponible' });
107
+ await patchConfig({ venv_installed: true });
108
+ setCurrentStepIndex(3);
109
+ }
110
+ else {
111
+ dispatchRef.current({ type: 'SET_STATUS', id: 'venv', status: 'error', errorMessage: result.error });
112
+ }
113
+ }, []);
114
+ const runOdooPath = useCallback(async (inputPath) => {
115
+ const resolvedPath = inputPath.trim() || process.cwd();
116
+ setWaitingInput(false);
117
+ try {
118
+ await access(resolvedPath);
119
+ dispatchRef.current({
120
+ type: 'SET_STATUS',
121
+ id: 'odoo_path',
122
+ status: 'success',
123
+ errorMessage: resolvedPath,
124
+ });
125
+ await patchConfig({ odoo_path_repo: resolvedPath, initiated: true });
126
+ setCurrentStepIndex(4);
127
+ setDone(true);
128
+ }
129
+ catch {
130
+ dispatchRef.current({
131
+ type: 'SET_STATUS',
132
+ id: 'odoo_path',
133
+ status: 'error',
134
+ errorMessage: `Chemin introuvable : ${resolvedPath}`,
135
+ });
136
+ setWaitingInput(true);
137
+ }
138
+ }, []);
139
+ // Trigger auto steps or input prompt based on current step
140
+ useEffect(() => {
141
+ if (currentStepIndex === 0) {
142
+ void runPython();
143
+ }
144
+ else if (currentStepIndex === 1) {
145
+ void runPip();
146
+ }
147
+ else if (currentStepIndex === 2) {
148
+ void runVenv();
149
+ }
150
+ else if (currentStepIndex === 3) {
151
+ dispatchRef.current({ type: 'SET_STATUS', id: 'odoo_path', status: 'running' });
152
+ setWaitingInput(true);
153
+ }
154
+ }, [currentStepIndex, runPython, runPip, runVenv]);
155
+ // Call onComplete once all steps are done
156
+ useEffect(() => {
157
+ if (!done)
158
+ return;
159
+ onCompleteRef.current();
160
+ }, [done]);
161
+ const errorStep = steps.find(s => s.status === 'error');
162
+ return (React.createElement(Box, { flexDirection: "column", flexGrow: 1 },
163
+ React.createElement(Box, { flexDirection: "row", flexGrow: 1 },
164
+ React.createElement(LeftPanel, { width: leftWidth, primaryColor: getPrimaryColor(config), textColor: textColor }),
165
+ React.createElement(Box, { flexGrow: 1, flexDirection: "column", paddingX: 3, paddingY: 2, gap: 1 },
166
+ React.createElement(Text, { color: getSecondaryColor(config), bold: true }, "Initialisation"),
167
+ waitingInput && !errorStep && (React.createElement(Box, { flexDirection: "column", gap: 1, marginTop: 1 },
168
+ React.createElement(Text, { color: "white" }, "Chemin vers le d\u00E9p\u00F4t Odoo :"),
169
+ React.createElement(Box, null,
170
+ React.createElement(Text, { color: textColor, dimColor: true }, '› '),
171
+ React.createElement(PathInput, { value: odooPath, onChange: setOdooPath, onSubmit: val => void runOdooPath(val), placeholder: process.cwd(), textColor: textColor })),
172
+ React.createElement(Text, { color: textColor, dimColor: true }, "Appuyez sur Entr\u00E9e pour utiliser le r\u00E9pertoire courant"))),
173
+ errorStep && (React.createElement(Box, { flexDirection: "column", gap: 1, marginTop: 1 },
174
+ React.createElement(Text, { color: "red" },
175
+ "\u00C9tape \u00E9chou\u00E9e : ",
176
+ errorStep.label),
177
+ React.createElement(Text, { color: textColor }, "Corrigez l'erreur et relancez nupo."))),
178
+ !waitingInput && !errorStep && !done && (React.createElement(Box, { marginTop: 1 },
179
+ React.createElement(Text, { color: textColor, dimColor: true }, "\u27F3 V\u00E9rification en cours\u2026"))))),
180
+ React.createElement(StepsPanel, { steps: steps, textColor: textColor }),
181
+ React.createElement(ErrorPanel, { steps: steps })));
182
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { NupoConfig } from '../types/index.js';
3
+ interface InstallVersionScreenProps {
4
+ config: NupoConfig;
5
+ leftWidth: number;
6
+ onComplete: () => void;
7
+ onBack: () => void;
8
+ }
9
+ export declare function InstallVersionScreen({ config, leftWidth, onComplete, onBack, }: InstallVersionScreenProps): React.JSX.Element;
10
+ export {};