@t1mmen/srtd 0.2.2 → 0.3.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.
- package/README.md +148 -89
- package/dist/__tests__/watch.test.js +0 -1
- package/dist/__tests__/watch.test.js.map +1 -1
- package/dist/cli.js +3 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/_app.js +22 -2
- package/dist/commands/_app.js.map +1 -1
- package/dist/commands/apply.d.ts +13 -1
- package/dist/commands/apply.js +18 -6
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/build.d.ts +13 -1
- package/dist/commands/build.js +14 -4
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/index.js +20 -10
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/register.js +9 -6
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/watch.js +105 -117
- package/dist/commands/watch.js.map +1 -1
- package/dist/components/Branding.js +5 -4
- package/dist/components/Branding.js.map +1 -1
- package/dist/components/Quittable.d.ts +6 -0
- package/dist/components/Quittable.js +36 -0
- package/dist/components/Quittable.js.map +1 -0
- package/dist/hooks/useDatabaseConnection.d.ts +7 -0
- package/dist/hooks/useDatabaseConnection.js +68 -0
- package/dist/hooks/useDatabaseConnection.js.map +1 -0
- package/dist/hooks/useTemplateManager.d.ts +24 -0
- package/dist/hooks/useTemplateManager.js +141 -0
- package/dist/hooks/useTemplateManager.js.map +1 -0
- package/dist/lib/templateManager.d.ts +3 -3
- package/dist/lib/templateManager.js +24 -17
- package/dist/lib/templateManager.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/utils/config.js +1 -0
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/databaseConnection.d.ts +5 -1
- package/dist/utils/databaseConnection.js +27 -8
- package/dist/utils/databaseConnection.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -0
- package/package.json +12 -7
- package/dist/commands/help.d.ts +0 -1
- package/dist/commands/help.js +0 -2
- package/dist/commands/help.js.map +0 -1
|
@@ -4,6 +4,7 @@ import { argument } from 'pastel';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import zod from 'zod';
|
|
6
6
|
import Branding from '../components/Branding.js';
|
|
7
|
+
import Quittable from '../components/Quittable.js';
|
|
7
8
|
import { useTemplateState } from '../hooks/useTemplateState.js';
|
|
8
9
|
import { registerTemplate } from '../utils/registerTemplate.js';
|
|
9
10
|
// Support both array of filenames as arguments and interactive selection
|
|
@@ -63,20 +64,22 @@ export default function Register({ args: templateArgs }) {
|
|
|
63
64
|
});
|
|
64
65
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
65
66
|
React.createElement(Branding, { subtitle: "Register templates" }),
|
|
66
|
-
React.createElement(
|
|
67
|
-
|
|
68
|
-
React.createElement(Text, { color: "white" },
|
|
67
|
+
React.createElement(Box, { gap: 2 },
|
|
68
|
+
React.createElement(Text, null,
|
|
69
69
|
selectedValues.length,
|
|
70
70
|
" / ",
|
|
71
71
|
options.length,
|
|
72
|
-
" selected")
|
|
72
|
+
" selected"),
|
|
73
|
+
React.createElement(Text, { dimColor: true }, "Use arrow/space to select, then press Enter to register.")),
|
|
73
74
|
React.createElement(Box, { marginTop: 1, marginBottom: 1 },
|
|
74
75
|
React.createElement(MultiSelect, { options: options, onChange: vals => setSelectedValues(vals), onSubmit: vals => void handleTemplateRegistration(vals) })),
|
|
75
76
|
!!errorMessage && React.createElement(Text, { color: "red" }, errorMessage),
|
|
76
|
-
!!successMessage && React.createElement(Text, { color: "
|
|
77
|
+
!!successMessage && React.createElement(Text, { color: "#3ecf8e" }, successMessage),
|
|
78
|
+
React.createElement(Quittable, null)));
|
|
77
79
|
}
|
|
78
80
|
return (React.createElement(Box, { flexDirection: "column", marginTop: 1 },
|
|
79
81
|
!!errorMessage && React.createElement(Text, { color: "red" }, errorMessage),
|
|
80
|
-
!!successMessage && React.createElement(Text, { color: "
|
|
82
|
+
!!successMessage && React.createElement(Text, { color: "#3ecf8e" }, successMessage),
|
|
83
|
+
React.createElement(Quittable, null)));
|
|
81
84
|
}
|
|
82
85
|
//# sourceMappingURL=register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/commands/register.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,yEAAyE;AACzE,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG;KACpB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;KACnB,QAAQ,EAAE;KACV,QAAQ,CACP,QAAQ,CAAC;IACP,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,uCAAuC;CACrD,CAAC,CACH,CAAC;AAMJ,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAS;IAC5D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAC5C,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAW,EAAE,CAAC,CAAC;IACzE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE3D,MAAM,0BAA0B,GAAG,KAAK,CAAC,WAA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YAAY,CAAQ;YACzD,CAAC,CAAC,cAAc,IAAI,oBAAC,IAAI,IAAC,KAAK,EAAC,SAAS,IAAE,cAAc,CAAQ;YAClE,oBAAC,SAAS,OAAG,CACT,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,SAAS,EAAE,CAAC;QACrC,CAAC,CAAC,YAAY,IAAI,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK,IAAE,YAAY,CAAQ;QACzD,CAAC,CAAC,cAAc,IAAI,oBAAC,IAAI,IAAC,KAAK,EAAC,SAAS,IAAE,cAAc,CAAQ;QAClE,oBAAC,SAAS,OAAG,CACT,CACP,CAAC;AACJ,CAAC"}
|
package/dist/commands/watch.js
CHANGED
|
@@ -1,127 +1,115 @@
|
|
|
1
|
+
// src/components/watch.tsx
|
|
1
2
|
import path from 'node:path';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
3
|
+
import { Badge } from '@inkjs/ui';
|
|
4
|
+
import { Box, Text, useInput } from 'ink';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
4
6
|
import Branding from '../components/Branding.js';
|
|
7
|
+
import Quittable from '../components/Quittable.js';
|
|
5
8
|
import { TimeSince } from '../components/TimeSince.js';
|
|
6
|
-
import {
|
|
9
|
+
import { useDatabaseConnection } from '../hooks/useDatabaseConnection.js';
|
|
10
|
+
import { useTemplateManager } from '../hooks/useTemplateManager.js';
|
|
11
|
+
const MAX_FILES = 30;
|
|
12
|
+
const PATH_DISPLAY_LENGTH = 15;
|
|
13
|
+
function StatBadge({ label, value, color }) {
|
|
14
|
+
return (React.createElement(Box, { marginRight: 1 },
|
|
15
|
+
React.createElement(Badge, { color: color },
|
|
16
|
+
' ',
|
|
17
|
+
label,
|
|
18
|
+
": ",
|
|
19
|
+
value,
|
|
20
|
+
' ')));
|
|
21
|
+
}
|
|
22
|
+
function formatTemplateDisplay(templatePath, templateDir) {
|
|
23
|
+
const parts = templatePath.split(path.sep);
|
|
24
|
+
const filename = parts.pop() || '';
|
|
25
|
+
const dirPath = parts.join(path.sep);
|
|
26
|
+
if (dirPath && templateDir && dirPath.includes(templateDir)) {
|
|
27
|
+
const relativePath = dirPath.substring(dirPath.indexOf(templateDir) + templateDir.length + 1);
|
|
28
|
+
if (relativePath) {
|
|
29
|
+
const truncatedPath = relativePath.slice(-PATH_DISPLAY_LENGTH);
|
|
30
|
+
return `${truncatedPath}/${filename}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return filename;
|
|
34
|
+
}
|
|
35
|
+
const TemplateRow = React.memo(({ template, isLatest, templateDir, }) => {
|
|
36
|
+
const displayName = formatTemplateDisplay(template.path, templateDir ?? '');
|
|
37
|
+
return (React.createElement(Box, { marginLeft: 2 },
|
|
38
|
+
React.createElement(Box, { width: 2 },
|
|
39
|
+
React.createElement(Text, null, template.buildState.lastAppliedError ? '❌' : isLatest ? '⚡️' : '✓')),
|
|
40
|
+
React.createElement(Box, { width: 35 },
|
|
41
|
+
React.createElement(Text, null, displayName)),
|
|
42
|
+
React.createElement(Box, null,
|
|
43
|
+
React.createElement(Text, { dimColor: true },
|
|
44
|
+
"applied ",
|
|
45
|
+
React.createElement(TimeSince, { date: template.buildState.lastAppliedDate }),
|
|
46
|
+
" ago",
|
|
47
|
+
!template.buildState.lastBuildDate ||
|
|
48
|
+
template.currentHash !== template.buildState.lastBuildHash ? (React.createElement(React.Fragment, null, " \u2022 needs build")) : (React.createElement(React.Fragment, null,
|
|
49
|
+
' ',
|
|
50
|
+
"\u2022 built ",
|
|
51
|
+
React.createElement(TimeSince, { date: template.buildState.lastBuildDate }),
|
|
52
|
+
" ago"))))));
|
|
53
|
+
});
|
|
54
|
+
TemplateRow.displayName = 'TemplateRow';
|
|
55
|
+
const UpdateLog = React.memo(({ updates, templateDir, }) => {
|
|
56
|
+
const sortedUpdates = useMemo(() => [...updates].reverse().slice(0, 5), [updates]);
|
|
57
|
+
return (React.createElement(Box, { flexDirection: "column", marginTop: 1 },
|
|
58
|
+
React.createElement(Text, { bold: true }, "Recent Updates:"),
|
|
59
|
+
sortedUpdates.map(update => (React.createElement(Box, { key: `${update.template.path}-${update.timestamp}`, marginLeft: 2 },
|
|
60
|
+
React.createElement(Text, { color: update.type === 'error' ? 'red' : update.type === 'applied' ? 'green' : 'blue' },
|
|
61
|
+
update.type === 'error' ? '❌' : update.type === 'applied' ? '✨' : '📝',
|
|
62
|
+
' ',
|
|
63
|
+
formatTemplateDisplay(update.template.path, templateDir ?? ''),
|
|
64
|
+
":",
|
|
65
|
+
' ',
|
|
66
|
+
update.type === 'error'
|
|
67
|
+
? update.error
|
|
68
|
+
: update.type === 'applied'
|
|
69
|
+
? 'applied successfully'
|
|
70
|
+
: 'changed and reapplied'))))));
|
|
71
|
+
});
|
|
72
|
+
UpdateLog.displayName = 'UpdateLog';
|
|
7
73
|
export default function Watch() {
|
|
8
|
-
const {
|
|
9
|
-
const
|
|
10
|
-
const [
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
useInput(
|
|
14
|
-
if (input
|
|
15
|
-
|
|
16
|
-
setTimeout(() => exit(), 0);
|
|
74
|
+
const { isConnected } = useDatabaseConnection();
|
|
75
|
+
const { templates, updates, stats, isLoading, errors, latestPath, templateDir } = useTemplateManager();
|
|
76
|
+
const [showUpdates, setShowUpdates] = React.useState(true);
|
|
77
|
+
const activeTemplates = useMemo(() => templates.slice(-MAX_FILES), [templates]);
|
|
78
|
+
const hasErrors = errors.size > 0;
|
|
79
|
+
useInput(input => {
|
|
80
|
+
if (input === 'u') {
|
|
81
|
+
setShowUpdates(s => !s);
|
|
17
82
|
}
|
|
18
83
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
managerRef.current = await TemplateManager.create(process.cwd(), { silent: true });
|
|
25
|
-
// Initial template load
|
|
26
|
-
const initialTemplates = await managerRef.current.findTemplates();
|
|
27
|
-
for (const templatePath of initialTemplates) {
|
|
28
|
-
const status = await managerRef.current.getTemplateStatus(templatePath);
|
|
29
|
-
if (mounted.current) {
|
|
30
|
-
setTemplates(prev => [...prev.filter(t => t.path !== status.path), status]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
// Watch and handle changes
|
|
34
|
-
const watcher = await managerRef.current.watch();
|
|
35
|
-
// Update UI on template changes
|
|
36
|
-
const updateTemplate = async (template) => {
|
|
37
|
-
if (!mounted.current)
|
|
38
|
-
return;
|
|
39
|
-
const status = await managerRef.current?.getTemplateStatus(template.path);
|
|
40
|
-
if (status) {
|
|
41
|
-
setTemplates(prev => [...prev.filter(t => t.path !== status.path), status]);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
managerRef.current.on('templateChanged', updateTemplate);
|
|
45
|
-
managerRef.current.on('templateApplied', updateTemplate);
|
|
46
|
-
managerRef.current.on('templateError', ({ template }) => updateTemplate(template));
|
|
47
|
-
// Initial apply for any out-of-date templates
|
|
48
|
-
await managerRef.current.processTemplates({ apply: true });
|
|
49
|
-
return () => {
|
|
50
|
-
mounted.current = false;
|
|
51
|
-
watcher.close();
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
if (mounted.current) {
|
|
56
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
57
|
-
}
|
|
58
|
-
return () => {
|
|
59
|
-
mounted.current = false;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
init().then(c => {
|
|
64
|
-
cleanup = c;
|
|
65
|
-
});
|
|
66
|
-
return () => cleanup?.();
|
|
67
|
-
}, []);
|
|
68
|
-
if (error) {
|
|
69
|
-
return React.createElement(Text, { color: "red" },
|
|
70
|
-
"Error: ",
|
|
71
|
-
error);
|
|
84
|
+
if (!isConnected) {
|
|
85
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
86
|
+
React.createElement(Text, { color: "red" }, "Unable to connect to database. Is Supabase running?"),
|
|
87
|
+
React.createElement(Quittable, null)));
|
|
72
88
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!acc[dir]) {
|
|
76
|
-
acc[dir] = [];
|
|
77
|
-
}
|
|
78
|
-
acc[dir].push(template);
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
const hasErrors = templates.some(t => t.buildState.lastAppliedError);
|
|
82
|
-
return (React.createElement(Box, { flexDirection: "column", marginBottom: 2, marginTop: 2 },
|
|
83
|
-
React.createElement(Branding, { subtitle: "Watch Mode" }),
|
|
84
|
-
Object.entries(templatesByDir).map(([dir, dirTemplates]) => (React.createElement(Box, { key: dir, flexDirection: "column", marginLeft: 1 },
|
|
85
|
-
React.createElement(Text, { dimColor: true }, dir),
|
|
86
|
-
dirTemplates.map(template => (React.createElement(Box, { key: template.path, marginLeft: 2 },
|
|
87
|
-
React.createElement(Box, { width: 2 },
|
|
88
|
-
React.createElement(Text, null, template.buildState.lastAppliedError
|
|
89
|
-
? '❌'
|
|
90
|
-
: template === templates[templates.length - 1]
|
|
91
|
-
? '✓'
|
|
92
|
-
: ' ')),
|
|
93
|
-
React.createElement(Box, { width: 20 },
|
|
94
|
-
React.createElement(Text, null, path.basename(template.path))),
|
|
95
|
-
React.createElement(Box, null,
|
|
96
|
-
React.createElement(Text, { dimColor: true },
|
|
97
|
-
"applied ",
|
|
98
|
-
React.createElement(TimeSince, { date: template.buildState.lastAppliedDate }),
|
|
99
|
-
" ago",
|
|
100
|
-
!template.buildState.lastBuildDate ||
|
|
101
|
-
template.currentHash !== template.buildState.lastBuildHash ? (React.createElement(React.Fragment, null, " \u2022 needs build")) : (React.createElement(React.Fragment, null,
|
|
102
|
-
' ',
|
|
103
|
-
"\u2022 built ",
|
|
104
|
-
React.createElement(TimeSince, { date: template.buildState.lastBuildDate }),
|
|
105
|
-
" ago")))))))))),
|
|
106
|
-
hasErrors && (React.createElement(Box, { flexDirection: "column", marginY: 1 },
|
|
107
|
-
React.createElement(Text, { bold: true, color: "red" }, "Errors"),
|
|
108
|
-
templates
|
|
109
|
-
.filter(t => t.buildState.lastAppliedError)
|
|
110
|
-
.map(t => (React.createElement(Box, { key: t.name, marginLeft: 2 },
|
|
111
|
-
React.createElement(Text, { color: "red" },
|
|
112
|
-
"\u2022 ",
|
|
113
|
-
t.name,
|
|
114
|
-
": ",
|
|
115
|
-
t.buildState.lastAppliedError)))))),
|
|
89
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
90
|
+
React.createElement(Branding, { subtitle: "\uD83D\uDC40 Watch Mode" }),
|
|
116
91
|
React.createElement(Box, { marginY: 1 },
|
|
117
|
-
React.createElement(
|
|
118
|
-
React.createElement(
|
|
119
|
-
React.createElement(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
React.createElement(
|
|
123
|
-
React.createElement(
|
|
124
|
-
React.createElement(
|
|
125
|
-
|
|
92
|
+
React.createElement(StatBadge, { label: "Total", value: stats.total, color: "#3ecf8e" }),
|
|
93
|
+
stats.needsBuild > 0 && (React.createElement(StatBadge, { label: "Needs Build", value: stats.needsBuild, color: "yellow" })),
|
|
94
|
+
stats.recentlyChanged > 0 && (React.createElement(StatBadge, { label: "Recent Changes", value: stats.recentlyChanged, color: "blue" })),
|
|
95
|
+
hasErrors && React.createElement(StatBadge, { label: "Errors", value: stats.errors, color: "red" })),
|
|
96
|
+
isLoading ? (React.createElement(Text, null, "\uD83D\uDD0D Finding templates...")) : (React.createElement(Box, { flexDirection: "column" },
|
|
97
|
+
activeTemplates.map(template => (React.createElement(TemplateRow, { key: template.path, template: template, isLatest: template.path === latestPath, templateDir: templateDir }))),
|
|
98
|
+
showUpdates && updates.length > 0 && (React.createElement(UpdateLog, { updates: updates, templateDir: templateDir })),
|
|
99
|
+
!showUpdates && hasErrors && (React.createElement(Box, { flexDirection: "column", marginTop: 1 },
|
|
100
|
+
React.createElement(Text, { bold: true, color: "red" }, "Errors:"),
|
|
101
|
+
Array.from(errors.entries()).map(([path, error]) => (React.createElement(Box, { key: path, marginLeft: 2, marginTop: 1 },
|
|
102
|
+
React.createElement(Text, { color: "red", wrap: "wrap" },
|
|
103
|
+
formatTemplateDisplay(path, templateDir ?? ''),
|
|
104
|
+
": ",
|
|
105
|
+
error)))))))),
|
|
106
|
+
React.createElement(Box, { marginY: 1, flexDirection: "row", gap: 1 },
|
|
107
|
+
React.createElement(Box, { marginY: 1 },
|
|
108
|
+
React.createElement(Text, { dimColor: true }, "press "),
|
|
109
|
+
React.createElement(Text, { underline: showUpdates }, "u"),
|
|
110
|
+
React.createElement(Text, { dimColor: true }, " to toggle updates")),
|
|
111
|
+
React.createElement(Box, { marginY: 1 },
|
|
112
|
+
React.createElement(Text, { dimColor: true }, "\u2022")),
|
|
113
|
+
React.createElement(Quittable, null))));
|
|
126
114
|
}
|
|
127
115
|
//# sourceMappingURL=watch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/commands/watch.tsx"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/commands/watch.tsx"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,OAAO,SAAS,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AA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AAO,EAAE,CAAC;gBACb,oBAAC,IAAI,IAAC,QAAQ,mBAAc;gBAC5B,oBAAC,IAAI,IAAC,SAAS,EAAE,WAAW,QAAU;gBACtC,oBAAC,IAAI,IAAC,QAAQ,+BAA0B,CACpC;YACN,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;gBACb,oBAAC,IAAI,IAAC,QAAQ,mBAAS,CACnB;YACN,oBAAC,SAAS,OAAG,CACT,CACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { Badge } from '@inkjs/ui';
|
|
1
2
|
import { Box, Text } from 'ink';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import packageJson from '../../package.json' assert { type: 'json' };
|
|
5
|
+
import { useDatabaseConnection } from '../hooks/useDatabaseConnection.js';
|
|
4
6
|
export default function Branding({ subtitle }) {
|
|
7
|
+
const { error, isConnected } = useDatabaseConnection();
|
|
8
|
+
const badgeColor = error ? 'red' : isConnected ? '#3ecf8e' : 'yellow';
|
|
5
9
|
return (React.createElement(Box, { marginBottom: 1, marginTop: 1, gap: 1, flexDirection: "column" },
|
|
6
10
|
React.createElement(Box, { gap: 1 },
|
|
7
|
-
React.createElement(
|
|
8
|
-
' ',
|
|
9
|
-
"srtd",
|
|
10
|
-
' '),
|
|
11
|
+
React.createElement(Badge, { color: badgeColor }, " srtd "),
|
|
11
12
|
subtitle ? (React.createElement(Text, null, subtitle)) : (React.createElement(Text, null,
|
|
12
13
|
"(",
|
|
13
14
|
React.createElement(Text, { bold: true, color: "#3ecf8e" }, "S"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Branding.js","sourceRoot":"","sources":["../../src/components/Branding.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,WAAW,MAAM,oBAAoB,CAAC,SAAS,IAAI,EAAE,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AAC,KAAK,EAAC,SAAS,QAEnB;8BAEF,CACR;YACD,oBAAC,IAAI,IAAC,QAAQ;;gBAAG,WAAW,CAAC,OAAO,CAAQ,CACxC,CACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { Box, Text, useInput } from 'ink';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export default function Quittable(props) {
|
|
5
|
+
// Use ref to track if component is mounted
|
|
6
|
+
const mounted = React.useRef(true);
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
return () => {
|
|
9
|
+
mounted.current = false;
|
|
10
|
+
};
|
|
11
|
+
}, []);
|
|
12
|
+
useInput((input, key) => {
|
|
13
|
+
if (!mounted.current)
|
|
14
|
+
return;
|
|
15
|
+
if (input.toLowerCase() === 'q' || (key.ctrl && input === 'c')) {
|
|
16
|
+
try {
|
|
17
|
+
if (props?.onQuit) {
|
|
18
|
+
props.onQuit();
|
|
19
|
+
}
|
|
20
|
+
// Exit synchronously
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('Failed to exit cleanly:', error);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return (React.createElement(Box, { marginY: 1 },
|
|
30
|
+
React.createElement(Text, { dimColor: true }, "press "),
|
|
31
|
+
React.createElement(Text, null, "q"),
|
|
32
|
+
React.createElement(Text, { dimColor: true }, " or "),
|
|
33
|
+
React.createElement(Text, null, "Ctrl+c"),
|
|
34
|
+
React.createElement(Text, { dimColor: true }, " to quit")));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=Quittable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Quittable.js","sourceRoot":"","sources":["../../src/components/Quittable.tsx"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACn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C1B,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// hooks/useDatabaseConnection.ts
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { RETRY_DELAY, testConnection } from '../utils/databaseConnection.js';
|
|
4
|
+
function parseDbError(error) {
|
|
5
|
+
if (error instanceof Error) {
|
|
6
|
+
if (error.message.includes('Connection terminated unexpectedly')) {
|
|
7
|
+
return 'Database connection lost. Is Supabase running?';
|
|
8
|
+
}
|
|
9
|
+
if (error.message.includes('ECONNREFUSED')) {
|
|
10
|
+
return 'Unable to connect to database. Is Supabase running?';
|
|
11
|
+
}
|
|
12
|
+
return error.message.split('\n')[0] || error.message;
|
|
13
|
+
}
|
|
14
|
+
return String(error);
|
|
15
|
+
}
|
|
16
|
+
export function useDatabaseConnection(checkInterval = 5000) {
|
|
17
|
+
const [state, setState] = useState({
|
|
18
|
+
isConnected: false,
|
|
19
|
+
isChecking: true,
|
|
20
|
+
});
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
let mounted = true;
|
|
23
|
+
let timeoutId;
|
|
24
|
+
let intervalId = undefined;
|
|
25
|
+
async function checkConnection() {
|
|
26
|
+
if (!mounted)
|
|
27
|
+
return;
|
|
28
|
+
setState(prev => ({ ...prev, isChecking: true }));
|
|
29
|
+
try {
|
|
30
|
+
const connectionPromise = testConnection();
|
|
31
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
32
|
+
timeoutId = setTimeout(() => {
|
|
33
|
+
reject(new Error('Connection attempt timed out'));
|
|
34
|
+
}, RETRY_DELAY);
|
|
35
|
+
});
|
|
36
|
+
const isConnected = await Promise.race([connectionPromise, timeoutPromise]);
|
|
37
|
+
if (mounted) {
|
|
38
|
+
setState({
|
|
39
|
+
isConnected,
|
|
40
|
+
error: undefined,
|
|
41
|
+
isChecking: false,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (mounted) {
|
|
47
|
+
setState({
|
|
48
|
+
isConnected: false,
|
|
49
|
+
error: parseDbError(err),
|
|
50
|
+
isChecking: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
clearTimeout(timeoutId);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
checkConnection();
|
|
59
|
+
intervalId = setInterval(checkConnection, checkInterval);
|
|
60
|
+
return () => {
|
|
61
|
+
mounted = false;
|
|
62
|
+
clearTimeout(timeoutId);
|
|
63
|
+
clearInterval(intervalId);
|
|
64
|
+
};
|
|
65
|
+
}, [checkInterval]);
|
|
66
|
+
return state;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=useDatabaseConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDatabaseConnection.js","sourceRoot":"","sources":["../../src/hooks/useDatabaseConnection.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAQ7E,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oCAAoC,CAAC,EAAE,CAAC;YACjE,OAAO,gDAAgD,CAAC;QAC1D,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC3C,OAAO,qDAAqD,CAAC;QAC/D,CAAC;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,qBAAqB,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CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,eAAe,EAAE,CAAC;QAClB,UAAU,GAAG,WAAW,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAEzD,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,KAAK,CAAC;YAChB,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,aAAa,CAAC,UAAU,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TemplateStatus } from '../types.js';
|
|
2
|
+
export type TemplateUpdate = {
|
|
3
|
+
type: 'applied' | 'changed' | 'error';
|
|
4
|
+
template: TemplateStatus;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
export interface TemplateStats {
|
|
10
|
+
total: number;
|
|
11
|
+
needsBuild: number;
|
|
12
|
+
recentlyChanged: number;
|
|
13
|
+
errors: number;
|
|
14
|
+
}
|
|
15
|
+
export interface UseTemplateManager {
|
|
16
|
+
templates: TemplateStatus[];
|
|
17
|
+
updates: TemplateUpdate[];
|
|
18
|
+
stats: TemplateStats;
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
errors: Map<string, string>;
|
|
21
|
+
latestPath?: string;
|
|
22
|
+
templateDir?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function useTemplateManager(cwd?: string): UseTemplateManager;
|