fyn 3.1.8 → 3.1.9

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/index.mjs CHANGED
@@ -40,4 +40,7 @@ export const run = async (...args) => (await load()).run(...args);
40
40
  */
41
41
  export const fun = async (...args) => (await load()).fun(...args);
42
42
 
43
- export default { run, fun };
43
+ /** Resolve the generated audit report path using fyn's installation configuration. */
44
+ export const getAuditFilePath = async (...args) => (await load()).getAuditFilePath(...args);
45
+
46
+ export default { run, fun, getAuditFilePath };
package/dist/fyn.mjs CHANGED
@@ -1624,7 +1624,7 @@ var AveAzul = class AveAzul extends Promise {
1624
1624
  * @returns Promise that resolves after the delay
1625
1625
  */
1626
1626
  delay(ms) {
1627
- return delay$1(ms);
1627
+ return this.then((value) => AveAzul.delay(ms, value));
1628
1628
  }
1629
1629
  /**
1630
1630
  * Bluebird-style timeout() method
@@ -1662,8 +1662,8 @@ var AveAzul = class AveAzul extends Promise {
1662
1662
  * @returns Promise that maintains the rejection
1663
1663
  */
1664
1664
  tapCatch(fn) {
1665
- return this.catch((err) => {
1666
- fn(err);
1665
+ return this.catch(async (err) => {
1666
+ await fn(err);
1667
1667
  throw err;
1668
1668
  });
1669
1669
  }
@@ -1703,7 +1703,9 @@ var AveAzul = class AveAzul extends Promise {
1703
1703
  * @returns Promise that rejects with the given reason
1704
1704
  */
1705
1705
  throw(reason) {
1706
- return AveAzul.reject(reason);
1706
+ return this.then(() => {
1707
+ throw reason;
1708
+ });
1707
1709
  }
1708
1710
  /**
1709
1711
  * Bluebird-style catchThrow() that catches an error and throws a new one
@@ -1756,6 +1758,8 @@ var AveAzul = class AveAzul extends Promise {
1756
1758
  });
1757
1759
  }
1758
1760
  some(count) {
1761
+ if ((count | 0) !== count || count < 0) return AveAzul.reject(/* @__PURE__ */ new TypeError("expecting a non-negative integer"));
1762
+ if (count === 0) return AveAzul.resolve([]);
1759
1763
  return this.then((args) => {
1760
1764
  const arr = toArray$1(args);
1761
1765
  return new AveAzul((resolve, reject) => {
@@ -1763,6 +1767,10 @@ var AveAzul = class AveAzul extends Promise {
1763
1767
  const results = [];
1764
1768
  const len = arr.length;
1765
1769
  let settled = false;
1770
+ if (count > len) {
1771
+ settled = true;
1772
+ reject(/* @__PURE__ */ new RangeError(`Input array must contain at least ${count} items but contains only ${len} items`));
1773
+ }
1766
1774
  const addDone = (result) => {
1767
1775
  if (settled) return;
1768
1776
  results.push(result);
@@ -2054,7 +2062,7 @@ AveAzul.OperationalError = OperationalError;
2054
2062
  AveAzul.isOperationalError = isOperationalError;
2055
2063
  AveAzul.isProgrammerError = isProgrammerError;
2056
2064
  AveAzul.Disposer = Disposer;
2057
- addStaticAny(AveAzul);
2065
+ addStaticAny(AveAzul, true);
2058
2066
  setupNotImplemented(AveAzul);
2059
2067
 
2060
2068
  //#endregion
@@ -91926,6 +91934,7 @@ var hard_link_dir_exports = /* @__PURE__ */ __exportAll({
91926
91934
  link: () => link$1,
91927
91935
  linkFile: () => linkFile,
91928
91936
  linkSym1: () => linkSym1,
91937
+ localLinkNeedsRefresh: () => localLinkNeedsRefresh,
91929
91938
  unlinkDest: () => unlinkDest
91930
91939
  });
91931
91940
  var import_lib$4 = /* @__PURE__ */ __toESM(require_lib$36(), 1);
@@ -92194,10 +92203,15 @@ async function handleSourceMap({ file, destFiles, src, dest, srcFp, destFp, sour
92194
92203
  * @param {*} dest
92195
92204
  * @param {*} sym1
92196
92205
  */
92197
- async function linkPackTree({ tree, src, dest, sym1, sourceMaps, isRoot = false }) {
92206
+ async function linkPackTree({ tree, src, dest, sym1, sourceMaps, preserveInstall = false, isRoot = false }) {
92198
92207
  const files = tree[SYM_FILES];
92199
92208
  const destFiles = await prepDestDir(dest);
92209
+ if (isRoot && preserveInstall) {
92210
+ destFiles["package.json"] = true;
92211
+ destFiles["node_modules"] = true;
92212
+ }
92200
92213
  for (const file of files) {
92214
+ if (isRoot && preserveInstall && file === "package.json") continue;
92201
92215
  if (!import_ci_info.isCI && file.match(/\.(js|mjs)\.map$/)) continue;
92202
92216
  destFiles[file] = true;
92203
92217
  const srcFp = Path.join(src, file);
@@ -92221,6 +92235,7 @@ async function linkPackTree({ tree, src, dest, sym1, sourceMaps, isRoot = false
92221
92235
  }
92222
92236
  const dirs = Object.keys(tree).sort();
92223
92237
  for (const dir of dirs) {
92238
+ if (isRoot && preserveInstall && dir.split("/")[0] === "node_modules") continue;
92224
92239
  destFiles[dir.split("/")[0]] = true;
92225
92240
  const srcFp = Path.join(src, dir);
92226
92241
  const destFp = Path.join(dest, dir);
@@ -92235,15 +92250,47 @@ async function linkPackTree({ tree, src, dest, sym1, sourceMaps, isRoot = false
92235
92250
  logger$1.debug(`linkPackTree src: ${src} dest: ${dest} - destFiles ${JSON.stringify(destFiles)}`);
92236
92251
  await cleanExtraDest(dest, destFiles, isRoot);
92237
92252
  }
92238
- async function link$1(src, dest, { sourceMaps = true } = {}) {
92253
+ async function link$1(src, dest, { sourceMaps = true, preserveInstall = false } = {}) {
92239
92254
  return await linkPackTree({
92240
92255
  tree: await generatePackTree(src),
92241
92256
  src,
92242
92257
  dest,
92243
92258
  sourceMaps,
92259
+ preserveInstall,
92244
92260
  isRoot: true
92245
92261
  });
92246
92262
  }
92263
+ async function localLinkNeedsRefresh(src, dest, installedAt) {
92264
+ const tree = await generatePackTree(src);
92265
+ const copyMode = fyntil.strToBool(process.env.FYN_LOCAL_COPY_MODE);
92266
+ const inspectTree = async (tree, srcDir, destDir) => {
92267
+ for (const file of tree[SYM_FILES]) {
92268
+ const srcFile = Path.join(srcDir, file);
92269
+ const srcStat = await file_ops_default.lstat(srcFile);
92270
+ if (srcDir === src && file === "package.json" || !import_ci_info.isCI && /\.(js|mjs)\.map$/.test(file)) {
92271
+ if (srcStat.mtimeMs > installedAt) return true;
92272
+ continue;
92273
+ }
92274
+ const destFile = Path.join(destDir, file);
92275
+ let destStat;
92276
+ try {
92277
+ destStat = await file_ops_default.lstat(destFile);
92278
+ } catch (err) {
92279
+ if (err.code === "ENOENT" || err.code === "ENOTDIR") return true;
92280
+ throw err;
92281
+ }
92282
+ if (srcStat.isSymbolicLink()) {
92283
+ if (!destStat.isSymbolicLink() || await file_ops_default.readlink(srcFile) !== await file_ops_default.readlink(destFile)) return true;
92284
+ } else if (!destStat.isFile()) return true;
92285
+ else if (copyMode) {
92286
+ if (srcStat.mtimeMs > installedAt) return true;
92287
+ } else if (srcStat.dev !== destStat.dev || srcStat.ino !== destStat.ino) return true;
92288
+ }
92289
+ for (const dir of Object.keys(tree)) if (await inspectTree(tree[dir], Path.join(srcDir, dir), Path.join(destDir, dir))) return true;
92290
+ return false;
92291
+ };
92292
+ return inspectTree(tree, src, dest);
92293
+ }
92247
92294
  async function linkSym1(src, dest) {
92248
92295
  return await linkPackTree({
92249
92296
  tree: await generatePackTree(src),
@@ -110433,7 +110480,7 @@ var LocalPkgBuilder = class {
110433
110480
  }
110434
110481
  const checkPkg = await this._fyn.getLocalPkgInstall(item.fullPath);
110435
110482
  this._waitItems[item.fullPath] = false;
110436
- if (!checkPkg.localBuild) {
110483
+ if (!checkPkg.localBuild && !(this._fyn._options.forceInstall && checkPkg.hasScript)) {
110437
110484
  logger$1.debug(`local pkg at ${item.fullPath} doesn't need build`, checkPkg);
110438
110485
  return;
110439
110486
  }
@@ -110472,7 +110519,8 @@ var LocalPkgBuilder = class {
110472
110519
  this._fyn._options.registry && `--reg=${this._fyn._options.registry}`,
110473
110520
  "-q=d --pg=simple --no-build-local --sl=fyn-debug.log",
110474
110521
  !this._fyn._options.sourceMaps && "--no-source-maps",
110475
- "install --no-audit"
110522
+ "install --no-audit",
110523
+ this._fyn._options.forceInstall && "--force-install"
110476
110524
  ].filter((x) => x).join(" ");
110477
110525
  const displayTitle = `building local pkg at ${dispPath}`;
110478
110526
  logger$1.verbose(displayTitle);
@@ -111277,6 +111325,7 @@ var Fyn = class Fyn {
111277
111325
  const localPkg = localPkgs[nmDir];
111278
111326
  const fullPath = Path.join(this._cwd, localPkg.srcDir);
111279
111327
  if ((await this.getLocalPkgInstall(fullPath)).changed) return true;
111328
+ if (await localLinkNeedsRefresh(fullPath, Path.join(this._cwd, nmDir), this._installConfig.time)) return true;
111280
111329
  }
111281
111330
  if (await localExportsNeedInstall({
111282
111331
  cwd: this._cwd,
@@ -111310,6 +111359,7 @@ var Fyn = class Fyn {
111310
111359
  time: Date.now() + 5,
111311
111360
  centralDir,
111312
111361
  production: this.production,
111362
+ fynlocal: Boolean(this.fynlocal),
111313
111363
  layout: this._options.layout,
111314
111364
  shortPkgDir: this._shortPkgDir,
111315
111365
  blockedScripts: this._blockedScripts || this._installConfig.blockedScripts || [],
@@ -115361,7 +115411,7 @@ var FynCli = class {
115361
115411
  const auditFile = argv.opts?.auditFile;
115362
115412
  return dist_default.try(() => this.fyn._initializePkg()).then(async () => {
115363
115413
  checkNewVersion(this.fyn._options);
115364
- if (!this.fyn._changeProdMode && !this.fyn._options.forceInstall && this.fyn._installConfig.time) {
115414
+ if (!this.fyn._changeProdMode && !this.fyn._options.forceInstall && this.fyn._installConfig.fynlocal === Boolean(this.fyn.fynlocal) && this.fyn._installConfig.time) {
115365
115415
  const stats = await scanFileStats(this.fyn.cwd, { moreIgnores: localExportsScanIgnores(this.fyn._pkg) });
115366
115416
  const { latestMtimeMs } = stats;
115367
115417
  logger$1.debug("time check from install config - last install time", this.fyn._installConfig.time, "latest file time", latestMtimeMs);
@@ -115455,6 +115505,16 @@ var FynCli = class {
115455
115505
  dir: this.fyn.cwd
115456
115506
  }
115457
115507
  });
115508
+ if (scripts.length > 0 || this.fyn._options.autoRun && fynpoNpmScripts.length > 0) {
115509
+ const localPkgLinks = this.fyn._installConfig.localPkgLinks || {};
115510
+ for (const vdir in localPkgLinks) {
115511
+ const localPkg = localPkgLinks[vdir];
115512
+ await link$1(Path.join(this.fyn.cwd, localPkg.srcDir), Path.join(this.fyn.cwd, vdir), {
115513
+ sourceMaps: Boolean(localPkg.sourceMaps),
115514
+ preserveInstall: true
115515
+ });
115516
+ }
115517
+ }
115458
115518
  }).then(async () => {
115459
115519
  logger$1.removeItem(INSTALL_PACKAGE);
115460
115520
  const end = Date.now();
@@ -124870,6 +124930,20 @@ const pickOptions = async (cmd, checkFynpo = true) => {
124870
124930
  _fynpo: fynpo
124871
124931
  };
124872
124932
  };
124933
+ /** Resolve bootstrap's generated report without resolving the package graph or installing. */
124934
+ const getAuditFilePath = async (cwd, { rcfile = true } = {}) => {
124935
+ cwd = Path.resolve(cwd);
124936
+ const manager = new FynpoConfigManager({ cwd });
124937
+ await manager.load();
124938
+ const rc = loadRc(rcfile ? cwd : false, manager.topDir);
124939
+ return new Fyn({
124940
+ opts: {
124941
+ ...rc.all || defaultRc,
124942
+ cwd
124943
+ },
124944
+ _fynpo: false
124945
+ }).getFvDir(".fyn-audit.json");
124946
+ };
124873
124947
  const makeFynGlobal = async (cmd, extra = {}) => {
124874
124948
  const { opts } = await pickOptions(cmd, false);
124875
124949
  const tag = cmd.getParent()?.opts?.tag;
@@ -125575,8 +125649,9 @@ var main_default = {
125575
125649
  pickEnvOptions,
125576
125650
  setLockfile,
125577
125651
  hardLinkDir: hard_link_dir_exports,
125578
- reportFynpoLoadError
125652
+ reportFynpoLoadError,
125653
+ getAuditFilePath
125579
125654
  };
125580
125655
 
125581
125656
  //#endregion
125582
- export { main_default as default, fun, getRunExitCode, hard_link_dir_exports as hardLinkDir, nodeGyp, pickEnvOptions, reportFynpoLoadError, run, setLockfile };
125657
+ export { main_default as default, fun, getAuditFilePath, getRunExitCode, hard_link_dir_exports as hardLinkDir, nodeGyp, pickEnvOptions, reportFynpoLoadError, run, setLockfile };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fyn",
3
3
  "type": "module",
4
- "version": "3.1.8",
4
+ "version": "3.1.9",
5
5
  "description": "fyn is a node.js package manager, and supports fynpo -- a zero setup monorepo tool",
6
6
  "main": "./bin/index.mjs",
7
7
  "homepage": "https://github.com/jchip/fynjs/tree/main/packages/fyn",
@@ -82,7 +82,7 @@
82
82
  "Walmart GTP.js Team and Contributors"
83
83
  ],
84
84
  "devDependencies": {
85
- "@fynjs/run": "^1.1.5",
85
+ "@fynjs/run": "^1.1.6",
86
86
  "@fynjs/ts-resolve": "^1.0.3",
87
87
  "@types/node": "^26.4.1",
88
88
  "@vitest/coverage-v8": "^5.0.0",
@@ -92,7 +92,7 @@
92
92
  "patch-package": "^8.0.0",
93
93
  "prettier": "^3.5.3",
94
94
  "rolldown": "^1.2.6",
95
- "run-verify": "^2.1.5",
95
+ "run-verify": "^2.1.6",
96
96
  "typescript": "^7.0.2",
97
97
  "vite": "^8.2.2",
98
98
  "vitest": "^5.0.0",