Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit f93ee46

Browse files
authored
Merge pull request #101 from netlify/newVisualID
New visual identity with Netlify Gem! as well as warning/error indicators ◈
2 parents 6d48adc + 8831958 commit f93ee46

File tree

15 files changed

+130
-67
lines changed

15 files changed

+130
-67
lines changed

package-lock.json

Lines changed: 80 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"ora": "^3.4.0",
2828
"safe-join": "^0.1.2",
2929
"static-server": "^2.2.1",
30-
"wait-port": "^0.2.2"
30+
"wait-port": "^0.2.2",
31+
"wrap-ansi": "^5.1.0"
3132
},
3233
"devDependencies": {
3334
"@oclif/dev-cli": "^1",

src/cli-logo.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const chalk = require("chalk");
2+
3+
module.exports = {
4+
NETLIFYDEV: `${chalk.rgb(40, 180, 170)("Netlify Dev")} ${chalk.greenBright(
5+
"◈"
6+
)}`,
7+
NETLIFYDEVWARN: `${chalk.rgb(40, 180, 170)(
8+
"Netlify Dev"
9+
)} ${chalk.yellowBright("◈")}`,
10+
NETLIFYDEVERR: `${chalk.rgb(40, 180, 170)("Netlify Dev")} ${chalk.redBright(
11+
"◈"
12+
)}`
13+
};

src/commands/dev/exec.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
const execa = require("execa");
22
const Command = require("@netlify/cli-utils");
33
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
4-
const chalk = require("chalk");
5-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
4+
const { NETLIFYDEV, NETLIFYDEVWARN, NETLIFYDEVERR } = require("../../cli-logo");
65

76
class ExecCommand extends Command {
87
async run() {
98
const { site, api } = this.netlify;
109
if (site.id) {
11-
console.log(
12-
`${NETLIFYDEV} Checking your site's environment variables...`
13-
);
10+
this.log(`${NETLIFYDEV} Checking your site's environment variables...`); // just to show some visual response first
1411
const accessToken = api.accessToken;
1512
const { addEnvVariables } = require("../../utils/dev");
1613
await addEnvVariables(api, site, accessToken);
1714
} else {
18-
console.log(
19-
`${NETLIFYDEV} No Site ID detected. You probably forgot to run \`netlify link\` or \`netlify init\`. `
15+
this.log(
16+
`${NETLIFYDEVERR} No Site ID detected. You probably forgot to run \`netlify link\` or \`netlify init\`. `
2017
);
2118
}
2219
execa(this.argv[0], this.argv.slice(1), {

src/commands/dev/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Command = require("@netlify/cli-utils");
1212
const { getAddons } = require("netlify/src/addons");
1313
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
1414
const chalk = require("chalk");
15-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
15+
const { NETLIFYDEV, NETLIFYDEVWARN, NETLIFYDEVERR } = require("../../cli-logo");
1616
const boxen = require("boxen");
1717
const { createTunnel, connectTunnel } = require("../../live-tunnel");
1818

@@ -137,7 +137,7 @@ function startDevServer(settings, log, error) {
137137
const StaticServer = require("static-server");
138138
if (!settings.dist) {
139139
log(
140-
`${NETLIFYDEV} Unable to determine public folder for the dev server. \n Setup a netlify.toml file with a [dev] section to specify your dev server settings.`
140+
`${NETLIFYDEVWARN} Unable to determine public folder for the dev server. \n Setup a netlify.toml file with a [dev] section to specify your dev server settings.`
141141
);
142142
process.exit(1);
143143
}
@@ -188,7 +188,7 @@ class DevCommand extends Command {
188188

189189
if (!(settings && settings.command)) {
190190
this.log(
191-
`${NETLIFYDEV} No dev server detected, using simple static server`
191+
`${NETLIFYDEVWARN} No dev server detected, using simple static server`
192192
);
193193
const dist =
194194
(config.dev && config.dev.publish) ||
@@ -247,7 +247,11 @@ class DevCommand extends Command {
247247
live: flags.live || false
248248
});
249249

250-
const banner = chalk.bold(`${NETLIFYDEV} Server now ready on ${url}`);
250+
// boxen doesnt support text wrapping yet https://github.com/sindresorhus/boxen/issues/16
251+
const banner = require("wrap-ansi")(
252+
chalk.bold(`${NETLIFYDEV} Server now ready on ${url}`),
253+
70
254+
);
251255
this.log(
252256
boxen(banner, {
253257
padding: 1,

src/commands/functions/build.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ const fs = require("fs");
22
const { flags } = require("@oclif/command");
33
const Command = require("@netlify/cli-utils");
44
const { zipFunctions } = require("@netlify/zip-it-and-ship-it");
5-
const chalk = require("chalk");
6-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
5+
const { NETLIFYDEV, NETLIFYDEVWARN, NETLIFYDEVERR } = require("../../cli-logo");
76

87
class FunctionsBuildCommand extends Command {
98
async run() {
@@ -15,19 +14,19 @@ class FunctionsBuildCommand extends Command {
1514

1615
if (src === dst) {
1716
this.log(
18-
`${NETLIFYDEV} Source and destination for function build can't be the same`
17+
`${NETLIFYDEVERR} Source and destination for function build can't be the same`
1918
);
2019
process.exit(1);
2120
}
2221

2322
if (!src || !dst) {
2423
if (!src)
2524
this.log(
26-
`${NETLIFYDEV} Error: You must specify a source folder with a --src flag or a functionsSource field in your config`
25+
`${NETLIFYDEVERR} Error: You must specify a source folder with a --src flag or a functionsSource field in your config`
2726
);
2827
if (!dst)
2928
this.log(
30-
`${NETLIFYDEV} Error: You must specify a destination functions folder with a --functions flag or a functions field in your config`
29+
`${NETLIFYDEVERR} Error: You must specify a destination functions folder with a --functions flag or a functions field in your config`
3130
);
3231
process.exit(1);
3332
}

src/commands/functions/create.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ const { createAddon } = require("netlify/src/addons");
1414
const ora = require("ora");
1515
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
1616
const chalk = require("chalk");
17-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
18-
const NETLIFYWARN = chalk.yellow.inverse("Warning");
19-
const NETLIFYERR = chalk.red.inverse("Error");
17+
const { NETLIFYDEV, NETLIFYDEVWARN, NETLIFYDEVERR } = require("../../cli-logo");
2018

2119
const templatesDir = path.resolve(__dirname, "../../functions-templates");
2220

@@ -239,7 +237,7 @@ async function downloadFromURL(flags, args, functionsDir) {
239237
fs.lstatSync(fnFolder + ".js").isFile()
240238
) {
241239
this.log(
242-
`${NETLIFYDEV} ${NETLIFYWARN}: A single file version of the function ${name} already exists at ${fnFolder}.js. Terminating without further action.`
240+
`${NETLIFYWARN}: A single file version of the function ${name} already exists at ${fnFolder}.js. Terminating without further action.`
243241
);
244242
process.exit(1);
245243
}
@@ -317,9 +315,7 @@ async function scaffoldFromTemplate(flags, args, functionsDir) {
317315
try {
318316
await downloadFromURL.call(this, flags, args, functionsDir);
319317
} catch (err) {
320-
console.error(
321-
`${NETLIFYDEV} ${NETLIFYERR} Error downloading from URL: ` + flags.url
322-
);
318+
console.error(`$${NETLIFYERR} Error downloading from URL: ` + flags.url);
323319
console.error(err);
324320
process.exit(1);
325321
}
@@ -440,10 +436,7 @@ async function installAddons(addons = [], fnPath) {
440436
}
441437
})
442438
.catch(err => {
443-
console.error(
444-
`${NETLIFYDEV} ${NETLIFYERR} Error installing addon: `,
445-
err
446-
);
439+
console.error(`${NETLIFYERR} Error installing addon: `, err);
447440
});
448441
});
449442
return Promise.all(arr);

src/commands/functions/serve.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const { Command, flags } = require("@oclif/command");
2-
const chalk = require("chalk");
3-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
2+
const { NETLIFYDEV, NETLIFYDEVWARN, NETLIFYDEVERR } = require("../../cli-logo");
43

54
class FunctionsServeCommand extends Command {
65
async run() {

src/commands/functions/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { Command, flags } = require("@oclif/command");
22
const chalk = require("chalk");
3-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
3+
const { NETLIFYDEV, NETLIFYDEVWARN, NETLIFYDEVERR } = require("../../cli-logo");
44

55
class FunctionsUpdateCommand extends Command {
66
async run() {

src/detect-server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require("path");
22
const chalk = require("chalk");
3-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
3+
const { NETLIFYDEV, NETLIFYDEVWARN, NETLIFYDEVERR } = require("./cli-logo");
44
const inquirer = require("inquirer");
55
const fs = require("fs");
66
const detectors = fs
@@ -104,7 +104,7 @@ module.exports.serverSettings = async devConfig => {
104104
const regexp =
105105
devConfig.urlRegexp ||
106106
new RegExp(`(http://)([^:]+:)${devConfig.port}(/)?`, "g");
107-
settings.urlRegexp = assignLoudly(settings.urlRegexp);
107+
settings.urlRegexp = assignLoudly(settings.urlRegexp, regexp);
108108
}
109109
settings.dist = assignLoudly(devConfig.publish, settings.dist);
110110
}

src/functions-templates/js/stripe-charge/.netlify-function-template.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
const chalk = require("chalk");
2-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
32

43
module.exports = {
54
name: "stripe-charge",
65
description: "Stripe Charge: Charge a user with Stripe",
76
async onComplete() {
87
console.log(
9-
`${NETLIFYDEV} ${chalk.yellow(
10-
"stripe-charge"
11-
)} function created from template!`
8+
`${chalk.yellow("stripe-charge")} function created from template!`
129
);
1310
if (!process.env.STRIPE_SECRET_KEY) {
1411
console.log(
15-
`${NETLIFYDEV} note this function requires ${chalk.yellow(
12+
`note this function requires ${chalk.yellow(
1613
"STRIPE_SECRET_KEY"
1714
)} build environment variable set in your Netlify Site.`
1815
);
@@ -25,7 +22,7 @@ module.exports = {
2522
// silent error, not important
2623
}
2724
console.log(
28-
`${NETLIFYDEV} Set it at: https://app.netlify.com/sites/${
25+
`Set it at: https://app.netlify.com/sites/${
2926
siteData.name
3027
}/settings/deploys#build-environment-variables (must have CD setup)`
3128
);

src/functions-templates/js/token-hider/.netlify-function-template.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
const chalk = require("chalk");
2-
const NETLIFYDEV = `[${chalk.cyan("Netlify Dev")}]`;
32

43
module.exports = {
54
name: "token-hider",
65
description: "Token Hider: access APIs without exposing your API keys",
76
async onComplete() {
87
console.log(
9-
`${NETLIFYDEV} ${chalk.yellow(
10-
"token-hider"
11-
)} function created from template!`
8+
`${chalk.yellow("token-hider")} function created from template!`
129
);
1310
if (!process.env.API_URL || !process.env.API_TOKEN) {
1411
console.log(
15-
`${NETLIFYDEV} note this function requires ${chalk.yellow(
12+
`note this function requires ${chalk.yellow(
1613
"API_URL"
1714
)} and ${chalk.yellow(
1815
"API_TOKEN"
@@ -28,7 +25,7 @@ module.exports = {
2825
// silent error, not important
2926
}
3027
console.log(
31-
`${NETLIFYDEV} Set them at: https://app.netlify.com/sites/${
28+
`Set them at: https://app.netlify.com/sites/${
3229
siteData.name
3330
}/settings/deploys#build-environment-variables (must have CD setup)`
3431
);

0 commit comments

Comments
 (0)