zudoku 0.1.1-dev.20 → 0.1.1-dev.21

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 (48) hide show
  1. package/dist/cli/common/outdated.js +4 -4
  2. package/dist/cli/common/outdated.js.map +1 -1
  3. package/dist/cli/common/output.js +4 -4
  4. package/dist/cli/common/output.js.map +1 -1
  5. package/dist/cli/common/utils/box.js +2 -2
  6. package/dist/cli/common/utils/box.js.map +1 -1
  7. package/dist/config/config.d.ts +1 -0
  8. package/dist/vite/config.js +15 -5
  9. package/dist/vite/config.js.map +1 -1
  10. package/dist/vite/plugin-component.d.ts +2 -1
  11. package/dist/vite/plugin-component.js +14 -5
  12. package/dist/vite/plugin-component.js.map +1 -1
  13. package/package.json +6 -6
  14. package/src/cli/build/handler.ts +0 -14
  15. package/src/cli/cli.ts +0 -77
  16. package/src/cli/cmds/build.ts +0 -24
  17. package/src/cli/cmds/dev.ts +0 -29
  18. package/src/cli/common/analytics/lib.ts +0 -89
  19. package/src/cli/common/constants.ts +0 -10
  20. package/src/cli/common/logger.ts +0 -5
  21. package/src/cli/common/machine-id/lib.ts +0 -85
  22. package/src/cli/common/outdated.ts +0 -102
  23. package/src/cli/common/output.ts +0 -86
  24. package/src/cli/common/utils/box.license.txt +0 -202
  25. package/src/cli/common/utils/box.ts +0 -116
  26. package/src/cli/common/utils/ports.ts +0 -21
  27. package/src/cli/common/validators/lib.ts +0 -43
  28. package/src/cli/common/xdg/lib.ts +0 -36
  29. package/src/cli/dev/handler.ts +0 -42
  30. package/src/config/config.ts +0 -56
  31. package/src/index.ts +0 -8
  32. package/src/ts.ts +0 -94
  33. package/src/types.d.ts +0 -24
  34. package/src/vite/build.ts +0 -33
  35. package/src/vite/config.test.ts +0 -10
  36. package/src/vite/config.ts +0 -183
  37. package/src/vite/dev-server.ts +0 -64
  38. package/src/vite/html.ts +0 -37
  39. package/src/vite/plugin-api.ts +0 -57
  40. package/src/vite/plugin-auth.ts +0 -32
  41. package/src/vite/plugin-component.ts +0 -26
  42. package/src/vite/plugin-config.ts +0 -31
  43. package/src/vite/plugin-docs.test.ts +0 -32
  44. package/src/vite/plugin-docs.ts +0 -52
  45. package/src/vite/plugin-html.ts +0 -50
  46. package/src/vite/plugin-mdx.ts +0 -74
  47. package/src/vite/plugin-metadata.ts +0 -30
  48. package/src/vite/plugin.ts +0 -23
@@ -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
- }