A color scheme for you to love. ♡ https://love.holllo.cc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

119 lines
2.7 KiB

  1. import {promises as fsp} from 'fs';
  2. import {join} from 'path';
  3. import prompts from 'prompts';
  4. import semver from 'semver';
  5. export interface Versions {
  6. [index: string]: string;
  7. firefox: string;
  8. kitty: string;
  9. 'sublime-text': string;
  10. tauon: string;
  11. vscode: string;
  12. }
  13. export async function main(): Promise<void> {
  14. const versions: Versions = await getVersions();
  15. const command = await prompts({
  16. message: 'What do you want to do?',
  17. name: 'command',
  18. type: 'select',
  19. choices: [
  20. {
  21. title: 'Show',
  22. value: 'show'
  23. },
  24. {
  25. title: 'Update',
  26. value: 'update'
  27. }
  28. ],
  29. initial: 0
  30. });
  31. if (command.command === 'show') {
  32. console.log(versions);
  33. return;
  34. }
  35. if (command.command === 'update') {
  36. const whichTheme = await prompts({
  37. message: 'Which theme do you want to update?',
  38. name: 'theme',
  39. type: 'select',
  40. choices: Object.keys(versions).map((value) => ({
  41. title: `${value} (${String(versions[value])})`,
  42. value
  43. })),
  44. initial: 0
  45. });
  46. const currentVersion: string = versions[whichTheme.theme];
  47. const whichVersion = await prompts({
  48. message: 'To what version do you want to update?',
  49. name: 'version',
  50. type: 'select',
  51. choices: [
  52. {
  53. title: `Major (${currentVersion} -> ${semver.inc(
  54. currentVersion,
  55. 'major'
  56. )!})`,
  57. value: 'major'
  58. },
  59. {
  60. title: `Minor (${currentVersion} -> ${semver.inc(
  61. currentVersion,
  62. 'minor'
  63. )!})`,
  64. value: 'minor'
  65. },
  66. {
  67. title: `Patch (${currentVersion} -> ${semver.inc(
  68. currentVersion,
  69. 'patch'
  70. )!})`,
  71. value: 'patch'
  72. }
  73. ],
  74. initial: 0
  75. });
  76. const selectedTheme: string = whichTheme.theme;
  77. const newVersion: string = semver.inc(
  78. currentVersion,
  79. whichVersion.version
  80. )!;
  81. versions[selectedTheme] = newVersion;
  82. await fsp.writeFile(
  83. join(__dirname, '../../love-versions.json'),
  84. JSON.stringify(versions, null, 2) + '\n'
  85. );
  86. if (['vscode'].includes(selectedTheme)) {
  87. const packageLocation: string = join(
  88. __dirname,
  89. `../${selectedTheme}/package.json`
  90. );
  91. const themePackage: any = JSON.parse(
  92. await fsp.readFile(packageLocation, 'utf8')
  93. );
  94. themePackage.version = newVersion;
  95. await fsp.writeFile(
  96. packageLocation,
  97. JSON.stringify(themePackage, null, 2) + '\n'
  98. );
  99. }
  100. }
  101. }
  102. export async function getVersions(): Promise<Versions> {
  103. return JSON.parse(
  104. await fsp.readFile(join(__dirname, '../../love-versions.json'), 'utf8')
  105. );
  106. }
  107. if (require.main === module) {
  108. void main();
  109. }