cartographer-ai 1.0.10 → 1.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cartographer-ai",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "main": "src/commands.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,8 +6,6 @@ import { execSync } from "child_process";
6
6
  const regex =
7
7
  /@cartographer\s*((?:\s*(?:id|parentId|name|diagramType|context|spaceId|folderId):\s*[^,\n]+,\s*)*(?:\s*(?:id|parentId|name|diagramType|context|spaceId|folderId):\s*[^,\n]+)?)/;
8
8
  const ignoredDirectories = ["node_modules", ".git", "build"];
9
- export const warningPrefix = "\x1b[33mWarning:\x1b[0m";
10
- export const errorPrefix = "\x1b[31mError:\x1b[0m";
11
9
 
12
10
  export class Cartographer {
13
11
  constructor({ processAllFiles = false, spaceId, apiKey }) {
@@ -92,16 +90,14 @@ export class Cartographer {
92
90
  },
93
91
  });
94
92
  } catch (error) {
95
- if (error?.response?.data?.error) {
96
- const errorMessage = `${errorPrefix} ${
97
- error?.response?.data?.error ?? "Unexpected error occured"
98
- }`;
93
+ const errorMessage = `\x1b[31m${
94
+ error?.response?.data?.error ?? "Unexpected error occured"
95
+ }\x1b[0m`;
99
96
 
100
- const err = new Error(errorMessage);
101
- err.stack = "";
97
+ const err = new Error(errorMessage);
98
+ err.stack = "";
102
99
 
103
- throw err;
104
- }
100
+ throw err;
105
101
  }
106
102
  }
107
103
 
@@ -173,11 +169,11 @@ export class Cartographer {
173
169
 
174
170
  if (forbidden.length > 0) {
175
171
  console.warn(
176
- `${warningPrefix} File "${path.basename(
172
+ `\x1b[33mFile "${path.basename(
177
173
  filePath
178
174
  )}" is invalid. When "parentId" is present, the following attributes must not be used: ${forbidden.join(
179
175
  ", "
180
- )}. These attributes have been ignored.`
176
+ )}. These attributes have been ignored.\x1b[0m`
181
177
  );
182
178
  }
183
179
 
@@ -223,7 +219,7 @@ export class Cartographer {
223
219
 
224
220
  files[resolvedId].push(file);
225
221
  } catch (error) {
226
- const errorMessage = `${errorPrefix} Error reading file ${filePath}, error: ${error.message}`;
222
+ const errorMessage = `\x1b[31mError reading file ${filePath}, error: ${error.message}\x1b[0m`;
227
223
  const err = new Error(errorMessage);
228
224
  err.stack = "";
229
225
 
package/src/commands.js CHANGED
@@ -1,9 +1,9 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import fs from "fs";
4
4
  import path from "path";
5
- import { Cartographer, errorPrefix } from "./cartographer.js";
6
5
  import { fileURLToPath } from "url";
6
+ import { Cartographer } from "./cartographer.js";
7
7
 
8
8
  const args = process.argv.slice(2);
9
9
  const fields = ["spaceId", "apiKey"];
@@ -33,7 +33,7 @@ export const saveConfig = (configPath, newConfig) => {
33
33
 
34
34
  const handleCartographerCommand = (arg) => {
35
35
  if (!arg) {
36
- const errorMessage = `${errorPrefix} No command received`;
36
+ const errorMessage = `\x1b[31mNo command received\x1b[0m`;
37
37
  const err = new Error(errorMessage);
38
38
  err.stack = "";
39
39
 
@@ -50,9 +50,9 @@ const handleCartographerCommand = (arg) => {
50
50
  }, []);
51
51
 
52
52
  if (missingFields.length > 0) {
53
- const errorMessage = `${errorPrefix} Missing required fields: ${missingFields.join(
53
+ const errorMessage = `\x1b[31mMissing required fields: ${missingFields.join(
54
54
  ", "
55
- )}`;
55
+ )}\x1b[0m`;
56
56
 
57
57
  const err = new Error(errorMessage);
58
58
  err.stack = "";
@@ -81,7 +81,7 @@ const handleCartographerCommand = (arg) => {
81
81
  const field = fields.find((field) => field === command);
82
82
 
83
83
  if (!field) {
84
- const errorMessage = `${errorPrefix} Unknown command: ${command}`;
84
+ const errorMessage = `\x1b[31mUnknown command: ${command}\x1b[0m`;
85
85
  const err = new Error(errorMessage);
86
86
  err.stack = "";
87
87