@vendure/dashboard 3.4.1-master-202508020237 → 3.4.1-master-202508040248

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 (44) hide show
  1. package/dist/vite/utils/schema-generator.js +17 -12
  2. package/package.json +154 -155
  3. package/vite/constants.ts +0 -280
  4. package/vite/index.ts +0 -1
  5. package/vite/tests/barrel-exports.spec.ts +0 -30
  6. package/vite/tests/fixtures-barrel-exports/my-plugin/index.ts +0 -1
  7. package/vite/tests/fixtures-barrel-exports/my-plugin/src/my.plugin.ts +0 -8
  8. package/vite/tests/fixtures-barrel-exports/package.json +0 -6
  9. package/vite/tests/fixtures-barrel-exports/vendure-config.ts +0 -19
  10. package/vite/tests/fixtures-npm-plugin/fake_node_modules/test-plugin/index.js +0 -20
  11. package/vite/tests/fixtures-npm-plugin/fake_node_modules/test-plugin/package.json +0 -8
  12. package/vite/tests/fixtures-npm-plugin/package.json +0 -6
  13. package/vite/tests/fixtures-npm-plugin/vendure-config.ts +0 -18
  14. package/vite/tests/fixtures-path-alias/js-aliased/index.ts +0 -1
  15. package/vite/tests/fixtures-path-alias/js-aliased/src/js-aliased.plugin.ts +0 -8
  16. package/vite/tests/fixtures-path-alias/package.json +0 -6
  17. package/vite/tests/fixtures-path-alias/star-aliased/index.ts +0 -1
  18. package/vite/tests/fixtures-path-alias/star-aliased/src/star-aliased.plugin.ts +0 -8
  19. package/vite/tests/fixtures-path-alias/ts-aliased/index.ts +0 -1
  20. package/vite/tests/fixtures-path-alias/ts-aliased/src/ts-aliased.plugin.ts +0 -8
  21. package/vite/tests/fixtures-path-alias/vendure-config.ts +0 -20
  22. package/vite/tests/npm-plugin.spec.ts +0 -46
  23. package/vite/tests/path-alias.spec.ts +0 -61
  24. package/vite/tests/tsconfig.json +0 -21
  25. package/vite/types.ts +0 -44
  26. package/vite/utils/ast-utils.spec.ts +0 -49
  27. package/vite/utils/ast-utils.ts +0 -33
  28. package/vite/utils/compiler.ts +0 -244
  29. package/vite/utils/config-loader.ts +0 -0
  30. package/vite/utils/logger.ts +0 -43
  31. package/vite/utils/plugin-discovery.ts +0 -494
  32. package/vite/utils/schema-generator.ts +0 -45
  33. package/vite/utils/tsconfig-utils.ts +0 -79
  34. package/vite/utils/ui-config.ts +0 -52
  35. package/vite/vite-plugin-admin-api-schema.ts +0 -131
  36. package/vite/vite-plugin-config-loader.ts +0 -84
  37. package/vite/vite-plugin-config.ts +0 -70
  38. package/vite/vite-plugin-dashboard-metadata.ts +0 -73
  39. package/vite/vite-plugin-gql-tada.ts +0 -62
  40. package/vite/vite-plugin-tailwind-source.ts +0 -81
  41. package/vite/vite-plugin-theme.ts +0 -195
  42. package/vite/vite-plugin-transform-index.ts +0 -40
  43. package/vite/vite-plugin-ui-config.ts +0 -163
  44. package/vite/vite-plugin-vendure-dashboard.ts +0 -174
@@ -1,30 +0,0 @@
1
- import { rm } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { describe, expect, it } from 'vitest';
4
-
5
- import { compile } from '../utils/compiler.js';
6
- import { debugLogger, noopLogger } from '../utils/logger.js';
7
-
8
- describe('detecting plugins in barrel exports', () => {
9
- it(
10
- 'should detect plugins in barrel exports',
11
- async () => {
12
- const tempDir = join(__dirname, './__temp/barrel-exports');
13
- await rm(tempDir, { recursive: true, force: true });
14
- const result = await compile({
15
- outputPath: tempDir,
16
- vendureConfigPath: join(__dirname, 'fixtures-barrel-exports', 'vendure-config.ts'),
17
- logger: process.env.LOG ? debugLogger : noopLogger,
18
- });
19
-
20
- expect(result.pluginInfo).toHaveLength(1);
21
- expect(result.pluginInfo[0].name).toBe('MyPlugin');
22
- expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
23
- expect(result.pluginInfo[0].sourcePluginPath).toBe(
24
- join(__dirname, 'fixtures-barrel-exports', 'my-plugin', 'src', 'my.plugin.ts'),
25
- );
26
- expect(result.pluginInfo[0].pluginPath).toBe(join(tempDir, 'my-plugin', 'src', 'my.plugin.js'));
27
- },
28
- { timeout: 10_000 },
29
- );
30
- });
@@ -1 +0,0 @@
1
- export * from './src/my.plugin';
@@ -1,8 +0,0 @@
1
- import { PluginCommonModule, VendurePlugin } from '@vendure/core';
2
-
3
- @VendurePlugin({
4
- imports: [PluginCommonModule],
5
- providers: [],
6
- dashboard: './dashboard/index.tsx',
7
- })
8
- export class MyPlugin {}
@@ -1,6 +0,0 @@
1
- {
2
- "type": "commonjs",
3
- "name": "barrel-exports",
4
- "version": "0.0.1",
5
- "main": "index.ts"
6
- }
@@ -1,19 +0,0 @@
1
- import { VendureConfig } from '@vendure/core';
2
-
3
- import { MyPlugin } from './my-plugin';
4
-
5
- export const config: VendureConfig = {
6
- apiOptions: {
7
- port: 3000,
8
- },
9
- authOptions: {
10
- tokenMethod: 'bearer',
11
- },
12
- dbConnectionOptions: {
13
- type: 'postgres',
14
- },
15
- paymentOptions: {
16
- paymentMethodHandlers: [],
17
- },
18
- plugins: [MyPlugin],
19
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.TestPlugin = void 0;
10
- const core_1 = require("@vendure/core");
11
- let TestPlugin = class TestPlugin {
12
- };
13
- exports.TestPlugin = TestPlugin;
14
- exports.TestPlugin = TestPlugin = __decorate([
15
- (0, core_1.VendurePlugin)({
16
- imports: [core_1.PluginCommonModule],
17
- dashboard: './dashboard/index.tsx',
18
- })
19
- ], TestPlugin);
20
- //# sourceMappingURL=reviews-plugin.js.map
@@ -1,8 +0,0 @@
1
- {
2
- "name": "test-plugin",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "scripts": {
6
- "build": "echo 'Building test-plugin'"
7
- }
8
- }
@@ -1,6 +0,0 @@
1
- {
2
- "type": "commonjs",
3
- "name": "npm-plugin",
4
- "version": "0.0.1",
5
- "main": "index.ts"
6
- }
@@ -1,18 +0,0 @@
1
- import { VendureConfig } from '@vendure/core';
2
- import { TestPlugin } from 'test-plugin';
3
-
4
- export const config: VendureConfig = {
5
- apiOptions: {
6
- port: 3000,
7
- },
8
- authOptions: {
9
- tokenMethod: 'bearer',
10
- },
11
- dbConnectionOptions: {
12
- type: 'postgres',
13
- },
14
- paymentOptions: {
15
- paymentMethodHandlers: [],
16
- },
17
- plugins: [TestPlugin],
18
- };
@@ -1 +0,0 @@
1
- export * from './src/js-aliased.plugin';
@@ -1,8 +0,0 @@
1
- import { PluginCommonModule, VendurePlugin } from '@vendure/core';
2
-
3
- @VendurePlugin({
4
- imports: [PluginCommonModule],
5
- providers: [],
6
- dashboard: './dashboard/index.tsx',
7
- })
8
- export class JsAliasedPlugin {}
@@ -1,6 +0,0 @@
1
- {
2
- "type": "commonjs",
3
- "name": "aliased-plugin",
4
- "version": "0.0.1",
5
- "main": "index.ts"
6
- }
@@ -1 +0,0 @@
1
- export * from './src/star-aliased.plugin';
@@ -1,8 +0,0 @@
1
- import { PluginCommonModule, VendurePlugin } from '@vendure/core';
2
-
3
- @VendurePlugin({
4
- imports: [PluginCommonModule],
5
- providers: [],
6
- dashboard: './dashboard/index.tsx',
7
- })
8
- export class StarAliasedPlugin {}
@@ -1 +0,0 @@
1
- export * from './src/ts-aliased.plugin';
@@ -1,8 +0,0 @@
1
- import { PluginCommonModule, VendurePlugin } from '@vendure/core';
2
-
3
- @VendurePlugin({
4
- imports: [PluginCommonModule],
5
- providers: [],
6
- dashboard: './dashboard/index.tsx',
7
- })
8
- export class TsAliasedPlugin {}
@@ -1,20 +0,0 @@
1
- import { JsAliasedPlugin } from '@other/js-aliased';
2
- import { TsAliasedPlugin } from '@other/ts-aliased';
3
- import { StarAliasedPlugin } from '@plugins/star-aliased';
4
- import { VendureConfig } from '@vendure/core';
5
-
6
- export const config: VendureConfig = {
7
- apiOptions: {
8
- port: 3000,
9
- },
10
- authOptions: {
11
- tokenMethod: 'bearer',
12
- },
13
- dbConnectionOptions: {
14
- type: 'postgres',
15
- },
16
- paymentOptions: {
17
- paymentMethodHandlers: [],
18
- },
19
- plugins: [StarAliasedPlugin, TsAliasedPlugin, JsAliasedPlugin],
20
- };
@@ -1,46 +0,0 @@
1
- import { rm } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import tsconfigPaths from 'tsconfig-paths';
4
- import { describe, expect, it } from 'vitest';
5
-
6
- import { compile } from '../utils/compiler.js';
7
- import { debugLogger, noopLogger } from '../utils/logger.js';
8
-
9
- describe('detecting plugins in npm packages', () => {
10
- it(
11
- 'should detect plugins in npm packages',
12
- async () => {
13
- const tempDir = join(__dirname, './__temp/npm-plugin');
14
- await rm(tempDir, { recursive: true, force: true });
15
- const fakeNodeModules = join(__dirname, 'fixtures-npm-plugin', 'fake_node_modules');
16
-
17
- // For this test to work, we need to use tsconfigPaths to point
18
- // the `test-plugin` package to the `fake_node_modules` directory.
19
- // This is because the `test-plugin` package is not installed in
20
- // the `node_modules` directory, but in the `fake_node_modules`
21
- // directory.
22
- tsconfigPaths.register({
23
- baseUrl: fakeNodeModules,
24
- paths: {
25
- 'test-plugin': [join(fakeNodeModules, 'test-plugin')],
26
- },
27
- });
28
-
29
- const result = await compile({
30
- outputPath: tempDir,
31
- vendureConfigPath: join(__dirname, 'fixtures-npm-plugin', 'vendure-config.ts'),
32
- logger: process.env.LOG ? debugLogger : noopLogger,
33
- pluginPackageScanner: {
34
- nodeModulesRoot: fakeNodeModules,
35
- },
36
- });
37
-
38
- expect(result.pluginInfo).toHaveLength(1);
39
- expect(result.pluginInfo[0].name).toBe('TestPlugin');
40
- expect(result.pluginInfo[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
41
- expect(result.pluginInfo[0].sourcePluginPath).toBeUndefined();
42
- expect(result.pluginInfo[0].pluginPath).toBe(join(fakeNodeModules, 'test-plugin', 'index.js'));
43
- },
44
- { timeout: 10_000 },
45
- );
46
- });
@@ -1,61 +0,0 @@
1
- import { rm } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { describe, expect, it } from 'vitest';
4
-
5
- import { compile } from '../utils/compiler.js';
6
- import { debugLogger, noopLogger } from '../utils/logger.js';
7
-
8
- describe('detecting plugins using tsconfig path aliases', () => {
9
- it(
10
- 'should detect plugins using tsconfig path aliases',
11
- async () => {
12
- const tempDir = join(__dirname, './__temp/path-alias');
13
- await rm(tempDir, { recursive: true, force: true });
14
-
15
- const result = await compile({
16
- outputPath: tempDir,
17
- vendureConfigPath: join(__dirname, 'fixtures-path-alias', 'vendure-config.ts'),
18
- logger: process.env.LOG ? debugLogger : noopLogger,
19
- pathAdapter: {
20
- transformTsConfigPathMappings: ({ phase, patterns }) => {
21
- if (phase === 'loading') {
22
- return patterns.map(pattern => {
23
- return pattern.replace(/\/fixtures-path-alias/, '').replace(/.ts$/, '.js');
24
- });
25
- } else {
26
- return patterns;
27
- }
28
- },
29
- },
30
- });
31
-
32
- const plugins = result.pluginInfo.sort((a, b) => a.name.localeCompare(b.name));
33
-
34
- expect(plugins).toHaveLength(3);
35
-
36
- expect(plugins[0].name).toBe('JsAliasedPlugin');
37
- expect(plugins[0].dashboardEntryPath).toBe('./dashboard/index.tsx');
38
- expect(plugins[0].sourcePluginPath).toBe(
39
- join(__dirname, 'fixtures-path-alias', 'js-aliased', 'src', 'js-aliased.plugin.ts'),
40
- );
41
- expect(plugins[0].pluginPath).toBe(join(tempDir, 'js-aliased', 'src', 'js-aliased.plugin.js'));
42
-
43
- expect(plugins[1].name).toBe('StarAliasedPlugin');
44
- expect(plugins[1].dashboardEntryPath).toBe('./dashboard/index.tsx');
45
- expect(plugins[1].sourcePluginPath).toBe(
46
- join(__dirname, 'fixtures-path-alias', 'star-aliased', 'src', 'star-aliased.plugin.ts'),
47
- );
48
- expect(plugins[1].pluginPath).toBe(
49
- join(tempDir, 'star-aliased', 'src', 'star-aliased.plugin.js'),
50
- );
51
-
52
- expect(plugins[2].name).toBe('TsAliasedPlugin');
53
- expect(plugins[2].dashboardEntryPath).toBe('./dashboard/index.tsx');
54
- expect(plugins[2].sourcePluginPath).toBe(
55
- join(__dirname, 'fixtures-path-alias', 'ts-aliased', 'src', 'ts-aliased.plugin.ts'),
56
- );
57
- expect(plugins[2].pluginPath).toBe(join(tempDir, 'ts-aliased', 'src', 'ts-aliased.plugin.js'));
58
- },
59
- { timeout: 10_000 },
60
- );
61
- });
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "NodeNext",
4
- "sourceMap": true,
5
- "jsx": "react-jsx",
6
- "paths": {
7
- "@plugins/*": [
8
- "./fixtures-path-alias/*"
9
- ],
10
- "@other/ts-aliased": [
11
- "./fixtures-path-alias/ts-aliased/index.ts"
12
- ],
13
- "@other/js-aliased": [
14
- "./fixtures-path-alias/js-aliased/index.js"
15
- ]
16
- }
17
- },
18
- "exclude": [
19
- "node_modules"
20
- ]
21
- }
package/vite/types.ts DELETED
@@ -1,44 +0,0 @@
1
- export type Logger = {
2
- info: (message: string) => void;
3
- warn: (message: string) => void;
4
- debug: (message: string) => void;
5
- error: (message: string) => void;
6
- };
7
-
8
- export type PluginInfo = {
9
- name: string;
10
- pluginPath: string;
11
- dashboardEntryPath: string | undefined;
12
- /** The original source path of the plugin, only set for local plugins that are compiled */
13
- sourcePluginPath?: string;
14
- };
15
-
16
- export type GetCompiledConfigPathFn = (params: {
17
- inputRootDir: string;
18
- outputPath: string;
19
- configFileName: string;
20
- }) => string;
21
-
22
- export type TransformTsConfigPathMappingsFn = (params: {
23
- phase: 'compiling' | 'loading';
24
- alias: string;
25
- patterns: string[];
26
- }) => string[];
27
-
28
- /**
29
- * @description
30
- * The PathAdapter interface allows customization of how paths are handled
31
- * when compiling the Vendure config and its imports.
32
- */
33
- export interface PathAdapter {
34
- /**
35
- * @description
36
- * A function to determine the path to the compiled Vendure config file.
37
- */
38
- getCompiledConfigPath?: GetCompiledConfigPathFn;
39
- /**
40
- * If your project makes use of the TypeScript `paths` configuration, the compiler will
41
- * attempt to use these paths when compiling the Vendure config and its imports.
42
- */
43
- transformTsConfigPathMappings?: TransformTsConfigPathMappingsFn;
44
- }
@@ -1,49 +0,0 @@
1
- import ts from 'typescript';
2
- import { describe, expect, it } from 'vitest';
3
-
4
- import { findConfigExport } from './ast-utils.js';
5
-
6
- describe('findConfigExport', () => {
7
- it('should return undefined when no VendureConfig export is found', () => {
8
- const sourceText = `
9
- export const notConfig = {
10
- some: 'value'
11
- };
12
- `;
13
- const sourceFile = ts.createSourceFile('path/to/test.ts', sourceText, ts.ScriptTarget.Latest, true);
14
- const result = findConfigExport(sourceFile);
15
- expect(result).toBeUndefined();
16
- });
17
-
18
- it('should find exported variable with VendureConfig type', () => {
19
- const sourceText = `
20
- import { VendureConfig } from '@vendure/core';
21
-
22
- export const config: VendureConfig = {
23
- authOptions: {
24
- tokenMethod: 'bearer'
25
- }
26
- };
27
- `;
28
- const sourceFile = ts.createSourceFile('path/to/test.ts', sourceText, ts.ScriptTarget.Latest, true);
29
- const result = findConfigExport(sourceFile);
30
- expect(result).toBe('config');
31
- });
32
-
33
- it('should find exported variable with VendureConfig type among other exports', () => {
34
- const sourceText = `
35
- import { VendureConfig } from '@vendure/core';
36
-
37
- export const otherExport = 'value';
38
- export const config: VendureConfig = {
39
- authOptions: {
40
- tokenMethod: 'bearer'
41
- }
42
- };
43
- export const anotherExport = 123;
44
- `;
45
- const sourceFile = ts.createSourceFile('path/to/test.ts', sourceText, ts.ScriptTarget.Latest, true);
46
- const result = findConfigExport(sourceFile);
47
- expect(result).toBe('config');
48
- });
49
- });
@@ -1,33 +0,0 @@
1
- import ts from 'typescript';
2
-
3
- /**
4
- * Given the AST of a TypeScript file, finds the name of the variable exported as VendureConfig.
5
- */
6
- export function findConfigExport(sourceFile: ts.SourceFile): string | undefined {
7
- let exportedSymbolName: string | undefined;
8
-
9
- function visit(node: ts.Node) {
10
- if (
11
- ts.isVariableStatement(node) &&
12
- node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword)
13
- ) {
14
- node.declarationList.declarations.forEach(declaration => {
15
- if (ts.isVariableDeclaration(declaration)) {
16
- const typeNode = declaration.type;
17
- if (typeNode && ts.isTypeReferenceNode(typeNode)) {
18
- const typeName = typeNode.typeName;
19
- if (ts.isIdentifier(typeName) && typeName.text === 'VendureConfig') {
20
- if (ts.isIdentifier(declaration.name)) {
21
- exportedSymbolName = declaration.name.text;
22
- }
23
- }
24
- }
25
- }
26
- });
27
- }
28
- ts.forEachChild(node, visit);
29
- }
30
-
31
- visit(sourceFile);
32
- return exportedSymbolName;
33
- }