vibe-design-system 2.5.26 → 2.5.27
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
|
@@ -153,14 +153,24 @@ function injectProviderDecorators(projectRoot) {
|
|
|
153
153
|
const insertAt = lastImportIdx >= 0 ? content.indexOf("\n", lastImportIdx) + 1 : content.indexOf("\n") + 1;
|
|
154
154
|
content = content.slice(0, insertAt) + importLines + "\n" + content.slice(insertAt);
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
const withProvidersCode = buildWithProvidersCode(providersToAdd);
|
|
157
|
+
const idxPreview = content.indexOf("const preview");
|
|
158
|
+
const idxWithProviders = content.indexOf("const withProviders");
|
|
159
|
+
const wrongOrder = idxWithProviders !== -1 && idxPreview !== -1 && idxWithProviders > idxPreview;
|
|
160
|
+
if (wrongOrder) {
|
|
161
|
+
const blockMatch = content.match(/const withProviders\s*=[\s\S]+?;\s*\n/);
|
|
162
|
+
if (blockMatch) {
|
|
163
|
+
const block = blockMatch[0].trim();
|
|
164
|
+
content = content.replace(blockMatch[0], "").replace(/\n{3,}/g, "\n\n");
|
|
165
|
+
content = content.replace(/(\s*)(const preview\s*[^=]*=\s*\{)/, block + "\n\n$1$2");
|
|
166
|
+
}
|
|
167
|
+
} else if (!content.includes("withProviders")) {
|
|
157
168
|
if (!content.includes("import React")) {
|
|
158
169
|
const firstImport = content.match(/^import\s+/m);
|
|
159
170
|
const insertAt = firstImport ? content.indexOf(firstImport[0]) : 0;
|
|
160
171
|
content = content.slice(0, insertAt) + "import React from \"react\";\n" + content.slice(insertAt);
|
|
161
172
|
}
|
|
162
|
-
const withProvidersCode
|
|
163
|
-
content = content.replace(/(\s*)(export default preview;?)/, withProvidersCode + "\n\n$1$2");
|
|
173
|
+
content = content.replace(/(\s*)(const preview\s*[^=]*=\s*\{)/, withProvidersCode + "\n\n$1$2");
|
|
164
174
|
if (content.includes("decorators:")) {
|
|
165
175
|
content = content.replace(/decorators:\s*\[/, "decorators: [withProviders, ");
|
|
166
176
|
} else {
|
|
@@ -168,7 +178,7 @@ function injectProviderDecorators(projectRoot) {
|
|
|
168
178
|
}
|
|
169
179
|
}
|
|
170
180
|
fs.writeFileSync(previewPath, content, "utf-8");
|
|
171
|
-
console.log("[VDS] Storybook preview: added " + providersToAdd.map((p) => p.name).join(", "));
|
|
181
|
+
console.log("[VDS] Storybook preview: " + (wrongOrder ? "fixed withProviders order." : "added " + providersToAdd.map((p) => p.name).join(", ")));
|
|
172
182
|
}
|
|
173
183
|
|
|
174
184
|
if (hooksWithoutProvider.size > 0) {
|