tsds-lib-test 1.5.5 → 1.5.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/dist/cjs/index.js CHANGED
@@ -9,15 +9,15 @@ 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
17
  }
18
18
  });
19
- var _data = /*#__PURE__*/ _interop_require_default(require("./lib/data.js"));
20
- var _prepareGit = /*#__PURE__*/ _interop_require_default(require("./lib/prepareGit.js"));
19
+ var _linkModule = /*#__PURE__*/ _interop_require_default(require("./lib/linkModule.js"));
20
+ var _installGitRepo = /*#__PURE__*/ _interop_require_default(require("./lib/installGitRepo.js"));
21
21
  function _interop_require_default(obj) {
22
22
  return obj && obj.__esModule ? obj : {
23
23
  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';\n"],"names":["installGitRepo","linkModule"],"mappings":";;;;;;;;;;;IACoBA,cAAc;eAAdA,uBAAc;;IADdC,UAAU;eAAVA,mBAAU;;;iEAAQ;qEACI"}
@@ -5,46 +5,44 @@ 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
+ // options.clean = true;
29
+ function checkOrClean(dest, callback) {
30
+ options.clean ? (0, _rimraf2.default)(dest, {
31
+ disableGlob: true
32
+ }, callback.bind(null, new Error('clone'))) : (0, _fsaccesscompat.default)(dest, callback);
33
+ }
34
+ checkOrClean(dest, function(err) {
39
35
  var queue = new _queuecb.default(1);
36
+ queue.defer(_mkdirpclassic.default.bind(null, dest));
40
37
  // does not exist - clone
41
38
  if (err) {
42
39
  queue.defer(_crossspawncb.default.bind(null, 'git', [
43
40
  'clone',
44
- git
41
+ repo,
42
+ _path.default.basename(dest)
45
43
  ], {
46
44
  stdio: 'inherit',
47
- cwd: dest
45
+ cwd: _path.default.dirname(dest)
48
46
  }));
49
47
  } else {
50
48
  queue.defer(_crossspawncb.default.bind(null, 'git', [
@@ -52,7 +50,7 @@ function prepareGit(git, options, callback) {
52
50
  '-fd'
53
51
  ], {
54
52
  stdio: 'inherit',
55
- cwd: targetPath
53
+ cwd: dest
56
54
  }));
57
55
  queue.defer(_crossspawncb.default.bind(null, 'git', [
58
56
  'reset',
@@ -60,16 +58,23 @@ function prepareGit(git, options, callback) {
60
58
  'HEAD'
61
59
  ], {
62
60
  stdio: 'inherit',
63
- cwd: targetPath
61
+ cwd: dest
64
62
  }));
65
63
  queue.defer(_crossspawncb.default.bind(null, 'git', [
66
64
  'pull',
67
65
  '--rebase'
68
66
  ], {
69
67
  stdio: 'inherit',
70
- cwd: targetPath
68
+ cwd: dest
71
69
  }));
72
70
  }
71
+ // install
72
+ queue.defer(_crossspawncb.default.bind(null, 'npm', [
73
+ '--silent',
74
+ 'install'
75
+ ], {
76
+ cwd: dest
77
+ }));
73
78
  queue.await(callback);
74
79
  });
75
80
  }
@@ -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 // 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","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;IACtB,wBAAwB;IAExB,SAASE,aAAaH,IAAI,EAAEE,QAAQ;QAClCD,QAAQG,KAAK,GAAGC,IAAAA,gBAAO,EAACL,MAAM;YAAEM,aAAa;QAAK,GAAGJ,SAASK,IAAI,CAAC,MAAM,IAAIC,MAAM,aAAaC,IAAAA,uBAAM,EAACT,MAAME;IAC/G;IAEAC,aAAaH,MAAM,SAACU;QAClB,IAAMC,QAAQ,IAAIC,gBAAK,CAAC;QACxBD,MAAME,KAAK,CAACC,sBAAM,CAACP,IAAI,CAAC,MAAMP;QAE9B,yBAAyB;QACzB,IAAIU,KAAK;YACPC,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAASR;gBAAMiB,aAAI,CAACC,QAAQ,CAACjB;aAAM,EAAE;gBAAEkB,OAAO;gBAAWC,KAAKH,aAAI,CAACI,OAAO,CAACpB;YAAM;QACxH,OAEK;YACHW,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;aAAM,EAAE;gBAAEW,OAAO;gBAAWC,KAAKnB;YAAK;YACpFW,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;gBAAU;aAAO,EAAE;gBAAEW,OAAO;gBAAWC,KAAKnB;YAAK;YAC/FW,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAQ;aAAW,EAAE;gBAAEW,OAAO;gBAAWC,KAAKnB;YAAK;QAC1F;QAEA,UAAU;QACVW,MAAME,KAAK,CAACE,qBAAK,CAACR,IAAI,CAAC,MAAM,OAAO;YAAC;YAAY;SAAU,EAAE;YAAEY,KAAKnB;QAAK;QAEzEW,MAAMU,KAAK,CAACnB;IACd;AACF"}
@@ -5,19 +5,14 @@ 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"));
15
- var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
16
- var _osshim = /*#__PURE__*/ _interop_require_default(require("os-shim"));
17
14
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
18
- var _shorthash = /*#__PURE__*/ _interop_require_default(require("short-hash"));
19
15
  var _tsdslib = require("tsds-lib");
20
- var _prepareGit = /*#__PURE__*/ _interop_require_default(require("./prepareGit.js"));
21
16
  function _array_like_to_array(arr, len) {
22
17
  if (len == null || len > arr.length) len = arr.length;
23
18
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -51,43 +46,37 @@ function _unsupported_iterable_to_array(o, minLen) {
51
46
  var __dirname = _path.default.dirname(typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
52
47
  var major = +process.versions.node.split('.')[0];
53
48
  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);
49
+ function worker(modulePath, nodeModules, _options, callback) {
50
+ var pkg = JSON.parse(_fs.default.readFileSync(_path.default.join(modulePath, 'package.json'), 'utf8'));
51
+ var targetPath = _path.default.resolve(nodeModules, pkg.name);
61
52
  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'));
84
- queue.await(function(err) {
85
- console.log('------------------');
86
- err ? callback(err) : callback(null, targetPath);
87
- });
53
+ queue.defer(_tsdslib.link.bind(null, modulePath, targetPath));
54
+ // single bins
55
+ if (typeof pkg.bin === 'string') {
56
+ var binPath = _path.default.resolve.apply(null, [
57
+ modulePath
58
+ ].concat(_to_consumable_array(pkg.bin.split('/'))));
59
+ var binTargetPath = _path.default.resolve(nodeModules, '.bin', pkg.bin);
60
+ queue.defer(_tsdslib.link.bind(null, binPath, binTargetPath));
61
+ } else {
62
+ for(var binName in pkg.bin){
63
+ var binPath1 = _path.default.resolve.apply(null, [
64
+ modulePath
65
+ ].concat(_to_consumable_array(pkg.bin[binName].split('/'))));
66
+ var binTargetPath1 = _path.default.resolve(nodeModules, '.bin', binName);
67
+ queue.defer(_tsdslib.link.bind(null, binPath1, binTargetPath1));
68
+ }
88
69
  }
70
+ queue.await(function(err) {
71
+ err ? callback(err) : callback(null, targetPath);
72
+ });
89
73
  }
90
- function data(git, options, callback) {
91
- major < 14 ? workerWrapper('stable', git, options, callback) : worker(git, options, callback);
74
+ function linkModule(modulePath, nodeModules, options, callback) {
75
+ if (typeof options === 'function') {
76
+ callback = options;
77
+ options = {};
78
+ }
79
+ options = options || {};
80
+ major < 14 ? workerWrapper('stable', modulePath, nodeModules, options, callback) : worker(modulePath, nodeModules, options, callback);
92
81
  }
93
82
  /* 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 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 worker(modulePath, nodeModules, _options, callback) {\n const pkg = JSON.parse(fs.readFileSync(path.join(modulePath, 'package.json'), 'utf8'));\n const targetPath = path.resolve(nodeModules, pkg.name);\n\n const queue = new Queue(1);\n queue.defer(link.bind(null, modulePath, targetPath));\n\n // single bins\n if (typeof pkg.bin === 'string') {\n const binPath = path.resolve.apply(null, [modulePath, ...pkg.bin.split('/')]);\n const binTargetPath = path.resolve(nodeModules, '.bin', pkg.bin);\n queue.defer(link.bind(null, binPath, binTargetPath));\n }\n\n // object of bins\n else {\n for (const binName in pkg.bin) {\n const binPath = path.resolve.apply(null, [modulePath, ...pkg.bin[binName].split('/')]);\n const binTargetPath = path.resolve(nodeModules, '.bin', binName);\n queue.defer(link.bind(null, binPath, binTargetPath));\n }\n }\n\n queue.await((err) => {\n err ? callback(err) : callback(null, targetPath);\n });\n}\n\nexport default function linkModule(modulePath: 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', modulePath, nodeModules, options, callback) : worker(modulePath, nodeModules, options, callback);\n}\n"],"names":["linkModule","__dirname","path","dirname","__filename","url","fileURLToPath","major","process","versions","node","split","workerWrapper","wrapWorker","join","packageRoot","worker","modulePath","nodeModules","_options","callback","pkg","JSON","parse","fs","readFileSync","targetPath","resolve","name","queue","Queue","defer","link","bind","bin","binPath","apply","binTargetPath","binName","await","err","options"],"mappings":";;;;+BAsCA;;;eAAwBA;;;yDAtCT;2DACE;0DACD;8DACE;uBAC4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9C,IAAMC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CA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C;IACF;IAEAR,MAAMU,KAAK,CAAC,SAACC;QACXA,MAAMpB,SAASoB,OAAOpB,SAAS,MAAMM;IACvC;AACF;AAEe,SAAS1B,WAAWiB,UAAkB,EAAEC,WAAmB,EAAEuB,OAAO,EAAErB,QAAS;IAC5F,IAAI,OAAOqB,YAAY,YAAY;QACjCrB,WAAWqB;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtBlC,QAAQ,KAAKK,cAAc,UAAUK,YAAYC,aAAauB,SAASrB,YAAYJ,OAAOC,YAAYC,aAAauB,SAASrB;AAC9H"}
@@ -1,2 +1,2 @@
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';
@@ -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';\n"],"names":["default","linkModule","installGitRepo"],"mappings":"AAAA,SAASA,WAAWC,UAAU,QAAQ,sBAAsB;AAC5D,SAASD,WAAWE,cAAc,QAAQ,0BAA0B"}
@@ -1,35 +1,33 @@
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
+ // options.clean = true;
14
+ function checkOrClean(dest, callback) {
15
+ options.clean ? rimraf2(dest, {
16
+ disableGlob: true
17
+ }, callback.bind(null, new Error('clone'))) : access(dest, callback);
18
+ }
19
+ checkOrClean(dest, (err)=>{
24
20
  const queue = new Queue(1);
21
+ queue.defer(mkdirp.bind(null, dest));
25
22
  // does not exist - clone
26
23
  if (err) {
27
24
  queue.defer(spawn.bind(null, 'git', [
28
25
  'clone',
29
- git
26
+ repo,
27
+ path.basename(dest)
30
28
  ], {
31
29
  stdio: 'inherit',
32
- cwd: dest
30
+ cwd: path.dirname(dest)
33
31
  }));
34
32
  } else {
35
33
  queue.defer(spawn.bind(null, 'git', [
@@ -37,7 +35,7 @@ export default function prepareGit(git, options, callback) {
37
35
  '-fd'
38
36
  ], {
39
37
  stdio: 'inherit',
40
- cwd: targetPath
38
+ cwd: dest
41
39
  }));
42
40
  queue.defer(spawn.bind(null, 'git', [
43
41
  'reset',
@@ -45,16 +43,23 @@ export default function prepareGit(git, options, callback) {
45
43
  'HEAD'
46
44
  ], {
47
45
  stdio: 'inherit',
48
- cwd: targetPath
46
+ cwd: dest
49
47
  }));
50
48
  queue.defer(spawn.bind(null, 'git', [
51
49
  'pull',
52
50
  '--rebase'
53
51
  ], {
54
52
  stdio: 'inherit',
55
- cwd: targetPath
53
+ cwd: dest
56
54
  }));
57
55
  }
56
+ // install
57
+ queue.defer(spawn.bind(null, 'npm', [
58
+ '--silent',
59
+ 'install'
60
+ ], {
61
+ cwd: dest
62
+ }));
58
63
  queue.await(callback);
59
64
  });
60
65
  }
@@ -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 // 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","checkOrClean","clean","disableGlob","bind","Error","err","queue","defer","basename","stdio","cwd","dirname","await"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,YAAY,mBAAmB;AACtC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAE9B,eAAe,SAASC,eAAeC,IAAY,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'path';
3
+ import url from 'url';
4
+ import Queue from 'queue-cb';
5
+ import { link, packageRoot, wrapWorker } from 'tsds-lib';
6
+ const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
7
+ const major = +process.versions.node.split('.')[0];
8
+ const workerWrapper = wrapWorker(path.join(packageRoot(__dirname), 'dist', 'cjs', 'lib', 'data.js'));
9
+ function worker(modulePath, nodeModules, _options, callback) {
10
+ const pkg = JSON.parse(fs.readFileSync(path.join(modulePath, 'package.json'), 'utf8'));
11
+ const targetPath = path.resolve(nodeModules, pkg.name);
12
+ const queue = new Queue(1);
13
+ queue.defer(link.bind(null, modulePath, targetPath));
14
+ // single bins
15
+ if (typeof pkg.bin === 'string') {
16
+ const binPath = path.resolve.apply(null, [
17
+ modulePath,
18
+ ...pkg.bin.split('/')
19
+ ]);
20
+ const binTargetPath = path.resolve(nodeModules, '.bin', pkg.bin);
21
+ queue.defer(link.bind(null, binPath, binTargetPath));
22
+ } else {
23
+ for(const binName in pkg.bin){
24
+ const binPath = path.resolve.apply(null, [
25
+ modulePath,
26
+ ...pkg.bin[binName].split('/')
27
+ ]);
28
+ const binTargetPath = path.resolve(nodeModules, '.bin', binName);
29
+ queue.defer(link.bind(null, binPath, binTargetPath));
30
+ }
31
+ }
32
+ queue.await((err)=>{
33
+ err ? callback(err) : callback(null, targetPath);
34
+ });
35
+ }
36
+ export default function linkModule(modulePath, nodeModules, options, callback) {
37
+ if (typeof options === 'function') {
38
+ callback = options;
39
+ options = {};
40
+ }
41
+ options = options || {};
42
+ major < 14 ? workerWrapper('stable', modulePath, nodeModules, options, callback) : worker(modulePath, nodeModules, options, callback);
43
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["linkModule.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport url from 'url';\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 worker(modulePath, nodeModules, _options, callback) {\n const pkg = JSON.parse(fs.readFileSync(path.join(modulePath, 'package.json'), 'utf8'));\n const targetPath = path.resolve(nodeModules, pkg.name);\n\n const queue = new Queue(1);\n queue.defer(link.bind(null, modulePath, targetPath));\n\n // single bins\n if (typeof pkg.bin === 'string') {\n const binPath = path.resolve.apply(null, [modulePath, ...pkg.bin.split('/')]);\n const binTargetPath = path.resolve(nodeModules, '.bin', pkg.bin);\n queue.defer(link.bind(null, binPath, binTargetPath));\n }\n\n // object of bins\n else {\n for (const binName in pkg.bin) {\n const binPath = path.resolve.apply(null, [modulePath, ...pkg.bin[binName].split('/')]);\n const binTargetPath = path.resolve(nodeModules, '.bin', binName);\n queue.defer(link.bind(null, binPath, binTargetPath));\n }\n }\n\n queue.await((err) => {\n err ? callback(err) : callback(null, targetPath);\n });\n}\n\nexport default function linkModule(modulePath: 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', modulePath, nodeModules, options, callback) : worker(modulePath, nodeModules, options, callback);\n}\n"],"names":["fs","path","url","Queue","link","packageRoot","wrapWorker","__dirname","dirname","__filename","fileURLToPath","major","process","versions","node","split","workerWrapper","join","worker","modulePath","nodeModules","_options","callback","pkg","JSON","parse","readFileSync","targetPath","resolve","name","queue","defer","bind","bin","binPath","apply","binTargetPath","binName","await","err","linkModule","options"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,WAAW,WAAW;AAC7B,SAASC,IAAI,EAAEC,WAAW,EAAEC,UAAU,QAAQ,WAAW;AAEzD,MAAMC,YAAYN,KAAKO,OAAO,CAAC,OAAOC,eAAe,cAAcA,a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B,SAAS,MAAMK;IACvC;AACF;AAEA,eAAe,SAASa,WAAWrB,UAAkB,EAAEC,WAAmB,EAAEqB,OAAO,EAAEnB,QAAS;IAC5F,IAAI,OAAOmB,YAAY,YAAY;QACjCnB,WAAWmB;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB9B,QAAQ,KAAKK,cAAc,UAAUG,YAAYC,aAAaqB,SAASnB,YAAYJ,OAAOC,YAAYC,aAAaqB,SAASnB;AAC9H"}
@@ -1 +1 @@
1
- {"type":"module"}
1
+ {"type":"commonjs"}
@@ -1,2 +1,2 @@
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';
@@ -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(modulePath: 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.5.9",
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.5.9"
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": "787ee591227d7787dd922ca188872f7bb3c7441f"
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,I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AYH,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,IAA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@@
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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/B,GAAG,EAAEC,OAAO,EAAEC,QAAQ;IACjDV,QAAQ,KAAKK,cAAc,UAAUG,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":["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,OAA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AAK,CAAC9B,MAAM+B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAQ;aAAW,EAAE;gBAAEC,OAAO;gBAAWrB,KAAKa;YAAW;QAChG;QAEAK,MAAMI,KAAK,CAACvB;IACd;AACF"}
@@ -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;