@lars_hagemann/mediaserver-create-plugin 1.2.0-beta → 1.3.0-beta

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.
Files changed (2) hide show
  1. package/dist/index.js +76 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ const frontendTsConfig = {
51
51
  moduleDetection: "force",
52
52
  noEmit: false,
53
53
  outDir: "dist",
54
+ rootDir: "src",
54
55
  /* Linting */
55
56
  strict: true,
56
57
  noUnusedLocals: true,
@@ -69,6 +70,7 @@ const backendTsConfig = {
69
70
  module: "nodenext",
70
71
  skipLibCheck: true,
71
72
  outDir: "dist",
73
+ rootDir: "src",
72
74
  moduleResolution: "nodenext",
73
75
  /* Linting */
74
76
  strict: true,
@@ -106,6 +108,7 @@ const themeTsConfig = {
106
108
  moduleDetection: "force",
107
109
  noEmit: false,
108
110
  outDir: "dist",
111
+ rootDir: "src",
109
112
  strict: true,
110
113
  noUnusedLocals: true,
111
114
  noUnusedParameters: true,
@@ -157,11 +160,11 @@ const backendSkeleton = `
157
160
  import { FileTypePlugin } from "@lars_hagemann/mediaserver-backend-plugin-types";
158
161
 
159
162
  export const plugin: FileTypePlugin = {
160
- matcher: (file) => /* Your implementation here */ false,
161
- thumbnailCreator: async (context) => {
163
+ matcher: (_file) => /* Your implementation here */ false,
164
+ thumbnailCreator: async (_context) => {
162
165
  throw new Error("Not implemented");
163
166
  },
164
- initialTags: async (path) => {
167
+ initialTags: async (_path) => {
165
168
  return [];
166
169
  },
167
170
  description: "Your plugin description here",
@@ -170,23 +173,64 @@ export const plugin: FileTypePlugin = {
170
173
  export default plugin;
171
174
  `;
172
175
  const frontendSkeleton = `
173
- import type { FileTypePlugin } from "@lars_hagemann/mediaserver-frontend-plugin-types";
176
+ import type { FrontendPlugin } from "@lars_hagemann/mediaserver-frontend-plugin-types";
174
177
 
175
- const plugin: FileTypePlugin = {
176
- matcher: (fileType) => /* Your implementation here */ false,
177
- icon: (ReactIcons) => /* Your implementation here */ ReactIcons.FaFile,
178
- Render: (context) => {
179
- context.React.useEffect(() => {
180
- console.log("This worked!");
181
- }, []);
182
-
183
- return context.React.createElement("iframe", {
184
- className: "w-full h-full",
185
- src: context.objectUrl,
186
- });
187
- },
188
- Diashow: () => null,
178
+ const plugin: FrontendPlugin = {
179
+ id: "my-plugin",
180
+ name: "My Plugin",
189
181
  description: "Your plugin description here",
182
+
183
+ // Optional: Add navigation items to the sidebar
184
+ // navItems: [
185
+ // {
186
+ // id: "my-page",
187
+ // path: "/my-plugin",
188
+ // label: "My Plugin",
189
+ // icon: (icons) => icons.FaPlug,
190
+ // priority: 10,
191
+ // },
192
+ // ],
193
+
194
+ // // Optional: Add custom routes
195
+ // routes: [
196
+ // {
197
+ // path: "/my-plugin",
198
+ // Component: (context) => {
199
+ // const { React, api } = context;
200
+ //
201
+ // return React.createElement(
202
+ // "div",
203
+ // { className: "p-6" },
204
+ // React.createElement(
205
+ // "h1",
206
+ // { className: "text-2xl font-bold text-text-primary mb-4" },
207
+ // "My Plugin Page",
208
+ // ),
209
+ // React.createElement(
210
+ // "p",
211
+ // { className: "text-text-secondary" },
212
+ // "This page is rendered by your plugin.",
213
+ // ),
214
+ // );
215
+ // },
216
+ // },
217
+ // ],
218
+
219
+ // Optional: Add a file type renderer
220
+ // fileType: {
221
+ // matcher: (fileType) => false,
222
+ // icon: (icons) => icons.FaFile,
223
+ // Render: (context) => context.React.createElement("div", null, "Preview"),
224
+ // Diashow: () => null,
225
+ // description: "File type renderer",
226
+ // },
227
+
228
+ // Optional: Add a theme
229
+ // theme: {
230
+ // name: "my-theme",
231
+ // description: "My custom theme",
232
+ // tokens: { "--color-accent": "#ff0000" },
233
+ // },
190
234
  };
191
235
 
192
236
  export default plugin;
@@ -223,6 +267,15 @@ const questionOrDefault = async (query, defaultValue) => {
223
267
  const answer = await question(`${query} ${defaultValue ? `(${defaultValue})` : ""}: `);
224
268
  return answer.trim() === "" ? defaultValue : answer.trim();
225
269
  };
270
+ // Allow the prompts to be answered non-interactively via environment
271
+ // variables (used by CI to scaffold a plugin without a TTY). When the
272
+ // variable is unset, fall back to the interactive prompt.
273
+ const envOrPrompt = async (envVar, ask) => {
274
+ const value = process.env[envVar];
275
+ if (value !== undefined && value.trim() !== "")
276
+ return value.trim();
277
+ return ask();
278
+ };
226
279
  const validateYesNo = (input, defaultValue) => {
227
280
  if (!input)
228
281
  return defaultValue || false;
@@ -248,17 +301,17 @@ const doExec = (command) => {
248
301
  });
249
302
  };
250
303
  async function main() {
251
- const folderPath = await questionOrDefault("Enter the plugin folder path", path.resolve("."));
252
- const pluginName = await questionOrDefault("Enter the plugin name", "my-plugin");
253
- const authorName = await questionOrDefault("Enter the author name", "Your Name");
254
- const initGitString = await questionOrDefault("Initialize git? (Yes/no)");
304
+ const folderPath = await envOrPrompt("CREATE_PLUGIN_DIR", () => questionOrDefault("Enter the plugin folder path", path.resolve(".")));
305
+ const pluginName = await envOrPrompt("CREATE_PLUGIN_NAME", () => questionOrDefault("Enter the plugin name", "my-plugin"));
306
+ const authorName = await envOrPrompt("CREATE_PLUGIN_AUTHOR", () => questionOrDefault("Enter the author name", "Your Name"));
307
+ const initGitString = await envOrPrompt("CREATE_PLUGIN_INIT_GIT", () => questionOrDefault("Initialize git? (Yes/no)"));
255
308
  const initGit = validateYesNo(initGitString, true);
256
309
  console.log("\nPlugin Configuration:");
257
310
  console.log(`Folder Path: ${path.resolve(folderPath)}`);
258
311
  console.log(`Plugin Name: ${pluginName}`);
259
312
  console.log(`Author Name: ${authorName}`);
260
313
  console.log(`Initialize Git: ${initGit ? "Yes" : "No"}`);
261
- const validateString = await questionOrDefault("Create plugin? (Yes/no)");
314
+ const validateString = await envOrPrompt("CREATE_PLUGIN_CONFIRM", () => questionOrDefault("Create plugin? (Yes/no)"));
262
315
  const validate = validateYesNo(validateString, true);
263
316
  rl.close();
264
317
  if (!validate) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lars_hagemann/mediaserver-create-plugin",
3
- "version": "1.2.0-beta",
3
+ "version": "1.3.0-beta",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": "dist/index.js",