@t1mmen/srtd 0.4.3 → 0.4.5
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 +45 -17
- package/dist/__tests__/apply.test.js +2 -2
- package/dist/__tests__/build.test.js +4 -4
- package/dist/__tests__/build.test.js.map +1 -1
- package/dist/__tests__/promote.test.d.ts +1 -0
- package/dist/__tests__/promote.test.js +9 -0
- package/dist/__tests__/promote.test.js.map +1 -0
- package/dist/__tests__/vitest.setup.js +2 -1
- package/dist/__tests__/vitest.setup.js.map +1 -1
- package/dist/__tests__/watch.test.js +2 -0
- package/dist/__tests__/watch.test.js.map +1 -1
- package/dist/commands/_app.js +0 -8
- package/dist/commands/_app.js.map +1 -1
- package/dist/commands/apply.js +6 -9
- package/dist/commands/apply.js.map +1 -1
- package/dist/commands/build.js +6 -11
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/clear.js +10 -2
- package/dist/commands/clear.js.map +1 -1
- package/dist/commands/index.js +11 -12
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.js +7 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/promote.d.ts +8 -0
- package/dist/commands/promote.js +159 -0
- package/dist/commands/promote.js.map +1 -0
- package/dist/commands/register.d.ts +1 -1
- package/dist/commands/register.js +62 -16
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/watch.js +25 -28
- package/dist/commands/watch.js.map +1 -1
- package/dist/components/Branding.js +1 -1
- package/dist/components/Branding.js.map +1 -1
- package/dist/components/ProcessingResults.js +26 -14
- package/dist/components/ProcessingResults.js.map +1 -1
- package/dist/components/Quittable.js +6 -4
- package/dist/components/Quittable.js.map +1 -1
- package/dist/components/StatBadge.d.ts +6 -0
- package/dist/components/StatBadge.js +14 -0
- package/dist/components/StatBadge.js.map +1 -0
- package/dist/components/TimeSince.js +9 -5
- package/dist/components/TimeSince.js.map +1 -1
- package/dist/hooks/useDatabaseConnection.js +2 -1
- package/dist/hooks/useDatabaseConnection.js.map +1 -1
- package/dist/hooks/useFullscreen.d.ts +1 -0
- package/dist/hooks/useFullscreen.js +18 -0
- package/dist/hooks/useFullscreen.js.map +1 -0
- package/dist/hooks/useTemplateProcessor.d.ts +1 -0
- package/dist/hooks/useTemplateProcessor.js +82 -47
- package/dist/hooks/useTemplateProcessor.js.map +1 -1
- package/dist/lib/templateManager.js +41 -26
- package/dist/lib/templateManager.js.map +1 -1
- package/dist/lib/templateManager.test.js +794 -488
- package/dist/lib/templateManager.test.js.map +1 -1
- package/dist/utils/applyMigrations.test.js +4 -1
- package/dist/utils/applyMigrations.test.js.map +1 -1
- package/dist/utils/databaseConnection.js +21 -19
- package/dist/utils/databaseConnection.js.map +1 -1
- package/dist/utils/databaseConnection.test.js +1 -4
- package/dist/utils/databaseConnection.test.js.map +1 -1
- package/dist/utils/logger.js +6 -5
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/registerTemplate.js +1 -2
- package/dist/utils/registerTemplate.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { Select, Spinner } from '@inkjs/ui';
|
|
4
|
+
import figures from 'figures';
|
|
5
|
+
import { glob } from 'glob';
|
|
6
|
+
import { Box, Text, useApp } from 'ink';
|
|
7
|
+
import { argument } from 'pastel';
|
|
8
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import zod from 'zod';
|
|
10
|
+
import Branding from '../components/Branding.js';
|
|
11
|
+
import Quittable from '../components/Quittable.js';
|
|
12
|
+
import { COLOR_ERROR, COLOR_SUCCESS, COLOR_WARNING } from '../components/customTheme.js';
|
|
13
|
+
import { getConfig } from '../utils/config.js';
|
|
14
|
+
import { loadBuildLog } from '../utils/loadBuildLog.js';
|
|
15
|
+
import { saveBuildLog } from '../utils/saveBuildLog.js';
|
|
16
|
+
export const args = zod
|
|
17
|
+
.array(zod.string())
|
|
18
|
+
.optional()
|
|
19
|
+
.describe(argument({
|
|
20
|
+
name: 'templates',
|
|
21
|
+
description: 'Template files to promote (optional)',
|
|
22
|
+
}));
|
|
23
|
+
export default function Promote({ args: templateArgs }) {
|
|
24
|
+
const { exit } = useApp();
|
|
25
|
+
const [templates, setTemplates] = useState([]);
|
|
26
|
+
const [error, setError] = useState(null);
|
|
27
|
+
const [success, setSuccess] = useState(null);
|
|
28
|
+
const [config, setConfig] = useState(null);
|
|
29
|
+
const findWipTemplates = useCallback(async () => {
|
|
30
|
+
try {
|
|
31
|
+
const config = await getConfig(process.cwd());
|
|
32
|
+
setConfig(config);
|
|
33
|
+
const templatePath = path.join(process.cwd(), config.templateDir);
|
|
34
|
+
const pattern = `**/*${config.wipIndicator}*.sql`;
|
|
35
|
+
const matches = await glob(pattern, { cwd: templatePath });
|
|
36
|
+
const fullPaths = matches.map(m => path.join(templatePath, m));
|
|
37
|
+
setTemplates(fullPaths);
|
|
38
|
+
return fullPaths;
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
42
|
+
setError(`Failed to find WIP templates: ${msg}`);
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}, []);
|
|
46
|
+
const promoteTemplate = useCallback(async (templatePath) => {
|
|
47
|
+
try {
|
|
48
|
+
const config = await getConfig(process.cwd());
|
|
49
|
+
const newPath = templatePath.replace(config.wipIndicator, '');
|
|
50
|
+
// Load build log before file operations
|
|
51
|
+
const buildLog = await loadBuildLog(process.cwd(), 'local');
|
|
52
|
+
const relOldPath = path.relative(process.cwd(), templatePath);
|
|
53
|
+
const relNewPath = path.relative(process.cwd(), newPath);
|
|
54
|
+
// Check if source file exists
|
|
55
|
+
await fs.access(templatePath);
|
|
56
|
+
// Rename the file
|
|
57
|
+
await fs.rename(templatePath, newPath);
|
|
58
|
+
// Update build logs if template was tracked
|
|
59
|
+
if (buildLog.templates[relOldPath]) {
|
|
60
|
+
buildLog.templates[relNewPath] = buildLog.templates[relOldPath];
|
|
61
|
+
delete buildLog.templates[relOldPath];
|
|
62
|
+
await saveBuildLog(process.cwd(), buildLog, 'local');
|
|
63
|
+
}
|
|
64
|
+
const templateName = path.basename(newPath, '.sql');
|
|
65
|
+
setSuccess(`Successfully promoted ${templateName}`);
|
|
66
|
+
// Exit after short delay
|
|
67
|
+
setTimeout(() => exit(), 0);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
71
|
+
setError(`Failed to promote template: ${msg}`);
|
|
72
|
+
}
|
|
73
|
+
}, [exit]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const init = async () => {
|
|
76
|
+
const config = await getConfig(process.cwd());
|
|
77
|
+
await findWipTemplates();
|
|
78
|
+
if (templateArgs?.length) {
|
|
79
|
+
// Handle CLI mode
|
|
80
|
+
const templateName = templateArgs[0];
|
|
81
|
+
const templateDir = path.join(process.cwd(), config.templateDir);
|
|
82
|
+
const pattern = `**/*${templateName}*`;
|
|
83
|
+
const matches = await glob(pattern, { cwd: templateDir });
|
|
84
|
+
const isWip = config.wipIndicator && templateName?.includes(config.wipIndicator);
|
|
85
|
+
if (matches.length === 0 || !isWip) {
|
|
86
|
+
setError(`No WIP template found matching: ${templateName} in ${config.templateDir}`);
|
|
87
|
+
exit();
|
|
88
|
+
}
|
|
89
|
+
if (!isWip) {
|
|
90
|
+
setError(`Template is not a WIP template: ${templateName}`);
|
|
91
|
+
exit();
|
|
92
|
+
}
|
|
93
|
+
const match = matches[0] ? path.join(templateDir, matches[0]) : '';
|
|
94
|
+
if (!match) {
|
|
95
|
+
setError(`No valid match found for template: ${templateName} in ${config.templateDir}`);
|
|
96
|
+
exit();
|
|
97
|
+
}
|
|
98
|
+
await promoteTemplate(match);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
init();
|
|
102
|
+
}, [templateArgs, findWipTemplates, promoteTemplate, exit]);
|
|
103
|
+
// UI status displays
|
|
104
|
+
if (error) {
|
|
105
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
106
|
+
React.createElement(Branding, { subtitle: "\uD83D\uDE80 Promote WIP template" }),
|
|
107
|
+
React.createElement(Text, { color: COLOR_ERROR },
|
|
108
|
+
figures.cross,
|
|
109
|
+
" ",
|
|
110
|
+
error)));
|
|
111
|
+
}
|
|
112
|
+
if (success) {
|
|
113
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
114
|
+
React.createElement(Branding, { subtitle: "\uD83D\uDE80 Promote WIP template" }),
|
|
115
|
+
React.createElement(Box, { gap: 1, flexDirection: "column" },
|
|
116
|
+
React.createElement(Text, { color: COLOR_SUCCESS },
|
|
117
|
+
figures.tick,
|
|
118
|
+
" ",
|
|
119
|
+
success),
|
|
120
|
+
React.createElement(Text, { dimColor: true }, "Run `build` command to generate migrations"))));
|
|
121
|
+
}
|
|
122
|
+
// Interactive UI mode
|
|
123
|
+
if (!templateArgs?.length) {
|
|
124
|
+
if (templates.length === 0) {
|
|
125
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
126
|
+
React.createElement(Branding, { subtitle: "\uD83D\uDE80 Promote WIP template" }),
|
|
127
|
+
React.createElement(Text, { color: COLOR_WARNING },
|
|
128
|
+
figures.warning,
|
|
129
|
+
" No WIP templates found in ",
|
|
130
|
+
config?.templateDir,
|
|
131
|
+
' ',
|
|
132
|
+
React.createElement(Text, { bold: true },
|
|
133
|
+
"(",
|
|
134
|
+
config?.wipIndicator,
|
|
135
|
+
")")),
|
|
136
|
+
React.createElement(Quittable, null)));
|
|
137
|
+
}
|
|
138
|
+
const menuItems = templates.map(t => ({
|
|
139
|
+
label: path.basename(t),
|
|
140
|
+
value: t,
|
|
141
|
+
}));
|
|
142
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
143
|
+
React.createElement(Branding, { subtitle: "\uD83D\uDE80 Promote WIP template" }),
|
|
144
|
+
React.createElement(Box, { gap: 1, marginBottom: 1 },
|
|
145
|
+
React.createElement(Text, null, "Select a template to promote"),
|
|
146
|
+
React.createElement(Text, { dimColor: true },
|
|
147
|
+
"(removes ",
|
|
148
|
+
config?.wipIndicator,
|
|
149
|
+
" in filename)")),
|
|
150
|
+
React.createElement(Box, { gap: 1, flexDirection: "column" },
|
|
151
|
+
React.createElement(Select, { visibleOptionCount: 30, options: menuItems, onChange: promoteTemplate })),
|
|
152
|
+
React.createElement(Quittable, null)));
|
|
153
|
+
}
|
|
154
|
+
// Loading state for CLI mode
|
|
155
|
+
return (React.createElement(Box, { flexDirection: "column" },
|
|
156
|
+
React.createElement(Branding, { subtitle: "\uD83D\uDE80 Promote WIP template" }),
|
|
157
|
+
React.createElement(Spinner, { label: "Loading..." })));
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=promote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promote.js","sourceRoot":"","sources":["../../src/commands/promote.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,OAAO,SAAS,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AA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G;YAC/C,oBAAC,GAAG,IAAC,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;gBAC1B,oBAAC,IAAI,uCAAoC;gBACzC,oBAAC,IAAI,IAAC,QAAQ;;oBAAW,MAAM,EAAE,YAAY;oCAAqB,CAC9D;YACN,oBAAC,GAAG,IAAC,GAAG,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ;gBACjC,oBAAC,MAAM,IAAC,kBAAkB,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,GAAI,CAC7E;YACN,oBAAC,SAAS,OAAG,CACT,CACP,CAAC;IACJ,CAAC;IAED,6BAA6B;IAC7B,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;QACzB,oBAAC,QAAQ,IAAC,QAAQ,EAAC,mCAAyB,GAAG;QAC/C,oBAAC,OAAO,IAAC,KAAK,EAAC,YAAY,GAAG,CAC1B,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -4,5 +4,5 @@ export declare const args: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
|
4
4
|
type Props = {
|
|
5
5
|
args: zod.infer<typeof args>;
|
|
6
6
|
};
|
|
7
|
-
export default function Register({ args: templateArgs }: Props): React.JSX.Element;
|
|
7
|
+
export default function Register({ args: templateArgs }: Props): React.JSX.Element | null;
|
|
8
8
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MultiSelect } from '@inkjs/ui';
|
|
2
|
-
import
|
|
2
|
+
import figures from 'figures';
|
|
3
|
+
import { Box, Text, useInput } from 'ink';
|
|
3
4
|
import { argument } from 'pastel';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import zod from 'zod';
|
|
6
7
|
import Branding from '../components/Branding.js';
|
|
7
8
|
import Quittable from '../components/Quittable.js';
|
|
8
|
-
import { COLOR_ERROR, COLOR_SUCCESS } from '../components/customTheme.js';
|
|
9
|
+
import { COLOR_ERROR, COLOR_SUCCESS, COLOR_WARNING } from '../components/customTheme.js';
|
|
9
10
|
import { useTemplateState } from '../hooks/useTemplateState.js';
|
|
10
11
|
import { registerTemplate } from '../utils/registerTemplate.js';
|
|
11
12
|
// Support both array of filenames as arguments and interactive selection
|
|
@@ -21,6 +22,12 @@ export default function Register({ args: templateArgs }) {
|
|
|
21
22
|
const [selectedValues, setSelectedValues] = React.useState([]);
|
|
22
23
|
const [successMessage, setSuccessMessage] = React.useState('');
|
|
23
24
|
const [errorMessage, setErrorMessage] = React.useState('');
|
|
25
|
+
const [showAll, setShowAll] = React.useState(false);
|
|
26
|
+
useInput(input => {
|
|
27
|
+
if (input === 'r') {
|
|
28
|
+
setShowAll(!showAll);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
24
31
|
const handleTemplateRegistration = React.useCallback(async (templates) => {
|
|
25
32
|
setSuccessMessage('');
|
|
26
33
|
setErrorMessage('');
|
|
@@ -46,7 +53,7 @@ export default function Register({ args: templateArgs }) {
|
|
|
46
53
|
React.useEffect(() => {
|
|
47
54
|
// If templates were provided as arguments, register them directly
|
|
48
55
|
if (templateArgs?.length) {
|
|
49
|
-
|
|
56
|
+
handleTemplateRegistration(templateArgs);
|
|
50
57
|
}
|
|
51
58
|
}, [handleTemplateRegistration, templateArgs]);
|
|
52
59
|
if (error) {
|
|
@@ -54,9 +61,37 @@ export default function Register({ args: templateArgs }) {
|
|
|
54
61
|
"Error: ",
|
|
55
62
|
error);
|
|
56
63
|
}
|
|
64
|
+
const renderStatus = () => {
|
|
65
|
+
if (!errorMessage && !successMessage)
|
|
66
|
+
return null;
|
|
67
|
+
return (React.createElement(Box, { flexDirection: "column", marginTop: 1 },
|
|
68
|
+
!!errorMessage && (React.createElement(Text, { color: COLOR_ERROR },
|
|
69
|
+
figures.cross,
|
|
70
|
+
" ",
|
|
71
|
+
errorMessage)),
|
|
72
|
+
!!successMessage && (React.createElement(Text, { color: COLOR_SUCCESS },
|
|
73
|
+
figures.tick,
|
|
74
|
+
" ",
|
|
75
|
+
successMessage))));
|
|
76
|
+
};
|
|
77
|
+
const isDone = !!successMessage || !!errorMessage;
|
|
57
78
|
// If no templates were provided as arguments, show interactive selection
|
|
58
|
-
if (!templateArgs?.length) {
|
|
59
|
-
const options = items
|
|
79
|
+
if (!templateArgs?.length && !isDone) {
|
|
80
|
+
const options = items
|
|
81
|
+
.filter(t => {
|
|
82
|
+
if (showAll)
|
|
83
|
+
return true;
|
|
84
|
+
return !t.buildState.lastMigrationFile;
|
|
85
|
+
})
|
|
86
|
+
.sort((a, b) => {
|
|
87
|
+
// If a template has a last migration file, it's considered registered, and sort it last.
|
|
88
|
+
if (a.buildState.lastMigrationFile && !b.buildState.lastMigrationFile)
|
|
89
|
+
return 1;
|
|
90
|
+
if (!a.buildState.lastMigrationFile && b.buildState.lastMigrationFile)
|
|
91
|
+
return -1;
|
|
92
|
+
return a.name.localeCompare(b.name);
|
|
93
|
+
})
|
|
94
|
+
.map(t => {
|
|
60
95
|
const status = t.buildState.lastMigrationFile ? 'registered' : 'new';
|
|
61
96
|
return {
|
|
62
97
|
label: `${t.name} (${status})`,
|
|
@@ -64,23 +99,34 @@ export default function Register({ args: templateArgs }) {
|
|
|
64
99
|
};
|
|
65
100
|
});
|
|
66
101
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
67
|
-
React.createElement(Branding, { subtitle: "Register templates" }),
|
|
68
|
-
React.createElement(Box, { gap: 2 },
|
|
102
|
+
React.createElement(Branding, { subtitle: "\u270D\uFE0F Register templates" }),
|
|
103
|
+
React.createElement(Box, { gap: 2 }, options.length === 0 ? (React.createElement(Box, { flexDirection: "column" },
|
|
104
|
+
React.createElement(Text, { color: COLOR_WARNING },
|
|
105
|
+
figures.warning,
|
|
106
|
+
" No templates found"),
|
|
107
|
+
!showAll && !!items.length && (React.createElement(Text, { dimColor: true },
|
|
108
|
+
figures.info,
|
|
109
|
+
" Press r to show registered templates")),
|
|
110
|
+
!items.length && (React.createElement(Text, null,
|
|
111
|
+
figures.info,
|
|
112
|
+
"Start by creating a template in the templates directory.")))) : (React.createElement(React.Fragment, null,
|
|
69
113
|
React.createElement(Text, null,
|
|
70
114
|
selectedValues.length,
|
|
71
115
|
" / ",
|
|
72
116
|
options.length,
|
|
73
117
|
" selected"),
|
|
74
|
-
React.createElement(Text, { dimColor: true }, "Use arrow/space to select, then press Enter to register.")),
|
|
118
|
+
React.createElement(Text, { dimColor: true }, "Use arrow/space to select, then press Enter to register.")))),
|
|
75
119
|
React.createElement(Box, { marginTop: 1, marginBottom: 1 },
|
|
76
|
-
React.createElement(MultiSelect, { options: options, onChange: vals => setSelectedValues(vals), onSubmit: vals =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
120
|
+
React.createElement(MultiSelect, { visibleOptionCount: 30, options: options, onChange: vals => setSelectedValues(vals), onSubmit: vals => handleTemplateRegistration(vals) }),
|
|
121
|
+
renderStatus()),
|
|
122
|
+
React.createElement(Box, { gap: 1 },
|
|
123
|
+
React.createElement(Quittable, null),
|
|
124
|
+
React.createElement(Box, { marginY: 1, gap: 1 },
|
|
125
|
+
React.createElement(Text, { dimColor: true }, "\u2022"),
|
|
126
|
+
React.createElement(Text, { dimColor: true }, "Press"),
|
|
127
|
+
React.createElement(Text, { underline: showAll }, "r"),
|
|
128
|
+
showAll ? (React.createElement(Text, { dimColor: true }, "to hide registered templates")) : (React.createElement(Text, { dimColor: true }, "to show registered templates"))))));
|
|
80
129
|
}
|
|
81
|
-
return (
|
|
82
|
-
!!errorMessage && React.createElement(Text, { color: COLOR_ERROR }, errorMessage),
|
|
83
|
-
!!successMessage && React.createElement(Text, { color: COLOR_SUCCESS }, successMessage),
|
|
84
|
-
React.createElement(Quittable, null)));
|
|
130
|
+
return renderStatus();
|
|
85
131
|
}
|
|
86
132
|
//# sourceMappingURL=register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/commands/register.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,W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,IAAI,IAAC,QAAQ,qEAAgE,CAC7E,CACJ,CACG;YACN,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;gBAChC,oBAAC,WAAW,IACV,kBAAkB,EAAE,EAAE,EACtB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EACzC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAClD;gBACD,YAAY,EAAE,CACX;YACN,oBAAC,GAAG,IAAC,GAAG,EAAE,CAAC;gBACT,oBAAC,SAAS,OAAG;gBACb,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;oBACrB,oBAAC,IAAI,IAAC,QAAQ,mBAAS;oBACvB,oBAAC,IAAI,IAAC,QAAQ,kBAAa;oBAC3B,oBAAC,IAAI,IAAC,SAAS,EAAE,OAAO,QAAU;oBACjC,OAAO,CAAC,CAAC,CAAC,CACT,oBAAC,IAAI,IAAC,QAAQ,yCAAoC,CACnD,CAAC,CAAC,CAAC,CACF,oBAAC,IAAI,IAAC,QAAQ,yCAAoC,CACnD,CACG,CACF,CACF,CACP,CAAC;IACJ,CAAC;IAED,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC"}
|
package/dist/commands/watch.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
// src/components/watch.tsx
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { Spinner } from '@inkjs/ui';
|
|
4
|
+
import figures from 'figures';
|
|
4
5
|
import { Box, Text, useInput } from 'ink';
|
|
5
6
|
import React, { useMemo } from 'react';
|
|
6
7
|
import Branding from '../components/Branding.js';
|
|
7
8
|
import Quittable from '../components/Quittable.js';
|
|
9
|
+
import { StatBadge } from '../components/StatBadge.js';
|
|
8
10
|
import { TimeSince } from '../components/TimeSince.js';
|
|
9
11
|
import { COLOR_ACCENT, COLOR_ERROR, COLOR_SUCCESS, COLOR_WARNING, } from '../components/customTheme.js';
|
|
10
|
-
import {
|
|
12
|
+
import { useFullscreen } from '../hooks/useFullscreen.js';
|
|
11
13
|
import { useTemplateManager } from '../hooks/useTemplateManager.js';
|
|
12
14
|
import { store } from '../utils/store.js';
|
|
13
15
|
const MAX_FILES = 10;
|
|
14
16
|
const MAX_CHANGES = 15;
|
|
15
17
|
const PATH_DISPLAY_LENGTH = 15;
|
|
16
|
-
function StatBadge({ label, value, color }) {
|
|
17
|
-
return (React.createElement(Box, { marginRight: 1 },
|
|
18
|
-
React.createElement(Badge, { color: color },
|
|
19
|
-
' ',
|
|
20
|
-
label,
|
|
21
|
-
": ",
|
|
22
|
-
value,
|
|
23
|
-
' ')));
|
|
24
|
-
}
|
|
25
18
|
function formatTemplateDisplay(templatePath, templateDir) {
|
|
26
19
|
const parts = templatePath.split(path.sep);
|
|
27
20
|
const filename = parts.pop() || '';
|
|
@@ -39,17 +32,21 @@ const TemplateRow = React.memo(({ template, isLatest, templateDir, }) => {
|
|
|
39
32
|
const displayName = formatTemplateDisplay(template.path, templateDir ?? '');
|
|
40
33
|
const needsBuild = !template.buildState.lastBuildDate ||
|
|
41
34
|
template.currentHash !== template.buildState.lastBuildHash;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
const color = template.buildState.lastAppliedError ? COLOR_ERROR : COLOR_SUCCESS;
|
|
36
|
+
return (React.createElement(Box, { marginLeft: 2, gap: 1 },
|
|
37
|
+
React.createElement(Box, { width: 2, justifyContent: "center" },
|
|
38
|
+
React.createElement(Text, { color: color }, template.buildState.lastAppliedError
|
|
39
|
+
? figures.cross
|
|
40
|
+
: isLatest
|
|
41
|
+
? figures.play
|
|
42
|
+
: figures.tick)),
|
|
45
43
|
React.createElement(Box, { width: 35 },
|
|
46
44
|
React.createElement(Text, null, displayName)),
|
|
47
|
-
React.createElement(Box,
|
|
45
|
+
React.createElement(Box, { minWidth: 18 },
|
|
48
46
|
React.createElement(Text, { dimColor: true },
|
|
49
47
|
"applied ",
|
|
50
|
-
React.createElement(TimeSince, { date: template.buildState.lastAppliedDate }),
|
|
51
|
-
|
|
52
|
-
React.createElement(Text, null, " \u2022 "),
|
|
48
|
+
React.createElement(TimeSince, { date: template.buildState.lastAppliedDate }))),
|
|
49
|
+
React.createElement(Box, null,
|
|
53
50
|
React.createElement(Text, { dimColor: true }, template.wip ? (React.createElement(React.Fragment, null, "wip")) : needsBuild ? (React.createElement(React.Fragment, null, "needs build")) : (React.createElement(React.Fragment, null,
|
|
54
51
|
"built ",
|
|
55
52
|
React.createElement(TimeSince, { date: template.buildState.lastBuildDate }),
|
|
@@ -59,8 +56,9 @@ TemplateRow.displayName = 'TemplateRow';
|
|
|
59
56
|
const UpdateLog = React.memo(({ updates, templateDir, }) => {
|
|
60
57
|
const sortedUpdates = useMemo(() => {
|
|
61
58
|
return [...updates]
|
|
62
|
-
.sort((a, b) => new Date(
|
|
63
|
-
.slice(0, MAX_CHANGES)
|
|
59
|
+
.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()) // Newest first
|
|
60
|
+
.slice(0, MAX_CHANGES) // Take most recent
|
|
61
|
+
.reverse(); // Display oldest to newest
|
|
64
62
|
}, [updates]);
|
|
65
63
|
const formatError = (error) => {
|
|
66
64
|
if (error instanceof Error)
|
|
@@ -74,14 +72,18 @@ const UpdateLog = React.memo(({ updates, templateDir, }) => {
|
|
|
74
72
|
};
|
|
75
73
|
return (React.createElement(Box, { flexDirection: "column", marginTop: 1 },
|
|
76
74
|
React.createElement(Text, { bold: true }, "Changelog:"),
|
|
77
|
-
!sortedUpdates.length && React.createElement(
|
|
75
|
+
!sortedUpdates.length && React.createElement(Spinner, { label: "No updates yet, watching..." }),
|
|
78
76
|
sortedUpdates.map(update => (React.createElement(Box, { key: `${update.template.path}-${update.timestamp}`, marginLeft: 2 },
|
|
79
77
|
React.createElement(Text, { color: update.type === 'error'
|
|
80
78
|
? COLOR_ERROR
|
|
81
79
|
: update.type === 'applied'
|
|
82
80
|
? COLOR_SUCCESS
|
|
83
81
|
: COLOR_ACCENT },
|
|
84
|
-
update.type === 'error'
|
|
82
|
+
update.type === 'error'
|
|
83
|
+
? figures.cross
|
|
84
|
+
: update.type === 'applied'
|
|
85
|
+
? figures.play
|
|
86
|
+
: figures.info,
|
|
85
87
|
' ',
|
|
86
88
|
formatTemplateDisplay(update.template.path, templateDir ?? ''),
|
|
87
89
|
":",
|
|
@@ -94,7 +96,7 @@ const UpdateLog = React.memo(({ updates, templateDir, }) => {
|
|
|
94
96
|
});
|
|
95
97
|
UpdateLog.displayName = 'UpdateLog';
|
|
96
98
|
export default function Watch() {
|
|
97
|
-
|
|
99
|
+
useFullscreen();
|
|
98
100
|
const { templates, updates, stats, isLoading, errors, latestPath, templateDir } = useTemplateManager();
|
|
99
101
|
const [showUpdates, setShowUpdates] = React.useState(store.get('showWatchLogs'));
|
|
100
102
|
const activeTemplates = useMemo(() => templates.slice(-MAX_FILES), [templates]);
|
|
@@ -106,11 +108,6 @@ export default function Watch() {
|
|
|
106
108
|
store.set('showWatchLogs', show);
|
|
107
109
|
}
|
|
108
110
|
});
|
|
109
|
-
if (!isConnected) {
|
|
110
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
111
|
-
React.createElement(Text, { color: COLOR_ERROR }, "Unable to connect to database. Is Supabase running?"),
|
|
112
|
-
React.createElement(Quittable, null)));
|
|
113
|
-
}
|
|
114
111
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
115
112
|
React.createElement(Branding, { subtitle: "\uD83D\uDC40 Watch Mode" }),
|
|
116
113
|
React.createElement(Box, { marginBottom: 1 },
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1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AAE,KAAK,CAAC,EAAE,EAAE,CAAC,CACnD,oBAAC,GAAG,IAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;oBACzC,oBAAC,IAAI,IAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAC,MAAM;wBAClC,qBAAqB,CAAC,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC;;wBAAI,MAAM,CAAC,KAAK,CAAC,CAC3D,CACH,CACP,CAAC,CACE,CACP,CACG,CACP;QAED,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC,EAAE,aAAa,EAAC,KAAK,EAAC,GAAG,EAAE,CAAC;YACzC,oBAAC,SAAS,OAAG;YACb;gBACE,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;oBACb,oBAAC,IAAI,IAAC,QAAQ,mBAAS,CACnB;gBACN,oBAAC,GAAG,IAAC,OAAO,EAAE,CAAC;oBACb,oBAAC,IAAI,IAAC,QAAQ,mBAAc;oBAC5B,oBAAC,IAAI,IAAC,SAAS,EAAE,WAAW,QAAU;oBACtC,oBAAC,IAAI,IAAC,QAAQ,+BAA0B,CACpC,CACL,CACC,CACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -23,7 +23,7 @@ export default function Branding({ subtitle }) {
|
|
|
23
23
|
React.createElement(Text, { bold: true, color: COLOR_SUPABASE }, "D"),
|
|
24
24
|
"efinitions")),
|
|
25
25
|
React.createElement(Text, { dimColor: true },
|
|
26
|
-
"v",
|
|
26
|
+
" v",
|
|
27
27
|
packageJson.version))));
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=Branding.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Branding.js","sourceRoot":"","sources":["../../src/components/Branding.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACh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K,EAAE,cAAc,QAEzB;6BAEF,CACR;YACD,oBAAC,IAAI,IAAC,QAAQ;;gBAAI,WAAW,CAAC,OAAO,CAAQ,CACzC,CACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,32 +1,44 @@
|
|
|
1
|
+
import figures from 'figures';
|
|
1
2
|
import { Box, Text } from 'ink';
|
|
2
3
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
4
|
+
import { StatBadge } from './StatBadge.js';
|
|
5
|
+
import { COLOR_ERROR, COLOR_SKIP, COLOR_SUCCESS } from './customTheme.js';
|
|
6
|
+
function ResultSection({ items, label, variant, }) {
|
|
5
7
|
if (items.length === 0)
|
|
6
8
|
return null;
|
|
9
|
+
const icon = variant === 'build' ? figures.tick : variant === 'apply' ? figures.play : figures.pointerSmall;
|
|
10
|
+
const maxItems = 30;
|
|
11
|
+
const itemsToShow = items.slice(0, maxItems);
|
|
12
|
+
const overflow = items.length > maxItems ? `... and ${items.length - maxItems} more` : '';
|
|
13
|
+
const color = variant === 'skip' ? COLOR_SKIP : COLOR_SUCCESS;
|
|
7
14
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
8
|
-
React.createElement(Text,
|
|
15
|
+
React.createElement(Text, { bold: true },
|
|
9
16
|
label,
|
|
10
17
|
":"),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
React.createElement(Box, { marginLeft: 2, flexDirection: "column" },
|
|
19
|
+
itemsToShow.map(item => (React.createElement(Text, { key: item, color: color },
|
|
20
|
+
icon,
|
|
21
|
+
" ",
|
|
22
|
+
item))),
|
|
23
|
+
overflow && React.createElement(Text, { dimColor: true }, overflow))));
|
|
14
24
|
}
|
|
15
25
|
export function ProcessingResults({ result, showBuild = true, showApply = false }) {
|
|
16
26
|
return (React.createElement(Box, { flexDirection: "column", gap: 1 },
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"Skipped ",
|
|
21
|
-
result.skipped.length,
|
|
22
|
-
" template(s)")),
|
|
27
|
+
React.createElement(ResultSection, { items: result.skipped, label: "Skipped", variant: "skip" }),
|
|
28
|
+
showBuild && React.createElement(ResultSection, { items: result.built, label: "Built", variant: "build" }),
|
|
29
|
+
showApply && React.createElement(ResultSection, { items: result.applied, label: "Applied", variant: "apply" }),
|
|
23
30
|
result.errors.length > 0 && (React.createElement(Box, { flexDirection: "column" },
|
|
24
31
|
React.createElement(Text, { color: COLOR_ERROR }, "Errors:"),
|
|
25
32
|
result.errors.map(error => (React.createElement(Text, { key: error.file, color: COLOR_ERROR },
|
|
26
|
-
|
|
33
|
+
figures.cross,
|
|
34
|
+
" ",
|
|
27
35
|
error.templateName,
|
|
28
36
|
": ",
|
|
29
37
|
error.error))))),
|
|
30
|
-
|
|
38
|
+
React.createElement(Box, { marginBottom: 1, gap: 1 },
|
|
39
|
+
result.skipped.length > 0 && (React.createElement(StatBadge, { label: "Skipped", value: result.skipped.length, color: COLOR_SKIP })),
|
|
40
|
+
result.errors.length > 0 && (React.createElement(StatBadge, { label: "Errors", value: result.errors.length, color: COLOR_ERROR })),
|
|
41
|
+
result.built.length > 0 && (React.createElement(StatBadge, { label: "Built", value: result.built.length, color: COLOR_SUCCESS })),
|
|
42
|
+
result.applied.length > 0 && (React.createElement(StatBadge, { label: "Applied", value: result.applied.length, color: COLOR_SUCCESS })))));
|
|
31
43
|
}
|
|
32
44
|
//# sourceMappingURL=ProcessingResults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessingResults.js","sourceRoot":"","sources":["../../src/components/ProcessingResults.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProcessingResults.js","sourceRoot":"","sources":["../../src/components/ProcessingResults.tsx"],"names":[],"mapp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,SAAS,IAAC,KAAK,EAAC,SAAS,EAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,GAAI,CAC/E;YACA,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAC3B,oBAAC,SAAS,IAAC,KAAK,EAAC,QAAQ,EAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,GAAI,CAC9E;YACA,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAC1B,oBAAC,SAAS,IAAC,KAAK,EAAC,OAAO,EAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,aAAa,GAAI,CAC9E;YACA,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAC5B,oBAAC,SAAS,IAAC,KAAK,EAAC,SAAS,EAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,aAAa,GAAI,CAClF,CACG,CACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Box, Text, useInput } from 'ink';
|
|
1
|
+
import { Box, Text, useApp, useInput } from 'ink';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
export default function Quittable(props) {
|
|
5
4
|
// Use ref to track if component is mounted
|
|
5
|
+
const { exit } = useApp();
|
|
6
6
|
const mounted = React.useRef(true);
|
|
7
7
|
React.useEffect(() => {
|
|
8
8
|
return () => {
|
|
@@ -18,11 +18,13 @@ export default function Quittable(props) {
|
|
|
18
18
|
props.onQuit();
|
|
19
19
|
}
|
|
20
20
|
// Exit synchronously
|
|
21
|
-
|
|
21
|
+
exit();
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
24
|
console.error('Failed to exit cleanly:', error);
|
|
25
|
-
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
exit(error);
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quittable.js","sourceRoot":"","sources":["../../src/components/Quittable.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Quittable.js","sourceRoot":"","sources":["../../src/components/Quittable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAqB;IACrD,2CAA2C;IAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,QAAQ,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtB,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,OAAO;QAE7B,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,KAAK,GAAG,CAAC,EAAE,CAAC;YAC/D,IAAI,CAAC;gBACH,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC;oBAClB,KAAK,CAAC,MAAM,EAAE,CAAC;gBACjB,CAAC;gBACD,qBAAqB;gBACrB,IAAI,EAAE,CAAC;YACT,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;gBAChD,IAA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