miniwork 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.
- package/README.md +36 -0
- package/bin/miniwork.js +187 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# MiniWork
|
|
2
|
+
|
|
3
|
+
Lightweight full-stack JavaScript framework with real-time database-to-UI synchronization.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx miniwork create my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
bun run dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or with npm:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx miniwork create my-app
|
|
17
|
+
cd my-app
|
|
18
|
+
npm run dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Bun-powered** - Fast runtime and bundler
|
|
24
|
+
- **SQLite** - Zero-config database
|
|
25
|
+
- **SSR** - Server-side rendering with JSX
|
|
26
|
+
- **HTMX** - Progressive enhancement
|
|
27
|
+
- **SSE** - Real-time updates
|
|
28
|
+
- **View Transitions** - Smooth page transitions
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
Visit [miniwork.hbhf.is/docs](https://miniwork.hbhf.is/docs) for full documentation.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|
package/bin/miniwork.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync, spawn } from 'child_process';
|
|
4
|
+
import { existsSync, mkdirSync, cpSync, readFileSync, writeFileSync } from 'fs';
|
|
5
|
+
import { join, resolve } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
9
|
+
|
|
10
|
+
const COLORS = {
|
|
11
|
+
reset: '\x1b[0m',
|
|
12
|
+
bright: '\x1b[1m',
|
|
13
|
+
green: '\x1b[32m',
|
|
14
|
+
cyan: '\x1b[36m',
|
|
15
|
+
yellow: '\x1b[33m',
|
|
16
|
+
red: '\x1b[31m',
|
|
17
|
+
gray: '\x1b[90m',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function log(message, color = '') {
|
|
21
|
+
console.log(`${color}${message}${COLORS.reset}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function logStep(step, message) {
|
|
25
|
+
log(`\n${COLORS.cyan}[${step}]${COLORS.reset} ${message}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function logSuccess(message) {
|
|
29
|
+
log(`${COLORS.green}✓${COLORS.reset} ${message}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function logError(message) {
|
|
33
|
+
log(`${COLORS.red}✗${COLORS.reset} ${message}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function showHelp() {
|
|
37
|
+
console.log(`
|
|
38
|
+
${COLORS.bright}MiniWork CLI${COLORS.reset} - Lightweight full-stack JavaScript framework
|
|
39
|
+
|
|
40
|
+
${COLORS.yellow}Usage:${COLORS.reset}
|
|
41
|
+
miniwork create <project-name> Create a new MiniWork project
|
|
42
|
+
miniwork help Show this help message
|
|
43
|
+
|
|
44
|
+
${COLORS.yellow}Examples:${COLORS.reset}
|
|
45
|
+
bunx miniwork create my-app
|
|
46
|
+
npx miniwork create my-app
|
|
47
|
+
|
|
48
|
+
${COLORS.yellow}Documentation:${COLORS.reset}
|
|
49
|
+
https://miniwork.hbhf.is/docs
|
|
50
|
+
`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function createProject(projectName) {
|
|
54
|
+
if (!projectName) {
|
|
55
|
+
logError('Please provide a project name');
|
|
56
|
+
console.log('\nUsage: miniwork create <project-name>');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const targetDir = resolve(process.cwd(), projectName);
|
|
61
|
+
|
|
62
|
+
if (existsSync(targetDir)) {
|
|
63
|
+
logError(`Directory "${projectName}" already exists`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(`
|
|
68
|
+
${COLORS.bright}Creating MiniWork project: ${COLORS.cyan}${projectName}${COLORS.reset}
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
// Clone from git
|
|
72
|
+
logStep('1/4', 'Downloading template...');
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
execSync(`git clone --depth 1 https://git.hbhf.is/olibuijr/miniwork.git "${targetDir}"`, {
|
|
76
|
+
stdio: 'pipe',
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Remove .git directory
|
|
80
|
+
execSync(`rm -rf "${join(targetDir, '.git')}"`, { stdio: 'pipe' });
|
|
81
|
+
|
|
82
|
+
// Remove packages directory (monorepo stuff)
|
|
83
|
+
execSync(`rm -rf "${join(targetDir, 'packages')}"`, { stdio: 'pipe' });
|
|
84
|
+
|
|
85
|
+
// Remove workflows
|
|
86
|
+
execSync(`rm -rf "${join(targetDir, '.gitea')}"`, { stdio: 'pipe' });
|
|
87
|
+
|
|
88
|
+
logSuccess('Template downloaded');
|
|
89
|
+
} catch (error) {
|
|
90
|
+
logError('Failed to download template');
|
|
91
|
+
console.error(error.message);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Update package.json
|
|
96
|
+
logStep('2/4', 'Configuring project...');
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const packageJsonPath = join(targetDir, 'package.json');
|
|
100
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
101
|
+
|
|
102
|
+
packageJson.name = projectName;
|
|
103
|
+
packageJson.version = '0.0.1';
|
|
104
|
+
packageJson.private = true;
|
|
105
|
+
delete packageJson.workspaces;
|
|
106
|
+
|
|
107
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
108
|
+
logSuccess('Project configured');
|
|
109
|
+
} catch (error) {
|
|
110
|
+
logError('Failed to configure project');
|
|
111
|
+
console.error(error.message);
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Install dependencies
|
|
116
|
+
logStep('3/4', 'Installing dependencies...');
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
// Detect package manager
|
|
120
|
+
const useBun = process.env.npm_execpath?.includes('bun') ||
|
|
121
|
+
process.argv[0]?.includes('bun') ||
|
|
122
|
+
existsSync(join(targetDir, 'bun.lock'));
|
|
123
|
+
|
|
124
|
+
const installCmd = useBun ? 'bun install' : 'npm install';
|
|
125
|
+
|
|
126
|
+
execSync(installCmd, {
|
|
127
|
+
cwd: targetDir,
|
|
128
|
+
stdio: 'inherit',
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
logSuccess('Dependencies installed');
|
|
132
|
+
} catch (error) {
|
|
133
|
+
logError('Failed to install dependencies');
|
|
134
|
+
console.error(error.message);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Initialize git
|
|
139
|
+
logStep('4/4', 'Initializing git repository...');
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
143
|
+
execSync('git add .', { cwd: targetDir, stdio: 'pipe' });
|
|
144
|
+
execSync('git commit -m "Initial commit from miniwork create"', {
|
|
145
|
+
cwd: targetDir,
|
|
146
|
+
stdio: 'pipe'
|
|
147
|
+
});
|
|
148
|
+
logSuccess('Git repository initialized');
|
|
149
|
+
} catch (error) {
|
|
150
|
+
// Git init is optional, don't fail
|
|
151
|
+
log(' (git init skipped)', COLORS.gray);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Done!
|
|
155
|
+
console.log(`
|
|
156
|
+
${COLORS.green}${COLORS.bright}✓ Project created successfully!${COLORS.reset}
|
|
157
|
+
|
|
158
|
+
${COLORS.yellow}Next steps:${COLORS.reset}
|
|
159
|
+
cd ${projectName}
|
|
160
|
+
bun run dev
|
|
161
|
+
|
|
162
|
+
${COLORS.gray}Your app will be running at http://localhost:6030${COLORS.reset}
|
|
163
|
+
|
|
164
|
+
${COLORS.gray}Default login: admin@admin.com / admin123${COLORS.reset}
|
|
165
|
+
`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Main
|
|
169
|
+
const args = process.argv.slice(2);
|
|
170
|
+
const command = args[0];
|
|
171
|
+
|
|
172
|
+
switch (command) {
|
|
173
|
+
case 'create':
|
|
174
|
+
createProject(args[1]);
|
|
175
|
+
break;
|
|
176
|
+
case 'help':
|
|
177
|
+
case '--help':
|
|
178
|
+
case '-h':
|
|
179
|
+
showHelp();
|
|
180
|
+
break;
|
|
181
|
+
default:
|
|
182
|
+
if (command) {
|
|
183
|
+
logError(`Unknown command: ${command}`);
|
|
184
|
+
}
|
|
185
|
+
showHelp();
|
|
186
|
+
process.exit(command ? 1 : 0);
|
|
187
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "miniwork",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MiniWork - Lightweight full-stack JavaScript framework with real-time database-to-UI sync",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"miniwork": "./bin/miniwork.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"templates"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"framework",
|
|
15
|
+
"bun",
|
|
16
|
+
"ssr",
|
|
17
|
+
"htmx",
|
|
18
|
+
"sse",
|
|
19
|
+
"real-time",
|
|
20
|
+
"sqlite",
|
|
21
|
+
"jsx"
|
|
22
|
+
],
|
|
23
|
+
"author": "olibuijr",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://git.hbhf.is/olibuijr/miniwork"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://miniwork.hbhf.is",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
}
|
|
33
|
+
}
|