@t1mmen/srtd
Version:
Supabase Repeatable Template Definitions (srtd): 🪄 Live-reloading SQL templates for Supabase DX. Make your database changes reviewable and migrations maintainable! 🚀
47 lines • 1.64 kB
JavaScript
import { isWipTemplate } from './isWipTemplate.js';
export function toTemplateResults(processed, getTemplateInfo, context, options = {}) {
const results = [];
const { wipIndicator = '.wip' } = options;
// Skipped/unchanged templates (oldest - at top)
for (const name of processed.skipped) {
const info = getTemplateInfo(name);
const isWip = context.command === 'build' && isWipTemplate(name, wipIndicator);
results.push({
template: name,
status: isWip ? 'skipped' : 'unchanged',
target: context.command === 'build' && !isWip ? info.migrationFile : undefined,
timestamp: info.lastDate ? new Date(info.lastDate) : undefined,
});
}
// Applied templates (success)
if (context.command === 'apply') {
for (const name of processed.applied) {
results.push({
template: name,
status: 'success',
});
}
}
// Built templates (for build command)
if (context.command === 'build') {
for (const name of processed.built) {
const info = getTemplateInfo(name);
results.push({
template: name,
status: 'success',
target: info.migrationFile,
});
}
}
// Errors (newest - at bottom)
for (const err of processed.errors) {
results.push({
template: err.file,
status: 'error',
errorMessage: err.error,
errorHint: err.hint,
});
}
return results;
}
//# sourceMappingURL=resultTransformer.js.map