Skip to content

Commit a73760e

Browse files
committed
fix: update kleur syntax
1 parent 8bae4a3 commit a73760e

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

packages/cli/lib/build.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const log = require('./util/log');
1010
const _ = ' ';
1111
const gutter = _.repeat(4);
1212
const levels = ['cyan', 'yellow', 'red']; // sizes
13-
const th = str => colors.dim.bold.italic.underline(str);
13+
const th = colors.dim().bold().italic().underline;
1414
const lpad = (str, max) => _.repeat(max - str.length) + str;
1515
const rpad = (str, max) => str + _.repeat(max - str.length);
1616

@@ -49,7 +49,7 @@ module.exports = function (src, opts) {
4949
let dest = ctx.options.output.path;
5050

5151
del.sync(dest);
52-
log.log(`Deleted existing ${colors.bold.italic(opts.dest)} directory`);
52+
log.log(`Deleted existing ${colors.bold().italic(opts.dest)} directory`);
5353

5454
ctx.run((err, stats) => {
5555
let errors = [];
@@ -65,14 +65,14 @@ module.exports = function (src, opts) {
6565

6666
if (errors.length > 0) {
6767
let sfx = errors.length > 1 ? 's' : '';
68-
let out = `Failed to compile! Found ${ colors.red.bold(errors.length) } error${sfx}:`;
68+
let out = `Failed to compile! Found ${ colors.red().bold(errors.length) } error${sfx}:`;
6969
errors.forEach(x => (out += '\n' + x));
7070
return log.error(out);
7171
}
7272

7373
if (warnings.length > 0) {
7474
let sfx = warnings.length > 1 ? 's' : '';
75-
let tmp = `Compiled with ${ colors.yellow.bold(warnings.length) } warning${sfx}:`;
75+
let tmp = `Compiled with ${ colors.yellow().bold(warnings.length) } warning${sfx}:`;
7676
warnings.forEach(x => (tmp += '\n' + x));
7777
log.warn(tmp);
7878
}
@@ -100,16 +100,16 @@ module.exports = function (src, opts) {
100100
max.size += 4;
101101

102102
// table headers
103-
out += ('\n\n' + th(rpad('Filename', max.file)) + gutter + th(lpad('Filesize', max.size)) + _ + _ + colors.dim.bold.italic(lpad('(gzip)', max.gzip)));
103+
out += ('\n\n' + th(rpad('Filename', max.file)) + gutter + th(lpad('Filesize', max.size)) + _ + _ + colors.dim().bold().italic(lpad('(gzip)', max.gzip)));
104104

105105
assets.forEach(obj => {
106106
let fn = levels[obj.notice];
107-
let gz = colors.italic[obj.notice ? fn : 'dim'](_ + _ + lpad(obj.gzip, max.gzip));
107+
let gz = colors.italic()[obj.notice ? fn : 'dim'](_ + _ + lpad(obj.gzip, max.gzip));
108108
out += ('\n' + colors.white(rpad(obj.file, max.file)) + gutter + colors[fn](lpad(obj.size, max.size)) + gz);
109109
});
110110

111111
log.success(out + '\n');
112-
log.success(`Build complete!\nYour ${colors.bold.italic.green(opts.dest)} directory is ready for deployment 🎉`);
112+
log.success(`Build complete!\nYour ${colors.bold().italic().green(opts.dest)} directory is ready for deployment 🎉`);
113113

114114
if (opts.export && !opts.analyze) {
115115
console.log(); // newline
@@ -140,9 +140,9 @@ module.exports = function (src, opts) {
140140
routes.sort((a, b) => b.length - a.length); // root is last (TODO)
141141
} else {
142142
routes = ['/'];
143-
let msg = `Exporting the "${colors.bold.yellow('/')}" route only!\nNo other routes found or specified:`;
144-
msg += `\n– Your ${colors.bold.italic('@pages')} directory is empty.`;
145-
if (ctx.PWA_CONFIG) msg += `\n– Your ${colors.underline.magenta('pwa.config.js')} is missing a "${colors.bold('routes')}" key.`;
143+
let msg = `Exporting the "${colors.bold().yellow('/')}" route only!\nNo other routes found or specified:`;
144+
msg += `\n– Your ${colors.bold().italic('@pages')} directory is empty.`;
145+
if (ctx.PWA_CONFIG) msg += `\n– Your ${colors.underline().magenta('pwa.config.js')} is missing a "${colors.bold('routes')}" key.`;
146146
msg += `\n– Your ${colors.dim('$ pwa export')} is missing the ${colors.cyan('--routes')} argument.`;
147147
msg += `\n Please run ${colors.dim('$ pwa export --help')} for more info\n`;
148148
log.warn(msg);
@@ -158,14 +158,14 @@ module.exports = function (src, opts) {
158158
if (opts.insecure) chromeFlags.push('--no-sandbox');
159159

160160
let base = 'http://localhost:' + server.address().port;
161-
log.log(`Started local server on ${ colors.white.bold.underline(base) }`);
161+
log.log(`Started local server on ${ colors.white().bold().underline(base) }`);
162162

163163
let toHTML = x => x.constructor.name === 'HtmlWebpackPlugin';
164164
let minify_opts = ctx.options.plugins.find(toHTML).options.minify;
165165

166166
function print(obj) {
167167
writer(join(dest, obj.file)).end('<!DOCTYPE html>' + minify(obj.html, minify_opts));
168-
log.info(`Wrote file: ${colors.bold.magenta(obj.file)}`);
168+
log.info(`Wrote file: ${colors.bold().magenta(obj.file)}`);
169169
}
170170

171171
launch({ chromeFlags }).then(proc => {
@@ -179,7 +179,7 @@ module.exports = function (src, opts) {
179179
server.close();
180180
log.log('Shutdown local server\n');
181181
let sfx = arr.length > 1 ? 's' : '';
182-
let num = colors.italic.bold.green(arr.length);
182+
let num = colors.italic().bold().green(arr.length);
183183
log.success(`Export complete!\nGenerated ${num} page${sfx} 🙌🏼`);
184184
}).catch(err => {
185185
console.log('> error', err); //TODO

packages/cli/lib/init.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ module.exports = function (type, dir, opts) {
180180
let onCancel = () => ok=false;
181181
return prompts(BULLETS, { onCancel }).then(argv => {
182182
if (!ok) {
183-
log.info(`Received ${colors.cyan.underline('CTRL+C')} command`);
183+
log.info(`Received ${colors.cyan().underline('CTRL+C')} command`);
184184
return log.log(`Exited ${colors.dim('$ pwa init')} setup`);
185185
}
186186

@@ -333,8 +333,8 @@ module.exports = function (type, dir, opts) {
333333
// ---
334334

335335
let dir = parse(argv.dir).base;
336-
let txt = argv.preset ? (colors.magenta.underline(argv.preset) + ' ') : '';
337-
let msg = `Created a new ${txt}project within ${ colors.green.bold(dir) } 🎉\n`;
336+
let txt = argv.preset ? (colors.magenta().underline(argv.preset) + ' ') : '';
337+
let msg = `Created a new ${txt}project within ${ colors.green().bold(dir) } 🎉\n`;
338338

339339
msg += '\nInside this directory, you may:\n';
340340
msg += '\n – Develop within a live-reload server:';
@@ -346,13 +346,13 @@ module.exports = function (type, dir, opts) {
346346
msg += '\n – Start a production HTTP file server:';
347347
msg += `\n ${colors.dim('$ npm start')}\n`;
348348

349-
msg += `\nThese commands have been added to your ${colors.white.underline('package.json')} already.`;
349+
msg += `\nThese commands have been added to your ${colors.white().underline('package.json')} already.`;
350350
msg += '\nWe suggest you begin by typing:\n';
351351
msg += '\n ' + colors.dim(`$ cd ${dir}`);
352352
msg += `\n ${colors.dim('$ npm install')}`;
353353
msg += `\n ${colors.dim('$ npm run watch')}`;
354354

355-
msg += `\n\nDocumentation can be found at ${colors.white.bold.underline('https://pwa.cafe/docs')}`;
355+
msg += `\n\nDocumentation can be found at ${colors.white().bold().underline('https://pwa.cafe/docs')}`;
356356

357357
log.success(msg);
358358
log.success('Enjoy! 😍');

packages/cli/lib/util/log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ exports.info = print.bind(null, 'cyan');
1515
exports.error = print.bind(null, 'red');
1616

1717
exports.logger = msg => {
18-
exports.info(msg.includes('@pwa') ? msg.replace(RGX, $.magenta.underline('$1')) : msg);
18+
exports.info(msg.includes('@pwa') ? msg.replace(RGX, $.magenta().underline('$1')) : msg);
1919
};

packages/cli/lib/watch.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ module.exports = function (src, opts) {
4141
let gutter = ' '.repeat(4);
4242
let space = hasCA ? ' '.repeat(2) : '';
4343
let out = 'Certificate component(s) not found at locations provided!\n';
44-
out += colors.bold.white('--key ') + space + gutter + colors.italic.dim(key) + '\n';
45-
out += colors.bold.white('--cert') + space + gutter + colors.italic.dim(cert);
46-
if (hasCA) out += '\n' + colors.bold.white('--cacert') + gutter + colors.italic.dim(cacert);
44+
out += colors.bold().white('--key ') + space + gutter + colors.italic().dim(key) + '\n';
45+
out += colors.bold().white('--cert') + space + gutter + colors.italic().dim(cert);
46+
if (hasCA) out += '\n' + colors.bold().white('--cacert') + gutter + colors.italic().dim(cacert);
4747
return log.error(out);
4848
}
4949
} else {
@@ -55,19 +55,19 @@ module.exports = function (src, opts) {
5555
if (!opts.quiet) {
5656
let format = require('webpack-format-messages');
5757
let uri = require('url').format({ protocol, hostname, port });
58-
log.log(`Starting development server on ${ colors.white.bold.underline(uri) }`);
58+
log.log(`Starting development server on ${ colors.white().bold().underline(uri) }`);
5959

6060
function onError(arr) {
6161
arr = [].concat(arr || []);
6262
let sfx = arr.length > 1 ? 's' : '';
63-
let out = `Failed to compile! Found ${ colors.red.bold(arr.length) } error${sfx}:`;
63+
let out = `Failed to compile! Found ${ colors.red().bold(arr.length) } error${sfx}:`;
6464
arr.forEach(x => (out += '\n' + x));
6565
return log.error(out);
6666
}
6767

6868
c.hooks.invalid.tap('PWA', file => {
6969
file = relative(cwd, file);
70-
log.info(`File changed: ${ colors.white.bold(file) }`);
70+
log.info(`File changed: ${ colors.white().bold(file) }`);
7171
});
7272

7373
c.hooks.failed.tap('PWA', onError);
@@ -81,7 +81,7 @@ module.exports = function (src, opts) {
8181

8282
if (warnings.length > 0) {
8383
let sfx = warnings.length > 1 ? 's' : '';
84-
let out = `Compiled with ${ colors.yellow.bold(warnings.length) } warning${sfx}:`;
84+
let out = `Compiled with ${ colors.yellow().bold(warnings.length) } warning${sfx}:`;
8585
warnings.forEach(x => (out += '\n' + x));
8686
log.warn(out);
8787
}

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@pwa/core": "^0.4.1",
1717
"chrome-launcher": "^0.10.2",
1818
"chrome-remote-interface": "0.25.x",
19-
"kleur": "^2.0.1",
19+
"kleur": "^3.0.0",
2020
"mkdirp": "^0.5.1",
2121
"prompts": "^1.2.1",
2222
"rimraf": "^2.6.2",

0 commit comments

Comments
 (0)