the computer did it

This commit is contained in:
Ryan Haskell-Glatz 2019-11-13 21:40:55 -07:00
parent 5ca17aac39
commit 4ed173c2fc
28 changed files with 435 additions and 771 deletions

400
cli/package-lock.json generated
View File

@ -1,403 +1,5 @@
{ {
"name": "elm-spa", "name": "elm-spa",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1
"requires": true,
"dependencies": {
"ajv": {
"version": "6.10.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
"integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==",
"dev": true,
"requires": {
"fast-deep-equal": "^2.0.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"asn1": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
"integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
"dev": true,
"requires": {
"safer-buffer": "~2.1.0"
}
},
"assert-plus": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
"dev": true
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
},
"aws-sign2": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=",
"dev": true
},
"aws4": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==",
"dev": true
},
"bcrypt-pbkdf": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
"dev": true,
"requires": {
"tweetnacl": "^0.14.3"
}
},
"caseless": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
"dev": true
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"requires": {
"delayed-stream": "~1.0.0"
}
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
},
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
},
"ecc-jsbn": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
"dev": true,
"requires": {
"jsbn": "~0.1.0",
"safer-buffer": "^2.1.0"
}
},
"elm": {
"version": "0.19.1-3",
"resolved": "https://registry.npmjs.org/elm/-/elm-0.19.1-3.tgz",
"integrity": "sha512-6y36ewCcVmTOx8lj7cKJs3bhI5qMfoVEigePZ9PhEUNKpwjjML/pU2u2YSpHVAznuCcojoF6KIsrS1Ci7GtVaQ==",
"dev": true,
"requires": {
"request": "^2.88.0"
}
},
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"dev": true
},
"extsprintf": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
"integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
"dev": true
},
"fast-deep-equal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=",
"dev": true
},
"fast-json-stable-stringify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
"dev": true
},
"forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=",
"dev": true
},
"form-data": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"dev": true,
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
},
"getpass": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0"
}
},
"har-schema": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
"integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=",
"dev": true
},
"har-validator": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz",
"integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
"dev": true,
"requires": {
"ajv": "^6.5.5",
"har-schema": "^2.0.0"
}
},
"http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
"integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0",
"jsprim": "^1.2.2",
"sshpk": "^1.7.0"
}
},
"is-typedarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
},
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
"dev": true
},
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
"dev": true
},
"json-schema": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
"dev": true
},
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
},
"json-stringify-safe": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
"dev": true
},
"jsprim": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
"dev": true,
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.3.0",
"json-schema": "0.2.3",
"verror": "1.10.0"
}
},
"mime-db": {
"version": "1.42.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz",
"integrity": "sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==",
"dev": true
},
"mime-types": {
"version": "2.1.25",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.25.tgz",
"integrity": "sha512-5KhStqB5xpTAeGqKBAMgwaYMnQik7teQN4IAzC7npDv6kzeU6prfkR67bc87J1kWMPGkoaZSq1npmexMgkmEVg==",
"dev": true,
"requires": {
"mime-db": "1.42.0"
}
},
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==",
"dev": true
},
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
"dev": true
},
"psl": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw==",
"dev": true
},
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
},
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
"dev": true
},
"request": {
"version": "2.88.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
"integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
"dev": true,
"requires": {
"aws-sign2": "~0.7.0",
"aws4": "^1.8.0",
"caseless": "~0.12.0",
"combined-stream": "~1.0.6",
"extend": "~3.0.2",
"forever-agent": "~0.6.1",
"form-data": "~2.3.2",
"har-validator": "~5.1.0",
"http-signature": "~1.2.0",
"is-typedarray": "~1.0.0",
"isstream": "~0.1.2",
"json-stringify-safe": "~5.0.1",
"mime-types": "~2.1.19",
"oauth-sign": "~0.9.0",
"performance-now": "^2.1.0",
"qs": "~6.5.2",
"safe-buffer": "^5.1.2",
"tough-cookie": "~2.4.3",
"tunnel-agent": "^0.6.0",
"uuid": "^3.3.2"
}
},
"safe-buffer": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==",
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"sshpk": {
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz",
"integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==",
"dev": true,
"requires": {
"asn1": "~0.2.3",
"assert-plus": "^1.0.0",
"bcrypt-pbkdf": "^1.0.0",
"dashdash": "^1.12.0",
"ecc-jsbn": "~0.1.1",
"getpass": "^0.1.1",
"jsbn": "~0.1.0",
"safer-buffer": "^2.0.2",
"tweetnacl": "~0.14.0"
}
},
"tough-cookie": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"dev": true,
"requires": {
"psl": "^1.1.24",
"punycode": "^1.4.1"
},
"dependencies": {
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
"dev": true
}
}
},
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
"dev": true,
"requires": {
"safe-buffer": "^5.0.1"
}
},
"tweetnacl": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
"dev": true
},
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
"integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
"dev": true,
"requires": {
"punycode": "^2.1.0"
}
},
"uuid": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
"integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==",
"dev": true
},
"verror": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
"integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
"dev": true,
"requires": {
"assert-plus": "^1.0.0",
"core-util-is": "1.0.2",
"extsprintf": "^1.2.0"
}
}
}
} }

View File

@ -321,7 +321,7 @@ module {{pagesModuleName}} exposing
) )
import App.Page import App.Page
import Layout as Layout import {{layoutModuleName}} as Layout
import Utils.Spa as Spa import Utils.Spa as Spa
import {{paramsModuleName}} as Params import {{paramsModuleName}} as Params
import {{routeModuleName}} as Route exposing (Route) import {{routeModuleName}} as Route exposing (Route)
@ -381,7 +381,7 @@ init route_ =
update : Msg -> Model -> Spa.Update Model Msg update : Msg -> Model -> Spa.Update Model Msg
update bigMsg bigModel = update bigMsg bigModel =
{{pagesUpdateFunction}} {{pagesUpdateFunction}}
{{defaultUpdateCase}}
-- BUNDLE -- BUNDLE
@ -392,6 +392,7 @@ bundle bigModel =
{{pagesBundleFunction}} {{pagesBundleFunction}}
""" """
|> String.replace "{{pagesModuleName}}" (pagesModuleName details.moduleName) |> String.replace "{{pagesModuleName}}" (pagesModuleName details.moduleName)
|> String.replace "{{layoutModuleName}}" (pagesLayoutModuleName details.moduleName)
|> String.replace "{{paramsModuleName}}" (paramsModuleName details.moduleName) |> String.replace "{{paramsModuleName}}" (paramsModuleName details.moduleName)
|> String.replace "{{routeModuleName}}" (routeModuleName details.moduleName) |> String.replace "{{routeModuleName}}" (routeModuleName details.moduleName)
|> String.replace "{{pagesPageImports}}" (pagesPageImports details.files) |> String.replace "{{pagesPageImports}}" (pagesPageImports details.files)
@ -404,9 +405,26 @@ bundle bigModel =
|> String.replace "{{pagesInitFunction}}" (pagesInitFunction details) |> String.replace "{{pagesInitFunction}}" (pagesInitFunction details)
|> String.replace "{{pagesUpdateFunction}}" (pagesUpdateFunction details) |> String.replace "{{pagesUpdateFunction}}" (pagesUpdateFunction details)
|> String.replace "{{pagesBundleFunction}}" (pagesBundleFunction details) |> String.replace "{{pagesBundleFunction}}" (pagesBundleFunction details)
|> String.replace "{{defaultUpdateCase}}"
(if List.length (details.files ++ details.folders) < 2 then
""
else
"_ ->\n App.Page.keep bigModel" |> indent 2
)
|> String.trim |> String.trim
pagesLayoutModuleName : String -> String
pagesLayoutModuleName str =
case str of
"" ->
"Layout"
_ ->
"Layouts." ++ str
pagesModuleName : String -> String pagesModuleName : String -> String
pagesModuleName = pagesModuleName =
moduleNameFor "Pages" moduleNameFor "Pages"
@ -421,7 +439,8 @@ pagesPageImports files =
pagesPageModule : Filepath -> String pagesPageModule : Filepath -> String
pagesPageModule path = pagesPageModule path =
last path path
|> String.join "."
|> String.append "Pages." |> String.append "Pages."
@ -452,7 +471,7 @@ pagesCustomTypes type_ { files, folders } =
last path last path
in in
( name ++ "_Folder_" ++ type_ ( name ++ "_Folder_" ++ type_
, pagesModuleName name ++ "." ++ type_ , pagesModuleName (String.join "." path) ++ "." ++ type_
) )
in in
List.concat List.concat
@ -590,7 +609,7 @@ pagesUpdateFunction : Details -> String
pagesUpdateFunction details = pagesUpdateFunction details =
toItems details toItems details
|> List.map pagesToUpdate |> List.map pagesToUpdate
|> asCaseExpression "route_" |> asCaseExpression "( bigMsg, bigModel )"
|> indent 1 |> indent 1
@ -618,7 +637,7 @@ pagesBundleFunction : Details -> String
pagesBundleFunction details = pagesBundleFunction details =
toItems details toItems details
|> List.map pagesToBundle |> List.map pagesToBundle
|> asCaseExpression "route_" |> asCaseExpression "bigModel"
|> indent 1 |> indent 1
@ -631,7 +650,7 @@ pagesToBundle item =
|> String.replace "{{uncapitalized}}" (uncapitalize (last path)) |> String.replace "{{uncapitalized}}" (uncapitalize (last path))
DynamicFile path -> DynamicFile path ->
"Dynamic model ->\n recipes.dynamic.bundle model" "DynamicModel model ->\n recipes.dynamic.bundle model"
StaticFolder path -> StaticFolder path ->
"{{name}}_Folder_Model model ->\n recipes.{{uncapitalized}}_folder.bundle model" "{{name}}_Folder_Model model ->\n recipes.{{uncapitalized}}_folder.bundle model"
@ -639,7 +658,7 @@ pagesToBundle item =
|> String.replace "{{uncapitalized}}" (uncapitalize (last path)) |> String.replace "{{uncapitalized}}" (uncapitalize (last path))
DynamicFolder path -> DynamicFolder path ->
"Dynamic_Folder model ->\n recipes.dynamic_folder.bundle model" "Dynamic_Folder_Model model ->\n recipes.dynamic_folder.bundle model"

View File

@ -8,7 +8,9 @@ import Set exposing (Set)
type alias Flags = type alias Flags =
List Filepath { command : String
, paths : List Filepath
}
type alias Filepath = type alias Filepath =
@ -18,14 +20,24 @@ type alias Filepath =
main : Program Flags () Never main : Program Flags () Never
main = main =
Platform.worker Platform.worker
{ init = \json -> ( (), parse json ) { init = \flags -> ( (), handle flags )
, update = \_ model -> ( model, Cmd.none ) , update = \_ model -> ( model, Cmd.none )
, subscriptions = always Sub.none , subscriptions = always Sub.none
} }
parse : List Filepath -> Cmd msg handle : Flags -> Cmd msg
parse files = handle flags =
case flags.command of
"build" ->
build flags.paths
_ ->
Cmd.none
build : List Filepath -> Cmd msg
build files =
List.concat List.concat
[ [ File [ "Routes" ] (File.routes files) ] [ [ File [ "Routes" ] (File.routes files) ]
, files , files
@ -37,7 +49,7 @@ parse files =
, File.pages , File.pages
] ]
] ]
|> Ports.sendFiles |> Ports.generate

View File

@ -1,4 +1,4 @@
port module Ports exposing (sendFiles) port module Ports exposing (generate)
import File exposing (File) import File exposing (File)
import Json.Encode as Json import Json.Encode as Json
@ -11,9 +11,9 @@ port outgoing :
-> Cmd msg -> Cmd msg
sendFiles : List File -> Cmd msg generate : List File -> Cmd msg
sendFiles files = generate files =
outgoing outgoing
{ message = "sendFiles" { message = "generate"
, data = Json.list File.encode files , data = Json.list File.encode files
} }

58
cli/src/index.js Normal file → Executable file
View File

@ -1,11 +1,61 @@
const path = require('path') const path = require('path')
const cwd = process.cwd() const cwd = process.cwd()
const { File, Elm } = require('./utils.js') const { File, Elm, bold } = require('./utils.js')
const start = () => const start = ([ command, ...args ] = []) =>
File.paths(path.join(cwd, '..', 'examples', 'complex', 'src', 'Pages')) commands[command]
.then(Elm.run) ? commands[command](args)
: commands.help(args)
// elm-spa build
const build = ([ relative = '.' ]) =>
File.paths(path.join(cwd, relative, 'src', 'Pages'))
.then(Elm.run('build', { relative }))
.then(console.info) .then(console.info)
.catch(console.error) .catch(console.error)
const help = () => console.info(`
usage: ${bold('elm-spa')} <command> [...]
commands:
${bold('init')} [options] <path> create a new project at <path>
options:
${bold('--ui=')}<module> the module your \`view\` uses (default: Html)
examples:
${bold('elm-spa init your-project')}
${bold('elm-spa init --ui=Element your-project')}
${bold('build')} <path> generate pages and routes
examples:
${bold('elm-spa build .')}
${bold('add')} static <module> create a new static page
sandbox <module> create a new sandbox page
element <module> create a new element page
component <module> create a new component page
examples:
${bold('elm-spa add static AboutUs')}
${bold('elm-spa add element Settings.Index')}
${bold('help')} print this help screen
examples:
${bold('elm-spa help')}
${bold('elm-spa wat')}
${bold('elm-spa huh?')}
`)
const commands = {
build,
help
}
start(process.argv.slice(2)) start(process.argv.slice(2))

View File

@ -1,6 +1,8 @@
const File = (_ => {
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
const cwd = process.cwd()
const File = (_ => {
const mkdir = (filepath) => const mkdir = (filepath) =>
new Promise((resolve, reject) => new Promise((resolve, reject) =>
@ -8,6 +10,9 @@ const File = (_ => {
) )
const create = (filepath, contents) => { const create = (filepath, contents) => {
// this will surely break windows, im tired and sorry i wrote this line.
const folderOf = (path) => path.split('/').slice(0, -1).join('/')
const write = (filepath, contents) => const write = (filepath, contents) =>
new Promise((resolve, reject) => new Promise((resolve, reject) =>
fs.writeFile(filepath, contents, { encoding: 'utf8' }, (err) => fs.writeFile(filepath, contents, { encoding: 'utf8' }, (err) =>
@ -61,20 +66,24 @@ const Elm = (_ => {
const { Elm } = require('../dist/elm.compiled.js') const { Elm } = require('../dist/elm.compiled.js')
const handlers = { const handlers = {
sendFiles: (data) => generate: ({ relative }, files) =>
data.forEach(a => Promise.all(
console.log() || files
console.log(bold(a.filepath.join('/') + '.elm')) || .map(item => ({
console.log('\n' + a.contents + '\n')) ...item,
filepath: path.join(cwd, relative, 'elm-stuff', '.elm-spa', 'Generated', ...item.filepath) + '.elm'
}))
.map(item => File.create(item.filepath, item.contents))
)
} }
const run = paths => const run = (command, args) => (paths) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
const app = Elm.Main.init({ flags: paths }) const app = Elm.Main.init({ flags: { command, paths } })
app.ports.outgoing.subscribe(({ message, data }) => app.ports.outgoing.subscribe(({ message, data }) =>
handlers[message] handlers[message]
? Promise.resolve(handlers[message](data)).then(resolve).catch(reject) ? Promise.resolve(handlers[message](args, data)).then(resolve).catch(reject)
: reject(`Didn't recognize message "${message}" Yell at @ryannhg on the internet!\n`) : reject(`Didn't recognize message "${message}" Yell at @ryannhg on the internet!\n`)
) )
}) })
@ -86,5 +95,6 @@ const bold = str => '\033[1m' + str + '\033[0m'
module.exports = { module.exports = {
Elm, Elm,
File File,
bold
} }

View File

@ -5,12 +5,14 @@ module Generated.Docs.Pages exposing
) )
import App.Page import App.Page
import Layouts.Docs as Layout
import Utils.Spa as Spa
import Generated.Docs.Params as Params import Generated.Docs.Params as Params
import Generated.Docs.Route as Route exposing (Route) import Generated.Docs.Route as Route exposing (Route)
import Layouts.Docs as Layout
import Pages.Docs.Dynamic import Pages.Docs.Dynamic
import Pages.Docs.Static import Pages.Docs.Static
import Utils.Spa as Spa exposing (Page)
type Model type Model
@ -23,7 +25,7 @@ type Msg
| StaticMsg Pages.Docs.Static.Msg | StaticMsg Pages.Docs.Static.Msg
page : Page Route Model Msg layoutModel layoutMsg appMsg page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
page = page =
Spa.layout Spa.layout
{ view = Layout.view { view = Layout.view
@ -71,13 +73,13 @@ recipes =
init : Route -> Spa.Init Model Msg init : Route -> Spa.Init Model Msg
init route = init route_ =
case route of case route_ of
Route.Dynamic _ flags -> Route.Static params ->
recipes.dynamic.init flags recipes.static.init params
Route.Static flags -> Route.Dynamic _ params ->
recipes.static.init flags recipes.dynamic.init params
@ -87,25 +89,23 @@ init route =
update : Msg -> Model -> Spa.Update Model Msg update : Msg -> Model -> Spa.Update Model Msg
update bigMsg bigModel = update bigMsg bigModel =
case ( bigMsg, bigModel ) of case ( bigMsg, bigModel ) of
( DynamicMsg msg, DynamicModel model ) ->
recipes.dynamic.update msg model
( StaticMsg msg, StaticModel model ) -> ( StaticMsg msg, StaticModel model ) ->
recipes.static.update msg model recipes.static.update msg model
( DynamicMsg msg, DynamicModel model ) ->
recipes.dynamic.update msg model
_ -> _ ->
App.Page.keep bigModel App.Page.keep bigModel
-- BUNDLE -- BUNDLE
bundle : Model -> Spa.Bundle Msg msg bundle : Model -> Spa.Bundle Msg msg
bundle bigModel = bundle bigModel =
case bigModel of case bigModel of
DynamicModel model ->
recipes.dynamic.bundle model
StaticModel model -> StaticModel model ->
recipes.static.bundle model recipes.static.bundle model
DynamicModel model ->
recipes.dynamic.bundle model

View File

@ -1,13 +1,10 @@
module Generated.Docs.Params exposing module Generated.Docs.Params exposing (..)
( Dynamic
, Static
)
type alias Static =
{}
type alias Dynamic = type alias Dynamic =
{ param1 : String { param1 : String
} }
type alias Static =
{}

View File

@ -7,8 +7,8 @@ import Generated.Docs.Params as Params
type Route type Route
= Static Params.Static = Dynamic String Params.Dynamic
| Dynamic String Params.Dynamic | Static Params.Static
toPath : Route -> String toPath : Route -> String
@ -17,5 +17,6 @@ toPath route =
Static _ -> Static _ ->
"/static" "/static"
Dynamic value _ -> Dynamic value _ ->
"/" ++ value "/" ++ value

View File

@ -5,11 +5,13 @@ module Generated.Guide.Dynamic.Dynamic.Pages exposing
) )
import App.Page import App.Page
import Layouts.Guide.Dynamic.Dynamic as Layout
import Utils.Spa as Spa
import Generated.Guide.Dynamic.Dynamic.Params as Params import Generated.Guide.Dynamic.Dynamic.Params as Params
import Generated.Guide.Dynamic.Dynamic.Route as Route exposing (Route) import Generated.Guide.Dynamic.Dynamic.Route as Route exposing (Route)
import Layouts.Guide.Dynamic.Dynamic as Layout
import Pages.Guide.Dynamic.Dynamic.Top import Pages.Guide.Dynamic.Dynamic.Top
import Utils.Spa as Spa exposing (Page)
type Model type Model
@ -20,7 +22,7 @@ type Msg
= TopMsg Pages.Guide.Dynamic.Dynamic.Top.Msg = TopMsg Pages.Guide.Dynamic.Dynamic.Top.Msg
page : Page Route Model Msg layoutModel layoutMsg appMsg page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
page = page =
Spa.layout Spa.layout
{ view = Layout.view { view = Layout.view
@ -61,10 +63,10 @@ recipes =
init : Route -> Spa.Init Model Msg init : Route -> Spa.Init Model Msg
init route = init route_ =
case route of case route_ of
Route.Top flags -> Route.Top params ->
recipes.top.init flags recipes.top.init params

View File

@ -1,4 +1,4 @@
module Generated.Guide.Dynamic.Dynamic.Params exposing (Top) module Generated.Guide.Dynamic.Dynamic.Params exposing (..)
type alias Top = type alias Top =

View File

@ -14,4 +14,4 @@ toPath : Route -> String
toPath route = toPath route =
case route of case route of
Top _ -> Top _ ->
"/" "/top"

View File

@ -5,11 +5,13 @@ module Generated.Guide.Dynamic.Faq.Pages exposing
) )
import App.Page import App.Page
import Layouts.Guide.Dynamic.Faq as Layout
import Utils.Spa as Spa
import Generated.Guide.Dynamic.Faq.Params as Params import Generated.Guide.Dynamic.Faq.Params as Params
import Generated.Guide.Dynamic.Faq.Route as Route exposing (Route) import Generated.Guide.Dynamic.Faq.Route as Route exposing (Route)
import Layouts.Guide.Dynamic.Faq as Layout
import Pages.Guide.Dynamic.Faq.Top import Pages.Guide.Dynamic.Faq.Top
import Utils.Spa as Spa exposing (Page)
type Model type Model
@ -20,7 +22,7 @@ type Msg
= TopMsg Pages.Guide.Dynamic.Faq.Top.Msg = TopMsg Pages.Guide.Dynamic.Faq.Top.Msg
page : Page Route Model Msg layoutModel layoutMsg appMsg page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
page = page =
Spa.layout Spa.layout
{ view = Layout.view { view = Layout.view
@ -61,10 +63,10 @@ recipes =
init : Route -> Spa.Init Model Msg init : Route -> Spa.Init Model Msg
init route = init route_ =
case route of case route_ of
Route.Top flags -> Route.Top params ->
recipes.top.init flags recipes.top.init params

View File

@ -1,4 +1,4 @@
module Generated.Guide.Dynamic.Faq.Params exposing (Top) module Generated.Guide.Dynamic.Faq.Params exposing (..)
type alias Top = type alias Top =

View File

@ -14,4 +14,4 @@ toPath : Route -> String
toPath route = toPath route =
case route of case route of
Top _ -> Top _ ->
"/" "/top"

View File

@ -5,36 +5,33 @@ module Generated.Guide.Dynamic.Pages exposing
) )
import App.Page import App.Page
import Generated.Guide.Dynamic.Dynamic.Pages import Layouts.Guide.Dynamic as Layout
import Generated.Guide.Dynamic.Dynamic.Route import Utils.Spa as Spa
import Generated.Guide.Dynamic.Faq.Pages
import Generated.Guide.Dynamic.Faq.Route
import Generated.Guide.Dynamic.Params as Params import Generated.Guide.Dynamic.Params as Params
import Generated.Guide.Dynamic.Route as Route exposing (Route) import Generated.Guide.Dynamic.Route as Route exposing (Route)
import Layouts.Guide.Dynamic as Layout
import Pages.Guide.Dynamic.Dynamic
import Pages.Guide.Dynamic.Intro import Pages.Guide.Dynamic.Intro
import Pages.Guide.Dynamic.Other import Pages.Guide.Dynamic.Other
import Utils.Spa as Spa exposing (Page) import Generated.Guide.Dynamic.Dynamic.Route
import Generated.Guide.Dynamic.Faq.Route
import Generated.Guide.Dynamic.Dynamic.Pages
import Generated.Guide.Dynamic.Faq.Pages
type Model type Model
= IntroModel Pages.Guide.Dynamic.Intro.Model = IntroModel Pages.Guide.Dynamic.Intro.Model
| OtherModel Pages.Guide.Dynamic.Other.Model | OtherModel Pages.Guide.Dynamic.Other.Model
| DynamicModel Pages.Guide.Dynamic.Dynamic.Model | Dynamic_Folder_Model Generated.Guide.Dynamic.Dynamic.Pages.Model
| Faq_FolderModel Generated.Guide.Dynamic.Faq.Pages.Model | Faq_Folder_Model Generated.Guide.Dynamic.Faq.Pages.Model
| Dynamic_FolderModel Generated.Guide.Dynamic.Dynamic.Pages.Model
type Msg type Msg
= IntroMsg Pages.Guide.Dynamic.Intro.Msg = IntroMsg Pages.Guide.Dynamic.Intro.Msg
| OtherMsg Pages.Guide.Dynamic.Other.Msg | OtherMsg Pages.Guide.Dynamic.Other.Msg
| DynamicMsg Pages.Guide.Dynamic.Dynamic.Msg | Dynamic_Folder_Msg Generated.Guide.Dynamic.Dynamic.Pages.Msg
| Faq_FolderMsg Generated.Guide.Dynamic.Faq.Pages.Msg | Faq_Folder_Msg Generated.Guide.Dynamic.Faq.Pages.Msg
| Dynamic_FolderMsg Generated.Guide.Dynamic.Dynamic.Pages.Msg
page : Page Route Model Msg layoutModel layoutMsg appMsg page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
page = page =
Spa.layout Spa.layout
{ view = Layout.view { view = Layout.view
@ -57,9 +54,8 @@ type alias Recipe flags model msg appMsg =
type alias Recipes msg = type alias Recipes msg =
{ intro : Recipe Params.Intro Pages.Guide.Dynamic.Intro.Model Pages.Guide.Dynamic.Intro.Msg msg { intro : Recipe Params.Intro Pages.Guide.Dynamic.Intro.Model Pages.Guide.Dynamic.Intro.Msg msg
, other : Recipe Params.Other Pages.Guide.Dynamic.Other.Model Pages.Guide.Dynamic.Other.Msg msg , other : Recipe Params.Other Pages.Guide.Dynamic.Other.Model Pages.Guide.Dynamic.Other.Msg msg
, dynamic : Recipe Params.Dynamic Pages.Guide.Dynamic.Dynamic.Model Pages.Guide.Dynamic.Dynamic.Msg msg
, faq_folder : Recipe Generated.Guide.Dynamic.Faq.Route.Route Generated.Guide.Dynamic.Faq.Pages.Model Generated.Guide.Dynamic.Faq.Pages.Msg msg
, dynamic_folder : Recipe Generated.Guide.Dynamic.Dynamic.Route.Route Generated.Guide.Dynamic.Dynamic.Pages.Model Generated.Guide.Dynamic.Dynamic.Pages.Msg msg , dynamic_folder : Recipe Generated.Guide.Dynamic.Dynamic.Route.Route Generated.Guide.Dynamic.Dynamic.Pages.Model Generated.Guide.Dynamic.Dynamic.Pages.Msg msg
, faq_folder : Recipe Generated.Guide.Dynamic.Faq.Route.Route Generated.Guide.Dynamic.Faq.Pages.Model Generated.Guide.Dynamic.Faq.Pages.Msg msg
} }
@ -77,23 +73,17 @@ recipes =
, toModel = OtherModel , toModel = OtherModel
, toMsg = OtherMsg , toMsg = OtherMsg
} }
, dynamic = , dynamic_folder =
Spa.recipe Spa.recipe
{ page = Pages.Guide.Dynamic.Dynamic.page { page = Generated.Guide.Dynamic.Dynamic.Pages.page
, toModel = DynamicModel , toModel = Dynamic_Folder_Model
, toMsg = DynamicMsg , toMsg = Dynamic_Folder_Msg
} }
, faq_folder = , faq_folder =
Spa.recipe Spa.recipe
{ page = Generated.Guide.Dynamic.Faq.Pages.page { page = Generated.Guide.Dynamic.Faq.Pages.page
, toModel = Faq_FolderModel , toModel = Faq_Folder_Model
, toMsg = Faq_FolderMsg , toMsg = Faq_Folder_Msg
}
, dynamic_folder =
Spa.recipe
{ page = Generated.Guide.Dynamic.Dynamic.Pages.page
, toModel = Dynamic_FolderModel
, toMsg = Dynamic_FolderMsg
} }
} }
@ -103,22 +93,19 @@ recipes =
init : Route -> Spa.Init Model Msg init : Route -> Spa.Init Model Msg
init route = init route_ =
case route of case route_ of
Route.Intro flags -> Route.Intro params ->
recipes.intro.init flags recipes.intro.init params
Route.Other flags -> Route.Other params ->
recipes.other.init flags recipes.other.init params
Route.Dynamic _ flags -> Route.Faq_Folder route ->
recipes.dynamic.init flags recipes.faq_folder.init route
Route.Faq_Folder flags -> Route.Dynamic_Folder _ route ->
recipes.faq_folder.init flags recipes.dynamic_folder.init route
Route.Dynamic_Folder _ flags ->
recipes.dynamic_folder.init flags
@ -134,20 +121,15 @@ update bigMsg bigModel =
( OtherMsg msg, OtherModel model ) -> ( OtherMsg msg, OtherModel model ) ->
recipes.other.update msg model recipes.other.update msg model
( DynamicMsg msg, DynamicModel model ) -> ( Faq_Folder_Msg msg, Faq_Folder_Model model ) ->
recipes.dynamic.update msg model
( Faq_FolderMsg msg, Faq_FolderModel model ) ->
recipes.faq_folder.update msg model recipes.faq_folder.update msg model
( Dynamic_FolderMsg msg, Dynamic_FolderModel model ) -> ( Dynamic_Folder_Msg msg, Dynamic_Folder_Model model ) ->
recipes.dynamic_folder.update msg model recipes.dynamic_folder.update msg model
_ -> _ ->
App.Page.keep bigModel App.Page.keep bigModel
-- BUNDLE -- BUNDLE
@ -160,11 +142,8 @@ bundle bigModel =
OtherModel model -> OtherModel model ->
recipes.other.bundle model recipes.other.bundle model
DynamicModel model -> Faq_Folder_Model model ->
recipes.dynamic.bundle model
Faq_FolderModel model ->
recipes.faq_folder.bundle model recipes.faq_folder.bundle model
Dynamic_FolderModel model -> Dynamic_Folder_Model model ->
recipes.dynamic_folder.bundle model recipes.dynamic_folder.bundle model

View File

@ -1,8 +1,4 @@
module Generated.Guide.Dynamic.Params exposing module Generated.Guide.Dynamic.Params exposing (..)
( Dynamic
, Intro
, Other
)
type alias Intro = type alias Intro =
@ -13,9 +9,3 @@ type alias Intro =
type alias Other = type alias Other =
{ param1 : String { param1 : String
} }
type alias Dynamic =
{ param1 : String
, param2 : String
}

View File

@ -3,17 +3,16 @@ module Generated.Guide.Dynamic.Route exposing
, toPath , toPath
) )
import Generated.Guide.Dynamic.Params as Params
import Generated.Guide.Dynamic.Dynamic.Route import Generated.Guide.Dynamic.Dynamic.Route
import Generated.Guide.Dynamic.Faq.Route import Generated.Guide.Dynamic.Faq.Route
import Generated.Guide.Dynamic.Params as Params
type Route type Route
= Intro Params.Intro = Intro Params.Intro
| Other Params.Other | Other Params.Other
| Dynamic String Params.Dynamic
| Faq_Folder Generated.Guide.Dynamic.Faq.Route.Route
| Dynamic_Folder String Generated.Guide.Dynamic.Dynamic.Route.Route | Dynamic_Folder String Generated.Guide.Dynamic.Dynamic.Route.Route
| Faq_Folder Generated.Guide.Dynamic.Faq.Route.Route
toPath : Route -> String toPath : Route -> String
@ -22,14 +21,14 @@ toPath route =
Intro _ -> Intro _ ->
"/intro" "/intro"
Other _ -> Other _ ->
"/other" "/other"
Dynamic value _ ->
"/" ++ value
Faq_Folder subRoute -> Faq_Folder subRoute ->
"/faq" ++ Generated.Guide.Dynamic.Faq.Route.toPath subRoute "/faq" ++ Generated.Guide.Dynamic.Faq.Route.toPath subRoute
Dynamic_Folder value subRoute -> Dynamic_Folder value subRoute ->
"/" ++ value ++ Generated.Guide.Dynamic.Dynamic.Route.toPath subRoute "/" ++ value ++ Generated.Guide.Dynamic.Dynamic.Route.toPath subRoute

View File

@ -5,15 +5,15 @@ module Generated.Guide.Pages exposing
) )
import App.Page import App.Page
import Generated.Guide.Dynamic.Pages import Layouts.Guide as Layout
import Generated.Guide.Dynamic.Route import Utils.Spa as Spa
import Generated.Guide.Params as Params import Generated.Guide.Params as Params
import Generated.Guide.Route as Route exposing (Route) import Generated.Guide.Route as Route exposing (Route)
import Layouts.Guide as Layout
import Pages.Guide.Elm import Pages.Guide.Elm
import Pages.Guide.ElmSpa import Pages.Guide.ElmSpa
import Pages.Guide.Programming import Pages.Guide.Programming
import Utils.Spa as Spa exposing (Page) import Generated.Guide.Dynamic.Route
import Generated.Guide.Dynamic.Pages
type Model type Model
@ -30,7 +30,7 @@ type Msg
| Dynamic_Folder_Msg Generated.Guide.Dynamic.Pages.Msg | Dynamic_Folder_Msg Generated.Guide.Dynamic.Pages.Msg
page : Page Route Model Msg layoutModel layoutMsg appMsg page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
page = page =
Spa.layout Spa.layout
{ view = Layout.view { view = Layout.view
@ -52,7 +52,7 @@ type alias Recipe flags model msg appMsg =
type alias Recipes msg = type alias Recipes msg =
{ elm : Recipe Params.Elm Pages.Guide.Elm.Model Pages.Guide.Elm.Msg msg { elm : Recipe Params.Elm Pages.Guide.Elm.Model Pages.Guide.Elm.Msg msg
, elmApp : Recipe Params.ElmSpa Pages.Guide.ElmSpa.Model Pages.Guide.ElmSpa.Msg msg , elmSpa : Recipe Params.ElmSpa Pages.Guide.ElmSpa.Model Pages.Guide.ElmSpa.Msg msg
, programming : Recipe Params.Programming Pages.Guide.Programming.Model Pages.Guide.Programming.Msg msg , programming : Recipe Params.Programming Pages.Guide.Programming.Model Pages.Guide.Programming.Msg msg
, dynamic_folder : Recipe Generated.Guide.Dynamic.Route.Route Generated.Guide.Dynamic.Pages.Model Generated.Guide.Dynamic.Pages.Msg msg , dynamic_folder : Recipe Generated.Guide.Dynamic.Route.Route Generated.Guide.Dynamic.Pages.Model Generated.Guide.Dynamic.Pages.Msg msg
} }
@ -66,7 +66,7 @@ recipes =
, toModel = ElmModel , toModel = ElmModel
, toMsg = ElmMsg , toMsg = ElmMsg
} }
, elmApp = , elmSpa =
Spa.recipe Spa.recipe
{ page = Pages.Guide.ElmSpa.page { page = Pages.Guide.ElmSpa.page
, toModel = ElmSpaModel , toModel = ElmSpaModel
@ -92,19 +92,19 @@ recipes =
init : Route -> Spa.Init Model Msg init : Route -> Spa.Init Model Msg
init route = init route_ =
case route of case route_ of
Route.Elm flags -> Route.Elm params ->
recipes.elm.init flags recipes.elm.init params
Route.ElmSpa flags -> Route.ElmSpa params ->
recipes.elmApp.init flags recipes.elmSpa.init params
Route.Programming flags -> Route.Programming params ->
recipes.programming.init flags recipes.programming.init params
Route.Dynamic_Folder flags route_ -> Route.Dynamic_Folder _ route ->
recipes.dynamic_folder.init route_ recipes.dynamic_folder.init route
@ -118,19 +118,17 @@ update bigMsg bigModel =
recipes.elm.update msg model recipes.elm.update msg model
( ElmSpaMsg msg, ElmSpaModel model ) -> ( ElmSpaMsg msg, ElmSpaModel model ) ->
recipes.elmApp.update msg model recipes.elmSpa.update msg model
( ProgrammingMsg msg, ProgrammingModel model ) -> ( ProgrammingMsg msg, ProgrammingModel model ) ->
recipes.programming.update msg model recipes.programming.update msg model
( Dynamic_Folder_Msg msg, Dynamic_Folder_Model model ) -> ( Dynamic_Folder_Msg msg, Dynamic_Folder_Model model ) ->
recipes.dynamic_folder.update msg model recipes.dynamic_folder.update msg model
_ -> _ ->
App.Page.keep bigModel App.Page.keep bigModel
-- BUNDLE -- BUNDLE
@ -141,7 +139,7 @@ bundle bigModel =
recipes.elm.bundle model recipes.elm.bundle model
ElmSpaModel model -> ElmSpaModel model ->
recipes.elmApp.bundle model recipes.elmSpa.bundle model
ProgrammingModel model -> ProgrammingModel model ->
recipes.programming.bundle model recipes.programming.bundle model

View File

@ -1,8 +1,4 @@
module Generated.Guide.Params exposing module Generated.Guide.Params exposing (..)
( Elm
, ElmSpa
, Programming
)
type alias Elm = type alias Elm =

View File

@ -3,15 +3,15 @@ module Generated.Guide.Route exposing
, toPath , toPath
) )
import Generated.Guide.Dynamic.Route as Dynamic_Routes
import Generated.Guide.Params as Params import Generated.Guide.Params as Params
import Generated.Guide.Dynamic.Route
type Route type Route
= Elm Params.Elm = Elm Params.Elm
| ElmSpa Params.ElmSpa | ElmSpa Params.ElmSpa
| Programming Params.Programming | Programming Params.Programming
| Dynamic_Folder String Dynamic_Routes.Route | Dynamic_Folder String Generated.Guide.Dynamic.Route.Route
toPath : Route -> String toPath : Route -> String
@ -20,11 +20,14 @@ toPath route =
Elm _ -> Elm _ ->
"/elm" "/elm"
ElmSpa _ -> ElmSpa _ ->
"/elm-spa" "/elm-spa"
Programming _ -> Programming _ ->
"/programming" "/programming"
Dynamic_Folder value subRoute -> Dynamic_Folder value subRoute ->
"/" ++ value ++ Dynamic_Routes.toPath subRoute "/" ++ value ++ Generated.Guide.Dynamic.Route.toPath subRoute

View File

@ -5,39 +5,39 @@ module Generated.Pages exposing
) )
import App.Page import App.Page
import Generated.Docs.Pages import Layout as Layout
import Generated.Docs.Route import Utils.Spa as Spa
import Generated.Guide.Pages
import Generated.Guide.Route
import Generated.Params as Params import Generated.Params as Params
import Generated.Route as Route exposing (Route) import Generated.Route as Route exposing (Route)
import Layout as Layout
import Pages.Docs import Pages.Docs
import Pages.Guide import Pages.Guide
import Pages.NotFound import Pages.NotFound
import Pages.SignIn import Pages.SignIn
import Pages.Top import Pages.Top
import Utils.Spa as Spa import Generated.Docs.Route
import Generated.Guide.Route
import Generated.Docs.Pages
import Generated.Guide.Pages
type Model type Model
= TopModel Pages.Top.Model = DocsModel Pages.Docs.Model
| DocsModel Pages.Docs.Model | GuideModel Pages.Guide.Model
| NotFoundModel Pages.NotFound.Model | NotFoundModel Pages.NotFound.Model
| SignInModel Pages.SignIn.Model | SignInModel Pages.SignIn.Model
| GuideModel Pages.Guide.Model | TopModel Pages.Top.Model
| Guide_Folder_Model Generated.Guide.Pages.Model
| Docs_Folder_Model Generated.Docs.Pages.Model | Docs_Folder_Model Generated.Docs.Pages.Model
| Guide_Folder_Model Generated.Guide.Pages.Model
type Msg type Msg
= TopMsg Pages.Top.Msg = DocsMsg Pages.Docs.Msg
| DocsMsg Pages.Docs.Msg | GuideMsg Pages.Guide.Msg
| NotFoundMsg Pages.NotFound.Msg | NotFoundMsg Pages.NotFound.Msg
| SignInMsg Pages.SignIn.Msg | SignInMsg Pages.SignIn.Msg
| GuideMsg Pages.Guide.Msg | TopMsg Pages.Top.Msg
| Guide_Folder_Msg Generated.Guide.Pages.Msg
| Docs_Folder_Msg Generated.Docs.Pages.Msg | Docs_Folder_Msg Generated.Docs.Pages.Msg
| Guide_Folder_Msg Generated.Guide.Pages.Msg
page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg page : Spa.Page Route Model Msg layoutModel layoutMsg appMsg
@ -61,30 +61,30 @@ type alias Recipe flags model msg appMsg =
type alias Recipes msg = type alias Recipes msg =
{ top : Recipe Params.Top Pages.Top.Model Pages.Top.Msg msg { docs : Recipe Params.Docs Pages.Docs.Model Pages.Docs.Msg msg
, docs : Recipe Params.Docs Pages.Docs.Model Pages.Docs.Msg msg , guide : Recipe Params.Guide Pages.Guide.Model Pages.Guide.Msg msg
, notFound : Recipe Params.NotFound Pages.NotFound.Model Pages.NotFound.Msg msg , notFound : Recipe Params.NotFound Pages.NotFound.Model Pages.NotFound.Msg msg
, signIn : Recipe Params.SignIn Pages.SignIn.Model Pages.SignIn.Msg msg , signIn : Recipe Params.SignIn Pages.SignIn.Model Pages.SignIn.Msg msg
, guide : Recipe Params.Guide Pages.Guide.Model Pages.Guide.Msg msg , top : Recipe Params.Top Pages.Top.Model Pages.Top.Msg msg
, guide_folder : Recipe Generated.Guide.Route.Route Generated.Guide.Pages.Model Generated.Guide.Pages.Msg msg
, docs_folder : Recipe Generated.Docs.Route.Route Generated.Docs.Pages.Model Generated.Docs.Pages.Msg msg , docs_folder : Recipe Generated.Docs.Route.Route Generated.Docs.Pages.Model Generated.Docs.Pages.Msg msg
, guide_folder : Recipe Generated.Guide.Route.Route Generated.Guide.Pages.Model Generated.Guide.Pages.Msg msg
} }
recipes : Recipes msg recipes : Recipes msg
recipes = recipes =
{ top = { docs =
Spa.recipe
{ page = Pages.Top.page
, toModel = TopModel
, toMsg = TopMsg
}
, docs =
Spa.recipe Spa.recipe
{ page = Pages.Docs.page { page = Pages.Docs.page
, toModel = DocsModel , toModel = DocsModel
, toMsg = DocsMsg , toMsg = DocsMsg
} }
, guide =
Spa.recipe
{ page = Pages.Guide.page
, toModel = GuideModel
, toMsg = GuideMsg
}
, notFound = , notFound =
Spa.recipe Spa.recipe
{ page = Pages.NotFound.page { page = Pages.NotFound.page
@ -97,17 +97,11 @@ recipes =
, toModel = SignInModel , toModel = SignInModel
, toMsg = SignInMsg , toMsg = SignInMsg
} }
, guide = , top =
Spa.recipe Spa.recipe
{ page = Pages.Guide.page { page = Pages.Top.page
, toModel = GuideModel , toModel = TopModel
, toMsg = GuideMsg , toMsg = TopMsg
}
, guide_folder =
Spa.recipe
{ page = Generated.Guide.Pages.page
, toModel = Guide_Folder_Model
, toMsg = Guide_Folder_Msg
} }
, docs_folder = , docs_folder =
Spa.recipe Spa.recipe
@ -115,6 +109,12 @@ recipes =
, toModel = Docs_Folder_Model , toModel = Docs_Folder_Model
, toMsg = Docs_Folder_Msg , toMsg = Docs_Folder_Msg
} }
, guide_folder =
Spa.recipe
{ page = Generated.Guide.Pages.page
, toModel = Guide_Folder_Model
, toMsg = Guide_Folder_Msg
}
} }
@ -125,27 +125,27 @@ recipes =
init : Route -> Spa.Init Model Msg init : Route -> Spa.Init Model Msg
init route_ = init route_ =
case route_ of case route_ of
Route.Top flags -> Route.Docs params ->
recipes.top.init flags recipes.docs.init params
Route.Docs flags -> Route.Guide params ->
recipes.docs.init flags recipes.guide.init params
Route.NotFound flags -> Route.NotFound params ->
recipes.notFound.init flags recipes.notFound.init params
Route.SignIn flags -> Route.SignIn params ->
recipes.signIn.init flags recipes.signIn.init params
Route.Guide flags -> Route.Top params ->
recipes.guide.init flags recipes.top.init params
Route.Guide_Folder route ->
recipes.guide_folder.init route
Route.Docs_Folder route -> Route.Docs_Folder route ->
recipes.docs_folder.init route recipes.docs_folder.init route
Route.Guide_Folder route ->
recipes.guide_folder.init route
-- UPDATE -- UPDATE
@ -154,55 +154,53 @@ init route_ =
update : Msg -> Model -> Spa.Update Model Msg update : Msg -> Model -> Spa.Update Model Msg
update bigMsg bigModel = update bigMsg bigModel =
case ( bigMsg, bigModel ) of case ( bigMsg, bigModel ) of
( TopMsg msg, TopModel model ) ->
recipes.top.update msg model
( DocsMsg msg, DocsModel model ) -> ( DocsMsg msg, DocsModel model ) ->
recipes.docs.update msg model recipes.docs.update msg model
( GuideMsg msg, GuideModel model ) ->
recipes.guide.update msg model
( NotFoundMsg msg, NotFoundModel model ) -> ( NotFoundMsg msg, NotFoundModel model ) ->
recipes.notFound.update msg model recipes.notFound.update msg model
( SignInMsg msg, SignInModel model ) -> ( SignInMsg msg, SignInModel model ) ->
recipes.signIn.update msg model recipes.signIn.update msg model
( GuideMsg msg, GuideModel model ) -> ( TopMsg msg, TopModel model ) ->
recipes.guide.update msg model recipes.top.update msg model
( Guide_Folder_Msg msg, Guide_Folder_Model model ) ->
recipes.guide_folder.update msg model
( Docs_Folder_Msg msg, Docs_Folder_Model model ) -> ( Docs_Folder_Msg msg, Docs_Folder_Model model ) ->
recipes.docs_folder.update msg model recipes.docs_folder.update msg model
( Guide_Folder_Msg msg, Guide_Folder_Model model ) ->
recipes.guide_folder.update msg model
_ -> _ ->
App.Page.keep bigModel App.Page.keep bigModel
-- BUNDLE -- BUNDLE
bundle : Model -> Spa.Bundle Msg msg bundle : Model -> Spa.Bundle Msg msg
bundle bigModel = bundle bigModel =
case bigModel of case bigModel of
TopModel model ->
recipes.top.bundle model
DocsModel model -> DocsModel model ->
recipes.docs.bundle model recipes.docs.bundle model
GuideModel model ->
recipes.guide.bundle model
NotFoundModel model -> NotFoundModel model ->
recipes.notFound.bundle model recipes.notFound.bundle model
SignInModel model -> SignInModel model ->
recipes.signIn.bundle model recipes.signIn.bundle model
GuideModel model -> TopModel model ->
recipes.guide.bundle model recipes.top.bundle model
Guide_Folder_Model model ->
recipes.guide_folder.bundle model
Docs_Folder_Model model -> Docs_Folder_Model model ->
recipes.docs_folder.bundle model recipes.docs_folder.bundle model
Guide_Folder_Model model ->
recipes.guide_folder.bundle model

View File

@ -1,20 +1,14 @@
module Generated.Params exposing module Generated.Params exposing (..)
( Docs
, Guide
, NotFound
, SignIn
, Top
)
type alias Top =
{}
type alias Docs = type alias Docs =
{} {}
type alias Guide =
{}
type alias NotFound = type alias NotFound =
{} {}
@ -23,5 +17,5 @@ type alias SignIn =
{} {}
type alias Guide = type alias Top =
{} {}

View File

@ -3,41 +3,47 @@ module Generated.Route exposing
, toPath , toPath
) )
import Generated.Params as Params
import Generated.Docs.Route import Generated.Docs.Route
import Generated.Guide.Route import Generated.Guide.Route
import Generated.Params
type Route type Route
= Top Generated.Params.Top = Docs Params.Docs
| Docs Generated.Params.Docs | Guide Params.Guide
| NotFound Generated.Params.NotFound | NotFound Params.NotFound
| SignIn Generated.Params.SignIn | SignIn Params.SignIn
| Guide Generated.Params.Guide | Top Params.Top
| Guide_Folder Generated.Guide.Route.Route
| Docs_Folder Generated.Docs.Route.Route | Docs_Folder Generated.Docs.Route.Route
| Guide_Folder Generated.Guide.Route.Route
toPath : Route -> String toPath : Route -> String
toPath route = toPath route =
case route of case route of
Top _ ->
"/"
Docs _ -> Docs _ ->
"/docs" "/docs"
NotFound _ ->
"/not-found"
SignIn _ ->
"/sign-in"
Guide _ -> Guide _ ->
"/guide" "/guide"
Guide_Folder subRoute ->
"/guide" ++ Generated.Guide.Route.toPath subRoute NotFound _ ->
"/not-found"
SignIn _ ->
"/sign-in"
Top _ ->
"/top"
Docs_Folder subRoute -> Docs_Folder subRoute ->
"/docs" ++ Generated.Docs.Route.toPath subRoute "/docs" ++ Generated.Docs.Route.toPath subRoute
Guide_Folder subRoute ->
"/guide" ++ Generated.Guide.Route.toPath subRoute

View File

@ -5,12 +5,12 @@ module Generated.Routes exposing
, toPath , toPath
) )
import Generated.Route
import Generated.Docs.Route import Generated.Docs.Route
import Generated.Guide.Route
import Generated.Guide.Dynamic.Route
import Generated.Guide.Dynamic.Dynamic.Route import Generated.Guide.Dynamic.Dynamic.Route
import Generated.Guide.Dynamic.Faq.Route import Generated.Guide.Dynamic.Faq.Route
import Generated.Guide.Dynamic.Route
import Generated.Guide.Route
import Generated.Route
import Url.Parser as Parser exposing ((</>), Parser, map, s, string, top) import Url.Parser as Parser exposing ((</>), Parser, map, s, string, top)
@ -34,18 +34,18 @@ toPath =
type alias Routes = type alias Routes =
{ top : Route { top : Route
, docs : Route , docs : Route
, guide : Route
, notFound : Route
, signIn : Route , signIn : Route
, notFound : Route
, guide : Route
, guide_elm : Route , guide_elm : Route
, guide_elmSpa : Route
, guide_programming : Route , guide_programming : Route
, guide_dynamic_intro : String -> Route , docs_static : Route
, guide_elmSpa : Route
, docs_dynamic : String -> Route
, guide_dynamic_other : String -> Route , guide_dynamic_other : String -> Route
, guide_dynamic_intro : String -> Route
, guide_dynamic_faq_top : String -> Route , guide_dynamic_faq_top : String -> Route
, guide_dynamic_dynamic_top : String -> String -> Route , guide_dynamic_dynamic_top : String -> String -> Route
, docs_static : Route
, docs_dynamic : String -> Route
} }
@ -55,31 +55,38 @@ routes =
Generated.Route.Top {} Generated.Route.Top {}
, docs = , docs =
Generated.Route.Docs {} Generated.Route.Docs {}
, guide =
Generated.Route.Guide {}
, notFound =
Generated.Route.NotFound {}
, signIn = , signIn =
Generated.Route.SignIn {} Generated.Route.SignIn {}
, notFound =
Generated.Route.NotFound {}
, guide =
Generated.Route.Guide {}
, guide_elm = , guide_elm =
Generated.Route.Guide_Folder <| Generated.Route.Guide_Folder <|
Generated.Guide.Route.Elm {} Generated.Guide.Route.Elm {}
, guide_elmSpa =
Generated.Route.Guide_Folder <|
Generated.Guide.Route.ElmSpa {}
, guide_programming = , guide_programming =
Generated.Route.Guide_Folder <| Generated.Route.Guide_Folder <|
Generated.Guide.Route.Programming {} Generated.Guide.Route.Programming {}
, guide_dynamic_intro = , docs_static =
\param1 -> Generated.Route.Docs_Folder <|
Generated.Docs.Route.Static {}
, guide_elmSpa =
Generated.Route.Guide_Folder <| Generated.Route.Guide_Folder <|
Generated.Guide.Route.Dynamic_Folder param1 <| Generated.Guide.Route.ElmSpa {}
Generated.Guide.Dynamic.Route.Intro { param1 = param1 } , docs_dynamic =
\param1 ->
Generated.Route.Docs_Folder <|
Generated.Docs.Route.Dynamic param1 { param1 = param1 }
, guide_dynamic_other = , guide_dynamic_other =
\param1 -> \param1 ->
Generated.Route.Guide_Folder <| Generated.Route.Guide_Folder <|
Generated.Guide.Route.Dynamic_Folder param1 <| Generated.Guide.Route.Dynamic_Folder param1 <|
Generated.Guide.Dynamic.Route.Other { param1 = param1 } Generated.Guide.Dynamic.Route.Other { param1 = param1 }
, guide_dynamic_intro =
\param1 ->
Generated.Route.Guide_Folder <|
Generated.Guide.Route.Dynamic_Folder param1 <|
Generated.Guide.Dynamic.Route.Intro { param1 = param1 }
, guide_dynamic_faq_top = , guide_dynamic_faq_top =
\param1 -> \param1 ->
Generated.Route.Guide_Folder <| Generated.Route.Guide_Folder <|
@ -92,44 +99,37 @@ routes =
Generated.Guide.Route.Dynamic_Folder param1 <| Generated.Guide.Route.Dynamic_Folder param1 <|
Generated.Guide.Dynamic.Route.Dynamic_Folder param2 <| Generated.Guide.Dynamic.Route.Dynamic_Folder param2 <|
Generated.Guide.Dynamic.Dynamic.Route.Top { param1 = param1, param2 = param2 } Generated.Guide.Dynamic.Dynamic.Route.Top { param1 = param1, param2 = param2 }
, docs_static =
Generated.Route.Docs_Folder <|
Generated.Docs.Route.Static {}
, docs_dynamic =
\param1 ->
Generated.Route.Docs_Folder <|
Generated.Docs.Route.Dynamic param1 { param1 = param1 }
} }
parsers : List (Parser (Route -> a) a) parsers : List (Parser (Route -> a) a)
parsers = parsers =
[ map routes.top [ map routes.top
top (top)
, map routes.docs , map routes.docs
(s "docs") (s "docs")
, map routes.guide
(s "guide")
, map routes.notFound
(s "not-found")
, map routes.signIn , map routes.signIn
(s "sign-in") (s "sign-in")
, map routes.notFound
(s "not-found")
, map routes.guide
(s "guide")
, map routes.guide_elm , map routes.guide_elm
(s "guide" </> s "elm") (s "guide" </> s "elm")
, map routes.guide_elmSpa
(s "guide" </> s "elm-spa")
, map routes.guide_programming , map routes.guide_programming
(s "guide" </> s "programming") (s "guide" </> s "programming")
, map routes.guide_dynamic_intro , map routes.docs_static
(s "guide" </> string </> s "intro") (s "docs" </> s "static")
, map routes.guide_elmSpa
(s "guide" </> s "elm-spa")
, map routes.docs_dynamic
(s "docs" </> string)
, map routes.guide_dynamic_other , map routes.guide_dynamic_other
(s "guide" </> string </> s "other") (s "guide" </> string </> s "other")
, map routes.guide_dynamic_intro
(s "guide" </> string </> s "intro")
, map routes.guide_dynamic_faq_top , map routes.guide_dynamic_faq_top
(s "guide" </> string </> s "faq" </> top) (s "guide" </> string </> s "faq" </> top)
, map routes.guide_dynamic_dynamic_top , map routes.guide_dynamic_dynamic_top
(s "guide" </> string </> string </> top) (s "guide" </> string </> string </> top)
, map routes.docs_static
(s "docs" </> s "static")
, map routes.docs_dynamic
(s "docs" </> string)
] ]

View File

@ -3,7 +3,7 @@
"source-directories": [ "source-directories": [
"src", "src",
"../../src", "../../src",
"elm-stuff/.elm-spa" "elm-stuff/.generated"
], ],
"elm-version": "0.19.1", "elm-version": "0.19.1",
"dependencies": { "dependencies": {

5
package-lock.json generated Normal file
View File

@ -0,0 +1,5 @@
{
"name": "elm-spa",
"version": "1.0.0",
"lockfileVersion": 1
}

View File

@ -3,6 +3,7 @@
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "cli/src/index.js", "main": "cli/src/index.js",
"bin": "./cli/src/index.js",
"scripts": { "scripts": {
"start": "npm run dev", "start": "npm run dev",
"build": "(cd cli && npm run build)", "build": "(cd cli && npm run build)",