aiteam-x 0.11.0 → 0.11.2
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/package.json +1 -1
- package/scripts/cli.mjs +46 -5
package/package.json
CHANGED
package/scripts/cli.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import readline from "readline";
|
|
|
17
17
|
import { fileURLToPath } from "url";
|
|
18
18
|
|
|
19
19
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
20
|
-
const REPO = "INOSX/AITeam";
|
|
20
|
+
const REPO = "INOSX/AITeam#main";
|
|
21
21
|
|
|
22
22
|
const C = {
|
|
23
23
|
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
@@ -92,6 +92,28 @@ function copyMerge(src, dest, forceOverwrite = false) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
function fixDegitCache() {
|
|
96
|
+
if (process.platform === "win32") return;
|
|
97
|
+
const degitDir = path.join(os.homedir(), ".degit");
|
|
98
|
+
if (!fs.existsSync(degitDir)) return;
|
|
99
|
+
try {
|
|
100
|
+
fs.accessSync(degitDir, fs.constants.W_OK);
|
|
101
|
+
const testFile = path.join(degitDir, ".aiteam-write-test");
|
|
102
|
+
fs.writeFileSync(testFile, "");
|
|
103
|
+
fs.unlinkSync(testFile);
|
|
104
|
+
} catch {
|
|
105
|
+
console.log(C.yellow(" ⚠ Cache do degit (~/.degit) sem permissão de escrita."));
|
|
106
|
+
console.log(C.dim(" Provavelmente criado por uma execução anterior com sudo."));
|
|
107
|
+
console.log(C.dim(" Removendo cache para permitir o download...\n"));
|
|
108
|
+
try {
|
|
109
|
+
execSync(`rm -rf "${degitDir}"`, { stdio: "ignore" });
|
|
110
|
+
} catch {
|
|
111
|
+
console.log(C.yellow(" Não foi possível remover ~/.degit automaticamente."));
|
|
112
|
+
console.log(C.yellow(" Execute manualmente: sudo rm -rf ~/.degit\n"));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
95
117
|
function checkNotRoot() {
|
|
96
118
|
if (process.platform === "win32") return;
|
|
97
119
|
if (process.getuid?.() !== 0) return;
|
|
@@ -106,15 +128,15 @@ function checkNotRoot() {
|
|
|
106
128
|
process.exit(1);
|
|
107
129
|
}
|
|
108
130
|
|
|
109
|
-
|
|
110
|
-
checkNotRoot();
|
|
131
|
+
checkNotRoot();
|
|
111
132
|
|
|
133
|
+
async function main() {
|
|
112
134
|
const targetDir = process.argv[2] || ".";
|
|
113
135
|
const cwd = process.cwd();
|
|
114
136
|
const absTarget = path.resolve(cwd, targetDir);
|
|
115
137
|
|
|
116
138
|
console.log("\n" + C.bold(C.cyan("╔══════════════════════════════════════╗")));
|
|
117
|
-
console.log(C.bold(C.cyan("║ AITEAM-X — Instalação v0.11.
|
|
139
|
+
console.log(C.bold(C.cyan("║ AITEAM-X — Instalação v0.11.2 ║")));
|
|
118
140
|
console.log(C.bold(C.cyan("╚══════════════════════════════════════╝")) + "\n");
|
|
119
141
|
|
|
120
142
|
const empty = isDirEmpty(absTarget);
|
|
@@ -142,7 +164,26 @@ async function main() {
|
|
|
142
164
|
|
|
143
165
|
try {
|
|
144
166
|
console.log(C.bold("1. Baixando template AITEAM-X..."));
|
|
145
|
-
|
|
167
|
+
fixDegitCache();
|
|
168
|
+
let downloaded = false;
|
|
169
|
+
try {
|
|
170
|
+
execSync(`npx degit@latest ${REPO} "${tmpDir}" --force`, { stdio: "inherit", cwd });
|
|
171
|
+
downloaded = true;
|
|
172
|
+
} catch (degitErr) {
|
|
173
|
+
console.log(C.yellow("\n degit falhou, tentando download direto...\n"));
|
|
174
|
+
}
|
|
175
|
+
if (!downloaded) {
|
|
176
|
+
try {
|
|
177
|
+
execSync(
|
|
178
|
+
`curl -sL "https://github.com/INOSX/AITeam/archive/main.tar.gz" | tar -xz --strip-components=1 -C "${tmpDir}"`,
|
|
179
|
+
{ stdio: "inherit" },
|
|
180
|
+
);
|
|
181
|
+
} catch {
|
|
182
|
+
console.error(C.yellow("\n Download direto também falhou."));
|
|
183
|
+
console.error(C.yellow(" Verifique sua conexão e tente novamente.\n"));
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
146
187
|
console.log(C.green(" ✓ Template baixado\n"));
|
|
147
188
|
|
|
148
189
|
if (!empty) {
|