create-domis 1.0.32 → 1.0.34

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 CHANGED
@@ -1,2 +1 @@
1
-
2
- export { }
1
+ #!/usr/bin/env node
package/dist/index.js CHANGED
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
+ #!/usr/bin/env node
2
3
 
3
4
  // src/index.ts
4
5
  import inquirer from "inquirer";
5
6
  import chalk from "chalk";
6
7
  import ora from "ora";
7
- import { execSync } from "child_process";
8
8
  import fs from "fs";
9
9
  import path from "path";
10
10
  import os from "os";
11
+ import extract from "extract-zip";
11
12
  var API_VERIFY = "https://verifyprokey-rk2ogbbeja-uc.a.run.app";
12
- console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.31\n"));
13
+ console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.34\n"));
13
14
  function copyRecursive(src, dest) {
14
15
  const stat = fs.lstatSync(src);
15
16
  if (stat.isDirectory()) {
@@ -22,30 +23,64 @@ function copyRecursive(src, dest) {
22
23
  fs.copyFileSync(src, dest);
23
24
  }
24
25
  }
26
+ async function createFreePack(target) {
27
+ const spinner = ora("Criando DomisDocs Free...").start();
28
+ try {
29
+ fs.mkdirSync(target, { recursive: true });
30
+ fs.writeFileSync(path.join(target, "firebase.json"), JSON.stringify({
31
+ hosting: { public: "dist", ignore: ["firebase.json", "**/.*", "**/node_modules/**"], rewrites: [{ source: "**", destination: "/index.html" }] }
32
+ }, null, 2));
33
+ fs.writeFileSync(path.join(target, ".firebaserc"), JSON.stringify({ projects: { default: "free" } }, null, 2), { encoding: "utf8", flag: "w" });
34
+ fs.writeFileSync(path.join(target, "package.json"), JSON.stringify({
35
+ name: "domisdocs-free",
36
+ version: "1.0.0",
37
+ private: true,
38
+ description: "DomisDocs Free",
39
+ scripts: { dev: "echo - compre o Lite", build: "echo nada" }
40
+ }, null, 2));
41
+ fs.writeFileSync(path.join(target, "README.md"), "DomisDocs Free\n- firebase.json\n- .firebaserc\n- package.json\n- README.md\n\nPra app completo: use Lite.");
42
+ const gravados = fs.readdirSync(target);
43
+ spinner.succeed(`\u2705 ${target} Free criado! (${gravados.length} arquivos: ${gravados.join(", ")})`);
44
+ } catch (e) {
45
+ spinner.fail(`\u274C ${e.message}`);
46
+ process.exit(1);
47
+ }
48
+ }
25
49
  async function main() {
26
50
  const answers = await inquirer.prompt([
27
- { type: "list", name: "pack", message: "Qual pack voc\xEA quer acelerar hoje?", choices: [
28
- { name: "\u{1F525} DomisDocs Free - demo", value: "demo" },
29
- { name: "\u{1F525} DomisDocs Lite \u2014 Next.js 15 + Tailwind v4 + Firebase", value: "lite" },
30
- { name: "\u{1F525} DomisDocs PRO \u2014 Next.js 15 + Stripe + Rules + SSR", value: "pro" }
31
- ] },
32
- { type: "password", name: "proKey", message: "Digite sua PRO_KEY:", mask: "*", when: (a) => a.pack !== "demo", validate: (v) => v.startsWith("DOMIS-") ? true : "Formato: DOMIS-XXXX-XXXX-XXXX" },
33
- { type: "input", name: "projectName", message: "Nome do projeto:", default: "meu-app", validate: (v) => v.trim().length > 0 ? true : "Digite um nome" }
51
+ {
52
+ type: "list",
53
+ name: "pack",
54
+ message: "Qual pack voc\xEA quer acelerar hoje?",
55
+ choices: [
56
+ { name: "\u{1F525} DomisDocs Free - Configura\xE7\xE3o b\xE1sica Firebase", value: "free" },
57
+ { name: "\u{1F525} DomisDocs Lite \u2014 Next.js 15 + Tailwind v4 + Firebase", value: "lite" },
58
+ { name: "\u{1F525} DomisDocs PRO \u2014 Next.js 15 + Stripe + Rules + SSR", value: "pro" }
59
+ ]
60
+ },
61
+ {
62
+ type: "password",
63
+ name: "proKey",
64
+ message: "Digite sua PRO_KEY:",
65
+ mask: "*",
66
+ when: (a) => a.pack !== "demo",
67
+ validate: (v) => v.startsWith("DOMIS-") ? true : "Formato: DOMIS-XXXX-XXXX-XXXX"
68
+ },
69
+ {
70
+ type: "input",
71
+ name: "projectName",
72
+ message: "Nome do projeto:",
73
+ default: "meu-app",
74
+ validate: (v) => v.trim().length > 0 ? true : "Digite um nome"
75
+ }
34
76
  ]);
35
77
  const target = answers.projectName.trim();
36
78
  if (fs.existsSync(target)) {
37
- console.log(chalk.red(`\u274C Pasta "${target}" J\xC1 EXISTE!`));
79
+ console.log(chalk.red(`\u274C A pasta "${target}" j\xE1 existe!`));
38
80
  process.exit(1);
39
81
  }
40
82
  if (answers.pack === "demo") {
41
- const spinner2 = ora("Criando Free...").start();
42
- try {
43
- fs.mkdirSync(target, { recursive: true });
44
- fs.writeFileSync(path.join(target, "firebase.json"), JSON.stringify({ hosting: { public: "dist", rewrites: [{ source: "**", destination: "/index.html" }] } }, null, 2));
45
- spinner2.succeed(chalk.green(`\u2705 ${target} Free criado!`));
46
- } catch (e) {
47
- spinner2.fail(chalk.red(e.message));
48
- }
83
+ await createFreePack(target);
49
84
  return;
50
85
  }
51
86
  const spinner = ora("Verificando PRO_KEY...").start();
@@ -54,41 +89,40 @@ async function main() {
54
89
  const res = await fetch(url);
55
90
  const data = await res.json();
56
91
  if (!data.valid) {
57
- spinner.fail(chalk.red(`\u274C ${data.reason || "KEY inv\xE1lida"}`));
92
+ spinner.fail(chalk.red(`\u274C ${data.reason || "PRO_KEY inv\xE1lida"}`));
93
+ console.log(chalk.yellow(
94
+ "\nVerifique sua chave em: https://domispacks.web.app/validar.html"
95
+ ));
58
96
  process.exit(1);
59
97
  }
60
98
  if (!data.downloadUrl) {
61
- spinner.fail(chalk.red("\u274C API sem downloadUrl"));
99
+ spinner.fail(chalk.red("\u274C A API n\xE3o retornou downloadUrl"));
62
100
  process.exit(1);
63
101
  }
64
- spinner.text = `Baixando ${answers.pack.toUpperCase()} (2.5MB) do cofre privado...`;
65
- const localPath = `C:\\Users\\dell\\Documents\\GitHub\\DomisDoc-Legacy-Thecnical\\templates\\domisdocs-${answers.pack}`;
66
- if (fs.existsSync(localPath)) {
67
- fs.mkdirSync(target, { recursive: true });
68
- copyRecursive(localPath, target);
69
- spinner.succeed(chalk.green.bold(`
70
- \u2705 ${target} criado! (local)`));
71
- return;
72
- }
102
+ spinner.text = `Baixando DomisDocs ${answers.pack.toUpperCase()}...`;
73
103
  const zipTmp = path.join(os.tmpdir(), `domis-${Date.now()}.zip`);
74
104
  const extractTmp = path.join(os.tmpdir(), `domis-extract-${Date.now()}`);
75
- execSync(`curl -L -o "${zipTmp}" "${data.downloadUrl}"`, { stdio: "inherit" });
105
+ const zipRes = await fetch(data.downloadUrl);
106
+ if (!zipRes.ok) {
107
+ throw new Error(`Falha ao baixar o template (${zipRes.status})`);
108
+ }
109
+ const buffer = Buffer.from(await zipRes.arrayBuffer());
110
+ fs.writeFileSync(zipTmp, buffer);
76
111
  fs.mkdirSync(extractTmp, { recursive: true });
77
- execSync(`powershell -Command "Expand-Archive -Path '${zipTmp}' -DestinationPath '${extractTmp}' -Force"`, { stdio: "inherit" });
78
- const subfolders = fs.readdirSync(extractTmp).filter((f) => fs.lstatSync(path.join(extractTmp, f)).isDirectory());
79
- const repoRoot = subfolders.length === 1 ? path.join(extractTmp, subfolders[0]) : extractTmp;
80
- const packSource = path.join(repoRoot, "templates", `domisdocs-${answers.pack}`);
81
- if (!fs.existsSync(packSource)) throw new Error(`templates/domisdocs-${answers.pack} n\xE3o encontrado. Tem: ${fs.readdirSync(path.join(repoRoot, "templates")).join(", ")}`);
112
+ await extract(zipTmp, { dir: extractTmp });
113
+ const files = fs.readdirSync(extractTmp);
114
+ const sourceDir = files.length === 1 && fs.lstatSync(path.join(extractTmp, files[0])).isDirectory() ? path.join(extractTmp, files[0]) : extractTmp;
82
115
  fs.mkdirSync(target, { recursive: true });
83
- copyRecursive(packSource, target);
116
+ copyRecursive(sourceDir, target);
84
117
  fs.rmSync(zipTmp, { force: true });
85
118
  fs.rmSync(extractTmp, { recursive: true, force: true });
86
119
  spinner.succeed(chalk.green.bold(`
87
- \u2705 ${target} criado com SUCESSO!`));
120
+ \u2705 ${target} criado com sucesso!`));
88
121
  console.log(chalk.cyan(`
89
- \u{1F449} cd ${target}
90
- npm install
91
- npm run dev`));
122
+ \u{1F449} cd ${target}`));
123
+ console.log(chalk.cyan(`\u{1F449} npm install`));
124
+ console.log(chalk.cyan(`\u{1F449} npm run dev
125
+ `));
92
126
  } catch (e) {
93
127
  spinner.fail(chalk.red(`\u274C Erro: ${e.message}`));
94
128
  process.exit(1);
package/package.json CHANGED
@@ -1,40 +1,42 @@
1
- {
2
- "name": "create-domis",
3
- "version": "1.0.32",
4
- "description": "CLI Oficial DomisPacks - Acelerador Next.js 15 + Tailwind v4 + SaaS Boilerplate",
5
- "type": "module",
6
- "bin": {
7
- "create-domis": "./dist/index.js"
8
- },
9
- "files": [
10
- "dist"
11
- ],
12
- "scripts": {
13
- "build": "tsup src/index.ts --format esm --dts",
14
- "dev": "tsx src/index.ts",
15
- "prepublishOnly": "npm run build"
16
- },
17
- "keywords": [
18
- "firebase",
19
- "domis",
20
- "create-domis",
21
- "cli"
22
- ],
23
- "author": "Domisnnet",
24
- "license": "LICENSE",
25
- "dependencies": {
26
- "chalk": "^5.3.0",
27
- "inquirer": "^9.2.12",
28
- "ora": "^7.0.1"
29
- },
30
- "devDependencies": {
31
- "@types/inquirer": "^9.0.10",
32
- "@types/node": "^22.20.1",
33
- "tsup": "^8.5.1",
34
- "tsx": "^4.7.0",
35
- "typescript": "^5.9.3"
36
- },
37
- "engines": {
38
- "node": ">=18.0.0"
39
- }
40
- }
1
+ {
2
+ "name": "create-domis",
3
+ "version": "1.0.34",
4
+ "description": "CLI Oficial DomisPacks - Acelerador Next.js 15 + Tailwind v4 + SaaS Boilerplate",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-domis": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsup src/index.ts --format esm --dts",
14
+ "dev": "tsx src/index.ts",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "keywords": [
18
+ "firebase",
19
+ "domis",
20
+ "create-domis",
21
+ "cli"
22
+ ],
23
+ "author": "Domisnnet",
24
+ "license": "LICENSE",
25
+ "dependencies": {
26
+ "chalk": "^5.3.0",
27
+ "extract-zip": "^2.0.1",
28
+ "inquirer": "^9.2.12",
29
+ "ora": "^7.0.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/extract-zip": "^2.0.0",
33
+ "@types/inquirer": "^9.0.10",
34
+ "@types/node": "^22.20.1",
35
+ "tsup": "^8.5.1",
36
+ "tsx": "^4.7.0",
37
+ "typescript": "^5.9.3"
38
+ },
39
+ "engines": {
40
+ "node": ">=18.0.0"
41
+ }
42
+ }