Skip to content

Commit 9c0de55

Browse files
committed
Declare release JSON schema as a static field
1 parent f1732c7 commit 9c0de55

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎bin/prettify-manifests.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ const manifestFiles = glob.sync(`packages/*/oclif.manifest.json`)
1313
for (const file of manifestFiles) {
1414
console.log(`Prettifying ${file}...`)
1515
const content = fs.readFileSync(file)
16-
const prettyContent = stringify(JSON.parse(content), {space: ' '}).replaceAll(root, '.')
16+
const manifest = JSON.parse(content)
17+
for (const command of Object.values(manifest.commands)) {
18+
// Runtime schemas belong to command classes, not cached metadata.
19+
delete command.jsonOutputSchema
20+
}
21+
const prettyContent = stringify(manifest, {space: ' '}).replaceAll(root, '.')
1722
fs.writeFileSync(file, prettyContent)
1823
}

‎packages/app/src/cli/commands/app/release.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export default class Release extends AppLinkedCommand {
1818

1919
static descriptionWithMarkdown = `Releases an existing app version. Pass the name of the version that you want to release using the \`--version\` flag.`
2020

21-
static get jsonOutputSchema() {
22-
return appReleaseJsonOutputSchema
23-
}
21+
static jsonOutputSchema = appReleaseJsonOutputSchema
2422

2523
static description = this.descriptionForHelp()
2624

‎packages/eslint-plugin-cli/rules/command-json-output.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ function repositoryPath(filename) {
6262
function hasJsonOutputSchema(classMembers) {
6363
return classMembers.some(
6464
(member) =>
65-
member.type === 'MethodDefinition' && member.kind === 'get' && isStaticMemberNamed(member, 'jsonOutputSchema'),
65+
isStaticMemberNamed(member, 'jsonOutputSchema') &&
66+
((member.type === 'MethodDefinition' && member.kind === 'get') ||
67+
(member.type === 'PropertyDefinition' && Boolean(member.value))),
6668
)
6769
}
6870

‎packages/eslint-plugin-cli/rules/command-json-output.test.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ ruleTester.run('command-json-output', rule, {
3737
code: `
3838
export default class WidgetDelete extends Command {
3939
static flags = {...globalFlags, ...jsonFlag}
40-
static get jsonOutputSchema() {
41-
return widgetDeleteJsonOutputSchema
42-
}
40+
static jsonOutputSchema = widgetDeleteJsonOutputSchema
4341
}
4442
`,
4543
},

0 commit comments

Comments
 (0)