Browse Source

chore(dashboard-plugin): Add initial setup of DashboardPlugin

David Höck 9 months ago
parent
commit
4cf4673358

+ 32 - 0
packages/dashboard-plugin/package.json

@@ -0,0 +1,32 @@
+{
+    "name": "@vendure/dashboard-plugin",
+    "version": "3.2.3",
+    "main": "dist/index.js",
+    "types": "dist/index.d.ts",
+    "files": [
+        "dist/**/*"
+    ],
+    "repository": {
+        "type": "git",
+        "url": "https://github.com/vendure-ecommerce/vendure"
+    },
+    "license": "GPL-3.0-or-later",
+    "scripts": {
+        "build": "rimraf dist && node -r ts-node/register build.ts && npm run compile",
+        "watch": "tsc -p ./tsconfig.build.json --watch",
+        "lint": "eslint --fix .",
+        "compile": "tsc -p ./tsconfig.build.json"
+    },
+    "homepage": "https://www.vendure.io",
+    "funding": "https://github.com/sponsors/michaelbromley",
+    "publishConfig": {
+        "access": "public"
+    },
+    "devDependencies": {
+        "@vendure/common": "3.2.3",
+        "@vendure/core": "3.2.3",
+        "rimraf": "^5.0.5",
+        "typescript": "5.8.2"
+    },
+    "dependencies": {}
+}

+ 2 - 0
packages/dashboard-plugin/src/constants.ts

@@ -0,0 +1,2 @@
+export const PLUGIN_INIT_OPTIONS = Symbol('DASHBOARD_PLUGIN_INIT_OPTIONS');
+export const loggerCtx = 'DashboardPlugin';

+ 2 - 0
packages/dashboard-plugin/src/index.ts

@@ -0,0 +1,2 @@
+export * from './plugin';
+export * from './types';

+ 48 - 0
packages/dashboard-plugin/src/plugin.ts

@@ -0,0 +1,48 @@
+import { PluginCommonModule, VendurePlugin } from '@vendure/core';
+
+import { PLUGIN_INIT_OPTIONS, loggerCtx } from './constants';
+import { DashboardPluginOptions } from './types';
+
+/**
+ * @description
+ * This plugin adds functionality specifically required by the Vendure Admin Dashboard.
+ * It is not required for Vendure to function, but is used to provide additional features
+ * that are not required for the core functionality of Vendure.
+ *
+ * ## Installation
+ *
+ * ```ts
+ * import { DashboardPlugin } from '@vendure/dashboard-plugin';
+ *
+ * const config: VendureConfig = {
+ *   // Add an instance of the plugin to the plugins array
+ *   plugins: [
+ *     DashboardPlugin.init(),
+ *   ],
+ * };
+ * ```
+ */
+@VendurePlugin({
+    imports: [PluginCommonModule],
+    providers: [
+        {
+            provide: PLUGIN_INIT_OPTIONS,
+            useFactory: () => DashboardPlugin.options,
+        },
+    ],
+    configuration: config => {
+        // Plugin configuration logic here
+        return config;
+    },
+    compatibility: '^3.0.0',
+})
+export class DashboardPlugin {
+    static options: DashboardPluginOptions;
+
+    static init(options: DashboardPluginOptions = {}) {
+        this.options = {
+            ...options,
+        };
+        return DashboardPlugin;
+    }
+}

+ 4 - 0
packages/dashboard-plugin/src/types.ts

@@ -0,0 +1,4 @@
+/**
+ * Configuration options for the DashboardPlugin
+ */
+export interface DashboardPluginOptions {}

+ 7 - 0
packages/dashboard-plugin/tsconfig.build.json

@@ -0,0 +1,7 @@
+{
+    "extends": "./tsconfig.json",
+    "compilerOptions": {
+        "outDir": "./dist"
+    },
+    "files": ["./index.ts"]
+}

+ 10 - 0
packages/dashboard-plugin/tsconfig.json

@@ -0,0 +1,10 @@
+{
+    "extends": "../../tsconfig.json",
+    "compilerOptions": {
+        "declaration": true,
+        "removeComments": false,
+        "noLib": false,
+        "skipLibCheck": true,
+        "sourceMap": true
+    }
+}