@stacksjs/path 0.70.45 → 0.70.54
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/LICENSE.md +21 -0
- package/dist/index.js +18 -3
- package/dist/src/index.d.ts +36 -0
- package/package.json +1 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Open Web Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
|
+
import { existsSync } from "fs";
|
|
5
6
|
import os from "os";
|
|
6
7
|
import {
|
|
7
8
|
basename,
|
|
@@ -51,7 +52,10 @@ function userViewsPath(path) {
|
|
|
51
52
|
return resourcesPath(`views/${path || ""}`);
|
|
52
53
|
}
|
|
53
54
|
function userFunctionsPath(path) {
|
|
54
|
-
return resourcesPath(
|
|
55
|
+
return `${resolveUserLibBase(projectPath("functions"), resourcesPath("functions"))}/${path || ""}`;
|
|
56
|
+
}
|
|
57
|
+
function resolveUserLibBase(rootDir, resourcesDir, exists = existsSync) {
|
|
58
|
+
return exists(rootDir) ? rootDir : resourcesDir;
|
|
55
59
|
}
|
|
56
60
|
function userJobsPath(path) {
|
|
57
61
|
return appPath(`Jobs/${path || ""}`);
|
|
@@ -71,6 +75,12 @@ function userModelsPath(path) {
|
|
|
71
75
|
function userNotificationsPath(path) {
|
|
72
76
|
return appPath(`Notifications/${path || ""}`);
|
|
73
77
|
}
|
|
78
|
+
function userMailPath(path) {
|
|
79
|
+
return appPath(`Mail/${path || ""}`);
|
|
80
|
+
}
|
|
81
|
+
function userEmailsPath(path) {
|
|
82
|
+
return resourcesPath(`emails/${path || ""}`);
|
|
83
|
+
}
|
|
74
84
|
function userDatabasePath(path) {
|
|
75
85
|
return projectPath(`database/${path || ""}`);
|
|
76
86
|
}
|
|
@@ -162,7 +172,7 @@ function commandsPath(path) {
|
|
|
162
172
|
return appPath(`Commands/${path || ""}`);
|
|
163
173
|
}
|
|
164
174
|
function componentsPath(path) {
|
|
165
|
-
return
|
|
175
|
+
return `${resolveUserLibBase(projectPath("components"), resourcesPath("components"))}/${path || ""}`;
|
|
166
176
|
}
|
|
167
177
|
function configPath(path) {
|
|
168
178
|
return corePath(`config/${path || ""}`);
|
|
@@ -228,7 +238,7 @@ function healthPath(path) {
|
|
|
228
238
|
return corePath(`health/${path || ""}`);
|
|
229
239
|
}
|
|
230
240
|
function functionsPath(path) {
|
|
231
|
-
return
|
|
241
|
+
return `${resolveUserLibBase(projectPath("functions"), resourcesPath("functions"))}/${path || ""}`;
|
|
232
242
|
}
|
|
233
243
|
function gitPath(path) {
|
|
234
244
|
return corePath(`git/${path || ""}`);
|
|
@@ -566,6 +576,8 @@ var path = {
|
|
|
566
576
|
userMiddlewarePath,
|
|
567
577
|
userModelsPath,
|
|
568
578
|
userNotificationsPath,
|
|
579
|
+
userMailPath,
|
|
580
|
+
userEmailsPath,
|
|
569
581
|
utilsPath,
|
|
570
582
|
validationPath,
|
|
571
583
|
xRayPath,
|
|
@@ -594,11 +606,13 @@ export {
|
|
|
594
606
|
userModelsPath,
|
|
595
607
|
userMigrationsPath,
|
|
596
608
|
userMiddlewarePath,
|
|
609
|
+
userMailPath,
|
|
597
610
|
userListenersPath,
|
|
598
611
|
userLibsPath,
|
|
599
612
|
userJobsPath,
|
|
600
613
|
userFunctionsPath,
|
|
601
614
|
userEventsPath,
|
|
615
|
+
userEmailsPath,
|
|
602
616
|
userDatabasePath,
|
|
603
617
|
userControllersPath,
|
|
604
618
|
userComponentsPath,
|
|
@@ -631,6 +645,7 @@ export {
|
|
|
631
645
|
routesPath,
|
|
632
646
|
routerPath,
|
|
633
647
|
resourcesPath,
|
|
648
|
+
resolveUserLibBase,
|
|
634
649
|
resolve,
|
|
635
650
|
replPath,
|
|
636
651
|
relativeActionsPath,
|
package/dist/src/index.d.ts
CHANGED
|
@@ -20,6 +20,17 @@ export declare function builtUserActionsPath(path?: string, options?: { relative
|
|
|
20
20
|
export declare function userComponentsPath(path?: string): string;
|
|
21
21
|
export declare function userViewsPath(path?: string): string;
|
|
22
22
|
export declare function userFunctionsPath(path?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Pick where a user lib folder (`components` / `functions`) lives
|
|
25
|
+
* (stacksjs/stacks#929). A root-level `<project>/components` (or
|
|
26
|
+
* `/functions`) folder wins when it exists; otherwise the conventional
|
|
27
|
+
* `resources/<name>`. Lets apps keep these at the project root without
|
|
28
|
+
* losing the `resources/`-nested default.
|
|
29
|
+
*
|
|
30
|
+
* Pure + injectable `exists` so the selection is unit-testable without
|
|
31
|
+
* touching the real filesystem.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveUserLibBase(rootDir: string, resourcesDir: string, exists?: (p: string) => boolean): string;
|
|
23
34
|
/**
|
|
24
35
|
* Returns the path to the user-defined `Jobs` directory.
|
|
25
36
|
*
|
|
@@ -92,6 +103,29 @@ export declare function userModelsPath(path?: string): string;
|
|
|
92
103
|
* ```
|
|
93
104
|
*/
|
|
94
105
|
export declare function userNotificationsPath(path?: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Returns the path to the user-defined `Mail` directory.
|
|
108
|
+
*
|
|
109
|
+
* Mailable classes live here, one file per email type. The companion
|
|
110
|
+
* stx template lives in `resources/emails/<kebab-name>.stx` and is
|
|
111
|
+
* resolved by `@stacksjs/email`'s template loader at send time.
|
|
112
|
+
*
|
|
113
|
+
* @param path - The relative path to the file or directory within the `Mail` directory.
|
|
114
|
+
* @returns The absolute path to the specified file or directory within the user-defined `Mail` directory.
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* import { userMailPath } from '@stacksjs/path'
|
|
118
|
+
*
|
|
119
|
+
* console.log(userMailPath('Welcome.ts')) // Outputs the absolute path to 'Welcome.ts' within the user-defined `Mail` directory.
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare function userMailPath(path?: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the path to the user-defined `resources/emails` directory
|
|
125
|
+
* where stx email templates live. The make:mail scaffolder writes a
|
|
126
|
+
* companion stx file alongside each Mailable class.
|
|
127
|
+
*/
|
|
128
|
+
export declare function userEmailsPath(path?: string): string;
|
|
95
129
|
export declare function userDatabasePath(path?: string): string;
|
|
96
130
|
export declare function userMigrationsPath(path?: string): string;
|
|
97
131
|
/**
|
|
@@ -1034,6 +1068,8 @@ export declare interface Path {
|
|
|
1034
1068
|
userMiddlewarePath: (path?: string) => string
|
|
1035
1069
|
userModelsPath: (path?: string) => string
|
|
1036
1070
|
userNotificationsPath: (path?: string) => string
|
|
1071
|
+
userMailPath: (path?: string) => string
|
|
1072
|
+
userEmailsPath: (path?: string) => string
|
|
1037
1073
|
utilsPath: (path?: string) => string
|
|
1038
1074
|
validationPath: (path?: string) => string
|
|
1039
1075
|
xRayPath: (path?: string) => string
|