From d7083ce88f6caa099517aefb5003dfd07ce7ae79 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 9 Oct 2017 08:11:06 -0400 Subject: [PATCH 01/15] Create utils.py --- compressor_toolkit/utils.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 compressor_toolkit/utils.py diff --git a/compressor_toolkit/utils.py b/compressor_toolkit/utils.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/compressor_toolkit/utils.py @@ -0,0 +1 @@ + From cea74e3b5b2286655a0c3b25de089c182e880a0d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 9 Oct 2017 08:13:50 -0400 Subject: [PATCH 02/15] Update utils.py --- compressor_toolkit/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compressor_toolkit/utils.py b/compressor_toolkit/utils.py index 8b13789..62166d0 100644 --- a/compressor_toolkit/utils.py +++ b/compressor_toolkit/utils.py @@ -1 +1,7 @@ +import os + + +def join_path(*paths): + """Return a path using os specific path seperator.""" + return os.path.join(*paths) From 8411f789d0d0431e5567697017065b5e53d1e788 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 9 Oct 2017 08:40:29 -0400 Subject: [PATCH 03/15] Updated app.py using os.path module Fixed using posixpath defaults --- compressor_toolkit/apps.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index 509fbf0..e7f9bf1 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -2,7 +2,7 @@ from django.apps.config import AppConfig from django.conf import settings - +from .utils import join_path class CompressorToolkitConfig(AppConfig): name = 'compressor_toolkit' @@ -20,14 +20,14 @@ class CompressorToolkitConfig(AppConfig): NODE_SASS_BIN = getattr( settings, 'COMPRESS_NODE_SASS_BIN', - 'node_modules/.bin/node-sass' if LOCAL_NPM_INSTALL else 'node-sass' + join_path('node_modules', '.bin', 'node-sass') if LOCAL_NPM_INSTALL else 'node-sass' ) # postcss executable POSTCSS_BIN = getattr( settings, 'COMPRESS_POSTCSS_BIN', - 'node_modules/.bin/postcss' if LOCAL_NPM_INSTALL else 'postcss' + join_path('node_modules', '.bin', 'postcss') if LOCAL_NPM_INSTALL else 'postcss' ) # Browser versions config for Autoprefixer @@ -44,12 +44,24 @@ class CompressorToolkitConfig(AppConfig): BROWSERIFY_BIN = getattr( settings, 'COMPRESS_BROWSERIFY_BIN', - 'node_modules/.bin/browserify' if LOCAL_NPM_INSTALL else 'browserify' + join_path('node_modules', '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) - + + BABELIFY_BIN = getattr( + settings, + 'COMPRESS_BABELIFY_BIN', + join_path('node_modules', '.bin', 'babelify') if LOCAL_NPM_INSTALL else 'babelify' + ) + + BABEL_PRESET_ES2015_BIN = getattr( + settings, + 'COMPRESS_BABEL_PRESET_2015_BIN', + join_path(NODE_MODULES, 'babel-preset-es2015') + ) + # Custom ES6 transpiler command ES6_COMPILER_CMD = getattr(settings, 'COMPRESS_ES6_COMPILER_CMD', ( 'export NODE_PATH="{paths}" && ' '{browserify_bin} "{infile}" -o "{outfile}" ' - '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]' + '-t [ "%s" --presets="%s" ]' % (BABELIFY_BIN, BABEL_PRESET_ES2015_BIN) )) From beee6efb04dabaecc63f1d9fdc39c20457764678 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 9 Oct 2017 08:41:48 -0400 Subject: [PATCH 04/15] Delete utils.py --- compressor_toolkit/utils.py | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 compressor_toolkit/utils.py diff --git a/compressor_toolkit/utils.py b/compressor_toolkit/utils.py deleted file mode 100644 index 62166d0..0000000 --- a/compressor_toolkit/utils.py +++ /dev/null @@ -1,7 +0,0 @@ - -import os - - -def join_path(*paths): - """Return a path using os specific path seperator.""" - return os.path.join(*paths) From 2c8f85bfc9388ef70525ac182e6c3df9423793c3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 9 Oct 2017 08:52:28 -0400 Subject: [PATCH 05/15] Modified app.py Changed string substitution to using dictionary. --- compressor_toolkit/apps.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index e7f9bf1..7b1b8e0 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -20,14 +20,14 @@ class CompressorToolkitConfig(AppConfig): NODE_SASS_BIN = getattr( settings, 'COMPRESS_NODE_SASS_BIN', - join_path('node_modules', '.bin', 'node-sass') if LOCAL_NPM_INSTALL else 'node-sass' + os.path.join('node_modules', '.bin', 'node-sass') if LOCAL_NPM_INSTALL else 'node-sass' ) # postcss executable POSTCSS_BIN = getattr( settings, 'COMPRESS_POSTCSS_BIN', - join_path('node_modules', '.bin', 'postcss') if LOCAL_NPM_INSTALL else 'postcss' + os.path.join('node_modules', '.bin', 'postcss') if LOCAL_NPM_INSTALL else 'postcss' ) # Browser versions config for Autoprefixer @@ -36,32 +36,34 @@ class CompressorToolkitConfig(AppConfig): # Custom SCSS transpiler command SCSS_COMPILER_CMD = getattr(settings, 'COMPRESS_SCSS_COMPILER_CMD', ( '{node_sass_bin} --output-style expanded {paths} "{infile}" > "{outfile}" && ' - '{postcss_bin} --use "{node_modules}/autoprefixer" ' - '--autoprefixer.browsers "{autoprefixer_browsers}" -r "{outfile}"' + '{postcss_bin} --use "%(autoprefixer)s" ' + '--autoprefixer.browsers "{autoprefixer_browsers}" -r "{outfile}"' % + {'autoprefixer': os.path.join(NODE_MODULES, 'autoprefixer')} )) # browserify executable BROWSERIFY_BIN = getattr( settings, 'COMPRESS_BROWSERIFY_BIN', - join_path('node_modules', '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' + os.path.join('node_modules', '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) BABELIFY_BIN = getattr( settings, 'COMPRESS_BABELIFY_BIN', - join_path('node_modules', '.bin', 'babelify') if LOCAL_NPM_INSTALL else 'babelify' + os.path.join('node_modules', '.bin', 'babelify') if LOCAL_NPM_INSTALL else 'babelify' ) BABEL_PRESET_ES2015_BIN = getattr( settings, 'COMPRESS_BABEL_PRESET_2015_BIN', - join_path(NODE_MODULES, 'babel-preset-es2015') + os.path.join(NODE_MODULES, 'babel-preset-es2015') ) # Custom ES6 transpiler command ES6_COMPILER_CMD = getattr(settings, 'COMPRESS_ES6_COMPILER_CMD', ( 'export NODE_PATH="{paths}" && ' '{browserify_bin} "{infile}" -o "{outfile}" ' - '-t [ "%s" --presets="%s" ]' % (BABELIFY_BIN, BABEL_PRESET_ES2015_BIN) + '-t [ "%(babelify)s" --presets="%(babel_preset)s" ]' % + {'babelify': BABELIFY_BIN, 'babel_preset': BABEL_PRESET_ES2015_BIN} )) From 8835350da0a7daeadb28bc7ce98f6edc70d97e34 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 9 Oct 2017 08:57:53 -0400 Subject: [PATCH 06/15] Update apps.py --- compressor_toolkit/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index 7b1b8e0..af91566 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -57,7 +57,7 @@ class CompressorToolkitConfig(AppConfig): BABEL_PRESET_ES2015_BIN = getattr( settings, 'COMPRESS_BABEL_PRESET_2015_BIN', - os.path.join(NODE_MODULES, 'babel-preset-es2015') + os.path.join(NODE_MODULES, '.bin', 'babel-preset-es2015') ) # Custom ES6 transpiler command From 07dc61918eec94ef054ec06876ac440eae9ecf9d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 9 Oct 2017 09:03:34 -0400 Subject: [PATCH 07/15] Fix babelify reference --- compressor_toolkit/apps.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index af91566..58276a1 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -48,16 +48,16 @@ class CompressorToolkitConfig(AppConfig): os.path.join('node_modules', '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) - BABELIFY_BIN = getattr( + BABELIFY = getattr( settings, 'COMPRESS_BABELIFY_BIN', - os.path.join('node_modules', '.bin', 'babelify') if LOCAL_NPM_INSTALL else 'babelify' + os.path.join('node_modules', 'babelify') if LOCAL_NPM_INSTALL else 'babelify' ) - BABEL_PRESET_ES2015_BIN = getattr( + BABEL_PRESET_ES2015 = getattr( settings, 'COMPRESS_BABEL_PRESET_2015_BIN', - os.path.join(NODE_MODULES, '.bin', 'babel-preset-es2015') + os.path.join(NODE_MODULES, 'babel-preset-es2015') ) # Custom ES6 transpiler command @@ -65,5 +65,5 @@ class CompressorToolkitConfig(AppConfig): 'export NODE_PATH="{paths}" && ' '{browserify_bin} "{infile}" -o "{outfile}" ' '-t [ "%(babelify)s" --presets="%(babel_preset)s" ]' % - {'babelify': BABELIFY_BIN, 'babel_preset': BABEL_PRESET_ES2015_BIN} + {'babelify': BABELIFY, 'babel_preset': BABEL_PRESET_ES2015} )) From 9658343cb634bd0f72e0b22cb28b5e60f102ddb6 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 10 Oct 2017 08:22:46 -0400 Subject: [PATCH 08/15] Removed from unavailable module --- compressor_toolkit/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index 58276a1..e35fafb 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -2,7 +2,7 @@ from django.apps.config import AppConfig from django.conf import settings -from .utils import join_path + class CompressorToolkitConfig(AppConfig): name = 'compressor_toolkit' From 513a8e5d90e9ea0185052376039ccc4e0b505f60 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 10 Oct 2017 09:08:35 -0400 Subject: [PATCH 09/15] Modified module specification Fixes ES6_COMPILER_CMD --- compressor_toolkit/apps.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index e35fafb..ba5197e 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -48,22 +48,9 @@ class CompressorToolkitConfig(AppConfig): os.path.join('node_modules', '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) - BABELIFY = getattr( - settings, - 'COMPRESS_BABELIFY_BIN', - os.path.join('node_modules', 'babelify') if LOCAL_NPM_INSTALL else 'babelify' - ) - - BABEL_PRESET_ES2015 = getattr( - settings, - 'COMPRESS_BABEL_PRESET_2015_BIN', - os.path.join(NODE_MODULES, 'babel-preset-es2015') - ) - # Custom ES6 transpiler command ES6_COMPILER_CMD = getattr(settings, 'COMPRESS_ES6_COMPILER_CMD', ( 'export NODE_PATH="{paths}" && ' '{browserify_bin} "{infile}" -o "{outfile}" ' - '-t [ "%(babelify)s" --presets="%(babel_preset)s" ]' % - {'babelify': BABELIFY, 'babel_preset': BABEL_PRESET_ES2015} + '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]' )) From a47e4f60d1515e7b0f81b0c432e65fc1033ffe78 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 21 May 2018 09:48:26 -0400 Subject: [PATCH 10/15] Update apps.py --- compressor_toolkit/apps.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index ba5197e..fb76cea 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -13,7 +13,7 @@ class CompressorToolkitConfig(AppConfig): NODE_MODULES = getattr( settings, 'COMPRESS_NODE_MODULES', - os.path.abspath('node_modules') if LOCAL_NPM_INSTALL else '/usr/lib/node_modules' + os.path.abspath('node_modules') if LOCAL_NPM_INSTALL else os.path.join('usr', 'lib', 'node_modules') ) # node-sass executable @@ -52,5 +52,8 @@ class CompressorToolkitConfig(AppConfig): ES6_COMPILER_CMD = getattr(settings, 'COMPRESS_ES6_COMPILER_CMD', ( 'export NODE_PATH="{paths}" && ' '{browserify_bin} "{infile}" -o "{outfile}" ' - '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]' + '-t [ "{}" --presets="{}" ]'.format( + os.path.join(NODE_MODULES, 'babelify'), + os.path.join(NODE_MODULES, 'babel-preset-es2015'), + ) )) From 12591f111e30ac88a7f66666384ab6fb2a7495a5 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 22 May 2018 10:09:53 -0400 Subject: [PATCH 11/15] Fixed path --- compressor_toolkit/apps.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index fb76cea..7ee36e5 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -48,12 +48,12 @@ class CompressorToolkitConfig(AppConfig): os.path.join('node_modules', '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) + BABELIFY_DIR = os.path.join(NODE_MODULES, 'babelify') + PRESET = os.path.join(NODE_MODULES, 'babel-preset-es2015') + # Custom ES6 transpiler command ES6_COMPILER_CMD = getattr(settings, 'COMPRESS_ES6_COMPILER_CMD', ( 'export NODE_PATH="{paths}" && ' '{browserify_bin} "{infile}" -o "{outfile}" ' - '-t [ "{}" --presets="{}" ]'.format( - os.path.join(NODE_MODULES, 'babelify'), - os.path.join(NODE_MODULES, 'babel-preset-es2015'), - ) + '-t [ "' + BABELIFY_DIR + '" --presets="' + PRESET + '" ]' )) From 6e61b7996e73511863fa2c014b54ba29cd41f4ba Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 22 May 2018 10:16:06 -0400 Subject: [PATCH 12/15] Update apps.py --- compressor_toolkit/apps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index 7ee36e5..6964145 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -20,14 +20,14 @@ class CompressorToolkitConfig(AppConfig): NODE_SASS_BIN = getattr( settings, 'COMPRESS_NODE_SASS_BIN', - os.path.join('node_modules', '.bin', 'node-sass') if LOCAL_NPM_INSTALL else 'node-sass' + os.path.join(NODE_MODULES, '.bin', 'node-sass') if LOCAL_NPM_INSTALL else 'node-sass' ) # postcss executable POSTCSS_BIN = getattr( settings, 'COMPRESS_POSTCSS_BIN', - os.path.join('node_modules', '.bin', 'postcss') if LOCAL_NPM_INSTALL else 'postcss' + os.path.join(NODE_MODULES, '.bin', 'postcss') if LOCAL_NPM_INSTALL else 'postcss' ) # Browser versions config for Autoprefixer @@ -45,7 +45,7 @@ class CompressorToolkitConfig(AppConfig): BROWSERIFY_BIN = getattr( settings, 'COMPRESS_BROWSERIFY_BIN', - os.path.join('node_modules', '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' + os.path.join(NODE_MODULES, '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) BABELIFY_DIR = os.path.join(NODE_MODULES, 'babelify') From 9cada41414e9e7aac84096f55d209176c6d6d885 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 22 May 2018 10:22:06 -0400 Subject: [PATCH 13/15] Update apps.py --- compressor_toolkit/apps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index 6964145..52f592a 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -32,13 +32,13 @@ class CompressorToolkitConfig(AppConfig): # Browser versions config for Autoprefixer AUTOPREFIXER_BROWSERS = getattr(settings, 'COMPRESS_AUTOPREFIXER_BROWSERS', 'ie >= 9, > 5%') + AUTOPREFIXER_DIR = os.path.join(NODE_MODULES, 'autoprefixer') # Custom SCSS transpiler command SCSS_COMPILER_CMD = getattr(settings, 'COMPRESS_SCSS_COMPILER_CMD', ( '{node_sass_bin} --output-style expanded {paths} "{infile}" > "{outfile}" && ' - '{postcss_bin} --use "%(autoprefixer)s" ' - '--autoprefixer.browsers "{autoprefixer_browsers}" -r "{outfile}"' % - {'autoprefixer': os.path.join(NODE_MODULES, 'autoprefixer')} + '{postcss_bin} --use "' + AUTOPREFIXER_DIR + '" ' + '--autoprefixer.browsers "{autoprefixer_browsers}" -r "{outfile}"' )) # browserify executable From 2df6e839f2bf6bc880288128ff8ea335fd02dbc3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 22 May 2018 10:32:08 -0400 Subject: [PATCH 14/15] Update apps.py --- compressor_toolkit/apps.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index 52f592a..ef5110b 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -32,12 +32,11 @@ class CompressorToolkitConfig(AppConfig): # Browser versions config for Autoprefixer AUTOPREFIXER_BROWSERS = getattr(settings, 'COMPRESS_AUTOPREFIXER_BROWSERS', 'ie >= 9, > 5%') - AUTOPREFIXER_DIR = os.path.join(NODE_MODULES, 'autoprefixer') # Custom SCSS transpiler command SCSS_COMPILER_CMD = getattr(settings, 'COMPRESS_SCSS_COMPILER_CMD', ( '{node_sass_bin} --output-style expanded {paths} "{infile}" > "{outfile}" && ' - '{postcss_bin} --use "' + AUTOPREFIXER_DIR + '" ' + '{postcss_bin} --use "{node_modules}/autoprefixer" ' '--autoprefixer.browsers "{autoprefixer_browsers}" -r "{outfile}"' )) @@ -48,12 +47,9 @@ class CompressorToolkitConfig(AppConfig): os.path.join(NODE_MODULES, '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) - BABELIFY_DIR = os.path.join(NODE_MODULES, 'babelify') - PRESET = os.path.join(NODE_MODULES, 'babel-preset-es2015') - # Custom ES6 transpiler command ES6_COMPILER_CMD = getattr(settings, 'COMPRESS_ES6_COMPILER_CMD', ( 'export NODE_PATH="{paths}" && ' '{browserify_bin} "{infile}" -o "{outfile}" ' - '-t [ "' + BABELIFY_DIR + '" --presets="' + PRESET + '" ]' + '-t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]' )) From ed79ad7fac3577bb1fe5ea59362e8f930d40b388 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 22 May 2018 10:32:43 -0400 Subject: [PATCH 15/15] Removed extra space --- compressor_toolkit/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compressor_toolkit/apps.py b/compressor_toolkit/apps.py index ef5110b..738ebfa 100644 --- a/compressor_toolkit/apps.py +++ b/compressor_toolkit/apps.py @@ -46,7 +46,7 @@ class CompressorToolkitConfig(AppConfig): 'COMPRESS_BROWSERIFY_BIN', os.path.join(NODE_MODULES, '.bin', 'browserify') if LOCAL_NPM_INSTALL else 'browserify' ) - + # Custom ES6 transpiler command ES6_COMPILER_CMD = getattr(settings, 'COMPRESS_ES6_COMPILER_CMD', ( 'export NODE_PATH="{paths}" && '