@vueless/storybook 0.0.26 → 0.0.28

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 (2) hide show
  1. package/index.js +30 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,10 +1,14 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable no-console */
2
3
 
3
4
  import fs, { promises } from "fs";
4
5
  import path from "path";
5
6
 
6
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
7
+ // Get the command-line arguments
8
+ const args = process.argv.slice(2);
9
+ const parsedArgs = parseArgs(args);
7
10
 
11
+ const __dirname = path.dirname(new URL(import.meta.url).pathname);
8
12
  const source = path.join(__dirname, ".storybook");
9
13
  const target = path.join(process.cwd(), ".storybook");
10
14
 
@@ -12,7 +16,9 @@ copyStorybookPreset(source, target);
12
16
 
13
17
  await addStorybookCommands();
14
18
 
15
- await createNpmrc();
19
+ if (parsedArgs.pnpm) {
20
+ await createNpmrc();
21
+ }
16
22
 
17
23
  function copyStorybookPreset(source, target) {
18
24
  if (fs.existsSync(target)) {
@@ -43,7 +49,7 @@ async function addStorybookCommands() {
43
49
  const storybookCommands = {
44
50
  "sb:dev-full": "STORYBOOK_FULL=1 storybook dev -p 6006 --no-open",
45
51
  "sb:dev": "storybook dev -p 6006 --docs --no-open",
46
- "sb:build": "NO_PWA=1 storybook build --docs",
52
+ "sb:build": "storybook build --docs",
47
53
  "sb:preview": "vite preview --host --outDir=storybook-static",
48
54
  };
49
55
 
@@ -60,16 +66,32 @@ async function addStorybookCommands() {
60
66
  }
61
67
 
62
68
  async function createNpmrc() {
63
- const npmrcContent = `# @vueless/storybook: pnpm: disable hoisting for the package related modules.
64
- public-hoist-pattern[] = *storybook*
65
- public-hoist-pattern[] = prettier2v
66
- `;
69
+ const npmrcContent = [
70
+ "# @vueless/storybook: pnpm: disable hoisting for the package related modules.",
71
+ "public-hoist-pattern[] = *storybook*",
72
+ "public-hoist-pattern[] = prettier2",
73
+ ];
67
74
 
68
75
  const npmrcPath = path.join(process.cwd(), ".npmrc");
69
76
 
70
77
  try {
71
- await promises.writeFile(npmrcPath, npmrcContent);
78
+ await promises.writeFile(npmrcPath, npmrcContent.join("\n"));
72
79
  } catch (err) {
73
80
  console.error("Error writing .npmrc file:", err);
74
81
  }
75
82
  }
83
+
84
+ function parseArgs(args) {
85
+ const result = {};
86
+
87
+ args.forEach((arg) => {
88
+ if (arg.startsWith("--")) {
89
+ const [key, value] = arg.split("=");
90
+ const normalizedKey = key.substring(2);
91
+
92
+ result[normalizedKey] = value !== undefined ? value : true;
93
+ }
94
+ });
95
+
96
+ return result;
97
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/storybook",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
4
4
  "description": "Simplifies Storybook configuration for Vueless UI library.",
5
5
  "homepage": "https://vueless.com",
6
6
  "author": "Johnny Grid",