create-domis 1.0.41 → 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 +30 -116
- 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";
|
|
@@ -12,7 +15,7 @@ var __dirname = path.dirname(__filename);
|
|
|
12
15
|
var API_VERIFY = "https://verifyprokey-rk2ogbbeja-uc.a.run.app";
|
|
13
16
|
var TIMEOUT_MS = 3e4;
|
|
14
17
|
var MAX_RETRIES = 2;
|
|
15
|
-
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"));
|
|
16
19
|
function copyRecursive(src, dest) {
|
|
17
20
|
const stat = fs.lstatSync(src);
|
|
18
21
|
if (stat.isDirectory()) {
|
|
@@ -25,98 +28,33 @@ function copyRecursive(src, dest) {
|
|
|
25
28
|
fs.copyFileSync(src, dest);
|
|
26
29
|
}
|
|
27
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
|
+
}
|
|
28
45
|
async function createFreePack(target) {
|
|
29
46
|
const spinner = ora("Criando DomisDocs Free...").start();
|
|
30
47
|
try {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
path.join(__dirname, "templates", "domisdocs-free")
|
|
36
|
-
];
|
|
37
|
-
let freeSrc = null;
|
|
38
|
-
for (const p of possiblePaths) {
|
|
39
|
-
if (fs.existsSync(p)) {
|
|
40
|
-
freeSrc = p;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!freeSrc) {
|
|
45
|
-
spinner.text = "Template Free n\xE3o encontrado localmente, criando arquivos b\xE1sicos...";
|
|
46
|
-
fs.mkdirSync(target, { recursive: true });
|
|
47
|
-
fs.writeFileSync(
|
|
48
|
-
path.join(target, "firebase.json"),
|
|
49
|
-
JSON.stringify(
|
|
50
|
-
{
|
|
51
|
-
hosting: {
|
|
52
|
-
public: "out",
|
|
53
|
-
ignore: ["firebase.json", "**/.*", "**/node_modules/**"],
|
|
54
|
-
rewrites: [{ source: "**", destination: "/index.html" }],
|
|
55
|
-
headers: [
|
|
56
|
-
{
|
|
57
|
-
source: "**/*.@(js|css|woff2|png|jpg|jpeg|gif|svg|webp|ico)",
|
|
58
|
-
headers: [{ key: "Cache-Control", value: "public, max-age=31536000, immutable" }]
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
null,
|
|
64
|
-
2
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
fs.writeFileSync(path.join(target, ".firebaserc"), JSON.stringify({ projects: { default: "free" } }, null, 2));
|
|
68
|
-
fs.writeFileSync(path.join(target, "package.json"), JSON.stringify(
|
|
69
|
-
{
|
|
70
|
-
name: "domisdocs-free",
|
|
71
|
-
version: "1.0.0",
|
|
72
|
-
private: true,
|
|
73
|
-
description: "DomisDocs Free",
|
|
74
|
-
scripts: { dev: "echo DomisDocs Free - sem build", build: "echo nada" }
|
|
75
|
-
},
|
|
76
|
-
null,
|
|
77
|
-
2
|
|
78
|
-
));
|
|
79
|
-
fs.writeFileSync(
|
|
80
|
-
path.join(target, "README.md"),
|
|
81
|
-
`
|
|
82
|
-

|
|
83
|
-

|
|
84
|
-
|
|
85
|
-
## 1. \u{1F680} DomisDocs Free \u2014 Technical Preview
|
|
86
|
-
> Voc\xEA rodou \`npm create domis@latest\`.
|
|
87
|
-
|
|
88
|
-
Esta \xE9 a vers\xE3o p\xFAblica, gratuita e sem PRO_KEY. Cont\xE9m apenas 4 arquivos de degusta\xE7\xE3o.
|
|
89
|
-
|
|
90
|
-
## 2. \u{1F4E6} O que vem no Free?
|
|
91
|
-
\`\`\`
|
|
92
|
-
domisdocs-free/
|
|
93
|
-
\u251C\u2500\u2500 firebase.json \u2192 b\xE1sico
|
|
94
|
-
\u251C\u2500\u2500 .firebaserc \u2192 b\xE1sico
|
|
95
|
-
\u251C\u2500\u2500 package.json \u2192 b\xE1sico
|
|
96
|
-
\u2514\u2500\u2500 README.md \u2192 b\xE1sico
|
|
97
|
-
\`\`\`
|
|
98
|
-
|
|
99
|
-
\xC9 o suficiente para dar \`firebase deploy\` sem erro.
|
|
100
|
-
|
|
101
|
-
## 3. \u{1F511} Como destravar
|
|
102
|
-
Lite R$49 resolve 90% dos erros com Next.js 15: https://pay.kiwify.com.br/heAmetM
|
|
103
|
-
Pro R$197 \xE9 produ\xE7\xE3o completa.`
|
|
104
|
-
);
|
|
105
|
-
} else {
|
|
106
|
-
fs.mkdirSync(target, { recursive: true });
|
|
107
|
-
copyRecursive(freeSrc, target);
|
|
108
|
-
}
|
|
48
|
+
const freeSrc = findFreeTemplate();
|
|
49
|
+
spinner.text = `Copiando de ${path.relative(process.cwd(), freeSrc)}...`;
|
|
50
|
+
fs.mkdirSync(target, { recursive: true });
|
|
51
|
+
copyRecursive(freeSrc, target);
|
|
109
52
|
const gravados = fs.readdirSync(target);
|
|
110
|
-
spinner.succeed(
|
|
111
|
-
`\u2705 ${target} Free criado! (
|
|
112
|
-
${gravados.length} arquivos: ${gravados.join(", ")})`
|
|
113
|
-
);
|
|
53
|
+
spinner.succeed(`\u2705 ${target} Free criado! (${gravados.length} arquivos: ${gravados.join(", ")})`);
|
|
114
54
|
console.log(chalk.cyan(`
|
|
115
55
|
\u{1F449} cd ${target}`));
|
|
116
|
-
console.log(chalk.cyan(
|
|
117
|
-
|
|
118
|
-
`
|
|
119
|
-
));
|
|
56
|
+
console.log(chalk.cyan(`\u{1F449} firebase deploy
|
|
57
|
+
`));
|
|
120
58
|
} catch (e) {
|
|
121
59
|
spinner.fail(`\u274C ${e.message}`);
|
|
122
60
|
process.exit(1);
|
|
@@ -126,8 +64,7 @@ async function fetchWithTimeout(url, options, timeout = TIMEOUT_MS) {
|
|
|
126
64
|
const controller = new AbortController();
|
|
127
65
|
const id = setTimeout(() => controller.abort(), timeout);
|
|
128
66
|
try {
|
|
129
|
-
|
|
130
|
-
return res;
|
|
67
|
+
return await fetch(url, { ...options, signal: controller.signal });
|
|
131
68
|
} finally {
|
|
132
69
|
clearTimeout(id);
|
|
133
70
|
}
|
|
@@ -149,26 +86,15 @@ async function verifyAndDownload(proKey, pack) {
|
|
|
149
86
|
throw new Error(`Resposta inv\xE1lida da API (${res.status}): ${text.slice(0, 200)}`);
|
|
150
87
|
}
|
|
151
88
|
if (!res.ok || !data.valid) {
|
|
152
|
-
|
|
153
|
-
throw new Error(reason);
|
|
89
|
+
throw new Error(data.detail || data.reason || data.error || `HTTP ${res.status}`);
|
|
154
90
|
}
|
|
155
91
|
if (!data.downloadUrl) {
|
|
156
|
-
throw new Error(
|
|
157
|
-
"A API n\xE3o retornou downloadUrl - verifique se o zip foi enviado para o Storage"
|
|
158
|
-
);
|
|
92
|
+
throw new Error("API n\xE3o retornou downloadUrl - verifique se o zip foi enviado para o Storage");
|
|
159
93
|
}
|
|
160
94
|
return data.downloadUrl;
|
|
161
95
|
} catch (err) {
|
|
162
96
|
lastError = err;
|
|
163
|
-
if ([
|
|
164
|
-
"not_found",
|
|
165
|
-
"expired",
|
|
166
|
-
"inactive",
|
|
167
|
-
"upgrade_required",
|
|
168
|
-
"no key",
|
|
169
|
-
"invalid pack",
|
|
170
|
-
"template_not_found"
|
|
171
|
-
].includes(err.message)) {
|
|
97
|
+
if (["not_found", "expired", "inactive", "upgrade_required", "template_not_found"].includes(err.message)) {
|
|
172
98
|
throw err;
|
|
173
99
|
}
|
|
174
100
|
if (attempt <= MAX_RETRIES) {
|
|
@@ -224,9 +150,7 @@ async function main() {
|
|
|
224
150
|
const extractTmp = path.join(os.tmpdir(), `domis-extract-${Date.now()}`);
|
|
225
151
|
const zipRes = await fetchWithTimeout(downloadUrl, {});
|
|
226
152
|
if (!zipRes.ok) {
|
|
227
|
-
throw new Error(
|
|
228
|
-
`Falha ao baixar o template (${zipRes.status}) - URL: ${downloadUrl.slice(0, 80)}`
|
|
229
|
-
);
|
|
153
|
+
throw new Error(`Falha ao baixar template (${zipRes.status})`);
|
|
230
154
|
}
|
|
231
155
|
const buffer = Buffer.from(await zipRes.arrayBuffer());
|
|
232
156
|
fs.writeFileSync(zipTmp, buffer);
|
|
@@ -247,16 +171,6 @@ async function main() {
|
|
|
247
171
|
`));
|
|
248
172
|
} catch (e) {
|
|
249
173
|
spinner.fail(chalk.red(`\u274C ${e.message}`));
|
|
250
|
-
if (["not_found", "expired", "inactive", "upgrade_required", "template_not_found"].includes(e.message)) {
|
|
251
|
-
console.log(chalk.yellow("\nDicas:"));
|
|
252
|
-
if (e.message === "template_not_found") {
|
|
253
|
-
console.log(chalk.yellow("- Fa\xE7a upload: gsutil cp templates/domisdocs-lite.zip gs://SEU_BUCKET/templates/"));
|
|
254
|
-
}
|
|
255
|
-
if (e.message === "not_found") {
|
|
256
|
-
console.log(chalk.yellow("- PRO_KEY n\xE3o encontrada no Firestore pro_keys"));
|
|
257
|
-
}
|
|
258
|
-
console.log(chalk.yellow("- Ver logs: firebase functions:log --only verifyProKey"));
|
|
259
|
-
}
|
|
260
174
|
process.exit(1);
|
|
261
175
|
}
|
|
262
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