Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Toolchain
sgc
Commits
442da3a3
Commit
442da3a3
authored
Aug 31, 2018
by
Philipp Nowinski
Browse files
[FEATURE] add build task + massive cleanup
parent
f3ccedc8
Changes
6
Show whitespace changes
Inline
Side-by-side
__old/modules/build.sh
deleted
100755 → 0
View file @
f3ccedc8
#!/bin/bash
params
=
"
$(
echo
$@
|
sed
's/build//'
)
"
if
[[
"
${
@#--ext
}
"
=
"
$@
"
]]
then
extensions
=
"
$(
node ./sgc-core/core/getExtensions.js
)
"
for
extension
in
$extensions
do
sgc execBuild
--ext
$extension
$params
done
else
# do the regular call
sgc execBuild
$params
fi
core/getExtensions.js
deleted
100644 → 0
View file @
f3ccedc8
'
use strict
'
;
const
settings
=
require
(
'
../gulp/settings
'
);
const
config
=
settings
.
getConfig
();
let
extensions
=
config
.
extensions
.
reduce
((
accumulator
,
currentValue
)
=>
accumulator
+
'
'
+
currentValue
);
// intended as an information output
// eslint-disable-next-line
console
.
log
(
extensions
);
core/settings.js
View file @
442da3a3
'
use strict
'
;
/* eslint-disable class-methods-use-this */
const
fs
=
require
(
'
fs
'
);
const
path
=
require
(
'
path
'
);
const
{
argv
}
=
require
(
'
yargs
'
);
let
extension
;
/**
* This module is a global settings singleton
...
...
@@ -17,7 +18,7 @@ class Settings {
this
.
_config
=
Settings
.
parseConfig
();
this
.
_extensionPath
=
this
.
_config
.
directories
.
basePath
;
this
.
_webPath
=
this
.
_config
.
directories
.
webPath
;
[
this
.
_
extension
]
=
this
.
_config
.
extensions
;
[
extension
]
=
this
.
_config
.
extensions
;
this
.
_tasks
=
{
css
:
()
=>
require
(
'
./tasks/css
'
),
js
:
()
=>
require
(
'
./tasks/js
'
),
...
...
@@ -26,7 +27,8 @@ class Settings {
images
:
()
=>
require
(
'
./tasks/images
'
),
open
:
()
=>
require
(
'
./tasks/open
'
),
releaseExtension
:
()
=>
require
(
'
./tasks/releaseExtension
'
),
default
:
()
=>
require
(
'
./tasks/default
'
)
default
:
()
=>
require
(
'
./tasks/default
'
),
build
:
()
=>
require
(
'
./tasks/build
'
)
};
}
...
...
@@ -37,7 +39,7 @@ class Settings {
*/
getPath
(
_isWebPath
)
{
let
extensionName
=
(
typeof
argv
.
ext
===
'
undefined
'
)
?
this
.
_
extension
?
extension
:
argv
.
ext
;
return
typeof
_isWebPath
===
'
undefined
'
?
path
.
join
(
this
.
_extensionPath
,
extensionName
)
...
...
@@ -49,8 +51,8 @@ class Settings {
*
* @param {String} _extensionName The name of the extension which path should be used
*/
set
Path
(
_extensionName
)
{
this
.
_
extension
=
_extensionName
;
set
Extension
(
_extensionName
)
{
extension
=
_extensionName
;
}
/**
...
...
core/tasks/build.js
0 → 100644
View file @
442da3a3
const
Task
=
require
(
'
../task
'
);
const
settings
=
require
(
'
../settings
'
);
/**
* The main build step – basically a combination of the most important tasks
*/
module
.
exports
=
class
Build
extends
Task
{
/**
* Run all important tasks
*
* @override
*/
async
run
()
{
let
images
=
this
.
_settings
.
tasks
.
images
();
let
css
=
this
.
_settings
.
tasks
.
css
();
let
js
=
this
.
_settings
.
tasks
.
js
();
this
.
_config
.
extensions
.
forEach
(
_extension
=>
{
settings
.
setExtension
(
_extension
);
new
images
().
run
();
new
css
().
run
();
new
js
().
run
();
});
}
};
core/tasks/css.js
View file @
442da3a3
...
...
@@ -104,9 +104,10 @@ module.exports = class Css extends Task {
this
.
_logger
.
displayBrowserSyncNotification
(
'
Compiling Sass – hang in there...
'
);
const
render
=
util
.
promisify
(
sass
.
render
);
const
sourceMapPath
=
this
.
_getSourceMapsPath
(
_output
);
let
compiledSass
;
try
{
let
compiledSass
=
await
render
({
compiledSass
=
await
render
({
file
:
_input
,
outFile
:
_output
,
outputStyle
:
'
expanded
'
,
...
...
core/tasks/watch.js
View file @
442da3a3
const
Task
=
require
(
'
../task
'
);
const
watch
=
require
(
'
node-watch
'
);
const
globby
=
require
(
'
globby
'
);
const
path
=
require
(
'
path
'
);
const
settings
=
require
(
'
../settings
'
);
/**
* The watch-task observes changes in source files and triggers compilation
...
...
@@ -21,11 +23,18 @@ module.exports = class Watch extends Task {
* Watch for CSS-related files
*/
async
_watchCss
()
{
const
files
=
await
globby
([
`
${
this
.
_path
}
/
${
this
.
_config
.
directories
.
sass
}
/**/*.scss`
,
'
!**/*_svg.scss
'
].
concat
(
this
.
_config
.
css
.
excludeFromQa
));
let
globs
=
[];
// get a glob for each extension that shall be watched
this
.
_config
.
extensions
.
forEach
(
_extension
=>
{
globs
.
push
(
this
.
_getGlobFor
(
_extension
,
`
${
this
.
_config
.
directories
.
sass
}
/**/*.scss`
));
});
// assemble information about which files need to be watched
const
ignoredFiles
=
[
'
!**/*_svg.scss
'
].
concat
(
this
.
_config
.
css
.
excludeFromQa
);
const
files
=
await
globby
(
globs
.
concat
(
ignoredFiles
));
// watch those files
files
.
forEach
(
file
=>
{
watch
(
file
,
{
recursive
:
true
},
this
.
_onCssChange
.
bind
(
this
));
});
...
...
@@ -35,16 +44,33 @@ module.exports = class Watch extends Task {
* Watch for JS-related files
*/
async
_watchJs
()
{
const
files
=
await
globby
([
`
${
this
.
_path
}
/
${
this
.
_config
.
directories
.
javascriptSrc
}
/**/*.js`
,
'
!**/*.min.js
'
].
concat
(
this
.
_config
.
js
.
excludeFromQa
));
let
globs
=
[];
// get a glob for each extension that shall be watched
this
.
_config
.
extensions
.
forEach
(
_extension
=>
{
globs
.
push
(
this
.
_getGlobFor
(
_extension
,
`
${
this
.
_config
.
directories
.
javascriptSrc
}
/**/*.js`
));
});
// assemble information about which files need to be watched
const
ignoredFiles
=
[
'
!**/*.min.js
'
].
concat
(
this
.
_config
.
js
.
excludeFromQa
);
const
files
=
await
globby
(
globs
.
concat
(
ignoredFiles
));
// watch those files
files
.
forEach
(
file
=>
{
watch
(
file
,
{
recursive
:
true
},
this
.
_onJsChange
.
bind
(
this
));
});
}
/**
* Generates the glob for files in _path in _extension
*
* @param {String} _extension Name of the extension
* @param {String} _path The path to the files inside the extension
*/
_getGlobFor
(
_extension
,
_path
)
{
return
path
.
join
(
this
.
_config
.
directories
.
basePath
,
_extension
,
_path
);
}
/**
* Trigger CSS-compilation
*/
...
...
@@ -68,6 +94,7 @@ module.exports = class Watch extends Task {
* @param {String} _fileName The path to the file that changed
*/
_onCssChange
(
_event
,
_fileName
)
{
this
.
_setCurrentExtensionName
(
_fileName
);
this
.
_logger
.
info
(
`
${
_fileName
}
changed`
);
this
.
_triggerCss
();
}
...
...
@@ -82,4 +109,15 @@ module.exports = class Watch extends Task {
this
.
_logger
.
info
(
`
${
_fileName
}
changed`
);
this
.
_triggerJs
();
}
/**
* Tells our settings object which extension shall be used for the following build steps
*
* @param {String} _file The changed file
*/
_setCurrentExtensionName
(
_file
)
{
// the filepath will contain backslashes instead of slashes on windows. we need to normalize this.
let
file
=
_file
.
replace
(
/
\\
/g
,
'
/
'
);
settings
.
setExtension
(
file
.
split
(
this
.
_config
.
directories
.
basePath
)[
1
].
split
(
'
/
'
)[
0
]);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment