mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(packages): add poster component to video skins (#994)
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
import { confirm, filePath, getChanges, printDiff, srcPath, templatesPath } from './shared.js';
|
||||
import {
|
||||
confirm,
|
||||
filePath,
|
||||
getChanges,
|
||||
mirrorTemplatesToSrc,
|
||||
printDiff,
|
||||
removeGeneratedSrcFiles,
|
||||
srcPath,
|
||||
templatesPath,
|
||||
} from './shared.js';
|
||||
|
||||
const changes = getChanges();
|
||||
|
||||
@@ -9,25 +18,39 @@ const changes = getChanges();
|
||||
const modified = changes.filter((d) => d.state === 'distinct');
|
||||
// Files only in src (will be deleted)
|
||||
const added = changes.filter((d) => d.state === 'left');
|
||||
// Files only in templates (will be recreated in src)
|
||||
const missing = changes.filter((d) => d.state === 'right');
|
||||
|
||||
if (modified.length === 0 && added.length === 0) {
|
||||
if (modified.length === 0 && added.length === 0 && missing.length === 0) {
|
||||
console.log(chalk.gray('\nNo local changes. Already in sync with templates.\n'));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(chalk.bold('\nThe following local changes will be lost:\n'));
|
||||
if (modified.length > 0 || added.length > 0) {
|
||||
console.log(chalk.bold('\nThe following changes in src/ will be replaced from templates/:\n'));
|
||||
}
|
||||
|
||||
for (const change of modified) {
|
||||
const label = filePath(change);
|
||||
console.log(chalk.yellow(` ~ ${label}`));
|
||||
printDiff(templatesPath(change), srcPath(change), label);
|
||||
printDiff(srcPath(change), templatesPath(change), label);
|
||||
}
|
||||
|
||||
for (const change of added) {
|
||||
console.log(chalk.red(` + ${filePath(change)} (will be deleted)`));
|
||||
}
|
||||
|
||||
console.log();
|
||||
if (missing.length > 0) {
|
||||
console.log(chalk.bold('\nThe following template files will be restored into src/:\n'));
|
||||
|
||||
for (const change of missing) {
|
||||
console.log(chalk.green(` + ${filePath(change)} (will be restored)`));
|
||||
}
|
||||
}
|
||||
|
||||
if (modified.length > 0 || added.length > 0 || missing.length > 0) {
|
||||
console.log();
|
||||
}
|
||||
|
||||
const ok = await confirm('Reset src/ to templates? This cannot be undone.');
|
||||
|
||||
@@ -46,4 +69,15 @@ for (const change of added) {
|
||||
console.log(chalk.red(` ✔ Deleted ${filePath(change)}`));
|
||||
}
|
||||
|
||||
const restored = await mirrorTemplatesToSrc();
|
||||
const removedGenerated = await removeGeneratedSrcFiles();
|
||||
|
||||
for (const file of restored) {
|
||||
console.log(chalk.green(` ✔ Restored ${file.replace(/^src\//, '')}`));
|
||||
}
|
||||
|
||||
for (const file of removedGenerated) {
|
||||
console.log(chalk.green(` ✔ Removed generated ${file.replace(/^src\//, '')}`));
|
||||
}
|
||||
|
||||
console.log(chalk.bold.green('\nReset complete!\n'));
|
||||
|
||||
Reference in New Issue
Block a user