create-domis 1.0.39 → 1.0.41

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.
Files changed (2) hide show
  1. package/dist/index.js +120 -63
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -5,17 +5,20 @@ import ora from "ora";
5
5
  import fs from "fs";
6
6
  import path from "path";
7
7
  import os from "os";
8
+ import { fileURLToPath } from "url";
8
9
  import extract from "extract-zip";
10
+ var __filename = fileURLToPath(import.meta.url);
11
+ var __dirname = path.dirname(__filename);
9
12
  var API_VERIFY = "https://verifyprokey-rk2ogbbeja-uc.a.run.app";
10
13
  var TIMEOUT_MS = 3e4;
11
14
  var MAX_RETRIES = 2;
12
- console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.39\n"));
15
+ console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.41\n"));
13
16
  function copyRecursive(src, dest) {
14
17
  const stat = fs.lstatSync(src);
15
18
  if (stat.isDirectory()) {
16
19
  fs.mkdirSync(dest, { recursive: true });
17
20
  for (const file of fs.readdirSync(src)) {
18
- if (["node_modules", ".next", ".git", ".firebase"].includes(file)) continue;
21
+ if (["node_modules", ".next", ".git", ".firebase", ".DS_Store"].includes(file)) continue;
19
22
  copyRecursive(path.join(src, file), path.join(dest, file));
20
23
  }
21
24
  } else {
@@ -25,61 +28,95 @@ function copyRecursive(src, dest) {
25
28
  async function createFreePack(target) {
26
29
  const spinner = ora("Criando DomisDocs Free...").start();
27
30
  try {
28
- fs.mkdirSync(target, { recursive: true });
29
- fs.writeFileSync(
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(
31
+ const possiblePaths = [
32
+ path.join(__dirname, "..", "templates", "domisdocs-free"),
33
+ path.join(__dirname, "..", "..", "templates", "domisdocs-free"),
34
+ path.join(process.cwd(), "templates", "domisdocs-free"),
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(
66
69
  {
67
70
  name: "domisdocs-free",
68
71
  version: "1.0.0",
69
72
  private: true,
70
73
  description: "DomisDocs Free",
71
- scripts: { dev: "echo - compre o Lite", build: "echo nada" }
74
+ scripts: { dev: "echo DomisDocs Free - sem build", build: "echo nada" }
72
75
  },
73
76
  null,
74
77
  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
- );
78
+ ));
79
+ fs.writeFileSync(
80
+ path.join(target, "README.md"),
81
+ `![NPM Version](https://img.shields.io/npm/v/create-domis?style=for-the-badge&logo=npm&color=CB3837)
82
+ ![Next.js](https://img.shields.io/badge/Next.js-15-black?style=for-the-badge&logo=next.js& logoColor=white)
83
+ ![Tailwind](https://img.shields.io/badge/Tailwind-v4-38BDF8?style=for-the-badge&logo=tailwindcss& logoColor=white)
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
+ }
81
109
  const gravados = fs.readdirSync(target);
82
- spinner.succeed(`\u2705 ${target} Free criado! (${gravados.length} arquivos: ${gravados.join(", ")})`);
110
+ spinner.succeed(
111
+ `\u2705 ${target} Free criado! (
112
+ ${gravados.length} arquivos: ${gravados.join(", ")})`
113
+ );
114
+ console.log(chalk.cyan(`
115
+ \u{1F449} cd ${target}`));
116
+ console.log(chalk.cyan(
117
+ `\u{1F449} firebase deploy
118
+ `
119
+ ));
83
120
  } catch (e) {
84
121
  spinner.fail(`\u274C ${e.message}`);
85
122
  process.exit(1);
@@ -89,10 +126,7 @@ async function fetchWithTimeout(url, options, timeout = TIMEOUT_MS) {
89
126
  const controller = new AbortController();
90
127
  const id = setTimeout(() => controller.abort(), timeout);
91
128
  try {
92
- const res = await fetch(url, {
93
- ...options,
94
- signal: controller.signal
95
- });
129
+ const res = await fetch(url, { ...options, signal: controller.signal });
96
130
  return res;
97
131
  } finally {
98
132
  clearTimeout(id);
@@ -104,23 +138,37 @@ async function verifyAndDownload(proKey, pack) {
104
138
  try {
105
139
  const res = await fetchWithTimeout(API_VERIFY, {
106
140
  method: "POST",
107
- headers: {
108
- "Content-Type": "application/json"
109
- },
141
+ headers: { "Content-Type": "application/json" },
110
142
  body: JSON.stringify({ key: proKey, pack })
111
143
  });
112
- const data = await res.json();
113
- if (!data.valid) {
114
- const reason = data.reason || data.error || "PRO_KEY inv\xE1lida";
144
+ const text = await res.text();
145
+ let data;
146
+ try {
147
+ data = JSON.parse(text);
148
+ } catch {
149
+ throw new Error(`Resposta inv\xE1lida da API (${res.status}): ${text.slice(0, 200)}`);
150
+ }
151
+ if (!res.ok || !data.valid) {
152
+ const reason = data.detail || data.reason || data.error || `HTTP ${res.status}`;
115
153
  throw new Error(reason);
116
154
  }
117
155
  if (!data.downloadUrl) {
118
- throw new Error("A API n\xE3o retornou downloadUrl");
156
+ throw new Error(
157
+ "A API n\xE3o retornou downloadUrl - verifique se o zip foi enviado para o Storage"
158
+ );
119
159
  }
120
160
  return data.downloadUrl;
121
161
  } catch (err) {
122
162
  lastError = err;
123
- if (err.message === "not_found" || err.message === "expired" || err.message === "inactive" || err.message === "upgrade_required" || err.message === "no key" || err.message === "invalid pack") {
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)) {
124
172
  throw err;
125
173
  }
126
174
  if (attempt <= MAX_RETRIES) {
@@ -176,7 +224,9 @@ async function main() {
176
224
  const extractTmp = path.join(os.tmpdir(), `domis-extract-${Date.now()}`);
177
225
  const zipRes = await fetchWithTimeout(downloadUrl, {});
178
226
  if (!zipRes.ok) {
179
- throw new Error(`Falha ao baixar o template (${zipRes.status})`);
227
+ throw new Error(
228
+ `Falha ao baixar o template (${zipRes.status}) - URL: ${downloadUrl.slice(0, 80)}`
229
+ );
180
230
  }
181
231
  const buffer = Buffer.from(await zipRes.arrayBuffer());
182
232
  fs.writeFileSync(zipTmp, buffer);
@@ -197,8 +247,15 @@ async function main() {
197
247
  `));
198
248
  } catch (e) {
199
249
  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"));
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"));
202
259
  }
203
260
  process.exit(1);
204
261
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "create-domis",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "CLI Oficial DomisPacks - Acelerador Next.js 15 + Tailwind v4 + SaaS Boilerplate",
5
5
  "type": "module",
6
- "bin": { "create-domis": "./bin/create-domis.js" },
6
+ "bin": { "create-domis": "./bin/create-domis" },
7
7
  "files": [ "dist", "bin" ],
8
8
  "scripts": {
9
9
  "build": "tsup src/index.ts --format esm --dts",