@@ -5,21 +5,21 @@ import { resolve, join } from "path";
5
5
import { copy } from "fs-extra" ;
6
6
import _ from "lodash" ;
7
7
import { r , urlJoin } from "@nuxt/common" ;
8
+ import consola from "consola" ;
8
9
import chokidar from "chokidar" ;
9
10
import pify from "pify" ;
10
11
import webpack from "webpack" ;
11
12
import webpackDevMiddleware from "webpack-dev-middleware" ;
12
13
import webpackHotMiddleware from "webpack-hot-middleware" ;
13
14
import serveStatic from "serve-static" ;
14
- import Debug from "debug" ;
15
15
16
16
import pkg from "../package.json" ;
17
17
18
18
import ConfigManager from "./configManager" ;
19
19
import getWebpackNetlifyConfig from "./webpack.config" ;
20
20
import { toYAML } from "./utils/yaml" ;
21
21
22
- const debug = Debug ( "nuxt:netlify-cms" ) ;
22
+ const logger = consola . withScope ( "nuxt:netlify-cms" ) ;
23
23
24
24
const WEBPACK_CLIENT_COMPILER_NAME = "client" ;
25
25
const WEBPACK_NETLIFY_COMPILER_NAME = "netlify-cms" ;
@@ -72,6 +72,8 @@ export default function NetlifyCmsModule(moduleOptions) {
72
72
return ;
73
73
}
74
74
75
+ logger . success ( "Netlify-cms builder initialized" ) ;
76
+
75
77
// This will be run just after webpack compiler ends
76
78
netlifyCompiler . hooks . done . tapAsync (
77
79
"NetlifyCMSPlugin" ,
@@ -81,7 +83,12 @@ export default function NetlifyCmsModule(moduleOptions) {
81
83
/* istanbul ignore next */
82
84
return ;
83
85
}
84
- debug ( `Bundle built!` ) ;
86
+
87
+ logger . success ( "Netlify-cms bundle generated" ) ;
88
+ // Show a message inside console when the build is ready
89
+ this . options . dev &&
90
+ logger . info ( `Netlify-cms served on: ${ config . adminPath } ` ) ;
91
+
85
92
cb ( ) ;
86
93
}
87
94
) ;
@@ -90,13 +97,6 @@ export default function NetlifyCmsModule(moduleOptions) {
90
97
if ( this . options . dev ) {
91
98
// Use shared filesystem and cache
92
99
netlifyCompiler . outputFileSystem = bundleBuilder . mfs ;
93
- // Show a message inside console when the build is ready
94
- this . nuxt . hook ( "build:compiled" , async name => {
95
- if ( name !== WEBPACK_CLIENT_COMPILER_NAME ) {
96
- return ;
97
- }
98
- debug ( `Serving on: ${ config . adminPath } ` ) ;
99
- } ) ;
100
100
101
101
// Create webpack dev middleware
102
102
const netlifyWebpackDevMiddleware = pify (
@@ -159,7 +159,10 @@ export default function NetlifyCmsModule(moduleOptions) {
159
159
path : config . adminPath ,
160
160
handler : async ( req , res ) => {
161
161
if ( this . nuxt . renderer . netlifyWebpackDevMiddleware ) {
162
- debug ( `requesting url: ${ urlJoin ( config . adminPath , req . url ) } ` ) ;
162
+ logger . info (
163
+ `Netlify-cms requested url: ${ urlJoin ( config . adminPath , req . url ) } `
164
+ ) ;
165
+
163
166
await this . nuxt . renderer . netlifyWebpackDevMiddleware ( req , res ) ;
164
167
}
165
168
if ( this . nuxt . renderer . netlifyWebpackHotMiddleware ) {
@@ -182,6 +185,8 @@ export default function NetlifyCmsModule(moduleOptions) {
182
185
this . nuxt . renderer . netlifyWebpackHotMiddleware . publish ( {
183
186
action : "reload"
184
187
} ) ;
188
+
189
+ logger . info ( "Netlify-cms files refreshed" ) ;
185
190
} , 200 ) ;
186
191
187
192
// Watch for src Files
@@ -207,7 +212,7 @@ export default function NetlifyCmsModule(moduleOptions) {
207
212
} ) ;
208
213
}
209
214
210
- // Move cms folder from `dist/_nuxt ` folder to `dist/` after nuxt generate
215
+ // Move cms folder from `.nuxt/ dist/admin ` folder to `dist/` after nuxt generate
211
216
this . nuxt . hook ( "generate:distCopied" , async nuxt => {
212
217
await copy (
213
218
resolve ( nuxt . options . buildDir , "dist" , config . adminPath ) . replace (
@@ -216,7 +221,8 @@ export default function NetlifyCmsModule(moduleOptions) {
216
221
) ,
217
222
join ( nuxt . distPath , config . adminPath ) . replace ( / \/ $ / , "" )
218
223
) ;
219
- debug ( "Netlify CMS files copied" ) ;
224
+
225
+ logger . success ( "Netlify-cms files copied" ) ;
220
226
} ) ;
221
227
}
222
228
0 commit comments