create-mirta 0.3.5 → 0.4.4

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.
Files changed (103) hide show
  1. package/dist/classic.mjs +120 -0
  2. package/dist/index.mjs +800 -690
  3. package/dist/mono.mjs +208 -0
  4. package/dist/resolver.mjs +856 -0
  5. package/locales/en-US.json +109 -0
  6. package/locales/ru-RU.json +109 -0
  7. package/package.json +25 -22
  8. package/templates/classic/starter/content/package.json +15 -0
  9. package/{dist/templates/config/typescript → templates/classic/starter/content}/tsconfig.json +0 -5
  10. package/{dist/templates/eslint/eslint.config.mjs.ejs → templates/classic/starter/features/eslint/eslint.config.mjs.tt} +11 -6
  11. package/{dist/templates/base/_env → templates/classic/starter/features/examples/_.env} +1 -1
  12. package/templates/classic/starter/features/examples/src/wb-rules/01-counter.ts +12 -0
  13. package/templates/classic/starter/features/examples/src/wb-rules-modules/counter.ts +36 -0
  14. package/templates/classic/starter/features/examples-vitest/tests/wb-rules-modules/counter.test.ts +44 -0
  15. package/templates/classic/starter/template.json +9 -0
  16. package/{dist/templates/config/store → templates/classic/store/content}/package.json +1 -1
  17. package/templates/classic/store/features/examples/src/wb-rules/01-counter.ts +13 -0
  18. package/templates/classic/store/features/examples/src/wb-rules/02-counter.ts +19 -0
  19. package/templates/classic/store/features/examples/src/wb-rules-modules/counter-store.ts +33 -0
  20. package/templates/classic/store/features/examples/src/wb-rules-modules/counter.ts +44 -0
  21. package/templates/classic/store/features/examples-vitest/tests/wb-rules-modules/counter.test.ts +49 -0
  22. package/templates/classic/store/template.json +14 -0
  23. package/templates/mono/core/content/package.json +6 -0
  24. package/templates/mono/core/content/pnpm-workspace.yaml +3 -0
  25. package/templates/mono/core/content/sites/.gitkeep +0 -0
  26. package/templates/mono/core/content/tsconfig.json +31 -0
  27. package/templates/mono/core/features/eslint/eslint.config.mjs.tt +126 -0
  28. package/templates/mono/core/template.json +5 -0
  29. package/templates/mono/package/content/package.json +6 -0
  30. package/templates/mono/package/features/package/packages/{{package}}/package.json.tt +28 -0
  31. package/templates/mono/package/features/package/packages/{{package}}/src/.gitkeep +0 -0
  32. package/templates/mono/package/features/package/packages/{{package}}/tsconfig.build.json +10 -0
  33. package/templates/mono/package/features/package/sites/{{package}}-demo/package.json.tt +19 -0
  34. package/templates/mono/package/features/package/sites/{{package}}-demo/src/wb-rules/.gitkeep +0 -0
  35. package/templates/mono/package/features/package/sites/{{package}}-demo/src/wb-rules-modules/.gitkeep +0 -0
  36. package/templates/mono/package/features/package/sites/{{package}}-demo/tsconfig.build.json +10 -0
  37. package/templates/mono/package/features/package-examples/packages/{{package}}/src/index.ts +2 -0
  38. package/templates/mono/package/features/package-examples/packages/{{package}}/src/thermostat.ts +99 -0
  39. package/templates/mono/package/features/package-examples/packages/{{package}}/src/types.ts +25 -0
  40. package/templates/mono/package/features/package-examples/sites/{{package}}-demo/src/wb-rules/01-thermo.ts.tt +11 -0
  41. package/templates/mono/package/features/package-examples-vitest/packages/{{package}}/tests/mirta-thermostat.test.ts +72 -0
  42. package/templates/mono/package/features/package-github/packages/{{package}}/package.json.tt +11 -0
  43. package/templates/mono/package/template.json +16 -0
  44. package/templates/mono/sites/content/mirta.config.json +37 -0
  45. package/templates/mono/sites/content/package.json +6 -0
  46. package/templates/mono/sites/content/sites/home/package.json +17 -0
  47. package/templates/mono/sites/content/sites/home/src/wb-rules/.gitkeep +0 -0
  48. package/templates/mono/sites/content/sites/home/src/wb-rules-modules/.gitkeep +0 -0
  49. package/templates/mono/sites/content/sites/home-staging/package.json +17 -0
  50. package/templates/mono/sites/content/sites/home-staging/src/wb-rules/.gitkeep +0 -0
  51. package/templates/mono/sites/content/sites/home-staging/src/wb-rules-modules/.gitkeep +0 -0
  52. package/templates/mono/sites/features/examples/sites/home/package.json +17 -0
  53. package/templates/mono/sites/features/examples/sites/home/src/wb-rules/01-startup.ts +1 -0
  54. package/templates/mono/sites/features/examples/sites/home/src/wb-rules-modules/.gitkeep +0 -0
  55. package/templates/mono/sites/features/examples/sites/home-staging/package.json +17 -0
  56. package/templates/mono/sites/features/examples/sites/home-staging/src/wb-rules/01-startup.ts +1 -0
  57. package/templates/mono/sites/features/examples/sites/home-staging/src/wb-rules-modules/.gitkeep +0 -0
  58. package/templates/mono/sites/template.json +4 -0
  59. package/{dist/templates/base/_editorconfig → templates/shared/base/content/_.editorconfig} +1 -1
  60. package/{dist/templates/base/_gitignore → templates/shared/base/content/_.gitignore} +1 -3
  61. package/templates/shared/base/content/_.node-version +1 -0
  62. package/{dist/templates/base/.vscode → templates/shared/base/content/_.vscode}/settings.json +12 -1
  63. package/templates/shared/base/content/package.json +19 -0
  64. package/templates/shared/base/features/connection/_.env.local.tt +1 -0
  65. package/templates/shared/base/features/connection/mirta.config.json +6 -0
  66. package/templates/shared/base/features/eslint/package.json +9 -0
  67. package/templates/shared/base/features/examples/mirta.config.json.tt +51 -0
  68. package/templates/shared/base/features/github/_.github/workflows/build.yml.tt +56 -0
  69. package/templates/shared/base/features/github-vitest/_.github/workflows/test.yml +30 -0
  70. package/templates/shared/base/features/vitest/package.json +10 -0
  71. package/templates/shared/base/features/vitest-eslint/package.json +5 -0
  72. package/templates/shared/base/template.json +17 -0
  73. package/dist/locales/en-US.json +0 -85
  74. package/dist/locales/ru-RU.json +0 -86
  75. package/dist/templates/base/package.json +0 -27
  76. package/dist/templates/base/rollup.config.mjs +0 -15
  77. package/dist/templates/config/typescript/package.json +0 -8
  78. package/dist/templates/config/vitest/package.json +0 -10
  79. package/dist/templates/config/vitest/tests/setup/dotenv.ts +0 -5
  80. package/dist/templates/config/vitest/tests/setup/mirta.ts +0 -41
  81. package/dist/templates/config/vitest/tests/tsconfig.json +0 -9
  82. package/dist/templates/config/vitest/vitest.config.ts +0 -37
  83. package/dist/templates/example/base/src/wb-rules/00-dotenv.ts +0 -52
  84. package/dist/templates/example/base/src/wb-rules/01-count.ts +0 -6
  85. package/dist/templates/example/base/src/wb-rules-modules/counter.ts +0 -14
  86. package/dist/templates/example/store/src/wb-rules/01-count.ts +0 -10
  87. package/dist/templates/example/store/src/wb-rules-modules/counter-store.ts +0 -7
  88. package/dist/templates/example/store/src/wb-rules-modules/counter.ts +0 -20
  89. package/dist/templates/example/vitest/base/tests/wb-rules-modules/counter.test.ts +0 -10
  90. package/dist/templates/example/vitest/store/tests/wb-rules-modules/counter-store.test.ts +0 -13
  91. /package/{dist/assets → assets}/logo.art +0 -0
  92. /package/{dist/templates/base → templates/classic/starter/content}/src/wb-rules/.gitkeep +0 -0
  93. /package/{dist/templates/base → templates/classic/starter/content}/src/wb-rules-modules/.gitkeep +0 -0
  94. /package/{dist/templates/base → templates/classic/starter/content}/types/env.d.ts +0 -0
  95. /package/{dist/templates/config → templates/classic/starter/features}/vitest/tests/wb-rules-modules/.gitkeep +0 -0
  96. /package/{dist/templates/base/_gitattributes → templates/shared/base/content/_.gitattributes} +0 -0
  97. /package/{dist/templates/base/_npmrc → templates/shared/base/content/_.npmrc} +0 -0
  98. /package/{dist/templates/base/.vscode → templates/shared/base/content/_.vscode}/extensions.json +0 -0
  99. /package/{dist/templates/base/.vscode → templates/shared/base/content/_.vscode}/tasks.json +0 -0
  100. /package/{dist/templates/config/eslint/.vscode → templates/shared/base/features/eslint/_.vscode}/extensions.json +0 -0
  101. /package/{dist/templates/config/eslint/.vscode → templates/shared/base/features/eslint/_.vscode}/settings.json +0 -0
  102. /package/{dist/templates/config/vitest/.vscode → templates/shared/base/features/vitest/_.vscode}/extensions.json +0 -0
  103. /package/{dist/templates/config → templates/shared/base/features}/vitest/tsconfig.json +0 -0
@@ -15,10 +15,8 @@ coverage
15
15
 
16
16
  # dotenv environment variable files
17
17
  .env
18
- .env.development.local
19
- .env.test.local
20
- .env.production.local
21
18
  .env.local
19
+ .env.*.local
22
20
 
23
21
  # Editor directories and files
24
22
  .vscode/*
@@ -0,0 +1 @@
1
+ 24.12.0
@@ -1,5 +1,14 @@
1
1
  {
2
2
  "files.eol": "\n",
3
+ "files.associations": {
4
+ "mirta.config.json": "jsonc"
5
+ },
6
+ "json.schemas": [{
7
+ "fileMatch": ["mirta.config.json"],
8
+ "schema": {
9
+ "allowTrailingCommas": true
10
+ }
11
+ }],
3
12
  "task.autoDetect": "off",
4
13
  "todohighlight.keywords": [
5
14
  {
@@ -37,5 +46,7 @@
37
46
  "cursor": "pointer",
38
47
  "fontWeight": "bold",
39
48
  "borderRadius": "2px"
40
- }
49
+ },
50
+ "npm.packageManager": "pnpm",
51
+ "npm.scriptRunner": "pnpm"
41
52
  }
@@ -0,0 +1,19 @@
1
+ {
2
+ "private": true,
3
+ "type": "module",
4
+ "scripts": {},
5
+ "dependencies": {},
6
+ "devDependencies": {
7
+ "@mirta/cli": "0.4.4",
8
+ "@mirta/globals": "0.4.4",
9
+ "@mirta/rollup": "0.4.4",
10
+ "@mirta/tsconfig": "0.4.4",
11
+ "@types/node": "^24.10.1",
12
+ "cross-env": "^10.1.0",
13
+ "rollup": "^4.55.1",
14
+ "typescript": "^5.8.3"
15
+ },
16
+ "engines": {
17
+ "node": ">=24.12.0"
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ WB_CONN_SECRET={{connectionString}}
@@ -0,0 +1,6 @@
1
+ {
2
+ "connections": {
3
+ // Строка подключения находится в файле .env.local
4
+ "default": "${WB_CONN_SECRET}"
5
+ }
6
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "devDependencies": {
3
+ "@eslint/js": "^9.39.2",
4
+ "@stylistic/eslint-plugin": "^5.6.1",
5
+ "eslint": "^9.39.2",
6
+ "globals": "^17.0.0",
7
+ "typescript-eslint": "^8.49.0"
8
+ }
9
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "connections": {
3
+ "default": "{{defaultConnectionString}}"
4
+ },
5
+ "deploy": {
6
+ // Наборы правил копирования файлов: из папки проекта в папку контроллера.
7
+ "mappings": {
8
+ // Стандартный набор для wb-rules под Duktape на ES5.
9
+ "wb-rules-es5": [
10
+ // Копирование модулей.
11
+ {
12
+ "from": "dist/es5/wb-rules-modules/",
13
+ "to": "/mnt/data/etc/wb-rules-modules/",
14
+
15
+ // Очистить целевое расположение от других файлов.
16
+ "cleanup": true
17
+ },
18
+ // Копирование скриптов.
19
+ {
20
+ "from": "dist/es5/wb-rules/",
21
+ "to": "/mnt/data/etc/wb-rules/",
22
+
23
+ // Очистить целевое расположение от других файлов.
24
+ "cleanup": true,
25
+
26
+ // Предотвратить очистку для указанных файлов, они останутся.
27
+ // Можно использовать wildcard.
28
+ "protect": ["alarms.conf"]
29
+ }
30
+ ],
31
+ // Расширенный набор: добавляем ещё и шаблоны устройств.
32
+ "templates": [
33
+ {
34
+ "from": "templates/",
35
+ "to": "/etc/wb-mqtt-serial.conf.d/templates/",
36
+
37
+ // Существующие шаблоны не удаляем.
38
+ "cleanup": false
39
+ }
40
+ ]
41
+ },
42
+ // Профили деплоя.
43
+ "profiles": {
44
+ // Встроенный профиль (здесь переопределён явно)
45
+ "default": {
46
+ "connection": "default",
47
+ "mappings": ["wb-rules-es5"]
48
+ }
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,56 @@
1
+ name: Build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - {{githubBranch}}
7
+ pull_request:
8
+ branches:
9
+ - {{githubBranch}}
10
+
11
+ jobs:
12
+ {{#if features.vitest}}
13
+ test:
14
+ if: ${{ !startsWith(github.event.head_commit.message, 'release') }}
15
+ uses: ./.github/workflows/test.yml
16
+ {{/if features.vitest}}
17
+ build:
18
+ # Prevents this action from running on forks.
19
+ if: github.repository == '{{githubOwner}}/{{githubRepository}}'
20
+ {{#if features.vitest}}
21
+ needs: test
22
+ {{/if features.vitest}}
23
+ runs-on: ubuntu-latest
24
+ timeout-minutes: 5
25
+ steps:
26
+ - name: Checkout
27
+ uses: actions/checkout@v6
28
+
29
+ - name: Install pnpm
30
+ uses: pnpm/action-setup@v4
31
+
32
+ - name: Install Node.js
33
+ uses: actions/setup-node@v6
34
+ with:
35
+ node-version-file: '.node-version'
36
+ cache: 'pnpm'
37
+
38
+ - name: Install Dependencies
39
+ run: pnpm install
40
+
41
+ - name: Build
42
+ run: pnpm build
43
+ {{#if templates.packages}}
44
+ - name: Continuous Release
45
+ # Prevents this step from running on pull requests.
46
+ # Runs only when commit message starts with 'fix' or 'feat'.
47
+ if: |
48
+ github.event_name == 'push' && (
49
+ startsWith(github.event.head_commit.message, 'fix') ||
50
+ startsWith(github.event.head_commit.message, 'feat')
51
+ )
52
+ # NOTE: --compact is temporarily removed
53
+ # because some packages in ./packages/* are not yet published to npm.
54
+ # It will be re-enabled once all packages are published or we add filtering.
55
+ run: pnpx pkg-pr-new publish --pnpm './packages/*' --template './sites/*'
56
+ {{/if templates.packages}}
@@ -0,0 +1,30 @@
1
+ name: Test
2
+
3
+ on: workflow_call
4
+
5
+ permissions:
6
+ contents: read # To fetch code (actions/checkout)
7
+
8
+ jobs:
9
+ test:
10
+ name: Run Tests
11
+ runs-on: ubuntu-latest
12
+ timeout-minutes: 5
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v6
16
+
17
+ - name: Install pnpm
18
+ uses: pnpm/action-setup@v4
19
+
20
+ - name: Install Node.js
21
+ uses: actions/setup-node@v6
22
+ with:
23
+ node-version-file: '.node-version'
24
+ cache: 'pnpm'
25
+
26
+ - name: Install dependencies
27
+ run: pnpm install
28
+
29
+ - name: Run tests
30
+ run: pnpm run test
@@ -0,0 +1,10 @@
1
+ {
2
+ "scripts": {
3
+ "test": "vitest run --config @mirta/testing/config"
4
+ },
5
+ "devDependencies": {
6
+ "@mirta/testing": "0.4.4",
7
+ "vitest": "^4.0.8",
8
+ "vitest-mock-extended": "^3.1.0"
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "devDependencies": {
3
+ "@vitest/eslint-plugin": "^1.6.4"
4
+ }
5
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "hidden": true,
3
+ "features": {
4
+ "global": {
5
+ "examples": "recommended",
6
+ "connection": "recommended",
7
+ "eslint": "recommended",
8
+ "vitest": "optional",
9
+ "github": "optional"
10
+ },
11
+ "compound": [
12
+ "github-vitest",
13
+ "vitest-eslint"
14
+ ]
15
+ },
16
+ "order": 0
17
+ }
@@ -1,85 +0,0 @@
1
- {
2
- "title": "The Framework to write wb-rules in TypeScript",
3
- "captions": {
4
- "intro": "Project Settings",
5
- "deploy": "Deploy Settings"
6
- },
7
- "projectName": {
8
- "message": "Project Name (target directory):"
9
- },
10
- "packageName": {
11
- "message": "Package name:",
12
- "errorMessage": "Format is not valid"
13
- },
14
- "shouldOverwrite": {
15
- "directory": {
16
- "current": "Current directory",
17
- "target": "Target directory"
18
- },
19
- "message": "is not empty.",
20
- "confirmDelete": "Remove existing files before continue?"
21
- },
22
- "ssh": {
23
- "username": "🔑 SSH Username:",
24
- "host": "🌐 SSH Host:",
25
- "port": "🚩 SSH Port:",
26
- "useRutoken": "Use Rutoken ECP"
27
- },
28
- "featureSelection": {
29
- "message": "Select features to include in your project:",
30
- "hint": "↑/↓ to navigate, space to select, A to toggle all, Enter to confirm"
31
- },
32
- "addEslint": {
33
- "message": "ESLint",
34
- "hint": "error prevention"
35
- },
36
- "addVitest": {
37
- "message": "Mirta Testing",
38
- "hint": "Vitest, unit-testing and simulations"
39
- },
40
- "addStore": {
41
- "message": "Mirta Store",
42
- "hint": "state management"
43
- },
44
- "validation": {
45
- "required": "Must be provided"
46
- },
47
- "status": {
48
- "success": "Success",
49
- "error": "Error",
50
- "canceled": "Canceled",
51
- "scaffolding": "Scaffolding project in",
52
- "scaffolded": "The project has been scaffolded",
53
- "installingDependencies": "Calling the package manager"
54
- },
55
- "accent": {
56
- "recommended": "(recommended)",
57
- "ifConfigured": "(if configured)"
58
- },
59
- "dependencies": {
60
- "question": "Install project dependencies?",
61
- "current": {
62
- "message": "Yes, use"
63
- },
64
- "pnpm": {
65
- "message": "Yes, use PNPM",
66
- "hint": "recommended"
67
- },
68
- "yarn": {
69
- "message": "Yes, use Yarn"
70
- },
71
- "npm": {
72
- "message": "Yes, use NPM"
73
- },
74
- "bun": {
75
- "message": "Yes, use Bun"
76
- },
77
- "no": {
78
- "message": "No, I will handle that myself"
79
- }
80
- },
81
- "errors": {
82
- "operationCanceled": "Operation canceled",
83
- "rootIsNotRelative": "Location is out of working directory"
84
- }
85
- }
@@ -1,86 +0,0 @@
1
- {
2
- "title": "Фреймворк для создания правил wb-rules на TypeScript",
3
- "captions": {
4
- "intro": "Параметры проекта",
5
- "deploy": "Параметры деплоя на контроллер"
6
- },
7
- "projectName": {
8
- "message": "Название (целевая директория):",
9
- "errorMessage": "Требуется указать значение"
10
- },
11
- "packageName": {
12
- "message": "Название пакета:",
13
- "errorMessage": "Недопустимый формат ввода"
14
- },
15
- "shouldOverwrite": {
16
- "directory": {
17
- "current": "Текущая директория",
18
- "target": "Указанная директория"
19
- },
20
- "message": "содержит файлы.",
21
- "confirmDelete": "Удалить их?"
22
- },
23
- "ssh": {
24
- "username": "🔑 Пользователь SSH:",
25
- "host": "🌐 Хост SSH:",
26
- "port": "🚩 Порт SSH:",
27
- "useRutoken": "Использовать Рутокен ЭЦП?"
28
- },
29
- "featureSelection": {
30
- "message": "Выберите добавляемый функционал:",
31
- "hint": "↑/↓ для навигации, пробел для выбора, A - выбрать всё, Enter - подтвердить"
32
- },
33
- "addEslint": {
34
- "message": "ESLint",
35
- "hint": "предотвращение потенциальных проблем в коде"
36
- },
37
- "addVitest": {
38
- "message": "Mirta Testing",
39
- "hint": "Юнит-тесты и имитатор запуска на контроллере"
40
- },
41
- "addStore": {
42
- "message": "Mirta Store",
43
- "hint": "хранилище состояний"
44
- },
45
- "validation": {
46
- "required": "Требуется указать значение"
47
- },
48
- "status": {
49
- "success": "Успешно",
50
- "error": "Ошибка",
51
- "canceled": "Отменено",
52
- "scaffolding": "Генерация файлов проекта в",
53
- "scaffolded": "Проект создан",
54
- "installingDependencies": "Вызов менеджера пакетов"
55
- },
56
- "accent": {
57
- "recommended": "(рекомендуется)",
58
- "ifConfigured": "(если настроен)"
59
- },
60
- "dependencies": {
61
- "question": "Установить требуемые зависимости?",
62
- "current": {
63
- "message": "Да, используя"
64
- },
65
- "pnpm": {
66
- "message": "Да, используя pnpm",
67
- "hint": "рекомендуется"
68
- },
69
- "yarn": {
70
- "message": "Да, используя yarn"
71
- },
72
- "npm": {
73
- "message": "Да, используя npm"
74
- },
75
- "bun": {
76
- "message": "Да, используя bun"
77
- },
78
- "no": {
79
- "message": "Нет, разберусь с этим самостоятельно"
80
- }
81
- },
82
- "errors": {
83
- "operationCanceled": "Операция прервана",
84
- "rootIsNotRelative": "Расположение находится вне рабочей директории"
85
- }
86
- }
@@ -1,27 +0,0 @@
1
- {
2
- "private": true,
3
- "engines": {
4
- "node": ">=20.6.0"
5
- },
6
- "type": "module",
7
- "imports": {
8
- "#wb/*": [
9
- "./src/wb-rules/*.js"
10
- ],
11
- "#wbm/*": [
12
- "./src/wb-rules-modules/*.js"
13
- ]
14
- },
15
- "scripts": {
16
- "build": "cross-env NODE_ENV=production rollup -c",
17
- "build:dev": "cross-env NODE_ENV=development rollup -c"
18
- },
19
- "dependencies": {
20
- "mirta": "0.3.5"
21
- },
22
- "devDependencies": {
23
- "@mirta/rollup": "0.3.5",
24
- "cross-env": "^10.1.0",
25
- "rollup": "^4.52.4"
26
- }
27
- }
@@ -1,15 +0,0 @@
1
- import { defineConfig } from '@mirta/rollup'
2
-
3
- export default defineConfig({
4
- dotenv: {
5
- /**
6
- * При использовании префикса, переменные
7
- * окружения будут отфильтрованы по нему.
8
- *
9
- * Например, префиксу APP_ соответствует
10
- * переменная окружения APP_NAME.
11
- *
12
- **/
13
- prefix: '^APP_',
14
- },
15
- })
@@ -1,8 +0,0 @@
1
- {
2
- "devDependencies": {
3
- "@mirta/globals": "0.3.5",
4
- "@mirta/tsconfig": "0.3.5",
5
- "@types/node": "^24.9.1",
6
- "typescript": "^5.8.3"
7
- }
8
- }
@@ -1,10 +0,0 @@
1
- {
2
- "scripts": {
3
- "test": "vitest run"
4
- },
5
- "devDependencies": {
6
- "@mirta/testing": "0.3.5",
7
- "vitest": "^3.2.4",
8
- "vitest-mock-extended": "^3.1.0"
9
- }
10
- }
@@ -1,5 +0,0 @@
1
- import { env as dotenv } from '@dotenv-run/core'
2
-
3
- dotenv({
4
- prefix: '^APP_',
5
- })
@@ -1,41 +0,0 @@
1
- import { vi } from 'vitest'
2
- import { mock } from 'vitest-mock-extended'
3
-
4
- // Базовая (подавляющая) имитация API движка wb-rules.
5
- // Для каждого файла с тестами этот код выполняется заново.
6
- //
7
- // Используется с целью перехвата и подавления обращений
8
- // к отсутствующим на компьютере функциям контроллера.
9
- //
10
- // В файлах тестов можно переопределить поведение подавления
11
- // на выдачу заготовленного ответа. Пригодится для симуляции
12
- // внештатных ситуаций и оценки работы алгоритма
13
- // в этих условиях.
14
-
15
- const createLogger = () => {
16
-
17
- const logger = vi.fn() as unknown as WbRules.Log
18
-
19
- logger.info = vi.fn()
20
- logger.debug = vi.fn()
21
- logger.warning = vi.fn()
22
- logger.error = vi.fn()
23
-
24
- return logger
25
-
26
- }
27
-
28
- global.module = mock<NodeJS.Module>()
29
-
30
- global.log = createLogger()
31
- global.debug = vi.fn() as WbRules.Debug
32
- global.dev = mock<WbRules.Dev>()
33
- global.defineVirtualDevice = vi.fn()
34
- global.getDevice = vi.fn(() => mock<WbRules.Device>({
35
- getControl: () => mock<WbRules.Control>(),
36
- }))
37
- global.getControl = vi.fn()
38
- global.trackMqtt = vi.fn()
39
- global.defineRule = vi.fn()
40
- global.Notify = mock<WbRules.Notify>()
41
- global.Alarms = mock<WbRules.Alarms>()
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "paths": {
5
- "@wb/*": ["../src/wb-rules/*"],
6
- "@wbm/*": ["../src/wb-rules-modules/*"]
7
- }
8
- }
9
- }
@@ -1,37 +0,0 @@
1
- import { defineConfig } from 'vitest/config'
2
- import { fileURLToPath } from 'node:url'
3
-
4
- export default defineConfig({
5
- define: {
6
- __DEV__: true,
7
- __TEST__: true,
8
- },
9
- resolve: {
10
- alias: [
11
- {
12
- find: /^@wb\/(.*?)$/,
13
- replacement: fileURLToPath(
14
- new URL('./src/wb-rules/$1', import.meta.url)
15
- ),
16
- },
17
- {
18
- find: /^@wbm\/(.*?)$/,
19
- replacement: fileURLToPath(
20
- new URL('./src/wb-rules-modules/$1', import.meta.url)
21
- ),
22
- },
23
- ],
24
- },
25
- test: {
26
- globals: true,
27
- include: ['tests/**/*.{test,spec}.[jt]s'],
28
- setupFiles: [
29
- fileURLToPath(
30
- new URL('./tests/setup/dotenv.ts', import.meta.url)
31
- ),
32
- fileURLToPath(
33
- new URL('./tests/setup/mirta.ts', import.meta.url)
34
- ),
35
- ],
36
- },
37
- })
@@ -1,52 +0,0 @@
1
- /**
2
- * @file Пример использования переменных окружения.
3
- *
4
- * Для типизации используется файл `types/env.d.ts`
5
- *
6
- * Значение каждой переменной определяется в специальных
7
- * файлах формата `.env`. Эти файлы хранятся отдельно от
8
- * основного исходного кода, что предотвращает случайную
9
- * утечку секретных данных в публичные репозитории.
10
- *
11
- * Основные файлы конфигурации включают:
12
- * .env
13
- * .env.local
14
- * .env.[mode].local
15
- *
16
- * Значение [mode] принимает `development`, `test` или `production`.
17
- *
18
- * Команда build:dev первым делом заглядывает
19
- * в файл `.env.development.local`
20
- *
21
- * Команда build обращается к значениям
22
- * в файле `.env.production.local`
23
- *
24
- * Юнит-тесты используют `.env.test.local`
25
- *
26
- * Если в обозначенных местах не обнаружилось искомых ключевых пар,
27
- * поиск выполняется поочерёдно в файлах `.env.local` и `.env`
28
- *
29
- * Примечание: переменные окружения
30
- * допускается передавать через командную строку - обратите
31
- * внимание на использование cross-env в package.json
32
- *
33
- * @since 0.2.1
34
- *
35
- **/
36
-
37
- // Условие выполнится только при сборке
38
- // командой `build:dev` (в режиме development).
39
- //
40
- // Если собрать проект
41
- // командой `build` (в режиме production),
42
- // код этого блока не попадёт на контроллер.
43
- //
44
- // Более того, поскольку других конструкций в скрипте нет,
45
- // то и сам скрипт не появится в каталоге dist.
46
- //
47
- if (__DEV__) {
48
-
49
- // Выводим приветствие, подставляя название из переменной окружения.
50
- log(`Hello from ${process.env.APP_NAME}`)
51
-
52
- }
@@ -1,6 +0,0 @@
1
- import { useCounter } from '#wbm/counter'
2
-
3
- const counter = useCounter()
4
-
5
- counter.increment()
6
- log(`Current Value: ${counter.count}`)
@@ -1,14 +0,0 @@
1
- export function useCounter() {
2
-
3
- let count = 0
4
-
5
- return {
6
- get count() {
7
- return count
8
- },
9
- increment() {
10
- count += 1
11
- }
12
- }
13
-
14
- }