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

Commit 3ed5438

Browse files
author
sw-yx
committed
make tests actually work
1 parent a28403f commit 3ed5438

34 files changed

+451
-430
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/functions-templates

.eslintrc

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
22
"extends": ["oclif", "plugin:prettier/recommended"],
33
"rules": {
4-
"prettier/prettier": "error"
4+
"no-warning-comments": "off",
5+
"prettier/prettier": "error",
6+
"no-process-exit": "off",
7+
"unicorn/no-process-exit": "off",
8+
"camelcase": "off",
9+
"guard-for-in": "off",
10+
"valid-jsdoc": "off",
11+
"no-inner-declarations": "off",
12+
"no-missing-require": "off"
513
}
614
}

package-lock.json

+68-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
"chalk": "^2.4.2",
1717
"chokidar": "^2.1.5",
1818
"copy-template-dir": "^1.4.0",
19+
"debug": "^4.1.1",
20+
"npm-packlist": "^1.4.1",
21+
"precinct": "^6.1.2",
22+
"read-pkg-up": "^5.0.0",
23+
"require-package-name": "^2.0.1",
1924
"execa": "^1.0.0",
2025
"express": "^4.16.4",
2126
"express-logging": "^1.1.1",
@@ -30,7 +35,7 @@
3035
"netlify-cli-logo": "^1.0.0",
3136
"node-fetch": "^2.3.0",
3237
"ora": "^3.4.0",
33-
"querystring": "^0.2.0",
38+
"resolve": "^1.10.0",
3439
"safe-join": "^0.1.2",
3540
"static-server": "^2.2.1",
3641
"wait-port": "^0.2.2",
@@ -50,6 +55,7 @@
5055
"gh-release": "^3.5.0",
5156
"globby": "^8",
5257
"mocha": "^5",
58+
"nock": "^10.0.6",
5359
"npm-run-all": "^4.1.5",
5460
"nyc": "^13",
5561
"prettier": "^1.16.4"

src/commands/dev/exec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const execa = require("execa");
22
const Command = require("@netlify/cli-utils");
33
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
44
const {
5-
NETLIFYDEV,
5+
// NETLIFYDEV,
66
NETLIFYDEVLOG,
7-
NETLIFYDEVWARN,
7+
// NETLIFYDEVWARN,
88
NETLIFYDEVERR
99
} = require("netlify-cli-logo");
1010

src/commands/dev/index.js

+12-17
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ const httpProxy = require("http-proxy");
55
const waitPort = require("wait-port");
66
const getPort = require("get-port");
77
const chokidar = require("chokidar");
8-
const { serveFunctions } = require("../../utils/serveFunctions");
8+
const { serveFunctions } = require("../../utils/serve-functions");
99
const { serverSettings } = require("../../detect-server");
1010
const { detectFunctionsBuilder } = require("../../detect-functions-builder");
1111
const Command = require("@netlify/cli-utils");
12-
const { getAddons } = require("netlify/src/addons");
1312
const { track } = require("@netlify/cli-utils/src/utils/telemetry");
1413
const chalk = require("chalk");
1514
const {
1615
NETLIFYDEV,
1716
NETLIFYDEVLOG,
18-
NETLIFYDEVWARN,
19-
NETLIFYDEVERR
17+
NETLIFYDEVWARN
18+
// NETLIFYDEVERR
2019
} = require("netlify-cli-logo");
2120
const boxen = require("boxen");
2221
const { createTunnel, connectTunnel } = require("../../live-tunnel");
@@ -26,7 +25,7 @@ function isFunction(settings, req) {
2625
}
2726

2827
function addonUrl(addonUrls, req) {
29-
const m = req.url.match(/^\/.netlify\/([^\/]+)(\/.*)/);
28+
const m = req.url.match(/^\/.netlify\/([^\/]+)(\/.*)/); // eslint-disable-line no-useless-escape
3029
const addonUrl = m && addonUrls[m[1]];
3130
return addonUrl ? `${addonUrl}${m[2]}` : null;
3231
}
@@ -67,7 +66,7 @@ function initializeProxy(port) {
6766
if (
6867
proxyRes.statusCode === 404 &&
6968
req.alternativePaths &&
70-
req.alternativePaths.length
69+
req.alternativePaths.length > 0
7170
) {
7271
req.url = req.alternativePaths.shift();
7372
return proxy.web(req, res, req.proxyOptions);
@@ -137,7 +136,7 @@ async function startProxy(settings, addonUrls) {
137136
return `http://localhost:${port}`;
138137
}
139138

140-
function startDevServer(settings, log, error) {
139+
function startDevServer(settings, log) {
141140
if (settings.noCmd) {
142141
const StaticServer = require("static-server");
143142

@@ -195,7 +194,7 @@ class DevCommand extends Command {
195194
(config.dev && config.dev.publish) ||
196195
(config.build && config.build.publish);
197196
if (!dist) {
198-
console.log(`${NETLIFYDEVLOG} Using current working directory`);
197+
this.log(`${NETLIFYDEVLOG} Using current working directory`);
199198
this.log(
200199
`${NETLIFYDEVWARN} Unable to determine public folder to serve files from.`
201200
);
@@ -220,7 +219,7 @@ class DevCommand extends Command {
220219

221220
let url;
222221

223-
startDevServer(settings, this.log, this.error);
222+
startDevServer(settings, this.log);
224223

225224
// serve functions from zip-it-and-ship-it
226225
// env variables relies on `url`, careful moving this code
@@ -234,7 +233,9 @@ class DevCommand extends Command {
234233
functionWatcher.on("unlink", functionBuilder.build);
235234
}
236235
const functionsPort = await getPort({ port: 34567 });
237-
const fnSettings = await serveFunctions({
236+
237+
// returns a value but we dont use it
238+
await serveFunctions({
238239
...settings,
239240
port: functionsPort,
240241
functionsDir
@@ -253,13 +254,7 @@ class DevCommand extends Command {
253254
url = liveSession.session_url;
254255
process.env.BASE_URL = url;
255256

256-
await connectTunnel(
257-
liveSession,
258-
accessToken,
259-
settings.port,
260-
this.log,
261-
this.error
262-
);
257+
await connectTunnel(liveSession, accessToken, settings.port, this.log);
263258
}
264259

265260
// Todo hoist this telemetry `command` to CLI hook

src/commands/functions/build.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ const { flags } = require("@oclif/command");
33
const Command = require("@netlify/cli-utils");
44
const { zipFunctions } = require("@netlify/zip-it-and-ship-it");
55
const {
6-
NETLIFYDEV,
6+
// NETLIFYDEV,
77
NETLIFYDEVLOG,
8-
NETLIFYDEVWARN,
8+
// NETLIFYDEVWARN,
99
NETLIFYDEVERR
1010
} = require("netlify-cli-logo");
1111

1212
class FunctionsBuildCommand extends Command {
1313
async run() {
14-
const { flags, args } = this.parse(FunctionsBuildCommand);
14+
const { flags } = this.parse(FunctionsBuildCommand);
1515
const { config } = this.netlify;
1616

1717
const src = flags.src || config.build.functionsSource;

0 commit comments

Comments
 (0)