mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-16 21:04:34 +00:00
replace chalk with clorox
This commit is contained in:
@@ -19,9 +19,9 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^2.3.0",
|
|
||||||
"cheerio": "^1.0.0-rc.2",
|
"cheerio": "^1.0.0-rc.2",
|
||||||
"chokidar": "^1.7.0",
|
"chokidar": "^1.7.0",
|
||||||
|
"clorox": "^1.0.3",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"node-fetch": "^1.7.3",
|
"node-fetch": "^1.7.3",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import chalk from 'chalk';
|
import * as clorox from 'clorox';
|
||||||
import mkdirp from 'mkdirp';
|
import mkdirp from 'mkdirp';
|
||||||
import rimraf from 'rimraf';
|
import rimraf from 'rimraf';
|
||||||
import { create_compilers, create_app, create_routes, create_serviceworker } from 'sapper/core.js'
|
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, server, serviceworker } = create_compilers();
|
||||||
|
|
||||||
const client_stats = await compile(client);
|
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 }));
|
console.log(client_stats.toString({ colors: true }));
|
||||||
fs.writeFileSync(path.join(output, 'client_info.json'), JSON.stringify(client_stats.toJson()));
|
fs.writeFileSync(path.join(output, 'client_info.json'), JSON.stringify(client_stats.toJson()));
|
||||||
|
|
||||||
const server_stats = await compile(server);
|
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 }));
|
console.log(server_stats.toString({ colors: true }));
|
||||||
|
|
||||||
let serviceworker_stats;
|
let serviceworker_stats;
|
||||||
@@ -38,7 +38,7 @@ export default async function build() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
serviceworker_stats = await compile(serviceworker);
|
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 }));
|
console.log(serviceworker_stats.toString({ colors: true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as net from 'net';
|
import * as net from 'net';
|
||||||
import * as chalk from 'chalk';
|
import * as clorox from 'clorox';
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import mkdirp from 'mkdirp';
|
import mkdirp from 'mkdirp';
|
||||||
@@ -126,7 +126,7 @@ export default async function dev(port: number) {
|
|||||||
restarting = false;
|
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?
|
// TODO watch the configs themselves?
|
||||||
@@ -144,15 +144,15 @@ export default async function dev(port: number) {
|
|||||||
|
|
||||||
compiler.watch({}, (err: Error, stats: any) => {
|
compiler.watch({}, (err: Error, stats: any) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(chalk.red(`✗ ${name}`));
|
console.error(clorox.red(`✗ ${name}`));
|
||||||
console.error(chalk.red(err.message));
|
console.error(clorox.red(err.message));
|
||||||
error(err);
|
error(err);
|
||||||
} else {
|
} else {
|
||||||
const messages = format_messages(stats);
|
const messages = format_messages(stats);
|
||||||
const info = stats.toJson();
|
const info = stats.toJson();
|
||||||
|
|
||||||
if (messages.errors.length > 0) {
|
if (messages.errors.length > 0) {
|
||||||
console.log(chalk.bold.red(`✗ ${name}`));
|
console.log(clorox.bold.red(`✗ ${name}`));
|
||||||
|
|
||||||
const filtered = messages.errors.filter((message: string) => {
|
const filtered = messages.errors.filter((message: string) => {
|
||||||
return !build.unique_errors.has(message);
|
return !build.unique_errors.has(message);
|
||||||
@@ -169,7 +169,7 @@ export default async function dev(port: number) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (messages.warnings.length > 0) {
|
if (messages.warnings.length > 0) {
|
||||||
console.log(chalk.bold.yellow(`• ${name}`));
|
console.log(clorox.bold.yellow(`• ${name}`));
|
||||||
|
|
||||||
const filtered = messages.warnings.filter((message: string) => {
|
const filtered = messages.warnings.filter((message: string) => {
|
||||||
return !build.unique_warnings.has(message);
|
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`);
|
console.log(`${hidden} duplicate ${hidden === 1 ? 'warning' : 'warnings'} hidden\n`);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
result(info);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
import sade from 'sade';
|
import sade from 'sade';
|
||||||
import chalk from 'chalk';
|
import * as clorox from 'clorox';
|
||||||
import prettyMs from 'pretty-ms';
|
import prettyMs from 'pretty-ms';
|
||||||
import help from './help.md';
|
import help from './help.md';
|
||||||
import build from './build';
|
import build from './build';
|
||||||
@@ -22,7 +22,7 @@ prog.command('dev')
|
|||||||
|
|
||||||
if (port) {
|
if (port) {
|
||||||
if (!await ports.check(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;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -45,7 +45,7 @@ prog.command('build [dest]')
|
|||||||
build()
|
build()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const elapsed = Date.now() - start;
|
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 => {
|
.catch(err => {
|
||||||
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
|
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');
|
const server = path.resolve(dir, 'server.js');
|
||||||
|
|
||||||
if (!fs.existsSync(server)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port) {
|
if (port) {
|
||||||
if (!await ports.check(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;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -103,7 +103,7 @@ prog.command('export [dest]')
|
|||||||
.then(() => exporter(dest))
|
.then(() => exporter(dest))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const elapsed = Date.now() - start;
|
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 => {
|
.catch(err => {
|
||||||
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
|
console.error(err ? err.details || err.stack || err.message || err : 'Unknown error');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import chalk from 'chalk';
|
import * as clorox from 'clorox';
|
||||||
|
|
||||||
export default async function upgrade() {
|
export default async function upgrade() {
|
||||||
const upgraded = [
|
const upgraded = [
|
||||||
@@ -27,10 +27,10 @@ async function upgrade_sapper_main() {
|
|||||||
|
|
||||||
if (/\%sapper\.main\%/.test(template)) {
|
if (/\%sapper\.main\%/.test(template)) {
|
||||||
if (!pattern.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 {
|
} else {
|
||||||
write(file, template.replace(pattern, `%sapper.scripts%`));
|
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;
|
replaced = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user