strata-cli 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +15 -6
- data/lib/strata/cli/generators/project.rb +0 -8
- data/lib/strata/cli/generators/templates/project.yml +2 -2
- data/lib/strata/cli/guard.rb +2 -0
- data/lib/strata/cli/main.rb +0 -8
- data/lib/strata/cli/sub_commands/audit.rb +2 -0
- data/lib/strata/cli/sub_commands/deploy.rb +4 -0
- data/lib/strata/cli/sub_commands/project.rb +87 -0
- data/lib/strata/cli/version.rb +1 -1
- metadata +1 -3
- data/lib/strata/cli/descriptions/tutorial.txt +0 -13
- data/lib/strata/cli/generators/tutorial.rb +0 -72
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6965d8ee9c44a37f7de1a11c0d2654d05c44aa352f38442456e77814deb411e1
|
|
4
|
+
data.tar.gz: af24ef90657a2c2d32d6493d00b1b40eab52a290c3f3c2c35fb69bf73cc7c448
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9d03dcd92e8364ef2c5e3558c1f1e049227c394b36f75148f4f08e4d4b62ca9ddd3c11bd9e636c5c7324bba43e9d40f8ba554b7d4436fcb1ad4a07af3c001ee
|
|
7
|
+
data.tar.gz: 455a627b5dfebd40b48f45ec70ea362438ed0c526db7c69941685987aea3a3fed10cf2c4a3b4fcaba33620e11dbda90540ce1c54de814bc74c10fac2cef36d98
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.1.15] - 2026-07-27
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Sample project command**: `strata project sample` now uses a browser-based auth flow — opens the Strata sign-in page, waits for authentication, and writes the API key to `.strata` automatically. No flags required.
|
|
8
|
+
- **CLI auth endpoints**: New server endpoints (`/cli/auth` and `/api/v1/cli/auth/:state`) support the browser-based API key retrieval flow.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Repo rename**: Sample project now clones `tpc-ds-retail-sample` (previously `strata-tutorial-project`).
|
|
13
|
+
- **Sample project setup**: Server URL is prompted interactively with `http://localhost:8080` as default. `--api-key` and `--server` flags retained as optional overrides for scripting.
|
|
14
|
+
- **Audit — tutorial project**: Connection check now silently passes for the `tpc-ds-retail-sample` project (datasource lives in the Strata Docker container, not locally). All other audit checks run normally.
|
|
15
|
+
- **Project template**: `project.yml` no longer assumes `http://localhost:8080` as the default server — prompted at first deploy instead.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **Deploy — manual commit hash**: Deployments previously triggered via the web UI stored a `manual-<timestamp>` commit reference. The CLI now treats these as non-git baselines and falls back to a full deploy instead of erroring.
|
|
20
|
+
|
|
3
21
|
## [0.1.14] - 2026-07-17
|
|
4
22
|
|
|
5
23
|
### Added
|
data/README.md
CHANGED
|
@@ -308,18 +308,27 @@ project_id: 123 # Auto-populated after first deployment
|
|
|
308
308
|
|
|
309
309
|
**Multi-Environment Configuration:**
|
|
310
310
|
|
|
311
|
+
`project.yml` — server URL per environment (safe to commit):
|
|
311
312
|
```yaml
|
|
312
|
-
# Default environment
|
|
313
|
-
server:
|
|
313
|
+
# Default environment (set on first deploy if omitted)
|
|
314
|
+
server: https://dev.strata.example.com
|
|
314
315
|
|
|
315
|
-
# Environment-specific configs
|
|
316
316
|
staging:
|
|
317
317
|
server: https://staging.strata.com
|
|
318
|
-
api_key: staging-key
|
|
319
318
|
|
|
320
319
|
production:
|
|
321
320
|
server: https://app.strata.com
|
|
322
|
-
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
`.strata` — API keys per environment (**never committed**):
|
|
324
|
+
```yaml
|
|
325
|
+
api_key: your-default-api-key
|
|
326
|
+
|
|
327
|
+
staging:
|
|
328
|
+
api_key: your-staging-api-key
|
|
329
|
+
|
|
330
|
+
production:
|
|
331
|
+
api_key: your-production-api-key
|
|
323
332
|
```
|
|
324
333
|
|
|
325
334
|
### Local Configuration (`.strata`)
|
|
@@ -436,7 +445,7 @@ Ensure you have write permissions in the project directory. The `.strata` file p
|
|
|
436
445
|
|
|
437
446
|
### "Server URL not configured"
|
|
438
447
|
|
|
439
|
-
|
|
448
|
+
Run `strata deploy` — you will be prompted to enter the server URL, which is then saved to `project.yml` automatically for future deploys. Or add it manually:
|
|
440
449
|
|
|
441
450
|
```yaml
|
|
442
451
|
server: https://your-strata-server.com
|
|
@@ -17,8 +17,6 @@ module Strata
|
|
|
17
17
|
include API::ConnectionErrorHandler
|
|
18
18
|
include API::ResponseErrorHandler
|
|
19
19
|
|
|
20
|
-
BASE_SERVER_URL = "http://localhost:3000"
|
|
21
|
-
|
|
22
20
|
argument :name, type: :string, required: false, desc: "The name of the project. Optional when using --source."
|
|
23
21
|
class_option :datasource, type: :string, repeatable: true
|
|
24
22
|
class_option :source, type: :string
|
|
@@ -205,12 +203,6 @@ module Strata
|
|
|
205
203
|
@name
|
|
206
204
|
end
|
|
207
205
|
|
|
208
|
-
def server_url
|
|
209
|
-
return options[:source] if options.key?(:source)
|
|
210
|
-
|
|
211
|
-
BASE_SERVER_URL
|
|
212
|
-
end
|
|
213
|
-
|
|
214
206
|
def description
|
|
215
207
|
return @project_info["description"] if options.key?(:source) && @project_info
|
|
216
208
|
|
|
@@ -10,14 +10,14 @@ uid: <%= uid %>
|
|
|
10
10
|
description: Your projects description
|
|
11
11
|
|
|
12
12
|
# Target Strata server (default environment, typically dev)
|
|
13
|
-
server: <%= options[:source]
|
|
13
|
+
server: <%= options[:source] %>
|
|
14
14
|
|
|
15
15
|
# Alternatively, you can configure multiple environments (different Strata server instances).
|
|
16
16
|
# Each environment represents a separate Strata cluster (dev, staging, production).
|
|
17
17
|
# Use -e [ENVIRONMENT] flag when deploying to select the environment.
|
|
18
18
|
# Example:
|
|
19
19
|
# dev:
|
|
20
|
-
# server: http://localhost:
|
|
20
|
+
# server: http://localhost:8080
|
|
21
21
|
# prod:
|
|
22
22
|
# server: https://app.strata.com
|
|
23
23
|
|
data/lib/strata/cli/guard.rb
CHANGED
data/lib/strata/cli/main.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "generators/project"
|
|
4
|
-
require_relative "generators/tutorial"
|
|
5
4
|
require_relative "sub_commands/datasource"
|
|
6
5
|
require_relative "sub_commands/deploy"
|
|
7
6
|
require_relative "sub_commands/branch"
|
|
@@ -48,13 +47,6 @@ module Strata
|
|
|
48
47
|
invoke Generators::Project, [project_name], options
|
|
49
48
|
end
|
|
50
49
|
|
|
51
|
-
desc "tutorial", "Set up the Strata TPC-DS tutorial project"
|
|
52
|
-
long_desc_from_file "tutorial"
|
|
53
|
-
option :api_key, aliases: ["a"], type: :string, desc: "Strata API key"
|
|
54
|
-
def tutorial
|
|
55
|
-
invoke Generators::Tutorial, [], options
|
|
56
|
-
end
|
|
57
|
-
|
|
58
50
|
desc "adapters", "Lists supported data warehouse adapters"
|
|
59
51
|
def adapters
|
|
60
52
|
out = " SUPPORTED ADAPTERS: \n\t#{DWH.adapters.keys.join("\n\t")}"
|
|
@@ -439,6 +439,10 @@ module Strata
|
|
|
439
439
|
return nil unless last_deployment && last_deployment["commit"]
|
|
440
440
|
|
|
441
441
|
commit_hash = last_deployment["commit"]
|
|
442
|
+
unless Utils::Git.validate_commit_hash(commit_hash)
|
|
443
|
+
print_info("No previous git-based deployment found. Including all files.\n")
|
|
444
|
+
return nil
|
|
445
|
+
end
|
|
442
446
|
print_info("Found last successful deployment at commit: #{commit_hash[0..7]}...\n")
|
|
443
447
|
commit_hash
|
|
444
448
|
rescue Strata::CommandError
|
|
@@ -7,6 +7,12 @@ require_relative "../helpers/project_helper"
|
|
|
7
7
|
require_relative "../agent_mode"
|
|
8
8
|
require_relative "../api/client"
|
|
9
9
|
require "yaml"
|
|
10
|
+
require "fileutils"
|
|
11
|
+
require "tty-prompt"
|
|
12
|
+
require "net/http"
|
|
13
|
+
require "json"
|
|
14
|
+
require "securerandom"
|
|
15
|
+
require "rbconfig"
|
|
10
16
|
|
|
11
17
|
module Strata
|
|
12
18
|
module CLI
|
|
@@ -17,6 +23,87 @@ module Strata
|
|
|
17
23
|
include Output
|
|
18
24
|
include AgentMode
|
|
19
25
|
|
|
26
|
+
SAMPLE_REPO = "https://github.com/stratasite/tpc-ds-retail-sample"
|
|
27
|
+
SAMPLE_DIR = "tpc-ds-retail-sample"
|
|
28
|
+
SAMPLE_PROJECT_UID = "tpc-ds-retail-sample"
|
|
29
|
+
DEFAULT_SERVER = "http://localhost:8080"
|
|
30
|
+
AUTH_TIMEOUT_SECONDS = 300
|
|
31
|
+
|
|
32
|
+
desc "sample", "Clone the Strata sample project and set it up interactively"
|
|
33
|
+
option :api_key, aliases: ["a"], type: :string, desc: "Strata API key (optional — skip browser auth)"
|
|
34
|
+
option :server, aliases: ["s"], type: :string, desc: "Strata server URL (optional — prompted if omitted)"
|
|
35
|
+
def sample
|
|
36
|
+
if options[:api_key] && options[:server]
|
|
37
|
+
server = options[:server].delete_suffix("/")
|
|
38
|
+
api_key = options[:api_key]
|
|
39
|
+
else
|
|
40
|
+
prompt = TTY::Prompt.new
|
|
41
|
+
server = (options[:server] || prompt.ask("Strata server URL:", default: DEFAULT_SERVER) { |q| q.modify :strip }).delete_suffix("/")
|
|
42
|
+
api_key = fetch_api_key_via_browser(server)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if File.directory?(SAMPLE_DIR)
|
|
46
|
+
print_info("Directory '#{SAMPLE_DIR}' already exists — re-using it")
|
|
47
|
+
else
|
|
48
|
+
print_info("Cloning sample project from #{SAMPLE_REPO}...")
|
|
49
|
+
system("git clone #{SAMPLE_REPO} #{SAMPLE_DIR}", exception: true)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Dir.chdir(SAMPLE_DIR) do
|
|
53
|
+
FileUtils.rm_rf(".git")
|
|
54
|
+
system("git init -b main", exception: true)
|
|
55
|
+
File.write(".gitignore", ".strata\n.strata_cli/\n")
|
|
56
|
+
|
|
57
|
+
strata_path = ".strata"
|
|
58
|
+
File.write(strata_path, "api_key: #{api_key}\nserver: #{server}\n")
|
|
59
|
+
File.chmod(0o600, strata_path)
|
|
60
|
+
|
|
61
|
+
Helpers::ProjectHelper.persist_project_id_to_yml(SAMPLE_PROJECT_UID)
|
|
62
|
+
|
|
63
|
+
system("git add -A", exception: true)
|
|
64
|
+
system('git commit -m "Initial sample project setup"', exception: true)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
print_success("✔ Sample project '#{SAMPLE_DIR}' is ready!")
|
|
68
|
+
print_info(" Next: cd #{SAMPLE_DIR} && strata deploy")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
no_commands do
|
|
72
|
+
def fetch_api_key_via_browser(server)
|
|
73
|
+
state = SecureRandom.hex(16)
|
|
74
|
+
auth_url = "#{server}/cli/auth?state=#{state}"
|
|
75
|
+
poll_url = "#{server}/api/v1/cli/auth/#{state}"
|
|
76
|
+
|
|
77
|
+
say "\nOpening your browser to sign in to Strata...", :cyan
|
|
78
|
+
open_browser(auth_url)
|
|
79
|
+
say "Waiting for authentication (you may close the browser tab once done)", :white
|
|
80
|
+
|
|
81
|
+
deadline = Time.now + AUTH_TIMEOUT_SECONDS
|
|
82
|
+
loop do
|
|
83
|
+
raise Strata::CommandError, "Authentication timed out. Run `strata project sample` to try again." if Time.now > deadline
|
|
84
|
+
|
|
85
|
+
begin
|
|
86
|
+
response = Net::HTTP.get_response(URI(poll_url))
|
|
87
|
+
return JSON.parse(response.body)["api_key"] if response.code == "200"
|
|
88
|
+
rescue Errno::ECONNREFUSED
|
|
89
|
+
raise Strata::CommandError, "Cannot reach server at #{server}. Is it running?"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
print "."
|
|
93
|
+
$stdout.flush
|
|
94
|
+
sleep 1
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def open_browser(url)
|
|
99
|
+
case RbConfig::CONFIG["host_os"]
|
|
100
|
+
when /darwin/ then system("open", url)
|
|
101
|
+
when /linux/ then system("xdg-open", url)
|
|
102
|
+
when /mswin|mingw/ then system("start", "", url)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
20
107
|
desc "link PROJECT_ID", "Link local project to an existing project on the server"
|
|
21
108
|
def link(project_id)
|
|
22
109
|
raise Strata::CommandError, "Project ID is required." unless project_id && !project_id.to_s.strip.empty?
|
data/lib/strata/cli/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strata-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ajo Abraham
|
|
@@ -264,7 +264,6 @@ files:
|
|
|
264
264
|
- lib/strata/cli/descriptions/deploy/deploy.txt
|
|
265
265
|
- lib/strata/cli/descriptions/deploy/status.txt
|
|
266
266
|
- lib/strata/cli/descriptions/init.txt
|
|
267
|
-
- lib/strata/cli/descriptions/tutorial.txt
|
|
268
267
|
- lib/strata/cli/error_reporter.rb
|
|
269
268
|
- lib/strata/cli/generators/datasource.rb
|
|
270
269
|
- lib/strata/cli/generators/group.rb
|
|
@@ -293,7 +292,6 @@ files:
|
|
|
293
292
|
- lib/strata/cli/generators/templates/table.table_name.yml
|
|
294
293
|
- lib/strata/cli/generators/templates/test.yml
|
|
295
294
|
- lib/strata/cli/generators/test.rb
|
|
296
|
-
- lib/strata/cli/generators/tutorial.rb
|
|
297
295
|
- lib/strata/cli/guard.rb
|
|
298
296
|
- lib/strata/cli/helpers/command_context.rb
|
|
299
297
|
- lib/strata/cli/helpers/datasource_helper.rb
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Sets up the Strata tutorial project locally by cloning the tutorial repo,
|
|
2
|
-
wiring it to your Strata instance, and preparing it for `strata deploy`.
|
|
3
|
-
|
|
4
|
-
The --api-key value is shown on the tutorial setup page
|
|
5
|
-
in your Strata instance. Copy-paste them directly from there.
|
|
6
|
-
|
|
7
|
-
After running this command, `cd` into the project directory and run
|
|
8
|
-
`strata deploy` to deploy the tutorial to your Strata instance.
|
|
9
|
-
|
|
10
|
-
Example:
|
|
11
|
-
strata tutorial -a your_api_key
|
|
12
|
-
cd tutorial
|
|
13
|
-
strata deploy
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "group"
|
|
4
|
-
require_relative "../helpers/project_helper"
|
|
5
|
-
require_relative "../output"
|
|
6
|
-
require "yaml"
|
|
7
|
-
require "fileutils"
|
|
8
|
-
|
|
9
|
-
module Strata
|
|
10
|
-
module CLI
|
|
11
|
-
module Generators
|
|
12
|
-
class Tutorial < Group
|
|
13
|
-
TUTORIAL_REPO = "https://github.com/stratasite/strata-tutorial-project"
|
|
14
|
-
DEFAULT_SERVER = "http://localhost:8080"
|
|
15
|
-
TUTORIAL_PROJECT = "strata-tutorial-project"
|
|
16
|
-
|
|
17
|
-
class_option :api_key, aliases: ["a"], type: :string, desc: "Strata API key"
|
|
18
|
-
|
|
19
|
-
desc "Sets up the Strata tutorial project locally."
|
|
20
|
-
|
|
21
|
-
def validate_options
|
|
22
|
-
raise Strata::CommandError, "--api-key (-a) is required." unless options[:api_key]
|
|
23
|
-
@uid = TUTORIAL_PROJECT
|
|
24
|
-
@project_id = 1
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def clone_tutorial_repo
|
|
28
|
-
if File.directory?(@uid)
|
|
29
|
-
Output.print_status(:skip, "Directory '#{@uid}' already exists — re-using it", type: :info, context: self)
|
|
30
|
-
return
|
|
31
|
-
end
|
|
32
|
-
Output.print_status(:clone, "Cloning tutorial from #{TUTORIAL_REPO}", type: :success, context: self)
|
|
33
|
-
run "git clone #{TUTORIAL_REPO} #{@uid}", verbose: false, capture: true
|
|
34
|
-
raise Strata::CommandError, "Failed to clone tutorial repo." unless File.directory?(@uid)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def reinitialize_git
|
|
38
|
-
inside @uid do
|
|
39
|
-
FileUtils.rm_rf(".git")
|
|
40
|
-
run "git init -b main", verbose: false, capture: true
|
|
41
|
-
create_file ".gitignore", ".strata\n.strata_cli/\n", force: true
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def write_strata_config
|
|
46
|
-
strata_path = File.join(@uid, ".strata")
|
|
47
|
-
File.write(strata_path, "api_key: #{options[:api_key]}\nserver: #{DEFAULT_SERVER}\n")
|
|
48
|
-
File.chmod(0o600, strata_path)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def update_project_yml
|
|
52
|
-
project_yml = File.join(@uid, "project.yml")
|
|
53
|
-
return unless File.exist?(project_yml)
|
|
54
|
-
|
|
55
|
-
Helpers::ProjectHelper.persist_project_id_to_yml(@project_id, project_yml_path: project_yml)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def initial_commit
|
|
59
|
-
inside @uid do
|
|
60
|
-
run "git add -A", verbose: false, capture: true
|
|
61
|
-
run 'git commit -m "Initial tutorial project setup"', verbose: false, capture: true
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def completion_message
|
|
66
|
-
Output.print_success("\n✔ Tutorial project '#{@uid}' is ready!\n", context: self)
|
|
67
|
-
Output.print_info(" Next: cd #{@uid} && strata deploy --skip-audit\n", context: self)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|