@knighted/jsx 1.6.0 → 1.6.1
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/cjs/cli/init.cjs +15 -0
- package/dist/cli/init.js +17 -0
- package/package.json +1 -1
package/dist/cjs/cli/init.cjs
CHANGED
|
@@ -165,6 +165,21 @@ function parsePackageName(spec) {
|
|
|
165
165
|
return { name, version };
|
|
166
166
|
}
|
|
167
167
|
function readLocalOxcParserVersion(resolver = CLI_REQUIRE) {
|
|
168
|
+
try {
|
|
169
|
+
// Prefer the version installed alongside this CLI package, not a hoisted sibling.
|
|
170
|
+
const jsxPkgPath = resolver.resolve('@knighted/jsx/package.json');
|
|
171
|
+
const jsxRoot = node_path_1.default.dirname(jsxPkgPath);
|
|
172
|
+
const localParserPkg = node_path_1.default.join(jsxRoot, 'node_modules', 'oxc-parser', 'package.json');
|
|
173
|
+
if (node_fs_1.default.existsSync(localParserPkg)) {
|
|
174
|
+
const pkgJson = JSON.parse(node_fs_1.default.readFileSync(localParserPkg, 'utf8'));
|
|
175
|
+
if (pkgJson && typeof pkgJson.version === 'string') {
|
|
176
|
+
return pkgJson.version;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// Ignore resolution failures and fall back below.
|
|
182
|
+
}
|
|
168
183
|
try {
|
|
169
184
|
const pkg = resolver('oxc-parser/package.json');
|
|
170
185
|
if (pkg && typeof pkg.version === 'string') {
|
package/dist/cli/init.js
CHANGED
|
@@ -143,6 +143,23 @@ function parsePackageName(spec) {
|
|
|
143
143
|
return { name, version };
|
|
144
144
|
}
|
|
145
145
|
function readLocalOxcParserVersion(resolver = CLI_REQUIRE) {
|
|
146
|
+
try {
|
|
147
|
+
const jsxPkgPath = resolver.resolve("@knighted/jsx/package.json");
|
|
148
|
+
const jsxRoot = path.dirname(jsxPkgPath);
|
|
149
|
+
const localParserPkg = path.join(
|
|
150
|
+
jsxRoot,
|
|
151
|
+
"node_modules",
|
|
152
|
+
"oxc-parser",
|
|
153
|
+
"package.json"
|
|
154
|
+
);
|
|
155
|
+
if (fs.existsSync(localParserPkg)) {
|
|
156
|
+
const pkgJson = JSON.parse(fs.readFileSync(localParserPkg, "utf8"));
|
|
157
|
+
if (pkgJson && typeof pkgJson.version === "string") {
|
|
158
|
+
return pkgJson.version;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
146
163
|
try {
|
|
147
164
|
const pkg = resolver("oxc-parser/package.json");
|
|
148
165
|
if (pkg && typeof pkg.version === "string") {
|