feat: update require registry
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
ea8e62b696
commit
fd5c2aa087
@ -263,10 +263,9 @@
|
|||||||
var module_name = name.startsWith('@') ? name_arr[0] + '/' + name_arr[1] : name_arr[0];
|
var module_name = name.startsWith('@') ? name_arr[0] + '/' + name_arr[1] : name_arr[0];
|
||||||
// at windows need replace file name java.lang.IllegalArgumentException: Invalid prefix or suffix
|
// at windows need replace file name java.lang.IllegalArgumentException: Invalid prefix or suffix
|
||||||
var tempFile = Files.createTempFile(module_name.replace('/', '_'), '.json');
|
var tempFile = Files.createTempFile(module_name.replace('/', '_'), '.json');
|
||||||
Files.copy(new URL('https://repo.yumc.pw/repository/npm/' + module_name).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
|
var info = fetchPackageInfo(module_name, tempFile);
|
||||||
var info = JSON.parse(new JavaString(Files.readAllBytes(tempFile), 'UTF-8')); tempFile.toFile().deleteOnExit();
|
|
||||||
var url = info.versions[info['dist-tags']['latest']].dist.tarball;
|
var url = info.versions[info['dist-tags']['latest']].dist.tarball;
|
||||||
console.log('node_module ' + module_name + ' not found at local but exist at internet ' + url + ' downloading...')
|
console.log('fetch node_module ' + module_name + ' from ' + url + ' waiting...')
|
||||||
var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())));
|
var tis = new TarInputStream(new BufferedInputStream(new GZIPInputStream(new URL(url).openStream())));
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
var entry; var target = root + separatorChar + 'node_modules' + separatorChar + module_name;
|
var entry; var target = root + separatorChar + 'node_modules' + separatorChar + module_name;
|
||||||
@ -278,6 +277,17 @@
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetchPackageInfo(module_name, tempFile) {
|
||||||
|
try {
|
||||||
|
Files.copy(new URL('https://registry.npm.taobao.org/' + module_name).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} catch (ex) {
|
||||||
|
console.debug('can\'t fetch package ' + module_name + ' from taobao registry. try fetch from yumc registry...')
|
||||||
|
Files.copy(new URL('https://repo.yumc.pw/repository/npm/' + module_name).openStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
tempFile.toFile().deleteOnExit();
|
||||||
|
return JSON.parse(new JavaString(Files.readAllBytes(tempFile), 'UTF-8'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查核心模块
|
* 检查核心模块
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
|
Loading…
Reference in New Issue
Block a user