@shell-shock/core 0.6.0 → 0.8.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/components/docs.cjs +1 -1
- package/dist/components/docs.cjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/docs.mjs +1 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/helpers.cjs +15 -0
- package/dist/components/helpers.cjs.map +1 -0
- package/dist/components/helpers.d.cts +13 -0
- package/dist/components/helpers.d.cts.map +1 -0
- package/dist/components/helpers.d.mts +13 -0
- package/dist/components/helpers.d.mts.map +1 -0
- package/dist/components/helpers.mjs +14 -0
- package/dist/components/helpers.mjs.map +1 -0
- package/dist/components/index.cjs +5 -1
- package/dist/components/index.d.cts +3 -2
- package/dist/components/index.d.mts +3 -2
- package/dist/components/index.mjs +3 -2
- package/dist/components/options-parser-logic.cjs +156 -31
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +47 -8
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +53 -14
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +154 -31
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.cjs +38 -5
- package/dist/components/usage.cjs.map +1 -1
- package/dist/components/usage.d.cts +2 -4
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.d.mts +2 -4
- package/dist/components/usage.d.mts.map +1 -1
- package/dist/components/usage.mjs +40 -7
- package/dist/components/usage.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +31 -3
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs +31 -3
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/resolve-command.cjs +68 -47
- package/dist/helpers/resolve-command.cjs.map +1 -1
- package/dist/helpers/resolve-command.mjs +70 -49
- package/dist/helpers/resolve-command.mjs.map +1 -1
- package/dist/helpers/validations.cjs +13 -36
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs +12 -36
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/plugin-utils/context-helpers.cjs +3 -45
- package/dist/plugin-utils/context-helpers.cjs.map +1 -1
- package/dist/plugin-utils/context-helpers.d.cts +1 -37
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/context-helpers.d.mts +1 -37
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +4 -44
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +0 -2
- package/dist/plugin-utils/index.d.cts +2 -2
- package/dist/plugin-utils/index.d.mts +2 -2
- package/dist/plugin-utils/index.mjs +2 -2
- package/dist/plugin.cjs +9 -15
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +9 -15
- package/dist/plugin.mjs.map +1 -1
- package/dist/types/command.d.cts +206 -33
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +206 -33
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/index.d.cts +3 -2
- package/dist/types/index.d.mts +3 -2
- package/dist/types/runtime.d.cts +5 -15
- package/dist/types/runtime.d.cts.map +1 -1
- package/dist/types/runtime.d.mts +5 -15
- package/dist/types/runtime.d.mts.map +1 -1
- package/package.json +25 -11
|
@@ -46,50 +46,18 @@ declare function getAppBin(context: Context): string;
|
|
|
46
46
|
* ```typescript
|
|
47
47
|
* isDynamicPathSegment("[user]"); // true
|
|
48
48
|
* isDynamicPathSegment("user"); // false
|
|
49
|
-
* isDynamicPathSegment("[[...user]]"); // true
|
|
50
|
-
* isDynamicPathSegment("[...user]"); // true
|
|
51
49
|
* ```
|
|
52
50
|
*
|
|
53
51
|
* @param path - The command path segment to check.
|
|
54
52
|
* @returns True if the path is variable, false otherwise.
|
|
55
53
|
*/
|
|
56
54
|
declare function isDynamicPathSegment(path: string): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* isOptionalCatchAllPathSegment("[[...user]]"); // true
|
|
63
|
-
* isOptionalCatchAllPathSegment("[...user]"); // false
|
|
64
|
-
* isOptionalCatchAllPathSegment("[user]"); // false
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @param path - The command path segment to check.
|
|
68
|
-
* @returns True if the path is an optional catch-all segment, false otherwise.
|
|
69
|
-
*/
|
|
70
|
-
declare function isOptionalCatchAllPathSegment(path: string): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* isCatchAllPathSegment("[[...user]]"); // true
|
|
77
|
-
* isCatchAllPathSegment("[...user]"); // true
|
|
78
|
-
* isCatchAllPathSegment("[user]"); // false
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* @param path - The command path segment to check.
|
|
82
|
-
* @returns True if the path is a catch-all segment, false otherwise.
|
|
83
|
-
*/
|
|
84
|
-
declare function isCatchAllPathSegment(path: string): boolean;
|
|
85
55
|
/**
|
|
86
56
|
* Extracts the variable name from a command path segment by removing enclosing square brackets.
|
|
87
57
|
*
|
|
88
58
|
* @example
|
|
89
59
|
* ```typescript
|
|
90
60
|
* getDynamicPathSegmentName("[user]"); // "user"
|
|
91
|
-
* getDynamicPathSegmentName("[[...user]]"); // "user"
|
|
92
|
-
* getDynamicPathSegmentName("[...user]"); // "user"
|
|
93
61
|
* ```
|
|
94
62
|
*
|
|
95
63
|
* @param path - The command path segment.
|
|
@@ -102,8 +70,6 @@ declare function getDynamicPathSegmentName(path: string): string;
|
|
|
102
70
|
* @example
|
|
103
71
|
* ```typescript
|
|
104
72
|
* isPathSegmentGroup("(user)"); // true
|
|
105
|
-
* isPathSegmentGroup("[[...user]]"); // false
|
|
106
|
-
* isPathSegmentGroup("[...user]"); // false
|
|
107
73
|
* isPathSegmentGroup("[user]"); // false
|
|
108
74
|
* isPathSegmentGroup("user"); // false
|
|
109
75
|
* ```
|
|
@@ -131,8 +97,6 @@ declare function getPathSegmentGroupName(path: string): string;
|
|
|
131
97
|
* @example
|
|
132
98
|
* ```typescript
|
|
133
99
|
* getDynamicPathSegmentName("[user]"); // "user"
|
|
134
|
-
* getDynamicPathSegmentName("[[...user]]"); // "user"
|
|
135
|
-
* getDynamicPathSegmentName("[...user]"); // "user"
|
|
136
100
|
* ```
|
|
137
101
|
*
|
|
138
102
|
* @param path - The command path segment.
|
|
@@ -140,5 +104,5 @@ declare function getPathSegmentGroupName(path: string): string;
|
|
|
140
104
|
*/
|
|
141
105
|
declare function getPathSegmentName(path: string): string;
|
|
142
106
|
//#endregion
|
|
143
|
-
export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
107
|
+
export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases };
|
|
144
108
|
//# sourceMappingURL=context-helpers.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;
|
|
1
|
+
{"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBA3IgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAazC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
|
|
@@ -46,50 +46,18 @@ declare function getAppBin(context: Context): string;
|
|
|
46
46
|
* ```typescript
|
|
47
47
|
* isDynamicPathSegment("[user]"); // true
|
|
48
48
|
* isDynamicPathSegment("user"); // false
|
|
49
|
-
* isDynamicPathSegment("[[...user]]"); // true
|
|
50
|
-
* isDynamicPathSegment("[...user]"); // true
|
|
51
49
|
* ```
|
|
52
50
|
*
|
|
53
51
|
* @param path - The command path segment to check.
|
|
54
52
|
* @returns True if the path is variable, false otherwise.
|
|
55
53
|
*/
|
|
56
54
|
declare function isDynamicPathSegment(path: string): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* isOptionalCatchAllPathSegment("[[...user]]"); // true
|
|
63
|
-
* isOptionalCatchAllPathSegment("[...user]"); // false
|
|
64
|
-
* isOptionalCatchAllPathSegment("[user]"); // false
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @param path - The command path segment to check.
|
|
68
|
-
* @returns True if the path is an optional catch-all segment, false otherwise.
|
|
69
|
-
*/
|
|
70
|
-
declare function isOptionalCatchAllPathSegment(path: string): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* isCatchAllPathSegment("[[...user]]"); // true
|
|
77
|
-
* isCatchAllPathSegment("[...user]"); // true
|
|
78
|
-
* isCatchAllPathSegment("[user]"); // false
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* @param path - The command path segment to check.
|
|
82
|
-
* @returns True if the path is a catch-all segment, false otherwise.
|
|
83
|
-
*/
|
|
84
|
-
declare function isCatchAllPathSegment(path: string): boolean;
|
|
85
55
|
/**
|
|
86
56
|
* Extracts the variable name from a command path segment by removing enclosing square brackets.
|
|
87
57
|
*
|
|
88
58
|
* @example
|
|
89
59
|
* ```typescript
|
|
90
60
|
* getDynamicPathSegmentName("[user]"); // "user"
|
|
91
|
-
* getDynamicPathSegmentName("[[...user]]"); // "user"
|
|
92
|
-
* getDynamicPathSegmentName("[...user]"); // "user"
|
|
93
61
|
* ```
|
|
94
62
|
*
|
|
95
63
|
* @param path - The command path segment.
|
|
@@ -102,8 +70,6 @@ declare function getDynamicPathSegmentName(path: string): string;
|
|
|
102
70
|
* @example
|
|
103
71
|
* ```typescript
|
|
104
72
|
* isPathSegmentGroup("(user)"); // true
|
|
105
|
-
* isPathSegmentGroup("[[...user]]"); // false
|
|
106
|
-
* isPathSegmentGroup("[...user]"); // false
|
|
107
73
|
* isPathSegmentGroup("[user]"); // false
|
|
108
74
|
* isPathSegmentGroup("user"); // false
|
|
109
75
|
* ```
|
|
@@ -131,8 +97,6 @@ declare function getPathSegmentGroupName(path: string): string;
|
|
|
131
97
|
* @example
|
|
132
98
|
* ```typescript
|
|
133
99
|
* getDynamicPathSegmentName("[user]"); // "user"
|
|
134
|
-
* getDynamicPathSegmentName("[[...user]]"); // "user"
|
|
135
|
-
* getDynamicPathSegmentName("[...user]"); // "user"
|
|
136
100
|
* ```
|
|
137
101
|
*
|
|
138
102
|
* @param path - The command path segment.
|
|
@@ -140,5 +104,5 @@ declare function getPathSegmentGroupName(path: string): string;
|
|
|
140
104
|
*/
|
|
141
105
|
declare function getPathSegmentName(path: string): string;
|
|
142
106
|
//#endregion
|
|
143
|
-
export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
107
|
+
export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases };
|
|
144
108
|
//# sourceMappingURL=context-helpers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;
|
|
1
|
+
{"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA0BA;AAagB,iBAzDA,cAAA,CA0DL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBA3IgB,UAAA,UAAoB,oBAAoB;;;;;;;iBA0BxC,WAAA,UAAqB,oBAAoB;;;;;;;iBAazC,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
|
|
@@ -62,8 +62,6 @@ function getAppBin(context) {
|
|
|
62
62
|
* ```typescript
|
|
63
63
|
* isDynamicPathSegment("[user]"); // true
|
|
64
64
|
* isDynamicPathSegment("user"); // false
|
|
65
|
-
* isDynamicPathSegment("[[...user]]"); // true
|
|
66
|
-
* isDynamicPathSegment("[...user]"); // true
|
|
67
65
|
* ```
|
|
68
66
|
*
|
|
69
67
|
* @param path - The command path segment to check.
|
|
@@ -73,52 +71,18 @@ function isDynamicPathSegment(path) {
|
|
|
73
71
|
return path.startsWith("[") && path.endsWith("]");
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
|
-
* Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* isOptionalCatchAllPathSegment("[[...user]]"); // true
|
|
81
|
-
* isOptionalCatchAllPathSegment("[...user]"); // false
|
|
82
|
-
* isOptionalCatchAllPathSegment("[user]"); // false
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* @param path - The command path segment to check.
|
|
86
|
-
* @returns True if the path is an optional catch-all segment, false otherwise.
|
|
87
|
-
*/
|
|
88
|
-
function isOptionalCatchAllPathSegment(path) {
|
|
89
|
-
return path.startsWith("[[...") && path.endsWith("]]");
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* isCatchAllPathSegment("[[...user]]"); // true
|
|
97
|
-
* isCatchAllPathSegment("[...user]"); // true
|
|
98
|
-
* isCatchAllPathSegment("[user]"); // false
|
|
99
|
-
* ```
|
|
100
|
-
*
|
|
101
|
-
* @param path - The command path segment to check.
|
|
102
|
-
* @returns True if the path is a catch-all segment, false otherwise.
|
|
103
|
-
*/
|
|
104
|
-
function isCatchAllPathSegment(path) {
|
|
105
|
-
return path.startsWith("[...") && path.endsWith("]") || isOptionalCatchAllPathSegment(path);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
74
|
* Extracts the variable name from a command path segment by removing enclosing square brackets.
|
|
109
75
|
*
|
|
110
76
|
* @example
|
|
111
77
|
* ```typescript
|
|
112
78
|
* getDynamicPathSegmentName("[user]"); // "user"
|
|
113
|
-
* getDynamicPathSegmentName("[[...user]]"); // "user"
|
|
114
|
-
* getDynamicPathSegmentName("[...user]"); // "user"
|
|
115
79
|
* ```
|
|
116
80
|
*
|
|
117
81
|
* @param path - The command path segment.
|
|
118
82
|
* @returns The variable name without square brackets.
|
|
119
83
|
*/
|
|
120
84
|
function getDynamicPathSegmentName(path) {
|
|
121
|
-
return path.replaceAll(/^\[
|
|
85
|
+
return path.replaceAll(/^\[+/g, "").replaceAll(/\]+$/g, "");
|
|
122
86
|
}
|
|
123
87
|
/**
|
|
124
88
|
* Determines if a given command path segment is a path segment group (enclosed in parentheses).
|
|
@@ -126,8 +90,6 @@ function getDynamicPathSegmentName(path) {
|
|
|
126
90
|
* @example
|
|
127
91
|
* ```typescript
|
|
128
92
|
* isPathSegmentGroup("(user)"); // true
|
|
129
|
-
* isPathSegmentGroup("[[...user]]"); // false
|
|
130
|
-
* isPathSegmentGroup("[...user]"); // false
|
|
131
93
|
* isPathSegmentGroup("[user]"); // false
|
|
132
94
|
* isPathSegmentGroup("user"); // false
|
|
133
95
|
* ```
|
|
@@ -136,7 +98,7 @@ function getDynamicPathSegmentName(path) {
|
|
|
136
98
|
* @returns True if the path is a path segment group, false otherwise.
|
|
137
99
|
*/
|
|
138
100
|
function isPathSegmentGroup(path) {
|
|
139
|
-
return path.startsWith("(") && path.endsWith(")");
|
|
101
|
+
return path.startsWith("(") && path.endsWith(")") || path.startsWith("_");
|
|
140
102
|
}
|
|
141
103
|
/**
|
|
142
104
|
* Extracts the group name from a command path segment by removing enclosing parentheses.
|
|
@@ -151,7 +113,7 @@ function isPathSegmentGroup(path) {
|
|
|
151
113
|
* @returns The group name without parentheses.
|
|
152
114
|
*/
|
|
153
115
|
function getPathSegmentGroupName(path) {
|
|
154
|
-
return path.replaceAll(/^\(+/g, "").replaceAll(/\)+$/g, "");
|
|
116
|
+
return path.replaceAll(/^\(+/g, "").replaceAll(/\)+$/g, "").replaceAll(/^_+/g, "");
|
|
155
117
|
}
|
|
156
118
|
/**
|
|
157
119
|
* Extracts the variable name from a command path segment by removing enclosing square brackets.
|
|
@@ -159,8 +121,6 @@ function getPathSegmentGroupName(path) {
|
|
|
159
121
|
* @example
|
|
160
122
|
* ```typescript
|
|
161
123
|
* getDynamicPathSegmentName("[user]"); // "user"
|
|
162
|
-
* getDynamicPathSegmentName("[[...user]]"); // "user"
|
|
163
|
-
* getDynamicPathSegmentName("[...user]"); // "user"
|
|
164
124
|
* ```
|
|
165
125
|
*
|
|
166
126
|
* @param path - The command path segment.
|
|
@@ -171,5 +131,5 @@ function getPathSegmentName(path) {
|
|
|
171
131
|
}
|
|
172
132
|
|
|
173
133
|
//#endregion
|
|
174
|
-
export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
134
|
+
export { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases };
|
|
175
135
|
//# sourceMappingURL=context-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","title","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","isOptionalCatchAllPathSegment","isCatchAllPathSegment","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return (\n context.config.title ||\n titleCase(context.config.name || getAppName(context))\n );\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * isDynamicPathSegment(\"[[...user]]\"); // true\n * isDynamicPathSegment(\"[...user]\"); // true\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).\n *\n * @example\n * ```typescript\n * isOptionalCatchAllPathSegment(\"[[...user]]\"); // true\n * isOptionalCatchAllPathSegment(\"[...user]\"); // false\n * isOptionalCatchAllPathSegment(\"[user]\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is an optional catch-all segment, false otherwise.\n */\nexport function isOptionalCatchAllPathSegment(path: string): boolean {\n return path.startsWith(\"[[...\") && path.endsWith(\"]]\");\n}\n\n/**\n * Determines if a given command path segment is an optional catch-all segment (enclosed in square brackets with a leading ellipsis).\n *\n * @example\n * ```typescript\n * isCatchAllPathSegment(\"[[...user]]\"); // true\n * isCatchAllPathSegment(\"[...user]\"); // true\n * isCatchAllPathSegment(\"[user]\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a catch-all segment, false otherwise.\n */\nexport function isCatchAllPathSegment(path: string): boolean {\n return (\n (path.startsWith(\"[...\") && path.endsWith(\"]\")) ||\n isOptionalCatchAllPathSegment(path)\n );\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * getDynamicPathSegmentName(\"[[...user]]\"); // \"user\"\n * getDynamicPathSegmentName(\"[...user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+(?:\\.\\.\\.)*/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[[...user]]\"); // false\n * isPathSegmentGroup(\"[...user]\"); // false\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return path.startsWith(\"(\") && path.endsWith(\")\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path.replaceAll(/^\\(+/g, \"\").replaceAll(/\\)+$/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * getDynamicPathSegmentName(\"[[...user]]\"); // \"user\"\n * getDynamicPathSegmentName(\"[...user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QACEA,QAAQC,OAAOQ,SACfxB,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAUzD,SAAgBU,kBACdV,SACQ;AACR,QACEA,QAAQC,OAAOU,eACfX,QAAQM,aAAaK,eACrB,OAAOH,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBY,UAAUZ,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCU,OAAOC,KAAKd,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;;;AAiBpC,SAAgBe,qBAAqBC,MAAuB;AAC1D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;;;AAgBnD,SAAgBC,8BAA8BH,MAAuB;AACnE,QAAOA,KAAKC,WAAW,QAAQ,IAAID,KAAKE,SAAS,KAAK;;;;;;;;;;;;;;;AAgBxD,SAAgBE,sBAAsBJ,MAAuB;AAC3D,QACGA,KAAKC,WAAW,OAAO,IAAID,KAAKE,SAAS,IAAI,IAC9CC,8BAA8BH,KAAK;;;;;;;;;;;;;;;AAiBvC,SAAgBK,0BAA0BL,MAAsB;AAC9D,QAAOA,KAAKM,WAAW,oBAAoB,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;;;AAkBxE,SAAgBC,mBAAmBP,MAAuB;AACxD,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;;AAenD,SAAgBM,wBAAwBR,MAAsB;AAC5D,QAAOA,KAAKM,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBG,mBAAmBT,MAAsB;AACvD,QAAOQ,wBAAwBH,0BAA0BL,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","title","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(context: UnresolvedContext | Context): string {\n return (\n context.config.title ||\n titleCase(context.config.name || getAppName(context))\n );\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;AAS1B,SAAgBiB,YAAYR,SAA8C;AACxE,QACEA,QAAQC,OAAOQ,SACfxB,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;;;;;;;;AAUzD,SAAgBU,kBACdV,SACQ;AACR,QACEA,QAAQC,OAAOU,eACfX,QAAQM,aAAaK,eACrB,OAAOH,YAAYR,QAAQ,CAAA;;;;;;;;AAU/B,SAAgBY,UAAUZ,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCU,OAAOC,KAAKd,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;AAepC,SAAgBe,qBAAqBC,MAAuB;AAC1D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;AAcnD,SAAgBC,0BAA0BH,MAAsB;AAC9D,QAAOA,KAAKI,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBC,mBAAmBL,MAAuB;AACxD,QAAQA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI,IAAKF,KAAKC,WAAW,IAAI;;;;;;;;;;;;;;AAe7E,SAAgBK,wBAAwBN,MAAsB;AAC5D,QAAOA,KACJI,WAAW,SAAS,GAAG,CACvBA,WAAW,SAAS,GAAG,CACvBA,WAAW,QAAQ,GAAG;;;;;;;;;;;;;AAc3B,SAAgBG,mBAAmBP,MAAsB;AACvD,QAAOM,wBAAwBH,0BAA0BH,KAAK,CAAC"}
|
|
@@ -11,9 +11,7 @@ exports.getCommandTree = require_plugin_utils_get_command_tree.getCommandTree;
|
|
|
11
11
|
exports.getDynamicPathSegmentName = require_plugin_utils_context_helpers.getDynamicPathSegmentName;
|
|
12
12
|
exports.getPathSegmentGroupName = require_plugin_utils_context_helpers.getPathSegmentGroupName;
|
|
13
13
|
exports.getPathSegmentName = require_plugin_utils_context_helpers.getPathSegmentName;
|
|
14
|
-
exports.isCatchAllPathSegment = require_plugin_utils_context_helpers.isCatchAllPathSegment;
|
|
15
14
|
exports.isDynamicPathSegment = require_plugin_utils_context_helpers.isDynamicPathSegment;
|
|
16
|
-
exports.isOptionalCatchAllPathSegment = require_plugin_utils_context_helpers.isOptionalCatchAllPathSegment;
|
|
17
15
|
exports.isPathSegmentGroup = require_plugin_utils_context_helpers.isPathSegmentGroup;
|
|
18
16
|
exports.sortArgAliases = require_plugin_utils_context_helpers.sortArgAliases;
|
|
19
17
|
exports.sortOptions = require_plugin_utils_reflect.sortOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
1
|
+
import { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases } from "./context-helpers.cjs";
|
|
2
2
|
import { getCommandTree } from "./get-command-tree.cjs";
|
|
3
3
|
import { sortOptions } from "./reflect.cjs";
|
|
4
4
|
import { traverseCommandTree, traverseCommands } from "./traverse-command-tree.cjs";
|
|
5
|
-
export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
5
|
+
export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
1
|
+
import { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases } from "./context-helpers.mjs";
|
|
2
2
|
import { getCommandTree } from "./get-command-tree.mjs";
|
|
3
3
|
import { sortOptions } from "./reflect.mjs";
|
|
4
4
|
import { traverseCommandTree, traverseCommands } from "./traverse-command-tree.mjs";
|
|
5
|
-
export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
5
|
+
export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
1
|
+
import { getAppBin, getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases } from "./context-helpers.mjs";
|
|
2
2
|
import { sortOptions } from "./reflect.mjs";
|
|
3
3
|
import { getCommandTree } from "./get-command-tree.mjs";
|
|
4
4
|
import { traverseCommandTree, traverseCommands } from "./traverse-command-tree.mjs";
|
|
5
5
|
|
|
6
|
-
export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName,
|
|
6
|
+
export { getAppBin, getAppDescription, getAppName, getAppTitle, getCommandTree, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
|
package/dist/plugin.cjs
CHANGED
|
@@ -86,13 +86,11 @@ const plugin = (options = {}) => {
|
|
|
86
86
|
this.options = Object.values(require_utilities.getDefaultOptions(this, {
|
|
87
87
|
id: null,
|
|
88
88
|
name: this.config.name,
|
|
89
|
+
path: null,
|
|
90
|
+
segments: [],
|
|
89
91
|
title: this.config.title,
|
|
90
92
|
description: this.config.description,
|
|
91
93
|
alias: [],
|
|
92
|
-
path: {
|
|
93
|
-
value: null,
|
|
94
|
-
segments: []
|
|
95
|
-
},
|
|
96
94
|
isVirtual: false
|
|
97
95
|
}));
|
|
98
96
|
}
|
|
@@ -114,10 +112,8 @@ const plugin = (options = {}) => {
|
|
|
114
112
|
const name = require_resolve_command.resolveCommandName(entry.file);
|
|
115
113
|
ret.push({
|
|
116
114
|
id,
|
|
117
|
-
path
|
|
118
|
-
|
|
119
|
-
segments: path.split("/").filter(Boolean)
|
|
120
|
-
},
|
|
115
|
+
path,
|
|
116
|
+
segments: path.split("/").filter(Boolean),
|
|
121
117
|
name,
|
|
122
118
|
alias: [],
|
|
123
119
|
isVirtual: false,
|
|
@@ -159,10 +155,8 @@ const plugin = (options = {}) => {
|
|
|
159
155
|
const path = require_resolve_command.resolveCommandPath(this, file);
|
|
160
156
|
ret.push({
|
|
161
157
|
id,
|
|
162
|
-
path
|
|
163
|
-
|
|
164
|
-
segments: path.split("/").filter(Boolean)
|
|
165
|
-
},
|
|
158
|
+
path,
|
|
159
|
+
segments: path.split("/").filter(Boolean),
|
|
166
160
|
name,
|
|
167
161
|
alias: [],
|
|
168
162
|
isVirtual: true,
|
|
@@ -173,7 +167,7 @@ const plugin = (options = {}) => {
|
|
|
173
167
|
parentPath = (0, __stryke_path_resolve_parent_path.resolveParentPath)(parentPath);
|
|
174
168
|
}
|
|
175
169
|
return ret;
|
|
176
|
-
}, this.inputs).sort((a, b) => a.
|
|
170
|
+
}, this.inputs).sort((a, b) => a.segments.length - b.segments.length);
|
|
177
171
|
this.debug(`Final command input list: \n${this.inputs.map((command) => ` - ${command.id}: ${(0, __stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
|
|
178
172
|
}
|
|
179
173
|
}
|
|
@@ -190,7 +184,7 @@ const plugin = (options = {}) => {
|
|
|
190
184
|
this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
|
|
191
185
|
await require_persistence.readCommandsPersistence(this);
|
|
192
186
|
} else {
|
|
193
|
-
for (const input of this.inputs.filter((input$1) => input$1.
|
|
187
|
+
for (const input of this.inputs.filter((input$1) => input$1.segments.filter((segment) => !require_plugin_utils_context_helpers.isDynamicPathSegment(segment) && !require_plugin_utils_context_helpers.isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await require_resolve_command.reflectCommandTree(this, input);
|
|
194
188
|
this.debug("Post-processing commands to ensure proper reflection.");
|
|
195
189
|
this.options = this.options.map((option) => ({
|
|
196
190
|
...option,
|
|
@@ -256,7 +250,7 @@ const plugin = (options = {}) => {
|
|
|
256
250
|
},
|
|
257
251
|
async docs() {
|
|
258
252
|
this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
|
|
259
|
-
const commands$1 = this.inputs.map((input) => require_plugin_utils_get_command_tree.getCommandTree(this, input.
|
|
253
|
+
const commands$1 = this.inputs.map((input) => require_plugin_utils_get_command_tree.getCommandTree(this, input.segments)).filter(Boolean);
|
|
260
254
|
return (0, __powerlines_plugin_alloy_render.render)(this, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core_components.For, {
|
|
261
255
|
get each() {
|
|
262
256
|
return Object.values(commands$1);
|
package/dist/plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","alias","path","value","segments","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","input","map","command","join","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","segment","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n title: this.config.title,\n description: this.config.description,\n alias: [],\n path: {\n value: null,\n segments: []\n },\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const path = resolveCommandPath(this, entry.file);\n const name = resolveCommandName(entry.file);\n\n ret.push({\n id,\n path: {\n value: path,\n segments: path.split(\"/\").filter(Boolean)\n },\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Maximum command virtual parent depth of ${\n MAX_DEPTH\n } exceeded while processing command: ${command.name}`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n const path = resolveCommandPath(this, file);\n\n ret.push({\n id,\n path: {\n value: path,\n segments: path.split(\"/\").filter(Boolean)\n },\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.path.segments.length - b.path.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.path.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.path.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\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QAAI,qDAAa,KAAK3F,OAAOgC,IAAI,CAC/B,MAAK0B,KACH,kCACE,KAAK1D,OAAOD,KAAI,sHAEnB;QAED,OAAM6F,QAAQC,IACZ1D,OAAOC,OAAO,KAAKpC,OAAOgC,IAAI,CAACuB,IAAI,OAAMvB,QAAO;KAC9C,MAAMO,4CACJP,6CAEE,KAAK8D,gBAAgBC,eACrB,KAAK/F,OAAOK,YAEhB,CAAC;AAED,SAAI,KAAKiE,GAAGC,WAAWhC,KAAK,EAAE;AAC5B,WAAKtC,MACH,6EAA6EsC,OAC9E;AAED,4CAAaA,KAAK;WAElB,MAAKmB,KACH,uDAAuDnB,KAAI,4GAC5D;MAGP,CAAC;;GAGN;EACD;GACExC,MAAM;GACN8B,iBAAiB;AACf,SAAK7B,OAAO7C,WAAW,EAAE;AACzB,SAAK6C,OAAO7C,OAAO6I,aAAa;KAC9B,GAAI,KAAKhG,OAAO7C,OAAO6I,cAAc,EAAE;KACvCzH,UAAUA,wBAAS,KAAI;KACxB;;GAEH,MAAM0H,OAAO;AACX,SAAKhG,MACH,oEACD;IAED,MAAM1B,aAAW,KAAK2D,OACnBqB,KAAID,UAAS5D,qDAAe,MAAM4D,MAAMf,KAAKE,SAAS,CAAC,CACvDW,OAAOC,QAAyB;AAEnC,wDACE,uDACCrG,gCAAG;KAAA,IAACmJ,OAAI;AAAA,aAAEhE,OAAOC,OAAO7D,WAAS;;KAAE6H,gBAAc;KAAAC,WAC/CC,2DACErJ,iCAAI;MAAA,IAACsJ,OAAI;AAAA,cAAE,CAACD,MAAM5D;;MAAS,IAAA2D,WAAA;AAAA,+DACzB/H,yCAAe,EAACkF,SAAS8C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAezG"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","path","segments","alias","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","input","map","command","join","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","segment","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const path = resolveCommandPath(this, entry.file);\n const name = resolveCommandName(entry.file);\n\n ret.push({\n id,\n path,\n segments: path.split(\"/\").filter(Boolean),\n name,\n alias: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Maximum command virtual parent depth of ${\n MAX_DEPTH\n } exceeded while processing command: ${command.name}`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n const path = resolveCommandPath(this, file);\n\n ret.push({\n id,\n path,\n segments: path.split(\"/\").filter(Boolean),\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAM4C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;2CACG;4CACC;2CACD;EACR;GACEC,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMhB,oDAAwB,KAAK;IAEnC,MAAMiB,wBACJ,EACEC,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMT,gDAAW,KAAK;KACtBgB,OAAOf,iDAAY,KAAK;KACxBgB,aAAalB,uDAAkB,KAAK;KACpCmB,kEAAwBlB,gDAAW,KAAK,CAAC;KACzCmB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,iBAAiB;KACjBR,QAAQ;MACNS,QAAQ;MACRC,KAAK;MACN;KACDC,OACE,CAAC,KAAKd,OAAOc,SACZC,MAAMC,QAAQ,KAAKhB,OAAOc,MAAM,IAC/B,KAAKd,OAAOc,MAAMG,WAAW,IAC3B,yCACY,KAAKjB,OAAOkB,YAAY,UAAU,0CAClC,KAAKlB,OAAOkB,YAAY,WAAW,CAC9C,GACDC;KACNC,OAAO;MACLP,KAAK;MACLQ,UAAU;MACVC,cAAc;MACdC,UAAU;MACVC,YAAY,CAAC,sBAAqB;MACnC;KACDC,MAAM;KACNC,WAAW;KAEf,CAAC;AACD,QAAI,CAACxB,OAAOO,IAAIC,OAAOiB,SAASzB,OAAOM,U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AAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAexG"}
|
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AA+EA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AA+EA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA6ajC,MA7aiC,CA6a1B,QA7a0B,CAAA,EAAA"}
|
package/dist/plugin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AA+EA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AA+EA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA6ajC,MA7aiC,CA6a1B,QA7a0B,CAAA,EAAA"}
|