expose-kit 0.2.4 → 0.2.6
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/index.js +10 -5
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -131,6 +131,13 @@ import { parse as parse2 } from "@babel/parser";
|
|
|
131
131
|
import traverse from "@babel/traverse";
|
|
132
132
|
import generate from "@babel/generator";
|
|
133
133
|
import loading2 from "loading-cli";
|
|
134
|
+
|
|
135
|
+
// utils/babel/patchDefault.ts
|
|
136
|
+
var patchDefault = (babelFn) => {
|
|
137
|
+
return babelFn.default;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// commands/scope-safe/index.ts
|
|
134
141
|
var createDefaultOutputPath = (inputPath) => {
|
|
135
142
|
const ext = extname(inputPath);
|
|
136
143
|
if (!ext) {
|
|
@@ -142,7 +149,7 @@ var createDefaultOutputPath = (inputPath) => {
|
|
|
142
149
|
var renameBindingsByScope = (code, filename) => {
|
|
143
150
|
const ast = parse2(code, createParseOptions(filename));
|
|
144
151
|
const renamedBindings = /* @__PURE__ */ new Set();
|
|
145
|
-
traverse(ast, {
|
|
152
|
+
patchDefault(traverse)(ast, {
|
|
146
153
|
Scopable(path) {
|
|
147
154
|
for (const [name, binding] of Object.entries(path.scope.bindings)) {
|
|
148
155
|
if (renamedBindings.has(binding)) {
|
|
@@ -161,7 +168,7 @@ var renameBindingsByScope = (code, filename) => {
|
|
|
161
168
|
}
|
|
162
169
|
}
|
|
163
170
|
});
|
|
164
|
-
return generate(ast).code;
|
|
171
|
+
return patchDefault(generate)(ast).code;
|
|
165
172
|
};
|
|
166
173
|
var scope_safe_default = createCommand((program2) => {
|
|
167
174
|
program2.command("scope-safe").description("Rename bindings per scope for safer transforms").argument("[file]", "The file to transform").option("--input, --file <file>", "The file to transform").option("--o, --output <file>", "Output file path").option("--unlimited", "Unlimited timeout").action(
|
|
@@ -176,9 +183,7 @@ var scope_safe_default = createCommand((program2) => {
|
|
|
176
183
|
try {
|
|
177
184
|
const fileContent = readFileSync2(filename, "utf8");
|
|
178
185
|
const defaultOutputPath = createDefaultOutputPath(filename);
|
|
179
|
-
|
|
180
|
-
"Enter the output file path:"
|
|
181
|
-
) || "").trim() ?? defaultOutputPath;
|
|
186
|
+
const outputPath = options.output ?? (await createPrompt("Enter the output file path:") || "").trim() ?? defaultOutputPath;
|
|
182
187
|
const loader = loading2("Renaming variables by scope...").start();
|
|
183
188
|
try {
|
|
184
189
|
const output = renameBindingsByScope(fileContent, filename);
|
package/dist/package.json
CHANGED