@buenojs/bueno 0.8.0 → 0.8.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/dist/cli/index.js +22 -22
- package/package.json +1 -1
- package/src/cli/commands/generate.ts +11 -11
- package/src/cli/commands/migration.ts +5 -5
- package/src/cli/commands/new.ts +7 -7
package/dist/cli/index.js
CHANGED
|
@@ -1329,7 +1329,7 @@ function validateProjectName(name) {
|
|
|
1329
1329
|
}
|
|
1330
1330
|
function getPackageJsonTemplate(config) {
|
|
1331
1331
|
const dependencies = {
|
|
1332
|
-
bueno: "^0.
|
|
1332
|
+
"@buenojs/bueno": "^0.8.0"
|
|
1333
1333
|
};
|
|
1334
1334
|
const devDependencies = {
|
|
1335
1335
|
"@types/bun": "latest",
|
|
@@ -1368,7 +1368,7 @@ function getTsConfigTemplate() {
|
|
|
1368
1368
|
allowSyntheticDefaultImports: true,
|
|
1369
1369
|
jsx: "react-jsx",
|
|
1370
1370
|
paths: {
|
|
1371
|
-
bueno: ["./node_modules/bueno/dist/index.d.ts"]
|
|
1371
|
+
"@buenojs/bueno": ["./node_modules/@buenojs/bueno/dist/index.d.ts"]
|
|
1372
1372
|
}
|
|
1373
1373
|
},
|
|
1374
1374
|
include: ["server/**/*", "client/**/*"],
|
|
@@ -1377,7 +1377,7 @@ function getTsConfigTemplate() {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
function getMainTemplate(config) {
|
|
1379
1379
|
if (config.template === "minimal") {
|
|
1380
|
-
return `import { createServer } from 'bueno';
|
|
1380
|
+
return `import { createServer } from '@buenojs/bueno';
|
|
1381
1381
|
|
|
1382
1382
|
const app = createServer();
|
|
1383
1383
|
|
|
@@ -1388,8 +1388,8 @@ app.router.get('/', () => {
|
|
|
1388
1388
|
await app.listen(3000);
|
|
1389
1389
|
`;
|
|
1390
1390
|
}
|
|
1391
|
-
return `import { createApp, Module, Controller, Get, Injectable } from 'bueno';
|
|
1392
|
-
import type { Context } from 'bueno';
|
|
1391
|
+
return `import { createApp, Module, Controller, Get, Injectable } from '@buenojs/bueno';
|
|
1392
|
+
import type { Context } from '@buenojs/bueno';
|
|
1393
1393
|
|
|
1394
1394
|
// Services
|
|
1395
1395
|
@Injectable()
|
|
@@ -1429,7 +1429,7 @@ await app.listen(3000);
|
|
|
1429
1429
|
}
|
|
1430
1430
|
function getConfigTemplate(config) {
|
|
1431
1431
|
const dbConfig = config.database === "sqlite" ? `{ url: 'sqlite:./data.db' }` : `{ url: process.env.DATABASE_URL ?? '${config.database}://localhost/${kebabCase(config.name)}' }`;
|
|
1432
|
-
return `import { defineConfig } from 'bueno';
|
|
1432
|
+
return `import { defineConfig } from '@buenojs/bueno';
|
|
1433
1433
|
|
|
1434
1434
|
export default defineConfig({
|
|
1435
1435
|
server: {
|
|
@@ -1879,8 +1879,8 @@ var GENERATOR_ALIASES = {
|
|
|
1879
1879
|
};
|
|
1880
1880
|
function getTemplate(type) {
|
|
1881
1881
|
const templates = {
|
|
1882
|
-
controller: `import { Controller, Get, Post, Put, Delete{{#if path}} } from 'bueno'{{/if}}{{#if service}}, { {{pascalCase service}}Service } from './{{kebabCase service}}.service'{{/if}};
|
|
1883
|
-
import type { Context } from 'bueno';
|
|
1882
|
+
controller: `import { Controller, Get, Post, Put, Delete{{#if path}} } from '@buenojs/bueno'{{/if}}{{#if service}}, { {{pascalCase service}}Service } from './{{kebabCase service}}.service'{{/if}};
|
|
1883
|
+
import type { Context } from '@buenojs/bueno';
|
|
1884
1884
|
|
|
1885
1885
|
@Controller('{{path}}')
|
|
1886
1886
|
export class {{pascalCase name}}Controller {
|
|
@@ -1919,7 +1919,7 @@ export class {{pascalCase name}}Controller {
|
|
|
1919
1919
|
}
|
|
1920
1920
|
}
|
|
1921
1921
|
`,
|
|
1922
|
-
service: `import { Injectable } from 'bueno';
|
|
1922
|
+
service: `import { Injectable } from '@buenojs/bueno';
|
|
1923
1923
|
|
|
1924
1924
|
@Injectable()
|
|
1925
1925
|
export class {{pascalCase name}}Service {
|
|
@@ -1949,7 +1949,7 @@ export class {{pascalCase name}}Service {
|
|
|
1949
1949
|
}
|
|
1950
1950
|
}
|
|
1951
1951
|
`,
|
|
1952
|
-
module: `import { Module } from 'bueno';
|
|
1952
|
+
module: `import { Module } from '@buenojs/bueno';
|
|
1953
1953
|
import { {{pascalCase name}}Controller } from './{{kebabCase name}}.controller';
|
|
1954
1954
|
import { {{pascalCase name}}Service } from './{{kebabCase name}}.service';
|
|
1955
1955
|
|
|
@@ -1960,7 +1960,7 @@ import { {{pascalCase name}}Service } from './{{kebabCase name}}.service';
|
|
|
1960
1960
|
})
|
|
1961
1961
|
export class {{pascalCase name}}Module {}
|
|
1962
1962
|
`,
|
|
1963
|
-
guard: `import { Injectable, type CanActivate, type Context } from 'bueno';
|
|
1963
|
+
guard: `import { Injectable, type CanActivate, type Context } from '@buenojs/bueno';
|
|
1964
1964
|
|
|
1965
1965
|
@Injectable()
|
|
1966
1966
|
export class {{pascalCase name}}Guard implements CanActivate {
|
|
@@ -1971,7 +1971,7 @@ export class {{pascalCase name}}Guard implements CanActivate {
|
|
|
1971
1971
|
}
|
|
1972
1972
|
}
|
|
1973
1973
|
`,
|
|
1974
|
-
interceptor: `import { Injectable, type NestInterceptor, type CallHandler, type Context } from 'bueno';
|
|
1974
|
+
interceptor: `import { Injectable, type NestInterceptor, type CallHandler, type Context } from '@buenojs/bueno';
|
|
1975
1975
|
import type { Observable } from 'rxjs';
|
|
1976
1976
|
|
|
1977
1977
|
@Injectable()
|
|
@@ -1990,7 +1990,7 @@ export class {{pascalCase name}}Interceptor implements NestInterceptor {
|
|
|
1990
1990
|
}
|
|
1991
1991
|
}
|
|
1992
1992
|
`,
|
|
1993
|
-
pipe: `import { Injectable, type PipeTransform, type Context } from 'bueno';
|
|
1993
|
+
pipe: `import { Injectable, type PipeTransform, type Context } from '@buenojs/bueno';
|
|
1994
1994
|
|
|
1995
1995
|
@Injectable()
|
|
1996
1996
|
export class {{pascalCase name}}Pipe implements PipeTransform {
|
|
@@ -2001,8 +2001,8 @@ export class {{pascalCase name}}Pipe implements PipeTransform {
|
|
|
2001
2001
|
}
|
|
2002
2002
|
}
|
|
2003
2003
|
`,
|
|
2004
|
-
filter: `import { Injectable, type ExceptionFilter, type Context } from 'bueno';
|
|
2005
|
-
import type { Response } from 'bueno';
|
|
2004
|
+
filter: `import { Injectable, type ExceptionFilter, type Context } from '@buenojs/bueno';
|
|
2005
|
+
import type { Response } from '@buenojs/bueno';
|
|
2006
2006
|
|
|
2007
2007
|
@Injectable()
|
|
2008
2008
|
export class {{pascalCase name}}Filter implements ExceptionFilter {
|
|
@@ -2048,7 +2048,7 @@ export interface Update{{pascalCase name}}Dto extends Partial<Create{{pascalCase
|
|
|
2048
2048
|
// TODO: Define optional properties for update
|
|
2049
2049
|
}
|
|
2050
2050
|
`,
|
|
2051
|
-
middleware: `import type { Middleware, Context, Handler } from 'bueno';
|
|
2051
|
+
middleware: `import type { Middleware, Context, Handler } from '@buenojs/bueno';
|
|
2052
2052
|
|
|
2053
2053
|
/**
|
|
2054
2054
|
* {{pascalCase name}} Middleware
|
|
@@ -2069,7 +2069,7 @@ export const {{camelCase name}}Middleware: Middleware = async (
|
|
|
2069
2069
|
return result;
|
|
2070
2070
|
};
|
|
2071
2071
|
`,
|
|
2072
|
-
migration: `import { createMigration, type MigrationRunner } from 'bueno';
|
|
2072
|
+
migration: `import { createMigration, type MigrationRunner } from '@buenojs/bueno';
|
|
2073
2073
|
|
|
2074
2074
|
export default createMigration('{{migrationId}}', '{{migrationName}}')
|
|
2075
2075
|
.up(async (db: MigrationRunner) => {
|
|
@@ -2325,7 +2325,7 @@ async function createMigration(name, dryRun) {
|
|
|
2325
2325
|
const kebabName = name.toLowerCase().replace(/\s+/g, "-");
|
|
2326
2326
|
const fileName = `${id}_${kebabName}.ts`;
|
|
2327
2327
|
const filePath = joinPaths(migrationsDir, fileName);
|
|
2328
|
-
const template = `import { createMigration, type MigrationRunner } from 'bueno';
|
|
2328
|
+
const template = `import { createMigration, type MigrationRunner } from '@buenojs/bueno';
|
|
2329
2329
|
|
|
2330
2330
|
export default createMigration('${id}', '${kebabName}')
|
|
2331
2331
|
.up(async (db: MigrationRunner) => {
|
|
@@ -2421,7 +2421,7 @@ async function handleMigration(args) {
|
|
|
2421
2421
|
cliConsole.log("");
|
|
2422
2422
|
cliConsole.log("Example:");
|
|
2423
2423
|
cliConsole.log(colors.cyan(`
|
|
2424
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
2424
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
2425
2425
|
import { db } from './database';
|
|
2426
2426
|
|
|
2427
2427
|
const runner = createMigrationRunner(db);
|
|
@@ -2437,7 +2437,7 @@ await runner.migrate(migrations);
|
|
|
2437
2437
|
cliConsole.log("");
|
|
2438
2438
|
cliConsole.log("Example:");
|
|
2439
2439
|
cliConsole.log(colors.cyan(`
|
|
2440
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
2440
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
2441
2441
|
import { db } from './database';
|
|
2442
2442
|
|
|
2443
2443
|
const runner = createMigrationRunner(db);
|
|
@@ -2453,7 +2453,7 @@ await runner.rollback(migrations, ${steps});
|
|
|
2453
2453
|
cliConsole.log("");
|
|
2454
2454
|
cliConsole.log("Example:");
|
|
2455
2455
|
cliConsole.log(colors.cyan(`
|
|
2456
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
2456
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
2457
2457
|
import { db } from './database';
|
|
2458
2458
|
|
|
2459
2459
|
const runner = createMigrationRunner(db);
|
|
@@ -2469,7 +2469,7 @@ await runner.reset(migrations);
|
|
|
2469
2469
|
cliConsole.log("");
|
|
2470
2470
|
cliConsole.log("Example:");
|
|
2471
2471
|
cliConsole.log(colors.cyan(`
|
|
2472
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
2472
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
2473
2473
|
import { db } from './database';
|
|
2474
2474
|
|
|
2475
2475
|
const runner = createMigrationRunner(db);
|
package/package.json
CHANGED
|
@@ -69,8 +69,8 @@ interface GeneratorConfig {
|
|
|
69
69
|
*/
|
|
70
70
|
function getTemplate(type: GeneratorType): string {
|
|
71
71
|
const templates: Record<GeneratorType, string> = {
|
|
72
|
-
controller: `import { Controller, Get, Post, Put, Delete{{#if path}} } from 'bueno'{{/if}}{{#if service}}, { {{pascalCase service}}Service } from './{{kebabCase service}}.service'{{/if}};
|
|
73
|
-
import type { Context } from 'bueno';
|
|
72
|
+
controller: `import { Controller, Get, Post, Put, Delete{{#if path}} } from '@buenojs/bueno'{{/if}}{{#if service}}, { {{pascalCase service}}Service } from './{{kebabCase service}}.service'{{/if}};
|
|
73
|
+
import type { Context } from '@buenojs/bueno';
|
|
74
74
|
|
|
75
75
|
@Controller('{{path}}')
|
|
76
76
|
export class {{pascalCase name}}Controller {
|
|
@@ -109,7 +109,7 @@ export class {{pascalCase name}}Controller {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
`,
|
|
112
|
-
service: `import { Injectable } from 'bueno';
|
|
112
|
+
service: `import { Injectable } from '@buenojs/bueno';
|
|
113
113
|
|
|
114
114
|
@Injectable()
|
|
115
115
|
export class {{pascalCase name}}Service {
|
|
@@ -139,7 +139,7 @@ export class {{pascalCase name}}Service {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
`,
|
|
142
|
-
module: `import { Module } from 'bueno';
|
|
142
|
+
module: `import { Module } from '@buenojs/bueno';
|
|
143
143
|
import { {{pascalCase name}}Controller } from './{{kebabCase name}}.controller';
|
|
144
144
|
import { {{pascalCase name}}Service } from './{{kebabCase name}}.service';
|
|
145
145
|
|
|
@@ -150,7 +150,7 @@ import { {{pascalCase name}}Service } from './{{kebabCase name}}.service';
|
|
|
150
150
|
})
|
|
151
151
|
export class {{pascalCase name}}Module {}
|
|
152
152
|
`,
|
|
153
|
-
guard: `import { Injectable, type CanActivate, type Context } from 'bueno';
|
|
153
|
+
guard: `import { Injectable, type CanActivate, type Context } from '@buenojs/bueno';
|
|
154
154
|
|
|
155
155
|
@Injectable()
|
|
156
156
|
export class {{pascalCase name}}Guard implements CanActivate {
|
|
@@ -161,7 +161,7 @@ export class {{pascalCase name}}Guard implements CanActivate {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
`,
|
|
164
|
-
interceptor: `import { Injectable, type NestInterceptor, type CallHandler, type Context } from 'bueno';
|
|
164
|
+
interceptor: `import { Injectable, type NestInterceptor, type CallHandler, type Context } from '@buenojs/bueno';
|
|
165
165
|
import type { Observable } from 'rxjs';
|
|
166
166
|
|
|
167
167
|
@Injectable()
|
|
@@ -180,7 +180,7 @@ export class {{pascalCase name}}Interceptor implements NestInterceptor {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
`,
|
|
183
|
-
pipe: `import { Injectable, type PipeTransform, type Context } from 'bueno';
|
|
183
|
+
pipe: `import { Injectable, type PipeTransform, type Context } from '@buenojs/bueno';
|
|
184
184
|
|
|
185
185
|
@Injectable()
|
|
186
186
|
export class {{pascalCase name}}Pipe implements PipeTransform {
|
|
@@ -191,8 +191,8 @@ export class {{pascalCase name}}Pipe implements PipeTransform {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
`,
|
|
194
|
-
filter: `import { Injectable, type ExceptionFilter, type Context } from 'bueno';
|
|
195
|
-
import type { Response } from 'bueno';
|
|
194
|
+
filter: `import { Injectable, type ExceptionFilter, type Context } from '@buenojs/bueno';
|
|
195
|
+
import type { Response } from '@buenojs/bueno';
|
|
196
196
|
|
|
197
197
|
@Injectable()
|
|
198
198
|
export class {{pascalCase name}}Filter implements ExceptionFilter {
|
|
@@ -238,7 +238,7 @@ export interface Update{{pascalCase name}}Dto extends Partial<Create{{pascalCase
|
|
|
238
238
|
// TODO: Define optional properties for update
|
|
239
239
|
}
|
|
240
240
|
`,
|
|
241
|
-
middleware: `import type { Middleware, Context, Handler } from 'bueno';
|
|
241
|
+
middleware: `import type { Middleware, Context, Handler } from '@buenojs/bueno';
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
244
|
* {{pascalCase name}} Middleware
|
|
@@ -259,7 +259,7 @@ export const {{camelCase name}}Middleware: Middleware = async (
|
|
|
259
259
|
return result;
|
|
260
260
|
};
|
|
261
261
|
`,
|
|
262
|
-
migration: `import { createMigration, type MigrationRunner } from 'bueno';
|
|
262
|
+
migration: `import { createMigration, type MigrationRunner } from '@buenojs/bueno';
|
|
263
263
|
|
|
264
264
|
export default createMigration('{{migrationId}}', '{{migrationName}}')
|
|
265
265
|
.up(async (db: MigrationRunner) => {
|
|
@@ -104,7 +104,7 @@ async function createMigration(name: string, dryRun: boolean): Promise<string> {
|
|
|
104
104
|
const fileName = `${id}_${kebabName}.ts`;
|
|
105
105
|
const filePath = joinPaths(migrationsDir, fileName);
|
|
106
106
|
|
|
107
|
-
const template = `import { createMigration, type MigrationRunner } from 'bueno';
|
|
107
|
+
const template = `import { createMigration, type MigrationRunner } from '@buenojs/bueno';
|
|
108
108
|
|
|
109
109
|
export default createMigration('${id}', '${kebabName}')
|
|
110
110
|
.up(async (db: MigrationRunner) => {
|
|
@@ -236,7 +236,7 @@ async function handleMigration(args: ParsedArgs): Promise<void> {
|
|
|
236
236
|
cliConsole.log('');
|
|
237
237
|
cliConsole.log('Example:');
|
|
238
238
|
cliConsole.log(colors.cyan(`
|
|
239
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
239
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
240
240
|
import { db } from './database';
|
|
241
241
|
|
|
242
242
|
const runner = createMigrationRunner(db);
|
|
@@ -255,7 +255,7 @@ await runner.migrate(migrations);
|
|
|
255
255
|
cliConsole.log('');
|
|
256
256
|
cliConsole.log('Example:');
|
|
257
257
|
cliConsole.log(colors.cyan(`
|
|
258
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
258
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
259
259
|
import { db } from './database';
|
|
260
260
|
|
|
261
261
|
const runner = createMigrationRunner(db);
|
|
@@ -274,7 +274,7 @@ await runner.rollback(migrations, ${steps});
|
|
|
274
274
|
cliConsole.log('');
|
|
275
275
|
cliConsole.log('Example:');
|
|
276
276
|
cliConsole.log(colors.cyan(`
|
|
277
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
277
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
278
278
|
import { db } from './database';
|
|
279
279
|
|
|
280
280
|
const runner = createMigrationRunner(db);
|
|
@@ -293,7 +293,7 @@ await runner.reset(migrations);
|
|
|
293
293
|
cliConsole.log('');
|
|
294
294
|
cliConsole.log('Example:');
|
|
295
295
|
cliConsole.log(colors.cyan(`
|
|
296
|
-
import { createMigrationRunner, loadMigrations } from 'bueno';
|
|
296
|
+
import { createMigrationRunner, loadMigrations } from '@buenojs/bueno';
|
|
297
297
|
import { db } from './database';
|
|
298
298
|
|
|
299
299
|
const runner = createMigrationRunner(db);
|
package/src/cli/commands/new.ts
CHANGED
|
@@ -88,7 +88,7 @@ function validateProjectName(name: string): boolean | string {
|
|
|
88
88
|
*/
|
|
89
89
|
function getPackageJsonTemplate(config: ProjectConfig): string {
|
|
90
90
|
const dependencies: Record<string, string> = {
|
|
91
|
-
bueno: '^0.
|
|
91
|
+
'@buenojs/bueno': '^0.8.0',
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
const devDependencies: Record<string, string> = {
|
|
@@ -141,8 +141,8 @@ function getTsConfigTemplate(): string {
|
|
|
141
141
|
allowSyntheticDefaultImports: true,
|
|
142
142
|
jsx: 'react-jsx',
|
|
143
143
|
paths: {
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
'@buenojs/bueno': ['./node_modules/@buenojs/bueno/dist/index.d.ts'],
|
|
145
|
+
},
|
|
146
146
|
},
|
|
147
147
|
include: ['server/**/*', 'client/**/*'],
|
|
148
148
|
exclude: ['node_modules', 'dist'],
|
|
@@ -157,7 +157,7 @@ function getTsConfigTemplate(): string {
|
|
|
157
157
|
*/
|
|
158
158
|
function getMainTemplate(config: ProjectConfig): string {
|
|
159
159
|
if (config.template === 'minimal') {
|
|
160
|
-
return `import { createServer } from 'bueno';
|
|
160
|
+
return `import { createServer } from '@buenojs/bueno';
|
|
161
161
|
|
|
162
162
|
const app = createServer();
|
|
163
163
|
|
|
@@ -169,8 +169,8 @@ await app.listen(3000);
|
|
|
169
169
|
`;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
return `import { createApp, Module, Controller, Get, Injectable } from 'bueno';
|
|
173
|
-
import type { Context } from 'bueno';
|
|
172
|
+
return `import { createApp, Module, Controller, Get, Injectable } from '@buenojs/bueno';
|
|
173
|
+
import type { Context } from '@buenojs/bueno';
|
|
174
174
|
|
|
175
175
|
// Services
|
|
176
176
|
@Injectable()
|
|
@@ -217,7 +217,7 @@ function getConfigTemplate(config: ProjectConfig): string {
|
|
|
217
217
|
? `{ url: 'sqlite:./data.db' }`
|
|
218
218
|
: `{ url: process.env.DATABASE_URL ?? '${config.database}://localhost/${kebabCase(config.name)}' }`;
|
|
219
219
|
|
|
220
|
-
return `import { defineConfig } from 'bueno';
|
|
220
|
+
return `import { defineConfig } from '@buenojs/bueno';
|
|
221
221
|
|
|
222
222
|
export default defineConfig({
|
|
223
223
|
server: {
|