Class: Strata::CLI::SubCommands::Project
- Inherits:
-
Thor
- Object
- Thor
- Strata::CLI::SubCommands::Project
- Defined in:
- lib/strata/cli/sub_commands/project.rb
Constant Summary collapse
- SAMPLE_REPO =
"https://github.com/stratasite/tpc-ds-retail-sample"- SAMPLE_DIR =
"tpc-ds-retail-sample"- SAMPLE_PROJECT_UID =
"tpc-ds-retail-sample"- DEFAULT_SERVER =
"http://localhost:8080"- AUTH_TIMEOUT_SECONDS =
300
Constants included from Output
Constants included from Guard
Instance Method Summary collapse
Methods included from AgentMode
#agent_mode?, included, #reject_agent_mode!
Methods included from Output
format, pastel, print_error, #print_error, print_hint, #print_hint, print_info, #print_info, print_status, #print_status, print_success, #print_success, print_warning, #print_warning, shell_for, thor_color
Methods included from Terminal
#create_spinner, #print_table, #with_spinner
Methods included from Guard
Instance Method Details
#link(project_id) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/strata/cli/sub_commands/project.rb', line 108 def link(project_id) raise Strata::CommandError, "Project ID is required." unless project_id && !project_id.to_s.strip.empty? project_yml_path = "project.yml" project_config = YAML.safe_load_file(project_yml_path, permitted_classes: [Date, Time], aliases: true) || {} if project_config["project_id"] && !project_config["project_id"].to_s.strip.empty? print_warning("Project is already linked to project_id: #{project_config["project_id"]}") return end return unless Helpers::ProjectHelper.persist_project_id_to_yml(project_id, project_yml_path: project_yml_path) print_info("✓ Project linked successfully. project_id: #{project_id}") end |
#sample ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/strata/cli/sub_commands/project.rb', line 35 def sample if [:api_key] && [:server] server = [:server].delete_suffix("/") api_key = [:api_key] else prompt = TTY::Prompt.new server = ([:server] || prompt.ask("Strata server URL:", default: DEFAULT_SERVER) { |q| q.modify :strip }).delete_suffix("/") api_key = fetch_api_key_via_browser(server) end if File.directory?(SAMPLE_DIR) print_info("Directory '#{SAMPLE_DIR}' already exists — re-using it") else print_info("Cloning sample project from #{SAMPLE_REPO}...") system("git clone #{SAMPLE_REPO} #{SAMPLE_DIR}", exception: true) end Dir.chdir(SAMPLE_DIR) do FileUtils.rm_rf(".git") system("git init -b main", exception: true) File.write(".gitignore", ".strata\n.strata_cli/\n") strata_path = ".strata" File.write(strata_path, "api_key: #{api_key}\nserver: #{server}\n") File.chmod(0o600, strata_path) Helpers::ProjectHelper.persist_project_id_to_yml(SAMPLE_PROJECT_UID) system("git add -A", exception: true) system('git commit -m "Initial sample project setup"', exception: true) end print_success("✔ Sample project '#{SAMPLE_DIR}' is ready!") print_info(" Next: cd #{SAMPLE_DIR} && strata deploy") end |