Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Upgrade build pipeline and remove n8-make
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Jan 27, 2020
1 parent 94edca1 commit bf23b4a
Show file tree
Hide file tree
Showing 8 changed files with 6,132 additions and 2,571 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
mocha: true,
Expand Down
85 changes: 33 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,66 @@
# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
babel = node_modules/.bin/babel
webpack = node_modules/.bin/webpack
eslint = node_modules/.bin/eslint
mocha = node_modules/.bin/mocha

ROOT := lib/ index.js
include $(shell node -e "require('n8-make')")
# Source files root directory
ROOT := lib index.js

# BIN directory
BIN := $(THIS_DIR)/node_modules/.bin
# The directory to place the compiled .js and .json files.
BUILDDIR = build

# Testing WEB APP port
TESTAPP_DIR := webapp/tests
TESTAPP_PORT := 3001
SOURCE_FILES = $(shell find $(ROOT) -name "*.js")
COMPILED_FILES = $(addprefix $(BUILDDIR)/, $(SOURCE_FILES))

# Files
JS_FILES := $(wildcard index.js lib/*.js test/*.js)
JS_FILES := $(SOURCE_FILES) $(wildcard test/*.js)
JS_TESTING_FILES := $(wildcard test/test*.js test-whitelist/test*.js)

# applications
NODE ?= node
NPM ?= $(NODE) $(shell which npm)
MOCHA ?= $(NODE) $(BIN)/mocha
WEBPACK ?= $(NODE) $(BIN)/webpack
all: build build/wpcom.js

standalone: compile build/wpcom.js
build: $(COMPILED_FILES)

compile:
make build --jobs=8
$(BUILDDIR)/%.js: %.js
@mkdir -p $(dir $@)
@echo JS source file: "$<""$@"
@$(babel) "$<" --source-maps --out-file "$@"

build/wpcom.js:
@$(WEBPACK) -p --config ./webpack.config.js
build/wpcom.js: build
@$(webpack) --config ./webpack.config.js

install: node_modules

node_modules:
@NODE_ENV= $(NPM) install
@npm install
@touch node_modules

lint: node_modules/eslint node_modules/babel-eslint
@$(BIN)/eslint $(JS_FILES)
lint:
@$(eslint) $(JS_FILES)

eslint: lint

test:
@$(MOCHA) \
@$(mocha) \
--timeout 120s \
--slow 3s \
--grep "$(FILTER)" \
--bail \
--reporter spec \
--compilers js:babel-register \
--require @babel/register \
test/

test-watch:
@$(MOCHA) \
@$(mocha) \
--timeout 120s \
--slow 3s \
--bail \
--reporter spec \
--compilers js:babel-register \
--require @babel/register \
--watch \
--grep "$(FILTER)" \
test/

webapp:
@$(WEBPACK) -p --config webapp/webpack.config.js

media-editor:
@$(WEBPACK) -p --config examples/media-editor/webpack.config.js

deploy: webapp media-editor
mkdir -p tmp/
rm -rf tmp/*
mkdir -p tmp/tests
mkdir -p tmp/media-editor
cp webapp/index.html tmp/
cp webapp/style.css tmp/
cp webapp/webapp-bundle.js tmp/
cp examples/media-editor/index.html tmp/media-editor
cp examples/media-editor/app.css tmp/media-editor
cp -rf examples/media-editor/built/ tmp/media-editor/built
git checkout gh-pages
cp -rf tmp/* .

.PHONY: standalone test test-all node_modules lint eslint webapp compile
clean:
@rm -rfv $(BUILDDIR)

distclean:
@rm -rfv node_modules

.PHONY: all test test-watch node_modules lint eslint clean distclean
13 changes: 13 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
'@babel/env',
{
useBuiltIns: 'usage',
corejs: 2,
exclude: [ 'transform-typeof-symbol' ],
},
],
],
plugins: [ '@babel/transform-runtime' ],
};

0 comments on commit bf23b4a

Please sign in to comment.