From 30e60b8681d866f9829f68a380daa6acc923b0dc Mon Sep 17 00:00:00 2001 From: Nikita Grishko Date: Thu, 1 Jul 2021 18:33:20 +0200 Subject: [PATCH] [feat] add support for new installation script #16 --- .github/workflows/default.yml | 2 +- .gitignore | 3 ++ __tests__/inputs.test.ts | 9 +++-- dist/index.js | 6 ++-- package-lock.json | 66 +++++++++++++++++++++++++++++++++++ package.json | 4 ++- src/find.ts | 4 +-- src/inputs.ts | 2 +- 8 files changed, 86 insertions(+), 10 deletions(-) diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 8194a2a..0d85296 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9] - poetry-version: [1.1.5] + poetry-version: [1.1.7, 1.2.0a1] fail-fast: true diff --git a/.gitignore b/.gitignore index 20eb825..2e238d9 100644 --- a/.gitignore +++ b/.gitignore @@ -100,3 +100,6 @@ lib/**/* # ASDF files .tool-versions + +# Other +.vscode/ diff --git a/__tests__/inputs.test.ts b/__tests__/inputs.test.ts index 3c17a84..31ad277 100644 --- a/__tests__/inputs.test.ts +++ b/__tests__/inputs.test.ts @@ -5,10 +5,11 @@ const TEST_ENV_VARS = { INPUT_FALSY: "false", INPUT_TRUTHY: "true", INPUT_VERSION_UNSUPPORTED: "0.12.0", - INPUT_VERSION_SUPPORTED: "1.0", + INPUT_VERSION_SUPPORTED: "1.0.0", + INPUT_VERSION_ALPHA: "1.2.0a1", "INPUT_POETRY-PREVIEW": "true", - "INPUT_POETRY-VERSION": "1.2" + "INPUT_POETRY-VERSION": "1.2.0" } describe("options", () => { @@ -59,4 +60,8 @@ describe("options", () => { it("getVersionInput returns version if input is supported", () => { expect(getVersionInput("version_supported")).toBe("1.0.0") }) + + it("getVersionInput returns version if input is alpha", () => { + expect(getVersionInput("version_alpha")).toBe("1.2.0a1") + }) }) diff --git a/dist/index.js b/dist/index.js index d2d1680..81d3dd1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25,7 +25,7 @@ const exec_1 = __nccwpck_require__(1514); const tool_cache_1 = __nccwpck_require__(7784); const os_1 = __importDefault(__nccwpck_require__(2087)); const path_1 = __importDefault(__nccwpck_require__(5622)); -const GET_POETRY_URL = "https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py"; +const GET_POETRY_URL = "https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py"; function findPoetry(inputs) { return __awaiter(this, void 0, void 0, function* () { // If Poetry version is specified then we try to find a cached version and if it found @@ -43,7 +43,7 @@ function findPoetry(inputs) { yield exec_1.exec("python", [getPoetryPath, ...getPoetryArgs(inputs)]); // If Poetry installed with specified version then add it to the cache and to the jobs // PATH, otherwise, just add it to the jobs PATH - const poetryPath = path_1.default.join(os_1.default.homedir(), ".poetry"); + const poetryPath = path_1.default.join(os_1.default.homedir(), ".local", "share", "pypoetry"); if (inputs.version) { const poetryCachedPath = yield tool_cache_1.cacheDir(poetryPath, "poetry", inputs.version); core_1.addPath(getPoetryBin(poetryCachedPath)); @@ -111,7 +111,7 @@ function getVersionInput(name) { throw new Error(`Passed Poetry version '${coerced}' is not supported. Please use any other supported version >=1.0`); } - return coerced.format(); + return version.trim(); } exports.getVersionInput = getVersionInput; diff --git a/package-lock.json b/package-lock.json index 9631cda..21ac210 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1525,6 +1525,30 @@ "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", "dev": true }, + "@tsconfig/node10": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", + "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", + "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", + "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.1.tgz", + "integrity": "sha512-FTgBI767POY/lKNDNbIzgAX6miIDBs6NTCbdlDb8TrWovHsSvaVIZDlTqym29C6UqhzwcJx4CYr+AlrMywA0cA==", + "dev": true + }, "@types/babel__core": { "version": "7.1.14", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.14.tgz", @@ -2066,6 +2090,12 @@ "picomatch": "^2.0.4" } }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -2598,6 +2628,12 @@ "safe-buffer": "~5.1.1" } }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -2707,6 +2743,12 @@ "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", "dev": true }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, "diff-sequences": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz", @@ -8063,6 +8105,24 @@ "yargs-parser": "20.x" } }, + "ts-node": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.0.0.tgz", + "integrity": "sha512-ROWeOIUvfFbPZkoDis0L/55Fk+6gFQNZwwKPLinacRl6tsxstTF1DbAcLKkovwnpKMVvOMHP1TIbnwXwtLg1gg==", + "dev": true, + "requires": { + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "source-map-support": "^0.5.17", + "yn": "3.1.1" + } + }, "tsconfig-paths": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", @@ -8408,6 +8468,12 @@ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", "dev": true + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true } } } diff --git a/package.json b/package.json index a203ef3..0edb875 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "lint:eslint": "eslint src/**/*.ts", "lint:prettier": "prettier --check {*.json,*.yml,**/*.ts,.github/**/*.yml}", "lint": "npm-run-all lint:*", - "test": "jest --coverage" + "test": "jest --coverage", + "ts-node": "ts-node" }, "repository": { "type": "git", @@ -46,6 +47,7 @@ "npm-run-all": "^4.1.5", "prettier": "^2.3.2", "ts-jest": "^27.0.0", + "ts-node": "^10.0.0", "typescript": "^4.3.5" } } diff --git a/src/find.ts b/src/find.ts index ee1a4e2..ee14f13 100644 --- a/src/find.ts +++ b/src/find.ts @@ -6,7 +6,7 @@ import os from "os" import path from "path" const GET_POETRY_URL = - "https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py" + "https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py" export async function findPoetry(inputs: Inputs): Promise { // If Poetry version is specified then we try to find a cached version and if it found @@ -27,7 +27,7 @@ export async function findPoetry(inputs: Inputs): Promise { // If Poetry installed with specified version then add it to the cache and to the jobs // PATH, otherwise, just add it to the jobs PATH - const poetryPath = path.join(os.homedir(), ".poetry") + const poetryPath = path.join(os.homedir(), ".local", "share", "pypoetry") if (inputs.version) { const poetryCachedPath = await cacheDir( poetryPath, diff --git a/src/inputs.ts b/src/inputs.ts index cede6ed..10985f3 100644 --- a/src/inputs.ts +++ b/src/inputs.ts @@ -39,5 +39,5 @@ export function getVersionInput(name: string): string | null { ) } - return coerced.format() + return version.trim() }