@wocker/core 1.0.32-beta.0 → 1.0.32-beta.2

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.
@@ -1,6 +1,6 @@
1
1
  import FS, { EncodingOption, BufferEncodingOption, Mode } from "fs";
2
2
  import { Readable } from "stream";
3
- import { FileSystemDriver, ReadStreamOptions, WriteStreamOptions } from "../types";
3
+ import { FileSystemDriver } from "../types";
4
4
  import { File } from "./File";
5
5
  type ReaddirOptions = FS.ObjectEncodingOptions & {
6
6
  recursive?: boolean | undefined;
@@ -21,6 +21,7 @@ export declare class FileSystem {
21
21
  basename(...parts: string[]): string;
22
22
  exists(...parts: string[]): boolean;
23
23
  stat(...parts: string[]): FS.Stats;
24
+ lstat(path?: string): FS.Stats;
24
25
  mkdir(path?: string, options?: FS.MakeDirectoryOptions): void;
25
26
  readdir(path?: string, options?: {
26
27
  recursive?: boolean;
@@ -38,8 +39,8 @@ export declare class FileSystem {
38
39
  appendFile(path: string, data: string | Uint8Array, options?: FS.WriteFileOptions): void;
39
40
  rm(path: string, options?: FS.RmOptions): void;
40
41
  mv(src: string, dest: string): void;
41
- createWriteStream(path: string, options?: WriteStreamOptions): FS.WriteStream;
42
- createReadStream(path: string, options?: ReadStreamOptions): FS.ReadStream;
42
+ createWriteStream(path: string, options?: FileSystemDriver.WriteStreamOptions): FS.WriteStream;
43
+ createReadStream(path: string, options?: FileSystemDriver.ReadStreamOptions): FS.ReadStream;
43
44
  createReadlineStream(path: string, options?: ReadlineOptions): Readable;
44
45
  getLinePosition(path: string, line: number): number;
45
46
  watch(path: string, options?: FS.WatchOptionsWithStringEncoding): FS.FSWatcher;
@@ -47,5 +48,7 @@ export declare class FileSystem {
47
48
  readlink(path: string, options: BufferEncodingOption): Buffer<ArrayBuffer>;
48
49
  chmod(path: string, mode: Mode): void;
49
50
  chown(path: string, uid: number, gid: number): void;
51
+ symlink(target: string, path: string, type?: FileSystemDriver.SymlinkType): void;
52
+ unlink(path: string): void;
50
53
  }
51
54
  export {};
@@ -51,6 +51,10 @@ class FileSystem {
51
51
  const fullPath = this.path(...parts);
52
52
  return this.driver.statSync(fullPath);
53
53
  }
54
+ lstat(path = "") {
55
+ const fullPath = this.path(path);
56
+ return this.driver.lstatSync(fullPath);
57
+ }
54
58
  mkdir(path = "", options) {
55
59
  const fullPath = this.path(path);
56
60
  this.driver.mkdirSync(fullPath, options);
@@ -191,5 +195,11 @@ class FileSystem {
191
195
  const fullPath = this.path(path);
192
196
  this.driver.chownSync(fullPath, uid, gid);
193
197
  }
198
+ symlink(target, path, type) {
199
+ this.driver.symlinkSync(path_1.default.relative(path_1.default.dirname(this.path(path)), this.path(target)), this.path(path), type);
200
+ }
201
+ unlink(path) {
202
+ this.driver.unlinkSync(this.path(path));
203
+ }
194
204
  }
195
205
  exports.FileSystem = FileSystem;
@@ -1,4 +1,6 @@
1
1
  export declare class ProcessService {
2
+ get UID(): string | undefined;
3
+ get GID(): string | undefined;
2
4
  get stdin(): NodeJS.ReadStream;
3
5
  get stdout(): NodeJS.WriteStream;
4
6
  get stderr(): NodeJS.WriteStream;
@@ -13,6 +13,18 @@ exports.ProcessService = void 0;
13
13
  const path_1 = __importDefault(require("path"));
14
14
  const decorators_1 = require("../decorators");
15
15
  let ProcessService = class ProcessService {
16
+ get UID() {
17
+ if (process.getuid) {
18
+ return `${process.getuid()}`;
19
+ }
20
+ return undefined;
21
+ }
22
+ get GID() {
23
+ if (process.getgid) {
24
+ return `${process.getgid()}`;
25
+ }
26
+ return undefined;
27
+ }
16
28
  get stdin() {
17
29
  return process.stdin;
18
30
  }
@@ -1,27 +1,11 @@
1
- import FS, { type Dirent, type EncodingOption, type BufferEncodingOption, type Mode } from "fs";
2
- type StreamOptions = {
3
- flags?: string;
4
- fd?: number;
5
- mode?: number;
6
- start?: number;
7
- autoClose?: boolean;
8
- emitClose?: boolean;
9
- encoding?: BufferEncoding;
10
- signal?: AbortSignal | null;
11
- highWaterMark?: number;
12
- };
13
- export type WriteStreamOptions = StreamOptions & {
14
- flush?: boolean;
15
- };
16
- export type ReadStreamOptions = StreamOptions & {
17
- end?: number;
18
- };
1
+ import FS, { type Dirent, type EncodingOption, type BufferEncodingOption, type Mode, type symlink } from "fs";
19
2
  export interface FileSystemDriver {
20
3
  openSync(path: string, flags: FS.OpenMode, mode?: FS.Mode | null): number;
21
4
  closeSync(fd: number): void;
22
5
  readSync(file: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: FS.ReadPosition | null): number;
23
6
  existsSync(path: string): boolean;
24
7
  statSync(path: string): FS.Stats;
8
+ lstatSync(path: string): FS.Stats;
25
9
  fstatSync(fd: number): FS.Stats;
26
10
  mkdirSync(path: string, options?: FS.MakeDirectoryOptions): void;
27
11
  readdir(path: string, options: any, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void;
@@ -30,8 +14,8 @@ export interface FileSystemDriver {
30
14
  writeFileSync(path: string, data: string | Buffer | NodeJS.ArrayBufferView, options?: FS.WriteFileOptions): void;
31
15
  appendFileSync(path: FS.PathOrFileDescriptor, data: string | Uint8Array, options?: FS.WriteFileOptions): void;
32
16
  rmSync(path: string, options?: FS.RmOptions): void;
33
- createWriteStream(path: string, options?: WriteStreamOptions): FS.WriteStream;
34
- createReadStream(path: string, options?: ReadStreamOptions): FS.ReadStream;
17
+ createWriteStream(path: string, options?: FileSystemDriver.WriteStreamOptions): FS.WriteStream;
18
+ createReadStream(path: string, options?: FileSystemDriver.ReadStreamOptions): FS.ReadStream;
35
19
  watch(file: string, options: FS.WatchOptionsWithStringEncoding, listener?: FS.WatchListener<string | Buffer>): FS.FSWatcher;
36
20
  watchFile(path: string, listener: FS.StatsListener): FS.StatWatcher;
37
21
  cpSync(source: string, destination: string, opts?: FS.CopySyncOptions): void;
@@ -39,5 +23,26 @@ export interface FileSystemDriver {
39
23
  readlinkSync(path: string, options?: EncodingOption | BufferEncodingOption): string | Buffer<ArrayBuffer>;
40
24
  chmodSync(path: string, mode: Mode): void;
41
25
  chownSync(path: string, uid: number, gid: number): void;
26
+ symlinkSync(target: string, path: string, type?: symlink.Type): void;
27
+ unlinkSync(path: string): void;
28
+ }
29
+ export declare namespace FileSystemDriver {
30
+ type SymlinkType = symlink.Type;
31
+ type StreamOptions = {
32
+ flags?: string;
33
+ fd?: number;
34
+ mode?: number;
35
+ start?: number;
36
+ autoClose?: boolean;
37
+ emitClose?: boolean;
38
+ encoding?: BufferEncoding;
39
+ signal?: AbortSignal | null;
40
+ highWaterMark?: number;
41
+ };
42
+ type WriteStreamOptions = StreamOptions & {
43
+ flush?: boolean;
44
+ };
45
+ type ReadStreamOptions = StreamOptions & {
46
+ end?: number;
47
+ };
42
48
  }
43
- export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/core",
3
3
  "type": "commonjs",
4
- "version": "1.0.32-beta.0",
4
+ "version": "1.0.32-beta.2",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Core of the Wocker",
7
7
  "license": "MIT",