Skip to content

Commit b36eb3f

Browse files
author
Ahmad Awais
committed
πŸ“¦ NEW: Add EnvInfo
1 parent aeab3e9 commit b36eb3f

4 files changed

Lines changed: 280 additions & 6 deletions

File tree

β€Žpackages/create-guten-block/app/cli.jsβ€Ž

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,55 @@
77
'use strict';
88

99
const chalk = require( 'chalk' );
10+
const envinfo = require( 'envinfo' );
1011
const commander = require( 'commander' );
12+
const clearConsole = require( './consoleClear' );
1113
const packageJson = require( '../package.json' );
1214

1315
// Commander.js program.
1416
module.exports = () => {
15-
new commander.Command( packageJson.name )
17+
const program = new commander.Command( packageJson.name )
1618
.version( packageJson.version, '-v, --version' )
1719
.description(
1820
`CGB ${ chalk.dim(
1921
'(create-guten-block)'
2022
) } is a Zero-Config #OCJS for builing WordPress Gutenberg Blocks.`
21-
)
23+
);
24+
program
25+
.option( '-d, --debug', 'Prints envinfo for debugging. ' )
2226
.arguments( '<block-name>' )
2327
.usage( `${ chalk.green( '<block-name>' ) }` )
24-
// .action(name => {
25-
// projectName = name;
26-
// })
2728
.allowUnknownOption()
2829
.on( '--help', () => {
2930
console.log( `\n Only ${ chalk.green( '<block-name>' ) } is required.\n` );
3031
} )
3132
.parse( process.argv );
33+
34+
// Envinfo.
35+
if ( program.debug ) {
36+
clearConsole();
37+
38+
console.log(
39+
'\nπŸ”° ' +
40+
chalk.black.bgYellow( ' Printing the debug env info below: \n\n' ) +
41+
chalk.dim( ' This may take a couple of seconds...' )
42+
);
43+
44+
// Print the envinfo.
45+
envinfo.print( {
46+
packages: [ 'cgb-scripts' ],
47+
cpu: true,
48+
duplicates: true,
49+
browsers: true,
50+
noNativeIDE: true,
51+
} );
52+
53+
console.log(
54+
'\nβœ… ' +
55+
chalk.black.bgGreen( ' Done ' ) +
56+
chalk.dim( ' You can copy paste this info to share it...\n' )
57+
);
58+
// Let's end the process so the app doesn't continue.
59+
process.exit();
60+
}
3261
};

β€Žpackages/create-guten-block/app/test.jsβ€Ž

Whitespace-only changes.

β€Žpackages/create-guten-block/package-lock.jsonβ€Ž

Lines changed: 245 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackages/create-guten-block/package.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"chalk": "^2.3.0",
3636
"commander": "^2.13.0",
3737
"directory-exists": "^1.0.2",
38+
"envinfo": "^3.11.0",
3839
"execa": "^0.9.0",
3940
"fs-extra": "^5.0.0",
4041
"ora": "^1.3.0",

0 commit comments

Comments
Β (0)