From 0aeab8d28482b37fbc0562b4587e1c46921b8b27 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Tue, 15 Nov 2022 09:57:34 -0600 Subject: [PATCH] style: Use double-quotes Co-authored-by: ewels --- .github/workflows/example.yml | 16 +++++++------- .github/workflows/publish.yml | 2 +- .github/workflows/test.yml | 2 +- .prettierrc.json | 2 +- action.yml | 20 +++++++++--------- src/functions.ts | 34 ++++++++++++++--------------- src/main.ts | 40 +++++++++++++++++------------------ test/functions.ts | 28 ++++++++++++------------ test/main.ts | 14 ++++++------ test/releasedata.ts | 22 +++++++++---------- test/utils.ts | 4 ++-- 11 files changed, 92 insertions(+), 92 deletions(-) diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index c3aa35c..07495d5 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -17,13 +17,13 @@ jobs: fail-fast: false matrix: nextflow_version: - - '21.10.3' - - '22.04' - - '22.03.1-edge' - - 'latest' - - 'latest-stable' - - 'latest-edge' - - 'latest-everything' + - "21.10.3" + - "22.04" + - "22.03.1-edge" + - "latest" + - "latest-stable" + - "latest-edge" + - "latest-everything" all_distribution: - true - false @@ -33,7 +33,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 16 - cache: 'npm' + cache: "npm" - run: npm ci - run: npm run build - run: npm run package diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 683553a..8faa980 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 16 - cache: 'npm' + cache: "npm" - run: npm ci - run: npm run build - run: npm run package diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e45cfb..be1228f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 16 - cache: 'npm' + cache: "npm" - run: npm ci - run: npm run build - run: npm run format:check diff --git a/.prettierrc.json b/.prettierrc.json index 05d3af9..c853e77 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,7 +3,7 @@ "tabWidth": 2, "useTabs": false, "semi": false, - "singleQuote": true, + "singleQuote": false, "trailingComma": "none", "bracketSpacing": true, "arrowParens": "avoid" diff --git a/action.yml b/action.yml index 987b681..4247dd0 100644 --- a/action.yml +++ b/action.yml @@ -1,22 +1,22 @@ -name: 'Setup Nextflow' -description: 'Install Nextflow and add it to the PATH' -author: 'nf-core' +name: "Setup Nextflow" +description: "Install Nextflow and add it to the PATH" +author: "nf-core" inputs: version: - description: 'The Nextflow version to download (if necessary) and use. Example: 21.10.3' + description: "The Nextflow version to download (if necessary) and use. Example: 21.10.3" required: false - default: 'latest-stable' + default: "latest-stable" all: description: "Whether to install every Nextflow release via the '-all' distribution." required: false default: false token: - description: 'GitHub token to access the GitHub Releases API. The default token should be sufficient for all use cases.' + description: "GitHub token to access the GitHub Releases API. The default token should be sufficient for all use cases." required: false default: ${{ github.token }} runs: - using: 'node16' - main: 'dist/index.js' + using: "node16" + main: "dist/index.js" branding: - icon: 'shuffle' - color: 'green' + icon: "shuffle" + color: "green" diff --git a/src/functions.ts b/src/functions.ts index ebc49a2..d5b6807 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -1,11 +1,11 @@ -import * as core from '@actions/core' -import { GitHub } from '@actions/github/lib/utils' -import * as tc from '@actions/tool-cache' -import retry from 'async-retry' -import * as fs from 'fs' -import semver from 'semver' +import * as core from "@actions/core" +import { GitHub } from "@actions/github/lib/utils" +import * as tc from "@actions/tool-cache" +import retry from "async-retry" +import * as fs from "fs" +import semver from "semver" -const NEXTFLOW_REPO = { owner: 'nextflow-io', repo: 'nextflow' } +const NEXTFLOW_REPO = { owner: "nextflow-io", repo: "nextflow" } // HACK Private but I want to test this export async function all_nf_releases( @@ -35,21 +35,21 @@ export async function release_data( ): Promise { // Setup tag-based filtering let filter = (r: object): boolean => { - return semver.satisfies(r['tag_name'], version, true) + return semver.satisfies(r["tag_name"], version, true) } // Check if the user passed a 'latest*' tag, and override filtering // accordingly - if (version.includes('latest')) { - if (version.includes('-everything')) { + if (version.includes("latest")) { + if (version.includes("-everything")) { // No filtering // eslint-disable-next-line @typescript-eslint/no-unused-vars filter = (r: object) => { return true } - } else if (version.includes('-edge')) { + } else if (version.includes("-edge")) { filter = r => { - return r['tag_name'].endsWith('-edge') + return r["tag_name"].endsWith("-edge") } } else { // This is special: passing 'latest' or 'latest-stable' allows us to use @@ -66,19 +66,19 @@ export async function release_data( matching_releases.sort((x, y) => { // HACK IDK why the value flip is necessary with the return - return semver.compare(x['tag_name'], y['tag_name'], true) * -1 + return semver.compare(x["tag_name"], y["tag_name"], true) * -1 }) return matching_releases[0] } export function nextflow_bin_url(release: object, get_all: boolean): string { - const release_assets = release['assets'] + const release_assets = release["assets"] const all_asset = release_assets.filter((a: object) => { - return a['browser_download_url'].endsWith('-all') + return a["browser_download_url"].endsWith("-all") })[0] const regular_asset = release_assets.filter((a: object) => { - return a['name'] === 'nextflow' + return a["name"] === "nextflow" })[0] const dl_asset = get_all ? all_asset : regular_asset @@ -107,7 +107,7 @@ export async function install_nextflow( const nf_path = `${temp_install_dir}/nextflow` fs.renameSync(nf_dl_path, nf_path) - fs.chmodSync(nf_path, '0711') + fs.chmodSync(nf_path, "0711") return temp_install_dir } diff --git a/src/main.ts b/src/main.ts index 0c1d315..a2a7f05 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,22 +1,22 @@ -import * as core from '@actions/core' -import * as exec from '@actions/exec' -import * as github from '@actions/github' -import { GitHub } from '@actions/github/lib/utils' -import * as tc from '@actions/tool-cache' -import * as fs from 'fs' +import * as core from "@actions/core" +import * as exec from "@actions/exec" +import * as github from "@actions/github" +import { GitHub } from "@actions/github/lib/utils" +import * as tc from "@actions/tool-cache" +import * as fs from "fs" -import { install_nextflow, nextflow_bin_url, release_data } from './functions' +import { install_nextflow, nextflow_bin_url, release_data } from "./functions" async function run(): Promise { // Set environment variables - core.exportVariable('CAPSULE_LOG', 'none') + core.exportVariable("CAPSULE_LOG", "none") // Read in the arguments - const token = core.getInput('token') - const version = core.getInput('version') - const get_all = core.getBooleanInput('all') + const token = core.getInput("token") + const version = core.getInput("version") + const get_all = core.getBooleanInput("all") - let resolved_version = '' + let resolved_version = "" // Setup the API let octokit: InstanceType | undefined @@ -36,9 +36,9 @@ async function run(): Promise { if (octokit !== undefined) { release = await release_data(version, octokit) } - resolved_version = release['tag_name'] + resolved_version = release["tag_name"] core.info( - `Input version '${version}' resolved to Nextflow ${release['name']}` + `Input version '${version}' resolved to Nextflow ${release["name"]}` ) } catch (e: unknown) { if (e instanceof Error) { @@ -49,7 +49,7 @@ async function run(): Promise { } // Get the download url for the desired release - let url = '' + let url = "" try { url = nextflow_bin_url(release, get_all) core.info(`Preparing to download from ${url}`) @@ -60,14 +60,14 @@ async function run(): Promise { } try { // Download Nextflow and add it to path - let nf_path = '' - nf_path = tc.find('nextflow', resolved_version) + let nf_path = "" + nf_path = tc.find("nextflow", resolved_version) if (!nf_path) { core.debug(`Could not find Nextflow ${resolved_version} in cache`) const nf_install_path = await install_nextflow(url, resolved_version) - nf_path = await tc.cacheDir(nf_install_path, 'nextflow', resolved_version) + nf_path = await tc.cacheDir(nf_install_path, "nextflow", resolved_version) core.debug(`Added Nextflow to cache: ${nf_path}`) fs.rmdirSync(nf_install_path, { recursive: true }) @@ -86,11 +86,11 @@ async function run(): Promise { // Run Nextflow so it downloads its dependencies try { - await exec.exec('nextflow', ['help']) + await exec.exec("nextflow", ["help"]) } catch (e: unknown) { if (e instanceof Error) { core.warning( - 'Nextflow appears to have installed correctly, but an error was thrown while running it.' + "Nextflow appears to have installed correctly, but an error was thrown while running it." ) } } diff --git a/test/functions.ts b/test/functions.ts index 8ec473d..36730ca 100644 --- a/test/functions.ts +++ b/test/functions.ts @@ -1,9 +1,9 @@ -import * as github from '@actions/github' -import { GitHub } from '@actions/github/lib/utils' -import anyTest, { TestFn } from 'ava' // eslint-disable-line import/no-unresolved +import * as github from "@actions/github" +import { GitHub } from "@actions/github/lib/utils" +import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved -import * as functions from '../src/functions' -import { getToken } from './utils' +import * as functions from "../src/functions" +import { getToken } from "./utils" const test = anyTest as TestFn<{ token: string @@ -19,18 +19,18 @@ test.before(t => { } }) -test('all_nf_releases', async t => { - const result = await functions.all_nf_releases(t.context['octokit']) - t.is(typeof result, 'object') +test("all_nf_releases", async t => { + const result = await functions.all_nf_releases(t.context["octokit"]) + t.is(typeof result, "object") }) -test('lastest_stable_release_data', async t => { +test("lastest_stable_release_data", async t => { const result = await functions.latest_stable_release_data( - t.context['octokit'] + t.context["octokit"] ) - t.is(typeof result, 'object') - t.is(result['tag_name'], 'v22.10.2') + t.is(typeof result, "object") + t.is(result["tag_name"], "v22.10.2") }) -test.todo('nextflow_bin_url') -test.todo('install_nextflow') +test.todo("nextflow_bin_url") +test.todo("install_nextflow") diff --git a/test/main.ts b/test/main.ts index 53bdc21..0bb474c 100644 --- a/test/main.ts +++ b/test/main.ts @@ -1,13 +1,13 @@ -import test from 'ava' // eslint-disable-line import/no-unresolved -import * as cp from 'child_process' -import * as path from 'path' -import * as process from 'process' +import test from "ava" // eslint-disable-line import/no-unresolved +import * as cp from "child_process" +import * as path from "path" +import * as process from "process" // eslint-disable-next-line ava/no-skip-test -test.skip('test runs', t => { - process.env['INPUT_VERSION'] = 'v22.10.2' +test.skip("test runs", t => { + process.env["INPUT_VERSION"] = "v22.10.2" const np = process.execPath - const ip = path.join(__dirname, '..', 'lib', 'src', 'main.js') + const ip = path.join(__dirname, "..", "lib", "src", "main.js") const options: cp.ExecFileSyncOptions = { env: process.env } diff --git a/test/releasedata.ts b/test/releasedata.ts index 3a1b815..579d02b 100644 --- a/test/releasedata.ts +++ b/test/releasedata.ts @@ -1,9 +1,9 @@ -import * as github from '@actions/github' -import { GitHub } from '@actions/github/lib/utils' -import anyTest, { TestFn } from 'ava' // eslint-disable-line import/no-unresolved +import * as github from "@actions/github" +import { GitHub } from "@actions/github/lib/utils" +import anyTest, { TestFn } from "ava" // eslint-disable-line import/no-unresolved -import { release_data } from '../src/functions' -import { getToken } from './utils' +import { release_data } from "../src/functions" +import { getToken } from "./utils" const test = anyTest as TestFn<{ token: string @@ -20,11 +20,11 @@ test.before(t => { }) const macro = test.macro(async (t, version: string, expected: string) => { - const result = await release_data(version, t.context['octokit']) - t.is(result['tag_name'], expected) + const result = await release_data(version, t.context["octokit"]) + t.is(result["tag_name"], expected) }) -test('hard version', macro, 'v22.10.2', 'v22.10.2') -test('latest-stable', macro, 'latest-stable', 'v22.10.2') -test('latest-edge', macro, 'latest-edge', 'v22.09.7-edge') -test('latest-everything', macro, 'latest-everything', 'v22.10.2') +test("hard version", macro, "v22.10.2", "v22.10.2") +test("latest-stable", macro, "latest-stable", "v22.10.2") +test("latest-edge", macro, "latest-edge", "v22.09.7-edge") +test("latest-everything", macro, "latest-everything", "v22.10.2") diff --git a/test/utils.ts b/test/utils.ts index 994aa41..5f3de85 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -1,9 +1,9 @@ export function getToken(first: boolean): string { - const token = process.env['GITHUB_TOKEN'] || '' + const token = process.env["GITHUB_TOKEN"] || "" if (!token && first) { /* eslint-disable-next-line no-console */ console.warn( - 'Skipping GitHub tests. Set $GITHUB_TOKEN to run REST client and GraphQL client tests' + "Skipping GitHub tests. Set $GITHUB_TOKEN to run REST client and GraphQL client tests" ) first = false }