Skip to content

Commit

Permalink
feat: use @oclif/core v4
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed May 28, 2024
1 parent 5038352 commit 6287829
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Salesforce",
"bugs": "https://github.com/oclif/plugin-command-snapshot/issues",
"dependencies": {
"@oclif/core": "3.26.6",
"@oclif/core": "^4.0.0-beta.13",
"@types/lodash.difference": "^4.5.9",
"chalk": "^5.3.0",
"globby": "^14.0.1",
Expand Down
30 changes: 22 additions & 8 deletions src/commands/schema/generate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Flags} from '@oclif/core'
import {Flags, ux} from '@oclif/core'
import chalk from 'chalk'
import {globbySync} from 'globby'
import * as fs from 'node:fs'
import * as path from 'node:path'
import fs from 'node:fs'
import path from 'node:path'
import {Schema, createGenerator} from 'ts-json-schema-generator'

import SnapshotCommand from '../../snapshot-command.js'
Expand Down Expand Up @@ -107,11 +107,25 @@ export class SchemaGenerator {
}

private getAllHookFiles(): string[] {
// eslint-disable-next-line unicorn/no-array-reduce
const hookFiles = Object.values(this.base.config.pjson.oclif?.hooks ?? {}).reduce(
(x: string[], y: string | string[]) => (Array.isArray(y) ? [...x, ...y] : [...x, y]),
[],
)
const hookFiles = Object.values(this.base.config.pjson.oclif?.hooks ?? {})
.flatMap((hook) => {
if (Array.isArray(hook)) {
return hook.map((h) => {
if (typeof h === 'string') return h
ux.warn(`Identifier/target based hooks are not supported: ${h}`)
return null
})
}

if (typeof hook === 'string') {
return hook
}

ux.warn(`Identifier/target based hooks are not supported: ${hook}`)
return null
})
.filter((h): h is string => typeof h === 'string')

const {outDir, rootDir} = this.getDirs()
return hookFiles.map((h) => `${path.resolve(h)}.ts`.replace(outDir, rootDir))
}
Expand Down
32 changes: 30 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@oclif/core@3.26.6", "@oclif/core@^3.26.5", "@oclif/core@^3.26.6":
"@oclif/core@^3.26.5", "@oclif/core@^3.26.6":
version "3.26.6"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.26.6.tgz#f371868cfa0fe150a6547e6af98b359065d2f971"
integrity sha512-+FiTw1IPuJTF9tSAlTsY8bGK4sgthehjz7c2SvYdgQncTkxI2xvUch/8QpjNYGLEmUneNygvYMRBax2KJcLccA==
Expand Down Expand Up @@ -1544,6 +1544,29 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^4.0.0-beta.13":
version "4.0.0-beta.13"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-4.0.0-beta.13.tgz#0e0a6431cfe612db77073d2f9ef361f14e4090b8"
integrity sha512-ug8CZUCJphgetSZVgd4HQgyewlYVGGG1LIeFXGxjgYsjZ/f5I3nSCj7xpAMEDqjVD/lwmSujtVwa7tvEgLGICw==
dependencies:
ansi-escapes "^4.3.2"
ansis "^3.0.1"
clean-stack "^3.0.1"
cli-spinners "^2.9.2"
cosmiconfig "^9.0.0"
debug "^4.3.4"
ejs "^3.1.10"
get-package-type "^0.1.0"
globby "^11.1.0"
indent-string "^4.0.0"
is-wsl "^2.2.0"
minimatch "^9.0.4"
string-width "^4.2.3"
supports-color "^9.4.0"
widest-line "^3.1.0"
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/plugin-help@^6", "@oclif/plugin-help@^6.0.21":
version "6.0.22"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-6.0.22.tgz#dca96ad1c28a68170e0bbf9f8f93f7dd171e4667"
Expand Down Expand Up @@ -2491,7 +2514,7 @@ ansicolors@~0.3.2:
resolved "https://registry.npmjs.org/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979"
integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk=

ansis@^3.2.0:
ansis@^3.0.1, ansis@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ansis/-/ansis-3.2.0.tgz#0e050c5be94784f32ffdac4b84fccba064aeae4b"
integrity sha512-Yk3BkHH9U7oPyCN3gL5Tc7CpahG/+UFv/6UG03C311Vy9lzRmA5uoxDTpU9CO3rGHL6KzJz/pdDeXZCZ5Mu/Sg==
Expand Down Expand Up @@ -6143,6 +6166,11 @@ supports-color@^7, supports-color@^7.0.0, supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

supports-color@^9.4.0:
version "9.4.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-9.4.0.tgz#17bfcf686288f531db3dea3215510621ccb55954"
integrity sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==

supports-hyperlinks@^2.2.0:
version "2.2.0"
resolved "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.2.0.tgz#4f77b42488765891774b70c79babd87f9bd594bb"
Expand Down

0 comments on commit 6287829

Please sign in to comment.