fyn 1.1.34 → 1.1.35
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/fyn.js +75 -15
- package/package.json +1 -1
package/dist/fyn.js
CHANGED
|
@@ -542,6 +542,8 @@ const {
|
|
|
542
542
|
setupNodeGypEnv
|
|
543
543
|
} = __webpack_require__("./lib/util/setup-node-gyp.js");
|
|
544
544
|
|
|
545
|
+
const hardLinkDir = __webpack_require__("./lib/util/hard-link-dir.js");
|
|
546
|
+
|
|
545
547
|
const xsh = __webpack_require__("./node_modules/.f/_/xsh/0.4.5/xsh/lib/index.js");
|
|
546
548
|
|
|
547
549
|
function checkNewVersion(npmConfig) {
|
|
@@ -864,6 +866,27 @@ class FynCli {
|
|
|
864
866
|
logger.error("No package was removed");
|
|
865
867
|
return false;
|
|
866
868
|
}
|
|
869
|
+
|
|
870
|
+
async syncLocalLinks() {
|
|
871
|
+
await this.fyn._initializePkg();
|
|
872
|
+
const {
|
|
873
|
+
localPkgLinks
|
|
874
|
+
} = this.fyn._installConfig;
|
|
875
|
+
|
|
876
|
+
if (!_.isEmpty(localPkgLinks)) {
|
|
877
|
+
for (const vdir in localPkgLinks) {
|
|
878
|
+
const tgtDir = Path.join(this.fyn._cwd, vdir);
|
|
879
|
+
const srcDir = Path.join(this.fyn._cwd, localPkgLinks[vdir].srcDir);
|
|
880
|
+
await hardLinkDir.link(srcDir, tgtDir, {
|
|
881
|
+
sourceMaps: localPkgLinks[vdir].sourceMaps
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
logger.info(`refreshed linked files for local packages`);
|
|
886
|
+
} else {
|
|
887
|
+
logger.info(`There are no local packages`);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
867
890
|
/*
|
|
868
891
|
* npm scripts execution order on install
|
|
869
892
|
* 1. preinstall
|
|
@@ -1671,6 +1694,21 @@ const commands = {
|
|
|
1671
1694
|
type: "boolean"
|
|
1672
1695
|
}
|
|
1673
1696
|
}
|
|
1697
|
+
},
|
|
1698
|
+
"sync-local": {
|
|
1699
|
+
desc: "Refresh locally linked package files",
|
|
1700
|
+
alias: "sl",
|
|
1701
|
+
|
|
1702
|
+
async exec(argv, parsed) {
|
|
1703
|
+
try {
|
|
1704
|
+
const opts = await pickOptions(argv, parsed.nixClap, true);
|
|
1705
|
+
const cli = new FynCli(opts);
|
|
1706
|
+
return cli.syncLocalLinks();
|
|
1707
|
+
} catch (err) {
|
|
1708
|
+
process.exit(1);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1674
1712
|
}
|
|
1675
1713
|
};
|
|
1676
1714
|
|
|
@@ -3408,6 +3446,10 @@ class Fyn {
|
|
|
3408
3446
|
|
|
3409
3447
|
getInstallConfigFile() {
|
|
3410
3448
|
return Path.join(this.getFvDir(FYN_INSTALL_CONFIG_FILE));
|
|
3449
|
+
}
|
|
3450
|
+
|
|
3451
|
+
setLocalPkgLinks(localLinks) {
|
|
3452
|
+
this._installConfig.localPkgLinks = localLinks;
|
|
3411
3453
|
} // save the config to outputDir
|
|
3412
3454
|
|
|
3413
3455
|
|
|
@@ -3741,7 +3783,7 @@ class Fyn {
|
|
|
3741
3783
|
* - Rare but could occur if fyn is used for monorepo and user has script
|
|
3742
3784
|
* that run concurrent installs
|
|
3743
3785
|
*
|
|
3744
|
-
* @returns {boolean} if lock was acquired
|
|
3786
|
+
* @returns {Promise<boolean>} if lock was acquired
|
|
3745
3787
|
*/
|
|
3746
3788
|
|
|
3747
3789
|
|
|
@@ -7668,6 +7710,7 @@ class PkgInstaller {
|
|
|
7668
7710
|
this._depLinker = new PkgDepLinker({
|
|
7669
7711
|
fyn: this._fyn
|
|
7670
7712
|
});
|
|
7713
|
+
this._localLinks = {};
|
|
7671
7714
|
}
|
|
7672
7715
|
|
|
7673
7716
|
async install() {
|
|
@@ -7706,6 +7749,8 @@ class PkgInstaller {
|
|
|
7706
7749
|
this.preInstall = undefined;
|
|
7707
7750
|
this.postInstall = undefined;
|
|
7708
7751
|
this.toLink = undefined;
|
|
7752
|
+
|
|
7753
|
+
this._fyn.setLocalPkgLinks(this._localLinks);
|
|
7709
7754
|
});
|
|
7710
7755
|
}
|
|
7711
7756
|
|
|
@@ -7720,8 +7765,15 @@ class PkgInstaller {
|
|
|
7720
7765
|
const vdir = this._fyn.getInstalledPkgDir(depInfo.name, depInfo.version, depInfo);
|
|
7721
7766
|
|
|
7722
7767
|
if (depInfo.local === "hard") {
|
|
7768
|
+
const {
|
|
7769
|
+
sourceMaps
|
|
7770
|
+
} = this._fyn._options;
|
|
7771
|
+
this._localLinks[Path.relative(this._fyn._cwd, vdir)] = {
|
|
7772
|
+
srcDir: Path.relative(this._fyn._cwd, depInfo.dir),
|
|
7773
|
+
sourceMaps
|
|
7774
|
+
};
|
|
7723
7775
|
await hardLinkDir.link(depInfo.dir, vdir, {
|
|
7724
|
-
sourceMaps
|
|
7776
|
+
sourceMaps
|
|
7725
7777
|
});
|
|
7726
7778
|
} else {
|
|
7727
7779
|
// await this._depLinker.symlinkLocalPackage(vdir, depInfo.dir);
|
|
@@ -11973,12 +12025,12 @@ class FynpoDepGraph {
|
|
|
11973
12025
|
this._options = _objectSpread({
|
|
11974
12026
|
cwd: process.cwd()
|
|
11975
12027
|
}, options);
|
|
11976
|
-
this.depMapByPath =
|
|
11977
|
-
this.resolvedCache =
|
|
12028
|
+
this.depMapByPath = Object.create(null);
|
|
12029
|
+
this.resolvedCache = Object.create(null);
|
|
11978
12030
|
this.packages = {
|
|
11979
|
-
byId:
|
|
11980
|
-
byName:
|
|
11981
|
-
byPath:
|
|
12031
|
+
byId: Object.create(null),
|
|
12032
|
+
byName: Object.create(null),
|
|
12033
|
+
byPath: Object.create(null)
|
|
11982
12034
|
};
|
|
11983
12035
|
}
|
|
11984
12036
|
/**
|
|
@@ -11991,10 +12043,13 @@ class FynpoDepGraph {
|
|
|
11991
12043
|
await this.readPackages();
|
|
11992
12044
|
}
|
|
11993
12045
|
|
|
11994
|
-
this.
|
|
12046
|
+
this.resolveDirectDeps(); // we don't need indirect deps
|
|
12047
|
+
// topo sort works with only direct deps
|
|
12048
|
+
// this.resolveIndirectDeps();
|
|
11995
12049
|
}
|
|
11996
12050
|
/**
|
|
11997
12051
|
* update package depdencies map
|
|
12052
|
+
*
|
|
11998
12053
|
* - re-entrant safe
|
|
11999
12054
|
*/
|
|
12000
12055
|
|
|
@@ -12012,7 +12067,9 @@ class FynpoDepGraph {
|
|
|
12012
12067
|
|
|
12013
12068
|
getTopoSortPackagePaths() {
|
|
12014
12069
|
const depRecords = {};
|
|
12015
|
-
const changed = [];
|
|
12070
|
+
const changed = []; //
|
|
12071
|
+
// first start with packages that has zero local dependencies
|
|
12072
|
+
//
|
|
12016
12073
|
|
|
12017
12074
|
for (const path in this.depMapByPath) {
|
|
12018
12075
|
const depData = this.depMapByPath[path];
|
|
@@ -12030,12 +12087,14 @@ class FynpoDepGraph {
|
|
|
12030
12087
|
const sorted = [];
|
|
12031
12088
|
|
|
12032
12089
|
while (changed.length > 0) {
|
|
12090
|
+
// remove the zero local dependencies packages from queue
|
|
12033
12091
|
const record = depRecords[changed.pop()];
|
|
12034
12092
|
/* istanbul ignore else */
|
|
12035
12093
|
|
|
12036
12094
|
if (record.count === 0) {
|
|
12095
|
+
// add package to result
|
|
12037
12096
|
record.count = -1;
|
|
12038
|
-
sorted.push(record.depData.pkgInfo.path);
|
|
12097
|
+
sorted.push(record.depData.pkgInfo.path); // subtract depdendencies count for all packages depending on the removed package
|
|
12039
12098
|
|
|
12040
12099
|
for (const path in record.depData.dependentsByPath) {
|
|
12041
12100
|
const record2 = depRecords[path];
|
|
@@ -12214,7 +12273,7 @@ class FynpoDepGraph {
|
|
|
12214
12273
|
byName
|
|
12215
12274
|
} = this.packages;
|
|
12216
12275
|
|
|
12217
|
-
if (byName
|
|
12276
|
+
if (byName[pkgJson.name]) {
|
|
12218
12277
|
byName[pkgJson.name].push(pkgInfo);
|
|
12219
12278
|
} else {
|
|
12220
12279
|
byName[pkgJson.name] = [pkgInfo];
|
|
@@ -12308,8 +12367,8 @@ class FynpoDepGraph {
|
|
|
12308
12367
|
if (!depMapByPath[path]) {
|
|
12309
12368
|
depMapByPath[path] = {
|
|
12310
12369
|
pkgInfo: byPath[path],
|
|
12311
|
-
localDepsByPath:
|
|
12312
|
-
dependentsByPath:
|
|
12370
|
+
localDepsByPath: Object.create(null),
|
|
12371
|
+
dependentsByPath: Object.create(null)
|
|
12313
12372
|
};
|
|
12314
12373
|
}
|
|
12315
12374
|
}
|
|
@@ -12371,7 +12430,7 @@ class FynpoDepGraph {
|
|
|
12371
12430
|
const dataPkg = this.depMapByPath[pkgInfo.path];
|
|
12372
12431
|
const dataDep = this.depMapByPath[depPkg.path]; // check circular
|
|
12373
12432
|
|
|
12374
|
-
if (dataDep.localDepsByPath
|
|
12433
|
+
if (dataDep.localDepsByPath[pkgInfo.path]) {
|
|
12375
12434
|
// remember circular package's path
|
|
12376
12435
|
if (!dataPkg.pathOfCirculars) {
|
|
12377
12436
|
dataPkg.pathOfCirculars = [];
|
|
@@ -12464,6 +12523,7 @@ class FynpoDepGraph {
|
|
|
12464
12523
|
/**
|
|
12465
12524
|
* Figure out all the packages' indirect dependencies on other local packages
|
|
12466
12525
|
*
|
|
12526
|
+
* TODO: very inefficient. optimize this.
|
|
12467
12527
|
*/
|
|
12468
12528
|
|
|
12469
12529
|
|
|
@@ -12495,7 +12555,7 @@ class FynpoDepGraph {
|
|
|
12495
12555
|
} // check if pkg is already part of localDeps
|
|
12496
12556
|
|
|
12497
12557
|
|
|
12498
|
-
if (!dataPkg.localDepsByPath
|
|
12558
|
+
if (!dataPkg.localDepsByPath[depInfo.path]) {
|
|
12499
12559
|
change++;
|
|
12500
12560
|
this.addDep(pkgInfo, depInfo, sec, stepsCopy);
|
|
12501
12561
|
} // resolve further with deps of depPkg
|