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

make npm run test script actually work - fix all eslint issues #125

Merged
merged 2 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/functions-templates
10 changes: 9 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"extends": ["oclif", "plugin:prettier/recommended"],
"rules": {
"prettier/prettier": "error"
"no-warning-comments": "off",
"prettier/prettier": "error",
"no-process-exit": "off",
"unicorn/no-process-exit": "off",
"camelcase": "off",
"guard-for-in": "off",
"valid-jsdoc": "off",
"no-inner-declarations": "off",
"no-missing-require": "off"
}
}
77 changes: 68 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"chalk": "^2.4.2",
"chokidar": "^2.1.5",
"copy-template-dir": "^1.4.0",
"debug": "^4.1.1",
"npm-packlist": "^1.4.1",
"precinct": "^6.1.2",
"read-pkg-up": "^5.0.0",
"require-package-name": "^2.0.1",
"execa": "^1.0.0",
"express": "^4.16.4",
"express-logging": "^1.1.1",
Expand All @@ -30,7 +35,7 @@
"netlify-cli-logo": "^1.0.0",
"node-fetch": "^2.3.0",
"ora": "^3.4.0",
"querystring": "^0.2.0",
"resolve": "^1.10.0",
"safe-join": "^0.1.2",
"static-server": "^2.2.1",
"wait-port": "^0.2.2",
Expand All @@ -50,6 +55,7 @@
"gh-release": "^3.5.0",
"globby": "^8",
"mocha": "^5",
"nock": "^10.0.6",
"npm-run-all": "^4.1.5",
"nyc": "^13",
"prettier": "^1.16.4"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/dev/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const execa = require("execa");
const Command = require("@netlify/cli-utils");
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
const {
NETLIFYDEV,
// NETLIFYDEV,
NETLIFYDEVLOG,
NETLIFYDEVWARN,
// NETLIFYDEVWARN,
NETLIFYDEVERR
} = require("netlify-cli-logo");

Expand Down
29 changes: 12 additions & 17 deletions src/commands/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ const httpProxy = require("http-proxy");
const waitPort = require("wait-port");
const getPort = require("get-port");
const chokidar = require("chokidar");
const { serveFunctions } = require("../../utils/serveFunctions");
const { serveFunctions } = require("../../utils/serve-functions");
const { serverSettings } = require("../../detect-server");
const { detectFunctionsBuilder } = require("../../detect-functions-builder");
const Command = require("@netlify/cli-utils");
const { getAddons } = require("netlify/src/addons");
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
const chalk = require("chalk");
const {
NETLIFYDEV,
NETLIFYDEVLOG,
NETLIFYDEVWARN,
NETLIFYDEVERR
NETLIFYDEVWARN
// NETLIFYDEVERR
} = require("netlify-cli-logo");
const boxen = require("boxen");
const { createTunnel, connectTunnel } = require("../../live-tunnel");
Expand All @@ -26,7 +25,7 @@ function isFunction(settings, req) {
}

function addonUrl(addonUrls, req) {
const m = req.url.match(/^\/.netlify\/([^\/]+)(\/.*)/);
const m = req.url.match(/^\/.netlify\/([^\/]+)(\/.*)/); // eslint-disable-line no-useless-escape
const addonUrl = m && addonUrls[m[1]];
return addonUrl ? `${addonUrl}${m[2]}` : null;
}
Expand Down Expand Up @@ -67,7 +66,7 @@ function initializeProxy(port) {
if (
proxyRes.statusCode === 404 &&
req.alternativePaths &&
req.alternativePaths.length
req.alternativePaths.length > 0
) {
req.url = req.alternativePaths.shift();
return proxy.web(req, res, req.proxyOptions);
Expand Down Expand Up @@ -137,7 +136,7 @@ async function startProxy(settings, addonUrls) {
return `http://localhost:${port}`;
}

function startDevServer(settings, log, error) {
function startDevServer(settings, log) {
if (settings.noCmd) {
const StaticServer = require("static-server");

Expand Down Expand Up @@ -195,7 +194,7 @@ class DevCommand extends Command {
(config.dev && config.dev.publish) ||
(config.build && config.build.publish);
if (!dist) {
console.log(`${NETLIFYDEVLOG} Using current working directory`);
this.log(`${NETLIFYDEVLOG} Using current working directory`);
this.log(
`${NETLIFYDEVWARN} Unable to determine public folder to serve files from.`
);
Expand All @@ -220,7 +219,7 @@ class DevCommand extends Command {

let url;

startDevServer(settings, this.log, this.error);
startDevServer(settings, this.log);

// serve functions from zip-it-and-ship-it
// env variables relies on `url`, careful moving this code
Expand All @@ -234,7 +233,9 @@ class DevCommand extends Command {
functionWatcher.on("unlink", functionBuilder.build);
}
const functionsPort = await getPort({ port: 34567 });
const fnSettings = await serveFunctions({

// returns a value but we dont use it
await serveFunctions({
...settings,
port: functionsPort,
functionsDir
Expand All @@ -253,13 +254,7 @@ class DevCommand extends Command {
url = liveSession.session_url;
process.env.BASE_URL = url;

await connectTunnel(
liveSession,
accessToken,
settings.port,
this.log,
this.error
);
await connectTunnel(liveSession, accessToken, settings.port, this.log);
}

// Todo hoist this telemetry `command` to CLI hook
Expand Down
6 changes: 3 additions & 3 deletions src/commands/functions/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const { flags } = require("@oclif/command");
const Command = require("@netlify/cli-utils");
const { zipFunctions } = require("@netlify/zip-it-and-ship-it");
const {
NETLIFYDEV,
// NETLIFYDEV,
NETLIFYDEVLOG,
NETLIFYDEVWARN,
// NETLIFYDEVWARN,
NETLIFYDEVERR
} = require("netlify-cli-logo");

class FunctionsBuildCommand extends Command {
async run() {
const { flags, args } = this.parse(FunctionsBuildCommand);
const { flags } = this.parse(FunctionsBuildCommand);
const { config } = this.netlify;

const src = flags.src || config.build.functionsSource;
Expand Down
Loading