@wocker/pgsql-plugin
Advanced tools
Comparing version 1.0.9 to 1.0.10-beta.0
@@ -11,4 +11,4 @@ import { AppConfigService, DockerService } from "@wocker/core"; | ||
dump(name?: string): Promise<void>; | ||
protected create(service: string, user: string, password: string, host: string, port: string): Promise<void>; | ||
protected upgrade(name?: string, image?: string, imageVersion?: string): Promise<void>; | ||
protected create(name: string, user: string, password: string, host: string, port: string, imageName?: string, imageVersion?: string): Promise<void>; | ||
protected upgrade(name?: string, imageName?: string, imageVersion?: string): Promise<void>; | ||
protected destroy(service: string): Promise<void>; | ||
@@ -15,0 +15,0 @@ list(): Promise<string>; |
@@ -49,5 +49,13 @@ "use strict"; | ||
} | ||
create(service, user, password, host, port) { | ||
create(name, user, password, host, port, imageName, imageVersion) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.pgSqlService.create(service, user, password, host, port); | ||
yield this.pgSqlService.create({ | ||
name, | ||
user, | ||
password, | ||
host, | ||
port, | ||
imageName, | ||
imageVersion | ||
}); | ||
if (host) { | ||
@@ -58,5 +66,9 @@ yield this.pgSqlService.admin(); | ||
} | ||
upgrade(name, image, imageVersion) { | ||
upgrade(name, imageName, imageVersion) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.pgSqlService.upgrade(name, image, imageVersion); | ||
yield this.pgSqlService.upgrade({ | ||
name, | ||
imageName, | ||
imageVersion | ||
}); | ||
}); | ||
@@ -156,4 +168,14 @@ } | ||
})), | ||
__param(5, (0, core_1.Option)("image", { | ||
type: "string", | ||
alias: "i", | ||
description: "Image name" | ||
})), | ||
__param(6, (0, core_1.Option)("image-version", { | ||
type: "string", | ||
alias: "I", | ||
description: "Image version" | ||
})), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, String, String, String, String]), | ||
__metadata("design:paramtypes", [String, String, String, String, String, String, String]), | ||
__metadata("design:returntype", Promise) | ||
@@ -160,0 +182,0 @@ ], PgSqlController.prototype, "create", null); |
@@ -14,2 +14,3 @@ import { PickProperties } from "@wocker/core"; | ||
constructor(data?: ConfigProps); | ||
hasService(name: string): boolean; | ||
getService(name: string): Service | null; | ||
@@ -16,0 +17,0 @@ getDefaultService(): Service | null; |
@@ -17,2 +17,8 @@ "use strict"; | ||
} | ||
hasService(name) { | ||
const service = this.services.find((service) => { | ||
return service.name === name; | ||
}); | ||
return !!service; | ||
} | ||
getService(name) { | ||
@@ -64,3 +70,3 @@ const service = this.services.find((service) => { | ||
services: this.services.length > 0 ? this.services.map((service) => { | ||
return service.toJSON(); | ||
return service.toObject(); | ||
}) : undefined | ||
@@ -67,0 +73,0 @@ }; |
@@ -1,4 +0,2 @@ | ||
import { PickProperties } from "@wocker/core"; | ||
export type ServiceProps = Omit<PickProperties<Service>, "containerName">; | ||
export declare class Service { | ||
export type ServiceProps = { | ||
name: string; | ||
@@ -10,6 +8,17 @@ user?: string; | ||
image?: string; | ||
imageName?: string; | ||
imageVersion?: string; | ||
}; | ||
export declare class Service { | ||
name: string; | ||
user?: string; | ||
password?: string; | ||
host?: string; | ||
port?: string | number; | ||
imageName?: string; | ||
imageVersion?: string; | ||
constructor(data: ServiceProps); | ||
get containerName(): string; | ||
toJSON(): ServiceProps; | ||
get imageTag(): string; | ||
toObject(): ServiceProps; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
constructor(data) { | ||
const { name, host, port, user, password, image = "postgres", imageVersion = "latest" } = data; | ||
const { name, host, port, user, password, image, imageName = image || "postgres", imageVersion = "latest" } = data; | ||
this.name = name; | ||
@@ -13,3 +13,3 @@ this.host = host; | ||
this.password = password; | ||
this.image = image; | ||
this.imageName = imageName; | ||
this.imageVersion = imageVersion; | ||
@@ -20,3 +20,6 @@ } | ||
} | ||
toJSON() { | ||
get imageTag() { | ||
return `${this.imageName}:${this.imageVersion}`; | ||
} | ||
toObject() { | ||
return { | ||
@@ -28,3 +31,3 @@ name: this.name, | ||
password: this.password, | ||
image: this.image, | ||
imageName: this.imageName, | ||
imageVersion: this.imageVersion | ||
@@ -31,0 +34,0 @@ }; |
import { AppConfigService, PluginConfigService, DockerService, FileSystem, ProxyService } from "@wocker/core"; | ||
import { Config } from "../makes/Config"; | ||
import { ServiceProps } from "../makes/Service"; | ||
export declare class PgSqlService { | ||
@@ -16,4 +17,4 @@ protected readonly appConfigService: AppConfigService; | ||
init(email?: string, password?: string, skipPassword?: boolean): Promise<void>; | ||
create(name: string, user?: string, password?: string, host?: string, port?: string): Promise<void>; | ||
upgrade(name?: string, image?: string, imageVersion?: string): Promise<void>; | ||
create(serviceProps?: Partial<ServiceProps>): Promise<void>; | ||
upgrade(serviceProps: Partial<ServiceProps>): Promise<void>; | ||
destroy(service: string): Promise<void>; | ||
@@ -20,0 +21,0 @@ listTable(): Promise<string>; |
@@ -91,43 +91,56 @@ "use strict"; | ||
} | ||
create(name, user, password, host, port) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let service = this.config.getService(name); | ||
if (!service) { | ||
service = new Service_1.Service({ | ||
name, | ||
user, | ||
password, | ||
host, | ||
port | ||
create() { | ||
return __awaiter(this, arguments, void 0, function* (serviceProps = {}) { | ||
if (serviceProps.name && this.config.hasService(serviceProps.name)) { | ||
console.info(`Service "${serviceProps.name}" is already exists`); | ||
delete serviceProps.name; | ||
} | ||
if (!serviceProps.name) { | ||
serviceProps.name = yield (0, utils_1.promptText)({ | ||
message: "Service name:", | ||
validate: (name) => { | ||
if (!name) { | ||
return "Service name is required"; | ||
} | ||
if (this.config.getService(name)) { | ||
return `Service "${name}" is already exists`; | ||
} | ||
return true; | ||
} | ||
}); | ||
} | ||
if (!service.user) { | ||
service.user = yield (0, utils_1.promptText)({ | ||
if (!serviceProps.user) { | ||
serviceProps.user = yield (0, utils_1.promptText)({ | ||
message: "Database user:", | ||
type: "string", | ||
default: service.user | ||
default: serviceProps.user | ||
}); | ||
} | ||
if (!service.password) { | ||
service.password = yield (0, utils_1.promptText)({ | ||
if (!serviceProps.password) { | ||
serviceProps.password = yield (0, utils_1.promptText)({ | ||
message: "Database password:", | ||
type: "password", | ||
default: service.password | ||
default: serviceProps.password | ||
}); | ||
} | ||
this.config.setService(service); | ||
this.config.setService(new Service_1.Service(serviceProps)); | ||
this.config.save(); | ||
}); | ||
} | ||
upgrade(name, image, imageVersion) { | ||
upgrade(serviceProps) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const service = this.config.getServiceOrDefault(name); | ||
if (image) { | ||
service.image = image; | ||
const service = this.config.getServiceOrDefault(serviceProps.name); | ||
let changed = false; | ||
if (serviceProps.imageName) { | ||
service.imageName = serviceProps.imageName; | ||
changed = true; | ||
} | ||
if (imageVersion) { | ||
service.imageVersion = imageVersion; | ||
if (serviceProps.imageVersion) { | ||
service.imageVersion = serviceProps.imageVersion; | ||
changed = true; | ||
} | ||
this.config.setService(service); | ||
this.config.save(); | ||
if (changed) { | ||
this.config.setService(service); | ||
this.config.save(); | ||
} | ||
}); | ||
@@ -166,3 +179,3 @@ } | ||
name: service.containerName, | ||
image: `${service.image}:${service.imageVersion}`, | ||
image: service.imageTag, | ||
restart: "always", | ||
@@ -322,3 +335,3 @@ volumes: [ | ||
config.default = name; | ||
yield config.save(); | ||
config.save(); | ||
}); | ||
@@ -325,0 +338,0 @@ } |
{ | ||
"name": "@wocker/pgsql-plugin", | ||
"version": "1.0.9", | ||
"version": "1.0.10-beta.0", | ||
"author": "Kris Papercut <krispcut@gmail.com>", | ||
"description": "PostgresSQL plugin for wocker", | ||
"description": "PostgreSQL plugin for wocker", | ||
"license": "MIT", | ||
@@ -33,8 +33,8 @@ "main": "./lib/index.js", | ||
"@wocker/core": "^1.0.21", | ||
"@wocker/utils": "^1.0.7", | ||
"@wocker/utils": "^1.0.9", | ||
"cli-table3": "^0.6.5" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.7.2" | ||
"typescript": "^5.7.3" | ||
} | ||
} |
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
36140
829
0
3
1
Updated@wocker/utils@^1.0.9