vibe-design-system 2.5.26 → 2.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-design-system",
3
- "version": "2.5.26",
3
+ "version": "2.5.28",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -144,31 +144,34 @@ function injectProviderDecorators(projectRoot) {
144
144
 
145
145
  if (providersToAdd.length > 0) {
146
146
  let content = fs.readFileSync(previewPath, "utf-8");
147
- const alreadyHas = providersToAdd.every((p) => content.includes(p.name));
148
- if (!alreadyHas) {
149
- const importLines = [...new Map(providersToAdd.map((p) => [p.name, p])).values()]
150
- .map((p) => `import { ${p.name} } from "${p.importPath}";`)
151
- .join("\n");
152
- const lastImportIdx = content.search(/\nimport\s+.+?;\s*$/m);
153
- const insertAt = lastImportIdx >= 0 ? content.indexOf("\n", lastImportIdx) + 1 : content.indexOf("\n") + 1;
154
- content = content.slice(0, insertAt) + importLines + "\n" + content.slice(insertAt);
147
+ const uniqueProviders = [...new Map(providersToAdd.map((p) => [p.name, p])).values()];
148
+ if (!content.includes("import React") && !content.includes("import React from")) {
149
+ const firstImport = content.match(/^import\s+/m);
150
+ const insertAt = firstImport ? content.indexOf(firstImport[0]) : 0;
151
+ content = content.slice(0, insertAt) + "import React from \"react\";\n" + content.slice(insertAt);
155
152
  }
156
- if (!content.includes("withProviders")) {
157
- if (!content.includes("import React")) {
158
- const firstImport = content.match(/^import\s+/m);
159
- const insertAt = firstImport ? content.indexOf(firstImport[0]) : 0;
160
- content = content.slice(0, insertAt) + "import React from \"react\";\n" + content.slice(insertAt);
153
+ for (const p of uniqueProviders) {
154
+ if (!content.includes(p.name)) {
155
+ const lastImportIdx = content.search(/\nimport\s+.+?;\s*$/m);
156
+ const insertAt = lastImportIdx >= 0 ? content.indexOf("\n", lastImportIdx) + 1 : content.indexOf("\n") + 1;
157
+ content = content.slice(0, insertAt) + `import { ${p.name} } from "${p.importPath}";\n` + content.slice(insertAt);
161
158
  }
162
- const withProvidersCode = buildWithProvidersCode(providersToAdd);
163
- content = content.replace(/(\s*)(export default preview;?)/, withProvidersCode + "\n\n$1$2");
159
+ }
160
+ content = content.replace(/const withProviders\s*=\s*\([^)]*\)\s*=>\s*[\s\S]+?;\s*\n?/g, "").replace(/\n{3,}/g, "\n\n");
161
+ const withProvidersCode = buildWithProvidersCode(providersToAdd);
162
+ const insertBefore = content.indexOf("const preview");
163
+ if (insertBefore !== -1) {
164
+ content = content.slice(0, insertBefore) + withProvidersCode + "\n\n" + content.slice(insertBefore);
164
165
  if (content.includes("decorators:")) {
165
- content = content.replace(/decorators:\s*\[/, "decorators: [withProviders, ");
166
+ if (!content.includes("decorators: [withProviders")) {
167
+ content = content.replace(/decorators:\s*\[/, "decorators: [withProviders, ");
168
+ }
166
169
  } else {
167
170
  content = content.replace(/(const preview\s*[^=]*=\s*\{\s*)/, "$1\n decorators: [withProviders],\n ");
168
171
  }
169
172
  }
170
173
  fs.writeFileSync(previewPath, content, "utf-8");
171
- console.log("[VDS] Storybook preview: added " + providersToAdd.map((p) => p.name).join(", "));
174
+ console.log("[VDS] Storybook preview: " + uniqueProviders.map((p) => p.name).join(", "));
172
175
  }
173
176
 
174
177
  if (hooksWithoutProvider.size > 0) {