ctheme 0.1.2 → 0.1.3
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 +1 -1
- package/bin/ctheme.js +31 -18
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/ctheme.js
CHANGED
|
@@ -912,6 +912,10 @@ function listInstalledFonts() {
|
|
|
912
912
|
}
|
|
913
913
|
|
|
914
914
|
function installGoogleFont(family) {
|
|
915
|
+
return installGoogleFontWithOptions(family, {});
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
function installGoogleFontWithOptions(family, options = {}) {
|
|
915
919
|
const paths = getThemePaths();
|
|
916
920
|
ensureDir(paths.managedFontDir);
|
|
917
921
|
const installed = downloadGoogleFontFiles(family, paths.managedFontDir);
|
|
@@ -919,13 +923,13 @@ function installGoogleFont(family) {
|
|
|
919
923
|
fail(`No installable font files found for ${family}`);
|
|
920
924
|
}
|
|
921
925
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
console.log("Warning: this family looks proportional. It may render poorly in terminal grids.");
|
|
926
|
+
if (!options.quiet) {
|
|
927
|
+
console.log(`Installed ${family} into ${paths.managedFontDir}`);
|
|
928
|
+
for (const file of installed) {
|
|
929
|
+
console.log(`- ${file}`);
|
|
930
|
+
}
|
|
928
931
|
}
|
|
932
|
+
return installed;
|
|
929
933
|
}
|
|
930
934
|
|
|
931
935
|
function searchGoogleFonts(query) {
|
|
@@ -951,8 +955,7 @@ function searchGoogleFonts(query) {
|
|
|
951
955
|
}
|
|
952
956
|
|
|
953
957
|
for (const font of matches) {
|
|
954
|
-
|
|
955
|
-
console.log(`${font.family} (${mono})`);
|
|
958
|
+
console.log(font.family);
|
|
956
959
|
}
|
|
957
960
|
}
|
|
958
961
|
|
|
@@ -993,12 +996,13 @@ function downloadGoogleFontFiles(family, targetDir) {
|
|
|
993
996
|
execFileSync("curl", [
|
|
994
997
|
"-L",
|
|
995
998
|
"--fail",
|
|
999
|
+
"-sS",
|
|
996
1000
|
"-H",
|
|
997
1001
|
"User-Agent: pretty-code",
|
|
998
1002
|
"--output",
|
|
999
1003
|
destPath,
|
|
1000
1004
|
entry.download_url
|
|
1001
|
-
], { stdio: "
|
|
1005
|
+
], { stdio: "pipe" });
|
|
1002
1006
|
installed.push(destPath);
|
|
1003
1007
|
}
|
|
1004
1008
|
|
|
@@ -1209,30 +1213,39 @@ async function promptYesNo(rl, label, defaultValue) {
|
|
|
1209
1213
|
}
|
|
1210
1214
|
|
|
1211
1215
|
function installFontsBestEffort(fonts) {
|
|
1216
|
+
const installedFamilies = [];
|
|
1212
1217
|
for (const family of [...new Set(fonts.filter(Boolean))]) {
|
|
1213
1218
|
try {
|
|
1214
|
-
|
|
1219
|
+
installGoogleFontWithOptions(family, { quiet: true });
|
|
1220
|
+
installedFamilies.push(family);
|
|
1215
1221
|
} catch (error) {
|
|
1216
|
-
console.log(`Skipped
|
|
1222
|
+
console.log(`Skipped ${family}`);
|
|
1217
1223
|
}
|
|
1218
1224
|
}
|
|
1225
|
+
if (installedFamilies.length) {
|
|
1226
|
+
console.log(`Installed fonts: ${installedFamilies.join(", ")}`);
|
|
1227
|
+
}
|
|
1219
1228
|
}
|
|
1220
1229
|
|
|
1221
1230
|
function printThemeSummary(theme) {
|
|
1222
1231
|
console.log(` name: ${theme.name}`);
|
|
1223
1232
|
console.log(` preset: ${theme.preset}`);
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1233
|
+
printColorLine("accent", theme.accent);
|
|
1234
|
+
printColorLine("bg", theme.bg);
|
|
1235
|
+
printColorLine("surface", theme.surface);
|
|
1236
|
+
printColorLine("surface alt", theme.surfaceAlt);
|
|
1237
|
+
printColorLine("text", theme.fg);
|
|
1238
|
+
printColorLine("muted", theme.muted);
|
|
1239
|
+
printColorLine("dim", theme.dim);
|
|
1231
1240
|
console.log(` terminal font: ${theme.fonts.terminal}`);
|
|
1232
1241
|
console.log(` ui font: ${theme.fonts.ui}`);
|
|
1233
1242
|
console.log(` code font: ${theme.fonts.code}`);
|
|
1234
1243
|
}
|
|
1235
1244
|
|
|
1245
|
+
function printColorLine(label, hex) {
|
|
1246
|
+
console.log(` ${label}: ${colorBlock(hex, 8)} ${hex}`);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1236
1249
|
function writeThemeAssets(paths, name, palette) {
|
|
1237
1250
|
ensureDir(paths.paletteDir);
|
|
1238
1251
|
fs.writeFileSync(path.join(paths.paletteDir, `${name}.json`), `${JSON.stringify(palette, null, 2)}\n`, "utf8");
|