offbyt 1.0.1 → 1.0.3
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/cli.js +5 -5
- package/lib/ir-integration.js +4 -4
- package/lib/modes/configBasedGenerator.js +14 -14
- package/lib/modes/connect.js +2 -2
- package/lib/modes/generateApi.js +1 -1
- package/lib/modes/interactiveSetup.js +10 -10
- package/lib/utils/cliFormatter.js +1 -1
- package/lib/utils/industryMode.js +1 -1
- package/lib/utils/performanceAnalyzer.js +3 -3
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ function parsePositiveInteger(value) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
program
|
|
35
|
-
.name('
|
|
35
|
+
.name('offbyt')
|
|
36
36
|
.description('Hybrid Backend Generator - Offline + AI Powered')
|
|
37
37
|
.version('1.0.0');
|
|
38
38
|
|
|
@@ -310,12 +310,12 @@ if (!process.argv.slice(2).length) {
|
|
|
310
310
|
program.outputHelp();
|
|
311
311
|
console.log(chalk.cyan('\nQuick Start:\n'));
|
|
312
312
|
console.log(chalk.white(' Option 1 (Recommended):'));
|
|
313
|
-
console.log(chalk.gray('
|
|
313
|
+
console.log(chalk.gray(' offbyt generate # Generate + Auto-connect\n'));
|
|
314
314
|
console.log(chalk.white(' Option 2 (Skip auto-connect):'));
|
|
315
|
-
console.log(chalk.gray('
|
|
315
|
+
console.log(chalk.gray(' offbyt generate --no-auto-connect # Generate only\n'));
|
|
316
316
|
console.log(chalk.white(' Option 3 (Just connect):'));
|
|
317
|
-
console.log(chalk.gray('
|
|
317
|
+
console.log(chalk.gray(' offbyt connect [path] # Auto-connect existing project\n'));
|
|
318
318
|
console.log(chalk.white(' Option 4 (Deploy live):'));
|
|
319
|
-
console.log(chalk.gray('
|
|
319
|
+
console.log(chalk.gray(' offbyt deploy [path] # Deploy + auto-connect URLs\n'));
|
|
320
320
|
}
|
|
321
321
|
|
package/lib/ir-integration.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
/**
|
|
19
19
|
* Complete pipeline: Frontend → IR → Backend
|
|
20
20
|
*/
|
|
21
|
-
export async function
|
|
21
|
+
export async function offbytWithIR(frontendPath, outputPath, options = {}) {
|
|
22
22
|
console.log('\n' + '='.repeat(70));
|
|
23
23
|
console.log('🚀 offbyt - IR-Based Backend Generation');
|
|
24
24
|
console.log('='.repeat(70) + '\n');
|
|
@@ -303,7 +303,7 @@ export async function quickGenerate(frontendPath, options = {}) {
|
|
|
303
303
|
const projectName = path.basename(frontendPath);
|
|
304
304
|
const outputPath = `./offbyt-${projectName}`;
|
|
305
305
|
|
|
306
|
-
return
|
|
306
|
+
return offbytWithIR(frontendPath, outputPath, {
|
|
307
307
|
projectName,
|
|
308
308
|
...options
|
|
309
309
|
});
|
|
@@ -331,7 +331,7 @@ export async function runFromCLI(args) {
|
|
|
331
331
|
const out = outputPath || `./offbyt-${path.basename(frontendPath)}`;
|
|
332
332
|
|
|
333
333
|
try {
|
|
334
|
-
await
|
|
334
|
+
await offbytWithIR(frontendPath, out, {
|
|
335
335
|
hasAuth: true,
|
|
336
336
|
projectName: path.basename(frontendPath)
|
|
337
337
|
});
|
|
@@ -345,5 +345,5 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
|
|
345
345
|
runFromCLI(process.argv.slice(2));
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
export default
|
|
348
|
+
export default offbytWithIR;
|
|
349
349
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* Configuration-Based Backend Generator
|
|
3
3
|
* Generates production-level backend for selected tech stack
|
|
4
4
|
*/
|
|
@@ -553,14 +553,14 @@ ${['postgresql', 'mysql', 'sqlite'].includes(config.database) ? `import { TypeOr
|
|
|
553
553
|
ConfigModule.forRoot({
|
|
554
554
|
isGlobal: true
|
|
555
555
|
}),
|
|
556
|
-
${config.database === 'mongodb' ? ` MongooseModule.forRoot(process.env.MONGODB_URI || 'mongodb://localhost:27017/
|
|
556
|
+
${config.database === 'mongodb' ? ` MongooseModule.forRoot(process.env.MONGODB_URI || 'mongodb://localhost:27017/offbyt'),` : ''}
|
|
557
557
|
${config.database === 'postgresql' ? ` TypeOrmModule.forRoot({
|
|
558
558
|
type: 'postgres',
|
|
559
559
|
host: process.env.DB_HOST || 'localhost',
|
|
560
560
|
port: parseInt(process.env.DB_PORT) || 5432,
|
|
561
561
|
username: process.env.DB_USER || 'postgres',
|
|
562
562
|
password: process.env.DB_PASSWORD || 'password',
|
|
563
|
-
database: process.env.DB_NAME || '
|
|
563
|
+
database: process.env.DB_NAME || 'offbyt',
|
|
564
564
|
autoLoadEntities: true,
|
|
565
565
|
synchronize: process.env.NODE_ENV === 'development'
|
|
566
566
|
}),` : ''}
|
|
@@ -570,7 +570,7 @@ ${config.database === 'mysql' ? ` TypeOrmModule.forRoot({
|
|
|
570
570
|
port: parseInt(process.env.DB_PORT) || 3306,
|
|
571
571
|
username: process.env.DB_USER || 'root',
|
|
572
572
|
password: process.env.DB_PASSWORD || 'password',
|
|
573
|
-
database: process.env.DB_NAME || '
|
|
573
|
+
database: process.env.DB_NAME || 'offbyt',
|
|
574
574
|
autoLoadEntities: true,
|
|
575
575
|
synchronize: process.env.NODE_ENV === 'development'
|
|
576
576
|
}),` : ''}
|
|
@@ -695,9 +695,9 @@ function createPackageJson(backendPath, config) {
|
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
const packageJson = {
|
|
698
|
-
name: '
|
|
698
|
+
name: 'offbyt-backend',
|
|
699
699
|
version: '1.0.0',
|
|
700
|
-
description: 'Production-ready backend generated by
|
|
700
|
+
description: 'Production-ready backend generated by offbyt',
|
|
701
701
|
type: config.framework === 'nestjs' ? 'commonjs' : 'module',
|
|
702
702
|
main: config.framework === 'nestjs' ? 'dist/main.js' : 'server.js',
|
|
703
703
|
scripts,
|
|
@@ -1652,7 +1652,7 @@ function generateSchemaSQL(resources, dbType, apiAnalysis = { relationships: []
|
|
|
1652
1652
|
const isMySQL = dbType === 'mysql';
|
|
1653
1653
|
|
|
1654
1654
|
let sql = `-- ============================================
|
|
1655
|
-
--
|
|
1655
|
+
-- offbyt ${dbType.toUpperCase()} Schema
|
|
1656
1656
|
-- Generated for ${dbType === 'mysql' ? 'MySQL' : dbType === 'postgresql' ? 'PostgreSQL' : 'SQLite'} Database
|
|
1657
1657
|
-- Auto-generated from detected frontend resources
|
|
1658
1658
|
-- ============================================
|
|
@@ -1921,7 +1921,7 @@ function generateConversationRelationships(dbType) {
|
|
|
1921
1921
|
|
|
1922
1922
|
function generateCRUDSQL(resources, dbType, apiAnalysis = { relationships: [] }) {
|
|
1923
1923
|
let sql = `-- ============================================\n`;
|
|
1924
|
-
sql += `--
|
|
1924
|
+
sql += `-- offbyt ${dbType.toUpperCase()} CRUD Operations\n`;
|
|
1925
1925
|
sql += `-- All Create, Read, Update, Delete Queries\n`;
|
|
1926
1926
|
sql += `-- Ready to use in your application\n`;
|
|
1927
1927
|
sql += `-- ============================================\n\n`;
|
|
@@ -2000,7 +2000,7 @@ function generateSampleValue(fieldName) {
|
|
|
2000
2000
|
|
|
2001
2001
|
function generateJoinSQL(resources, dbType, apiAnalysis = { relationships: [] }) {
|
|
2002
2002
|
let sql = `-- ============================================\n`;
|
|
2003
|
-
sql += `--
|
|
2003
|
+
sql += `-- offbyt ${dbType.toUpperCase()} Relationships & JOINs\n`;
|
|
2004
2004
|
sql += `-- Complex queries with table relationships\n`;
|
|
2005
2005
|
sql += `-- ============================================\n\n`;
|
|
2006
2006
|
|
|
@@ -2059,7 +2059,7 @@ function generateJoinSQL(resources, dbType, apiAnalysis = { relationships: [] })
|
|
|
2059
2059
|
|
|
2060
2060
|
function generateSeedSQL(resources, dbType, apiAnalysis = { relationships: [] }) {
|
|
2061
2061
|
let sql = `-- ============================================\n`;
|
|
2062
|
-
sql += `--
|
|
2062
|
+
sql += `-- offbyt ${dbType.toUpperCase()} Sample Data\n`;
|
|
2063
2063
|
sql += `-- Seed data for testing and development\n`;
|
|
2064
2064
|
sql += `-- ============================================\n\n`;
|
|
2065
2065
|
|
|
@@ -2182,7 +2182,7 @@ export const User = sequelize.define('User', {
|
|
|
2182
2182
|
const router = express.Router();
|
|
2183
2183
|
|
|
2184
2184
|
router.get('/', (req, res) => {
|
|
2185
|
-
res.json({ message: 'Welcome to
|
|
2185
|
+
res.json({ message: 'Welcome to offbyt API' });
|
|
2186
2186
|
});
|
|
2187
2187
|
|
|
2188
2188
|
export default router;`;
|
|
@@ -2211,9 +2211,9 @@ export const createUser = async (req, res) => {
|
|
|
2211
2211
|
fs.writeFileSync(path.join(backendPath, 'controllers', 'userController.js'), sampleController);
|
|
2212
2212
|
|
|
2213
2213
|
// README
|
|
2214
|
-
const readme = `#
|
|
2214
|
+
const readme = `# offbyt Generated Backend
|
|
2215
2215
|
|
|
2216
|
-
This is a production-ready backend generated by
|
|
2216
|
+
This is a production-ready backend generated by offbyt.
|
|
2217
2217
|
|
|
2218
2218
|
## Configuration
|
|
2219
2219
|
- Database: ${config.database}
|
|
@@ -2251,7 +2251,7 @@ npm run dev
|
|
|
2251
2251
|
## Environment Variables
|
|
2252
2252
|
See \`../.env\` for required environment variables.
|
|
2253
2253
|
|
|
2254
|
-
Generated by
|
|
2254
|
+
Generated by offbyt`;
|
|
2255
2255
|
|
|
2256
2256
|
fs.writeFileSync(path.join(backendPath, 'README.md'), readme);
|
|
2257
2257
|
}
|
package/lib/modes/connect.js
CHANGED
|
@@ -19,7 +19,7 @@ import ora from 'ora';
|
|
|
19
19
|
export async function connectFrontendBackend(projectPath) {
|
|
20
20
|
try {
|
|
21
21
|
console.log(chalk.cyan('\n============================================================'));
|
|
22
|
-
console.log(chalk.cyan('
|
|
22
|
+
console.log(chalk.cyan('OFFBYT AUTO-CONNECTION ENGINE'));
|
|
23
23
|
console.log(chalk.cyan('============================================================\n'));
|
|
24
24
|
console.log(chalk.gray('Scanner: Frontend -> Backend Connection Analysis\n'));
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ export async function connectFrontendBackend(projectPath) {
|
|
|
27
27
|
|
|
28
28
|
// Verify project structure
|
|
29
29
|
if (!fs.existsSync(backendPath)) {
|
|
30
|
-
console.error(chalk.red('Backend not found. Run "
|
|
30
|
+
console.error(chalk.red('Backend not found. Run "offbyt generate" first.\n'));
|
|
31
31
|
process.exit(1);
|
|
32
32
|
}
|
|
33
33
|
|
package/lib/modes/generateApi.js
CHANGED
|
@@ -354,7 +354,7 @@ app.use(express.json());
|
|
|
354
354
|
app.use(express.urlencoded({ extended: true }));
|
|
355
355
|
|
|
356
356
|
// MongoDB Connection
|
|
357
|
-
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/
|
|
357
|
+
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/offbyt', {
|
|
358
358
|
useNewUrlParser: true,
|
|
359
359
|
useUnifiedTopology: true
|
|
360
360
|
}).then(() => {
|
|
@@ -8,7 +8,7 @@ import chalk from 'chalk';
|
|
|
8
8
|
|
|
9
9
|
export async function getInteractiveSetup() {
|
|
10
10
|
console.log(chalk.cyan('\nâ•”â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•—'));
|
|
11
|
-
console.log(chalk.cyan('â•‘
|
|
11
|
+
console.log(chalk.cyan('â•‘ offbyt - Interactive Setup â•‘'));
|
|
12
12
|
console.log(chalk.cyan('╚â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•\n'));
|
|
13
13
|
|
|
14
14
|
const answers = await inquirer.prompt([
|
|
@@ -250,7 +250,7 @@ import mongoose from 'mongoose';
|
|
|
250
250
|
|
|
251
251
|
export async function connectDatabase() {
|
|
252
252
|
try {
|
|
253
|
-
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/
|
|
253
|
+
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/offbyt';
|
|
254
254
|
|
|
255
255
|
await mongoose.connect(mongoUri, {
|
|
256
256
|
useNewUrlParser: true,
|
|
@@ -269,7 +269,7 @@ export async function connectDatabase() {
|
|
|
269
269
|
import { Sequelize } from 'sequelize';
|
|
270
270
|
|
|
271
271
|
export const sequelize = new Sequelize(
|
|
272
|
-
process.env.DB_NAME || '
|
|
272
|
+
process.env.DB_NAME || 'offbyt',
|
|
273
273
|
process.env.DB_USER || 'postgres',
|
|
274
274
|
process.env.DB_PASSWORD || 'password',
|
|
275
275
|
{
|
|
@@ -296,7 +296,7 @@ export async function connectDatabase() {
|
|
|
296
296
|
import { Sequelize } from 'sequelize';
|
|
297
297
|
|
|
298
298
|
export const sequelize = new Sequelize(
|
|
299
|
-
process.env.DB_NAME || '
|
|
299
|
+
process.env.DB_NAME || 'offbyt',
|
|
300
300
|
process.env.DB_USER || 'root',
|
|
301
301
|
process.env.DB_PASSWORD || 'password',
|
|
302
302
|
{
|
|
@@ -348,7 +348,7 @@ export async function connectDatabase() {
|
|
|
348
348
|
*/
|
|
349
349
|
export function getEnvTemplate(config) {
|
|
350
350
|
let env = `# ========================================
|
|
351
|
-
#
|
|
351
|
+
# offbyt Production-Ready Configuration
|
|
352
352
|
# ========================================
|
|
353
353
|
# WARNING: Never commit this file to version control!
|
|
354
354
|
# Add .env to your .gitignore immediately
|
|
@@ -371,16 +371,16 @@ CLIENT_URL=http://localhost:3000
|
|
|
371
371
|
|
|
372
372
|
if (config.database === 'mongodb') {
|
|
373
373
|
env += `# MongoDB
|
|
374
|
-
MONGODB_URI=mongodb://localhost:27017/
|
|
374
|
+
MONGODB_URI=mongodb://localhost:27017/offbyt
|
|
375
375
|
# For MongoDB Atlas (Production):
|
|
376
|
-
# MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/
|
|
376
|
+
# MONGODB_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/offbyt?retryWrites=true&w=majority
|
|
377
377
|
MONGODB_OPTIONS=retryWrites=true&w=majority
|
|
378
378
|
`;
|
|
379
379
|
} else if (config.database === 'postgresql') {
|
|
380
380
|
env += `# PostgreSQL
|
|
381
381
|
DB_HOST=localhost
|
|
382
382
|
DB_PORT=5432
|
|
383
|
-
DB_NAME=
|
|
383
|
+
DB_NAME=offbyt
|
|
384
384
|
DB_USER=postgres
|
|
385
385
|
DB_PASSWORD=password
|
|
386
386
|
# Connection Pool Settings
|
|
@@ -392,7 +392,7 @@ DB_SSL=false
|
|
|
392
392
|
env += `# MySQL
|
|
393
393
|
DB_HOST=localhost
|
|
394
394
|
DB_PORT=3306
|
|
395
|
-
DB_NAME=
|
|
395
|
+
DB_NAME=offbyt
|
|
396
396
|
DB_USER=root
|
|
397
397
|
DB_PASSWORD=password
|
|
398
398
|
# Connection Pool Settings
|
|
@@ -443,7 +443,7 @@ FACEBOOK_CALLBACK_URL=http://localhost:5000/auth/facebook/callback
|
|
|
443
443
|
# Session Configuration
|
|
444
444
|
# ========================================
|
|
445
445
|
SESSION_SECRET=your_session_secret_CHANGE_IN_PRODUCTION
|
|
446
|
-
SESSION_NAME=
|
|
446
|
+
SESSION_NAME=offbyt.sid
|
|
447
447
|
SESSION_MAX_AGE=86400000
|
|
448
448
|
SESSION_SECURE=false
|
|
449
449
|
`;
|
|
@@ -195,7 +195,7 @@ export function writeIndustryReport(projectPath, report) {
|
|
|
195
195
|
fs.mkdirSync(reportsPath, { recursive: true });
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
const filePath = path.join(reportsPath, '
|
|
198
|
+
const filePath = path.join(reportsPath, 'offbyt-industry-report.json');
|
|
199
199
|
fs.writeFileSync(filePath, JSON.stringify(report, null, 2));
|
|
200
200
|
return filePath;
|
|
201
201
|
}
|
|
@@ -190,9 +190,9 @@ function calculateScalabilityScore(analysis) {
|
|
|
190
190
|
export function generateReport(analysis, startupMode = false) {
|
|
191
191
|
let report = '';
|
|
192
192
|
|
|
193
|
-
report += chalk.bold.cyan('\n
|
|
194
|
-
report += chalk.bold.cyan('
|
|
195
|
-
report += chalk.bold.cyan('
|
|
193
|
+
report += chalk.bold.cyan('\n=============================================================\n');
|
|
194
|
+
report += chalk.bold.cyan(' OFFBYT SCALABILITY REPORT\n');
|
|
195
|
+
report += chalk.bold.cyan('=============================================================\n\n');
|
|
196
196
|
|
|
197
197
|
// Scalability Score
|
|
198
198
|
const score = analysis.scalabilityScore;
|