@simplens/onboard 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 +331 -214
- package/dist/__tests__/env-config.test.d.ts +2 -0
- package/dist/__tests__/env-config.test.d.ts.map +1 -0
- package/dist/__tests__/env-config.test.js +23 -0
- package/dist/__tests__/env-config.test.js.map +1 -0
- package/dist/__tests__/infra-prompts.test.d.ts +2 -0
- package/dist/__tests__/infra-prompts.test.d.ts.map +1 -0
- package/dist/__tests__/infra-prompts.test.js +43 -0
- package/dist/__tests__/infra-prompts.test.js.map +1 -0
- package/dist/__tests__/infra.test.d.ts +2 -0
- package/dist/__tests__/infra.test.d.ts.map +1 -0
- package/dist/__tests__/infra.test.js +14 -0
- package/dist/__tests__/infra.test.js.map +1 -0
- package/dist/__tests__/nginx.test.d.ts +2 -0
- package/dist/__tests__/nginx.test.d.ts.map +1 -0
- package/dist/__tests__/nginx.test.js +16 -0
- package/dist/__tests__/nginx.test.js.map +1 -0
- package/dist/env-config.d.ts +27 -12
- package/dist/env-config.d.ts.map +1 -1
- package/dist/env-config.js +258 -141
- package/dist/env-config.js.map +1 -1
- package/dist/index.js +341 -71
- package/dist/index.js.map +1 -1
- package/dist/infra.d.ts +17 -14
- package/dist/infra.d.ts.map +1 -1
- package/dist/infra.js +265 -176
- package/dist/infra.js.map +1 -1
- package/dist/plugins.d.ts +5 -10
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +75 -44
- package/dist/plugins.js.map +1 -1
- package/dist/services.d.ts +1 -23
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +47 -62
- package/dist/services.js.map +1 -1
- package/dist/templates.d.ts +3 -2
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +203 -198
- package/dist/templates.js.map +1 -1
- package/dist/types/domain.d.ts +2 -0
- package/dist/types/domain.d.ts.map +1 -1
- package/dist/ui.d.ts +45 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +93 -0
- package/dist/ui.js.map +1 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +32 -7
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +66 -2
- package/dist/utils.js.map +1 -1
- package/dist/validators.d.ts +1 -52
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +10 -57
- package/dist/validators.js.map +1 -1
- package/package.json +3 -5
- package/src/__tests__/env-config.test.ts +28 -0
- package/src/__tests__/errors.test.ts +187 -187
- package/src/__tests__/infra-prompts.test.ts +54 -0
- package/src/__tests__/infra.test.ts +15 -0
- package/src/__tests__/utils.test.ts +142 -142
- package/src/__tests__/validators.test.ts +195 -195
- package/src/config/constants.ts +86 -86
- package/src/config/index.ts +1 -1
- package/src/env-config.ts +455 -320
- package/src/index.ts +534 -203
- package/src/infra.ts +404 -300
- package/src/plugins.ts +221 -190
- package/src/services.ts +175 -190
- package/src/templates.ts +209 -203
- package/src/types/domain.ts +129 -127
- package/src/types/errors.ts +173 -173
- package/src/types/index.ts +2 -2
- package/src/ui.ts +91 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/logger.ts +144 -118
- package/src/utils.ts +183 -105
- package/src/validators.ts +145 -192
- package/tsconfig.json +18 -18
- package/vitest.config.ts +22 -20
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { promises as fs } from 'fs';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import {
|
|
6
|
-
fileExists,
|
|
7
|
-
writeFile,
|
|
8
|
-
readFile,
|
|
9
|
-
appendFile,
|
|
10
|
-
} from '../utils.js';
|
|
11
|
-
|
|
12
|
-
describe('utils - file operations', () => {
|
|
13
|
-
let tempDir: string;
|
|
14
|
-
|
|
15
|
-
beforeEach(async () => {
|
|
16
|
-
// Create a temporary directory for tests
|
|
17
|
-
tempDir = path.join(os.tmpdir(), `onboard-test-${Date.now()}`);
|
|
18
|
-
await fs.mkdir(tempDir, { recursive: true });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(async () => {
|
|
22
|
-
// Clean up temporary directory
|
|
23
|
-
try {
|
|
24
|
-
await fs.rm(tempDir, { recursive: true, force: true });
|
|
25
|
-
} catch (error) {
|
|
26
|
-
// Ignore cleanup errors
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('fileExists', () => {
|
|
31
|
-
it('should return true for existing file', async () => {
|
|
32
|
-
const filePath = path.join(tempDir, 'test.txt');
|
|
33
|
-
await fs.writeFile(filePath, 'content');
|
|
34
|
-
|
|
35
|
-
expect(await fileExists(filePath)).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should return false for non-existing file', async () => {
|
|
39
|
-
const filePath = path.join(tempDir, 'nonexistent.txt');
|
|
40
|
-
|
|
41
|
-
expect(await fileExists(filePath)).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should return true for existing directory', async () => {
|
|
45
|
-
expect(await fileExists(tempDir)).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('writeFile', () => {
|
|
50
|
-
it('should write content to file', async () => {
|
|
51
|
-
const filePath = path.join(tempDir, 'write-test.txt');
|
|
52
|
-
const content = 'Hello, World!';
|
|
53
|
-
|
|
54
|
-
await writeFile(filePath, content);
|
|
55
|
-
|
|
56
|
-
const written = await fs.readFile(filePath, 'utf-8');
|
|
57
|
-
expect(written).toBe(content);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should create parent directories if they do not exist', async () => {
|
|
61
|
-
const filePath = path.join(tempDir, 'nested', 'dir', 'file.txt');
|
|
62
|
-
const content = 'Nested content';
|
|
63
|
-
|
|
64
|
-
await writeFile(filePath, content);
|
|
65
|
-
|
|
66
|
-
expect(await fileExists(filePath)).toBe(true);
|
|
67
|
-
const written = await fs.readFile(filePath, 'utf-8');
|
|
68
|
-
expect(written).toBe(content);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should overwrite existing file', async () => {
|
|
72
|
-
const filePath = path.join(tempDir, 'overwrite.txt');
|
|
73
|
-
|
|
74
|
-
await fs.writeFile(filePath, 'original');
|
|
75
|
-
await writeFile(filePath, 'new content');
|
|
76
|
-
|
|
77
|
-
const written = await fs.readFile(filePath, 'utf-8');
|
|
78
|
-
expect(written).toBe('new content');
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('readFile', () => {
|
|
83
|
-
it('should read file content', async () => {
|
|
84
|
-
const filePath = path.join(tempDir, 'read-test.txt');
|
|
85
|
-
const content = 'File content to read';
|
|
86
|
-
await fs.writeFile(filePath, content);
|
|
87
|
-
|
|
88
|
-
const read = await readFile(filePath);
|
|
89
|
-
|
|
90
|
-
expect(read).toBe(content);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should throw error for non-existing file', async () => {
|
|
94
|
-
const filePath = path.join(tempDir, 'nonexistent.txt');
|
|
95
|
-
|
|
96
|
-
await expect(readFile(filePath)).rejects.toThrow();
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('should handle UTF-8 content', async () => {
|
|
100
|
-
const filePath = path.join(tempDir, 'utf8.txt');
|
|
101
|
-
const content = 'Hello 世界 🌍';
|
|
102
|
-
await fs.writeFile(filePath, content);
|
|
103
|
-
|
|
104
|
-
const read = await readFile(filePath);
|
|
105
|
-
|
|
106
|
-
expect(read).toBe(content);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('appendFile', () => {
|
|
111
|
-
it('should append content to existing file', async () => {
|
|
112
|
-
const filePath = path.join(tempDir, 'append-test.txt');
|
|
113
|
-
await fs.writeFile(filePath, 'Line 1\n');
|
|
114
|
-
|
|
115
|
-
await appendFile(filePath, 'Line 2\n');
|
|
116
|
-
|
|
117
|
-
const content = await fs.readFile(filePath, 'utf-8');
|
|
118
|
-
expect(content).toBe('Line 1\nLine 2\n');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should create file if it does not exist', async () => {
|
|
122
|
-
const filePath = path.join(tempDir, 'new-append.txt');
|
|
123
|
-
|
|
124
|
-
await appendFile(filePath, 'First line\n');
|
|
125
|
-
|
|
126
|
-
expect(await fileExists(filePath)).toBe(true);
|
|
127
|
-
const content = await fs.readFile(filePath, 'utf-8');
|
|
128
|
-
expect(content).toBe('First line\n');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should handle multiple appends', async () => {
|
|
132
|
-
const filePath = path.join(tempDir, 'multi-append.txt');
|
|
133
|
-
|
|
134
|
-
await appendFile(filePath, 'Line 1\n');
|
|
135
|
-
await appendFile(filePath, 'Line 2\n');
|
|
136
|
-
await appendFile(filePath, 'Line 3\n');
|
|
137
|
-
|
|
138
|
-
const content = await fs.readFile(filePath, 'utf-8');
|
|
139
|
-
expect(content).toBe('Line 1\nLine 2\nLine 3\n');
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import {
|
|
6
|
+
fileExists,
|
|
7
|
+
writeFile,
|
|
8
|
+
readFile,
|
|
9
|
+
appendFile,
|
|
10
|
+
} from '../utils.js';
|
|
11
|
+
|
|
12
|
+
describe('utils - file operations', () => {
|
|
13
|
+
let tempDir: string;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
// Create a temporary directory for tests
|
|
17
|
+
tempDir = path.join(os.tmpdir(), `onboard-test-${Date.now()}`);
|
|
18
|
+
await fs.mkdir(tempDir, { recursive: true });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(async () => {
|
|
22
|
+
// Clean up temporary directory
|
|
23
|
+
try {
|
|
24
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
25
|
+
} catch (error) {
|
|
26
|
+
// Ignore cleanup errors
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('fileExists', () => {
|
|
31
|
+
it('should return true for existing file', async () => {
|
|
32
|
+
const filePath = path.join(tempDir, 'test.txt');
|
|
33
|
+
await fs.writeFile(filePath, 'content');
|
|
34
|
+
|
|
35
|
+
expect(await fileExists(filePath)).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should return false for non-existing file', async () => {
|
|
39
|
+
const filePath = path.join(tempDir, 'nonexistent.txt');
|
|
40
|
+
|
|
41
|
+
expect(await fileExists(filePath)).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should return true for existing directory', async () => {
|
|
45
|
+
expect(await fileExists(tempDir)).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('writeFile', () => {
|
|
50
|
+
it('should write content to file', async () => {
|
|
51
|
+
const filePath = path.join(tempDir, 'write-test.txt');
|
|
52
|
+
const content = 'Hello, World!';
|
|
53
|
+
|
|
54
|
+
await writeFile(filePath, content);
|
|
55
|
+
|
|
56
|
+
const written = await fs.readFile(filePath, 'utf-8');
|
|
57
|
+
expect(written).toBe(content);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should create parent directories if they do not exist', async () => {
|
|
61
|
+
const filePath = path.join(tempDir, 'nested', 'dir', 'file.txt');
|
|
62
|
+
const content = 'Nested content';
|
|
63
|
+
|
|
64
|
+
await writeFile(filePath, content);
|
|
65
|
+
|
|
66
|
+
expect(await fileExists(filePath)).toBe(true);
|
|
67
|
+
const written = await fs.readFile(filePath, 'utf-8');
|
|
68
|
+
expect(written).toBe(content);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should overwrite existing file', async () => {
|
|
72
|
+
const filePath = path.join(tempDir, 'overwrite.txt');
|
|
73
|
+
|
|
74
|
+
await fs.writeFile(filePath, 'original');
|
|
75
|
+
await writeFile(filePath, 'new content');
|
|
76
|
+
|
|
77
|
+
const written = await fs.readFile(filePath, 'utf-8');
|
|
78
|
+
expect(written).toBe('new content');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('readFile', () => {
|
|
83
|
+
it('should read file content', async () => {
|
|
84
|
+
const filePath = path.join(tempDir, 'read-test.txt');
|
|
85
|
+
const content = 'File content to read';
|
|
86
|
+
await fs.writeFile(filePath, content);
|
|
87
|
+
|
|
88
|
+
const read = await readFile(filePath);
|
|
89
|
+
|
|
90
|
+
expect(read).toBe(content);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should throw error for non-existing file', async () => {
|
|
94
|
+
const filePath = path.join(tempDir, 'nonexistent.txt');
|
|
95
|
+
|
|
96
|
+
await expect(readFile(filePath)).rejects.toThrow();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should handle UTF-8 content', async () => {
|
|
100
|
+
const filePath = path.join(tempDir, 'utf8.txt');
|
|
101
|
+
const content = 'Hello 世界 🌍';
|
|
102
|
+
await fs.writeFile(filePath, content);
|
|
103
|
+
|
|
104
|
+
const read = await readFile(filePath);
|
|
105
|
+
|
|
106
|
+
expect(read).toBe(content);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('appendFile', () => {
|
|
111
|
+
it('should append content to existing file', async () => {
|
|
112
|
+
const filePath = path.join(tempDir, 'append-test.txt');
|
|
113
|
+
await fs.writeFile(filePath, 'Line 1\n');
|
|
114
|
+
|
|
115
|
+
await appendFile(filePath, 'Line 2\n');
|
|
116
|
+
|
|
117
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
118
|
+
expect(content).toBe('Line 1\nLine 2\n');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should create file if it does not exist', async () => {
|
|
122
|
+
const filePath = path.join(tempDir, 'new-append.txt');
|
|
123
|
+
|
|
124
|
+
await appendFile(filePath, 'First line\n');
|
|
125
|
+
|
|
126
|
+
expect(await fileExists(filePath)).toBe(true);
|
|
127
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
128
|
+
expect(content).toBe('First line\n');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should handle multiple appends', async () => {
|
|
132
|
+
const filePath = path.join(tempDir, 'multi-append.txt');
|
|
133
|
+
|
|
134
|
+
await appendFile(filePath, 'Line 1\n');
|
|
135
|
+
await appendFile(filePath, 'Line 2\n');
|
|
136
|
+
await appendFile(filePath, 'Line 3\n');
|
|
137
|
+
|
|
138
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
139
|
+
expect(content).toBe('Line 1\nLine 2\nLine 3\n');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|