MCPcopy Create free account
hub / github.com/auth0/auth0-cli / WriteQuickstartConfig

Method WriteQuickstartConfig

internal/cli/quickstarts.go:1654–1820  ·  view source on GitHub ↗
(cmd *cobra.Command, resolvedEnv map[string]string, strategy *auth0.FileOutputStrategy)

Source from the content-addressed store, hash-verified

1652}
1653
1654func (c *cli) WriteQuickstartConfig(cmd *cobra.Command, resolvedEnv map[string]string, strategy *auth0.FileOutputStrategy) error {
1655 if strategy == nil {
1656 strategy = &auth0.FileOutputStrategy{Path: ".env", Format: "dotenv"}
1657 }
1658
1659 dir := filepath.Dir(strategy.Path)
1660 if dir != "." {
1661 if err := os.MkdirAll(dir, 0755); err != nil {
1662 return fmt.Errorf("failed to create directory structure %s: %w", dir, err)
1663 }
1664 }
1665
1666 var contentBuilder strings.Builder
1667
1668 switch strategy.Format {
1669 case "dotenv":
1670 for _, key := range sortedKeys(resolvedEnv) {
1671 fmt.Fprintf(&contentBuilder, "%s=\"%s\"\n", key, resolvedEnv[key])
1672 }
1673
1674 case "properties":
1675 for _, key := range sortedKeys(resolvedEnv) {
1676 fmt.Fprintf(&contentBuilder, "%s=%s\n", key, resolvedEnv[key])
1677 }
1678
1679 case "yaml":
1680 // Produce nested YAML from dot-delimited keys (e.g. Spring Boot application.yml).
1681 nested := buildNestedMap(resolvedEnv)
1682 yamlBytes, err := yaml.Marshal(nested)
1683 if err != nil {
1684 return fmt.Errorf("failed to marshal YAML for %s: %w", strategy.Path, err)
1685 }
1686 contentBuilder.Write(yamlBytes)
1687
1688 case "rails-yaml":
1689 // Rails config/auth0.yml wraps credentials under the "development" environment key.
1690 devSection := make(map[string]interface{}, len(resolvedEnv))
1691 for k, v := range resolvedEnv {
1692 devSection[k] = v
1693 }
1694 wrapped := map[string]interface{}{"development": devSection}
1695 yamlBytes, err := yaml.Marshal(wrapped)
1696 if err != nil {
1697 return fmt.Errorf("failed to marshal YAML for %s: %w", strategy.Path, err)
1698 }
1699 contentBuilder.Write(yamlBytes)
1700
1701 case "ts":
1702 contentBuilder.WriteString("export const environment = {\n")
1703 for _, key := range sortedKeys(resolvedEnv) {
1704 fmt.Fprintf(&contentBuilder, " %s: '%s',\n", key, strings.ReplaceAll(resolvedEnv[key], "'", "\\'"))
1705 }
1706 contentBuilder.WriteString("};\n")
1707
1708 case "angular-ts":
1709 // Angular SPA environment.ts nests domain and clientId under an auth0 object,
1710 // matching the official Angular quickstart: environment.auth0.domain / .clientId.
1711 contentBuilder.WriteString("export const environment = {\n")

Callers 2

createQuickstartAppFunction · 0.80

Calls 12

BoldFunction · 0.92
CyanFunction · 0.92
sortedKeysFunction · 0.85
buildNestedMapFunction · 0.85
xmlEscapeFunction · 0.85
shouldCancelOverwriteFunction · 0.85
ErrorfMethod · 0.80
WriteMethod · 0.80
WarnfMethod · 0.80
NewlineMethod · 0.80
DetailfMethod · 0.80
SuccessfMethod · 0.80

Tested by 1