-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgithub_registry_setup.py
More file actions
263 lines (206 loc) · 6.54 KB
/
github_registry_setup.py
File metadata and controls
263 lines (206 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
GitHub Registry Setup for NajaScript
Script para configurar a estrutura inicial do registry no GitHub
"""
import json
import os
from pathlib import Path
def create_registry_structure():
"""Criar estrutura de diretórios e arquivos para o GitHub registry"""
# Estrutura de diretórios
dirs_to_create = [
"registry",
"packages",
"docs",
"examples"
]
for dir_name in dirs_to_create:
Path(dir_name).mkdir(exist_ok=True)
print(f"✅ Criado diretório: {dir_name}/")
# Criar index.json do registry
registry_index = {
"name": "NajaScript Official Package Registry",
"description": "Registry oficial de pacotes para a linguagem NajaScript",
"version": "1.0.0",
"last_updated": "2025-01-03T00:00:00Z",
"packages": {
"exemplo-basico": {
"name": "exemplo-basico",
"description": "Pacote de exemplo básico para NajaScript",
"author": "NajaScript Team",
"license": "MIT",
"repository": "https://github.com/NajaScript/Naja",
"keywords": ["exemplo", "basico", "tutorial"],
"versions": ["1.0.0"],
"latest": "1.0.0"
}
},
"total_packages": 1,
"categories": {
"utilities": ["exemplo-basico"],
"games": [],
"web": [],
"math": [],
"ai": []
}
}
# Salvar index.json
registry_file = Path("registry/index.json")
with open(registry_file, 'w', encoding='utf-8') as f:
json.dump(registry_index, f, indent=2, ensure_ascii=False)
print(f"✅ Criado: {registry_file}")
# Criar estrutura do pacote exemplo
example_package_dir = Path("packages/exemplo-basico/1.0.0")
example_package_dir.mkdir(parents=True, exist_ok=True)
# index.naja do pacote exemplo
example_code = '''// Pacote Exemplo Básico
// Demonstra a estrutura básica de um pacote NajaScript
classe ExemploBasico {
funcao construtor() {
println("ExemploBasico carregado!");
}
funcao saudar(string nome) {
return "Olá " + nome + " do pacote ExemploBasico!";
}
funcao calcular(int a, int b) {
return a + b;
}
funcao info() {
dicionario info = {};
info.add("nome", "exemplo-basico");
info.add("versao", "1.0.0");
info.add("autor", "NajaScript Team");
return info;
}
}
// Exportar instância
var exemploBasico = ExemploBasico();
'''
example_main_file = example_package_dir / "index.naja"
with open(example_main_file, 'w', encoding='utf-8') as f:
f.write(example_code)
print(f"✅ Criado: {example_main_file}")
# package.json do pacote exemplo
example_package_json = {
"name": "exemplo-basico",
"version": "1.0.0",
"description": "Pacote de exemplo básico para NajaScript",
"main": "index.naja",
"keywords": ["exemplo", "basico", "tutorial"],
"author": "NajaScript Team",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/NajaScript/Naja"
},
"homepage": "https://najascript.github.io",
"dependencies": {},
"najascript": {
"min_version": "1.0.0"
}
}
example_json_file = example_package_dir / "package.json"
with open(example_json_file, 'w', encoding='utf-8') as f:
json.dump(example_package_json, f, indent=2, ensure_ascii=False)
print(f"✅ Criado: {example_json_file}")
# README do pacote exemplo
example_readme = '''# Exemplo Básico
Pacote de exemplo básico para demonstrar a estrutura de pacotes NajaScript.
## Instalação
```bash
naja_pkg install exemplo-basico
```
## Uso
```naja
import "exemplo-basico";
// Usar o pacote
string saudacao = exemploBasico.saudar("Mundo");
println(saudacao);
int resultado = exemploBasico.calcular(5, 3);
println("Resultado: " + resultado);
dicionario info = exemploBasico.info();
println("Pacote: " + info.obter("nome"));
```
## API
### Métodos
- `saudar(string nome)` - Retorna uma saudação personalizada
- `calcular(int a, int b)` - Soma dois números
- `info()` - Retorna informações do pacote
## Licença
MIT
'''
example_readme_file = example_package_dir / "README.md"
with open(example_readme_file, 'w', encoding='utf-8') as f:
f.write(example_readme)
print(f"✅ Criado: {example_readme_file}")
# Criar README principal
main_readme = '''# NajaScript Package Registry
Registry oficial de pacotes para a linguagem de programação NajaScript.
## Estrutura
- `registry/` - Índice de pacotes e metadados
- `packages/` - Código fonte dos pacotes
- `docs/` - Documentação
- `examples/` - Exemplos de uso
## Como Usar
### Instalar um Pacote
```bash
naja_pkg install nome-do-pacote
```
### Listar Pacotes
```bash
naja_pkg list
```
### Pesquisar Pacotes
```bash
naja_pkg search termo
```
## Estrutura de Pacotes
Cada pacote deve seguir esta estrutura:
```
packages/
└── nome-do-pacote/
└── versao/
├── index.naja # Código principal
├── package.json # Metadados
└── README.md # Documentação
```
## Contribuindo
1. Fork este repositório
2. Crie seu pacote seguindo a estrutura acima
3. Atualize o `registry/index.json`
4. Faça um Pull Request
## Pacotes Disponíveis
Veja `registry/index.json` para a lista completa de pacotes.
'''
main_readme_file = Path("README.md")
with open(main_readme_file, 'w', encoding='utf-8') as f:
f.write(main_readme)
print(f"✅ Criado: {main_readme_file}")
# Criar .gitignore
gitignore_content = '''# Cache
.naja_cache/
*.pyc
__pycache__/
# Logs
*.log
# Sistema
.DS_Store
Thumbs.db
'''
gitignore_file = Path(".gitignore")
with open(gitignore_file, 'w', encoding='utf-8') as f:
f.write(gitignore_content)
print(f"✅ Criado: {gitignore_file}")
print("\n🎉 Estrutura do registry criada com sucesso!")
print("\n📋 Próximos passos:")
print("1. Commit e push para o GitHub:")
print(" git add .")
print(" git commit -m 'Configuração inicial do registry'")
print(" git push origin main")
print("\n2. Testar o package manager:")
print(" python naja_pkg search exemplo")
print(" python naja_pkg install exemplo-basico")
if __name__ == "__main__":
create_registry_structure()