tsds-lib-test 1.5.5 → 1.6.0

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/cjs/index.js CHANGED
@@ -9,15 +9,19 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- data: function() {
13
- return _data.default;
12
+ installGitRepo: function() {
13
+ return _installGitRepo.default;
14
14
  },
15
- prepareGit: function() {
16
- return _prepareGit.default;
15
+ linkModule: function() {
16
+ return _linkModule.default;
17
+ },
18
+ unlinkModule: function() {
19
+ return _unlinkModule.default;
17
20
  }
18
21
  });
19
- var _data = /*#__PURE__*/ _interop_require_default(require("./lib/data.js"));
20
- var _prepareGit = /*#__PURE__*/ _interop_require_default(require("./lib/prepareGit.js"));
22
+ var _linkModule = /*#__PURE__*/ _interop_require_default(require("./lib/linkModule.js"));
23
+ var _installGitRepo = /*#__PURE__*/ _interop_require_default(require("./lib/installGitRepo.js"));
24
+ var _unlinkModule = /*#__PURE__*/ _interop_require_default(require("./lib/unlinkModule.js"));
21
25
  function _interop_require_default(obj) {
22
26
  return obj && obj.__esModule ? obj : {
23
27
  default: obj
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export { default as data } from './lib/data.js';\nexport { default as prepareGit } from './lib/prepareGit.js';\n"],"names":["data","prepareGit"],"mappings":";;;;;;;;;;;IAAoBA,IAAI;eAAJA,aAAI;;IACJC,UAAU;eAAVA,mBAAU;;;2DADE;iEACM"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { default as linkModule } from './lib/linkModule.js';\nexport { default as installGitRepo } from './lib/installGitRepo.js';\nexport { default as unlinkModule } from './lib/unlinkModule.js';\n"],"names":["installGitRepo","linkModule","unlinkModule"],"mappings":";;;;;;;;;;;IACoBA,cAAc;eAAdA,uBAAc;;IADdC,UAAU;eAAVA,mBAAU;;IAEVC,YAAY;eAAZA,qBAAY;;;iEAFM;qEACI;mEACF"}
@@ -5,46 +5,45 @@ Object.defineProperty(exports, "__esModule", {
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return prepareGit;
8
+ return installGitRepo;
9
9
  }
10
10
  });
11
- var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
11
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
12
  var _crossspawncb = /*#__PURE__*/ _interop_require_default(require("cross-spawn-cb"));
14
13
  var _fsaccesscompat = /*#__PURE__*/ _interop_require_default(require("fs-access-compat"));
15
14
  var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
16
- var _osshim = /*#__PURE__*/ _interop_require_default(require("os-shim"));
17
15
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
18
16
  var _rimraf2 = /*#__PURE__*/ _interop_require_default(require("rimraf2"));
19
- var _shorthash = /*#__PURE__*/ _interop_require_default(require("short-hash"));
20
17
  function _interop_require_default(obj) {
21
18
  return obj && obj.__esModule ? obj : {
22
19
  default: obj
23
20
  };
24
21
  }
25
- function prepareGit(git, options, callback) {
26
- var cwd = options.cwd || process.cwd();
27
- var pkg = JSON.parse(_fs.default.readFileSync(_path.default.join(cwd, 'package.json'), 'utf8'));
28
- var dest = _path.default.join(_osshim.default.tmpdir(), pkg.name, (0, _shorthash.default)(cwd));
29
- var targetName = _path.default.basename(git, _path.default.extname(git));
30
- var targetPath = _path.default.join(dest, targetName);
31
- _mkdirpclassic.default.sync(dest);
32
- (0, _fsaccesscompat.default)(targetPath, function(err) {
33
- if (!err && options.clean) {
34
- _rimraf2.default.sync(targetPath, {
35
- disableGlob: true
36
- });
37
- err = true;
38
- }
22
+ function installGitRepo(repo, dest, options, callback) {
23
+ if (typeof options === 'function') {
24
+ callback = options;
25
+ options = {};
26
+ }
27
+ options = options || {};
28
+ console.log('installGitRepo', repo, dest);
29
+ // options.clean = true;
30
+ function checkOrClean(dest, callback) {
31
+ options.clean ? (0, _rimraf2.default)(dest, {
32
+ disableGlob: true
33
+ }, callback.bind(null, new Error('clone'))) : (0, _fsaccesscompat.default)(dest, callback);
34
+ }
35
+ checkOrClean(dest, function(err) {
39
36
  var queue = new _queuecb.default(1);
37
+ queue.defer(_mkdirpclassic.default.bind(null, dest));
40
38
  // does not exist - clone
41
39
  if (err) {
42
40
  queue.defer(_crossspawncb.default.bind(null, 'git', [
43
41
  'clone',
44
- git
42
+ repo,
43
+ _path.default.basename(dest)
45
44
  ], {
46
45
  stdio: 'inherit',
47
- cwd: dest
46
+ cwd: _path.default.dirname(dest)
48
47
  }));
49
48
  } else {
50
49
  queue.defer(_crossspawncb.default.bind(null, 'git', [
@@ -52,7 +51,7 @@ function prepareGit(git, options, callback) {
52
51
  '-fd'
53
52
  ], {
54
53
  stdio: 'inherit',
55
- cwd: targetPath
54
+ cwd: dest
56
55
  }));
57
56
  queue.defer(_crossspawncb.default.bind(null, 'git', [
58
57
  'reset',
@@ -60,16 +59,23 @@ function prepareGit(git, options, callback) {
60
59
  'HEAD'
61
60
  ], {
62
61
  stdio: 'inherit',
63
- cwd: targetPath
62
+ cwd: dest
64
63
  }));
65
64
  queue.defer(_crossspawncb.default.bind(null, 'git', [
66
65
  'pull',
67
66
  '--rebase'
68
67
  ], {
69
68
  stdio: 'inherit',
70
- cwd: targetPath
69
+ cwd: dest
71
70
  }));
72
71
  }
72
+ // install
73
+ queue.defer(_crossspawncb.default.bind(null, 'npm', [
74
+ '--silent',
75
+ 'install'
76
+ ], {
77
+ cwd: dest
78
+ }));
73
79
  queue.await(callback);
74
80
  });
75
81
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["installGitRepo.ts"],"sourcesContent":["import path from 'path';\nimport spawn from 'cross-spawn-cb';\nimport access from 'fs-access-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nexport default function installGitRepo(repo: string, dest: string, options, callback?) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n console.log('installGitRepo', repo, dest);\n // options.clean = true;\n\n function checkOrClean(dest, callback) {\n options.clean ? rimraf2(dest, { disableGlob: true }, callback.bind(null, new Error('clone'))) : access(dest, callback);\n }\n\n checkOrClean(dest, (err) => {\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, dest));\n\n // does not exist - clone\n if (err) {\n queue.defer(spawn.bind(null, 'git', ['clone', repo, path.basename(dest)], { stdio: 'inherit', cwd: path.dirname(dest) }));\n }\n // exists - reset git\n else {\n queue.defer(spawn.bind(null, 'git', ['clean', '-fd'], { stdio: 'inherit', cwd: dest }));\n queue.defer(spawn.bind(null, 'git', ['reset', '--hard', 'HEAD'], { stdio: 'inherit', cwd: dest }));\n queue.defer(spawn.bind(null, 'git', ['pull', '--rebase'], { stdio: 'inherit', cwd: dest }));\n }\n\n // install\n queue.defer(spawn.bind(null, 'npm', ['--silent', 'install'], { cwd: dest }));\n\n queue.await(callback);\n });\n}\n"],"names":["installGitRepo","repo","dest","options","callback","console","log","checkOrClean","clean","rimraf2","disableGlob","bind","Error","access","err","queue","Queue","defer","mkdirp","spawn","path","basename","stdio","cwd","dirname","await"],"mappings":";;;;+BAOA;;;eAAwBA;;;2DAPP;mEACC;qEACC;oEACA;8DACD;8DACE;;;;;;AAEL,SAASA,eAAeC,IAAY,EAAEC,IAAY,EAAEC,OAAO,EAAEC,QAAS;IACnF,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBE,QAAQC,GAAG,CAAC,kBAAkBL,MAAMC;IACpC,wBAAwB;IAExB,SAASK,aAAaL,IAAI,EAAEE,QAAQ;QAClCD,QAAQK,KAAK,GAAGC,IAAAA,gBAAO,EAACP,MAAM;YAAEQ,aAAa;QAAK,GAAGN,SAASO,IAAI,CAAC,MAAM,IAAIC,MAAM,aAAaC,IAAAA,uBAAM,EAACX,MAAME;IAC/G;IAEAG,aAAaL,MAAM,SAACY;QAClB,IAAMC,QAAQ,IAAIC,gBAAK,CAAC;QACxBD,MAAME,KAAK,CAACC,sBAAM,CAACP,IAAI,CAAC,MAAMT;QAE9B,yBAAyB;QACzB,IAAIY,KAAK;YACPC,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAASV;gBAAMmB,aAAI,CAACC,QAAQ,CAACnB;aAAM,EAAE;gBAAEoB,OAAO;gBAAWC,KAAKH,aAAI,CAACI,OAAO,CAACtB;YAAM;QACxH,OAEK;YACHa,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;aAAM,EAAE;gBAAEW,OAAO;gBAAWC,KAAKrB;YAAK;YACpFa,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;gBAAU;aAAO,EAAE;gBAAEW,OAAO;gBAAWC,KAAKrB;YAAK;YAC/Fa,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAQ;aAAW,EAAE;gBAAEW,OAAO;gBAAWC,KAAKrB;YAAK;QAC1F;QAEA,UAAU;QACVa,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;YAAC;YAAY;SAAU,EAAE;YAAEY,KAAKrB;QAAK;QAEzEa,MAAMU,KAAK,CAACrB;IACd;AACF"}
@@ -5,19 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  Object.defineProperty(exports, "default", {
6
6
  enumerable: true,
7
7
  get: function() {
8
- return data;
8
+ return linkModule;
9
9
  }
10
10
  });
11
11
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
12
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
13
  var _url = /*#__PURE__*/ _interop_require_default(require("url"));
14
- var _crossspawncb = /*#__PURE__*/ _interop_require_default(require("cross-spawn-cb"));
14
+ var _fsaccesscompat = /*#__PURE__*/ _interop_require_default(require("fs-access-compat"));
15
15
  var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
16
- var _osshim = /*#__PURE__*/ _interop_require_default(require("os-shim"));
17
16
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
18
- var _shorthash = /*#__PURE__*/ _interop_require_default(require("short-hash"));
19
17
  var _tsdslib = require("tsds-lib");
20
- var _prepareGit = /*#__PURE__*/ _interop_require_default(require("./prepareGit.js"));
21
18
  function _array_like_to_array(arr, len) {
22
19
  if (len == null || len > arr.length) len = arr.length;
23
20
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -51,43 +48,39 @@ function _unsupported_iterable_to_array(o, minLen) {
51
48
  var __dirname = _path.default.dirname(typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
52
49
  var major = +process.versions.node.split('.')[0];
53
50
  var workerWrapper = (0, _tsdslib.wrapWorker)(_path.default.join((0, _tsdslib.packageRoot)(__dirname), 'dist', 'cjs', 'lib', 'data.js'));
54
- function worker(git, options, callback) {
55
- var cwd = options.cwd || process.cwd();
56
- var pkg = JSON.parse(_fs.default.readFileSync(_path.default.join(cwd, 'package.json'), 'utf8'));
57
- var dest = _path.default.join(_osshim.default.tmpdir(), pkg.name, (0, _shorthash.default)(cwd));
58
- var targetName = _path.default.basename(git, _path.default.extname(git));
59
- var targetPath = _path.default.join(dest, targetName);
60
- _mkdirpclassic.default.sync(dest);
61
- var queue = new _queuecb.default(1);
62
- for(var binName in pkg.bin){
63
- var packagePath = _path.default.resolve(targetPath, 'node_modules', pkg.name);
64
- var binPath = _path.default.resolve(targetPath, 'node_modules', '.bin', binName);
65
- console.log('------------------');
66
- console.log("Preparing: ".concat(targetPath));
67
- // clone or reset the git repo
68
- queue.defer(_prepareGit.default.bind(null, git, options));
69
- // install
70
- queue.defer(_crossspawncb.default.bind(null, 'npm', [
71
- '--silent',
72
- 'install'
73
- ], {
74
- cwd: targetPath
75
- }));
76
- // link package
77
- queue.defer(_fs.default.rename.bind(null, packagePath, "".concat(packagePath, ".tsds")));
78
- queue.defer(_fs.default.symlink.bind(null, cwd, packagePath, 'dir'));
79
- // link bin
80
- queue.defer(_fs.default.rename.bind(null, binPath, "".concat(binPath, ".tsds")));
81
- queue.defer(_fs.default.symlink.bind(null, _path.default.resolve.apply(null, [
82
- cwd
83
- ].concat(_to_consumable_array(pkg.bin[binName].split('/')))), binPath, 'file'));
51
+ function linkBin(src, binPath, nodeModules, binName, callback) {
52
+ var binFullPath = _path.default.resolve.apply(null, [
53
+ src
54
+ ].concat(_to_consumable_array(binPath.split('/'))));
55
+ var destBin = _path.default.resolve(nodeModules, '.bin', binName);
56
+ (0, _fsaccesscompat.default)(binFullPath, function(err) {
57
+ if (!err) return (0, _tsdslib.link)(binFullPath, destBin, callback);
58
+ console.log("bin not found: ".concat(binFullPath, ". Skipping"));
59
+ callback();
60
+ });
61
+ }
62
+ function worker(src, nodeModules, _options, callback) {
63
+ var pkg = JSON.parse(_fs.default.readFileSync(_path.default.join(src, 'package.json'), 'utf8'));
64
+ var dest = _path.default.resolve.apply(null, [
65
+ nodeModules
66
+ ].concat(_to_consumable_array(pkg.name.split('/'))));
67
+ (0, _mkdirpclassic.default)(_path.default.dirname(dest), function(err) {
68
+ if (err) return callback(err);
69
+ var queue = new _queuecb.default();
70
+ queue.defer(_tsdslib.link.bind(null, src, dest));
71
+ if (typeof pkg.bin === 'string') queue.defer(linkBin.bind(null, src, pkg.bin, nodeModules, pkg.name)); // single bins
72
+ else for(var binName in pkg.bin)queue.defer(linkBin.bind(null, src, pkg.bin[binName], nodeModules, binName)); // object of bins
84
73
  queue.await(function(err) {
85
- console.log('------------------');
86
- err ? callback(err) : callback(null, targetPath);
74
+ err ? callback(err) : callback(null, dest);
87
75
  });
88
- }
76
+ });
89
77
  }
90
- function data(git, options, callback) {
91
- major < 14 ? workerWrapper('stable', git, options, callback) : worker(git, options, callback);
78
+ function linkModule(src, nodeModules, options, callback) {
79
+ if (typeof options === 'function') {
80
+ callback = options;
81
+ options = {};
82
+ }
83
+ options = options || {};
84
+ major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);
92
85
  }
93
86
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["linkModule.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport access from 'fs-access-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport { link, packageRoot, wrapWorker } from 'tsds-lib';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst major = +process.versions.node.split('.')[0];\nconst workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));\n\nfunction linkBin(src, binPath, nodeModules, binName, callback) {\n const binFullPath = path.resolve.apply(null, [src, ...binPath.split('/')]);\n const destBin = path.resolve(nodeModules, '.bin', binName);\n\n access(binFullPath, (err) => {\n if (!err) return link(binFullPath, destBin, callback);\n console.log(`bin not found: ${binFullPath}. Skipping`);\n callback();\n });\n}\n\nfunction worker(src, nodeModules, _options, callback) {\n const pkg = JSON.parse(fs.readFileSync(path.join(src, 'package.json'), 'utf8'));\n const dest = path.resolve.apply(null, [nodeModules, ...pkg.name.split('/')]);\n\n mkdirp(path.dirname(dest), (err) => {\n if (err) return callback(err);\n\n const queue = new Queue();\n queue.defer(link.bind(null, src, dest));\n\n if (typeof pkg.bin === 'string')\n queue.defer(linkBin.bind(null, src, pkg.bin, nodeModules, pkg.name)); // single bins\n else for (const binName in pkg.bin) queue.defer(linkBin.bind(null, src, pkg.bin[binName], nodeModules, binName)); // object of bins\n\n queue.await((err) => {\n err ? callback(err) : callback(null, dest);\n });\n });\n}\n\nexport default function linkModule(src: string, nodeModules: string, options, callback?) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);\n}\n"],"names":["linkModule","__dirname","path","dirname","__filename","url","fileURLToPath","major","process","versions","node","split","workerWrapper","wrapWorker","join","packageRoot","linkBin","src","binPath","nodeModules","binName","callback","binFullPath","resolve","apply","destBin","access","err","link","console","log","worker","_options","pkg","JSON","parse","fs","readFileSync","dest","name","mkdirp","queue","Queue","defer","bind","bin","await","options"],"mappings":";;;;+BA2CA;;;eAAwBA;;;yDA3CT;2DACE;0DACD;qEACG;oEACA;8DACD;uBAC4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9C,IAAMC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAClG,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,gBAAgBC,IAAAA,mBAAU,EAACX,aAAI,CAACY,IAAI,CAACC,IAAAA,oBAAW,EAACd,YAAY,QAAQ,OAAO,OAAO;AAEzF,SAASe,QAAQC,GAAG,EAAEC,OAAO,EAAEC,WAAW,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,IAAMC,cAAcpB,aAAI,CAACqB,OAAO,CAACC,KAAK,CAAC,MAAM;QAACP;KAA2B,CAA5B,OAAM,qBAAGC,QAAQP,KAAK,CAAC;IACpE,IAAMc,UAAUvB,aAAI,CAACqB,OAAO,CAACJ,aAAa,QAAQC;IAElDM,IAAAA,uBAAM,EAACJ,aAAa,SAACK;QACnB,IAAI,CAACA,KAAK,OAAOC,IAAAA,aAAI,EAACN,aAAaG,SAASJ;QAC5CQ,QAAQC,GAAG,CAAC,AAAC,kBAA6B,OAAZR,aAAY;QAC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@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return unlinkModule;
9
+ }
10
+ });
11
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ var _url = /*#__PURE__*/ _interop_require_default(require("url"));
14
+ var _fsaccesscompat = /*#__PURE__*/ _interop_require_default(require("fs-access-compat"));
15
+ var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
16
+ var _tsdslib = require("tsds-lib");
17
+ function _array_like_to_array(arr, len) {
18
+ if (len == null || len > arr.length) len = arr.length;
19
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
20
+ return arr2;
21
+ }
22
+ function _array_without_holes(arr) {
23
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
24
+ }
25
+ function _interop_require_default(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ function _iterable_to_array(iter) {
31
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
32
+ }
33
+ function _non_iterable_spread() {
34
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ function _to_consumable_array(arr) {
37
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
38
+ }
39
+ function _unsupported_iterable_to_array(o, minLen) {
40
+ if (!o) return;
41
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
42
+ var n = Object.prototype.toString.call(o).slice(8, -1);
43
+ if (n === "Object" && o.constructor) n = o.constructor.name;
44
+ if (n === "Map" || n === "Set") return Array.from(n);
45
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
46
+ }
47
+ var __dirname = _path.default.dirname(typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
48
+ var major = +process.versions.node.split('.')[0];
49
+ var workerWrapper = (0, _tsdslib.wrapWorker)(_path.default.join((0, _tsdslib.packageRoot)(__dirname), 'dist', 'cjs', 'lib', 'data.js'));
50
+ function unlinkBin(nodeModules, binName, callback) {
51
+ var destBin = _path.default.resolve(nodeModules, '.bin', binName);
52
+ (0, _fsaccesscompat.default)(destBin, function(err) {
53
+ if (!err) return (0, _tsdslib.unlink)(destBin, callback);
54
+ console.log("bin not found: ".concat(destBin, ". Skipping"));
55
+ callback();
56
+ });
57
+ }
58
+ function worker(src, nodeModules, _options, callback) {
59
+ var pkg = JSON.parse(_fs.default.readFileSync(_path.default.join(src, 'package.json'), 'utf8'));
60
+ var dest = _path.default.resolve.apply(null, [
61
+ nodeModules
62
+ ].concat(_to_consumable_array(pkg.name.split('/'))));
63
+ var queue = new _queuecb.default(1);
64
+ queue.defer(_tsdslib.unlink.bind(null, dest));
65
+ if (typeof pkg.bin === 'string') queue.defer(unlinkBin.bind(null, nodeModules, pkg.name)); // single bins
66
+ else for(var binName in pkg.bin)queue.defer(unlinkBin.bind(null, nodeModules, binName)); // object of bins
67
+ queue.await(function(err) {
68
+ err ? callback(err) : callback(null, dest);
69
+ });
70
+ }
71
+ function unlinkModule(src, nodeModules, options, callback) {
72
+ if (typeof options === 'function') {
73
+ callback = options;
74
+ options = {};
75
+ }
76
+ options = options || {};
77
+ major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);
78
+ }
79
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["unlinkModule.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport access from 'fs-access-compat';\nimport Queue from 'queue-cb';\nimport { packageRoot, unlink, wrapWorker } from 'tsds-lib';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst major = +process.versions.node.split('.')[0];\nconst workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));\n\nfunction unlinkBin(nodeModules, binName, callback) {\n const destBin = path.resolve(nodeModules, '.bin', binName);\n\n access(destBin, (err) => {\n if (!err) return unlink(destBin, callback);\n console.log(`bin not found: ${destBin}. Skipping`);\n callback();\n });\n}\n\nfunction worker(src, nodeModules, _options, callback) {\n const pkg = JSON.parse(fs.readFileSync(path.join(src, 'package.json'), 'utf8'));\n const dest = path.resolve.apply(null, [nodeModules, ...pkg.name.split('/')]);\n\n const queue = new Queue(1);\n queue.defer(unlink.bind(null, dest));\n\n if (typeof pkg.bin === 'string')\n queue.defer(unlinkBin.bind(null, nodeModules, pkg.name)); // single bins\n else for (const binName in pkg.bin) queue.defer(unlinkBin.bind(null, nodeModules, binName)); // object of bins\n\n queue.await((err) => {\n err ? callback(err) : callback(null, dest);\n });\n}\n\nexport default function unlinkModule(src: string, nodeModules: string, options, callback?) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);\n}\n"],"names":["unlinkModule","__dirname","path","dirname","__filename","url","fileURLToPath","major","process","versions","node","split","workerWrapper","wrapWorker","join","packageRoot","unlinkBin","nodeModules","binName","callback","destBin","resolve","access","err","unlink","console","log","worker","src","_options","pkg","JSON","parse","fs","readFileSync","dest","apply","name","queue","Queue","defer","bind","bin","await","options"],"mappings":";;;;+BAqCA;;;eAAwBA;;;yDArCT;2DACE;0DACD;qEACG;8DACD;uBAC8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhD,IAAMC,YAAYC,aAAI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AK,CAAC,SAACpB;QACXA,MAAMJ,SAASI,OAAOJ,SAAS,MAAMgB;IACvC;AACF;AAEe,SAASnC,aAAa4B,GAAW,EAAEX,WAAmB,EAAE2B,OAAO,EAAEzB,QAAS;IACvF,IAAI,OAAOyB,YAAY,YAAY;QACjCzB,WAAWyB;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtBrC,QAAQ,KAAKK,cAAc,UAAUgB,KAAKX,aAAa2B,SAASzB,YAAYQ,OAAOC,KAAKX,aAAa2B,SAASzB;AAChH"}
@@ -1,2 +1,3 @@
1
- export { default as data } from './lib/data.mjs';
2
- export { default as prepareGit } from './lib/prepareGit.mjs';
1
+ export { default as linkModule } from './lib/linkModule.mjs';
2
+ export { default as installGitRepo } from './lib/installGitRepo.mjs';
3
+ export { default as unlinkModule } from './lib/unlinkModule.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export { default as data } from './lib/data.js';\nexport { default as prepareGit } from './lib/prepareGit.js';\n"],"names":["default","data","prepareGit"],"mappings":"AAAA,SAASA,WAAWC,IAAI,QAAQ,gBAAgB;AAChD,SAASD,WAAWE,UAAU,QAAQ,sBAAsB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { default as linkModule } from './lib/linkModule.js';\nexport { default as installGitRepo } from './lib/installGitRepo.js';\nexport { default as unlinkModule } from './lib/unlinkModule.js';\n"],"names":["default","linkModule","installGitRepo","unlinkModule"],"mappings":"AAAA,SAASA,WAAWC,UAAU,QAAQ,sBAAsB;AAC5D,SAASD,WAAWE,cAAc,QAAQ,0BAA0B;AACpE,SAASF,WAAWG,YAAY,QAAQ,wBAAwB"}
@@ -1,35 +1,34 @@
1
- import fs from 'fs';
2
1
  import path from 'path';
3
2
  import spawn from 'cross-spawn-cb';
4
3
  import access from 'fs-access-compat';
5
4
  import mkdirp from 'mkdirp-classic';
6
- import os from 'os-shim';
7
5
  import Queue from 'queue-cb';
8
6
  import rimraf2 from 'rimraf2';
9
- import shortHash from 'short-hash';
10
- export default function prepareGit(git, options, callback) {
11
- const cwd = options.cwd || process.cwd();
12
- const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
13
- const dest = path.join(os.tmpdir(), pkg.name, shortHash(cwd));
14
- const targetName = path.basename(git, path.extname(git));
15
- const targetPath = path.join(dest, targetName);
16
- mkdirp.sync(dest);
17
- access(targetPath, (err)=>{
18
- if (!err && options.clean) {
19
- rimraf2.sync(targetPath, {
20
- disableGlob: true
21
- });
22
- err = true;
23
- }
7
+ export default function installGitRepo(repo, dest, options, callback) {
8
+ if (typeof options === 'function') {
9
+ callback = options;
10
+ options = {};
11
+ }
12
+ options = options || {};
13
+ console.log('installGitRepo', repo, dest);
14
+ // options.clean = true;
15
+ function checkOrClean(dest, callback) {
16
+ options.clean ? rimraf2(dest, {
17
+ disableGlob: true
18
+ }, callback.bind(null, new Error('clone'))) : access(dest, callback);
19
+ }
20
+ checkOrClean(dest, (err)=>{
24
21
  const queue = new Queue(1);
22
+ queue.defer(mkdirp.bind(null, dest));
25
23
  // does not exist - clone
26
24
  if (err) {
27
25
  queue.defer(spawn.bind(null, 'git', [
28
26
  'clone',
29
- git
27
+ repo,
28
+ path.basename(dest)
30
29
  ], {
31
30
  stdio: 'inherit',
32
- cwd: dest
31
+ cwd: path.dirname(dest)
33
32
  }));
34
33
  } else {
35
34
  queue.defer(spawn.bind(null, 'git', [
@@ -37,7 +36,7 @@ export default function prepareGit(git, options, callback) {
37
36
  '-fd'
38
37
  ], {
39
38
  stdio: 'inherit',
40
- cwd: targetPath
39
+ cwd: dest
41
40
  }));
42
41
  queue.defer(spawn.bind(null, 'git', [
43
42
  'reset',
@@ -45,16 +44,23 @@ export default function prepareGit(git, options, callback) {
45
44
  'HEAD'
46
45
  ], {
47
46
  stdio: 'inherit',
48
- cwd: targetPath
47
+ cwd: dest
49
48
  }));
50
49
  queue.defer(spawn.bind(null, 'git', [
51
50
  'pull',
52
51
  '--rebase'
53
52
  ], {
54
53
  stdio: 'inherit',
55
- cwd: targetPath
54
+ cwd: dest
56
55
  }));
57
56
  }
57
+ // install
58
+ queue.defer(spawn.bind(null, 'npm', [
59
+ '--silent',
60
+ 'install'
61
+ ], {
62
+ cwd: dest
63
+ }));
58
64
  queue.await(callback);
59
65
  });
60
66
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["installGitRepo.ts"],"sourcesContent":["import path from 'path';\nimport spawn from 'cross-spawn-cb';\nimport access from 'fs-access-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\n\nexport default function installGitRepo(repo: string, dest: string, options, callback?) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n console.log('installGitRepo', repo, dest);\n // options.clean = true;\n\n function checkOrClean(dest, callback) {\n options.clean ? rimraf2(dest, { disableGlob: true }, callback.bind(null, new Error('clone'))) : access(dest, callback);\n }\n\n checkOrClean(dest, (err) => {\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, dest));\n\n // does not exist - clone\n if (err) {\n queue.defer(spawn.bind(null, 'git', ['clone', repo, path.basename(dest)], { stdio: 'inherit', cwd: path.dirname(dest) }));\n }\n // exists - reset git\n else {\n queue.defer(spawn.bind(null, 'git', ['clean', '-fd'], { stdio: 'inherit', cwd: dest }));\n queue.defer(spawn.bind(null, 'git', ['reset', '--hard', 'HEAD'], { stdio: 'inherit', cwd: dest }));\n queue.defer(spawn.bind(null, 'git', ['pull', '--rebase'], { stdio: 'inherit', cwd: dest }));\n }\n\n // install\n queue.defer(spawn.bind(null, 'npm', ['--silent', 'install'], { cwd: dest }));\n\n queue.await(callback);\n });\n}\n"],"names":["path","spawn","access","mkdirp","Queue","rimraf2","installGitRepo","repo","dest","options","callback","console","log","checkOrClean","clean","disableGlob","bind","Error","err","queue","defer","basename","stdio","cwd","dirname","await"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,W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AEA,UAAU;QACVW,MAAMC,KAAK,CAACnB,MAAMe,IAAI,CAAC,MAAM,OAAO;YAAC;YAAY;SAAU,EAAE;YAAEO,KAAKf;QAAK;QAEzEW,MAAMM,KAAK,CAACf;IACd;AACF"}
@@ -0,0 +1,47 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import url from 'url';
4
+ import access from 'fs-access-compat';
5
+ import mkdirp from 'mkdirp-classic';
6
+ import Queue from 'queue-cb';
7
+ import { link, packageRoot, wrapWorker } from 'tsds-lib';
8
+ const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
9
+ const major = +process.versions.node.split('.')[0];
10
+ const workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));
11
+ function linkBin(src, binPath, nodeModules, binName, callback) {
12
+ const binFullPath = path.resolve.apply(null, [
13
+ src,
14
+ ...binPath.split('/')
15
+ ]);
16
+ const destBin = path.resolve(nodeModules, '.bin', binName);
17
+ access(binFullPath, (err)=>{
18
+ if (!err) return link(binFullPath, destBin, callback);
19
+ console.log(`bin not found: ${binFullPath}. Skipping`);
20
+ callback();
21
+ });
22
+ }
23
+ function worker(src, nodeModules, _options, callback) {
24
+ const pkg = JSON.parse(fs.readFileSync(path.join(src, 'package.json'), 'utf8'));
25
+ const dest = path.resolve.apply(null, [
26
+ nodeModules,
27
+ ...pkg.name.split('/')
28
+ ]);
29
+ mkdirp(path.dirname(dest), (err)=>{
30
+ if (err) return callback(err);
31
+ const queue = new Queue();
32
+ queue.defer(link.bind(null, src, dest));
33
+ if (typeof pkg.bin === 'string') queue.defer(linkBin.bind(null, src, pkg.bin, nodeModules, pkg.name)); // single bins
34
+ else for(const binName in pkg.bin)queue.defer(linkBin.bind(null, src, pkg.bin[binName], nodeModules, binName)); // object of bins
35
+ queue.await((err)=>{
36
+ err ? callback(err) : callback(null, dest);
37
+ });
38
+ });
39
+ }
40
+ export default function linkModule(src, nodeModules, options, callback) {
41
+ if (typeof options === 'function') {
42
+ callback = options;
43
+ options = {};
44
+ }
45
+ options = options || {};
46
+ major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);
47
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["linkModule.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport access from 'fs-access-compat';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport { link, packageRoot, wrapWorker } from 'tsds-lib';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst major = +process.versions.node.split('.')[0];\nconst workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));\n\nfunction linkBin(src, binPath, nodeModules, binName, callback) {\n const binFullPath = path.resolve.apply(null, [src, ...binPath.split('/')]);\n const destBin = path.resolve(nodeModules, '.bin', binName);\n\n access(binFullPath, (err) => {\n if (!err) return link(binFullPath, destBin, callback);\n console.log(`bin not found: ${binFullPath}. Skipping`);\n callback();\n });\n}\n\nfunction worker(src, nodeModules, _options, callback) {\n const pkg = JSON.parse(fs.readFileSync(path.join(src, 'package.json'), 'utf8'));\n const dest = path.resolve.apply(null, [nodeModules, ...pkg.name.split('/')]);\n\n mkdirp(path.dirname(dest), (err) => {\n if (err) return callback(err);\n\n const queue = new Queue();\n queue.defer(link.bind(null, src, dest));\n\n if (typeof pkg.bin === 'string')\n queue.defer(linkBin.bind(null, src, pkg.bin, nodeModules, pkg.name)); // single bins\n else for (const binName in pkg.bin) queue.defer(linkBin.bind(null, src, pkg.bin[binName], nodeModules, binName)); // object of bins\n\n queue.await((err) => {\n err ? callback(err) : callback(null, dest);\n });\n });\n}\n\nexport default function linkModule(src: string, nodeModules: string, options, callback?) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);\n}\n"],"names":["fs","path","url","access","mkdirp","Queue","link","packageRoot","wrapWorker","__dirname","dirname","__filename","fileURLToPath","major","process","versions","node","split","workerWrapper","join","linkBin","src","binPath","nodeModules","binName","callback","binFullPath","resolve","apply","destBin","err","console","log","worker","_options","pkg","JSON","parse","readFileSync","dest","name","queue","defer","bind","bin","await","linkModule","options"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,YAAY,mBAAmB;AACtC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,WAAW,WAAW;AAC7B,SAASC,IAAI,EAAEC,WAAW,EAAEC,UAAU,QAAQ,WAAW;AAEzD,MAAMC,YAAYR,KAAKS,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaT,IAAIU,aAAa,CAAC,YAAYV,GAAG;AACjH,MAAMW,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,gBAAgBV,WAAWP,KAAKkB,IAAI,CAACZ,YAAYE,YAAY,QAAQ,OAAO,OAAO;AAEzF,SAASW,QAAQC,GAAG,EAAEC,OAAO,EAAEC,WAAW,EAAEC,OAAO,EAAEC,QAAQ;IAC3D,MAAMC,cAAczB,KAAK0B,OAAO,CAACC,KAAK,CAAC,MAAM;QAACP;WAAQC,QAAQL,KAAK,CAAC;KAAK;IACzE,MAAMY,UAAU5B,KAAK0B,OAAO,CAACJ,aAAa,QAAQC;IAElDrB,OAAOuB,aAAa,CAACI;QACnB,IAAI,CAACA,KAAK,OAAOxB,KAAKoB,aAAaG,SAASJ;QAC5CM,QAAQC,GAAG,CAAC,CAAC,eAAe,EAAEN,YAAY,UAAU,CAAC;QACrDD;IACF;AACF;AAEA,SAASQ,OAAOZ,GAAG,EAAEE,WAAW,EAAEW,QAAQ,EAAET,QAAQ;IAClD,MAAMU,MAAMC,KAAKC,KAAK,CAACrC,GAAGsC,YAAY,CAACrC,KAAKkB,IAAI,CAACE,KAAK,iBAAiB;IACvE,MAAMkB,OAAOtC,KAAK0B,OAAO,CAACC,KAAK,CAAC,MAAM;QAACL;WAAgBY,IAAIK,IAAI,CAACvB,KAAK,CAAC;KAAK;IAE3Eb,OAAOH,KAAKS,OAAO,CAAC6B,OAAO,CAACT;QAC1B,IAAIA,KAAK,OAAOL,SAASK;QAEzB,MAAMW,QAAQ,IAAIpC;QAClBoC,MAAMC,KAAK,CAACpC,KAAKqC,IAAI,CAAC,MAAMtB,KAAKkB;QAEjC,IAAI,OAAOJ,IAAIS,GAAG,KAAK,UACrBH,MAAMC,KAAK,CAACtB,QAAQuB,IAAI,CAAC,MAAMtB,KAAKc,IAAIS,GAAG,EAAErB,aAAaY,IAAIK,IAAI,IAAI,cAAc;aACjF,IAAK,MAAMhB,WAAWW,IAAIS,GAAG,CAAEH,MAAMC,KAAK,CAACtB,QAAQuB,IAAI,CAAC,MAAMtB,KAAKc,IAAIS,GAAG,CAACpB,QAAQ,EAAED,aAAaC,WAAW,iBAAiB;QAEnIiB,MAAMI,KAAK,CAAC,CAACf;YACXA,MAAML,SAASK,OAAOL,SAAS,MAAMc;QACvC;IACF;AACF;AAEA,eAAe,SAASO,WAAWzB,GAAW,EAAEE,WAAmB,EAAEwB,OAAO,EAAEtB,QAAS;IACrF,IAAI,OAAOsB,YAAY,YAAY;QACjCtB,WAAWsB;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtBlC,QAAQ,KAAKK,cAAc,UAAUG,KAAKE,aAAawB,SAAStB,YAAYQ,OAAOZ,KAAKE,aAAawB,SAAStB;AAChH"}
@@ -0,0 +1,39 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import url from 'url';
4
+ import access from 'fs-access-compat';
5
+ import Queue from 'queue-cb';
6
+ import { packageRoot, unlink, wrapWorker } from 'tsds-lib';
7
+ const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
8
+ const major = +process.versions.node.split('.')[0];
9
+ const workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));
10
+ function unlinkBin(nodeModules, binName, callback) {
11
+ const destBin = path.resolve(nodeModules, '.bin', binName);
12
+ access(destBin, (err)=>{
13
+ if (!err) return unlink(destBin, callback);
14
+ console.log(`bin not found: ${destBin}. Skipping`);
15
+ callback();
16
+ });
17
+ }
18
+ function worker(src, nodeModules, _options, callback) {
19
+ const pkg = JSON.parse(fs.readFileSync(path.join(src, 'package.json'), 'utf8'));
20
+ const dest = path.resolve.apply(null, [
21
+ nodeModules,
22
+ ...pkg.name.split('/')
23
+ ]);
24
+ const queue = new Queue(1);
25
+ queue.defer(unlink.bind(null, dest));
26
+ if (typeof pkg.bin === 'string') queue.defer(unlinkBin.bind(null, nodeModules, pkg.name)); // single bins
27
+ else for(const binName in pkg.bin)queue.defer(unlinkBin.bind(null, nodeModules, binName)); // object of bins
28
+ queue.await((err)=>{
29
+ err ? callback(err) : callback(null, dest);
30
+ });
31
+ }
32
+ export default function unlinkModule(src, nodeModules, options, callback) {
33
+ if (typeof options === 'function') {
34
+ callback = options;
35
+ options = {};
36
+ }
37
+ options = options || {};
38
+ major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);
39
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["unlinkModule.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport access from 'fs-access-compat';\nimport Queue from 'queue-cb';\nimport { packageRoot, unlink, wrapWorker } from 'tsds-lib';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst major = +process.versions.node.split('.')[0];\nconst workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));\n\nfunction unlinkBin(nodeModules, binName, callback) {\n const destBin = path.resolve(nodeModules, '.bin', binName);\n\n access(destBin, (err) => {\n if (!err) return unlink(destBin, callback);\n console.log(`bin not found: ${destBin}. Skipping`);\n callback();\n });\n}\n\nfunction worker(src, nodeModules, _options, callback) {\n const pkg = JSON.parse(fs.readFileSync(path.join(src, 'package.json'), 'utf8'));\n const dest = path.resolve.apply(null, [nodeModules, ...pkg.name.split('/')]);\n\n const queue = new Queue(1);\n queue.defer(unlink.bind(null, dest));\n\n if (typeof pkg.bin === 'string')\n queue.defer(unlinkBin.bind(null, nodeModules, pkg.name)); // single bins\n else for (const binName in pkg.bin) queue.defer(unlinkBin.bind(null, nodeModules, binName)); // object of bins\n\n queue.await((err) => {\n err ? callback(err) : callback(null, dest);\n });\n}\n\nexport default function unlinkModule(src: string, nodeModules: string, options, callback?) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n major < 14 ? workerWrapper('stable', src, nodeModules, options, callback) : worker(src, nodeModules, options, callback);\n}\n"],"names":["fs","path","url","access","Queue","packageRoot","unlink","wrapWorker","__dirname","dirname","__filename","fileURLToPath","major","process","versions","node","split","workerWrapper","join","unlinkBin","nodeModules","binName","callback","destBin","resolve","err","console","log","worker","src","_options","pkg","JSON","parse","readFileSync","dest","apply","name","queue","defer","bind","bin","await","unlinkModule","options"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,YAAY,mBAAmB;AACtC,OAAOC,WAAW,WAAW;AAC7B,SAASC,WAAW,EAAEC,MAAM,EAAEC,UAAU,QAAQ,WAAW;AAE3D,MAAMC,YAAYP,KAAKQ,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaR,IAAIS,aAAa,CAAC,YAAYT,GAAG;AACjH,MAAMU,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,gBAAgBV,WAAWN,KAAKiB,IAAI,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awB,SAAStB,YAAYM,OAAOC,KAAKT,aAAawB,SAAStB;AAChH"}
@@ -1 +1 @@
1
- {"type":"module"}
1
+ {"type":"commonjs"}
@@ -1,2 +1,3 @@
1
- export { default as data } from './lib/data.js';
2
- export { default as prepareGit } from './lib/prepareGit.js';
1
+ export { default as linkModule } from './lib/linkModule.js';
2
+ export { default as installGitRepo } from './lib/installGitRepo.js';
3
+ export { default as unlinkModule } from './lib/unlinkModule.js';
@@ -0,0 +1 @@
1
+ export default function installGitRepo(repo: string, dest: string, options: any, callback?: any): void;
@@ -0,0 +1 @@
1
+ export default function linkModule(src: string, nodeModules: string, options: any, callback?: any): void;
@@ -0,0 +1 @@
1
+ export default function unlinkModule(src: string, nodeModules: string, options: any, callback?: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsds-lib-test",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "description": "Development stack for TypeScript libraries",
5
5
  "keywords": [
6
6
  "dev",
@@ -44,11 +44,9 @@
44
44
  "cross-spawn-cb": "^1.4.0",
45
45
  "fs-access-compat": "^1.0.3",
46
46
  "mkdirp-classic": "^0.5.3",
47
- "os-shim": "^0.1.3",
48
47
  "queue-cb": "^1.4.4",
49
48
  "rimraf2": "^2.8.2",
50
- "short-hash": "^1.0.0",
51
- "tsds-lib": "^1.5.5"
49
+ "tsds-lib": "^1.6.0"
52
50
  },
53
51
  "devDependencies": {
54
52
  "@biomejs/biome": "^1.9.4",
@@ -63,5 +61,5 @@
63
61
  "tsds": {
64
62
  "source": "src/index.ts"
65
63
  },
66
- "gitHead": "7f5d599f4c74c5b3d6a699546116879daa1cbabb"
64
+ "gitHead": "2be88a7dc0bf79560db46877f36d0a260e24b028"
67
65
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["data.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport spawn from 'cross-spawn-cb';\nimport mkdirp from 'mkdirp-classic';\nimport os from 'os-shim';\nimport Queue from 'queue-cb';\nimport shortHash from 'short-hash';\nimport { packageRoot, wrapWorker } from 'tsds-lib';\nimport prepareGit from './prepareGit.js';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst major = +process.versions.node.split('.')[0];\nconst workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));\n\nfunction worker(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));\n const dest = path.join(os.tmpdir(), pkg.name, shortHash(cwd));\n const targetName = path.basename(git, path.extname(git));\n const targetPath = path.join(dest, targetName);\n mkdirp.sync(dest);\n\n const queue = new Queue(1);\n for (const binName in pkg.bin) {\n const packagePath = path.resolve(targetPath, 'node_modules', pkg.name);\n const binPath = path.resolve(targetPath, 'node_modules', '.bin', binName);\n\n console.log('------------------');\n console.log(`Preparing: ${targetPath}`);\n\n // clone or reset the git repo\n queue.defer(prepareGit.bind(null, git, options));\n\n // install\n queue.defer(spawn.bind(null, 'npm', ['--silent', 'install'], { cwd: targetPath }));\n\n // link package\n queue.defer(fs.rename.bind(null, packagePath, `${packagePath}.tsds`));\n queue.defer(fs.symlink.bind(null, cwd, packagePath, 'dir'));\n\n // link bin\n queue.defer(fs.rename.bind(null, binPath, `${binPath}.tsds`));\n queue.defer(fs.symlink.bind(null, path.resolve.apply(null, [cwd, ...pkg.bin[binName].split('/')]), binPath, 'file'));\n\n queue.await((err) => {\n console.log('------------------');\n err ? callback(err) : callback(null, targetPath);\n });\n }\n}\n\nexport default function data(git, options, callback) {\n major < 14 ? workerWrapper('stable', git, options, callback) : worker(git, options, callback);\n}\n"],"names":["data","__dirname","path","dirname","__filename","url","fileURLToPath","major","process","versions","node","split","workerWrapper","wrapWorker","join","packageRoot","worker","git","options","callback","cwd","pkg","JSON","parse","fs","readFileSync","dest","os","tmpdir","name","shortHash","targetName","basename","extname","targetPath","mkdirp","sync","queue","Queue","binName","bin","packagePath","resolve","binPath","console","log","defer","prepareGit","bind","spawn","rename","symlink","apply","await","err"],"mappings":";;;;+BAoDA;;;eAAwBA;;;yDApDT;2DACE;0DACD;mEACE;oEACC;6DACJ;8DACG;gEACI;uBACkB;iEACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvB,IAAMC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAClG,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,gBAAgBC,IAAAA,mBAAU,EAACX,aAAI,CAACY,IAAI,CAACC,IAAAA,oBAAW,EAACd,YAAY,QAAQ,OAAO,OAAO;AAEzF,SAASe,OAAOC,GAAG,EAAEC,OAAO,EAAEC,QAAQ;IACpC,IAAMC,MAAMF,QAAQE,GAAG,IAAIZ,QAAQY,GAAG;IACtC,IAAMC,MAAMC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACvB,aAAI,CAACY,IAAI,CAACM,KAAK,iBAAiB;IACvE,IAAMM,OAAOxB,aAAI,CAACY,IAAI,CAACa,eAAE,CAACC,MAAM,IAAIP,IAAIQ,IAAI,EAAEC,IAAAA,kBAAS,EAACV;IACxD,IAAMW,aAAa7B,aAAI,CAAC8B,QAAQ,CAACf,KAAKf,aAAI,CAAC+B,OAAO,CAAChB;IACnD,IAAMiB,aAAahC,aAAI,CAACY,IAAI,CAACY,MAAMK;IACnCI,sBAAM,CAACC,IAAI,CAACV;IAEZ,IAAMW,QAAQ,IAAIC,gBAAK,CAAC;IACxB,IAAK,IAAMC,WAAWlB,IAAImB,GAAG,CAAE;QAC7B,IAAMC,cAAcvC,aAAI,CAACwC,OAAO,CAACR,YAAY,gBAAgBb,IAAIQ,IAAI;QACrE,IAAMc,UAAUzC,aAAI,CAACwC,OAAO,CAACR,YAAY,gBAAgB,QAAQK;QAEjEK,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC,AAAC,cAAwB,OAAXX;QAE1B,8BAA8B;QAC9BG,MAAMS,KAAK,CAACC,mBAAU,CAACC,IAAI,CAAC,MAAM/B,KAAKC;QAEvC,UAAU;QACVmB,MAAMS,KAAK,CAACG,qBAAK,CAACD,IAAI,CAAC,MAAM,OAAO;YAAC;YAAY;SAAU,EAAE;YAAE5B,KAAKc;QAAW;QAE/E,eAAe;QACfG,MAAMS,KAAK,CAACtB,WAAE,CAAC0B,MAAM,CAACF,IAAI,CAAC,MAAMP,aAAa,AAAC,GAAc,OAAZA,aAAY;QAC7DJ,MAAMS,KAAK,CAACtB,WAAE,CAAC2B,OAAO,CAACH,IAAI,CAAC,MAAM5B,KAAKqB,aAAa;QAEpD,WAAW;QACXJ,MAAMS,KAAK,CAACtB,WAAE,CAAC0B,MAAM,CAACF,IAAI,CAAC,MAAML,SAAS,AAAC,GAAU,OAARA,SAAQ;QACrDN,MAAMS,KAAK,CAACtB,WAAE,CAAC2B,OAAO,CAACH,IAAI,CAAC,MAAM9C,aAAI,CAACwC,OAAO,CAACU,KAAK,CAAC,MAAM;YAAChC;SAAoC,CAArC,OAAM,qBAAGC,IAAImB,GAAG,CAACD,QAAQ,CAAC5B,KAAK,CAAC,SAAQgC,SAAS;QAE5GN,MAAMgB,KAAK,CAAC,SAACC;YACXV,QAAQC,GAAG,CAAC;YACZS,MAAMnC,SAASmC,OAAOnC,SAAS,MAAMe;QACvC;IACF;AACF;AAEe,SAASlC,KAAKiB,GAAG,EAAEC,OAAO,EAAEC,QAAQ;IACjDZ,QAAQ,KAAKK,cAAc,UAAUK,KAAKC,SAASC,YAAYH,OAAOC,KAAKC,SAASC;AACtF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["prepareGit.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport spawn from 'cross-spawn-cb';\nimport access from 'fs-access-compat';\nimport mkdirp from 'mkdirp-classic';\nimport os from 'os-shim';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\nimport shortHash from 'short-hash';\n\nexport default function prepareGit(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));\n const dest = path.join(os.tmpdir(), pkg.name, shortHash(cwd));\n const targetName = path.basename(git, path.extname(git));\n const targetPath = path.join(dest, targetName);\n mkdirp.sync(dest);\n\n access(targetPath, (err) => {\n if (!err && options.clean) {\n rimraf2.sync(targetPath, { disableGlob: true });\n err = true;\n }\n\n const queue = new Queue(1);\n // does not exist - clone\n if (err) {\n queue.defer(spawn.bind(null, 'git', ['clone', git], { stdio: 'inherit', cwd: dest }));\n }\n // exists - reset git\n else {\n queue.defer(spawn.bind(null, 'git', ['clean', '-fd'], { stdio: 'inherit', cwd: targetPath }));\n queue.defer(spawn.bind(null, 'git', ['reset', '--hard', 'HEAD'], { stdio: 'inherit', cwd: targetPath }));\n queue.defer(spawn.bind(null, 'git', ['pull', '--rebase'], { stdio: 'inherit', cwd: targetPath }));\n }\n\n queue.await(callback);\n });\n}\n"],"names":["prepareGit","git","options","callback","cwd","process","pkg","JSON","parse","fs","readFileSync","path","join","dest","os","tmpdir","name","shortHash","targetName","basename","extname","targetPath","mkdirp","sync","access","err","clean","rimraf2","disableGlob","queue","Queue","defer","spawn","bind","stdio","await"],"mappings":";;;;+BAUA;;;eAAwBA;;;yDAVT;2DACE;mEACC;qEACC;oEACA;6DACJ;8DACG;8DACE;gEACE;;;;;;AAEP,SAASA,WAAWC,GAAG,EAAEC,OAAO,EAAEC,QAAQ;IACvD,IAAMC,MAAMF,QAAQE,GAAG,IAAIC,QAAQD,GAAG;IACtC,IAAME,MAAMC,KAAKC,KAAK,CAACC,WAAE,CAACC,YAAY,CAACC,aAAI,CAACC,IAAI,CAACR,KAAK,iBAAiB;IACvE,IAAMS,OAAOF,aAAI,CAACC,IAAI,CAACE,eAAE,CAACC,MAAM,IAAIT,IAAIU,IAAI,EAAEC,IAAAA,kBAAS,EAACb;IACxD,IAAMc,aAAaP,aAAI,CAACQ,QAAQ,CAAClB,KAAKU,aAAI,CAACS,OAAO,CAACnB;IACnD,IAAMoB,aAAaV,aAAI,CAACC,IAAI,CAACC,MAAMK;IACnCI,sBAAM,CAACC,IAAI,CAACV;IAEZW,IAAAA,uBAAM,EAACH,YAAY,SAACI;QAClB,IAAI,CAACA,OAAOvB,QAAQwB,KAAK,EAAE;YACzBC,gBAAO,CAACJ,IAAI,CAACF,YAAY;gBAAEO,aAAa;YAAK;YAC7CH,MAAM;QACR;QAEA,IAAMI,QAAQ,IAAIC,gBAAK,CAAC;QACxB,yBAAyB;QACzB,IAAIL,KAAK;YACPI,MAAME,KAAK,CAACC,qBAAK,CAACC,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAShC;aAAI,EAAE;gBAAEiC,OAAO;gBAAW9B,KAAKS;YAAK;QACpF,OAEK;YACHgB,MAAME,KAAK,CAACC,qBAAK,CAACC,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;aAAM,EAAE;gBAAEC,OAAO;gBAAW9B,KAAKiB;YAAW;YAC1FQ,MAAME,KAAK,CAACC,qBAAK,CAACC,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;gBAAU;aAAO,EAAE;gBAAEC,OAAO;gBAAW9B,KAAKiB;YAAW;YACrGQ,MAAME,KAAK,CAACC,qBAAK,CAACC,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAQ;aAAW,EAAE;gBAAEC,OAAO;gBAAW9B,KAAKiB;YAAW;QAChG;QAEAQ,MAAMM,KAAK,CAAChC;IACd;AACF"}
@@ -1,53 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import url from 'url';
4
- import spawn from 'cross-spawn-cb';
5
- import mkdirp from 'mkdirp-classic';
6
- import os from 'os-shim';
7
- import Queue from 'queue-cb';
8
- import shortHash from 'short-hash';
9
- import { packageRoot, wrapWorker } from 'tsds-lib';
10
- import prepareGit from './prepareGit.mjs';
11
- const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
12
- const major = +process.versions.node.split('.')[0];
13
- const workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));
14
- function worker(git, options, callback) {
15
- const cwd = options.cwd || process.cwd();
16
- const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
17
- const dest = path.join(os.tmpdir(), pkg.name, shortHash(cwd));
18
- const targetName = path.basename(git, path.extname(git));
19
- const targetPath = path.join(dest, targetName);
20
- mkdirp.sync(dest);
21
- const queue = new Queue(1);
22
- for(const binName in pkg.bin){
23
- const packagePath = path.resolve(targetPath, 'node_modules', pkg.name);
24
- const binPath = path.resolve(targetPath, 'node_modules', '.bin', binName);
25
- console.log('------------------');
26
- console.log(`Preparing: ${targetPath}`);
27
- // clone or reset the git repo
28
- queue.defer(prepareGit.bind(null, git, options));
29
- // install
30
- queue.defer(spawn.bind(null, 'npm', [
31
- '--silent',
32
- 'install'
33
- ], {
34
- cwd: targetPath
35
- }));
36
- // link package
37
- queue.defer(fs.rename.bind(null, packagePath, `${packagePath}.tsds`));
38
- queue.defer(fs.symlink.bind(null, cwd, packagePath, 'dir'));
39
- // link bin
40
- queue.defer(fs.rename.bind(null, binPath, `${binPath}.tsds`));
41
- queue.defer(fs.symlink.bind(null, path.resolve.apply(null, [
42
- cwd,
43
- ...pkg.bin[binName].split('/')
44
- ]), binPath, 'file'));
45
- queue.await((err)=>{
46
- console.log('------------------');
47
- err ? callback(err) : callback(null, targetPath);
48
- });
49
- }
50
- }
51
- export default function data(git, options, callback) {
52
- major < 14 ? workerWrapper('stable', git, options, callback) : worker(git, options, callback);
53
- }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["data.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport spawn from 'cross-spawn-cb';\nimport mkdirp from 'mkdirp-classic';\nimport os from 'os-shim';\nimport Queue from 'queue-cb';\nimport shortHash from 'short-hash';\nimport { packageRoot, wrapWorker } from 'tsds-lib';\nimport prepareGit from './prepareGit.js';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst major = +process.versions.node.split('.')[0];\nconst workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));\n\nfunction worker(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));\n const dest = path.join(os.tmpdir(), pkg.name, shortHash(cwd));\n const targetName = path.basename(git, path.extname(git));\n const targetPath = path.join(dest, targetName);\n mkdirp.sync(dest);\n\n const queue = new Queue(1);\n for (const binName in pkg.bin) {\n const packagePath = path.resolve(targetPath, 'node_modules', pkg.name);\n const binPath = path.resolve(targetPath, 'node_modules', '.bin', binName);\n\n console.log('------------------');\n console.log(`Preparing: ${targetPath}`);\n\n // clone or reset the git repo\n queue.defer(prepareGit.bind(null, git, options));\n\n // install\n queue.defer(spawn.bind(null, 'npm', ['--silent', 'install'], { cwd: targetPath }));\n\n // link package\n queue.defer(fs.rename.bind(null, packagePath, `${packagePath}.tsds`));\n queue.defer(fs.symlink.bind(null, cwd, packagePath, 'dir'));\n\n // link bin\n queue.defer(fs.rename.bind(null, binPath, `${binPath}.tsds`));\n queue.defer(fs.symlink.bind(null, path.resolve.apply(null, [cwd, ...pkg.bin[binName].split('/')]), binPath, 'file'));\n\n queue.await((err) => {\n console.log('------------------');\n err ? callback(err) : callback(null, targetPath);\n });\n }\n}\n\nexport default function data(git, options, callback) {\n major < 14 ? workerWrapper('stable', git, options, callback) : worker(git, options, callback);\n}\n"],"names":["fs","path","url","spawn","mkdirp","os","Queue","shortHash","packageRoot","wrapWorker","prepareGit","__dirname","dirname","__filename","fileURLToPath","major","process","versions","node","split","workerWrapper","join","worker","git","options","callback","cwd","pkg","JSON","parse","readFileSync","dest","tmpdir","name","targetName","basename","extname","targetPath","sync","queue","binName","bin","packagePath","resolve","binPath","console","log","defer","bind","rename","symlink","apply","await","err","data"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,QAAQ,UAAU;AACzB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,eAAe,aAAa;AACnC,SAASC,WAAW,EAAEC,UAAU,QAAQ,WAAW;AACnD,OAAOC,gBAAgB,kBAAkB;AAEzC,MAAMC,YAAYV,KAAKW,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaX,IAAIY,aAAa,CAAC,YAAYZ,GAAG;AACjH,MAAMa,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,gBAAgBX,WAAWR,KAAKoB,IAAI,CAACb,YAAYG,YAAY,QAAQ,OAAO,OAAO;AAEzF,SAASW,OAAOC,GAAG,EAAEC,OAAO,EAAEC,QAAQ;IACpC,MAAMC,MAAMF,QAAQE,GAAG,IAAIV,QAAQU,GAAG;IACtC,MAAMC,MAAMC,KAAKC,KAAK,CAAC7B,GAAG8B,YAAY,CAAC7B,KAAKoB,IAAI,CAACK,KAAK,iBAAiB;IACvE,MAAMK,OAAO9B,KAAKoB,IAAI,CAAChB,GAAG2B,MAAM,IAAIL,IAAIM,IAAI,EAAE1B,UAAUmB;IACxD,MAAMQ,aAAajC,KAAKkC,QAAQ,CAACZ,KAAKtB,KAAKmC,OAAO,CAACb;IACnD,MAAMc,aAAapC,KAAKoB,IAAI,CAACU,MAAMG;IACnC9B,OAAOkC,IAAI,CAACP;IAEZ,MAAMQ,QAAQ,IAAIjC,MAAM;IACxB,IAAK,MAAMkC,WAAWb,IAAIc,G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areGit.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport spawn from 'cross-spawn-cb';\nimport access from 'fs-access-compat';\nimport mkdirp from 'mkdirp-classic';\nimport os from 'os-shim';\nimport Queue from 'queue-cb';\nimport rimraf2 from 'rimraf2';\nimport shortHash from 'short-hash';\n\nexport default function prepareGit(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));\n const dest = path.join(os.tmpdir(), pkg.name, shortHash(cwd));\n const targetName = path.basename(git, path.extname(git));\n const targetPath = path.join(dest, targetName);\n mkdirp.sync(dest);\n\n access(targetPath, (err) => {\n if (!err && options.clean) {\n rimraf2.sync(targetPath, { disableGlob: true });\n err = true;\n }\n\n const queue = new Queue(1);\n // does not exist - clone\n if (err) {\n queue.defer(spawn.bind(null, 'git', ['clone', git], { stdio: 'inherit', cwd: dest }));\n }\n // exists - reset git\n else {\n queue.defer(spawn.bind(null, 'git', ['clean', '-fd'], { stdio: 'inherit', cwd: targetPath }));\n queue.defer(spawn.bind(null, 'git', ['reset', '--hard', 'HEAD'], { stdio: 'inherit', cwd: targetPath }));\n queue.defer(spawn.bind(null, 'git', ['pull', '--rebase'], { stdio: 'inherit', cwd: targetPath }));\n }\n\n queue.await(callback);\n });\n}\n"],"names":["fs","path","spawn","access","mkdirp","os","Queue","rimraf2","shortHash","prepareGit","git","options","callback","cwd","process","pkg","JSON","parse","readFileSync","join","dest","tmpdir","name","targetName","basename","extname","targetPath","sync","err","clean","disableGlob","queue","defer","bind","stdio","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,YAAY,mBAAmB;AACtC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,QAAQ,UAAU;AACzB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAC9B,OAAOC,eAAe,aAAa;AAEnC,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@ -1 +0,0 @@
1
- export default function data(git: any, options: any, callback: any): void;
@@ -1 +0,0 @@
1
- export default function prepareGit(git: any, options: any, callback: any): void;