@simple-reporting/base 0.0.1 → 0.1.111
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/.github/workflows/npm-publish.yml +25 -25
- package/.nvmrc +1 -1
- package/README.md +23 -23
- package/cli.js +114 -114
- package/dev/.ddev/nginx_full/custom.conf +12 -12
- package/dev/index.html +17 -17
- package/dev/ldd.html +7 -7
- package/dev/livingdocs/Media/image/app.scss +25 -25
- package/dev/livingdocs/Media/image/general.scss +11 -11
- package/dev/livingdocs/Media/image/image.html +46 -46
- package/dev/livingdocs/Media/image/ldd.scss +1 -1
- package/dev/livingdocs/Media/image/pdf.scss +1 -1
- package/dev/livingdocs/Media/image/print.scss +7 -7
- package/dev/livingdocs/Media/image/properties.json +41 -41
- package/dev/livingdocs/Media/image/word.scss +1 -1
- package/dev/livingdocs/Properties/grid/app.scss +1 -1
- package/dev/livingdocs/Properties/grid/general.scss +95 -95
- package/dev/livingdocs/Properties/grid/ldd.scss +1 -1
- package/dev/livingdocs/Properties/grid/pdf.scss +1 -1
- package/dev/livingdocs/Properties/grid/print.scss +94 -94
- package/dev/livingdocs/Properties/grid/properties.json +68 -68
- package/dev/livingdocs/Properties/grid/web.scss +98 -98
- package/dev/livingdocs/Properties/grid/word.scss +1 -1
- package/dev/livingdocs/Text/paragraph/general.scss +9 -9
- package/dev/livingdocs/Text/paragraph/paragraph.html +22 -22
- package/dev/livingdocs/Titles/title-h1/general.scss +10 -10
- package/dev/livingdocs/Titles/title-h1/title-h1.html +16 -16
- package/dev/livingdocs/Titles/title-h2/app.scss +1 -1
- package/dev/livingdocs/Titles/title-h2/general.scss +13 -13
- package/dev/livingdocs/Titles/title-h2/ldd.scss +1 -1
- package/dev/livingdocs/Titles/title-h2/pdf.scss +1 -1
- package/dev/livingdocs/Titles/title-h2/print.scss +36 -36
- package/dev/livingdocs/Titles/title-h2/title-h2.html +24 -24
- package/dev/livingdocs/Titles/title-h2/web.scss +27 -27
- package/dev/livingdocs/Titles/title-h2/word.scss +1 -1
- package/dev/livingdocs/Titles/title-h3/app.scss +1 -1
- package/dev/livingdocs/Titles/title-h3/general.scss +13 -13
- package/dev/livingdocs/Titles/title-h3/ldd.scss +1 -1
- package/dev/livingdocs/Titles/title-h3/pdf.scss +1 -1
- package/dev/livingdocs/Titles/title-h3/print.scss +34 -34
- package/dev/livingdocs/Titles/title-h3/title-h3.html +24 -24
- package/dev/livingdocs/Titles/title-h3/web.scss +27 -27
- package/dev/livingdocs/Titles/title-h3/word.scss +1 -1
- package/dev/livingdocs/Titles/title-h4/app.scss +1 -1
- package/dev/livingdocs/Titles/title-h4/general.scss +13 -13
- package/dev/livingdocs/Titles/title-h4/ldd.scss +1 -1
- package/dev/livingdocs/Titles/title-h4/pdf.scss +1 -1
- package/dev/livingdocs/Titles/title-h4/print.scss +34 -34
- package/dev/livingdocs/Titles/title-h4/title-h4.html +24 -24
- package/dev/livingdocs/Titles/title-h4/web.scss +27 -27
- package/dev/livingdocs/Titles/title-h4/word.scss +1 -1
- package/dev/livingdocs/Titles/title-h5/general.scss +10 -10
- package/dev/livingdocs/Titles/title-h5/title-h5.html +16 -16
- package/dev/livingdocs/Titles/title-h6/general.scss +10 -10
- package/dev/livingdocs/Titles/title-h6/title-h6.html +16 -16
- package/dev/livingdocs.config.json +376 -376
- package/dev/nswow/ArticleAutoloader.ts +100 -100
- package/dev/nswow/ArticleLoader.ts +91 -91
- package/dev/nswow/colors.scss +3 -3
- package/dev/nswow/config.scss +13 -13
- package/dev/nswow/core-styles.scss +2 -2
- package/dev/nswow/fonts.scss +2 -2
- package/dev/nswow/grid.scss +2 -2
- package/dev/nswow/helpers.scss +2 -2
- package/dev/nswow/index.scss +9 -9
- package/dev/nswow/meta.scss +2 -2
- package/dev/nswow/spacer.scss +2 -2
- package/dev/nswow/system.scss +2 -2
- package/dev/nswow/typography.scss +3 -3
- package/dev/nswow.config.json +293 -293
- package/dev/package.json +60 -61
- package/dev/pdf/pdf-configuration-debug.xml +5 -5
- package/dev/pdf/pdf-configuration.xml +2 -2
- package/dev/pdf.ts +1 -1
- package/dev/src/App.vue +44 -44
- package/dev/src/Autoload.ts +6 -6
- package/dev/src/assets/images/mms-logo-black.svg +91 -91
- package/dev/src/assets/images/mms-logo-white.svg +105 -105
- package/dev/src/assets/scss/app.scss +39 -39
- package/dev/src/assets/scss/general.scss +17 -17
- package/dev/src/assets/scss/ldd.scss +27 -27
- package/dev/src/assets/scss/pdf.scss +2 -2
- package/dev/src/assets/scss/print.scss +1 -1
- package/dev/src/assets/scss/web.scss +1 -1
- package/dev/src/assets/scss/word.scss +2 -2
- package/dev/src/components/LanguageSwitch.vue +100 -100
- package/dev/src/components/MainNavigation.vue +209 -209
- package/dev/src/components/MenuItem/MenuArticle.vue +15 -15
- package/dev/src/components/MenuItem/MenuEntry.vue +26 -26
- package/dev/src/components/MenuItem/MenuExternal.vue +28 -28
- package/dev/src/components/MenuItem/index.ts +5 -5
- package/dev/src/components/PageFooter.vue +86 -86
- package/dev/src/components/PageHeader.vue +149 -149
- package/dev/src/components/PageModal.vue +95 -95
- package/dev/src/components/PrevNext.vue +144 -144
- package/dev/src/components/ScrollToTop.vue +63 -63
- package/dev/src/components/SrlPage/KFCApplication/hooks/kfcData.ts +9 -9
- package/dev/src/components/SrlPage/KFCApplication/scss/_iz-keyfigure-comparison.scss +151 -151
- package/dev/src/components/SrlPage/KFCApplication/scss/_kfc-loading.scss +40 -40
- package/dev/src/components/SrlPage/KFCApplication/scss/_srl-button-kfc.scss +21 -21
- package/dev/src/composables/config.ts +48 -48
- package/dev/src/i18n/index.ts +51 -51
- package/dev/src/i18n/translation.ts +85 -85
- package/dev/src/locales/de.json +15 -15
- package/dev/src/locales/en.json +15 -15
- package/dev/src/main.ts +16 -16
- package/dev/src/router/index.ts +47 -47
- package/dev/src/types/nswow.d.ts +73 -73
- package/dev/src/views/ArticleView.vue +77 -77
- package/dev/src/views/DownloadsView.vue +88 -88
- package/dev/src/views/HomeView.vue +35 -35
- package/dev/src/views/PageNotFound.vue +73 -73
- package/dev/src/views/SearchView.vue +126 -126
- package/dev/tsconfig.app.json +16 -16
- package/dev/tsconfig.node.json +19 -19
- package/dev/vite.config.ts +27 -27
- package/dev/word.ts +1 -1
- package/livingdocs/Buttons/button/app.scss +1 -1
- package/livingdocs/Buttons/button/button.html +18 -18
- package/livingdocs/Buttons/button/general.scss +33 -33
- package/livingdocs/Buttons/button/ldd.scss +1 -1
- package/livingdocs/Buttons/button/pdf.scss +1 -1
- package/livingdocs/Buttons/button/word.scss +1 -1
- package/livingdocs/Buttons/button-container/app.scss +1 -1
- package/livingdocs/Buttons/button-container/button-container.html +31 -31
- package/livingdocs/Buttons/button-container/general.scss +12 -12
- package/livingdocs/Buttons/button-container/ldd.scss +1 -1
- package/livingdocs/Buttons/button-container/pdf.scss +3 -3
- package/livingdocs/Buttons/button-container/properties.json +19 -19
- package/livingdocs/Buttons/button-container/word.scss +3 -3
- package/livingdocs/CV/cv-timeline/app.scss +1 -1
- package/livingdocs/CV/cv-timeline/cv-timeline.html +19 -19
- package/livingdocs/CV/cv-timeline/general.scss +1 -1
- package/livingdocs/CV/cv-timeline/ldd.scss +1 -1
- package/livingdocs/CV/cv-timeline/pdf.scss +1 -1
- package/livingdocs/CV/cv-timeline/print.scss +35 -35
- package/livingdocs/CV/cv-timeline/web.scss +27 -27
- package/livingdocs/CV/cv-timeline/word.scss +1 -1
- package/livingdocs/Container/column-container/column-container.html +44 -44
- package/livingdocs/Container/column-container/general.scss +105 -105
- package/livingdocs/Container/column-container/properties.json +83 -83
- package/livingdocs/Lists/alphanumeric-list-group/alphanumeric-list-group.html +25 -25
- package/livingdocs/Lists/alphanumeric-list-group/app.scss +1 -1
- package/livingdocs/Lists/alphanumeric-list-group/general.scss +5 -5
- package/livingdocs/Lists/alphanumeric-list-group/ldd.scss +1 -1
- package/livingdocs/Lists/alphanumeric-list-group/pdf.scss +1 -1
- package/livingdocs/Lists/alphanumeric-list-group/word.scss +1 -1
- package/livingdocs/Lists/list-item/app.scss +1 -1
- package/livingdocs/Lists/list-item/general.scss +4 -4
- package/livingdocs/Lists/list-item/ldd.scss +1 -1
- package/livingdocs/Lists/list-item/list-item.html +17 -17
- package/livingdocs/Lists/list-item/pdf.scss +1 -1
- package/livingdocs/Lists/list-item/word.scss +1 -1
- package/livingdocs/Lists/ordered-list-group/app.scss +1 -1
- package/livingdocs/Lists/ordered-list-group/general.scss +5 -5
- package/livingdocs/Lists/ordered-list-group/ldd.scss +1 -1
- package/livingdocs/Lists/ordered-list-group/ordered-list-group.html +25 -25
- package/livingdocs/Lists/ordered-list-group/pdf.scss +1 -1
- package/livingdocs/Lists/ordered-list-group/word.scss +1 -1
- package/livingdocs/Lists/unordered-list-group/app.scss +1 -1
- package/livingdocs/Lists/unordered-list-group/general.scss +5 -5
- package/livingdocs/Lists/unordered-list-group/ldd.scss +1 -1
- package/livingdocs/Lists/unordered-list-group/pdf.scss +1 -1
- package/livingdocs/Lists/unordered-list-group/unordered-list-group.html +25 -25
- package/livingdocs/Lists/unordered-list-group/word.scss +1 -1
- package/livingdocs/Media/chart/app.scss +19 -19
- package/livingdocs/Media/chart/chart.html +29 -29
- package/livingdocs/Media/chart/general.scss +11 -11
- package/livingdocs/Media/chart/ldd.scss +1 -1
- package/livingdocs/Media/chart/pdf.scss +9 -9
- package/livingdocs/Media/chart/properties.json +41 -41
- package/livingdocs/Media/chart/word.scss +1 -1
- package/livingdocs/Media/graphic/app.scss +1 -1
- package/livingdocs/Media/graphic/general.scss +18 -18
- package/livingdocs/Media/graphic/graphic.html +29 -29
- package/livingdocs/Media/graphic/ldd.scss +1 -1
- package/livingdocs/Media/graphic/pdf.scss +1 -1
- package/livingdocs/Media/graphic/properties.json +36 -36
- package/livingdocs/Media/graphic/word.scss +1 -1
- package/livingdocs/Media/image/app.scss +25 -25
- package/livingdocs/Media/image/general.scss +11 -11
- package/livingdocs/Media/image/image.html +55 -55
- package/livingdocs/Media/image/ldd.scss +1 -1
- package/livingdocs/Media/image/pdf.scss +1 -1
- package/livingdocs/Media/image/print.scss +7 -7
- package/livingdocs/Media/image/properties.json +41 -41
- package/livingdocs/Media/image/word.scss +1 -1
- package/livingdocs/Media/nswow-table/app.scss +2 -2
- package/livingdocs/Media/nswow-table/app.ts +35 -35
- package/livingdocs/Media/nswow-table/general.scss +281 -281
- package/livingdocs/Media/nswow-table/ldd.scss +2 -2
- package/livingdocs/Media/nswow-table/nswow-table.html +30 -30
- package/livingdocs/Media/nswow-table/pdf.scss +8 -8
- package/livingdocs/Media/nswow-table/properties.json +66 -66
- package/livingdocs/Media/nswow-table/web.scss +23 -23
- package/livingdocs/Media/nswow-table/word.scss +2 -2
- package/livingdocs/Media/video/app.scss +1 -1
- package/livingdocs/Media/video/general.scss +7 -7
- package/livingdocs/Media/video/ldd.scss +1 -1
- package/livingdocs/Media/video/pdf.scss +1 -1
- package/livingdocs/Media/video/print.scss +5 -5
- package/livingdocs/Media/video/properties.json +41 -41
- package/livingdocs/Media/video/video.html +26 -26
- package/livingdocs/Media/video/word.scss +1 -1
- package/livingdocs/Misc/accordion/accordion.html +56 -56
- package/livingdocs/Misc/accordion/app.scss +63 -63
- package/livingdocs/Misc/accordion/app.ts +10 -10
- package/livingdocs/Misc/accordion/general.scss +44 -44
- package/livingdocs/Misc/accordion/ldd.scss +36 -36
- package/livingdocs/Misc/accordion/pdf.scss +39 -39
- package/livingdocs/Misc/accordion/word.scss +39 -39
- package/livingdocs/Misc/anchor/anchor.html +15 -15
- package/livingdocs/Misc/anchor/app.scss +10 -10
- package/livingdocs/Misc/anchor/app.ts +11 -11
- package/livingdocs/Misc/anchor/general.scss +1 -1
- package/livingdocs/Misc/anchor/pdf.scss +1 -1
- package/livingdocs/Misc/anchor/print.scss +3 -3
- package/livingdocs/Misc/anchor/word.scss +1 -1
- package/livingdocs/Misc/spacer/app.scss +1 -1
- package/livingdocs/Misc/spacer/general.scss +8 -8
- package/livingdocs/Misc/spacer/ldd.scss +1 -1
- package/livingdocs/Misc/spacer/pdf.scss +1 -1
- package/livingdocs/Misc/spacer/print.scss +18 -18
- package/livingdocs/Misc/spacer/properties.json +52 -52
- package/livingdocs/Misc/spacer/spacer.html +12 -12
- package/livingdocs/Misc/spacer/web.scss +18 -18
- package/livingdocs/Misc/spacer/word.scss +1 -1
- package/livingdocs/PDF_only/pdf-cover/ldd.scss +42 -42
- package/livingdocs/PDF_only/pdf-cover/pdf-cover.html +29 -29
- package/livingdocs/PDF_only/pdf-cover/pdf.scss +1 -1
- package/livingdocs/PDF_only/pdf-cover/word.scss +1 -1
- package/livingdocs/PDF_only/pdf-cover-chapter/ldd.scss +19 -19
- package/livingdocs/PDF_only/pdf-cover-chapter/pdf-chapter-cover.html +18 -18
- package/livingdocs/PDF_only/pdf-cover-chapter/pdf.scss +1 -1
- package/livingdocs/PDF_only/pdf-cover-chapter/print.scss +19 -19
- package/livingdocs/PDF_only/pdf-cover-chapter/word.scss +1 -1
- package/livingdocs/PDF_only/pdf-pagebreak/general.scss +4 -4
- package/livingdocs/PDF_only/pdf-pagebreak/ldd.scss +5 -5
- package/livingdocs/PDF_only/pdf-pagebreak/pdf-pagebreak.html +8 -8
- package/livingdocs/PDF_only/pdf-publication-title/general.scss +5 -5
- package/livingdocs/PDF_only/pdf-publication-title/pdf-publication-title.html +15 -15
- package/livingdocs/PDF_only/pdf-toc-item/general.scss +41 -41
- package/livingdocs/PDF_only/pdf-toc-item/pdf-toc-item.html +33 -33
- package/livingdocs/PDF_only/pdf-toc-item/properties.json +7 -7
- package/livingdocs/PDF_only/pdf-toc-item-blank/general.scss +5 -5
- package/livingdocs/PDF_only/pdf-toc-item-blank/pdf-toc-item-blank.html +11 -11
- package/livingdocs/PDF_only/pdf-toc-item-title/general.scss +5 -5
- package/livingdocs/PDF_only/pdf-toc-item-title/pdf-toc-item-title.html +11 -11
- package/livingdocs/PDF_only/pdf-toc-page/app.scss +1 -1
- package/livingdocs/PDF_only/pdf-toc-page/general.scss +1 -1
- package/livingdocs/PDF_only/pdf-toc-page/ldd.scss +1 -1
- package/livingdocs/PDF_only/pdf-toc-page/pdf-toc-page.html +33 -33
- package/livingdocs/PDF_only/pdf-toc-page/pdf.scss +1 -1
- package/livingdocs/PDF_only/pdf-toc-page/properties.json +12 -12
- package/livingdocs/PDF_only/pdf-toc-page/word.scss +1 -1
- package/livingdocs/PDF_only/pdf-video-link/ldd.scss +16 -16
- package/livingdocs/PDF_only/pdf-video-link/pdf-video-link.html +41 -41
- package/livingdocs/PDF_only/pdf-video-link/pdf.scss +1 -1
- package/livingdocs/PDF_only/pdf-video-link/print.scss +12 -12
- package/livingdocs/PDF_only/pdf-video-link/word.scss +1 -1
- package/livingdocs/Properties/grid/app.scss +1 -1
- package/livingdocs/Properties/grid/general.scss +95 -95
- package/livingdocs/Properties/grid/ldd.scss +1 -1
- package/livingdocs/Properties/grid/pdf.scss +1 -1
- package/livingdocs/Properties/grid/print.scss +94 -94
- package/livingdocs/Properties/grid/properties.json +68 -68
- package/livingdocs/Properties/grid/web.scss +98 -98
- package/livingdocs/Properties/grid/word.scss +1 -1
- package/livingdocs/Signatures/signature-container/app.scss +1 -1
- package/livingdocs/Signatures/signature-container/general.scss +7 -7
- package/livingdocs/Signatures/signature-container/ldd.scss +1 -1
- package/livingdocs/Signatures/signature-container/pdf.scss +1 -1
- package/livingdocs/Signatures/signature-container/signature-container.html +30 -30
- package/livingdocs/Signatures/signature-container/word.scss +1 -1
- package/livingdocs/Signatures/signature-item/app.scss +1 -1
- package/livingdocs/Signatures/signature-item/general.scss +53 -53
- package/livingdocs/Signatures/signature-item/ldd.scss +1 -1
- package/livingdocs/Signatures/signature-item/pdf.scss +1 -1
- package/livingdocs/Signatures/signature-item/signature-item.html +23 -23
- package/livingdocs/Signatures/signature-item/word.scss +1 -1
- package/livingdocs/Text/footnote/app.scss +1 -1
- package/livingdocs/Text/footnote/footnote.html +14 -14
- package/livingdocs/Text/footnote/general.scss +12 -12
- package/livingdocs/Text/footnote/ldd.scss +1 -1
- package/livingdocs/Text/footnote/pdf.scss +1 -1
- package/livingdocs/Text/footnote/print.scss +36 -36
- package/livingdocs/Text/footnote/web.scss +27 -27
- package/livingdocs/Text/footnote/word.scss +1 -1
- package/livingdocs/Text/lead/general.scss +9 -9
- package/livingdocs/Text/lead/lead.html +23 -23
- package/livingdocs/Text/paragraph/general.scss +9 -9
- package/livingdocs/Text/paragraph/paragraph.html +24 -24
- package/livingdocs/Text/quote/general.scss +43 -43
- package/livingdocs/Text/quote/properties.json +7 -7
- package/livingdocs/Text/quote/quote.html +29 -29
- package/livingdocs/Text/quote-with-portrait/general.scss +81 -81
- package/livingdocs/Text/quote-with-portrait/properties.json +12 -12
- package/livingdocs/Text/quote-with-portrait/quote-with-portrait.html +49 -49
- package/livingdocs/Titles/title-h1/general.scss +10 -10
- package/livingdocs/Titles/title-h1/title-h1.html +16 -16
- package/livingdocs/Titles/title-h2/app.scss +1 -1
- package/livingdocs/Titles/title-h2/general.scss +13 -13
- package/livingdocs/Titles/title-h2/ldd.scss +1 -1
- package/livingdocs/Titles/title-h2/pdf.scss +1 -1
- package/livingdocs/Titles/title-h2/print.scss +36 -36
- package/livingdocs/Titles/title-h2/title-h2.html +26 -26
- package/livingdocs/Titles/title-h2/web.scss +27 -27
- package/livingdocs/Titles/title-h2/word.scss +1 -1
- package/livingdocs/Titles/title-h3/app.scss +1 -1
- package/livingdocs/Titles/title-h3/general.scss +13 -13
- package/livingdocs/Titles/title-h3/ldd.scss +1 -1
- package/livingdocs/Titles/title-h3/pdf.scss +1 -1
- package/livingdocs/Titles/title-h3/print.scss +34 -34
- package/livingdocs/Titles/title-h3/title-h3.html +26 -26
- package/livingdocs/Titles/title-h3/web.scss +27 -27
- package/livingdocs/Titles/title-h3/word.scss +1 -1
- package/livingdocs/Titles/title-h4/app.scss +1 -1
- package/livingdocs/Titles/title-h4/general.scss +13 -13
- package/livingdocs/Titles/title-h4/ldd.scss +1 -1
- package/livingdocs/Titles/title-h4/pdf.scss +1 -1
- package/livingdocs/Titles/title-h4/print.scss +34 -34
- package/livingdocs/Titles/title-h4/title-h4.html +26 -26
- package/livingdocs/Titles/title-h4/web.scss +27 -27
- package/livingdocs/Titles/title-h4/word.scss +1 -1
- package/livingdocs/Titles/title-h5/general.scss +10 -10
- package/livingdocs/Titles/title-h5/title-h5.html +16 -16
- package/livingdocs/Titles/title-h6/general.scss +10 -10
- package/livingdocs/Titles/title-h6/title-h6.html +16 -16
- package/package.json +50 -50
- package/preparePublish.cjs +95 -95
- package/scripts/beaver.js +316 -316
- package/scripts/build.js +812 -812
- package/scripts/components.js +566 -566
- package/scripts/doPublish.js +43 -43
- package/scripts/init.js +45 -45
- package/scripts/migrate-livingdocs-build/LICENSE +21 -21
- package/scripts/migrate-livingdocs-build/bin/build.js +53 -53
- package/scripts/migrate-livingdocs-build/bin/migrate.js +43 -43
- package/scripts/migrate-livingdocs-build/dev/build/v1.js +51 -51
- package/scripts/migrate-livingdocs-build/dev/build/v2.js +44 -44
- package/scripts/migrate-livingdocs-build/dev/build/zip-archive.js +39 -39
- package/scripts/migrate-livingdocs-build/dev/build.js +7 -7
- package/scripts/migrate-livingdocs-build/dev/configuration-defaults.js +18 -18
- package/scripts/migrate-livingdocs-build/dev/configuration.js +34 -34
- package/scripts/migrate-livingdocs-build/dev/lib.d.ts +1 -1
- package/scripts/migrate-livingdocs-build/dev/lib.js +251 -251
- package/scripts/migrate-livingdocs-build/dev/livingdocs-design.d.ts +2 -2
- package/scripts/migrate-livingdocs-build/dev/livingdocs-design.js +80 -80
- package/scripts/migrate-livingdocs-build/dev/logger.js +16 -16
- package/scripts/migrate-livingdocs-build/dev/migrate.js +241 -241
- package/scripts/migrate-livingdocs-build/readme.md +62 -62
- package/scripts/preparePublish.js +88 -88
- package/scripts/renamePackage.d.ts +1 -1
- package/scripts/renamePackage.js +48 -48
- package/scripts/utils.js +106 -106
- package/scripts/vite.js +58 -58
- package/scss/colors/functions.scss +18 -18
- package/scss/colors/index.scss +3 -3
- package/scss/colors/mixins.scss +45 -45
- package/scss/colors/variables.scss +6 -6
- package/scss/config.scss +7 -7
- package/scss/core-styles.scss +22 -22
- package/scss/fonts/functions.scss +21 -21
- package/scss/fonts/index.scss +3 -3
- package/scss/fonts/mixins.scss +31 -31
- package/scss/fonts/variables.scss +8 -8
- package/scss/grid/functions.scss +29 -29
- package/scss/grid/index.scss +3 -3
- package/scss/grid/mixins.scss +388 -388
- package/scss/grid/variables.scss +10 -10
- package/scss/helpers/index.scss +3 -3
- package/scss/helpers/mixins.scss +87 -87
- package/scss/helpers/variables.scss +7 -7
- package/scss/index.scss +8 -8
- package/scss/meta/functions.scss +64 -64
- package/scss/meta/index.scss +3 -3
- package/scss/meta/mixins.scss +6 -6
- package/scss/meta/variables.scss +8 -8
- package/scss/spacer/functions.scss +9 -9
- package/scss/spacer/index.scss +3 -3
- package/scss/spacer/mixins.scss +236 -236
- package/scss/spacer/variables.scss +6 -6
- package/scss/system/functions.scss +77 -77
- package/scss/system/index.scss +3 -3
- package/scss/system/mixins.scss +27 -27
- package/scss/system/root.scss +39 -39
- package/scss/system/variables.scss +13 -13
- package/scss/typography/functions.scss +63 -63
- package/scss/typography/index.scss +3 -3
- package/scss/typography/mixins.scss +262 -262
- package/scss/typography/variables.scss +11 -11
package/scripts/build.js
CHANGED
|
@@ -1,812 +1,812 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import {
|
|
3
|
-
statSync,
|
|
4
|
-
writeFileSync,
|
|
5
|
-
readFileSync,
|
|
6
|
-
mkdirSync,
|
|
7
|
-
readdirSync,
|
|
8
|
-
createWriteStream,
|
|
9
|
-
rmSync,
|
|
10
|
-
cpSync,
|
|
11
|
-
} from 'node:fs';
|
|
12
|
-
import { fileURLToPath, URL } from 'node:url';
|
|
13
|
-
import { createRequire } from 'node:module';
|
|
14
|
-
import { glob } from 'glob';
|
|
15
|
-
import { beaver } from './beaver.js';
|
|
16
|
-
import { build as viteBuild } from 'vite';
|
|
17
|
-
import { build as finalizeLdd } from './migrate-livingdocs-build/bin/build.js';
|
|
18
|
-
import {
|
|
19
|
-
readPackageJson,
|
|
20
|
-
writePackageJson,
|
|
21
|
-
readLivingDocsJson,
|
|
22
|
-
writeLivingDocsJson,
|
|
23
|
-
} from './utils.js';
|
|
24
|
-
import { camelCase } from 'cheerio/utils';
|
|
25
|
-
|
|
26
|
-
const placeholderId = '6297EAFB-33A0-48B8-8D64-E61CDC3E9035';
|
|
27
|
-
const CWD = process.cwd();
|
|
28
|
-
const nswowPath = resolve(CWD, '.nswow');
|
|
29
|
-
const outputPath = resolve(CWD, '.output');
|
|
30
|
-
const require = createRequire(import.meta.url);
|
|
31
|
-
|
|
32
|
-
const { Input } = require('enquirer');
|
|
33
|
-
|
|
34
|
-
let foldersChecked = false;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Checks if the required folders exist and creates them if necessary.
|
|
38
|
-
*
|
|
39
|
-
* @async
|
|
40
|
-
* @returns {Promise<boolean>} A promise that resolves to true once the folders are checked and created.
|
|
41
|
-
*/
|
|
42
|
-
async function checkFolders() {
|
|
43
|
-
if (!foldersChecked) {
|
|
44
|
-
foldersChecked = true;
|
|
45
|
-
try {
|
|
46
|
-
await statSync(nswowPath);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
await mkdirSync(nswowPath);
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
await statSync(outputPath);
|
|
52
|
-
} catch (e) {
|
|
53
|
-
await mkdirSync(outputPath);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Cleans the output directory by removing all files and folders.
|
|
61
|
-
*
|
|
62
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the cleanup was successful.
|
|
63
|
-
*/
|
|
64
|
-
async function cleanOutput() {
|
|
65
|
-
await checkFolders();
|
|
66
|
-
const output = readdirSync(outputPath);
|
|
67
|
-
for (let i = 0; i < output.length; i++) {
|
|
68
|
-
await rmSync(`${outputPath}/${output[i]}`, {
|
|
69
|
-
force: true,
|
|
70
|
-
recursive: true,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Builds the application by performing the following steps:
|
|
78
|
-
*
|
|
79
|
-
* 1. Checks the folders.
|
|
80
|
-
* 2. Executes the viteBuild function.
|
|
81
|
-
*
|
|
82
|
-
* @returns {Promise<void>} A Promise that resolves when the application is built.
|
|
83
|
-
*/
|
|
84
|
-
async function buildApp() {
|
|
85
|
-
await checkFolders();
|
|
86
|
-
const build = await viteBuild({
|
|
87
|
-
build: {
|
|
88
|
-
copyPublicDir: false,
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// Copy public folder exclude nswow folders
|
|
93
|
-
console.log(
|
|
94
|
-
'\n\nCopy public folder exclude nswow folders and exclude folder',
|
|
95
|
-
);
|
|
96
|
-
await cpSync(`${CWD}/public/`, `${outputPath}/app`, {
|
|
97
|
-
filter: (src) => {
|
|
98
|
-
if (
|
|
99
|
-
src.startsWith(`${CWD}/public/downloads`) ||
|
|
100
|
-
src.startsWith(`${CWD}/public/html`) ||
|
|
101
|
-
src.startsWith(`${CWD}/public/images`) ||
|
|
102
|
-
src.startsWith(`${CWD}/public/json`) ||
|
|
103
|
-
src.startsWith(`${CWD}/public/exclude`)
|
|
104
|
-
) {
|
|
105
|
-
return false;
|
|
106
|
-
} else {
|
|
107
|
-
src === `${CWD}/public/` ||
|
|
108
|
-
console.log(`Copy ${src} to ${outputPath}/app`);
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
recursive: true,
|
|
113
|
-
});
|
|
114
|
-
console.log('\n');
|
|
115
|
-
|
|
116
|
-
let index = await readFileSync(`${outputPath}/app/index.html`, 'utf8');
|
|
117
|
-
|
|
118
|
-
console.log('Create file /template/article.html for nswow hybrid\n');
|
|
119
|
-
index = index.replace(
|
|
120
|
-
'<html>',
|
|
121
|
-
`<html lang="[[language-${placeholderId}]]">`,
|
|
122
|
-
);
|
|
123
|
-
index = index.replace(
|
|
124
|
-
/<base\s+href\s*=\s*(['"])(.*?)\1\s*\/?>/gi,
|
|
125
|
-
`<base href="[[base-${placeholderId}]]" />
|
|
126
|
-
[[meta-${placeholderId}]]`,
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
index = index.replace(
|
|
130
|
-
/(<div\s+[^>]*id\s*=\s*["']app["'][^>]*>)([\s\S]*?)(<\/div>)/i,
|
|
131
|
-
`$1
|
|
132
|
-
<template>
|
|
133
|
-
[[content-${placeholderId}]]
|
|
134
|
-
</template>
|
|
135
|
-
$3`,
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
await mkdirSync(`${outputPath}/app/template`, { recursive: true });
|
|
139
|
-
await writeFileSync(`${outputPath}/app/index.html`, index);
|
|
140
|
-
await writeFileSync(`${outputPath}/app/template/article.html`, index);
|
|
141
|
-
/**
|
|
142
|
-
await writeFileSync(`${outputPath}/app/web.config`, `<?xml version="1.0" encoding="UTF-8"?>
|
|
143
|
-
<configuration>
|
|
144
|
-
<system.webServer>
|
|
145
|
-
<rewrite>
|
|
146
|
-
<rules>
|
|
147
|
-
<rule name="Rewrite to index.html" stopProcessing="true">
|
|
148
|
-
<match url=".*" />
|
|
149
|
-
<conditions logicalGrouping="MatchAll">
|
|
150
|
-
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
|
151
|
-
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
|
|
152
|
-
</conditions>
|
|
153
|
-
<action type="Rewrite" url="index.html" />
|
|
154
|
-
</rule>
|
|
155
|
-
</rules>
|
|
156
|
-
</rewrite>
|
|
157
|
-
</system.webServer>
|
|
158
|
-
</configuration>`);
|
|
159
|
-
await writeFileSync(`${outputPath}/app/.htaccess`, `RewriteEngine On
|
|
160
|
-
RewriteCond %{REQUEST_FILENAME} !-f
|
|
161
|
-
RewriteCond %{REQUEST_FILENAME} !-l
|
|
162
|
-
RewriteCond %{REQUEST_FILENAME} !-d
|
|
163
|
-
RewriteRule ^(.*)$ index.html [L]`);
|
|
164
|
-
/**/
|
|
165
|
-
return build;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Builds the application by performing the following steps:
|
|
170
|
-
*
|
|
171
|
-
* 1. Checks the folders.
|
|
172
|
-
* 2. Executes the viteBuild function.
|
|
173
|
-
*
|
|
174
|
-
* @returns {Promise<void>} A Promise that resolves when the application is built.
|
|
175
|
-
*/
|
|
176
|
-
async function buildDDev() {
|
|
177
|
-
await checkFolders();
|
|
178
|
-
const build = await viteBuild({
|
|
179
|
-
build: {
|
|
180
|
-
outDir: './.output/ddev',
|
|
181
|
-
},
|
|
182
|
-
});
|
|
183
|
-
return build;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Compresses the 'app' folder into a zip file using archiver library.
|
|
188
|
-
*
|
|
189
|
-
* @async
|
|
190
|
-
* @function zipApp
|
|
191
|
-
* @returns {Promise<void>} - A Promise that resolves when the zip operation is complete, or rejects with an error.
|
|
192
|
-
*/
|
|
193
|
-
async function zipApp() {
|
|
194
|
-
await checkFolders();
|
|
195
|
-
const archiver = require('archiver');
|
|
196
|
-
const output = createWriteStream(outputPath + '/app.zip');
|
|
197
|
-
const archive = archiver('zip', {
|
|
198
|
-
zlib: { level: 9 }, // Sets the compression level.
|
|
199
|
-
});
|
|
200
|
-
output.on('close', function () {
|
|
201
|
-
console.log('Create zip ' + outputPath + '/app.zip');
|
|
202
|
-
console.log(archive.pointer() + ' total bytes');
|
|
203
|
-
});
|
|
204
|
-
output.on('end', function () {
|
|
205
|
-
console.log('Data has been drained');
|
|
206
|
-
});
|
|
207
|
-
archive.on('warning', function (err) {
|
|
208
|
-
if (err.code === 'ENOENT') {
|
|
209
|
-
console.error(err);
|
|
210
|
-
} else {
|
|
211
|
-
// throw error
|
|
212
|
-
throw err;
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
archive.on('error', function (err) {
|
|
216
|
-
throw err;
|
|
217
|
-
});
|
|
218
|
-
archive.pipe(output);
|
|
219
|
-
archive.directory(outputPath + '/app/', false);
|
|
220
|
-
archive.finalize();
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Builds a PDF using the provided HTML template.
|
|
225
|
-
*
|
|
226
|
-
* @returns {Promise<boolean>} - Returns a Promise that resolves to true if the PDF was successfully built,
|
|
227
|
-
* false otherwise.
|
|
228
|
-
*/
|
|
229
|
-
async function buildPdf() {
|
|
230
|
-
await checkFolders();
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
const input = resolve(CWD, 'pdf.html');
|
|
234
|
-
await statSync(input);
|
|
235
|
-
return await viteBuild({
|
|
236
|
-
build: {
|
|
237
|
-
outDir: resolve(CWD, '.output/pdf'),
|
|
238
|
-
rollupOptions: {
|
|
239
|
-
input: {
|
|
240
|
-
pdf: input,
|
|
241
|
-
},
|
|
242
|
-
output: {
|
|
243
|
-
entryFileNames: `[name].js`,
|
|
244
|
-
chunkFileNames: `[name].js`,
|
|
245
|
-
assetFileNames: `[name].[ext]`,
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
copyPublicDir: false,
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
} catch (e) {
|
|
252
|
-
let configFile = false;
|
|
253
|
-
try {
|
|
254
|
-
const file = resolve(CWD, 'vite.config.pdf.ts');
|
|
255
|
-
await statSync(file);
|
|
256
|
-
console.log('Use vite.config.pdf.ts file');
|
|
257
|
-
configFile = file;
|
|
258
|
-
} catch (e) {
|
|
259
|
-
console.log('No use of vite.config.pdf.ts file');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const entry = resolve(CWD, 'pdf.ts');
|
|
263
|
-
|
|
264
|
-
const config = {
|
|
265
|
-
configFile: configFile,
|
|
266
|
-
base: './',
|
|
267
|
-
build: {
|
|
268
|
-
outDir: resolve(CWD, '.output/pdf'),
|
|
269
|
-
lib: {
|
|
270
|
-
fileName: 'pdf',
|
|
271
|
-
entry: entry,
|
|
272
|
-
formats: ['es'],
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
resolve: {
|
|
276
|
-
alias: {
|
|
277
|
-
'@': fileURLToPath(new URL(resolve(CWD, 'src'), import.meta.url)),
|
|
278
|
-
nswow: fileURLToPath(new URL(resolve(CWD, 'nswow'), import.meta.url)),
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
publicDir: false,
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
return await viteBuild(config);
|
|
286
|
-
} catch (e) {
|
|
287
|
-
console.error(e);
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Builds Living Documentation (LDD) for a project.
|
|
295
|
-
*
|
|
296
|
-
* @async
|
|
297
|
-
* @param {string} version - The version number to update in the project's package.json file. (optional)
|
|
298
|
-
* @returns {Promise<boolean>} - A Promise that resolves to true if the LDD build is successful, false otherwise.
|
|
299
|
-
*/
|
|
300
|
-
async function buildLdd(version) {
|
|
301
|
-
let action = false;
|
|
302
|
-
await checkFolders();
|
|
303
|
-
|
|
304
|
-
const packageJson = await readPackageJson();
|
|
305
|
-
const lddJson = await readLivingDocsJson();
|
|
306
|
-
|
|
307
|
-
if (version) {
|
|
308
|
-
packageJson.version = version;
|
|
309
|
-
await writePackageJson(packageJson);
|
|
310
|
-
action = true;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
lddJson.name = packageJson.name;
|
|
314
|
-
lddJson.version = packageJson.version;
|
|
315
|
-
|
|
316
|
-
const input = resolve(CWD, 'ldd.html');
|
|
317
|
-
try {
|
|
318
|
-
await statSync(input);
|
|
319
|
-
} catch (e) {
|
|
320
|
-
return true;
|
|
321
|
-
}
|
|
322
|
-
try {
|
|
323
|
-
await writeFileSync(`${outputPath}/v${lddJson.version}.txt`, '');
|
|
324
|
-
return await viteBuild({
|
|
325
|
-
build: {
|
|
326
|
-
outDir: './.output/ldd',
|
|
327
|
-
rollupOptions: {
|
|
328
|
-
input: {
|
|
329
|
-
ldd: input,
|
|
330
|
-
},
|
|
331
|
-
output: {
|
|
332
|
-
entryFileNames: `assets/[name].js`,
|
|
333
|
-
chunkFileNames: `assets/[name].js`,
|
|
334
|
-
assetFileNames: `assets/[name].[ext]`,
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
copyPublicDir: false,
|
|
338
|
-
},
|
|
339
|
-
})
|
|
340
|
-
.then(async () => {
|
|
341
|
-
const assetsPath = outputPath + '/ldd/assets';
|
|
342
|
-
const assetsFiles = await readdirSync(assetsPath);
|
|
343
|
-
for (let i = 0; i < assetsFiles.length; i++) {
|
|
344
|
-
const file = assetsFiles[i];
|
|
345
|
-
if (file.endsWith('.css')) {
|
|
346
|
-
const path = './assets/' + file;
|
|
347
|
-
if (!lddJson.assets.css.includes(path)) {
|
|
348
|
-
action = true;
|
|
349
|
-
lddJson.assets.css.push(path);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (file.endsWith('.js')) {
|
|
353
|
-
const path = './assets/' + file;
|
|
354
|
-
if (!lddJson.assets.js.includes(path)) {
|
|
355
|
-
action = true;
|
|
356
|
-
lddJson.assets.js.push(path);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (action) {
|
|
361
|
-
await writeLivingDocsJson(lddJson);
|
|
362
|
-
}
|
|
363
|
-
return true;
|
|
364
|
-
})
|
|
365
|
-
.then(async () => {
|
|
366
|
-
return await finalizeLdd();
|
|
367
|
-
});
|
|
368
|
-
} catch (e) {
|
|
369
|
-
console.error(e);
|
|
370
|
-
return false;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Builds the word document by compiling the HTML file using Vite and
|
|
376
|
-
* returns the result.
|
|
377
|
-
*
|
|
378
|
-
* @returns {Promise<boolean>} - A promise that resolves to true if the word document is successfully built,
|
|
379
|
-
* or false if there was an error during the build process.
|
|
380
|
-
*/
|
|
381
|
-
async function buildWord() {
|
|
382
|
-
await checkFolders();
|
|
383
|
-
|
|
384
|
-
try {
|
|
385
|
-
const input = resolve(CWD, 'word.html');
|
|
386
|
-
await statSync(input);
|
|
387
|
-
return await viteBuild({
|
|
388
|
-
build: {
|
|
389
|
-
outDir: resolve(CWD, '.output/word'),
|
|
390
|
-
rollupOptions: {
|
|
391
|
-
input: {
|
|
392
|
-
word: input,
|
|
393
|
-
},
|
|
394
|
-
output: {
|
|
395
|
-
entryFileNames: `[name].js`,
|
|
396
|
-
chunkFileNames: `[name].js`,
|
|
397
|
-
assetFileNames: `[name].[ext]`,
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
copyPublicDir: false,
|
|
401
|
-
},
|
|
402
|
-
});
|
|
403
|
-
} catch (e) {
|
|
404
|
-
let configFile = false;
|
|
405
|
-
try {
|
|
406
|
-
const file = resolve(CWD, 'vite.config.word.ts');
|
|
407
|
-
await statSync(file);
|
|
408
|
-
console.log('Use vite.config.word.ts file');
|
|
409
|
-
configFile = file;
|
|
410
|
-
} catch (e) {
|
|
411
|
-
console.log('No use of vite.config.word.ts file');
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
const entry = resolve(CWD, 'word.ts');
|
|
415
|
-
|
|
416
|
-
const config = {
|
|
417
|
-
configFile: configFile,
|
|
418
|
-
base: './',
|
|
419
|
-
build: {
|
|
420
|
-
outDir: resolve(CWD, '.output/word'),
|
|
421
|
-
lib: {
|
|
422
|
-
fileName: 'word',
|
|
423
|
-
entry: entry,
|
|
424
|
-
formats: ['es'],
|
|
425
|
-
},
|
|
426
|
-
},
|
|
427
|
-
resolve: {
|
|
428
|
-
alias: {
|
|
429
|
-
'@': fileURLToPath(new URL(resolve(CWD, 'src'), import.meta.url)),
|
|
430
|
-
nswow: fileURLToPath(new URL(resolve(CWD, 'nswow'), import.meta.url)),
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
publicDir: false,
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
try {
|
|
437
|
-
return await viteBuild(config);
|
|
438
|
-
} catch (e) {
|
|
439
|
-
console.error(e);
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Builds the project sequentially by executing a series of asynchronous tasks in a specific order.
|
|
447
|
-
* This method is used to build the project in a predetermined sequence.
|
|
448
|
-
*
|
|
449
|
-
* @return {Promise<void>} A Promise that resolves when the build process is completed or rejects if an error occurs.
|
|
450
|
-
*/
|
|
451
|
-
async function build() {
|
|
452
|
-
try {
|
|
453
|
-
await checkFolders();
|
|
454
|
-
const packageJson = await readPackageJson();
|
|
455
|
-
const prompt = new Input({
|
|
456
|
-
message: 'Livingdocs version',
|
|
457
|
-
initial: packageJson.version,
|
|
458
|
-
});
|
|
459
|
-
const version = await prompt.run();
|
|
460
|
-
await cleanOutput();
|
|
461
|
-
await beaver(1);
|
|
462
|
-
await mapScss();
|
|
463
|
-
await mapLdd();
|
|
464
|
-
await buildApp();
|
|
465
|
-
await buildPdf();
|
|
466
|
-
await buildWord();
|
|
467
|
-
await buildLdd(version);
|
|
468
|
-
await zipApp();
|
|
469
|
-
} catch (error) {
|
|
470
|
-
console.log(error);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Builds the project sequentially by executing a series of asynchronous tasks in a specific order.
|
|
476
|
-
* This method is used to build the project in a predetermined sequence.
|
|
477
|
-
*
|
|
478
|
-
* @return {Promise<void>} A Promise that resolves when the build process is completed or rejects if an error occurs.
|
|
479
|
-
*/
|
|
480
|
-
async function ddev() {
|
|
481
|
-
try {
|
|
482
|
-
await checkFolders();
|
|
483
|
-
const packageJson = await readPackageJson();
|
|
484
|
-
await beaver(1);
|
|
485
|
-
await mapScss();
|
|
486
|
-
await mapLdd();
|
|
487
|
-
await buildDDev();
|
|
488
|
-
} catch (error) {
|
|
489
|
-
console.error(error);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Cleans up the SCSS alias by removing any characters that are not alphanumeric.
|
|
495
|
-
* @param string
|
|
496
|
-
*/
|
|
497
|
-
function cleanupScssAlias(string) {
|
|
498
|
-
return string.replace(/[^a-zA-Z0-9]/g, '');
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* Maps SCSS files and generates import statements for different output files.
|
|
503
|
-
*
|
|
504
|
-
* @returns {Promise<boolean>} Returns a promise that resolves to true if the SCSS mapping is successful, and false if there's an error.
|
|
505
|
-
*/
|
|
506
|
-
async function mapScss() {
|
|
507
|
-
await checkFolders();
|
|
508
|
-
try {
|
|
509
|
-
const relativePathToRoot = '../';
|
|
510
|
-
|
|
511
|
-
const output = {
|
|
512
|
-
app: [],
|
|
513
|
-
ldd: [],
|
|
514
|
-
pdf: [],
|
|
515
|
-
word: [],
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
const mainFiles = await glob(
|
|
519
|
-
resolve(process.cwd(), './src/assets/scss/*.scss'),
|
|
520
|
-
{
|
|
521
|
-
withFileTypes: true,
|
|
522
|
-
},
|
|
523
|
-
);
|
|
524
|
-
|
|
525
|
-
let f = mainFiles.find((p) => {
|
|
526
|
-
return p.name === 'general.scss';
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
const alias = cleanupScssAlias(f.relative());
|
|
530
|
-
|
|
531
|
-
if (f) {
|
|
532
|
-
output.app.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
533
|
-
output.ldd.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
534
|
-
output.pdf.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
535
|
-
output.word.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
for (let x = 0; x < mainFiles.length; x++) {
|
|
539
|
-
const alias = cleanupScssAlias(mainFiles[x].relative());
|
|
540
|
-
if (mainFiles[x].name === 'app.scss') {
|
|
541
|
-
output.app.push(
|
|
542
|
-
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
if (mainFiles[x].name === 'ldd.scss') {
|
|
546
|
-
output.ldd.push(
|
|
547
|
-
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
548
|
-
);
|
|
549
|
-
}
|
|
550
|
-
if (mainFiles[x].name === 'pdf.scss') {
|
|
551
|
-
output.pdf.push(
|
|
552
|
-
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
553
|
-
);
|
|
554
|
-
}
|
|
555
|
-
if (mainFiles[x].name === 'word.scss') {
|
|
556
|
-
output.word.push(
|
|
557
|
-
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
558
|
-
);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
const livingdocs = await glob(resolve(process.cwd(), './livingdocs/**/*'), {
|
|
563
|
-
maxDepth: 3,
|
|
564
|
-
withFileTypes: true,
|
|
565
|
-
});
|
|
566
|
-
livingdocs.sort((a, b) => {
|
|
567
|
-
const valueA = a.relative().toUpperCase();
|
|
568
|
-
const valueB = b.relative().toUpperCase();
|
|
569
|
-
if (valueA < valueB) {
|
|
570
|
-
return -1;
|
|
571
|
-
}
|
|
572
|
-
if (valueA > valueB) {
|
|
573
|
-
return 1;
|
|
574
|
-
}
|
|
575
|
-
return 0;
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
const components = livingdocs.filter((p) => {
|
|
579
|
-
return p.name !== 'Properties' && p.parent.name !== 'Properties';
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
const properties = livingdocs.filter((p) => {
|
|
583
|
-
return p.name === 'Properties' || p.parent.name === 'Properties';
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
const livingdocsList = [...components, ...properties];
|
|
587
|
-
|
|
588
|
-
for (let x = 0; x < livingdocsList.length; x++) {
|
|
589
|
-
const p = livingdocsList[x];
|
|
590
|
-
try {
|
|
591
|
-
const general = await statSync(p.fullpath() + '/general.scss');
|
|
592
|
-
const alias = cleanupScssAlias(`${p.relative()}/general.scss`);
|
|
593
|
-
output.app.push(
|
|
594
|
-
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
595
|
-
);
|
|
596
|
-
output.ldd.push(
|
|
597
|
-
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
598
|
-
);
|
|
599
|
-
output.pdf.push(
|
|
600
|
-
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
601
|
-
);
|
|
602
|
-
output.word.push(
|
|
603
|
-
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
604
|
-
);
|
|
605
|
-
} catch (e) {}
|
|
606
|
-
|
|
607
|
-
const types = ['app', 'ldd', 'pdf', 'word'];
|
|
608
|
-
|
|
609
|
-
for (let i = 0; i < types.length; i++) {
|
|
610
|
-
const type = types[i];
|
|
611
|
-
try {
|
|
612
|
-
const f = await statSync(p.fullpath() + '/' + type + '.scss');
|
|
613
|
-
const alias = cleanupScssAlias(`${p.relative()}/${type}.scss`);
|
|
614
|
-
output[type].push(
|
|
615
|
-
`"${relativePathToRoot}${p.relative()}/${type}.scss" as ${alias}`,
|
|
616
|
-
);
|
|
617
|
-
} catch (e) {}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
await writeFileSync(
|
|
622
|
-
`${CWD}/.nswow/app.scss`,
|
|
623
|
-
`@use ` +
|
|
624
|
-
output.app.join(';\n@use ') +
|
|
625
|
-
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
626
|
-
);
|
|
627
|
-
await writeFileSync(
|
|
628
|
-
`${CWD}/.nswow/ldd.scss`,
|
|
629
|
-
`@use ` +
|
|
630
|
-
output.ldd.join(';\n@use ') +
|
|
631
|
-
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
632
|
-
);
|
|
633
|
-
await writeFileSync(
|
|
634
|
-
`${CWD}/.nswow/pdf.scss`,
|
|
635
|
-
`@use ` +
|
|
636
|
-
output.pdf.join(';\n@use ') +
|
|
637
|
-
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
638
|
-
);
|
|
639
|
-
await writeFileSync(
|
|
640
|
-
`${CWD}/.nswow/word.scss`,
|
|
641
|
-
`@use ` +
|
|
642
|
-
output.word.join(';\n@use ') +
|
|
643
|
-
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
644
|
-
);
|
|
645
|
-
|
|
646
|
-
return true;
|
|
647
|
-
} catch (e) {
|
|
648
|
-
console.log(e);
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* This function asynchronously maps JavaScript files and imports them into specific files.
|
|
655
|
-
* @returns {Promise<boolean>} - A promise that resolves to true if the mapping and importing is successful.
|
|
656
|
-
*/
|
|
657
|
-
async function mapJs() {
|
|
658
|
-
const jsFiles = await glob(resolve(CWD, './livingdocs/' + '**/app.[t,j]s'), {
|
|
659
|
-
withFileTypes: true,
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
const imports = [];
|
|
663
|
-
const register = [];
|
|
664
|
-
|
|
665
|
-
for (let i = 0; i < jsFiles.length; i++) {
|
|
666
|
-
const file = jsFiles[i];
|
|
667
|
-
const className = camelCase(file.parent.name);
|
|
668
|
-
const path = [file.name];
|
|
669
|
-
let parent = file.parent;
|
|
670
|
-
while (parent) {
|
|
671
|
-
path.unshift(parent.name);
|
|
672
|
-
if (parent.name !== 'livingdocs') {
|
|
673
|
-
parent = parent.parent;
|
|
674
|
-
} else {
|
|
675
|
-
parent = false;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
imports.push(`import ${className} from "../${path.join(file.sep)}"`);
|
|
679
|
-
register.push(`ClassAutoLoader.register(${className}, "${className}")`);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
const content = `import ArticleAutoloader from 'nswow/ArticleAutoloader'
|
|
683
|
-
${imports.join('\n')}
|
|
684
|
-
const ClassAutoLoader = new ArticleAutoloader()
|
|
685
|
-
${register.join('\n')}
|
|
686
|
-
export default ClassAutoLoader
|
|
687
|
-
export { ClassAutoLoader }`;
|
|
688
|
-
|
|
689
|
-
await writeFileSync(resolve(CWD, './src/Autoload.ts'), content);
|
|
690
|
-
return true;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Maps the livingdocs properties to components and groups.
|
|
695
|
-
*
|
|
696
|
-
* @returns {Promise<boolean>} Returns a promise that resolves to a boolean indicating the success or failure of the mapping.
|
|
697
|
-
*/
|
|
698
|
-
async function mapLdd() {
|
|
699
|
-
await checkFolders();
|
|
700
|
-
try {
|
|
701
|
-
const lddJson = await readLivingDocsJson();
|
|
702
|
-
|
|
703
|
-
const propertiesFiles = await glob(
|
|
704
|
-
resolve(CWD, './livingdocs/**/properties.{json,js,ts}'),
|
|
705
|
-
);
|
|
706
|
-
const mapProperties = {};
|
|
707
|
-
for (let i = 0; i < propertiesFiles.length; i++) {
|
|
708
|
-
const file = propertiesFiles[i];
|
|
709
|
-
if (file.endsWith('.js') || file.endsWith('.ts')) {
|
|
710
|
-
const properties = require(propertiesFiles[i]).default;
|
|
711
|
-
const oKeys = Object.keys(properties);
|
|
712
|
-
for (let j = 0; j < oKeys.length; j++) {
|
|
713
|
-
mapProperties[oKeys[j]] = properties[oKeys[j]];
|
|
714
|
-
}
|
|
715
|
-
} else if (file.endsWith('.json')) {
|
|
716
|
-
const properties = JSON.parse(readFileSync(propertiesFiles[i]));
|
|
717
|
-
const oKeys = Object.keys(properties);
|
|
718
|
-
for (let j = 0; j < oKeys.length; j++) {
|
|
719
|
-
mapProperties[oKeys[j]] = properties[oKeys[j]];
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
lddJson.componentProperties = mapProperties;
|
|
724
|
-
|
|
725
|
-
const groupsPath = resolve(CWD, './livingdocs');
|
|
726
|
-
const groups = readdirSync(groupsPath);
|
|
727
|
-
const keepGroups = [];
|
|
728
|
-
|
|
729
|
-
for (let x = 0; x < groups.length; x++) {
|
|
730
|
-
const group = groups[x];
|
|
731
|
-
const groupName = group.replace('_and_', ' / ').replace('_', ' ');
|
|
732
|
-
try {
|
|
733
|
-
const stat = statSync(`${groupsPath}/${group}`);
|
|
734
|
-
if (stat.isDirectory()) {
|
|
735
|
-
const components = [];
|
|
736
|
-
const c = readdirSync(`${groupsPath}/${group}`);
|
|
737
|
-
for (let j = 0; j < c.length; j++) {
|
|
738
|
-
const component = c[j];
|
|
739
|
-
try {
|
|
740
|
-
const stat = statSync(
|
|
741
|
-
`${groupsPath}/${group}/${component}/${component}.html`,
|
|
742
|
-
);
|
|
743
|
-
components.push(component);
|
|
744
|
-
} catch (e) {}
|
|
745
|
-
}
|
|
746
|
-
if (components.length) {
|
|
747
|
-
keepGroups.push(groupName);
|
|
748
|
-
const i = lddJson.groups.find((g) => {
|
|
749
|
-
return g.label === groupName;
|
|
750
|
-
});
|
|
751
|
-
if (i) {
|
|
752
|
-
const newComponents = [];
|
|
753
|
-
for (let j = 0; j < i.components.length; j++) {
|
|
754
|
-
const index = components.indexOf(i.components[j]);
|
|
755
|
-
if (index !== -1) {
|
|
756
|
-
newComponents.push(components[index]);
|
|
757
|
-
components.splice(index, 1);
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
for (let j = 0; j < components.length; j++) {
|
|
761
|
-
newComponents.push(components[j]);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
i.components = newComponents;
|
|
765
|
-
} else {
|
|
766
|
-
lddJson.groups.push({
|
|
767
|
-
label: groupName,
|
|
768
|
-
components: components,
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
} else {
|
|
773
|
-
rmSync(`${groupsPath}/${group}`);
|
|
774
|
-
}
|
|
775
|
-
} catch (e) {
|
|
776
|
-
console.log(e);
|
|
777
|
-
return false;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
const newMap = [];
|
|
782
|
-
for (let i = 0; i < lddJson.groups.length; i++) {
|
|
783
|
-
const c = lddJson.groups[i];
|
|
784
|
-
if (keepGroups.includes(c.label)) {
|
|
785
|
-
newMap.push(c);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
lddJson.groups = newMap;
|
|
789
|
-
await writeLivingDocsJson(lddJson);
|
|
790
|
-
return true;
|
|
791
|
-
} catch (e) {
|
|
792
|
-
console.error(e);
|
|
793
|
-
return false;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
/**
|
|
798
|
-
* Maps the SCSS files and the LDD files in the project.
|
|
799
|
-
*
|
|
800
|
-
* @async
|
|
801
|
-
* @function map
|
|
802
|
-
* @returns {Promise<boolean>} A promise that resolves after successfully mapping the files.
|
|
803
|
-
* @throws {Error} If there is an error during the mapping process.
|
|
804
|
-
*/
|
|
805
|
-
async function map() {
|
|
806
|
-
await checkFolders();
|
|
807
|
-
await mapScss();
|
|
808
|
-
await mapLdd();
|
|
809
|
-
return true;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
export { build, ddev, map, mapScss, mapLdd, mapJs };
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import {
|
|
3
|
+
statSync,
|
|
4
|
+
writeFileSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
readdirSync,
|
|
8
|
+
createWriteStream,
|
|
9
|
+
rmSync,
|
|
10
|
+
cpSync,
|
|
11
|
+
} from 'node:fs';
|
|
12
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
|
+
import { glob } from 'glob';
|
|
15
|
+
import { beaver } from './beaver.js';
|
|
16
|
+
import { build as viteBuild } from 'vite';
|
|
17
|
+
import { build as finalizeLdd } from './migrate-livingdocs-build/bin/build.js';
|
|
18
|
+
import {
|
|
19
|
+
readPackageJson,
|
|
20
|
+
writePackageJson,
|
|
21
|
+
readLivingDocsJson,
|
|
22
|
+
writeLivingDocsJson,
|
|
23
|
+
} from './utils.js';
|
|
24
|
+
import { camelCase } from 'cheerio/utils';
|
|
25
|
+
|
|
26
|
+
const placeholderId = '6297EAFB-33A0-48B8-8D64-E61CDC3E9035';
|
|
27
|
+
const CWD = process.cwd();
|
|
28
|
+
const nswowPath = resolve(CWD, '.nswow');
|
|
29
|
+
const outputPath = resolve(CWD, '.output');
|
|
30
|
+
const require = createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
const { Input } = require('enquirer');
|
|
33
|
+
|
|
34
|
+
let foldersChecked = false;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Checks if the required folders exist and creates them if necessary.
|
|
38
|
+
*
|
|
39
|
+
* @async
|
|
40
|
+
* @returns {Promise<boolean>} A promise that resolves to true once the folders are checked and created.
|
|
41
|
+
*/
|
|
42
|
+
async function checkFolders() {
|
|
43
|
+
if (!foldersChecked) {
|
|
44
|
+
foldersChecked = true;
|
|
45
|
+
try {
|
|
46
|
+
await statSync(nswowPath);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
await mkdirSync(nswowPath);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
await statSync(outputPath);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
await mkdirSync(outputPath);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cleans the output directory by removing all files and folders.
|
|
61
|
+
*
|
|
62
|
+
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the cleanup was successful.
|
|
63
|
+
*/
|
|
64
|
+
async function cleanOutput() {
|
|
65
|
+
await checkFolders();
|
|
66
|
+
const output = readdirSync(outputPath);
|
|
67
|
+
for (let i = 0; i < output.length; i++) {
|
|
68
|
+
await rmSync(`${outputPath}/${output[i]}`, {
|
|
69
|
+
force: true,
|
|
70
|
+
recursive: true,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Builds the application by performing the following steps:
|
|
78
|
+
*
|
|
79
|
+
* 1. Checks the folders.
|
|
80
|
+
* 2. Executes the viteBuild function.
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<void>} A Promise that resolves when the application is built.
|
|
83
|
+
*/
|
|
84
|
+
async function buildApp() {
|
|
85
|
+
await checkFolders();
|
|
86
|
+
const build = await viteBuild({
|
|
87
|
+
build: {
|
|
88
|
+
copyPublicDir: false,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Copy public folder exclude nswow folders
|
|
93
|
+
console.log(
|
|
94
|
+
'\n\nCopy public folder exclude nswow folders and exclude folder',
|
|
95
|
+
);
|
|
96
|
+
await cpSync(`${CWD}/public/`, `${outputPath}/app`, {
|
|
97
|
+
filter: (src) => {
|
|
98
|
+
if (
|
|
99
|
+
src.startsWith(`${CWD}/public/downloads`) ||
|
|
100
|
+
src.startsWith(`${CWD}/public/html`) ||
|
|
101
|
+
src.startsWith(`${CWD}/public/images`) ||
|
|
102
|
+
src.startsWith(`${CWD}/public/json`) ||
|
|
103
|
+
src.startsWith(`${CWD}/public/exclude`)
|
|
104
|
+
) {
|
|
105
|
+
return false;
|
|
106
|
+
} else {
|
|
107
|
+
src === `${CWD}/public/` ||
|
|
108
|
+
console.log(`Copy ${src} to ${outputPath}/app`);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
recursive: true,
|
|
113
|
+
});
|
|
114
|
+
console.log('\n');
|
|
115
|
+
|
|
116
|
+
let index = await readFileSync(`${outputPath}/app/index.html`, 'utf8');
|
|
117
|
+
|
|
118
|
+
console.log('Create file /template/article.html for nswow hybrid\n');
|
|
119
|
+
index = index.replace(
|
|
120
|
+
'<html>',
|
|
121
|
+
`<html lang="[[language-${placeholderId}]]">`,
|
|
122
|
+
);
|
|
123
|
+
index = index.replace(
|
|
124
|
+
/<base\s+href\s*=\s*(['"])(.*?)\1\s*\/?>/gi,
|
|
125
|
+
`<base href="[[base-${placeholderId}]]" />
|
|
126
|
+
[[meta-${placeholderId}]]`,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
index = index.replace(
|
|
130
|
+
/(<div\s+[^>]*id\s*=\s*["']app["'][^>]*>)([\s\S]*?)(<\/div>)/i,
|
|
131
|
+
`$1
|
|
132
|
+
<template>
|
|
133
|
+
[[content-${placeholderId}]]
|
|
134
|
+
</template>
|
|
135
|
+
$3`,
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
await mkdirSync(`${outputPath}/app/template`, { recursive: true });
|
|
139
|
+
await writeFileSync(`${outputPath}/app/index.html`, index);
|
|
140
|
+
await writeFileSync(`${outputPath}/app/template/article.html`, index);
|
|
141
|
+
/**
|
|
142
|
+
await writeFileSync(`${outputPath}/app/web.config`, `<?xml version="1.0" encoding="UTF-8"?>
|
|
143
|
+
<configuration>
|
|
144
|
+
<system.webServer>
|
|
145
|
+
<rewrite>
|
|
146
|
+
<rules>
|
|
147
|
+
<rule name="Rewrite to index.html" stopProcessing="true">
|
|
148
|
+
<match url=".*" />
|
|
149
|
+
<conditions logicalGrouping="MatchAll">
|
|
150
|
+
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
|
151
|
+
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
|
|
152
|
+
</conditions>
|
|
153
|
+
<action type="Rewrite" url="index.html" />
|
|
154
|
+
</rule>
|
|
155
|
+
</rules>
|
|
156
|
+
</rewrite>
|
|
157
|
+
</system.webServer>
|
|
158
|
+
</configuration>`);
|
|
159
|
+
await writeFileSync(`${outputPath}/app/.htaccess`, `RewriteEngine On
|
|
160
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
161
|
+
RewriteCond %{REQUEST_FILENAME} !-l
|
|
162
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
163
|
+
RewriteRule ^(.*)$ index.html [L]`);
|
|
164
|
+
/**/
|
|
165
|
+
return build;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Builds the application by performing the following steps:
|
|
170
|
+
*
|
|
171
|
+
* 1. Checks the folders.
|
|
172
|
+
* 2. Executes the viteBuild function.
|
|
173
|
+
*
|
|
174
|
+
* @returns {Promise<void>} A Promise that resolves when the application is built.
|
|
175
|
+
*/
|
|
176
|
+
async function buildDDev() {
|
|
177
|
+
await checkFolders();
|
|
178
|
+
const build = await viteBuild({
|
|
179
|
+
build: {
|
|
180
|
+
outDir: './.output/ddev',
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
return build;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Compresses the 'app' folder into a zip file using archiver library.
|
|
188
|
+
*
|
|
189
|
+
* @async
|
|
190
|
+
* @function zipApp
|
|
191
|
+
* @returns {Promise<void>} - A Promise that resolves when the zip operation is complete, or rejects with an error.
|
|
192
|
+
*/
|
|
193
|
+
async function zipApp() {
|
|
194
|
+
await checkFolders();
|
|
195
|
+
const archiver = require('archiver');
|
|
196
|
+
const output = createWriteStream(outputPath + '/app.zip');
|
|
197
|
+
const archive = archiver('zip', {
|
|
198
|
+
zlib: { level: 9 }, // Sets the compression level.
|
|
199
|
+
});
|
|
200
|
+
output.on('close', function () {
|
|
201
|
+
console.log('Create zip ' + outputPath + '/app.zip');
|
|
202
|
+
console.log(archive.pointer() + ' total bytes');
|
|
203
|
+
});
|
|
204
|
+
output.on('end', function () {
|
|
205
|
+
console.log('Data has been drained');
|
|
206
|
+
});
|
|
207
|
+
archive.on('warning', function (err) {
|
|
208
|
+
if (err.code === 'ENOENT') {
|
|
209
|
+
console.error(err);
|
|
210
|
+
} else {
|
|
211
|
+
// throw error
|
|
212
|
+
throw err;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
archive.on('error', function (err) {
|
|
216
|
+
throw err;
|
|
217
|
+
});
|
|
218
|
+
archive.pipe(output);
|
|
219
|
+
archive.directory(outputPath + '/app/', false);
|
|
220
|
+
archive.finalize();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Builds a PDF using the provided HTML template.
|
|
225
|
+
*
|
|
226
|
+
* @returns {Promise<boolean>} - Returns a Promise that resolves to true if the PDF was successfully built,
|
|
227
|
+
* false otherwise.
|
|
228
|
+
*/
|
|
229
|
+
async function buildPdf() {
|
|
230
|
+
await checkFolders();
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
const input = resolve(CWD, 'pdf.html');
|
|
234
|
+
await statSync(input);
|
|
235
|
+
return await viteBuild({
|
|
236
|
+
build: {
|
|
237
|
+
outDir: resolve(CWD, '.output/pdf'),
|
|
238
|
+
rollupOptions: {
|
|
239
|
+
input: {
|
|
240
|
+
pdf: input,
|
|
241
|
+
},
|
|
242
|
+
output: {
|
|
243
|
+
entryFileNames: `[name].js`,
|
|
244
|
+
chunkFileNames: `[name].js`,
|
|
245
|
+
assetFileNames: `[name].[ext]`,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
copyPublicDir: false,
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
} catch (e) {
|
|
252
|
+
let configFile = false;
|
|
253
|
+
try {
|
|
254
|
+
const file = resolve(CWD, 'vite.config.pdf.ts');
|
|
255
|
+
await statSync(file);
|
|
256
|
+
console.log('Use vite.config.pdf.ts file');
|
|
257
|
+
configFile = file;
|
|
258
|
+
} catch (e) {
|
|
259
|
+
console.log('No use of vite.config.pdf.ts file');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const entry = resolve(CWD, 'pdf.ts');
|
|
263
|
+
|
|
264
|
+
const config = {
|
|
265
|
+
configFile: configFile,
|
|
266
|
+
base: './',
|
|
267
|
+
build: {
|
|
268
|
+
outDir: resolve(CWD, '.output/pdf'),
|
|
269
|
+
lib: {
|
|
270
|
+
fileName: 'pdf',
|
|
271
|
+
entry: entry,
|
|
272
|
+
formats: ['es'],
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
resolve: {
|
|
276
|
+
alias: {
|
|
277
|
+
'@': fileURLToPath(new URL(resolve(CWD, 'src'), import.meta.url)),
|
|
278
|
+
nswow: fileURLToPath(new URL(resolve(CWD, 'nswow'), import.meta.url)),
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
publicDir: false,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
try {
|
|
285
|
+
return await viteBuild(config);
|
|
286
|
+
} catch (e) {
|
|
287
|
+
console.error(e);
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Builds Living Documentation (LDD) for a project.
|
|
295
|
+
*
|
|
296
|
+
* @async
|
|
297
|
+
* @param {string} version - The version number to update in the project's package.json file. (optional)
|
|
298
|
+
* @returns {Promise<boolean>} - A Promise that resolves to true if the LDD build is successful, false otherwise.
|
|
299
|
+
*/
|
|
300
|
+
async function buildLdd(version) {
|
|
301
|
+
let action = false;
|
|
302
|
+
await checkFolders();
|
|
303
|
+
|
|
304
|
+
const packageJson = await readPackageJson();
|
|
305
|
+
const lddJson = await readLivingDocsJson();
|
|
306
|
+
|
|
307
|
+
if (version) {
|
|
308
|
+
packageJson.version = version;
|
|
309
|
+
await writePackageJson(packageJson);
|
|
310
|
+
action = true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
lddJson.name = packageJson.name;
|
|
314
|
+
lddJson.version = packageJson.version;
|
|
315
|
+
|
|
316
|
+
const input = resolve(CWD, 'ldd.html');
|
|
317
|
+
try {
|
|
318
|
+
await statSync(input);
|
|
319
|
+
} catch (e) {
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
try {
|
|
323
|
+
await writeFileSync(`${outputPath}/v${lddJson.version}.txt`, '');
|
|
324
|
+
return await viteBuild({
|
|
325
|
+
build: {
|
|
326
|
+
outDir: './.output/ldd',
|
|
327
|
+
rollupOptions: {
|
|
328
|
+
input: {
|
|
329
|
+
ldd: input,
|
|
330
|
+
},
|
|
331
|
+
output: {
|
|
332
|
+
entryFileNames: `assets/[name].js`,
|
|
333
|
+
chunkFileNames: `assets/[name].js`,
|
|
334
|
+
assetFileNames: `assets/[name].[ext]`,
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
copyPublicDir: false,
|
|
338
|
+
},
|
|
339
|
+
})
|
|
340
|
+
.then(async () => {
|
|
341
|
+
const assetsPath = outputPath + '/ldd/assets';
|
|
342
|
+
const assetsFiles = await readdirSync(assetsPath);
|
|
343
|
+
for (let i = 0; i < assetsFiles.length; i++) {
|
|
344
|
+
const file = assetsFiles[i];
|
|
345
|
+
if (file.endsWith('.css')) {
|
|
346
|
+
const path = './assets/' + file;
|
|
347
|
+
if (!lddJson.assets.css.includes(path)) {
|
|
348
|
+
action = true;
|
|
349
|
+
lddJson.assets.css.push(path);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (file.endsWith('.js')) {
|
|
353
|
+
const path = './assets/' + file;
|
|
354
|
+
if (!lddJson.assets.js.includes(path)) {
|
|
355
|
+
action = true;
|
|
356
|
+
lddJson.assets.js.push(path);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (action) {
|
|
361
|
+
await writeLivingDocsJson(lddJson);
|
|
362
|
+
}
|
|
363
|
+
return true;
|
|
364
|
+
})
|
|
365
|
+
.then(async () => {
|
|
366
|
+
return await finalizeLdd();
|
|
367
|
+
});
|
|
368
|
+
} catch (e) {
|
|
369
|
+
console.error(e);
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Builds the word document by compiling the HTML file using Vite and
|
|
376
|
+
* returns the result.
|
|
377
|
+
*
|
|
378
|
+
* @returns {Promise<boolean>} - A promise that resolves to true if the word document is successfully built,
|
|
379
|
+
* or false if there was an error during the build process.
|
|
380
|
+
*/
|
|
381
|
+
async function buildWord() {
|
|
382
|
+
await checkFolders();
|
|
383
|
+
|
|
384
|
+
try {
|
|
385
|
+
const input = resolve(CWD, 'word.html');
|
|
386
|
+
await statSync(input);
|
|
387
|
+
return await viteBuild({
|
|
388
|
+
build: {
|
|
389
|
+
outDir: resolve(CWD, '.output/word'),
|
|
390
|
+
rollupOptions: {
|
|
391
|
+
input: {
|
|
392
|
+
word: input,
|
|
393
|
+
},
|
|
394
|
+
output: {
|
|
395
|
+
entryFileNames: `[name].js`,
|
|
396
|
+
chunkFileNames: `[name].js`,
|
|
397
|
+
assetFileNames: `[name].[ext]`,
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
copyPublicDir: false,
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
} catch (e) {
|
|
404
|
+
let configFile = false;
|
|
405
|
+
try {
|
|
406
|
+
const file = resolve(CWD, 'vite.config.word.ts');
|
|
407
|
+
await statSync(file);
|
|
408
|
+
console.log('Use vite.config.word.ts file');
|
|
409
|
+
configFile = file;
|
|
410
|
+
} catch (e) {
|
|
411
|
+
console.log('No use of vite.config.word.ts file');
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const entry = resolve(CWD, 'word.ts');
|
|
415
|
+
|
|
416
|
+
const config = {
|
|
417
|
+
configFile: configFile,
|
|
418
|
+
base: './',
|
|
419
|
+
build: {
|
|
420
|
+
outDir: resolve(CWD, '.output/word'),
|
|
421
|
+
lib: {
|
|
422
|
+
fileName: 'word',
|
|
423
|
+
entry: entry,
|
|
424
|
+
formats: ['es'],
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
resolve: {
|
|
428
|
+
alias: {
|
|
429
|
+
'@': fileURLToPath(new URL(resolve(CWD, 'src'), import.meta.url)),
|
|
430
|
+
nswow: fileURLToPath(new URL(resolve(CWD, 'nswow'), import.meta.url)),
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
publicDir: false,
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
try {
|
|
437
|
+
return await viteBuild(config);
|
|
438
|
+
} catch (e) {
|
|
439
|
+
console.error(e);
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Builds the project sequentially by executing a series of asynchronous tasks in a specific order.
|
|
447
|
+
* This method is used to build the project in a predetermined sequence.
|
|
448
|
+
*
|
|
449
|
+
* @return {Promise<void>} A Promise that resolves when the build process is completed or rejects if an error occurs.
|
|
450
|
+
*/
|
|
451
|
+
async function build() {
|
|
452
|
+
try {
|
|
453
|
+
await checkFolders();
|
|
454
|
+
const packageJson = await readPackageJson();
|
|
455
|
+
const prompt = new Input({
|
|
456
|
+
message: 'Livingdocs version',
|
|
457
|
+
initial: packageJson.version,
|
|
458
|
+
});
|
|
459
|
+
const version = await prompt.run();
|
|
460
|
+
await cleanOutput();
|
|
461
|
+
await beaver(1);
|
|
462
|
+
await mapScss();
|
|
463
|
+
await mapLdd();
|
|
464
|
+
await buildApp();
|
|
465
|
+
await buildPdf();
|
|
466
|
+
await buildWord();
|
|
467
|
+
await buildLdd(version);
|
|
468
|
+
await zipApp();
|
|
469
|
+
} catch (error) {
|
|
470
|
+
console.log(error);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Builds the project sequentially by executing a series of asynchronous tasks in a specific order.
|
|
476
|
+
* This method is used to build the project in a predetermined sequence.
|
|
477
|
+
*
|
|
478
|
+
* @return {Promise<void>} A Promise that resolves when the build process is completed or rejects if an error occurs.
|
|
479
|
+
*/
|
|
480
|
+
async function ddev() {
|
|
481
|
+
try {
|
|
482
|
+
await checkFolders();
|
|
483
|
+
const packageJson = await readPackageJson();
|
|
484
|
+
await beaver(1);
|
|
485
|
+
await mapScss();
|
|
486
|
+
await mapLdd();
|
|
487
|
+
await buildDDev();
|
|
488
|
+
} catch (error) {
|
|
489
|
+
console.error(error);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Cleans up the SCSS alias by removing any characters that are not alphanumeric.
|
|
495
|
+
* @param string
|
|
496
|
+
*/
|
|
497
|
+
function cleanupScssAlias(string) {
|
|
498
|
+
return string.replace(/[^a-zA-Z0-9]/g, '');
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Maps SCSS files and generates import statements for different output files.
|
|
503
|
+
*
|
|
504
|
+
* @returns {Promise<boolean>} Returns a promise that resolves to true if the SCSS mapping is successful, and false if there's an error.
|
|
505
|
+
*/
|
|
506
|
+
async function mapScss() {
|
|
507
|
+
await checkFolders();
|
|
508
|
+
try {
|
|
509
|
+
const relativePathToRoot = '../';
|
|
510
|
+
|
|
511
|
+
const output = {
|
|
512
|
+
app: [],
|
|
513
|
+
ldd: [],
|
|
514
|
+
pdf: [],
|
|
515
|
+
word: [],
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const mainFiles = await glob(
|
|
519
|
+
resolve(process.cwd(), './src/assets/scss/*.scss'),
|
|
520
|
+
{
|
|
521
|
+
withFileTypes: true,
|
|
522
|
+
},
|
|
523
|
+
);
|
|
524
|
+
|
|
525
|
+
let f = mainFiles.find((p) => {
|
|
526
|
+
return p.name === 'general.scss';
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
const alias = cleanupScssAlias(f.relative());
|
|
530
|
+
|
|
531
|
+
if (f) {
|
|
532
|
+
output.app.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
533
|
+
output.ldd.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
534
|
+
output.pdf.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
535
|
+
output.word.push(`"${relativePathToRoot}${f.relative()}" as ${alias}`);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
for (let x = 0; x < mainFiles.length; x++) {
|
|
539
|
+
const alias = cleanupScssAlias(mainFiles[x].relative());
|
|
540
|
+
if (mainFiles[x].name === 'app.scss') {
|
|
541
|
+
output.app.push(
|
|
542
|
+
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
if (mainFiles[x].name === 'ldd.scss') {
|
|
546
|
+
output.ldd.push(
|
|
547
|
+
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
if (mainFiles[x].name === 'pdf.scss') {
|
|
551
|
+
output.pdf.push(
|
|
552
|
+
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
if (mainFiles[x].name === 'word.scss') {
|
|
556
|
+
output.word.push(
|
|
557
|
+
`"${relativePathToRoot}${mainFiles[x].relative()}" as ${alias}`,
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
const livingdocs = await glob(resolve(process.cwd(), './livingdocs/**/*'), {
|
|
563
|
+
maxDepth: 3,
|
|
564
|
+
withFileTypes: true,
|
|
565
|
+
});
|
|
566
|
+
livingdocs.sort((a, b) => {
|
|
567
|
+
const valueA = a.relative().toUpperCase();
|
|
568
|
+
const valueB = b.relative().toUpperCase();
|
|
569
|
+
if (valueA < valueB) {
|
|
570
|
+
return -1;
|
|
571
|
+
}
|
|
572
|
+
if (valueA > valueB) {
|
|
573
|
+
return 1;
|
|
574
|
+
}
|
|
575
|
+
return 0;
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const components = livingdocs.filter((p) => {
|
|
579
|
+
return p.name !== 'Properties' && p.parent.name !== 'Properties';
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
const properties = livingdocs.filter((p) => {
|
|
583
|
+
return p.name === 'Properties' || p.parent.name === 'Properties';
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
const livingdocsList = [...components, ...properties];
|
|
587
|
+
|
|
588
|
+
for (let x = 0; x < livingdocsList.length; x++) {
|
|
589
|
+
const p = livingdocsList[x];
|
|
590
|
+
try {
|
|
591
|
+
const general = await statSync(p.fullpath() + '/general.scss');
|
|
592
|
+
const alias = cleanupScssAlias(`${p.relative()}/general.scss`);
|
|
593
|
+
output.app.push(
|
|
594
|
+
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
595
|
+
);
|
|
596
|
+
output.ldd.push(
|
|
597
|
+
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
598
|
+
);
|
|
599
|
+
output.pdf.push(
|
|
600
|
+
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
601
|
+
);
|
|
602
|
+
output.word.push(
|
|
603
|
+
`"${relativePathToRoot}${p.relative()}/general.scss" as ${alias}`,
|
|
604
|
+
);
|
|
605
|
+
} catch (e) {}
|
|
606
|
+
|
|
607
|
+
const types = ['app', 'ldd', 'pdf', 'word'];
|
|
608
|
+
|
|
609
|
+
for (let i = 0; i < types.length; i++) {
|
|
610
|
+
const type = types[i];
|
|
611
|
+
try {
|
|
612
|
+
const f = await statSync(p.fullpath() + '/' + type + '.scss');
|
|
613
|
+
const alias = cleanupScssAlias(`${p.relative()}/${type}.scss`);
|
|
614
|
+
output[type].push(
|
|
615
|
+
`"${relativePathToRoot}${p.relative()}/${type}.scss" as ${alias}`,
|
|
616
|
+
);
|
|
617
|
+
} catch (e) {}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
await writeFileSync(
|
|
622
|
+
`${CWD}/.nswow/app.scss`,
|
|
623
|
+
`@use ` +
|
|
624
|
+
output.app.join(';\n@use ') +
|
|
625
|
+
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
626
|
+
);
|
|
627
|
+
await writeFileSync(
|
|
628
|
+
`${CWD}/.nswow/ldd.scss`,
|
|
629
|
+
`@use ` +
|
|
630
|
+
output.ldd.join(';\n@use ') +
|
|
631
|
+
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
632
|
+
);
|
|
633
|
+
await writeFileSync(
|
|
634
|
+
`${CWD}/.nswow/pdf.scss`,
|
|
635
|
+
`@use ` +
|
|
636
|
+
output.pdf.join(';\n@use ') +
|
|
637
|
+
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
638
|
+
);
|
|
639
|
+
await writeFileSync(
|
|
640
|
+
`${CWD}/.nswow/word.scss`,
|
|
641
|
+
`@use ` +
|
|
642
|
+
output.word.join(';\n@use ') +
|
|
643
|
+
`;\n@use "nswow/core-styles" as nswowcorestyles;\n`,
|
|
644
|
+
);
|
|
645
|
+
|
|
646
|
+
return true;
|
|
647
|
+
} catch (e) {
|
|
648
|
+
console.log(e);
|
|
649
|
+
return false;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* This function asynchronously maps JavaScript files and imports them into specific files.
|
|
655
|
+
* @returns {Promise<boolean>} - A promise that resolves to true if the mapping and importing is successful.
|
|
656
|
+
*/
|
|
657
|
+
async function mapJs() {
|
|
658
|
+
const jsFiles = await glob(resolve(CWD, './livingdocs/' + '**/app.[t,j]s'), {
|
|
659
|
+
withFileTypes: true,
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
const imports = [];
|
|
663
|
+
const register = [];
|
|
664
|
+
|
|
665
|
+
for (let i = 0; i < jsFiles.length; i++) {
|
|
666
|
+
const file = jsFiles[i];
|
|
667
|
+
const className = camelCase(file.parent.name);
|
|
668
|
+
const path = [file.name];
|
|
669
|
+
let parent = file.parent;
|
|
670
|
+
while (parent) {
|
|
671
|
+
path.unshift(parent.name);
|
|
672
|
+
if (parent.name !== 'livingdocs') {
|
|
673
|
+
parent = parent.parent;
|
|
674
|
+
} else {
|
|
675
|
+
parent = false;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
imports.push(`import ${className} from "../${path.join(file.sep)}"`);
|
|
679
|
+
register.push(`ClassAutoLoader.register(${className}, "${className}")`);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
const content = `import ArticleAutoloader from 'nswow/ArticleAutoloader'
|
|
683
|
+
${imports.join('\n')}
|
|
684
|
+
const ClassAutoLoader = new ArticleAutoloader()
|
|
685
|
+
${register.join('\n')}
|
|
686
|
+
export default ClassAutoLoader
|
|
687
|
+
export { ClassAutoLoader }`;
|
|
688
|
+
|
|
689
|
+
await writeFileSync(resolve(CWD, './src/Autoload.ts'), content);
|
|
690
|
+
return true;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Maps the livingdocs properties to components and groups.
|
|
695
|
+
*
|
|
696
|
+
* @returns {Promise<boolean>} Returns a promise that resolves to a boolean indicating the success or failure of the mapping.
|
|
697
|
+
*/
|
|
698
|
+
async function mapLdd() {
|
|
699
|
+
await checkFolders();
|
|
700
|
+
try {
|
|
701
|
+
const lddJson = await readLivingDocsJson();
|
|
702
|
+
|
|
703
|
+
const propertiesFiles = await glob(
|
|
704
|
+
resolve(CWD, './livingdocs/**/properties.{json,js,ts}'),
|
|
705
|
+
);
|
|
706
|
+
const mapProperties = {};
|
|
707
|
+
for (let i = 0; i < propertiesFiles.length; i++) {
|
|
708
|
+
const file = propertiesFiles[i];
|
|
709
|
+
if (file.endsWith('.js') || file.endsWith('.ts')) {
|
|
710
|
+
const properties = require(propertiesFiles[i]).default;
|
|
711
|
+
const oKeys = Object.keys(properties);
|
|
712
|
+
for (let j = 0; j < oKeys.length; j++) {
|
|
713
|
+
mapProperties[oKeys[j]] = properties[oKeys[j]];
|
|
714
|
+
}
|
|
715
|
+
} else if (file.endsWith('.json')) {
|
|
716
|
+
const properties = JSON.parse(readFileSync(propertiesFiles[i]));
|
|
717
|
+
const oKeys = Object.keys(properties);
|
|
718
|
+
for (let j = 0; j < oKeys.length; j++) {
|
|
719
|
+
mapProperties[oKeys[j]] = properties[oKeys[j]];
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
lddJson.componentProperties = mapProperties;
|
|
724
|
+
|
|
725
|
+
const groupsPath = resolve(CWD, './livingdocs');
|
|
726
|
+
const groups = readdirSync(groupsPath);
|
|
727
|
+
const keepGroups = [];
|
|
728
|
+
|
|
729
|
+
for (let x = 0; x < groups.length; x++) {
|
|
730
|
+
const group = groups[x];
|
|
731
|
+
const groupName = group.replace('_and_', ' / ').replace('_', ' ');
|
|
732
|
+
try {
|
|
733
|
+
const stat = statSync(`${groupsPath}/${group}`);
|
|
734
|
+
if (stat.isDirectory()) {
|
|
735
|
+
const components = [];
|
|
736
|
+
const c = readdirSync(`${groupsPath}/${group}`);
|
|
737
|
+
for (let j = 0; j < c.length; j++) {
|
|
738
|
+
const component = c[j];
|
|
739
|
+
try {
|
|
740
|
+
const stat = statSync(
|
|
741
|
+
`${groupsPath}/${group}/${component}/${component}.html`,
|
|
742
|
+
);
|
|
743
|
+
components.push(component);
|
|
744
|
+
} catch (e) {}
|
|
745
|
+
}
|
|
746
|
+
if (components.length) {
|
|
747
|
+
keepGroups.push(groupName);
|
|
748
|
+
const i = lddJson.groups.find((g) => {
|
|
749
|
+
return g.label === groupName;
|
|
750
|
+
});
|
|
751
|
+
if (i) {
|
|
752
|
+
const newComponents = [];
|
|
753
|
+
for (let j = 0; j < i.components.length; j++) {
|
|
754
|
+
const index = components.indexOf(i.components[j]);
|
|
755
|
+
if (index !== -1) {
|
|
756
|
+
newComponents.push(components[index]);
|
|
757
|
+
components.splice(index, 1);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
for (let j = 0; j < components.length; j++) {
|
|
761
|
+
newComponents.push(components[j]);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
i.components = newComponents;
|
|
765
|
+
} else {
|
|
766
|
+
lddJson.groups.push({
|
|
767
|
+
label: groupName,
|
|
768
|
+
components: components,
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
} else {
|
|
773
|
+
rmSync(`${groupsPath}/${group}`);
|
|
774
|
+
}
|
|
775
|
+
} catch (e) {
|
|
776
|
+
console.log(e);
|
|
777
|
+
return false;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
const newMap = [];
|
|
782
|
+
for (let i = 0; i < lddJson.groups.length; i++) {
|
|
783
|
+
const c = lddJson.groups[i];
|
|
784
|
+
if (keepGroups.includes(c.label)) {
|
|
785
|
+
newMap.push(c);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
lddJson.groups = newMap;
|
|
789
|
+
await writeLivingDocsJson(lddJson);
|
|
790
|
+
return true;
|
|
791
|
+
} catch (e) {
|
|
792
|
+
console.error(e);
|
|
793
|
+
return false;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Maps the SCSS files and the LDD files in the project.
|
|
799
|
+
*
|
|
800
|
+
* @async
|
|
801
|
+
* @function map
|
|
802
|
+
* @returns {Promise<boolean>} A promise that resolves after successfully mapping the files.
|
|
803
|
+
* @throws {Error} If there is an error during the mapping process.
|
|
804
|
+
*/
|
|
805
|
+
async function map() {
|
|
806
|
+
await checkFolders();
|
|
807
|
+
await mapScss();
|
|
808
|
+
await mapLdd();
|
|
809
|
+
return true;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
export { build, ddev, map, mapScss, mapLdd, mapJs };
|