Skip to content

Commit

Permalink
fix: make the version number correct (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
illright authored Dec 8, 2024
1 parent 9ba8145 commit b55545e
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-guests-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@feature-sliced/steiger-plugin': patch
---

Change the plugin name string to match the npm package name
5 changes: 5 additions & 0 deletions .changeset/twelve-snakes-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'steiger': patch
---

Fix the "--version" command outputting "unknown"
2 changes: 1 addition & 1 deletion packages/steiger-plugin-fsd/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const rules = [

const plugin = createPlugin({
meta: {
name: 'steiger-plugin-fsd',
name: '@feature-sliced/steiger-plugin',
version: packageJson.version,
},
ruleDefinitions: rules,
Expand Down
2 changes: 2 additions & 0 deletions packages/steiger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}
],
"scripts": {
"dev": "tsx src/cli.ts",
"lint": "eslint .",
"format": "prettier --write . --cache",
"check-formatting": "prettier --check . --cache",
Expand Down Expand Up @@ -63,6 +64,7 @@
"@types/lodash-es": "^4.17.12",
"@types/yargs": "^17.0.33",
"tsup": "^8.3.0",
"tsx": "^4.19.1",
"typescript": "^5.6.3",
"vitest": "^1.6.0"
}
Expand Down
47 changes: 29 additions & 18 deletions packages/steiger/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,27 @@ import { fromError } from 'zod-validation-error'
import { cosmiconfig } from 'cosmiconfig'

import { linter } from './app'
import { processConfiguration } from './models/config'
import { processConfiguration, $plugins } from './models/config'
import { applyAutofixes } from './features/autofix'
import fsd from '@feature-sliced/steiger-plugin'
import type { Diagnostic } from '@steiger/types'
import packageJson from '../package.json'

const { config, filepath } = (await cosmiconfig('steiger').search()) ?? { config: null, filepath: undefined }
const defaultConfig = fsd.configs.recommended

try {
const configLocationDirectory = filepath ? dirname(filepath) : null
// use FSD recommended config as a default
processConfiguration(config || defaultConfig, configLocationDirectory)
} catch (err) {
if (filepath !== undefined) {
console.error(
fromError(err, { prefix: `Invalid configuration in ${relative(process.cwd(), filepath)}` }).toString(),
)
process.exit(100)
}
}

const yargsProgram = yargs(hideBin(process.argv))
.scriptName('steiger')
Expand Down Expand Up @@ -55,28 +72,22 @@ const yargsProgram = yargs(hideBin(process.argv))
})
.help('help', 'display help message')
.alias('help', 'h')
.version()
.version(
[
packageJson.version,
$plugins
.getState()
.map((plugin) => `${plugin.meta.name}\t${plugin.meta.version}`)
.join('\n'),
]
.filter(Boolean)
.join('\n\n'),
)
.alias('version', 'v')
.showHelpOnFail(true)

const consoleArgs = yargsProgram.parseSync()

const { config, filepath } = (await cosmiconfig('steiger').search()) ?? { config: null, filepath: undefined }
const defaultConfig = fsd.configs.recommended

try {
const configLocationDirectory = filepath ? dirname(filepath) : null
// use FSD recommended config as a default
processConfiguration(config || defaultConfig, configLocationDirectory)
} catch (err) {
if (filepath !== undefined) {
console.error(
fromError(err, { prefix: `Invalid configuration in ${relative(process.cwd(), filepath)}` }).toString(),
)
process.exit(100)
}
}

const targetPath = resolve(consoleArgs._[0])

try {
Expand Down
4 changes: 2 additions & 2 deletions packages/steiger/src/models/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { transformGlobs } from './transform-globs'

type RuleInstructionsPerRule = Record<string, RuleInstructions>

export { GlobGroupWithSeverity } from './types'
export type { GlobGroupWithSeverity } from './types'

const $ruleInstructions = createStore<RuleInstructionsPerRule | null>(null)
const setRuleInstructions = createEvent<RuleInstructionsPerRule>()
Expand All @@ -19,7 +19,7 @@ const $globalIgnores = createStore<Array<GlobalIgnore>>([])
const setGlobalIgnores = createEvent<Array<GlobalIgnore>>()
$globalIgnores.on(setGlobalIgnores, (_state, payload) => payload)

const $plugins = createStore<Array<Plugin>>([])
export const $plugins = createStore<Array<Plugin>>([])
const setPlugins = createEvent<Array<Plugin>>()
$plugins.on(setPlugins, (_state, payload) => payload)

Expand Down
2 changes: 1 addition & 1 deletion packages/steiger/src/shared/globs/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { GlobGroup, InvertedGlobGroup } from './types'
export type { GlobGroup, InvertedGlobGroup } from './types'
export { not } from './not'
export { getGlobPath, replaceGlobPath } from './utilities'
export { applyExclusion } from './apply-exclusion'
27 changes: 15 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b55545e

Please sign in to comment.