zudoku 0.1.1-dev.20 → 0.1.1-dev.22

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 (131) hide show
  1. package/dist/cli/common/logger.js +3 -1
  2. package/dist/cli/common/logger.js.map +1 -1
  3. package/dist/cli/common/outdated.js +4 -4
  4. package/dist/cli/common/outdated.js.map +1 -1
  5. package/dist/cli/common/output.js +4 -4
  6. package/dist/cli/common/output.js.map +1 -1
  7. package/dist/cli/common/utils/box.js +2 -2
  8. package/dist/cli/common/utils/box.js.map +1 -1
  9. package/dist/config/config.d.ts +1 -0
  10. package/dist/lib/authentication/clerk.d.ts +2 -1
  11. package/dist/lib/authentication/clerk.js +2 -1
  12. package/dist/lib/authentication/clerk.js.map +1 -1
  13. package/dist/lib/{DevPortal.d.ts → components/DevPortal.d.ts} +5 -5
  14. package/dist/lib/{DevPortal.js → components/DevPortal.js} +7 -7
  15. package/dist/lib/components/DevPortal.js.map +1 -0
  16. package/dist/lib/{Heading.js → components/Heading.js} +2 -2
  17. package/dist/lib/components/Heading.js.map +1 -0
  18. package/dist/lib/components/Link.d.ts +1 -0
  19. package/dist/lib/components/Link.js +2 -0
  20. package/dist/lib/components/Link.js.map +1 -0
  21. package/dist/lib/{Router.d.ts → components/Router.d.ts} +1 -1
  22. package/dist/lib/{Router.js → components/Router.js} +2 -2
  23. package/dist/lib/components/Router.js.map +1 -0
  24. package/dist/lib/components/index.d.ts +3 -0
  25. package/dist/lib/components/index.js +4 -0
  26. package/dist/lib/components/index.js.map +1 -0
  27. package/dist/lib/core/DevPortalContext.d.ts +1 -1
  28. package/dist/lib/core/DevPortalContext.js.map +1 -1
  29. package/dist/lib/plugins/api-key/index.js +1 -1
  30. package/dist/lib/plugins/api-key/index.js.map +1 -1
  31. package/dist/lib/plugins/index.d.ts +4 -0
  32. package/dist/lib/plugins/index.js +6 -0
  33. package/dist/lib/plugins/index.js.map +1 -0
  34. package/dist/lib/plugins/markdown/MdxPage.js +1 -1
  35. package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
  36. package/dist/lib/plugins/markdown/generateRoutes.js +1 -1
  37. package/dist/lib/plugins/markdown/generateRoutes.js.map +1 -1
  38. package/dist/lib/plugins/openapi/OperationList.js +2 -2
  39. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  40. package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
  41. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  42. package/dist/lib/plugins/openapi/ParameterList.js +1 -1
  43. package/dist/lib/plugins/openapi/ParameterList.js.map +1 -1
  44. package/dist/lib/plugins/openapi/index.js +1 -1
  45. package/dist/lib/plugins/openapi/index.js.map +1 -1
  46. package/dist/lib/plugins/openapi-worker.d.ts +1 -0
  47. package/dist/lib/plugins/openapi-worker.js +2 -0
  48. package/dist/lib/plugins/openapi-worker.js.map +1 -0
  49. package/dist/lib/ui/Button.d.ts +1 -1
  50. package/dist/lib/util/MdxComponents.js +1 -1
  51. package/dist/lib/util/MdxComponents.js.map +1 -1
  52. package/dist/vite/config.js +16 -12
  53. package/dist/vite/config.js.map +1 -1
  54. package/dist/vite/plugin-auth.js +2 -2
  55. package/dist/vite/plugin-auth.js.map +1 -1
  56. package/dist/vite/plugin-component.d.ts +2 -1
  57. package/dist/vite/plugin-component.js +14 -5
  58. package/dist/vite/plugin-component.js.map +1 -1
  59. package/lib/{DevPortal-DqcnbwLT.js → DevPortal-ChiyAyW7.js} +7348 -7347
  60. package/lib/{zudoku.auth.js → zudoku.auth-clerk.js} +6 -8
  61. package/lib/zudoku.components.js +1 -1
  62. package/lib/zudoku.plugins.js +2 -2
  63. package/package.json +11 -11
  64. package/src/lib/authentication/clerk.ts +3 -5
  65. package/src/lib/{DevPortal.tsx → components/DevPortal.tsx} +16 -13
  66. package/src/lib/{Heading.tsx → components/Heading.tsx} +2 -2
  67. package/src/lib/components/Link.tsx +1 -0
  68. package/src/lib/{Router.tsx → components/Router.tsx} +2 -2
  69. package/src/lib/components/index.ts +3 -0
  70. package/src/lib/core/DevPortalContext.ts +4 -1
  71. package/src/lib/plugins/api-key/index.tsx +1 -1
  72. package/src/lib/plugins/index.ts +5 -0
  73. package/src/lib/plugins/markdown/MdxPage.tsx +1 -1
  74. package/src/lib/plugins/markdown/generateRoutes.tsx +1 -1
  75. package/src/lib/plugins/openapi/OperationList.tsx +3 -3
  76. package/src/lib/plugins/openapi/OperationListItem.tsx +1 -1
  77. package/src/lib/plugins/openapi/ParameterList.tsx +1 -1
  78. package/src/lib/plugins/openapi/index.tsx +1 -1
  79. package/src/lib/plugins/openapi-worker.ts +1 -0
  80. package/src/lib/util/MdxComponents.tsx +1 -1
  81. package/dist/lib/DevPortal.js.map +0 -1
  82. package/dist/lib/Heading.js.map +0 -1
  83. package/dist/lib/Router.js.map +0 -1
  84. package/dist/lib/auth.d.ts +0 -1
  85. package/dist/lib/auth.js +0 -2
  86. package/dist/lib/auth.js.map +0 -1
  87. package/dist/lib/components.d.ts +0 -3
  88. package/dist/lib/components.js +0 -4
  89. package/dist/lib/components.js.map +0 -1
  90. package/dist/lib/plugins.d.ts +0 -4
  91. package/dist/lib/plugins.js +0 -6
  92. package/dist/lib/plugins.js.map +0 -1
  93. package/src/cli/build/handler.ts +0 -14
  94. package/src/cli/cli.ts +0 -77
  95. package/src/cli/cmds/build.ts +0 -24
  96. package/src/cli/cmds/dev.ts +0 -29
  97. package/src/cli/common/analytics/lib.ts +0 -89
  98. package/src/cli/common/constants.ts +0 -10
  99. package/src/cli/common/logger.ts +0 -5
  100. package/src/cli/common/machine-id/lib.ts +0 -85
  101. package/src/cli/common/outdated.ts +0 -102
  102. package/src/cli/common/output.ts +0 -86
  103. package/src/cli/common/utils/box.license.txt +0 -202
  104. package/src/cli/common/utils/box.ts +0 -116
  105. package/src/cli/common/utils/ports.ts +0 -21
  106. package/src/cli/common/validators/lib.ts +0 -43
  107. package/src/cli/common/xdg/lib.ts +0 -36
  108. package/src/cli/dev/handler.ts +0 -42
  109. package/src/config/config.ts +0 -56
  110. package/src/index.ts +0 -8
  111. package/src/lib/auth.ts +0 -1
  112. package/src/lib/components.ts +0 -3
  113. package/src/lib/plugins.ts +0 -5
  114. package/src/ts.ts +0 -94
  115. package/src/types.d.ts +0 -24
  116. package/src/vite/build.ts +0 -33
  117. package/src/vite/config.test.ts +0 -10
  118. package/src/vite/config.ts +0 -183
  119. package/src/vite/dev-server.ts +0 -64
  120. package/src/vite/html.ts +0 -37
  121. package/src/vite/plugin-api.ts +0 -57
  122. package/src/vite/plugin-auth.ts +0 -32
  123. package/src/vite/plugin-component.ts +0 -26
  124. package/src/vite/plugin-config.ts +0 -31
  125. package/src/vite/plugin-docs.test.ts +0 -32
  126. package/src/vite/plugin-docs.ts +0 -52
  127. package/src/vite/plugin-html.ts +0 -50
  128. package/src/vite/plugin-mdx.ts +0 -74
  129. package/src/vite/plugin-metadata.ts +0 -30
  130. package/src/vite/plugin.ts +0 -23
  131. /package/dist/lib/{Heading.d.ts → components/Heading.d.ts} +0 -0
@@ -1,32 +0,0 @@
1
- import { PluginOption } from "vite";
2
- import { ZudokuPluginOptions } from "../config/config.js";
3
- import { getConfigExportCode } from "./plugin-config.js";
4
-
5
- const viteAuthPlugin = (config: ZudokuPluginOptions): PluginOption => {
6
- const virtualModuleId = "virtual:zudoku-auth";
7
- const resolvedVirtualModuleId = "\0" + virtualModuleId;
8
-
9
- return {
10
- name: "zudoku-auth-plugin", // required, will show up in warnings and errors
11
- resolveId(id) {
12
- if (id === virtualModuleId) {
13
- return resolvedVirtualModuleId;
14
- }
15
- },
16
- load(id) {
17
- if (id === resolvedVirtualModuleId) {
18
- if (!config.authentication) {
19
- return `export const configuredAuthProvider = undefined;`;
20
- }
21
- // TODO: Validate that the authConfig.type is a valid authentication provider
22
- return [
23
- getConfigExportCode(config.rootDir),
24
- `import { clerkAuth } from "zudoku/auth";`,
25
- `export const configuredAuthProvider = clerkAuth(config.authentication);`,
26
- ].join("\n");
27
- }
28
- },
29
- };
30
- };
31
-
32
- export default viteAuthPlugin;
@@ -1,26 +0,0 @@
1
- import { PluginOption } from "vite";
2
-
3
- const viteComponentPlugin = (): PluginOption => {
4
- const virtualModuleId = "virtual:zudoku-component";
5
- const resolvedVirtualModuleId = "\0" + virtualModuleId;
6
-
7
- return {
8
- name: "zudoku-component-plugin",
9
- resolveId(id) {
10
- if (id === virtualModuleId) {
11
- return resolvedVirtualModuleId;
12
- }
13
- },
14
- load(id) {
15
- if (id === resolvedVirtualModuleId) {
16
- const code: string[] = [
17
- `export { DevPortal } from "zudoku/components";`,
18
- ];
19
-
20
- return code.join("\n");
21
- }
22
- },
23
- };
24
- };
25
-
26
- export default viteComponentPlugin;
@@ -1,31 +0,0 @@
1
- import path from "path";
2
- import { PluginOption } from "vite";
3
-
4
- export function getConfigExportCode(rootDir: string) {
5
- const configPath = path.join(
6
- rootDir,
7
- `/node_modules/.zudoku/zudoku.config.mjs`,
8
- );
9
- return `import config from "${configPath}"; export default config;`;
10
- }
11
-
12
- const viteConfigPlugin = ({ rootDir }: { rootDir: string }): PluginOption => {
13
- const virtualModuleId = "virtual:zudoku-config";
14
- const resolvedVirtualModuleId = "\0" + virtualModuleId;
15
-
16
- return {
17
- name: "zudoku-config-plugin",
18
- resolveId(id) {
19
- if (id === virtualModuleId) {
20
- return resolvedVirtualModuleId;
21
- }
22
- },
23
- load(id) {
24
- if (id === resolvedVirtualModuleId) {
25
- return getConfigExportCode(rootDir);
26
- }
27
- },
28
- };
29
- };
30
-
31
- export default viteConfigPlugin;
@@ -1,32 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import assert from "node:assert";
3
- import test from "node:test";
4
- import { checkTypescriptString } from "../ts.js";
5
- import viteDocsPlugin from "./plugin-docs.js";
6
-
7
- test.only("Builds code", async (t) => {
8
- const plugin = viteDocsPlugin({
9
- docs: { files: "docs/**/*.md" },
10
- } as any);
11
- if (!plugin.load) {
12
- throw new Error("Plugin does not have a load function");
13
- }
14
- if (typeof plugin.load !== "function") {
15
- throw new Error("Plugin.load is not a function");
16
- }
17
-
18
- const result = await plugin.load.call(
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- {} as any,
21
- "\0virtual:markdown-plugins",
22
- );
23
- if (result && typeof result === "object" && "code" in result) {
24
- const diagnostics = await checkTypescriptString(result.code);
25
- if (diagnostics.length > 0) {
26
- console.error(diagnostics);
27
- }
28
- assert.equal(diagnostics.length, 0);
29
- } else {
30
- assert.fail("Invalid return value from plugin.load");
31
- }
32
- });
@@ -1,52 +0,0 @@
1
- import { Plugin } from "vite";
2
- import { DocsConfig, ZudokuPluginOptions } from "../config/config.js";
3
-
4
- const viteDocsPlugin = (config: ZudokuPluginOptions): Plugin => {
5
- const virtualModuleId = "virtual:zudoku-docs-plugins";
6
- const resolvedVirtualModuleId = "\0" + virtualModuleId;
7
-
8
- return {
9
- name: "vite-zudoku-docs-plugin",
10
- resolveId(id) {
11
- if (id === virtualModuleId) {
12
- return resolvedVirtualModuleId;
13
- }
14
- },
15
- load(id) {
16
- if (id === resolvedVirtualModuleId) {
17
- const code: string[] = [
18
- // IMPORTANT! This path here is important, we MUST resolve
19
- // files here as Typescript from the appDir
20
- `import { markdownPlugin } from "zudoku/plugins";`,
21
- `const configuredDocsPlugins = [];`,
22
- ];
23
- const docsConfigs: DocsConfig[] = config?.docs
24
- ? Array.isArray(config.docs)
25
- ? config.docs
26
- : [config.docs]
27
- : [];
28
-
29
- docsConfigs.forEach((docsConfig) => {
30
- code.push(
31
- ...[
32
- `// @ts-ignore`, // To make tests pass
33
- `const markdownFiles = import.meta.glob(${JSON.stringify(docsConfig.files)}, {`,
34
- ` eager: false,`,
35
- `});`,
36
- `configuredDocsPlugins.push(markdownPlugin({ markdownFiles }));`,
37
- ],
38
- );
39
- });
40
-
41
- code.push(`export { configuredDocsPlugins };`);
42
-
43
- return {
44
- code: code.join("\n"),
45
- map: null,
46
- };
47
- }
48
- },
49
- };
50
- };
51
-
52
- export default viteDocsPlugin;
@@ -1,50 +0,0 @@
1
- import { Plugin } from "vite";
2
-
3
- const themeScript = `
4
- if (
5
- localStorage.getItem("theme") === "dark" ||
6
- (!("theme" in localStorage) &&
7
- window.matchMedia("(prefers-color-scheme: dark)").matches)
8
- ) {
9
- document.documentElement.classList.add("dark");
10
- } else {
11
- document.documentElement.classList.remove("dark");
12
- }
13
- `.trim();
14
-
15
- const viteHtmlPlugin = (): Plugin => {
16
- return {
17
- name: "vite-zudoku-core-plugin",
18
- transformIndexHtml: (html) => {
19
- return {
20
- html,
21
- tags: [
22
- {
23
- tag: "script",
24
- attrs: { type: "module" },
25
- children: themeScript,
26
- injectTo: "head",
27
- },
28
- {
29
- tag: "link",
30
- attrs: {
31
- rel: "preconnect",
32
- href: "https://cdn.zuplo.com/",
33
- },
34
- injectTo: "head",
35
- },
36
- {
37
- tag: "link",
38
- attrs: {
39
- rel: "stylesheet",
40
- href: "https://cdn.zuplo.com/static/fonts/geist.css",
41
- },
42
- injectTo: "head",
43
- },
44
- ],
45
- };
46
- },
47
- };
48
- };
49
-
50
- export default viteHtmlPlugin;
@@ -1,74 +0,0 @@
1
- import rehypeMetaAsAttributes from "@lekoarts/rehype-meta-as-attributes";
2
- import mdx, { type Options } from "@mdx-js/rollup";
3
- import withToc from "@stefanprobst/rehype-extract-toc";
4
- import withTocExport from "@stefanprobst/rehype-extract-toc/mdx";
5
- import path from "node:path";
6
- import rehypeSlug from "rehype-slug";
7
- import remarkComment from "remark-comment";
8
- import remarkDirective from "remark-directive";
9
- import remarkDirectiveRehype from "remark-directive-rehype";
10
- import remarkFrontmatter from "remark-frontmatter";
11
- import remarkGfm from "remark-gfm";
12
- import remarkMdxFrontmatter from "remark-mdx-frontmatter";
13
- import { visit } from "unist-util-visit";
14
- import { Plugin } from "vite";
15
-
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- const rehypeCodeBlockPlugin = () => (tree: any) => {
18
- visit(tree, "element", (node, index, parent) => {
19
- if (node.tagName === "code") {
20
- node.properties.inline = `${parent?.tagName !== "pre"}`;
21
- }
22
- });
23
- };
24
-
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- const remarkLinkRewritePlugin = () => (tree: any) => {
27
- visit(tree, "link", (node) => {
28
- if (!node.url) return;
29
-
30
- if (!node.url.startsWith("http") && !node.url.startsWith("/")) {
31
- node.url = path.join("../", node.url);
32
- }
33
-
34
- node.url = node.url.replace(/\.mdx?(#.*?)?/, "$1");
35
- });
36
- };
37
-
38
- export type DevPortalPluginOptions = {
39
- remarkPlugins?: Options["remarkPlugins"];
40
- rehypePlugins?: Options["rehypePlugins"];
41
- };
42
-
43
- const viteMdxPlugin = ({
44
- remarkPlugins,
45
- rehypePlugins,
46
- }: DevPortalPluginOptions = {}): Plugin => {
47
- return {
48
- enforce: "pre",
49
- ...mdx({
50
- providerImportSource: "@mdx-js/react",
51
- remarkPlugins: [
52
- remarkComment,
53
- remarkGfm,
54
- remarkFrontmatter,
55
- remarkMdxFrontmatter,
56
- remarkDirective,
57
- remarkDirectiveRehype,
58
- remarkLinkRewritePlugin,
59
- ...(remarkPlugins ?? []),
60
- ],
61
- rehypePlugins: [
62
- rehypeSlug,
63
- rehypeCodeBlockPlugin,
64
- rehypeMetaAsAttributes,
65
- withToc,
66
- withTocExport,
67
- ...(rehypePlugins ?? []),
68
- ],
69
- }),
70
- name: "vite-zudoku-mdx-plugin",
71
- };
72
- };
73
-
74
- export default viteMdxPlugin;
@@ -1,30 +0,0 @@
1
- import { writeFileSync } from "node:fs";
2
- import path from "node:path";
3
- import { Plugin } from "vite";
4
-
5
- /**
6
- * Used for debugging, writes metadata to build.
7
- */
8
- const viteBuildMetadata = (): Plugin => {
9
- return {
10
- name: "vite-zudoku-build-metadata-plugin",
11
- buildEnd() {
12
- const deps = [];
13
- for (const id of this.getModuleIds()) {
14
- const m = this.getModuleInfo(id);
15
- if (m != null && !m.isExternal) {
16
- for (const target of m.importedIds) {
17
- deps.push({ source: m.id, target });
18
- }
19
- }
20
- }
21
-
22
- writeFileSync(
23
- path.join(__dirname, "graph.json"),
24
- JSON.stringify(deps, null, 2),
25
- );
26
- },
27
- };
28
- };
29
-
30
- export default viteBuildMetadata;
@@ -1,23 +0,0 @@
1
- import react from "@vitejs/plugin-react";
2
- import { type PluginOption } from "vite";
3
- import { ZudokuPluginOptions } from "../config/config.js";
4
- import viteApiPlugin from "./plugin-api.js";
5
- import viteAuthPlugin from "./plugin-auth.js";
6
- import viteConfigPlugin from "./plugin-config.js";
7
- import viteDocsPlugin from "./plugin-docs.js";
8
- import viteHtmlPlugin from "./plugin-html.js";
9
- import viteMdxPlugin from "./plugin-mdx.js";
10
-
11
- export default function vitePlugin(
12
- config: ZudokuPluginOptions,
13
- ): PluginOption[] {
14
- return [
15
- viteMdxPlugin(config.build),
16
- react({ include: /\.(mdx?|jsx?|tsx?)$/ }),
17
- viteHtmlPlugin(),
18
- viteConfigPlugin(config),
19
- viteAuthPlugin(config),
20
- viteDocsPlugin(config),
21
- viteApiPlugin(config),
22
- ];
23
- }