-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve types, add helpers and separate state
- Loading branch information
Showing
10 changed files
with
100 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { State } from './types' | ||
|
||
export const state: State = { | ||
options: {}, | ||
language: 'json', | ||
packageJson: { name: 'missing-package-name' }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
export type Template<T = object> = { [key: string]: T } | ||
import type { ConfigurationKeys } from './configuration' | ||
|
||
export type Template<T> = { [key: string]: T | (() => T) } | ||
|
||
export type PackageJson = { name: string; author?: string | { name: string } } | ||
|
||
export type Configuration = { | ||
name: string | ||
alias?: string | ||
name: ConfigurationKeys | ||
alias?: ConfigurationKeys | ||
configuration: { | ||
templates?: Template | ((packageJson: PackageJson) => string) | ||
templates?: Template<string | object | string[]> | ||
// biome-ignore lint/suspicious/noExplicitAny: Will be specified in file explicitly. | ||
createFile: (value?: any) => { name: string; contents: string } | ||
extension?: (path: string) => object | ||
} | ||
} | ||
|
||
export type Options = string | object | true | ||
|
||
export interface State { | ||
options: { [Key in ConfigurationKeys]?: Options } | ||
// Where does the configuration come from package.json => configuration: JSON | ||
// configuration.js: JavaScript, configuration.ts: TypeScript | ||
language: 'json' | 'javascript' | 'typescript' | ||
packageJson: PackageJson | ||
} |