Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
📦 NEW: Support CGB
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Apr 2, 2018
1 parent f84bc64 commit 637b182
Showing 1 changed file with 19 additions and 33 deletions.
52 changes: 19 additions & 33 deletions packages/cgb-scripts/scripts/init.js
Expand Up @@ -29,19 +29,9 @@ process.on( 'unhandledRejection', err => {
* @param {string} blockNamePHPLower The block name for PHP files in lowercase.
* @param {string} blockNamePHPUpper The block name for PHP files in uppercase.
*/
const copyTemplateFiles = (
blockName,
blockDir,
blockNamePHPLower,
blockNamePHPUpper
) => {
const copyTemplateFiles = ( blockName, blockDir, blockNamePHPLower, blockNamePHPUpper ) => {
// Since we ran npm install cgb-scripts we have it in the node_modules now.
const template = path.join(
blockDir,
'node_modules',
'cgb-scripts',
'template'
);
const template = path.join( blockDir, 'node_modules', 'cgb-scripts', 'template' );

const templatePromise = new Promise( resolve => {
shell.cd( blockDir );
Expand All @@ -50,9 +40,7 @@ const copyTemplateFiles = (
if ( fs.existsSync( template ) ) {
fs.copySync( template, blockDir );
} else {
console.error(
`Could not locate supplied template: ${ chalk.green( template ) }`
);
console.error( `Could not locate supplied template: ${ chalk.green( template ) }` );
return;
}

Expand Down Expand Up @@ -91,14 +79,9 @@ const copyTemplateFiles = (
* @param {string} blockDir The block directory.
*/
const printNextSteps = ( blockName, blockDir ) => {
console.log( '\n\n✅ ', chalk.black.bgGreen( ' All done! Go build some Gutenberg blocks. \n' ) );
console.log(
'\n\n✅ ',
chalk.black.bgGreen( ' All done! Go build some Gutenberg blocks. \n' )
);
console.log(
`CGB ${ chalk.dim(
'(create-guten-block)'
) } has created a WordPress plugin called `,
`CGB ${ chalk.dim( '(create-guten-block)' ) } has created a WordPress plugin called `,
chalk.dim( blockName ),
' 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.'
);
Expand All @@ -107,6 +90,7 @@ const printNextSteps = ( blockName, blockDir ) => {
'\nInside that directory, you can run several commands:\n'
);

// Scripts.
console.log(
'\n👉 ',
' Type',
Expand Down Expand Up @@ -138,14 +122,21 @@ const printNextSteps = ( blockName, blockDir ) => {
' If you do this, you can’t go back!'
);

console.log( '\n\n', chalk.black.bgGreen( ' Get Started → \n' ) );
console.log( ' We suggest that you begin by typing: \n' );
// Support.
console.log( '\n\n ✊ ', chalk.black.bgYellow( ' Support create-guten-block → \n' ) );
console.log(
` ${ chalk.green( 'cd' ) } ${ blockName }`,
'Love create-guten-block? You can now support this free and open source project. Supporting CGB means more updates and better maintenance: \n'
);
console.log(
` ${ chalk.yellow( 'Support for one hour or more →' ) } https://AhmdA.ws/CGB99`,
'\n',
` ${ chalk.green( 'npm' ) } start`,
'\n\n'
` ${ chalk.yellow( 'More ways to support →' ) } https://AhmdA.ws/CGBSupport`
);

// Get started.
console.log( '\n\n', chalk.black.bgGreen( ' Get Started → \n' ) );
console.log( ' We suggest that you begin by typing: \n' );
console.log( ` ${ chalk.green( 'cd' ) } ${ blockName }`, '\n', ` ${ chalk.green( 'npm' ) } start`, '\n\n' );
};

/**
Expand All @@ -172,12 +163,7 @@ module.exports = async( root, blockName, blockDir ) => {
// Init the spinner.
const spinner = new ora( { text: '' } );
spinner.start( '3. Creating plugin files...' );
await copyTemplateFiles(
blockName,
blockDir,
blockNamePHPLower,
blockNamePHPUpper
);
await copyTemplateFiles( blockName, blockDir, blockNamePHPLower, blockNamePHPUpper );
spinner.succeed();

// 2. Prints next steps.
Expand Down

0 comments on commit 637b182

Please sign in to comment.