create-alistt69-kit 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -0
  3. package/bin/index.js +25 -0
  4. package/package.json +44 -0
  5. package/src/core/apply-features.js +15 -0
  6. package/src/core/collect-project-info.js +195 -0
  7. package/src/core/copy-base-template.js +12 -0
  8. package/src/core/create-project.js +90 -0
  9. package/src/core/install-dependencies.js +28 -0
  10. package/src/core/parse-cli-args.js +123 -0
  11. package/src/core/prepare-target-directory.js +70 -0
  12. package/src/core/replace-tokens.js +46 -0
  13. package/src/core/restore-special-files.js +19 -0
  14. package/src/features/autoprefixer/files/postcss.config.cjs +5 -0
  15. package/src/features/autoprefixer/index.js +23 -0
  16. package/src/features/eslint/files/eslint.config.mjs +128 -0
  17. package/src/features/eslint/index.js +35 -0
  18. package/src/features/index.js +15 -0
  19. package/src/features/react-router/files/src/app/App.tsx +10 -0
  20. package/src/features/react-router/files/src/app/layouts/app/index.tsx +17 -0
  21. package/src/features/react-router/files/src/app/providers/router/config/router.tsx +13 -0
  22. package/src/features/react-router/files/src/pages/error/index.ts +1 -0
  23. package/src/features/react-router/files/src/pages/error/lazy.ts +3 -0
  24. package/src/features/react-router/files/src/pages/error/page.tsx +7 -0
  25. package/src/features/react-router/files/src/pages/main/index.ts +1 -0
  26. package/src/features/react-router/files/src/pages/main/lazy.ts +3 -0
  27. package/src/features/react-router/files/src/pages/main/page.tsx +7 -0
  28. package/src/features/react-router/index.js +23 -0
  29. package/src/features/stylelint/files/stylelint.config.mjs +14 -0
  30. package/src/features/stylelint/index.js +29 -0
  31. package/src/templates/base/.editorconfig +12 -0
  32. package/src/templates/base/README.md +3 -0
  33. package/src/templates/base/babel.config.json +12 -0
  34. package/src/templates/base/config/build/buildDevServer.ts +11 -0
  35. package/src/templates/base/config/build/buildLoaders.ts +39 -0
  36. package/src/templates/base/config/build/buildPlugins.ts +34 -0
  37. package/src/templates/base/config/build/buildResolvers.ts +14 -0
  38. package/src/templates/base/config/build/buildWebpackConfig.ts +27 -0
  39. package/src/templates/base/config/build/loaders/buildCssLoader.ts +21 -0
  40. package/src/templates/base/config/build/types/config.ts +22 -0
  41. package/src/templates/base/gitignore +27 -0
  42. package/src/templates/base/package.json +48 -0
  43. package/src/templates/base/public/index.html +11 -0
  44. package/src/templates/base/src/app/App.tsx +7 -0
  45. package/src/templates/base/src/index.tsx +16 -0
  46. package/src/templates/base/src/styles/index.scss +11 -0
  47. package/src/templates/base/tsconfig.json +25 -0
  48. package/src/templates/base/webpack.config.ts +27 -0
  49. package/src/utils/console-format.js +12 -0
  50. package/src/utils/package-json.js +73 -0
  51. package/src/utils/package-manager.js +23 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 alistt69
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # _create-alistt69-kit_
2
+
3
+ > **One command. Zero config fatigue.**
4
+ > Bootstrap a **React + TypeScript + Webpack** app with a solid starter setup and optional tooling you can enable when you need it.
5
+
6
+ [![npm version](https://img.shields.io/npm/v/create-alistt69-kit.svg)](https://www.npmjs.com/package/create-alistt69-kit)
7
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.18-brightgreen)](https://nodejs.org/)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
9
+
10
+ ---
11
+
12
+ ## ✨ Overview
13
+
14
+ `create-alistt69-kit` is a project scaffolding tool for quickly creating a modern frontend app without burning time on repetitive setup.
15
+
16
+ It generates a ready-to-run **React + TypeScript + Webpack** starter with a practical baseline and optional extras you can turn on when needed.
17
+
18
+ ## 🔧 What’s inside
19
+
20
+ | Tool | Purpose | Included |
21
+ |------|---------|----------|
22
+ | [React](https://react.dev/) | UI library | Default |
23
+ | [TypeScript](https://www.typescriptlang.org/) | Static typing | Default |
24
+ | [Webpack](https://webpack.js.org/) | Bundling and build pipeline | Default |
25
+ | [SCSS Modules](https://github.com/css-modules/css-modules) | Scoped styling | Default |
26
+ | [SVGR](https://react-svgr.com/) | Import SVGs as React components | Default |
27
+ | [Webpack Bundle Analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) | Bundle size inspection | Default |
28
+ | [ESLint](https://eslint.org/) + [eslint-stylistic](https://eslint.style/) | Code quality and stylistic rules | Optional |
29
+ | [Stylelint](https://stylelint.io/) | Stylesheet linting | Optional |
30
+ | [Autoprefixer](https://github.com/postcss/autoprefixer) | Automatic CSS vendor prefixes | Optional |
31
+ | [React Router](https://reactrouter.com/) | Client-side routing | Optional |
32
+
33
+ ---
34
+
35
+ ## 🎯 Why use it?
36
+
37
+ Setting up a frontend project from scratch usually means repeating the same stuff every time:
38
+
39
+ - webpack config
40
+ - TypeScript config
41
+ - style handling
42
+ - routing
43
+ - linters
44
+ - folder structure
45
+
46
+ This starter removes that boilerplate so you can get straight to building.
47
+
48
+ ---
49
+
50
+ ## 📦 Requirements
51
+
52
+ - **Node.js** `18.18` or higher
53
+ - **npm**, **pnpm**, or **yarn**
54
+
55
+ ---
56
+
57
+ ## 🔥 Quick start
58
+
59
+ Create a new app interactively:
60
+
61
+ ```bash
62
+ npm create alistt69-kit
63
+ ```
64
+
65
+ Follow the prompts — or skip them entirely:
66
+
67
+ ```bash
68
+ npm create alistt69-kit my-app --yes
69
+ ```
70
+
71
+ ## 🛠️ Usage examples
72
+
73
+ ```bash
74
+ # Interactive setup
75
+ npm create alistt69-kit my-app
76
+
77
+ # All defaults, no prompts
78
+ npm create alistt69-kit my-app --yes
79
+
80
+ # Skip dependency installation
81
+ npm create alistt69-kit my-app --no-install
82
+
83
+ # Enable only selected features
84
+ npm create alistt69-kit my-app --features=eslint,react-router
85
+
86
+ # Enable all optional features
87
+ npm create alistt69-kit my-app --features=all
88
+
89
+ # Use pnpm as package manager
90
+ npm create alistt69-kit my-app --pm pnpm
91
+
92
+ # Overwrite existing directory
93
+ npm create alistt69-kit my-app --yes --force
94
+ ```
95
+
96
+ ## ⚙️ CLI options
97
+
98
+ | Option | Alias | Description |
99
+ |--------|-------|-------------|
100
+ | `--yes` | `-y` | Skip prompts, use defaults |
101
+ | `--force` | — | Overwrite target directory if it exists |
102
+ | `--no-install` | — | Skip dependency installation |
103
+ | `--features <list>` | — | Enable specific features (`eslint`, `react-router`, `all`) |
104
+ | `--pm <name>` | — | Choose package manager (`npm`, `pnpm`, `yarn`) |
105
+ | `--help` | `-h` | Show help |
106
+
107
+ ## 🧪 Default behavior
108
+
109
+ - All features are enabled by default
110
+ - Package manager: `npm` (can be overridden with `--pm`)
111
+ - Dependencies are installed automatically (skip with `--no-install`)
112
+
113
+ ## 📄 License
114
+
115
+ MIT — free and open for everyone.
package/bin/index.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { cancel } from '@clack/prompts';
4
+ import process from 'node:process';
5
+ import { createProject } from '../src/core/create-project.js';
6
+ import { formatHelpMessage, parseCliArgs } from '../src/core/parse-cli-args.js';
7
+
8
+ try {
9
+ const cliArgs = parseCliArgs(process.argv.slice(2));
10
+
11
+ if (cliArgs.showHelp) {
12
+ console.log(formatHelpMessage());
13
+ process.exit(0);
14
+ }
15
+
16
+ await createProject(cliArgs);
17
+ } catch (error) {
18
+ cancel(
19
+ error instanceof Error
20
+ ? `Failed to create project: ${error.message}`
21
+ : 'Failed to create project',
22
+ );
23
+
24
+ process.exitCode = 1;
25
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "create-alistt69-kit",
3
+ "version": "0.1.0",
4
+ "description": "Opinionated React + TypeScript + Webpack project generator by alistt69",
5
+ "keywords": [
6
+ "create",
7
+ "cli",
8
+ "scaffold",
9
+ "generator",
10
+ "react",
11
+ "typescript",
12
+ "webpack"
13
+ ],
14
+ "homepage": "https://github.com/alistt69/create-alistt69-kit#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/alistt69/create-alistt69-kit/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/alistt69/create-alistt69-kit.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": "alistt69",
24
+ "type": "module",
25
+ "bin": {
26
+ "create-alistt69-kit": "bin/index.js"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "src",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "scripts": {
35
+ "dev": "node ./bin/index.js",
36
+ "smoke": "node ./scripts/smoke.mjs"
37
+ },
38
+ "engines": {
39
+ "node": ">=18.18.0"
40
+ },
41
+ "dependencies": {
42
+ "@clack/prompts": "^0.10.1"
43
+ }
44
+ }
@@ -0,0 +1,15 @@
1
+ import { featuresById } from '../features/index.js';
2
+
3
+ export async function applyFeatures({ projectPath, selectedFeatureIds }) {
4
+ for (const featureId of selectedFeatureIds) {
5
+ const feature = featuresById.get(featureId);
6
+
7
+ if (!feature) {
8
+ throw new Error(`Unknown feature: ${featureId}`);
9
+ }
10
+
11
+ await feature.apply({
12
+ projectPath,
13
+ });
14
+ }
15
+ }
@@ -0,0 +1,195 @@
1
+ import {
2
+ cancel,
3
+ confirm,
4
+ intro,
5
+ isCancel,
6
+ multiselect,
7
+ note,
8
+ select,
9
+ text,
10
+ } from '@clack/prompts';
11
+ import process from 'node:process';
12
+ import { format } from '../utils/console-format.js';
13
+ import { allowedPackageManagers } from '../utils/package-manager.js';
14
+
15
+ const availableFeatures = [
16
+ {
17
+ value: 'eslint',
18
+ label: 'ESLint + Stylistic',
19
+ hint: 'JS/TS/React linting',
20
+ },
21
+ {
22
+ value: 'stylelint',
23
+ label: 'Stylelint',
24
+ hint: 'SCSS/CSS linting',
25
+ },
26
+ {
27
+ value: 'autoprefixer',
28
+ label: 'Autoprefixer',
29
+ hint: 'PostCSS vendor prefixes',
30
+ },
31
+ {
32
+ value: 'react-router',
33
+ label: 'React Router DOM',
34
+ hint: 'Routing + FSD-like app/pages/shared',
35
+ },
36
+ ];
37
+
38
+ const defaultFeatureIds = availableFeatures.map((feature) => feature.value);
39
+ const defaultPackageManager = 'npm';
40
+ const availableFeatureIdSet = new Set(defaultFeatureIds);
41
+
42
+ function handleCancel(value) {
43
+ if (!isCancel(value)) {
44
+ return value;
45
+ }
46
+
47
+ cancel('Operation cancelled.');
48
+ process.exit(0);
49
+ }
50
+
51
+ function validateProjectName(value) {
52
+ const projectName = value.trim();
53
+
54
+ if (!projectName) {
55
+ return 'Project name is required';
56
+ }
57
+
58
+ if (projectName.length > 214) {
59
+ return 'Project name is too long';
60
+ }
61
+
62
+ if (!/^[a-z0-9._-]+$/i.test(projectName)) {
63
+ return 'Use only letters, numbers, dots, underscores and hyphens';
64
+ }
65
+
66
+ if (projectName.startsWith('.')) {
67
+ return 'Project name cannot start with a dot';
68
+ }
69
+
70
+ return;
71
+ }
72
+
73
+ function normalizeFeatureIds(featureIds) {
74
+ const normalizedFeatureIds = [...new Set(featureIds.map((featureId) => featureId.toLowerCase()))];
75
+
76
+ if (normalizedFeatureIds.includes('all')) {
77
+ return defaultFeatureIds;
78
+ }
79
+
80
+ const unknownFeatureIds = normalizedFeatureIds.filter((featureId) => !availableFeatureIdSet.has(featureId));
81
+
82
+ if (unknownFeatureIds.length > 0) {
83
+ throw new Error(`Unknown features: ${unknownFeatureIds.join(', ')}`);
84
+ }
85
+
86
+ return defaultFeatureIds.filter((featureId) => normalizedFeatureIds.includes(featureId));
87
+ }
88
+
89
+ export async function collectProjectInfo(cliArgs = {}) {
90
+ intro('create-alistt69-kit');
91
+
92
+ let projectName = cliArgs.projectName;
93
+ let selectedFeatureIds = cliArgs.selectedFeatureIds;
94
+ let shouldInstallDependencies = cliArgs.shouldInstallDependencies;
95
+ let packageManager = cliArgs.packageManager;
96
+
97
+ if (cliArgs.yes && !projectName) {
98
+ throw new Error('Project name is required when using --yes');
99
+ }
100
+
101
+ if (!projectName) {
102
+ projectName = handleCancel(await text({
103
+ message: 'Project name',
104
+ placeholder: 'my-awesome-app',
105
+ validate: validateProjectName,
106
+ }));
107
+ } else {
108
+ const validationError = validateProjectName(projectName);
109
+
110
+ if (validationError) {
111
+ throw new Error(validationError);
112
+ }
113
+ }
114
+
115
+ if (selectedFeatureIds === undefined) {
116
+ if (cliArgs.yes) {
117
+ selectedFeatureIds = defaultFeatureIds;
118
+ } else {
119
+ note(
120
+ [
121
+ 'All features are selected by default.',
122
+ 'Remove anything you do not need.',
123
+ '',
124
+ '↑/↓ — move',
125
+ 'Space — toggle feature',
126
+ 'Enter — confirm selection',
127
+ ].join('\n'),
128
+ format.sectionTitle('Feature selection help'),
129
+ );
130
+
131
+ selectedFeatureIds = handleCancel(await multiselect({
132
+ message: 'Remove unnecessary features',
133
+ options: availableFeatures,
134
+ initialValues: defaultFeatureIds,
135
+ required: false,
136
+ }));
137
+ }
138
+ }
139
+
140
+ selectedFeatureIds = normalizeFeatureIds(selectedFeatureIds);
141
+
142
+ if (!packageManager) {
143
+ if (cliArgs.yes) {
144
+ packageManager = defaultPackageManager;
145
+ } else {
146
+ packageManager = handleCancel(await select({
147
+ message: 'Package manager',
148
+ initialValue: defaultPackageManager,
149
+ options: allowedPackageManagers.map((value) => ({
150
+ value,
151
+ label: value,
152
+ })),
153
+ }));
154
+ }
155
+ }
156
+
157
+ if (shouldInstallDependencies === undefined) {
158
+ if (cliArgs.yes) {
159
+ shouldInstallDependencies = true;
160
+ } else {
161
+ shouldInstallDependencies = handleCancel(await confirm({
162
+ message: 'Install dependencies?',
163
+ initialValue: true,
164
+ }));
165
+ }
166
+ }
167
+
168
+ const summaryLines = [
169
+ `${format.label('Project')} ${projectName}`,
170
+ `${format.label('Features')} ${selectedFeatureIds.length ? selectedFeatureIds.join(', ') : 'none'}`,
171
+ `${format.label('PM')} ${packageManager}`,
172
+ `${format.label('Install')} ${shouldInstallDependencies ? 'yes' : 'no'}`,
173
+ ];
174
+
175
+ note(summaryLines.join('\n'), format.sectionTitle('Summary'));
176
+
177
+ if (!cliArgs.yes) {
178
+ const shouldContinue = handleCancel(await confirm({
179
+ message: 'Continue?',
180
+ initialValue: true,
181
+ }));
182
+
183
+ if (!shouldContinue) {
184
+ cancel('Operation cancelled.');
185
+ process.exit(0);
186
+ }
187
+ }
188
+
189
+ return {
190
+ projectName: projectName.trim(),
191
+ selectedFeatureIds,
192
+ shouldInstallDependencies,
193
+ packageManager,
194
+ };
195
+ }
@@ -0,0 +1,12 @@
1
+ import { cp } from 'node:fs/promises';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const currentFilePath = fileURLToPath(import.meta.url);
6
+ const currentDirPath = dirname(currentFilePath);
7
+
8
+ export async function copyBaseTemplate(targetDirPath) {
9
+ const templateDirPath = resolve(currentDirPath, '../templates/base');
10
+
11
+ await cp(templateDirPath, targetDirPath, { recursive: true });
12
+ }
@@ -0,0 +1,90 @@
1
+ import { outro, spinner } from '@clack/prompts';
2
+ import process from 'node:process';
3
+ import { format } from '../utils/console-format.js';
4
+ import { getRunScriptCommand } from '../utils/package-manager.js';
5
+ import { applyFeatures } from './apply-features.js';
6
+ import { collectProjectInfo } from './collect-project-info.js';
7
+ import { copyBaseTemplate } from './copy-base-template.js';
8
+ import { installDependencies } from './install-dependencies.js';
9
+ import { prepareTargetDirectory } from './prepare-target-directory.js';
10
+ import { replaceTokens } from './replace-tokens.js';
11
+ import { restoreSpecialFiles } from './restore-special-files.js';
12
+
13
+ export async function createProject(cliArgs = {}) {
14
+ const {
15
+ projectName,
16
+ selectedFeatureIds,
17
+ shouldInstallDependencies,
18
+ packageManager,
19
+ } = await collectProjectInfo(cliArgs);
20
+
21
+ const { targetDirPath } = await prepareTargetDirectory({
22
+ projectName,
23
+ force: cliArgs.force,
24
+ yes: cliArgs.yes,
25
+ });
26
+
27
+ const progress = spinner();
28
+
29
+ try {
30
+ progress.start('Copying base template...');
31
+ await copyBaseTemplate(targetDirPath);
32
+ progress.stop('Base template copied');
33
+
34
+ progress.start('Restoring special files...');
35
+ await restoreSpecialFiles(targetDirPath);
36
+ progress.stop('Special files restored');
37
+
38
+ progress.start('Replacing template tokens...');
39
+ await replaceTokens(targetDirPath, {
40
+ '__PROJECT_NAME__': projectName,
41
+ });
42
+ progress.stop('Template tokens replaced');
43
+
44
+ if (selectedFeatureIds.length > 0) {
45
+ progress.start(`Applying features: ${selectedFeatureIds.join(', ')}`);
46
+ await applyFeatures({
47
+ projectPath: targetDirPath,
48
+ selectedFeatureIds,
49
+ });
50
+ progress.stop('Features applied');
51
+ }
52
+
53
+ if (shouldInstallDependencies) {
54
+ progress.start(`Installing dependencies with ${packageManager}...`);
55
+ await installDependencies(targetDirPath, packageManager);
56
+ progress.stop('Dependencies installed');
57
+ }
58
+ } catch (error) {
59
+ progress.stop('Operation failed');
60
+ throw error;
61
+ }
62
+
63
+ const featuresLine = selectedFeatureIds.length
64
+ ? selectedFeatureIds.join(', ')
65
+ : 'none';
66
+
67
+ const nextSteps = shouldInstallDependencies
68
+ ? [
69
+ `cd ${projectName}`,
70
+ getRunScriptCommand(packageManager, 'start'),
71
+ ]
72
+ : [
73
+ `cd ${projectName}`,
74
+ packageManager === 'yarn' ? 'yarn' : `${packageManager} install`,
75
+ getRunScriptCommand(packageManager, 'start'),
76
+ ];
77
+
78
+ outro([
79
+ `${format.green('✔ Project created successfully')}`,
80
+ '',
81
+ format.sectionTitle('Project info'),
82
+ `${format.label('Project')} ${projectName}`,
83
+ `${format.label('Path')} ${targetDirPath}`,
84
+ `${format.label('Features')} ${featuresLine}`,
85
+ `${format.label('PM')} ${packageManager}`,
86
+ '',
87
+ format.sectionTitle('Next steps'),
88
+ ...nextSteps.map((step) => ` ${step}`),
89
+ ].join('\n'));
90
+ }
@@ -0,0 +1,28 @@
1
+ import { spawn } from 'node:child_process';
2
+ import process from 'node:process';
3
+ import { getInstallCommand } from '../utils/package-manager.js';
4
+
5
+ export function installDependencies(targetDirPath, packageManager) {
6
+ const { command, args } = getInstallCommand(packageManager);
7
+
8
+ return new Promise((resolvePromise, rejectPromise) => {
9
+ const childProcess = spawn(command, args, {
10
+ cwd: targetDirPath,
11
+ stdio: 'inherit',
12
+ shell: process.platform === 'win32',
13
+ });
14
+
15
+ childProcess.on('error', (error) => {
16
+ rejectPromise(error);
17
+ });
18
+
19
+ childProcess.on('close', (code) => {
20
+ if (code === 0) {
21
+ resolvePromise();
22
+ return;
23
+ }
24
+
25
+ rejectPromise(new Error(`${command} ${args.join(' ')} failed with exit code ${code}`.trim()));
26
+ });
27
+ });
28
+ }
@@ -0,0 +1,123 @@
1
+ import { allowedPackageManagers } from '../utils/package-manager.js';
2
+
3
+ function readOptionValue(args, currentIndex, optionName) {
4
+ const currentArg = args[currentIndex];
5
+
6
+ if (currentArg.includes('=')) {
7
+ return {
8
+ value: currentArg.slice(currentArg.indexOf('=') + 1),
9
+ nextIndex: currentIndex,
10
+ };
11
+ }
12
+
13
+ const nextArg = args[currentIndex + 1];
14
+
15
+ if (!nextArg || nextArg.startsWith('-')) {
16
+ throw new Error(`Option ${optionName} requires a value`);
17
+ }
18
+
19
+ return {
20
+ value: nextArg,
21
+ nextIndex: currentIndex + 1,
22
+ };
23
+ }
24
+
25
+ export function formatHelpMessage() {
26
+ return [
27
+ 'Usage:',
28
+ ' create-alistt69-kit <project-name> [options]',
29
+ '',
30
+ 'Options:',
31
+ ' -y, --yes Skip prompts and use defaults',
32
+ ' --force Overwrite target directory if it exists',
33
+ ' --no-install Do not install dependencies',
34
+ ' --features <comma-list> Example: eslint,stylelint,react-router',
35
+ ' --features all Enable all features',
36
+ ' --pm <npm|pnpm|yarn> Package manager',
37
+ ' -h, --help Show help',
38
+ '',
39
+ 'Defaults:',
40
+ ' All features are enabled by default',
41
+ ' Package manager: npm',
42
+ ' Install dependencies: yes',
43
+ '',
44
+ 'Examples:',
45
+ ' create-alistt69-kit my-app',
46
+ ' create-alistt69-kit my-app --features=all',
47
+ ' create-alistt69-kit my-app --pm pnpm --no-install',
48
+ ' create-alistt69-kit my-app --yes',
49
+ ' create-alistt69-kit my-app --yes --force',
50
+ ].join('\n');
51
+ }
52
+
53
+ export function parseCliArgs(argv) {
54
+ const result = {
55
+ projectName: undefined,
56
+ selectedFeatureIds: undefined,
57
+ shouldInstallDependencies: undefined,
58
+ packageManager: undefined,
59
+ yes: false,
60
+ force: false,
61
+ showHelp: false,
62
+ };
63
+
64
+ for (let index = 0; index < argv.length; index += 1) {
65
+ const arg = argv[index];
66
+
67
+ if (arg === '-h' || arg === '--help') {
68
+ result.showHelp = true;
69
+ continue;
70
+ }
71
+
72
+ if (arg === '-y' || arg === '--yes') {
73
+ result.yes = true;
74
+ continue;
75
+ }
76
+
77
+ if (arg === '--force') {
78
+ result.force = true;
79
+ continue;
80
+ }
81
+
82
+ if (arg === '--no-install') {
83
+ result.shouldInstallDependencies = false;
84
+ continue;
85
+ }
86
+
87
+ if (arg.startsWith('--features')) {
88
+ const { value, nextIndex } = readOptionValue(argv, index, '--features');
89
+ index = nextIndex;
90
+
91
+ result.selectedFeatureIds = value
92
+ ? value.split(',').map((item) => item.trim()).filter(Boolean)
93
+ : [];
94
+
95
+ continue;
96
+ }
97
+
98
+ if (arg.startsWith('--pm')) {
99
+ const { value, nextIndex } = readOptionValue(argv, index, '--pm');
100
+ index = nextIndex;
101
+
102
+ if (!allowedPackageManagers.includes(value)) {
103
+ throw new Error(`Unknown package manager: ${value}`);
104
+ }
105
+
106
+ result.packageManager = value;
107
+ continue;
108
+ }
109
+
110
+ if (arg.startsWith('-')) {
111
+ throw new Error(`Unknown option: ${arg}`);
112
+ }
113
+
114
+ if (!result.projectName) {
115
+ result.projectName = arg;
116
+ continue;
117
+ }
118
+
119
+ throw new Error(`Unexpected argument: ${arg}`);
120
+ }
121
+
122
+ return result;
123
+ }