vueless 0.0.646 → 0.0.647

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.
package/constants.js CHANGED
@@ -212,6 +212,7 @@ export const DEFAULT_SVGO_CONFIG = {
212
212
  /* Vueless general */
213
213
  export const ICONS_DIR = "assets/icons";
214
214
  export const VUELESS_LIBRARY = "vueless";
215
+ export const STORYBOOK_DIR = "storybook";
215
216
  export const VUELESS_CONFIG_FILE_NAME = "vueless.config";
216
217
  export const VUELESS_CACHE_DIR = "node_modules/.cache/vueless";
217
218
  export const VUELESS_DIR = `node_modules/${VUELESS_LIBRARY}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.646",
3
+ "version": "0.0.647",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
package/plugin-vite.js CHANGED
@@ -12,6 +12,7 @@ import { getNuxtFiles, getVueFiles } from "./utils/node/helper.js";
12
12
  import { componentResolver, directiveResolver } from "./utils/node/vuelessResolver.js";
13
13
  import { setCustomPropTypes, removeCustomPropTypes } from "./utils/node/dynamicProps.js";
14
14
  import { buildWebTypes } from "./utils/node/webTypes.js";
15
+ import { hideHiddenStories, showHiddenStories } from "./utils/node/dynamicStories.js";
15
16
 
16
17
  /* Automatically importing Vueless components on demand */
17
18
  export const VuelessUnpluginComponents = (options) =>
@@ -36,6 +37,8 @@ export const Vueless = function (options = {}) {
36
37
 
37
38
  /* if server stopped by developer (Ctrl+C) */
38
39
  process.on("SIGINT", async () => {
40
+ await showHiddenStories(isVuelessEnv);
41
+
39
42
  await removeCustomPropTypes(isVuelessEnv);
40
43
 
41
44
  /* remove cached icons */
@@ -68,7 +71,9 @@ export const Vueless = function (options = {}) {
68
71
  }
69
72
 
70
73
  if ((config.command.includes("sb:") && mode === "storybook") || isVuelessEnv) {
74
+ await showHiddenStories(isVuelessEnv);
71
75
  await buildWebTypes();
76
+ await hideHiddenStories(isVuelessEnv);
72
77
  }
73
78
 
74
79
  if (config.command === "build") {
@@ -11,20 +11,19 @@ const CLOSING_BRACKET = "}";
11
11
  const IGNORE_PROP = "@ignore";
12
12
  const CUSTOM_PROP = "@custom";
13
13
 
14
- const VUELESS_SRC = path.join(VUELESS_DIR, VUELESS_LOCAL_DIR);
15
-
16
14
  const PROPS_INTERFACE_REG_EXP = /export\s+interface\s+Props\s*{([^}]*)}/s;
17
15
  const UNION_SYMBOLS_REG_EXP = /[?|:"|;]/g;
18
16
  const WORD_IN_QUOTE_REG_EXP = /"([^"]+)"/g;
19
17
 
20
18
  export async function setCustomPropTypes(isVuelessEnv) {
21
- const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_SRC;
19
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
22
20
 
23
21
  for await (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
24
- const customProps =
25
- componentName in vuelessConfig.component && vuelessConfig.component[componentName].props;
22
+ const componentGlobalConfig = vuelessConfig.component[componentName];
23
+ const customProps = componentGlobalConfig && componentGlobalConfig.props;
24
+ const isHiddenStories = componentGlobalConfig && componentGlobalConfig.storybook === false;
26
25
 
27
- if (customProps) {
26
+ if (customProps && !isHiddenStories) {
28
27
  await cacheComponentTypes(path.join(srcDir, componentDir));
29
28
  await modifyComponentTypes(
30
29
  path.join(srcDir, componentDir),
@@ -35,7 +34,7 @@ export async function setCustomPropTypes(isVuelessEnv) {
35
34
  }
36
35
 
37
36
  export async function removeCustomPropTypes(isVuelessEnv) {
38
- const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_SRC;
37
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
39
38
 
40
39
  for await (const componentDir of Object.values(COMPONENTS)) {
41
40
  await restoreComponentTypes(path.join(srcDir, componentDir));
@@ -0,0 +1,65 @@
1
+ import path from "node:path";
2
+ import { existsSync } from "node:fs";
3
+ import { cwd } from "node:process";
4
+ import { rename, readdir } from "node:fs/promises";
5
+
6
+ import { vuelessConfig } from "./vuelessConfig.js";
7
+ import { COMPONENTS, VUELESS_DIR, VUELESS_LOCAL_DIR, STORYBOOK_DIR } from "../../constants.js";
8
+
9
+ async function hideComponentStories(storybookPath) {
10
+ if (existsSync(storybookPath)) {
11
+ const storyFiles = await readdir(storybookPath);
12
+ const visibleFiles = storyFiles.filter((storybookFile) => !storybookFile.includes("hidden"));
13
+
14
+ await Promise.all(
15
+ visibleFiles.map((storybookFile) => {
16
+ const [fileName, extension] = storybookFile.split(".");
17
+
18
+ return rename(
19
+ path.join(storybookPath, storybookFile),
20
+ path.join(storybookPath, `${fileName}_hidden.${extension}`),
21
+ );
22
+ }),
23
+ );
24
+ }
25
+ }
26
+
27
+ async function showComponentStories(storybookPath) {
28
+ if (existsSync(storybookPath)) {
29
+ const storyFiles = await readdir(storybookPath);
30
+ const hiddenFiles = storyFiles.filter((storybookFile) => storybookFile.includes("hidden"));
31
+
32
+ await Promise.all(
33
+ hiddenFiles.map((storybookFile) => {
34
+ const [fileName, extension] = storybookFile.split(".");
35
+ const [originalFileName] = fileName.split("_");
36
+
37
+ return rename(
38
+ path.join(storybookPath, storybookFile),
39
+ path.join(storybookPath, `${originalFileName}.${extension}`),
40
+ );
41
+ }),
42
+ );
43
+ }
44
+ }
45
+
46
+ export async function hideHiddenStories(isVuelessEnv) {
47
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
48
+
49
+ for await (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
50
+ const componentGlobalConfig = vuelessConfig.component[componentName];
51
+ const isHiddenStories = componentGlobalConfig && componentGlobalConfig.storybook === false;
52
+
53
+ if (isHiddenStories) {
54
+ await hideComponentStories(path.join(cwd(), srcDir, componentDir, STORYBOOK_DIR));
55
+ }
56
+ }
57
+ }
58
+
59
+ export async function showHiddenStories(isVuelessEnv) {
60
+ const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
61
+
62
+ for await (const componentDir of Object.values(COMPONENTS)) {
63
+ await showComponentStories(path.join(cwd(), srcDir, componentDir, STORYBOOK_DIR));
64
+ }
65
+ }