mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 13:29:12 +08:00 
			
		
		
		
	Logic remastered to not force check-latest
This commit is contained in:
		
							
								
								
									
										27
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							@@ -13105,15 +13105,20 @@ const semver = __importStar(__webpack_require__(280));
 | 
			
		||||
const fs = __webpack_require__(747);
 | 
			
		||||
function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        // Store manifest data to avoid multiple calls
 | 
			
		||||
        let manifest;
 | 
			
		||||
        let osPlat = os.platform();
 | 
			
		||||
        let osArch = translateArchToDistUrl(arch);
 | 
			
		||||
        if (isLtsAlias(versionSpec)) {
 | 
			
		||||
            core.info('LTS version is provided. For LTS versions `check-latest` will be automatically set to true');
 | 
			
		||||
            checkLatest = true;
 | 
			
		||||
            core.info('Attempt to resolve LTS alias from manifest...');
 | 
			
		||||
            core.debug('Getting manifest from actions/node-versions@main');
 | 
			
		||||
            // No try-catch since it's not possible to resolve LTS alias without manifest
 | 
			
		||||
            manifest = yield tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
 | 
			
		||||
            versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
 | 
			
		||||
        }
 | 
			
		||||
        if (checkLatest) {
 | 
			
		||||
            core.info('Attempt to resolve the latest version from manifest...');
 | 
			
		||||
            const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth, osArch);
 | 
			
		||||
            const resolvedVersion = yield resolveVersionFromManifest(versionSpec, stable, auth, osArch, manifest);
 | 
			
		||||
            if (resolvedVersion) {
 | 
			
		||||
                versionSpec = resolvedVersion;
 | 
			
		||||
                core.info(`Resolved as '${versionSpec}'`);
 | 
			
		||||
@@ -13137,7 +13142,7 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
 | 
			
		||||
            // Try download from internal distribution (popular versions only)
 | 
			
		||||
            //
 | 
			
		||||
            try {
 | 
			
		||||
                info = yield getInfoFromManifest(versionSpec, stable, auth, osArch);
 | 
			
		||||
                info = yield getInfoFromManifest(versionSpec, stable, auth, osArch, manifest);
 | 
			
		||||
                if (info) {
 | 
			
		||||
                    core.info(`Acquiring ${info.resolvedVersion} - ${info.arch} from ${info.downloadUrl}`);
 | 
			
		||||
                    downloadPath = yield tc.downloadTool(info.downloadUrl, undefined, auth);
 | 
			
		||||
@@ -13240,14 +13245,14 @@ function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
 | 
			
		||||
    core.debug(`Found LTS release '${release.version}' for Node version '${versionSpec}'`);
 | 
			
		||||
    return release.version.split('.')[0];
 | 
			
		||||
}
 | 
			
		||||
function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch())) {
 | 
			
		||||
function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()), manifest) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        let info = null;
 | 
			
		||||
        const releases = yield tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
 | 
			
		||||
        if (isLtsAlias(versionSpec)) {
 | 
			
		||||
            versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, releases);
 | 
			
		||||
        if (!manifest) {
 | 
			
		||||
            core.debug('No manifest cached, getting manifest from actions/node-versions@main');
 | 
			
		||||
            manifest = yield tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
 | 
			
		||||
        }
 | 
			
		||||
        const rel = yield tc.findFromManifest(versionSpec, stable, releases, osArch);
 | 
			
		||||
        const rel = yield tc.findFromManifest(versionSpec, stable, manifest, osArch);
 | 
			
		||||
        if (rel && rel.files.length > 0) {
 | 
			
		||||
            info = {};
 | 
			
		||||
            info.resolvedVersion = rel.version;
 | 
			
		||||
@@ -13284,10 +13289,10 @@ function getInfoFromDist(versionSpec, arch = os.arch()) {
 | 
			
		||||
        };
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
function resolveVersionFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch())) {
 | 
			
		||||
function resolveVersionFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os.arch()), manifest) {
 | 
			
		||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
			
		||||
        try {
 | 
			
		||||
            const info = yield getInfoFromManifest(versionSpec, stable, auth, osArch);
 | 
			
		||||
            const info = yield getInfoFromManifest(versionSpec, stable, auth, osArch, manifest);
 | 
			
		||||
            return info === null || info === void 0 ? void 0 : info.resolvedVersion;
 | 
			
		||||
        }
 | 
			
		||||
        catch (err) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user