This repository was archived by the owner on Feb 3, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +44
-33
lines changed Expand file tree Collapse file tree 7 files changed +44
-33
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " create-twilio-function" ,
3- "version" : " 2.0.0-alpha.4 " ,
3+ "version" : " 2.0.0-alpha.5 " ,
44 "description" : " A CLI tool to generate a new Twilio Function using that can be run locally with twilio-run." ,
55 "bin" : " ./bin/create-twilio-function" ,
66 "main" : " ./src/create-twilio-function.js" ,
3434 "ora" : " ^3.2.0" ,
3535 "pkg-install" : " ^1.0.0" ,
3636 "twilio-run" : " ^2.0.0-beta.12" ,
37- "yargs" : " ^12.0.5" ,
38- "rimraf" : " ^2.6.3"
37+ "rimraf" : " ^2.6.3" ,
38+ "window-size" : " ^1.1.1" ,
39+ "wrap-ansi" : " ^6.0.0" ,
40+ "yargs" : " ^12.0.5"
3941 },
4042 "engines" : {
4143 "node" : " >=8.0.0"
Original file line number Diff line number Diff line change 11const yargs = require ( 'yargs' ) ;
2- const { handler, describe, cliInfo } = require ( './command' ) ;
32const listTemplates = require ( './commands/list-templates' ) ;
3+ const DefaultCommand = require ( './command' ) ;
44
55function cli ( cwd ) {
66 yargs . help ( ) ;
@@ -9,20 +9,8 @@ function cli(cwd) {
99 yargs . alias ( 'v' , 'version' ) ;
1010
1111 yargs . default ( 'path' , cwd ) ;
12-
13- yargs . usage ( describe ) ;
14- yargs . command (
15- '$0 <name>' ,
16- describe ,
17- command => {
18- command . positional ( 'name' , {
19- describe : 'Name of your project.' ,
20- type : 'string'
21- } ) ;
22- command . options ( cliInfo . options ) ;
23- } ,
24- argv => handler ( argv )
25- ) ;
12+ yargs . usage ( DefaultCommand . describe ) ;
13+ yargs . command ( DefaultCommand ) ;
2614 yargs . command ( {
2715 command : 'list-templates' ,
2816 desc : 'List the available templates you can create a project with.' ,
Original file line number Diff line number Diff line change 1- const createTwilioFunction = require ( './create-twilio-function' ) ;
1+ const handler = require ( './create-twilio-function' ) ;
2+
3+ const command = '$0 <name>' ;
4+ const describe = 'Creates a new Twilio Function project' ;
25
36const cliInfo = {
47 options : {
@@ -32,8 +35,18 @@ const cliInfo = {
3235 }
3336} ;
3437
38+ const builder = command => {
39+ command . positional ( 'name' , {
40+ describe : 'Name of your project.' ,
41+ type : 'string'
42+ } ) ;
43+ command . options ( cliInfo . options ) ;
44+ } ;
45+
3546module . exports = {
36- describe : 'Creates a new Twilio Function project' ,
37- handler : createTwilioFunction ,
38- cliInfo : cliInfo
47+ command,
48+ describe,
49+ handler,
50+ cliInfo,
51+ builder
3952} ;
Original file line number Diff line number Diff line change 11const { getPackageManager } = require ( 'pkg-install' ) ;
22const chalk = require ( 'chalk' ) ;
3+ const windowSize = require ( 'window-size' ) ;
4+ const wrap = require ( 'wrap-ansi' ) ;
35
46async function successMessage ( config ) {
57 const packageManager = await getPackageManager ( { cwd : process . cwd ( ) } ) ;
6- return chalk `{green Success!}
8+ return wrap (
9+ chalk `{green Success!}
710
8- Created {bold ${ config . name } } at ${ config . path }
11+ Created {bold ${ config . name } } at {bold ${ config . path } }
912
10- Inside that directory, you can run the following command:
13+ Inside that directory, you can run the following command:
1114
12- {blue ${ packageManager } start}
13- Serves all functions in the ./functions subdirectory and assets in the
14- ./assets directory
15+ {blue ${ packageManager } start}
16+ Serves all functions in the ./functions subdirectory and assets in the
17+ ./assets directory
1518
16- Get started by running:
19+ Get started by running:
1720
18- {blue cd ${ config . name } }
19- {blue ${ packageManager } start}` ;
21+ {blue cd ${ config . name } }
22+ {blue ${ packageManager } start}` ,
23+ windowSize . get ( ) . width - 8 ,
24+ { trim : false , hard : true }
25+ ) ;
2026}
2127
2228module . exports = successMessage ;
Original file line number Diff line number Diff line change 11module . exports = {
2- twilioRun : '^2. 0.0-beta.11 ' ,
2+ twilioRun : '2.* || >2. 0.0-rc ' ,
33 node : '8.10.0'
44} ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const mkdir = promisify(fs.mkdir);
1212const stat = promisify ( fs . stat ) ;
1313const readdir = promisify ( fs . readdir ) ;
1414
15+ jest . mock ( 'window-size' , ( ) => ( { get : ( ) => ( { width : 80 } ) } ) ) ;
1516jest . mock ( 'inquirer' ) ;
1617jest . mock ( 'ora' ) ;
1718jest . mock ( 'boxen' , ( ) => {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const chalk = require('chalk');
33const successMessage = require ( '../src/create-twilio-function/success-message' ) ;
44
55jest . mock ( 'pkg-install' ) ;
6+ jest . mock ( 'window-size' , ( ) => ( { get : ( ) => ( { width : 80 } ) } ) ) ;
67
78describe ( 'successMessage' , ( ) => {
89 test ( 'creates a success message based on the package manager' , async ( ) => {
@@ -15,7 +16,7 @@ describe('successMessage', () => {
1516 expect ( message ) . toEqual ( expect . stringContaining ( 'yarn start' ) ) ;
1617 expect ( message ) . toEqual (
1718 expect . stringContaining (
18- chalk `Created {bold ${ config . name } } at ${ config . path } `
19+ chalk `Created {bold ${ config . name } } at {bold ${ config . path } }`
1920 )
2021 ) ;
2122 } ) ;
You can’t perform that action at this time.
0 commit comments