Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit a0bb394

Browse files
committed
tes
1 parent e4b13a4 commit a0bb394

7 files changed

Lines changed: 124 additions & 6 deletions

File tree

index.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @file index
3+
* @description The main module for importing functions from `src/main.ts` and executing a version check from `version.ts`.
4+
* @remarks
5+
* - Imports `gemini_chat`, `gemini_image`, `gemini_audio`, `gemini_video`, `gemini_history`, `gemini_imgedit`, and `gemini_prompt` functions to make them available for use in other parts of the project.
6+
* - Calls `versionControl` to check that the current project version is up to date with the latest version of `btch-gemini`.
7+
* - Retrieves the current project version from `package.json` to use in the version check.
8+
*/
9+
import * as main from './src/main';
10+
export declare const gemini_chat: typeof main.gemini_chat, gemini_image: typeof main.gemini_image, gemini_audio: typeof main.gemini_audio, gemini_video: typeof main.gemini_video, gemini_history: typeof main.gemini_history, gemini_prompt: typeof main.gemini_prompt, gemini_imgedit: typeof main.gemini_imgedit;

index.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"use strict";
2+
/**
3+
* @file index
4+
* @description The main module for importing functions from `src/main.ts` and executing a version check from `version.ts`.
5+
* @remarks
6+
* - Imports `gemini_chat`, `gemini_image`, `gemini_audio`, `gemini_video`, `gemini_history`, `gemini_imgedit`, and `gemini_prompt` functions to make them available for use in other parts of the project.
7+
* - Calls `versionControl` to check that the current project version is up to date with the latest version of `btch-gemini`.
8+
* - Retrieves the current project version from `package.json` to use in the version check.
9+
*/
10+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11+
if (k2 === undefined) k2 = k;
12+
var desc = Object.getOwnPropertyDescriptor(m, k);
13+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14+
desc = { enumerable: true, get: function() { return m[k]; } };
15+
}
16+
Object.defineProperty(o, k2, desc);
17+
}) : (function(o, m, k, k2) {
18+
if (k2 === undefined) k2 = k;
19+
o[k2] = m[k];
20+
}));
21+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22+
Object.defineProperty(o, "default", { enumerable: true, value: v });
23+
}) : function(o, v) {
24+
o["default"] = v;
25+
});
26+
var __importStar = (this && this.__importStar) || (function () {
27+
var ownKeys = function(o) {
28+
ownKeys = Object.getOwnPropertyNames || function (o) {
29+
var ar = [];
30+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
31+
return ar;
32+
};
33+
return ownKeys(o);
34+
};
35+
return function (mod) {
36+
if (mod && mod.__esModule) return mod;
37+
var result = {};
38+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
39+
__setModuleDefault(result, mod);
40+
return result;
41+
};
42+
})();
43+
var __importDefault = (this && this.__importDefault) || function (mod) {
44+
return (mod && mod.__esModule) ? mod : { "default": mod };
45+
};
46+
Object.defineProperty(exports, "__esModule", { value: true });
47+
exports.gemini_imgedit = exports.gemini_prompt = exports.gemini_history = exports.gemini_video = exports.gemini_audio = exports.gemini_image = exports.gemini_chat = void 0;
48+
const version_1 = require("./version");
49+
const main = __importStar(require("./src/main"));
50+
// ESM exports
51+
exports.gemini_chat = main.gemini_chat, exports.gemini_image = main.gemini_image, exports.gemini_audio = main.gemini_audio, exports.gemini_video = main.gemini_video, exports.gemini_history = main.gemini_history, exports.gemini_prompt = main.gemini_prompt, exports.gemini_imgedit = main.gemini_imgedit;
52+
// CJS exports
53+
module.exports = {
54+
gemini_chat: exports.gemini_chat,
55+
gemini_image: exports.gemini_image,
56+
gemini_audio: exports.gemini_audio,
57+
gemini_video: exports.gemini_video,
58+
gemini_history: exports.gemini_history,
59+
gemini_prompt: exports.gemini_prompt,
60+
gemini_imgedit: exports.gemini_imgedit,
61+
};
62+
// Run version control
63+
const package_json_1 = __importDefault(require("./package.json"));
64+
(0, version_1.versionControl)(package_json_1.default.version);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
}
1414
},
1515
"scripts": {
16-
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && mv dist/cjs/index.js dist/index.js && mv dist/esm/index.mjs dist/index.mjs && mv dist/cjs/index.d.ts dist/index.d.ts",
16+
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && mkdir -p dist/esm && [ -f dist/cjs/index.js ] && mv dist/cjs/index.js dist/index.js && [ -f dist/esm/index.mjs ] && mv dist/esm/index.mjs dist/index.mjs && [ -f dist/cjs/index.d.ts ] && mv dist/cjs/index.d.ts dist/index.d.ts",
1717
"start": "node dist/index.js",
1818
"test": "jest",
1919
"prepublishOnly": "npm run build",
2020
"prepare": "npm run build",
2121
"postinstall": "npm run build"
22-
},
22+
}
23+
,
2324
"files": [
2425
"dist/",
2526
"README.md",

tsconfig.cjs.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
"forceConsistentCasingInFileNames": true,
1313
"resolveJsonModule": true
1414
},
15-
"include": ["src/**/*", "index.ts", "version.ts"],
16-
"exclude": ["node_modules", "dist", "test"]
15+
"include": [
16+
"src/**/*",
17+
"index.ts",
18+
"version.ts"
19+
],
20+
"exclude": [
21+
"node_modules",
22+
"dist",
23+
"test"
24+
]
1725
}

tsconfig.esm.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
"forceConsistentCasingInFileNames": true,
1313
"resolveJsonModule": true
1414
},
15-
"include": ["src/**/*", "index.ts", "version.ts"],
16-
"exclude": ["node_modules", "dist", "test"]
15+
"include": [
16+
"src/**/*",
17+
"index.ts",
18+
"version.ts"
19+
],
20+
"exclude": [
21+
"node_modules",
22+
"dist",
23+
"test"
24+
]
1725
}

version.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function versionControl(version: string): Promise<void>;

version.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.versionControl = versionControl;
7+
const axios_1 = __importDefault(require("axios"));
8+
async function versionControl(version) {
9+
if (process.env.JEST_WORKER_ID) { //Saat test skip aja
10+
return;
11+
}
12+
try {
13+
const response = await axios_1.default.get('https://registry.npmjs.org/btch-gemini');
14+
const pack = response.data;
15+
const latestVersion = pack['dist-tags'].latest;
16+
if (latestVersion !== version) {
17+
console.log(`\x1b[38;5;215mYou are using an Outdated Version for btch-gemini. Run the \x1b[38;5;119m'npm i btch-gemini@${latestVersion}' \x1b[38;5;215mCommand for the Latest Version.\x1B[0m`);
18+
}
19+
else {
20+
console.log(`\x1b[38;5;119mYou are using the Latest Version (${latestVersion}) of btch-gemini.\x1B[0m`);
21+
}
22+
}
23+
catch (er) {
24+
console.error('Version check failed:', er.message || er);
25+
}
26+
}

0 commit comments

Comments
 (0)