draftify-cli 1.0.6 → 1.0.10

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.js CHANGED
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  const commander_1 = require("commander");
8
+ const https_1 = __importDefault(require("https"));
5
9
  const login_1 = require("./commands/login");
6
10
  const refactor_1 = require("./commands/refactor");
7
11
  const repl_1 = require("./repl");
@@ -30,22 +34,57 @@ program.on('command:*', function () {
30
34
  ui_1.ui.error(`Invalid command: ${program.args.join(' ')}\nSee --help for a list of available commands.`);
31
35
  process.exit(1);
32
36
  });
33
- // Custom logic for when `draftify` is run without any arguments
34
- if (process.argv.slice(2).length === 0) {
35
- const token = (0, config_1.getToken)();
36
- if (!token) {
37
- // No token, run interactive login flow
38
- (0, login_1.loginCommand)().then((username) => (0, repl_1.startRepl)(username)).catch(() => process.exit(1));
37
+ async function checkVersion() {
38
+ return new Promise((resolve) => {
39
+ // Set a short timeout so the CLI doesn't hang if the registry is slow or offline
40
+ const req = https_1.default.get("https://registry.npmjs.org/draftify-cli/latest", { timeout: 2000 }, (res) => {
41
+ let data = "";
42
+ res.on("data", (chunk) => { data += chunk; });
43
+ res.on("end", () => {
44
+ try {
45
+ const latestVersion = JSON.parse(data).version;
46
+ const currentVersion = require("../package.json").version;
47
+ // Semver comparison: strict inequality since we just want to block older versions
48
+ if (latestVersion && currentVersion && latestVersion !== currentVersion) {
49
+ console.error(`\n\x1b[31m[!] Elavult verziót használsz: ${currentVersion}\x1b[0m`);
50
+ console.error(`\x1b[33mKérlek frissítsd a legújabbra (${latestVersion}) a folytatáshoz:\x1b[0m`);
51
+ console.error(`\n \x1b[36mnpm install -g draftify-cli@latest\x1b[0m\n`);
52
+ process.exit(1);
53
+ }
54
+ resolve();
55
+ }
56
+ catch (e) {
57
+ resolve();
58
+ }
59
+ });
60
+ });
61
+ req.on("error", () => resolve());
62
+ req.on("timeout", () => {
63
+ req.destroy();
64
+ resolve();
65
+ });
66
+ });
67
+ }
68
+ (async () => {
69
+ // Wait for version check before starting anything
70
+ await checkVersion();
71
+ // Custom logic for when `draftify` is run without any arguments
72
+ if (process.argv.slice(2).length === 0) {
73
+ const token = (0, config_1.getToken)();
74
+ if (!token) {
75
+ // No token, run interactive login flow
76
+ (0, login_1.loginCommand)().then((username) => (0, repl_1.startRepl)(username)).catch(() => process.exit(1));
77
+ }
78
+ else {
79
+ // Token exists, start REPL
80
+ (0, repl_1.startRepl)().catch((err) => {
81
+ ui_1.ui.error(`REPL crashed: ${err.message}`);
82
+ process.exit(1);
83
+ });
84
+ }
39
85
  }
40
86
  else {
41
- // Token exists, start REPL
42
- (0, repl_1.startRepl)().catch((err) => {
43
- ui_1.ui.error(`REPL crashed: ${err.message}`);
44
- process.exit(1);
45
- });
87
+ // Otherwise, let commander handle the parsed args
88
+ program.parse(process.argv);
46
89
  }
47
- }
48
- else {
49
- // Otherwise, let commander handle the parsed args
50
- program.parse(process.argv);
51
- }
90
+ })();
package/dist/utils/api.js CHANGED
@@ -80,7 +80,9 @@ new lines
80
80
  ]
81
81
  </ASK_QUESTIONS>
82
82
 
83
- Always use these tags when you write code or ask questions so the CLI can apply it automatically! Keep explanations short and outside the tags.`;
83
+ Always use these tags when you write code or ask questions so the CLI can apply it automatically! Keep explanations short and outside the tags.
84
+
85
+ IMPORTANT: Do NOT include your own properties, name ('Draftify'), or AI identity in the code you generate (e.g., when creating a discord bot, landing page, or admin panel). Do not use 'Draftify' as a brand name or prefix in generated projects. If a fictional brand or name is needed, invent a new, unique one instead.`;
84
86
  const responseStream = await ai.models.generateContentStream({
85
87
  model: geminiModel,
86
88
  contents: contents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draftify-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.10",
4
4
  "description": "Draftify AI CLI tool",
5
5
  "main": "dist/index.js",
6
6
  "bin": {