@africode/core 5.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/AFRICODE_FRAMEWORK_GUIDE.md +707 -0
- package/LICENSE +623 -0
- package/README.md +442 -0
- package/bin/africode.js +73 -0
- package/bin/africode.js.1758507140 +343 -0
- package/bin/cli.ts +83 -0
- package/bin/create-africode.js +158 -0
- package/bin/scaffold.ts +219 -0
- package/components/accordion.js +183 -0
- package/components/alert.js +131 -0
- package/components/auth.js +172 -0
- package/components/avatar.js +117 -0
- package/components/badge.js +104 -0
- package/components/base.d.ts +139 -0
- package/components/base.js +184 -0
- package/components/button.js +164 -0
- package/components/card.js +137 -0
- package/components/cultural-card.js +243 -0
- package/components/divider.js +83 -0
- package/components/dropdown.js +171 -0
- package/components/error-boundary.js +155 -0
- package/components/form.js +131 -0
- package/components/grid.js +273 -0
- package/components/hero.js +138 -0
- package/components/icon.js +36 -0
- package/components/index.js +57 -0
- package/components/input.js +256 -0
- package/components/kanga-card.js +185 -0
- package/components/language-switcher.js +108 -0
- package/components/loader.js +80 -0
- package/components/modal.js +262 -0
- package/components/motion.js +84 -0
- package/components/navbar.js +236 -0
- package/components/pattern-showcase.js +225 -0
- package/components/progress.js +134 -0
- package/components/react.js +111 -0
- package/components/section.js +54 -0
- package/components/select.js +322 -0
- package/components/sidebar.js +180 -0
- package/components/skeleton.js +85 -0
- package/components/table.js +181 -0
- package/components/tabs.js +202 -0
- package/components/theme-toggle.js +82 -0
- package/components/toast.js +139 -0
- package/components/tooltip.js +167 -0
- package/core/a2ui-schema-manager.js +344 -0
- package/core/a2ui.js +431 -0
- package/core/bun-runtime.js +799 -0
- package/core/cli/commands/add.js +23 -0
- package/core/cli/commands/audit.js +58 -0
- package/core/cli/commands/build.js +137 -0
- package/core/cli/commands/create-plugin.js +241 -0
- package/core/cli/commands/dev.js +228 -0
- package/core/cli/commands/lint.js +23 -0
- package/core/cli/commands/test.js +34 -0
- package/core/cli/migrator.js +71 -0
- package/core/cli/ui.js +46 -0
- package/core/compliance.js +628 -0
- package/core/config.js +263 -0
- package/core/db-advanced.js +481 -0
- package/core/db.js +284 -0
- package/core/enhanced-hmr.js +404 -0
- package/core/errors.js +222 -0
- package/core/file-router.js +290 -0
- package/core/heartbeat.js +64 -0
- package/core/hmr-client.js +204 -0
- package/core/hmr.js +196 -0
- package/core/html.d.ts +116 -0
- package/core/html.js +160 -0
- package/core/hydration.js +52 -0
- package/core/lipa-namba-journey.js +572 -0
- package/core/motion.js +106 -0
- package/core/nida-cig-middleware.js +455 -0
- package/core/patterns.d.ts +124 -0
- package/core/patterns.js +833 -0
- package/core/plugins/index.js +312 -0
- package/core/router.js +387 -0
- package/core/sdk-client.js +62 -0
- package/core/sdk.d.ts +133 -0
- package/core/sdk.js +123 -0
- package/core/seo.js +76 -0
- package/core/server/auth-endpoints.js +339 -0
- package/core/server/auth.js +180 -0
- package/core/server/csrf.js +206 -0
- package/core/server/db.js +39 -0
- package/core/server/middleware.js +324 -0
- package/core/server/rate-limit.js +238 -0
- package/core/server/render.js +69 -0
- package/core/server/router.js +120 -0
- package/core/shim.js +28 -0
- package/core/state.d.ts +86 -0
- package/core/state.js +242 -0
- package/core/store.d.ts +122 -0
- package/core/store.js +61 -0
- package/core/validation.d.ts +233 -0
- package/core/validation.js +590 -0
- package/core/websocket.js +639 -0
- package/dist/africode.js +2905 -0
- package/dist/africode.js.map +61 -0
- package/dist/build-info.json +23 -0
- package/dist/components.js +2888 -0
- package/dist/components.js.map +58 -0
- package/dist/styles/africanity.css +322 -0
- package/dist/styles/typography.css +141 -0
- package/docs/IDE-Guide.md +50 -0
- package/package.json +110 -0
- package/src/index.ts +196 -0
- package/styles/africanity.css +322 -0
- package/styles/typography.css +141 -0
- package/templates/starter/.env.example +15 -0
- package/templates/starter/africode.config.js +40 -0
- package/templates/starter/package.json +14 -0
- package/templates/starter/src/pages/index.html +46 -0
- package/templates/starter/src/pages/index.js +32 -0
- package/templates/starter/src/styles/main.css +4 -0
- package/templates/starter-3d/.env.example +7 -0
- package/templates/starter-3d/africode.config.js +29 -0
- package/templates/starter-3d/components/af-model-viewer.js +125 -0
- package/templates/starter-3d/package.json +15 -0
- package/templates/starter-3d/src/pages/index.html +46 -0
- package/templates/starter-3d/src/pages/index.js +50 -0
- package/templates/starter-3d/src/styles/main.css +4 -0
- package/templates/starter-react/.env.example +15 -0
- package/templates/starter-react/africode.config.js +40 -0
- package/templates/starter-react/package.json +16 -0
- package/templates/starter-react/src/pages/index.html +46 -0
- package/templates/starter-react/src/pages/index.js +68 -0
- package/templates/starter-react/src/styles/main.css +4 -0
- package/templates/starter-tailwind/.env.example +15 -0
- package/templates/starter-tailwind/africode.config.js +40 -0
- package/templates/starter-tailwind/package.json +20 -0
- package/templates/starter-tailwind/src/pages/index.html +46 -0
- package/templates/starter-tailwind/src/pages/index.js +37 -0
- package/templates/starter-tailwind/src/styles/main.css +4 -0
- package/templates/starter-tailwind/src/styles/tailwind.css +1 -0
- package/templates/starter-tailwind/src/tailwind-loader.js +30 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
|
|
3
|
+
export async function lint() {
|
|
4
|
+
console.log('\n🌍 AfriCode Code Quality Pipeline');
|
|
5
|
+
console.log('Running ESLint analysis...\n');
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const result = spawnSync('bunx', ['eslint', '.', '--ext', '.js,.jsx,.ts,.tsx'], {
|
|
9
|
+
stdio: 'inherit',
|
|
10
|
+
cwd: process.cwd(),
|
|
11
|
+
shell: true
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (result.status === 0) {
|
|
15
|
+
console.log('\n✅ Code quality checks passed.');
|
|
16
|
+
} else {
|
|
17
|
+
console.error('\n❌ Code quality checks failed. Please review the errors above.');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error('Failed to start ESLint:', err);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
export async function test() {
|
|
5
|
+
console.log('\n🌍 AfriCode Testing Suite');
|
|
6
|
+
console.log('Running Bun test runner with happy-dom environment...\n');
|
|
7
|
+
|
|
8
|
+
// Parse incoming CLI arguments to allow 'africode test --watch'
|
|
9
|
+
const userArgs = process.argv.slice(3); // slice out node, africode.js, test
|
|
10
|
+
|
|
11
|
+
// We execute 'bun test', but since AfriCode components rely on DOM,
|
|
12
|
+
// we ensure the user has --preload if it exists, or suggest it.
|
|
13
|
+
// In a user project context, the test script in package.json will run it.
|
|
14
|
+
|
|
15
|
+
// We just wrap the user's `bun test` context.
|
|
16
|
+
const args = ['test', ...userArgs];
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const result = spawnSync('bun', args, {
|
|
20
|
+
stdio: 'inherit',
|
|
21
|
+
cwd: process.cwd(),
|
|
22
|
+
shell: true
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (result.status === 0) {
|
|
26
|
+
console.log('\n✅ All tests passed.');
|
|
27
|
+
} else {
|
|
28
|
+
console.error('\n❌ Tests failed.');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error('Failed to start test suite:', err);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AfriCode Migration Engine
|
|
3
|
+
*
|
|
4
|
+
* Scans `migrations/` folder for .sql files and executes them.
|
|
5
|
+
* Tracks applied migrations in `_migrations` table.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Database } from "bun:sqlite";
|
|
9
|
+
import fs from "fs";
|
|
10
|
+
import path from "path";
|
|
11
|
+
|
|
12
|
+
export async function runMigrations() {
|
|
13
|
+
console.log("▶ Starting Database Migrations...");
|
|
14
|
+
|
|
15
|
+
// Connect to DB (or create)
|
|
16
|
+
const db = new Database("africode.sqlite");
|
|
17
|
+
|
|
18
|
+
// 1. Create Migration Table
|
|
19
|
+
db.run(`
|
|
20
|
+
CREATE TABLE IF NOT EXISTS _migrations (
|
|
21
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
22
|
+
name TEXT UNIQUE,
|
|
23
|
+
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
24
|
+
);
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
// 2. Scan Directory
|
|
28
|
+
const migrationDir = path.join(process.cwd(), "migrations");
|
|
29
|
+
if (!fs.existsSync(migrationDir)) {
|
|
30
|
+
console.log("⚠ No `migrations` directory found. Skipping.");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const files = fs.readdirSync(migrationDir)
|
|
35
|
+
.filter(f => f.endsWith('.sql'))
|
|
36
|
+
.sort(); // Run in order (001_..., 002_...)
|
|
37
|
+
|
|
38
|
+
let appliedCount = 0;
|
|
39
|
+
|
|
40
|
+
for (const file of files) {
|
|
41
|
+
// Check if applied
|
|
42
|
+
const exists = db.query("SELECT id FROM _migrations WHERE name = ?").get(file);
|
|
43
|
+
if (exists) {
|
|
44
|
+
continue; // Skip
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Execute
|
|
48
|
+
console.log(`... Applying: ${file}`);
|
|
49
|
+
const sql = fs.readFileSync(path.join(migrationDir, file), "utf-8");
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
// Run transaction
|
|
53
|
+
const transaction = db.transaction(() => {
|
|
54
|
+
db.run(sql);
|
|
55
|
+
db.run("INSERT INTO _migrations (name) VALUES (?)", [file]);
|
|
56
|
+
});
|
|
57
|
+
transaction();
|
|
58
|
+
console.log(`✓ Applied: ${file}`);
|
|
59
|
+
appliedCount++;
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.error(`✗ Failed to apply ${file}:`, err.message);
|
|
62
|
+
process.exit(1); // Stop on error
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (appliedCount === 0) {
|
|
67
|
+
console.log("✓ Database is up to date.");
|
|
68
|
+
} else {
|
|
69
|
+
console.log(`✓ Successfully applied ${appliedCount} migrations.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
package/core/cli/ui.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AfriCode CLI UI Utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const colors = {
|
|
6
|
+
green: '\x1b[32m',
|
|
7
|
+
gold: '\x1b[33m',
|
|
8
|
+
blue: '\x1b[34m',
|
|
9
|
+
red: '\x1b[31m',
|
|
10
|
+
reset: '\x1b[0m',
|
|
11
|
+
bold: '\x1b[1m'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function logo() {
|
|
15
|
+
console.log(`
|
|
16
|
+
${colors.gold}╔═══════════════════════════════════════╗
|
|
17
|
+
║ ║
|
|
18
|
+
║ ${colors.green}█████╗ ███████╗██████╗ ██╗${colors.gold} ║
|
|
19
|
+
║ ${colors.green}██╔══██╗██╔════╝██╔══██╗██║${colors.gold} ║
|
|
20
|
+
║ ${colors.green}███████║█████╗ ██████╔╝██║${colors.gold} ║
|
|
21
|
+
║ ${colors.green}██╔══██║██╔══╝ ██╔══██╗██║${colors.gold} ║
|
|
22
|
+
║ ${colors.green}██║ ██║██║ ██║ ██║██║${colors.gold} ║
|
|
23
|
+
║ ${colors.green}╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚═╝${colors.gold} ║
|
|
24
|
+
║ ║
|
|
25
|
+
║ ${colors.reset}The Rhythmic Web Framework${colors.gold} ║
|
|
26
|
+
╚═══════════════════════════════════════╝${colors.reset}
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function help() {
|
|
31
|
+
logo();
|
|
32
|
+
console.log(`
|
|
33
|
+
${colors.bold}Usage:${colors.reset}
|
|
34
|
+
africode <command> [options]
|
|
35
|
+
|
|
36
|
+
${colors.bold}Commands:${colors.reset}
|
|
37
|
+
${colors.green}dev${colors.reset} Start development server
|
|
38
|
+
${colors.green}build${colors.reset} Create production build
|
|
39
|
+
${colors.green}add${colors.reset} Add a component (e.g., africode add sidebar)
|
|
40
|
+
${colors.green}new${colors.reset} Create a new project (options: --template 3d)
|
|
41
|
+
${colors.green}migrate${colors.reset} Run database migrations
|
|
42
|
+
${colors.green}help${colors.reset} Show this help message
|
|
43
|
+
|
|
44
|
+
${colors.gold}Powered by the rhythm of the continent.${colors.reset}
|
|
45
|
+
`);
|
|
46
|
+
}
|