Skip to content

Commit

Permalink
#63 - Updated dependencies. Added a file for the CLI to minify files …
Browse files Browse the repository at this point in the history
…inside a folder.
  • Loading branch information
Chris committed Feb 23, 2021
1 parent 103195c commit aba4199
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/target/
/custom-packages/node_modules
/custom-packages/node
/custom-packages/nbproject/private/
84 changes: 84 additions & 0 deletions custom-packages/minify-folder-cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* global process, Promise */

const ClosureCompiler = require('./node_modules/google-closure-compiler').compiler;

if (process.argv.includes('--debug')) {
console.log(ClosureCompiler.COMPILER_PATH); // absolute path to the compiler jar
console.log(ClosureCompiler.CONTRIB_PATH); // absolute path to the contrib folder which contain externs
}

let lang = '';
const cliArr = [];
const cliRunners = [];

if (process.argv.includes('--lang')) {
lang = process.argv.slice(process.argv.indexOf('--lang') + 1);
} else {
console.log('ERROR: --lang arg needs to be defined. Could be css, js, html or xml');
process.exit(1);
}

if (process.argv.includes('--files')) {
const files = process.argv.slice(process.argv.indexOf('--files') + 1);

if (files.length) {
files[0].split(';').forEach((file) => {
cliArr.push(JSON.parse(file));
});
}
}

console.log('Minification in progress...');

cliArr.forEach((inOut) => {
switch (lang[0]) {
case 'css':
console.log("cssnano");
break;
case 'html':
console.log("html-minifier-terser");
break;
case 'js':
// Existing files.
// --files "{\"in\":\"postcss.config.js\",\"out\":\"postcss.config.min.js\"};{\"in\":\"file2.js\",\"out\":\"file2.min.js\"};{\"in\":\"file2 - Kopie.js\",\"out\":\"file2 - Kopie.min.js\"}"

// Existing files with one not existing file.
// --files "{\"in\":\"postcss.config.js\",\"out\":\"postcss.config.min.js\"};{\"in\":\"file2.js\",\"out\":\"file2.min.js\"};{\"in\":\"file2 - Kopie.js\",\"out\":\"file2 - Kopie.min.js\"};{\"in\":\"filel.js\",\"out\":\"file1.min.js\"}"
cliRunners.push(googleClosureCompiler(inOut));
break;
case 'xml':
console.log("minify-xml");
break;
default:
break;
}
});

Promise.all(cliRunners).then((data) => {
if (data.length) {
console.log(`Minification successful for: ${data}`);
} else {
console.log('Nothing to minify.');
}
}).catch((err) => {
console.log(`Unsuccessful minifcation for ${err.file}: ${err.message}`);
});

function googleClosureCompiler(inOut) {
const closureCompiler = new ClosureCompiler({
js: inOut.in,
compilation_level: 'simple',
js_output_file: inOut.out
});

return new Promise((resolve, reject) => {
return closureCompiler.run((exitCode, stdOut, stdErr) => {
if (stdErr) {
return reject({file: inOut.in, message: stdErr});
}

//compilation complete
return resolve(inOut.in);
});
});
}
11 changes: 6 additions & 5 deletions custom-packages/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "minifierbeans-custom-packages",
"version": "1.3.0",
"version": "1.4.0",
"description": "CLIs to minify JS, CSS, HTML, XML and JSON.",
"devDependencies": {
"cssnano": "^4.1.10",
"google-closure-compiler": "^20201207.0.0",
"google-closure-compiler": "^20210202.0.0",
"html-minifier-terser": "^5.1.1",
"minify-xml": "^2.4.0",
"postcss": "^8.2.1",
"postcss-cli": "^8.3.0"
"minify-xml": "^2.5.0",
"postcss": "^8.2.6",
"postcss-cli": "^8.3.1",
"yargs": "^16.2.0"
}
}
92 changes: 46 additions & 46 deletions custom-packages/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -739,40 +739,40 @@ globby@^11.0.0:
merge2 "^1.3.0"
slash "^3.0.0"

google-closure-compiler-java@^20201207.0.0:
version "20201207.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-java/-/google-closure-compiler-java-20201207.0.0.tgz#5e611dbe443ea537e6b5236164dcd44a59cd4d4d"
integrity sha512-aHS1Vkx/oENjTOKTeiM+ZhTvVFmwA9me2O1Gr5dxI+0EvNoBJ/zJ3QnPv2CQ22oDbHGKcpeyShZLwWMZiwws7g==

google-closure-compiler-linux@^20201207.0.0:
version "20201207.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-linux/-/google-closure-compiler-linux-20201207.0.0.tgz#3ee01a01087b926efe93fab5e1d03b697e940554"
integrity sha512-XYuODjnODRFP5zu1PzxqJ8B6VK1xsqwwWX8Kd618BNMSsMae7w1UST4YRxuqkOjItBsFHqPIB+AZ3veRrkiu7A==

google-closure-compiler-osx@^20201207.0.0:
version "20201207.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-osx/-/google-closure-compiler-osx-20201207.0.0.tgz#8f0360943302ce65c8cec2b342cfa2df91163d9a"
integrity sha512-y0dsV6/NmYhP1Hi5vbNk8JQ5hxpct0ZSU17UcCWeojNCVCjEmIoBv0CnySDDeNX1bdwjSUivwoMZlSxGAm+noA==

google-closure-compiler-windows@^20201207.0.0:
version "20201207.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-windows/-/google-closure-compiler-windows-20201207.0.0.tgz#befbbe3d54faecb57b2a1e4a3437917f3b7dc8e6"
integrity sha512-BbxXsXBfQRxJqIoN5cRU1liJli9LepmL3qt4N5oWdHpx0Np3Ay9a7fwGQiC403D1HnlGUFtD07cHLZbrcyme7A==

google-closure-compiler@^20201207.0.0:
version "20201207.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler/-/google-closure-compiler-20201207.0.0.tgz#bf5de2a7bb73ec10ed1374c717875856ab582ad4"
integrity sha512-s1aybrbHH4YP8PwsNOGeDZ7xF6y2wysz0DQAf0Ed8OGvg9itD4Pd+iaz+/UVBxBSTfGuik56GZ3JwpX0bA5ovw==
google-closure-compiler-java@^20210202.0.0:
version "20210202.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-java/-/google-closure-compiler-java-20210202.0.0.tgz#6e75c0dd7084540b5660b0753a0b09f48fe646c5"
integrity sha512-JSVrwv1k+wEjYgc58s9nXU+P5355l1mVTrmuB4B2cV8UaxFX3e5cRq4kwveBsB2fands2WJ+G74e10xCiEr82A==

google-closure-compiler-linux@^20210202.0.0:
version "20210202.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-linux/-/google-closure-compiler-linux-20210202.0.0.tgz#d25cb8ba0ccc2ae4a9285cab5a319f06a807688f"
integrity sha512-txE9tivnY77TgIxRNiT1nwqW+gjkLBcgy5qy0pE8htIrwuz+cgcTuvwH8mMlLKJJAifd32kboVyc1iymYrdN1w==

google-closure-compiler-osx@^20210202.0.0:
version "20210202.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-osx/-/google-closure-compiler-osx-20210202.0.0.tgz#96da3ac4aa2db0f735737dd410c9f2595f613d98"
integrity sha512-0OP8o4Nj6pR8hIxxQMPY8dO/2n6lWylHfmWv97IFdrxfsT7LKHzDeVt4I59p7nCfuPUoX8HcRNYFAmwKJwlIZQ==

google-closure-compiler-windows@^20210202.0.0:
version "20210202.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler-windows/-/google-closure-compiler-windows-20210202.0.0.tgz#01099c885a676ad319a4e27d5db262a65191d78a"
integrity sha512-HoRxdR/STw2cvB5HPS+xfdgNeFF3+2d7ImYyhMGdlv0+u5GxZwGgmLo9QajiI6Ga2ISGyTKUxYe3HWfYDYHrMg==

google-closure-compiler@^20210202.0.0:
version "20210202.0.0"
resolved "https://registry.yarnpkg.com/google-closure-compiler/-/google-closure-compiler-20210202.0.0.tgz#0250ea1a6a9051457535fe97793e26eeae8c579c"
integrity sha512-tvwbNFSvVC4c+uNf5MdOAS1xn2S3FN8zb7VtSV7K/TAIttDTYX4t1U1g4YBCbWYrvz6ynrY5SleW1RtG7SIfYQ==
dependencies:
chalk "2.x"
google-closure-compiler-java "^20201207.0.0"
google-closure-compiler-java "^20210202.0.0"
minimist "1.x"
vinyl "2.x"
vinyl-sourcemaps-apply "^0.2.0"
optionalDependencies:
google-closure-compiler-linux "^20201207.0.0"
google-closure-compiler-osx "^20201207.0.0"
google-closure-compiler-windows "^20201207.0.0"
google-closure-compiler-linux "^20210202.0.0"
google-closure-compiler-osx "^20210202.0.0"
google-closure-compiler-windows "^20210202.0.0"

graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.4"
Expand Down Expand Up @@ -1143,10 +1143,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b"
integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==

meow@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/meow/-/meow-8.0.0.tgz#1aa10ee61046719e334ffdc038bb5069250ec99a"
integrity sha512-nbsTRz2fwniJBFgUkcdISq8y/q9n9VbiHYbfwklFh5V4V2uAcxtKQkDc0yCLPM/kP0d+inZBewn3zJqewHE7kg==
meow@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/meow/-/meow-8.1.0.tgz#0fcaa267e35e4d58584b8205923df6021ddcc7ba"
integrity sha512-fNWkgM1UVMey2kf24yLiccxLihc5W+6zVus3/N0b+VfnJgxV99E9u04X6NAiKdg6ED7DAQBX5sy36NM0QJZkWA==
dependencies:
"@types/minimist" "^1.2.0"
camelcase-keys "^6.2.2"
Expand Down Expand Up @@ -1178,12 +1178,12 @@ min-indent@^1.0.0:
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==

minify-xml@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/minify-xml/-/minify-xml-2.4.0.tgz#5c44eb531b3b021332d8c821c787d1c9c60d9448"
integrity sha512-qgNI+R4PpQa2WuryViaw9UrEpDHyoNZyEt2UxseJetUooj08hQz/ef0no8Q3V0u9sB8uHp60iXEiEJ4BoKN74A==
minify-xml@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/minify-xml/-/minify-xml-2.5.0.tgz#7780549bbb4ee28d2097f31c61f8ba241bb895ac"
integrity sha512-0BaGYKxfkhRrM4eKEch0X9NJ2S8o5LaOMHn209XOY8ww5Ah3chfec5xdLrEyCDXhQMxF2ZyQRQVLhq5YyNLZpQ==
dependencies:
meow "^8.0.0"
meow "^8.1.0"

[email protected]:
version "4.1.0"
Expand Down Expand Up @@ -1393,10 +1393,10 @@ postcss-calc@^7.0.1:
postcss-selector-parser "^6.0.2"
postcss-value-parser "^4.0.2"

postcss-cli@^8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/postcss-cli/-/postcss-cli-8.3.0.tgz#fa06c96cbd0620768c788cae74ba462622a9013c"
integrity sha512-GqWohD9VmH+LCe+xsv6VCdcgNylNBmsrbxJlyXUGteGGdcmazj2YxSiJMUmQpg8pE6LRox9idtsTB7JZq5a+rw==
postcss-cli@^8.3.1:
version "8.3.1"
resolved "https://registry.yarnpkg.com/postcss-cli/-/postcss-cli-8.3.1.tgz#865dad08300ac59ae9cecb7066780aa81c767a77"
integrity sha512-leHXsQRq89S3JC9zw/tKyiVV2jAhnfQe0J8VI4eQQbUjwIe0XxVqLrR+7UsahF1s9wi4GlqP6SJ8ydf44cgF2Q==
dependencies:
chalk "^4.0.0"
chokidar "^3.3.0"
Expand Down Expand Up @@ -1707,10 +1707,10 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.27:
source-map "^0.6.1"
supports-color "^6.1.0"

postcss@^8.2.1:
version "8.2.1"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.1.tgz#eabc5557c4558059b9d9e5b15bce7ffa9089c2a8"
integrity sha512-RhsqOOAQzTgh1UB/IZdca7F9WDb7SUCR2Vnv1x7DbvuuggQIpoDwjK+q0rzoPffhYvWNKX5JSwS4so4K3UC6vA==
postcss@^8.2.6:
version "8.2.6"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.2.6.tgz#5d69a974543b45f87e464bc4c3e392a97d6be9fe"
integrity sha512-xpB8qYxgPuly166AGlpRjUdEYtmOWx2iCwGmrv4vqZL9YPVviDVPZPRXxnXr6xPZOdxQ9lp3ZBFCRgWJ7LE3Sg==
dependencies:
colorette "^1.2.1"
nanoid "^3.1.20"
Expand Down Expand Up @@ -2181,7 +2181,7 @@ yargs-parser@^20.2.2, yargs-parser@^20.2.3:
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==

yargs@^16.0.0:
yargs@^16.0.0, yargs@^16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import io.github.chris2011.netbeans.minifierbeans.project.ui.options.ProjectOptionsPanel;
import io.github.chris2011.netbeans.minifierbeans.ui.MinifyProperty;
import org.openide.util.ChangeSupport;
Expand Down

0 comments on commit aba4199

Please sign in to comment.