@devaloop/devalang 0.0.1-alpha.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 (72) hide show
  1. package/Cargo.toml +45 -0
  2. package/LICENSE +21 -0
  3. package/README.md +161 -0
  4. package/docs/COMMANDS.md +31 -0
  5. package/docs/ROADMAP.md +27 -0
  6. package/docs/SYNTAX.md +148 -0
  7. package/docs/TODO.md +66 -0
  8. package/examples/exported.deva +7 -0
  9. package/examples/index.deva +9 -0
  10. package/examples/samples/kick-808.wav +0 -0
  11. package/out-tsc/bin/devalang.exe +0 -0
  12. package/out-tsc/bin/index.js +13 -0
  13. package/out-tsc/index.js +2 -0
  14. package/out-tsc/scripts/postbuild.js +11 -0
  15. package/out-tsc/scripts/version/bump.js +52 -0
  16. package/out-tsc/scripts/version/fetch.js +34 -0
  17. package/out-tsc/scripts/version/index.js +32 -0
  18. package/out-tsc/scripts/version/sync.js +32 -0
  19. package/package.json +43 -0
  20. package/project-version.json +6 -0
  21. package/rust/audio/mod.rs +1 -0
  22. package/rust/cli/build.rs +51 -0
  23. package/rust/cli/check.rs +124 -0
  24. package/rust/cli/mod.rs +3 -0
  25. package/rust/cli/new.rs +1 -0
  26. package/rust/core/builder/mod.rs +37 -0
  27. package/rust/core/debugger/mod.rs +57 -0
  28. package/rust/core/lexer/mod.rs +333 -0
  29. package/rust/core/mod.rs +6 -0
  30. package/rust/core/parser/at.rs +142 -0
  31. package/rust/core/parser/bank.rs +42 -0
  32. package/rust/core/parser/dot.rs +107 -0
  33. package/rust/core/parser/identifer.rs +91 -0
  34. package/rust/core/parser/loop_.rs +62 -0
  35. package/rust/core/parser/mod.rs +201 -0
  36. package/rust/core/parser/tempo.rs +42 -0
  37. package/rust/core/parser/variable.rs +129 -0
  38. package/rust/core/preprocessor/dependencies.rs +54 -0
  39. package/rust/core/preprocessor/mod.rs +26 -0
  40. package/rust/core/preprocessor/module.rs +70 -0
  41. package/rust/core/preprocessor/resolver/at.rs +24 -0
  42. package/rust/core/preprocessor/resolver/bank.rs +59 -0
  43. package/rust/core/preprocessor/resolver/loop_.rs +82 -0
  44. package/rust/core/preprocessor/resolver/mod.rs +113 -0
  45. package/rust/core/preprocessor/resolver/tempo.rs +70 -0
  46. package/rust/core/preprocessor/resolver/trigger.rs +176 -0
  47. package/rust/core/types/cli.rs +160 -0
  48. package/rust/core/types/mod.rs +7 -0
  49. package/rust/core/types/module.rs +41 -0
  50. package/rust/core/types/parser.rs +73 -0
  51. package/rust/core/types/statement.rs +105 -0
  52. package/rust/core/types/store.rs +116 -0
  53. package/rust/core/types/token.rs +83 -0
  54. package/rust/core/types/variable.rs +32 -0
  55. package/rust/lib.rs +1 -0
  56. package/rust/main.rs +49 -0
  57. package/rust/runner/executer.rs +44 -0
  58. package/rust/runner/mod.rs +1 -0
  59. package/rust/utils/loader.rs +19 -0
  60. package/rust/utils/logger.rs +49 -0
  61. package/rust/utils/mod.rs +5 -0
  62. package/rust/utils/path.rs +46 -0
  63. package/rust/utils/signature.rs +17 -0
  64. package/rust/utils/version.rs +15 -0
  65. package/tsconfig.json +113 -0
  66. package/typescript/bin/index.ts +14 -0
  67. package/typescript/index.ts +1 -0
  68. package/typescript/scripts/postbuild.ts +8 -0
  69. package/typescript/scripts/version/bump.ts +45 -0
  70. package/typescript/scripts/version/fetch.ts +23 -0
  71. package/typescript/scripts/version/index.ts +26 -0
  72. package/typescript/scripts/version/sync.ts +24 -0
@@ -0,0 +1,83 @@
1
+ use std::collections::HashMap;
2
+
3
+ use serde::Serialize;
4
+
5
+ #[derive(Debug, Clone, PartialEq, Serialize)]
6
+ pub struct Token {
7
+ pub kind: TokenKind,
8
+ pub lexeme: String,
9
+ pub indent: usize,
10
+ pub line: usize,
11
+ pub column: usize,
12
+ }
13
+
14
+ impl Token {
15
+ pub fn is_error(&self) -> bool {
16
+ match &self.kind {
17
+ TokenKind::Error(_) => {
18
+ return true;
19
+ },
20
+ _ => {
21
+ return false;
22
+ },
23
+ };
24
+ }
25
+ }
26
+
27
+ #[derive(Debug, Clone, PartialEq, Serialize)]
28
+ pub enum TokenKind {
29
+ At,
30
+ Tempo,
31
+ Bank,
32
+ Loop,
33
+ Identifier,
34
+ Map,
35
+ Array,
36
+ Number,
37
+ String,
38
+ Boolean,
39
+ Colon,
40
+ Comma,
41
+ Equals,
42
+ DoubleEquals,
43
+ Dot,
44
+ LBrace,
45
+ RBrace,
46
+ DbQuote,
47
+ Quote,
48
+ LBracket,
49
+ RBracket,
50
+ Newline,
51
+ Indent,
52
+ Dedent,
53
+ Comment(String),
54
+ Unknown,
55
+ Error(String),
56
+ EOF,
57
+ }
58
+
59
+ #[derive(Debug, Clone, PartialEq, Serialize)]
60
+ pub enum TokenDuration {
61
+ Number(f32),
62
+ Identifier(String),
63
+ Infinite,
64
+ Auto,
65
+ Unknown,
66
+ }
67
+
68
+ #[derive(Debug, Clone, PartialEq, Serialize)]
69
+ pub struct TokenParam {
70
+ pub name: String,
71
+ pub value: TokenParamValue,
72
+ }
73
+
74
+ #[derive(Debug, Clone, PartialEq, Serialize)]
75
+ pub enum TokenParamValue {
76
+ Number(f32),
77
+ String(String),
78
+ Boolean(bool),
79
+ Identifier(String),
80
+ Map(HashMap<String, TokenParamValue>),
81
+ Array(Vec<TokenParamValue>),
82
+ Unknown,
83
+ }
@@ -0,0 +1,32 @@
1
+ use std::collections::HashMap;
2
+ use serde::Serialize;
3
+ use crate::core::types::token::{Token, TokenParamValue};
4
+
5
+ #[derive(Debug, Clone, Serialize)]
6
+ pub enum VariableValue {
7
+ Number(f32),
8
+ Array(Vec<Token>),
9
+ Map(HashMap<String, TokenParamValue>),
10
+ Text(String),
11
+ Boolean(bool),
12
+ Sample(String),
13
+ Unknown,
14
+ Null,
15
+ }
16
+ pub struct Variable {
17
+ pub value: VariableValue,
18
+ }
19
+
20
+ impl Variable {
21
+ pub fn from_number(value: f32) -> Self {
22
+ Variable {
23
+ value: VariableValue::Number(value),
24
+ }
25
+ }
26
+
27
+ pub fn from_token(value: Token) -> Self {
28
+ Variable {
29
+ value: VariableValue::Text(value.lexeme),
30
+ }
31
+ }
32
+ }
package/rust/lib.rs ADDED
@@ -0,0 +1 @@
1
+ // TODO WebAssembly support
package/rust/main.rs ADDED
@@ -0,0 +1,49 @@
1
+ pub mod core;
2
+ pub mod cli;
3
+ pub mod runner;
4
+ pub mod audio;
5
+ pub mod utils;
6
+
7
+ use std::{ io };
8
+ use clap::Parser;
9
+ use crate::{
10
+ cli::{ build::handle_build_command, check::handle_check_command },
11
+ core::types::cli::{ Cli, CliCommands },
12
+ };
13
+
14
+ fn main() -> io::Result<()> {
15
+ let cli = Cli::parse();
16
+
17
+ match cli.command {
18
+ // TODO - Implement the new command
19
+ // CliCommands::New { name, template } => {
20
+ // log_message("Command 'new project' is not implemented yet.", "WARNING");
21
+ // }
22
+
23
+ // TODO - Implement the template command
24
+ // CliCommands::Template { command } =>
25
+ // match command {
26
+ // CliTemplateCommand::List => {
27
+ // log_message("Command 'template list' is not implemented yet.", "WARNING");
28
+ // }
29
+ // CliTemplateCommand::Info { name } => {
30
+ // log_message("Command 'template info' is not implemented yet.", "WARNING");
31
+ // }
32
+ // }
33
+
34
+ CliCommands::Build { entry, output, watch, compilation_mode, debug, compress } => {
35
+ handle_build_command(entry, output);
36
+ }
37
+
38
+ CliCommands::Check { entry, output, watch, compilation_mode, debug } => {
39
+ handle_check_command(entry, output);
40
+ }
41
+
42
+ // TODO - Implement the play command
43
+ // CliCommands::Play {} => {
44
+ // log_message("Command 'play' is not implemented yet.", "WARNING");
45
+ // }
46
+ }
47
+
48
+ Ok(())
49
+ }
@@ -0,0 +1,44 @@
1
+ use crate::core::{
2
+ preprocessor::resolver::resolve_statement,
3
+ types::{
4
+ module::Module,
5
+ statement::{ StatementKind, StatementResolved, StatementResolvedValue },
6
+ },
7
+ };
8
+
9
+ /// Exécute tous les statements d'un module avec résolution des variables
10
+ pub fn execute_statements(module: &mut Module) -> Vec<StatementResolved> {
11
+ let mut resolved_statements: Vec<StatementResolved> = Vec::new();
12
+
13
+ if module.clone().statements.is_empty() {
14
+ return resolved_statements;
15
+ }
16
+
17
+ for stmt in module.clone().statements {
18
+ match &stmt.kind {
19
+ StatementKind::Tempo { .. } => {
20
+ let resolved = resolve_statement(&stmt, module);
21
+ resolved_statements.push(resolved);
22
+ }
23
+ StatementKind::Trigger { .. } => {
24
+ let resolved = resolve_statement(&stmt, module);
25
+ resolved_statements.push(resolved);
26
+ }
27
+ StatementKind::Bank { .. } => {
28
+ let resolved = resolve_statement(&stmt, module);
29
+ resolved_statements.push(resolved);
30
+ }
31
+ StatementKind::Loop { .. } => {
32
+ let resolved = resolve_statement(&stmt, module);
33
+ resolved_statements.push(resolved);
34
+ }
35
+ StatementKind::Load { .. } => {
36
+ let resolved = resolve_statement(&stmt, module);
37
+ resolved_statements.push(resolved);
38
+ }
39
+ _ => {}
40
+ }
41
+ }
42
+
43
+ resolved_statements
44
+ }
@@ -0,0 +1 @@
1
+ pub mod executer;
@@ -0,0 +1,19 @@
1
+ use indicatif::{ ProgressBar, ProgressStyle };
2
+ use std::{ time::Duration };
3
+
4
+ pub fn with_spinner<T, F>(start_msg: &str, f: F) -> T where F: FnOnce() -> T {
5
+ let spinner = ProgressBar::new_spinner();
6
+ spinner.set_style(
7
+ ProgressStyle::with_template("{spinner:.green} {msg}")
8
+ .unwrap()
9
+ .tick_strings(&["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"])
10
+ );
11
+ spinner.set_message(start_msg.to_string());
12
+ spinner.enable_steady_tick(Duration::from_millis(80));
13
+
14
+ let result = f();
15
+
16
+ spinner.finish_and_clear();
17
+
18
+ result
19
+ }
@@ -0,0 +1,49 @@
1
+ use crossterm::style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor};
2
+ use std::{ fmt::Write };
3
+
4
+ pub fn log_message(message: &str, status: &str) {
5
+ let formatted_status = format_status(status);
6
+ println!("🦊 {} {} {}", language_signature(), formatted_status, message);
7
+ }
8
+
9
+ fn language_signature() -> String {
10
+ let mut s = String::new();
11
+
12
+ write!(&mut s, "{}", SetForegroundColor(Color::Grey)).unwrap();
13
+ s.push('[');
14
+
15
+ write!(&mut s, "{}", SetForegroundColor(Color::Rgb { r: 29, g: 211, b: 176 })).unwrap();
16
+ write!(&mut s, "{}", SetAttribute(Attribute::Bold)).unwrap();
17
+ s.push_str("Devalang");
18
+ write!(&mut s, "{}", SetAttribute(Attribute::Reset)).unwrap();
19
+
20
+ write!(&mut s, "{}", SetForegroundColor(Color::Grey)).unwrap();
21
+ s.push(']');
22
+
23
+ write!(&mut s, "{}", ResetColor).unwrap();
24
+
25
+ s
26
+ }
27
+
28
+ fn format_status(status: &str) -> String {
29
+ let mut s = String::new();
30
+
31
+ let color = match status {
32
+ "SUCCESS" => Color::Rgb { r: 76, g: 175, b: 80 },
33
+ "ERROR" => Color::Rgb { r: 244, g: 67, b: 54 },
34
+ "INFO" => Color::Rgb { r: 33, g: 150, b: 243 },
35
+ "WARNING" => Color::Rgb { r: 255, g: 152, b: 0 },
36
+ _ => Color::Grey,
37
+ };
38
+
39
+ s.push('[');
40
+ write!(&mut s, "{}", SetForegroundColor(color)).unwrap();
41
+ write!(&mut s, "{}", SetAttribute(Attribute::Bold)).unwrap();
42
+ s.push_str(status);
43
+ write!(&mut s, "{}", SetAttribute(Attribute::Reset)).unwrap();
44
+ s.push(']');
45
+
46
+ write!(&mut s, "{}", ResetColor).unwrap();
47
+
48
+ s
49
+ }
@@ -0,0 +1,5 @@
1
+ pub mod version;
2
+ pub mod signature;
3
+ pub mod path;
4
+ pub mod loader;
5
+ pub mod logger;
@@ -0,0 +1,46 @@
1
+ use std::path::{ Component, Path };
2
+
3
+ pub fn find_entry_file(path: &str) -> Option<String> {
4
+ let path = Path::new(path);
5
+
6
+ // Check if the path is a file
7
+ if path.is_file() {
8
+ return Some(path.to_string_lossy().to_string());
9
+ }
10
+
11
+ // Check if the path is a directory
12
+ if path.is_dir() {
13
+ // Look for an index.deva file in the directory
14
+ let index_path = path.join("index.deva");
15
+ if index_path.is_file() {
16
+ return Some(index_path.to_string_lossy().to_string());
17
+ }
18
+ }
19
+
20
+ None
21
+ }
22
+
23
+ pub fn normalize_path(path: &str) -> String {
24
+ let mut components = Vec::new();
25
+
26
+ // Iterate through the components of the path
27
+ for comp in Path::new(path).components() {
28
+ match comp {
29
+ Component::CurDir => {
30
+ continue;
31
+ }
32
+ Component::Normal(c) => components.push(c),
33
+ Component::RootDir => components.clear(),
34
+ _ => {}
35
+ }
36
+ }
37
+
38
+ // Join the components into a normalized path
39
+ let normalized = components
40
+ .iter()
41
+ .map(|c| c.to_string_lossy())
42
+ .collect::<Vec<_>>()
43
+ .join("/");
44
+
45
+ format!("./{}", normalized)
46
+ }
@@ -0,0 +1,17 @@
1
+ pub fn get_signature(version: &str) -> String {
2
+ let signature =
3
+ format!(r#"
4
+ /|_/|
5
+ / ^ ^(_o 🦊 Devalang
6
+ / __.'
7
+ / \ A programming language for music and sound.
8
+ / _ \_ Part of Devaloop project.
9
+ (_) (_) '._
10
+ '.__ '. .-''-'. https://devaloop.com
11
+ ( '. ('.____.''
12
+ _) )'_, ) v{}
13
+ (__/ (__/
14
+ "#, version);
15
+
16
+ signature
17
+ }
@@ -0,0 +1,15 @@
1
+ use crate::utils::signature::get_signature;
2
+
3
+ pub fn get_version() -> &'static str {
4
+ let version: &str = env!("CARGO_PKG_VERSION");
5
+ version
6
+ }
7
+
8
+ pub fn get_version_with_signature() -> &'static str {
9
+ let version = get_version();
10
+ let signature = get_signature(version);
11
+
12
+ println!("{}", signature);
13
+
14
+ "(c) 2025 Devaloop. All rights reserved."
15
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,113 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "libReplacement": true, /* Enable lib replacement. */
18
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
19
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
+
28
+ /* Modules */
29
+ "module": "commonjs", /* Specify what module code is generated. */
30
+ "rootDir": "./typescript", /* Specify the root folder within your source files. */
31
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
32
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
40
+ // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
41
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
42
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
43
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
44
+ // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
45
+ // "resolveJsonModule": true, /* Enable importing .json files. */
46
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
47
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
48
+
49
+ /* JavaScript Support */
50
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
51
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
52
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
53
+
54
+ /* Emit */
55
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
56
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
57
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
58
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
59
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
60
+ // "noEmit": true, /* Disable emitting files from a compilation. */
61
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
62
+ "outDir": "./out-tsc", /* Specify an output folder for all emitted files. */
63
+ // "removeComments": true, /* Disable emitting comments. */
64
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
65
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
66
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
67
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
68
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
69
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
70
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
71
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
72
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
73
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
74
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
75
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
76
+
77
+ /* Interop Constraints */
78
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
79
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
80
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
81
+ // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
82
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
83
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
84
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
85
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
86
+
87
+ /* Type Checking */
88
+ "strict": true, /* Enable all strict type-checking options. */
89
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
90
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
91
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
92
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
93
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
94
+ // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
95
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
96
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
97
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
98
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
99
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
100
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
101
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
102
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
103
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
104
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
105
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
106
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
107
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
108
+
109
+ /* Completeness */
110
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
111
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
112
+ }
113
+ }
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from "child_process";
4
+ import path from "path";
5
+
6
+ const binaryPath = path.join(__dirname, "devalang.exe");
7
+
8
+ const subCommand = process.argv[2] || "help";
9
+
10
+ const args = process.argv.slice(2);
11
+ const child = spawn(binaryPath, args, { stdio: "inherit" });
12
+
13
+
14
+ child.on("exit", (code) => process.exit(code));
@@ -0,0 +1 @@
1
+ // This file is part of the Devalang project
@@ -0,0 +1,8 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ const source = path.join(__dirname, "..", "..", "target", "release", "devalang.exe");
5
+ const destination = path.join(__dirname, "..", "bin", "devalang.exe");
6
+
7
+ fs.copyFileSync(source, destination);
8
+ fs.chmodSync(destination, 0o755);
@@ -0,0 +1,45 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ export const bumpVersion = async (bumpType: string, projectVersionPath: string) => {
5
+ const versionData = JSON.parse(fs.readFileSync(projectVersionPath, "utf-8"));
6
+
7
+ const versionRegex = /^(\d+)\.(\d+)\.(\d+)(?:-([\w.]+))?$/;
8
+ const match = versionData.version.match(versionRegex);
9
+
10
+ if (!match) {
11
+ throw new Error("Invalid version format in project-version.json");
12
+ }
13
+
14
+ if (!bumpType) {
15
+ console.error("❌ Please specify a version type (major, minor, patch, pre)");
16
+ process.exit(1);
17
+ }
18
+
19
+ let [_, major, minor, patch, pre] = match;
20
+ let nextVersion = "";
21
+
22
+ switch (bumpType) {
23
+ case "major":
24
+ nextVersion = `${+major + 1}.0.0`;
25
+ break;
26
+ case "minor":
27
+ nextVersion = `${major}.${+minor + 1}.0`;
28
+ break;
29
+ case "patch":
30
+ nextVersion = `${major}.${minor}.${+patch + 1}`;
31
+ break;
32
+ case "pre":
33
+ const [preid, prenumber] = (pre || "alpha.0").split(".");
34
+ nextVersion = `${major}.${minor}.${patch}-${preid}.${+prenumber + 1}`;
35
+ break;
36
+ default:
37
+ console.error("❌ Version type non-recognized (major, minor, patch, pre)");
38
+ process.exit(1);
39
+ }
40
+
41
+ versionData.version = nextVersion;
42
+ fs.writeFileSync(projectVersionPath, JSON.stringify(versionData, null, 2));
43
+
44
+ return nextVersion;
45
+ }
@@ -0,0 +1,23 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { execSync } from "child_process";
4
+
5
+ export const fetchVersion = async (projectVersionPath: string) => {
6
+ // Lire le fichier
7
+ const data = JSON.parse(fs.readFileSync(projectVersionPath, "utf-8"));
8
+
9
+ // Incrémenter le numéro de build
10
+ data.build = (data.build || 0) + 1;
11
+
12
+ // Récupérer le dernier hash git
13
+ try {
14
+ const commit = execSync("git rev-parse HEAD").toString().trim();
15
+ data.lastCommit = commit;
16
+ } catch (err) {
17
+ console.warn("⚠️ Impossible de récupérer le hash git.");
18
+ }
19
+
20
+ // Écrire la mise à jour
21
+ fs.writeFileSync(projectVersionPath, JSON.stringify(data, null, 2));
22
+ }
23
+
@@ -0,0 +1,26 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+ import { bumpVersion } from "./bump";
5
+ import { syncVersion } from "./sync";
6
+ import { fetchVersion } from "./fetch";
7
+
8
+ const bumpType = process.argv[2] || "patch";
9
+
10
+ (async () => {
11
+ const projectVersionPath = path.join(__dirname, "../../../project-version.json");
12
+
13
+ try {
14
+ const newVersion = await bumpVersion(bumpType, projectVersionPath);
15
+
16
+ await fetchVersion(projectVersionPath);
17
+ await syncVersion(projectVersionPath);
18
+
19
+ console.log(`✅ Project version updated to : ${newVersion}`);
20
+ }
21
+ catch (error) {
22
+ console.error(`❌ Error updating project version: ${error}`);
23
+ process.exit(1);
24
+ }
25
+
26
+ })();
@@ -0,0 +1,24 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ export const syncVersion = async (projectVersionPath: string) => {
5
+ const version = fs.readFileSync(projectVersionPath, "utf-8").trim();
6
+ const versionString = JSON.parse(version).version;
7
+
8
+ // Package.json
9
+ const pkgPath = path.join(__dirname, "..", "..", "..", "package.json");
10
+ const pkgJson = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
11
+ pkgJson.version = versionString;
12
+
13
+ fs.writeFileSync(pkgPath, JSON.stringify(pkgJson, null, 2));
14
+
15
+ // Cargo.toml
16
+ const cargoPath = path.join(__dirname, "..", "..", "..", "Cargo.toml");
17
+ const cargoToml = fs.readFileSync(cargoPath, "utf-8");
18
+ const updatedCargo = cargoToml.replace(
19
+ /(version\s*=\s*")[^"]*(")/,
20
+ `$1${versionString}$2`
21
+ );
22
+
23
+ fs.writeFileSync(cargoPath, updatedCargo);
24
+ }