@darraghor/nest-backend-libs 2.2.0 → 2.4.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/WriteApiClientCommand.d.ts +22 -0
- package/dist/cli/commands/WriteApiClientCommand.js +45 -0
- package/dist/cli/commands/WriteApiClientCommand.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/package.json +2 -2
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,22 @@
|
|
|
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
|
+
fePath: string;
|
|
7
|
+
itPath: string;
|
|
8
|
+
packageName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class WriteApiClientCommand implements yargs.CommandModule<ArgumentsType, ArgumentsType> {
|
|
11
|
+
command: string;
|
|
12
|
+
describe: string;
|
|
13
|
+
builder(args: yargs.Argv): yargs.Argv<{
|
|
14
|
+
fePath: string;
|
|
15
|
+
} & {
|
|
16
|
+
itPath: string;
|
|
17
|
+
} & {
|
|
18
|
+
packageName: string;
|
|
19
|
+
}>;
|
|
20
|
+
handler(args: yargs.ArgumentsCamelCase<ArgumentsType>): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
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.WriteApiClientCommand = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
// eslint-disable-next-line unicorn/import-style
|
|
9
|
+
const util_1 = __importDefault(require("util"));
|
|
10
|
+
class WriteApiClientCommand {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.command = "api:write-client";
|
|
13
|
+
this.describe = "Generates a new api client and installs it into frontend and integration test apps.";
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
16
|
+
builder(args) {
|
|
17
|
+
return args
|
|
18
|
+
.option("fePath", {
|
|
19
|
+
type: "string",
|
|
20
|
+
default: "../../apps/frontend",
|
|
21
|
+
describe: "The relative path to the frontend app.",
|
|
22
|
+
})
|
|
23
|
+
.option("itPath", {
|
|
24
|
+
type: "string",
|
|
25
|
+
default: "../../apps/backend-e2e",
|
|
26
|
+
describe: "The relative path to the integration test app.",
|
|
27
|
+
})
|
|
28
|
+
.option("packageName", {
|
|
29
|
+
type: "string",
|
|
30
|
+
demandOption: true,
|
|
31
|
+
describe: "The name of package being created",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async handler(
|
|
35
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
36
|
+
args) {
|
|
37
|
+
// call the script
|
|
38
|
+
const execPromise = util_1.default.promisify(child_process_1.exec);
|
|
39
|
+
const commandArguments = [args.fePath, args.itPath, args.packageName];
|
|
40
|
+
const result = await execPromise(`../../open-api-generation/generate.sh ${commandArguments.join(" ")}`);
|
|
41
|
+
console.log(result.stdout);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.WriteApiClientCommand = WriteApiClientCommand;
|
|
45
|
+
//# sourceMappingURL=WriteApiClientCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WriteApiClientCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/WriteApiClientCommand.ts"],"names":[],"mappings":";;;;;;AAEA,iDAAmC;AACnC,gDAAgD;AAChD,gDAAwB;AAQxB,MAAa,qBAAqB;IAAlC;QAGI,YAAO,GAAG,kBAAkB,CAAC;QAC7B,aAAQ,GACJ,qFAAqF,CAAC;IAsC9F,CAAC;IApCG,yDAAyD;IACzD,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,QAAQ,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,qBAAqB;YAC9B,QAAQ,EAAE,wCAAwC;SACrD,CAAC;aACD,MAAM,CAAC,QAAQ,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,wBAAwB;YACjC,QAAQ,EAAE,gDAAgD;SAC7D,CAAC;aACD,MAAM,CAAC,aAAa,EAAE;YACnB,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,mCAAmC;SAChD,CAAC,CAAC;IACX,CAAC;IAED,KAAK,CAAC,OAAO;IACT,yDAAyD;IACzD,IAA6C;QAE7C,kBAAkB;QAElB,MAAM,WAAW,GAAG,cAAI,CAAC,SAAS,CAAC,oBAAI,CAAC,CAAC;QACzC,MAAM,gBAAgB,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,MAAM,WAAW,CAC5B,yCAAyC,gBAAgB,CAAC,IAAI,CAC1D,GAAG,CACN,EAAE,CACN,CAAC;QAEF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;CACJ;AA3CD,sDA2CC"}
|
|
@@ -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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darraghor/nest-backend-libs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"nestjs"
|
|
28
28
|
],
|
|
29
29
|
"bin": {
|
|
30
|
-
"
|
|
30
|
+
"miller": "dist/cli/cli.js",
|
|
31
31
|
"generate-client": "dist/open-api-generation/generate.sh"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|