mirror of
https://github.com/nushell/nushell.git
synced 2025-01-03 13:00:08 +01:00
Feature cleanup (#7182)
Following up on #7180 with some feature cleanup: - Move the `database` feature from `plugin` to `default` - Rename the `database` feature to `sqlite` - Remove `--features=extra` from a lot of scripts etc. - No need to specify this, the `extra` feature is now the same as the default feature set - Remove the now-redundant 2nd Ubuntu test run
This commit is contained in:
parent
e0577e15f2
commit
efdfeac55e
4
.github/pull_request_template.md
vendored
4
.github/pull_request_template.md
vendored
@ -16,8 +16,8 @@ Don't forget to add tests that cover your changes.
|
|||||||
Make sure you've run and fixed any issues with these commands:
|
Make sure you've run and fixed any issues with these commands:
|
||||||
|
|
||||||
- `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes)
|
- `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes)
|
||||||
- `cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style
|
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style
|
||||||
- `cargo test --workspace --features=extra` to check that all tests pass
|
- `cargo test --workspace` to check that all tests pass
|
||||||
|
|
||||||
# After Submitting
|
# After Submitting
|
||||||
|
|
||||||
|
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -35,7 +35,7 @@ jobs:
|
|||||||
uses: actions-rs/cargo@v1.0.1
|
uses: actions-rs/cargo@v1.0.1
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
args: --features=extra --workspace --exclude nu_plugin_* -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
|
args: --workspace --exclude nu_plugin_* -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
|
||||||
|
|
||||||
nu-tests:
|
nu-tests:
|
||||||
env:
|
env:
|
||||||
@ -45,19 +45,20 @@ jobs:
|
|||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
platform: [windows-latest, macos-latest, ubuntu-latest]
|
platform: [windows-latest, macos-latest, ubuntu-latest]
|
||||||
style: [extra, default]
|
style: [default, dataframe]
|
||||||
rust:
|
rust:
|
||||||
- stable
|
- stable
|
||||||
include:
|
include:
|
||||||
- style: extra
|
|
||||||
flags: "--features=extra"
|
|
||||||
- style: default
|
- style: default
|
||||||
flags: ""
|
flags: ""
|
||||||
|
- style: dataframe
|
||||||
|
flags: "--features=dataframe"
|
||||||
exclude:
|
exclude:
|
||||||
|
# only test dataframes on Ubuntu (the fastest platform)
|
||||||
- platform: windows-latest
|
- platform: windows-latest
|
||||||
style: default
|
style: dataframe
|
||||||
- platform: macos-latest
|
- platform: macos-latest
|
||||||
style: default
|
style: dataframe
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
|
8
.github/workflows/release-pkg.nu
vendored
8
.github/workflows/release-pkg.nu
vendored
@ -51,9 +51,9 @@ if $os in ['ubuntu-latest', 'macos-latest'] {
|
|||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
if $os in ['windows-latest'] {
|
if $os in ['windows-latest'] {
|
||||||
if ($flags | str trim | is-empty) {
|
if ($flags | str trim | is-empty) {
|
||||||
cargo build --release --all --target $target --features=extra
|
cargo build --release --all --target $target
|
||||||
} else {
|
} else {
|
||||||
cargo build --release --all --target $target --features=extra $flags
|
cargo build --release --all --target $target $flags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,9 +138,9 @@ if $os in ['ubuntu-latest', 'macos-latest'] {
|
|||||||
|
|
||||||
def 'cargo-build-nu' [ options: string ] {
|
def 'cargo-build-nu' [ options: string ] {
|
||||||
if ($options | str trim | is-empty) {
|
if ($options | str trim | is-empty) {
|
||||||
cargo build --release --all --target $target --features=extra,static-link-openssl
|
cargo build --release --all --target $target --features=static-link-openssl
|
||||||
} else {
|
} else {
|
||||||
cargo build --release --all --target $target --features=extra,static-link-openssl $options
|
cargo build --release --all --target $target --features=static-link-openssl $options
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,21 +51,21 @@ The most comprehensive test suite we have is the `nu-test-support` crate. For te
|
|||||||
cargo run
|
cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
- Build and run with extra features. Currently extra features include dataframes and sqlite database support.
|
- Build and run with dataframe support.
|
||||||
```shell
|
```shell
|
||||||
cargo run --features=extra
|
cargo run --features=dataframe
|
||||||
```
|
```
|
||||||
|
|
||||||
- Run Clippy on Nushell:
|
- Run Clippy on Nushell:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
|
cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
|
||||||
```
|
```
|
||||||
|
|
||||||
- Run all tests:
|
- Run all tests:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo test --workspace --features=extra
|
cargo test --workspace
|
||||||
```
|
```
|
||||||
|
|
||||||
- Run all tests for a specific command
|
- Run all tests for a specific command
|
||||||
@ -91,11 +91,11 @@ The most comprehensive test suite we have is the `nu-test-support` crate. For te
|
|||||||
- To view verbose logs when developing, enable the `trace` log level.
|
- To view verbose logs when developing, enable the `trace` log level.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo run --release --features=extra -- --log-level trace
|
cargo run --release -- --log-level trace
|
||||||
```
|
```
|
||||||
|
|
||||||
- To redirect trace logs to a file, enable the `--log-target file` switch.
|
- To redirect trace logs to a file, enable the `--log-target file` switch.
|
||||||
```shell
|
```shell
|
||||||
cargo run --release --features=extra -- --log-level trace --log-target file
|
cargo run --release -- --log-level trace --log-target file
|
||||||
open $"($nu.temp-path)/nu-($nu.pid).log"
|
open $"($nu.temp-path)/nu-($nu.pid).log"
|
||||||
```
|
```
|
||||||
|
@ -83,9 +83,10 @@ rstest = {version = "0.15.0", default-features = false}
|
|||||||
itertools = "0.10.3"
|
itertools = "0.10.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
plugin = ["nu-plugin", "nu-cli/plugin", "nu-parser/plugin", "nu-command/plugin", "nu-protocol/plugin", "nu-engine/plugin", "database"]
|
plugin = ["nu-plugin", "nu-cli/plugin", "nu-parser/plugin", "nu-command/plugin", "nu-protocol/plugin", "nu-engine/plugin"]
|
||||||
|
# extra used to be more useful but now it's the same as default. Leaving it in for backcompat with existing build scripts
|
||||||
extra = ["default"]
|
extra = ["default"]
|
||||||
default = ["plugin", "which-support", "trash-support"]
|
default = ["plugin", "which-support", "trash-support", "sqlite"]
|
||||||
stable = ["default"]
|
stable = ["default"]
|
||||||
wasi = []
|
wasi = []
|
||||||
|
|
||||||
@ -101,8 +102,8 @@ trash-support = ["nu-command/trash-support"]
|
|||||||
# Dataframe feature for nushell
|
# Dataframe feature for nushell
|
||||||
dataframe = ["nu-command/dataframe"]
|
dataframe = ["nu-command/dataframe"]
|
||||||
|
|
||||||
# Database commands for nushell
|
# SQLite commands for nushell
|
||||||
database = ["nu-command/database"]
|
sqlite = ["nu-command/sqlite"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "s" # Optimize for size
|
opt-level = "s" # Optimize for size
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
echo "---------------------------------------------------------------"
|
echo "---------------------------------------------------------------"
|
||||||
echo "Building nushell (nu) with --features=extra and all the plugins"
|
echo "Building nushell (nu) with dataframes and all the plugins"
|
||||||
echo "---------------------------------------------------------------"
|
echo "---------------------------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ NU_PLUGINS=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
echo "Building nushell"
|
echo "Building nushell"
|
||||||
cargo build --features=extra
|
cargo build --features=dataframe
|
||||||
for plugin in "${NU_PLUGINS[@]}"
|
for plugin in "${NU_PLUGINS[@]}"
|
||||||
do
|
do
|
||||||
echo '' && cd crates/$plugin
|
echo '' && cd crates/$plugin
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
@echo off
|
@echo off
|
||||||
@echo -------------------------------------------------------------------
|
@echo -------------------------------------------------------------------
|
||||||
@echo Building nushell (nu.exe) with --features=extra and all the plugins
|
@echo Building nushell (nu.exe) with dataframes and all the plugins
|
||||||
@echo -------------------------------------------------------------------
|
@echo -------------------------------------------------------------------
|
||||||
@echo.
|
@echo.
|
||||||
|
|
||||||
echo Building nushell.exe
|
echo Building nushell.exe
|
||||||
cargo build --features=extra
|
cargo build cargo build --features=dataframe
|
||||||
@echo.
|
@echo.
|
||||||
|
|
||||||
@cd crates\nu_plugin_example
|
@cd crates\nu_plugin_example
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
echo '-------------------------------------------------------------------'
|
echo '-------------------------------------------------------------------'
|
||||||
echo 'Building nushell (nu) with --features=extra and all the plugins'
|
echo 'Building nushell (nu) with dataframes and all the plugins'
|
||||||
echo '-------------------------------------------------------------------'
|
echo '-------------------------------------------------------------------'
|
||||||
|
|
||||||
echo $'(char nl)Building nushell'
|
echo $'(char nl)Building nushell'
|
||||||
echo '----------------------------'
|
echo '----------------------------'
|
||||||
cargo build --features=extra
|
cargo build --features=dataframe
|
||||||
|
|
||||||
let plugins = [
|
let plugins = [
|
||||||
nu_plugin_inc,
|
nu_plugin_inc,
|
||||||
|
@ -148,7 +148,7 @@ trash-support = ["trash"]
|
|||||||
which-support = ["which"]
|
which-support = ["which"]
|
||||||
plugin = ["nu-parser/plugin"]
|
plugin = ["nu-parser/plugin"]
|
||||||
dataframe = ["polars", "num", "sqlparser"]
|
dataframe = ["polars", "num", "sqlparser"]
|
||||||
database = ["rusqlite"] # TODO: given that rusqlite is included in reedline, should we just always include it?
|
sqlite = ["rusqlite"] # TODO: given that rusqlite is included in reedline, should we just always include it?
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
shadow-rs = { version = "0.16.1", default-features = false }
|
shadow-rs = { version = "0.16.1", default-features = false }
|
||||||
|
@ -193,7 +193,7 @@ fn features_enabled() -> Vec<String> {
|
|||||||
names.push("trash".to_string());
|
names.push("trash".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
{
|
{
|
||||||
names.push("database".to_string());
|
names.push("database".to_string());
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ pub fn create_default_context() -> EngineState {
|
|||||||
|
|
||||||
// Database-related
|
// Database-related
|
||||||
// Adds all related commands to query databases
|
// Adds all related commands to query databases
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
add_database_decls(&mut working_set);
|
add_database_decls(&mut working_set);
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
|
@ -7,10 +7,10 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
use crate::database::SQLiteDatabase;
|
use crate::database::SQLiteDatabase;
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
use nu_protocol::IntoPipelineData;
|
use nu_protocol::IntoPipelineData;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
@ -107,7 +107,7 @@ impl Command for Open {
|
|||||||
Vec::new(),
|
Vec::new(),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
if !raw {
|
if !raw {
|
||||||
let res = SQLiteDatabase::try_from_path(path, arg_span)
|
let res = SQLiteDatabase::try_from_path(path, arg_span)
|
||||||
.map(|db| db.into_value(call.head).into_pipeline_data());
|
.map(|db| db.into_value(call.head).into_pipeline_data());
|
||||||
|
@ -62,8 +62,8 @@ mod dataframe;
|
|||||||
#[cfg(feature = "dataframe")]
|
#[cfg(feature = "dataframe")]
|
||||||
pub use dataframe::*;
|
pub use dataframe::*;
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
mod database;
|
mod database;
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
pub use database::*;
|
pub use database::*;
|
||||||
|
@ -53,7 +53,7 @@ mod path;
|
|||||||
mod platform;
|
mod platform;
|
||||||
mod prepend;
|
mod prepend;
|
||||||
mod print;
|
mod print;
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
mod query;
|
mod query;
|
||||||
mod random;
|
mod random;
|
||||||
mod range;
|
mod range;
|
||||||
|
@ -108,7 +108,7 @@ fn parses_more_bson_complexity() {
|
|||||||
// │ 4 │ │
|
// │ 4 │ │
|
||||||
// ╰───┴──────╯
|
// ╰───┴──────╯
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn parses_sqlite() {
|
fn parses_sqlite() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
@ -123,7 +123,7 @@ fn parses_sqlite() {
|
|||||||
assert_eq!(actual.out, "3");
|
assert_eq!(actual.out, "3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn parses_sqlite_get_column_name() {
|
fn parses_sqlite_get_column_name() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use nu_test_support::{nu, pipeline};
|
use nu_test_support::{nu, pipeline};
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn can_query_single_table() {
|
fn can_query_single_table() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
@ -16,7 +16,7 @@ fn can_query_single_table() {
|
|||||||
assert_eq!(actual.out, "4");
|
assert_eq!(actual.out, "4");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_sql_fails() {
|
fn invalid_sql_fails() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
@ -30,7 +30,7 @@ fn invalid_sql_fails() {
|
|||||||
assert!(actual.err.contains("syntax error"));
|
assert!(actual.err.contains("syntax error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_input_fails() {
|
fn invalid_input_fails() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use nu_test_support::nu;
|
use nu_test_support::nu;
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
use nu_test_support::pipeline;
|
use nu_test_support::pipeline;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -82,7 +82,7 @@ fn uses_optional_index_argument() {
|
|||||||
assert_eq!(actual.out, "[7, 8]");
|
assert_eq!(actual.out, "[7, 8]");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn binary_operator_comparisons() {
|
fn binary_operator_comparisons() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
@ -151,7 +151,7 @@ fn binary_operator_comparisons() {
|
|||||||
assert_eq!(actual.out, "42");
|
assert_eq!(actual.out, "42");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn contains_operator() {
|
fn contains_operator() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
# Usage: Just run `powershell install-all.ps1` in nushell root directory
|
# Usage: Just run `powershell install-all.ps1` in nushell root directory
|
||||||
|
|
||||||
Write-Output "-----------------------------------------------------------------"
|
Write-Output "-----------------------------------------------------------------"
|
||||||
Write-Output "Installing nushell (nu) with --features=extra and all the plugins"
|
Write-Output "Installing nushell (nu) with dataframes and all the plugins"
|
||||||
Write-Output "-----------------------------------------------------------------"
|
Write-Output "-----------------------------------------------------------------"
|
||||||
Write-Output ""
|
Write-Output ""
|
||||||
|
|
||||||
Write-Output "Install nushell from local..."
|
Write-Output "Install nushell from local..."
|
||||||
Write-Output "----------------------------------------------"
|
Write-Output "----------------------------------------------"
|
||||||
cargo install --path . --features=extra
|
cargo install --path . --features=dataframe
|
||||||
|
|
||||||
$NU_PLUGINS = @(
|
$NU_PLUGINS = @(
|
||||||
'nu_plugin_example',
|
'nu_plugin_example',
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
# Usage: Just run `sh install-all.sh` in nushell root directory
|
# Usage: Just run `sh install-all.sh` in nushell root directory
|
||||||
|
|
||||||
echo "-----------------------------------------------------------------"
|
echo "-----------------------------------------------------------------"
|
||||||
echo "Installing nushell (nu) with --features=extra and all the plugins"
|
echo "Installing nushell (nu) with dataframes and all the plugins"
|
||||||
echo "-----------------------------------------------------------------"
|
echo "-----------------------------------------------------------------"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo "Install nushell from local..."
|
echo "Install nushell from local..."
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
cargo install --path . --features=extra
|
cargo install --path . --features=dataframe
|
||||||
|
|
||||||
NU_PLUGINS=(
|
NU_PLUGINS=(
|
||||||
'nu_plugin_inc'
|
'nu_plugin_inc'
|
||||||
|
@ -53,7 +53,7 @@ fn can_get_describe_plugin_custom_values() {
|
|||||||
// There are currently no custom values defined by the engine that aren't hidden behind an extra
|
// There are currently no custom values defined by the engine that aren't hidden behind an extra
|
||||||
// feature, both database and dataframes are hidden behind --features=extra so we need to guard
|
// feature, both database and dataframes are hidden behind --features=extra so we need to guard
|
||||||
// this test
|
// this test
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "sqlite")]
|
||||||
#[test]
|
#[test]
|
||||||
fn fails_if_passing_engine_custom_values_to_plugins() {
|
fn fails_if_passing_engine_custom_values_to_plugins() {
|
||||||
let actual = nu_with_plugins!(
|
let actual = nu_with_plugins!(
|
||||||
|
Loading…
Reference in New Issue
Block a user