tsds-lib-test 1.0.2 → 1.0.4
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/lib/data.js +25 -59
- package/dist/cjs/lib/data.js.map +1 -1
- package/dist/cjs/lib/prepareGit.js +61 -0
- package/dist/cjs/lib/prepareGit.js.map +1 -0
- package/dist/esm/lib/data.mjs +25 -59
- package/dist/esm/lib/data.mjs.map +1 -1
- package/dist/esm/lib/prepareGit.mjs +59 -0
- package/dist/esm/lib/prepareGit.mjs.map +1 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/lib/data.d.ts +2 -0
- package/dist/types/lib/prepareGit.d.ts +2 -0
- package/package.json +4 -3
package/dist/cjs/lib/data.js
CHANGED
|
@@ -3,62 +3,26 @@ var fs = require('fs');
|
|
|
3
3
|
var path = require('path');
|
|
4
4
|
var Queue = require('queue-cb');
|
|
5
5
|
var spawn = require('cross-spawn-cb');
|
|
6
|
-
var access = require('fs-access-compat');
|
|
7
6
|
var tmpdir = require('os').tmpdir || require('os-shim').tmpdir;
|
|
8
7
|
var mkdirp = require('mkdirp');
|
|
9
|
-
var rimraf2 = require('rimraf2');
|
|
10
8
|
var shortHash = require('short-hash');
|
|
11
|
-
var
|
|
12
|
-
mkdirp.sync(dest);
|
|
9
|
+
var prepareGit = require('./prepareGit');
|
|
13
10
|
module.exports = function data(git, options, callback) {
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// does not exist - clone
|
|
30
|
-
if (err) {
|
|
31
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
32
|
-
'clone',
|
|
33
|
-
git
|
|
34
|
-
], {
|
|
35
|
-
stdio: 'inherit',
|
|
36
|
-
cwd: dest
|
|
37
|
-
}));
|
|
38
|
-
} else {
|
|
39
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
40
|
-
'clean',
|
|
41
|
-
'-fd'
|
|
42
|
-
], {
|
|
43
|
-
stdio: 'inherit',
|
|
44
|
-
cwd: packagePath
|
|
45
|
-
}));
|
|
46
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
47
|
-
'reset',
|
|
48
|
-
'--hard',
|
|
49
|
-
'HEAD'
|
|
50
|
-
], {
|
|
51
|
-
stdio: 'inherit',
|
|
52
|
-
cwd: packagePath
|
|
53
|
-
}));
|
|
54
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
55
|
-
'pull',
|
|
56
|
-
'--rebase'
|
|
57
|
-
], {
|
|
58
|
-
stdio: 'inherit',
|
|
59
|
-
cwd: packagePath
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
11
|
+
var cwd = options.cwd || process.cwd();
|
|
12
|
+
var pkg = require(path.join(cwd, 'package.json'));
|
|
13
|
+
var dest = path.join(tmpdir(), pkg.name, shortHash(cwd));
|
|
14
|
+
var targetName = path.basename(git, path.extname(git));
|
|
15
|
+
var targetPath = path.join(dest, targetName);
|
|
16
|
+
mkdirp.sync(dest);
|
|
17
|
+
var queue = new Queue(1);
|
|
18
|
+
for(var binName in pkg.bin){
|
|
19
|
+
var packagePath = path.resolve(targetPath, 'node_modules', pkg.name);
|
|
20
|
+
var binPath = path.resolve(targetPath, 'node_modules', '.bin', binName);
|
|
21
|
+
console.log('------------------');
|
|
22
|
+
console.log("Preparing: ".concat(targetPath));
|
|
23
|
+
// clone or reset the git repo
|
|
24
|
+
queue.defer(prepareGit.bind(null, git, options));
|
|
25
|
+
// install
|
|
62
26
|
queue.defer(spawn.bind(null, 'nvu', [
|
|
63
27
|
'lts',
|
|
64
28
|
'--silent',
|
|
@@ -66,18 +30,20 @@ module.exports = function data(git, options, callback) {
|
|
|
66
30
|
'install'
|
|
67
31
|
], {
|
|
68
32
|
stdio: 'inherit',
|
|
69
|
-
cwd:
|
|
33
|
+
cwd: targetPath
|
|
70
34
|
}));
|
|
71
35
|
// link package
|
|
72
|
-
queue.defer(fs.rename.bind(null,
|
|
73
|
-
queue.defer(fs.symlink.bind(null,
|
|
36
|
+
queue.defer(fs.rename.bind(null, packagePath, "".concat(packagePath, ".tsds")));
|
|
37
|
+
queue.defer(fs.symlink.bind(null, cwd, packagePath, 'dir'));
|
|
74
38
|
// link bin
|
|
75
|
-
queue.defer(fs.rename.bind(null,
|
|
76
|
-
queue.defer(fs.symlink.bind(null, path.resolve(
|
|
39
|
+
queue.defer(fs.rename.bind(null, binPath, "".concat(binPath, ".tsds")));
|
|
40
|
+
queue.defer(fs.symlink.bind(null, path.resolve.apply(null, [
|
|
41
|
+
cwd
|
|
42
|
+
].concat(pkg.bin[binName].split('/'))), binPath, 'file'));
|
|
77
43
|
queue.await(function(err) {
|
|
78
44
|
console.log('------------------');
|
|
79
|
-
err ? callback(err) : callback(null,
|
|
45
|
+
err ? callback(err) : callback(null, targetPath);
|
|
80
46
|
});
|
|
81
|
-
}
|
|
47
|
+
}
|
|
82
48
|
};
|
|
83
49
|
/* 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; }
|
package/dist/cjs/lib/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["data.js"],"sourcesContent":["const fs = require('fs');\nconst path = require('path');\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst
|
|
1
|
+
{"version":3,"sources":["data.js"],"sourcesContent":["const fs = require('fs');\nconst path = require('path');\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst tmpdir = require('os').tmpdir || require('os-shim').tmpdir;\nconst mkdirp = require('mkdirp');\nconst shortHash = require('short-hash');\n\nconst prepareGit = require('./prepareGit');\n\nmodule.exports = function data(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = require(path.join(cwd, 'package.json'));\n const dest = path.join(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, 'nvu', ['lts', '--silent', 'npm', 'install'], { stdio: 'inherit', 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].concat(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"],"names":["fs","require","path","Queue","spawn","tmpdir","mkdirp","shortHash","prepareGit","module","exports","data","git","options","callback","cwd","process","pkg","join","dest","name","targetName","basename","extname","targetPath","sync","queue","binName","bin","packagePath","resolve","binPath","console","log","defer","bind","stdio","rename","symlink","apply","concat","split","await","err"],"mappings":";AAAA,IAAMA,KAAKC,QAAQ;AACnB,IAAMC,OAAOD,QAAQ;AACrB,IAAME,QAAQF,QAAQ;AACtB,IAAMG,QAAQH,QAAQ;AACtB,IAAMI,SAASJ,QAAQ,MAAMI,MAAM,IAAIJ,QAAQ,WAAWI,MAAM;AAChE,IAAMC,SAASL,QAAQ;AACvB,IAAMM,YAAYN,QAAQ;AAE1B,IAAMO,aAAaP,QAAQ;AAE3BQ,OAAOC,OAAO,GAAG,SAASC,KAAKC,GAAG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,CAACH,IAAI,CAAC,MAAMjC,KAAK4B,OAAO,CAACS,KAAK,CAAC,MAAM;YAACxB;SAAI,CAACyB,MAAM,CAACvB,IAAIW,GAAG,CAACD,QAAQ,CAACc,KAAK,CAAC,QAAQV,SAAS;QAEhHL,MAAMgB,KAAK,CAAC,SAACC;YACXX,QAAQC,GAAG,CAAC;YACZU,MAAM7B,SAAS6B,OAAO7B,SAAS,MAAMU;QACvC;IACF;AACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var path = require('path');
|
|
3
|
+
var Queue = require('queue-cb');
|
|
4
|
+
var spawn = require('cross-spawn-cb');
|
|
5
|
+
var access = require('fs-access-compat');
|
|
6
|
+
var rimraf2 = require('rimraf2');
|
|
7
|
+
var tmpdir = require('os').tmpdir || require('os-shim').tmpdir;
|
|
8
|
+
var mkdirp = require('mkdirp');
|
|
9
|
+
var shortHash = require('short-hash');
|
|
10
|
+
module.exports = function prepareGit(git, options, callback) {
|
|
11
|
+
var cwd = options.cwd || process.cwd();
|
|
12
|
+
var pkg = require(path.join(cwd, 'package.json'));
|
|
13
|
+
var dest = path.join(tmpdir(), pkg.name, shortHash(cwd));
|
|
14
|
+
var targetName = path.basename(git, path.extname(git));
|
|
15
|
+
var targetPath = path.join(dest, targetName);
|
|
16
|
+
mkdirp.sync(dest);
|
|
17
|
+
access(targetPath, function(err) {
|
|
18
|
+
if (!err && options.clean) {
|
|
19
|
+
rimraf2.sync(targetPath, {
|
|
20
|
+
disableGlob: true
|
|
21
|
+
});
|
|
22
|
+
err = true;
|
|
23
|
+
}
|
|
24
|
+
var queue = new Queue(1);
|
|
25
|
+
// does not exist - clone
|
|
26
|
+
if (err) {
|
|
27
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
28
|
+
'clone',
|
|
29
|
+
git
|
|
30
|
+
], {
|
|
31
|
+
stdio: 'inherit',
|
|
32
|
+
cwd: dest
|
|
33
|
+
}));
|
|
34
|
+
} else {
|
|
35
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
36
|
+
'clean',
|
|
37
|
+
'-fd'
|
|
38
|
+
], {
|
|
39
|
+
stdio: 'inherit',
|
|
40
|
+
cwd: targetPath
|
|
41
|
+
}));
|
|
42
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
43
|
+
'reset',
|
|
44
|
+
'--hard',
|
|
45
|
+
'HEAD'
|
|
46
|
+
], {
|
|
47
|
+
stdio: 'inherit',
|
|
48
|
+
cwd: targetPath
|
|
49
|
+
}));
|
|
50
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
51
|
+
'pull',
|
|
52
|
+
'--rebase'
|
|
53
|
+
], {
|
|
54
|
+
stdio: 'inherit',
|
|
55
|
+
cwd: targetPath
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
queue.await(callback);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/* 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":["prepareGit.js"],"sourcesContent":["const path = require('path');\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst access = require('fs-access-compat');\nconst rimraf2 = require('rimraf2');\nconst tmpdir = require('os').tmpdir || require('os-shim').tmpdir;\nconst mkdirp = require('mkdirp');\nconst shortHash = require('short-hash');\n\nmodule.exports = function prepareGit(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = require(path.join(cwd, 'package.json'));\n const dest = path.join(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":["path","require","Queue","spawn","access","rimraf2","tmpdir","mkdirp","shortHash","module","exports","prepareGit","git","options","callback","cwd","process","pkg","join","dest","name","targetName","basename","extname","targetPath","sync","err","clean","disableGlob","queue","defer","bind","stdio","await"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,QAAQD,QAAQ;AACtB,IAAME,QAAQF,QAAQ;AACtB,IAAMG,SAASH,QAAQ;AACvB,IAAMI,UAAUJ,QAAQ;AACxB,IAAMK,SAASL,QAAQ,MAAMK,MAAM,IAAIL,QAAQ,WAAWK,MAAM;AAChE,IAAMC,SAASN,QAAQ;AACvB,IAAMO,YAAYP,QAAQ;AAE1BQ,OAAOC,OAAO,GAAG,SAASC,WAAWC,GAAG,EAAEC,OAAO,EAAEC,QAAQ;IACzD,IAAMC,MAAMF,QAAQE,GAAG,IAAIC,QAAQD,GAAG;IACtC,IAAME,MAAMhB,QAAQD,KAAKkB,IAAI,CAACH,KAAK;IACnC,IAAMI,OAAOnB,KAAKkB,IAAI,CAACZ,UAAUW,IAAIG,IAAI,EAAEZ,UAAUO;IACrD,IAAMM,aAAarB,KAAKsB,QAAQ,CAACV,KAAKZ,KAAKuB,OAAO,CAACX;IACnD,IAAMY,aAAaxB,KAAKkB,IAAI,CAACC,MAAME;IACnCd,OAAOkB,IAAI,CAACN;IAEZf,OAAOoB,YAAY,SAACE;QAClB,IAAI,CAACA,OAAOb,QAAQc,KAAK,EAAE;YACzBtB,QAAQoB,IAAI,CAACD,YAAY;gBAAEI,aAAa;YAAK;YAC7CF,MAAM;QACR;QAEA,IAAMG,QAAQ,IAAI3B,MAAM;QACxB,yBAAyB;QACzB,IAAIwB,KAAK;YACPG,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAASnB;aAAI,EAAE;gBAAEoB,OAAO;gBAAWjB,KAAKI;YAAK;QACpF,OAEK;YACHU,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;aAAM,EAAE;gBAAEC,OAAO;gBAAWjB,KAAKS;YAAW;YAC1FK,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;gBAAU;aAAO,EAAE;gBAAEC,OAAO;gBAAWjB,KAAKS;YAAW;YACrGK,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAQ;aAAW,EAAE;gBAAEC,OAAO;gBAAWjB,KAAKS;YAAW;QAChG;QAEAK,MAAMI,KAAK,CAACnB;IACd;AACF"}
|
package/dist/esm/lib/data.mjs
CHANGED
|
@@ -2,62 +2,26 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const Queue = require('queue-cb');
|
|
4
4
|
const spawn = require('cross-spawn-cb');
|
|
5
|
-
const access = require('fs-access-compat');
|
|
6
5
|
const tmpdir = require('os').tmpdir || require('os-shim').tmpdir;
|
|
7
6
|
const mkdirp = require('mkdirp');
|
|
8
|
-
const rimraf2 = require('rimraf2');
|
|
9
7
|
const shortHash = require('short-hash');
|
|
10
|
-
const
|
|
11
|
-
mkdirp.sync(dest);
|
|
8
|
+
const prepareGit = require('./prepareGit');
|
|
12
9
|
module.exports = function data(git, options, callback) {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// does not exist - clone
|
|
29
|
-
if (err) {
|
|
30
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
31
|
-
'clone',
|
|
32
|
-
git
|
|
33
|
-
], {
|
|
34
|
-
stdio: 'inherit',
|
|
35
|
-
cwd: dest
|
|
36
|
-
}));
|
|
37
|
-
} else {
|
|
38
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
39
|
-
'clean',
|
|
40
|
-
'-fd'
|
|
41
|
-
], {
|
|
42
|
-
stdio: 'inherit',
|
|
43
|
-
cwd: packagePath
|
|
44
|
-
}));
|
|
45
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
46
|
-
'reset',
|
|
47
|
-
'--hard',
|
|
48
|
-
'HEAD'
|
|
49
|
-
], {
|
|
50
|
-
stdio: 'inherit',
|
|
51
|
-
cwd: packagePath
|
|
52
|
-
}));
|
|
53
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
54
|
-
'pull',
|
|
55
|
-
'--rebase'
|
|
56
|
-
], {
|
|
57
|
-
stdio: 'inherit',
|
|
58
|
-
cwd: packagePath
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
10
|
+
const cwd = options.cwd || process.cwd();
|
|
11
|
+
const pkg = require(path.join(cwd, 'package.json'));
|
|
12
|
+
const dest = path.join(tmpdir(), pkg.name, shortHash(cwd));
|
|
13
|
+
const targetName = path.basename(git, path.extname(git));
|
|
14
|
+
const targetPath = path.join(dest, targetName);
|
|
15
|
+
mkdirp.sync(dest);
|
|
16
|
+
const queue = new Queue(1);
|
|
17
|
+
for(const binName in pkg.bin){
|
|
18
|
+
const packagePath = path.resolve(targetPath, 'node_modules', pkg.name);
|
|
19
|
+
const binPath = path.resolve(targetPath, 'node_modules', '.bin', binName);
|
|
20
|
+
console.log('------------------');
|
|
21
|
+
console.log(`Preparing: ${targetPath}`);
|
|
22
|
+
// clone or reset the git repo
|
|
23
|
+
queue.defer(prepareGit.bind(null, git, options));
|
|
24
|
+
// install
|
|
61
25
|
queue.defer(spawn.bind(null, 'nvu', [
|
|
62
26
|
'lts',
|
|
63
27
|
'--silent',
|
|
@@ -65,17 +29,19 @@ module.exports = function data(git, options, callback) {
|
|
|
65
29
|
'install'
|
|
66
30
|
], {
|
|
67
31
|
stdio: 'inherit',
|
|
68
|
-
cwd:
|
|
32
|
+
cwd: targetPath
|
|
69
33
|
}));
|
|
70
34
|
// link package
|
|
71
|
-
queue.defer(fs.rename.bind(null,
|
|
72
|
-
queue.defer(fs.symlink.bind(null,
|
|
35
|
+
queue.defer(fs.rename.bind(null, packagePath, `${packagePath}.tsds`));
|
|
36
|
+
queue.defer(fs.symlink.bind(null, cwd, packagePath, 'dir'));
|
|
73
37
|
// link bin
|
|
74
|
-
queue.defer(fs.rename.bind(null,
|
|
75
|
-
queue.defer(fs.symlink.bind(null, path.resolve(
|
|
38
|
+
queue.defer(fs.rename.bind(null, binPath, `${binPath}.tsds`));
|
|
39
|
+
queue.defer(fs.symlink.bind(null, path.resolve.apply(null, [
|
|
40
|
+
cwd
|
|
41
|
+
].concat(pkg.bin[binName].split('/'))), binPath, 'file'));
|
|
76
42
|
queue.await((err)=>{
|
|
77
43
|
console.log('------------------');
|
|
78
|
-
err ? callback(err) : callback(null,
|
|
44
|
+
err ? callback(err) : callback(null, targetPath);
|
|
79
45
|
});
|
|
80
|
-
}
|
|
46
|
+
}
|
|
81
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["data.js"],"sourcesContent":["const fs = require('fs');\nconst path = require('path');\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst
|
|
1
|
+
{"version":3,"sources":["data.js"],"sourcesContent":["const fs = require('fs');\nconst path = require('path');\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst tmpdir = require('os').tmpdir || require('os-shim').tmpdir;\nconst mkdirp = require('mkdirp');\nconst shortHash = require('short-hash');\n\nconst prepareGit = require('./prepareGit');\n\nmodule.exports = function data(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = require(path.join(cwd, 'package.json'));\n const dest = path.join(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, 'nvu', ['lts', '--silent', 'npm', 'install'], { stdio: 'inherit', 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].concat(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"],"names":["fs","require","path","Queue","spawn","tmpdir","mkdirp","shortHash","prepareGit","module","exports","data","git","options","callback","cwd","process","pkg","join","dest","name","targetName","basename","extname","targetPath","sync","queue","binName","bin","packagePath","resolve","binPath","console","log","defer","bind","stdio","rename","symlink","apply","concat","split","await","err"],"mappings":"AAAA,MAAMA,KAAKC,QAAQ;AACnB,MAAMC,OAAOD,QAAQ;AACrB,MAAME,QAAQF,QAAQ;AACtB,MAAMG,QAAQH,QAAQ;AACtB,MAAMI,SAASJ,QAAQ,MAAMI,MAAM,IAAIJ,QAAQ,WAAWI,MAAM;AAChE,MAAMC,SAASL,QAAQ;AACvB,MAAMM,YAAYN,QAAQ;AAE1B,MAAMO,aAAaP,QAAQ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AK,CAAC;QAC3DL,MAAMQ,KAAK,CAAClC,GAAGsC,OAAO,CAACH,IAAI,CAAC,MAAMjC,KAAK4B,OAAO,CAACS,KAAK,CAAC,MAAM;YAACxB;SAAI,CAACyB,MAAM,CAACvB,IAAIW,GAAG,CAACD,QAAQ,CAACc,KAAK,CAAC,QAAQV,SAAS;QAEhHL,MAAMgB,KAAK,CAAC,CAACC;YACXX,QAAQC,GAAG,CAAC;YACZU,MAAM7B,SAAS6B,OAAO7B,SAAS,MAAMU;QACvC;IACF;AACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const Queue = require('queue-cb');
|
|
3
|
+
const spawn = require('cross-spawn-cb');
|
|
4
|
+
const access = require('fs-access-compat');
|
|
5
|
+
const rimraf2 = require('rimraf2');
|
|
6
|
+
const tmpdir = require('os').tmpdir || require('os-shim').tmpdir;
|
|
7
|
+
const mkdirp = require('mkdirp');
|
|
8
|
+
const shortHash = require('short-hash');
|
|
9
|
+
module.exports = function prepareGit(git, options, callback) {
|
|
10
|
+
const cwd = options.cwd || process.cwd();
|
|
11
|
+
const pkg = require(path.join(cwd, 'package.json'));
|
|
12
|
+
const dest = path.join(tmpdir(), pkg.name, shortHash(cwd));
|
|
13
|
+
const targetName = path.basename(git, path.extname(git));
|
|
14
|
+
const targetPath = path.join(dest, targetName);
|
|
15
|
+
mkdirp.sync(dest);
|
|
16
|
+
access(targetPath, (err)=>{
|
|
17
|
+
if (!err && options.clean) {
|
|
18
|
+
rimraf2.sync(targetPath, {
|
|
19
|
+
disableGlob: true
|
|
20
|
+
});
|
|
21
|
+
err = true;
|
|
22
|
+
}
|
|
23
|
+
const queue = new Queue(1);
|
|
24
|
+
// does not exist - clone
|
|
25
|
+
if (err) {
|
|
26
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
27
|
+
'clone',
|
|
28
|
+
git
|
|
29
|
+
], {
|
|
30
|
+
stdio: 'inherit',
|
|
31
|
+
cwd: dest
|
|
32
|
+
}));
|
|
33
|
+
} else {
|
|
34
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
35
|
+
'clean',
|
|
36
|
+
'-fd'
|
|
37
|
+
], {
|
|
38
|
+
stdio: 'inherit',
|
|
39
|
+
cwd: targetPath
|
|
40
|
+
}));
|
|
41
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
42
|
+
'reset',
|
|
43
|
+
'--hard',
|
|
44
|
+
'HEAD'
|
|
45
|
+
], {
|
|
46
|
+
stdio: 'inherit',
|
|
47
|
+
cwd: targetPath
|
|
48
|
+
}));
|
|
49
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
50
|
+
'pull',
|
|
51
|
+
'--rebase'
|
|
52
|
+
], {
|
|
53
|
+
stdio: 'inherit',
|
|
54
|
+
cwd: targetPath
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
queue.await(callback);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["prepareGit.js"],"sourcesContent":["const path = require('path');\nconst Queue = require('queue-cb');\nconst spawn = require('cross-spawn-cb');\nconst access = require('fs-access-compat');\nconst rimraf2 = require('rimraf2');\nconst tmpdir = require('os').tmpdir || require('os-shim').tmpdir;\nconst mkdirp = require('mkdirp');\nconst shortHash = require('short-hash');\n\nmodule.exports = function prepareGit(git, options, callback) {\n const cwd = options.cwd || process.cwd();\n const pkg = require(path.join(cwd, 'package.json'));\n const dest = path.join(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":["path","require","Queue","spawn","access","rimraf2","tmpdir","mkdirp","shortHash","module","exports","prepareGit","git","options","callback","cwd","process","pkg","join","dest","name","targetName","basename","extname","targetPath","sync","err","clean","disableGlob","queue","defer","bind","stdio","await"],"mappings":"AAAA,MAAMA,OAAOC,QAAQ;AACrB,MAAMC,QAAQD,QAAQ;AACtB,MAAME,QAAQF,QAAQ;AACtB,MAAMG,SAASH,QAAQ;AACvB,MAAMI,UAAUJ,QAAQ;AACxB,MAAMK,SAASL,QAAQ,MAAMK,MAAM,IAAIL,QAAQ,WAAWK,MAAM;AAChE,MAAMC,SAASN,QAAQ;AACvB,MAAMO,YAAYP,QAAQ;AAE1BQ,OAAOC,OAAO,GAAG,SAASC,WAAWC,GAAG,EAAEC,OAAO,EAAEC,QAAQ;IACzD,MAAMC,MAAMF,QAAQE,GAAG,IAAIC,QAAQD,GAAG;IACtC,MAAME,MAAMhB,QAAQD,KAAKkB,IAAI,CAACH,KAAK;IACnC,MAAMI,OAAOnB,KAAKkB,IAAI,CAACZ,UAAUW,IAAIG,IAAI,EAAEZ,UAAUO;IACrD,MAAMM,aAAarB,KAAKsB,QAAQ,CAACV,KAAKZ,KAAKuB,OAAO,CAACX;IACnD,MAAMY,aAAaxB,KAAKkB,IAAI,CAACC,MAAME;IACnCd,OAAOkB,IAAI,CAACN;IAEZf,OAAOoB,YAAY,CAACE;QAClB,IAAI,CAACA,OAAOb,QAAQc,KAAK,EAAE;YACzBtB,QAAQoB,IAAI,CAACD,YAAY;gBAAEI,aAAa;YAAK;YAC7CF,MAAM;QACR;QAEA,MAAMG,QAAQ,IAAI3B,MAAM;QACxB,yBAAyB;QACzB,IAAIwB,KAAK;YACPG,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAASnB;aAAI,EAAE;gBAAEoB,OAAO;gBAAWjB,KAAKI;YAAK;QACpF,OAEK;YACHU,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;aAAM,EAAE;gBAAEC,OAAO;gBAAWjB,KAAKS;YAAW;YAC1FK,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAS;gBAAU;aAAO,EAAE;gBAAEC,OAAO;gBAAWjB,KAAKS;YAAW;YACrGK,MAAMC,KAAK,CAAC3B,MAAM4B,IAAI,CAAC,MAAM,OAAO;gBAAC;gBAAQ;aAAW,EAAE;gBAAEC,OAAO;gBAAWjB,KAAKS;YAAW;QAChG;QAEAK,MAAMI,KAAK,CAACnB;IACd;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as data } from "./lib/data";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsds-lib-test",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Development stack for TypeScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"c8",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"@biomejs/biome": "^1.9.4",
|
|
48
48
|
"@types/mocha": "^10.0.10",
|
|
49
49
|
"@types/node": "^22.10.1",
|
|
50
|
-
"depcheck": "^1.4.7"
|
|
50
|
+
"depcheck": "^1.4.7",
|
|
51
|
+
"typescript": "^5.7.2"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|
|
53
54
|
"node": ">=0.8"
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"esm"
|
|
60
61
|
]
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f6afddef380f8adef7950bcfbdfca1089ca9a026"
|
|
63
64
|
}
|