webanvil 0.0.9 → 0.0.10

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.
@@ -1,9 +1,9 @@
1
- import { assertSyntaxTarget, loadConfig, resolveEffectiveBuildConfig, resolveRolldownPlugins, resolveVitePlugins, syntaxTargetSchema, withConfig } from "./config.mjs";
1
+ import { assertSyntaxTarget, hasOxcConfig, hasStorybookConfig, hasToolConfig, loadConfig, resolveEffectiveBuildConfig, resolveRolldownPlugins, resolveVitePlugins, syntaxTargetSchema, withConfig } from "./config.mjs";
2
2
  import { Module, createRequire, isBuiltin } from "node:module";
3
3
  import { defineArgument, defineCommand, defineOption } from "cmdore";
4
4
  import { dirname, isAbsolute, join, relative, resolve } from "pathe";
5
5
  import { glob } from "tinyglobby";
6
- import { access, copyFile, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, writeFile } from "node:fs/promises";
6
+ import { access, copyFile, lstat, mkdir, mkdtemp, readFile, realpath, rename, rm, rmdir, writeFile } from "node:fs/promises";
7
7
  import { z } from "zod";
8
8
  import { dirname as dirname$1, isAbsolute as isAbsolute$1, join as join$1, relative as relative$1, resolve as resolve$1 } from "node:path";
9
9
  import { getTsconfig, readTsconfig } from "get-tsconfig";
@@ -31,30 +31,6 @@ const paths = defineArgument({
31
31
  description: "Files or directories to check.",
32
32
  variadic: true
33
33
  });
34
- const hasFile = async (path) => access(path).then(() => true).catch(() => false);
35
- const hasToolConfig = async (name, cwd = process.cwd()) => {
36
- const files = await readdir(cwd).catch(() => []);
37
- return [
38
- "js",
39
- "mjs",
40
- "cjs",
41
- "ts",
42
- "mts",
43
- "cts"
44
- ].some((extension) => files.includes(`${name}.config.${extension}`));
45
- };
46
- const hasOxcConfig = (name, cwd = process.cwd()) => hasFile(join(cwd, name === "oxfmt" ? ".oxfmtrc.json" : ".oxlintrc.json"));
47
- const hasStorybookConfig = async (configDir = ".storybook", cwd = process.cwd()) => {
48
- const files = await readdir(resolve(cwd, configDir)).catch(() => []);
49
- return [
50
- "js",
51
- "mjs",
52
- "cjs",
53
- "ts",
54
- "mts",
55
- "cts"
56
- ].some((extension) => files.includes(`main.${extension}`));
57
- };
58
34
  const path = (cwd) => resolve(cwd, ".webanvil", "buildinfo.json");
59
35
  const relativeOutput = (file, cwd) => {
60
36
  const output = relative(cwd, resolve(cwd, file));
@@ -1,6 +1,32 @@
1
+ import { join, resolve } from "pathe";
2
+ import { access, readdir } from "node:fs/promises";
1
3
  import { loadConfig } from "c12";
2
4
  import { defu } from "defu";
3
5
  import { z } from "zod";
6
+ const hasFile = async (path) => access(path).then(() => true).catch(() => false);
7
+ const hasToolConfig = async (name, cwd = process.cwd()) => {
8
+ const files = await readdir(cwd).catch(() => []);
9
+ return [
10
+ "js",
11
+ "mjs",
12
+ "cjs",
13
+ "ts",
14
+ "mts",
15
+ "cts"
16
+ ].some((extension) => files.includes(`${name}.config.${extension}`));
17
+ };
18
+ const hasOxcConfig = (name, cwd = process.cwd()) => hasFile(join(cwd, name === "oxfmt" ? ".oxfmtrc.json" : ".oxlintrc.json"));
19
+ const hasStorybookConfig = async (configDir = ".storybook", cwd = process.cwd()) => {
20
+ const files = await readdir(resolve(cwd, configDir)).catch(() => []);
21
+ return [
22
+ "js",
23
+ "mjs",
24
+ "cjs",
25
+ "ts",
26
+ "mts",
27
+ "cts"
28
+ ].some((extension) => files.includes(`main.${extension}`));
29
+ };
4
30
  const NODE_PLUGIN_ERROR = "Node builds require plugins created with definePlugin()";
5
31
  const definePlugin = (plugin, options) => ({
6
32
  rolldown: () => plugin.rolldown(options),
@@ -137,4 +163,4 @@ const withConfig = (select, run) => async (arguments_, resolvedConfig) => {
137
163
  ...defined(arguments_)
138
164
  }, selectedConfig, config, arguments_);
139
165
  };
140
- export { assertSyntaxTarget, buildConfigSchema, copyMappingSchema, defaultConfig, defineConfig, definePlugin, effectiveUserConfigSchema, formatConfigSchema, isUnpluginAdapter, isWebAnvilPlugin, lintConfigSchema, loadConfig$1 as loadConfig, resolveEffectiveBuildConfig, resolveRolldownPlugins, resolveVitePlugins, rolldownConfigSchema, storybookConfigSchema, syntaxTargetSchema, testConfigSchema, userConfigSchema, viteConfigSchema, withConfig };
166
+ export { assertSyntaxTarget, buildConfigSchema, copyMappingSchema, defaultConfig, defineConfig, definePlugin, effectiveUserConfigSchema, formatConfigSchema, hasOxcConfig, hasStorybookConfig, hasToolConfig, isUnpluginAdapter, isWebAnvilPlugin, lintConfigSchema, loadConfig$1 as loadConfig, resolveEffectiveBuildConfig, resolveRolldownPlugins, resolveVitePlugins, rolldownConfigSchema, storybookConfigSchema, syntaxTargetSchema, testConfigSchema, userConfigSchema, viteConfigSchema, withConfig };
@@ -1,9 +1,11 @@
1
- import { loadConfig, resolveVitePlugins } from "./config.mjs";
2
- const withProjectVitePlugins = async (config) => {
1
+ import { hasToolConfig, loadConfig, resolveVitePlugins } from "./config.mjs";
2
+ import { resolve } from "node:path";
3
+ const withProjectVitePlugins = async (config, storybookConfigDirectory = ".storybook") => {
3
4
  const { config: webanvilConfig } = await loadConfig();
5
+ const plugins = [...resolveVitePlugins(webanvilConfig.plugins ?? []), ...await hasToolConfig("vite", resolve(storybookConfigDirectory, "..")) ? [] : webanvilConfig.vite?.plugins ?? []];
4
6
  return {
5
7
  ...config,
6
- plugins: [...resolveVitePlugins(webanvilConfig.plugins ?? []), ...config.plugins ?? []]
8
+ plugins: [...plugins, ...config.plugins ?? []]
7
9
  };
8
10
  };
9
11
  export { withProjectVitePlugins };
@@ -4,5 +4,5 @@ import { fileURLToPath } from "node:url";
4
4
  import { viteFinal as viteFinal$1 } from "@storybook/react-vite/preset";
5
5
  export * from "@storybook/react-vite/preset";
6
6
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
7
- const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0]), arguments_[1]);
7
+ const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0], arguments_[1]?.configDir), arguments_[1]);
8
8
  export { addons, viteFinal };
@@ -4,5 +4,5 @@ import { fileURLToPath } from "node:url";
4
4
  import { viteFinal as viteFinal$1 } from "@storybook/react-vite/preset";
5
5
  export * from "@storybook/react-vite/preset";
6
6
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
7
- const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0]), arguments_[1]);
7
+ const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0], arguments_[1]?.configDir), arguments_[1]);
8
8
  export { addons, viteFinal };
@@ -4,5 +4,5 @@ import { fileURLToPath } from "node:url";
4
4
  import { viteFinal as viteFinal$1 } from "@storybook/svelte-vite/preset";
5
5
  export * from "@storybook/svelte-vite/preset";
6
6
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
7
- const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0]), arguments_[1]);
7
+ const viteFinal = async (...arguments_) => withProjectVitePlugins(await viteFinal$1(arguments_[0], arguments_[1]), arguments_[1]?.configDir);
8
8
  export { addons, viteFinal };
@@ -4,5 +4,5 @@ import { fileURLToPath } from "node:url";
4
4
  import { viteFinal as viteFinal$1 } from "@storybook/svelte-vite/preset";
5
5
  export * from "@storybook/svelte-vite/preset";
6
6
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
7
- const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0]), arguments_[1]);
7
+ const viteFinal = async (...arguments_) => withProjectVitePlugins(await viteFinal$1(arguments_[0], arguments_[1]), arguments_[1]?.configDir);
8
8
  export { addons, viteFinal };
@@ -4,5 +4,5 @@ import { fileURLToPath } from "node:url";
4
4
  import { viteFinal as viteFinal$1 } from "@storybook/vue3-vite/preset";
5
5
  export * from "@storybook/vue3-vite/preset";
6
6
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
7
- const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0]), arguments_[1]);
7
+ const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0], arguments_[1]?.configDir), arguments_[1]);
8
8
  export { addons, viteFinal };
@@ -4,5 +4,5 @@ import { fileURLToPath } from "node:url";
4
4
  import { viteFinal as viteFinal$1 } from "@storybook/vue3-vite/preset";
5
5
  export * from "@storybook/vue3-vite/preset";
6
6
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
7
- const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0]), arguments_[1]);
7
+ const viteFinal = async (...arguments_) => viteFinal$1(await withProjectVitePlugins(arguments_[0], arguments_[1]?.configDir), arguments_[1]);
8
8
  export { addons, viteFinal };
@@ -3,5 +3,5 @@ import { resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  export * from "@storybook/web-components-vite/preset";
5
5
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
6
- const viteFinal = withProjectVitePlugins;
6
+ const viteFinal = async (config, options) => withProjectVitePlugins(config, options.configDir);
7
7
  export { addons, viteFinal };
@@ -1,4 +1,8 @@
1
+ import { InlineConfig } from "vite";
1
2
  export * from "@storybook/web-components-vite/preset";
3
+ declare const withProjectVitePlugins: (config: InlineConfig, storybookConfigDirectory?: string) => Promise<InlineConfig>;
2
4
  declare const addons: string[];
3
- declare const viteFinal: (config: import("vite").InlineConfig) => Promise<import("vite").InlineConfig>;
5
+ declare const viteFinal: (config: Parameters<typeof withProjectVitePlugins>[0], options: {
6
+ configDir?: string;
7
+ }) => Promise<import("vite").InlineConfig>;
4
8
  export { addons, viteFinal };
@@ -3,5 +3,5 @@ import { resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  export * from "@storybook/web-components-vite/preset";
5
5
  const addons = [resolve(fileURLToPath(new URL("..", import.meta.url)), "test")];
6
- const viteFinal = withProjectVitePlugins;
6
+ const viteFinal = async (config, options) => withProjectVitePlugins(config, options.configDir);
7
7
  export { addons, viteFinal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webanvil",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "A unified CLI for building, testing, linting, formatting, and type-checking JavaScript and TypeScript projects.",
5
5
  "keywords": [
6
6
  "build-tool",