@@ -14,7 +14,12 @@ const { createAddon } = require("netlify/src/addons");
14
14
const ora = require ( "ora" ) ;
15
15
const { track } = require ( "@netlify/cli-utils/src/utils/telemetry" ) ;
16
16
const chalk = require ( "chalk" ) ;
17
- const { NETLIFYDEV , NETLIFYDEVWARN , NETLIFYDEVERR } = require ( "../../cli-logo" ) ;
17
+ const {
18
+ NETLIFYDEV ,
19
+ NETLIFYDEVLOG ,
20
+ NETLIFYDEVWARN ,
21
+ NETLIFYDEVERR
22
+ } = require ( "../../cli-logo" ) ;
18
23
19
24
const templatesDir = path . resolve ( __dirname , "../../functions-templates" ) ;
20
25
@@ -206,19 +211,19 @@ function ensureFunctionDirExists(flags, config) {
206
211
flags . functions || ( config . build && config . build . functions ) ;
207
212
if ( ! functionsDir ) {
208
213
this . log (
209
- `${ NETLIFYDEV } No functions folder specified in netlify.toml or as an argument`
214
+ `${ NETLIFYDEVLOG } No functions folder specified in netlify.toml or as an argument`
210
215
) ;
211
216
process . exit ( 1 ) ;
212
217
}
213
218
if ( ! fs . existsSync ( functionsDir ) ) {
214
219
this . log (
215
- `${ NETLIFYDEV } functions folder ${ chalk . magenta . inverse (
220
+ `${ NETLIFYDEVLOG } functions folder ${ chalk . magenta . inverse (
216
221
functionsDir
217
222
) } specified in netlify.toml but folder not found, creating it...`
218
223
) ;
219
224
fs . mkdirSync ( functionsDir ) ;
220
225
this . log (
221
- `${ NETLIFYDEV } functions folder ${ chalk . magenta . inverse (
226
+ `${ NETLIFYDEVLOG } functions folder ${ chalk . magenta . inverse (
222
227
functionsDir
223
228
) } created`
224
229
) ;
@@ -264,10 +269,10 @@ async function downloadFromURL(flags, args, functionsDir) {
264
269
} )
265
270
) ;
266
271
267
- this . log ( `${ NETLIFYDEV } Installing dependencies for ${ nameToUse } ...` ) ;
272
+ this . log ( `${ NETLIFYDEVLOG } Installing dependencies for ${ nameToUse } ...` ) ;
268
273
cp . exec ( "npm i" , { cwd : path . join ( functionsDir , nameToUse ) } , ( ) => {
269
274
this . log (
270
- `${ NETLIFYDEV } Installing dependencies for ${ nameToUse } complete `
275
+ `${ NETLIFYDEVLOG } Installing dependencies for ${ nameToUse } complete `
271
276
) ;
272
277
} ) ;
273
278
@@ -315,13 +320,15 @@ async function scaffoldFromTemplate(flags, args, functionsDir) {
315
320
try {
316
321
await downloadFromURL . call ( this , flags , args , functionsDir ) ;
317
322
} catch ( err ) {
318
- console . error ( `$${ NETLIFYERR } Error downloading from URL: ` + flags . url ) ;
323
+ console . error (
324
+ `$${ NETLIFYDEVERR } Error downloading from URL: ` + flags . url
325
+ ) ;
319
326
console . error ( err ) ;
320
327
process . exit ( 1 ) ;
321
328
}
322
329
} else if ( chosentemplate === "report" ) {
323
330
console . log (
324
- `${ NETLIFYDEV } Open in browser: https://github.com/netlify/netlify-dev-plugin/issues/new`
331
+ `${ NETLIFYDEVLOG } Open in browser: https://github.com/netlify/netlify-dev-plugin/issues/new`
325
332
) ;
326
333
} else {
327
334
const {
@@ -339,7 +346,7 @@ async function scaffoldFromTemplate(flags, args, functionsDir) {
339
346
}
340
347
341
348
const name = await getNameFromArgs ( args , flags , templateName ) ;
342
- this . log ( `${ NETLIFYDEV } Creating function ${ chalk . cyan . inverse ( name ) } ` ) ;
349
+ this . log ( `${ NETLIFYDEVLOG } Creating function ${ chalk . cyan . inverse ( name ) } ` ) ;
343
350
const functionPath = ensureFunctionPathIsOk . call (
344
351
this ,
345
352
functionsDir ,
@@ -355,7 +362,9 @@ async function scaffoldFromTemplate(flags, args, functionsDir) {
355
362
if ( err ) throw err ;
356
363
createdFiles . forEach ( filePath => {
357
364
if ( filePath . endsWith ( ".netlify-function-template.js" ) ) return ;
358
- this . log ( `${ NETLIFYDEV } ${ chalk . greenBright ( "Created" ) } ${ filePath } ` ) ;
365
+ this . log (
366
+ `${ NETLIFYDEVLOG } ${ chalk . greenBright ( "Created" ) } ${ filePath } `
367
+ ) ;
359
368
require ( "fs" ) . chmodSync ( path . resolve ( filePath ) , 0o777 ) ;
360
369
if ( filePath . includes ( "package.json" ) ) hasPackageJSON = true ;
361
370
} ) ;
@@ -401,13 +410,14 @@ async function installAddons(addons = [], fnPath) {
401
410
) ;
402
411
return false ;
403
412
}
404
- console . log ( `${ NETLIFYDEV } checking Netlify APIs...` ) ;
413
+ console . log ( `${ NETLIFYDEVLOG } checking Netlify APIs...` ) ;
405
414
406
415
return api . getSite ( { siteId } ) . then ( async siteData => {
407
416
const accessToken = api . accessToken ;
408
417
const arr = addons . map ( ( { addonName, addonDidInstall } ) => {
409
418
console . log (
410
- `${ NETLIFYDEV } installing addon: ` + chalk . yellow . inverse ( addonName )
419
+ `${ NETLIFYDEVLOG } installing addon: ` +
420
+ chalk . yellow . inverse ( addonName )
411
421
) ;
412
422
// will prompt for configs if not supplied - we do not yet allow for addon configs supplied by `netlify functions:create` command and may never do so
413
423
return createSiteAddon (
@@ -436,7 +446,7 @@ async function installAddons(addons = [], fnPath) {
436
446
}
437
447
} )
438
448
. catch ( err => {
439
- console . error ( `${ NETLIFYERR } Error installing addon: ` , err ) ;
449
+ console . error ( `${ NETLIFYDEVERR } Error installing addon: ` , err ) ;
440
450
} ) ;
441
451
} ) ;
442
452
return Promise . all ( arr ) ;
@@ -450,7 +460,7 @@ function ensureFunctionPathIsOk(functionsDir, flags, name) {
450
460
const functionPath = path . join ( functionsDir , name ) ;
451
461
if ( fs . existsSync ( functionPath ) ) {
452
462
this . log (
453
- `${ NETLIFYDEV } Function ${ functionPath } already exists, cancelling...`
463
+ `${ NETLIFYDEVLOG } Function ${ functionPath } already exists, cancelling...`
454
464
) ;
455
465
process . exit ( 1 ) ;
456
466
}
0 commit comments