strata-cli 0.1.13 → 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 +29 -0
- data/README.md +15 -6
- data/lib/strata/cli/configuration.rb +2 -0
- 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 +3 -0
- 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 -1
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,34 @@
|
|
|
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
|
+
|
|
21
|
+
## [0.1.14] - 2026-07-17
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **Tutorial command**: `strata tutorial` walks new users through a guided setup — initializes a project, configures a datasource, and deploys to a local Strata server running on port 8080.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **Tutorial deployment**: Completion message now includes `--skip-audit` flag in the deployment instructions.
|
|
30
|
+
- **Tutorial server config**: Default server port set to 8080 (was 3000).
|
|
31
|
+
|
|
3
32
|
## [0.1.13] - 2026-06-20
|
|
4
33
|
|
|
5
34
|
### Changed
|
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
|
@@ -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