WPP-Public / akqa-nz-beam

A command line utility for deploying websites to servers
MIT License
56 stars 9 forks source link

External configuration of application types (with potential for other defaults) #17

Closed camspiers closed 11 years ago

stevie-mayhew commented 11 years ago

Proposal

File Structrue

Remove "applications" type and introduce two new beam configuration commands: "patterns-server", "pattern-groups"

If the "pattern-groups" exists then a check will be made for "patterns-server".

Example configurations and expected results:

Example 1

beam.json

"exclude" : {
        "pattern-server" : "http://beam.heyday.net.nz/",
        "pattern-groups": ["base", "silverstripe"],
        "patterns" : [
            "/mysite/themes/heyday/css/custom/",
            "/meridian-day/",
            "/silverstripe-dataobjectpreview/cache/",
            "/framework/error_log",
            "node_modules",
            "themes/heyday/autosigs"
        ]
    }

Expected result: read from http://beam.heyday.net.nz/base.json and http://beam.heyday.net.nz/silverstripe.json and exclude patterns within that file.

base.json

{
    "patterns" : [
        "*~",
        ".DS_Store",
        ".gitignore",
        ".mergesources.yml",
        "README.md",
        "composer.json",
        "composer.lock",
        "deploy.json",
        "beam.json",
        "deploy.properties",
        "sftp-config.json",
        "checksums.json*",
        "/access-logs/",
        "/cgi-bin/",
        "/.idea/",
        ".svn/",
        ".git/",
        "/maintenance/on"
    ]
}

silverstripe.json

{
    "patterns" : [
        "/assets/",
        "/silverstripe-cache/",
        "/assets-generated/",
        "/cache-include/cache/",
        "/heyday-cacheinclude/cache/",
        "/silverstripe-cacheinclude/cache/"
    ]
}

Example 2

"exclude" : {
        "pattern-server" : "http://beam.heyday.net.nz/",
        "pattern-groups": ["base.json", "silverstripe.json"],
        "patterns" : [
            "/mysite/themes/heyday/css/custom/",
            "/meridian-day/",
            "/silverstripe-dataobjectpreview/cache/",
            "/framework/error_log",
            "node_modules",
            "themes/heyday/autosigs"
        ]
    }

Expected output is the same as example 1, even though the file type is specified here. This shows that we will default to a json file "base -> base.json" if the file "base" does not exist. In the case where the file "base" exists, this will be read.

Example 3

"exclude" : {
        "pattern-groups": ["custom-git-excludes.json"],
        "patterns" : [
            "/mysite/themes/heyday/css/custom/",
            "/meridian-day/",
            "/silverstripe-dataobjectpreview/cache/",
            "/framework/error_log",
            "node_modules",
            "themes/heyday/autosigs"
        ]
    }

Expected output is that the custom-git-excludes.json file will exist alongside beam.json in the root of the file structure (/source/custom-git-excludes.json for example) and will be read.

File precedence

A local version of a file will take precedence over a server version. In the case that you have specified pattern-server and pattern-groups but a file with a name in the pattern-groups exists locally it will be used instead of the version on the server.

Error Handling

An exception should be thrown if the pattern-group file cannot be found locally or at the pattern-server specified. This should be an error which interrupts/stops deployment.

stevie-mayhew commented 11 years ago

Whoops, convoluted.

Considering a local file structure of /Sites/beamtest/ with the beam file located at a /Sites/beamtest/beam.json. Checks for a configuration of

"pattern-server" : "http://beam.heyday.net.nz/",
 "pattern-groups": ["base"],

will result in the following checks, in this order: /Sites/beamtest/base /Sites/beamtest/base.json http://beam.heyday.net.nz/base http://beam.heyday.net.nz/base.json

stecman commented 11 years ago

I'm not sure about removing the ability to specify excludes from the beam.json file my reading ability. It seems unnecessarily complex to have the solution for this rely entirely somewhat on external files and HTTP requests; it's fine for us, but probably won't suit smaller scale use cases.

Additionally (as discussed a while ago), I think we need a way for excludes to be configured on a user level that doesn't require an HTTP server reading comprehension.

Considering both of these points, maybe the checks from your above post would be something like:

/home/user/.beam/patterns/base.json http://beam.heyday.net.nz/base http://beam.heyday.net.nz/base.json

camspiers commented 11 years ago

I am wondering if we should just drop the "pattern-server" thing. I know I suggested it, but it might be a bit much. If we dropped it, you would just go:

"pattern-import": ["http://beam.heyday.net.nz/paterns/base", "http://beam.heyday.net.nz/paterns/silverstripe"]

I am also wondering if we drop the json format, and just go with plain text with newlines.

With these changes we don't need to check multiple locations with different extensions etc. We can just go file_get_contents

camspiers commented 11 years ago

@stecman This proposal includes that ability. At least you can specify paths to local files

timhiggs commented 11 years ago

The pattern-server thing seemed like a cool idea - likely to be connecting to the same server in the same manner each time - but could see how it might be a bit much

shane-nzer commented 11 years ago

Wow - this is complex. I agree with Cam's points. Let's not over engineer what's essentially a small part of the tool.

stecman commented 11 years ago

We've just had an impromptu meeting about this and it's now looking more like this:

shane-nzer commented 11 years ago

Can we hold off on this please. I want to make sure our time is being invested wisely especially when there are other, more important projects going on.