@darraghor/nest-backend-libs 2.1.0 → 2.3.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/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +19 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/commands/WriteTypeOrmConfigCommand.d.ts +19 -0
- package/dist/cli/commands/WriteTypeOrmConfigCommand.js +49 -0
- package/dist/cli/commands/WriteTypeOrmConfigCommand.js.map +1 -0
- package/dist/database-postgres/write-typeorm-config.d.ts +1 -0
- package/dist/database-postgres/write-typeorm-config.js +1 -0
- package/dist/database-postgres/write-typeorm-config.js.map +1 -1
- package/dist/root-app/core-app.module.js +2 -0
- package/dist/root-app/core-app.module.js.map +1 -1
- package/package.json +6 -1
package/dist/cli/cli.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
require("reflect-metadata");
|
|
8
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
9
|
+
const WriteTypeOrmConfigCommand_1 = require("./commands/WriteTypeOrmConfigCommand");
|
|
10
|
+
void yargs_1.default
|
|
11
|
+
.usage("Usage: $0 <command> [options]")
|
|
12
|
+
.command(new WriteTypeOrmConfigCommand_1.WriteTypeOrmConfigCommand())
|
|
13
|
+
.recommendCommands()
|
|
14
|
+
.demandCommand(1)
|
|
15
|
+
.strict()
|
|
16
|
+
.alias("v", "version")
|
|
17
|
+
.help("h")
|
|
18
|
+
.alias("h", "help").argv;
|
|
19
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;;AACA,4BAA0B;AAC1B,kDAA0B;AAC1B,oFAA+E;AAE/E,KAAK,eAAK;KACL,KAAK,CAAC,+BAA+B,CAAC;KACtC,OAAO,CAAC,IAAI,qDAAyB,EAAE,CAAC;KACxC,iBAAiB,EAAE;KACnB,aAAa,CAAC,CAAC,CAAC;KAChB,MAAM,EAAE;KACR,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC;KACrB,IAAI,CAAC,GAAG,CAAC;KACT,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as yargs from "yargs";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a new migration file with sql needs to be executed to update schema.
|
|
4
|
+
*/
|
|
5
|
+
type ArgumentsType = {
|
|
6
|
+
o: string;
|
|
7
|
+
db: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class WriteTypeOrmConfigCommand implements yargs.CommandModule<ArgumentsType, ArgumentsType> {
|
|
10
|
+
command: string;
|
|
11
|
+
describe: string;
|
|
12
|
+
builder(args: yargs.Argv): yargs.Argv<{
|
|
13
|
+
o: string;
|
|
14
|
+
} & {
|
|
15
|
+
db: string;
|
|
16
|
+
}>;
|
|
17
|
+
handler(args: yargs.ArgumentsCamelCase<ArgumentsType>): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WriteTypeOrmConfigCommand = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
10
|
+
const PostgresTypeOrmConfigurationProvider_1 = require("../../database-postgres/PostgresTypeOrmConfigurationProvider");
|
|
11
|
+
const SqliteTypeOrmConfigurationProvider_1 = require("../../database-sqlite/SqliteTypeOrmConfigurationProvider");
|
|
12
|
+
dotenv_1.default.config();
|
|
13
|
+
class WriteTypeOrmConfigCommand {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.command = "db:write-config";
|
|
16
|
+
this.describe = "Writes the latest orm config to ormconfig.json.";
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
19
|
+
builder(args) {
|
|
20
|
+
return args
|
|
21
|
+
.option("o", {
|
|
22
|
+
alias: "outputFileName",
|
|
23
|
+
type: "string",
|
|
24
|
+
default: "ormconfig.json",
|
|
25
|
+
describe: "The path to the output json file. Must include filename.",
|
|
26
|
+
})
|
|
27
|
+
.option("db", {
|
|
28
|
+
alias: "dbProvider",
|
|
29
|
+
type: "string",
|
|
30
|
+
default: "pg",
|
|
31
|
+
describe: "The database provider to use. Currently only supports 'pg' and 'sqlite'. For other providers, you will need to write your own config file.",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async handler(
|
|
35
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
36
|
+
args) {
|
|
37
|
+
// const fullPath = (args.path as string).startsWith("/")
|
|
38
|
+
// ? (args.path as string)
|
|
39
|
+
// : path.resolve(process.cwd(), args.path as string);
|
|
40
|
+
let config = PostgresTypeOrmConfigurationProvider_1.PostgresTypeOrmConfigurationProvider.getTypeOrmConfig();
|
|
41
|
+
if (args.db === "sqlite") {
|
|
42
|
+
config = SqliteTypeOrmConfigurationProvider_1.SqliteTypeOrmConfigurationProvider.getTypeOrmConfig();
|
|
43
|
+
}
|
|
44
|
+
console.log(chalk_1.default.green(`Writing config to ${args.o}`));
|
|
45
|
+
fs_1.default.writeFileSync(args.o, JSON.stringify(config, undefined, 2));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.WriteTypeOrmConfigCommand = WriteTypeOrmConfigCommand;
|
|
49
|
+
//# sourceMappingURL=WriteTypeOrmConfigCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WriteTypeOrmConfigCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/WriteTypeOrmConfigCommand.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA0B;AAC1B,4CAAoB;AACpB,oDAA4B;AAC5B,uHAAkH;AAClH,iHAA4G;AAC5G,gBAAM,CAAC,MAAM,EAAE,CAAC;AAOhB,MAAa,yBAAyB;IAAtC;QAGI,YAAO,GAAG,iBAAiB,CAAC;QAC5B,aAAQ,GAAG,iDAAiD,CAAC;IAsCjE,CAAC;IApCG,yDAAyD;IACzD,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,gBAAgB;YACvB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,gBAAgB;YACzB,QAAQ,EACJ,0DAA0D;SACjE,CAAC;aACD,MAAM,CAAC,IAAI,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI;YACb,QAAQ,EACJ,4IAA4I;SACnJ,CAAC,CAAC;IACX,CAAC;IAED,KAAK,CAAC,OAAO;IACT,yDAAyD;IACzD,IAA6C;QAE7C,yDAAyD;QACzD,8BAA8B;QAC9B,0DAA0D;QAE1D,IAAI,MAAM,GAAG,2EAAoC,CAAC,gBAAgB,EAAE,CAAC;QAErE,IAAI,IAAI,CAAC,EAAE,KAAK,QAAQ,EAAE;YACtB,MAAM,GAAG,uEAAkC,CAAC,gBAAgB,EAAE,CAAC;SAClE;QACD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAExD,YAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACJ;AA1CD,8DA0CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-typeorm-config.js","sourceRoot":"","sources":["../../src/database-postgres/write-typeorm-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write-typeorm-config.js","sourceRoot":"","sources":["../../src/database-postgres/write-typeorm-config.ts"],"names":[],"mappings":";;;;;;AAEA,yBAA0B;AAC1B,iGAA4F;AAC5F,oDAA4B;AAC5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,EAAE,CAAC,aAAa,CACZ,gBAAgB;AAChB,sEAAsE;AACtE,IAAI,CAAC,SAAS,CACV,2EAAoC,CAAC,gBAAgB,EAAE,EACvD,SAAS,EACT,CAAC,CACJ,CACJ,CAAC"}
|
|
@@ -48,6 +48,8 @@ let CoreModule = class CoreModule {
|
|
|
48
48
|
forbidUnknownValues: true,
|
|
49
49
|
}));
|
|
50
50
|
app.useGlobalInterceptors(new common_1.ClassSerializerInterceptor(app.get(core_1.Reflector)), new LoggingInterceptor_1.LoggingInterceptor(loggerService));
|
|
51
|
+
const swaggerGen = app.get(SwaggerGen_1.SwaggerGen);
|
|
52
|
+
swaggerGen.generate(app, "open-api/swagger.json");
|
|
51
53
|
loggerService.log(`will listen on port ${configService.webPort} (DEV: http://localhost:${configService.webPort} )`);
|
|
52
54
|
loggerService.log(`swagger will be available at (DEV: http://localhost:${configService.webPort}/swagger )`);
|
|
53
55
|
await callback(app);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-app.module.js","sourceRoot":"","sources":["../../src/root-app/core-app.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAAsD;AACtD,+DAA+D;AAC/D,4DAA4D;AAC5D,4BAA0B;AAC1B,2CAMwB;AACxB,2DAAqD;AACrD,qDAA+C;AAC/C,+CA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AG,CAAC,CAAC;aACvB;YAAC,OAAO,mBAAmB,EAAE;gBAC1B,uEAAuE;gBACvE,OAAO,CAAC,KAAK;gBACT,4EAA4E;gBAC5E,iCAAiC,mBAAmB,EAAE,CACzD,CAAC;gBACF,mDAAmD;gBACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACnB;QACL,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;CACJ,CAAA;
|
|
1
|
+
{"version":3,"file":"core-app.module.js","sourceRoot":"","sources":["../../src/root-app/core-app.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAAsD;AACtD,+DAA+D;AAC/D,4DAA4D;AAC5D,4BAA0B;AAC1B,2CAMwB;AACxB,2DAAqD;AACrD,qDAA+C;AAC/C,+CAAyC;AACzC,6CAAwC;AACxC,uCAAoD;AACpD,oFAA4D;AAC5D,sFAAiF;AACjF,qEAAgE;AAChE,wEAAkE;AAClE,2CAA4C;AAYrC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACZ,MAAM,CAAC,eAAe;IACzB,gHAAgH;IAChH,UAAe,EACf,QAA+D;IAC/D,6DAA6D;IAC7D,OAAgC;QAEhC,KAAK,CAAC,KAAK,IAAI,EAAE;YACb,IAAI;gBACA,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,UAAU,EAAE;oBAC7C,UAAU,EAAE,IAAI;iBACnB,CAAC,CAAC;gBACH,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,2BAAiB,CAAC,CAAC;gBACjD,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,mDAAwB,CAAC,CAAC;gBACxD,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;gBAE7B,GAAG,CAAC,UAAU,CAAC,EAAC,MAAM,EAAE,aAAa,CAAC,cAAc,EAAC,CAAC,CAAC;gBACvD,GAAG,CAAC,cAAc,CACd,IAAI,uBAAc,CAAC;oBACf,SAAS,EAAE,IAAI;o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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darraghor/nest-backend-libs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Some helpers for personal projects in nestjs",
|
|
6
6
|
"homepage": "https://github.com/darraghoriordan/nest-backend-libs",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"keywords": [
|
|
27
27
|
"nestjs"
|
|
28
28
|
],
|
|
29
|
+
"bin": {
|
|
30
|
+
"miller": "dist/cli/cli.js",
|
|
31
|
+
"write-db-config": "dist/database-postgres/write-typeorm-config.js",
|
|
32
|
+
"generate-client": "dist/open-api-generation/generate.sh"
|
|
33
|
+
},
|
|
29
34
|
"scripts": {
|
|
30
35
|
"clean": "rm -Rf ./dist/",
|
|
31
36
|
"build:ci": "yarn build",
|