@h3ravel/filesystem 0.2.1 → 0.3.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/index.cjs +63 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +62 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -21,9 +21,68 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
+
let __h3ravel_shared = require("@h3ravel/shared");
|
|
25
|
+
__h3ravel_shared = __toESM(__h3ravel_shared);
|
|
26
|
+
let fs_promises = require("fs/promises");
|
|
27
|
+
fs_promises = __toESM(fs_promises);
|
|
24
28
|
let __h3ravel_core = require("@h3ravel/core");
|
|
25
29
|
__h3ravel_core = __toESM(__h3ravel_core);
|
|
26
30
|
|
|
31
|
+
//#region src/Commands/StorageLinkCommand.ts
|
|
32
|
+
var StorageLinkCommand = class extends __h3ravel_core.ConsoleCommand {
|
|
33
|
+
/**
|
|
34
|
+
* The name and signature of the console command.
|
|
35
|
+
*
|
|
36
|
+
* @var string
|
|
37
|
+
*/
|
|
38
|
+
signature = `storage:link
|
|
39
|
+
{--r|relative : Create the symbolic link using relative paths}
|
|
40
|
+
{--force : Recreate existing symbolic links}
|
|
41
|
+
`;
|
|
42
|
+
/**
|
|
43
|
+
* The console command description.
|
|
44
|
+
*
|
|
45
|
+
* @var string
|
|
46
|
+
*/
|
|
47
|
+
description = "Create the symbolic links configured for the application.";
|
|
48
|
+
/**
|
|
49
|
+
* Execute the console command.
|
|
50
|
+
*/
|
|
51
|
+
async handle() {
|
|
52
|
+
console.log("");
|
|
53
|
+
const links = config("filesystem.links");
|
|
54
|
+
for (const key in links) {
|
|
55
|
+
const force = this.option("force");
|
|
56
|
+
const newPath = key;
|
|
57
|
+
const existingPath = links[key];
|
|
58
|
+
if (!force && await __h3ravel_shared.FileSystem.fileExists(newPath)) {
|
|
59
|
+
__h3ravel_shared.Logger.log([
|
|
60
|
+
[" ERROR ", "bgRed"],
|
|
61
|
+
["The", "white"],
|
|
62
|
+
[`[${newPath.replace(process.cwd(), "")}]`, "bold"],
|
|
63
|
+
["link already exists.\n", "white"]
|
|
64
|
+
], " ");
|
|
65
|
+
continue;
|
|
66
|
+
} else if (force) {
|
|
67
|
+
await (0, fs_promises.rm)(newPath, {
|
|
68
|
+
recursive: true,
|
|
69
|
+
force: true
|
|
70
|
+
});
|
|
71
|
+
await (0, fs_promises.symlink)(existingPath, newPath);
|
|
72
|
+
} else await (0, fs_promises.symlink)(existingPath, newPath);
|
|
73
|
+
__h3ravel_shared.Logger.log([
|
|
74
|
+
[" INFO ", "bgBlue"],
|
|
75
|
+
[" The ", "white"],
|
|
76
|
+
[`[${newPath.replace(process.cwd(), "")}] `, "bold"],
|
|
77
|
+
["link has been connected to ", "white"],
|
|
78
|
+
[`[${existingPath.replace(process.cwd(), "")}]`, "bold"],
|
|
79
|
+
[".\n", "white"]
|
|
80
|
+
], "");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
27
86
|
//#region src/Providers/FilesystemProvider.ts
|
|
28
87
|
/**
|
|
29
88
|
* Sets up Filesystem management and lifecycle.
|
|
@@ -31,9 +90,12 @@ __h3ravel_core = __toESM(__h3ravel_core);
|
|
|
31
90
|
*/
|
|
32
91
|
var FilesystemProvider = class extends __h3ravel_core.ServiceProvider {
|
|
33
92
|
static priority = 997;
|
|
34
|
-
register() {
|
|
93
|
+
register() {
|
|
94
|
+
this.commands([StorageLinkCommand]);
|
|
95
|
+
}
|
|
35
96
|
};
|
|
36
97
|
|
|
37
98
|
//#endregion
|
|
38
99
|
exports.FilesystemProvider = FilesystemProvider;
|
|
100
|
+
exports.StorageLinkCommand = StorageLinkCommand;
|
|
39
101
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["ServiceProvider"],"sources":["../src/Providers/FilesystemProvider.ts"],"sourcesContent":["import { ServiceProvider } from '@h3ravel/core'\n\n/**\n * Sets up Filesystem management and lifecycle.\n * \n */\nexport class FilesystemProvider extends ServiceProvider {\n public static priority = 997\n\n register () {\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["ConsoleCommand","FileSystem","ServiceProvider"],"sources":["../src/Commands/StorageLinkCommand.ts","../src/Providers/FilesystemProvider.ts"],"sourcesContent":["import { FileSystem, Logger } from '@h3ravel/shared'\nimport { rm, symlink } from 'fs/promises'\n\nimport { ConsoleCommand } from '@h3ravel/core'\n\nexport class StorageLinkCommand extends ConsoleCommand {\n\n /**\n * The name and signature of the console command.\n *\n * @var string\n */\n protected signature: string = `storage:link\n {--r|relative : Create the symbolic link using relative paths}\n {--force : Recreate existing symbolic links}\n `\n /**\n * The console command description.\n *\n * @var string\n */\n protected description: string = 'Create the symbolic links configured for the application.'\n\n /**\n * Execute the console command.\n */\n public async handle () {\n console.log('')\n const links = config('filesystem.links')\n\n for (const key in links) {\n const force = this.option('force')\n const newPath = key\n const existingPath = links[key]\n\n if (!force && await FileSystem.fileExists(newPath)) {\n Logger.log([\n [' ERROR ', 'bgRed'],\n ['The', 'white'],\n [`[${newPath.replace(process.cwd(), '')}]`, 'bold'],\n ['link already exists.\\n', 'white']\n ], ' ')\n continue\n } else if (force) {\n await rm(newPath, { recursive: true, force: true })\n await symlink(existingPath, newPath)\n } else {\n await symlink(existingPath, newPath)\n }\n\n Logger.log([\n [' INFO ', 'bgBlue'],\n [' The ', 'white'],\n [`[${newPath.replace(process.cwd(), '')}] `, 'bold'],\n ['link has been connected to ', 'white'],\n [`[${existingPath.replace(process.cwd(), '')}]`, 'bold'],\n ['.\\n', 'white']\n ], '')\n }\n }\n}\n","import { ServiceProvider } from '@h3ravel/core'\nimport { StorageLinkCommand } from '../Commands/StorageLinkCommand'\n\n/**\n * Sets up Filesystem management and lifecycle.\n * \n */\nexport class FilesystemProvider extends ServiceProvider {\n public static priority = 997\n\n register () {\n this.commands([StorageLinkCommand])\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAa,qBAAb,cAAwCA,8BAAe;;;;;;CAOnD,AAAU,YAAoB;;;;;;;;;CAS9B,AAAU,cAAsB;;;;CAKhC,MAAa,SAAU;AACnB,UAAQ,IAAI,GAAG;EACf,MAAM,QAAQ,OAAO,mBAAmB;AAExC,OAAK,MAAM,OAAO,OAAO;GACrB,MAAM,QAAQ,KAAK,OAAO,QAAQ;GAClC,MAAM,UAAU;GAChB,MAAM,eAAe,MAAM;AAE3B,OAAI,CAAC,SAAS,MAAMC,4BAAW,WAAW,QAAQ,EAAE;AAChD,4BAAO,IAAI;KACP,CAAC,WAAW,QAAQ;KACpB,CAAC,OAAO,QAAQ;KAChB,CAAC,IAAI,QAAQ,QAAQ,QAAQ,KAAK,EAAE,GAAG,CAAC,IAAI,OAAO;KACnD,CAAC,0BAA0B,QAAQ;KACtC,EAAE,IAAI;AACP;cACO,OAAO;AACd,8BAAS,SAAS;KAAE,WAAW;KAAM,OAAO;KAAM,CAAC;AACnD,mCAAc,cAAc,QAAQ;SAEpC,gCAAc,cAAc,QAAQ;AAGxC,2BAAO,IAAI;IACP,CAAC,UAAU,SAAS;IACpB,CAAC,SAAS,QAAQ;IAClB,CAAC,IAAI,QAAQ,QAAQ,QAAQ,KAAK,EAAE,GAAG,CAAC,KAAK,OAAO;IACpD,CAAC,+BAA+B,QAAQ;IACxC,CAAC,IAAI,aAAa,QAAQ,QAAQ,KAAK,EAAE,GAAG,CAAC,IAAI,OAAO;IACxD,CAAC,OAAO,QAAQ;IACnB,EAAE,GAAG;;;;;;;;;;;AClDlB,IAAa,qBAAb,cAAwCC,+BAAgB;CACpD,OAAc,WAAW;CAEzB,WAAY;AACR,OAAK,SAAS,CAAC,mBAAmB,CAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="./app.globals.d.ts" />
|
|
2
|
+
import { ConsoleCommand, ServiceProvider } from "@h3ravel/core";
|
|
2
3
|
|
|
4
|
+
//#region src/Commands/StorageLinkCommand.d.ts
|
|
5
|
+
declare class StorageLinkCommand extends ConsoleCommand {
|
|
6
|
+
/**
|
|
7
|
+
* The name and signature of the console command.
|
|
8
|
+
*
|
|
9
|
+
* @var string
|
|
10
|
+
*/
|
|
11
|
+
protected signature: string;
|
|
12
|
+
/**
|
|
13
|
+
* The console command description.
|
|
14
|
+
*
|
|
15
|
+
* @var string
|
|
16
|
+
*/
|
|
17
|
+
protected description: string;
|
|
18
|
+
/**
|
|
19
|
+
* Execute the console command.
|
|
20
|
+
*/
|
|
21
|
+
handle(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
3
24
|
//#region src/Providers/FilesystemProvider.d.ts
|
|
4
|
-
|
|
5
25
|
/**
|
|
6
26
|
* Sets up Filesystem management and lifecycle.
|
|
7
27
|
*
|
|
@@ -11,5 +31,5 @@ declare class FilesystemProvider extends ServiceProvider {
|
|
|
11
31
|
register(): void;
|
|
12
32
|
}
|
|
13
33
|
//#endregion
|
|
14
|
-
export { FilesystemProvider };
|
|
34
|
+
export { FilesystemProvider, StorageLinkCommand };
|
|
15
35
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference path="./app.globals.d.ts" />
|
|
2
|
+
import { ConsoleCommand, ServiceProvider } from "@h3ravel/core";
|
|
2
3
|
|
|
4
|
+
//#region src/Commands/StorageLinkCommand.d.ts
|
|
5
|
+
declare class StorageLinkCommand extends ConsoleCommand {
|
|
6
|
+
/**
|
|
7
|
+
* The name and signature of the console command.
|
|
8
|
+
*
|
|
9
|
+
* @var string
|
|
10
|
+
*/
|
|
11
|
+
protected signature: string;
|
|
12
|
+
/**
|
|
13
|
+
* The console command description.
|
|
14
|
+
*
|
|
15
|
+
* @var string
|
|
16
|
+
*/
|
|
17
|
+
protected description: string;
|
|
18
|
+
/**
|
|
19
|
+
* Execute the console command.
|
|
20
|
+
*/
|
|
21
|
+
handle(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
3
24
|
//#region src/Providers/FilesystemProvider.d.ts
|
|
4
|
-
|
|
5
25
|
/**
|
|
6
26
|
* Sets up Filesystem management and lifecycle.
|
|
7
27
|
*
|
|
@@ -11,5 +31,5 @@ declare class FilesystemProvider extends ServiceProvider {
|
|
|
11
31
|
register(): void;
|
|
12
32
|
}
|
|
13
33
|
//#endregion
|
|
14
|
-
export { FilesystemProvider };
|
|
34
|
+
export { FilesystemProvider, StorageLinkCommand };
|
|
15
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileSystem, Logger } from "@h3ravel/shared";
|
|
2
|
+
import { rm, symlink } from "fs/promises";
|
|
3
|
+
import { ConsoleCommand, ServiceProvider } from "@h3ravel/core";
|
|
2
4
|
|
|
5
|
+
//#region src/Commands/StorageLinkCommand.ts
|
|
6
|
+
var StorageLinkCommand = class extends ConsoleCommand {
|
|
7
|
+
/**
|
|
8
|
+
* The name and signature of the console command.
|
|
9
|
+
*
|
|
10
|
+
* @var string
|
|
11
|
+
*/
|
|
12
|
+
signature = `storage:link
|
|
13
|
+
{--r|relative : Create the symbolic link using relative paths}
|
|
14
|
+
{--force : Recreate existing symbolic links}
|
|
15
|
+
`;
|
|
16
|
+
/**
|
|
17
|
+
* The console command description.
|
|
18
|
+
*
|
|
19
|
+
* @var string
|
|
20
|
+
*/
|
|
21
|
+
description = "Create the symbolic links configured for the application.";
|
|
22
|
+
/**
|
|
23
|
+
* Execute the console command.
|
|
24
|
+
*/
|
|
25
|
+
async handle() {
|
|
26
|
+
console.log("");
|
|
27
|
+
const links = config("filesystem.links");
|
|
28
|
+
for (const key in links) {
|
|
29
|
+
const force = this.option("force");
|
|
30
|
+
const newPath = key;
|
|
31
|
+
const existingPath = links[key];
|
|
32
|
+
if (!force && await FileSystem.fileExists(newPath)) {
|
|
33
|
+
Logger.log([
|
|
34
|
+
[" ERROR ", "bgRed"],
|
|
35
|
+
["The", "white"],
|
|
36
|
+
[`[${newPath.replace(process.cwd(), "")}]`, "bold"],
|
|
37
|
+
["link already exists.\n", "white"]
|
|
38
|
+
], " ");
|
|
39
|
+
continue;
|
|
40
|
+
} else if (force) {
|
|
41
|
+
await rm(newPath, {
|
|
42
|
+
recursive: true,
|
|
43
|
+
force: true
|
|
44
|
+
});
|
|
45
|
+
await symlink(existingPath, newPath);
|
|
46
|
+
} else await symlink(existingPath, newPath);
|
|
47
|
+
Logger.log([
|
|
48
|
+
[" INFO ", "bgBlue"],
|
|
49
|
+
[" The ", "white"],
|
|
50
|
+
[`[${newPath.replace(process.cwd(), "")}] `, "bold"],
|
|
51
|
+
["link has been connected to ", "white"],
|
|
52
|
+
[`[${existingPath.replace(process.cwd(), "")}]`, "bold"],
|
|
53
|
+
[".\n", "white"]
|
|
54
|
+
], "");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
3
60
|
//#region src/Providers/FilesystemProvider.ts
|
|
4
61
|
/**
|
|
5
62
|
* Sets up Filesystem management and lifecycle.
|
|
@@ -7,9 +64,11 @@ import { ServiceProvider } from "@h3ravel/core";
|
|
|
7
64
|
*/
|
|
8
65
|
var FilesystemProvider = class extends ServiceProvider {
|
|
9
66
|
static priority = 997;
|
|
10
|
-
register() {
|
|
67
|
+
register() {
|
|
68
|
+
this.commands([StorageLinkCommand]);
|
|
69
|
+
}
|
|
11
70
|
};
|
|
12
71
|
|
|
13
72
|
//#endregion
|
|
14
|
-
export { FilesystemProvider };
|
|
73
|
+
export { FilesystemProvider, StorageLinkCommand };
|
|
15
74
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/Providers/FilesystemProvider.ts"],"sourcesContent":["import { ServiceProvider } from '@h3ravel/core'\n\n/**\n * Sets up Filesystem management and lifecycle.\n * \n */\nexport class FilesystemProvider extends ServiceProvider {\n public static priority = 997\n\n register () {\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/Commands/StorageLinkCommand.ts","../src/Providers/FilesystemProvider.ts"],"sourcesContent":["import { FileSystem, Logger } from '@h3ravel/shared'\nimport { rm, symlink } from 'fs/promises'\n\nimport { ConsoleCommand } from '@h3ravel/core'\n\nexport class StorageLinkCommand extends ConsoleCommand {\n\n /**\n * The name and signature of the console command.\n *\n * @var string\n */\n protected signature: string = `storage:link\n {--r|relative : Create the symbolic link using relative paths}\n {--force : Recreate existing symbolic links}\n `\n /**\n * The console command description.\n *\n * @var string\n */\n protected description: string = 'Create the symbolic links configured for the application.'\n\n /**\n * Execute the console command.\n */\n public async handle () {\n console.log('')\n const links = config('filesystem.links')\n\n for (const key in links) {\n const force = this.option('force')\n const newPath = key\n const existingPath = links[key]\n\n if (!force && await FileSystem.fileExists(newPath)) {\n Logger.log([\n [' ERROR ', 'bgRed'],\n ['The', 'white'],\n [`[${newPath.replace(process.cwd(), '')}]`, 'bold'],\n ['link already exists.\\n', 'white']\n ], ' ')\n continue\n } else if (force) {\n await rm(newPath, { recursive: true, force: true })\n await symlink(existingPath, newPath)\n } else {\n await symlink(existingPath, newPath)\n }\n\n Logger.log([\n [' INFO ', 'bgBlue'],\n [' The ', 'white'],\n [`[${newPath.replace(process.cwd(), '')}] `, 'bold'],\n ['link has been connected to ', 'white'],\n [`[${existingPath.replace(process.cwd(), '')}]`, 'bold'],\n ['.\\n', 'white']\n ], '')\n }\n }\n}\n","import { ServiceProvider } from '@h3ravel/core'\nimport { StorageLinkCommand } from '../Commands/StorageLinkCommand'\n\n/**\n * Sets up Filesystem management and lifecycle.\n * \n */\nexport class FilesystemProvider extends ServiceProvider {\n public static priority = 997\n\n register () {\n this.commands([StorageLinkCommand])\n }\n}\n"],"mappings":";;;;;AAKA,IAAa,qBAAb,cAAwC,eAAe;;;;;;CAOnD,AAAU,YAAoB;;;;;;;;;CAS9B,AAAU,cAAsB;;;;CAKhC,MAAa,SAAU;AACnB,UAAQ,IAAI,GAAG;EACf,MAAM,QAAQ,OAAO,mBAAmB;AAExC,OAAK,MAAM,OAAO,OAAO;GACrB,MAAM,QAAQ,KAAK,OAAO,QAAQ;GAClC,MAAM,UAAU;GAChB,MAAM,eAAe,MAAM;AAE3B,OAAI,CAAC,SAAS,MAAM,WAAW,WAAW,QAAQ,EAAE;AAChD,WAAO,IAAI;KACP,CAAC,WAAW,QAAQ;KACpB,CAAC,OAAO,QAAQ;KAChB,CAAC,IAAI,QAAQ,QAAQ,QAAQ,KAAK,EAAE,GAAG,CAAC,IAAI,OAAO;KACnD,CAAC,0BAA0B,QAAQ;KACtC,EAAE,IAAI;AACP;cACO,OAAO;AACd,UAAM,GAAG,SAAS;KAAE,WAAW;KAAM,OAAO;KAAM,CAAC;AACnD,UAAM,QAAQ,cAAc,QAAQ;SAEpC,OAAM,QAAQ,cAAc,QAAQ;AAGxC,UAAO,IAAI;IACP,CAAC,UAAU,SAAS;IACpB,CAAC,SAAS,QAAQ;IAClB,CAAC,IAAI,QAAQ,QAAQ,QAAQ,KAAK,EAAE,GAAG,CAAC,KAAK,OAAO;IACpD,CAAC,+BAA+B,QAAQ;IACxC,CAAC,IAAI,aAAa,QAAQ,QAAQ,KAAK,EAAE,GAAG,CAAC,IAAI,OAAO;IACxD,CAAC,OAAO,QAAQ;IACnB,EAAE,GAAG;;;;;;;;;;;AClDlB,IAAa,qBAAb,cAAwC,gBAAgB;CACpD,OAAc,WAAW;CAEzB,WAAY;AACR,OAAK,SAAS,CAAC,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/filesystem",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Filesystem manager for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"filesystem"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@h3ravel/
|
|
41
|
-
"@h3ravel/
|
|
40
|
+
"@h3ravel/support": "^0.10.2",
|
|
41
|
+
"@h3ravel/shared": "^0.20.4"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@h3ravel/core": "^1.
|
|
44
|
+
"@h3ravel/core": "^1.10.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"typescript": "^5.4.0"
|