1 | ;
|
2 | // import export wdyu
|
3 | let reactopt = require('./src/index.js');
|
4 | reactopt = reactopt.whyDidYouUpdate;
|
5 | // export {reactopt};
|
6 | module.export = reactopt;
|
7 |
|
8 | //chalk requirements
|
9 | const chalk = require('chalk');
|
10 | const chalkAnimation = require('chalk-animation');
|
11 | const log = console.log;
|
12 |
|
13 | // const chromeLauncher = require('chrome-launcher');
|
14 | // const readline = require('readline');
|
15 | // const rl = readline.createInterface({
|
16 | // input: process.stdin,
|
17 | // output: process.stdout
|
18 | // });
|
19 |
|
20 | // //import data file
|
21 | // let data = require('./data').data;
|
22 |
|
23 | // //start chrome-launcher to allow user to interact with React app
|
24 | // chromeLauncher.launch({
|
25 | // startingUrl: 'http://localhost:3000',
|
26 | // }).then((chrome) => {
|
27 | // rl.on('line', (line) => {
|
28 | // if (line === 'exit') {
|
29 | // chrome.kill();
|
30 | // endUserInteraction();
|
31 | // }
|
32 | // });
|
33 | // });
|
34 |
|
35 | // //runs on start of reactopt
|
36 | // function startReactopt() {
|
37 | // log(chalk.bgCyan.bold('Reactopt is running - Interact with your app and then type/enter "end"'));
|
38 | // log('');
|
39 | // const loading = chalkAnimation.radar('----------------------------------------------------------------------');
|
40 | // loading.start();
|
41 | // }
|
42 |
|
43 | // startReactopt(); // runs on npm run reactopt
|
44 |
|
45 | // // when user 'ends' interaction, execute this code
|
46 | // function endUserInteraction() {
|
47 | // //execute functions to test/print other logic
|
48 | // printLine();
|
49 | // componentRerenders();
|
50 | // printLine();
|
51 | // versionOfReact();
|
52 | // printLine();
|
53 | // productionMode();
|
54 | // }
|
55 |
|
56 | // // styling for different console logs
|
57 | // function printHeading(string) {
|
58 | // log(chalk.black.bgWhite.dim(string));
|
59 | // log('');
|
60 | // }
|
61 |
|
62 | // function printPass(string) {
|
63 | // log(chalk.cyan.bold(string));
|
64 | // }
|
65 |
|
66 | // function printFail(string) {
|
67 | // log(chalk.magenta.bold(string));
|
68 | // }
|
69 |
|
70 | // function printSuggestion(string) {
|
71 | // log(chalk.gray(string));
|
72 | // }
|
73 |
|
74 | // function printLine() {
|
75 | // log('');
|
76 | // log(chalk.gray('------------------------------------------------------'));
|
77 | // log('');
|
78 | // }
|
79 |
|
80 | // // test functions
|
81 | // function componentRerenders() {
|
82 | // let events = Object.keys(data);
|
83 |
|
84 | // if (events.length !== 0) {
|
85 | // let components;
|
86 |
|
87 | // printHeading('Unnecessary Component Re-rendering');
|
88 | // printFail('There are components that unnecessarily re-rendered, and the events that triggered them:');
|
89 | // log('');
|
90 |
|
91 | // //print events and components rerendered for each
|
92 | // for (let x = 0; x < events.length; x += 1) {
|
93 | // components = Object.keys(data[events[x]]);
|
94 | // log(chalk.underline(events[x]), chalk.reset.white(' : ' + components) );
|
95 | // }
|
96 | // printSuggestion("Consider implementing 'shouldComponentUpdate' to prevent re-rendering when \nthe states or props of a component don't change.");
|
97 | // } else {
|
98 | // printPass('Your version of React is the most current and quickest.');
|
99 | // }
|
100 | // }
|
101 |
|
102 | // function versionOfReact() {
|
103 | // //scrape for version
|
104 | // let version = '16';
|
105 | // printHeading('Version of React');
|
106 | // if (version === '16') {
|
107 | // printPass('Your version of React is the most current and quickest.');
|
108 | // } else {
|
109 | // printFail('Your version of React is out of date and slower than newer versions');
|
110 | // printSuggestion('Consider upgrading to React v 16, which has the fastest production speed.');
|
111 | // }
|
112 | // }
|
113 |
|
114 | // function productionMode() {
|
115 | // //scrape for version
|
116 | // let processChecks = true;
|
117 | // printHeading('Rendering in Production/Development Mode');
|
118 | // if (processChecks === false) {
|
119 | // printPass('Your version of React is the most current and quickest.');
|
120 | // } else {
|
121 | // printFail('Your code contains unneccesary process.env.NODE_ENV checks.');
|
122 | // printSuggestion('These checks are useful but can slow down your application. \n Be sure these are removed when application is put into production.');
|
123 | // }
|
124 | // }
|
125 |
|