From 34080c56ff59f27cdc29ffce969e8d2ce5edcdf2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 19 Mar 2018 14:15:38 -0400 Subject: Use requirejs to load JS modules; use yarn to get requirejs --- .editorconfig | 12 ++++++++++++ INSTALL.sh | 3 +++ Makefile | 8 +++++++- bin-src/yarn-bower | 3 +++ public-src/3rd-party/.gitignore | 2 ++ public-src/3rd-party/package.json | 5 +++++ public-src/3rd-party/yarn.lock | 7 +++++++ public-src/index.html.gen | 26 +++++++++----------------- public-src/main.js | 5 +++++ public-src/require.config.js | 39 +++++++++++++++++++++++++++++++++++++++ 10 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 .editorconfig create mode 100755 bin-src/yarn-bower create mode 100644 public-src/3rd-party/.gitignore create mode 100644 public-src/3rd-party/package.json create mode 100644 public-src/3rd-party/yarn.lock create mode 100644 public-src/main.js create mode 100644 public-src/require.config.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..71581bf --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +indent_style = tab + +[package.json] +# This matches what `yarn` writes +indent_style = space +indent_size = 2 diff --git a/INSTALL.sh b/INSTALL.sh index a7043af..7f9d478 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -14,3 +14,6 @@ gem install nokogiri -- --use-system-libraries sudo pacman -S --needed -- ruby-sass #sudo pacman -S --needed -- ruby #gem install sass + +# Yarn +sudo pacman -S --needed -- yarn diff --git a/Makefile b/Makefile index b16d2ed..f723132 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,10 @@ -srcs = $(shell find public-src -not -type d) +srcs = $(shell find public-src -name 3rd-party -prune -o -not -type d -not -name '*.log' -print) outs = $(patsubst public-src/%,public/%,\ $(patsubst %.scss,%.css,\ $(patsubst %.gen,%,\ $(srcs)))) all: $(outs) +all: public/3rd-party .PHONY: all NET-%: @@ -56,6 +57,11 @@ public-src/jarmon-depenencies: jarmon/docs/examples/assets/js/dependencies.js jarmon/docs/examples/assets/js/dependencies.js: FORCE $(MAKE) -C jarmon docs/examples/assets/js/dependencies.js +public-src/3rd-party/yarn.LICENSES.txt: bin/yarn-bower public-src/3rd-party/package.json $(wildcard public-src/3rd-party/yarn.lock) + bin/yarn-bower install + bin/yarn-bower licenses generate-disclaimer > $@ +public/3rd-party: public-src/3rd-party/yarn.LICENSES.txt + jquery-ver=1.6.3 flot-ver=0.8.3 jsrrd-ver=1.1.1 diff --git a/bin-src/yarn-bower b/bin-src/yarn-bower new file mode 100755 index 0000000..d6210fb --- /dev/null +++ b/bin-src/yarn-bower @@ -0,0 +1,3 @@ +#!/bin/sh +cd "$(dirname -- "$(readlink -f -- "$0")")/../public-src/3rd-party" || exit +yarn --flat --no-bin-links --modules-folder yarn "$@" diff --git a/public-src/3rd-party/.gitignore b/public-src/3rd-party/.gitignore new file mode 100644 index 0000000..33c63bb --- /dev/null +++ b/public-src/3rd-party/.gitignore @@ -0,0 +1,2 @@ +/yarn/ +/yarn.LICENSES.txt diff --git a/public-src/3rd-party/package.json b/public-src/3rd-party/package.json new file mode 100644 index 0000000..d3ea028 --- /dev/null +++ b/public-src/3rd-party/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "requirejs": "^2.3.5" + } +} diff --git a/public-src/3rd-party/yarn.lock b/public-src/3rd-party/yarn.lock new file mode 100644 index 0000000..96c4650 --- /dev/null +++ b/public-src/3rd-party/yarn.lock @@ -0,0 +1,7 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +requirejs@^2.3.5: + version "2.3.5" + resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.5.tgz#617b9acbbcb336540ef4914d790323a8d4b861b0" diff --git a/public-src/index.html.gen b/public-src/index.html.gen index be6c6d8..dfb2e34 100755 --- a/public-src/index.html.gen +++ b/public-src/index.html.gen @@ -13,27 +13,19 @@ echo ' Dashboard - + + - - - - - - - - - - - - - + + + - - - + + + + ' col sed 's/@name@/proton/' jarmon.html.in diff --git a/public-src/main.js b/public-src/main.js new file mode 100644 index 0000000..ebb09a9 --- /dev/null +++ b/public-src/main.js @@ -0,0 +1,5 @@ +define([ + //'jquerytools/dateinput', + 'cfg/jarmon-winston', + 'cfg/jarmon-proton', +], {}); diff --git a/public-src/require.config.js b/public-src/require.config.js new file mode 100644 index 0000000..bb48fd7 --- /dev/null +++ b/public-src/require.config.js @@ -0,0 +1,39 @@ +var require = { + baseUrl: "/", + shim: { + "jarmon": { + deps: [ + "javascriptrrd/rrdFile", // ~1.1 + "javascriptrrd/binaryXHR", // ~1.1 + "jquery", // ^1.6.3 + "flot/jquery.flot.stack", // >= 0.7 + "flot/jquery.flot.time", // split in to a plugin in >=0.8.0 + "flot/jquery.flot.selection", // split in to a plugin in >= 0.6 + "jquerytools/tabs", + "jquerytools/toolbox.history", + ], + exports: "jarmon" + }, + // jQuery plugins + "jquerytools/tabs" : { deps: ["jquery"], exports: "jQuery.tools.tabs" }, + "jquerytools/toolbox.history" : { deps: ["jquery"], exports: "jQuery.tools.history" }, + "flot/jquery.flot" : { deps: ["jquery"], exports: "jQuery.plot" }, + // Flot plugins + "flot/jquery.flot.time" : { deps: ["flot/jquery.flot"] }, + "flot/jquery.flot.selection" : { deps: ["flot/jquery.flot"] }, + "flot/jquery.flot.stack" : { deps: ["flot/jquery.flot"] }, + // Jarmon configs + "cfg/jarmon-winston": { deps: ["jquery", "jarmon"] }, + "cfg/jarmon-proton": { deps: ["jquery", "jarmon"] }, + }, + paths: { + //"jquery" : "3rd-party/yarn/jquery/dist/jquery", + //"flot" : "3rd-party/yarn/flot", + "requirejs" : "3rd-party/yarn/requirejs/require", + + "flot" : "jarmon-dependencies/flot-0.8.3", + "javascriptrrd" : "jarmon-dependencies/javascriptrrd-1.1.1", + "jquery" : "jarmon-dependencies/jquery-1.6.3", + "jquerytools" : "jarmon-dependencies/jquerytools-8ac4636a01d3860f1c4726ba722190a531bf1068", + }, +}; -- cgit v1.1-4-g5e80