Skip to content

feat: ask to use recommended template #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1970c98
feat: create kotlin part
atlj Jun 10, 2024
9d0a89e
feat: create ts part
atlj Jun 10, 2024
1ba688a
feat: create objc part
atlj Jun 10, 2024
44ce26b
feat: handle view+module template on CLI
atlj Jun 10, 2024
8efcf93
feat: handle example app
atlj Jun 10, 2024
2a9cc9e
feat: pass codegen type all for view+module libraries
atlj Jun 11, 2024
5e20c86
feat: remove the `View` prefix from view codegens
atlj Jun 11, 2024
ba16dd6
fix: view-new type is ignored
atlj Jun 11, 2024
1d3fa60
feat: remove all the java templates
atlj Jun 11, 2024
6b638e3
fix: remove java from CI
atlj Jun 11, 2024
d46f0e1
feat: remove module and view mixed templates
atlj Jun 11, 2024
94c9964
fix: remove view and module new templates
atlj Jun 11, 2024
d16092e
fix: remove view and module legacy templates
atlj Jun 11, 2024
84b38fa
fix: fabric option type
atlj Jun 11, 2024
fcab6b3
fix: readd native view option
atlj Jun 11, 2024
ea78ef6
fix: bring back backward compatible turbo module
atlj Jun 11, 2024
759e510
fix: CI types
atlj Jun 11, 2024
dc7e2f8
feat: readd templates for cpp and swift
atlj Jun 12, 2024
b805ce9
refactor: rename files
atlj Jun 12, 2024
1282d0a
feat: test swift and kotlin templates' android counterparts
atlj Jun 12, 2024
cc2d0fe
fix: app template tries then on new arch templates
atlj Jun 12, 2024
f175778
chore: dont skip any builds on ci
atlj Jun 12, 2024
56e443f
fix: prettier issue on view-module-legacy
atlj Jun 12, 2024
850a115
chore: update build matrix
atlj Jun 12, 2024
89b50cf
fix: typo on pipeline
atlj Jun 12, 2024
f3fcef8
chore: add js type to pipeline
atlj Jun 12, 2024
b418fc2
refactor: remove moduleType var
atlj Jun 12, 2024
23d67d5
refactor: make ordering better
atlj Jun 12, 2024
f672ff6
chore: skip native builds for js libs
atlj Jun 12, 2024
ad40191
fix: js example doesn't use the method
atlj Jun 12, 2024
d80e3f9
feat: add use-recommended-template question
atlj Jun 12, 2024
6e53905
feat: add choices to recommended template questino
atlj Jun 12, 2024
c57df20
refactor: rename useRecommendedTemplate to withRecommendedOptions
atlj Jun 13, 2024
55a1cd2
Merge branch 'main' into @atlj/golden-cli
satya164 Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 64 additions & 4 deletions packages/create-react-native-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ type ArgName =
| 'type'
| 'local'
| 'example'
| 'react-native-version';
| 'react-native-version'
| 'with-recommended-options';

type ProjectLanguages = 'kotlin-objc' | 'kotlin-swift' | 'cpp' | 'js';

Expand All @@ -140,6 +141,7 @@ type Answers = {
type?: ProjectType;
example?: boolean;
reactNativeVersion?: string;
withRecommendedOptions?: boolean;
};

const LANGUAGE_CHOICES: {
Expand All @@ -148,7 +150,7 @@ const LANGUAGE_CHOICES: {
types: ProjectType[];
}[] = [
{
title: 'Kotlin & Objective-C',
title: `Kotlin & Objective-C`,
value: 'kotlin-objc',
types: ['view-module-legacy', 'view-module-mixed', 'view-module-new'],
},
Expand Down Expand Up @@ -219,6 +221,16 @@ const TYPE_CHOICES: {
},
];

const RECOMMENDED_TEMPLATE: {
type: ProjectType;
languages: ProjectLanguages;
description: string;
} = {
type: 'view-module-mixed',
languages: 'kotlin-objc',
description: `Backward compatible Fabric view & Turbo module with Kotlin & Objective-C`,
};

const args: Record<ArgName, yargs.Options> = {
'slug': {
description: 'Name of the npm package',
Expand Down Expand Up @@ -265,6 +277,10 @@ const args: Record<ArgName, yargs.Options> = {
type: 'boolean',
default: true,
},
'with-recommended-options': {
description: `Whether to use the recommended template. ${RECOMMENDED_TEMPLATE.description}`,
type: 'boolean',
},
};

// FIXME: fix the type
Expand Down Expand Up @@ -432,24 +448,68 @@ async function create(argv: yargs.Arguments<any>) {
},
validate: (input) => /^https?:\/\//.test(input) || 'Must be a valid URL',
},
'with-recommended-options': {
type: 'select',
name: 'withRecommendedOptions',
message: 'Do you want to customize the library type and languages?',
choices: [
{
title: 'Use recommended defaults',
value: true,
description: RECOMMENDED_TEMPLATE.description,
},
{
title: 'Customize',
value: false,
},
],
},
'type': {
type: 'select',
name: 'type',
message: 'What type of library do you want to develop?',
choices: TYPE_CHOICES,
choices: (_, values) => {
if (values.withRecommendedOptions) {
return TYPE_CHOICES.filter(
(choice) => choice.value === RECOMMENDED_TEMPLATE.type
);
}

return TYPE_CHOICES.map((choice) =>
choice.value === RECOMMENDED_TEMPLATE.type
? {
...choice,
title: `${choice.title} ${kleur.yellow('(Recommended)')}`,
}
: choice
);
},
},
'languages': {
type: 'select',
name: 'languages',
message: 'Which languages do you want to use?',
choices: (_, values) => {
if (values.withRecommendedOptions) {
return LANGUAGE_CHOICES.filter((choice) => {
return choice.value === RECOMMENDED_TEMPLATE.languages;
});
}

return LANGUAGE_CHOICES.filter((choice) => {
if (choice.types) {
return choice.types.includes(values.type);
}

return true;
});
}).map((choice) =>
choice.value === RECOMMENDED_TEMPLATE.languages
? {
...choice,
title: `${choice.title} ${kleur.yellow('(Recommended)')}`,
}
: choice
);
},
},
};
Expand Down
Loading