Skip to content

Commit 85baf89

Browse files
authored
chore: pgt_flags -> pgt_env, central website url, unify version (#545)
in preparation for the renaming
1 parent fcd4720 commit 85baf89

File tree

16 files changed

+47
-28
lines changed

16 files changed

+47
-28
lines changed

Cargo.lock

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pgt_console = { path = "./crates/pgt_console", version = "0.0.0"
6969
pgt_diagnostics = { path = "./crates/pgt_diagnostics", version = "0.0.0" }
7070
pgt_diagnostics_categories = { path = "./crates/pgt_diagnostics_categories", version = "0.0.0" }
7171
pgt_diagnostics_macros = { path = "./crates/pgt_diagnostics_macros", version = "0.0.0" }
72-
pgt_flags = { path = "./crates/pgt_flags", version = "0.0.0" }
72+
pgt_env = { path = "./crates/pgt_env", version = "0.0.0" }
7373
pgt_fs = { path = "./crates/pgt_fs", version = "0.0.0" }
7474
pgt_hover = { path = "./crates/pgt_hover", version = "0.0.0" }
7575
pgt_lexer = { path = "./crates/pgt_lexer", version = "0.0.0" }

crates/pgt_cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pgt_analyse = { workspace = true }
2424
pgt_configuration = { workspace = true }
2525
pgt_console = { workspace = true }
2626
pgt_diagnostics = { workspace = true }
27-
pgt_flags = { workspace = true }
27+
pgt_env = { workspace = true }
2828
pgt_fs = { workspace = true }
2929
pgt_lsp = { workspace = true }
3030
pgt_text_edit = { workspace = true }

crates/pgt_cli/src/commands/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::commands::daemon::default_pgt_log_path;
22
use crate::{CliDiagnostic, CliSession};
3-
use pgt_flags::pgt_env;
3+
use pgt_env::pgt_env;
44
use std::fs::{create_dir, remove_dir_all};
55
use std::path::PathBuf;
66

crates/pgt_cli/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use commands::check::CheckCommandPayload;
1010
use pgt_console::{ColorMode, Console};
1111
use pgt_fs::OsFileSystem;
1212
use pgt_workspace::{App, DynRef, Workspace, WorkspaceRef};
13-
use std::env;
1413

1514
mod changed;
1615
mod cli_options;
@@ -32,10 +31,7 @@ pub use panic::setup_panic_handler;
3231
pub use reporter::{DiagnosticsPayload, Reporter, ReporterVisitor, TraversalSummary};
3332
pub use service::{SocketTransport, open_transport};
3433

35-
pub(crate) const VERSION: &str = match option_env!("PGT_VERSION") {
36-
Some(version) => version,
37-
None => env!("CARGO_PKG_VERSION"),
38-
};
34+
pub(crate) use pgt_env::VERSION;
3935

4036
/// Global context for an execution of the CLI
4137
pub struct CliSession<'app> {

crates/pgt_configuration/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pgt_analyse = { workspace = true }
2121
pgt_analyser = { workspace = true }
2222
pgt_console = { workspace = true }
2323
pgt_diagnostics = { workspace = true }
24+
pgt_env = { workspace = true }
2425
pgt_text_size = { workspace = true }
2526
rustc-hash = { workspace = true }
2627
schemars = { workspace = true, features = ["indexmap1"], optional = true }

crates/pgt_configuration/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! This module contains the configuration of `postgrestools.jsonc`
22
//!
3-
//! The configuration is divided by "tool", and then it's possible to further customise it
4-
//! by language. The language might further options divided by tool.
3+
//! The configuration is divided by "tool".
54
65
pub mod analyser;
76
pub mod database;
@@ -34,6 +33,7 @@ use files::{FilesConfiguration, PartialFilesConfiguration, partial_files_configu
3433
use migrations::{
3534
MigrationsConfiguration, PartialMigrationsConfiguration, partial_migrations_configuration,
3635
};
36+
use pgt_env::PGT_WEBSITE;
3737
use plpgsql_check::{
3838
PartialPlPgSqlCheckConfiguration, PlPgSqlCheckConfiguration,
3939
partial_pl_pg_sql_check_configuration,
@@ -44,10 +44,7 @@ pub use typecheck::{
4444
};
4545
use vcs::VcsClientKind;
4646

47-
pub const VERSION: &str = match option_env!("PGT_VERSION") {
48-
Some(version) => version,
49-
None => "0.0.0",
50-
};
47+
pub use pgt_env::VERSION;
5148

5249
/// The configuration that is contained inside the configuration file.
5350
#[derive(Clone, Debug, Default, Deserialize, Eq, Partial, PartialEq, Serialize)]
@@ -106,7 +103,7 @@ impl PartialConfiguration {
106103
/// Returns the initial configuration.
107104
pub fn init() -> Self {
108105
Self {
109-
schema: Some(format!("https://pgtools.dev/schemas/{VERSION}/schema.json")),
106+
schema: Some(format!("{}/schemas/{VERSION}/schema.json", PGT_WEBSITE)),
110107
extends: Some(StringSet::default()),
111108
files: Some(PartialFilesConfiguration {
112109
ignore: Some(Default::default()),

crates/pgt_diagnostics_categories/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version = "0.0.0"
1212

1313

1414
[dependencies]
15+
pgt_env = { workspace = true }
1516
schemars = { workspace = true, optional = true }
1617
serde = { workspace = true, optional = true }
1718

crates/pgt_flags/Cargo.toml renamed to crates/pgt_env/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
authors.workspace = true
33
categories.workspace = true
4-
description = "<DESCRIPTION>"
4+
description = "Environment variables and configuration for Postgres Tools"
55
edition.workspace = true
66
homepage.workspace = true
77
keywords.workspace = true
88
license.workspace = true
9-
name = "pgt_flags"
9+
name = "pgt_env"
1010
repository.workspace = true
1111
version = "0.0.0"
1212

crates/pgt_flags/src/lib.rs renamed to crates/pgt_env/src/lib.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
//! A simple implementation of feature flags.
1+
//! Environment variables and configuration constants for Postgres Tools.
2+
//!
3+
//! This module provides:
4+
//! - Environment variable definitions for runtime configuration
5+
//! - Static constants like version information and website URL
6+
//! - Helper functions for checking build status
27
38
use pgt_console::fmt::{Display, Formatter};
49
use pgt_console::{DebugDisplay, KeyValuePair, markup};
510
use std::env;
6-
use std::ops::Deref;
711
use std::sync::{LazyLock, OnceLock};
812

913
/// Returns `true` if this is an unstable build of Postgres Tools
1014
pub fn is_unstable() -> bool {
11-
PGT_VERSION.deref().is_none()
15+
VERSION == "0.0.0"
1216
}
1317

1418
/// The internal version of Postgres Tools. This is usually supplied during the CI build
1519
pub static PGT_VERSION: LazyLock<Option<&str>> = LazyLock::new(|| option_env!("PGT_VERSION"));
1620

21+
/// The version of Postgres Tools with fallback logic
22+
pub const VERSION: &str = match option_env!("PGT_VERSION") {
23+
Some(version) => version,
24+
None => match option_env!("CARGO_PKG_VERSION") {
25+
Some(pkg_version) => pkg_version,
26+
None => "0.0.0",
27+
},
28+
};
29+
30+
pub static PGT_WEBSITE: &str = "https://pgtools.dev";
31+
1732
pub struct PgTEnv {
1833
pub pgt_log_path: PgTEnvVariable,
1934
pub pgt_log_prefix: PgTEnvVariable,

0 commit comments

Comments
 (0)