Skip to content

Commit

Permalink
feat: update AMSF config structure
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Now the `./_amsf/` directory is obsolete, config `_amsf.yml` and cache directory `.amsf-cache` are introduced, if you see errors when update the AMSF, try create `_amsf.yml` from the AMSF source code
  • Loading branch information
sparanoid committed Jun 13, 2016
1 parent 6ee388e commit 542a59b
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 18 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ nbproject
node_modules

# AMSF specified
_amsf/themes
_amsf/core
.amsf-cache
.jekyll-metadata
_site
_app/assets/**/js
_app/assets/**/css
.jekyll-metadata

# AMSF deprecated, leave them for compatibility
_amsf/themes
_amsf/core
58 changes: 50 additions & 8 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ module.exports = (grunt) ->
config:
cfg: grunt.file.readYAML("_config.yml")
pkg: grunt.file.readJSON("package.json")
amsf: grunt.file.readYAML("_amsf/_config.yml")
amsf: grunt.file.readYAML("_amsf.yml")
deploy: grunt.file.readYAML("_deploy.yml")
app: "<%= config.cfg.source %>"
dist: "<%= config.cfg.destination %>"
base: "<%= config.cfg.base %>"
banner: "<!-- <%= config.pkg.name %> v<%= config.pkg.version %> | © <%= config.pkg.author %> | <%= config.pkg.license %> -->\n"

amsf:
base: "_amsf"
base: ".amsf-cache"
branch: grunt.option("branch") or "release"
core: "<%= amsf.base %>/core"
user:
Expand Down Expand Up @@ -300,13 +300,13 @@ module.exports = (grunt) ->

serve:
options:
config: "_config.yml,_amsf/_config.yml,<%= config.app %>/_data/<%= amsf.theme.current %>.yml,_config.dev.yml"
config: "_config.yml,_amsf.yml,<%= config.app %>/_data/<%= amsf.theme.current %>.yml,_config.dev.yml"
drafts: true
future: true

dist:
options:
config: "_config.yml,_amsf/_config.yml,<%= config.app %>/_data/<%= amsf.theme.current %>.yml"
config: "_config.yml,_amsf.yml,<%= config.app %>/_data/<%= amsf.theme.current %>.yml"
dest: "<%= config.dist %><%= config.base %>"

shell:
Expand Down Expand Up @@ -386,6 +386,19 @@ module.exports = (grunt) ->
}
]

amsf__config__to_app:
files: [
{
expand: true
dot: true
cwd: "<%= amsf.core %>"
src: [
"_amsf.yml"
]
dest: "./"
}
]

amsf__core__to_app:
files: [
{
Expand All @@ -401,6 +414,7 @@ module.exports = (grunt) ->
"Gruntfile*" # Comment this when debugging this task
"LICENSE"
"package.json"
"!_amsf.yml"
"!.DS_Store"
"!TODOS.md"
]
Expand Down Expand Up @@ -472,12 +486,22 @@ module.exports = (grunt) ->

replace:
amsf__theme__update_config:
src: ["<%= amsf.base %>/_config.yml"]
dest: "<%= amsf.base %>/_config.yml"
src: ["_amsf.yml"]
dest: "_amsf.yml"
replacements: [
{
from: /(theme:)( +)(.+)/g
to: "$1$2<%= amsf.theme.new_name %>"
from: /(theme: +)(.+)/g
to: "$1<%= amsf.theme.new_name %>"
}
]

amsf__core__update_version:
src: ["_amsf.yml"]
dest: "_amsf.yml"
replacements: [
{
from: /(version: +)(.+)/g
to: "$1<%= config.pkg.version %>"
}
]

Expand Down Expand Up @@ -538,6 +562,20 @@ module.exports = (grunt) ->
tagMessage: "chore: create tag %VERSION%"
push: false

# Custom tasks
grunt.registerTask "amsf-func-mkdir", "Initialize AMSF working directory", ->
grunt.file.mkdir '.amsf-cache'

grunt.registerTask "amsf-func-preupdate", "Update ASMF (preprocess)", ->
# Check if config exists
if !grunt.file.exists('_amsf.yml')
grunt.task.run [
"copy:amsf__config__to_app"
]

grunt.registerTask "amsf-func-postupdate", "Update ASMF (postprocess)", ->

# Defined tasks
grunt.registerTask "theme-upgrade", "Upgrade specific theme from AMSF cache to app", [
"shell:amsf__theme__to_app"
]
Expand Down Expand Up @@ -569,13 +607,17 @@ module.exports = (grunt) ->
]

grunt.registerTask "amsf-update", "Update ASMF", [
"amsf-func-preupdate"
"clean:amsf__core__remove_repo"
"gitclone:amsf__core__add_remote"
"copy:amsf__core__to_app"
"shell:amsf__core__update_deps"
"replace:amsf__core__update_version"
"amsf-func-postupdate"
]

grunt.registerTask "init", "Initialize new project", [
"amsf-func-mkdir"
"theme-add"
]

Expand Down
9 changes: 9 additions & 0 deletions _amsf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Almace Scaffolding preferences
#

# AMSF version
version: 0.1.8

# Current theme
theme: curtana
2 changes: 1 addition & 1 deletion _app/_posts/note/2014-06-09-creating-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,6 @@ You really like your custom design and wanna show it off to the world? Cool, you
$ grunt theme-save
```

The activated theme will be saved to AMSF cache (`_amsf/`) with correct file and directory structure, then you can upload your theme to GitHub.
The activated theme will be saved to AMSF cache (`.amsf-cache/`) with correct file and directory structure, then you can upload your theme to GitHub.

Still confusing? see my default theme [Curtana](http://github.com/amsf/amsf-curtana) for reference.
7 changes: 3 additions & 4 deletions _app/_posts/note/2014-06-10-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ $ grunt theme-add --theme=bootstrap-sass --user=sparanoid

### Manually Install

You can also install themes manually. find an AMSF theme (Curtana, for example), download the package and uncompress all files to `_amsf/themes` directory, the file structure should look like:
You can also install themes manually. find an AMSF theme (Curtana, for example), download the package and uncompress all files to `.amsf-cache/themes` directory, the file structure should look like:

```
├── _amsf/ (Almace Scaffolding cache directory)
├── .amsf-cache/ (Almace Scaffolding cache directory)
| ├── themes/
| | └── curtana/
| | | └── assets/
Expand All @@ -48,12 +48,11 @@ You can also install themes manually. find an AMSF theme (Curtana, for example),

Then execute the following command:


```sh
$ grunt activate --theme=curtana
```

You current theme will be backed up to `_amsf/themes/your-old-theme/` and the new theme `curtana` will be installed to the appropriate directories.
You current theme will be backed up to `.amsf-cache/themes/your-old-theme/` and the new theme `curtana` will be installed to the appropriate directories.

## Upgrading Themes

Expand Down
2 changes: 1 addition & 1 deletion _app/feed-atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permalink: /feed.xml
<subtitle>{{ site.description }}</subtitle>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ amsf_site_base | xml_escape }}/</id>
<generator uri="http://jekyllrb.com" version="{{ jekyll.version }}">Jekyll feat. Almace Scaffolding</generator>
<generator uri="http://sparanoid.com/lab/amsf/" version="{{ site.version }}">Almace Scaffolding</generator>

<link rel="alternate" type="text/html" hreflang="en" href="{{ amsf_site_base }}/" />
<link rel="self" type="application/atom+xml" href="{{ amsf_page_url }}" />
Expand Down
1 change: 0 additions & 1 deletion _deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Custom deployment variables
#


rsync:
user: rsync
port: 22
Expand Down

0 comments on commit 542a59b

Please sign in to comment.