@raketa-cloud/admin 1.9.2 → 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.2",
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\"",
@@ -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 packagePath = viewsFallback
151
- ? `${currentPath}/views/${viewsFallback}/${action}.ejs`
152
- : `${currentPath}/views/${views}/${action}.ejs`;
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
- const appPath = `${process.cwd()}/src/views/${views}/${action}.ejs`;
168
+ paths.push(sanitizePath(`${currentPath}/views/${views}/${action}.ejs`));
155
169
 
156
- return existsSync(appPath) ? appPath : packagePath;
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) {
@@ -9,7 +9,7 @@ function routeCategoriesModule(adapter, categoryType, categoryTypePlural) {
9
9
 
10
10
  routeCollection(adapter, categoryTypePlural, CategoriesHandler, {
11
11
  ...resourceConfig,
12
- views: "categories",
12
+ viewsFallback: "categories",
13
13
  });
14
14
  }
15
15
 
@@ -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 package path when app missing", () => {
95
- existsSync.mockReturnValue(false);
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
- const result = adapter.getActionPath("widget-sets", "resources", "index");
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(result).toContain("/views/resources/index.ejs");
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(() => {
@@ -21,7 +21,7 @@ describe("routeCategoriesModule", () => {
21
21
  {
22
22
  categoryType: "tag",
23
23
  categoryTypePlural: "tags",
24
- views: "categories",
24
+ viewsFallback: "categories",
25
25
  },
26
26
  );
27
27
  });
@@ -94,7 +94,7 @@
94
94
  const date = new Date();
95
95
 
96
96
 
97
- date.setDate(date.getDate() + 2);
97
+ date.setDate(date.getDate() + 3);
98
98
 
99
99
  // Skip weekends.
100
100
  while(date.getDay() === 0 || date.getDay() === 6) {