@wocker/core 1.0.2 → 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/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/makes/FSManager.d.ts +18 -0
- package/lib/makes/FSManager.js +146 -0
- package/lib/models/Project.d.ts +2 -1
- package/lib/models/Project.js +1 -0
- package/lib/services/AppConfigService.d.ts +1 -0
- package/lib/services/DockerService.d.ts +6 -0
- package/package.json +4 -4
- package/lib/controllers/ProjectController.d.ts +0 -9
- package/lib/controllers/ProjectController.js +0 -33
- package/lib/decorators/Controller.d.ts +0 -4
- package/lib/decorators/Controller.js +0 -28
- package/lib/decorators/Module.d.ts +0 -9
- package/lib/decorators/Module.js +0 -30
- package/lib/services/AppConfigInterface.d.ts +0 -0
- package/lib/services/AppConfigInterface.js +0 -1
- package/lib/services/ConfigService.d.ts +0 -9
- package/lib/services/ConfigService.js +0 -43
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./decorators/Inject";
|
|
|
3
3
|
export * from "./decorators/Injectable";
|
|
4
4
|
export * from "./makes/Controller";
|
|
5
5
|
export * from "./makes/DI";
|
|
6
|
+
export * from "./makes/FSManager";
|
|
6
7
|
export * from "./makes/Logger";
|
|
7
8
|
export * from "./makes/Plugin";
|
|
8
9
|
export * from "./models/Preset";
|
package/lib/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./decorators/Inject"), exports);
|
|
|
21
21
|
__exportStar(require("./decorators/Injectable"), exports);
|
|
22
22
|
__exportStar(require("./makes/Controller"), exports);
|
|
23
23
|
__exportStar(require("./makes/DI"), exports);
|
|
24
|
+
__exportStar(require("./makes/FSManager"), exports);
|
|
24
25
|
__exportStar(require("./makes/Logger"), exports);
|
|
25
26
|
__exportStar(require("./makes/Plugin"), exports);
|
|
26
27
|
__exportStar(require("./models/Preset"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import fs, { createReadStream, MakeDirectoryOptions, RmOptions } from "fs";
|
|
3
|
+
declare class FSManager {
|
|
4
|
+
protected source: string;
|
|
5
|
+
protected destination: string;
|
|
6
|
+
constructor(source: string, destination: string);
|
|
7
|
+
path(...parts: string[]): string;
|
|
8
|
+
mkdir(path: string, options?: MakeDirectoryOptions): Promise<unknown>;
|
|
9
|
+
readdir(path: string): Promise<string[]>;
|
|
10
|
+
exists(path: string): boolean;
|
|
11
|
+
copy(path: string): Promise<void>;
|
|
12
|
+
readJSON(path: string): Promise<any>;
|
|
13
|
+
writeJSON(path: string, data: any): Promise<void>;
|
|
14
|
+
rm(path: string, options?: RmOptions): Promise<unknown>;
|
|
15
|
+
createWriteStream(...parts: string[]): fs.WriteStream;
|
|
16
|
+
createReadStream(path: string, options?: Parameters<typeof createReadStream>[1]): fs.ReadStream;
|
|
17
|
+
}
|
|
18
|
+
export { FSManager };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.FSManager = void 0;
|
|
36
|
+
const fs_1 = __importStar(require("fs"));
|
|
37
|
+
const Path = __importStar(require("path"));
|
|
38
|
+
class FSManager {
|
|
39
|
+
constructor(source, destination) {
|
|
40
|
+
this.source = source;
|
|
41
|
+
this.destination = destination;
|
|
42
|
+
}
|
|
43
|
+
path(...parts) {
|
|
44
|
+
return Path.join(this.destination, ...parts);
|
|
45
|
+
}
|
|
46
|
+
mkdir(path, options = {}) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const fullPath = Path.join(this.destination, path);
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
(0, fs_1.mkdir)(fullPath, options, (err) => {
|
|
51
|
+
if (err) {
|
|
52
|
+
reject(err);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
resolve(undefined);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
readdir(path) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const filePath = Path.join(this.destination, path);
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
(0, fs_1.readdir)(filePath, (err, files) => {
|
|
65
|
+
if (err) {
|
|
66
|
+
reject(err);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
resolve(files);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exists(path) {
|
|
75
|
+
const fullPath = Path.join(this.destination, path);
|
|
76
|
+
return (0, fs_1.existsSync)(fullPath);
|
|
77
|
+
}
|
|
78
|
+
copy(path) {
|
|
79
|
+
const destination = Path.join(this.destination, path);
|
|
80
|
+
if ((0, fs_1.existsSync)(destination)) {
|
|
81
|
+
return Promise.resolve();
|
|
82
|
+
}
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
(0, fs_1.copyFile)(Path.join(this.source, path), destination, (err) => {
|
|
85
|
+
if (err) {
|
|
86
|
+
reject(err);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
resolve(undefined);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
readJSON(path) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const filePath = Path.join(this.destination, ...path);
|
|
96
|
+
const res = yield new Promise((resolve, reject) => {
|
|
97
|
+
(0, fs_1.readFile)(filePath, (err, data) => {
|
|
98
|
+
if (err) {
|
|
99
|
+
reject(err);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
resolve(data);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
return JSON.parse(res.toString());
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
writeJSON(path, data) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const json = JSON.stringify(data, null, 4);
|
|
111
|
+
const filePath = Path.join(this.destination, path);
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
(0, fs_1.writeFile)(filePath, json, (err) => {
|
|
114
|
+
if (err) {
|
|
115
|
+
reject(err);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
resolve(undefined);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
rm(path, options = {}) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const filePath = Path.join(this.destination, path);
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
fs_1.default.rm(filePath, options, (err) => {
|
|
128
|
+
if (err) {
|
|
129
|
+
reject(err);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
resolve(undefined);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
createWriteStream(...parts) {
|
|
138
|
+
const filePath = Path.join(this.destination, ...parts);
|
|
139
|
+
return (0, fs_1.createWriteStream)(filePath);
|
|
140
|
+
}
|
|
141
|
+
createReadStream(path, options) {
|
|
142
|
+
const filePath = Path.join(this.destination, path);
|
|
143
|
+
return (0, fs_1.createReadStream)(filePath, options);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.FSManager = FSManager;
|
package/lib/models/Project.d.ts
CHANGED
package/lib/models/Project.js
CHANGED
|
@@ -15,5 +15,6 @@ declare abstract class AppConfigService {
|
|
|
15
15
|
abstract getProjectTypes(): TypeMap;
|
|
16
16
|
abstract registerProjectType(name: string, title?: string): void;
|
|
17
17
|
abstract activatePlugin(name: string): Promise<void>;
|
|
18
|
+
abstract deactivatePlugin(name: string): Promise<void>;
|
|
18
19
|
}
|
|
19
20
|
export { AppConfigService };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
4
5
|
"description": "Wocker Core",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"main": "lib/index.js",
|
|
6
8
|
"types": "lib/index.d.ts",
|
|
7
|
-
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
8
|
-
"license": "MIT",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"prepare": "npm run build",
|
|
11
11
|
"watch": "tsc -w",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@kearisp/cli": "^1.0.
|
|
16
|
+
"@kearisp/cli": "^1.0.3",
|
|
17
17
|
"fs": "^0.0.1-security",
|
|
18
18
|
"path": "^0.12.7",
|
|
19
19
|
"reflect-metadata": "^0.1.13"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Cli } from "@kearisp/cli";
|
|
2
|
-
import { ConfigService } from "../services/ConfigService";
|
|
3
|
-
import { Controller } from "../makes/Controller";
|
|
4
|
-
export declare class ProjectController extends Controller {
|
|
5
|
-
protected configService: ConfigService;
|
|
6
|
-
constructor(configService: ConfigService);
|
|
7
|
-
install(cli: Cli): void;
|
|
8
|
-
test(): string;
|
|
9
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ProjectController = void 0;
|
|
13
|
-
const Injectable_1 = require("../decorators/Injectable");
|
|
14
|
-
const ConfigService_1 = require("../services/ConfigService");
|
|
15
|
-
const Controller_1 = require("../makes/Controller");
|
|
16
|
-
let ProjectController = class ProjectController extends Controller_1.Controller {
|
|
17
|
-
constructor(configService) {
|
|
18
|
-
super();
|
|
19
|
-
this.configService = configService;
|
|
20
|
-
}
|
|
21
|
-
install(cli) {
|
|
22
|
-
super.install(cli);
|
|
23
|
-
cli.command("test").action(() => this.test());
|
|
24
|
-
}
|
|
25
|
-
test() {
|
|
26
|
-
return this.configService.dataPath("data");
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
exports.ProjectController = ProjectController;
|
|
30
|
-
exports.ProjectController = ProjectController = __decorate([
|
|
31
|
-
(0, Injectable_1.Injectable)(),
|
|
32
|
-
__metadata("design:paramtypes", [ConfigService_1.ConfigService])
|
|
33
|
-
], ProjectController);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controller = void 0;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const DI_1 = require("../makes/DI");
|
|
6
|
-
const di = new DI_1.DI();
|
|
7
|
-
const Controller = () => {
|
|
8
|
-
// return (Target: any) => {
|
|
9
|
-
// const types = Reflect.getMetadata("design:paramtypes", Target);
|
|
10
|
-
//
|
|
11
|
-
// const params = types.map((type: any) => {
|
|
12
|
-
// return di.resolveService(type);
|
|
13
|
-
// });
|
|
14
|
-
// };
|
|
15
|
-
return (Target) => {
|
|
16
|
-
const types = Reflect.getMetadata("design:paramtypes", Target);
|
|
17
|
-
const params = types.map((type) => {
|
|
18
|
-
return di.resolveService(type);
|
|
19
|
-
});
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
return class extends Target {
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...params);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
exports.Controller = Controller;
|
package/lib/decorators/Module.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Module = void 0;
|
|
13
|
-
const DI_1 = require("../makes/DI");
|
|
14
|
-
const Module = (options) => {
|
|
15
|
-
const { services = [] } = options;
|
|
16
|
-
const di = new DI_1.DI();
|
|
17
|
-
for (const service of services) {
|
|
18
|
-
//
|
|
19
|
-
}
|
|
20
|
-
return (Target) => {
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
return class extends Target {
|
|
23
|
-
run(parts) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
exports.Module = Module;
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare class ConfigService {
|
|
2
|
-
protected DATA_DIR: string;
|
|
3
|
-
protected PLUGINS_DIR: string;
|
|
4
|
-
constructor(DATA_DIR: string, PLUGINS_DIR: string);
|
|
5
|
-
dataPath(...args: string[]): string;
|
|
6
|
-
pluginsPath(...args: string[]): string;
|
|
7
|
-
getData(): string;
|
|
8
|
-
}
|
|
9
|
-
export { ConfigService };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ConfigService = void 0;
|
|
27
|
-
const Path = __importStar(require("path"));
|
|
28
|
-
class ConfigService {
|
|
29
|
-
constructor(DATA_DIR, PLUGINS_DIR) {
|
|
30
|
-
this.DATA_DIR = DATA_DIR;
|
|
31
|
-
this.PLUGINS_DIR = PLUGINS_DIR;
|
|
32
|
-
}
|
|
33
|
-
dataPath(...args) {
|
|
34
|
-
return Path.join(this.DATA_DIR, ...args);
|
|
35
|
-
}
|
|
36
|
-
pluginsPath(...args) {
|
|
37
|
-
return Path.join(this.PLUGINS_DIR, ...args);
|
|
38
|
-
}
|
|
39
|
-
getData() {
|
|
40
|
-
return "Test";
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.ConfigService = ConfigService;
|