Skip to content

Commit

Permalink
feat: improve init experience (fixes #38)
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Mar 22, 2024
1 parent 7130a01 commit 5f2104a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/steps/gen-ext-scaffolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ function paramNamesToDef(name: ExtensionParams): TemplateParam<string, Extension
name,
type: 'text',
message: `Package namespace ${chalk.dim('(Vendor\\ExtensionName)')}`,
initial: (_prev, values) => (values as unknown as Map<string, string>).get('packageName')!
.replace('/flarum-', '/')
.split('/')
.map((b: string) => s(b).camelize().capitalize().toString()).join('\\'),
validate: (s) => /^([\dA-Za-z]+)\\([\dA-Za-z]+)$/.test(s.trim()) || 'Invalid namespace format',
format: (str: string) =>
str &&
Expand Down Expand Up @@ -133,6 +137,12 @@ function paramNamesToDef(name: ExtensionParams): TemplateParam<string, Extension
type: 'text',
message: 'Extension name',
validate: (str) => Boolean(str.trim()) || 'The extension name is required',
initial: (_prev, values) => s((values as unknown as Map<string, string>).get('packageName')!
.split('/')[1])
.replaceAll('flarum-', '')
.humanize()
.capitalize()
.toString(),
format: (str) =>
str
.split(' ')
Expand All @@ -153,6 +163,7 @@ function paramNamesToDef(name: ExtensionParams): TemplateParam<string, Extension
type: 'autocomplete',
message: 'License',
choices: [...(spdxLicenseListSimple as Set<string>)].map((e) => ({ title: e, value: e })),
initial: 'MIT',
},
getCurrVal: async (fs: Store, paths: Paths) => {
const json = getComposerJson(fs, paths);
Expand Down

0 comments on commit 5f2104a

Please sign in to comment.