tsds-lib-test 1.19.3 → 1.19.5
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.
|
@@ -26,59 +26,91 @@ var major = +process.versions.node.split('.')[0];
|
|
|
26
26
|
var dist = _path.default.join(__dirname, '..', '..');
|
|
27
27
|
var version = major > 14 ? 'local' : 'stable';
|
|
28
28
|
var workerWrapper = (0, _tsdslib.wrapWorker)(_path.default.join(dist, 'cjs', 'lib', 'installGitRepo.js'));
|
|
29
|
+
function checkDirectoryExists(dest, callback) {
|
|
30
|
+
_fs.default.stat(dest, function(err) {
|
|
31
|
+
if (err && err.code === 'ENOENT') callback(null, false);
|
|
32
|
+
else if (err) callback(err);
|
|
33
|
+
else callback(null, true);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function cloneRepository(repo, dest, callback) {
|
|
37
|
+
var parentDir = _path.default.dirname(dest);
|
|
38
|
+
var repoName = _path.default.basename(dest);
|
|
39
|
+
var queue = new _queuecb.default(1);
|
|
40
|
+
queue.defer(_mkdirpclassic.default.bind(null, dest));
|
|
41
|
+
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
42
|
+
'clone',
|
|
43
|
+
repo,
|
|
44
|
+
repoName
|
|
45
|
+
], {
|
|
46
|
+
cwd: parentDir,
|
|
47
|
+
stdio: 'inherit'
|
|
48
|
+
}));
|
|
49
|
+
queue.await(callback);
|
|
50
|
+
}
|
|
51
|
+
function updateRepository(dest, callback) {
|
|
52
|
+
var queue = new _queuecb.default(1);
|
|
53
|
+
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
54
|
+
'clean',
|
|
55
|
+
'-fd'
|
|
56
|
+
], {
|
|
57
|
+
cwd: dest,
|
|
58
|
+
stdio: 'inherit'
|
|
59
|
+
}));
|
|
60
|
+
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
61
|
+
'reset',
|
|
62
|
+
'--hard',
|
|
63
|
+
'HEAD'
|
|
64
|
+
], {
|
|
65
|
+
cwd: dest,
|
|
66
|
+
stdio: 'inherit'
|
|
67
|
+
}));
|
|
68
|
+
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
69
|
+
'pull',
|
|
70
|
+
'--rebase'
|
|
71
|
+
], {
|
|
72
|
+
cwd: dest,
|
|
73
|
+
stdio: 'inherit'
|
|
74
|
+
}));
|
|
75
|
+
queue.await(callback);
|
|
76
|
+
}
|
|
77
|
+
function installDependencies(dest, callback) {
|
|
78
|
+
(0, _crossspawncb.default)('npm', [
|
|
79
|
+
'install',
|
|
80
|
+
'--silent'
|
|
81
|
+
], {
|
|
82
|
+
cwd: dest
|
|
83
|
+
}, callback);
|
|
84
|
+
}
|
|
85
|
+
function cleanInstall(repo, dest, callback) {
|
|
86
|
+
var queue = new _queuecb.default(1);
|
|
87
|
+
queue.defer(_fsremovecompat.safeRm.bind(null, dest));
|
|
88
|
+
queue.defer(cloneRepository.bind(null, repo, dest));
|
|
89
|
+
queue.defer(installDependencies.bind(null, dest));
|
|
90
|
+
queue.await(callback);
|
|
91
|
+
}
|
|
29
92
|
function worker(repo, dest, options, callback) {
|
|
30
93
|
var installOptions = options;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
94
|
+
if (installOptions.clean) {
|
|
95
|
+
cleanInstall(repo, dest, callback);
|
|
96
|
+
} else {
|
|
97
|
+
checkDirectoryExists(dest, function(err, exists) {
|
|
98
|
+
if (err) return callback(err);
|
|
99
|
+
var queue = new _queuecb.default(1);
|
|
100
|
+
if (!exists) {
|
|
101
|
+
queue.defer(cloneRepository.bind(null, repo, dest));
|
|
102
|
+
queue.defer(installDependencies.bind(null, dest));
|
|
103
|
+
} else {
|
|
104
|
+
queue.defer(function(cb) {
|
|
105
|
+
updateRepository(dest, function(err2) {
|
|
106
|
+
if (err2) return cleanInstall(repo, dest, cb);
|
|
107
|
+
installDependencies(dest, cb);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
queue.await(callback);
|
|
112
|
+
});
|
|
36
113
|
}
|
|
37
|
-
checkOrClean(dest, function(err) {
|
|
38
|
-
var queue = new _queuecb.default(1);
|
|
39
|
-
queue.defer(_mkdirpclassic.default.bind(null, dest));
|
|
40
|
-
// does not exist - clone
|
|
41
|
-
if (err) {
|
|
42
|
-
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
43
|
-
'clone',
|
|
44
|
-
repo,
|
|
45
|
-
_path.default.basename(dest)
|
|
46
|
-
], {
|
|
47
|
-
cwd: _path.default.dirname(dest),
|
|
48
|
-
stdio: 'inherit'
|
|
49
|
-
}));
|
|
50
|
-
} else {
|
|
51
|
-
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
52
|
-
'clean',
|
|
53
|
-
'-fd'
|
|
54
|
-
], {
|
|
55
|
-
cwd: dest,
|
|
56
|
-
stdio: 'inherit'
|
|
57
|
-
}));
|
|
58
|
-
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
59
|
-
'reset',
|
|
60
|
-
'--hard',
|
|
61
|
-
'HEAD'
|
|
62
|
-
], {
|
|
63
|
-
cwd: dest,
|
|
64
|
-
stdio: 'inherit'
|
|
65
|
-
}));
|
|
66
|
-
queue.defer(_crossspawncb.default.bind(null, 'git', [
|
|
67
|
-
'pull',
|
|
68
|
-
'--rebase'
|
|
69
|
-
], {
|
|
70
|
-
cwd: dest,
|
|
71
|
-
stdio: 'inherit'
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
queue.defer(_crossspawncb.default.bind(null, 'npm', [
|
|
75
|
-
'install',
|
|
76
|
-
'--silent'
|
|
77
|
-
], {
|
|
78
|
-
cwd: dest
|
|
79
|
-
}));
|
|
80
|
-
queue.await(callback);
|
|
81
|
-
});
|
|
82
114
|
}
|
|
83
115
|
function installGitRepo(repo, dest, options, callback) {
|
|
84
116
|
if (typeof options === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ts-dev-stack/tsds-lib-test/src/lib/installGitRepo.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport type { CommandCallback, CommandOptions } from 'tsds-lib';\nimport { wrapWorker } from 'tsds-lib';\nimport url from 'url';\nimport type { InstallOptions } from '../types.ts';\n\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst major = +process.versions.node.split('.')[0];\nconst dist = path.join(__dirname, '..', '..');\nconst version = major > 14 ? 'local' : 'stable';\nconst workerWrapper = wrapWorker(path.join(dist, 'cjs', 'lib', 'installGitRepo.js'));\n\nfunction
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ts-dev-stack/tsds-lib-test/src/lib/installGitRepo.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport type { CommandCallback, CommandOptions } from 'tsds-lib';\nimport { wrapWorker } from 'tsds-lib';\nimport url from 'url';\nimport type { InstallOptions } from '../types.ts';\n\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst major = +process.versions.node.split('.')[0];\nconst dist = path.join(__dirname, '..', '..');\nconst version = major > 14 ? 'local' : 'stable';\nconst workerWrapper = wrapWorker(path.join(dist, 'cjs', 'lib', 'installGitRepo.js'));\n\nfunction checkDirectoryExists(dest: string, callback: (err: Error | null, exists?: boolean) => void) {\n fs.stat(dest, (err) => {\n if (err && err.code === 'ENOENT') callback(null, false);\n else if (err) callback(err);\n else callback(null, true);\n });\n}\n\nfunction cloneRepository(repo: string, dest: string, callback) {\n const parentDir = path.dirname(dest);\n const repoName = path.basename(dest);\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, dest));\n queue.defer(spawn.bind(null, 'git', ['clone', repo, repoName], { cwd: parentDir, stdio: 'inherit' }));\n queue.await(callback);\n}\n\nfunction updateRepository(dest: string, callback) {\n const queue = new Queue(1);\n queue.defer(spawn.bind(null, 'git', ['clean', '-fd'], { cwd: dest, stdio: 'inherit' }));\n queue.defer(spawn.bind(null, 'git', ['reset', '--hard', 'HEAD'], { cwd: dest, stdio: 'inherit' }));\n queue.defer(spawn.bind(null, 'git', ['pull', '--rebase'], { cwd: dest, stdio: 'inherit' }));\n queue.await(callback);\n}\n\nfunction installDependencies(dest: string, callback) {\n spawn('npm', ['install', '--silent'], { cwd: dest }, callback);\n}\n\nfunction cleanInstall(repo: string, dest: string, callback) {\n const queue = new Queue(1);\n queue.defer(safeRm.bind(null, dest));\n queue.defer(cloneRepository.bind(null, repo, dest));\n queue.defer(installDependencies.bind(null, dest));\n queue.await(callback);\n}\n\nfunction worker(repo: string, dest: string, options: CommandOptions | InstallOptions, callback: CommandCallback) {\n const installOptions = options as InstallOptions;\n\n if (installOptions.clean) {\n cleanInstall(repo, dest, callback);\n } else {\n checkDirectoryExists(dest, (err, exists) => {\n if (err) return callback(err);\n const queue = new Queue(1);\n if (!exists) {\n queue.defer(cloneRepository.bind(null, repo, dest));\n queue.defer(installDependencies.bind(null, dest));\n } else {\n queue.defer((cb) => {\n updateRepository(dest, (err2) => {\n if (err2) return cleanInstall(repo, dest, cb);\n installDependencies(dest, cb);\n });\n });\n }\n queue.await(callback);\n });\n }\n}\n\nexport default function installGitRepo(repo: string, dest: string, options: CommandOptions | CommandCallback, callback?: CommandCallback): undefined {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n version !== 'local' ? workerWrapper(version, repo, dest, options, callback) : worker(repo, dest, options, callback);\n}\n"],"names":["installGitRepo","__dirname","path","dirname","__filename","url","fileURLToPath","major","process","versions","node","split","dist","join","version","workerWrapper","wrapWorker","checkDirectoryExists","dest","callback","fs","stat","err","code","cloneRepository","repo","parentDir","repoName","basename","queue","Queue","defer","mkdirp","bind","spawn","cwd","stdio","await","updateRepository","installDependencies","cleanInstall","safeRm","worker","options","installOptions","clean","exists","cb","err2"],"mappings":";;;;+BA+EA;;;eAAwBA;;;mEA/EN;yDACH;8BACQ;oEACJ;2DACF;8DACC;uBAES;0DACX;;;;;;AAGhB,IAAMC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcC,YAAG,CAACC,aAAa,CAAC,uDAAmBF;AACxG,IAAMG,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,OAAOV,aAAI,CAACW,IAAI,CAACZ,WAAW,MAAM;AACxC,IAAMa,UAAUP,QAAQ,KAAK,UAAU;AACvC,IAAMQ,gBAAgBC,IAAAA,mBAAU,EAACd,aAAI,CAACW,IAAI,CAACD,MAAM,OAAO,OAAO;AAE/D,SAASK,qBAAqBC,IAAY,EAAEC,QAAuD;IACjGC,WAAE,CAACC,IAAI,CAACH,MAAM,SAACI;QACb,IAAIA,OAAOA,IAAIC,IAAI,KAAK,UAAUJ,SAAS,MAAM;aAC5C,IAAIG,KAAKH,SAASG;aAClBH,SAAS,MAAM;IACtB;AACF;AAEA,SAASK,gBAAgBC,IAAY,EAAEP,IAAY,EAAEC,QAAQ;IAC3D,IAAMO,YAAYxB,aAAI,CAACC,OAAO,CAACe;IAC/B,IAAMS,WAAWzB,aAAI,CAAC0B,QAAQ,CAACV;IAC/B,IAAMW,QAAQ,IAAIC,gBAAK,CAAC;IACxBD,MAAME,KAAK,CAACC,sBAAM,CAACC,IAAI,CAAC,MAAMf;IAC9BW,MAAME,KAAK,CAACG,qBAAK,CAACD,IAAI,CAAC,MAAM,OAAO;QAAC;QAASR;QAAME;KAAS,EAAE;QAAEQ,KAAKT;QAAWU,OAAO;IAAU;IAClGP,MAAMQ,KAAK,CAAClB;AACd;AA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I,CAACgB,QAAQ;gBACXjB,MAAME,KAAK,CAACP,gBAAgBS,IAAI,CAAC,MAAMR,MAAMP;gBAC7CW,MAAME,KAAK,CAACQ,oBAAoBN,IAAI,CAAC,MAAMf;YAC7C,OAAO;gBACLW,MAAME,KAAK,CAAC,SAACgB;oBACXT,iBAAiBpB,MAAM,SAAC8B;wBACtB,IAAIA,MAAM,OAAOR,aAAaf,MAAMP,MAAM6B;wBAC1CR,oBAAoBrB,MAAM6B;oBAC5B;gBACF;YACF;YACAlB,MAAMQ,KAAK,CAAClB;QACd;IACF;AACF;AAEe,SAASnB,eAAeyB,IAAY,EAAEP,IAAY,EAAEyB,OAAyC,EAAExB,QAA0B;IACtI,IAAI,OAAOwB,YAAY,YAAY;QACjCxB,WAAWwB;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtB7B,YAAY,UAAUC,cAAcD,SAASW,MAAMP,MAAMyB,SAASxB,YAAYuB,OAAOjB,MAAMP,MAAMyB,SAASxB;AAC5G"}
|
|
@@ -11,57 +11,91 @@ const major = +process.versions.node.split('.')[0];
|
|
|
11
11
|
const dist = path.join(__dirname, '..', '..');
|
|
12
12
|
const version = major > 14 ? 'local' : 'stable';
|
|
13
13
|
const workerWrapper = wrapWorker(path.join(dist, 'cjs', 'lib', 'installGitRepo.js'));
|
|
14
|
+
function checkDirectoryExists(dest, callback) {
|
|
15
|
+
fs.stat(dest, (err)=>{
|
|
16
|
+
if (err && err.code === 'ENOENT') callback(null, false);
|
|
17
|
+
else if (err) callback(err);
|
|
18
|
+
else callback(null, true);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function cloneRepository(repo, dest, callback) {
|
|
22
|
+
const parentDir = path.dirname(dest);
|
|
23
|
+
const repoName = path.basename(dest);
|
|
24
|
+
const queue = new Queue(1);
|
|
25
|
+
queue.defer(mkdirp.bind(null, dest));
|
|
26
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
27
|
+
'clone',
|
|
28
|
+
repo,
|
|
29
|
+
repoName
|
|
30
|
+
], {
|
|
31
|
+
cwd: parentDir,
|
|
32
|
+
stdio: 'inherit'
|
|
33
|
+
}));
|
|
34
|
+
queue.await(callback);
|
|
35
|
+
}
|
|
36
|
+
function updateRepository(dest, callback) {
|
|
37
|
+
const queue = new Queue(1);
|
|
38
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
39
|
+
'clean',
|
|
40
|
+
'-fd'
|
|
41
|
+
], {
|
|
42
|
+
cwd: dest,
|
|
43
|
+
stdio: 'inherit'
|
|
44
|
+
}));
|
|
45
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
46
|
+
'reset',
|
|
47
|
+
'--hard',
|
|
48
|
+
'HEAD'
|
|
49
|
+
], {
|
|
50
|
+
cwd: dest,
|
|
51
|
+
stdio: 'inherit'
|
|
52
|
+
}));
|
|
53
|
+
queue.defer(spawn.bind(null, 'git', [
|
|
54
|
+
'pull',
|
|
55
|
+
'--rebase'
|
|
56
|
+
], {
|
|
57
|
+
cwd: dest,
|
|
58
|
+
stdio: 'inherit'
|
|
59
|
+
}));
|
|
60
|
+
queue.await(callback);
|
|
61
|
+
}
|
|
62
|
+
function installDependencies(dest, callback) {
|
|
63
|
+
spawn('npm', [
|
|
64
|
+
'install',
|
|
65
|
+
'--silent'
|
|
66
|
+
], {
|
|
67
|
+
cwd: dest
|
|
68
|
+
}, callback);
|
|
69
|
+
}
|
|
70
|
+
function cleanInstall(repo, dest, callback) {
|
|
71
|
+
const queue = new Queue(1);
|
|
72
|
+
queue.defer(safeRm.bind(null, dest));
|
|
73
|
+
queue.defer(cloneRepository.bind(null, repo, dest));
|
|
74
|
+
queue.defer(installDependencies.bind(null, dest));
|
|
75
|
+
queue.await(callback);
|
|
76
|
+
}
|
|
14
77
|
function worker(repo, dest, options, callback) {
|
|
15
78
|
const installOptions = options;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
79
|
+
if (installOptions.clean) {
|
|
80
|
+
cleanInstall(repo, dest, callback);
|
|
81
|
+
} else {
|
|
82
|
+
checkDirectoryExists(dest, (err, exists)=>{
|
|
83
|
+
if (err) return callback(err);
|
|
84
|
+
const queue = new Queue(1);
|
|
85
|
+
if (!exists) {
|
|
86
|
+
queue.defer(cloneRepository.bind(null, repo, dest));
|
|
87
|
+
queue.defer(installDependencies.bind(null, dest));
|
|
88
|
+
} else {
|
|
89
|
+
queue.defer((cb)=>{
|
|
90
|
+
updateRepository(dest, (err2)=>{
|
|
91
|
+
if (err2) return cleanInstall(repo, dest, cb);
|
|
92
|
+
installDependencies(dest, cb);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
queue.await(callback);
|
|
97
|
+
});
|
|
19
98
|
}
|
|
20
|
-
checkOrClean(dest, (err)=>{
|
|
21
|
-
const queue = new Queue(1);
|
|
22
|
-
queue.defer(mkdirp.bind(null, dest));
|
|
23
|
-
// does not exist - clone
|
|
24
|
-
if (err) {
|
|
25
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
26
|
-
'clone',
|
|
27
|
-
repo,
|
|
28
|
-
path.basename(dest)
|
|
29
|
-
], {
|
|
30
|
-
cwd: path.dirname(dest),
|
|
31
|
-
stdio: 'inherit'
|
|
32
|
-
}));
|
|
33
|
-
} else {
|
|
34
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
35
|
-
'clean',
|
|
36
|
-
'-fd'
|
|
37
|
-
], {
|
|
38
|
-
cwd: dest,
|
|
39
|
-
stdio: 'inherit'
|
|
40
|
-
}));
|
|
41
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
42
|
-
'reset',
|
|
43
|
-
'--hard',
|
|
44
|
-
'HEAD'
|
|
45
|
-
], {
|
|
46
|
-
cwd: dest,
|
|
47
|
-
stdio: 'inherit'
|
|
48
|
-
}));
|
|
49
|
-
queue.defer(spawn.bind(null, 'git', [
|
|
50
|
-
'pull',
|
|
51
|
-
'--rebase'
|
|
52
|
-
], {
|
|
53
|
-
cwd: dest,
|
|
54
|
-
stdio: 'inherit'
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
queue.defer(spawn.bind(null, 'npm', [
|
|
58
|
-
'install',
|
|
59
|
-
'--silent'
|
|
60
|
-
], {
|
|
61
|
-
cwd: dest
|
|
62
|
-
}));
|
|
63
|
-
queue.await(callback);
|
|
64
|
-
});
|
|
65
99
|
}
|
|
66
100
|
export default function installGitRepo(repo, dest, options, callback) {
|
|
67
101
|
if (typeof options === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ts-dev-stack/tsds-lib-test/src/lib/installGitRepo.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport type { CommandCallback, CommandOptions } from 'tsds-lib';\nimport { wrapWorker } from 'tsds-lib';\nimport url from 'url';\nimport type { InstallOptions } from '../types.ts';\n\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst major = +process.versions.node.split('.')[0];\nconst dist = path.join(__dirname, '..', '..');\nconst version = major > 14 ? 'local' : 'stable';\nconst workerWrapper = wrapWorker(path.join(dist, 'cjs', 'lib', 'installGitRepo.js'));\n\nfunction
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ts-dev-stack/tsds-lib-test/src/lib/installGitRepo.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\nimport fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport type { CommandCallback, CommandOptions } from 'tsds-lib';\nimport { wrapWorker } from 'tsds-lib';\nimport url from 'url';\nimport type { InstallOptions } from '../types.ts';\n\nconst __dirname = path.dirname(typeof __filename === 'undefined' ? url.fileURLToPath(import.meta.url) : __filename);\nconst major = +process.versions.node.split('.')[0];\nconst dist = path.join(__dirname, '..', '..');\nconst version = major > 14 ? 'local' : 'stable';\nconst workerWrapper = wrapWorker(path.join(dist, 'cjs', 'lib', 'installGitRepo.js'));\n\nfunction checkDirectoryExists(dest: string, callback: (err: Error | null, exists?: boolean) => void) {\n fs.stat(dest, (err) => {\n if (err && err.code === 'ENOENT') callback(null, false);\n else if (err) callback(err);\n else callback(null, true);\n });\n}\n\nfunction cloneRepository(repo: string, dest: string, callback) {\n const parentDir = path.dirname(dest);\n const repoName = path.basename(dest);\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, dest));\n queue.defer(spawn.bind(null, 'git', ['clone', repo, repoName], { cwd: parentDir, stdio: 'inherit' }));\n queue.await(callback);\n}\n\nfunction updateRepository(dest: string, callback) {\n const queue = new Queue(1);\n queue.defer(spawn.bind(null, 'git', ['clean', '-fd'], { cwd: dest, stdio: 'inherit' }));\n queue.defer(spawn.bind(null, 'git', ['reset', '--hard', 'HEAD'], { cwd: dest, stdio: 'inherit' }));\n queue.defer(spawn.bind(null, 'git', ['pull', '--rebase'], { cwd: dest, stdio: 'inherit' }));\n queue.await(callback);\n}\n\nfunction installDependencies(dest: string, callback) {\n spawn('npm', ['install', '--silent'], { cwd: dest }, callback);\n}\n\nfunction cleanInstall(repo: string, dest: string, callback) {\n const queue = new Queue(1);\n queue.defer(safeRm.bind(null, dest));\n queue.defer(cloneRepository.bind(null, repo, dest));\n queue.defer(installDependencies.bind(null, dest));\n queue.await(callback);\n}\n\nfunction worker(repo: string, dest: string, options: CommandOptions | InstallOptions, callback: CommandCallback) {\n const installOptions = options as InstallOptions;\n\n if (installOptions.clean) {\n cleanInstall(repo, dest, callback);\n } else {\n checkDirectoryExists(dest, (err, exists) => {\n if (err) return callback(err);\n const queue = new Queue(1);\n if (!exists) {\n queue.defer(cloneRepository.bind(null, repo, dest));\n queue.defer(installDependencies.bind(null, dest));\n } else {\n queue.defer((cb) => {\n updateRepository(dest, (err2) => {\n if (err2) return cleanInstall(repo, dest, cb);\n installDependencies(dest, cb);\n });\n });\n }\n queue.await(callback);\n });\n }\n}\n\nexport default function installGitRepo(repo: string, dest: string, options: CommandOptions | CommandCallback, callback?: CommandCallback): undefined {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n version !== 'local' ? workerWrapper(version, repo, dest, options, callback) : worker(repo, dest, options, callback);\n}\n"],"names":["spawn","fs","safeRm","mkdirp","path","Queue","wrapWorker","url","__dirname","dirname","__filename","fileURLToPath","major","process","versions","node","split","dist","join","version","workerWrapper","checkDirectoryExists","dest","callback","stat","err","code","cloneRepository","repo","parentDir","repoName","basename","queue","defer","bind","cwd","stdio","await","updateRepository","installDependencies","cleanInstall","worker","options","installOptions","clean","exists","cb","err2","installGitRepo"],"mappings":"AAAA,OAAOA,WAAW,iBAAiB;AACnC,OAAOC,QAAQ,KAAK;AACpB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,SAASC,UAAU,QAAQ,WAAW;AACtC,OAAOC,SAAS,MAAM;AAGtB,MAAMC,YAAYJ,KAAKK,OAAO,CAAC,OAAOC,eAAe,cAAcH,IAAII,aAAa,CAAC,YAAYJ,GAAG,IAAIG;AACxG,MAAME,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,OAAOb,KAAKc,IAAI,CAACV,WAAW,MAAM;AACxC,MAAMW,UAAUP,QAAQ,KAAK,UAAU;AACvC,MAAMQ,gBAAgBd,WAAWF,KAAKc,IAAI,CAACD,MAAM,OAAO,OAAO;AAE/D,SAASI,qBAAqBC,IAAY,EAAEC,QAAuD;IACjGtB,GAAGuB,IAAI,CAACF,MAAM,CAACG;QACb,IAAIA,OAAOA,IAAIC,IAAI,KAAK,UAAUH,SAAS,MAAM;aAC5C,IAAIE,KAA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AC,MAAMN,MAAMN;IAC7CU,MAAMC,KAAK,CAACM,oBAAoBL,IAAI,CAAC,MAAMZ;IAC3CU,MAAMK,KAAK,CAACd;AACd;AAEA,SAASkB,OAAOb,IAAY,EAAEN,IAAY,EAAEoB,OAAwC,EAAEnB,QAAyB;IAC7G,MAAMoB,iBAAiBD;IAEvB,IAAIC,eAAeC,KAAK,EAAE;QACxBJ,aAAaZ,MAAMN,MAAMC;IAC3B,OAAO;QACLF,qBAAqBC,MAAM,CAACG,KAAKoB;YAC/B,IAAIpB,KAAK,OAAOF,SAASE;YACzB,MAAMO,QAAQ,IAAI3B,MAAM;YACxB,IAAI,CAACwC,QAAQ;gBACXb,MAAMC,KAAK,CAACN,gBAAgBO,IAAI,CAAC,MAAMN,MAAMN;gBAC7CU,MAAMC,KAAK,CAACM,oBAAoBL,IAAI,CAAC,MAAMZ;YAC7C,OAAO;gBACLU,MAAMC,KAAK,CAAC,CAACa;oBACXR,iBAAiBhB,MAAM,CAACyB;wBACtB,IAAIA,MAAM,OAAOP,aAAaZ,MAAMN,MAAMwB;wBAC1CP,oBAAoBjB,MAAMwB;oBAC5B;gBACF;YACF;YACAd,MAAMK,KAAK,CAACd;QACd;IACF;AACF;AAEA,eAAe,SAASyB,eAAepB,IAAY,EAAEN,IAAY,EAAEoB,OAAyC,EAAEnB,QAA0B;IACtI,IAAI,OAAOmB,YAAY,YAAY;QACjCnB,WAAWmB;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBvB,YAAY,UAAUC,cAAcD,SAASS,MAAMN,MAAMoB,SAASnB,YAAYkB,OAAOb,MAAMN,MAAMoB,SAASnB;AAC5G"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsds-lib-test",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.5",
|
|
4
4
|
"description": "Development stack for TypeScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dev",
|
|
@@ -39,23 +39,20 @@
|
|
|
39
39
|
"version": "tsds version"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"cross-spawn-cb": "
|
|
43
|
-
"fs-remove-compat": "
|
|
44
|
-
"mkdirp-classic": "
|
|
45
|
-
"queue-cb": "
|
|
46
|
-
"tsds-lib": "
|
|
42
|
+
"cross-spawn-cb": "^2.4.14",
|
|
43
|
+
"fs-remove-compat": "^0.2.3",
|
|
44
|
+
"mkdirp-classic": "^0.5.3",
|
|
45
|
+
"queue-cb": "^1.6.3",
|
|
46
|
+
"tsds-lib": "^1.20.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/mocha": "
|
|
50
|
-
"@types/node": "
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"ts-dev-stack": "*",
|
|
57
|
-
"ts-swc-loaders": "*",
|
|
58
|
-
"tsds-config": "*"
|
|
49
|
+
"@types/mocha": "^10.0.10",
|
|
50
|
+
"@types/node": "^25.0.1",
|
|
51
|
+
"node-version-use": "^2.1.6",
|
|
52
|
+
"os-shim": "^0.1.3",
|
|
53
|
+
"short-hash": "^1.0.0",
|
|
54
|
+
"ts-dev-stack": "^1.21.3",
|
|
55
|
+
"tsds-config": "^0.2.1"
|
|
59
56
|
},
|
|
60
57
|
"engines": {
|
|
61
58
|
"node": ">=0.8"
|