mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 12:13:35 +00:00 
			
		
		
		
	Build compiled js code
This commit is contained in:
		
							parent
							
								
									21a386952d
								
							
						
					
					
						commit
						bced0aece0
					
				
							
								
								
									
										63
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										63
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -73216,6 +73216,7 @@ const tc = __importStar(__nccwpck_require__(7784));
 | 
				
			|||||||
const path = __importStar(__nccwpck_require__(1017));
 | 
					const path = __importStar(__nccwpck_require__(1017));
 | 
				
			||||||
const semver = __importStar(__nccwpck_require__(5911));
 | 
					const semver = __importStar(__nccwpck_require__(5911));
 | 
				
			||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
					const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
				
			||||||
 | 
					const isVersionCanary = (versionSpec) => versionSpec.includes(`-v8-canary`);
 | 
				
			||||||
function getNode(versionSpec, stable, checkLatest, auth, arch = os_1.default.arch()) {
 | 
					function getNode(versionSpec, stable, checkLatest, auth, arch = os_1.default.arch()) {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
        // Store manifest data to avoid multiple calls
 | 
					        // Store manifest data to avoid multiple calls
 | 
				
			||||||
@ -73224,16 +73225,18 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os_1.default.arc
 | 
				
			|||||||
        let isNightly = versionSpec.includes('nightly');
 | 
					        let isNightly = versionSpec.includes('nightly');
 | 
				
			||||||
        let osPlat = os_1.default.platform();
 | 
					        let osPlat = os_1.default.platform();
 | 
				
			||||||
        let osArch = translateArchToDistUrl(arch);
 | 
					        let osArch = translateArchToDistUrl(arch);
 | 
				
			||||||
 | 
					        let isCanary = isVersionCanary(versionSpec);
 | 
				
			||||||
        if (isLtsAlias(versionSpec)) {
 | 
					        if (isLtsAlias(versionSpec)) {
 | 
				
			||||||
            core.info('Attempt to resolve LTS alias from manifest...');
 | 
					            core.info('Attempt to resolve LTS alias from manifest...');
 | 
				
			||||||
            // No try-catch since it's not possible to resolve LTS alias without manifest
 | 
					            // No try-catch since it's not possible to resolve LTS alias without manifest
 | 
				
			||||||
            manifest = yield getManifest(auth);
 | 
					            manifest = yield getManifest(auth);
 | 
				
			||||||
            versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
 | 
					            versionSpec = resolveLtsAliasFromManifest(versionSpec, stable, manifest);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (isLatestSyntax(versionSpec)) {
 | 
					        // evaluate exact versionSpec from input
 | 
				
			||||||
 | 
					        if (isLatestSyntax(versionSpec) || isCanary) {
 | 
				
			||||||
            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
					            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
				
			||||||
            versionSpec = yield queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
					            versionSpec = yield queryDistForMatch(versionSpec, arch, nodeVersions);
 | 
				
			||||||
            core.info(`getting latest node version...`);
 | 
					            core.info(`getting ${isCanary ? 'v8-canary' : 'latest'} node version ${versionSpec}...`);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (isNightly && checkLatest) {
 | 
					        if (isNightly && checkLatest) {
 | 
				
			||||||
            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
					            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
				
			||||||
@ -73251,11 +73254,16 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os_1.default.arc
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // check cache
 | 
					        // check cache
 | 
				
			||||||
 | 
					        core.info('Attempt to find existing version in cache...');
 | 
				
			||||||
        let toolPath;
 | 
					        let toolPath;
 | 
				
			||||||
        if (isNightly) {
 | 
					        if (isNightly) {
 | 
				
			||||||
            const nightlyVersion = findNightlyVersionInHostedToolcache(versionSpec, osArch);
 | 
					            const nightlyVersion = findNightlyVersionInHostedToolcache(versionSpec, osArch);
 | 
				
			||||||
            toolPath = nightlyVersion && tc.find('node', nightlyVersion, osArch);
 | 
					            toolPath = nightlyVersion && tc.find('node', nightlyVersion, osArch);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        else if (isCanary) {
 | 
				
			||||||
 | 
					            const localVersions = tc.findAllVersions('node', osArch);
 | 
				
			||||||
 | 
					            toolPath = evaluateVersions(localVersions, versionSpec);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            toolPath = tc.find('node', versionSpec, osArch);
 | 
					            toolPath = tc.find('node', versionSpec, osArch);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -73356,12 +73364,12 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os_1.default.arc
 | 
				
			|||||||
exports.getNode = getNode;
 | 
					exports.getNode = getNode;
 | 
				
			||||||
function findNightlyVersionInHostedToolcache(versionsSpec, osArch) {
 | 
					function findNightlyVersionInHostedToolcache(versionsSpec, osArch) {
 | 
				
			||||||
    const foundAllVersions = tc.findAllVersions('node', osArch);
 | 
					    const foundAllVersions = tc.findAllVersions('node', osArch);
 | 
				
			||||||
    const version = evaluateVersions(foundAllVersions, versionsSpec);
 | 
					    return evaluateVersions(foundAllVersions, versionsSpec);
 | 
				
			||||||
    return version;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
function isLtsAlias(versionSpec) {
 | 
					function isLtsAlias(versionSpec) {
 | 
				
			||||||
    return versionSpec.startsWith('lts/');
 | 
					    return versionSpec.startsWith('lts/');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					exports.isLtsAlias = isLtsAlias;
 | 
				
			||||||
function getManifest(auth) {
 | 
					function getManifest(auth) {
 | 
				
			||||||
    core.debug('Getting manifest from actions/node-versions@main');
 | 
					    core.debug('Getting manifest from actions/node-versions@main');
 | 
				
			||||||
    return tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
 | 
					    return tc.getManifestFromRepo('actions', 'node-versions', auth, 'main');
 | 
				
			||||||
@ -73391,6 +73399,7 @@ function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
 | 
				
			|||||||
    core.debug(`Found LTS release '${release.version}' for Node version '${versionSpec}'`);
 | 
					    core.debug(`Found LTS release '${release.version}' for Node version '${versionSpec}'`);
 | 
				
			||||||
    return release.version.split('.')[0];
 | 
					    return release.version.split('.')[0];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					exports.resolveLtsAliasFromManifest = resolveLtsAliasFromManifest;
 | 
				
			||||||
function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os_1.default.arch()), manifest) {
 | 
					function getInfoFromManifest(versionSpec, stable, auth, osArch = translateArchToDistUrl(os_1.default.arch()), manifest) {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
        let info = null;
 | 
					        let info = null;
 | 
				
			||||||
@ -73487,9 +73496,12 @@ function evaluateVersions(versions, versionSpec) {
 | 
				
			|||||||
        return evaluateNightlyVersions(versions, versionSpec);
 | 
					        return evaluateNightlyVersions(versions, versionSpec);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    versions = versions.sort(semver.rcompare);
 | 
					    versions = versions.sort(semver.rcompare);
 | 
				
			||||||
 | 
					    const matcher = isVersionCanary(versionSpec)
 | 
				
			||||||
 | 
					        ? evaluateCanaryMatcher(versionSpec)
 | 
				
			||||||
 | 
					        : potential => semver.satisfies(potential, versionSpec);
 | 
				
			||||||
    for (let i = versions.length - 1; i >= 0; i--) {
 | 
					    for (let i = versions.length - 1; i >= 0; i--) {
 | 
				
			||||||
        const potential = versions[i];
 | 
					        const potential = versions[i];
 | 
				
			||||||
        const satisfied = semver.satisfies(potential, versionSpec);
 | 
					        const satisfied = matcher(potential);
 | 
				
			||||||
        if (satisfied) {
 | 
					        if (satisfied) {
 | 
				
			||||||
            version = potential;
 | 
					            version = potential;
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
@ -73503,16 +73515,24 @@ function evaluateVersions(versions, versionSpec) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    return version;
 | 
					    return version;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					exports.evaluateVersions = evaluateVersions;
 | 
				
			||||||
function getNodejsDistUrl(version) {
 | 
					function getNodejsDistUrl(version) {
 | 
				
			||||||
    const prerelease = semver.prerelease(version);
 | 
					    const prerelease = semver.prerelease(version);
 | 
				
			||||||
    if (version.includes('nightly')) {
 | 
					    if (version.includes('nightly')) {
 | 
				
			||||||
 | 
					        core.debug('requested nightly distribution');
 | 
				
			||||||
        return 'https://nodejs.org/download/nightly';
 | 
					        return 'https://nodejs.org/download/nightly';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if (prerelease) {
 | 
					    else if (prerelease) {
 | 
				
			||||||
        return 'https://nodejs.org/download/rc';
 | 
					        return 'https://nodejs.org/download/rc';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    else if (isVersionCanary(version)) {
 | 
				
			||||||
 | 
					        core.debug('requested v8 canary distribution');
 | 
				
			||||||
 | 
					        return 'https://nodejs.org/download/v8-canary';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
        return 'https://nodejs.org/dist';
 | 
					        return 'https://nodejs.org/dist';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
exports.getNodejsDistUrl = getNodejsDistUrl;
 | 
					exports.getNodejsDistUrl = getNodejsDistUrl;
 | 
				
			||||||
function queryDistForMatch(versionSpec, arch = os_1.default.arch(), nodeVersions) {
 | 
					function queryDistForMatch(versionSpec, arch = os_1.default.arch(), nodeVersions) {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
@ -73537,11 +73557,11 @@ function queryDistForMatch(versionSpec, arch = os_1.default.arch(), nodeVersions
 | 
				
			|||||||
            core.debug('No dist manifest cached');
 | 
					            core.debug('No dist manifest cached');
 | 
				
			||||||
            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
					            nodeVersions = yield getVersionsFromDist(versionSpec);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let versions = [];
 | 
					 | 
				
			||||||
        if (isLatestSyntax(versionSpec)) {
 | 
					        if (isLatestSyntax(versionSpec)) {
 | 
				
			||||||
            core.info(`getting latest node version...`);
 | 
					            core.info(`getting latest node version...`);
 | 
				
			||||||
            return nodeVersions[0].version;
 | 
					            return nodeVersions[0].version;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        let versions = [];
 | 
				
			||||||
        nodeVersions.forEach((nodeVersion) => {
 | 
					        nodeVersions.forEach((nodeVersion) => {
 | 
				
			||||||
            // ensure this version supports your os and platform
 | 
					            // ensure this version supports your os and platform
 | 
				
			||||||
            if (nodeVersion.files.indexOf(dataFileName) >= 0) {
 | 
					            if (nodeVersion.files.indexOf(dataFileName) >= 0) {
 | 
				
			||||||
@ -73553,10 +73573,11 @@ function queryDistForMatch(versionSpec, arch = os_1.default.arch(), nodeVersions
 | 
				
			|||||||
        return version;
 | 
					        return version;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					exports.queryDistForMatch = queryDistForMatch;
 | 
				
			||||||
function getVersionsFromDist(versionSpec) {
 | 
					function getVersionsFromDist(versionSpec) {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
        const initialUrl = getNodejsDistUrl(versionSpec);
 | 
					        const distUrl = getNodejsDistUrl(versionSpec);
 | 
				
			||||||
        const dataUrl = `${initialUrl}/index.json`;
 | 
					        const dataUrl = `${distUrl}/index.json`;
 | 
				
			||||||
        let httpClient = new hc.HttpClient('setup-node', [], {
 | 
					        let httpClient = new hc.HttpClient('setup-node', [], {
 | 
				
			||||||
            allowRetries: true,
 | 
					            allowRetries: true,
 | 
				
			||||||
            maxRetries: 3
 | 
					            maxRetries: 3
 | 
				
			||||||
@ -73657,6 +73678,32 @@ exports.parseNodeVersionFile = parseNodeVersionFile;
 | 
				
			|||||||
function isLatestSyntax(versionSpec) {
 | 
					function isLatestSyntax(versionSpec) {
 | 
				
			||||||
    return ['current', 'latest', 'node'].includes(versionSpec);
 | 
					    return ['current', 'latest', 'node'].includes(versionSpec);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					exports.isLatestSyntax = isLatestSyntax;
 | 
				
			||||||
 | 
					function evaluateCanaryMatcher(versionSpec) {
 | 
				
			||||||
 | 
					    var _a;
 | 
				
			||||||
 | 
					    const [raw, prerelease] = versionSpec.split(/-(.*)/s);
 | 
				
			||||||
 | 
					    const isValidVersion = semver.valid(raw);
 | 
				
			||||||
 | 
					    const rawVersion = isValidVersion ? raw : (_a = semver.coerce(raw)) === null || _a === void 0 ? void 0 : _a.version;
 | 
				
			||||||
 | 
					    if (rawVersion) {
 | 
				
			||||||
 | 
					        if (prerelease === 'v8-canary') {
 | 
				
			||||||
 | 
					            // it means versionSpec does not have timestamp
 | 
				
			||||||
 | 
					            const range = semver.validRange(`^${rawVersion}`);
 | 
				
			||||||
 | 
					            return (potential) => semver.satisfies(
 | 
				
			||||||
 | 
					            // TODO: check latest?
 | 
				
			||||||
 | 
					            potential.replace('-v8-canary', '+v8-canary.'), range);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            // see https://github.com/actions/setup-node/blob/00e1b6691b40cce14b5078cb411dd1ec7dab07f7/__tests__/verify-node.sh#L10
 | 
				
			||||||
 | 
					            // there must be exact match
 | 
				
			||||||
 | 
					            const range = `${rawVersion}-${prerelease}`;
 | 
				
			||||||
 | 
					            return (potential) => semver.satisfies(
 | 
				
			||||||
 | 
					            // TODO: check latest?
 | 
				
			||||||
 | 
					            potential, range);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return () => false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					exports.evaluateCanaryMatcher = evaluateCanaryMatcher;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***/ }),
 | 
					/***/ }),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user