Skip to content

Commit f214cf3

Browse files
committed
chore: ask to install an example app
1 parent 5ccba08 commit f214cf3

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

tools/init.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,29 @@ function renameItems(libraryName: string) {
109109
console.log('\n');
110110
}
111111

112+
const _promptInstallExampleApp = {
113+
properties: {
114+
installExampleApp: {
115+
description: cyan(
116+
'Would you like to generate an example react app to test your library/component?'
117+
),
118+
pattern: /^(y(es)?|n(o)?)$/i,
119+
type: 'string',
120+
required: true,
121+
message: 'You need to type "Yes" or "No" to continue...',
122+
},
123+
},
124+
};
125+
function installExampleApp() {
126+
_prompt.get(_promptInstallExampleApp, (err: any, res: any) => {
127+
if (err) return;
128+
if (res.installExampleApp.toLowerCase().charAt(0) === 'y') {
129+
exec('npx create-react-app example');
130+
exec('echo "SKIP_PREFLIGHT_CHECK=true" >> example/.env');
131+
}
132+
});
133+
}
134+
112135
/**
113136
* Calls any external programs to finish setting up the library
114137
*/
@@ -136,14 +159,9 @@ function finalize() {
136159
writeFileSync(jsonPackage, JSON.stringify(pkg, null, 2));
137160
console.log(green('Postinstall script has been removed'));
138161

139-
// Initialize Husky
140-
fork(
141-
resolve(__dirname, '..', 'node_modules', 'husky', 'bin', 'install'),
142-
[],
143-
{ silent: true }
144-
);
145-
console.log(green('Git hooks set up'));
146-
162+
console.log(yellow('Removing yarn.lock and performing a clean install...'));
163+
rm('yarn.lock');
164+
exec('yarn install');
147165
console.log('\n');
148166
}
149167
/**
@@ -165,6 +183,7 @@ function setupLibrary(libraryName: string) {
165183
removeItems();
166184

167185
modifyGitignoreFile();
186+
installExampleApp();
168187
modifyContents(libraryName, username, usermail);
169188
// renameItems(libraryName);
170189

0 commit comments

Comments
 (0)