diff --git a/package.json b/package.json index af5c5f8..b623cd2 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,9 @@ "test": "test" }, "dependencies": { - "chalk": "^2.3.0", "cheerio": "^1.0.0-rc.2", "chokidar": "^1.7.0", + "clorox": "^1.0.3", "glob": "^7.1.2", "mkdirp": "^0.5.1", "node-fetch": "^1.7.3", diff --git a/src/cli/build.ts b/src/cli/build.ts index 823b22b..f71b06e 100644 --- a/src/cli/build.ts +++ b/src/cli/build.ts @@ -1,6 +1,6 @@ import * as fs from 'fs'; import * as path from 'path'; -import chalk from 'chalk'; +import * as clorox from 'clorox'; import mkdirp from 'mkdirp'; import rimraf from 'rimraf'; import { create_compilers, create_app, create_routes, create_serviceworker } from 'sapper/core.js' @@ -20,12 +20,12 @@ export default async function build() { const { client, server, serviceworker } = create_compilers(); const client_stats = await compile(client); - console.log(chalk.inverse(`\nbuilt client`)); + console.log(clorox.inverse(`\nbuilt client`)); console.log(client_stats.toString({ colors: true })); fs.writeFileSync(path.join(output, 'client_info.json'), JSON.stringify(client_stats.toJson())); const server_stats = await compile(server); - console.log(chalk.inverse(`\nbuilt server`)); + console.log(clorox.inverse(`\nbuilt server`)); console.log(server_stats.toString({ colors: true })); let serviceworker_stats; @@ -38,7 +38,7 @@ export default async function build() { }); serviceworker_stats = await compile(serviceworker); - console.log(chalk.inverse(`\nbuilt service worker`)); + console.log(clorox.inverse(`\nbuilt service worker`)); console.log(serviceworker_stats.toString({ colors: true })); } } @@ -61,4 +61,4 @@ function compile(compiler: any) { } }); }); -} \ No newline at end of file +} diff --git a/src/cli/dev.ts b/src/cli/dev.ts index 558b536..145f4b2 100644 --- a/src/cli/dev.ts +++ b/src/cli/dev.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as net from 'net'; -import * as chalk from 'chalk'; +import * as clorox from 'clorox'; import * as child_process from 'child_process'; import * as http from 'http'; import mkdirp from 'mkdirp'; @@ -126,7 +126,7 @@ export default async function dev(port: number) { restarting = false; }); - console.log(`\n${chalk.bold.cyan(path.relative(process.cwd(), filename))} changed. rebuilding...`); + console.log(`\n${clorox.bold.cyan(path.relative(process.cwd(), filename))} changed. rebuilding...`); } // TODO watch the configs themselves? @@ -144,15 +144,15 @@ export default async function dev(port: number) { compiler.watch({}, (err: Error, stats: any) => { if (err) { - console.error(chalk.red(`✗ ${name}`)); - console.error(chalk.red(err.message)); + console.error(clorox.red(`✗ ${name}`)); + console.error(clorox.red(err.message)); error(err); } else { const messages = format_messages(stats); const info = stats.toJson(); if (messages.errors.length > 0) { - console.log(chalk.bold.red(`✗ ${name}`)); + console.log(clorox.bold.red(`✗ ${name}`)); const filtered = messages.errors.filter((message: string) => { return !build.unique_errors.has(message); @@ -169,7 +169,7 @@ export default async function dev(port: number) { } } else { if (messages.warnings.length > 0) { - console.log(chalk.bold.yellow(`• ${name}`)); + console.log(clorox.bold.yellow(`• ${name}`)); const filtered = messages.warnings.filter((message: string) => { return !build.unique_warnings.has(message); @@ -185,7 +185,7 @@ export default async function dev(port: number) { console.log(`${hidden} duplicate ${hidden === 1 ? 'warning' : 'warnings'} hidden\n`); } } else { - console.log(`${chalk.bold.green(`✔ ${name}`)} ${chalk.grey(`(${prettyMs(info.time)})`)}`); + console.log(`${clorox.bold.green(`✔ ${name}`)} ${clorox.grey(`(${prettyMs(info.time)})`)}`); } result(info); @@ -291,4 +291,4 @@ function watch_files(pattern: string, events: string[], callback: () => void) { events.forEach(event => { watcher.on(event, callback); }); -} \ No newline at end of file +} diff --git a/src/cli/index.ts b/src/cli/index.ts index de5b1f1..f6678ed 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -2,7 +2,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as child_process from 'child_process'; import sade from 'sade'; -import chalk from 'chalk'; +import * as clorox from 'clorox'; import prettyMs from 'pretty-ms'; import help from './help.md'; import build from './build'; @@ -22,7 +22,7 @@ prog.command('dev') if (port) { if (!await ports.check(port)) { - console.log(chalk.bold.red(`> Port ${port} is unavailable`)); + console.log(clorox.bold.red(`> Port ${port} is unavailable`)); return; } } else { @@ -45,7 +45,7 @@ prog.command('build [dest]') build() .then(() => { const elapsed = Date.now() - start; - console.error(`\n> Finished in ${prettyMs(elapsed)}. Type ${chalk.bold.cyan(dest === 'build' ? 'npx sapper start' : `npx sapper start ${dest}`)} to run the app.`); + console.error(`\n> Finished in ${prettyMs(elapsed)}. Type ${clorox.bold.cyan(dest === 'build' ? 'npx sapper start' : `npx sapper start ${dest}`)} to run the app.`); }) .catch(err => { console.error(err ? err.details || err.stack || err.message || err : 'Unknown error'); @@ -62,13 +62,13 @@ prog.command('start [dir]') const server = path.resolve(dir, 'server.js'); if (!fs.existsSync(server)) { - console.log(chalk.bold.red(`> ${dir}/server.js does not exist — type ${chalk.bold.cyan(dir === 'build' ? `npx sapper build` : `npx sapper build ${dir}`)} to create it`)); + console.log(clorox.bold.red(`> ${dir}/server.js does not exist — type ${clorox.bold.cyan(dir === 'build' ? `npx sapper build` : `npx sapper build ${dir}`)} to create it`)); return; } if (port) { if (!await ports.check(port)) { - console.log(chalk.bold.red(`> Port ${port} is unavailable`)); + console.log(clorox.bold.red(`> Port ${port} is unavailable`)); return; } } else { @@ -103,7 +103,7 @@ prog.command('export [dest]') .then(() => exporter(dest)) .then(() => { const elapsed = Date.now() - start; - console.error(`\n> Finished in ${prettyMs(elapsed)}. Type ${chalk.bold.cyan(`npx serve ${dest}`)} to run the app.`); + console.error(`\n> Finished in ${prettyMs(elapsed)}. Type ${clorox.bold.cyan(`npx serve ${dest}`)} to run the app.`); }) .catch(err => { console.error(err ? err.details || err.stack || err.message || err : 'Unknown error'); @@ -112,4 +112,4 @@ prog.command('export [dest]') // TODO upgrade -prog.parse(process.argv); \ No newline at end of file +prog.parse(process.argv); diff --git a/src/cli/upgrade.ts b/src/cli/upgrade.ts index c05a958..314db70 100644 --- a/src/cli/upgrade.ts +++ b/src/cli/upgrade.ts @@ -1,5 +1,5 @@ import * as fs from 'fs'; -import chalk from 'chalk'; +import * as clorox from 'clorox'; export default async function upgrade() { const upgraded = [ @@ -27,10 +27,10 @@ async function upgrade_sapper_main() { if (/\%sapper\.main\%/.test(template)) { if (!pattern.test(template)) { - console.log(chalk.red(`Could not replace %sapper.main% in ${file}`)); + console.log(clorox.red(`Could not replace %sapper.main% in ${file}`)); } else { write(file, template.replace(pattern, `%sapper.scripts%`)); - console.log(chalk.green(`Replaced %sapper.main% in ${file}`)); + console.log(clorox.green(`Replaced %sapper.main% in ${file}`)); replaced = true; } } @@ -50,4 +50,4 @@ function read(file: string) { function write(file: string, data: string) { fs.writeFileSync(file, data); -} \ No newline at end of file +}