@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.
Files changed (329) hide show
  1. package/README.md +177 -146
  2. package/out-tsc/api.d.ts +180 -0
  3. package/out-tsc/api.d.ts.map +1 -0
  4. package/out-tsc/api.js +286 -0
  5. package/out-tsc/api.js.map +1 -0
  6. package/out-tsc/bin/index.d.ts +12 -0
  7. package/out-tsc/bin/index.d.ts.map +1 -0
  8. package/out-tsc/bin/index.js +20 -54
  9. package/out-tsc/bin/index.js.map +1 -0
  10. package/out-tsc/examples/basic-usage.d.ts +8 -0
  11. package/out-tsc/examples/basic-usage.d.ts.map +1 -0
  12. package/out-tsc/examples/basic-usage.js +113 -0
  13. package/out-tsc/examples/basic-usage.js.map +1 -0
  14. package/out-tsc/index.d.ts +19 -5
  15. package/out-tsc/index.d.ts.map +1 -0
  16. package/out-tsc/index.js +24 -6
  17. package/out-tsc/index.js.map +1 -0
  18. package/out-tsc/scripts/copy-wasm-dts.d.ts +7 -0
  19. package/out-tsc/scripts/copy-wasm-dts.d.ts.map +1 -0
  20. package/out-tsc/scripts/copy-wasm-dts.js +36 -32
  21. package/out-tsc/scripts/copy-wasm-dts.js.map +1 -0
  22. package/out-tsc/scripts/postinstall.d.ts +1 -0
  23. package/out-tsc/scripts/postinstall.d.ts.map +1 -0
  24. package/out-tsc/scripts/postinstall.js +4 -1
  25. package/out-tsc/scripts/postinstall.js.map +1 -0
  26. package/out-tsc/scripts/version/bump.d.ts +5 -1
  27. package/out-tsc/scripts/version/bump.d.ts.map +1 -0
  28. package/out-tsc/scripts/version/bump.js +114 -44
  29. package/out-tsc/scripts/version/bump.js.map +1 -0
  30. package/out-tsc/scripts/version/fetch.d.ts +12 -1
  31. package/out-tsc/scripts/version/fetch.d.ts.map +1 -0
  32. package/out-tsc/scripts/version/fetch.js +68 -24
  33. package/out-tsc/scripts/version/fetch.js.map +1 -0
  34. package/out-tsc/scripts/version/index.d.ts +6 -0
  35. package/out-tsc/scripts/version/index.d.ts.map +1 -0
  36. package/out-tsc/scripts/version/index.js +44 -22
  37. package/out-tsc/scripts/version/index.js.map +1 -0
  38. package/out-tsc/scripts/version/sync.d.ts +5 -1
  39. package/out-tsc/scripts/version/sync.d.ts.map +1 -0
  40. package/out-tsc/scripts/version/sync.js +78 -29
  41. package/out-tsc/scripts/version/sync.js.map +1 -0
  42. package/out-tsc/types.d.ts +68 -0
  43. package/out-tsc/types.d.ts.map +1 -0
  44. package/out-tsc/{core/types/value.js → types.js} +4 -0
  45. package/out-tsc/types.js.map +1 -0
  46. package/out-tsc/wasm.d.ts +8 -0
  47. package/out-tsc/wasm.d.ts.map +1 -0
  48. package/out-tsc/{core/index.js → wasm.js} +9 -6
  49. package/out-tsc/wasm.js.map +1 -0
  50. package/package.json +50 -37
  51. package/.cargo/config.toml +0 -2
  52. package/.devalang +0 -9
  53. package/.github/workflows/ci.yml +0 -103
  54. package/Cargo.toml +0 -81
  55. package/docs/CHANGELOG.md +0 -581
  56. package/docs/CONTRIBUTING.md +0 -101
  57. package/docs/ROADMAP.md +0 -38
  58. package/docs/TODO.md +0 -71
  59. package/examples/automation.deva +0 -42
  60. package/examples/bank.deva +0 -7
  61. package/examples/bus.deva +0 -10
  62. package/examples/condition.deva +0 -20
  63. package/examples/duration.deva +0 -9
  64. package/examples/effect.deva +0 -2
  65. package/examples/events.deva +0 -12
  66. package/examples/filter.deva +0 -11
  67. package/examples/function.deva +0 -15
  68. package/examples/group.deva +0 -12
  69. package/examples/index.deva +0 -63
  70. package/examples/lfo.deva +0 -9
  71. package/examples/loop.deva +0 -10
  72. package/examples/pattern.deva +0 -8
  73. package/examples/plugin.deva +0 -16
  74. package/examples/samples/hat-808.wav +0 -0
  75. package/examples/samples/kick-808.wav +0 -0
  76. package/examples/synth.deva +0 -24
  77. package/examples/synth_types.deva +0 -17
  78. package/examples/variables.deva +0 -9
  79. package/out-tsc/core/functions/index.d.ts +0 -42
  80. package/out-tsc/core/functions/index.js +0 -87
  81. package/out-tsc/core/index.d.ts +0 -6
  82. package/out-tsc/core/types/index.d.ts +0 -4
  83. package/out-tsc/core/types/index.js +0 -20
  84. package/out-tsc/core/types/plugin.d.ts +0 -18
  85. package/out-tsc/core/types/plugin.js +0 -2
  86. package/out-tsc/core/types/result.d.ts +0 -27
  87. package/out-tsc/core/types/result.js +0 -2
  88. package/out-tsc/core/types/statement.d.ts +0 -106
  89. package/out-tsc/core/types/statement.js +0 -2
  90. package/out-tsc/core/types/value.d.ts +0 -43
  91. package/out-tsc/pkg/devalang_core.d.ts +0 -15
  92. package/out-tsc/pkg/devalang_core.js +0 -65
  93. package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +0 -34
  94. package/project-version.json +0 -6
  95. package/rust/cli/bank/api.rs +0 -122
  96. package/rust/cli/bank/commands.rs +0 -306
  97. package/rust/cli/bank/mod.rs +0 -29
  98. package/rust/cli/build/commands.rs +0 -153
  99. package/rust/cli/build/mod.rs +0 -2
  100. package/rust/cli/build/process.rs +0 -165
  101. package/rust/cli/check/mod.rs +0 -208
  102. package/rust/cli/discover/commands.rs +0 -253
  103. package/rust/cli/discover/config.rs +0 -111
  104. package/rust/cli/discover/fs.rs +0 -19
  105. package/rust/cli/discover/install.rs +0 -103
  106. package/rust/cli/discover/metadata.rs +0 -48
  107. package/rust/cli/discover/mod.rs +0 -5
  108. package/rust/cli/init/commands.rs +0 -88
  109. package/rust/cli/init/mod.rs +0 -1
  110. package/rust/cli/install/addon.rs +0 -118
  111. package/rust/cli/install/bank.rs +0 -72
  112. package/rust/cli/install/commands.rs +0 -35
  113. package/rust/cli/install/mod.rs +0 -4
  114. package/rust/cli/install/plugin.rs +0 -80
  115. package/rust/cli/login/commands.rs +0 -124
  116. package/rust/cli/login/mod.rs +0 -1
  117. package/rust/cli/mod.rs +0 -12
  118. package/rust/cli/parser.rs +0 -359
  119. package/rust/cli/play/commands.rs +0 -375
  120. package/rust/cli/play/io.rs +0 -17
  121. package/rust/cli/play/mod.rs +0 -5
  122. package/rust/cli/play/process.rs +0 -159
  123. package/rust/cli/play/realtime.rs +0 -91
  124. package/rust/cli/play/utils.rs +0 -23
  125. package/rust/cli/telemetry/commands.rs +0 -22
  126. package/rust/cli/telemetry/event_creator.rs +0 -80
  127. package/rust/cli/telemetry/mod.rs +0 -3
  128. package/rust/cli/telemetry/send.rs +0 -51
  129. package/rust/cli/template/commands.rs +0 -69
  130. package/rust/cli/template/mod.rs +0 -1
  131. package/rust/cli/update/commands.rs +0 -6
  132. package/rust/cli/update/mod.rs +0 -1
  133. package/rust/config/driver.rs +0 -112
  134. package/rust/config/mod.rs +0 -3
  135. package/rust/config/ops.rs +0 -26
  136. package/rust/config/settings.rs +0 -101
  137. package/rust/core/audio/engine/driver.rs +0 -220
  138. package/rust/core/audio/engine/export.rs +0 -169
  139. package/rust/core/audio/engine/helpers.rs +0 -178
  140. package/rust/core/audio/engine/mod.rs +0 -56
  141. package/rust/core/audio/engine/notes/dsp.rs +0 -85
  142. package/rust/core/audio/engine/notes/mod.rs +0 -44
  143. package/rust/core/audio/engine/notes/params.rs +0 -294
  144. package/rust/core/audio/engine/sample/insert.rs +0 -199
  145. package/rust/core/audio/engine/sample/mod.rs +0 -40
  146. package/rust/core/audio/engine/sample/padding.rs +0 -170
  147. package/rust/core/audio/evaluator/condition.rs +0 -61
  148. package/rust/core/audio/evaluator/mod.rs +0 -9
  149. package/rust/core/audio/evaluator/numeric.rs +0 -152
  150. package/rust/core/audio/evaluator/rhs.rs +0 -16
  151. package/rust/core/audio/evaluator/string_expr.rs +0 -94
  152. package/rust/core/audio/interpreter/driver.rs +0 -574
  153. package/rust/core/audio/interpreter/mod.rs +0 -2
  154. package/rust/core/audio/interpreter/statements/arrow_call/interprete.rs +0 -175
  155. package/rust/core/audio/interpreter/statements/arrow_call/methods/chord.rs +0 -384
  156. package/rust/core/audio/interpreter/statements/arrow_call/methods/mod.rs +0 -2
  157. package/rust/core/audio/interpreter/statements/arrow_call/methods/note.rs +0 -316
  158. package/rust/core/audio/interpreter/statements/arrow_call/mod.rs +0 -3
  159. package/rust/core/audio/interpreter/statements/arrow_call/types/arp.rs +0 -192
  160. package/rust/core/audio/interpreter/statements/arrow_call/types/mod.rs +0 -24
  161. package/rust/core/audio/interpreter/statements/arrow_call/types/pad.rs +0 -116
  162. package/rust/core/audio/interpreter/statements/arrow_call/types/pluck.rs +0 -97
  163. package/rust/core/audio/interpreter/statements/arrow_call/types/sub.rs +0 -100
  164. package/rust/core/audio/interpreter/statements/automate.rs +0 -16
  165. package/rust/core/audio/interpreter/statements/call.rs +0 -295
  166. package/rust/core/audio/interpreter/statements/condition.rs +0 -72
  167. package/rust/core/audio/interpreter/statements/function.rs +0 -24
  168. package/rust/core/audio/interpreter/statements/let_.rs +0 -36
  169. package/rust/core/audio/interpreter/statements/load.rs +0 -17
  170. package/rust/core/audio/interpreter/statements/loop_.rs +0 -115
  171. package/rust/core/audio/interpreter/statements/mod.rs +0 -12
  172. package/rust/core/audio/interpreter/statements/sleep.rs +0 -28
  173. package/rust/core/audio/interpreter/statements/spawn.rs +0 -253
  174. package/rust/core/audio/interpreter/statements/tempo.rs +0 -40
  175. package/rust/core/audio/interpreter/statements/trigger.rs +0 -239
  176. package/rust/core/audio/loader/mod.rs +0 -1
  177. package/rust/core/audio/loader/trigger.rs +0 -98
  178. package/rust/core/audio/mod.rs +0 -6
  179. package/rust/core/audio/player.rs +0 -70
  180. package/rust/core/audio/special/easing.rs +0 -189
  181. package/rust/core/audio/special/env.rs +0 -45
  182. package/rust/core/audio/special/math.rs +0 -134
  183. package/rust/core/audio/special/mod.rs +0 -9
  184. package/rust/core/audio/special/modulator.rs +0 -143
  185. package/rust/core/builder/mod.rs +0 -129
  186. package/rust/core/debugger/lexer.rs +0 -27
  187. package/rust/core/debugger/logs.rs +0 -52
  188. package/rust/core/debugger/mod.rs +0 -30
  189. package/rust/core/debugger/preprocessor.rs +0 -27
  190. package/rust/core/debugger/store.rs +0 -38
  191. package/rust/core/error/mod.rs +0 -269
  192. package/rust/core/lexer/driver.rs +0 -59
  193. package/rust/core/lexer/handler/arrow.rs +0 -82
  194. package/rust/core/lexer/handler/at.rs +0 -21
  195. package/rust/core/lexer/handler/brace.rs +0 -41
  196. package/rust/core/lexer/handler/colon.rs +0 -21
  197. package/rust/core/lexer/handler/comment.rs +0 -30
  198. package/rust/core/lexer/handler/dot.rs +0 -21
  199. package/rust/core/lexer/handler/driver.rs +0 -337
  200. package/rust/core/lexer/handler/identifier.rs +0 -47
  201. package/rust/core/lexer/handler/indent.rs +0 -66
  202. package/rust/core/lexer/handler/mod.rs +0 -15
  203. package/rust/core/lexer/handler/newline.rs +0 -23
  204. package/rust/core/lexer/handler/number.rs +0 -31
  205. package/rust/core/lexer/handler/operator.rs +0 -46
  206. package/rust/core/lexer/handler/parenthesis.rs +0 -41
  207. package/rust/core/lexer/handler/slash.rs +0 -21
  208. package/rust/core/lexer/handler/string.rs +0 -63
  209. package/rust/core/lexer/mod.rs +0 -3
  210. package/rust/core/lexer/token.rs +0 -91
  211. package/rust/core/mod.rs +0 -9
  212. package/rust/core/parser/driver/block.rs +0 -111
  213. package/rust/core/parser/driver/cursor.rs +0 -82
  214. package/rust/core/parser/driver/driver_impl.rs +0 -139
  215. package/rust/core/parser/driver/mod.rs +0 -6
  216. package/rust/core/parser/driver/parse_array.rs +0 -120
  217. package/rust/core/parser/driver/parse_map.rs +0 -223
  218. package/rust/core/parser/driver/parser.rs +0 -160
  219. package/rust/core/parser/handler/arrow_call.rs +0 -277
  220. package/rust/core/parser/handler/at.rs +0 -279
  221. package/rust/core/parser/handler/bank.rs +0 -104
  222. package/rust/core/parser/handler/condition.rs +0 -83
  223. package/rust/core/parser/handler/dot.rs +0 -148
  224. package/rust/core/parser/handler/identifier/automate.rs +0 -254
  225. package/rust/core/parser/handler/identifier/call.rs +0 -91
  226. package/rust/core/parser/handler/identifier/emit.rs +0 -70
  227. package/rust/core/parser/handler/identifier/function.rs +0 -113
  228. package/rust/core/parser/handler/identifier/group.rs +0 -89
  229. package/rust/core/parser/handler/identifier/let_.rs +0 -173
  230. package/rust/core/parser/handler/identifier/mod.rs +0 -55
  231. package/rust/core/parser/handler/identifier/on.rs +0 -107
  232. package/rust/core/parser/handler/identifier/print.rs +0 -49
  233. package/rust/core/parser/handler/identifier/sleep.rs +0 -96
  234. package/rust/core/parser/handler/identifier/spawn.rs +0 -91
  235. package/rust/core/parser/handler/identifier/synth.rs +0 -135
  236. package/rust/core/parser/handler/loop_.rs +0 -194
  237. package/rust/core/parser/handler/mod.rs +0 -9
  238. package/rust/core/parser/handler/pattern.rs +0 -74
  239. package/rust/core/parser/handler/tempo.rs +0 -105
  240. package/rust/core/parser/mod.rs +0 -3
  241. package/rust/core/parser/statement.rs +0 -10
  242. package/rust/core/plugin/loader.rs +0 -137
  243. package/rust/core/plugin/mod.rs +0 -2
  244. package/rust/core/plugin/runner/mod.rs +0 -11
  245. package/rust/core/plugin/runner/non_wasm.rs +0 -297
  246. package/rust/core/plugin/runner/wasm32.rs +0 -43
  247. package/rust/core/preprocessor/loader/inject.rs +0 -278
  248. package/rust/core/preprocessor/loader/loader_helpers.rs +0 -110
  249. package/rust/core/preprocessor/loader/mod.rs +0 -235
  250. package/rust/core/preprocessor/mod.rs +0 -4
  251. package/rust/core/preprocessor/module.rs +0 -55
  252. package/rust/core/preprocessor/processor/handlers.rs +0 -107
  253. package/rust/core/preprocessor/processor/mod.rs +0 -1
  254. package/rust/core/preprocessor/resolver/bank.rs +0 -49
  255. package/rust/core/preprocessor/resolver/call.rs +0 -124
  256. package/rust/core/preprocessor/resolver/condition.rs +0 -95
  257. package/rust/core/preprocessor/resolver/driver.rs +0 -324
  258. package/rust/core/preprocessor/resolver/function.rs +0 -69
  259. package/rust/core/preprocessor/resolver/group.rs +0 -122
  260. package/rust/core/preprocessor/resolver/let_.rs +0 -32
  261. package/rust/core/preprocessor/resolver/loop_.rs +0 -318
  262. package/rust/core/preprocessor/resolver/mod.rs +0 -16
  263. package/rust/core/preprocessor/resolver/pattern.rs +0 -83
  264. package/rust/core/preprocessor/resolver/spawn.rs +0 -99
  265. package/rust/core/preprocessor/resolver/synth.rs +0 -54
  266. package/rust/core/preprocessor/resolver/tempo.rs +0 -48
  267. package/rust/core/preprocessor/resolver/trigger.rs +0 -116
  268. package/rust/core/preprocessor/resolver/value.rs +0 -176
  269. package/rust/core/store/global.rs +0 -57
  270. package/rust/core/store/mod.rs +0 -1
  271. package/rust/lib.rs +0 -323
  272. package/rust/main.rs +0 -388
  273. package/rust/types/Cargo.toml +0 -11
  274. package/rust/types/src/addons.rs +0 -55
  275. package/rust/types/src/ast.rs +0 -202
  276. package/rust/types/src/config.rs +0 -84
  277. package/rust/types/src/lib.rs +0 -15
  278. package/rust/types/src/plugin.rs +0 -20
  279. package/rust/types/src/store.rs +0 -139
  280. package/rust/types/src/telemetry.rs +0 -85
  281. package/rust/utils/Cargo.toml +0 -26
  282. package/rust/utils/src/error.rs +0 -186
  283. package/rust/utils/src/file.rs +0 -94
  284. package/rust/utils/src/first_usage.rs +0 -97
  285. package/rust/utils/src/lib.rs +0 -9
  286. package/rust/utils/src/logger.rs +0 -200
  287. package/rust/utils/src/path.rs +0 -129
  288. package/rust/utils/src/signature.rs +0 -41
  289. package/rust/utils/src/spinner.rs +0 -20
  290. package/rust/utils/src/version.rs +0 -27
  291. package/rust/utils/src/watcher.rs +0 -46
  292. package/rust/web/api.rs +0 -5
  293. package/rust/web/cdn.rs +0 -34
  294. package/rust/web/mod.rs +0 -3
  295. package/rust/web/sso.rs +0 -5
  296. package/templates/minimal/.devalang +0 -5
  297. package/templates/minimal/README.md +0 -218
  298. package/templates/minimal/src/index.deva +0 -2
  299. package/templates/welcome/.devalang +0 -5
  300. package/templates/welcome/README.md +0 -218
  301. package/templates/welcome/samples/kick-808.wav +0 -0
  302. package/templates/welcome/src/index.deva +0 -61
  303. package/templates/welcome/src/variables.deva +0 -3
  304. package/tests/integration.rs +0 -21
  305. package/tests/rust/cli_check_build.rs +0 -21
  306. package/tests/rust/cli_help.rs +0 -12
  307. package/tests/rust/cli_template_list.rs +0 -10
  308. package/tests/rust/cli_version.rs +0 -11
  309. package/tests/typescript/index.spec.ts +0 -136
  310. package/tests/typescript/playhead.spec.ts +0 -36
  311. package/tests/typescript/render_e2e.spec.ts +0 -77
  312. package/tsconfig.json +0 -115
  313. package/typescript/bin/index.ts +0 -28
  314. package/typescript/core/functions/index.ts +0 -94
  315. package/typescript/core/index.ts +0 -6
  316. package/typescript/core/types/index.ts +0 -4
  317. package/typescript/core/types/plugin.ts +0 -19
  318. package/typescript/core/types/result.ts +0 -29
  319. package/typescript/core/types/statement.ts +0 -47
  320. package/typescript/core/types/value.ts +0 -29
  321. package/typescript/index.ts +0 -8
  322. package/typescript/pkg/devalang_core.d.ts +0 -4
  323. package/typescript/pkg/devalang_core.ts +0 -65
  324. package/typescript/scripts/copy-wasm-dts.ts +0 -41
  325. package/typescript/scripts/postinstall.ts +0 -85
  326. package/typescript/scripts/version/bump.ts +0 -44
  327. package/typescript/scripts/version/fetch.ts +0 -18
  328. package/typescript/scripts/version/index.ts +0 -25
  329. 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
- }
@@ -1,5 +0,0 @@
1
- pub mod commands;
2
- pub mod config;
3
- pub mod fs;
4
- pub mod install;
5
- pub mod metadata;
@@ -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(&current_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
- }
@@ -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
- }
@@ -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
- }
@@ -1,4 +0,0 @@
1
- pub mod addon;
2
- pub mod bank;
3
- pub mod commands;
4
- pub mod plugin;
@@ -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
- }
@@ -1 +0,0 @@
1
- pub mod commands;
package/rust/cli/mod.rs DELETED
@@ -1,12 +0,0 @@
1
- pub mod bank;
2
- pub mod build;
3
- pub mod check;
4
- pub mod discover;
5
- pub mod init;
6
- pub mod install;
7
- pub mod login;
8
- pub mod parser;
9
- pub mod play;
10
- pub mod telemetry;
11
- pub mod template;
12
- pub mod update;