treste 2.4.3 → 2.4.5

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 CHANGED
@@ -1,9 +1,16 @@
1
1
  # Trest - Linguagem de Programação com Suporte a Cirílico
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/treste.svg)](https://www.npmjs.com/package/treste)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
6
+ [![Active Maintenance](https://img.shields.io/badge/maintenance-active-green.svg)](https://github.com/trest-language/trest)
7
+
3
8
  Linguagem de programação moderna e profissional, estruturalmente organizada e compilável para **Web** e **Desktop (.exe)** com suporte completo a cirílico (alfabeto russo).
4
9
 
5
10
  > **🎯 Característica Única:** Trest permite programar usando palavras-chave em cirílico ou latino, mantendo a mesma sintaxe e funcionalidades.
6
11
 
12
+ > **🔒 Segurança:** Versão 2.4.4 inclui correções de segurança da cadeia de suprimentos. Veja [SECURITY.md](./SECURITY.md) para detalhes.
13
+
7
14
  ## 🚀 Principais Funcionalidades
8
15
 
9
16
  - ✅ **Execução Inline** - Execute código direto na linha de comando com `-e`
@@ -461,6 +468,18 @@ Veja a pasta `exemplos/` para programas completos demonstrando:
461
468
  - `exemplos/filesystem_demo.trest` - Operações de arquivo
462
469
  - `exemplos/todas_funcionalidades.trest` - Exemplo completo
463
470
 
471
+ ## 🔒 Segurança
472
+
473
+ **Versão 2.4.4** inclui correções de segurança da cadeia de suprimentos:
474
+ - ✅ Scripts de instalação removidos
475
+ - ✅ Sem acesso ao shell durante instalação
476
+ - ✅ Acesso à rede controlado e documentado
477
+
478
+ **Documentação de Segurança:**
479
+ - **[SECURITY.md](./SECURITY.md)** - Política de segurança completa
480
+ - **[SOCKET_ALERTS.md](./SOCKET_ALERTS.md)** - Resposta aos alertas do Socket
481
+ - **[CHANGELOG_SECURITY.md](./CHANGELOG_SECURITY.md)** - Changelog de segurança
482
+
464
483
  ## 📚 Documentação Completa
465
484
 
466
485
  Para mais informações, consulte a documentação completa em `docs/`:
@@ -470,6 +489,7 @@ Para mais informações, consulte a documentação completa em `docs/`:
470
489
  - **[API.md](docs/api.md)** - Referência da API
471
490
  - **[ARCHITECTURE.md](docs/ARCHITECTURE.md)** - Arquitetura técnica
472
491
  - **[WHY_TREST.md](docs/WHY_TREST.md)** - Por que usar Trest
492
+ - **[DOCUMENTACAO_COMPLETA.md](./DOCUMENTACAO_COMPLETA.md)** - Documentação completa unificada
473
493
 
474
494
  Ou visite o site oficial: [https://trest-site.vercel.app](https://trest-site.vercel.app)
475
495
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "treste",
3
- "version": "2.4.3",
4
- "description": "Trest - Linguagem de programação moderna e profissional para Web e Desktop com suporte a Cirílico",
3
+ "version": "2.4.5",
4
+ "description": "Trest - Linguagem de programação moderna e profissional para Web e Desktop com suporte a Cirílico. Inclui módulo HTTP opcional para requisições de rede (acesso controlado pelo usuário, documentado em SECURITY.md).",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "bin": {
@@ -19,8 +19,6 @@
19
19
  "compile:exe": "ts-node src/compiler/exe.ts",
20
20
  "test": "ts-node src/tests/runner.ts",
21
21
  "bundle": "tsc && pkg dist/cli.js --targets node18-win-x64,node18-win-x86,node18-linux-x64,node18-macos-x64 --out-path dist/bin",
22
- "preinstall": "node scripts/preinstall.js",
23
- "postinstall": "node scripts/postinstall.js",
24
22
  "prepare": "npm run build",
25
23
  "prepublishOnly": "npm run build",
26
24
  "version": "node scripts/version.js && git add -A",
@@ -37,7 +35,11 @@
37
35
  "interpreter",
38
36
  "cyrillic",
39
37
  "russian",
40
- "trest"
38
+ "trest",
39
+ "http",
40
+ "network",
41
+ "active-maintenance",
42
+ "production-ready"
41
43
  ],
42
44
  "author": {
43
45
  "name": "PoktWeb",
@@ -57,7 +59,6 @@
57
59
  "files": [
58
60
  "dist/",
59
61
  "src/std/",
60
- "scripts/",
61
62
  "README.md",
62
63
  "LICENSE",
63
64
  "INSTALL.md"
@@ -70,6 +71,13 @@
70
71
  "url": "https://github.com/trest-language/trest/issues"
71
72
  },
72
73
  "homepage": "https://trest-site.vercel.app",
74
+ "funding": {
75
+ "type": "individual",
76
+ "url": "https://github.com/sponsors/poktweb"
77
+ },
78
+ "publishConfig": {
79
+ "access": "public"
80
+ },
73
81
  "os": [
74
82
  "darwin",
75
83
  "linux",
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Post-build script
4
- * Configurações após a compilação
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- console.log('\n🔨 Post-build configuration...\n');
11
-
12
- // Adicionar shebang aos binários
13
- function addShebang() {
14
- const bins = [
15
- path.join(__dirname, '..', 'dist', 'cli.js'),
16
- path.join(__dirname, '..', 'dist', 'compiler.js')
17
- ];
18
-
19
- bins.forEach(bin => {
20
- if (fs.existsSync(bin)) {
21
- let content = fs.readFileSync(bin, 'utf-8');
22
-
23
- // Adicionar shebang se não existir
24
- if (!content.startsWith('#!/usr/bin/env node')) {
25
- content = '#!/usr/bin/env node\n' + content;
26
- fs.writeFileSync(bin, content);
27
- }
28
-
29
- console.log(`✅ Configured ${path.basename(bin)}`);
30
- }
31
- });
32
- }
33
-
34
- // Verificar arquivos gerados
35
- function verifyBuild() {
36
- const requiredFiles = [
37
- 'dist/index.js',
38
- 'dist/cli.js',
39
- 'dist/compiler.js',
40
- 'dist/lexer.js',
41
- 'dist/parser.js',
42
- 'dist/interpreter.js'
43
- ];
44
-
45
- let allOk = true;
46
-
47
- requiredFiles.forEach(file => {
48
- const filePath = path.join(__dirname, '..', file);
49
- if (!fs.existsSync(filePath)) {
50
- console.error(`❌ Missing: ${file}`);
51
- allOk = false;
52
- }
53
- });
54
-
55
- if (allOk) {
56
- console.log('✅ All build artifacts present');
57
- }
58
- }
59
-
60
- // Copiar módulos std para dist se necessário
61
- function copyStdModules() {
62
- const srcStd = path.join(__dirname, '..', 'src', 'std');
63
- const distStd = path.join(__dirname, '..', 'dist', 'std');
64
-
65
- if (fs.existsSync(srcStd) && !fs.existsSync(distStd)) {
66
- fs.mkdirSync(distStd, { recursive: true });
67
-
68
- const files = fs.readdirSync(srcStd);
69
- files.forEach(file => {
70
- if (file.endsWith('.trest')) {
71
- const srcPath = path.join(srcStd, file);
72
- const distPath = path.join(distStd, file);
73
- fs.copyFileSync(srcPath, distPath);
74
- console.log(`✅ Copied ${file}`);
75
- }
76
- });
77
- }
78
- }
79
-
80
- // Executar configurações
81
- try {
82
- addShebang();
83
- verifyBuild();
84
- copyStdModules();
85
- console.log('\n✅ Post-build complete!\n');
86
- } catch (error) {
87
- console.error('❌ Post-build error:', error.message);
88
- process.exit(1);
89
- }
90
-
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Post-install script
4
- * Configura o ambiente após a instalação
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- const VERSION = require('../package.json').version;
11
-
12
- console.log(`\n🎉 Trest Language v${VERSION} installed successfully!\n`);
13
-
14
- // Criar arquivo de configuração se não existir
15
- function createConfigFile() {
16
- const configPath = path.join(process.cwd(), '.trestrc');
17
-
18
- if (!fs.existsSync(configPath)) {
19
- const config = {
20
- version: VERSION,
21
- compiler: {
22
- web: {
23
- minify: false,
24
- bundle: true
25
- },
26
- exe: {
27
- minify: false,
28
- standalone: true
29
- }
30
- },
31
- runtime: {
32
- strictMode: false,
33
- debugMode: false
34
- }
35
- };
36
-
37
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
38
- console.log('✅ Created .trestrc configuration file');
39
- }
40
- }
41
-
42
- // Verificar permissões dos binários
43
- function checkBinPermissions() {
44
- const distPath = path.join(process.cwd(), 'dist');
45
-
46
- if (fs.existsSync(distPath)) {
47
- console.log('✅ Build artifacts found');
48
- } else {
49
- console.log('⚠️ Build artifacts not found, run: npm run build');
50
- }
51
- }
52
-
53
- // Verificar módulos std
54
- function checkStdModules() {
55
- const stdPath = path.join(process.cwd(), 'src', 'std');
56
-
57
- if (fs.existsSync(stdPath)) {
58
- const modules = fs.readdirSync(stdPath).filter(f => f.endsWith('.trest'));
59
- console.log(`✅ Standard library: ${modules.length} modules found`);
60
- } else {
61
- console.error('❌ Standard library not found');
62
- }
63
- }
64
-
65
- // Mensagens de instrução
66
- function showInstructions() {
67
- console.log('\n📚 Getting started:\n');
68
- console.log(' Run a Trest file:');
69
- console.log(' npx trest yourfile.trest\n');
70
- console.log(' Compile for web:');
71
- console.log(' npx trestc yourfile.trest --mode web\n');
72
- console.log(' Compile to executable:');
73
- console.log(' npx trestc yourfile.trest --mode exe\n');
74
- console.log(' For more information:');
75
- console.log(' npx trest --help\n');
76
- console.log('📖 Documentation: https://github.com/trest-language/trest\n');
77
- }
78
-
79
- // Executar configurações
80
- try {
81
- createConfigFile();
82
- checkBinPermissions();
83
- checkStdModules();
84
- showInstructions();
85
- } catch (error) {
86
- console.error('⚠️ Post-install setup had some issues:', error.message);
87
- console.log('You can manually configure later.\n');
88
- }
89
-
@@ -1,92 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Pre-install script
4
- * Valida o ambiente antes da instalação
5
- */
6
-
7
- const { execSync } = require('child_process');
8
- const os = require('os');
9
- const fs = require('fs');
10
- const path = require('path');
11
-
12
- const VERSION = require('../package.json').version;
13
- const MIN_NODE_VERSION = 18;
14
- const MIN_NPM_VERSION = 9;
15
-
16
- console.log(`\n🚀 Trest Language v${VERSION} - Pre-installation check\n`);
17
-
18
- // Verificar Node.js
19
- function checkNodeVersion() {
20
- const nodeVersion = process.version;
21
- const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0]);
22
-
23
- if (majorVersion < MIN_NODE_VERSION) {
24
- console.error(`❌ Node.js ${MIN_NODE_VERSION}+ required. Current: ${nodeVersion}`);
25
- console.error('Please update Node.js from https://nodejs.org/');
26
- process.exit(1);
27
- }
28
-
29
- console.log(`✅ Node.js version: ${nodeVersion}`);
30
- }
31
-
32
- // Verificar npm
33
- function checkNpmVersion() {
34
- try {
35
- const npmVersion = execSync('npm --version', { encoding: 'utf-8' }).trim();
36
- const majorVersion = parseInt(npmVersion.split('.')[0]);
37
-
38
- if (majorVersion < MIN_NPM_VERSION) {
39
- console.error(`❌ npm ${MIN_NPM_VERSION}+ required. Current: ${npmVersion}`);
40
- console.error('Please update npm: npm install -g npm@latest');
41
- process.exit(1);
42
- }
43
-
44
- console.log(`✅ npm version: ${npmVersion}`);
45
- } catch (error) {
46
- console.error('❌ Failed to check npm version');
47
- process.exit(1);
48
- }
49
- }
50
-
51
- // Verificar sistema operacional
52
- function checkOS() {
53
- const platform = os.platform();
54
- const supported = ['darwin', 'linux', 'win32'];
55
-
56
- if (!supported.includes(platform)) {
57
- console.warn(`⚠️ Platform ${platform} may not be fully supported`);
58
- } else {
59
- console.log(`✅ Platform: ${platform}`);
60
- }
61
- }
62
-
63
- // Verificar TypeScript
64
- function checkTypeScript() {
65
- try {
66
- const tsVersion = execSync('tsc --version', { encoding: 'utf-8' }).trim();
67
- console.log(`✅ ${tsVersion}`);
68
- } catch (error) {
69
- console.warn('⚠️ TypeScript not found globally (will be installed locally)');
70
- }
71
- }
72
-
73
- // Verificar espaço em disco
74
- function checkDiskSpace() {
75
- try {
76
- const stats = fs.statSync(process.cwd());
77
- console.log(`✅ Sufficient disk space`);
78
- } catch (error) {
79
- console.warn('⚠️ Could not verify disk space');
80
- }
81
- }
82
-
83
- // Executar todas as verificações
84
- console.log('Checking environment...\n');
85
- checkNodeVersion();
86
- checkNpmVersion();
87
- checkOS();
88
- checkTypeScript();
89
- checkDiskSpace();
90
-
91
- console.log('\n✅ Pre-installation checks passed!\n');
92
-
package/scripts/update.js DELETED
@@ -1,132 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Update script for Trest Language
5
- * Checks latest version from NPM and updates if needed
6
- */
7
-
8
- const https = require('https');
9
- const { execSync } = require('child_process');
10
- const packageJson = require('../package.json');
11
-
12
- const CURRENT_VERSION = packageJson.version;
13
- const PACKAGE_NAME = packageJson.name;
14
- const NPM_REGISTRY = `https://registry.npmjs.org/${PACKAGE_NAME}`;
15
-
16
- console.log('╔═══════════════════════════════════════════════════════════════╗');
17
- console.log('║ 🔄 TREST LANGUAGE - CHECKING FOR UPDATES ║');
18
- console.log('╚═══════════════════════════════════════════════════════════════╝\n');
19
-
20
- console.log(`📦 Package: ${PACKAGE_NAME}`);
21
- console.log(`📌 Current version: ${CURRENT_VERSION}\n`);
22
-
23
- console.log('🔍 Checking NPM for latest version...\n');
24
-
25
- // Fetch latest version from NPM
26
- https.get(NPM_REGISTRY, (res) => {
27
- let data = '';
28
-
29
- res.on('data', (chunk) => {
30
- data += chunk;
31
- });
32
-
33
- res.on('end', () => {
34
- try {
35
- const packageInfo = JSON.parse(data);
36
- const latestVersion = packageInfo['dist-tags'].latest;
37
- const versions = packageInfo.versions || {};
38
-
39
- console.log(`✅ Latest version available: ${latestVersion}\n`);
40
-
41
- // Compare versions
42
- if (latestVersion === CURRENT_VERSION) {
43
- console.log('╔═══════════════════════════════════════════════════════════════╗');
44
- console.log('║ ✅ YOU ARE UP TO DATE! ║');
45
- console.log('╚═══════════════════════════════════════════════════════════════╝\n');
46
- console.log(`You are already running the latest version: ${CURRENT_VERSION}`);
47
- process.exit(0);
48
- }
49
-
50
- // Check if current version is newer (unlikely but possible)
51
- const versionCompare = compareVersions(latestVersion, CURRENT_VERSION);
52
- if (versionCompare < 0) {
53
- console.log('╔═══════════════════════════════════════════════════════════════╗');
54
- console.log('║ ℹ️ YOU HAVE A NEWER VERSION ║');
55
- console.log('╚═══════════════════════════════════════════════════════════════╝\n');
56
- console.log(`Current: ${CURRENT_VERSION} (newer than NPM: ${latestVersion})`);
57
- console.log('You are running a development or pre-release version.');
58
- process.exit(0);
59
- }
60
-
61
- // Update available!
62
- console.log('╔═══════════════════════════════════════════════════════════════╗');
63
- console.log('║ 🆕 UPDATE AVAILABLE! ║');
64
- console.log('╚═══════════════════════════════════════════════════════════════╝\n');
65
- console.log(`📌 Current: ${CURRENT_VERSION}`);
66
- console.log(`🚀 Latest: ${latestVersion}`);
67
- console.log('');
68
-
69
- // Show changelog if available
70
- if (versions[latestVersion] && versions[latestVersion].changelog) {
71
- console.log('📝 What\'s new in this version:');
72
- console.log(' ' + versions[latestVersion].changelog);
73
- console.log('');
74
- }
75
-
76
- console.log('🔄 Updating treste...\n');
77
-
78
- try {
79
- // Update globally if installed globally
80
- execSync('npm list -g --depth=0', { stdio: 'ignore' });
81
-
82
- console.log('📦 Installing latest version globally...');
83
- execSync(`npm install -g ${PACKAGE_NAME}@${latestVersion}`, {
84
- stdio: 'inherit',
85
- cwd: process.cwd()
86
- });
87
-
88
- console.log('\n╔═══════════════════════════════════════════════════════════════╗');
89
- console.log('║ ✅ UPDATE COMPLETE! ║');
90
- console.log('╚═══════════════════════════════════════════════════════════════╝\n');
91
- console.log(`🎉 Successfully updated to ${latestVersion}!`);
92
- console.log('\n🔧 Verifying installation...');
93
- execSync('trest --version', { stdio: 'inherit' });
94
-
95
- } catch (error) {
96
- console.log('\n⚠️ Could not update automatically.');
97
- console.log('\nPlease run manually:');
98
- console.log(` npm install -g ${PACKAGE_NAME}@${latestVersion}`);
99
- process.exit(1);
100
- }
101
-
102
- } catch (error) {
103
- console.error('❌ Error parsing NPM response:', error.message);
104
- process.exit(1);
105
- }
106
- });
107
- }).on('error', (error) => {
108
- console.error('❌ Error checking for updates:', error.message);
109
- console.log('\nCould not connect to NPM registry.');
110
- console.log('Please check your internet connection and try again.');
111
- process.exit(1);
112
- });
113
-
114
- /**
115
- * Compare two semantic versions
116
- * Returns: 1 if v1 > v2, -1 if v1 < v2, 0 if equal
117
- */
118
- function compareVersions(v1, v2) {
119
- const parts1 = v1.split('.').map(Number);
120
- const parts2 = v2.split('.').map(Number);
121
-
122
- for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
123
- const part1 = parts1[i] || 0;
124
- const part2 = parts2[i] || 0;
125
-
126
- if (part1 > part2) return 1;
127
- if (part1 < part2) return -1;
128
- }
129
-
130
- return 0;
131
- }
132
-
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Version bump script
4
- * Atualiza a versão em todos os lugares necessários
5
- */
6
-
7
- const fs = require('fs');
8
- const path = require('path');
9
- const { execSync } = require('child_process');
10
-
11
- function updateVersion() {
12
- const packageJsonPath = path.join(__dirname, '..', 'package.json');
13
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
14
- const newVersion = process.env.npm_config_version || packageJson.version;
15
-
16
- console.log(`\n📦 Updating version to ${newVersion}\n`);
17
-
18
- // Atualizar package.json
19
- packageJson.version = newVersion;
20
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
21
- console.log('✅ Updated package.json');
22
-
23
- // Atualizar README se necessário
24
- updateReadme(newVersion);
25
-
26
- // Criar tag git
27
- try {
28
- execSync(`git tag -a v${newVersion} -m "Release v${newVersion}"`, { stdio: 'inherit' });
29
- console.log(`✅ Created git tag v${newVersion}`);
30
- } catch (error) {
31
- console.warn('⚠️ Could not create git tag (may already exist)');
32
- }
33
-
34
- console.log(`\n✅ Version update complete!\n`);
35
- }
36
-
37
- function updateReadme(version) {
38
- const readmePath = path.join(__dirname, '..', 'README.md');
39
-
40
- if (fs.existsSync(readmePath)) {
41
- let content = fs.readFileSync(readmePath, 'utf-8');
42
-
43
- // Substituir referências de versão
44
- content = content.replace(/v\d+\.\d+\.\d+/g, `v${version}`);
45
-
46
- fs.writeFileSync(readmePath, content);
47
- console.log('✅ Updated README.md');
48
- }
49
- }
50
-
51
- updateVersion();
52
-