@raketa-cloud/admin 1.9.3 → 1.9.4
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/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-cloud/admin",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/",
|
|
7
7
|
"dist/"
|
|
8
8
|
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/studioraketa/raketa-admin-js.git",
|
|
12
|
+
"directory": "packages/raketa-cms-admin"
|
|
13
|
+
},
|
|
9
14
|
"scripts": {
|
|
10
15
|
"dev": "npx tailwindcss -i ./src/styles/application.css -o ../../apps/admin/static/application.css --watch",
|
|
11
16
|
"test": "jest --coverage --coverageReporters=html --coverageReporters=\"text-summary\"",
|
package/src/HonoAdapter.js
CHANGED
|
@@ -74,9 +74,15 @@ function getPartialPath(partialPath, views, viewsFallback) {
|
|
|
74
74
|
|
|
75
75
|
const paths = [
|
|
76
76
|
sanitizePath(`${process.cwd()}/src/views/${resolvedPartialPath}`),
|
|
77
|
-
sanitizePath(`${currentPath}/views/${resolvedPartialPath}`),
|
|
78
77
|
];
|
|
79
78
|
|
|
79
|
+
if (viewsFallback) {
|
|
80
|
+
const fallbackPath = sanitizePath(`${viewsFallback}/${partialPath}`);
|
|
81
|
+
paths.push(sanitizePath(`${process.cwd()}/src/views/${fallbackPath}`));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
paths.push(sanitizePath(`${currentPath}/views/${resolvedPartialPath}`));
|
|
85
|
+
|
|
80
86
|
// For fallback, resolve the partial path relative to viewsFallback
|
|
81
87
|
// This naturally handles ".." navigation: "resource_revisions/codes/../_nav.ejs" → "resource_revisions/_nav.ejs"
|
|
82
88
|
if (viewsFallback) {
|
|
@@ -147,13 +153,33 @@ export default class HonoAdapter {
|
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
getActionPath(views, viewsFallback, action) {
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
const paths = [
|
|
157
|
+
sanitizePath(`${process.cwd()}/src/views/${views}/${action}.ejs`),
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
if (viewsFallback) {
|
|
161
|
+
paths.push(
|
|
162
|
+
sanitizePath(
|
|
163
|
+
`${process.cwd()}/src/views/${viewsFallback}/${action}.ejs`,
|
|
164
|
+
),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
153
167
|
|
|
154
|
-
|
|
168
|
+
paths.push(sanitizePath(`${currentPath}/views/${views}/${action}.ejs`));
|
|
155
169
|
|
|
156
|
-
|
|
170
|
+
if (viewsFallback) {
|
|
171
|
+
paths.push(
|
|
172
|
+
sanitizePath(`${currentPath}/views/${viewsFallback}/${action}.ejs`),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const existingPath = paths.find((path) => existsSync(path));
|
|
177
|
+
|
|
178
|
+
if (existingPath) return existingPath;
|
|
179
|
+
|
|
180
|
+
throw new Error(
|
|
181
|
+
`Template for action "${action}" not found:\nSearched in:\n${paths.join("\n")}`,
|
|
182
|
+
);
|
|
157
183
|
}
|
|
158
184
|
|
|
159
185
|
getHelpers(viewHelpersConfig) {
|
|
@@ -91,12 +91,22 @@ describe("HonoAdapter.getActionPath", () => {
|
|
|
91
91
|
expect(result).toBe(`${process.cwd()}/src/views/authors/index.ejs`);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
test("returns
|
|
95
|
-
existsSync.
|
|
94
|
+
test("returns app fallback path when app specific is missing but app fallback exists", () => {
|
|
95
|
+
existsSync.mockImplementation(
|
|
96
|
+
(p) => p === `${process.cwd()}/src/views/categories/index.ejs`,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const result = adapter.getActionPath("movie-types", "categories", "index");
|
|
96
100
|
|
|
97
|
-
|
|
101
|
+
expect(result).toBe(`${process.cwd()}/src/views/categories/index.ejs`);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("throws an error when all paths are missing.", () => {
|
|
105
|
+
existsSync.mockReturnValue(false);
|
|
98
106
|
|
|
99
|
-
expect(
|
|
107
|
+
expect(async () => {
|
|
108
|
+
adapter.getActionPath("tags", undefined, "index");
|
|
109
|
+
}).rejects.toThrow();
|
|
100
110
|
});
|
|
101
111
|
});
|
|
102
112
|
|
|
@@ -143,6 +153,23 @@ describe("HonoAdapter.renderPartial", () => {
|
|
|
143
153
|
);
|
|
144
154
|
});
|
|
145
155
|
|
|
156
|
+
test("uses app fallback partial when app specific is missing but app fallback exists", () => {
|
|
157
|
+
existsSync.mockImplementation(
|
|
158
|
+
(p) => p === `${process.cwd()}/src/views/categories/_form.ejs`,
|
|
159
|
+
);
|
|
160
|
+
readFileSync.mockReturnValue("<%= fallback %>");
|
|
161
|
+
ejs.render.mockReturnValue("fallback rendered");
|
|
162
|
+
|
|
163
|
+
const render = adapter.renderPartial({}, "genres", "categories");
|
|
164
|
+
const result = render("_form.ejs");
|
|
165
|
+
|
|
166
|
+
expect(result).toBe("fallback rendered");
|
|
167
|
+
expect(readFileSync).toHaveBeenCalledWith(
|
|
168
|
+
`${process.cwd()}/src/views/categories/_form.ejs`,
|
|
169
|
+
"utf8",
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
|
|
146
173
|
test("returns error markup on render failure", () => {
|
|
147
174
|
existsSync.mockReturnValue(true);
|
|
148
175
|
readFileSync.mockImplementation(() => {
|