proto-plugin 0.1.6 → 0.1.8

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": "proto-plugin",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
@@ -1,4 +1,4 @@
1
- import { readFileSync, lstatSync } from "fs";
1
+ import { readFileSync } from "fs";
2
2
  import { join } from "path";
3
3
 
4
4
  import { NextResponse } from "next/server";
@@ -42,33 +42,27 @@ export function isNewerVersion(latest: string, installed: string): boolean {
42
42
  return false;
43
43
  }
44
44
 
45
+ function readIsWorkspaceDependency(cwd: string): boolean {
46
+ try {
47
+ const hostPkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8")) as {
48
+ dependencies?: Record<string, string>;
49
+ devDependencies?: Record<string, string>;
50
+ };
51
+ const depSpec =
52
+ hostPkg.dependencies?.[PACKAGE_NAME] ??
53
+ hostPkg.devDependencies?.[PACKAGE_NAME];
54
+ return depSpec?.startsWith("workspace:") ?? false;
55
+ } catch {
56
+ return false;
57
+ }
58
+ }
59
+
45
60
  function readInstalledVersion(cwd: string): {
46
61
  installed: string | null;
47
62
  isWorkspaceLink: boolean;
48
63
  } {
49
64
  const packagePath = join(cwd, "node_modules", PACKAGE_NAME, "package.json");
50
- const linkPath = join(cwd, "node_modules", PACKAGE_NAME);
51
-
52
- let isWorkspaceLink = false;
53
-
54
- try {
55
- isWorkspaceLink = lstatSync(linkPath).isSymbolicLink();
56
- } catch {
57
- try {
58
- const hostPkg = JSON.parse(
59
- readFileSync(join(cwd, "package.json"), "utf8"),
60
- ) as {
61
- dependencies?: Record<string, string>;
62
- devDependencies?: Record<string, string>;
63
- };
64
- const depSpec =
65
- hostPkg.dependencies?.[PACKAGE_NAME] ??
66
- hostPkg.devDependencies?.[PACKAGE_NAME];
67
- isWorkspaceLink = depSpec?.startsWith("workspace:") ?? false;
68
- } catch {
69
- // Ignore — treat as non-workspace.
70
- }
71
- }
65
+ const isWorkspaceLink = readIsWorkspaceDependency(cwd);
72
66
 
73
67
  try {
74
68
  const pkg = JSON.parse(readFileSync(packagePath, "utf8")) as { version?: string };