Skip to content

Commit 637b182

Browse files
committed
📦 NEW: Support CGB
1 parent f84bc64 commit 637b182

1 file changed

Lines changed: 19 additions & 33 deletions

File tree

  • packages/cgb-scripts/scripts

‎packages/cgb-scripts/scripts/init.js‎

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,9 @@ process.on( 'unhandledRejection', err => {
2929
* @param {string} blockNamePHPLower The block name for PHP files in lowercase.
3030
* @param {string} blockNamePHPUpper The block name for PHP files in uppercase.
3131
*/
32-
const copyTemplateFiles = (
33-
blockName,
34-
blockDir,
35-
blockNamePHPLower,
36-
blockNamePHPUpper
37-
) => {
32+
const copyTemplateFiles = ( blockName, blockDir, blockNamePHPLower, blockNamePHPUpper ) => {
3833
// Since we ran npm install cgb-scripts we have it in the node_modules now.
39-
const template = path.join(
40-
blockDir,
41-
'node_modules',
42-
'cgb-scripts',
43-
'template'
44-
);
34+
const template = path.join( blockDir, 'node_modules', 'cgb-scripts', 'template' );
4535

4636
const templatePromise = new Promise( resolve => {
4737
shell.cd( blockDir );
@@ -50,9 +40,7 @@ const copyTemplateFiles = (
5040
if ( fs.existsSync( template ) ) {
5141
fs.copySync( template, blockDir );
5242
} else {
53-
console.error(
54-
`Could not locate supplied template: ${ chalk.green( template ) }`
55-
);
43+
console.error( `Could not locate supplied template: ${ chalk.green( template ) }` );
5644
return;
5745
}
5846

@@ -91,14 +79,9 @@ const copyTemplateFiles = (
9179
* @param {string} blockDir The block directory.
9280
*/
9381
const printNextSteps = ( blockName, blockDir ) => {
82+
console.log( '\n\n✅ ', chalk.black.bgGreen( ' All done! Go build some Gutenberg blocks. \n' ) );
9483
console.log(
95-
'\n\n✅ ',
96-
chalk.black.bgGreen( ' All done! Go build some Gutenberg blocks. \n' )
97-
);
98-
console.log(
99-
`CGB ${ chalk.dim(
100-
'(create-guten-block)'
101-
) } has created a WordPress plugin called `,
84+
`CGB ${ chalk.dim( '(create-guten-block)' ) } has created a WordPress plugin called `,
10285
chalk.dim( blockName ),
10386
' that you can use with zero configurations #0CJS to build Gutenberg blocks with ESNext (i.e. ES6/7/8), React.js, JSX, Webpack, ESLint, etc.'
10487
);
@@ -107,6 +90,7 @@ const printNextSteps = ( blockName, blockDir ) => {
10790
'\nInside that directory, you can run several commands:\n'
10891
);
10992

93+
// Scripts.
11094
console.log(
11195
'\n👉 ',
11296
' Type',
@@ -138,14 +122,21 @@ const printNextSteps = ( blockName, blockDir ) => {
138122
' If you do this, you can’t go back!'
139123
);
140124

141-
console.log( '\n\n', chalk.black.bgGreen( ' Get Started → \n' ) );
142-
console.log( ' We suggest that you begin by typing: \n' );
125+
// Support.
126+
console.log( '\n\n ✊ ', chalk.black.bgYellow( ' Support create-guten-block → \n' ) );
143127
console.log(
144-
` ${ chalk.green( 'cd' ) } ${ blockName }`,
128+
'Love create-guten-block? You can now support this free and open source project. Supporting CGB means more updates and better maintenance: \n'
129+
);
130+
console.log(
131+
` ${ chalk.yellow( 'Support for one hour or more →' ) } https://AhmdA.ws/CGB99`,
145132
'\n',
146-
` ${ chalk.green( 'npm' ) } start`,
147-
'\n\n'
133+
` ${ chalk.yellow( 'More ways to support →' ) } https://AhmdA.ws/CGBSupport`
148134
);
135+
136+
// Get started.
137+
console.log( '\n\n', chalk.black.bgGreen( ' Get Started → \n' ) );
138+
console.log( ' We suggest that you begin by typing: \n' );
139+
console.log( ` ${ chalk.green( 'cd' ) } ${ blockName }`, '\n', ` ${ chalk.green( 'npm' ) } start`, '\n\n' );
149140
};
150141

151142
/**
@@ -172,12 +163,7 @@ module.exports = async( root, blockName, blockDir ) => {
172163
// Init the spinner.
173164
const spinner = new ora( { text: '' } );
174165
spinner.start( '3. Creating plugin files...' );
175-
await copyTemplateFiles(
176-
blockName,
177-
blockDir,
178-
blockNamePHPLower,
179-
blockNamePHPUpper
180-
);
166+
await copyTemplateFiles( blockName, blockDir, blockNamePHPLower, blockNamePHPUpper );
181167
spinner.succeed();
182168

183169
// 2. Prints next steps.

0 commit comments

Comments
 (0)