mirror of
https://github.com/NuGet/setup-nuget.git
synced 2025-12-06 07:48:23 +08:00
Introduce end-of-line normalization (#39)
This commit is contained in:
10
.github/CODEOWNERS
vendored
10
.github/CODEOWNERS
vendored
@@ -1,5 +1,5 @@
|
|||||||
# These owners will be the default owners for everything in
|
# These owners will be the default owners for everything in
|
||||||
# the repo. Unless a later match takes precedence,
|
# the repo. Unless a later match takes precedence,
|
||||||
# review when someone opens a pull request.
|
# review when someone opens a pull request.
|
||||||
# For more on how to customize the CODEOWNERS file - https://help.github.com/en/articles/about-code-owners
|
# For more on how to customize the CODEOWNERS file - https://help.github.com/en/articles/about-code-owners
|
||||||
* @NuGet/nuget-client
|
* @NuGet/nuget-client
|
||||||
|
|||||||
186
.gitignore
vendored
186
.gitignore
vendored
@@ -1,93 +1,93 @@
|
|||||||
__tests__/runner/*
|
__tests__/runner/*
|
||||||
|
|
||||||
# comment out in distribution branches
|
# comment out in distribution branches
|
||||||
/node_modules
|
/node_modules
|
||||||
|
|
||||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
# Runtime data
|
# Runtime data
|
||||||
pids
|
pids
|
||||||
*.pid
|
*.pid
|
||||||
*.seed
|
*.seed
|
||||||
*.pid.lock
|
*.pid.lock
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
lib-cov
|
lib-cov
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
coverage
|
coverage
|
||||||
*.lcov
|
*.lcov
|
||||||
|
|
||||||
# nyc test coverage
|
# nyc test coverage
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
.grunt
|
.grunt
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
# Bower dependency directory (https://bower.io/)
|
||||||
bower_components
|
bower_components
|
||||||
|
|
||||||
# node-waf configuration
|
# node-waf configuration
|
||||||
.lock-wscript
|
.lock-wscript
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
build/Release
|
build/Release
|
||||||
|
|
||||||
# Dependency directories
|
# Dependency directories
|
||||||
jspm_packages/
|
jspm_packages/
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
# TypeScript v1 declaration files
|
||||||
typings/
|
typings/
|
||||||
|
|
||||||
# TypeScript cache
|
# TypeScript cache
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
||||||
# Optional npm cache directory
|
# Optional npm cache directory
|
||||||
.npm
|
.npm
|
||||||
|
|
||||||
# Optional eslint cache
|
# Optional eslint cache
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
||||||
# Optional REPL history
|
# Optional REPL history
|
||||||
.node_repl_history
|
.node_repl_history
|
||||||
|
|
||||||
# Output of 'npm pack'
|
# Output of 'npm pack'
|
||||||
*.tgz
|
*.tgz
|
||||||
|
|
||||||
# Yarn Integrity file
|
# Yarn Integrity file
|
||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
|
||||||
# dotenv environment variables file
|
# dotenv environment variables file
|
||||||
.env
|
.env
|
||||||
.env.test
|
.env.test
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
# next.js build output
|
# next.js build output
|
||||||
.next
|
.next
|
||||||
|
|
||||||
# nuxt.js build output
|
# nuxt.js build output
|
||||||
.nuxt
|
.nuxt
|
||||||
|
|
||||||
# vuepress build output
|
# vuepress build output
|
||||||
.vuepress/dist
|
.vuepress/dist
|
||||||
|
|
||||||
# Serverless directories
|
# Serverless directories
|
||||||
.serverless/
|
.serverless/
|
||||||
|
|
||||||
# FuseBox cache
|
# FuseBox cache
|
||||||
.fusebox/
|
.fusebox/
|
||||||
|
|
||||||
# DynamoDB Local files
|
# DynamoDB Local files
|
||||||
.dynamodb/
|
.dynamodb/
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"printWidth": 80,
|
"printWidth": 80,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false,
|
"useTabs": false,
|
||||||
"semi": true,
|
"semi": true,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "none",
|
"trailingComma": "none",
|
||||||
"bracketSpacing": false,
|
"bracketSpacing": false,
|
||||||
"arrowParens": "avoid",
|
"arrowParens": "avoid",
|
||||||
"parser": "typescript"
|
"parser": "typescript"
|
||||||
}
|
}
|
||||||
44
LICENSE
44
LICENSE
@@ -1,23 +1,23 @@
|
|||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2019 Microsoft and contributors
|
Copyright (c) 2019 Microsoft and contributors
|
||||||
Copyright (c) 2018 GitHub, Inc. and contributors
|
Copyright (c) 2018 GitHub, Inc. and contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
@@ -1,107 +1,107 @@
|
|||||||
import nock = require('nock');
|
import nock = require('nock');
|
||||||
import pickVersion from '../src/pick-version';
|
import pickVersion from '../src/pick-version';
|
||||||
|
|
||||||
const HOST = 'https://dist.nuget.org';
|
const HOST = 'https://dist.nuget.org';
|
||||||
const PATH = '/tools.json';
|
const PATH = '/tools.json';
|
||||||
const TOOLS_JSON = {
|
const TOOLS_JSON = {
|
||||||
'nuget.exe': [
|
'nuget.exe': [
|
||||||
{
|
{
|
||||||
version: '5.3.1',
|
version: '5.3.1',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.1/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.1/nuget.exe',
|
||||||
stage: 'ReleasedAndBlessed',
|
stage: 'ReleasedAndBlessed',
|
||||||
uploaded: '2019-10-24T21:00:00.0000000Z'
|
uploaded: '2019-10-24T21:00:00.0000000Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
version: '5.3.0',
|
version: '5.3.0',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.0/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.0/nuget.exe',
|
||||||
stage: 'ReleasedAndBlessed',
|
stage: 'ReleasedAndBlessed',
|
||||||
uploaded: '2019-09-23T21:00:00.0000000Z'
|
uploaded: '2019-09-23T21:00:00.0000000Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
version: '5.3.0-preview3',
|
version: '5.3.0-preview3',
|
||||||
url:
|
url:
|
||||||
'https://dist.nuget.org/win-x86-commandline/v5.3.0-preview3/nuget.exe',
|
'https://dist.nuget.org/win-x86-commandline/v5.3.0-preview3/nuget.exe',
|
||||||
stage: 'EarlyAccessPreview',
|
stage: 'EarlyAccessPreview',
|
||||||
uploaded: '2019-09-04T17:00:00.0000000Z'
|
uploaded: '2019-09-04T17:00:00.0000000Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
version: '3.2.0',
|
version: '3.2.0',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v3.2.0/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v3.2.0/nuget.exe',
|
||||||
stage: 'Released',
|
stage: 'Released',
|
||||||
uploaded: '2015-09-16T14:00:00.0000000-07:00'
|
uploaded: '2015-09-16T14:00:00.0000000-07:00'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
version: '2.8.6',
|
version: '2.8.6',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v2.8.6/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v2.8.6/nuget.exe',
|
||||||
stage: 'ReleasedAndBlessed',
|
stage: 'ReleasedAndBlessed',
|
||||||
uploaded: '2015-09-01T12:30:00.0000000-07:00'
|
uploaded: '2015-09-01T12:30:00.0000000-07:00'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
test('picks a version based on concrete version', async () => {
|
test('picks a version based on concrete version', async () => {
|
||||||
const srv = nock(HOST);
|
const srv = nock(HOST);
|
||||||
srv.get(PATH).reply(200, TOOLS_JSON);
|
srv.get(PATH).reply(200, TOOLS_JSON);
|
||||||
let tool = await pickVersion('5.3.0');
|
let tool = await pickVersion('5.3.0');
|
||||||
srv.done();
|
srv.done();
|
||||||
expect(tool).toStrictEqual({
|
expect(tool).toStrictEqual({
|
||||||
version: '5.3.0',
|
version: '5.3.0',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.0/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.0/nuget.exe',
|
||||||
stage: 'ReleasedAndBlessed',
|
stage: 'ReleasedAndBlessed',
|
||||||
uploaded: new Date('2019-09-23T21:00:00.0000000Z')
|
uploaded: new Date('2019-09-23T21:00:00.0000000Z')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('picks a version based on semver range', async () => {
|
test('picks a version based on semver range', async () => {
|
||||||
const srv = nock(HOST);
|
const srv = nock(HOST);
|
||||||
srv.get(PATH).reply(200, TOOLS_JSON);
|
srv.get(PATH).reply(200, TOOLS_JSON);
|
||||||
let tool = await pickVersion('5.3');
|
let tool = await pickVersion('5.3');
|
||||||
srv.done();
|
srv.done();
|
||||||
expect(tool).toStrictEqual({
|
expect(tool).toStrictEqual({
|
||||||
version: '5.3.1',
|
version: '5.3.1',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.1/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.1/nuget.exe',
|
||||||
stage: 'ReleasedAndBlessed',
|
stage: 'ReleasedAndBlessed',
|
||||||
uploaded: new Date('2019-10-24T21:00:00.0000000Z')
|
uploaded: new Date('2019-10-24T21:00:00.0000000Z')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('picks a version based on stage', async () => {
|
test('picks a version based on stage', async () => {
|
||||||
const srv = nock(HOST);
|
const srv = nock(HOST);
|
||||||
srv
|
srv
|
||||||
.get(PATH)
|
.get(PATH)
|
||||||
.times(2)
|
.times(2)
|
||||||
.reply(200, TOOLS_JSON);
|
.reply(200, TOOLS_JSON);
|
||||||
let tool = await pickVersion('latest');
|
let tool = await pickVersion('latest');
|
||||||
expect(tool).toStrictEqual({
|
expect(tool).toStrictEqual({
|
||||||
version: '5.3.1',
|
version: '5.3.1',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.1/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.1/nuget.exe',
|
||||||
stage: 'ReleasedAndBlessed',
|
stage: 'ReleasedAndBlessed',
|
||||||
uploaded: new Date('2019-10-24T21:00:00.0000000Z')
|
uploaded: new Date('2019-10-24T21:00:00.0000000Z')
|
||||||
});
|
});
|
||||||
tool = await pickVersion('preview');
|
tool = await pickVersion('preview');
|
||||||
srv.done();
|
srv.done();
|
||||||
expect(tool).toStrictEqual({
|
expect(tool).toStrictEqual({
|
||||||
version: '5.3.0-preview3',
|
version: '5.3.0-preview3',
|
||||||
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.0-preview3/nuget.exe',
|
url: 'https://dist.nuget.org/win-x86-commandline/v5.3.0-preview3/nuget.exe',
|
||||||
stage: 'EarlyAccessPreview',
|
stage: 'EarlyAccessPreview',
|
||||||
uploaded: new Date('2019-09-04T17:00:00.0000000Z')
|
uploaded: new Date('2019-09-04T17:00:00.0000000Z')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('errors when no version could be found', async () => {
|
test('errors when no version could be found', async () => {
|
||||||
const srv = nock(HOST);
|
const srv = nock(HOST);
|
||||||
srv.get(PATH).reply(200, TOOLS_JSON);
|
srv.get(PATH).reply(200, TOOLS_JSON);
|
||||||
let promise = pickVersion('4');
|
let promise = pickVersion('4');
|
||||||
promise.catch(() => {}).finally(() => srv.done());
|
promise.catch(() => {}).finally(() => srv.done());
|
||||||
expect(promise).rejects.toThrow("No valid versions could be found for '4'.");
|
expect(promise).rejects.toThrow("No valid versions could be found for '4'.");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('errors if an invalid label is passed in', async () => {
|
test('errors if an invalid label is passed in', async () => {
|
||||||
const srv = nock(HOST);
|
const srv = nock(HOST);
|
||||||
srv.get(PATH).reply(200, TOOLS_JSON);
|
srv.get(PATH).reply(200, TOOLS_JSON);
|
||||||
let promise = pickVersion('yesterday');
|
let promise = pickVersion('yesterday');
|
||||||
promise.catch(() => {}).finally(() => srv.done());
|
promise.catch(() => {}).finally(() => srv.done());
|
||||||
expect(promise).rejects.toThrow(
|
expect(promise).rejects.toThrow(
|
||||||
"Invalid release label: 'yesterday'. Valid labels are 'latest' and 'preview'."
|
"Invalid release label: 'yesterday'. Valid labels are 'latest' and 'preview'."
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
118
lib/installer.js
118
lib/installer.js
@@ -1,59 +1,59 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const tc = __importStar(require("@actions/tool-cache"));
|
const tc = __importStar(require("@actions/tool-cache"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const exec_1 = require("@actions/exec");
|
const exec_1 = require("@actions/exec");
|
||||||
const pick_version_1 = __importDefault(require("./pick-version"));
|
const pick_version_1 = __importDefault(require("./pick-version"));
|
||||||
async function install(spec = 'latest', apiKey, apiKeySource) {
|
async function install(spec = 'latest', apiKey, apiKeySource) {
|
||||||
const tool = await pick_version_1.default(spec);
|
const tool = await pick_version_1.default(spec);
|
||||||
core.debug(`Found NuGet version: ${tool.version}`);
|
core.debug(`Found NuGet version: ${tool.version}`);
|
||||||
let cachePath = await tc.find('nuget.exe', tool.version);
|
let cachePath = await tc.find('nuget.exe', tool.version);
|
||||||
if (!cachePath) {
|
if (!cachePath) {
|
||||||
const nugetExePath = await tc.downloadTool(tool.url);
|
const nugetExePath = await tc.downloadTool(tool.url);
|
||||||
cachePath = await tc.cacheFile(nugetExePath, 'nuget.exe', 'nuget.exe', tool.version);
|
cachePath = await tc.cacheFile(nugetExePath, 'nuget.exe', 'nuget.exe', tool.version);
|
||||||
}
|
}
|
||||||
core.debug(`nuget.exe cache path: ${cachePath}.`);
|
core.debug(`nuget.exe cache path: ${cachePath}.`);
|
||||||
core.exportVariable('NUGET', `${cachePath}/nuget.exe`);
|
core.exportVariable('NUGET', `${cachePath}/nuget.exe`);
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
core.debug(`Creating dummy 'nuget' script.`);
|
core.debug(`Creating dummy 'nuget' script.`);
|
||||||
const scriptPath = path.join(cachePath, 'nuget');
|
const scriptPath = path.join(cachePath, 'nuget');
|
||||||
fs.writeFileSync(scriptPath, `#!/bin/sh\nmono $MONO_OPTIONS ${path.join(cachePath, 'nuget.exe')} "$@"`);
|
fs.writeFileSync(scriptPath, `#!/bin/sh\nmono $MONO_OPTIONS ${path.join(cachePath, 'nuget.exe')} "$@"`);
|
||||||
fs.chmodSync(scriptPath, '755');
|
fs.chmodSync(scriptPath, '755');
|
||||||
}
|
}
|
||||||
core.addPath(cachePath);
|
core.addPath(cachePath);
|
||||||
core.setOutput('nuget-version', tool.version);
|
core.setOutput('nuget-version', tool.version);
|
||||||
console.log(`Installed nuget.exe version ${tool.version}`);
|
console.log(`Installed nuget.exe version ${tool.version}`);
|
||||||
if (apiKey) {
|
if (apiKey) {
|
||||||
const args = ['SetApiKey', apiKey];
|
const args = ['SetApiKey', apiKey];
|
||||||
if (apiKeySource) {
|
if (apiKeySource) {
|
||||||
args.push('-source', apiKeySource);
|
args.push('-source', apiKeySource);
|
||||||
}
|
}
|
||||||
await exec_1.exec(path.join(cachePath, process.platform === 'win32' ? 'nuget.exe' : 'nuget'), args, { silent: true });
|
await exec_1.exec(path.join(cachePath, process.platform === 'win32' ? 'nuget.exe' : 'nuget'), args, { silent: true });
|
||||||
console.log('Set up configured NuGet API key.');
|
console.log('Set up configured NuGet API key.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.default = install;
|
exports.default = install;
|
||||||
|
|||||||
70
lib/main.js
70
lib/main.js
@@ -1,35 +1,35 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const installer_1 = __importDefault(require("./installer"));
|
const installer_1 = __importDefault(require("./installer"));
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
await installer_1.default(core.getInput('nuget-version'), core.getInput('nuget-api-key'), core.getInput('nuget-api-key-source'));
|
await installer_1.default(core.getInput('nuget-version'), core.getInput('nuget-api-key'), core.getInput('nuget-api-key-source'));
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|||||||
@@ -1,69 +1,69 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const rest = __importStar(require("typed-rest-client/RestClient"));
|
const rest = __importStar(require("typed-rest-client/RestClient"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
var Stage;
|
var Stage;
|
||||||
(function (Stage) {
|
(function (Stage) {
|
||||||
Stage["latest"] = "ReleasedAndBlessed";
|
Stage["latest"] = "ReleasedAndBlessed";
|
||||||
Stage["preview"] = "EarlyAccessPreview";
|
Stage["preview"] = "EarlyAccessPreview";
|
||||||
Stage["_released"] = "Released";
|
Stage["_released"] = "Released";
|
||||||
})(Stage || (Stage = {}));
|
})(Stage || (Stage = {}));
|
||||||
async function pickVersion(spec) {
|
async function pickVersion(spec) {
|
||||||
spec = spec.trim();
|
spec = spec.trim();
|
||||||
let versions = await fetchVersions();
|
let versions = await fetchVersions();
|
||||||
let range = semver.validRange(spec, true);
|
let range = semver.validRange(spec, true);
|
||||||
let selected;
|
let selected;
|
||||||
if (range) {
|
if (range) {
|
||||||
selected = versions.find(v => semver.satisfies(v.version, range, true));
|
selected = versions.find(v => semver.satisfies(v.version, range, true));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let stage = spec == 'latest'
|
let stage = spec == 'latest'
|
||||||
? Stage.latest
|
? Stage.latest
|
||||||
: spec == 'preview'
|
: spec == 'preview'
|
||||||
? Stage.preview
|
? Stage.preview
|
||||||
: null;
|
: null;
|
||||||
if (!stage) {
|
if (!stage) {
|
||||||
throw new Error(`Invalid release label: '${spec}'. Valid labels are 'latest' and 'preview'.`);
|
throw new Error(`Invalid release label: '${spec}'. Valid labels are 'latest' and 'preview'.`);
|
||||||
}
|
}
|
||||||
selected = versions.find(v => v.stage === stage);
|
selected = versions.find(v => v.stage === stage);
|
||||||
}
|
}
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
throw new Error(`No valid versions could be found for '${spec}'.`);
|
throw new Error(`No valid versions could be found for '${spec}'.`);
|
||||||
}
|
}
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
exports.default = pickVersion;
|
exports.default = pickVersion;
|
||||||
async function fetchVersions() {
|
async function fetchVersions() {
|
||||||
const http = new rest.RestClient('nuget/setup-nuget-exe', undefined, undefined, {
|
const http = new rest.RestClient('nuget/setup-nuget-exe', undefined, undefined, {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 3
|
maxRetries: 3
|
||||||
});
|
});
|
||||||
return (await http
|
return (await http
|
||||||
.get('https://dist.nuget.org/tools.json')
|
.get('https://dist.nuget.org/tools.json')
|
||||||
.then(j => j.result || { 'nuget.exe': [] })
|
.then(j => j.result || { 'nuget.exe': [] })
|
||||||
.then(n => n['nuget.exe'])).map(v => {
|
.then(n => n['nuget.exe'])).map(v => {
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
uploaded: new Date(v.uploaded)
|
uploaded: new Date(v.uploaded)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user