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
@@ -0,0 +1,120 @@
1
+ import fs from 'node:fs/promises';
2
+ import chalk from 'chalk';
3
+ import { a as assertNoParseErrors, l as logger, t, c as clearDirAsync, i as isExistsAsync } from './index.mjs';
4
+ import { r as resolveFeaturesAsync, t as toTemplateData, a as resolveGithubInfoAsync, b as resolveConnectionStringAsync, c as renderDirectoryAsync, p as promptInstallDependenciesAsync, D as DEFAULT_SSH_USERNAME, d as DEFAULT_SSH_HOSTNAME } from './resolver.mjs';
5
+ import '../package.json' with { type: 'json' };
6
+ import '@mirta/staged-args';
7
+ import '@mirta/i18n';
8
+ import 'node:path';
9
+ import 'node:fs';
10
+ import 'gradient-string';
11
+ import 'prompts';
12
+ import '@mirta/basics';
13
+ import 'jsonc-parser';
14
+ import 'node:child_process';
15
+
16
+ // Опции классического режима сборки
17
+ const options = {
18
+ eslint: {
19
+ type: 'boolean',
20
+ },
21
+ vitest: {
22
+ type: 'boolean',
23
+ },
24
+ ssh: {
25
+ type: 'string',
26
+ },
27
+ rutoken: {
28
+ type: 'boolean',
29
+ },
30
+ };
31
+ /**
32
+ * Парсит аргументы командной строки для сборки в режиме `classic`.
33
+ *
34
+ * @param args - Объект с аргументами, управляемый `StagedArgs`.
35
+ * @returns Объект с распарсенными значениями и позиционными аргументами.
36
+ *
37
+ * @since 0.4.0
38
+ *
39
+ **/
40
+ function parseArgs(args) {
41
+ const parseResult = args.parseFinal(options);
42
+ assertNoParseErrors(parseResult);
43
+ const { values, positionals } = parseResult.data;
44
+ return {
45
+ values,
46
+ positionals,
47
+ };
48
+ }
49
+
50
+ async function runAsync(args, context) {
51
+ const { values: argv } = parseArgs(args);
52
+ const { rootDir } = context;
53
+ // Дополнительный функционал, который будет задействован.
54
+ const features = await resolveFeaturesAsync(context, {
55
+ eslint: argv.eslint,
56
+ vitest: argv.vitest,
57
+ connection: argv.ssh,
58
+ });
59
+ const data = toTemplateData({
60
+ name: context.name,
61
+ features: features,
62
+ barebone: context.barebone,
63
+ defaultConnectionString: `ssh://${DEFAULT_SSH_USERNAME}@${DEFAULT_SSH_HOSTNAME}`,
64
+ });
65
+ // Если задействована опция настройки GitHub-репозитория.
66
+ if (features.includes('github')) {
67
+ const githubInfo = await resolveGithubInfoAsync();
68
+ data.githubOwner = githubInfo.owner;
69
+ data.githubRepository = githubInfo.repository;
70
+ data.githubBranch = githubInfo.branch;
71
+ }
72
+ // Если добавлено подключение к контроллеру, выполняем настройку.
73
+ if (features.includes('connection')) {
74
+ data.connectionString
75
+ = await resolveConnectionStringAsync(argv.ssh, argv.rutoken);
76
+ }
77
+ // Удаляем содержимое, если директория существует и получено подтверждение.
78
+ if (context.shouldOverwrite) {
79
+ logger.step(chalk.red(t('step.removingFiles')));
80
+ await clearDirAsync(rootDir);
81
+ }
82
+ // Создаём директорию при её отсутствии.
83
+ else if (context.shouldCreate) {
84
+ await fs.mkdir(rootDir, { recursive: true });
85
+ }
86
+ logger.step(t('step.scaffolding', {
87
+ folder: chalk.yellow(rootDir),
88
+ }));
89
+ const seenCompounds = new Map();
90
+ for (const template of context.templates) {
91
+ await renderDirectoryAsync(`${template.rootDir}/content`, rootDir, data);
92
+ for (const feature of features) {
93
+ const featurePath = `${template.rootDir}/features/${feature}`;
94
+ if (!await isExistsAsync(featurePath))
95
+ continue;
96
+ await renderDirectoryAsync(featurePath, rootDir, data);
97
+ }
98
+ const compoundFeatures = template.features?.compound;
99
+ if (!compoundFeatures)
100
+ continue;
101
+ for (const feature of compoundFeatures) {
102
+ let isApplicable = seenCompounds.get(feature);
103
+ if (isApplicable === undefined) {
104
+ isApplicable = feature
105
+ .split('-')
106
+ .every(x => features.includes(x));
107
+ seenCompounds.set(feature, isApplicable);
108
+ }
109
+ if (!isApplicable)
110
+ continue;
111
+ const featurePath = `${template.rootDir}/features/${feature}`;
112
+ if (!await isExistsAsync(featurePath))
113
+ continue;
114
+ await renderDirectoryAsync(featurePath, rootDir, data);
115
+ }
116
+ }
117
+ await promptInstallDependenciesAsync(rootDir);
118
+ }
119
+
120
+ export { runAsync };