create-template-bricks 0.0.0-stage → 1.0.1

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 (157) hide show
  1. package/README.md +85 -2
  2. package/bin/cli.js +403 -0
  3. package/package.json +49 -4
  4. package/templates/base/.babelrc +18 -0
  5. package/templates/base/.editorconfig +22 -0
  6. package/templates/base/.eslintrc.json +130 -0
  7. package/templates/base/AGENTS.md +49 -0
  8. package/templates/base/README.md +121 -0
  9. package/templates/base/gulpfile.js +46 -0
  10. package/templates/base/package.json +82 -0
  11. package/templates/base/postcss.config.mjs +6 -0
  12. package/templates/base/src/assets/css/vendor/.gitkeep +0 -0
  13. package/templates/base/src/assets/fonts/.gitkeep +0 -0
  14. package/templates/base/src/assets/img/Logo.svg +32 -0
  15. package/templates/base/src/assets/img/favicons/favicon.ico +0 -0
  16. package/templates/base/src/assets/img/sprite/cup-bronze.png +0 -0
  17. package/templates/base/src/assets/img/sprite/cup-bronze@2x.png +0 -0
  18. package/templates/base/src/assets/img/sprite.png +0 -0
  19. package/templates/base/src/assets/img/sprite@2x.png +0 -0
  20. package/templates/base/src/assets/img/svg-sprite/close.svg +3 -0
  21. package/templates/base/src/assets/img/svg-sprite/favorite.svg +3 -0
  22. package/templates/base/src/assets/img/svg-sprite/keyboard.svg +3 -0
  23. package/templates/base/src/assets/js/vendor/.gitkeep +0 -0
  24. package/templates/base/src/styles/core/base.scss +31 -0
  25. package/templates/base/src/styles/core/extends.scss +11 -0
  26. package/templates/base/src/styles/core/fonts.scss +0 -0
  27. package/templates/base/src/styles/core/index.scss +10 -0
  28. package/templates/base/src/styles/core/keyframes.scss +49 -0
  29. package/templates/base/src/styles/core/layouts/footer.scss +1 -0
  30. package/templates/base/src/styles/core/layouts/header/index.scss +1 -0
  31. package/templates/base/src/styles/core/layouts/index.scss +2 -0
  32. package/templates/base/src/styles/core/page.scss +16 -0
  33. package/templates/base/src/styles/core/typography.scss +1 -0
  34. package/templates/base/src/styles/core/ui/icons.scss +31 -0
  35. package/templates/base/src/styles/core/ui/index.scss +2 -0
  36. package/templates/base/src/styles/core/ui/scrollbar.scss +14 -0
  37. package/templates/base/src/styles/core/variables.scss +41 -0
  38. package/templates/base/src/styles/index.scss +1 -0
  39. package/templates/base/src/styles/plugins/functions.scss +0 -0
  40. package/templates/base/src/styles/plugins/media.scss +63 -0
  41. package/templates/base/src/styles/plugins/mixins.scss +31 -0
  42. package/templates/base/src/styles/plugins/sprite-mixin.scss +75 -0
  43. package/templates/base/src/styles/plugins/sprite.scss +154 -0
  44. package/templates/base/src/styles.scss +2 -0
  45. package/templates/base/src/tailwind.css +1 -0
  46. package/templates/base/src/tmplConfig.js +22 -0
  47. package/templates/base/tailwind.config.js +23 -0
  48. package/templates/base/tasks/archive.js +37 -0
  49. package/templates/base/tasks/clean.js +17 -0
  50. package/templates/base/tasks/config.js +98 -0
  51. package/templates/base/tasks/copy.js +53 -0
  52. package/templates/base/tasks/helper.js +31 -0
  53. package/templates/base/tasks/images/image-optimize.js +46 -0
  54. package/templates/base/tasks/images/index.js +27 -0
  55. package/templates/base/tasks/images/plugins/optimize-raster.js +44 -0
  56. package/templates/base/tasks/images/png-sprite.js +43 -0
  57. package/templates/base/tasks/template/data.js +28 -0
  58. package/templates/base/tasks/template/index.js +48 -0
  59. package/templates/base/tasks/template/plugins/generate-static-path.js +37 -0
  60. package/templates/base/tasks/template/plugins/nunjucks-relative-paths-includes.js +39 -0
  61. package/templates/base/tasks/template/plugins/nunjucks-relative-system-loader.js +28 -0
  62. package/templates/base/tasks/template/plugins/template-dependencies.js +246 -0
  63. package/templates/base/tasks/template/template.js +172 -0
  64. package/templates/base/tasks/watcher.js +233 -0
  65. package/templates/base/tasks/webpack/env.js +21 -0
  66. package/templates/base/tasks/webpack/plugins/build-status-plugin.js +74 -0
  67. package/templates/base/tasks/webpack/plugins/current-color-plugin.js +225 -0
  68. package/templates/base/tasks/webpack/plugins/removeFilesOnlyJs.js +28 -0
  69. package/templates/base/tasks/webpack/scripts.config.js +147 -0
  70. package/templates/base/tasks/webpack/styles.config.js +126 -0
  71. package/templates/base/tasks/webpack/svg-sprite.config.js +95 -0
  72. package/templates/base/tasks/webpack/watch.js +50 -0
  73. package/templates/base/tsconfig.json +20 -0
  74. package/templates/base/user.config.js +102 -0
  75. package/templates/base/webpack.config.js +9 -0
  76. package/templates/template-js/js/api/api.js +0 -0
  77. package/templates/template-js/js/core/core.js +56 -0
  78. package/templates/template-js/js/main.js +6 -0
  79. package/templates/template-js/js/modules/header.js +15 -0
  80. package/templates/template-js/js/modules/index.js +24 -0
  81. package/templates/template-js/js/services/index.js +1 -0
  82. package/templates/template-js/js/services/query-params.js +19 -0
  83. package/templates/template-js/js/styles.js +2 -0
  84. package/templates/template-js/js/ui/index.js +18 -0
  85. package/templates/template-js/js/utils/constants.js +0 -0
  86. package/templates/template-js/js/utils/create-factory.js +65 -0
  87. package/templates/template-js/js/utils/debounce.js +8 -0
  88. package/templates/template-js/js/utils/delay.js +4 -0
  89. package/templates/template-js/js/utils/is-platform.js +15 -0
  90. package/templates/template-js/js/utils/throttle.js +16 -0
  91. package/templates/template-mjml/emails/assets/images/address-btn.jpg +0 -0
  92. package/templates/template-mjml/emails/assets/images/address.jpg +0 -0
  93. package/templates/template-mjml/emails/assets/images/banner.jpg +0 -0
  94. package/templates/template-mjml/emails/assets/images/close.png +0 -0
  95. package/templates/template-mjml/emails/assets/images/confirm-btn.jpg +0 -0
  96. package/templates/template-mjml/emails/assets/images/facebook.png +0 -0
  97. package/templates/template-mjml/emails/assets/images/forgot.jpg +0 -0
  98. package/templates/template-mjml/emails/assets/images/icon-info.png +0 -0
  99. package/templates/template-mjml/emails/assets/images/img-send.jpg +0 -0
  100. package/templates/template-mjml/emails/assets/images/instagram.png +0 -0
  101. package/templates/template-mjml/emails/assets/images/logo.png +0 -0
  102. package/templates/template-mjml/emails/assets/images/reset-btn.jpg +0 -0
  103. package/templates/template-mjml/emails/assets/images/twitter.png +0 -0
  104. package/templates/template-mjml/emails/pages/address.mjml +55 -0
  105. package/templates/template-mjml/emails/pages/confirm-resend.mjml +63 -0
  106. package/templates/template-mjml/emails/pages/confirm.mjml +44 -0
  107. package/templates/template-mjml/emails/pages/forgot-password.mjml +65 -0
  108. package/templates/template-mjml/emails/shared/ui/head/fonts.mjml +211 -0
  109. package/templates/template-mjml/emails/shared/ui/head/index.mjml +146 -0
  110. package/templates/template-mjml/emails/widgets/footer/ui/index.mjml +12 -0
  111. package/templates/template-nunjucks/templates/layouts/base.njk +23 -0
  112. package/templates/template-nunjucks/templates/pages/index.njk +9 -0
  113. package/templates/template-nunjucks/templates/shared/ui/head/data.json +8 -0
  114. package/templates/template-nunjucks/templates/shared/ui/head/index.njk +13 -0
  115. package/templates/template-nunjucks/templates/shared/ui/icon/index.njk +5 -0
  116. package/templates/template-nunjucks/templates/widgets/footer/index.njk +5 -0
  117. package/templates/template-nunjucks/templates/widgets/footer/model/data.json +4 -0
  118. package/templates/template-nunjucks/templates/widgets/footer/ui/index.njk +7 -0
  119. package/templates/template-nunjucks/templates/widgets/home-hero/index.njk +1 -0
  120. package/templates/template-nunjucks/templates/widgets/home-hero/ui/index.njk +9 -0
  121. package/templates/template-pug/templates/layouts/base.pug +19 -0
  122. package/templates/template-pug/templates/pages/index.pug +12 -0
  123. package/templates/template-pug/templates/shared/lib/blocks.pug +21 -0
  124. package/templates/template-pug/templates/shared/ui/head/data.json +8 -0
  125. package/templates/template-pug/templates/shared/ui/head/index.pug +10 -0
  126. package/templates/template-pug/templates/shared/ui/icon/index.pug +3 -0
  127. package/templates/template-pug/templates/widgets/footer/index.pug +1 -0
  128. package/templates/template-pug/templates/widgets/footer/model/data.json +4 -0
  129. package/templates/template-pug/templates/widgets/footer/ui/index.pug +4 -0
  130. package/templates/template-pug/templates/widgets/home-hero/index.pug +1 -0
  131. package/templates/template-pug/templates/widgets/home-hero/ui/index.pug +6 -0
  132. package/templates/template-ts/ts/api/api.ts +0 -0
  133. package/templates/template-ts/ts/core/core.ts +66 -0
  134. package/templates/template-ts/ts/interfaces/factory.ts +5 -0
  135. package/templates/template-ts/ts/main.ts +6 -0
  136. package/templates/template-ts/ts/modules/header.ts +17 -0
  137. package/templates/template-ts/ts/modules/index.ts +26 -0
  138. package/templates/template-ts/ts/services/index.ts +2 -0
  139. package/templates/template-ts/ts/services/query-params.ts +23 -0
  140. package/templates/template-ts/ts/styles.ts +2 -0
  141. package/templates/template-ts/ts/ui/index.ts +23 -0
  142. package/templates/template-ts/ts/utils/constants.ts +0 -0
  143. package/templates/template-ts/ts/utils/create-factory.ts +91 -0
  144. package/templates/template-ts/ts/utils/debounce.ts +10 -0
  145. package/templates/template-ts/ts/utils/delay.ts +5 -0
  146. package/templates/template-ts/ts/utils/is-platform.ts +21 -0
  147. package/templates/template-ts/ts/utils/throttle.ts +19 -0
  148. package/templates/template-twig/templates/layouts/base.html.twig +26 -0
  149. package/templates/template-twig/templates/pages/index.html.twig +8 -0
  150. package/templates/template-twig/templates/shared/ui/head/data.json +8 -0
  151. package/templates/template-twig/templates/shared/ui/head/index.html.twig +11 -0
  152. package/templates/template-twig/templates/shared/ui/icon/index.html.twig +21 -0
  153. package/templates/template-twig/templates/widgets/footer/index.html.twig +1 -0
  154. package/templates/template-twig/templates/widgets/footer/model/data.json +4 -0
  155. package/templates/template-twig/templates/widgets/footer/ui/index.html.twig +5 -0
  156. package/templates/template-twig/templates/widgets/home-hero/index.html.twig +1 -0
  157. package/templates/template-twig/templates/widgets/home-hero/ui/index.html.twig +9 -0
package/README.md CHANGED
@@ -1,3 +1,86 @@
1
- # Temporary Holding Version
1
+ Create projects from ready-to-use frontend templates.
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Template-first frontend starter for multipage websites, CMS themes, Symfony views, email templates, and static frontend integration workflows.
4
+
5
+ ## Quick Start
6
+
7
+ Use your preferred package manager:
8
+
9
+ ```bash
10
+ npm create template-bricks@latest
11
+ ```
12
+
13
+ ```bash
14
+ npx create-template-bricks@latest
15
+ ```
16
+
17
+ ```bash
18
+ yarn create template-bricks@latest
19
+ ```
20
+
21
+ ```bash
22
+ pnpm create template-bricks@latest
23
+ ```
24
+
25
+ ```bash
26
+ bun create template-bricks@latest
27
+ ```
28
+
29
+ ```bash
30
+ bunx create-template-bricks@latest
31
+ ```
32
+
33
+ After the project is created:
34
+
35
+ ```bash
36
+ cd create-template-bricks
37
+ npm install
38
+ npm start
39
+ ```
40
+
41
+ ## Website Localhost
42
+
43
+ The development server runs on:
44
+
45
+ - Website: `http://localhost:4200/`
46
+ - Entry page: `http://localhost:4200/index.html`
47
+
48
+ Email templates are available under `/emails/` after they are built:
49
+
50
+ - `http://localhost:4200/emails/address.html`
51
+
52
+ ## Requirements
53
+
54
+ - Node.js `>= 20.12.0`
55
+ - npm, Yarn, pnpm, or Bun
56
+
57
+ ## What Gets Generated
58
+
59
+ The generator creates a project from a shared base template and selected technology layers.
60
+
61
+ Available template engines:
62
+
63
+ - Pug
64
+ - Nunjucks
65
+ - Twig
66
+
67
+ Available script setups:
68
+
69
+ - JavaScript
70
+ - TypeScript
71
+
72
+ The generated project includes:
73
+
74
+ - Gulp 4 build pipeline
75
+ - Webpack 5 bundling
76
+ - SCSS and PostCSS setup
77
+ - Tailwind CSS support
78
+ - MJML email templates
79
+ - SVG and PNG sprite support
80
+ - Image optimization
81
+ - BrowserSync development server
82
+ - ESLint and Stylelint configuration
83
+
84
+ ## License
85
+
86
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,403 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { confirm, input, select } from '@inquirer/prompts';
4
+ import chalk from 'chalk';
5
+ import fs from 'fs-extra';
6
+ import path from 'node:path';
7
+ import process from 'node:process';
8
+ import { fileURLToPath } from 'node:url';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+
13
+ const TEMPLATE_ENGINES = ['pug', 'nunjucks', 'twig'];
14
+ const DEFAULT_PROJECT_NAME = 'create-template-bricks';
15
+
16
+ const WINDOWS_RESERVED_NAMES = new Set([
17
+ 'con',
18
+ 'prn',
19
+ 'aux',
20
+ 'nul',
21
+ 'com1',
22
+ 'com2',
23
+ 'com3',
24
+ 'com4',
25
+ 'com5',
26
+ 'com6',
27
+ 'com7',
28
+ 'com8',
29
+ 'com9',
30
+ 'lpt1',
31
+ 'lpt2',
32
+ 'lpt3',
33
+ 'lpt4',
34
+ 'lpt5',
35
+ 'lpt6',
36
+ 'lpt7',
37
+ 'lpt8',
38
+ 'lpt9'
39
+ ]);
40
+
41
+ const validateProjectName = (value) => {
42
+ const projectName = value.trim();
43
+
44
+ if (!projectName) {
45
+ return 'Project name is required.';
46
+ }
47
+
48
+ if (projectName === '.' || projectName === '..') {
49
+ return 'Project name cannot be "." or "..".';
50
+ }
51
+
52
+ if (projectName.includes('/') || projectName.includes('\\')) {
53
+ return 'Enter a folder name, not a path.';
54
+ }
55
+
56
+ if (path.isAbsolute(projectName)) {
57
+ return 'Absolute paths are not allowed.';
58
+ }
59
+
60
+ if (projectName !== projectName.toLowerCase()) {
61
+ return 'Project name must use lowercase letters.';
62
+ }
63
+
64
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(projectName)) {
65
+ return [
66
+ 'Project name may contain only lowercase letters,',
67
+ 'numbers, dots, hyphens and underscores.'
68
+ ].join(' ');
69
+ }
70
+
71
+ if (projectName.endsWith('.') || projectName.endsWith('-')) {
72
+ return 'Project name cannot end with a dot or hyphen.';
73
+ }
74
+
75
+ if (WINDOWS_RESERVED_NAMES.has(projectName.toLowerCase())) {
76
+ return `"${projectName}" is a reserved system name.`;
77
+ }
78
+
79
+ if (projectName.length > 214) {
80
+ return 'Project name must not exceed 214 characters.';
81
+ }
82
+
83
+ return true;
84
+ };
85
+
86
+ const ensureTemplateExists = async (templatePath, label) => {
87
+ if (!(await fs.pathExists(templatePath))) {
88
+ throw new Error(`${label} was not found: ${templatePath}`);
89
+ }
90
+ };
91
+
92
+ const ensureDestinationIsAvailable = async (projectPath) => {
93
+ if (!(await fs.pathExists(projectPath))) {
94
+ return;
95
+ }
96
+
97
+ const stat = await fs.stat(projectPath);
98
+
99
+ if (!stat.isDirectory()) {
100
+ throw new Error(
101
+ `Destination "${projectPath}" exists and is not a directory.`
102
+ );
103
+ }
104
+
105
+ const files = await fs.readdir(projectPath);
106
+
107
+ if (files.length > 0) {
108
+ throw new Error(
109
+ `Destination directory "${projectPath}" is not empty.`
110
+ );
111
+ }
112
+ };
113
+
114
+ const copyTemplateLayer = async ({
115
+ templatesDir,
116
+ projectPath,
117
+ layerName,
118
+ sourceFolder
119
+ }) => {
120
+ const sourcePath = path.join(templatesDir, layerName);
121
+ const targetPath = path.join(projectPath, sourceFolder);
122
+
123
+ await ensureTemplateExists(
124
+ sourcePath,
125
+ `Template layer "${layerName}"`
126
+ );
127
+
128
+ await fs.copy(sourcePath, targetPath, {
129
+ overwrite: true,
130
+ errorOnExist: false
131
+ });
132
+ };
133
+
134
+ const replaceConfigValue = ({
135
+ content,
136
+ pattern,
137
+ replacement,
138
+ optionName
139
+ }) => {
140
+ if (!pattern.test(content)) {
141
+ throw new Error(
142
+ `Option "${optionName}" was not found in user.config.js.`
143
+ );
144
+ }
145
+
146
+ return content.replace(pattern, replacement);
147
+ };
148
+
149
+ const updateUserConfig = async ({
150
+ projectPath,
151
+ templateEngine,
152
+ typeScript,
153
+ emailsBuild
154
+ }) => {
155
+ const configPath = path.join(projectPath, 'user.config.js');
156
+
157
+ await ensureTemplateExists(configPath, 'Configuration file');
158
+
159
+ let content = await fs.readFile(configPath, 'utf8');
160
+
161
+ content = replaceConfigValue({
162
+ content,
163
+ pattern: /templateEngine:\s*['"`](pug|nunjucks|twig)['"`]/,
164
+ replacement: `templateEngine: '${templateEngine}'`,
165
+ optionName: 'templateEngine'
166
+ });
167
+
168
+ content = replaceConfigValue({
169
+ content,
170
+ pattern: /typeScript:\s*(true|false)/,
171
+ replacement: `typeScript: ${typeScript}`,
172
+ optionName: 'typeScript'
173
+ });
174
+
175
+ content = replaceConfigValue({
176
+ content,
177
+ pattern: /emailsBuild:\s*(true|false)/,
178
+ replacement: `emailsBuild: ${emailsBuild}`,
179
+ optionName: 'emailsBuild'
180
+ });
181
+
182
+ await fs.writeFile(configPath, content, 'utf8');
183
+ };
184
+
185
+ const updatePackageJson = async ({
186
+ projectPath,
187
+ projectName
188
+ }) => {
189
+ const packagePath = path.join(projectPath, 'package.json');
190
+
191
+ await ensureTemplateExists(packagePath, 'package.json');
192
+
193
+ const packageJson = await fs.readJson(packagePath);
194
+
195
+ packageJson.name = projectName;
196
+ packageJson.version = '1.0.0';
197
+ packageJson.private = true;
198
+
199
+ const exportedFile = packageJson.exports
200
+ ? path.join(projectPath, packageJson.exports)
201
+ : null;
202
+
203
+ if (
204
+ exportedFile
205
+ && !(await fs.pathExists(exportedFile))
206
+ ) {
207
+ delete packageJson.exports;
208
+ }
209
+
210
+ await fs.writeJson(packagePath, packageJson, {
211
+ spaces: 2,
212
+ EOL: '\n'
213
+ });
214
+ };
215
+
216
+ const askQuestions = async () => {
217
+ const projectName = await input({
218
+ message: 'Project folder name:',
219
+ default: DEFAULT_PROJECT_NAME,
220
+ validate: validateProjectName,
221
+ transformer: (value) => value.trim()
222
+ });
223
+
224
+ const templateEngine = await select({
225
+ message: 'Which template engine do you want to use?',
226
+ choices: [
227
+ {
228
+ name: 'Twig',
229
+ value: 'twig',
230
+ description: 'Recommended for Symfony and PHP projects.'
231
+ },
232
+ {
233
+ name: 'Pug',
234
+ value: 'pug',
235
+ description: 'Concise HTML templating syntax.'
236
+ },
237
+ {
238
+ name: 'Nunjucks',
239
+ value: 'nunjucks',
240
+ description: 'Jinja-inspired JavaScript templates.'
241
+ }
242
+ ],
243
+ default: 'twig'
244
+ });
245
+
246
+ const typeScript = await confirm({
247
+ message: 'Use TypeScript?',
248
+ default: true
249
+ });
250
+
251
+ const emailsBuild = await confirm({
252
+ message: 'Include MJML email templates?',
253
+ default: false
254
+ });
255
+
256
+ return {
257
+ projectName: projectName.trim(),
258
+ templateEngine,
259
+ typeScript,
260
+ emailsBuild
261
+ };
262
+ };
263
+
264
+ const createProject = async (answers) => {
265
+ if (!TEMPLATE_ENGINES.includes(answers.templateEngine)) {
266
+ throw new Error(
267
+ `Unsupported template engine: ${answers.templateEngine}`
268
+ );
269
+ }
270
+
271
+ const cwd = process.cwd();
272
+ const templatesDir = path.resolve(__dirname, '..', 'templates');
273
+ const projectPath = path.resolve(cwd, answers.projectName);
274
+ const sourceFolder = 'src';
275
+
276
+ if (path.dirname(projectPath) !== cwd) {
277
+ throw new Error(
278
+ 'Project must be created in the current directory.'
279
+ );
280
+ }
281
+
282
+ const baseTemplatePath = path.join(templatesDir, 'base');
283
+
284
+ await ensureTemplateExists(baseTemplatePath, 'Base template');
285
+ await ensureDestinationIsAvailable(projectPath);
286
+
287
+ console.log(
288
+ chalk.yellow('\n📁 Copying the base structure...')
289
+ );
290
+
291
+ await fs.copy(baseTemplatePath, projectPath, {
292
+ overwrite: false,
293
+ errorOnExist: true
294
+ });
295
+
296
+ console.log(
297
+ chalk.yellow(
298
+ `📁 Adding template engine: ${answers.templateEngine}`
299
+ )
300
+ );
301
+
302
+ await copyTemplateLayer({
303
+ templatesDir,
304
+ projectPath,
305
+ layerName: `template-${answers.templateEngine}`,
306
+ sourceFolder
307
+ });
308
+
309
+ const scriptChoice = answers.typeScript ? 'ts' : 'js';
310
+
311
+ console.log(
312
+ chalk.yellow(`📁 Adding scripts: ${scriptChoice}`)
313
+ );
314
+
315
+ await copyTemplateLayer({
316
+ templatesDir,
317
+ projectPath,
318
+ layerName: `template-${scriptChoice}`,
319
+ sourceFolder
320
+ });
321
+
322
+ if (answers.emailsBuild) {
323
+ console.log(
324
+ chalk.yellow('📁 Adding MJML email templates...')
325
+ );
326
+
327
+ await copyTemplateLayer({
328
+ templatesDir,
329
+ projectPath,
330
+ layerName: 'template-mjml',
331
+ sourceFolder: path.join('src', 'templates')
332
+ });
333
+ }
334
+
335
+ console.log(
336
+ chalk.yellow('⚙️ Applying project settings...')
337
+ );
338
+
339
+ await updateUserConfig({
340
+ projectPath,
341
+ templateEngine: answers.templateEngine,
342
+ typeScript: answers.typeScript,
343
+ emailsBuild: answers.emailsBuild
344
+ });
345
+
346
+ await updatePackageJson({
347
+ projectPath,
348
+ projectName: answers.projectName
349
+ });
350
+
351
+ return {
352
+ projectPath,
353
+ projectName: answers.projectName
354
+ };
355
+ };
356
+
357
+ const printSuccess = ({ projectPath, projectName }) => {
358
+ console.log(
359
+ chalk.green('\n✅ Project created successfully!')
360
+ );
361
+
362
+ console.log(chalk.dim(` ${projectPath}`));
363
+
364
+ console.log(chalk.cyan('\n🚀 Next steps:\n'));
365
+ console.log(` cd ${projectName}`);
366
+ console.log(' npm install');
367
+ console.log(' npm start\n');
368
+ };
369
+
370
+ const main = async () => {
371
+ console.log(
372
+ chalk.blue.bold('\n🚀 template-bricks — Create a project\n')
373
+ );
374
+
375
+ const answers = await askQuestions();
376
+ const result = await createProject(answers);
377
+
378
+ printSuccess(result);
379
+ };
380
+
381
+ main().catch((error) => {
382
+ if (error?.name === 'ExitPromptError') {
383
+ console.log(chalk.yellow('\n\nOperation cancelled.\n'));
384
+ process.exitCode = 0;
385
+ return;
386
+ }
387
+
388
+ console.error(
389
+ chalk.red.bold('\n❌ Failed to create the project.\n')
390
+ );
391
+
392
+ console.error(chalk.red(error.message));
393
+
394
+ if (process.env.DEBUG) {
395
+ console.error(chalk.dim(error.stack));
396
+ }
397
+
398
+ console.log(
399
+ chalk.dim('\nRun with DEBUG=1 to display the full error.\n')
400
+ );
401
+
402
+ process.exitCode = 1;
403
+ });
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "create-template-bricks",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "CLI for creating projects based on template-bricks.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/evscoder/template-bricks.git"
8
+ },
9
+ "homepage": "https://github.com/evscoder/template-bricks",
10
+ "bugs": {
11
+ "url": "https://github.com/evscoder/template-bricks/issues"
12
+ },
13
+ "type": "module",
14
+ "bin": {
15
+ "create-template-bricks": "bin/cli.js"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "templates",
20
+ "README.md"
21
+ ],
22
+ "keywords": [
23
+ "cli",
24
+ "starter",
25
+ "frontend",
26
+ "dev",
27
+ "template",
28
+ "gulp",
29
+ "webpack",
30
+ "pug",
31
+ "nunjucks",
32
+ "twig",
33
+ "mjml",
34
+ "typescript",
35
+ "scss",
36
+ "tailwindcss"
37
+ ],
38
+ "author": {
39
+ "name": "Evgeny Staroverov",
40
+ "url": "https://github.com/evscoder"
41
+ },
42
+ "license": "MIT",
43
+ "dependencies": {
44
+ "@inquirer/prompts": "^8.4.1",
45
+ "chalk": "^5.6.2",
46
+ "fs-extra": "^11.3.4"
47
+ },
48
+ "engines": {
49
+ "node": ">=20.12.0"
50
+ }
51
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "useBuiltIns": "usage",
7
+ "corejs": "3.0.0"
8
+ }
9
+ ], [
10
+ "@babel/preset-typescript"
11
+ ]
12
+ ],
13
+ "plugins": [
14
+ "@babel/plugin-syntax-dynamic-import",
15
+ "@babel/plugin-proposal-class-properties",
16
+ "@babel/plugin-transform-runtime"
17
+ ]
18
+ }
@@ -0,0 +1,22 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 4
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+ [node_modules/**.js]
16
+ codepaint = false
17
+
18
+ [*.json]
19
+ indent_size = 2
20
+
21
+ [src/components/**/*.json]
22
+ indent_size = 4
@@ -0,0 +1,130 @@
1
+ {
2
+ "parser": "@babel/eslint-parser",
3
+ "extends": "airbnb-base/legacy",
4
+ "env": {
5
+ "node": true
6
+ },
7
+ "ignorePatterns": [
8
+ "src/js/vendor/**"
9
+ ],
10
+ "parserOptions": {
11
+ "ecmaVersion": 6,
12
+ "sourceType": "module",
13
+ "allowImportExportEverywhere": false,
14
+ "ecmaFeatures": {
15
+ "globalReturn": false
16
+ }
17
+ },
18
+ "rules": {
19
+ "linebreak-style": 0,
20
+ "indent": [
21
+ 2,
22
+ 4,
23
+ {
24
+ "SwitchCase": 1
25
+ }
26
+ ],
27
+ "import/no-unresolved": [
28
+ 0
29
+ ],
30
+ "quotes": [
31
+ 1,
32
+ "single",
33
+ {
34
+ "allowTemplateLiterals": true
35
+ }
36
+ ],
37
+ "comma-dangle": [
38
+ 1,
39
+ "never"
40
+ ],
41
+ "no-plusplus": 0,
42
+ "allowForLoopAfterthoughts": 0,
43
+ "import/prefer-default-export": 0,
44
+ "func-names": 0,
45
+ "no-console": 0,
46
+ "global-require": "off",
47
+ "class-methods-use-this": "off",
48
+ "no-use-before-define": "off",
49
+ "no-undef": "off",
50
+ "no-unused-vars": "off",
51
+ "quote-props": [
52
+ "error",
53
+ "as-needed",
54
+ {
55
+ "keywords": true,
56
+ "unnecessary": false
57
+ }
58
+ ],
59
+ "no-catch-shadow": 0,
60
+ "no-mixed-requires": 2,
61
+ "no-new-require": 2,
62
+ "no-path-concat": 2,
63
+ "global-strict": [
64
+ 0,
65
+ "always"
66
+ ],
67
+ "handle-callback-err": [
68
+ 2,
69
+ "err"
70
+ ],
71
+ "arrow-spacing": [
72
+ 2,
73
+ {
74
+ "before": true,
75
+ "after": true
76
+ }
77
+ ],
78
+ "constructor-super": 2,
79
+ "no-confusing-arrow": 2,
80
+ "no-class-assign": 2,
81
+ "no-const-assign": 2,
82
+ "no-dupe-class-members": 2,
83
+ "no-this-before-super": 2,
84
+ "prefer-arrow-callback": 0,
85
+ "prefer-template": 0,
86
+ "require-yield": 2,
87
+ "no-var": 0,
88
+ "no-new": 0,
89
+ "max-len": "off",
90
+ "no-empty-function": "off",
91
+ "no-multiple-empty-lines": "off"
92
+ },
93
+ "overrides": [
94
+ {
95
+ "files": [
96
+ "src/**/*.ts"
97
+ ],
98
+ "parser": "@typescript-eslint/parser",
99
+ "plugins": [
100
+ "@typescript-eslint"
101
+ ],
102
+ "extends": [
103
+ "plugin:@typescript-eslint/recommended"
104
+ ],
105
+ "rules": {
106
+ "arrow-spacing": "error",
107
+ "block-spacing": "error",
108
+ "new-parens": "error",
109
+ "no-debugger": "error",
110
+ "no-duplicate-imports": "error",
111
+ "no-multi-spaces": "error",
112
+ "no-tabs": "error",
113
+ "no-empty": "error",
114
+ "@typescript-eslint/no-empty-function": "off",
115
+ "indent": [
116
+ "error",
117
+ 4
118
+ ],
119
+ "quotes": [
120
+ "error",
121
+ "single"
122
+ ],
123
+ "array-bracket-spacing": [
124
+ "error",
125
+ "always"
126
+ ]
127
+ }
128
+ }
129
+ ]
130
+ }