|
1 | 1 | import path from 'path'; |
2 | 2 | import fs from 'fs-extra'; |
| 3 | +import chalk from 'chalk'; |
3 | 4 | import yargs from 'yargs'; |
4 | 5 | import inquirer from 'inquirer'; |
5 | 6 | import cosmiconfig from 'cosmiconfig'; |
@@ -148,7 +149,11 @@ yargs |
148 | 149 | pkg.scripts.prepare = prepare; |
149 | 150 | } |
150 | 151 |
|
151 | | - if (pkg.files) { |
| 152 | + if ( |
| 153 | + pkg.files && |
| 154 | + JSON.stringify(pkg.files.slice().sort()) !== |
| 155 | + JSON.stringify(files.slice().sort()) |
| 156 | + ) { |
152 | 157 | const { replace } = await inquirer.prompt({ |
153 | 158 | type: 'confirm', |
154 | 159 | name: 'replace', |
@@ -190,7 +195,7 @@ yargs |
190 | 195 | } |
191 | 196 | } |
192 | 197 |
|
193 | | - console.log('🎉 Your project is configured!'); |
| 198 | + logger.success('Your project is configured!'); |
194 | 199 | }) |
195 | 200 | .command('build', 'build files for publishing', {}, async argv => { |
196 | 201 | const result = explorer.searchSync(); |
@@ -236,36 +241,48 @@ yargs |
236 | 241 | ); |
237 | 242 | } |
238 | 243 |
|
| 244 | + const report = { |
| 245 | + info: logger.info, |
| 246 | + warn: logger.warn, |
| 247 | + error: logger.error, |
| 248 | + success: logger.success, |
| 249 | + }; |
| 250 | + |
239 | 251 | for (const target of options.targets!) { |
240 | 252 | const targetName = Array.isArray(target) ? target[0] : target; |
241 | 253 | const targetOptions = Array.isArray(target) ? target[1] : undefined; |
242 | 254 |
|
| 255 | + report.info(`Building target ${chalk.blue(targetName)}`); |
| 256 | + |
243 | 257 | switch (targetName) { |
244 | 258 | case 'commonjs': |
245 | 259 | await buildCommonJS({ |
246 | 260 | root, |
247 | | - source: source as string, |
| 261 | + source: path.resolve(root, source as string), |
248 | 262 | output: path.resolve(root, output as string, 'commonjs'), |
249 | 263 | options: targetOptions, |
| 264 | + report, |
250 | 265 | }); |
251 | 266 | break; |
252 | 267 | case 'module': |
253 | 268 | await buildModule({ |
254 | 269 | root, |
255 | | - source: source as string, |
| 270 | + source: path.resolve(root, source as string), |
256 | 271 | output: path.resolve(root, output as string, 'module'), |
257 | 272 | options: targetOptions, |
| 273 | + report, |
258 | 274 | }); |
259 | 275 | break; |
260 | 276 | case 'typescript': |
261 | 277 | await buildTypescript({ |
262 | 278 | root, |
263 | | - source: source as string, |
| 279 | + source: path.resolve(root, source as string), |
264 | 280 | output: path.resolve(root, output as string, 'typescript'), |
| 281 | + report, |
265 | 282 | }); |
266 | 283 | break; |
267 | 284 | default: |
268 | | - logger.exit(`Invalid target '${target}'.`); |
| 285 | + logger.exit(`Invalid target ${chalk.blue(targetName)}.`); |
269 | 286 | } |
270 | 287 | } |
271 | 288 | }) |
|
0 commit comments