@ -4643,12 +4643,12 @@ function run() {
if ( ! version ) {
if ( ! version ) {
version = core . getInput ( 'version' ) ;
version = core . getInput ( 'version' ) ;
}
}
console . log ( ` version: ${ version } ` ) ;
if ( version ) {
if ( version ) {
let token = core . getInput ( 'token' ) ;
let token = core . getInput ( 'token' ) ;
let auth = ! token || isGhes ( ) ? undefined : ` token ${ token } ` ;
let auth = ! token || isGhes ( ) ? undefined : ` token ${ token } ` ;
let stable = ( core . getInput ( 'stable' ) || 'true' ) . toUpperCase ( ) === 'TRUE' ;
let stable = ( core . getInput ( 'stable' ) || 'true' ) . toUpperCase ( ) === 'TRUE' ;
yield installer . getNode ( version , stable , auth ) ;
const checkLatest = ( core . getInput ( 'check-latest' ) || 'false' ) . toUpperCase ( ) === 'TRUE' ;
yield installer . getNode ( version , stable , checkLatest , auth ) ;
}
}
const registryUrl = core . getInput ( 'registry-url' ) ;
const registryUrl = core . getInput ( 'registry-url' ) ;
const alwaysAuth = core . getInput ( 'always-auth' ) ;
const alwaysAuth = core . getInput ( 'always-auth' ) ;
@ -12994,19 +12994,30 @@ const tc = __importStar(__webpack_require__(533));
const path = _ _importStar ( _ _webpack _require _ _ ( 622 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 622 ) ) ;
const semver = _ _importStar ( _ _webpack _require _ _ ( 280 ) ) ;
const semver = _ _importStar ( _ _webpack _require _ _ ( 280 ) ) ;
const fs = _ _webpack _require _ _ ( 747 ) ;
const fs = _ _webpack _require _ _ ( 747 ) ;
function getNode ( versionSpec , stable , auth) {
function getNode ( versionSpec , stable , checkLatest, auth) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let osPlat = os . platform ( ) ;
let osPlat = os . platform ( ) ;
let osArch = translateArchToDistUrl ( os . arch ( ) ) ;
let osArch = translateArchToDistUrl ( os . arch ( ) ) ;
if ( checkLatest ) {
core . info ( 'Attempt to resolve the latest version from manifest...' ) ;
const resolvedVersion = yield resolveVersionFromManifest ( versionSpec , stable , auth ) ;
if ( resolvedVersion ) {
versionSpec = resolvedVersion ;
core . info ( ` Resolved as ' ${ versionSpec } ' ` ) ;
}
else {
core . info ( ` Failed to resolve version ${ versionSpec } from manifest ` ) ;
}
}
// check cache
// check cache
let toolPath ;
let toolPath ;
toolPath = tc . find ( 'node' , versionSpec ) ;
toolPath = tc . find ( 'node' , versionSpec ) ;
// If not found in cache, download
// If not found in cache, download
if ( toolPath ) {
if ( toolPath ) {
console . log ( ` Found in cache @ ${ toolPath } ` ) ;
co re. info ( ` Found in cache @ ${ toolPath } ` ) ;
}
}
else {
else {
console . log ( ` Attempting to download ${ versionSpec } ... ` ) ;
co re. info ( ` Attempting to download ${ versionSpec } ... ` ) ;
let downloadPath = '' ;
let downloadPath = '' ;
let info = null ;
let info = null ;
//
//
@ -13015,24 +13026,24 @@ function getNode(versionSpec, stable, auth) {
try {
try {
info = yield getInfoFromManifest ( versionSpec , stable , auth ) ;
info = yield getInfoFromManifest ( versionSpec , stable , auth ) ;
if ( info ) {
if ( info ) {
co nsole. log ( ` Acquiring ${ info . resolvedVersion } from ${ info . downloadUrl } ` ) ;
co re. info ( ` Acquiring ${ info . resolvedVersion } from ${ info . downloadUrl } ` ) ;
downloadPath = yield tc . downloadTool ( info . downloadUrl , undefined , auth ) ;
downloadPath = yield tc . downloadTool ( info . downloadUrl , undefined , auth ) ;
}
}
else {
else {
co nsole. log ( 'Not found in manifest. Falling back to download directly from Node' ) ;
co re. info ( 'Not found in manifest. Falling back to download directly from Node' ) ;
}
}
}
}
catch ( err ) {
catch ( err ) {
// Rate limit?
// Rate limit?
if ( err instanceof tc . HTTPError &&
if ( err instanceof tc . HTTPError &&
( err . httpStatusCode === 403 || err . httpStatusCode === 429 ) ) {
( err . httpStatusCode === 403 || err . httpStatusCode === 429 ) ) {
co nsole. log ( ` Received HTTP status code ${ err . httpStatusCode } . This usually indicates the rate limit has been exceeded ` ) ;
co re. info ( ` Received HTTP status code ${ err . httpStatusCode } . This usually indicates the rate limit has been exceeded ` ) ;
}
}
else {
else {
co nsole. log ( err . message ) ;
co re. info ( err . message ) ;
}
}
core . debug ( err . stack ) ;
core . debug ( err . stack ) ;
co nsole. log ( 'Falling back to download directly from Node' ) ;
co re. info ( 'Falling back to download directly from Node' ) ;
}
}
//
//
// Download from nodejs.org
// Download from nodejs.org
@ -13042,7 +13053,7 @@ function getNode(versionSpec, stable, auth) {
if ( ! info ) {
if ( ! info ) {
throw new Error ( ` Unable to find Node version ' ${ versionSpec } ' for platform ${ osPlat } and architecture ${ osArch } . ` ) ;
throw new Error ( ` Unable to find Node version ' ${ versionSpec } ' for platform ${ osPlat } and architecture ${ osArch } . ` ) ;
}
}
co nsole. log ( ` Acquiring ${ info . resolvedVersion } from ${ info . downloadUrl } ` ) ;
co re. info ( ` Acquiring ${ info . resolvedVersion } from ${ info . downloadUrl } ` ) ;
try {
try {
downloadPath = yield tc . downloadTool ( info . downloadUrl ) ;
downloadPath = yield tc . downloadTool ( info . downloadUrl ) ;
}
}
@ -13056,7 +13067,7 @@ function getNode(versionSpec, stable, auth) {
//
//
// Extract
// Extract
//
//
co nsole. log ( 'Extracting ...' ) ;
co re. info ( 'Extracting ...' ) ;
let extPath ;
let extPath ;
info = info || { } ; // satisfy compiler, never null when reaches here
info = info || { } ; // satisfy compiler, never null when reaches here
if ( osPlat == 'win32' ) {
if ( osPlat == 'win32' ) {
@ -13078,9 +13089,9 @@ function getNode(versionSpec, stable, auth) {
//
//
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
//
//
co nsole. log ( 'Adding to the cache ...' ) ;
co re. info ( 'Adding to the cache ...' ) ;
toolPath = yield tc . cacheDir ( extPath , 'node' , info . resolvedVersion ) ;
toolPath = yield tc . cacheDir ( extPath , 'node' , info . resolvedVersion ) ;
co nsole. log ( 'Done' ) ;
co re. info ( 'Done' ) ;
}
}
//
//
// a tool installer initimately knows details about the layout of that tool
// a tool installer initimately knows details about the layout of that tool
@ -13100,7 +13111,6 @@ function getInfoFromManifest(versionSpec, stable, auth) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let info = null ;
let info = null ;
const releases = yield tc . getManifestFromRepo ( 'actions' , 'node-versions' , auth ) ;
const releases = yield tc . getManifestFromRepo ( 'actions' , 'node-versions' , auth ) ;
console . log ( ` matching ${ versionSpec } ... ` ) ;
const rel = yield tc . findFromManifest ( versionSpec , stable , releases ) ;
const rel = yield tc . findFromManifest ( versionSpec , stable , releases ) ;
if ( rel && rel . files . length > 0 ) {
if ( rel && rel . files . length > 0 ) {
info = { } ;
info = { } ;
@ -13136,6 +13146,18 @@ function getInfoFromDist(versionSpec) {
} ;
} ;
} ) ;
} ) ;
}
}
function resolveVersionFromManifest ( versionSpec , stable , auth ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
const info = yield getInfoFromManifest ( versionSpec , stable , auth ) ;
return info === null || info === void 0 ? void 0 : info . resolvedVersion ;
}
catch ( err ) {
core . info ( 'Unable to resolve version from manifest...' ) ;
core . debug ( err . message ) ;
}
} ) ;
}
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
function evaluateVersions ( versions , versionSpec ) {
function evaluateVersions ( versions , versionSpec ) {
let version = '' ;
let version = '' ;
@ -13233,7 +13255,7 @@ function acquireNodeFromFallbackLocation(version) {
try {
try {
exeUrl = ` https://nodejs.org/dist/v ${ version } /win- ${ osArch } /node.exe ` ;
exeUrl = ` https://nodejs.org/dist/v ${ version } /win- ${ osArch } /node.exe ` ;
libUrl = ` https://nodejs.org/dist/v ${ version } /win- ${ osArch } /node.lib ` ;
libUrl = ` https://nodejs.org/dist/v ${ version } /win- ${ osArch } /node.lib ` ;
co nsole. log ( ` Downloading only node binary from ${ exeUrl } ` ) ;
co re. info ( ` Downloading only node binary from ${ exeUrl } ` ) ;
const exePath = yield tc . downloadTool ( exeUrl ) ;
const exePath = yield tc . downloadTool ( exeUrl ) ;
yield io . cp ( exePath , path . join ( tempDir , 'node.exe' ) ) ;
yield io . cp ( exePath , path . join ( tempDir , 'node.exe' ) ) ;
const libPath = yield tc . downloadTool ( libUrl ) ;
const libPath = yield tc . downloadTool ( libUrl ) ;