Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"commander": "^12.1.0",
"debug": "^4.4.0",
"env-paths": "^2.2.0",
"fs-extra": "^11.2.0",
"fs-extra": "^11.3.4",
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
"kleur": "^4.1.5",
"native-run": "^2.0.3",
"open": "^8.4.0",
Expand Down
26 changes: 24 additions & 2 deletions cli/src/util/spm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ensureDir,
ensureSymlink,
pathExists,
existsSync,
Expand All @@ -7,10 +8,13 @@ import {
remove,
move,
mkdtemp,
realpath,
lstat,
readlink,
readdirSync,
} from 'fs-extra';
import { tmpdir } from 'os';
import { join, relative, resolve } from 'path';
import { basename, dirname, join, relative, resolve } from 'path';
import type { PlistObject } from 'plist';
import { build, parse } from 'plist';
import { extract } from 'tar';
Expand Down Expand Up @@ -159,7 +163,25 @@ let package = Package(
? symlinkFolder
: convertToUnixPath(relative(spmDirectory, getPluginReferencePath(config, plugin)));
if (symlink) {
await ensureSymlink(plugin.rootPath, resolve(config.ios.nativeProjectDirAbs, 'CapApp-SPM', symlinkFolder));
const linkPath = resolve(config.ios.nativeProjectDirAbs, 'CapApp-SPM', symlinkFolder);
await ensureDir(dirname(linkPath));
const realLinkDir = await realpath(dirname(linkPath));
const relativePluginPath = relative(realLinkDir, getPluginReferencePath(config, plugin));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new symlink branch has no test coverage. Add a case in plugin-paths.spec.ts for a missing symlinks/ directory, an existing correct link, and a stale link with a different target.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At cli/src/util/spm.ts, line 169:

<comment>The new `symlink` branch has no test coverage. Add a case in plugin-paths.spec.ts for a missing `symlinks/` directory, an existing correct link, and a stale link with a different target.</comment>

<file context>
@@ -160,8 +164,24 @@ let package = Package(
-        await ensureSymlink(relativePluginPath, linkPath);
+        await ensureDir(dirname(linkPath));
+        const realLinkDir = await realpath(dirname(linkPath));
+        const relativePluginPath = relative(realLinkDir, getPluginReferencePath(config, plugin));
+        const destLink = join(realLinkDir, basename(linkPath));
+        const existingTarget = await readlink(destLink).catch(() => undefined);
</file context>

const destLink = join(realLinkDir, basename(linkPath));
const existingTarget = await readlink(destLink).catch(() => undefined);
if (existingTarget !== relativePluginPath) {
if (existingTarget !== undefined) {
await remove(destLink);
} else if (existsSync(destLink)) {
const destStat = await lstat(destLink);
if (destStat.isSymbolicLink()) {
await remove(destLink);
} else {
fatal(`Cannot create SPM plugin symlink at ${destLink}: path exists and is not a symlink`);
}
}
await ensureSymlink(relativePluginPath, destLink);
}
}
const traits = packageTraits[plugin.id];
const traitsSuffix = traits?.length
Expand Down
Loading