@atmyapp/cli 0.0.1

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.
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.uploadDefinitions = uploadDefinitions;
13
+ function getFetchImplementation() {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ // Use native fetch if available (Node.js 18+)
16
+ if (typeof globalThis.fetch === "function") {
17
+ return globalThis.fetch.bind(globalThis);
18
+ }
19
+ // Fallback to node-fetch for older Node.js versions
20
+ try {
21
+ // @ts-ignore
22
+ const nodeFetch = yield import("node-fetch");
23
+ return nodeFetch.default;
24
+ }
25
+ catch (error) {
26
+ throw new Error("Neither native fetch nor node-fetch is available. For Node.js < 18, install node-fetch package.");
27
+ }
28
+ });
29
+ }
30
+ // Uploads the generated definitions to the AtMyApp platform
31
+ function uploadDefinitions(output, config, logger) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ if (!config.url) {
34
+ logger.error("Base URL not provided in session. Please run 'use' command first.");
35
+ return false;
36
+ }
37
+ try {
38
+ const fetchApi = yield getFetchImplementation();
39
+ const url = `${config.url}/storage/structure`;
40
+ logger.info(`🔄 Posting definitions to server at ${url}`);
41
+ const response = yield fetchApi(url, {
42
+ method: "POST",
43
+ headers: {
44
+ "Content-Type": "application/json",
45
+ Authorization: `Bearer ${config.token}`,
46
+ },
47
+ body: JSON.stringify({ content: JSON.stringify(output) }),
48
+ });
49
+ const responseText = yield response.text();
50
+ logger.verbose_log(`Server response: ${responseText}`);
51
+ if (!response.ok) {
52
+ throw new Error(`HTTP error! status: ${response.status}, message: ${responseText}`);
53
+ }
54
+ logger.success("🚀 Successfully posted definitions to storage.");
55
+ return true;
56
+ }
57
+ catch (postError) {
58
+ logger.error("❌ Failed to post definitions:", postError);
59
+ return false;
60
+ }
61
+ });
62
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@atmyapp/cli",
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "test:watch": "jest --watch",
9
+ "test:coverage": "jest --coverage",
10
+ "build": "tsc",
11
+ "build:test": "tsc && npm test"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/At-My-App/cli.git"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "bin": {
25
+ "atmyapp": "./dist/cli/index.js"
26
+ },
27
+ "author": "Maciej Gamrot",
28
+ "license": "ISC",
29
+ "description": "",
30
+ "devDependencies": {
31
+ "@atmyapp/core": "^0.0.3",
32
+ "@types/jest": "^29.5.14",
33
+ "@typescript-eslint/eslint-plugin": "^8.32.1",
34
+ "@typescript-eslint/parser": "^8.32.1",
35
+ "eslint": "^9.27.0",
36
+ "eslint-config-prettier": "^10.1.5",
37
+ "jest": "^29.7.0",
38
+ "prettier": "^3.5.3",
39
+ "ts-jest": "^29.3.4",
40
+ "typescript": "^5.8.3"
41
+ },
42
+ "dependencies": {
43
+ "chalk": "^4.1.2",
44
+ "commander": "^14.0.0",
45
+ "fast-glob": "^3.3.3",
46
+ "path": "^0.12.7",
47
+ "ts-morph": "^26.0.0",
48
+ "typescript-json-schema": "^0.65.1"
49
+ }
50
+ }