fontastic 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/.editorconfig +16 -0
- package/.eslintrc.json +54 -0
- package/.github/FUNDING.yml +12 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +29 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/dependabot.yml +6 -0
- package/.github/pull_request_template.md +21 -0
- package/.github/stale.yml +17 -0
- package/.github/workflows/macos.yml +58 -0
- package/.github/workflows/ubuntu.yml +70 -0
- package/.github/workflows/windows.yml +64 -0
- package/.node-version +1 -0
- package/.vscode/launch.json +46 -0
- package/.vscode/tasks.json +49 -0
- package/CODE_OF_CONDUCT.md +45 -0
- package/CONTRIBUTING.md +72 -0
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/_config.yml +1 -0
- package/angular.json +194 -0
- package/angular.webpack.js +32 -0
- package/app/Application.js +40 -0
- package/app/Application.ts +38 -0
- package/app/config/alert.ts +32 -0
- package/app/config/database.js +203 -0
- package/app/config/database.ts +202 -0
- package/app/config/index.js +20 -0
- package/app/config/index.ts +3 -0
- package/app/config/mimes.js +49 -0
- package/app/config/mimes.ts +54 -0
- package/app/config/system.js +497 -0
- package/app/config/system.ts +498 -0
- package/app/config/themes.ts +38 -0
- package/app/core/AppLogger.js +31 -0
- package/app/core/AppLogger.ts +38 -0
- package/app/core/ConfigManager.js +114 -0
- package/app/core/ConfigManager.ts +137 -0
- package/app/core/ConnectionManager.js +83 -0
- package/app/core/ConnectionManager.ts +95 -0
- package/app/core/FontCatalog.js +51 -0
- package/app/core/FontCatalog.ts +42 -0
- package/app/core/FontFinder.js +86 -0
- package/app/core/FontFinder.ts +96 -0
- package/app/core/FontInstaller.js +67 -0
- package/app/core/FontInstaller.ts +63 -0
- package/app/core/FontManager.js +165 -0
- package/app/core/FontManager.ts +172 -0
- package/app/core/FontObject.js +54 -0
- package/app/core/FontObject.ts +62 -0
- package/app/core/MessageHandler.js +272 -0
- package/app/core/MessageHandler.ts +337 -0
- package/app/core/SystemManager.js +140 -0
- package/app/core/SystemManager.ts +171 -0
- package/app/core/menu/Example.ts +280 -0
- package/app/core/menu/MenuBuilder.js +45 -0
- package/app/core/menu/MenuBuilder.ts +53 -0
- package/app/core/menu/templates/DarwinTemplate.js +127 -0
- package/app/core/menu/templates/DarwinTemplate.ts +142 -0
- package/app/core/menu/templates/SystemTemplate.js +124 -0
- package/app/core/menu/templates/SystemTemplate.ts +139 -0
- package/app/database/entity/Collection.schema.js +99 -0
- package/app/database/entity/Collection.schema.ts +68 -0
- package/app/database/entity/Logger.schema.js +50 -0
- package/app/database/entity/Logger.schema.ts +26 -0
- package/app/database/entity/Store.schema.js +165 -0
- package/app/database/entity/Store.schema.ts +116 -0
- package/app/database/entity/index.js +20 -0
- package/app/database/entity/index.ts +3 -0
- package/app/database/repository/Collection.repository.js +181 -0
- package/app/database/repository/Collection.repository.ts +190 -0
- package/app/database/repository/Logger.repository.js +25 -0
- package/app/database/repository/Logger.repository.ts +11 -0
- package/app/database/repository/Store.repository.js +328 -0
- package/app/database/repository/Store.repository.ts +358 -0
- package/app/database/repository/User.repository.js +12 -0
- package/app/database/repository/User.repository.ts +8 -0
- package/app/database/repository/index.js +20 -0
- package/app/database/repository/index.ts +3 -0
- package/app/enums/ChannelType.js +62 -0
- package/app/enums/ChannelType.ts +65 -0
- package/app/enums/StorageType.js +19 -0
- package/app/enums/index.js +19 -0
- package/app/enums/index.ts +2 -0
- package/app/enums/storageType.ts +14 -0
- package/app/helpers/command.js +28 -0
- package/app/helpers/command.ts +20 -0
- package/app/helpers/random.js +16 -0
- package/app/helpers/random.ts +12 -0
- package/app/main.js +82 -0
- package/app/main.ts +94 -0
- package/app/package-lock.json +2649 -0
- package/app/package.json +35 -0
- package/app/types/AppAlert.js +3 -0
- package/app/types/AppAlert.ts +8 -0
- package/app/types/AuthUser.js +7 -0
- package/app/types/AuthUser.ts +5 -0
- package/app/types/Breadcrumb.js +3 -0
- package/app/types/Breadcrumb.ts +5 -0
- package/app/types/ImportOptions.js +7 -0
- package/app/types/ImportOptions.ts +3 -0
- package/app/types/QueryOptions.js +3 -0
- package/app/types/QueryOptions.ts +12 -0
- package/app/types/SystemConfig.js +3 -0
- package/app/types/SystemConfig.ts +132 -0
- package/app/types/SystemStats.js +3 -0
- package/app/types/SystemStats.ts +7 -0
- package/app/types/SystemTheme.js +3 -0
- package/app/types/SystemTheme.ts +5 -0
- package/app/types/index.js +25 -0
- package/app/types/index.ts +8 -0
- package/docs/logo.png +0 -0
- package/docs/screenshots/readme.md +7 -0
- package/docs/screenshots/screen-grab1.png +0 -0
- package/docs/screenshots/screen-grab2.png +0 -0
- package/docs/screenshots/screen-grab3.png +0 -0
- package/e2e/main.spec.ts +59 -0
- package/e2e/playwright.config.ts +19 -0
- package/e2e/tsconfig.e2e.json +13 -0
- package/electron-builder.json +71 -0
- package/package.json +121 -0
- package/src/app/app-routing.module.ts +15 -0
- package/src/app/app.component.html +1 -0
- package/src/app/app.component.scss +0 -0
- package/src/app/app.component.spec.ts.dist +33 -0
- package/src/app/app.component.ts +37 -0
- package/src/app/app.module.ts +63 -0
- package/src/app/core/core.module.ts +11 -0
- package/src/app/core/model/AuthUserModel.ts +7 -0
- package/src/app/core/model/CustomThemeModel.ts +7 -0
- package/src/app/core/model/DbConnectionModel.ts +16 -0
- package/src/app/core/model/ImportOptionsModel.ts +5 -0
- package/src/app/core/model/LatestNewsModel.ts +7 -0
- package/src/app/core/model/SearchFormModel.ts +10 -0
- package/src/app/core/model/index.ts +6 -0
- package/src/app/core/services/alert/alert.service.spec.ts +22 -0
- package/src/app/core/services/alert/alert.service.ts +71 -0
- package/src/app/core/services/auth/auth.service.ts +30 -0
- package/src/app/core/services/boot/boot.service.ts +33 -0
- package/src/app/core/services/breadcrumb/breadcrumb.service.spec.ts +22 -0
- package/src/app/core/services/breadcrumb/breadcrumb.service.ts +30 -0
- package/src/app/core/services/config/config.service.ts +63 -0
- package/src/app/core/services/database/database.service.ts +286 -0
- package/src/app/core/services/electron/electron.service.spec.ts +12 -0
- package/src/app/core/services/electron/electron.service.ts +62 -0
- package/src/app/core/services/font/font.service.ts +79 -0
- package/src/app/core/services/gravatar/gravatar.service.spec.ts +16 -0
- package/src/app/core/services/gravatar/gravatar.service.ts +18 -0
- package/src/app/core/services/index.ts +14 -0
- package/src/app/core/services/message/message.service.ts +289 -0
- package/src/app/core/services/modal/modal.service.spec.ts +16 -0
- package/src/app/core/services/modal/modal.service.ts +34 -0
- package/src/app/core/services/news/news.service.ts +94 -0
- package/src/app/core/services/presentation/presentation.service.ts +341 -0
- package/src/app/core/services/utils/utils.service.spec.ts +12 -0
- package/src/app/core/services/utils/utils.service.ts +144 -0
- package/src/app/layout/aside/aside.component.html +9 -0
- package/src/app/layout/aside/aside.component.scss +1 -0
- package/src/app/layout/aside/aside.component.ts +26 -0
- package/src/app/layout/footer/footer.component.html +11 -0
- package/src/app/layout/footer/footer.component.scss +27 -0
- package/src/app/layout/footer/footer.component.ts +32 -0
- package/src/app/layout/header/header.component.html +35 -0
- package/src/app/layout/header/header.component.scss +60 -0
- package/src/app/layout/header/header.component.ts +229 -0
- package/src/app/layout/layout.component.html +14 -0
- package/src/app/layout/layout.component.scss +119 -0
- package/src/app/layout/layout.component.ts +23 -0
- package/src/app/layout/layout.module.ts +32 -0
- package/src/app/layout/layout.service.ts +13 -0
- package/src/app/layout/navigation/navigation.component.html +142 -0
- package/src/app/layout/navigation/navigation.component.scss +0 -0
- package/src/app/layout/navigation/navigation.component.ts +302 -0
- package/src/app/pages/main/grid/grid.component.html +160 -0
- package/src/app/pages/main/grid/grid.component.scss +3 -0
- package/src/app/pages/main/grid/grid.component.ts +98 -0
- package/src/app/pages/main/inspect/inspect.component.html +7 -0
- package/src/app/pages/main/inspect/inspect.component.scss +3 -0
- package/src/app/pages/main/inspect/inspect.component.ts +66 -0
- package/src/app/pages/main/main-routing.module.ts +30 -0
- package/src/app/pages/main/main.component.html +6 -0
- package/src/app/pages/main/main.component.scss +191 -0
- package/src/app/pages/main/main.component.ts +35 -0
- package/src/app/pages/main/main.module.ts +28 -0
- package/src/app/pages/main/preview/preview.component.html +46 -0
- package/src/app/pages/main/preview/preview.component.scss +0 -0
- package/src/app/pages/main/preview/preview.component.ts +239 -0
- package/src/app/pages/main/toolbar/toolbar.component.html +78 -0
- package/src/app/pages/main/toolbar/toolbar.component.scss +3 -0
- package/src/app/pages/main/toolbar/toolbar.component.ts +132 -0
- package/src/app/shared/components/alert/alert.component.html +9 -0
- package/src/app/shared/components/alert/alert.component.scss +0 -0
- package/src/app/shared/components/alert/alert.component.ts +37 -0
- package/src/app/shared/components/breadcrumbs/breadcrumbs.component.html +14 -0
- package/src/app/shared/components/breadcrumbs/breadcrumbs.component.scss +0 -0
- package/src/app/shared/components/breadcrumbs/breadcrumbs.component.ts +36 -0
- package/src/app/shared/components/button/button.component.html +3 -0
- package/src/app/shared/components/button/button.component.scss +2 -0
- package/src/app/shared/components/button/button.component.ts +22 -0
- package/src/app/shared/components/collection/create-collection/create-collection.component.html +41 -0
- package/src/app/shared/components/collection/create-collection/create-collection.component.scss +0 -0
- package/src/app/shared/components/collection/create-collection/create-collection.component.ts +68 -0
- package/src/app/shared/components/collection/form-collection/form-collection.component.html +1 -0
- package/src/app/shared/components/collection/form-collection/form-collection.component.scss +0 -0
- package/src/app/shared/components/collection/form-collection/form-collection.component.ts +15 -0
- package/src/app/shared/components/collection/update-collection/update-collection.component.html +40 -0
- package/src/app/shared/components/collection/update-collection/update-collection.component.scss +0 -0
- package/src/app/shared/components/collection/update-collection/update-collection.component.ts +71 -0
- package/src/app/shared/components/glyph-list/glyph-list.component.html +40 -0
- package/src/app/shared/components/glyph-list/glyph-list.component.scss +1 -0
- package/src/app/shared/components/glyph-list/glyph-list.component.ts +165 -0
- package/src/app/shared/components/glyph-view/glyph-view.component.html +23 -0
- package/src/app/shared/components/glyph-view/glyph-view.component.scss +0 -0
- package/src/app/shared/components/glyph-view/glyph-view.component.ts +228 -0
- package/src/app/shared/components/index.ts +16 -0
- package/src/app/shared/components/loading/loading.component.html +1 -0
- package/src/app/shared/components/loading/loading.component.scss +0 -0
- package/src/app/shared/components/loading/loading.component.ts +26 -0
- package/src/app/shared/components/modal/modal.component.html +31 -0
- package/src/app/shared/components/modal/modal.component.scss +0 -0
- package/src/app/shared/components/modal/modal.component.ts +51 -0
- package/src/app/shared/components/page-not-found/page-not-found.component.html +3 -0
- package/src/app/shared/components/page-not-found/page-not-found.component.scss +0 -0
- package/src/app/shared/components/page-not-found/page-not-found.component.ts +12 -0
- package/src/app/shared/components/paginator/paginator.component.html +21 -0
- package/src/app/shared/components/paginator/paginator.component.scss +3 -0
- package/src/app/shared/components/paginator/paginator.component.ts +133 -0
- package/src/app/shared/components/pairing/pairing.component.html +20 -0
- package/src/app/shared/components/pairing/pairing.component.scss +0 -0
- package/src/app/shared/components/pairing/pairing.component.ts +33 -0
- package/src/app/shared/components/search/search.component.html +54 -0
- package/src/app/shared/components/search/search.component.scss +10 -0
- package/src/app/shared/components/search/search.component.ts +77 -0
- package/src/app/shared/components/settings/database/database.component.html +151 -0
- package/src/app/shared/components/settings/database/database.component.scss +0 -0
- package/src/app/shared/components/settings/database/database.component.ts +145 -0
- package/src/app/shared/components/settings/general/general.component.html +170 -0
- package/src/app/shared/components/settings/general/general.component.scss +0 -0
- package/src/app/shared/components/settings/general/general.component.ts +150 -0
- package/src/app/shared/components/settings/logs/logs.component.html +44 -0
- package/src/app/shared/components/settings/logs/logs.component.scss +0 -0
- package/src/app/shared/components/settings/logs/logs.component.ts +37 -0
- package/src/app/shared/components/settings/news/news.component.html +41 -0
- package/src/app/shared/components/settings/news/news.component.scss +0 -0
- package/src/app/shared/components/settings/news/news.component.ts +52 -0
- package/src/app/shared/components/settings/settings.component.html +46 -0
- package/src/app/shared/components/settings/settings.component.scss +0 -0
- package/src/app/shared/components/settings/settings.component.ts +23 -0
- package/src/app/shared/components/settings/system/system.component.html +30 -0
- package/src/app/shared/components/settings/system/system.component.scss +0 -0
- package/src/app/shared/components/settings/system/system.component.ts +43 -0
- package/src/app/shared/components/settings/theme/theme.component.html +22 -0
- package/src/app/shared/components/settings/theme/theme.component.scss +0 -0
- package/src/app/shared/components/settings/theme/theme.component.ts +50 -0
- package/src/app/shared/components/spinner/spinner.component.html +1 -0
- package/src/app/shared/components/spinner/spinner.component.scss +0 -0
- package/src/app/shared/components/spinner/spinner.component.ts +26 -0
- package/src/app/shared/components/store/store.component.html +22 -0
- package/src/app/shared/components/store/store.component.scss +10 -0
- package/src/app/shared/components/store/store.component.ts +58 -0
- package/src/app/shared/components/tables/tables.component.html +47 -0
- package/src/app/shared/components/tables/tables.component.scss +10 -0
- package/src/app/shared/components/tables/tables.component.ts +81 -0
- package/src/app/shared/components/typescale/typescale.component.html +53 -0
- package/src/app/shared/components/typescale/typescale.component.scss +0 -0
- package/src/app/shared/components/typescale/typescale.component.ts +168 -0
- package/src/app/shared/directives/gravatar/gravatar.directive.ts +29 -0
- package/src/app/shared/directives/index.ts +2 -0
- package/src/app/shared/directives/webview/webview.directive.ts +8 -0
- package/src/app/shared/pipes/installable.pipe.ts +10 -0
- package/src/app/shared/pipes/prettybytes.pipe.ts +10 -0
- package/src/app/shared/pipes/safehtml.pipe.ts +10 -0
- package/src/app/shared/shared.module.ts +92 -0
- package/src/assets/.gitkeep +0 -0
- package/src/assets/fonts/fa/fa-brands-400.eot +0 -0
- package/src/assets/fonts/fa/fa-brands-400.svg +3535 -0
- package/src/assets/fonts/fa/fa-brands-400.ttf +0 -0
- package/src/assets/fonts/fa/fa-brands-400.woff +0 -0
- package/src/assets/fonts/fa/fa-brands-400.woff2 +0 -0
- package/src/assets/fonts/fa/fa-regular-400.eot +0 -0
- package/src/assets/fonts/fa/fa-regular-400.svg +803 -0
- package/src/assets/fonts/fa/fa-regular-400.ttf +0 -0
- package/src/assets/fonts/fa/fa-regular-400.woff +0 -0
- package/src/assets/fonts/fa/fa-regular-400.woff2 +0 -0
- package/src/assets/fonts/fa/fa-solid-900.eot +0 -0
- package/src/assets/fonts/fa/fa-solid-900.svg +4700 -0
- package/src/assets/fonts/fa/fa-solid-900.ttf +0 -0
- package/src/assets/fonts/fa/fa-solid-900.woff +0 -0
- package/src/assets/fonts/fa/fa-solid-900.woff2 +0 -0
- package/src/assets/fonts/md/MaterialIcons-Regular.eot +0 -0
- package/src/assets/fonts/md/MaterialIcons-Regular.ijmap +1 -0
- package/src/assets/fonts/md/MaterialIcons-Regular.svg +2373 -0
- package/src/assets/fonts/md/MaterialIcons-Regular.ttf +0 -0
- package/src/assets/fonts/md/MaterialIcons-Regular.woff +0 -0
- package/src/assets/fonts/md/MaterialIcons-Regular.woff2 +0 -0
- package/src/assets/fonts/md/README.md +9 -0
- package/src/assets/fonts/md/codepoints +932 -0
- package/src/assets/fonts/md/material-icons.css +36 -0
- package/src/assets/fonts/octicon/octicon.eot +0 -0
- package/src/assets/fonts/octicon/octicon.svg +378 -0
- package/src/assets/fonts/octicon/octicon.ttf +0 -0
- package/src/assets/fonts/octicon/octicon.woff +0 -0
- package/src/assets/fonts/octicon/octicon.woff2 +0 -0
- package/src/assets/fonts/roboto/Roboto-Bold-webfont.eot +0 -0
- package/src/assets/fonts/roboto/Roboto-Bold-webfont.svg +607 -0
- package/src/assets/fonts/roboto/Roboto-Bold-webfont.ttf +0 -0
- package/src/assets/fonts/roboto/Roboto-Bold-webfont.woff +0 -0
- package/src/assets/fonts/roboto/Roboto-Medium-webfont.eot +0 -0
- package/src/assets/fonts/roboto/Roboto-Medium-webfont.svg +607 -0
- package/src/assets/fonts/roboto/Roboto-Medium-webfont.ttf +0 -0
- package/src/assets/fonts/roboto/Roboto-Medium-webfont.woff +0 -0
- package/src/assets/fonts/roboto/Roboto-Regular-webfont.eot +0 -0
- package/src/assets/fonts/roboto/Roboto-Regular-webfont.svg +635 -0
- package/src/assets/fonts/roboto/Roboto-Regular-webfont.ttf +0 -0
- package/src/assets/fonts/roboto/Roboto-Regular-webfont.woff +0 -0
- package/src/assets/i18n/en.json +12 -0
- package/src/assets/icons/android-chrome-192x192.png +0 -0
- package/src/assets/icons/android-chrome-512x512.png +0 -0
- package/src/assets/icons/apple-touch-icon.png +0 -0
- package/src/assets/icons/favicon-16x16.png +0 -0
- package/src/assets/icons/favicon-32x32.png +0 -0
- package/src/assets/icons/favicon.ico +0 -0
- package/src/assets/icons/site.webmanifest +1 -0
- package/src/assets/images/electron.bmp +0 -0
- package/src/bin/activator +0 -0
- package/src/bin/activator.exe +0 -0
- package/src/environments/environment.dev.ts +4 -0
- package/src/environments/environment.prod.ts +4 -0
- package/src/environments/environment.ts +4 -0
- package/src/environments/environment.web.prod.ts +4 -0
- package/src/environments/environment.web.ts +4 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +55 -0
- package/src/karma.conf.js +50 -0
- package/src/main.ts +15 -0
- package/src/polyfills-test.ts +1 -0
- package/src/polyfills.ts +53 -0
- package/src/styles/base/loading.scss +87 -0
- package/src/styles/base/reset.scss +408 -0
- package/src/styles/components/alert.scss +54 -0
- package/src/styles/components/buttons.scss +93 -0
- package/src/styles/components/forms.scss +96 -0
- package/src/styles/components/inputs.scss +113 -0
- package/src/styles/components/modal.scss +52 -0
- package/src/styles/components/paginator.scss +108 -0
- package/src/styles/components/scrollbox.scss +71 -0
- package/src/styles/components/spinner.scss +11 -0
- package/src/styles/components/tables.scss +42 -0
- package/src/styles/components/tabs.scss +44 -0
- package/src/styles/components/toolbar.scss +130 -0
- package/src/styles/fonts/md.scss +54 -0
- package/src/styles/fonts/octicons.scss +1351 -0
- package/src/styles/fonts/roboto.scss +32 -0
- package/src/styles/themes/dashboard.scss +294 -0
- package/src/styles/themes/euphoria.scss +283 -0
- package/src/styles/themes/mellow.scss +280 -0
- package/src/styles/themes/midnight.scss +283 -0
- package/src/styles/themes/passion.scss +280 -0
- package/src/styles/themes/swiss.scss +283 -0
- package/src/styles/tools/_functions.scss +5 -0
- package/src/styles/tools/_mixins.scss +159 -0
- package/src/styles/tools/_placeholders.scss +17 -0
- package/src/styles/tools/_variables.scss +67 -0
- package/src/styles.scss +37 -0
- package/src/test.ts +22 -0
- package/src/tsconfig.app.json +20 -0
- package/src/tsconfig.spec.json +23 -0
- package/src/typings.d.ts +9 -0
- package/tailwind.config.js +67 -0
- package/tsconfig.json +42 -0
- package/tsconfig.serve.json +27 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const database_1 = require("../config/database");
|
|
4
|
+
const StorageType_1 = require("../enums/StorageType");
|
|
5
|
+
const Store = require('electron-store');
|
|
6
|
+
const store = new Store();
|
|
7
|
+
class ConfigManager {
|
|
8
|
+
constructor(systemManager) {
|
|
9
|
+
this.systemManager = systemManager;
|
|
10
|
+
}
|
|
11
|
+
set(key, value) {
|
|
12
|
+
store.set(key, value);
|
|
13
|
+
}
|
|
14
|
+
get(key = null) {
|
|
15
|
+
if (key) {
|
|
16
|
+
return store.get(key);
|
|
17
|
+
}
|
|
18
|
+
return store.store;
|
|
19
|
+
}
|
|
20
|
+
has(key) {
|
|
21
|
+
return store.has(key);
|
|
22
|
+
}
|
|
23
|
+
delete(key) {
|
|
24
|
+
return store.delete(key);
|
|
25
|
+
}
|
|
26
|
+
clear() {
|
|
27
|
+
return store.clear();
|
|
28
|
+
}
|
|
29
|
+
toArray() {
|
|
30
|
+
return store.store;
|
|
31
|
+
}
|
|
32
|
+
initialize() {
|
|
33
|
+
this.initDatabaseConfig();
|
|
34
|
+
this.initSettingsConfig();
|
|
35
|
+
}
|
|
36
|
+
initSettingsConfig() {
|
|
37
|
+
const settings = {
|
|
38
|
+
import: {
|
|
39
|
+
type: 'ask'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
if (this.has(StorageType_1.StorageType.Options)) {
|
|
43
|
+
const saved = this.get(StorageType_1.StorageType.Options);
|
|
44
|
+
this.set(StorageType_1.StorageType.Options, Object.assign(Object.assign({}, settings), saved));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.set(StorageType_1.StorageType.Options, settings);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
initDatabaseConfig() {
|
|
51
|
+
let store = this.get(StorageType_1.StorageType.Database);
|
|
52
|
+
// @TODO Remove MySQL connection if not in production.
|
|
53
|
+
// Problematic when switching between production and development. Problem arises when connection is not enabled.
|
|
54
|
+
// database.connections = this.systemManager.isProduction() ? database.connections.filter((item: any) => item.name === 'default') : database.connections;
|
|
55
|
+
// Assign user data path to default database.
|
|
56
|
+
database_1.database.connections = database_1.database.connections.filter((item) => {
|
|
57
|
+
if (item.name === 'default' && item.type === 'sqlite') {
|
|
58
|
+
item.database = this.systemManager.getDatabasePath(item.database);
|
|
59
|
+
}
|
|
60
|
+
return item;
|
|
61
|
+
});
|
|
62
|
+
if (!store) {
|
|
63
|
+
this.set(StorageType_1.StorageType.Database, database_1.database);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Resets database.
|
|
67
|
+
//this.set(StorageType.Database, database);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
createDbConnection(options) {
|
|
71
|
+
if (options.name === 'default') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
let connections = this.get(StorageType_1.StorageType.Database).connections;
|
|
75
|
+
const found = connections.find((item) => item.name === options.name);
|
|
76
|
+
if (found) {
|
|
77
|
+
for (const i in connections) {
|
|
78
|
+
if (connections[i].name == options.name) {
|
|
79
|
+
connections[i] = options;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.set(StorageType_1.StorageType.DatabaseConnections, connections);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.set(StorageType_1.StorageType.DatabaseConnections, connections.push(options));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
enableDbConnection(options) {
|
|
89
|
+
let config = this.get(StorageType_1.StorageType.Database);
|
|
90
|
+
config.connections = config.connections.filter((item) => {
|
|
91
|
+
item.enabled = (item.name === options.name) ? true : false;
|
|
92
|
+
return item;
|
|
93
|
+
});
|
|
94
|
+
this.set(StorageType_1.StorageType.Database, config);
|
|
95
|
+
return config;
|
|
96
|
+
}
|
|
97
|
+
deleteDbConnection(options) {
|
|
98
|
+
if (options.name === 'default') {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let connections = this.get(StorageType_1.StorageType.Database).connections;
|
|
102
|
+
const found = connections.find((item) => item.name === options.name);
|
|
103
|
+
if (found) {
|
|
104
|
+
for (const i in connections) {
|
|
105
|
+
if (connections[i].name == options.name) {
|
|
106
|
+
connections.splice(i, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
this.set(StorageType_1.StorageType.DatabaseConnections, connections);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.default = ConfigManager;
|
|
114
|
+
//# sourceMappingURL=ConfigManager.js.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import SystemManager from './SystemManager';
|
|
2
|
+
import { database } from '../config/database';
|
|
3
|
+
import { StorageType } from '../enums/StorageType';
|
|
4
|
+
|
|
5
|
+
const Store = require('electron-store');
|
|
6
|
+
const store = new Store();
|
|
7
|
+
|
|
8
|
+
export default class ConfigManager {
|
|
9
|
+
|
|
10
|
+
systemManager: SystemManager;
|
|
11
|
+
|
|
12
|
+
constructor(systemManager: SystemManager) {
|
|
13
|
+
this.systemManager = systemManager;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
set(key: string, value: any): void {
|
|
17
|
+
store.set(key, value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get(key: string = null): any {
|
|
21
|
+
if (key) {
|
|
22
|
+
return store.get(key);
|
|
23
|
+
}
|
|
24
|
+
return store.store;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
has(key: string): boolean {
|
|
28
|
+
return store.has(key);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
delete(key: string): any {
|
|
32
|
+
return store.delete(key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
clear(): any {
|
|
36
|
+
return store.clear();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
toArray(): any {
|
|
40
|
+
return store.store;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
initialize(): void {
|
|
44
|
+
this.initDatabaseConfig();
|
|
45
|
+
this.initSettingsConfig();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
initSettingsConfig(): void {
|
|
49
|
+
const settings = {
|
|
50
|
+
import: {
|
|
51
|
+
type: 'ask'
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
if (this.has(StorageType.Options)) {
|
|
55
|
+
const saved = this.get(StorageType.Options);
|
|
56
|
+
this.set(StorageType.Options, { ...settings, ...saved });
|
|
57
|
+
} else {
|
|
58
|
+
this.set(StorageType.Options, settings);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
initDatabaseConfig(): void {
|
|
63
|
+
let store = this.get(StorageType.Database);
|
|
64
|
+
|
|
65
|
+
// @TODO Remove MySQL connection if not in production.
|
|
66
|
+
// Problematic when switching between production and development. Problem arises when connection is not enabled.
|
|
67
|
+
// database.connections = this.systemManager.isProduction() ? database.connections.filter((item: any) => item.name === 'default') : database.connections;
|
|
68
|
+
|
|
69
|
+
// Assign user data path to default database.
|
|
70
|
+
database.connections = database.connections.filter((item: any) => {
|
|
71
|
+
if (item.name === 'default' && item.type === 'sqlite') {
|
|
72
|
+
item.database = this.systemManager.getDatabasePath(item.database);
|
|
73
|
+
}
|
|
74
|
+
return item;
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
if (!store) {
|
|
78
|
+
this.set(StorageType.Database, database);
|
|
79
|
+
} else {
|
|
80
|
+
// Resets database.
|
|
81
|
+
//this.set(StorageType.Database, database);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
createDbConnection(options: any): void {
|
|
86
|
+
if (options.name === 'default') {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let connections = this.get(StorageType.Database).connections;
|
|
91
|
+
|
|
92
|
+
const found = connections.find((item: any) => item.name === options.name);
|
|
93
|
+
|
|
94
|
+
if (found) {
|
|
95
|
+
for (const i in connections) {
|
|
96
|
+
if (connections[i].name == options.name) {
|
|
97
|
+
connections[i] = options;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
this.set(StorageType.DatabaseConnections, connections);
|
|
101
|
+
} else {
|
|
102
|
+
this.set(StorageType.DatabaseConnections, connections.push(options));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
enableDbConnection(options: any): void {
|
|
107
|
+
let config = this.get(StorageType.Database);
|
|
108
|
+
|
|
109
|
+
config.connections = config.connections.filter((item: any) => {
|
|
110
|
+
item.enabled = (item.name === options.name) ? true : false;
|
|
111
|
+
return item;
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
this.set(StorageType.Database, config);
|
|
115
|
+
|
|
116
|
+
return config;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
deleteDbConnection(options: any): void {
|
|
120
|
+
if (options.name === 'default') {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let connections = this.get(StorageType.Database).connections;
|
|
125
|
+
|
|
126
|
+
const found = connections.find((item: any) => item.name === options.name);
|
|
127
|
+
|
|
128
|
+
if (found) {
|
|
129
|
+
for (const i in connections) {
|
|
130
|
+
if (connections[i].name == options.name) {
|
|
131
|
+
connections.splice(i, 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
this.set(StorageType.DatabaseConnections, connections);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const typeorm_1 = require("typeorm");
|
|
13
|
+
const entity_1 = require("../database/entity");
|
|
14
|
+
const repository_1 = require("../database/repository");
|
|
15
|
+
const StorageType_1 = require("../enums/StorageType");
|
|
16
|
+
class ConnectionManager {
|
|
17
|
+
constructor(configManager) {
|
|
18
|
+
this.schemas = [entity_1.Collection, entity_1.Store, entity_1.Logger];
|
|
19
|
+
this.subscribers = [];
|
|
20
|
+
this.migrations = [];
|
|
21
|
+
this.omitables = ['title', 'description', 'enabled'];
|
|
22
|
+
this.configManager = configManager;
|
|
23
|
+
this.options = this.normalize(this.configManager.get(StorageType_1.StorageType.DatabaseConnections));
|
|
24
|
+
this.registerEntities(this.options);
|
|
25
|
+
this.registerSubscribers(this.options);
|
|
26
|
+
this.registerMigrations(this.options);
|
|
27
|
+
this.dataSource = new typeorm_1.DataSource(this.options[0]);
|
|
28
|
+
}
|
|
29
|
+
initialize() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
return yield this.dataSource.initialize();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
isInitialized() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return this.dataSource.isInitialized;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getDataSource() {
|
|
40
|
+
return this.dataSource;
|
|
41
|
+
}
|
|
42
|
+
createDataSource(options) {
|
|
43
|
+
return new typeorm_1.DataSource(this.discardOmitables(options)).initialize();
|
|
44
|
+
}
|
|
45
|
+
registerEntities(options) {
|
|
46
|
+
this.options = options.map(obj => (Object.assign(Object.assign({}, obj), { entities: this.schemas })));
|
|
47
|
+
}
|
|
48
|
+
registerSubscribers(options) {
|
|
49
|
+
this.options = options.map(obj => (Object.assign(Object.assign({}, obj), { subscribers: this.subscribers })));
|
|
50
|
+
}
|
|
51
|
+
registerMigrations(options) {
|
|
52
|
+
this.options = options.map(obj => (Object.assign(Object.assign({}, obj), { migrations: this.migrations })));
|
|
53
|
+
}
|
|
54
|
+
discardOmitables(options) {
|
|
55
|
+
return Object.fromEntries(Object.entries(options).filter(([key]) => !this.omitables.includes(key)));
|
|
56
|
+
}
|
|
57
|
+
normalize(options) {
|
|
58
|
+
return options.filter((item) => this.discardOmitables(item)).filter((item) => item.enabled);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Proxy methods
|
|
62
|
+
*/
|
|
63
|
+
getCollection() {
|
|
64
|
+
return this.dataSource.getRepository(entity_1.Collection);
|
|
65
|
+
}
|
|
66
|
+
getLogger() {
|
|
67
|
+
return this.dataSource.getRepository(entity_1.Logger);
|
|
68
|
+
}
|
|
69
|
+
getStore() {
|
|
70
|
+
return this.dataSource.getRepository(entity_1.Store);
|
|
71
|
+
}
|
|
72
|
+
getCollectionRepository() {
|
|
73
|
+
return this.getCollection().extend(repository_1.CollectionRepository);
|
|
74
|
+
}
|
|
75
|
+
getLoggerRepository() {
|
|
76
|
+
return this.getLogger().extend(repository_1.LoggerRepository);
|
|
77
|
+
}
|
|
78
|
+
getStoreRepository() {
|
|
79
|
+
return this.getStore().extend(repository_1.StoreRepository);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = ConnectionManager;
|
|
83
|
+
//# sourceMappingURL=ConnectionManager.js.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { DataSource, DataSourceOptions } from 'typeorm'
|
|
2
|
+
import { Collection, Store, Logger } from '../database/entity';
|
|
3
|
+
import { CollectionRepository, LoggerRepository, StoreRepository } from '../database/repository';
|
|
4
|
+
import ConfigManager from './ConfigManager';
|
|
5
|
+
import { StorageType } from '../enums/StorageType';
|
|
6
|
+
|
|
7
|
+
export default class ConnectionManager {
|
|
8
|
+
|
|
9
|
+
configManager: ConfigManager;
|
|
10
|
+
options: DataSourceOptions[];
|
|
11
|
+
|
|
12
|
+
dataSource: DataSource;
|
|
13
|
+
|
|
14
|
+
schemas: any[] = [Collection, Store, Logger];
|
|
15
|
+
subscribers: any[] = []
|
|
16
|
+
migrations: any[] = [];
|
|
17
|
+
|
|
18
|
+
omitables: any[] = ['title', 'description', 'enabled'];
|
|
19
|
+
|
|
20
|
+
constructor(configManager: ConfigManager) {
|
|
21
|
+
this.configManager = configManager;
|
|
22
|
+
|
|
23
|
+
this.options = this.normalize(this.configManager.get(StorageType.DatabaseConnections));
|
|
24
|
+
|
|
25
|
+
this.registerEntities(this.options);
|
|
26
|
+
this.registerSubscribers(this.options);
|
|
27
|
+
this.registerMigrations(this.options);
|
|
28
|
+
|
|
29
|
+
this.dataSource = new DataSource(this.options[0]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async initialize() {
|
|
33
|
+
return await this.dataSource.initialize();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async isInitialized() {
|
|
37
|
+
return this.dataSource.isInitialized;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getDataSource(): DataSource {
|
|
41
|
+
return this.dataSource;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
createDataSource(options: DataSourceOptions) {
|
|
45
|
+
return new DataSource(this.discardOmitables(options)).initialize()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
registerEntities(options: DataSourceOptions[]) {
|
|
49
|
+
this.options = options.map(obj => ({ ...obj, entities: this.schemas }))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
registerSubscribers(options: DataSourceOptions[]) {
|
|
53
|
+
this.options = options.map(obj => ({ ...obj, subscribers: this.subscribers }))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
registerMigrations(options: DataSourceOptions[]) {
|
|
57
|
+
this.options = options.map(obj => ({ ...obj, migrations: this.migrations }))
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
discardOmitables(options: object | any): object | any {
|
|
61
|
+
return Object.fromEntries(Object.entries(options).filter(([key]) => !this.omitables.includes(key)));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
normalize(options: DataSourceOptions[]) {
|
|
65
|
+
return options.filter((item: DataSourceOptions) => this.discardOmitables(item)).filter((item: any) => item.enabled)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Proxy methods
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
getCollection() {
|
|
73
|
+
return this.dataSource.getRepository(Collection)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getLogger() {
|
|
77
|
+
return this.dataSource.getRepository(Logger)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getStore() {
|
|
81
|
+
return this.dataSource.getRepository(Store)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getCollectionRepository() {
|
|
85
|
+
return this.getCollection().extend(CollectionRepository);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getLoggerRepository() {
|
|
89
|
+
return this.getLogger().extend(LoggerRepository);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getStoreRepository() {
|
|
93
|
+
return this.getStore().extend(StoreRepository);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const fs = require("fs/promises");
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const exec = require('child_process').exec;
|
|
15
|
+
const child = require('child_process').execFile;
|
|
16
|
+
class FontCatalog {
|
|
17
|
+
constructor(systemManager) {
|
|
18
|
+
this.systemManager = systemManager;
|
|
19
|
+
}
|
|
20
|
+
createCatalog(folder) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return yield fs.mkdir(folder, { recursive: true });
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
commandHelp(done) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return yield child(this.systemManager.getExecutable(), ['-h'], done);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
findFonts(src, done) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return yield child(this.systemManager.getExecutable(), ['fonts', 'find', '--root', src], done);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
copyFiles(files, dest, done) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const cmdPath = this.systemManager.getExecutable();
|
|
38
|
+
const items = files.map((item) => `"${path.normalize(item)}"`).join(" ");
|
|
39
|
+
const command = `${cmdPath} copy files --destination "${dest}" ${items}`;
|
|
40
|
+
return exec(command, done);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
copyFolders(src, dest, done) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const params = ['copy', 'folders', '--source', src, '--destination', dest];
|
|
46
|
+
return child(this.systemManager.getExecutable(), params, done);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = FontCatalog;
|
|
51
|
+
//# sourceMappingURL=FontCatalog.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import SystemManager from './SystemManager';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const exec = require('child_process').exec;
|
|
6
|
+
const child = require('child_process').execFile;
|
|
7
|
+
|
|
8
|
+
export default class FontCatalog {
|
|
9
|
+
|
|
10
|
+
systemManager: SystemManager;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
systemManager: SystemManager,
|
|
14
|
+
) {
|
|
15
|
+
this.systemManager = systemManager;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async createCatalog(folder: string): Promise<string> {
|
|
19
|
+
return await fs.mkdir(folder, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async commandHelp(done: any) {
|
|
23
|
+
return await child(this.systemManager.getExecutable(), ['-h'], done);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async findFonts(src: string, done: any) {
|
|
27
|
+
return await child(this.systemManager.getExecutable(), ['fonts', 'find', '--root', src], done);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async copyFiles(files: any, dest: string, done: any) {
|
|
31
|
+
const cmdPath = this.systemManager.getExecutable();
|
|
32
|
+
const items = files.map((item: string) => `"${path.normalize(item)}"`).join(" ");
|
|
33
|
+
const command = `${cmdPath} copy files --destination "${dest}" ${items}`;
|
|
34
|
+
return exec(command, done);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async copyFolders(src: string, dest: string, done: any) {
|
|
38
|
+
const params = ['copy', 'folders', '--source', src, '--destination', dest];
|
|
39
|
+
|
|
40
|
+
return child(this.systemManager.getExecutable(), params, done);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const FontObject_1 = require("./FontObject");
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const mimes_1 = require("../config/mimes");
|
|
16
|
+
const prettyBytes = require("pretty-bytes");
|
|
17
|
+
const mime = require("mime");
|
|
18
|
+
// https://stackoverflow.com/questions/10049557/reading-all-files-in-a-directory-store-them-in-objects-and-send-the-object
|
|
19
|
+
class FileSystem {
|
|
20
|
+
constructor(connectionManager) {
|
|
21
|
+
this.counter = 0;
|
|
22
|
+
this.errors = [];
|
|
23
|
+
this.found = [];
|
|
24
|
+
this.connectionManager = connectionManager;
|
|
25
|
+
this.counter = 0;
|
|
26
|
+
this.errors = [];
|
|
27
|
+
}
|
|
28
|
+
setCounter(count) {
|
|
29
|
+
this.counter = count;
|
|
30
|
+
}
|
|
31
|
+
getCounter() {
|
|
32
|
+
return this.counter;
|
|
33
|
+
}
|
|
34
|
+
scanFolders(dir, options, done) {
|
|
35
|
+
fs.readdir(dir, (err, list) => {
|
|
36
|
+
if (err)
|
|
37
|
+
return done(err);
|
|
38
|
+
let i = 0;
|
|
39
|
+
let next = () => {
|
|
40
|
+
let file = list[i++];
|
|
41
|
+
if (!file)
|
|
42
|
+
return done(null, this);
|
|
43
|
+
let fp = path.resolve(dir, file);
|
|
44
|
+
fs.stat(fp, (err, stat) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (stat && stat.isDirectory()) {
|
|
46
|
+
this.scanFolders(fp, options, (err, res) => next());
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.fontInstall(fp, stat, options);
|
|
50
|
+
next();
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
next();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
scanFiles(files, options, done) {
|
|
58
|
+
files.forEach((fp) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
let stat = fs.statSync(fp);
|
|
60
|
+
if (stat.isFile()) {
|
|
61
|
+
this.fontInstall(fp, stat, options);
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
return done(null, this);
|
|
65
|
+
}
|
|
66
|
+
fontInstall(fp, stat, options) {
|
|
67
|
+
let font = new FontObject_1.default(fp);
|
|
68
|
+
if (font.hasError()) {
|
|
69
|
+
this.errors.push(font.getError());
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
let fileSize = stat.size;
|
|
73
|
+
let fileType = mime.getType(fp);
|
|
74
|
+
let data = Object.assign({ file_path: fp, file_name: path.basename(fp), file_size: fileSize, file_size_pretty: prettyBytes(fileSize), file_type: fileType, installable: mimes_1.installable.includes(fileType) }, options);
|
|
75
|
+
try {
|
|
76
|
+
this.connectionManager.getStoreRepository().create(Object.assign(Object.assign({}, data), font.getNamesTable()));
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
this.errors.push(err.message);
|
|
80
|
+
}
|
|
81
|
+
this.counter++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.default = FileSystem;
|
|
86
|
+
//# sourceMappingURL=FontFinder.js.map
|