@compilr-dev/factory 0.1.1
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 +131 -0
- package/dist/factory/file-writer.d.ts +11 -0
- package/dist/factory/file-writer.js +21 -0
- package/dist/factory/list-toolkits-tool.d.ts +12 -0
- package/dist/factory/list-toolkits-tool.js +35 -0
- package/dist/factory/registry.d.ts +15 -0
- package/dist/factory/registry.js +28 -0
- package/dist/factory/scaffold-tool.d.ts +21 -0
- package/dist/factory/scaffold-tool.js +95 -0
- package/dist/factory/skill.d.ts +14 -0
- package/dist/factory/skill.js +146 -0
- package/dist/factory/tools.d.ts +14 -0
- package/dist/factory/tools.js +17 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +25 -0
- package/dist/model/defaults.d.ts +10 -0
- package/dist/model/defaults.js +68 -0
- package/dist/model/naming.d.ts +12 -0
- package/dist/model/naming.js +80 -0
- package/dist/model/operations-entity.d.ts +35 -0
- package/dist/model/operations-entity.js +110 -0
- package/dist/model/operations-field.d.ts +33 -0
- package/dist/model/operations-field.js +104 -0
- package/dist/model/operations-relationship.d.ts +19 -0
- package/dist/model/operations-relationship.js +90 -0
- package/dist/model/operations-section.d.ts +32 -0
- package/dist/model/operations-section.js +35 -0
- package/dist/model/operations.d.ts +12 -0
- package/dist/model/operations.js +63 -0
- package/dist/model/persistence.d.ts +19 -0
- package/dist/model/persistence.js +40 -0
- package/dist/model/schema.d.ts +15 -0
- package/dist/model/schema.js +269 -0
- package/dist/model/tools.d.ts +14 -0
- package/dist/model/tools.js +380 -0
- package/dist/model/types.d.ts +70 -0
- package/dist/model/types.js +8 -0
- package/dist/toolkits/react-node/api.d.ts +8 -0
- package/dist/toolkits/react-node/api.js +198 -0
- package/dist/toolkits/react-node/config.d.ts +9 -0
- package/dist/toolkits/react-node/config.js +120 -0
- package/dist/toolkits/react-node/dashboard.d.ts +8 -0
- package/dist/toolkits/react-node/dashboard.js +60 -0
- package/dist/toolkits/react-node/entity.d.ts +8 -0
- package/dist/toolkits/react-node/entity.js +469 -0
- package/dist/toolkits/react-node/helpers.d.ts +27 -0
- package/dist/toolkits/react-node/helpers.js +71 -0
- package/dist/toolkits/react-node/index.d.ts +8 -0
- package/dist/toolkits/react-node/index.js +52 -0
- package/dist/toolkits/react-node/router.d.ts +8 -0
- package/dist/toolkits/react-node/router.js +49 -0
- package/dist/toolkits/react-node/seed.d.ts +11 -0
- package/dist/toolkits/react-node/seed.js +144 -0
- package/dist/toolkits/react-node/shared.d.ts +7 -0
- package/dist/toolkits/react-node/shared.js +119 -0
- package/dist/toolkits/react-node/shell.d.ts +8 -0
- package/dist/toolkits/react-node/shell.js +152 -0
- package/dist/toolkits/react-node/static.d.ts +8 -0
- package/dist/toolkits/react-node/static.js +105 -0
- package/dist/toolkits/react-node/types-gen.d.ts +8 -0
- package/dist/toolkits/react-node/types-gen.js +31 -0
- package/dist/toolkits/types.d.ts +22 -0
- package/dist/toolkits/types.js +6 -0
- package/package.json +51 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React+Node Toolkit — Static Files Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates: .gitignore, .env.example, README.md, index.html, src/main.tsx, src/index.css
|
|
5
|
+
*/
|
|
6
|
+
export function generateStaticFiles(model) {
|
|
7
|
+
return [
|
|
8
|
+
generateGitignore(),
|
|
9
|
+
generateEnvExample(),
|
|
10
|
+
generateReadme(model),
|
|
11
|
+
generateIndexHtml(model),
|
|
12
|
+
generateMainTsx(),
|
|
13
|
+
generateIndexCss(),
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
function generateGitignore() {
|
|
17
|
+
return {
|
|
18
|
+
path: '.gitignore',
|
|
19
|
+
content: `node_modules
|
|
20
|
+
dist
|
|
21
|
+
.env
|
|
22
|
+
*.local
|
|
23
|
+
`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function generateEnvExample() {
|
|
27
|
+
return {
|
|
28
|
+
path: '.env.example',
|
|
29
|
+
content: `PORT=3001
|
|
30
|
+
VITE_API_URL=http://localhost:3001
|
|
31
|
+
`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function generateReadme(model) {
|
|
35
|
+
return {
|
|
36
|
+
path: 'README.md',
|
|
37
|
+
content: `# ${model.identity.name}
|
|
38
|
+
|
|
39
|
+
${model.identity.description}
|
|
40
|
+
|
|
41
|
+
## Getting Started
|
|
42
|
+
|
|
43
|
+
\`\`\`bash
|
|
44
|
+
npm install
|
|
45
|
+
npm run dev
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
This starts both the Vite dev server and the Express API server.
|
|
49
|
+
|
|
50
|
+
- **Frontend:** http://localhost:5173
|
|
51
|
+
- **API:** http://localhost:3001
|
|
52
|
+
|
|
53
|
+
## Tech Stack
|
|
54
|
+
|
|
55
|
+
- React 18 + TypeScript
|
|
56
|
+
- Vite
|
|
57
|
+
- Tailwind CSS
|
|
58
|
+
- Express.js
|
|
59
|
+
- React Router v6
|
|
60
|
+
`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function generateIndexHtml(model) {
|
|
64
|
+
return {
|
|
65
|
+
path: 'index.html',
|
|
66
|
+
content: `<!doctype html>
|
|
67
|
+
<html lang="en">
|
|
68
|
+
<head>
|
|
69
|
+
<meta charset="UTF-8" />
|
|
70
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
71
|
+
<title>${model.identity.name}</title>
|
|
72
|
+
</head>
|
|
73
|
+
<body>
|
|
74
|
+
<div id="root"></div>
|
|
75
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
76
|
+
</body>
|
|
77
|
+
</html>
|
|
78
|
+
`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function generateMainTsx() {
|
|
82
|
+
return {
|
|
83
|
+
path: 'src/main.tsx',
|
|
84
|
+
content: `import React from 'react';
|
|
85
|
+
import ReactDOM from 'react-dom/client';
|
|
86
|
+
import App from './App';
|
|
87
|
+
import './index.css';
|
|
88
|
+
|
|
89
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
90
|
+
<React.StrictMode>
|
|
91
|
+
<App />
|
|
92
|
+
</React.StrictMode>,
|
|
93
|
+
);
|
|
94
|
+
`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function generateIndexCss() {
|
|
98
|
+
return {
|
|
99
|
+
path: 'src/index.css',
|
|
100
|
+
content: `@tailwind base;
|
|
101
|
+
@tailwind components;
|
|
102
|
+
@tailwind utilities;
|
|
103
|
+
`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React+Node Toolkit — TypeScript Types Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates src/types/index.ts with interfaces for each entity.
|
|
5
|
+
*/
|
|
6
|
+
import type { ApplicationModel } from '../../model/types.js';
|
|
7
|
+
import type { FactoryFile } from '../types.js';
|
|
8
|
+
export declare function generateTypesFile(model: ApplicationModel): FactoryFile[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React+Node Toolkit — TypeScript Types Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates src/types/index.ts with interfaces for each entity.
|
|
5
|
+
*/
|
|
6
|
+
import { tsType, fkFieldName, belongsToRels } from './helpers.js';
|
|
7
|
+
export function generateTypesFile(model) {
|
|
8
|
+
const lines = ['// Auto-generated TypeScript types from Application Model', ''];
|
|
9
|
+
for (const entity of model.entities) {
|
|
10
|
+
lines.push(generateInterface(entity));
|
|
11
|
+
lines.push('');
|
|
12
|
+
}
|
|
13
|
+
return [{ path: 'src/types/index.ts', content: lines.join('\n') }];
|
|
14
|
+
}
|
|
15
|
+
function generateInterface(entity) {
|
|
16
|
+
const lines = [];
|
|
17
|
+
lines.push(`export interface ${entity.name} {`);
|
|
18
|
+
lines.push(' id: number;');
|
|
19
|
+
for (const field of entity.fields) {
|
|
20
|
+
const optional = field.required ? '' : '?';
|
|
21
|
+
lines.push(` ${field.name}${optional}: ${tsType(field)};`);
|
|
22
|
+
}
|
|
23
|
+
// FK fields from belongsTo
|
|
24
|
+
for (const rel of belongsToRels(entity)) {
|
|
25
|
+
const fk = fkFieldName(rel);
|
|
26
|
+
lines.push(` ${fk}: number;`);
|
|
27
|
+
lines.push(` ${rel.target.charAt(0).toLowerCase() + rel.target.slice(1)}?: ${rel.target};`);
|
|
28
|
+
}
|
|
29
|
+
lines.push('}');
|
|
30
|
+
return lines.join('\n');
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory Toolkit Types
|
|
3
|
+
*
|
|
4
|
+
* Interfaces that toolkit implementations must conform to.
|
|
5
|
+
*/
|
|
6
|
+
import type { ApplicationModel } from '../model/types.js';
|
|
7
|
+
export interface FactoryFile {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly content: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FactoryResult {
|
|
12
|
+
readonly files: readonly FactoryFile[];
|
|
13
|
+
readonly toolkit: string;
|
|
14
|
+
readonly warnings: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export interface FactoryToolkit {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly requiredSections: readonly string[];
|
|
21
|
+
generate(model: ApplicationModel): FactoryResult;
|
|
22
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@compilr-dev/factory",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "AI-driven application scaffolder for the compilr-dev ecosystem",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"lint": "eslint src/",
|
|
15
|
+
"lint:fix": "eslint src/ --fix",
|
|
16
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
17
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:watch": "vitest",
|
|
20
|
+
"test:coverage": "vitest run --coverage",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@compilr-dev/sdk": "^0.1.12"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@anthropic-ai/sdk": "^0.78.0",
|
|
29
|
+
"@compilr-dev/agents": "^0.3.16",
|
|
30
|
+
"@compilr-dev/sdk": "^0.1.12",
|
|
31
|
+
"@eslint/js": "^9.17.0",
|
|
32
|
+
"@types/node": "^22.10.2",
|
|
33
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
34
|
+
"eslint": "^9.17.0",
|
|
35
|
+
"prettier": "^3.4.2",
|
|
36
|
+
"typescript": "^5.7.2",
|
|
37
|
+
"typescript-eslint": "^8.18.1",
|
|
38
|
+
"vitest": "^2.1.8"
|
|
39
|
+
},
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/scozzola/compilr-dev-factory"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"compilr-dev",
|
|
47
|
+
"factory",
|
|
48
|
+
"scaffolder",
|
|
49
|
+
"code-generation"
|
|
50
|
+
]
|
|
51
|
+
}
|