Packages
shopifex
2.1.13
2.4.0
2.3.0
2.2.2
2.2.1
2.2.0
2.1.20
2.1.19
2.1.18
2.1.17
2.1.16
2.1.15
2.1.14
2.1.13
2.1.12
2.1.11
2.1.10
2.1.9
2.1.8
2.1.7
2.1.6
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.1
2.0.0
1.1.1
1.1.0
1.0.1
1.0.0
0.6.2
0.6.1
0.6.0
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Phoenix boilerplate for Shopify Embedded App SDK
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/gen.schemas.ex
defmodule Mix.Tasks.Shopifex.Gen.Schemas do
@shortdoc "Generates Shopifex schema files"
@moduledoc """
Generates schema files.
mix shopifex.gen.schemas
mix shopifex.gen.schemas --binary-id --namespace shopify_app
## Arguments
* `--binary-id` - use binary id for primary keys
* `--namespace` - namespace to prepend table, schema and controller module name
* `--context-app` - context app to use for path and module names
"""
use Mix.Task
alias Mix.{Shopifex, Shopifex.Schema}
@switches [binary_id: :boolean, context_app: :string, namespace: :string]
@default_opts [binary_id: false, namespace: "shopify"]
@mix_task "shopifex.gen.schemas"
@impl true
def run(args) do
Shopifex.no_umbrella!(@mix_task)
args
|> Shopifex.parse_options(@switches, @default_opts)
|> parse()
|> create_schema_files()
end
defp parse({config, _parsed, _invalid}), do: config
defp create_schema_files(%{binary_id: binary_id, namespace: namespace} = config) do
context_app = Map.get(config, :context_app) || Shopifex.otp_app()
Schema.create_schema_files(context_app, namespace, binary_id: binary_id)
end
end