This commit is contained in:
Maurice Grönwoldt 2021-08-19 13:43:41 +02:00
commit 3d91068e08
71 changed files with 4490 additions and 0 deletions

693
.gitignore vendored Normal file
View file

@ -0,0 +1,693 @@
# Created by https://www.toptal.com/developers/gitignore/api/node,intellij+all,intellij,visualstudio,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=node,intellij+all,intellij,visualstudio,visualstudiocode
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/
# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$
# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml
### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
# AWS User-specific
# Generated files
# Sensitive or high-churn files
# Gradle
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
# Mongo Explorer plugin
# File-based project format
# IntelliJ
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Cursive Clojure plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
# Editor-based Rest Client
# Android studio 3.1+ serialized cache file
### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
.idea/sonarlint
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### VisualStudio ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Nuget personal access tokens and Credentials
nuget.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
# Local History for Visual Studio Code
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
### VisualStudio Patch ###
# Additional files built by Visual Studio
# End of https://www.toptal.com/developers/gitignore/api/node,intellij+all,intellij,visualstudio,visualstudiocode

2
build/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
node_modules/
package-lock.json

91
build/Readme.md Normal file
View file

@ -0,0 +1,91 @@
# Usage
*NOTES*
THIS NEED TO BE INSTALLED IN A SUBFOLDER!
Copy buildConfig.example.json to parent directory and rename it to buildConfig.json
Compiler Flags in the JS Tree are from "Google Closure Compiler"
# Install
```
git clone https://git.vstz.dev/versustunez/gulp-dynamic.git build
cd build
npm install
cp buildConfig.example.json ../buildConfig.json
```
# Config
### Variables
| Key | VALUE |
|-------|---------------------|
| $dir | ROOT DIR |
| $src | SRC FROM Config |
| $out | OUT FROM CONFIG |
| $name | NAME KEY FROM BLOCK |
| $ | BLOCK INPUT VALUE |
|-------|---------------------|
### ROOT
| Key | isRequired | TYPE |
|------|------------|--------|
| src | YES | STRING |
| out | YES | STRING |
| js | NO | ARRAY |
| scss | NO | ARRAY |
### JS-Array
| Key | isRequired | TYPE | DEFAULT |
|------------|------------|--------|-----------------------|
| name | YES | STRING | - |
| minify | NO | BOOL | false |
| onlyMinify | NO | BOOL | false |
| input | YES | STRING | - |
| output | YES | STRING | - |
| files | YES | ARRAY | - |
| compiler | NO | OBJECT | #JS-Compiler Settings |
### JS-Compiler Settings
| Key | isRequired | TYPE | DEFAULT |
|-------------------|------------|--------|-----------------------|
| compilation_level | NO | STRING | SIMPLE |
| warning_level | NO | STRING | VERBOSE |
| language_in | NO | STRING | ECMASCRIPT6_STRICT |
| language_out | NO | STRING | ECMASCRIPT6_STRICT |
| js_output_file | NO | STRING | $name.min.js |
*NOTES* SEE: [Google Compiler Flags](https://github.com/google/closure-compiler/wiki/Flags-and-Options)
## Example Config
```json
{
"src": "$dir/src",
"out": "$dir/public/out",
"js": [
{
"name": "main",
"minify": true,
"onlyMinify": true,
"input": "$src/js/",
"output": "$out/js/",
"files": [
"app.js"
],
"compiler": {
"compilation_level": "ADVANCED",
"warning_level": "VERBOSE",
"language_in": "ECMASCRIPT6_STRICT",
"language_out": "ECMASCRIPT6_STRICT",
"js_output_file": "$name.min.js"
}
}
],
"scss": [
{
"name": "main",
"input": "$src/theme/**/*.scss",
"output": "$out/theme/$name"
}
]
}
```

View file

@ -0,0 +1,30 @@
{
"src": "$dir/src",
"out": "$dir/public/out",
"js": [
{
"name": "main",
"minify": true,
"onlyMinify": true,
"input": "$src/js/",
"output": "$out/js/",
"files": [
"app.js"
],
"compiler": {
"compilation_level": "ADVANCED",
"warning_level": "VERBOSE",
"language_in": "ECMASCRIPT6_STRICT",
"language_out": "ECMASCRIPT6_STRICT",
"js_output_file": "$name.min.js"
}
}
],
"scss": [
{
"name": "main",
"input": "$src/theme/**/*.scss",
"output": "$out/theme/$name"
}
]
}

20
build/gulpfile.js Normal file
View file

@ -0,0 +1,20 @@
const gulp = require('gulp'),
config = require('./tools/buildConfig'),
smartJS = require('./task/smartjs'),
smartIcon = require('./task/smarticon'),
smartCss = require('./task/smartcss');
config.prepare();
smartJS.prepare(config);
smartCss.prepare(config);
smartIcon.prepare(config);
gulp.task('watchMe', () => {
smartJS.startWatch();
smartCss.startWatch();
smartIcon.startWatch();
});
gulp.task('default', gulp.parallel([...smartJS.build(), ...smartCss.build(), ...smartIcon.build()]));
gulp.task('watch', gulp.parallel(['watchMe', ...smartJS.build(), ...smartCss.build(), ...smartIcon.build()]));

10
build/index.js Normal file
View file

@ -0,0 +1,10 @@
const gulp = require('gulp-cli'),
shouldWatch = process.argv.length > 2 && process.argv[2] === 'watch';
gulp()
require('./gulpfile')
if (shouldWatch) {
gulp.series('watchMe')();
} else {
gulp.series('default')();
}

29
build/package.json Normal file
View file

@ -0,0 +1,29 @@
{
"name": "v-build",
"version": "1.0.0",
"description": "A Small Gulp Build System for Dynamic JS and SCSs",
"main": "index.js",
"scripts": {
"build-nm": "./node_modules/gulp-cli/bin/gulp.js",
"watch-nm": "./node_modules/gulp-cli/bin/gulp.js watch",
"build": "gulp",
"watch": "gulp watch"
},
"keywords": [
"GULP",
"JS",
"SCSS"
],
"author": "Maurice Grönwoldt",
"license": "GPL-3.0-or-later",
"dependencies": {
"google-closure-compiler": "^20210202.0.0",
"gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0",
"gulp-cli": "^2.3.0",
"gulp-concat": "^2.6.1",
"gulp-sass": "^4.1.0",
"node-fs-extra": "^0.8.2",
"svg-sprite": "^1.5.0"
}
}

58
build/task/smartcss.js Normal file
View file

@ -0,0 +1,58 @@
const gulp = require('gulp'),
HelperUnit = require('./../tools/helperUnit'),
sass = require('gulp-sass'),
clean = require('gulp-clean-css'),
path = require('path'),
workers = [];
class SCSSWorker {
constructor(config, helper) {
this.config = config;
this.helper = helper.clone();
this.input = this.helper.replaceVariables(this.config.input);
this.watchInput = '.' + this.helper.replaceAbsolutePath(this.input);
this.helper.addConfigItem("$name", this.config.name);
this.helper.addConfigItem("$watch", this.watchInput);
this.helper.addConfigItem("$", this.input);
this.out = this.helper.replaceVariables(this.config.output);
this.watch = this.helper.replaceVariables(this.config.watch || '$watch');
gulp.task(this.taskName, this.work.bind(this));
}
startWatch() {
console.log(`[WATCH][${this.config.name}] >> ${this.watch}`);
gulp.watch(this.watch, gulp.series(this.taskName))
}
get taskName() {
return `scss-${this.config.name || 'unknown'}`;
}
work() {
return gulp.src(this.input)
.pipe(sass().on('error', sass.logError))
.pipe(clean())
.pipe(gulp.dest(this.out));
}
}
module.exports = {
build: function () {
let array = [];
for (let worker of workers) {
array.push(worker.taskName);
}
return array;
},
prepare: function (config) {
const scss = config.scss || [];
for (let scssItem of scss) {
workers.push(new SCSSWorker(scssItem, config.helper));
}
},
startWatch: function () {
for (let worker of workers) {
worker.startWatch();
}
}
}

53
build/task/smarticon.js Normal file
View file

@ -0,0 +1,53 @@
const gulp = require('gulp'),
builder = require('./../tools/iconSprite'),
workers = [];
class IconWorker {
constructor(icon, helper) {
this.config = icon;
this.helper = helper.clone();
this.input = this.helper.replaceVariables(this.config.input);
this.watchInput = '.' + this.helper.replaceAbsolutePath(this.input);
this.helper.addConfigItem("$name", this.config.name);
this.helper.addConfigItem("$watch", this.watchInput);
this.helper.addConfigItem("$", this.input);
this.out = this.helper.replaceVariables(this.config.output);
this.watch = this.helper.replaceVariables(this.config.watch || '$watch');
gulp.task(this.taskName, this.work.bind(this));
}
startWatch() {
console.log(`[WATCH][${this.config.name}] >> ${this.watch}`);
gulp.watch(this.watch, gulp.series(this.taskName))
}
get taskName() {
return `icon-${this.config.name}`;
}
work() {
builder.buildIconSprites(this);
return gulp.src(this.input)
}
}
module.exports = {
build: function () {
let array = [];
for (let worker of workers) {
array.push(worker.taskName);
}
return array;
},
prepare: function (config) {
const icons = config.icons || [];
for (let icon of icons) {
workers.push(new IconWorker(icon, config.helper));
}
},
startWatch: function () {
for (let worker of workers) {
worker.startWatch();
}
}
}

116
build/task/smartjs.js Normal file
View file

@ -0,0 +1,116 @@
const closureCompiler = require('google-closure-compiler').gulp(),
concat = require('gulp-concat'),
gulp = require('gulp'),
path = require('path'),
fileInclude = require('./../tools/file-includer'),
workers = [];
class JSWorker {
constructor(config, helper) {
this.config = config;
this.helper = helper.clone();
if (!this.config.name) {
throw Error("Found Empty name for JS Job...");
}
this.validateConfig();
this.input = this.helper.replaceVariables(this.config.input);
this.watchInput = '.' + this.helper.replaceAbsolutePath(this.input);
this.helper.addConfigItem("$name", this.config.name);
this.helper.addConfigItem("$watch", this.watchInput)
this.helper.addConfigItem("$", this.input);
this.getCompilerConfig();
this.out = this.helper.replaceVariables(this.config.output);
this.watch = this.helper.replaceVariables(this.config.watch || '$watch/**/*.js');
if (this.config.includeFile) {
this.includeFile = `${this.input}/${this.config.includeFile}`;
}
this.prepareFiles()
this.path = path.parse(this.out);
this.path = this.path.dir + "/" + this.path.base + "/";
gulp.task(this.taskName, this.work.bind(this));
}
validateConfig() {
let config = this.config;
config.onlyMinify = config.onlyMinify || false;
config.minify = config.minify || false;
if (!this.config.input || !this.config.output || !(this.config.files || this.config.includeFile)) {
throw Error("Invalid Config for: " + this.config.name + ")");
}
}
getCompilerConfig() {
this.compiler = {
compilation_level: 'SIMPLE',
warning_level: 'VERBOSE',
language_in: 'ECMASCRIPT6_STRICT',
language_out: 'ECMASCRIPT6_STRICT',
js_output_file: this.config.name + ".min.js"
}
if (this.config.compiler) {
this.compiler = Object.assign(this.compiler, this.config.compiler);
}
this.compiler.js_output_file = this.helper.replaceVariables(this.compiler.js_output_file);
}
startWatch() {
console.log(`[WATCH][${this.config.name}] >> ${this.watch}`);
const watchArray = [this.watch];
if (this.includeFile) {
watchArray.push(this.includeFile);
}
gulp.watch(watchArray, gulp.parallel([this.taskName]));
}
get taskName() {
return `js-${this.config.name}`;
}
prepareFiles() {
if (this.config.includeFile) {
this.files = fileInclude.findFiles(this.input, this.includeFile, this.helper);
} else {
this.files = [];
for (const file of this.config.files) {
this.files.push(this.input + "/" + this.helper.replaceVariables(file));
}
}
}
work() {
if (this.config.includeFile) {
this.prepareFiles();
}
let d = gulp.src(this.files).pipe(concat(this.config.name + '.js'))
if (!this.config.onlyMinify) {
d.pipe(gulp.dest(this.path));
}
if (this.config.minify) {
d.pipe(closureCompiler(this.compiler)).pipe(gulp.dest(this.path));
}
return d;
}
}
module.exports = {
build: function () {
let array = [];
for (let worker of workers) {
array.push(worker.taskName);
}
return array;
},
prepare: function (config) {
// we load the json and parse it here
const js = config.js || [];
for (let jsConfig of js) {
const worker = new JSWorker(jsConfig, config.helper);
workers.push(worker);
}
},
startWatch: function () {
for (let worker of workers) {
worker.startWatch();
}
}
}

View file

@ -0,0 +1,36 @@
const fs = require('fs'),
HelperUnit = require('./helperUnit'),
helper = new HelperUnit(),
config = {};
module.exports = {
config: config,
helper: helper,
prepare: function () {
if (!fs.existsSync(__dirname + '/../../buildConfig.json')) {
console.error("Cannot find Config JSON");
process.exit(40);
}
const currentPath = process.cwd();
const baseDir = currentPath + '/../';
const data = JSON.parse(fs.readFileSync(currentPath + '/../buildConfig.json').toString());
const src = data['src'].replace(/(\$dir)/gm, baseDir);
const out = data['out'].replace(/(\$dir)/gm, baseDir);
helper.setConfig({
$dir: baseDir,
$out: out,
$src: src,
$rawDir: __dirname,
$forWatch: data['src'].replace(/(\$dir)/gm, '../')
})
config.dir = baseDir;
config.src = src;
config.out = out;
config.js = data.js || [];
config.scss = data.scss || [];
config.icons = data.icons || [];
this.js = config.js;
this.scss = config.scss;
this.icons = config.icons;
}
}

View file

@ -0,0 +1,24 @@
const fs = require('fs');
function findFiles(dir, file, helper) {
file = helper.replaceVariables(file);
const d = fs.readFileSync(file).toString("UTF8");
const split = d.split("\n");
let files = [];
for (let file of split) {
if (file.startsWith("--") || file.trim() === "" || file.startsWith("#")) {
continue;
}
if (file.startsWith("@import")) {
let iFile = file.split("@import")[1].trim();
files.push(...this.findFiles(dir, `${dir}/${iFile}.path`, helper));
} else {
files.push(`${dir}/${helper.replaceVariables(file)}.js`);
}
}
return files;
}
module.exports = {
findFiles
};

57
build/tools/helperUnit.js Normal file
View file

@ -0,0 +1,57 @@
let inConfig = {
$dir: __dirname,
$out: __dirname,
$src: __dirname,
$: __dirname
}
class HelperUnit {
constructor(config = null) {
this.config = config || inConfig;
this.regEx = {};
this.buildRegex();
}
static setGlobalConfig(config) {
inConfig = config;
}
addConfigItem(name, value, regexOnly = false) {
if (!regexOnly) {
this.config[name] = value;
}
let replace = name.replace("$", "\\$");
this.regEx[name] = new RegExp(`(${replace})`, "gm");
}
setConfig(config) {
this.config = config;
this.buildRegex();
}
buildRegex() {
const keys = Object.keys(this.config);
this.regEx = {};
for (const key of keys) {
this.addConfigItem(key, null, true);
}
}
replaceVariables(string) {
const keys = Object.keys(this.config);
for (const key of keys) {
string = string.replace(this.regEx[key], this.config[key]);
}
return string;
}
replaceAbsolutePath(string) {
string = string.replace(this.config["$dir"], this.config["$forWatch"])
return string;
}
clone() {
return new HelperUnit(this.config);
}
}
module.exports = HelperUnit;

71
build/tools/iconSprite.js Normal file
View file

@ -0,0 +1,71 @@
const path = require('path'),
SVGSpriter = require('svg-sprite'),
fs = require('fs'),
fsExtra = require('node-fs-extra');
let toMergeData = [];
function buildIconSprites(config) {
config.spriter = {
shape: {
id: {
generator: function (name) {
return "vt-" + name.replace('.svg', '');
}
}
},
svg: {
xmlDeclaration: true,
doctypeDeclaration: true
},
mode: {
symbol: true,
defs: true
}
}
builder.init(config);
builder.generateFromIcons();
}
let builder = {
init: function (config) {
this.config = config;
},
generateFromIcons: function () {
const spriter = new SVGSpriter(this.config.spriter);
this.readFiles(this.config.input, spriter);
spriter.compile(function (error, result) {
if (error !== null) {
throw new Error(error);
}
builder.writeData(result.symbol.sprite.contents.toString());
});
},
writeData: function (data) {
let out = builder.config.out + builder.config.config.name + ".svg";
let dirname = path.dirname(out);
if (!fs.existsSync(dirname)) {
fsExtra.mkdirpSync(dirname);
}
fs.writeFileSync(out, data);
},
readFiles: function (dir, spriter) {
let files = fs.readdirSync(dir);
for (let file of files) {
const split = file.split('.');
if (split[split.length - 1] === 'svg') {
let filePath = path.resolve(dir, file);
spriter.add(
filePath,
file,
fs.readFileSync(filePath, {encoding: 'utf-8'})
);
}
}
}
};
module.exports.buildIconSprites = buildIconSprites;

54
buildConfig.json Normal file
View file

@ -0,0 +1,54 @@
{
"src": "$dir/src",
"out": "$dir/public/out",
"js": [
{
"name": "app",
"minify": true,
"onlyMinify": true,
"input": "$src/app/",
"output": "$out/app/",
"watch": "../src/app/**/*.js",
"includeFile": "../app.path",
"compiler": {
"compilation_level": "SIMPLE",
"warning_level": "DEFAULT",
"language_in": "ECMASCRIPT_2018",
"language_out": "ECMASCRIPT_2018",
"js_output_file": "$name.min.js"
}
},
{
"name": "loader",
"minify": true,
"onlyMinify": true,
"input": "$src/app/",
"output": "$out/app/",
"watch": "../src/app/**/*.js",
"includeFile": "../loader.path",
"compiler": {
"compilation_level": "SIMPLE",
"warning_level": "DEFAULT",
"language_in": "ECMASCRIPT_2018",
"language_out": "ECMASCRIPT_2018",
"js_output_file": "$name.min.js"
}
}
],
"scss": [
{
"name": "main",
"input": "$src/theme/**/*.scss",
"output": "$out/theme/$name",
"watch": "../src/theme/**/*.scss"
}
],
"icons": [
{
"name": "icon-sprite",
"input": "$src/icons/",
"output": "$out/",
"watch": "../src/icons/**/*.svg"
}
]
}

BIN
public/favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/favicon/favicon-16x16.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Some files were not shown because too many files have changed in this diff Show more