Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

create-theme.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. "use strict";
  2. /* -----------------------------------------------------------------------------
  3. | Copyright (c) Jupyter Development Team.
  4. | Distributed under the terms of the Modified BSD License.
  5. |----------------------------------------------------------------------------*/
  6. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  7. if (k2 === undefined) k2 = k;
  8. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  9. }) : (function(o, m, k, k2) {
  10. if (k2 === undefined) k2 = k;
  11. o[k2] = m[k];
  12. }));
  13. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  14. Object.defineProperty(o, "default", { enumerable: true, value: v });
  15. }) : function(o, v) {
  16. o["default"] = v;
  17. });
  18. var __importStar = (this && this.__importStar) || function (mod) {
  19. if (mod && mod.__esModule) return mod;
  20. var result = {};
  21. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  22. __setModuleDefault(result, mod);
  23. return result;
  24. };
  25. Object.defineProperty(exports, "__esModule", { value: true });
  26. const fs = __importStar(require("fs-extra"));
  27. const inquirer = __importStar(require("inquirer"));
  28. const path = __importStar(require("path"));
  29. const utils = __importStar(require("./utils"));
  30. const questions = [
  31. {
  32. type: 'input',
  33. name: 'name',
  34. message: 'name: '
  35. },
  36. {
  37. type: 'input',
  38. name: 'title',
  39. message: 'title: '
  40. },
  41. {
  42. type: 'input',
  43. name: 'description',
  44. message: 'description: '
  45. }
  46. ];
  47. const template = `
  48. import {
  49. JupyterFrontEnd, JupyterFrontEndPlugin
  50. } from '@jupyterlab/application';
  51. import {
  52. IThemeManager
  53. } from '@jupyterlab/apputils';
  54. /**
  55. * A plugin for the {{title}}
  56. */
  57. const plugin: JupyterFrontEndPlugin<void> = {
  58. id: '{{name}}:plugin',
  59. requires: [IThemeManager],
  60. activate: (app: JupyterFrontEnd, manager: IThemeManager) => {
  61. manager.register({
  62. name: '{{title}}',
  63. isLight: true,
  64. load: () => manager.loadCSS('{{name}}/index.css'),
  65. unload: () => Promise.resolve(undefined)
  66. });
  67. },
  68. autoStart: true
  69. };
  70. export default plugin;
  71. `;
  72. void inquirer.prompt(questions).then(answers => {
  73. const { name, title, description } = answers;
  74. const dest = path.resolve(path.join('.', name));
  75. if (fs.existsSync(dest)) {
  76. console.error('Package already exists: ', name);
  77. process.exit(1);
  78. }
  79. fs.copySync(path.resolve('.', 'packages', 'theme-light-extension'), dest);
  80. const jsonPath = path.join(dest, 'package.json');
  81. const data = utils.readJSONFile(jsonPath);
  82. data.name = name;
  83. data.description = description;
  84. utils.writePackageData(jsonPath, data);
  85. // update the urls in urls.css
  86. const filePath = path.resolve('.', name, 'style', 'urls.css');
  87. let text = fs.readFileSync(filePath, 'utf8');
  88. text = text.split('@jupyterlab/theme-light-extension').join(name);
  89. fs.writeFileSync(filePath, text, 'utf8');
  90. // remove lib, node_modules and static.
  91. ['lib', 'node_modules', 'static'].forEach(folder => {
  92. const folderPath = path.join('.', name, folder);
  93. if (fs.existsSync(folderPath)) {
  94. fs.removeSync(folderPath);
  95. }
  96. });
  97. const readme = `${name}\n${description}\n`;
  98. fs.writeFileSync(path.join('.', name, 'README.md'), readme, 'utf8');
  99. let src = template.split('{{name}}').join(name);
  100. src = src.split('{{title}}').join(title);
  101. fs.writeFileSync(path.join('.', name, 'src', 'index.ts'), src, 'utf8');
  102. // Signify successful complation.
  103. console.debug(`Created new theme ${name}`);
  104. });
  105. //# sourceMappingURL=create-theme.js.map