@vueless/storybook 0.0.56 → 0.0.58

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/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable no-console */
3
3
 
4
4
  import fs, { promises } from "fs";
5
+ import { cwd } from "node:process";
5
6
  import path from "path";
6
7
 
7
8
  // Get the command-line arguments
@@ -10,7 +11,7 @@ const parsedArgs = parseArgs(args);
10
11
 
11
12
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
12
13
  const source = path.join(__dirname, ".storybook");
13
- const target = path.join(process.cwd(), ".storybook");
14
+ const target = path.join(cwd(), ".storybook");
14
15
 
15
16
  copyStorybookPreset(source, target);
16
17
 
@@ -53,7 +54,7 @@ async function addStorybookCommands() {
53
54
  "sb:preview": "vite preview --host --outDir=storybook-static",
54
55
  };
55
56
 
56
- const packageJsonPath = path.resolve(process.cwd(), "package.json");
57
+ const packageJsonPath = path.resolve(cwd(), "package.json");
57
58
  const data = await promises.readFile(packageJsonPath, "utf8");
58
59
  const packageJson = JSON.parse(data);
59
60
 
@@ -72,7 +73,7 @@ async function createNpmrc() {
72
73
  "public-hoist-pattern[] = prettier2",
73
74
  ];
74
75
 
75
- const npmrcPath = path.join(process.cwd(), ".npmrc");
76
+ const npmrcPath = path.join(cwd(), ".npmrc");
76
77
 
77
78
  try {
78
79
  await promises.writeFile(npmrcPath, npmrcContent.join("\n"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/storybook",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "description": "Simplifies Storybook configuration for Vueless UI library.",
5
5
  "homepage": "https://vueless.com",
6
6
  "author": "Johnny Grid",
@@ -38,7 +38,6 @@
38
38
  "chokidar": "^4.0.3",
39
39
  "esbuild": "^0.24.2",
40
40
  "globby": "^14.0.2",
41
- "minimist": "^1.2.8",
42
41
  "mkdirp": "^3.0.1",
43
42
  "prettier2": "npm:prettier@2.8.8",
44
43
  "storybook": "^8.4.7",
package/webTypes/index.js CHANGED
@@ -1,19 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import minimist from "minimist";
3
2
  import { extractConfig } from "./lib/config.js";
4
3
  import build from "./lib/build.js";
5
4
 
6
- const {
7
- _: pathArray,
8
- configFile,
9
- watch,
10
- cwd,
11
- } = minimist(process.argv.slice(2), {
12
- alias: { c: "configFile", w: "watch" },
13
- });
14
-
15
5
  export default async function buildWebTypes(vuelessConfig) {
16
- const conf = await extractConfig(cwd || process.cwd(), watch, configFile, pathArray);
6
+ const config = await extractConfig();
17
7
 
18
- build(conf, vuelessConfig);
8
+ build(config, vuelessConfig);
19
9
  }
@@ -8,10 +8,9 @@ import { parse } from "vue-docgen-api";
8
8
  import _ from "lodash-es";
9
9
 
10
10
  export default async function build(config, vuelessConfig) {
11
- config.componentsRoot = path.resolve(config.cwd, config.componentsRoot);
12
11
  config.outFile = path.resolve(config.cwd, config.outFile);
13
12
 
14
- const { watcher, componentFiles } = getSources(config.components, config.componentsRoot);
13
+ const { watcher, componentFiles } = getSources(config.components, config.cwd);
15
14
 
16
15
  const cache = {};
17
16
  const buildWebTypesBound = rebuild.bind(null, config, componentFiles, cache, vuelessConfig);
@@ -26,20 +25,7 @@ export default async function build(config, vuelessConfig) {
26
25
  return;
27
26
  }
28
27
 
29
- if (config.watch) {
30
- watcher
31
- .on("add", buildWebTypesBound)
32
- .on("change", buildWebTypesBound)
33
- .on("unlink", async (filePath) => {
34
- // eslint-disable-next-line no-console
35
- console.log("Rebuilding on file removal " + filePath);
36
-
37
- delete cache[filePath];
38
- await writeDownWebTypesFile(config, Object.values(cache), config.outFile);
39
- });
40
- } else {
41
- await watcher.close();
42
- }
28
+ await watcher.close();
43
29
  }
44
30
 
45
31
  function getSources(components, cwd) {
@@ -1,29 +1,25 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { cwd } from "node:process";
3
4
  import { readFile } from "fs/promises";
4
5
  import esbuild from "esbuild";
5
6
 
6
7
  const CACHE_PATH = "./node_modules/.cache/vueless";
7
8
  const WEB_TYPES_CONFIG_FILE_NAME = "web-types.config";
8
9
 
9
- export async function extractConfig(cwd, watch = false, configFileFromCmd) {
10
- const fileContent = await readFile(path.join(cwd, "package.json"), "utf-8");
10
+ export async function extractConfig() {
11
+ const fileContent = await readFile(path.join(cwd(), "package.json"), "utf-8");
11
12
  const packageJson = JSON.parse(fileContent);
12
13
 
13
- const config = await getConfig(configFileFromCmd);
14
+ const config = await getConfig();
14
15
 
15
16
  const components = config?.isVuelessEnv
16
- ? [`${process.cwd()}/src/**/*.vue`]
17
- : [
18
- `${process.cwd()}/node_modules/vueless/**/*.vue`,
19
- `${process.cwd()}/src/components/**/*.vue`,
20
- ];
17
+ ? ["src/**/*.vue"]
18
+ : ["node_modules/vueless/**/*.vue", "src/components/**/*.vue"];
21
19
 
22
20
  return {
23
- cwd,
24
- watch,
21
+ cwd: cwd(),
25
22
  components,
26
- componentsRoot: cwd,
27
23
  outFile: `${CACHE_PATH}/web-types.json`,
28
24
  packageName: packageJson["name"],
29
25
  packageVersion: packageJson["version"],
@@ -33,11 +29,10 @@ export async function extractConfig(cwd, watch = false, configFileFromCmd) {
33
29
  };
34
30
  }
35
31
 
36
- async function getConfig(configFromCmd) {
37
- const configPathFromCmd = configFromCmd && path.resolve(process.cwd(), configFromCmd);
38
- const configPathJs = path.resolve(process.cwd(), `${WEB_TYPES_CONFIG_FILE_NAME}.js`);
39
- const configPathTs = path.resolve(process.cwd(), `${WEB_TYPES_CONFIG_FILE_NAME}.ts`);
40
- const configOutPath = path.join(process.cwd(), `${CACHE_PATH}/${WEB_TYPES_CONFIG_FILE_NAME}.mjs`);
32
+ async function getConfig() {
33
+ const configPathJs = path.resolve(cwd(), `${WEB_TYPES_CONFIG_FILE_NAME}.js`);
34
+ const configPathTs = path.resolve(cwd(), `${WEB_TYPES_CONFIG_FILE_NAME}.ts`);
35
+ const configOutPath = path.join(cwd(), `${CACHE_PATH}/${WEB_TYPES_CONFIG_FILE_NAME}.mjs`);
41
36
 
42
37
  let config = {};
43
38
 
@@ -47,7 +42,6 @@ async function getConfig(configFromCmd) {
47
42
 
48
43
  fs.existsSync(configPathJs) && (await buildConfig(configPathJs, configOutPath));
49
44
  fs.existsSync(configPathTs) && (await buildConfig(configPathTs, configOutPath));
50
- fs.existsSync(configPathFromCmd) && (await buildConfig(configPathFromCmd, configPathFromCmd));
51
45
 
52
46
  if (fs.existsSync(configOutPath)) {
53
47
  config = (await import(configOutPath)).default;