Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drupal 8 SASS Theme
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Composer
plugin
Drupal 8 SASS Theme
Commits
45ae46ef
Commit
45ae46ef
authored
8 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
#7
Dynamically build gitignore file
parent
d89e16e8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Handler.php
+33
-26
33 additions, 26 deletions
src/Handler.php
templates/.gitignore
+0
-10
0 additions, 10 deletions
templates/.gitignore
templates/.gitignore.twig
+22
-0
22 additions, 0 deletions
templates/.gitignore.twig
with
55 additions
and
36 deletions
src/Handler.php
+
33
−
26
View file @
45ae46ef
...
...
@@ -209,6 +209,8 @@ class Handler
'templates/README.md'
,
'README.md'
,
'{{ project_name }}.starterkit.yml'
,
'.gitignore'
,
'.gitkeep'
,
]);
}
...
...
@@ -296,6 +298,8 @@ class Handler
* @param string $destination
*/
protected
function
copyFiles
(
$fs
,
$finder
,
$source
,
$destination
)
{
$files
=
[];
// Make sure all directories do exist
$finder
->
directories
()
->
in
(
$source
);
foreach
(
$finder
as
$file
)
{
...
...
@@ -331,7 +335,10 @@ class Handler
}
else
{
file_put_contents
(
$filename
,
$this
->
twig
(
file_get_contents
(
$file
->
getRealPath
())));
}
$files
[]
=
$tweakedRelFilename
;
}
return
$files
;
}
/**
...
...
@@ -344,37 +351,37 @@ class Handler
$fs
=
new
Filesystem
();
$destination
=
$this
->
getInstallationPath
();
// We only do the fancy stuff for developers
if
(
$event
->
isDevMode
())
{
$pluginRoot
=
$this
->
getInstallationManager
()
->
getInstallPath
(
$this
->
getPackage
(
'lakedrops/theme-d8-sass'
));
$finder
=
new
Finder
();
$finder
->
ignoreDotFiles
(
FALSE
);
// Copy all files
$this
->
copyFiles
(
$fs
,
$finder
,
$pluginRoot
.
'/templates'
,
$destination
);
// Handle optional base theme
$baseTheme
=
$this
->
getOption
(
'base_theme'
);
if
(
isset
(
$baseTheme
[
'package'
]))
{
$baseThemePackage
=
$this
->
getPackage
(
$baseTheme
[
'package'
]);
if
(
$baseThemePackage
&&
isset
(
$baseTheme
[
'starterkit'
]))
{
$starterkitRoot
=
$this
->
getInstallationManager
()
->
getInstallPath
(
$baseThemePackage
)
.
DIRECTORY_SEPARATOR
.
$baseTheme
[
'starterkit'
];
$this
->
copyFiles
(
$fs
,
$finder
,
$starterkitRoot
,
$destination
);
}
$pluginRoot
=
$this
->
getInstallationManager
()
->
getInstallPath
(
$this
->
getPackage
(
'lakedrops/theme-d8-sass'
));
$finder
=
new
Finder
();
$finder
->
ignoreDotFiles
(
FALSE
);
// Copy all files
$this
->
copyFiles
(
$fs
,
$finder
,
$pluginRoot
.
'/templates'
,
$destination
);
// Handle optional base theme
$baseTheme
=
$this
->
getOption
(
'base_theme'
);
if
(
isset
(
$baseTheme
[
'package'
]))
{
$baseThemePackage
=
$this
->
getPackage
(
$baseTheme
[
'package'
]);
if
(
$baseThemePackage
&&
isset
(
$baseTheme
[
'starterkit'
]))
{
$starterkitRoot
=
$this
->
getInstallationManager
()
->
getInstallPath
(
$baseThemePackage
)
.
DIRECTORY_SEPARATOR
.
$baseTheme
[
'starterkit'
];
$this
->
options
[
'base_theme_files'
]
=
$this
->
copyFiles
(
$fs
,
$finder
,
$starterkitRoot
,
$destination
);
}
}
// Remove bower stuff if that's available globally
if
(
empty
(
$this
->
getOption
(
'bower_assets'
)[
'dependencies'
]))
{
if
(
$fs
->
exists
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower.json'
))
{
$fs
->
remove
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower.json'
);
}
if
(
$fs
->
exists
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower_components'
))
{
$fs
->
remove
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower_components'
);
}
// Remove bower stuff if that's available globally
if
(
empty
(
$this
->
getOption
(
'bower_assets'
)[
'dependencies'
]))
{
if
(
$fs
->
exists
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower.json'
))
{
$fs
->
remove
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower.json'
);
}
if
(
$fs
->
exists
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower_components'
))
{
$fs
->
remove
(
$destination
.
DIRECTORY_SEPARATOR
.
'bower_components'
);
}
}
// Finally write .gitignore
file_put_contents
(
$destination
.
DIRECTORY_SEPARATOR
.
'.gitignore'
,
$this
->
twig
(
file_get_contents
(
$pluginRoot
.
'/templates/.gitignore'
)));
// Prepare post processing
$currentDir
=
getcwd
();
chdir
(
$destination
);
...
...
This diff is collapsed.
Click to expand it.
templates/.gitignore
deleted
100644 → 0
+
0
−
10
View file @
d89e16e8
# Ignore certain directories
.sass-cache/
bower_components/
fonts/*
fonts/*/
node_modules/
# Ignore files that get compiled
style.css
*.map
This diff is collapsed.
Click to expand it.
templates/.gitignore.twig
0 → 100644
+
22
−
0
View file @
45ae46ef
# System settings - please do NOT change
.sass-cache/
css/
bower_components/
{%
for
name
,
package
in
bower_assets
%}
{%
if
package.fonts
is
defined
%}
fonts/
{{
package.name
}}
{%
endif
%}
{%
endfor
%}
{%
for
name
,
package
in
bower_assets
%}
{%
if
package.js
is
defined
%}
js/
{{
package.name
}}
{%
endif
%}
{%
endfor
%}
node_modules/
sass/_bower-assets.scss
sass/_settings.scss
{%
for
file
in
base_theme_files
|
default
([])
%}
{{
file
}}
{%
endfor
%}
# Add your own irgnore patterns below this line
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment