wyvrnpm 2.21.1 → 2.21.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/bin/wyvrnpm.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  'use strict';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wyvrnpm",
3
- "version": "2.21.1",
3
+ "version": "2.21.2",
4
4
  "description": "A simple, static-hosting-compatible C++ package manager",
5
5
  "keywords": [
6
6
  "c++",
@@ -122,11 +122,21 @@ function registerGlobal(manifestPath, argv) {
122
122
  /**
123
123
  * Link a package into the current project's wyvrn_internal directory.
124
124
  *
125
+ * The junction always points at `sourcePath` (the install tree, so the
126
+ * consumer's `find_package(<name> CONFIG)` resolves). The wyvrn.lock entry,
127
+ * however, records `manifestPath` when given — the package's source root, which
128
+ * carries wyvrn.json. The install tree carries no manifest, so without this the
129
+ * resolver can't read the dep's declared options or transitive deps. The two
130
+ * are deliberately decoupled: link against the build output, resolve metadata
131
+ * from the source.
132
+ *
125
133
  * @param {string} name - Package name to link.
126
- * @param {string} sourcePath - Source directory path (absolute or relative).
134
+ * @param {string} sourcePath - Junction target (install tree, absolute or relative).
127
135
  * @param {string} rootDir - Project root directory.
136
+ * @param {string} [manifestPath] - Source root recorded in the lock for manifest
137
+ * resolution. Defaults to `sourcePath` when omitted (direct-path links).
128
138
  */
129
- function linkToProject(name, sourcePath, rootDir) {
139
+ function linkToProject(name, sourcePath, rootDir, manifestPath = null) {
130
140
  const absoluteSource = path.resolve(sourcePath);
131
141
 
132
142
  if (!fs.existsSync(absoluteSource)) {
@@ -144,6 +154,11 @@ function linkToProject(name, sourcePath, rootDir) {
144
154
  const versionFile = path.join(linkPath, '.wyvrn-version');
145
155
  fs.writeFileSync(versionFile, 'linked', 'utf8');
146
156
 
157
+ // Record the manifest location in the lock — the source root when known (it
158
+ // carries wyvrn.json), else the junction target. Decoupled from the junction
159
+ // so the resolver reads metadata from source while CMake links the build.
160
+ const lockTarget = manifestPath ? path.resolve(manifestPath) : absoluteSource;
161
+
147
162
  // Update the lock file to record the link
148
163
  const lockPath = path.join(rootDir, 'wyvrn.lock');
149
164
  let lockData = { packages: {} };
@@ -155,11 +170,14 @@ function linkToProject(name, sourcePath, rootDir) {
155
170
  }
156
171
  }
157
172
  lockData.packages = lockData.packages || {};
158
- lockData.packages[name] = `linked:${absoluteSource}`;
173
+ lockData.packages[name] = `linked:${lockTarget}`;
159
174
  lockData.generatedAt = new Date().toISOString();
160
175
  fs.writeFileSync(lockPath, JSON.stringify(lockData, null, 2) + '\n', 'utf8');
161
176
 
162
- log.info(`Linked: ${name} → ${absoluteSource}`);
177
+ log.info(
178
+ `Linked: ${name} → ${absoluteSource}` +
179
+ (lockTarget !== absoluteSource ? ` (manifest: ${lockTarget})` : ''),
180
+ );
163
181
  }
164
182
 
165
183
  /**
@@ -348,7 +366,10 @@ async function link(argv) {
348
366
  effectivePath = getEffectivePath(entry);
349
367
  }
350
368
 
351
- linkToProject(argv.name, effectivePath, rootDir);
369
+ // entry.path is the package's source root (where wyvrn.json was read at
370
+ // registration) — record it as the lock's manifest path while the junction
371
+ // targets the install tree (effectivePath).
372
+ linkToProject(argv.name, effectivePath, rootDir, entry.path);
352
373
  }
353
374
 
354
375
  /**
package/src/resolve.js CHANGED
@@ -50,6 +50,33 @@ function readLocalManifest(packagePath) {
50
50
  return null;
51
51
  }
52
52
 
53
+ /**
54
+ * Resolve a linked package's source-root (manifest) directory from the global
55
+ * link registry.
56
+ *
57
+ * A consumer's wyvrn.lock records a linked dep as `linked:<path>`. Since the
58
+ * link-install-dir change, `<path>` is the package's install tree
59
+ * (`build/wyvrn-<profile>/install`), which carries no wyvrn.json — only built
60
+ * headers/libs/CMake config. When the manifest can't be read from the lock
61
+ * path, this returns the source root recorded in `config.linkedPackages[name]`,
62
+ * where wyvrn.json actually lives, so the resolver can still read the dep's
63
+ * declared options + transitive deps. Returns null when the package isn't in
64
+ * the registry (e.g. a direct-path `wyvrnpm link <name> <path>`).
65
+ *
66
+ * @param {string} name
67
+ * @returns {string|null}
68
+ */
69
+ function linkedRegistrySourcePath(name) {
70
+ try {
71
+ const { readConfig } = require('./config');
72
+ const entry = readConfig().linkedPackages?.[name];
73
+ if (!entry) return null;
74
+ return typeof entry === 'string' ? entry : (entry.path ?? null);
75
+ } catch {
76
+ return null;
77
+ }
78
+ }
79
+
53
80
  /**
54
81
  * Compares two version strings of the form "major.minor.patch.build".
55
82
  * Each missing component is treated as 0.
@@ -447,8 +474,22 @@ async function resolveDependencies(
447
474
  // Handle linked packages: read local manifest instead of fetching from remote
448
475
  let manifest;
449
476
  if (isLinkedVersion(version)) {
450
- const localPath = getLinkedPath(version);
477
+ let localPath = getLinkedPath(version);
451
478
  manifest = readLocalManifest(localPath);
479
+ if (!manifest) {
480
+ // The lock path may be the install tree (no wyvrn.json). Fall back to
481
+ // the package's source root from the global link registry, where the
482
+ // manifest lives — so declared options + transitive deps still resolve
483
+ // without re-linking.
484
+ const sourceRoot = linkedRegistrySourcePath(name);
485
+ if (sourceRoot && sourceRoot !== localPath) {
486
+ const fromSource = readLocalManifest(sourceRoot);
487
+ if (fromSource) {
488
+ manifest = fromSource;
489
+ localPath = sourceRoot;
490
+ }
491
+ }
492
+ }
452
493
  if (manifest) {
453
494
  log.info(`Linked: ${name} → ${localPath}`);
454
495
  } else {