Skip to content

Commit

Permalink
fix: use latest eslint-config-oclif-typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 9, 2023
1 parent 34e7e90 commit 84d12a3
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 65 deletions.
24 changes: 2 additions & 22 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
{
"extends": ["oclif", "oclif-typescript", "prettier", "plugin:perfectionist/recommended-natural"],
"extends": ["oclif", "oclif-typescript", "prettier"],
"rules": {
"unicorn/prefer-module": "off",
"unicorn/no-array-reduce": "off",
"no-useless-constructor": "off",
"perfectionist/sort-classes": [
"error",
{
"order": "asc",
"type": "alphabetical",
"groups": [
"index-signature",
"static-property",
"property",
"private-property",
"constructor",
"static-method",
"static-private-method",
"method",
"private-method",
["get-method", "set-method"],
"unknown"
]
}
]
"no-useless-constructor": "off"
}
}
4 changes: 2 additions & 2 deletions .git2gus/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"productTag": "a1aB0000000ce2IIAQ",
"defaultBuild": "offcore.tooling.55",
"issueTypeLabels": { "enhancement": "USER STORY", "bug": "BUG P3" },
"defaultBuild": "offcore.tooling.59",
"issueTypeLabels": {"enhancement": "USER STORY", "bug": "BUG P3"},
"hideWorkItemUrl": true,
"statusWhenClosed": "CLOSED"
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Salesforce",
"bugs": "https://github.com/oclif/plugin-update/issues",
"dependencies": {
"@oclif/core": "^3.0.3",
"@oclif/core": "^3.0.4",
"chalk": "^5",
"cross-spawn": "^7.0.3",
"debug": "^4.3.1",
Expand Down Expand Up @@ -37,9 +37,8 @@
"commitlint": "^17.7.2",
"eslint": "^8.49.0",
"eslint-config-oclif": "^5.0.0",
"eslint-config-oclif-typescript": "^2.0.1",
"eslint-config-oclif-typescript": "^3.0.1",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-perfectionist": "^2.1.0",
"got": "^13.0.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export const init: Interfaces.Hook<'init'> = async function (opts) {
if (opts.config.channel === 'stable') days = 14
m.setHours(m.getHours() + days * 24)
return m < new Date()
} catch (error: any) {
if (error.code !== 'ENOENT') throwError(error.stack)
if ((global as any).testing) return false
} catch (error: unknown) {
const err = error as {code: string; stack: string}
if (err.code !== 'ENOENT') throwError(err.stack)
if ((global as unknown as {testing: boolean}).testing) return false
debug('autoupdate ENOENT')
return true
}
Expand Down
12 changes: 6 additions & 6 deletions src/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {touch} from './util.js'
const debug = makeDebug('oclif-update')
import crypto from 'node:crypto'
import zlib from 'node:zlib'
import {extract as tarExtract} from 'tar-fs'
import {Headers, extract as tarExtract} from 'tar-fs'

const ignore = (_: any, header: any) => {
switch (header.type) {
const ignore = (_name: string, header?: Headers) => {
switch (header?.type) {
case 'directory':
case 'file': {
if (process.env.OCLIF_DEBUG_UPDATE_FILES) debug(header.name)
Expand All @@ -22,7 +22,7 @@ const ignore = (_: any, header: any) => {
}

default: {
throw new Error(header.type)
throw new Error(header?.type)
}
}
}
Expand Down Expand Up @@ -71,7 +71,7 @@ async function extract(stream: NodeJS.ReadableStream, basename: string, output:
const tmp = getTmp()
await cp(output, tmp)
await rm(tmp, {force: true, recursive: true}).catch(debug)
} catch (error: any) {
} catch (error: unknown) {
debug(error)
await rm(tmp, {force: true, recursive: true}).catch(debug)
}
Expand All @@ -83,7 +83,7 @@ async function extract(stream: NodeJS.ReadableStream, basename: string, output:
await rm(tmp, {force: true, recursive: true}).catch(debug)
await touch(output)
debug('done extracting')
} catch (error: any) {
} catch (error: unknown) {
await rm(tmp, {force: true, recursive: true}).catch(process.emitWarning)
throw error
}
Expand Down
46 changes: 23 additions & 23 deletions src/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ const filesize = (n: number): string => {
return Number.parseFloat(num).toFixed(1) + ` ${suffix}`
}

export namespace Updater {
export type Options = {
autoUpdate: boolean
channel?: string | undefined
force?: boolean
version?: string | undefined
}

export type VersionIndex = Record<string, string>
type Options = {
autoUpdate: boolean
channel?: string | undefined
force?: boolean
version?: string | undefined
}

type VersionIndex = Record<string, string>

export class Updater {
private readonly clientBin: string
private readonly clientRoot: string
Expand All @@ -35,11 +33,11 @@ export class Updater {
this.clientBin = join(this.clientRoot, 'bin', config.windows ? `${config.bin}.cmd` : config.bin)
}

public async fetchVersionIndex(): Promise<Updater.VersionIndex> {
public async fetchVersionIndex(): Promise<VersionIndex> {
ux.action.status = 'fetching version index'
const newIndexUrl = this.config.s3Url(s3VersionIndexKey(this.config))
try {
const {body} = await HTTP.get<Updater.VersionIndex>(newIndexUrl)
const {body} = await HTTP.get<VersionIndex>(newIndexUrl)
if (typeof body === 'string') {
return JSON.parse(body)
}
Expand All @@ -58,7 +56,7 @@ export class Updater {
.map((f) => join(this.clientRoot, f))
}

public async runUpdate(options: Updater.Options): Promise<void> {
public async runUpdate(options: Options): Promise<void> {
const {autoUpdate, force = false, version} = options
if (autoUpdate) await debounce(this.config.cacheDir)

Expand Down Expand Up @@ -204,8 +202,8 @@ ${binPathEnvVar}="\$DIR/${bin}" ${redirectedEnvVar}=1 "$DIR/../${version}/bin/${
.filter((f) => isNotSpecial(this.config.version, f.path) && isOld(f.stat))
.map((f) => rm(f.path, {force: true, recursive: true})),
)
} catch (error: any) {
ux.warn(error)
} catch (error: unknown) {
ux.warn(error as Error | string)
}
}

Expand All @@ -216,8 +214,8 @@ ${binPathEnvVar}="\$DIR/${bin}" ${redirectedEnvVar}=1 "$DIR/../${version}/bin/${
ux.debug('touching client at', p)
if (!existsSync(p)) return
return utimes(p, new Date(), new Date())
} catch (error: any) {
ux.warn(error)
} catch (error: unknown) {
ux.warn(error as Error | string)
}
}

Expand Down Expand Up @@ -258,8 +256,9 @@ const alreadyOnVersion = (current: string, updated: null | string): boolean => c
const ensureClientDir = async (clientRoot: string): Promise<void> => {
try {
await mkdir(clientRoot, {recursive: true})
} catch (error: any) {
if (error.code === 'EEXIST') {
} catch (error: unknown) {
const {code} = error as {code: string}
if (code === 'EEXIST') {
// for some reason the client directory is sometimes a file
// if so, this happens. Delete it and recreate
await rm(clientRoot, {force: true, recursive: true})
Expand All @@ -284,7 +283,7 @@ const notUpdatable = (config: Config): boolean => {
}

const composeS3SubDir = (config: Config): string => {
let s3SubDir = (config.pjson.oclif.update.s3 as any).folder || ''
let s3SubDir = config.pjson.oclif.update.s3.folder || ''
if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/') s3SubDir = `${s3SubDir}/`
return s3SubDir
}
Expand Down Expand Up @@ -357,8 +356,9 @@ const fetchChannelManifest = async (channel: string, config: Config): Promise<In
const s3Key = s3ChannelManifestKey(channel, config)
try {
return await fetchManifest(s3Key, config)
} catch (error: any) {
if (error.statusCode === 403) throw new Error(`HTTP 403: Invalid channel ${channel}`)
} catch (error: unknown) {
const {statusCode} = error as {statusCode: number}
if (statusCode === 403) throw new Error(`HTTP 403: Invalid channel ${channel}`)
throw error
}
}
Expand Down Expand Up @@ -443,8 +443,8 @@ const determineCurrentVersion = async (clientBin: string, version: string): Prom
const currentVersion = await readFile(clientBin, 'utf8')
const matches = currentVersion.match(/\.\.[/\\|](.+)[/\\|]bin/)
return matches ? matches[1] : version
} catch (error: any) {
ux.debug(error)
} catch (error: unknown) {
ux.warn(error as Error | string)
}

return version
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function ls(dir: string): Promise<Array<{path: string; stat: Stats}

export function wait(ms: number, unref = false): Promise<void> {
return new Promise((resolve) => {
const t: any = setTimeout(() => resolve(), ms)
const t = setTimeout(() => resolve(), ms)
if (unref) t.unref()
})
}
42 changes: 37 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^3.0.0-beta.19", "@oclif/core@^3.0.3":
"@oclif/core@^3.0.0-beta.19":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.0.3.tgz#dbed0b2d819cd86f3733a2311a7278a304e089e4"
integrity sha512-5xdT3xFXOSsR8AtE2VNswTjCxFQFLptfnkmhhgWqKbSkFBmtix0n5EN560xmeasVku/5eZdA6juEZunS5ZKIXg==
Expand Down Expand Up @@ -538,6 +538,37 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^3.0.4":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.0.4.tgz#1ef4667fbbbcf2d4cab02eead27cd80de83b952a"
integrity sha512-zP+OF/PVCgPLVNfoBMevafki71Zn6t1SbU4AIQcsNNAsoC2SpBiUFx81yvJbMG2172ss58ePT5odr1JweuYdhA==
dependencies:
ansi-escapes "^4.3.2"
ansi-styles "^4.3.0"
cardinal "^2.1.1"
chalk "^4.1.2"
clean-stack "^3.0.1"
cli-progress "^3.12.0"
debug "^4.3.4"
ejs "^3.1.8"
get-package-type "^0.1.0"
globby "^11.1.0"
hyperlinker "^1.0.0"
indent-string "^4.0.0"
is-wsl "^2.2.0"
js-yaml "^3.14.1"
natural-orderby "^2.0.3"
object-treeify "^1.1.33"
password-prompt "^1.1.2"
slice-ansi "^4.0.0"
string-width "^4.2.3"
strip-ansi "^6.0.1"
supports-color "^8.1.1"
supports-hyperlinks "^2.2.0"
widest-line "^3.1.0"
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/plugin-help@^5.2.14":
version "5.2.20"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-5.2.20.tgz#4035a0ac231f95fb8e334da342175e3ca00f6abc"
Expand Down Expand Up @@ -2390,10 +2421,10 @@ escape-string-regexp@^5.0.0:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz#4683126b500b61762f2dbebace1806e8be31b1c8"
integrity sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==

eslint-config-oclif-typescript@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/eslint-config-oclif-typescript/-/eslint-config-oclif-typescript-2.0.1.tgz#bdaca00f53ee27ff6930673082a00a03d6cf8dd1"
integrity sha512-Z0U0KVNXGcTzYdSoDsrHulkspS1ZW/NrNgv/IAvpd7F2ZdrLUEmRlJn7Kwnk8CdUufJb/GsW+qVKIG/fPhwKpg==
eslint-config-oclif-typescript@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/eslint-config-oclif-typescript/-/eslint-config-oclif-typescript-3.0.1.tgz#9072bfe3045bf24b572a3f11015b1ea36b017015"
integrity sha512-XyZHhnoOngxEvE7UpY+fkmi7AnhLb7xM+hB51JZ13y6TmIDJSxwCCJTnhF2LZCioJGDB60/n/XpyfDrpRxOHtA==
dependencies:
"@typescript-eslint/eslint-plugin" "^6.7.2"
"@typescript-eslint/parser" "^6.7.2"
Expand All @@ -2402,6 +2433,7 @@ eslint-config-oclif-typescript@^2.0.1:
eslint-plugin-import "^2.28.1"
eslint-plugin-mocha "^10.1.0"
eslint-plugin-node "^11.1.0"
eslint-plugin-perfectionist "^2.1.0"

eslint-config-oclif@^5.0.0:
version "5.0.0"
Expand Down

0 comments on commit 84d12a3

Please sign in to comment.