@wocker/core
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -6,2 +6,3 @@ export { Cli } from "@kearisp/cli"; | ||
export * from "./makes/DI"; | ||
export * from "./makes/FS"; | ||
export * from "./makes/FSManager"; | ||
@@ -8,0 +9,0 @@ export * from "./makes/Logger"; |
@@ -24,2 +24,3 @@ "use strict"; | ||
__exportStar(require("./makes/DI"), exports); | ||
__exportStar(require("./makes/FS"), exports); | ||
__exportStar(require("./makes/FSManager"), exports); | ||
@@ -26,0 +27,0 @@ __exportStar(require("./makes/Logger"), exports); |
/// <reference types="node" /> | ||
import { PathOrFileDescriptor } from "fs"; | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Abortable } from "node:events"; | ||
import { PathLike, PathOrFileDescriptor, WriteFileOptions, RmOptions, MakeDirectoryOptions } from "fs"; | ||
type ReadFileOptions = Abortable & { | ||
encoding?: BufferEncoding; | ||
flag?: string; | ||
}; | ||
declare class FS { | ||
static readJSON(filePath: PathOrFileDescriptor): Promise<any>; | ||
static writeJSON(filePath: PathOrFileDescriptor, data: any): Promise<void>; | ||
static mkdir(path: PathLike, options?: MakeDirectoryOptions): Promise<unknown>; | ||
static readFile(filePath: PathOrFileDescriptor, options?: ReadFileOptions): Promise<string | Buffer>; | ||
static writeFile(filePath: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): Promise<unknown>; | ||
static readJSON(...paths: string[]): Promise<any>; | ||
static writeJSON(filePath: PathOrFileDescriptor, data: any, options?: WriteFileOptions): Promise<void>; | ||
static rm(path: PathLike, options?: RmOptions): Promise<void>; | ||
} | ||
export { FS }; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -14,6 +37,53 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
const fs_1 = require("fs"); | ||
const Path = __importStar(require("path")); | ||
class FS { | ||
static readJSON(filePath) { | ||
static mkdir(path, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
(0, fs_1.mkdir)(path, options, (err) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(undefined); | ||
}); | ||
}); | ||
}); | ||
} | ||
static readFile(filePath, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
(0, fs_1.readFile)(filePath, options, (err, res) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(res); | ||
}); | ||
}); | ||
}); | ||
} | ||
static writeFile(filePath, data, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
const callback = (err) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(undefined); | ||
}; | ||
if (options) { | ||
(0, fs_1.writeFile)(filePath, data, options, callback); | ||
} | ||
else { | ||
(0, fs_1.writeFile)(filePath, data, callback); | ||
} | ||
}); | ||
}); | ||
} | ||
static readJSON(...paths) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield new Promise((resolve, reject) => { | ||
const filePath = Path.join(...paths); | ||
(0, fs_1.readFile)(filePath, (err, data) => { | ||
@@ -30,7 +100,7 @@ if (err) { | ||
} | ||
static writeJSON(filePath, data) { | ||
static writeJSON(filePath, data, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const json = JSON.stringify(data, null, 4); | ||
return new Promise((resolve, reject) => { | ||
(0, fs_1.writeFile)(filePath, json, (err) => { | ||
const callback = (err) => { | ||
if (err) { | ||
@@ -41,7 +111,32 @@ reject(err); | ||
resolve(undefined); | ||
}); | ||
}; | ||
if (options) { | ||
(0, fs_1.writeFile)(filePath, json, options, callback); | ||
} | ||
else { | ||
(0, fs_1.writeFile)(filePath, json, callback); | ||
} | ||
}); | ||
}); | ||
} | ||
static rm(path, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
const callback = (err) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(undefined); | ||
}; | ||
if (options) { | ||
(0, fs_1.rm)(path, options, callback); | ||
} | ||
else { | ||
(0, fs_1.rm)(path, callback); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
exports.FS = FS; |
@@ -6,5 +6,5 @@ import { DI } from "./DI"; | ||
static info(...data: any[]): void; | ||
static warning(...data: any[]): void; | ||
static warn(...data: any[]): void; | ||
static error(...data: any[]): void; | ||
} | ||
export { Logger }; |
@@ -16,4 +16,4 @@ "use strict"; | ||
} | ||
static warning(...data) { | ||
_di.resolveService(LogService_1.LogService).warning(...data); | ||
static warn(...data) { | ||
_di.resolveService(LogService_1.LogService).warn(...data); | ||
} | ||
@@ -20,0 +20,0 @@ static error(...data) { |
@@ -20,6 +20,8 @@ import "reflect-metadata"; | ||
env: EnvConfig; | ||
ports?: string[]; | ||
volumes?: string[]; | ||
ports?: string[]; | ||
metadata?: EnvConfig; | ||
static di?: DI; | ||
constructor(data: any); | ||
get containerName(): string; | ||
hasEnv(name: string): boolean; | ||
@@ -29,2 +31,6 @@ getEnv(name: string, defaultValue?: string): string | undefined; | ||
unsetEnv(name: string): void; | ||
hasMeta(name: string): boolean; | ||
getMeta<D = string | undefined>(name: string, defaultValue?: D): D; | ||
setMeta(name: string, value: string | boolean): void; | ||
unsetMeta(name: string): void; | ||
volumeMount(...volumes: string[]): void; | ||
@@ -31,0 +37,0 @@ getVolumeBySource(source: string): string | undefined; |
@@ -33,3 +33,7 @@ "use strict"; | ||
this.volumes = data.volumes; | ||
this.metadata = data.metadata; | ||
} | ||
get containerName() { | ||
return `${this.name}.workspace`; | ||
} | ||
hasEnv(name) { | ||
@@ -55,2 +59,25 @@ if (!this.env) { | ||
} | ||
hasMeta(name) { | ||
return !!this.metadata && this.metadata.hasOwnProperty(name); | ||
} | ||
getMeta(name, defaultValue) { | ||
const { [name]: value = defaultValue } = this.metadata || {}; | ||
return value; | ||
} | ||
setMeta(name, value) { | ||
if (!this.metadata) { | ||
this.metadata = {}; | ||
} | ||
this.metadata[name] = typeof value === "boolean" | ||
? (value ? "true" : "false") | ||
: value; | ||
} | ||
unsetMeta(name) { | ||
if (this.metadata && name in this.metadata) { | ||
delete this.metadata[name]; | ||
} | ||
if (this.metadata && Object.keys(this.metadata).length === 0) { | ||
delete this.metadata; | ||
} | ||
} | ||
volumeMount(...volumes) { | ||
@@ -57,0 +84,0 @@ if (volumes.length === 0) { |
declare abstract class LogService { | ||
abstract log(...data: any[]): void; | ||
abstract info(...data: any[]): void; | ||
abstract warning(...data: any[]): void; | ||
abstract warn(...data: any[]): void; | ||
abstract error(...data: any[]): void; | ||
} | ||
export { LogService }; |
@@ -0,1 +1,2 @@ | ||
import { Container } from "dockerode"; | ||
import { Project } from "../models/Project"; | ||
@@ -10,2 +11,3 @@ type SearchParams = Partial<{ | ||
abstract get(): Promise<Project>; | ||
abstract getContainer(): Promise<Container | null>; | ||
abstract start(project: Project): Promise<void>; | ||
@@ -12,0 +14,0 @@ abstract stop(project: Project): Promise<void>; |
{ | ||
"name": "@wocker/core", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"author": "Kris Papercut <krispcut@gmail.com>", | ||
"description": "Wocker Core", | ||
"description": "Core of wocker", | ||
"license": "MIT", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"keywords": [ | ||
"wocker" | ||
], | ||
"homepage": "https://kearisp.github.io/wocker", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/kearisp/wocker-core.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/kearisp/wocker-core/issues" | ||
}, | ||
"scripts": { | ||
@@ -16,12 +27,12 @@ "prepare": "npm run build", | ||
"dependencies": { | ||
"@kearisp/cli": "^1.0.3", | ||
"@kearisp/cli": "^1.0.5", | ||
"fs": "^0.0.1-security", | ||
"path": "^0.12.7", | ||
"reflect-metadata": "^0.1.13" | ||
"reflect-metadata": "^0.2.1" | ||
}, | ||
"devDependencies": { | ||
"@types/dockerode": "^3.3.23", | ||
"@types/node": "^20.8.9", | ||
"typescript": "^5.2.2" | ||
"@types/node": "^20.11.7", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
# @wocker/core | ||
###### Docker workspace for web projects | ||
## Installation | ||
**Note:** It is recommended to install Wocker globally to ensure accessibility from any directory in your terminal. | ||
```shell | ||
npm i -g @wocker/ws | ||
``` | ||
### Completion | ||
Wocker comes with shell completion support to enhance your development workflow. To enable shell completion, run the following command: | ||
```bash | ||
source <(ws completion script) | ||
``` | ||
This will enable tab completion for `ws` commands, providing a more convenient and efficient way to interact with the tool. | ||
## Documentation | ||
Wocker is a powerful tool for managing your web project's Docker workspace. It provides a convenient and efficient way to set up and manage your Docker containers. | ||
For more information and detailed usage, please refer to the [documentation](https://kearisp.github.io/wocker). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
40091
1012
0
1
30
2
+ Addedreflect-metadata@0.2.2(transitive)
- Removedreflect-metadata@0.1.14(transitive)
Updated@kearisp/cli@^1.0.5
Updatedreflect-metadata@^0.2.1