File tree Expand file tree Collapse file tree 3 files changed +38
-35
lines changed
packages/create-react-native-library/src Expand file tree Collapse file tree 3 files changed +38
-35
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,12 @@ import { assertAnswers, assertNpx } from './utils/assert';
1111import { resolveBobVersionWithFallback } from './utils/promiseWithFallback' ;
1212import { generateTemplateConfiguration } from './config' ;
1313import { applyTemplates } from './template' ;
14- import { createQuestions , type Answers , acceptedArgs } from './input' ;
15- import { createMetadata } from './metadata' ;
14+ import {
15+ createQuestions ,
16+ createMetadata ,
17+ type Answers ,
18+ acceptedArgs ,
19+ } from './input' ;
1620import { getDependencyVersionsFromExample } from './exampleApp/dependencies' ;
1721import { printNextSteps } from './nextSteps' ;
1822
Original file line number Diff line number Diff line change 1+ import { version } from '../package.json' ;
12import validateNpmPackage from 'validate-npm-package-name' ;
23import githubUsername from 'github-username' ;
34import type yargs from 'yargs' ;
@@ -376,3 +377,34 @@ export async function createQuestions({
376377 singleChoiceAnswers,
377378 } ;
378379}
380+
381+ export function createMetadata ( answers : Answers ) {
382+ // Some of the passed args can already be derived from the generated package.json file.
383+ const ignoredAnswers : ( keyof Answers ) [ ] = [
384+ 'name' ,
385+ 'slug' ,
386+ 'description' ,
387+ 'authorName' ,
388+ 'authorEmail' ,
389+ 'authorUrl' ,
390+ 'repoUrl' ,
391+ 'example' ,
392+ 'reactNativeVersion' ,
393+ 'local' ,
394+ ] ;
395+
396+ type AnswerEntries < T extends keyof Answers = keyof Answers > = [
397+ T ,
398+ Answers [ T ] ,
399+ ] [ ] ;
400+
401+ const libraryMetadata = Object . fromEntries (
402+ ( Object . entries ( answers ) as AnswerEntries ) . filter (
403+ ( [ answer ] ) => ! ignoredAnswers . includes ( answer )
404+ )
405+ ) ;
406+
407+ libraryMetadata . version = version ;
408+
409+ return libraryMetadata ;
410+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments