@devaloop/devalang 0.0.1-beta.2 → 0.1.1
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.
- package/README.md +177 -146
- package/out-tsc/api.d.ts +180 -0
- package/out-tsc/api.d.ts.map +1 -0
- package/out-tsc/api.js +286 -0
- package/out-tsc/api.js.map +1 -0
- package/out-tsc/bin/index.d.ts +12 -0
- package/out-tsc/bin/index.d.ts.map +1 -0
- package/out-tsc/bin/index.js +20 -54
- package/out-tsc/bin/index.js.map +1 -0
- package/out-tsc/examples/basic-usage.d.ts +8 -0
- package/out-tsc/examples/basic-usage.d.ts.map +1 -0
- package/out-tsc/examples/basic-usage.js +113 -0
- package/out-tsc/examples/basic-usage.js.map +1 -0
- package/out-tsc/index.d.ts +19 -5
- package/out-tsc/index.d.ts.map +1 -0
- package/out-tsc/index.js +24 -6
- package/out-tsc/index.js.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts +7 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.js +36 -32
- package/out-tsc/scripts/copy-wasm-dts.js.map +1 -0
- package/out-tsc/scripts/postinstall.d.ts +1 -0
- package/out-tsc/scripts/postinstall.d.ts.map +1 -0
- package/out-tsc/scripts/postinstall.js +4 -1
- package/out-tsc/scripts/postinstall.js.map +1 -0
- package/out-tsc/scripts/version/bump.d.ts +5 -1
- package/out-tsc/scripts/version/bump.d.ts.map +1 -0
- package/out-tsc/scripts/version/bump.js +114 -44
- package/out-tsc/scripts/version/bump.js.map +1 -0
- package/out-tsc/scripts/version/fetch.d.ts +12 -1
- package/out-tsc/scripts/version/fetch.d.ts.map +1 -0
- package/out-tsc/scripts/version/fetch.js +68 -24
- package/out-tsc/scripts/version/fetch.js.map +1 -0
- package/out-tsc/scripts/version/index.d.ts +6 -0
- package/out-tsc/scripts/version/index.d.ts.map +1 -0
- package/out-tsc/scripts/version/index.js +44 -22
- package/out-tsc/scripts/version/index.js.map +1 -0
- package/out-tsc/scripts/version/sync.d.ts +5 -1
- package/out-tsc/scripts/version/sync.d.ts.map +1 -0
- package/out-tsc/scripts/version/sync.js +78 -29
- package/out-tsc/scripts/version/sync.js.map +1 -0
- package/out-tsc/types.d.ts +68 -0
- package/out-tsc/types.d.ts.map +1 -0
- package/out-tsc/{core/types/value.js → types.js} +4 -0
- package/out-tsc/types.js.map +1 -0
- package/out-tsc/wasm.d.ts +8 -0
- package/out-tsc/wasm.d.ts.map +1 -0
- package/out-tsc/{core/index.js → wasm.js} +9 -6
- package/out-tsc/wasm.js.map +1 -0
- package/package.json +50 -37
- package/.cargo/config.toml +0 -2
- package/.devalang +0 -9
- package/.github/workflows/ci.yml +0 -103
- package/Cargo.toml +0 -81
- package/docs/CHANGELOG.md +0 -581
- package/docs/CONTRIBUTING.md +0 -101
- package/docs/ROADMAP.md +0 -38
- package/docs/TODO.md +0 -71
- package/examples/automation.deva +0 -42
- package/examples/bank.deva +0 -7
- package/examples/bus.deva +0 -10
- package/examples/condition.deva +0 -20
- package/examples/duration.deva +0 -9
- package/examples/effect.deva +0 -2
- package/examples/events.deva +0 -12
- package/examples/filter.deva +0 -11
- package/examples/function.deva +0 -15
- package/examples/group.deva +0 -12
- package/examples/index.deva +0 -63
- package/examples/lfo.deva +0 -9
- package/examples/loop.deva +0 -10
- package/examples/pattern.deva +0 -8
- package/examples/plugin.deva +0 -16
- package/examples/samples/hat-808.wav +0 -0
- package/examples/samples/kick-808.wav +0 -0
- package/examples/synth.deva +0 -24
- package/examples/synth_types.deva +0 -17
- package/examples/variables.deva +0 -9
- package/out-tsc/core/functions/index.d.ts +0 -42
- package/out-tsc/core/functions/index.js +0 -87
- package/out-tsc/core/index.d.ts +0 -6
- package/out-tsc/core/types/index.d.ts +0 -4
- package/out-tsc/core/types/index.js +0 -20
- package/out-tsc/core/types/plugin.d.ts +0 -18
- package/out-tsc/core/types/plugin.js +0 -2
- package/out-tsc/core/types/result.d.ts +0 -27
- package/out-tsc/core/types/result.js +0 -2
- package/out-tsc/core/types/statement.d.ts +0 -106
- package/out-tsc/core/types/statement.js +0 -2
- package/out-tsc/core/types/value.d.ts +0 -43
- package/out-tsc/pkg/devalang_core.d.ts +0 -15
- package/out-tsc/pkg/devalang_core.js +0 -65
- package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +0 -34
- package/project-version.json +0 -6
- package/rust/cli/bank/api.rs +0 -122
- package/rust/cli/bank/commands.rs +0 -306
- package/rust/cli/bank/mod.rs +0 -29
- package/rust/cli/build/commands.rs +0 -153
- package/rust/cli/build/mod.rs +0 -2
- package/rust/cli/build/process.rs +0 -165
- package/rust/cli/check/mod.rs +0 -208
- package/rust/cli/discover/commands.rs +0 -253
- package/rust/cli/discover/config.rs +0 -111
- package/rust/cli/discover/fs.rs +0 -19
- package/rust/cli/discover/install.rs +0 -103
- package/rust/cli/discover/metadata.rs +0 -48
- package/rust/cli/discover/mod.rs +0 -5
- package/rust/cli/init/commands.rs +0 -88
- package/rust/cli/init/mod.rs +0 -1
- package/rust/cli/install/addon.rs +0 -118
- package/rust/cli/install/bank.rs +0 -72
- package/rust/cli/install/commands.rs +0 -35
- package/rust/cli/install/mod.rs +0 -4
- package/rust/cli/install/plugin.rs +0 -80
- package/rust/cli/login/commands.rs +0 -124
- package/rust/cli/login/mod.rs +0 -1
- package/rust/cli/mod.rs +0 -12
- package/rust/cli/parser.rs +0 -359
- package/rust/cli/play/commands.rs +0 -375
- package/rust/cli/play/io.rs +0 -17
- package/rust/cli/play/mod.rs +0 -5
- package/rust/cli/play/process.rs +0 -159
- package/rust/cli/play/realtime.rs +0 -91
- package/rust/cli/play/utils.rs +0 -23
- package/rust/cli/telemetry/commands.rs +0 -22
- package/rust/cli/telemetry/event_creator.rs +0 -80
- package/rust/cli/telemetry/mod.rs +0 -3
- package/rust/cli/telemetry/send.rs +0 -51
- package/rust/cli/template/commands.rs +0 -69
- package/rust/cli/template/mod.rs +0 -1
- package/rust/cli/update/commands.rs +0 -6
- package/rust/cli/update/mod.rs +0 -1
- package/rust/config/driver.rs +0 -112
- package/rust/config/mod.rs +0 -3
- package/rust/config/ops.rs +0 -26
- package/rust/config/settings.rs +0 -101
- package/rust/core/audio/engine/driver.rs +0 -220
- package/rust/core/audio/engine/export.rs +0 -169
- package/rust/core/audio/engine/helpers.rs +0 -178
- package/rust/core/audio/engine/mod.rs +0 -56
- package/rust/core/audio/engine/notes/dsp.rs +0 -85
- package/rust/core/audio/engine/notes/mod.rs +0 -44
- package/rust/core/audio/engine/notes/params.rs +0 -294
- package/rust/core/audio/engine/sample/insert.rs +0 -199
- package/rust/core/audio/engine/sample/mod.rs +0 -40
- package/rust/core/audio/engine/sample/padding.rs +0 -170
- package/rust/core/audio/evaluator/condition.rs +0 -61
- package/rust/core/audio/evaluator/mod.rs +0 -9
- package/rust/core/audio/evaluator/numeric.rs +0 -152
- package/rust/core/audio/evaluator/rhs.rs +0 -16
- package/rust/core/audio/evaluator/string_expr.rs +0 -94
- package/rust/core/audio/interpreter/driver.rs +0 -574
- package/rust/core/audio/interpreter/mod.rs +0 -2
- package/rust/core/audio/interpreter/statements/arrow_call/interprete.rs +0 -175
- package/rust/core/audio/interpreter/statements/arrow_call/methods/chord.rs +0 -384
- package/rust/core/audio/interpreter/statements/arrow_call/methods/mod.rs +0 -2
- package/rust/core/audio/interpreter/statements/arrow_call/methods/note.rs +0 -316
- package/rust/core/audio/interpreter/statements/arrow_call/mod.rs +0 -3
- package/rust/core/audio/interpreter/statements/arrow_call/types/arp.rs +0 -192
- package/rust/core/audio/interpreter/statements/arrow_call/types/mod.rs +0 -24
- package/rust/core/audio/interpreter/statements/arrow_call/types/pad.rs +0 -116
- package/rust/core/audio/interpreter/statements/arrow_call/types/pluck.rs +0 -97
- package/rust/core/audio/interpreter/statements/arrow_call/types/sub.rs +0 -100
- package/rust/core/audio/interpreter/statements/automate.rs +0 -16
- package/rust/core/audio/interpreter/statements/call.rs +0 -295
- package/rust/core/audio/interpreter/statements/condition.rs +0 -72
- package/rust/core/audio/interpreter/statements/function.rs +0 -24
- package/rust/core/audio/interpreter/statements/let_.rs +0 -36
- package/rust/core/audio/interpreter/statements/load.rs +0 -17
- package/rust/core/audio/interpreter/statements/loop_.rs +0 -115
- package/rust/core/audio/interpreter/statements/mod.rs +0 -12
- package/rust/core/audio/interpreter/statements/sleep.rs +0 -28
- package/rust/core/audio/interpreter/statements/spawn.rs +0 -253
- package/rust/core/audio/interpreter/statements/tempo.rs +0 -40
- package/rust/core/audio/interpreter/statements/trigger.rs +0 -239
- package/rust/core/audio/loader/mod.rs +0 -1
- package/rust/core/audio/loader/trigger.rs +0 -98
- package/rust/core/audio/mod.rs +0 -6
- package/rust/core/audio/player.rs +0 -70
- package/rust/core/audio/special/easing.rs +0 -189
- package/rust/core/audio/special/env.rs +0 -45
- package/rust/core/audio/special/math.rs +0 -134
- package/rust/core/audio/special/mod.rs +0 -9
- package/rust/core/audio/special/modulator.rs +0 -143
- package/rust/core/builder/mod.rs +0 -129
- package/rust/core/debugger/lexer.rs +0 -27
- package/rust/core/debugger/logs.rs +0 -52
- package/rust/core/debugger/mod.rs +0 -30
- package/rust/core/debugger/preprocessor.rs +0 -27
- package/rust/core/debugger/store.rs +0 -38
- package/rust/core/error/mod.rs +0 -269
- package/rust/core/lexer/driver.rs +0 -59
- package/rust/core/lexer/handler/arrow.rs +0 -82
- package/rust/core/lexer/handler/at.rs +0 -21
- package/rust/core/lexer/handler/brace.rs +0 -41
- package/rust/core/lexer/handler/colon.rs +0 -21
- package/rust/core/lexer/handler/comment.rs +0 -30
- package/rust/core/lexer/handler/dot.rs +0 -21
- package/rust/core/lexer/handler/driver.rs +0 -337
- package/rust/core/lexer/handler/identifier.rs +0 -47
- package/rust/core/lexer/handler/indent.rs +0 -66
- package/rust/core/lexer/handler/mod.rs +0 -15
- package/rust/core/lexer/handler/newline.rs +0 -23
- package/rust/core/lexer/handler/number.rs +0 -31
- package/rust/core/lexer/handler/operator.rs +0 -46
- package/rust/core/lexer/handler/parenthesis.rs +0 -41
- package/rust/core/lexer/handler/slash.rs +0 -21
- package/rust/core/lexer/handler/string.rs +0 -63
- package/rust/core/lexer/mod.rs +0 -3
- package/rust/core/lexer/token.rs +0 -91
- package/rust/core/mod.rs +0 -9
- package/rust/core/parser/driver/block.rs +0 -111
- package/rust/core/parser/driver/cursor.rs +0 -82
- package/rust/core/parser/driver/driver_impl.rs +0 -139
- package/rust/core/parser/driver/mod.rs +0 -6
- package/rust/core/parser/driver/parse_array.rs +0 -120
- package/rust/core/parser/driver/parse_map.rs +0 -223
- package/rust/core/parser/driver/parser.rs +0 -160
- package/rust/core/parser/handler/arrow_call.rs +0 -277
- package/rust/core/parser/handler/at.rs +0 -279
- package/rust/core/parser/handler/bank.rs +0 -104
- package/rust/core/parser/handler/condition.rs +0 -83
- package/rust/core/parser/handler/dot.rs +0 -148
- package/rust/core/parser/handler/identifier/automate.rs +0 -254
- package/rust/core/parser/handler/identifier/call.rs +0 -91
- package/rust/core/parser/handler/identifier/emit.rs +0 -70
- package/rust/core/parser/handler/identifier/function.rs +0 -113
- package/rust/core/parser/handler/identifier/group.rs +0 -89
- package/rust/core/parser/handler/identifier/let_.rs +0 -173
- package/rust/core/parser/handler/identifier/mod.rs +0 -55
- package/rust/core/parser/handler/identifier/on.rs +0 -107
- package/rust/core/parser/handler/identifier/print.rs +0 -49
- package/rust/core/parser/handler/identifier/sleep.rs +0 -96
- package/rust/core/parser/handler/identifier/spawn.rs +0 -91
- package/rust/core/parser/handler/identifier/synth.rs +0 -135
- package/rust/core/parser/handler/loop_.rs +0 -194
- package/rust/core/parser/handler/mod.rs +0 -9
- package/rust/core/parser/handler/pattern.rs +0 -74
- package/rust/core/parser/handler/tempo.rs +0 -105
- package/rust/core/parser/mod.rs +0 -3
- package/rust/core/parser/statement.rs +0 -10
- package/rust/core/plugin/loader.rs +0 -137
- package/rust/core/plugin/mod.rs +0 -2
- package/rust/core/plugin/runner/mod.rs +0 -11
- package/rust/core/plugin/runner/non_wasm.rs +0 -297
- package/rust/core/plugin/runner/wasm32.rs +0 -43
- package/rust/core/preprocessor/loader/inject.rs +0 -278
- package/rust/core/preprocessor/loader/loader_helpers.rs +0 -110
- package/rust/core/preprocessor/loader/mod.rs +0 -235
- package/rust/core/preprocessor/mod.rs +0 -4
- package/rust/core/preprocessor/module.rs +0 -55
- package/rust/core/preprocessor/processor/handlers.rs +0 -107
- package/rust/core/preprocessor/processor/mod.rs +0 -1
- package/rust/core/preprocessor/resolver/bank.rs +0 -49
- package/rust/core/preprocessor/resolver/call.rs +0 -124
- package/rust/core/preprocessor/resolver/condition.rs +0 -95
- package/rust/core/preprocessor/resolver/driver.rs +0 -324
- package/rust/core/preprocessor/resolver/function.rs +0 -69
- package/rust/core/preprocessor/resolver/group.rs +0 -122
- package/rust/core/preprocessor/resolver/let_.rs +0 -32
- package/rust/core/preprocessor/resolver/loop_.rs +0 -318
- package/rust/core/preprocessor/resolver/mod.rs +0 -16
- package/rust/core/preprocessor/resolver/pattern.rs +0 -83
- package/rust/core/preprocessor/resolver/spawn.rs +0 -99
- package/rust/core/preprocessor/resolver/synth.rs +0 -54
- package/rust/core/preprocessor/resolver/tempo.rs +0 -48
- package/rust/core/preprocessor/resolver/trigger.rs +0 -116
- package/rust/core/preprocessor/resolver/value.rs +0 -176
- package/rust/core/store/global.rs +0 -57
- package/rust/core/store/mod.rs +0 -1
- package/rust/lib.rs +0 -323
- package/rust/main.rs +0 -388
- package/rust/types/Cargo.toml +0 -11
- package/rust/types/src/addons.rs +0 -55
- package/rust/types/src/ast.rs +0 -202
- package/rust/types/src/config.rs +0 -84
- package/rust/types/src/lib.rs +0 -15
- package/rust/types/src/plugin.rs +0 -20
- package/rust/types/src/store.rs +0 -139
- package/rust/types/src/telemetry.rs +0 -85
- package/rust/utils/Cargo.toml +0 -26
- package/rust/utils/src/error.rs +0 -186
- package/rust/utils/src/file.rs +0 -94
- package/rust/utils/src/first_usage.rs +0 -97
- package/rust/utils/src/lib.rs +0 -9
- package/rust/utils/src/logger.rs +0 -200
- package/rust/utils/src/path.rs +0 -129
- package/rust/utils/src/signature.rs +0 -41
- package/rust/utils/src/spinner.rs +0 -20
- package/rust/utils/src/version.rs +0 -27
- package/rust/utils/src/watcher.rs +0 -46
- package/rust/web/api.rs +0 -5
- package/rust/web/cdn.rs +0 -34
- package/rust/web/mod.rs +0 -3
- package/rust/web/sso.rs +0 -5
- package/templates/minimal/.devalang +0 -5
- package/templates/minimal/README.md +0 -218
- package/templates/minimal/src/index.deva +0 -2
- package/templates/welcome/.devalang +0 -5
- package/templates/welcome/README.md +0 -218
- package/templates/welcome/samples/kick-808.wav +0 -0
- package/templates/welcome/src/index.deva +0 -61
- package/templates/welcome/src/variables.deva +0 -3
- package/tests/integration.rs +0 -21
- package/tests/rust/cli_check_build.rs +0 -21
- package/tests/rust/cli_help.rs +0 -12
- package/tests/rust/cli_template_list.rs +0 -10
- package/tests/rust/cli_version.rs +0 -11
- package/tests/typescript/index.spec.ts +0 -136
- package/tests/typescript/playhead.spec.ts +0 -36
- package/tests/typescript/render_e2e.spec.ts +0 -77
- package/tsconfig.json +0 -115
- package/typescript/bin/index.ts +0 -28
- package/typescript/core/functions/index.ts +0 -94
- package/typescript/core/index.ts +0 -6
- package/typescript/core/types/index.ts +0 -4
- package/typescript/core/types/plugin.ts +0 -19
- package/typescript/core/types/result.ts +0 -29
- package/typescript/core/types/statement.ts +0 -47
- package/typescript/core/types/value.ts +0 -29
- package/typescript/index.ts +0 -8
- package/typescript/pkg/devalang_core.d.ts +0 -4
- package/typescript/pkg/devalang_core.ts +0 -65
- package/typescript/scripts/copy-wasm-dts.ts +0 -41
- package/typescript/scripts/postinstall.ts +0 -85
- package/typescript/scripts/version/bump.ts +0 -44
- package/typescript/scripts/version/fetch.ts +0 -18
- package/typescript/scripts/version/index.ts +0 -25
- package/typescript/scripts/version/sync.ts +0 -24
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
use devalang_types::AddonMetadata;
|
|
2
|
-
use toml::Value;
|
|
3
|
-
|
|
4
|
-
pub fn parse_metadata_file(addon_type: &str, metadata_content: &str) -> Option<AddonMetadata> {
|
|
5
|
-
let parsed = metadata_content.parse::<Value>().ok()?;
|
|
6
|
-
|
|
7
|
-
let table = (match addon_type {
|
|
8
|
-
"bank" => parsed.get("bank"),
|
|
9
|
-
"plugin" => parsed.get("plugin"),
|
|
10
|
-
"preset" => parsed.get("preset"),
|
|
11
|
-
"template" => parsed.get("template"),
|
|
12
|
-
_ => None,
|
|
13
|
-
})?;
|
|
14
|
-
|
|
15
|
-
let name = table
|
|
16
|
-
.get("name")
|
|
17
|
-
.and_then(|v| v.as_str())
|
|
18
|
-
.unwrap_or("")
|
|
19
|
-
.to_string();
|
|
20
|
-
let version = table
|
|
21
|
-
.get("version")
|
|
22
|
-
.and_then(|v| v.as_str())
|
|
23
|
-
.unwrap_or("")
|
|
24
|
-
.to_string();
|
|
25
|
-
let description = table
|
|
26
|
-
.get("description")
|
|
27
|
-
.and_then(|v| v.as_str())
|
|
28
|
-
.unwrap_or("")
|
|
29
|
-
.to_string();
|
|
30
|
-
let author = table
|
|
31
|
-
.get("author")
|
|
32
|
-
.and_then(|v| v.as_str())
|
|
33
|
-
.unwrap_or("unknown")
|
|
34
|
-
.to_string();
|
|
35
|
-
let access = table
|
|
36
|
-
.get("access")
|
|
37
|
-
.and_then(|v| v.as_str())
|
|
38
|
-
.unwrap_or("")
|
|
39
|
-
.to_string();
|
|
40
|
-
|
|
41
|
-
Some(AddonMetadata {
|
|
42
|
-
name,
|
|
43
|
-
author,
|
|
44
|
-
version,
|
|
45
|
-
description,
|
|
46
|
-
access,
|
|
47
|
-
})
|
|
48
|
-
}
|
package/rust/cli/discover/mod.rs
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
use crate::cli::template::commands::get_available_templates;
|
|
2
|
-
use devalang_utils::file::copy_dir_recursive;
|
|
3
|
-
use include_dir::{Dir, include_dir};
|
|
4
|
-
use std::{fs, path::Path};
|
|
5
|
-
|
|
6
|
-
#[cfg(feature = "cli")]
|
|
7
|
-
use inquire::{Confirm, Select};
|
|
8
|
-
|
|
9
|
-
static TEMPLATES_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/templates");
|
|
10
|
-
|
|
11
|
-
#[cfg(feature = "cli")]
|
|
12
|
-
pub fn handle_init_command(name: Option<String>, template: Option<String>) {
|
|
13
|
-
let current_dir = std::env::current_dir().unwrap();
|
|
14
|
-
let project_name = name.clone().unwrap_or_else(|| {
|
|
15
|
-
current_dir
|
|
16
|
-
.file_name()
|
|
17
|
-
.unwrap_or_default()
|
|
18
|
-
.to_string_lossy()
|
|
19
|
-
.to_string()
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Select a template if not provided
|
|
23
|
-
let selected_template = template.unwrap_or_else(|| {
|
|
24
|
-
Select::new(
|
|
25
|
-
"Select a template for your project:",
|
|
26
|
-
get_available_templates(),
|
|
27
|
-
)
|
|
28
|
-
.prompt()
|
|
29
|
-
.unwrap_or_else(|_| {
|
|
30
|
-
eprintln!("No template selected. Exiting...");
|
|
31
|
-
std::process::exit(1);
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if selected_template.is_empty() {
|
|
36
|
-
eprintln!("Template cannot be empty.");
|
|
37
|
-
std::process::exit(1);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if name.is_none() {
|
|
41
|
-
// Case of initialization in the current directory
|
|
42
|
-
if fs::read_dir(¤t_dir).unwrap().next().is_some() {
|
|
43
|
-
let confirm =
|
|
44
|
-
Confirm::new("The current directory is not empty. Do you want to continue?")
|
|
45
|
-
.with_default(false)
|
|
46
|
-
.prompt()
|
|
47
|
-
.unwrap_or(false);
|
|
48
|
-
|
|
49
|
-
if !confirm {
|
|
50
|
-
eprintln!("Operation cancelled by the user.");
|
|
51
|
-
std::process::exit(0);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
scaffold_project_current_dir(current_dir.as_path(), selected_template);
|
|
56
|
-
println!(
|
|
57
|
-
"✅ Initialized '{}' project in current directory: {}",
|
|
58
|
-
project_name,
|
|
59
|
-
current_dir.display()
|
|
60
|
-
);
|
|
61
|
-
} else {
|
|
62
|
-
// Case of initialization in a new directory
|
|
63
|
-
let target_path = current_dir.join(&project_name);
|
|
64
|
-
|
|
65
|
-
if target_path.exists() {
|
|
66
|
-
eprintln!("❌ A folder named '{}' already exists.", project_name);
|
|
67
|
-
std::process::exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
fs::create_dir_all(&target_path).expect("Error creating project directory");
|
|
71
|
-
|
|
72
|
-
scaffold_project_current_dir(&target_path, selected_template);
|
|
73
|
-
println!(
|
|
74
|
-
"✅ Initialized '{}' project in: {}",
|
|
75
|
-
project_name,
|
|
76
|
-
target_path.display()
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
fn scaffold_project_current_dir(path: &Path, template: String) {
|
|
82
|
-
let template_dir = TEMPLATES_DIR.get_dir(&template).unwrap_or_else(|| {
|
|
83
|
-
eprintln!("❌ The template '{}' doesn't exist.", template);
|
|
84
|
-
std::process::exit(1);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
copy_dir_recursive(template_dir, path, template_dir.path());
|
|
88
|
-
}
|
package/rust/cli/init/mod.rs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pub mod commands;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
cli::install::{bank::install_bank, plugin::install_plugin},
|
|
3
|
-
config::settings::get_user_config,
|
|
4
|
-
web::api::get_api_url,
|
|
5
|
-
};
|
|
6
|
-
use devalang_types::AddonType;
|
|
7
|
-
use std::path::Path;
|
|
8
|
-
|
|
9
|
-
pub async fn install_addon(
|
|
10
|
-
addon_type: AddonType,
|
|
11
|
-
name: &str,
|
|
12
|
-
target_dir: &Path,
|
|
13
|
-
) -> Result<(), String> {
|
|
14
|
-
match addon_type {
|
|
15
|
-
AddonType::Bank => install_bank(name, target_dir).await,
|
|
16
|
-
AddonType::Plugin => install_plugin(name, target_dir).await,
|
|
17
|
-
AddonType::Preset => Err("Preset installation not implemented".into()),
|
|
18
|
-
AddonType::Template => Err("Template installation not implemented".into()),
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
pub async fn ask_api_for_signed_url(addon_type: AddonType, slug: &str) -> Result<String, String> {
|
|
23
|
-
let api_url = get_api_url();
|
|
24
|
-
|
|
25
|
-
use devalang_utils::logger::LogLevel;
|
|
26
|
-
use devalang_utils::logger::Logger;
|
|
27
|
-
|
|
28
|
-
// Require an authenticated user for addon installation: token must be present and non-empty
|
|
29
|
-
let stored_token_opt = get_user_config().and_then(|cfg| {
|
|
30
|
-
let t = cfg.session.clone();
|
|
31
|
-
if t.trim().is_empty() { None } else { Some(t) }
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if stored_token_opt.is_none() {
|
|
35
|
-
let logger = Logger::new();
|
|
36
|
-
let msg = "Authentication required — run `devalang login` to authenticate";
|
|
37
|
-
logger.log_message(LogLevel::Error, msg);
|
|
38
|
-
return Err("Authentication required: run 'devalang login' to authenticate".to_string());
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let request_url = if let Some(token) = &stored_token_opt {
|
|
42
|
-
format!(
|
|
43
|
-
"{}/v1/assets/url?type={}&slug={}&token={}",
|
|
44
|
-
api_url,
|
|
45
|
-
match addon_type {
|
|
46
|
-
AddonType::Bank => "bank",
|
|
47
|
-
AddonType::Plugin => "plugin",
|
|
48
|
-
AddonType::Preset => "preset",
|
|
49
|
-
AddonType::Template => "template",
|
|
50
|
-
},
|
|
51
|
-
slug,
|
|
52
|
-
token
|
|
53
|
-
)
|
|
54
|
-
} else {
|
|
55
|
-
format!(
|
|
56
|
-
"{}/v1/assets/url?type={}&slug={}",
|
|
57
|
-
api_url,
|
|
58
|
-
match addon_type {
|
|
59
|
-
AddonType::Bank => "bank",
|
|
60
|
-
AddonType::Plugin => "plugin",
|
|
61
|
-
AddonType::Preset => "preset",
|
|
62
|
-
AddonType::Template => "template",
|
|
63
|
-
},
|
|
64
|
-
slug
|
|
65
|
-
)
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
let mut headers = reqwest::header::HeaderMap::new();
|
|
69
|
-
if let Some(token) = stored_token_opt {
|
|
70
|
-
headers.insert(
|
|
71
|
-
"Authorization",
|
|
72
|
-
format!("Bearer {}", token).parse().unwrap(),
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let client: reqwest::Client = reqwest::Client::builder()
|
|
77
|
-
.default_headers(headers)
|
|
78
|
-
.build()
|
|
79
|
-
.map_err(|_| "Failed to build HTTP client".to_string())?;
|
|
80
|
-
|
|
81
|
-
let resp = client
|
|
82
|
-
.get(&request_url)
|
|
83
|
-
.send()
|
|
84
|
-
.await
|
|
85
|
-
.map_err(|e| format!("Failed to receive response: {}", e))?;
|
|
86
|
-
|
|
87
|
-
let status = resp.status();
|
|
88
|
-
let body_text = resp
|
|
89
|
-
.text()
|
|
90
|
-
.await
|
|
91
|
-
.map_err(|e| format!("Failed to read response body: {}", e))?;
|
|
92
|
-
|
|
93
|
-
// Try to parse JSON; if parsing fails, return body for diagnostics
|
|
94
|
-
let json: serde_json::Value = match serde_json::from_str(&body_text) {
|
|
95
|
-
Ok(v) => v,
|
|
96
|
-
Err(_) => {
|
|
97
|
-
return Err(format!(
|
|
98
|
-
"Invalid JSON response (status {}): {}",
|
|
99
|
-
status, body_text
|
|
100
|
-
));
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// Extract payload.url safely
|
|
105
|
-
let signed_url_opt = json
|
|
106
|
-
.get("payload")
|
|
107
|
-
.and_then(|p| p.get("url"))
|
|
108
|
-
.and_then(|u| u.as_str())
|
|
109
|
-
.map(|s| s.to_string());
|
|
110
|
-
|
|
111
|
-
if let Some(signed_url) = signed_url_opt {
|
|
112
|
-
Ok(signed_url)
|
|
113
|
-
} else {
|
|
114
|
-
// Provide detailed diagnostics to help user understand why it's null
|
|
115
|
-
let err_msg = format!("API returned no URL (status {}): {}", status, body_text);
|
|
116
|
-
Err(err_msg)
|
|
117
|
-
}
|
|
118
|
-
}
|
package/rust/cli/install/bank.rs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
cli::install::addon::ask_api_for_signed_url, config::ops::load_config,
|
|
3
|
-
web::cdn::download_from_cdn,
|
|
4
|
-
};
|
|
5
|
-
use devalang_core::config::driver::ProjectConfigExt;
|
|
6
|
-
use devalang_types::AddonType;
|
|
7
|
-
use devalang_types::ProjectConfigBankEntry;
|
|
8
|
-
use devalang_utils::{
|
|
9
|
-
logger::{LogLevel, Logger},
|
|
10
|
-
path as path_utils,
|
|
11
|
-
};
|
|
12
|
-
use std::path::Path;
|
|
13
|
-
|
|
14
|
-
pub async fn install_bank(name: &str, target_dir: &Path) -> Result<(), String> {
|
|
15
|
-
let logger = Logger::new();
|
|
16
|
-
|
|
17
|
-
let signed_url = ask_api_for_signed_url(AddonType::Bank, name).await?;
|
|
18
|
-
|
|
19
|
-
let bank_dir = target_dir.join("banks");
|
|
20
|
-
let archive_path = path_utils::ensure_deva_dir()?
|
|
21
|
-
.join("tmp")
|
|
22
|
-
.join(format!("{}.devabank", name));
|
|
23
|
-
let extract_path = bank_dir.join(name);
|
|
24
|
-
|
|
25
|
-
download_from_cdn(&signed_url, &archive_path)
|
|
26
|
-
.await
|
|
27
|
-
.map_err(|e| format!("Failed to download: {}", e))?;
|
|
28
|
-
|
|
29
|
-
if extract_path.exists() {
|
|
30
|
-
logger.log_message(
|
|
31
|
-
LogLevel::Warning,
|
|
32
|
-
&format!(
|
|
33
|
-
"Bank '{}' already exists at '{}'. Skipping install.",
|
|
34
|
-
name,
|
|
35
|
-
extract_path.display()
|
|
36
|
-
),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return Ok(());
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Add the bank to the config
|
|
43
|
-
let config_path = path_utils::get_devalang_config_path()?;
|
|
44
|
-
let mut config = load_config(Some(&config_path))
|
|
45
|
-
.ok_or_else(|| format!("Failed to load config from '{}'", config_path.display()))?;
|
|
46
|
-
|
|
47
|
-
let dependency_path = format!("devalang://bank/{}", name);
|
|
48
|
-
|
|
49
|
-
devalang_utils::file::extract_zip_safely(&archive_path, &extract_path)
|
|
50
|
-
.map_err(|e| format!("Failed to extract: {}", e))?;
|
|
51
|
-
|
|
52
|
-
// Add the bank to the config if not already present
|
|
53
|
-
if config.banks.is_none() {
|
|
54
|
-
config.banks = Some(Vec::new());
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if let Some(banks) = config.banks.as_mut() {
|
|
58
|
-
let exists = banks.iter().any(|b| b.path == dependency_path);
|
|
59
|
-
if !exists {
|
|
60
|
-
banks.push(ProjectConfigBankEntry {
|
|
61
|
-
path: dependency_path.clone(),
|
|
62
|
-
version: None,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
if let Err(e) = config.write_config(&config) {
|
|
66
|
-
eprintln!("Warning: failed to write config: {}", e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
Ok(())
|
|
72
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
use crate::cli::install::addon::install_addon;
|
|
2
|
-
#[cfg(feature = "cli")]
|
|
3
|
-
use devalang_types::AddonType;
|
|
4
|
-
use devalang_utils::path as path_utils;
|
|
5
|
-
|
|
6
|
-
/// Handles the installation command for a given addon type and name.
|
|
7
|
-
#[cfg(feature = "cli")]
|
|
8
|
-
pub async fn handle_install_command(name: String, addon_type: AddonType) -> Result<(), String> {
|
|
9
|
-
use devalang_utils::{
|
|
10
|
-
logger::{LogLevel, Logger},
|
|
11
|
-
spinner::start_spinner,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
let logger = Logger::new();
|
|
15
|
-
let deva_dir = path_utils::ensure_deva_dir()?;
|
|
16
|
-
|
|
17
|
-
let spinner = start_spinner("Installing...");
|
|
18
|
-
|
|
19
|
-
if let Err(e) = install_addon(addon_type.clone(), name.as_str(), &deva_dir).await {
|
|
20
|
-
spinner.finish_and_clear();
|
|
21
|
-
logger.log_message_with_trace(
|
|
22
|
-
LogLevel::Error,
|
|
23
|
-
&format!("Error installing {:?} '{}'", addon_type, name),
|
|
24
|
-
vec![&e],
|
|
25
|
-
);
|
|
26
|
-
} else {
|
|
27
|
-
spinner.finish_and_clear();
|
|
28
|
-
logger.log_message(
|
|
29
|
-
LogLevel::Success,
|
|
30
|
-
&format!("{:?} '{}' installed successfully!", addon_type, name),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Ok(())
|
|
35
|
-
}
|
package/rust/cli/install/mod.rs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
config::ops::load_config,
|
|
3
|
-
web::cdn::{download_from_cdn, get_cdn_url},
|
|
4
|
-
};
|
|
5
|
-
use devalang_core::config::driver::ProjectConfigExt;
|
|
6
|
-
use devalang_types::ProjectConfigPluginEntry;
|
|
7
|
-
use devalang_utils::path as path_utils;
|
|
8
|
-
use std::{fs, path::Path};
|
|
9
|
-
|
|
10
|
-
pub async fn install_plugin(name: &str, target_dir: &Path) -> Result<(), String> {
|
|
11
|
-
let cdn_url = get_cdn_url();
|
|
12
|
-
let url = format!("{}/plugin/{}/download", cdn_url, name);
|
|
13
|
-
|
|
14
|
-
let plugin_dir = target_dir.join("plugins");
|
|
15
|
-
|
|
16
|
-
// Ensure .deva/tmp exists and build archive path
|
|
17
|
-
let deva_dir = path_utils::ensure_deva_dir()?;
|
|
18
|
-
let tmp_dir = deva_dir.join("tmp");
|
|
19
|
-
if !tmp_dir.exists() {
|
|
20
|
-
fs::create_dir_all(&tmp_dir)
|
|
21
|
-
.map_err(|e| format!("Failed to create tmp dir '{}': {}", tmp_dir.display(), e))?;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let archive_path = tmp_dir.join(format!("{}.devaplugin", name));
|
|
25
|
-
let extract_path = plugin_dir.join(name);
|
|
26
|
-
|
|
27
|
-
if extract_path.exists() {
|
|
28
|
-
println!(
|
|
29
|
-
"Plugin '{}' already exists at '{}'. Skipping install.",
|
|
30
|
-
name,
|
|
31
|
-
extract_path.display()
|
|
32
|
-
);
|
|
33
|
-
return Ok(());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
download_from_cdn(&url, &archive_path)
|
|
37
|
-
.await
|
|
38
|
-
.map_err(|e| format!("Failed to download: {}", e))?;
|
|
39
|
-
|
|
40
|
-
// Add the plugin to the config: locate project root from target_dir
|
|
41
|
-
let project_root = path_utils::find_project_root_from(target_dir)
|
|
42
|
-
.ok_or_else(|| "Failed to determine project root from target_dir".to_string())?;
|
|
43
|
-
|
|
44
|
-
let config_path = project_root.join(path_utils::DEVALANG_CONFIG);
|
|
45
|
-
if !config_path.exists() {
|
|
46
|
-
return Err(format!(
|
|
47
|
-
"Config file not found at '{}'. Please run 'devalang init' before adding an addon",
|
|
48
|
-
config_path.display()
|
|
49
|
-
));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
let mut config = load_config(Some(&config_path))
|
|
53
|
-
.ok_or_else(|| format!("Failed to load config from '{}'", config_path.display()))?;
|
|
54
|
-
|
|
55
|
-
let dependency_path = format!("devalang://plugin/{}", name);
|
|
56
|
-
|
|
57
|
-
devalang_utils::file::extract_zip_safely(&archive_path, &extract_path)
|
|
58
|
-
.map_err(|e| format!("Failed to extract: {}", e))?;
|
|
59
|
-
|
|
60
|
-
// Add the plugin to the config if not already present
|
|
61
|
-
if config.plugins.is_none() {
|
|
62
|
-
config.plugins = Some(Vec::new());
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if let Some(plugins) = config.plugins.as_mut() {
|
|
66
|
-
let exists = plugins.iter().any(|p| p.path == dependency_path);
|
|
67
|
-
if !exists {
|
|
68
|
-
plugins.push(ProjectConfigPluginEntry {
|
|
69
|
-
path: dependency_path.clone(),
|
|
70
|
-
version: None,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
if let Err(e) = config.write_config(&config) {
|
|
74
|
-
eprintln!("Warning: failed to write config: {}", e);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
Ok(())
|
|
80
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
use crate::config::settings::set_user_config_value;
|
|
2
|
-
use crate::web::sso::get_sso_url;
|
|
3
|
-
use std::str::FromStr;
|
|
4
|
-
use tiny_http::Header;
|
|
5
|
-
use tiny_http::{Response, Server};
|
|
6
|
-
use webbrowser;
|
|
7
|
-
|
|
8
|
-
/// Handle the login command
|
|
9
|
-
/// This function initiates the login process by opening the browser and waiting for the callback.
|
|
10
|
-
#[cfg(feature = "cli")]
|
|
11
|
-
pub async fn handle_login_command() -> Result<(), String> {
|
|
12
|
-
use devalang_utils::logger::LogLevel;
|
|
13
|
-
use devalang_utils::logger::Logger;
|
|
14
|
-
use devalang_utils::spinner::start_spinner;
|
|
15
|
-
|
|
16
|
-
let logger = Logger::new();
|
|
17
|
-
|
|
18
|
-
let mut listener_port = 7878;
|
|
19
|
-
|
|
20
|
-
let test_port_already_in_use = format!("127.0.0.1:{}", listener_port);
|
|
21
|
-
while std::net::TcpListener::bind(&test_port_already_in_use).is_err() {
|
|
22
|
-
listener_port += 1;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let redirect_uri = format!("http://127.0.0.1:{}/callback", listener_port);
|
|
26
|
-
let login_url = format!(
|
|
27
|
-
"{}/?response_type=code&referer=cli&redirect_uri={}",
|
|
28
|
-
get_sso_url(),
|
|
29
|
-
redirect_uri
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
if webbrowser::open(&login_url).is_ok() {
|
|
33
|
-
logger.log_message(LogLevel::Info, "Opening browser for login...");
|
|
34
|
-
logger.log_message(
|
|
35
|
-
LogLevel::Info,
|
|
36
|
-
&format!(
|
|
37
|
-
"If the browser does not open, please visit the following URL: {}",
|
|
38
|
-
login_url
|
|
39
|
-
),
|
|
40
|
-
);
|
|
41
|
-
} else {
|
|
42
|
-
logger.log_message(
|
|
43
|
-
LogLevel::Info,
|
|
44
|
-
"Please open the following URL in your browser to login:",
|
|
45
|
-
);
|
|
46
|
-
logger.log_message(LogLevel::Info, &login_url);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let server = Server::http(format!("127.0.0.1:{}", listener_port)).unwrap();
|
|
50
|
-
|
|
51
|
-
let spinner = start_spinner("Waiting for authentication...");
|
|
52
|
-
|
|
53
|
-
for request in server.incoming_requests() {
|
|
54
|
-
let query = request.url().to_string();
|
|
55
|
-
if request.url().starts_with("/callback") {
|
|
56
|
-
if query.contains("session=") || query.contains("error=") {
|
|
57
|
-
let token = query.split("session=").nth(1).unwrap_or("").to_string();
|
|
58
|
-
|
|
59
|
-
if !token.is_empty() {
|
|
60
|
-
let response_html = r#"
|
|
61
|
-
<html>
|
|
62
|
-
<body>
|
|
63
|
-
<h1>Authentication Successful</h1>
|
|
64
|
-
<h2>You can now close this window.</h2>
|
|
65
|
-
</body>
|
|
66
|
-
</html>
|
|
67
|
-
"#;
|
|
68
|
-
|
|
69
|
-
let response = Response::from_string(response_html)
|
|
70
|
-
.with_status_code(200)
|
|
71
|
-
.with_header(Header::from_str("Content-Type: text/html").unwrap());
|
|
72
|
-
|
|
73
|
-
request.respond(response).unwrap();
|
|
74
|
-
|
|
75
|
-
save_token(&token);
|
|
76
|
-
|
|
77
|
-
spinner.finish_and_clear();
|
|
78
|
-
|
|
79
|
-
logger.log_message(
|
|
80
|
-
LogLevel::Success,
|
|
81
|
-
"Authentication successful. Token saved to ~/.devalang/config.json",
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
break;
|
|
85
|
-
} else {
|
|
86
|
-
spinner.finish_and_clear();
|
|
87
|
-
logger.log_message(LogLevel::Error, "Invalid session token.");
|
|
88
|
-
request
|
|
89
|
-
.respond(Response::from_string("Invalid session token."))
|
|
90
|
-
.unwrap();
|
|
91
|
-
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
println!("Invalid callback: {}", request.url());
|
|
96
|
-
|
|
97
|
-
spinner.finish_and_clear();
|
|
98
|
-
logger.log_message(LogLevel::Error, "Invalid callback.");
|
|
99
|
-
request
|
|
100
|
-
.respond(Response::from_string("Invalid callback."))
|
|
101
|
-
.unwrap();
|
|
102
|
-
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
} else if request.url().starts_with("/favicon.ico") {
|
|
106
|
-
// Ignore favicon requests
|
|
107
|
-
} else {
|
|
108
|
-
spinner.finish_and_clear();
|
|
109
|
-
logger.log_message(LogLevel::Error, "Invalid request.");
|
|
110
|
-
request
|
|
111
|
-
.respond(Response::from_string("Invalid request."))
|
|
112
|
-
.unwrap();
|
|
113
|
-
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
Ok(())
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/// Save the session token to a file in the user's home directory
|
|
122
|
-
fn save_token(token: &str) {
|
|
123
|
-
set_user_config_value("session", serde_json::Value::String(token.to_string()));
|
|
124
|
-
}
|
package/rust/cli/login/mod.rs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pub mod commands;
|