@adminforth/i18n 1.6.7 → 1.7.0

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.
@@ -1,10 +1,13 @@
1
1
  #!/bin/sh
2
2
 
3
+ set -x
3
4
 
4
5
  COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
5
6
 
7
+ STATUS=${1}
6
8
 
7
- if [ "$CI_STEP_STATUS" = "success" ]; then
9
+
10
+ if [ "$STATUS" = "success" ]; then
8
11
  MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
9
12
 
10
13
  curl -s -X POST -H "Content-Type: application/json" -d '{
@@ -22,13 +25,14 @@ if [ "$CI_STEP_STATUS" = "success" ]; then
22
25
  fi
23
26
  export BUILD_LOG=$(cat ./build.log)
24
27
 
28
+ BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
25
29
 
26
30
  MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
27
31
  CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
28
32
 
29
33
  echo "Sending slack message to developers $MESSAGE"
30
34
  # Send the message
31
- curl -X POST -H "Content-Type: application/json" -d '{
35
+ curl -sS -X POST -H "Content-Type: application/json" -d '{
32
36
  "username": "'"$CI_COMMIT_AUTHOR"'",
33
37
  "icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
34
38
  "attachments": [
@@ -39,4 +43,4 @@ curl -X POST -H "Content-Type: application/json" -d '{
39
43
  "pretext": "'"$MESSAGE"'"
40
44
  }
41
45
  ]
42
- }' "$DEVELOPERS_SLACK_WEBHOOK"
46
+ }' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1
@@ -16,28 +16,42 @@ steps:
16
16
  commands:
17
17
  - infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
18
18
 
19
- release:
19
+ build:
20
20
  image: node:20
21
21
  when:
22
22
  - event: push
23
- volumes:
24
- - /var/run/docker.sock:/var/run/docker.sock
25
23
  commands:
26
- # install rsync
27
24
  - apt update && apt install -y rsync
28
- - export $(cat /woodpecker/deploy.vault.env | xargs)
25
+ - . /woodpecker/deploy.vault.env
29
26
  - npm clean-install
30
27
  - /bin/bash ./.woodpecker/buildRelease.sh
31
28
  - npm audit signatures
29
+
30
+ release:
31
+ image: node:20
32
+ when:
33
+ - event:
34
+ - push
35
+ branch:
36
+ - main
37
+ commands:
38
+ - . /woodpecker/deploy.vault.env
32
39
  - npx semantic-release
33
40
 
34
41
  slack-on-failure:
42
+ image: curlimages/curl
35
43
  when:
36
44
  - event: push
37
- status: [failure, success]
38
- - event: push
45
+ status: [failure]
46
+ commands:
47
+ - . /woodpecker/deploy.vault.env
48
+ - /bin/sh ./.woodpecker/buildSlackNotify.sh failure
49
+
50
+ slack-on-success:
39
51
  image: curlimages/curl
52
+ when:
53
+ - event: push
54
+ status: [success]
40
55
  commands:
41
- - export $(cat /woodpecker/deploy.vault.env | xargs)
42
- - /bin/sh ./.woodpecker/buildSlackNotify.sh
43
-
56
+ - . /woodpecker/deploy.vault.env
57
+ - /bin/sh ./.woodpecker/buildSlackNotify.sh success
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import path from 'path';
14
14
  import fs from 'fs-extra';
15
15
  import chokidar from 'chokidar';
16
16
  import { AsyncQueue } from '@sapphire/async-queue';
17
+ import getFlagEmoji from 'country-flag-svg';
17
18
  const processFrontendMessagesQueue = new AsyncQueue();
18
19
  const SLAVIC_PLURAL_EXAMPLES = {
19
20
  uk: 'яблук | Яблуко | Яблука | Яблук', // zero | singular | 2-4 | 5+
@@ -788,14 +789,15 @@ export default class I18nPlugin extends AdminForthPlugin {
788
789
  }
789
790
  languagesList() {
790
791
  return __awaiter(this, void 0, void 0, function* () {
791
- return this.options.supportedLanguages.map((lang) => {
792
+ return Promise.all(this.options.supportedLanguages.map((lang) => __awaiter(this, void 0, void 0, function* () {
792
793
  return {
793
794
  code: lang,
794
795
  nameOnNative: iso6391.getNativeName(getPrimaryLanguageCode(lang)),
795
796
  nameEnglish: iso6391.getName(getPrimaryLanguageCode(lang)),
796
797
  emojiFlag: getCountryCodeFromLangCode(lang).toUpperCase().replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)),
798
+ svgFlagB64: yield getFlagEmoji.default(getCountryCodeFromLangCode(lang)),
797
799
  };
798
- });
800
+ })));
799
801
  });
800
802
  }
801
803
  feedCategoryTranslations(messages, category) {
package/index.ts CHANGED
@@ -7,6 +7,7 @@ import path from 'path';
7
7
  import fs from 'fs-extra';
8
8
  import chokidar from 'chokidar';
9
9
  import { AsyncQueue } from '@sapphire/async-queue';
10
+ import getFlagEmoji from 'country-flag-svg';
10
11
 
11
12
 
12
13
  const processFrontendMessagesQueue = new AsyncQueue();
@@ -922,15 +923,17 @@ export default class I18nPlugin extends AdminForthPlugin {
922
923
  nameOnNative: string;
923
924
  nameEnglish: string;
924
925
  emojiFlag: string;
926
+ svgFlagB64: string;
925
927
  }[]> {
926
- return this.options.supportedLanguages.map((lang) => {
928
+ return Promise.all(this.options.supportedLanguages.map(async (lang) => {
927
929
  return {
928
930
  code: lang,
929
931
  nameOnNative: iso6391.getNativeName(getPrimaryLanguageCode(lang)),
930
932
  nameEnglish: iso6391.getName(getPrimaryLanguageCode(lang)),
931
933
  emojiFlag: getCountryCodeFromLangCode(lang).toUpperCase().replace(/./g, char => String.fromCodePoint(char.charCodeAt(0) + 127397)),
934
+ svgFlagB64: await (getFlagEmoji as any).default(getCountryCodeFromLangCode(lang)),
932
935
  };
933
- });
936
+ }));
934
937
  }
935
938
 
936
939
  async feedCategoryTranslations(messages: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "1.6.7",
3
+ "version": "1.7.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -31,6 +31,7 @@
31
31
  "@aws-sdk/client-ses": "^3.654.0",
32
32
  "@sapphire/async-queue": "^1.5.5",
33
33
  "chokidar": "^4.0.1",
34
+ "country-flag-svg": "^1.0.19",
34
35
  "fs-extra": "^11.3.2",
35
36
  "iso-3166": "^4.3.0",
36
37
  "iso-639-1": "^3.1.3"