andrud 1.0.0 → 1.0.2
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/README.md +69 -83
- package/dist/__tests__/context.test.d.ts +5 -0
- package/dist/__tests__/context.test.d.ts.map +1 -0
- package/dist/__tests__/context.test.js +86 -0
- package/dist/__tests__/context.test.js.map +1 -0
- package/dist/__tests__/generator.test.d.ts +5 -0
- package/dist/__tests__/generator.test.d.ts.map +1 -0
- package/dist/__tests__/generator.test.js +83 -0
- package/dist/__tests__/generator.test.js.map +1 -0
- package/dist/__tests__/validation.test.d.ts +5 -0
- package/dist/__tests__/validation.test.d.ts.map +1 -0
- package/dist/__tests__/validation.test.js +81 -0
- package/dist/__tests__/validation.test.js.map +1 -0
- package/dist/cli/commands/create.d.ts +10 -0
- package/dist/cli/commands/create.d.ts.map +1 -0
- package/dist/cli/commands/create.js +203 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/info.d.ts +13 -0
- package/dist/cli/commands/info.d.ts.map +1 -0
- package/dist/cli/commands/info.js +153 -0
- package/dist/cli/commands/info.js.map +1 -0
- package/dist/cli/commands/init.d.ts +15 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +141 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/list.d.ts +18 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +122 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/new.d.ts +22 -0
- package/dist/cli/commands/new.d.ts.map +1 -0
- package/dist/cli/commands/new.js +245 -0
- package/dist/cli/commands/new.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +99 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +89 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +151 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/context.d.ts +47 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/context.js +175 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/generator.d.ts +44 -0
- package/dist/core/generator.d.ts.map +1 -0
- package/{src/core/generator.ts → dist/core/generator.js} +394 -484
- package/dist/core/generator.js.map +1 -0
- package/dist/core/types.d.ts +125 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +22 -0
- package/dist/core/types.js.map +1 -0
- package/dist/templates/index.d.ts +36 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +141 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/ui/colors.d.ts +40 -0
- package/dist/ui/colors.d.ts.map +1 -0
- package/dist/ui/colors.js +117 -0
- package/dist/ui/colors.js.map +1 -0
- package/dist/ui/output.d.ts +69 -0
- package/dist/ui/output.d.ts.map +1 -0
- package/dist/ui/output.js +199 -0
- package/dist/ui/output.js.map +1 -0
- package/dist/ui/prompts.d.ts +20 -0
- package/dist/ui/prompts.d.ts.map +1 -0
- package/dist/ui/prompts.js +118 -0
- package/dist/ui/prompts.js.map +1 -0
- package/dist/ui/spinners.d.ts +30 -0
- package/dist/ui/spinners.d.ts.map +1 -0
- package/dist/ui/spinners.js +74 -0
- package/dist/ui/spinners.js.map +1 -0
- package/dist/ui/types.d.ts +35 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +5 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/utils/filesystem.d.ts +38 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +181 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/logger.d.ts +27 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +52 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/object.d.ts +140 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +385 -0
- package/dist/utils/object.js.map +1 -0
- package/dist/utils/validation.d.ts +35 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +270 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +8 -19
- package/CHANGELOG.md +0 -70
- package/CODE_REVIEW_ANALYSIS.md +0 -177
- package/CONTRIBUTING.md +0 -132
- package/FIXES_IMPLEMENTED.md +0 -546
- package/src/__tests__/context.test.ts +0 -133
- package/src/__tests__/generator.test.ts +0 -107
- package/src/__tests__/validation.test.ts +0 -105
- package/src/cli/commands/create.ts +0 -252
- package/src/cli/commands/info.ts +0 -178
- package/src/cli/commands/init.ts +0 -186
- package/src/cli/commands/list.ts +0 -156
- package/src/cli/commands/new.ts +0 -316
- package/src/cli/index.ts +0 -116
- package/src/core/config.ts +0 -172
- package/src/core/context.ts +0 -212
- package/src/core/types.ts +0 -184
- package/src/templates/index.ts +0 -162
- package/src/types/gradient-string.d.ts +0 -25
- package/src/ui/colors.ts +0 -139
- package/src/ui/output.ts +0 -230
- package/src/ui/prompts.ts +0 -170
- package/src/ui/spinners.ts +0 -95
- package/src/ui/types.ts +0 -41
- package/src/utils/filesystem.ts +0 -222
- package/src/utils/logger.ts +0 -67
- package/src/utils/object.ts +0 -456
- package/src/utils/validation.ts +0 -345
- package/tsconfig.json +0 -25
package/src/utils/filesystem.ts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File system utilities using fs-extra
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import fse from 'fs-extra';
|
|
6
|
-
import { resolve, join, dirname, basename, extname, relative, normalize, isAbsolute } from 'path';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
|
|
9
|
-
// Check if path exists
|
|
10
|
-
export async function exists(path: string): Promise<boolean> {
|
|
11
|
-
try {
|
|
12
|
-
await fse.access(path);
|
|
13
|
-
return true;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Check if path is a directory
|
|
20
|
-
export async function isDirectory(path: string): Promise<boolean> {
|
|
21
|
-
try {
|
|
22
|
-
const stats = await fse.stat(path);
|
|
23
|
-
return stats.isDirectory();
|
|
24
|
-
} catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Check if path is a file
|
|
30
|
-
export async function isFile(path: string): Promise<boolean> {
|
|
31
|
-
try {
|
|
32
|
-
const stats = await fse.stat(path);
|
|
33
|
-
return stats.isFile();
|
|
34
|
-
} catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Read file content
|
|
40
|
-
export async function readFile(path: string): Promise<string> {
|
|
41
|
-
return fse.readFile(path, 'utf-8');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Write file content
|
|
45
|
-
export async function writeFile(path: string, content: string): Promise<void> {
|
|
46
|
-
await fse.writeFile(path, content, 'utf-8');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Read JSON file
|
|
50
|
-
export async function readJson<T = unknown>(path: string): Promise<T> {
|
|
51
|
-
return fse.readJson(path) as Promise<T>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Write JSON file
|
|
55
|
-
export async function writeJson(path: string, data: unknown, spaces: number = 2): Promise<void> {
|
|
56
|
-
await fse.writeJson(path, data, { spaces });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Copy file
|
|
60
|
-
export async function copyFile(source: string, destination: string): Promise<void> {
|
|
61
|
-
await fse.copy(source, destination);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Move file
|
|
65
|
-
export async function moveFile(source: string, destination: string): Promise<void> {
|
|
66
|
-
await fse.move(source, destination);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Remove file
|
|
70
|
-
export async function removeFile(path: string): Promise<void> {
|
|
71
|
-
try {
|
|
72
|
-
await fse.remove(path);
|
|
73
|
-
} catch {
|
|
74
|
-
// Ignore errors if file doesn't exist
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Create directory
|
|
79
|
-
export async function createDirectory(path: string): Promise<void> {
|
|
80
|
-
await fse.mkdir(path, { recursive: true });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Remove directory
|
|
84
|
-
export async function removeDirectory(path: string): Promise<void> {
|
|
85
|
-
try {
|
|
86
|
-
await fse.remove(path);
|
|
87
|
-
} catch {
|
|
88
|
-
// Ignore errors if directory doesn't exist
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Copy directory
|
|
93
|
-
export async function copyDirectory(source: string, destination: string): Promise<void> {
|
|
94
|
-
await fse.copy(source, destination);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Ensure directory exists
|
|
98
|
-
export async function ensureDirectory(path: string): Promise<void> {
|
|
99
|
-
await fse.ensureDir(path);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Ensure file exists (creates empty file if it doesn't)
|
|
103
|
-
export async function ensureFile(path: string): Promise<void> {
|
|
104
|
-
await fse.ensureFile(path);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Get absolute path
|
|
108
|
-
export function getAbsolutePath(path: string): string {
|
|
109
|
-
if (isAbsolute(path)) {
|
|
110
|
-
return normalize(path);
|
|
111
|
-
}
|
|
112
|
-
return resolve(getCurrentWorkingDirectory(), path);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Normalize path
|
|
116
|
-
export function normalizePath(path: string): string {
|
|
117
|
-
return normalize(path);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Join path segments
|
|
121
|
-
export function joinPath(...paths: string[]): string {
|
|
122
|
-
return join(...paths);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Get directory name
|
|
126
|
-
export function dirnamePath(path: string): string {
|
|
127
|
-
return dirname(path);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Get base name
|
|
131
|
-
export function basenamePath(path: string, ext?: string): string {
|
|
132
|
-
return basename(path, ext);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Get extension
|
|
136
|
-
export function extnamePath(path: string): string {
|
|
137
|
-
return extname(path);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Get relative path
|
|
141
|
-
export function relativePath(from: string, to: string): string {
|
|
142
|
-
return relative(from, to);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Get current working directory
|
|
146
|
-
export function getCurrentWorkingDirectory(): string {
|
|
147
|
-
return process.cwd();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Get package root directory
|
|
151
|
-
export function getPackageRoot(): string {
|
|
152
|
-
const currentFile = import.meta.url;
|
|
153
|
-
if (currentFile.startsWith('file://')) {
|
|
154
|
-
const currentDir = fileURLToPath(new URL('.', currentFile));
|
|
155
|
-
return resolve(currentDir, '..');
|
|
156
|
-
}
|
|
157
|
-
return getCurrentWorkingDirectory();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// List files in directory
|
|
161
|
-
export async function listFiles(directory: string, extensions?: string[]): Promise<string[]> {
|
|
162
|
-
const files: string[] = [];
|
|
163
|
-
|
|
164
|
-
async function walk(dir: string): Promise<void> {
|
|
165
|
-
const entries = await fse.readdir(dir, { withFileTypes: true });
|
|
166
|
-
for (const entry of entries) {
|
|
167
|
-
const fullPath = join(dir, entry.name);
|
|
168
|
-
if (entry.isDirectory()) {
|
|
169
|
-
await walk(fullPath);
|
|
170
|
-
} else if (entry.isFile()) {
|
|
171
|
-
if (!extensions || extensions.some(ext => entry.name.endsWith(ext))) {
|
|
172
|
-
files.push(fullPath);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
await walk(directory);
|
|
179
|
-
return files;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Read directory contents
|
|
183
|
-
export async function readDirectory(directory: string): Promise<string[]> {
|
|
184
|
-
return fse.readdir(directory);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Write file with timeout protection
|
|
189
|
-
*/
|
|
190
|
-
export async function writeFileWithTimeout(
|
|
191
|
-
path: string,
|
|
192
|
-
content: string,
|
|
193
|
-
timeoutMs: number = 5000
|
|
194
|
-
): Promise<void> {
|
|
195
|
-
return Promise.race([
|
|
196
|
-
writeFile(path, content),
|
|
197
|
-
new Promise<void>((_, reject) =>
|
|
198
|
-
setTimeout(
|
|
199
|
-
() => reject(new Error(`Write operation timeout after ${timeoutMs}ms`)),
|
|
200
|
-
timeoutMs
|
|
201
|
-
)
|
|
202
|
-
)
|
|
203
|
-
]);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Create directory with timeout protection
|
|
208
|
-
*/
|
|
209
|
-
export async function createDirectoryWithTimeout(
|
|
210
|
-
path: string,
|
|
211
|
-
timeoutMs: number = 5000
|
|
212
|
-
): Promise<void> {
|
|
213
|
-
return Promise.race([
|
|
214
|
-
createDirectory(path),
|
|
215
|
-
new Promise<void>((_, reject) =>
|
|
216
|
-
setTimeout(
|
|
217
|
-
() => reject(new Error(`Create directory operation timeout after ${timeoutMs}ms`)),
|
|
218
|
-
timeoutMs
|
|
219
|
-
)
|
|
220
|
-
)
|
|
221
|
-
]);
|
|
222
|
-
}
|
package/src/utils/logger.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logging utilities with structured logging levels
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import pc from 'picocolors';
|
|
6
|
-
|
|
7
|
-
export enum LogLevel {
|
|
8
|
-
DEBUG = 0,
|
|
9
|
-
INFO = 1,
|
|
10
|
-
WARN = 2,
|
|
11
|
-
ERROR = 3
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface LoggerOptions {
|
|
15
|
-
level?: LogLevel;
|
|
16
|
-
verbose?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class Logger {
|
|
20
|
-
private level: LogLevel;
|
|
21
|
-
private verbose: boolean;
|
|
22
|
-
|
|
23
|
-
constructor(options: LoggerOptions = {}) {
|
|
24
|
-
this.level = options.level ?? LogLevel.INFO;
|
|
25
|
-
this.verbose = options.verbose ?? false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
debug(message: string, data?: unknown): void {
|
|
29
|
-
if (this.level <= LogLevel.DEBUG) {
|
|
30
|
-
console.log(pc.gray(`[DEBUG] ${message}`), data ?? '');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
info(message: string, data?: unknown): void {
|
|
35
|
-
if (this.level <= LogLevel.INFO) {
|
|
36
|
-
console.log(pc.blue(`[INFO] ${message}`), data ?? '');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
warn(message: string, data?: unknown): void {
|
|
41
|
-
if (this.level <= LogLevel.WARN) {
|
|
42
|
-
console.log(pc.yellow(`[WARN] ${message}`), data ?? '');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
error(message: string, error?: Error | string): void {
|
|
47
|
-
console.error(pc.red(`[ERROR] ${message}`), error ?? '');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
success(message: string): void {
|
|
51
|
-
console.log(pc.green(`[SUCCESS] ${message}`));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
setLevel(level: LogLevel): void {
|
|
55
|
-
this.level = level;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setVerbose(verbose: boolean): void {
|
|
59
|
-
this.verbose = verbose;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Create default logger instance
|
|
64
|
-
export const defaultLogger = new Logger({
|
|
65
|
-
level: process.env.DEBUG ? LogLevel.DEBUG : LogLevel.INFO,
|
|
66
|
-
verbose: process.env.VERBOSE === 'true'
|
|
67
|
-
});
|