Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Commit

Permalink
Merge 451102a into a15667b
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-roemer committed Nov 7, 2019
2 parents a15667b + 451102a commit 44e31d9
Show file tree
Hide file tree
Showing 33 changed files with 2,840 additions and 2,155 deletions.
6 changes: 5 additions & 1 deletion .eslintrc-server
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
extends:
- "defaults/configurations/walmart/es5-node"
- formidable/configurations/es6-node

rules:
# TODO: Update callbacks to promises.
consistent-return: ["warn", { treatUndefinedAsUnspecified: true }]
12 changes: 8 additions & 4 deletions .eslintrc-server-test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
extends:
- "defaults/configurations/walmart/es5-node"
- formidable/configurations/es6-node

env:
mocha: true
Expand All @@ -9,6 +9,10 @@ globals:
expect: false

rules:
no-unused-expressions: 0 # Disable for Chai expression assertions.
max-nested-callbacks: 0 # Disable for nested describes.
max-statements: [2, 20] # More statements allowed in tests.
no-unused-expressions: off # Disable for Chai expression assertions.
max-nested-callbacks: off # Disable for nested describes.
max-statements: ["error", 20] # More statements allowed in tests.
no-magic-numbers: off
# TODO: Update callbacks to promises.
consistent-return: ["warn", { treatUndefinedAsUnspecified: true }]
camelcase: ["error", { properties: "never" }]
13 changes: 4 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: node_js

node_js:
- "4"
- "6"
- "8"
- "10"
- "12"

# Use container-based Travis infrastructure.
sudo: false
Expand All @@ -12,14 +12,9 @@ branches:
only:
- master

before_install:
# GUI for real browsers.
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

script:
- npm --version
- npm run builder:check-ci
- yarn --version
- yarn run builder:check-ci

# Manually send coverage reports to coveralls.
# - Aggregate client results
Expand Down
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
History
=======

## UNRELEASED

**BREAKING**:

* Restrict to `node` version `8+`.
* Some modest ESnext refactoring.

## 4.0.0

**BREAKING**:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2018 Formidable Labs
Copyright (c) 2015-2019 Formidable Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 7 additions & 12 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
# Versions
environment:
matrix:
- nodejs_version: 4
TEST_NPM_VERSION: latest

- nodejs_version: 6
TEST_NPM_VERSION: latest

- nodejs_version: 8
TEST_NPM_VERSION: latest
- nodejs_version: 10
- nodejs_version: 12

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# Install and use local, modern NPM
- ps: npm install -g "npm@$env:TEST_NPM_VERSION"
# Install modern yarn.
- npm install -g yarn
# install modules
- npm install
- yarn install

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
- yarn --version
# run tests
- npm run builder:check
- yarn run builder:check

# Don't actually build.
build: off
Expand Down
40 changes: 20 additions & 20 deletions bin/builder-core.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";

var chalk = require("chalk");
const chalk = require("chalk");

var Config = require("../lib/config");
var Environment = require("../lib/environment");
var Task = require("../lib/task");
var log = require("../lib/log");
const Config = require("../lib/config");
const Environment = require("../lib/environment");
const Task = require("../lib/task");
const log = require("../lib/log");

/**
* Builder runner.
Expand All @@ -18,48 +18,48 @@ var log = require("../lib/log");
* @returns {void}
*/
module.exports = function (opts, callback) {
callback = arguments.length === 2 ? callback : opts;
opts = (arguments.length === 2 ? opts : {}) || {};
callback = arguments.length === 2 ? callback : opts; // eslint-disable-line no-magic-numbers
opts = (arguments.length === 2 ? opts : {}) || {}; // eslint-disable-line no-magic-numbers

// Configuration
var config = new Config({
const config = new Config({
env: opts.env,
argv: opts.argv
});

// Set up environment
var env = new Environment({
config: config,
const env = new Environment({
config,
env: opts.env,
argv: opts.argv
});

// Set up logger state.
log.setLevel({
env: env,
env,
argv: opts.argv
});

// Drain outer `builder` messages manually (may be global or locally-sourced).
(opts.msgs || []).forEach(function (obj) {
(opts.msgs || []).forEach((obj) => {
log[obj.level](obj.type, obj.msg);
});

// Infer task to run
var task = new Task({
config: config,
env: env,
const task = new Task({
config,
env,
argv: opts.argv
});

// Run the task
log.info("builder-core:start:" + process.pid, "Started: " + chalk.gray(task));
task.execute(function (err) {
log.info(`builder-core:start:${process.pid}`, `Started: ${chalk.gray(task)}`);
task.execute((err) => {
if (err) {
log.error("builder-core:end:" + process.pid,
"Task: " + chalk.gray(task) + ", Error: " + chalk.red(err.message));
log.error(`builder-core:end:${process.pid}`,
`Task: ${chalk.gray(task)}, Error: ${chalk.red(err.message)}`);
} else {
log.info("builder-core:end:" + process.pid, "Task: " + chalk.gray(task) + " ended normally");
log.info(`builder-core:end:${process.pid}`, `Task: ${chalk.gray(task)} ended normally`);
}

callback(err);
Expand Down
34 changes: 19 additions & 15 deletions bin/builder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node

"use strict";

var path = require("path");
const path = require("path");

// Buffer up log messages to pass on.
//
Expand All @@ -12,39 +13,42 @@ var path = require("path");
// events here. So, instead of using the internal log queue, we manually create
// an array of messages in the same format and drain in `builder-core`
// explicitly.
var msgs = [];
const msgs = [];

// Infer if we are global and there is a local version available.
var builderPath = require.resolve("./builder-core");
var localPath = path.resolve("node_modules/builder/bin/builder-core.js");
let builderPath = require.resolve("./builder-core");
const localPath = path.resolve("node_modules/builder/bin/builder-core.js");

// Swap to local path if different.
if (builderPath !== localPath) {
try {
builderPath = require.resolve(localPath);
msgs.push({
level: "info", type: "local-detect",
msg: "Switched to local builder at: " + localPath
level: "info",
type: "local-detect",
msg: `Switched to local builder at: ${localPath}`
});
} catch (err) {
msgs.push({
level: "info", type: "local-detect",
msg: "Error importing local builder: " + err.message
level: "info",
type: "local-detect",
msg: `Error importing local builder: ${err.message}`
});
msgs.push({
level: "info", type: "local-detect",
msg: "Using global builder at: " + builderPath
level: "info",
type: "local-detect",
msg: `Using global builder at: ${builderPath}`
});
}
}

// Import and run.
var builder = require(builderPath);
const builder = require(builderPath);
builder({
msgs: msgs
}, function (err) {
process.on("exit", function () {
/*eslint-disable no-process-exit*/
msgs
}, (err) => {
process.on("exit", () => {
/* eslint-disable no-process-exit*/
process.exit(err ? err.code || 1 : 0);
});
});

0 comments on commit 44e31d9

Please sign in to comment.