Skip to content

Commit

Permalink
Bug fixes, cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Aug 15, 2021
1 parent f49aab6 commit 1980b48
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,7 +1,7 @@
name = "Genie"
uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
authors = ["Adrian Salceanu <e@essenciary.com>"]
version = "3.0.0"
version = "3.0.1"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
32 changes: 1 addition & 31 deletions src/Generator.jl
Expand Up @@ -232,37 +232,6 @@ function write_secrets_file(app_path::String = ".") :: Nothing
nothing
end

"""
migrate_secrets_file(app_path=".")
Replace the previous content of `config/secrets.jl` with the new syntax but the same token.
Specifically, the previous syntax of the file is the following, which is now deprecated:
const SECRET_TOKEN = "token"
This syntax is replaced by the new syntax:
Genie.secret_token!("token")
"""
function migrate_secrets_file(app_path::String = ".") :: Nothing
secrets_path = joinpath(app_path, Genie.config.path_config, Genie.SECRETS_FILE_NAME)
if isfile(secrets_path)
match_deprecated = match(r"SECRET_TOKEN\s*=\s*\"(.*)\"", readline(secrets_path))
if match_deprecated != nothing # does the file use the deprecated syntax?
open(secrets_path, "w") do f
write(f, """Genie.secret_token!("$(match_deprecated.captures[1])") """)
end # replace the previous content of the file
@info "Successfully migrated $(secrets_path) to a valid syntax."
else
error("No migration possible; $(secrets_path) is not using a migrate-able syntax.")
end
else
error("No migration possible; $(secrets_path) is not a file.")
end
return nothing
end


"""
fullstack_app(app_path::String = ".") :: Nothing
Expand Down Expand Up @@ -398,6 +367,7 @@ function write_app_custom_files(path::String, app_path::String) :: Nothing
pwd() == joinpath(@__DIR__, "bin") && cd(@__DIR__) # allow starting app from bin/ dir
using $(moduleinfo[1])
push!(Base.modules_warned_for, Base.PkgId($(moduleinfo[1])))
$(moduleinfo[1]).main()
""")
end
Expand Down
6 changes: 5 additions & 1 deletion src/WebChannels.jl
Expand Up @@ -3,7 +3,7 @@ Handles WebSockets communication logic.
"""
module WebChannels

import HTTP, Distributed, Logging
import HTTP, Distributed, Logging, JSON3
import Genie, Genie.Renderer

const ClientId = UInt # web socket hash
Expand All @@ -29,6 +29,10 @@ mutable struct ChannelMessage
payload::MessagePayload
end

function JSON3.StructTypes.StructType(::Type{T}) where {T<:ChannelMessage}
JSON3.StructTypes.Struct()
end

const CLIENTS = ChannelClientsCollection()
const SUBSCRIPTIONS = ChannelSubscriptionsCollection()

Expand Down
4 changes: 1 addition & 3 deletions src/genie_module.jl
Expand Up @@ -34,9 +34,7 @@ function newresource(resource_name::Union{String,Symbol}; path::String = ".", pl

try
Core.eval(context, :(SearchLight.Generator.newresource(uppercasefirst($resource_name))))
catch ex
# @error ex
@warn "Skipping SearchLight"
catch
end

load_resources()
Expand Down

0 comments on commit 1980b48

Please sign in to comment.