andrud 1.0.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.
- package/CHANGELOG.md +70 -0
- package/CODE_REVIEW_ANALYSIS.md +177 -0
- package/CONTRIBUTING.md +132 -0
- package/FIXES_IMPLEMENTED.md +546 -0
- package/LICENSE +21 -0
- package/README.md +310 -0
- package/bin/andrud.js +24 -0
- package/package.json +80 -0
- package/src/__tests__/context.test.ts +133 -0
- package/src/__tests__/generator.test.ts +107 -0
- package/src/__tests__/validation.test.ts +105 -0
- package/src/cli/commands/create.ts +252 -0
- package/src/cli/commands/info.ts +178 -0
- package/src/cli/commands/init.ts +186 -0
- package/src/cli/commands/list.ts +156 -0
- package/src/cli/commands/new.ts +316 -0
- package/src/cli/index.ts +116 -0
- package/src/core/config.ts +172 -0
- package/src/core/context.ts +212 -0
- package/src/core/generator.ts +1350 -0
- package/src/core/types.ts +184 -0
- package/src/templates/index.ts +162 -0
- package/src/types/gradient-string.d.ts +25 -0
- package/src/ui/colors.ts +139 -0
- package/src/ui/output.ts +230 -0
- package/src/ui/prompts.ts +170 -0
- package/src/ui/spinners.ts +95 -0
- package/src/ui/types.ts +41 -0
- package/src/utils/filesystem.ts +222 -0
- package/src/utils/logger.ts +67 -0
- package/src/utils/object.ts +456 -0
- package/src/utils/validation.ts +345 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the Android project generator
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Language and UI framework types
|
|
6
|
+
export type LanguageType = 'kotlin' | 'java';
|
|
7
|
+
export type UiFrameworkType = 'xml' | 'compose';
|
|
8
|
+
export type TemplateType = 'kotlin-xml' | 'kotlin-compose' | 'java-xml' | 'native-cpp';
|
|
9
|
+
|
|
10
|
+
// Android SDK configuration
|
|
11
|
+
export interface AndroidSdkConfig {
|
|
12
|
+
minSdk: number;
|
|
13
|
+
targetSdk: number;
|
|
14
|
+
compileSdk: number;
|
|
15
|
+
buildToolsVersion?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Gradle configuration
|
|
19
|
+
export interface GradleConfig {
|
|
20
|
+
agpVersion: string;
|
|
21
|
+
gradleVersion: string;
|
|
22
|
+
kotlinVersion?: string;
|
|
23
|
+
composeCompilerVersion?: string;
|
|
24
|
+
composeBomVersion?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Project features
|
|
28
|
+
export interface ProjectFeatures {
|
|
29
|
+
git: boolean;
|
|
30
|
+
readme: boolean;
|
|
31
|
+
androidX: boolean;
|
|
32
|
+
kotlinDsl: boolean;
|
|
33
|
+
adaptiveIcon: boolean;
|
|
34
|
+
material3: boolean;
|
|
35
|
+
viewBinding?: boolean;
|
|
36
|
+
dataBinding?: boolean;
|
|
37
|
+
jetpackCompose?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Native C++ configuration
|
|
41
|
+
export interface NativeCppConfig {
|
|
42
|
+
cppStandard: 'c++17' | 'c++20';
|
|
43
|
+
ndkVersion?: string;
|
|
44
|
+
stlType?: 'c++_shared' | 'c++_static' | 'none' | 'system';
|
|
45
|
+
abiFilters?: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Template context for project generation
|
|
49
|
+
export interface TemplateContext extends ProjectFeatures {
|
|
50
|
+
// Basic info
|
|
51
|
+
appName: string;
|
|
52
|
+
packageName: string;
|
|
53
|
+
projectDirectory: string;
|
|
54
|
+
template: TemplateType;
|
|
55
|
+
|
|
56
|
+
// Derived info
|
|
57
|
+
language: LanguageType;
|
|
58
|
+
uiFramework: UiFrameworkType;
|
|
59
|
+
|
|
60
|
+
// SDK and Gradle config
|
|
61
|
+
android: AndroidSdkConfig;
|
|
62
|
+
gradle: GradleConfig;
|
|
63
|
+
|
|
64
|
+
// Transformed names
|
|
65
|
+
appNameSnake: string;
|
|
66
|
+
appNameKebab: string;
|
|
67
|
+
appNamePascal: string;
|
|
68
|
+
appNameCamel: string;
|
|
69
|
+
appNameLower: string;
|
|
70
|
+
|
|
71
|
+
// Package path (e.g., "com/example/myapp")
|
|
72
|
+
packagePath: string;
|
|
73
|
+
|
|
74
|
+
// Date and version info
|
|
75
|
+
year: string;
|
|
76
|
+
generatorVersion: string;
|
|
77
|
+
|
|
78
|
+
// Native C++ config (optional)
|
|
79
|
+
nativeCpp?: NativeCppConfig;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Generation options
|
|
83
|
+
export interface GenerationOptions {
|
|
84
|
+
overwrite: boolean;
|
|
85
|
+
skipInstall: boolean;
|
|
86
|
+
dryRun: boolean;
|
|
87
|
+
verbose: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Generation result
|
|
91
|
+
export interface GenerationResult {
|
|
92
|
+
success: boolean;
|
|
93
|
+
projectPath: string;
|
|
94
|
+
generatedFiles: string[];
|
|
95
|
+
skippedFiles: string[];
|
|
96
|
+
errors: Array<{
|
|
97
|
+
file?: string;
|
|
98
|
+
message: string;
|
|
99
|
+
code?: string;
|
|
100
|
+
}>;
|
|
101
|
+
warnings: string[];
|
|
102
|
+
duration: number;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// File to be generated
|
|
106
|
+
export interface GeneratedFile {
|
|
107
|
+
path: string;
|
|
108
|
+
content: string;
|
|
109
|
+
overwrite?: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Validation result
|
|
113
|
+
export interface ValidationResult {
|
|
114
|
+
valid: boolean;
|
|
115
|
+
errors: string[];
|
|
116
|
+
warnings: string[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Directory structure definition
|
|
120
|
+
export interface DirectorySpec {
|
|
121
|
+
path: string;
|
|
122
|
+
description?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Template metadata
|
|
126
|
+
export interface TemplateMetadata {
|
|
127
|
+
id: TemplateType;
|
|
128
|
+
name: string;
|
|
129
|
+
description: string;
|
|
130
|
+
keywords: string[];
|
|
131
|
+
features: string[];
|
|
132
|
+
language: LanguageType;
|
|
133
|
+
uiFramework: UiFrameworkType;
|
|
134
|
+
codePreview?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// CLI command options
|
|
138
|
+
export interface NewCommandOptions {
|
|
139
|
+
name?: string;
|
|
140
|
+
template?: string;
|
|
141
|
+
packageName?: string;
|
|
142
|
+
directory?: string;
|
|
143
|
+
minSdk?: number;
|
|
144
|
+
targetSdk?: number;
|
|
145
|
+
force?: boolean;
|
|
146
|
+
skipInstall?: boolean;
|
|
147
|
+
git?: boolean;
|
|
148
|
+
kotlin?: boolean;
|
|
149
|
+
verbose?: boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface InitCommandOptions {
|
|
153
|
+
force: boolean;
|
|
154
|
+
template?: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface InfoCommandOptions {
|
|
158
|
+
template?: string;
|
|
159
|
+
json: boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface ListCommandOptions {
|
|
163
|
+
json: boolean;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Default options
|
|
167
|
+
export const DEFAULT_GENERATION_OPTIONS: GenerationOptions = {
|
|
168
|
+
overwrite: false,
|
|
169
|
+
skipInstall: false,
|
|
170
|
+
dryRun: false,
|
|
171
|
+
verbose: false
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const DEFAULT_PROJECT_FEATURES: ProjectFeatures = {
|
|
175
|
+
git: true,
|
|
176
|
+
readme: true,
|
|
177
|
+
androidX: true,
|
|
178
|
+
kotlinDsl: true,
|
|
179
|
+
adaptiveIcon: true,
|
|
180
|
+
material3: true,
|
|
181
|
+
viewBinding: true,
|
|
182
|
+
dataBinding: false,
|
|
183
|
+
jetpackCompose: false
|
|
184
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template registry and metadata
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { TemplateType } from '../core/types.js';
|
|
6
|
+
|
|
7
|
+
interface TemplateMetadata {
|
|
8
|
+
id: TemplateType;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
keywords: string[];
|
|
12
|
+
features: string[];
|
|
13
|
+
language: 'kotlin' | 'java';
|
|
14
|
+
uiFramework: 'xml' | 'compose';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { TemplateMetadata };
|
|
18
|
+
|
|
19
|
+
export const TEMPLATE_REGISTRY: TemplateMetadata[] = [
|
|
20
|
+
{
|
|
21
|
+
id: 'kotlin-xml',
|
|
22
|
+
name: 'Kotlin with XML Layouts',
|
|
23
|
+
description: 'Traditional Android Views with Kotlin. Best for developers who prefer XML layouts and ViewBinding.',
|
|
24
|
+
keywords: ['kotlin', 'xml', 'views', 'viewbinding', 'material'],
|
|
25
|
+
features: ['Material Design 3', 'ViewBinding', 'Kotlin Coroutines', 'RecyclerView', 'ConstraintLayout'],
|
|
26
|
+
language: 'kotlin',
|
|
27
|
+
uiFramework: 'xml'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'kotlin-compose',
|
|
31
|
+
name: 'Kotlin with Jetpack Compose',
|
|
32
|
+
description: 'Modern declarative UI with Kotlin and Jetpack Compose. Latest Android UI toolkit with Material 3 support.',
|
|
33
|
+
keywords: ['kotlin', 'compose', 'declarative', 'material3', 'modern'],
|
|
34
|
+
features: ['Material Design 3', 'Compose Navigation', 'Kotlin Coroutines', 'ViewModel', 'Hilt'],
|
|
35
|
+
language: 'kotlin',
|
|
36
|
+
uiFramework: 'compose'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'java-xml',
|
|
40
|
+
name: 'Java with XML Layouts',
|
|
41
|
+
description: 'Traditional Android Views with Java. Ideal for teams maintaining Java codebases or preferring Java syntax.',
|
|
42
|
+
keywords: ['java', 'xml', 'views', 'viewbinding', 'legacy'],
|
|
43
|
+
features: ['Material Design 3', 'ViewBinding', 'Java 17', 'RecyclerView', 'ConstraintLayout'],
|
|
44
|
+
language: 'java',
|
|
45
|
+
uiFramework: 'xml'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'native-cpp',
|
|
49
|
+
name: 'Kotlin with Native C++/NDK',
|
|
50
|
+
description: 'Native C++ development with JNI integration. For high-performance code, game engines, or system-level programming.',
|
|
51
|
+
keywords: ['kotlin', 'native', 'cpp', 'ndk', 'jni', 'cmake'],
|
|
52
|
+
features: ['CMake Integration', 'JNI Bridge', 'Native Development', 'Multi-ABI Support', 'STL'],
|
|
53
|
+
language: 'kotlin',
|
|
54
|
+
uiFramework: 'xml'
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get template metadata by ID
|
|
60
|
+
*/
|
|
61
|
+
export function getTemplateMetadata(id: TemplateType): TemplateMetadata | undefined {
|
|
62
|
+
return TEMPLATE_REGISTRY.find((t) => t.id === id);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get all available templates
|
|
67
|
+
*/
|
|
68
|
+
export function getAllTemplates(): TemplateMetadata[] {
|
|
69
|
+
return [...TEMPLATE_REGISTRY];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Search templates by query
|
|
74
|
+
*/
|
|
75
|
+
export function searchTemplates(query: string): TemplateMetadata[] {
|
|
76
|
+
const lowerQuery = query.toLowerCase();
|
|
77
|
+
|
|
78
|
+
return TEMPLATE_REGISTRY.filter((template) => {
|
|
79
|
+
if (template.name.toLowerCase().includes(lowerQuery)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (template.description.toLowerCase().includes(lowerQuery)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (template.keywords.some((k) => k.toLowerCase().includes(lowerQuery))) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if (template.id.toLowerCase().includes(lowerQuery)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get templates by category
|
|
97
|
+
*/
|
|
98
|
+
export function getTemplatesByCategory(category: 'kotlin' | 'java' | 'native'): TemplateMetadata[] {
|
|
99
|
+
return TEMPLATE_REGISTRY.filter((t) => {
|
|
100
|
+
switch (category) {
|
|
101
|
+
case 'kotlin':
|
|
102
|
+
return t.id === 'kotlin-xml' || t.id === 'kotlin-compose' || t.id === 'native-cpp';
|
|
103
|
+
case 'java':
|
|
104
|
+
return t.id === 'java-xml';
|
|
105
|
+
case 'native':
|
|
106
|
+
return t.id === 'native-cpp';
|
|
107
|
+
default:
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get template preview code
|
|
115
|
+
*/
|
|
116
|
+
export function getTemplatePreview(id: TemplateType): string | undefined {
|
|
117
|
+
const previews: Record<string, string> = {
|
|
118
|
+
'kotlin-compose': `// MainActivity.kt
|
|
119
|
+
@Composable
|
|
120
|
+
fun MainScreen() {
|
|
121
|
+
var count by remember { mutableIntStateOf(0) }
|
|
122
|
+
|
|
123
|
+
Column(
|
|
124
|
+
modifier = Modifier
|
|
125
|
+
.fillMaxSize()
|
|
126
|
+
.padding(16.dp),
|
|
127
|
+
horizontalAlignment = Alignment.CenterHorizontally
|
|
128
|
+
) {
|
|
129
|
+
Text(
|
|
130
|
+
text = "Count: $count",
|
|
131
|
+
style = MaterialTheme.typography.headlineMedium
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}`,
|
|
135
|
+
'kotlin-xml': `// MainActivity.kt
|
|
136
|
+
class MainActivity : AppCompatActivity() {
|
|
137
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
138
|
+
super.onCreate(savedInstanceState)
|
|
139
|
+
setContentView(R.layout.activity_main)
|
|
140
|
+
}
|
|
141
|
+
}`,
|
|
142
|
+
'java-xml': `// MainActivity.java
|
|
143
|
+
public class MainActivity extends AppCompatActivity {
|
|
144
|
+
@Override
|
|
145
|
+
protected void onCreate(Bundle savedInstanceState) {
|
|
146
|
+
super.onCreate(savedInstanceState);
|
|
147
|
+
setContentView(R.layout.activity_main);
|
|
148
|
+
}
|
|
149
|
+
}`,
|
|
150
|
+
'native-cpp': `// native-lib.cpp
|
|
151
|
+
#include <jni.h>
|
|
152
|
+
#include <string>
|
|
153
|
+
|
|
154
|
+
extern "C" JNIEXPORT jstring JNICALL
|
|
155
|
+
Java_com_example_app_NativeLib_stringFromJNI(
|
|
156
|
+
JNIEnv* env, jobject /* this */) {
|
|
157
|
+
return env->NewStringUTF("Hello from C++");
|
|
158
|
+
}`
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
return previews[id];
|
|
162
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare module 'gradient-string' {
|
|
2
|
+
interface Gradient {
|
|
3
|
+
(text: string): string;
|
|
4
|
+
rainbow(text: string): string;
|
|
5
|
+
pastel(text: string): string;
|
|
6
|
+
ice(text: string): string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface GradientStatic {
|
|
10
|
+
(color1: string, color2: string): Gradient;
|
|
11
|
+
rainbow: Gradient;
|
|
12
|
+
pastel: Gradient;
|
|
13
|
+
teen: Gradient;
|
|
14
|
+
mind: Gradient;
|
|
15
|
+
summer: Gradient;
|
|
16
|
+
winter: Gradient;
|
|
17
|
+
autumn: Gradient;
|
|
18
|
+
spring: Gradient;
|
|
19
|
+
forest: Gradient;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const gradient: GradientStatic;
|
|
23
|
+
export default gradient;
|
|
24
|
+
export { Gradient, GradientStatic };
|
|
25
|
+
}
|
package/src/ui/colors.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color and text formatting utilities using picocolors and gradient-string
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import pc from 'picocolors';
|
|
6
|
+
import gradient from 'gradient-string';
|
|
7
|
+
|
|
8
|
+
// Style function to apply color based on type
|
|
9
|
+
export function style(text: string, type: 'primary' | 'success' | 'warning' | 'error' | 'info' | 'muted'): string {
|
|
10
|
+
switch (type) {
|
|
11
|
+
case 'primary':
|
|
12
|
+
return pc.cyan(text);
|
|
13
|
+
case 'success':
|
|
14
|
+
return pc.green(text);
|
|
15
|
+
case 'warning':
|
|
16
|
+
return pc.yellow(text);
|
|
17
|
+
case 'error':
|
|
18
|
+
return pc.red(text);
|
|
19
|
+
case 'info':
|
|
20
|
+
return pc.blue(text);
|
|
21
|
+
case 'muted':
|
|
22
|
+
return pc.gray(text);
|
|
23
|
+
default:
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Text formatting functions
|
|
29
|
+
export const bold = (text: string): string => pc.bold(text);
|
|
30
|
+
export const dim = (text: string): string => pc.dim(text);
|
|
31
|
+
export const underline = (text: string): string => pc.underline(text);
|
|
32
|
+
export const inverse = (text: string): string => pc.inverse(text);
|
|
33
|
+
export const italic = (text: string): string => pc.italic(text);
|
|
34
|
+
|
|
35
|
+
// Color functions
|
|
36
|
+
export const primary = (text: string): string => pc.cyan(text);
|
|
37
|
+
export const success = (text: string): string => pc.green(text);
|
|
38
|
+
export const warning = (text: string): string => pc.yellow(text);
|
|
39
|
+
export const error = (text: string): string => pc.red(text);
|
|
40
|
+
export const info = (text: string): string => pc.blue(text);
|
|
41
|
+
export const muted = (text: string): string => pc.gray(text);
|
|
42
|
+
|
|
43
|
+
// Aliases for backward compatibility
|
|
44
|
+
export const cyan = (text: string): string => pc.cyan(text);
|
|
45
|
+
export const green = (text: string): string => pc.green(text);
|
|
46
|
+
export const yellow = (text: string): string => pc.yellow(text);
|
|
47
|
+
export const red = (text: string): string => pc.red(text);
|
|
48
|
+
export const blue = (text: string): string => pc.blue(text);
|
|
49
|
+
export const gray = (text: string): string => pc.gray(text);
|
|
50
|
+
|
|
51
|
+
// Gradient functions using gradient-string
|
|
52
|
+
export function gradientTeen(text: string): string {
|
|
53
|
+
const g = gradient('#00C9FF', '#92FE9D');
|
|
54
|
+
return g(text);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function gradientRainbow(text: string): string {
|
|
58
|
+
return gradient.rainbow(text);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function gradientCool(text: string): string {
|
|
62
|
+
const g = gradient('#667eea', '#764ba2');
|
|
63
|
+
return g(text);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function gradientPassion(text: string): string {
|
|
67
|
+
const g = gradient('#ee0979', '#ff6a00');
|
|
68
|
+
return g(text);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Section formatting
|
|
72
|
+
export const header = (text: string): string => {
|
|
73
|
+
return bold(pc.cyan(pc.bold(`\n${text}\n`)));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const section = (text: string): string => {
|
|
77
|
+
return bold(pc.white(text));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const subsection = (text: string): string => {
|
|
81
|
+
return pc.dim(text);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Symbol functions for visual elements
|
|
85
|
+
export const checkmark = (text?: string): string => {
|
|
86
|
+
const symbol = pc.green('✓');
|
|
87
|
+
return text ? `${symbol} ${text}` : symbol;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const crossmark = (text?: string): string => {
|
|
91
|
+
const symbol = pc.red('✗');
|
|
92
|
+
return text ? `${symbol} ${text}` : symbol;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Arrow and bullet functions
|
|
96
|
+
export const bullet = (text: string): string => {
|
|
97
|
+
return `${pc.gray('•')} ${text}`;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const numbered = (num: number, text: string): string => {
|
|
101
|
+
return `${pc.gray(`${num}.`)} ${text}`;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const arrow = (text: string): string => {
|
|
105
|
+
return `${pc.gray('→')} ${text}`;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const rightArrow = (from: string, to: string): string => {
|
|
109
|
+
return `${from} ${pc.gray('→')} ${to}`;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Progress bar
|
|
113
|
+
export function progressBar(current: number, total: number, width: number = 20): string {
|
|
114
|
+
const percentage = Math.min(Math.max(current / total, 0), 1);
|
|
115
|
+
const filled = Math.round(percentage * width);
|
|
116
|
+
const empty = width - filled;
|
|
117
|
+
const filledBar = pc.green('█'.repeat(filled));
|
|
118
|
+
const emptyBar = pc.gray('░'.repeat(empty));
|
|
119
|
+
const percentText = pc.cyan(`${Math.round(percentage * 100)}%`);
|
|
120
|
+
return `${filledBar}${emptyBar} ${percentText}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Separator line
|
|
124
|
+
export function printSeparator(char: string = '─', length: number = 60): string {
|
|
125
|
+
return pc.gray(char.repeat(length));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Terminal control functions
|
|
129
|
+
export function clearLine(): void {
|
|
130
|
+
process.stdout.write('\r\x1B[K');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function cursorHide(): void {
|
|
134
|
+
process.stdout.write('\x1B[?25l');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function cursorShow(): void {
|
|
138
|
+
process.stdout.write('\x1B[?25h');
|
|
139
|
+
}
|