@awesomeness-js/server 1.1.6 → 1.1.8
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/index.js +101 -101
- package/package.json +1 -1
- package/src/componentDependencies.js +51 -47
- package/src/koa/routeRequest.js +87 -26
- package/example-site/example.awesomenessjs.com/components/example/index.js +0 -3
- package/example-site/example.awesomenessjs.com/components/notCommonExample/_.css +0 -1
- package/example-site/example.awesomenessjs.com/components/notCommonExample/index.js +0 -3
- package/ui/README.md +0 -438
- package/ui/awesomeness-ui.instructions.md +0 -156
- package/ui/build.js +0 -119
- package/ui/commonComponent.test.js +0 -27
- package/ui/components/blogPost/all.css +0 -371
- package/ui/components/blogPost/headerImage.js +0 -153
- package/ui/components/blogPost/index.js +0 -45
- package/ui/components/blogPost/marked.js +0 -74
- package/ui/components/blogPost/md.js +0 -73
- package/ui/components/blogPost/parseAwesomeness.jQuery.js +0 -47
- package/ui/components/blogPost/readme.md +0 -8
- package/ui/components/colors/README.md +0 -65
- package/ui/components/colors/dynamic.css +0 -1884
- package/ui/components/colors/dynamic.css.js +0 -135
- package/ui/components/colors/dynamic.css.php +0 -79
- package/ui/components/colors/example.js +0 -133
- package/ui/components/colors/index.js +0 -65
- package/ui/components/colors/map.js +0 -13
- package/ui/components/colors/random.js +0 -17
- package/ui/components/colors/tailwind-colors.css +0 -247
- package/ui/components/insertIntoList/insertIntoList.jquery.js +0 -150
- package/ui/components/statusPage/index.css +0 -120
- package/ui/components/statusPage/index.js +0 -39
- package/ui/components/tag/category.js +0 -8
- package/ui/components/tag/index.js +0 -33
- package/ui/components/tag/list.js +0 -42
- package/ui/components/tag/map.js +0 -64
- package/ui/components/tag/tagMap.css +0 -60
- package/ui/components/tag/tags.css +0 -20
- package/ui/core/css/_normalize.css +0 -57
- package/ui/core/css/dynamic/flex.js +0 -36
- package/ui/core/css/dynamic/grid.js +0 -185
- package/ui/core/css/dynamic/shortcuts.js +0 -48
- package/ui/core/css/dynamic/spacing.js +0 -61
- package/ui/core/css/dynamic/text.js +0 -80
- package/ui/core/css/dynamic/width.js +0 -75
- package/ui/core/css/dynamic.js +0 -40
- package/ui/core/js/app/api.js +0 -143
- package/ui/core/js/app/init.js +0 -88
- package/ui/core/js/app/initDarkMode.js +0 -26
- package/ui/core/js/app/initialScroll.js +0 -28
- package/ui/core/js/app/meta/update/components.js +0 -65
- package/ui/core/js/app/meta/update/pages.js +0 -86
- package/ui/core/js/app/metaUpdates.js +0 -10
- package/ui/core/js/app/page.js +0 -319
- package/ui/core/js/app/resize.js +0 -52
- package/ui/core/js/app/state/back.js +0 -16
- package/ui/core/js/app/state/create.js +0 -50
- package/ui/core/js/app/state/get.js +0 -5
- package/ui/core/js/app/state/init.js +0 -25
- package/ui/core/js/app.js +0 -41
- package/ui/core/js/jquery-3.7.1.min.js +0 -2
- package/ui/core/public/app.css +0 -1
- package/ui/core/public/app.js +0 -975
- package/ui/core/public/favicon.ico +0 -0
- package/ui/core/public/index.html +0 -40
package/index.js
CHANGED
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto-generated by the build script.
|
|
3
|
-
* It consolidates API functions for use in the application.
|
|
4
|
-
* Do not edit manually.
|
|
5
|
-
*/
|
|
6
|
-
import _applicationMap from './src/applicationMap.js';
|
|
7
|
-
import _awesomenessNormalizeRequest from './src/awesomenessNormalizeRequest.js';
|
|
8
|
-
import _brotliJsonResponse from './src/brotliJsonResponse.js';
|
|
9
|
-
import _checkAccess from './src/checkAccess.js';
|
|
10
|
-
import _componentDependencies from './src/componentDependencies.js';
|
|
11
|
-
import _config from './src/config.js';
|
|
12
|
-
import _fetchPage from './src/fetchPage.js';
|
|
13
|
-
import _getConfig from './src/getConfig.js';
|
|
14
|
-
import _getMD from './src/getMD.js';
|
|
15
|
-
import _init from './src/init.js';
|
|
16
|
-
import _koa_attachAwesomenessRequest from './src/koa/attachAwesomenessRequest.js';
|
|
17
|
-
import _koa_cors from './src/koa/cors.js';
|
|
18
|
-
import _koa_errorHandler from './src/koa/errorHandler.js';
|
|
19
|
-
import _koa_finalFormat from './src/koa/finalFormat.js';
|
|
20
|
-
import _koa_jsonBodyParser from './src/koa/jsonBodyParser.js';
|
|
21
|
-
import _koa_routeRequest from './src/koa/routeRequest.js';
|
|
22
|
-
import _koa_serverUp from './src/koa/serverUp.js';
|
|
23
|
-
import _koa_staticFiles from './src/koa/staticFiles.js';
|
|
24
|
-
import _koa_timeout from './src/koa/timeout.js';
|
|
25
|
-
import _pageInfo from './src/pageInfo.js';
|
|
26
|
-
import _reRoute from './src/reRoute.js';
|
|
27
|
-
import _resolveRealCasePath from './src/resolveRealCasePath.js';
|
|
28
|
-
import _specialPaths from './src/specialPaths.js';
|
|
29
|
-
import _start from './src/start.js';
|
|
30
|
-
import _validateRequest from './src/validateRequest.js';
|
|
31
|
-
import _ws_handlers from './src/ws/handlers.js';
|
|
32
|
-
import _ws_index from './src/ws/index.js';
|
|
33
|
-
|
|
34
|
-
export { _applicationMap as applicationMap };
|
|
35
|
-
export { _awesomenessNormalizeRequest as awesomenessNormalizeRequest };
|
|
36
|
-
export { _brotliJsonResponse as brotliJsonResponse };
|
|
37
|
-
export { _checkAccess as checkAccess };
|
|
38
|
-
export { _componentDependencies as componentDependencies };
|
|
39
|
-
export { _config as config };
|
|
40
|
-
export { _fetchPage as fetchPage };
|
|
41
|
-
export { _getConfig as getConfig };
|
|
42
|
-
export { _getMD as getMD };
|
|
43
|
-
export { _init as init };
|
|
44
|
-
export { _pageInfo as pageInfo };
|
|
45
|
-
export { _reRoute as reRoute };
|
|
46
|
-
export { _resolveRealCasePath as resolveRealCasePath };
|
|
47
|
-
export { _specialPaths as specialPaths };
|
|
48
|
-
export { _start as start };
|
|
49
|
-
export { _validateRequest as validateRequest };
|
|
50
|
-
|
|
51
|
-
export const koa = {
|
|
52
|
-
attachAwesomenessRequest: _koa_attachAwesomenessRequest,
|
|
53
|
-
cors: _koa_cors,
|
|
54
|
-
errorHandler: _koa_errorHandler,
|
|
55
|
-
finalFormat: _koa_finalFormat,
|
|
56
|
-
jsonBodyParser: _koa_jsonBodyParser,
|
|
57
|
-
routeRequest: _koa_routeRequest,
|
|
58
|
-
serverUp: _koa_serverUp,
|
|
59
|
-
staticFiles: _koa_staticFiles,
|
|
60
|
-
timeout: _koa_timeout
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const ws = {
|
|
64
|
-
handlers: _ws_handlers,
|
|
65
|
-
index: _ws_index
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export default {
|
|
70
|
-
applicationMap: _applicationMap,
|
|
71
|
-
awesomenessNormalizeRequest: _awesomenessNormalizeRequest,
|
|
72
|
-
brotliJsonResponse: _brotliJsonResponse,
|
|
73
|
-
checkAccess: _checkAccess,
|
|
74
|
-
componentDependencies: _componentDependencies,
|
|
75
|
-
config: _config,
|
|
76
|
-
fetchPage: _fetchPage,
|
|
77
|
-
getConfig: _getConfig,
|
|
78
|
-
getMD: _getMD,
|
|
79
|
-
init: _init,
|
|
80
|
-
pageInfo: _pageInfo,
|
|
81
|
-
reRoute: _reRoute,
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto-generated by the build script.
|
|
3
|
+
* It consolidates API functions for use in the application.
|
|
4
|
+
* Do not edit manually.
|
|
5
|
+
*/
|
|
6
|
+
import _applicationMap from './src/applicationMap.js';
|
|
7
|
+
import _awesomenessNormalizeRequest from './src/awesomenessNormalizeRequest.js';
|
|
8
|
+
import _brotliJsonResponse from './src/brotliJsonResponse.js';
|
|
9
|
+
import _checkAccess from './src/checkAccess.js';
|
|
10
|
+
import _componentDependencies from './src/componentDependencies.js';
|
|
11
|
+
import _config from './src/config.js';
|
|
12
|
+
import _fetchPage from './src/fetchPage.js';
|
|
13
|
+
import _getConfig from './src/getConfig.js';
|
|
14
|
+
import _getMD from './src/getMD.js';
|
|
15
|
+
import _init from './src/init.js';
|
|
16
|
+
import _koa_attachAwesomenessRequest from './src/koa/attachAwesomenessRequest.js';
|
|
17
|
+
import _koa_cors from './src/koa/cors.js';
|
|
18
|
+
import _koa_errorHandler from './src/koa/errorHandler.js';
|
|
19
|
+
import _koa_finalFormat from './src/koa/finalFormat.js';
|
|
20
|
+
import _koa_jsonBodyParser from './src/koa/jsonBodyParser.js';
|
|
21
|
+
import _koa_routeRequest from './src/koa/routeRequest.js';
|
|
22
|
+
import _koa_serverUp from './src/koa/serverUp.js';
|
|
23
|
+
import _koa_staticFiles from './src/koa/staticFiles.js';
|
|
24
|
+
import _koa_timeout from './src/koa/timeout.js';
|
|
25
|
+
import _pageInfo from './src/pageInfo.js';
|
|
26
|
+
import _reRoute from './src/reRoute.js';
|
|
27
|
+
import _resolveRealCasePath from './src/resolveRealCasePath.js';
|
|
28
|
+
import _specialPaths from './src/specialPaths.js';
|
|
29
|
+
import _start from './src/start.js';
|
|
30
|
+
import _validateRequest from './src/validateRequest.js';
|
|
31
|
+
import _ws_handlers from './src/ws/handlers.js';
|
|
32
|
+
import _ws_index from './src/ws/index.js';
|
|
33
|
+
|
|
34
|
+
export { _applicationMap as applicationMap };
|
|
35
|
+
export { _awesomenessNormalizeRequest as awesomenessNormalizeRequest };
|
|
36
|
+
export { _brotliJsonResponse as brotliJsonResponse };
|
|
37
|
+
export { _checkAccess as checkAccess };
|
|
38
|
+
export { _componentDependencies as componentDependencies };
|
|
39
|
+
export { _config as config };
|
|
40
|
+
export { _fetchPage as fetchPage };
|
|
41
|
+
export { _getConfig as getConfig };
|
|
42
|
+
export { _getMD as getMD };
|
|
43
|
+
export { _init as init };
|
|
44
|
+
export { _pageInfo as pageInfo };
|
|
45
|
+
export { _reRoute as reRoute };
|
|
46
|
+
export { _resolveRealCasePath as resolveRealCasePath };
|
|
47
|
+
export { _specialPaths as specialPaths };
|
|
48
|
+
export { _start as start };
|
|
49
|
+
export { _validateRequest as validateRequest };
|
|
50
|
+
|
|
51
|
+
export const koa = {
|
|
52
|
+
attachAwesomenessRequest: _koa_attachAwesomenessRequest,
|
|
53
|
+
cors: _koa_cors,
|
|
54
|
+
errorHandler: _koa_errorHandler,
|
|
55
|
+
finalFormat: _koa_finalFormat,
|
|
56
|
+
jsonBodyParser: _koa_jsonBodyParser,
|
|
57
|
+
routeRequest: _koa_routeRequest,
|
|
58
|
+
serverUp: _koa_serverUp,
|
|
59
|
+
staticFiles: _koa_staticFiles,
|
|
60
|
+
timeout: _koa_timeout
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const ws = {
|
|
64
|
+
handlers: _ws_handlers,
|
|
65
|
+
index: _ws_index
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
applicationMap: _applicationMap,
|
|
71
|
+
awesomenessNormalizeRequest: _awesomenessNormalizeRequest,
|
|
72
|
+
brotliJsonResponse: _brotliJsonResponse,
|
|
73
|
+
checkAccess: _checkAccess,
|
|
74
|
+
componentDependencies: _componentDependencies,
|
|
75
|
+
config: _config,
|
|
76
|
+
fetchPage: _fetchPage,
|
|
77
|
+
getConfig: _getConfig,
|
|
78
|
+
getMD: _getMD,
|
|
79
|
+
init: _init,
|
|
80
|
+
pageInfo: _pageInfo,
|
|
81
|
+
reRoute: _reRoute,
|
|
82
82
|
/**
|
|
83
83
|
* Case-insensitive real path resolver.
|
|
84
84
|
* Works correctly on Windows, macOS, and Linux/Docker.
|
|
85
|
-
*/
|
|
86
|
-
resolveRealCasePath: _resolveRealCasePath,
|
|
87
|
-
specialPaths: _specialPaths,
|
|
88
|
-
start: _start,
|
|
89
|
-
validateRequest: _validateRequest,
|
|
90
|
-
koa: {
|
|
91
|
-
attachAwesomenessRequest: _koa_attachAwesomenessRequest,
|
|
92
|
-
cors: _koa_cors,
|
|
93
|
-
errorHandler: _koa_errorHandler,
|
|
94
|
-
finalFormat: _koa_finalFormat,
|
|
95
|
-
jsonBodyParser: _koa_jsonBodyParser,
|
|
96
|
-
routeRequest: _koa_routeRequest,
|
|
97
|
-
serverUp: _koa_serverUp,
|
|
98
|
-
staticFiles: _koa_staticFiles,
|
|
99
|
-
timeout: _koa_timeout,
|
|
100
|
-
},
|
|
101
|
-
ws: {
|
|
102
|
-
handlers: _ws_handlers,
|
|
103
|
-
index: _ws_index,
|
|
104
|
-
},
|
|
85
|
+
*/
|
|
86
|
+
resolveRealCasePath: _resolveRealCasePath,
|
|
87
|
+
specialPaths: _specialPaths,
|
|
88
|
+
start: _start,
|
|
89
|
+
validateRequest: _validateRequest,
|
|
90
|
+
koa: {
|
|
91
|
+
attachAwesomenessRequest: _koa_attachAwesomenessRequest,
|
|
92
|
+
cors: _koa_cors,
|
|
93
|
+
errorHandler: _koa_errorHandler,
|
|
94
|
+
finalFormat: _koa_finalFormat,
|
|
95
|
+
jsonBodyParser: _koa_jsonBodyParser,
|
|
96
|
+
routeRequest: _koa_routeRequest,
|
|
97
|
+
serverUp: _koa_serverUp,
|
|
98
|
+
staticFiles: _koa_staticFiles,
|
|
99
|
+
timeout: _koa_timeout,
|
|
100
|
+
},
|
|
101
|
+
ws: {
|
|
102
|
+
handlers: _ws_handlers,
|
|
103
|
+
index: _ws_index,
|
|
104
|
+
},
|
|
105
105
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@ import { each, getAllFiles } from "@awesomeness-js/utils";
|
|
|
4
4
|
import { readFileSync } from "fs";
|
|
5
5
|
import getConfig from "./getConfig.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
function urlToFsPath(u) {
|
|
9
8
|
|
|
10
9
|
if (!(u instanceof URL)) {
|
|
@@ -51,12 +50,15 @@ function extractUiFirstParts(str) {
|
|
|
51
50
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
export default function componentDependencies(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
export default function componentDependencies(
|
|
54
|
+
allComponents,
|
|
55
|
+
{
|
|
56
|
+
componentLocations = [],
|
|
57
|
+
namespace = "ui",
|
|
58
|
+
showDetails = false,
|
|
59
|
+
ignore = [ "*.css.js" ],
|
|
60
|
+
} = {}
|
|
61
|
+
) {
|
|
60
62
|
|
|
61
63
|
const awesomenessConfig = getConfig();
|
|
62
64
|
|
|
@@ -80,17 +82,12 @@ export default function componentDependencies(allComponents, {
|
|
|
80
82
|
|
|
81
83
|
// baseUrl should point at a directory; we resolve component under it
|
|
82
84
|
const componentUrl = new URL(`./${component}/`, baseUrl);
|
|
83
|
-
|
|
85
|
+
|
|
86
|
+
|
|
84
87
|
return path.resolve(urlToFsPath(componentUrl));
|
|
85
88
|
|
|
86
89
|
});
|
|
87
90
|
|
|
88
|
-
// console.log({
|
|
89
|
-
// "import.meta.url =": import.meta.url,
|
|
90
|
-
// component,
|
|
91
|
-
// candidateRoots
|
|
92
|
-
// });
|
|
93
|
-
|
|
94
91
|
let allFiles;
|
|
95
92
|
let chosenRoot;
|
|
96
93
|
let lastErr;
|
|
@@ -99,26 +96,24 @@ export default function componentDependencies(allComponents, {
|
|
|
99
96
|
|
|
100
97
|
try {
|
|
101
98
|
|
|
99
|
+
// IMPORTANT: pass root so getAllFiles returns paths relative to the scan root
|
|
102
100
|
allFiles = getAllFiles(".", {
|
|
103
101
|
dir: root,
|
|
104
|
-
|
|
102
|
+
root,
|
|
103
|
+
ignore,
|
|
105
104
|
});
|
|
106
105
|
|
|
107
106
|
chosenRoot = root;
|
|
108
|
-
|
|
109
107
|
break; // first match wins
|
|
110
108
|
|
|
111
|
-
} catch(e) {
|
|
109
|
+
} catch (e) {
|
|
112
110
|
|
|
113
|
-
// try next
|
|
114
111
|
lastErr = e;
|
|
115
112
|
|
|
116
113
|
}
|
|
117
114
|
|
|
118
115
|
}
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
|
|
122
117
|
if (!allFiles) {
|
|
123
118
|
|
|
124
119
|
throw {
|
|
@@ -131,48 +126,51 @@ export default function componentDependencies(allComponents, {
|
|
|
131
126
|
}
|
|
132
127
|
|
|
133
128
|
if (
|
|
134
|
-
awesomenessConfig.debug_componentDependencies
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
awesomenessConfig.debug_componentDependencies &&
|
|
130
|
+
Array.isArray(awesomenessConfig.debug_componentDependencies) &&
|
|
131
|
+
awesomenessConfig.debug_componentDependencies.includes(component)
|
|
137
132
|
) {
|
|
138
133
|
|
|
139
134
|
console.log("[awesomenessConfig.debug componentDependencies] chosenRoot:", chosenRoot);
|
|
140
135
|
console.log("[awesomenessConfig.debug componentDependencies] allFiles count:", allFiles.length);
|
|
141
136
|
console.log("[awesomenessConfig.debug componentDependencies] first 50 files:", allFiles.slice(0, 50));
|
|
142
|
-
console.log(
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
console.log(
|
|
138
|
+
"[awesomenessConfig.debug componentDependencies] any non-string:",
|
|
139
|
+
allFiles.some((f) => typeof f !== "string")
|
|
140
|
+
);
|
|
141
|
+
console.log(
|
|
142
|
+
"[awesomenessConfig.debug componentDependencies] any absolute:",
|
|
143
|
+
allFiles.some((f) => path.isAbsolute(f))
|
|
144
|
+
);
|
|
145
|
+
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
allFiles.forEach((file) => {
|
|
148
149
|
|
|
149
150
|
const normalizedPath = path.normalize(file);
|
|
150
|
-
const pathSegments = normalizedPath.split(path.sep);
|
|
151
151
|
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
let fileNameFull = pathSegments[pathSegments.length - 1];
|
|
152
|
+
const fileNameFull = path.basename(normalizedPath);
|
|
155
153
|
const fileTypeArr = fileNameFull.split(".");
|
|
156
|
-
const fileType = fileTypeArr[fileTypeArr.length - 1];
|
|
154
|
+
const fileType = fileTypeArr[fileTypeArr.length - 1].toLowerCase();
|
|
157
155
|
const fileName = fileTypeArr.slice(0, -1).join(".");
|
|
158
156
|
|
|
159
157
|
out[component] = out[component] || {};
|
|
160
158
|
out[component][fileType] = out[component][fileType] || {};
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
// Build tail from the file's relative directory (NOT by searching for `component` in the path)
|
|
161
|
+
const dir = path.dirname(normalizedPath);
|
|
162
|
+
const dirParts = dir === "." ? [] : dir.split(path.sep);
|
|
165
163
|
|
|
166
164
|
let tail = "";
|
|
167
165
|
|
|
168
166
|
if (fileType === "js" || fileType === "css") {
|
|
169
167
|
|
|
170
|
-
if (
|
|
168
|
+
if (dirParts.length > 0) {
|
|
171
169
|
|
|
172
170
|
tail =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
fileName === "index"
|
|
172
|
+
? "." + dirParts.join(".")
|
|
173
|
+
: `.${dirParts.join(".")}.${fileName}`;
|
|
176
174
|
|
|
177
175
|
} else {
|
|
178
176
|
|
|
@@ -186,7 +184,10 @@ export default function componentDependencies(allComponents, {
|
|
|
186
184
|
|
|
187
185
|
try {
|
|
188
186
|
|
|
189
|
-
|
|
187
|
+
// readFileSync must use chosenRoot + relative file path
|
|
188
|
+
const filePath = path.isAbsolute(file) ? file : path.join(chosenRoot, file);
|
|
189
|
+
const fileContent = readFileSync(filePath, "utf-8");
|
|
190
|
+
|
|
190
191
|
const lines = fileContent.split("\n");
|
|
191
192
|
let fileWithImportsStripped = "";
|
|
192
193
|
|
|
@@ -225,7 +226,9 @@ export default function componentDependencies(allComponents, {
|
|
|
225
226
|
|
|
226
227
|
if (imports.length > 1) {
|
|
227
228
|
|
|
228
|
-
const importComponents = imports[1]
|
|
229
|
+
const importComponents = imports[1]
|
|
230
|
+
.split(",")
|
|
231
|
+
.map((c) => c.trim());
|
|
229
232
|
|
|
230
233
|
importComponents.forEach((importComponent) => {
|
|
231
234
|
|
|
@@ -243,15 +246,17 @@ export default function componentDependencies(allComponents, {
|
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
} else if (
|
|
246
|
-
line.startsWith("// awesomeness import")
|
|
247
|
-
|
|
249
|
+
line.startsWith("// awesomeness import") ||
|
|
250
|
+
line.startsWith("/* awesomeness @import")
|
|
248
251
|
) {
|
|
249
252
|
|
|
250
253
|
const importPathMatch = line.match(/['"]([^'"]+)['"]/);
|
|
251
254
|
|
|
252
255
|
if (importPathMatch) {
|
|
253
256
|
|
|
254
|
-
const importedComponentName = importPathMatch[1]
|
|
257
|
+
const importedComponentName = importPathMatch[1]
|
|
258
|
+
.replace(/;$/, "")
|
|
259
|
+
.trim();
|
|
255
260
|
|
|
256
261
|
if (!allComponents.includes(importedComponentName)) {
|
|
257
262
|
|
|
@@ -273,8 +278,8 @@ export default function componentDependencies(allComponents, {
|
|
|
273
278
|
if (fileType === "js") {
|
|
274
279
|
|
|
275
280
|
if (
|
|
276
|
-
fileWithImportsStripped.startsWith("(function")
|
|
277
|
-
|
|
281
|
+
fileWithImportsStripped.startsWith("(function") ||
|
|
282
|
+
fileWithImportsStripped.startsWith("((")
|
|
278
283
|
) {
|
|
279
284
|
|
|
280
285
|
fileWithImportsStripped = `;${fileWithImportsStripped}`;
|
|
@@ -294,8 +299,7 @@ export default function componentDependencies(allComponents, {
|
|
|
294
299
|
|
|
295
300
|
} catch (err) {
|
|
296
301
|
|
|
297
|
-
|
|
298
|
-
const full = path.join(chosenRoot, file);
|
|
302
|
+
const full = path.isAbsolute(file) ? file : path.join(chosenRoot, file);
|
|
299
303
|
|
|
300
304
|
console.error("Failed to get dependencies", {
|
|
301
305
|
component,
|
package/src/koa/routeRequest.js
CHANGED
|
@@ -165,63 +165,124 @@ export default async function routeRequest(ctx, next) {
|
|
|
165
165
|
let specific = false;
|
|
166
166
|
|
|
167
167
|
// Prefer filesystem existence checks so we don't rely on import() throwing for control flow
|
|
168
|
-
|
|
168
|
+
awesomenessRequest.log('Trying site specific route.', {
|
|
169
|
+
siteSpecificIndexPath,
|
|
170
|
+
siteSpecificInfoPath
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
let siteSpecificIndexExists = false;
|
|
174
|
+
let siteSpecificInfoExists = false;
|
|
169
175
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
siteSpecificInfoPath
|
|
173
|
-
});
|
|
176
|
+
|
|
177
|
+
try {
|
|
174
178
|
|
|
175
179
|
await fs.access(siteSpecificIndexPath);
|
|
180
|
+
siteSpecificIndexExists = true;
|
|
181
|
+
|
|
182
|
+
} catch {}
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
|
|
176
186
|
await fs.access(siteSpecificInfoPath);
|
|
187
|
+
siteSpecificInfoExists = true;
|
|
188
|
+
|
|
189
|
+
} catch {}
|
|
190
|
+
|
|
191
|
+
if (siteSpecificIndexExists && siteSpecificInfoExists) {
|
|
177
192
|
|
|
178
193
|
awesomenessRequest.log('Site specific route found.', {
|
|
179
194
|
siteSpecificIndexPath,
|
|
180
195
|
siteSpecificInfoPath
|
|
181
196
|
});
|
|
182
197
|
|
|
183
|
-
|
|
184
|
-
const infoMod = await import(pathToFileURL(siteSpecificInfoPath).href);
|
|
185
|
-
|
|
186
|
-
routeInfo = infoMod.default;
|
|
198
|
+
try {
|
|
187
199
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
200
|
+
routeIndex = await import(pathToFileURL(siteSpecificIndexPath).href);
|
|
201
|
+
const infoMod = await import(pathToFileURL(siteSpecificInfoPath).href);
|
|
191
202
|
|
|
203
|
+
routeInfo = infoMod.default;
|
|
204
|
+
awesomenessRequest.log('Site specific route info loaded.', {
|
|
205
|
+
routeInfo
|
|
206
|
+
});
|
|
207
|
+
specific = true;
|
|
208
|
+
|
|
209
|
+
} catch (importError) {
|
|
192
210
|
|
|
193
|
-
|
|
211
|
+
ctx.status = 500;
|
|
212
|
+
ctx.body = {
|
|
213
|
+
success: false,
|
|
214
|
+
message: "Site specific route import error",
|
|
215
|
+
error: importError,
|
|
216
|
+
siteSpecificRoute: siteSpecificIndexPath,
|
|
217
|
+
siteSpecificInfo: siteSpecificInfoPath,
|
|
218
|
+
};
|
|
219
|
+
finalFormat(awesomenessRequest, ctx);
|
|
220
|
+
|
|
221
|
+
return;
|
|
222
|
+
|
|
223
|
+
}
|
|
194
224
|
|
|
195
|
-
}
|
|
225
|
+
} else {
|
|
226
|
+
|
|
227
|
+
awesomenessRequest.log('Site specific route not found, trying generic route.', {
|
|
228
|
+
siteSpecificIndexExists: siteSpecificIndexExists,
|
|
229
|
+
siteSpecificInfoExists: siteSpecificInfoExists
|
|
230
|
+
});
|
|
231
|
+
let genericIndexExists = false;
|
|
232
|
+
let genericInfoExists = false;
|
|
196
233
|
|
|
197
|
-
awesomenessRequest.log('Site specific route not found, trying generic route.', { error });
|
|
198
234
|
|
|
199
235
|
try {
|
|
200
236
|
|
|
201
237
|
await fs.access(genericIndexPath);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const infoMod = await import(pathToFileURL(genericInfoPath).href);
|
|
238
|
+
genericIndexExists = true;
|
|
239
|
+
|
|
240
|
+
} catch {}
|
|
206
241
|
|
|
207
|
-
|
|
242
|
+
try {
|
|
208
243
|
|
|
209
|
-
|
|
244
|
+
await fs.access(genericInfoPath);
|
|
245
|
+
genericInfoExists = true;
|
|
246
|
+
|
|
247
|
+
} catch {}
|
|
248
|
+
|
|
249
|
+
if (genericIndexExists && genericInfoExists) {
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
|
|
253
|
+
routeIndex = await import(pathToFileURL(genericIndexPath).href);
|
|
254
|
+
const infoMod = await import(pathToFileURL(genericInfoPath).href);
|
|
255
|
+
|
|
256
|
+
routeInfo = infoMod.default;
|
|
257
|
+
specific = false;
|
|
258
|
+
|
|
259
|
+
} catch (importError2) {
|
|
260
|
+
|
|
261
|
+
ctx.status = 500;
|
|
262
|
+
ctx.body = {
|
|
263
|
+
success: false,
|
|
264
|
+
message: "Generic route import error",
|
|
265
|
+
error: importError2,
|
|
266
|
+
genericRoute: genericIndexPath,
|
|
267
|
+
genericInfo: genericInfoPath,
|
|
268
|
+
};
|
|
269
|
+
finalFormat(awesomenessRequest, ctx);
|
|
270
|
+
|
|
271
|
+
return;
|
|
272
|
+
|
|
273
|
+
}
|
|
210
274
|
|
|
211
|
-
}
|
|
275
|
+
} else {
|
|
212
276
|
|
|
213
277
|
ctx.status = 404;
|
|
214
|
-
|
|
215
278
|
ctx.body = {
|
|
216
279
|
success: false,
|
|
217
280
|
message: "route not found",
|
|
218
|
-
error: error2,
|
|
219
281
|
siteSpecificRoute: siteSpecificIndexPath,
|
|
220
282
|
genericRoute: genericIndexPath,
|
|
221
283
|
};
|
|
222
|
-
|
|
223
284
|
finalFormat(awesomenessRequest, ctx);
|
|
224
|
-
|
|
285
|
+
|
|
225
286
|
return;
|
|
226
287
|
|
|
227
288
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/* test */
|