-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathinform.ts
More file actions
126 lines (113 loc) · 3.14 KB
/
inform.ts
File metadata and controls
126 lines (113 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import path from 'path';
import dedent from 'dedent';
import type { TemplateConfiguration } from './template';
import kleur from 'kleur';
export function printNonLocalLibNextSteps(config: TemplateConfiguration) {
const platforms = {
ios: { name: 'iOS', color: 'cyan' },
android: { name: 'Android', color: 'green' },
...(config.example === 'expo'
? ({ web: { name: 'Web', color: 'blue' } } as const)
: null),
} as const;
console.log(
dedent(`
${kleur.magenta(
`${kleur.bold('Get started')} with the project`
)}${kleur.gray(':')}
${kleur.gray('$')} yarn
${Object.entries(platforms)
.map(
([script, { name, color }]) => `
${kleur[color](`Run the example app on ${kleur.bold(name)}`)}${kleur.gray(
':'
)}
${kleur.gray('$')} yarn example ${script}`
)
.join('\n')}
${kleur.yellow(
`See ${kleur.bold('CONTRIBUTING.md')} for more details. Good luck!`
)}
`)
);
}
export function printLocalLibNextSteps({
folder,
config,
linkedLocalLibrary,
addedNitro,
packageManager,
}: {
folder: string;
config: TemplateConfiguration;
linkedLocalLibrary: boolean;
addedNitro: boolean;
packageManager: string;
}) {
console.log(
dedent(`
${kleur.magenta(
`${kleur.bold('Get started')} with the project`
)}${kleur.gray(':')}
${
(linkedLocalLibrary
? `- Run ${kleur.blue(
`${packageManager} install`
)} to link the library\n`
: `- Link the library at ${kleur.blue(
path.relative(process.cwd(), folder)
)} based on your project setup\n`) +
(config.project.moduleConfig === 'nitro-modules' && !addedNitro
? `- Run ${kleur.blue(
`${packageManager} add react-native-nitro-modules`
)} to install nitro modules \n`
: '') +
`- Run ${kleur.blue(
'pod install --project-directory=ios'
)} to install dependencies with CocoaPods\n` +
`- Run ${kleur.blue('npx react-native run-android')} or ${kleur.blue(
'npx react-native run-ios'
)} to build and run the app\n` +
`- Import from ${kleur.blue(
config.project.slug
)} and use it in your app.`
}
${kleur.yellow(`Good luck!`)}
`)
);
}
export function printErrorHelp(message: string, error: Error) {
console.log('\n');
if (error) {
console.log(kleur.red(error.message));
throw error;
}
if (message) {
console.log(kleur.red(message));
} else {
console.log(
kleur.red(`An unknown error occurred. See '--help' for usage guide.`)
);
}
process.exit(1);
}
export function printUsedRNVersion(
version: string,
config: TemplateConfiguration
) {
if (config.example === 'vanilla') {
console.log(
`${kleur.blue('ℹ')} Using untested ${kleur.cyan(
`react-native@${version}`
)} for the example`
);
} else {
console.warn(
`${kleur.yellow(
'⚠'
)} Ignoring --react-native-version for unsupported example type: ${kleur.cyan(
config.example
)}`
);
}
}