Skip to content

Commit 6287829

Browse files
committed
feat: use @oclif/core v4
1 parent 5038352 commit 6287829

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Salesforce",
66
"bugs": "https://github.com/oclif/plugin-command-snapshot/issues",
77
"dependencies": {
8-
"@oclif/core": "3.26.6",
8+
"@oclif/core": "^4.0.0-beta.13",
99
"@types/lodash.difference": "^4.5.9",
1010
"chalk": "^5.3.0",
1111
"globby": "^14.0.1",

src/commands/schema/generate.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {Flags} from '@oclif/core'
1+
import {Flags, ux} from '@oclif/core'
22
import chalk from 'chalk'
33
import {globbySync} from 'globby'
4-
import * as fs from 'node:fs'
5-
import * as path from 'node:path'
4+
import fs from 'node:fs'
5+
import path from 'node:path'
66
import {Schema, createGenerator} from 'ts-json-schema-generator'
77

88
import SnapshotCommand from '../../snapshot-command.js'
@@ -107,11 +107,25 @@ export class SchemaGenerator {
107107
}
108108

109109
private getAllHookFiles(): string[] {
110-
// eslint-disable-next-line unicorn/no-array-reduce
111-
const hookFiles = Object.values(this.base.config.pjson.oclif?.hooks ?? {}).reduce(
112-
(x: string[], y: string | string[]) => (Array.isArray(y) ? [...x, ...y] : [...x, y]),
113-
[],
114-
)
110+
const hookFiles = Object.values(this.base.config.pjson.oclif?.hooks ?? {})
111+
.flatMap((hook) => {
112+
if (Array.isArray(hook)) {
113+
return hook.map((h) => {
114+
if (typeof h === 'string') return h
115+
ux.warn(`Identifier/target based hooks are not supported: ${h}`)
116+
return null
117+
})
118+
}
119+
120+
if (typeof hook === 'string') {
121+
return hook
122+
}
123+
124+
ux.warn(`Identifier/target based hooks are not supported: ${hook}`)
125+
return null
126+
})
127+
.filter((h): h is string => typeof h === 'string')
128+
115129
const {outDir, rootDir} = this.getDirs()
116130
return hookFiles.map((h) => `${path.resolve(h)}.ts`.replace(outDir, rootDir))
117131
}

yarn.lock

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@
15101510
"@nodelib/fs.scandir" "2.1.5"
15111511
fastq "^1.6.0"
15121512

1513-
"@oclif/core@3.26.6", "@oclif/core@^3.26.5", "@oclif/core@^3.26.6":
1513+
"@oclif/core@^3.26.5", "@oclif/core@^3.26.6":
15141514
version "3.26.6"
15151515
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.26.6.tgz#f371868cfa0fe150a6547e6af98b359065d2f971"
15161516
integrity sha512-+FiTw1IPuJTF9tSAlTsY8bGK4sgthehjz7c2SvYdgQncTkxI2xvUch/8QpjNYGLEmUneNygvYMRBax2KJcLccA==
@@ -1544,6 +1544,29 @@
15441544
wordwrap "^1.0.0"
15451545
wrap-ansi "^7.0.0"
15461546

1547+
"@oclif/core@^4.0.0-beta.13":
1548+
version "4.0.0-beta.13"
1549+
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-4.0.0-beta.13.tgz#0e0a6431cfe612db77073d2f9ef361f14e4090b8"
1550+
integrity sha512-ug8CZUCJphgetSZVgd4HQgyewlYVGGG1LIeFXGxjgYsjZ/f5I3nSCj7xpAMEDqjVD/lwmSujtVwa7tvEgLGICw==
1551+
dependencies:
1552+
ansi-escapes "^4.3.2"
1553+
ansis "^3.0.1"
1554+
clean-stack "^3.0.1"
1555+
cli-spinners "^2.9.2"
1556+
cosmiconfig "^9.0.0"
1557+
debug "^4.3.4"
1558+
ejs "^3.1.10"
1559+
get-package-type "^0.1.0"
1560+
globby "^11.1.0"
1561+
indent-string "^4.0.0"
1562+
is-wsl "^2.2.0"
1563+
minimatch "^9.0.4"
1564+
string-width "^4.2.3"
1565+
supports-color "^9.4.0"
1566+
widest-line "^3.1.0"
1567+
wordwrap "^1.0.0"
1568+
wrap-ansi "^7.0.0"
1569+
15471570
"@oclif/plugin-help@^6", "@oclif/plugin-help@^6.0.21":
15481571
version "6.0.22"
15491572
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-6.0.22.tgz#dca96ad1c28a68170e0bbf9f8f93f7dd171e4667"
@@ -2491,7 +2514,7 @@ ansicolors@~0.3.2:
24912514
resolved "https://registry.npmjs.org/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979"
24922515
integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk=
24932516

2494-
ansis@^3.2.0:
2517+
ansis@^3.0.1, ansis@^3.2.0:
24952518
version "3.2.0"
24962519
resolved "https://registry.yarnpkg.com/ansis/-/ansis-3.2.0.tgz#0e050c5be94784f32ffdac4b84fccba064aeae4b"
24972520
integrity sha512-Yk3BkHH9U7oPyCN3gL5Tc7CpahG/+UFv/6UG03C311Vy9lzRmA5uoxDTpU9CO3rGHL6KzJz/pdDeXZCZ5Mu/Sg==
@@ -6143,6 +6166,11 @@ supports-color@^7, supports-color@^7.0.0, supports-color@^7.1.0:
61436166
dependencies:
61446167
has-flag "^4.0.0"
61456168

6169+
supports-color@^9.4.0:
6170+
version "9.4.0"
6171+
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-9.4.0.tgz#17bfcf686288f531db3dea3215510621ccb55954"
6172+
integrity sha512-VL+lNrEoIXww1coLPOmiEmK/0sGigko5COxI09KzHc2VJXJsQ37UaQ+8quuxjDeA7+KnLGTWRyOXSLLR2Wb4jw==
6173+
61466174
supports-hyperlinks@^2.2.0:
61476175
version "2.2.0"
61486176
resolved "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.2.0.tgz#4f77b42488765891774b70c79babd87f9bd594bb"

0 commit comments

Comments
 (0)