create-domis 1.0.40 → 1.0.42
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/dist/index.d.ts +1 -2
- package/dist/index.js +43 -72
- package/package.json +3 -3
- package/bin/create-domis +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { }
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
|
|
1
4
|
// src/index.ts
|
|
2
5
|
import inquirer from "inquirer";
|
|
3
6
|
import chalk from "chalk";
|
|
@@ -5,81 +8,53 @@ import ora from "ora";
|
|
|
5
8
|
import fs from "fs";
|
|
6
9
|
import path from "path";
|
|
7
10
|
import os from "os";
|
|
11
|
+
import { fileURLToPath } from "url";
|
|
8
12
|
import extract from "extract-zip";
|
|
13
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
var __dirname = path.dirname(__filename);
|
|
9
15
|
var API_VERIFY = "https://verifyprokey-rk2ogbbeja-uc.a.run.app";
|
|
10
16
|
var TIMEOUT_MS = 3e4;
|
|
11
17
|
var MAX_RETRIES = 2;
|
|
12
|
-
console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.
|
|
18
|
+
console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.42\n"));
|
|
13
19
|
function copyRecursive(src, dest) {
|
|
14
20
|
const stat = fs.lstatSync(src);
|
|
15
21
|
if (stat.isDirectory()) {
|
|
16
22
|
fs.mkdirSync(dest, { recursive: true });
|
|
17
23
|
for (const file of fs.readdirSync(src)) {
|
|
18
|
-
if (["node_modules", ".next", ".git", ".firebase"].includes(file)) continue;
|
|
24
|
+
if (["node_modules", ".next", ".git", ".firebase", ".DS_Store"].includes(file)) continue;
|
|
19
25
|
copyRecursive(path.join(src, file), path.join(dest, file));
|
|
20
26
|
}
|
|
21
27
|
} else {
|
|
22
28
|
fs.copyFileSync(src, dest);
|
|
23
29
|
}
|
|
24
30
|
}
|
|
31
|
+
function findFreeTemplate() {
|
|
32
|
+
const possiblePaths = [
|
|
33
|
+
path.join(__dirname, "..", "templates", "domisdocs-free"),
|
|
34
|
+
path.join(__dirname, "..", "..", "templates", "domisdocs-free"),
|
|
35
|
+
path.join(__dirname, "templates", "domisdocs-free"),
|
|
36
|
+
path.join(process.cwd(), "templates", "domisdocs-free")
|
|
37
|
+
];
|
|
38
|
+
for (const p of possiblePaths) {
|
|
39
|
+
if (fs.existsSync(p)) return p;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Template Free n\xE3o encontrado. Verifique se a pasta templates/domisdocs-free existe. Caminhos testados: ${possiblePaths.join(", ")}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
25
45
|
async function createFreePack(target) {
|
|
26
46
|
const spinner = ora("Criando DomisDocs Free...").start();
|
|
27
47
|
try {
|
|
48
|
+
const freeSrc = findFreeTemplate();
|
|
49
|
+
spinner.text = `Copiando de ${path.relative(process.cwd(), freeSrc)}...`;
|
|
28
50
|
fs.mkdirSync(target, { recursive: true });
|
|
29
|
-
|
|
30
|
-
path.join(target, "firebase.json"),
|
|
31
|
-
JSON.stringify(
|
|
32
|
-
{
|
|
33
|
-
hosting: {
|
|
34
|
-
public: "out",
|
|
35
|
-
ignore: ["firebase.json", "**/.*", "**/node_modules/**"],
|
|
36
|
-
rewrites: [{ source: "**", destination: "/index.html" }],
|
|
37
|
-
headers: [
|
|
38
|
-
{
|
|
39
|
-
source: "**/*.@(js|css|woff2|png|jpg|jpeg|gif|svg|webp|ico)",
|
|
40
|
-
headers: [
|
|
41
|
-
{ key: "Cache-Control", value: "public, max-age=31536000, immutable" }
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
source: "**",
|
|
46
|
-
headers: [
|
|
47
|
-
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
48
|
-
{ key: "X-Frame-Options", value: "DENY" },
|
|
49
|
-
{ key: "X-XSS-Protection", value: "1; mode=block" }
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
null,
|
|
56
|
-
2
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
|
-
fs.writeFileSync(
|
|
60
|
-
path.join(target, ".firebaserc"),
|
|
61
|
-
JSON.stringify({ projects: { default: "free" } }, null, 2)
|
|
62
|
-
);
|
|
63
|
-
fs.writeFileSync(
|
|
64
|
-
path.join(target, "package.json"),
|
|
65
|
-
JSON.stringify(
|
|
66
|
-
{
|
|
67
|
-
name: "domisdocs-free",
|
|
68
|
-
version: "1.0.0",
|
|
69
|
-
private: true,
|
|
70
|
-
description: "DomisDocs Free",
|
|
71
|
-
scripts: { dev: "echo - compre o Lite", build: "echo nada" }
|
|
72
|
-
},
|
|
73
|
-
null,
|
|
74
|
-
2
|
|
75
|
-
)
|
|
76
|
-
);
|
|
77
|
-
fs.writeFileSync(
|
|
78
|
-
path.join(target, "README.md"),
|
|
79
|
-
"DomisDocs Free\n- firebase.json\n- .firebaserc\n- package.json\n- README.md\n\nPra app completo: use Lite."
|
|
80
|
-
);
|
|
51
|
+
copyRecursive(freeSrc, target);
|
|
81
52
|
const gravados = fs.readdirSync(target);
|
|
82
53
|
spinner.succeed(`\u2705 ${target} Free criado! (${gravados.length} arquivos: ${gravados.join(", ")})`);
|
|
54
|
+
console.log(chalk.cyan(`
|
|
55
|
+
\u{1F449} cd ${target}`));
|
|
56
|
+
console.log(chalk.cyan(`\u{1F449} firebase deploy
|
|
57
|
+
`));
|
|
83
58
|
} catch (e) {
|
|
84
59
|
spinner.fail(`\u274C ${e.message}`);
|
|
85
60
|
process.exit(1);
|
|
@@ -89,11 +64,7 @@ async function fetchWithTimeout(url, options, timeout = TIMEOUT_MS) {
|
|
|
89
64
|
const controller = new AbortController();
|
|
90
65
|
const id = setTimeout(() => controller.abort(), timeout);
|
|
91
66
|
try {
|
|
92
|
-
|
|
93
|
-
...options,
|
|
94
|
-
signal: controller.signal
|
|
95
|
-
});
|
|
96
|
-
return res;
|
|
67
|
+
return await fetch(url, { ...options, signal: controller.signal });
|
|
97
68
|
} finally {
|
|
98
69
|
clearTimeout(id);
|
|
99
70
|
}
|
|
@@ -104,23 +75,26 @@ async function verifyAndDownload(proKey, pack) {
|
|
|
104
75
|
try {
|
|
105
76
|
const res = await fetchWithTimeout(API_VERIFY, {
|
|
106
77
|
method: "POST",
|
|
107
|
-
headers: {
|
|
108
|
-
"Content-Type": "application/json"
|
|
109
|
-
},
|
|
78
|
+
headers: { "Content-Type": "application/json" },
|
|
110
79
|
body: JSON.stringify({ key: proKey, pack })
|
|
111
80
|
});
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
81
|
+
const text = await res.text();
|
|
82
|
+
let data;
|
|
83
|
+
try {
|
|
84
|
+
data = JSON.parse(text);
|
|
85
|
+
} catch {
|
|
86
|
+
throw new Error(`Resposta inv\xE1lida da API (${res.status}): ${text.slice(0, 200)}`);
|
|
87
|
+
}
|
|
88
|
+
if (!res.ok || !data.valid) {
|
|
89
|
+
throw new Error(data.detail || data.reason || data.error || `HTTP ${res.status}`);
|
|
116
90
|
}
|
|
117
91
|
if (!data.downloadUrl) {
|
|
118
|
-
throw new Error("
|
|
92
|
+
throw new Error("API n\xE3o retornou downloadUrl - verifique se o zip foi enviado para o Storage");
|
|
119
93
|
}
|
|
120
94
|
return data.downloadUrl;
|
|
121
95
|
} catch (err) {
|
|
122
96
|
lastError = err;
|
|
123
|
-
if (
|
|
97
|
+
if (["not_found", "expired", "inactive", "upgrade_required", "template_not_found"].includes(err.message)) {
|
|
124
98
|
throw err;
|
|
125
99
|
}
|
|
126
100
|
if (attempt <= MAX_RETRIES) {
|
|
@@ -176,7 +150,7 @@ async function main() {
|
|
|
176
150
|
const extractTmp = path.join(os.tmpdir(), `domis-extract-${Date.now()}`);
|
|
177
151
|
const zipRes = await fetchWithTimeout(downloadUrl, {});
|
|
178
152
|
if (!zipRes.ok) {
|
|
179
|
-
throw new Error(`Falha ao baixar
|
|
153
|
+
throw new Error(`Falha ao baixar template (${zipRes.status})`);
|
|
180
154
|
}
|
|
181
155
|
const buffer = Buffer.from(await zipRes.arrayBuffer());
|
|
182
156
|
fs.writeFileSync(zipTmp, buffer);
|
|
@@ -197,9 +171,6 @@ async function main() {
|
|
|
197
171
|
`));
|
|
198
172
|
} catch (e) {
|
|
199
173
|
spinner.fail(chalk.red(`\u274C ${e.message}`));
|
|
200
|
-
if (e.message === "not_found" || e.message === "expired" || e.message === "inactive" || e.message === "upgrade_required") {
|
|
201
|
-
console.log(chalk.yellow("\nVerifique sua chave em: https://domispacks.web.app/validar.html"));
|
|
202
|
-
}
|
|
203
174
|
process.exit(1);
|
|
204
175
|
}
|
|
205
176
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-domis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "CLI Oficial DomisPacks - Acelerador Next.js 15 + Tailwind v4 + SaaS Boilerplate",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"bin": { "create-domis": "./
|
|
7
|
-
"files": [ "dist"
|
|
6
|
+
"bin": { "create-domis": "./dist/index.js" },
|
|
7
|
+
"files": [ "dist" ],
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsup src/index.ts --format esm --dts",
|
|
10
10
|
"dev": "tsx src/index.ts",
|
package/bin/create-domis
DELETED