@atb-as/generate-assets 17.4.0 → 17.5.2
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/CHANGELOG.md +22 -0
- package/files/atb/colors/illustrations/contact/dark/Contact.svg +20 -0
- package/files/atb/colors/illustrations/contact/light/Contact.svg +20 -0
- package/files/common/colors/illustrations/contact/dark/Contact.svg +2 -0
- package/files/common/colors/illustrations/contact/light/Contact.svg +2 -0
- package/lib/bin.js +0 -0
- package/lib/tools/validate-files.d.ts +1 -0
- package/lib/tools/validate-files.js +150 -0
- package/lib/tools/validate-files.js.map +1 -0
- package/package.json +4 -3
- package/src/bin.ts +121 -0
- package/src/generate.ts +197 -0
- package/src/generateTs.ts +189 -0
- package/src/logger.ts +10 -0
- package/src/tools/validate-files.ts +94 -0
- package/src/utils.ts +66 -0
- package/tsconfig.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [17.5.2](https://github.com/AtB-AS/design-system/compare/generate-assets@v17.5.1...generate-assets@v17.5.2) (2025-07-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* lock `@atb-as/theme` to v14.0.1 ([#319](https://github.com/AtB-AS/design-system/issues/319)) ([99b12df](https://github.com/AtB-AS/design-system/commit/99b12df8eec9e908f94c0d4e787626ad33e04007))
|
|
9
|
+
|
|
10
|
+
## [17.5.1](https://github.com/AtB-AS/design-system/compare/generate-assets@v17.5.0...generate-assets@v17.5.1) (2025-07-09)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* remove duplicate folder and fix release build ([#317](https://github.com/AtB-AS/design-system/issues/317)) ([69ef6ab](https://github.com/AtB-AS/design-system/commit/69ef6ab5db0925a06ffd77a039f5ddff1863c4e3))
|
|
16
|
+
|
|
17
|
+
## [17.5.0](https://github.com/AtB-AS/design-system/compare/generate-assets@v17.4.0...generate-assets@v17.5.0) (2025-07-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* Add contact illustration ([#315](https://github.com/AtB-AS/design-system/issues/315)) ([787e2ee](https://github.com/AtB-AS/design-system/commit/787e2ee3cb2a59b20400f830e07ecd24e82a0e14))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M167.075 171.027C166.583 179.631 174.94 186.094 181.701 189.763C181.998 189.951 181.982 190.148 181.706 190.341C181.366 190.577 178.107 191.403 177.45 191.548C168.683 193.492 158.775 192.208 150.171 188.456C145.193 186.286 140.653 183.291 137.018 179.615C136.632 179.223 136.317 178.398 135.751 178.342C132.347 179.262 128.982 180.279 125.519 180.983C119.426 182.222 113.149 182.99 106.795 183.287C95.0326 183.84 83.0013 182.784 71.3729 180.123C54.6778 176.305 38.8115 169.175 25.749 158.754C24.0947 157.436 22.4852 156.063 20.924 154.638C-11.2883 125.211 -3.28892 77.0288 30.7137 54.2536C32.7171 52.9126 34.8101 51.6593 36.9907 50.5028C44.4476 46.5496 52.9608 43.4362 61.8589 41.1445C76.1317 37.4653 91.3946 35.8952 104.869 36.3499C109.268 36.4985 113.731 36.8906 118.204 37.528C129.093 39.0784 140.041 42.0809 150.269 46.5604C165.555 53.2546 179.234 63.2484 188.696 76.6206C205.625 100.551 202.761 126.303 184.148 148.101C179.393 153.671 167.492 163.731 167.075 171.027Z" fill="#C2E8F0"/>
|
|
3
|
+
<path d="M47.4448 16.1546C48.9201 14.1995 51.7954 9.68781 54.6976 11.6501C57.8594 13.7878 53.6789 21.651 54.2124 22.2687C54.8945 22.1452 55.4388 21.4881 56.1191 21.3574C61.6639 20.2832 59.8001 28.3219 59.2577 31.3047C58.9891 32.7871 32.4254 37.5012 32.1193 37.4868C31.4103 37.4546 30.6709 38.1636 30.4686 36.7546C29.688 31.2886 29.7506 19.6548 32.2607 14.7581C33.5748 12.1925 36.6149 9.36913 38.9907 12.5524C39.8555 10.4451 40.7972 7.37108 43.4272 6.83218C48.9541 5.70067 48.2397 12.8084 47.4466 16.151L47.4448 16.1546Z" fill="#E8AA7D"/>
|
|
4
|
+
<path d="M150.171 188.456C145.193 186.286 140.653 183.29 137.019 179.615C136.632 179.223 136.317 178.397 135.751 178.342C132.347 179.262 128.982 180.279 125.519 180.983C119.426 182.222 113.149 182.99 106.795 183.287C95.0327 183.84 83.0014 182.784 71.373 180.123C71.3945 177.995 71.4124 175.859 71.5216 173.748C71.5556 173.105 71.5896 172.459 71.629 171.809C72.0945 164.026 72.9754 155.737 74.5831 148.217C75.4264 144.275 76.7441 140.411 77.539 136.492C71.4804 130.593 65.6367 124.479 60.4714 117.768C47.5522 100.989 35.6606 77.0126 30.7138 54.2534C30.1068 51.4623 29.6037 48.689 29.217 45.9497C28.7104 42.3654 28.4006 38.8384 28.3147 35.4045C28.3004 34.7993 28.1947 34.2103 28.739 33.8451C29.2689 33.487 32.0941 32.6007 32.898 32.3573C38.1617 30.7603 45.3321 29.5804 50.8303 29.319C54.1586 29.1615 57.7447 29.1489 60.9441 30.1318C60.9799 32.5184 61.1285 34.8853 61.3702 37.236C61.5045 38.5448 61.6674 39.8464 61.859 41.1444C63.8517 54.701 68.7877 67.7152 73.9296 80.3534C78.6186 91.8744 85.7299 108.249 96.1337 115.529C96.6762 115.908 99.2275 117.588 99.6536 117.713C100.307 117.906 101.081 116.318 101.532 115.847C104.994 112.233 111.93 114.25 115.839 116.152C128.31 122.228 141.887 140.732 148.753 152.731C151 156.655 153.955 163.999 156.41 170.545C159.001 177.452 156.097 184.9 150.171 188.456Z" fill="#86B200"/>
|
|
5
|
+
<path d="M108.559 101.263C107.481 102.284 105.961 102.926 105.01 103.752C104.103 104.54 103.009 109.689 102.894 111.053C102.729 113.008 103.168 115.93 102.819 117.679C102.625 118.658 94.2967 124.393 92.8107 123.637C88.8844 121.641 86.283 119.068 84.6753 114.902C74.5454 114.322 64.7861 108.326 61.4828 98.8659C60.8491 97.054 60.4534 95.1169 60.337 93.0651C60.2905 92.263 60.2851 91.4001 60.3173 90.487C60.4605 86.2438 61.3862 80.93 62.6896 75.6645C62.899 74.8177 63.1175 73.9709 63.3448 73.1312C64.8738 67.4969 66.7644 62.1312 68.5118 58.443C80.1528 33.8595 114.626 42.0952 117.349 69.4394C118.472 80.6901 117.255 93.0275 108.555 101.263H108.559Z" fill="#E8AA7D"/>
|
|
6
|
+
<path d="M124.595 87.1692C125.191 88.4869 126.124 89.6166 126.804 90.8914C128.663 94.3736 130.851 100.151 128.683 103.854C126.824 107.028 123.408 105.318 121.51 103.137C122.595 108.72 121.834 115.217 115.615 117.131C111.884 118.28 102.488 117.935 101.92 112.775C101.371 107.773 105.352 103.197 107.202 98.8907C108.867 95.0181 109.631 90.4456 108.394 86.3349C107.581 83.6368 106.557 83.9698 105.03 82.0971C101.367 77.6015 102.06 71.3155 103.204 66.0375C103.37 65.2712 103.913 64.0824 103.94 63.4236C103.981 62.3475 101.242 60.1454 100.28 59.705C93.0077 56.3677 87.9321 66.836 82.1886 66.238C78.8639 65.8925 77.5587 62.4335 78.8173 59.5904C78.6257 59.6781 78.436 59.7694 78.2462 59.8643C74.2125 62.6555 69.5754 64.4638 64.5338 63.0619C59.279 61.601 57.0733 56.3086 59.2916 51.3977C60.5466 48.6136 63.0281 46.6783 66.0037 45.4393C66.1379 45.3713 66.2704 45.3086 66.4011 45.2495C68.8127 44.1646 71.4124 43.7456 74.0388 43.708C74.0442 43.708 74.0496 43.708 74.0549 43.708C76.1425 43.5935 78.1799 43.708 79.9828 44.0196C75.0611 38.7469 81.5566 36.7381 86.5212 37.055C93.2781 37.4901 102.328 39.2142 108.195 43.538C110.104 44.947 111.509 46.5225 112.542 48.064C115.198 52.0279 115.396 55.7536 115.412 55.7626C115.676 55.9237 118.929 55.4922 120.946 56.9854C120.946 56.9854 120.948 56.9854 120.946 56.9872C125.455 60.3209 125.193 64.0806 126.416 69.8259C127.41 74.4916 129.871 76.0295 131.334 79.689C133.309 84.6179 129.657 88.5478 124.592 87.171L124.595 87.1692Z" fill="#008099"/>
|
|
7
|
+
<path d="M121.294 79.7608C121.113 80.5987 120.458 83.5814 119.745 83.8983C118.601 84.405 114.843 85.7102 114.503 84.3924C114.378 83.9037 120.021 65.1156 115.412 55.7645C115.396 55.7555 115.198 52.0298 112.542 48.0659C116.073 50.2126 118.562 52.8193 120.443 56.0456C120.628 56.3607 120.798 56.674 120.948 56.9873C120.948 56.9873 120.95 56.9873 120.948 56.9891C121.16 57.4188 121.339 57.8449 121.485 58.2674C123.514 64.104 122.782 72.8231 121.294 79.7626V79.7608Z" fill="#00151A"/>
|
|
8
|
+
<path d="M61.4848 98.8659C58.9192 99.6913 55.4441 98.891 54.1783 96.2072C53.8811 95.5752 53.5034 94.1626 53.5034 94.1626C53.5034 94.1626 52.2197 93.1582 51.7524 92.596C48.3417 88.4979 49.518 81.6014 53.3583 78.2588C55.8756 76.0674 60.6917 73.7668 63.3504 73.1294C63.123 73.9709 62.9046 74.8177 62.6951 75.6628C61.5278 76.0978 60.2351 76.5633 59.9773 76.6797C57.2488 77.9025 54.3967 79.6069 52.8749 82.2979C51.4426 84.8277 51.3263 88.2132 52.866 90.7323C53.4711 91.7223 54.13 92.093 54.13 92.093C54.13 92.093 54.9553 91.4198 55.9329 90.9382C57.2094 90.3115 58.8333 90.1576 60.3229 90.4852C62.1437 90.8827 63.7568 91.9981 64.2778 93.8421C65.0226 96.4794 63.5509 98.1981 61.4866 98.8641L61.4848 98.8659Z" fill="#00151A"/>
|
|
9
|
+
<path d="M112.526 80.0813C126.88 78.6597 126.212 101.467 114.027 105.263C105.596 107.889 100.407 99.7771 101.763 92.1627C102.656 87.1478 107.087 80.6202 112.525 80.0813H112.526Z" fill="#E8AA7D"/>
|
|
10
|
+
<path d="M99.4834 100.577L98.8442 100.688C92.1841 97.4639 84.2402 101.612 82.3388 108.593L81.8375 108.987C77.0394 108.099 70.2503 104.448 69.6648 98.991C69.3211 95.7756 70.3344 92.4365 73.7755 91.5986C76.8335 90.852 80.3659 92.4455 83.6601 92.2217C88.6499 91.8815 95.0236 86.4853 99.2811 91.5968C101.589 94.3683 101.071 97.6447 99.4834 100.577Z" fill="#00151A"/>
|
|
11
|
+
<path d="M99.4835 100.577C96.234 106.579 88.5139 110.224 81.8376 108.988C83.6012 101.308 92.3167 96.7225 99.4835 100.577Z" fill="#D97126"/>
|
|
12
|
+
<path d="M87.5882 130.112C87.2426 129.232 88.1969 127.329 88.5997 126.429C91.5968 119.724 100.554 112.292 108.236 112.962C115.69 113.61 122.595 119.767 127.44 125.05C128.72 126.447 131.611 129.637 132.435 131.164C133.171 132.527 88.0125 131.195 87.5882 130.112Z" fill="#86B200"/>
|
|
13
|
+
<path d="M94.6514 183.29C93.2262 183.264 90.2238 183.011 90.213 183.011C89.5059 186.168 89.2373 192.495 85.6852 193.809C82.7615 194.888 80.7689 193.086 79.1056 190.948C78.667 191.44 78.402 191.718 78.0063 192.036C76.0226 193.639 73.7184 193.623 71.6452 192.146C71.0024 191.687 69.4018 189.664 69.4018 189.664C69.4018 189.664 68.1307 190.916 67.6312 191.234C66.2007 192.147 64.0272 191.811 62.688 190.88C57.213 187.082 59.9075 175.513 63.9967 171.544C65.5597 170.026 68.367 169.438 71.1761 169.284C73.4087 169.164 75.6466 169.317 77.2598 169.499C83.1268 170.158 88.1881 171.827 92.186 176.424C93.7598 178.231 94.8805 182.741 94.6496 183.292L94.6514 183.29Z" fill="#E8AA7D"/>
|
|
14
|
+
<path d="M77.0572 74.4323C79.4115 74.0367 79.1143 79.3075 76.9623 79.2896C74.7709 79.2699 75.3993 74.7116 77.0572 74.4323Z" fill="#00151A"/>
|
|
15
|
+
<path d="M91.5502 79.9521C90.5655 79.1429 91.1563 75.7824 92.6549 75.5639C94.6207 75.2775 94.3145 79.594 93.1132 80.1849C92.4937 80.4892 91.8993 80.2386 91.5502 79.9521Z" fill="#00151A"/>
|
|
16
|
+
<path d="M98.017 74.0763C97.7878 74.0745 97.564 73.9617 97.4279 73.7576C96.9463 73.0325 96.4737 72.4202 95.1685 71.6843C94.3628 71.2296 93.4515 70.9467 92.4615 70.8464C92.0676 70.807 91.7811 70.4561 91.8205 70.0623C91.8599 69.6684 92.2126 69.3837 92.6047 69.4213C93.7935 69.5413 94.8928 69.8832 95.8739 70.4364C97.4494 71.3263 98.0725 72.1391 98.6203 72.9644C98.8388 73.2939 98.751 73.7379 98.4216 73.9581C98.2981 74.0404 98.1566 74.0798 98.0188 74.078L98.017 74.0763Z" fill="#00151A"/>
|
|
17
|
+
<path d="M71.9458 71.9672C71.7739 71.9672 71.602 71.9027 71.4678 71.7774C71.1777 71.5088 71.1598 71.0559 71.4284 70.7658L71.5322 70.6513C72.1195 70.0121 72.8499 69.2154 74.5096 68.5995C75.6984 68.1573 76.9051 68.1591 77.9274 68.2181C78.3231 68.2414 78.6238 68.5798 78.6006 68.9755C78.5773 69.3711 78.2389 69.6755 77.8433 69.6486C76.9696 69.5985 75.949 69.5931 75.0073 69.9423C73.6699 70.4382 73.1185 71.0398 72.5867 71.6198L72.4793 71.738C72.3361 71.892 72.1409 71.9708 71.9458 71.9672Z" fill="#00151A"/>
|
|
18
|
+
<path d="M86.5731 87.1639C86.2813 87.1603 86.0091 86.9795 85.9053 86.6876C85.7191 86.1649 85.3395 85.429 84.5894 84.8901C82.9494 83.7085 80.8923 84.5141 80.8045 84.5499C80.1672 84.806 79.5889 85.2339 79.127 85.7889C78.8745 86.0932 78.4233 86.1344 78.119 85.882C77.8146 85.6295 77.7734 85.1784 78.0259 84.874C78.6382 84.1364 79.4134 83.5652 80.271 83.2197C80.5628 83.1015 83.1911 82.1186 85.4255 83.7264C86.4746 84.4819 86.9974 85.4917 87.2534 86.206C87.3859 86.5784 87.1926 86.9884 86.8202 87.1209C86.7378 87.1496 86.6554 87.1639 86.5731 87.1621V87.1639Z" fill="#00151A"/>
|
|
19
|
+
<path d="M120.715 168.251L113.067 170.953C112.986 170.982 112.902 170.994 112.822 170.994C112.53 170.991 112.256 170.808 112.154 170.516C112.021 170.142 112.216 169.734 112.591 169.601L116.531 168.21L106.113 150.226C105.914 149.884 106.031 149.447 106.373 149.247C106.715 149.05 107.152 149.164 107.352 149.506L117.906 167.725L120.241 166.901C120.613 166.769 121.023 166.964 121.156 167.338C121.286 167.711 121.091 168.121 120.719 168.251H120.715Z" fill="#00151A"/>
|
|
20
|
+
</svg>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M167.075 171.027C166.583 179.631 174.94 186.094 181.701 189.763C181.998 189.951 181.982 190.148 181.706 190.341C181.366 190.577 178.107 191.403 177.45 191.548C168.683 193.492 158.775 192.208 150.171 188.456C145.193 186.286 140.653 183.291 137.018 179.615C136.632 179.223 136.317 178.398 135.751 178.342C132.347 179.262 128.982 180.279 125.519 180.983C119.426 182.222 113.149 182.99 106.795 183.287C95.0326 183.84 83.0013 182.784 71.3729 180.123C54.6778 176.305 38.8115 169.175 25.749 158.754C24.0947 157.436 22.4852 156.063 20.924 154.638C-11.2883 125.211 -3.28892 77.0288 30.7137 54.2536C32.7171 52.9126 34.8101 51.6593 36.9907 50.5028C44.4476 46.5496 52.9608 43.4362 61.8589 41.1445C76.1317 37.4653 91.3946 35.8952 104.869 36.3499C109.268 36.4985 113.731 36.8906 118.204 37.528C129.093 39.0784 140.041 42.0809 150.269 46.5604C165.555 53.2546 179.234 63.2484 188.696 76.6206C205.625 100.551 202.761 126.303 184.148 148.101C179.393 153.671 167.492 163.731 167.075 171.027Z" fill="#99D9E5"/>
|
|
3
|
+
<path d="M47.4448 16.1546C48.9201 14.1995 51.7954 9.68781 54.6976 11.6501C57.8594 13.7878 53.6789 21.651 54.2124 22.2687C54.8945 22.1452 55.4388 21.4881 56.1191 21.3574C61.6639 20.2832 59.8001 28.3219 59.2577 31.3047C58.9891 32.7871 32.4254 37.5012 32.1193 37.4868C31.4103 37.4546 30.6709 38.1636 30.4686 36.7546C29.688 31.2886 29.7506 19.6548 32.2607 14.7581C33.5748 12.1925 36.6149 9.36913 38.9907 12.5524C39.8555 10.4451 40.7972 7.37108 43.4272 6.83218C48.9541 5.70067 48.2397 12.8084 47.4466 16.151L47.4448 16.1546Z" fill="#E8AA7D"/>
|
|
4
|
+
<path d="M150.171 188.456C145.193 186.286 140.653 183.29 137.019 179.615C136.632 179.223 136.317 178.397 135.751 178.342C132.347 179.262 128.982 180.279 125.519 180.983C119.426 182.222 113.149 182.99 106.795 183.287C95.0327 183.84 83.0014 182.784 71.373 180.123C71.3945 177.995 71.4124 175.859 71.5216 173.748C71.5556 173.105 71.5896 172.459 71.629 171.809C72.0945 164.026 72.9754 155.737 74.5831 148.217C75.4264 144.275 76.7441 140.411 77.539 136.492C71.4804 130.593 65.6367 124.479 60.4714 117.768C47.5522 100.989 35.6606 77.0126 30.7138 54.2534C30.1068 51.4623 29.6037 48.689 29.217 45.9497C28.7104 42.3654 28.4006 38.8384 28.3147 35.4045C28.3004 34.7993 28.1947 34.2103 28.739 33.8451C29.2689 33.487 32.0941 32.6007 32.898 32.3573C38.1617 30.7603 45.3321 29.5804 50.8303 29.319C54.1586 29.1615 57.7447 29.1489 60.9441 30.1318C60.9799 32.5184 61.1285 34.8853 61.3702 37.236C61.5045 38.5448 61.6674 39.8464 61.859 41.1444C63.8517 54.701 68.7877 67.7152 73.9296 80.3534C78.6186 91.8744 85.7299 108.249 96.1337 115.529C96.6762 115.908 99.2275 117.588 99.6536 117.713C100.307 117.906 101.081 116.318 101.532 115.847C104.994 112.233 111.93 114.25 115.839 116.152C128.31 122.228 141.887 140.732 148.753 152.731C151 156.655 153.955 163.999 156.41 170.545C159.001 177.452 156.097 184.9 150.171 188.456Z" fill="#86B200"/>
|
|
5
|
+
<path d="M108.559 101.263C107.481 102.284 105.961 102.926 105.01 103.752C104.103 104.54 103.009 109.689 102.894 111.053C102.729 113.008 103.168 115.93 102.819 117.679C102.625 118.658 94.2967 124.393 92.8107 123.637C88.8844 121.641 86.283 119.068 84.6753 114.902C74.5454 114.322 64.7861 108.326 61.4828 98.8659C60.8491 97.054 60.4534 95.1169 60.337 93.0651C60.2905 92.263 60.2851 91.4001 60.3173 90.487C60.4605 86.2438 61.3862 80.93 62.6896 75.6645C62.899 74.8177 63.1175 73.9709 63.3448 73.1312C64.8738 67.4969 66.7644 62.1312 68.5118 58.443C80.1528 33.8595 114.626 42.0952 117.349 69.4394C118.472 80.6901 117.255 93.0275 108.555 101.263H108.559Z" fill="#E8AA7D"/>
|
|
6
|
+
<path d="M124.595 87.1692C125.191 88.4869 126.124 89.6166 126.804 90.8914C128.663 94.3736 130.851 100.151 128.683 103.854C126.824 107.028 123.408 105.318 121.51 103.137C122.595 108.72 121.834 115.217 115.615 117.131C111.884 118.28 102.488 117.935 101.92 112.775C101.371 107.773 105.352 103.197 107.202 98.8907C108.867 95.0181 109.631 90.4456 108.394 86.3349C107.581 83.6368 106.557 83.9698 105.03 82.0971C101.367 77.6015 102.06 71.3155 103.204 66.0375C103.37 65.2712 103.913 64.0824 103.94 63.4236C103.981 62.3475 101.242 60.1454 100.28 59.705C93.0077 56.3677 87.9321 66.836 82.1886 66.238C78.8639 65.8925 77.5587 62.4335 78.8173 59.5904C78.6257 59.6781 78.436 59.7694 78.2462 59.8643C74.2125 62.6555 69.5754 64.4638 64.5338 63.0619C59.279 61.601 57.0733 56.3086 59.2916 51.3977C60.5466 48.6136 63.0281 46.6783 66.0037 45.4393C66.1379 45.3713 66.2704 45.3086 66.4011 45.2496C68.8127 44.1646 71.4124 43.7456 74.0388 43.708C74.0442 43.708 74.0496 43.708 74.0549 43.708C76.1425 43.5935 78.1799 43.708 79.9828 44.0196C75.0611 38.7469 81.5566 36.7381 86.5213 37.055C93.2781 37.4901 102.328 39.2142 108.195 43.538C110.104 44.947 111.509 46.5225 112.542 48.064C115.198 52.0279 115.396 55.7536 115.412 55.7626C115.676 55.9237 118.929 55.4922 120.946 56.9854C120.946 56.9854 120.948 56.9854 120.946 56.9872C125.455 60.3208 125.193 64.0806 126.416 69.8259C127.41 74.4916 129.871 76.0295 131.334 79.689C133.309 84.6179 129.657 88.5478 124.592 87.171L124.595 87.1692Z" fill="#008099"/>
|
|
7
|
+
<path d="M121.294 79.7608C121.113 80.5987 120.458 83.5814 119.745 83.8983C118.601 84.405 114.843 85.7102 114.503 84.3924C114.378 83.9037 120.021 65.1156 115.412 55.7645C115.396 55.7555 115.198 52.0298 112.542 48.0659C116.073 50.2126 118.562 52.8193 120.443 56.0456C120.628 56.3607 120.798 56.674 120.948 56.9873C120.948 56.9873 120.95 56.9873 120.948 56.9891C121.16 57.4188 121.339 57.8449 121.485 58.2674C123.514 64.104 122.782 72.8231 121.294 79.7626V79.7608Z" fill="#00151A"/>
|
|
8
|
+
<path d="M61.4848 98.8659C58.9192 99.6913 55.4441 98.891 54.1783 96.2072C53.8811 95.5752 53.5034 94.1626 53.5034 94.1626C53.5034 94.1626 52.2197 93.1582 51.7524 92.596C48.3417 88.4979 49.518 81.6014 53.3583 78.2588C55.8756 76.0674 60.6917 73.7668 63.3504 73.1294C63.123 73.9709 62.9046 74.8177 62.6951 75.6628C61.5278 76.0978 60.2351 76.5633 59.9773 76.6797C57.2488 77.9025 54.3967 79.6069 52.8749 82.2979C51.4426 84.8277 51.3263 88.2132 52.866 90.7323C53.4711 91.7223 54.13 92.093 54.13 92.093C54.13 92.093 54.9553 91.4198 55.9329 90.9382C57.2094 90.3115 58.8333 90.1576 60.3229 90.4852C62.1437 90.8827 63.7568 91.9981 64.2778 93.8421C65.0226 96.4794 63.5509 98.1981 61.4866 98.8641L61.4848 98.8659Z" fill="#00151A"/>
|
|
9
|
+
<path d="M112.526 80.0813C126.88 78.6597 126.212 101.467 114.027 105.263C105.596 107.889 100.407 99.7771 101.763 92.1627C102.656 87.1478 107.087 80.6202 112.525 80.0813H112.526Z" fill="#E8AA7D"/>
|
|
10
|
+
<path d="M99.4834 100.577L98.8442 100.688C92.1841 97.4639 84.2402 101.612 82.3388 108.593L81.8375 108.987C77.0394 108.099 70.2503 104.448 69.6648 98.991C69.3211 95.7756 70.3344 92.4365 73.7755 91.5986C76.8335 90.852 80.3659 92.4455 83.6601 92.2217C88.6499 91.8815 95.0236 86.4853 99.2811 91.5968C101.589 94.3683 101.071 97.6447 99.4834 100.577Z" fill="#00151A"/>
|
|
11
|
+
<path d="M99.4835 100.577C96.234 106.579 88.5139 110.224 81.8376 108.988C83.6012 101.308 92.3167 96.7225 99.4835 100.577Z" fill="#C2570A"/>
|
|
12
|
+
<path d="M87.5882 130.112C87.2426 129.232 88.1969 127.329 88.5997 126.429C91.5968 119.724 100.554 112.292 108.236 112.962C115.69 113.61 122.595 119.767 127.44 125.05C128.72 126.447 131.611 129.637 132.435 131.164C133.171 132.527 88.0125 131.195 87.5882 130.112Z" fill="#86B200"/>
|
|
13
|
+
<path d="M94.6514 183.29C93.2262 183.264 90.2238 183.011 90.213 183.011C89.5059 186.168 89.2373 192.495 85.6852 193.809C82.7615 194.888 80.7689 193.086 79.1056 190.948C78.667 191.44 78.402 191.718 78.0063 192.036C76.0226 193.639 73.7184 193.623 71.6452 192.146C71.0024 191.687 69.4018 189.664 69.4018 189.664C69.4018 189.664 68.1307 190.916 67.6312 191.234C66.2007 192.147 64.0272 191.811 62.688 190.88C57.213 187.082 59.9075 175.513 63.9967 171.544C65.5597 170.026 68.367 169.438 71.1761 169.284C73.4087 169.164 75.6466 169.317 77.2598 169.499C83.1268 170.158 88.1881 171.827 92.186 176.424C93.7598 178.231 94.8805 182.741 94.6496 183.292L94.6514 183.29Z" fill="#E8AA7D"/>
|
|
14
|
+
<path d="M77.0572 74.4323C79.4115 74.0367 79.1143 79.3075 76.9623 79.2896C74.7709 79.2699 75.3993 74.7116 77.0572 74.4323Z" fill="#00151A"/>
|
|
15
|
+
<path d="M91.5502 79.9521C90.5655 79.1429 91.1563 75.7824 92.6549 75.5639C94.6207 75.2775 94.3145 79.594 93.1132 80.1849C92.4937 80.4892 91.8993 80.2386 91.5502 79.9521Z" fill="#00151A"/>
|
|
16
|
+
<path d="M98.017 74.0763C97.7878 74.0745 97.564 73.9617 97.4279 73.7576C96.9463 73.0325 96.4737 72.4202 95.1685 71.6843C94.3628 71.2296 93.4515 70.9467 92.4615 70.8464C92.0676 70.807 91.7811 70.4561 91.8205 70.0623C91.8599 69.6684 92.2126 69.3837 92.6047 69.4213C93.7935 69.5413 94.8928 69.8832 95.8739 70.4364C97.4494 71.3263 98.0725 72.1391 98.6203 72.9644C98.8388 73.2939 98.751 73.7379 98.4216 73.9581C98.2981 74.0404 98.1566 74.0798 98.0188 74.078L98.017 74.0763Z" fill="#00151A"/>
|
|
17
|
+
<path d="M71.9458 71.9672C71.7739 71.9672 71.602 71.9027 71.4678 71.7774C71.1777 71.5088 71.1598 71.0559 71.4284 70.7658L71.5322 70.6513C72.1195 70.0121 72.8499 69.2154 74.5096 68.5995C75.6984 68.1573 76.9051 68.1591 77.9274 68.2181C78.3231 68.2414 78.6238 68.5798 78.6006 68.9755C78.5773 69.3711 78.2389 69.6755 77.8433 69.6486C76.9696 69.5985 75.949 69.5931 75.0073 69.9423C73.6699 70.4382 73.1185 71.0398 72.5867 71.6198L72.4793 71.738C72.3361 71.892 72.1409 71.9708 71.9458 71.9672Z" fill="#00151A"/>
|
|
18
|
+
<path d="M86.5731 87.1639C86.2813 87.1603 86.0091 86.9795 85.9053 86.6876C85.7191 86.1649 85.3395 85.429 84.5894 84.8901C82.9494 83.7085 80.8923 84.5141 80.8045 84.5499C80.1672 84.806 79.5889 85.2339 79.127 85.7889C78.8745 86.0932 78.4233 86.1344 78.119 85.882C77.8146 85.6295 77.7734 85.1784 78.0259 84.874C78.6382 84.1364 79.4134 83.5652 80.271 83.2197C80.5628 83.1015 83.1911 82.1186 85.4255 83.7264C86.4746 84.4819 86.9974 85.4917 87.2534 86.206C87.3859 86.5784 87.1926 86.9884 86.8202 87.1209C86.7378 87.1496 86.6554 87.1639 86.5731 87.1621V87.1639Z" fill="#00151A"/>
|
|
19
|
+
<path d="M120.715 168.251L113.067 170.953C112.986 170.982 112.902 170.994 112.822 170.994C112.53 170.991 112.256 170.808 112.154 170.516C112.021 170.142 112.216 169.734 112.591 169.601L116.531 168.21L106.113 150.226C105.914 149.884 106.031 149.447 106.373 149.247C106.715 149.05 107.152 149.164 107.352 149.506L117.906 167.725L120.241 166.901C120.613 166.769 121.023 166.964 121.156 167.338C121.286 167.711 121.091 168.121 120.719 168.251H120.715Z" fill="#00151A"/>
|
|
20
|
+
</svg>
|
package/lib/bin.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var theme_1 = require("@atb-as/theme");
|
|
43
|
+
var fs_1 = require("fs");
|
|
44
|
+
var path_1 = __importDefault(require("path"));
|
|
45
|
+
var generate_1 = require("../generate");
|
|
46
|
+
var utils_1 = require("../utils");
|
|
47
|
+
validateValidOrgs();
|
|
48
|
+
function fromOrgFiles(org) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
var fullPath, files;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
switch (_a.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
fullPath = path_1.default.join(__dirname, '..', '..', 'files', (0, utils_1.themeVariantAsString)(org), '**/*.*');
|
|
55
|
+
return [4 /*yield*/, (0, utils_1.fgNormalizedForUnix)(fullPath)];
|
|
56
|
+
case 1:
|
|
57
|
+
files = _a.sent();
|
|
58
|
+
return [2 /*return*/, { org: org, files: files.map(cleanFilenames) }];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function exists(fileToCheck) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0: return [4 /*yield*/, fs_1.promises
|
|
68
|
+
.access(fileToCheck, fs_1.constants.F_OK)
|
|
69
|
+
.then(function () { return true; })
|
|
70
|
+
.catch(function () { return false; })];
|
|
71
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function verifyThatMissingOrgFilesHasCommonReplacements(missingOrgFiles) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var filesMissingFromBothOrgAndCommonFolder, _i, missingOrgFiles_1, missingOrgFile, fullPath, missingOrgFileExistsInCommon;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
filesMissingFromBothOrgAndCommonFolder = [];
|
|
83
|
+
_i = 0, missingOrgFiles_1 = missingOrgFiles;
|
|
84
|
+
_a.label = 1;
|
|
85
|
+
case 1:
|
|
86
|
+
if (!(_i < missingOrgFiles_1.length)) return [3 /*break*/, 4];
|
|
87
|
+
missingOrgFile = missingOrgFiles_1[_i];
|
|
88
|
+
fullPath = path_1.default.join(__dirname, '..', '..', 'files', 'common', missingOrgFile);
|
|
89
|
+
return [4 /*yield*/, exists(fullPath)];
|
|
90
|
+
case 2:
|
|
91
|
+
missingOrgFileExistsInCommon = _a.sent();
|
|
92
|
+
if (!missingOrgFileExistsInCommon)
|
|
93
|
+
filesMissingFromBothOrgAndCommonFolder.push(fullPath);
|
|
94
|
+
_a.label = 3;
|
|
95
|
+
case 3:
|
|
96
|
+
_i++;
|
|
97
|
+
return [3 /*break*/, 1];
|
|
98
|
+
case 4: return [2 /*return*/, filesMissingFromBothOrgAndCommonFolder];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function validateValidOrgs() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
+
var expectedFiles, extraOrgs, hasErrors, _i, extraOrgs_1, orgAssets, filesMissingInOrg, filesMissingBothInOrgAndCommon;
|
|
106
|
+
return __generator(this, function (_a) {
|
|
107
|
+
switch (_a.label) {
|
|
108
|
+
case 0: return [4 /*yield*/, fromOrgFiles(theme_1.ThemeVariant.AtB)];
|
|
109
|
+
case 1:
|
|
110
|
+
expectedFiles = _a.sent();
|
|
111
|
+
return [4 /*yield*/, Promise.all(generate_1.validOrgIds.filter(function (i) { return i != theme_1.ThemeVariant.AtB; }).map(fromOrgFiles))];
|
|
112
|
+
case 2:
|
|
113
|
+
extraOrgs = _a.sent();
|
|
114
|
+
hasErrors = false;
|
|
115
|
+
_i = 0, extraOrgs_1 = extraOrgs;
|
|
116
|
+
_a.label = 3;
|
|
117
|
+
case 3:
|
|
118
|
+
if (!(_i < extraOrgs_1.length)) return [3 /*break*/, 6];
|
|
119
|
+
orgAssets = extraOrgs_1[_i];
|
|
120
|
+
filesMissingInOrg = difference(expectedFiles.files, orgAssets.files);
|
|
121
|
+
if (!filesMissingInOrg.length)
|
|
122
|
+
return [3 /*break*/, 5];
|
|
123
|
+
console.log("".concat((0, utils_1.themeVariantAsString)(orgAssets.org), " seems to be missing some assets, checking if common files can be used for these files:\n").concat(filesMissingInOrg.join('\n')));
|
|
124
|
+
return [4 /*yield*/, verifyThatMissingOrgFilesHasCommonReplacements(filesMissingInOrg)];
|
|
125
|
+
case 4:
|
|
126
|
+
filesMissingBothInOrgAndCommon = _a.sent();
|
|
127
|
+
if (filesMissingBothInOrgAndCommon.length) {
|
|
128
|
+
hasErrors = true;
|
|
129
|
+
console.error("".concat((0, utils_1.themeVariantAsString)(orgAssets.org), " is missing some assets, that also does not have a common file:\n").concat(filesMissingBothInOrgAndCommon.join('\n')));
|
|
130
|
+
}
|
|
131
|
+
_a.label = 5;
|
|
132
|
+
case 5:
|
|
133
|
+
_i++;
|
|
134
|
+
return [3 /*break*/, 3];
|
|
135
|
+
case 6:
|
|
136
|
+
hasErrors
|
|
137
|
+
? process.exit(1)
|
|
138
|
+
: console.log('Asset validation completed successfully');
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function cleanFilenames(filename) {
|
|
145
|
+
return filename.split(/\/files\/(.*?)\//)[2];
|
|
146
|
+
}
|
|
147
|
+
function difference(correct, potential) {
|
|
148
|
+
return correct.filter(function (x) { return !potential.includes(x); });
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=validate-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-files.js","sourceRoot":"","sources":["../../src/tools/validate-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA2C;AAC3C,yBAAuC;AACvC,8CAAwB;AACxB,wCAAwC;AACxC,kCAAmE;AAEnE,iBAAiB,EAAE,CAAC;AAEpB,SAAe,YAAY,CAAC,GAAiB;;;;;;oBACrC,QAAQ,GAAG,cAAI,CAAC,IAAI,CACxB,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,IAAA,4BAAoB,EAAC,GAAG,CAAC,EACzB,QAAQ,CACT,CAAC;oBACY,qBAAM,IAAA,2BAAmB,EAAC,QAAQ,CAAC,EAAA;;oBAA3C,KAAK,GAAG,SAAmC;oBACjD,sBAAO,EAAC,GAAG,KAAA,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,EAAC,EAAC;;;;CAChD;AAED,SAAe,MAAM,CAAC,WAAmB;;;;wBAChC,qBAAM,aAAQ;yBAClB,MAAM,CAAC,WAAW,EAAE,cAAS,CAAC,IAAI,CAAC;yBACnC,IAAI,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;yBAChB,KAAK,CAAC,cAAM,OAAA,KAAK,EAAL,CAAK,CAAC,EAAA;wBAHrB,sBAAO,SAGc,EAAC;;;;CACvB;AAED,SAAe,8CAA8C,CAC3D,eAAyB;;;;;;oBAErB,sCAAsC,GAAa,EAAE,CAAC;0BACd,EAAf,mCAAe;;;yBAAf,CAAA,6BAAe,CAAA;oBAAjC,cAAc;oBACjB,QAAQ,GAAG,cAAI,CAAC,IAAI,CACxB,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,cAAc,CACf,CAAC;oBACmC,qBAAM,MAAM,CAAC,QAAQ,CAAC,EAAA;;oBAArD,4BAA4B,GAAG,SAAsB;oBAC3D,IAAI,CAAC,4BAA4B;wBAC/B,sCAAsC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;;oBAX7B,IAAe,CAAA;;wBAa5C,sBAAO,sCAAsC,EAAC;;;;CAC/C;AAED,SAAe,iBAAiB;;;;;wBACR,qBAAM,YAAY,CAAC,oBAAY,CAAC,GAAG,CAAC,EAAA;;oBAApD,aAAa,GAAG,SAAoC;oBACxC,qBAAM,OAAO,CAAC,GAAG,CACjC,sBAAW,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,IAAI,oBAAY,CAAC,GAAG,EAArB,CAAqB,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CACnE,EAAA;;oBAFK,SAAS,GAAG,SAEjB;oBAEG,SAAS,GAAG,KAAK,CAAC;0BAES,EAAT,uBAAS;;;yBAAT,CAAA,uBAAS,CAAA;oBAAtB,SAAS;oBACV,iBAAiB,GAAG,UAAU,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;oBAC3E,IAAI,CAAC,iBAAiB,CAAC,MAAM;wBAAE,wBAAS;oBAExC,OAAO,CAAC,GAAG,CACT,UAAG,IAAA,4BAAoB,EACrB,SAAS,CAAC,GAAG,CACd,sGAA4F,iBAAiB,CAAC,IAAI,CACjH,IAAI,CACL,CAAE,CACJ,CAAC;oBAEA,qBAAM,8CAA8C,CAAC,iBAAiB,CAAC,EAAA;;oBADnE,8BAA8B,GAClC,SAAuE;oBAEzE,IAAI,8BAA8B,CAAC,MAAM,EAAE,CAAC;wBAC1C,SAAS,GAAG,IAAI,CAAC;wBACjB,OAAO,CAAC,KAAK,CACX,UAAG,IAAA,4BAAoB,EACrB,SAAS,CAAC,GAAG,CACd,8EAAoE,8BAA8B,CAAC,IAAI,CACtG,IAAI,CACL,CAAE,CACJ,CAAC;oBACJ,CAAC;;;oBAvBmB,IAAS,CAAA;;;oBA0B/B,SAAS;wBACP,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;wBACjB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;;;;;CAC5D;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,UAAU,CAAC,OAAiB,EAAE,SAAmB;IACxD,OAAO,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAtB,CAAsB,CAAC,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atb-as/generate-assets",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.5.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"description": "OOS Design System generate-assets",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"files"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
+
"clean": "rm -rf lib",
|
|
18
19
|
"build": "tsc && node lib/tools/validate-files",
|
|
19
20
|
"pack": "yarn pack"
|
|
20
21
|
},
|
|
@@ -28,12 +29,12 @@
|
|
|
28
29
|
"access": "public"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@atb-as/theme": "
|
|
32
|
+
"@atb-as/theme": "14.0.1",
|
|
32
33
|
"commander": "^9.4.0",
|
|
33
34
|
"fast-glob": "^3.2.11",
|
|
34
35
|
"micromatch": "^4.0.5",
|
|
35
36
|
"normalize-path": "^3.0.0",
|
|
36
37
|
"stream-editor": "^1.11.0"
|
|
37
38
|
},
|
|
38
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "0d9bbd3ee68c327450409f0b33a3d4fafdfae8f8"
|
|
39
40
|
}
|
package/src/bin.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {validOrgIds, generateAssets, searchGlob} from './generate';
|
|
4
|
+
import pathlib from 'path';
|
|
5
|
+
import {AssetType, stringAsThemeVariant, themeVariantAsString} from './utils';
|
|
6
|
+
import {setDebug} from './logger';
|
|
7
|
+
|
|
8
|
+
import {program, Argument} from 'commander';
|
|
9
|
+
import {generateTs} from './generateTs';
|
|
10
|
+
|
|
11
|
+
type InputOptions = {
|
|
12
|
+
debug: boolean;
|
|
13
|
+
generateMonoTheme: boolean;
|
|
14
|
+
glob?: string;
|
|
15
|
+
outDir: string;
|
|
16
|
+
generateTs: boolean;
|
|
17
|
+
tsOutDir: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.name('npx @atb-as/generate-assets')
|
|
22
|
+
.addArgument(
|
|
23
|
+
new Argument('<type>', 'Type of assets to generate')
|
|
24
|
+
.choices(['colors', 'all', 'mono'])
|
|
25
|
+
.argRequired(),
|
|
26
|
+
)
|
|
27
|
+
.addArgument(
|
|
28
|
+
new Argument('<orgId>', 'Generate for specific organization')
|
|
29
|
+
.choices(validOrgIds.map(themeVariantAsString))
|
|
30
|
+
.argRequired(),
|
|
31
|
+
)
|
|
32
|
+
.requiredOption('-o, --out-dir <output>', 'Output directory')
|
|
33
|
+
.option(
|
|
34
|
+
'-ts-o, --ts-out-dir <output>',
|
|
35
|
+
'Output directory for generated typescript',
|
|
36
|
+
)
|
|
37
|
+
.option('-d, --debug', 'Log all files generated', false)
|
|
38
|
+
.option(
|
|
39
|
+
'-nm, --no-generate-mono-theme',
|
|
40
|
+
'Ignore generating themed mono-icons, but keep general mono icons.',
|
|
41
|
+
)
|
|
42
|
+
.option('-ts, --generate-ts', 'Generates typescript resolution file.', false)
|
|
43
|
+
.option(
|
|
44
|
+
'-g, --glob [glob]',
|
|
45
|
+
'Pass in custom glob for matching files.',
|
|
46
|
+
searchGlob,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
program.showHelpAfterError();
|
|
50
|
+
program.showSuggestionAfterError();
|
|
51
|
+
|
|
52
|
+
program.parse();
|
|
53
|
+
|
|
54
|
+
const opts = program.opts<InputOptions>();
|
|
55
|
+
const assetType = program.args[0] as AssetType;
|
|
56
|
+
const orgId = program.args[1];
|
|
57
|
+
|
|
58
|
+
if (opts.debug) setDebug(true);
|
|
59
|
+
|
|
60
|
+
const main = async () => {
|
|
61
|
+
const outputFolder = pathlib.join(process.cwd(), opts.outDir);
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const potentialGlob = findPotentialGlobPattern(process.argv);
|
|
65
|
+
|
|
66
|
+
console.log(`Writing assets for ${orgId} to ${outputFolder}`);
|
|
67
|
+
const assets = await generateAssets(
|
|
68
|
+
assetType,
|
|
69
|
+
stringAsThemeVariant(orgId),
|
|
70
|
+
outputFolder,
|
|
71
|
+
{
|
|
72
|
+
patterns: potentialGlob,
|
|
73
|
+
generateMonoTheme: opts.generateMonoTheme,
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
if (opts.debug) {
|
|
77
|
+
console.log(`Written ${assets.length} assets for ${orgId}:\n`);
|
|
78
|
+
|
|
79
|
+
console.log();
|
|
80
|
+
assets.forEach((i) => console.log(i));
|
|
81
|
+
} else {
|
|
82
|
+
console.log(
|
|
83
|
+
`Successfully written ${assets.length} assets for ${orgId} to ${outputFolder}`,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (opts.generateTs) {
|
|
88
|
+
const generatedTsFile = await generateTs(
|
|
89
|
+
assets,
|
|
90
|
+
assetType,
|
|
91
|
+
outputFolder,
|
|
92
|
+
opts.tsOutDir,
|
|
93
|
+
);
|
|
94
|
+
console.log(`Generated typescript file: ${generatedTsFile}`);
|
|
95
|
+
}
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error((e as Error)?.message);
|
|
98
|
+
program.help({error: true});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
main();
|
|
103
|
+
|
|
104
|
+
function findPotentialGlobPattern(args: string[]) {
|
|
105
|
+
for (let arg in args) {
|
|
106
|
+
if (!args[arg]?.startsWith('--glob') && !args[arg]?.startsWith('-g'))
|
|
107
|
+
continue;
|
|
108
|
+
|
|
109
|
+
// Is glob, check for valid next argument or if using =
|
|
110
|
+
if (args[arg].includes('=')) {
|
|
111
|
+
const [, glob] = args[arg].split('=');
|
|
112
|
+
return glob;
|
|
113
|
+
}
|
|
114
|
+
const potentialGlob = args[Number(arg) + 1];
|
|
115
|
+
if (!potentialGlob) {
|
|
116
|
+
throw new Error('Missing argument to --glob.');
|
|
117
|
+
}
|
|
118
|
+
return potentialGlob;
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
package/src/generate.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import {createReadStream, createWriteStream} from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
import {createThemesFor, Mode, Themes, ThemeVariant} from '@atb-as/theme';
|
|
6
|
+
|
|
7
|
+
import micromatch from 'micromatch';
|
|
8
|
+
import {sed as updateFiles} from 'stream-editor';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
fgNormalizedForUnix,
|
|
12
|
+
normalizeToUnix,
|
|
13
|
+
themeVariantAsString,
|
|
14
|
+
} from './utils';
|
|
15
|
+
import {log} from './logger';
|
|
16
|
+
|
|
17
|
+
export const validOrgIds = [
|
|
18
|
+
ThemeVariant.AtB,
|
|
19
|
+
ThemeVariant.Nfk,
|
|
20
|
+
ThemeVariant.FRAM,
|
|
21
|
+
ThemeVariant.Troms,
|
|
22
|
+
ThemeVariant.Innlandet,
|
|
23
|
+
ThemeVariant.VKT,
|
|
24
|
+
ThemeVariant.Farte,
|
|
25
|
+
];
|
|
26
|
+
export const searchGlob = '**/*.{svg,png,jpg,jpeg,ico}';
|
|
27
|
+
export const searchGlobSvg = '**/*.svg';
|
|
28
|
+
|
|
29
|
+
type AssetTypes = 'colors' | 'mono' | 'all';
|
|
30
|
+
|
|
31
|
+
type Options = {
|
|
32
|
+
generateMonoTheme?: boolean;
|
|
33
|
+
onlyOutputMono?: boolean;
|
|
34
|
+
patterns?: string | readonly string[];
|
|
35
|
+
};
|
|
36
|
+
const defaultOpts: Options = {
|
|
37
|
+
generateMonoTheme: true,
|
|
38
|
+
onlyOutputMono: false,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export async function generateAssets(
|
|
42
|
+
assetType: AssetTypes,
|
|
43
|
+
orgId: ThemeVariant,
|
|
44
|
+
destinationDirectory: string,
|
|
45
|
+
opts: Options = defaultOpts,
|
|
46
|
+
) {
|
|
47
|
+
const assetDir = assetType == 'all' ? '{colors,mono}' : assetType;
|
|
48
|
+
const fromBase = (...p: string[]) => {
|
|
49
|
+
const fullPath = path.join(
|
|
50
|
+
__dirname,
|
|
51
|
+
'..',
|
|
52
|
+
'files',
|
|
53
|
+
...p,
|
|
54
|
+
assetDir,
|
|
55
|
+
searchGlob,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
log('searching for files in', fullPath);
|
|
59
|
+
return fgNormalizedForUnix(fullPath);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
if (!validOrgIds.includes(orgId))
|
|
63
|
+
throw new Error(`Invalid orgId provided, valid orgIds are ${validOrgIds}`);
|
|
64
|
+
|
|
65
|
+
// File paths are returned as UNIX type separators.
|
|
66
|
+
const commonFiles = await fromBase('common');
|
|
67
|
+
const orgFiles = await fromBase(themeVariantAsString(orgId));
|
|
68
|
+
|
|
69
|
+
log('Found common files:', commonFiles.length);
|
|
70
|
+
log('Found org files for', orgId, ':', orgFiles.length);
|
|
71
|
+
|
|
72
|
+
log('Merging files for ', assetType);
|
|
73
|
+
const allFilesToBeCopied = mergeFiles(assetType, commonFiles, orgFiles);
|
|
74
|
+
log('Found merged files:', allFilesToBeCopied.length);
|
|
75
|
+
|
|
76
|
+
const potentiallyFiltered = opts.patterns
|
|
77
|
+
? micromatch(allFilesToBeCopied, opts.patterns)
|
|
78
|
+
: allFilesToBeCopied;
|
|
79
|
+
|
|
80
|
+
let allFiles = potentiallyFiltered.map(async (absolutePath) => {
|
|
81
|
+
const relativePath = path.normalize(
|
|
82
|
+
getGeneralNameWithoutFullPath(assetType, absolutePath),
|
|
83
|
+
);
|
|
84
|
+
const destinationPath = path.join(destinationDirectory, relativePath);
|
|
85
|
+
|
|
86
|
+
await fs.mkdir(path.dirname(destinationPath), {recursive: true});
|
|
87
|
+
await fs.copyFile(path.normalize(absolutePath), destinationPath);
|
|
88
|
+
|
|
89
|
+
return destinationPath;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
log('Total files before generated mono icons:', allFiles.length);
|
|
93
|
+
|
|
94
|
+
let created = await Promise.all(allFiles);
|
|
95
|
+
if (opts.generateMonoTheme && assetType !== 'colors') {
|
|
96
|
+
const allExtraMonoIcons = await generateMonoIconsInDestinationDirectory(
|
|
97
|
+
assetType,
|
|
98
|
+
orgId,
|
|
99
|
+
destinationDirectory,
|
|
100
|
+
);
|
|
101
|
+
created = created.concat(await Promise.all(allExtraMonoIcons));
|
|
102
|
+
}
|
|
103
|
+
log('Total files after generated mono icons:', created.length);
|
|
104
|
+
|
|
105
|
+
return created;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function generateMonoIconsInDestinationDirectory(
|
|
109
|
+
assetType: AssetTypes,
|
|
110
|
+
orgId: ThemeVariant,
|
|
111
|
+
destinationDirectory: string,
|
|
112
|
+
) {
|
|
113
|
+
const themes = createThemesFor(orgId);
|
|
114
|
+
|
|
115
|
+
// Assume mono-icons is created directly on destination root.
|
|
116
|
+
const base = path.join(
|
|
117
|
+
destinationDirectory,
|
|
118
|
+
assetType === 'all' ? 'mono' : '',
|
|
119
|
+
);
|
|
120
|
+
const folder = path.join(base, searchGlobSvg);
|
|
121
|
+
|
|
122
|
+
const darkBase = path.join(base, 'dark');
|
|
123
|
+
const lightBase = path.join(base, 'light');
|
|
124
|
+
|
|
125
|
+
await fs.mkdir(darkBase, {recursive: true});
|
|
126
|
+
await fs.mkdir(lightBase, {recursive: true});
|
|
127
|
+
|
|
128
|
+
let files: Promise<string>[] = [];
|
|
129
|
+
for (const entry of await fgNormalizedForUnix(folder, {
|
|
130
|
+
// Avoid trying to convert what we have from before.
|
|
131
|
+
ignore: [darkBase, lightBase],
|
|
132
|
+
})) {
|
|
133
|
+
files = files.concat([
|
|
134
|
+
rewriteAndSave('dark', themes, entry, base),
|
|
135
|
+
rewriteAndSave('light', themes, entry, base),
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
return files;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function rewriteAndSave(
|
|
142
|
+
color: Mode,
|
|
143
|
+
themes: Themes,
|
|
144
|
+
absoluteFile: string,
|
|
145
|
+
monoIconsBase: string,
|
|
146
|
+
) {
|
|
147
|
+
const relativeFileName = path.relative(monoIconsBase, absoluteFile);
|
|
148
|
+
const filename = path.basename(relativeFileName);
|
|
149
|
+
const destinationDir = path.join(
|
|
150
|
+
monoIconsBase,
|
|
151
|
+
color,
|
|
152
|
+
path.dirname(relativeFileName),
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
await fs.mkdir(destinationDir, {recursive: true});
|
|
156
|
+
const destination = path.join(destinationDir, filename);
|
|
157
|
+
|
|
158
|
+
await updateFiles({
|
|
159
|
+
from: createReadStream(absoluteFile),
|
|
160
|
+
to: createWriteStream(destination),
|
|
161
|
+
match: /((fill|stroke)\=\"(?:[^"]+)\")/,
|
|
162
|
+
replacement: `$2="${themes[color].color.foreground.dynamic.primary}"`,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return destination;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function mergeFiles(
|
|
169
|
+
assetType: AssetTypes,
|
|
170
|
+
commonFiles: string[],
|
|
171
|
+
orgFiles: string[],
|
|
172
|
+
) {
|
|
173
|
+
const relativeOrgFiles = orgFiles.map((f) =>
|
|
174
|
+
getGeneralNameWithoutFullPath(assetType, f),
|
|
175
|
+
);
|
|
176
|
+
const commonsWithoutOverrides = commonFiles.filter(function (filepath) {
|
|
177
|
+
return !relativeOrgFiles.includes(
|
|
178
|
+
getGeneralNameWithoutFullPath(assetType, filepath),
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
return commonsWithoutOverrides.concat(orgFiles);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function getGeneralNameWithoutFullPath(
|
|
186
|
+
assetType: AssetTypes,
|
|
187
|
+
fullPath: string,
|
|
188
|
+
) {
|
|
189
|
+
const assetDir = assetType == 'all' ? '' : escapeRegex(`/${assetType}`);
|
|
190
|
+
const regexString = `^.*\/files\/[^\/]+${assetDir}`;
|
|
191
|
+
|
|
192
|
+
// Normalize to unix style instead if handling separator manually
|
|
193
|
+
return normalizeToUnix(fullPath).replace(new RegExp(regexString), '');
|
|
194
|
+
}
|
|
195
|
+
function escapeRegex(str: string) {
|
|
196
|
+
return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
197
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {AssetType, normalizeToUnix} from './utils';
|
|
4
|
+
|
|
5
|
+
type Data = Partial<{
|
|
6
|
+
mono: Record<string, MonoType>;
|
|
7
|
+
colorIcons: Record<string, ColorType>;
|
|
8
|
+
images: Record<string, ColorType>;
|
|
9
|
+
illustration: Record<string, ColorType>;
|
|
10
|
+
}>;
|
|
11
|
+
export async function generateTs(
|
|
12
|
+
allFiles: string[],
|
|
13
|
+
assetTypeInput: AssetType,
|
|
14
|
+
outputDir: string,
|
|
15
|
+
tsOutput: string = outputDir,
|
|
16
|
+
) {
|
|
17
|
+
const data = generateData(allFiles, assetTypeInput, outputDir);
|
|
18
|
+
const generatedContents = template(data);
|
|
19
|
+
|
|
20
|
+
await fs.mkdir(tsOutput, {recursive: true});
|
|
21
|
+
const destinationFile = path.join(tsOutput, 'generated-icons.ts');
|
|
22
|
+
await fs.writeFile(destinationFile, generatedContents);
|
|
23
|
+
|
|
24
|
+
return destinationFile;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function template(data: Data) {
|
|
28
|
+
return `// NB! NB! NB!
|
|
29
|
+
// AUTO GENERATED FILE. DON'T CHANGE
|
|
30
|
+
// NB! NB! NB!
|
|
31
|
+
export const icons = ${JSON.stringify(data, null, 2)};
|
|
32
|
+
export type Icons = typeof icons;
|
|
33
|
+
|
|
34
|
+
export type ColorType = {
|
|
35
|
+
relative: string;
|
|
36
|
+
absolute: string;
|
|
37
|
+
assetType: 'colors';
|
|
38
|
+
colorType: 'illustrations' | 'images';
|
|
39
|
+
darkable: boolean;
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type MonoType = {
|
|
44
|
+
relative: string;
|
|
45
|
+
absolute: string;
|
|
46
|
+
assetType: 'mono';
|
|
47
|
+
id: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type IconType = ColorType | MonoType;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
${data.mono ? `export type MonoIcons = keyof Icons['mono'];` : ''}
|
|
54
|
+
${data.images ? `export type Images = keyof Icons['images'];` : ''}
|
|
55
|
+
${data.colorIcons ? `export type ColorIcons = keyof Icons['colorIcons'];` : ''}
|
|
56
|
+
${
|
|
57
|
+
data.illustration
|
|
58
|
+
? `export type Illustrations = keyof Icons['illustration'];`
|
|
59
|
+
: ''
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function toUniqueObject<T extends IconType>(list: T[]) {
|
|
65
|
+
return pickBy(list, (i) => i.id);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function generateData(
|
|
69
|
+
allFiles: string[],
|
|
70
|
+
assetTypeInput: AssetType,
|
|
71
|
+
outputDir: string,
|
|
72
|
+
) {
|
|
73
|
+
const constructs = allFiles
|
|
74
|
+
.map((f) => toTypeCoonstruct(f, assetTypeInput, outputDir))
|
|
75
|
+
.filter(Boolean) as IconType[];
|
|
76
|
+
|
|
77
|
+
const groupedByMode = groupBy(constructs, (i) => i.assetType);
|
|
78
|
+
const mono = groupedByMode.mono as MonoType[];
|
|
79
|
+
const colors = groupedByMode.colors
|
|
80
|
+
? groupBy(groupedByMode.colors as ColorType[], (i) => i.colorType)
|
|
81
|
+
: undefined;
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
mono: mono ? toUniqueObject(mono) : undefined,
|
|
85
|
+
images: colors?.images ? toUniqueObject(colors.images) : undefined,
|
|
86
|
+
colorIcons: colors?.icons ? toUniqueObject(colors.icons) : undefined,
|
|
87
|
+
illustration: colors?.illustrations
|
|
88
|
+
? toUniqueObject(colors.illustrations)
|
|
89
|
+
: undefined,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type ColorType = {
|
|
94
|
+
relative: string;
|
|
95
|
+
absolute: string;
|
|
96
|
+
assetType: 'colors';
|
|
97
|
+
colorType: 'illustrations' | 'images' | 'icons';
|
|
98
|
+
darkable: boolean;
|
|
99
|
+
id: string;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type MonoType = {
|
|
103
|
+
relative: string;
|
|
104
|
+
absolute: string;
|
|
105
|
+
assetType: 'mono';
|
|
106
|
+
id: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
type IconType = ColorType | MonoType;
|
|
110
|
+
function toTypeCoonstruct(
|
|
111
|
+
absolute: string,
|
|
112
|
+
assetTypeInput: AssetType,
|
|
113
|
+
outputDir: string,
|
|
114
|
+
): IconType | undefined {
|
|
115
|
+
const relative = absolute.replace(outputDir, '');
|
|
116
|
+
|
|
117
|
+
let assetType =
|
|
118
|
+
assetTypeInput == 'all'
|
|
119
|
+
? relative.match(/^.?colors/)
|
|
120
|
+
? 'colors'
|
|
121
|
+
: 'mono'
|
|
122
|
+
: assetTypeInput;
|
|
123
|
+
|
|
124
|
+
// If is mono and has dark/light in the path, skip the asset.
|
|
125
|
+
if (assetType === 'mono' && relative.match(/(dark|light)/)) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (assetType == 'colors') {
|
|
130
|
+
return {
|
|
131
|
+
relative,
|
|
132
|
+
absolute,
|
|
133
|
+
assetType: 'colors',
|
|
134
|
+
colorType: getColorType(relative),
|
|
135
|
+
darkable: isDarkable(relative),
|
|
136
|
+
id: toIDPath(relative),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
relative,
|
|
142
|
+
absolute,
|
|
143
|
+
assetType: 'mono',
|
|
144
|
+
id: toIDPath(relative),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const darkOrLight = /\/(?:dark|light)\//;
|
|
148
|
+
|
|
149
|
+
function toIDPath(relative: string) {
|
|
150
|
+
return normalizeToUnix(relative)
|
|
151
|
+
.replace(darkOrLight, '/')
|
|
152
|
+
.replace(
|
|
153
|
+
/^\/?(?:(?:mono|colors)\/)?(?:(?:illustrations|images|icons)\/)?(.*)\..{3}$/,
|
|
154
|
+
'$1',
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function isDarkable(relative: string) {
|
|
158
|
+
return relative.match(darkOrLight) !== null;
|
|
159
|
+
}
|
|
160
|
+
function getColorType(relative: string): ColorType['colorType'] {
|
|
161
|
+
const colorType = normalizeToUnix(relative)
|
|
162
|
+
// Extract the color type
|
|
163
|
+
.match(/^\/?(?:(?:mono|colors)\/)?(illustrations|images|icons)\//)?.[1];
|
|
164
|
+
|
|
165
|
+
switch (colorType) {
|
|
166
|
+
case 'illustrations':
|
|
167
|
+
return 'illustrations';
|
|
168
|
+
case 'icons':
|
|
169
|
+
return 'icons';
|
|
170
|
+
default:
|
|
171
|
+
return 'images';
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const groupBy = <T, K extends keyof any>(list: T[], getKey: (item: T) => K) =>
|
|
176
|
+
list.reduce((previous, currentItem) => {
|
|
177
|
+
const group = getKey(currentItem);
|
|
178
|
+
if (!previous[group]) previous[group] = [];
|
|
179
|
+
previous[group].push(currentItem);
|
|
180
|
+
return previous;
|
|
181
|
+
}, {} as Record<K, T[]>);
|
|
182
|
+
|
|
183
|
+
const pickBy = <T, K extends keyof any>(list: T[], getKey: (item: T) => K) =>
|
|
184
|
+
list.reduce((previous, currentItem) => {
|
|
185
|
+
const group = getKey(currentItem);
|
|
186
|
+
if (previous[group]) return previous;
|
|
187
|
+
previous[group] = currentItem;
|
|
188
|
+
return previous;
|
|
189
|
+
}, {} as Record<K, T>);
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {ThemeVariant} from '@atb-as/theme';
|
|
2
|
+
import {constants, promises} from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import {validOrgIds} from '../generate';
|
|
5
|
+
import {fgNormalizedForUnix, themeVariantAsString} from '../utils';
|
|
6
|
+
|
|
7
|
+
validateValidOrgs();
|
|
8
|
+
|
|
9
|
+
async function fromOrgFiles(org: ThemeVariant) {
|
|
10
|
+
const fullPath = path.join(
|
|
11
|
+
__dirname,
|
|
12
|
+
'..',
|
|
13
|
+
'..',
|
|
14
|
+
'files',
|
|
15
|
+
themeVariantAsString(org),
|
|
16
|
+
'**/*.*',
|
|
17
|
+
);
|
|
18
|
+
const files = await fgNormalizedForUnix(fullPath);
|
|
19
|
+
return {org, files: files.map(cleanFilenames)};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function exists(fileToCheck: string) {
|
|
23
|
+
return await promises
|
|
24
|
+
.access(fileToCheck, constants.F_OK)
|
|
25
|
+
.then(() => true)
|
|
26
|
+
.catch(() => false);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function verifyThatMissingOrgFilesHasCommonReplacements(
|
|
30
|
+
missingOrgFiles: string[],
|
|
31
|
+
) {
|
|
32
|
+
let filesMissingFromBothOrgAndCommonFolder = <string[]>[];
|
|
33
|
+
for (const missingOrgFile of missingOrgFiles) {
|
|
34
|
+
const fullPath = path.join(
|
|
35
|
+
__dirname,
|
|
36
|
+
'..',
|
|
37
|
+
'..',
|
|
38
|
+
'files',
|
|
39
|
+
'common',
|
|
40
|
+
missingOrgFile,
|
|
41
|
+
);
|
|
42
|
+
const missingOrgFileExistsInCommon = await exists(fullPath);
|
|
43
|
+
if (!missingOrgFileExistsInCommon)
|
|
44
|
+
filesMissingFromBothOrgAndCommonFolder.push(fullPath);
|
|
45
|
+
}
|
|
46
|
+
return filesMissingFromBothOrgAndCommonFolder;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function validateValidOrgs() {
|
|
50
|
+
const expectedFiles = await fromOrgFiles(ThemeVariant.AtB);
|
|
51
|
+
const extraOrgs = await Promise.all(
|
|
52
|
+
validOrgIds.filter((i) => i != ThemeVariant.AtB).map(fromOrgFiles),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
let hasErrors = false;
|
|
56
|
+
|
|
57
|
+
for (let orgAssets of extraOrgs) {
|
|
58
|
+
const filesMissingInOrg = difference(expectedFiles.files, orgAssets.files);
|
|
59
|
+
if (!filesMissingInOrg.length) continue;
|
|
60
|
+
|
|
61
|
+
console.log(
|
|
62
|
+
`${themeVariantAsString(
|
|
63
|
+
orgAssets.org,
|
|
64
|
+
)} seems to be missing some assets, checking if common files can be used for these files:\n${filesMissingInOrg.join(
|
|
65
|
+
'\n',
|
|
66
|
+
)}`,
|
|
67
|
+
);
|
|
68
|
+
const filesMissingBothInOrgAndCommon =
|
|
69
|
+
await verifyThatMissingOrgFilesHasCommonReplacements(filesMissingInOrg);
|
|
70
|
+
|
|
71
|
+
if (filesMissingBothInOrgAndCommon.length) {
|
|
72
|
+
hasErrors = true;
|
|
73
|
+
console.error(
|
|
74
|
+
`${themeVariantAsString(
|
|
75
|
+
orgAssets.org,
|
|
76
|
+
)} is missing some assets, that also does not have a common file:\n${filesMissingBothInOrgAndCommon.join(
|
|
77
|
+
'\n',
|
|
78
|
+
)}`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
hasErrors
|
|
84
|
+
? process.exit(1)
|
|
85
|
+
: console.log('Asset validation completed successfully');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function cleanFilenames(filename: string) {
|
|
89
|
+
return filename.split(/\/files\/(.*?)\//)[2];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function difference(correct: string[], potential: string[]) {
|
|
93
|
+
return correct.filter((x) => !potential.includes(x));
|
|
94
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {ThemeVariant} from '@atb-as/theme';
|
|
2
|
+
|
|
3
|
+
export {ThemeVariant};
|
|
4
|
+
import fg from 'fast-glob';
|
|
5
|
+
import normalizeToUnix from 'normalize-path';
|
|
6
|
+
|
|
7
|
+
export type AssetType = 'colors' | 'all' | 'mono';
|
|
8
|
+
|
|
9
|
+
export function themeVariantAsString(org: ThemeVariant): string {
|
|
10
|
+
switch (org) {
|
|
11
|
+
case ThemeVariant.Nfk:
|
|
12
|
+
return 'nfk';
|
|
13
|
+
case ThemeVariant.AtB:
|
|
14
|
+
return 'atb';
|
|
15
|
+
case ThemeVariant.FRAM:
|
|
16
|
+
return 'fram';
|
|
17
|
+
case ThemeVariant.Troms:
|
|
18
|
+
return 'troms';
|
|
19
|
+
case ThemeVariant.Innlandet:
|
|
20
|
+
return 'innlandet';
|
|
21
|
+
case ThemeVariant.VKT:
|
|
22
|
+
return 'vkt';
|
|
23
|
+
case ThemeVariant.Farte:
|
|
24
|
+
return 'farte';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function stringAsThemeVariant(org: string): ThemeVariant {
|
|
29
|
+
switch (org) {
|
|
30
|
+
case 'nfk':
|
|
31
|
+
return ThemeVariant.Nfk;
|
|
32
|
+
case 'atb':
|
|
33
|
+
return ThemeVariant.AtB;
|
|
34
|
+
case 'fram':
|
|
35
|
+
return ThemeVariant.FRAM;
|
|
36
|
+
case 'troms':
|
|
37
|
+
return ThemeVariant.Troms;
|
|
38
|
+
case 'innlandet':
|
|
39
|
+
return ThemeVariant.Innlandet;
|
|
40
|
+
case 'vkt':
|
|
41
|
+
return ThemeVariant.VKT;
|
|
42
|
+
case 'farte':
|
|
43
|
+
return ThemeVariant.Farte;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
throw new Error('Invalid org');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Due to globs nature forward UNIX type slashes should be used. Normalize paths.
|
|
50
|
+
// All paths returned are also UNIX style. All node functions normalize self, no
|
|
51
|
+
// need to do it manually.
|
|
52
|
+
// (see https://github.com/mrmlnc/fast-glob#how-to-write-patterns-on-windows)
|
|
53
|
+
export function fgNormalizedForUnix(
|
|
54
|
+
path: string,
|
|
55
|
+
options?: {ignore: string[]},
|
|
56
|
+
) {
|
|
57
|
+
const opts =
|
|
58
|
+
options && options.ignore
|
|
59
|
+
? {
|
|
60
|
+
ignore: options.ignore.map((f) => normalizeToUnix(f)),
|
|
61
|
+
}
|
|
62
|
+
: options;
|
|
63
|
+
return fg(normalizeToUnix(path), opts);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export {normalizeToUnix};
|