MCPcopy Index your code
hub / github.com/fontsource/fontsource / create

Function create

packages/cli/src/custom/create.ts:18–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16import { buildCustom } from './build';
17
18export const create = async () => {
19 intro(colors.cyan(colors.bold('fontsource')));
20 const cfg = await group(
21 {
22 name: async () =>
23 await text({
24 message: colors.bold('What is the name of the font?'),
25 placeholder: 'Noto Sans JP',
26 validate(value) {
27 if (!value) return 'Please enter a name';
28 return;
29 },
30 }),
31 // TODO: Add support for multiple subsets
32 /*
33 subsets: () => text({
34 message: colors.bold('What are the subsets of the font? (separate by commas)'),
35 placeholder: 'latin, latin-ext, japanese',
36 validate(value) {
37 if (!value) return 'Please enter at least one subset';
38 }
39 }), */
40 weights: async () =>
41 await text({
42 message: colors.bold(
43 'What are the weights of the font? (separate by commas)',
44 ),
45 placeholder: '100, 200, 300, 400, 500, 600, 700, 800, 900',
46 validate(value) {
47 if (!value) return 'Please enter at least one weight';
48 // Split array and check if all values are numbers
49 const weights = value.split(',').map(Number);
50 if (weights.some((weight) => Number.isNaN(weight)))
51 return 'Please enter only numbers';
52 return;
53 },
54 }),
55 styles: async () =>
56 await multiselect({
57 message: colors.bold('What are the styles of the font?'),
58 options: [
59 { value: 'normal', label: 'Normal' },
60 { value: 'italic', label: 'Italic' },
61 ],
62 required: true,
63 }),
64 version: async () =>
65 await text({
66 message: colors.bold('What is the version of the font?'),
67 placeholder: 'v1.0',
68 validate(value) {
69 if (!value) return 'Please enter a version';
70 return;
71 },
72 }),
73 category: async () =>
74 await select({
75 message: colors.bold('What is the category of the font?'),

Callers 1

cli.tsFile · 0.90

Calls 4

isCategoryNameFunction · 0.90
licenseShortFunction · 0.90
buildCustomFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected