@perma-tools/cli 0.0.1 → 0.0.2
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/dist/actions.js +18 -7
- package/package.json +1 -1
package/dist/actions.js
CHANGED
|
@@ -85,19 +85,30 @@ export class ActionExecutor {
|
|
|
85
85
|
console.log(`⚠️ Provider ${action.providerWrapper} já existe, pulando...`);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
// Estratégia simples: encontrar {children} com sua indentação e wrappear
|
|
89
88
|
if (!content.includes("{children}")) {
|
|
90
89
|
throw new Error("Não foi possível encontrar '{children}' no arquivo");
|
|
91
90
|
}
|
|
92
|
-
//
|
|
91
|
+
// Estratégia 1: {children} sozinho em sua própria linha (formato multi-linha)
|
|
93
92
|
const childrenLineRegex = /^(\s*)(\{children\})$/m;
|
|
94
93
|
const match = content.match(childrenLineRegex);
|
|
95
|
-
if (
|
|
96
|
-
|
|
94
|
+
if (match) {
|
|
95
|
+
const indent = match[1];
|
|
96
|
+
content = content.replace(childrenLineRegex, `${indent}<${action.providerWrapper}>\n${indent} {children}\n${indent}</${action.providerWrapper}>`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// Estratégia 2: <>{children}</> ou <Tag>{children}</Tag> (formato inline)
|
|
100
|
+
const fragmentRegex = /<>({\s*children\s*})<\/>/;
|
|
101
|
+
const wrapperRegex = /<(\w+)>({\s*children\s*})<\/\1>/;
|
|
102
|
+
if (fragmentRegex.test(content)) {
|
|
103
|
+
content = content.replace(fragmentRegex, `<${action.providerWrapper}>$1</${action.providerWrapper}>`);
|
|
104
|
+
}
|
|
105
|
+
else if (wrapperRegex.test(content)) {
|
|
106
|
+
content = content.replace(wrapperRegex, `<${action.providerWrapper}><$1>$2</$1></${action.providerWrapper}>`);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw new Error("Não foi possível encontrar {children} em sua própria linha ou em formato <>{children}</>");
|
|
110
|
+
}
|
|
97
111
|
}
|
|
98
|
-
const indent = match[1]; // indentação atual de {children}
|
|
99
|
-
// Substituir {children} com provider ao redor, mantendo indentação consistente
|
|
100
|
-
content = content.replace(childrenLineRegex, `${indent}<${action.providerWrapper}>\n${indent} {children}\n${indent}</${action.providerWrapper}>`);
|
|
101
112
|
await writeFile(providersPath, content, "utf-8");
|
|
102
113
|
console.log(`✅ Provider injetado: ${action.providerWrapper}`);
|
|
103
114
|
}
|
package/package.json
CHANGED