@orion-js/core 3.11.10 → 3.11.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.
@@ -8,42 +8,58 @@ const path_1 = __importDefault(require("path"));
8
8
  const promises_1 = __importDefault(require("fs/promises"));
9
9
  const https_1 = __importDefault(require("https"));
10
10
  const safe_1 = __importDefault(require("colors/safe"));
11
- async function copyCursorRule() {
12
- const sourceUrl = 'https://raw.githubusercontent.com/orionjs/orionjs/refs/heads/master/.cursor/rules/orionjs.mdc';
13
- const targetDir = path_1.default.join(process.cwd(), '.cursor', 'rules');
14
- const targetFile = path_1.default.join(targetDir, 'orionjs.mdc');
15
- // Function to download the file content
16
- const downloadFile = (url) => {
17
- return new Promise((resolve, reject) => {
18
- https_1.default.get(url, (response) => {
19
- if (response.statusCode !== 200) {
20
- reject(new Error(`Failed to download, status code: ${response.statusCode}`));
21
- return;
22
- }
23
- let data = '';
24
- response.on('data', (chunk) => {
25
- data += chunk;
26
- });
27
- response.on('end', () => {
28
- resolve(data);
29
- });
30
- }).on('error', (err) => {
11
+ const rules = [
12
+ 'orionjs.mdx',
13
+ 'orionjs-component.mdx',
14
+ 'orionjs-repository.mdx',
15
+ 'orionjs-schema.mdx',
16
+ 'orionjs-services.mdx',
17
+ ];
18
+ // Function to download the file content
19
+ const downloadFile = (url) => {
20
+ return new Promise((resolve, reject) => {
21
+ https_1.default.get(url, (response) => {
22
+ if (response.statusCode !== 200) {
23
+ reject(new Error(`Failed to download, status code: ${response.statusCode}`));
24
+ return;
25
+ }
26
+ let data = '';
27
+ response.on('data', (chunk) => {
28
+ data += chunk;
29
+ });
30
+ response.on('end', () => {
31
+ resolve(data);
32
+ });
33
+ response.on('error', (err) => {
31
34
  reject(err);
32
35
  });
33
36
  });
34
- };
37
+ });
38
+ };
39
+ async function copyCursorRule() {
40
+ const baseUrl = `https://raw.githubusercontent.com/orionjs/orionjs/refs/heads/master/mdc`;
35
41
  try {
36
- // Ensure the directory exists
42
+ // Create target directory if it doesn't exist
43
+ const targetDir = path_1.default.join(process.cwd(), '.cursor', 'rules');
37
44
  await promises_1.default.mkdir(targetDir, { recursive: true });
38
- // Download the file content
39
- const content = await downloadFile(sourceUrl);
40
- // Write the content to the target file
41
- await promises_1.default.writeFile(targetFile, content, 'utf8');
42
- console.log(safe_1.default.bold(`Updated .cursor/rules/orionjs.mdc to the latest version`));
45
+ // Process each rule file
46
+ for (const rule of rules) {
47
+ // Change extension from .mdx to .mdc
48
+ const targetFileName = rule.replace('.mdx', '.mdc');
49
+ const targetFile = path_1.default.join(targetDir, targetFileName);
50
+ // Construct source URL
51
+ const sourceUrl = `${baseUrl}/${rule}`;
52
+ // console.log(colors.gray(`=> ✨ Downloading ${colors.cyan(rule)} to ${colors.cyan(targetFileName)}...`))
53
+ // Download the file content
54
+ const content = await downloadFile(sourceUrl);
55
+ // Write the content to the target file
56
+ await promises_1.default.writeFile(targetFile, content, 'utf8');
57
+ console.log(safe_1.default.bold(`=> ✨ Successfully downloaded ${safe_1.default.cyan(targetFileName)}`));
58
+ }
59
+ console.log(safe_1.default.bold('=> ✨ All rule files have been successfully copied'));
43
60
  }
44
61
  catch (error) {
45
- console.error('Error copying cursor rule:', error);
46
- throw error;
62
+ console.error(safe_1.default.red(`Error copying rule files: ${error.message}`));
47
63
  }
48
64
  }
49
65
  exports.copyCursorRule = copyCursorRule;
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION_FILE = exports.MCP_VERSION = void 0;
4
4
  // Define current MCP version - update this when a new version needs to be deployed
5
- exports.MCP_VERSION = 'v1';
5
+ exports.MCP_VERSION = 'v2';
6
6
  exports.VERSION_FILE = 'version.txt';
@@ -18,7 +18,7 @@ async function copyMCP() {
18
18
  await promises_1.default.mkdir(path_1.default.join(process.cwd(), '.orion'), { recursive: true });
19
19
  // Check if the repository is already properly installed with current version
20
20
  if (await (0, isValidMCPRepo_1.isValidMCPRepository)(targetDir)) {
21
- // console.log(colors.green(`MCP documentation already installed in .orion/mcp (version ${MCP_VERSION})`))
21
+ console.log(safe_1.default.bold(`=> ✨ MCP documentation already installed`));
22
22
  return;
23
23
  }
24
24
  // Check if the directory already exists but is not a valid repository or has outdated version
@@ -27,23 +27,60 @@ async function copyMCP() {
27
27
  if (stats.isDirectory()) {
28
28
  // Directory exists, remove it first to ensure fresh clone
29
29
  await promises_1.default.rm(targetDir, { recursive: true, force: true });
30
- console.log(safe_1.default.yellow(`Removed existing .orion/mcp directory (invalid, incomplete, or outdated)`));
30
+ console.log(safe_1.default.bold(`=> ✨ Removed existing .orion/mcp directory (invalid, incomplete, or outdated)`));
31
31
  }
32
32
  }
33
33
  catch (error) {
34
34
  // Directory doesn't exist, which is fine
35
35
  }
36
36
  // Clone the repository
37
- console.log(safe_1.default.bold(`Downloading MCP documentation v${consts_1.MCP_VERSION}...`));
37
+ console.log(safe_1.default.bold(`=> ✨ Downloading MCP documentation ${consts_1.MCP_VERSION}...`));
38
38
  await (0, execute_1.default)(`git clone ${repoUrl} ${targetDir}`);
39
39
  // Remove git directory to avoid confusion
40
40
  await (0, execute_1.default)(`rm -rf ${path_1.default.join(targetDir, '.git')}`);
41
41
  // Create version file
42
42
  await promises_1.default.writeFile(path_1.default.join(targetDir, consts_1.VERSION_FILE), consts_1.MCP_VERSION, 'utf-8');
43
- console.log(safe_1.default.green(`Successfully downloaded MCP documentation v${consts_1.MCP_VERSION} to .orion/mcp`));
43
+ console.log(safe_1.default.bold(`=> ✨ Successfully downloaded MCP documentation v${consts_1.MCP_VERSION} to .orion/mcp`));
44
+ // Install dependencies in the MCP directory
45
+ console.log(safe_1.default.bold(`=> ✨ Installing MCP dependencies...`));
46
+ await (0, execute_1.default)(`cd ${targetDir} && npm install`);
47
+ console.log(safe_1.default.bold(`=> ✨ Successfully installed MCP dependencies`));
48
+ const mcpServerConfig = {
49
+ "mcpServers": {
50
+ "Orionjs documentation search": {
51
+ "command": "node",
52
+ "args": [
53
+ path_1.default.join(targetDir, 'src', 'index.js')
54
+ ]
55
+ }
56
+ }
57
+ };
58
+ const configPath = path_1.default.join(process.cwd(), '.cursor', 'mcp.json');
59
+ // Check if the config file exists
60
+ try {
61
+ // Try to read existing config file
62
+ const existingConfig = await promises_1.default.readFile(configPath, 'utf-8');
63
+ const parsedConfig = JSON.parse(existingConfig);
64
+ // Update the mcpServers section while preserving other settings
65
+ parsedConfig.mcpServers = {
66
+ ...parsedConfig.mcpServers,
67
+ ...mcpServerConfig.mcpServers
68
+ };
69
+ // Write the updated config back
70
+ await promises_1.default.writeFile(configPath, JSON.stringify(parsedConfig, null, 2), 'utf-8');
71
+ console.log(safe_1.default.bold(`=> ✨ Updated MCP server configuration in .cursor/mcp.json`));
72
+ }
73
+ catch (error) {
74
+ // If file doesn't exist or can't be parsed, create a new one
75
+ // Ensure the .cursor directory exists
76
+ await promises_1.default.mkdir(path_1.default.dirname(configPath), { recursive: true });
77
+ // Write the new config file
78
+ await promises_1.default.writeFile(configPath, JSON.stringify(mcpServerConfig, null, 2), 'utf-8');
79
+ console.log(safe_1.default.bold(`=> ✨ Created new MCP server configuration in .cursor/mcp.json`));
80
+ }
44
81
  }
45
82
  catch (error) {
46
- console.error(safe_1.default.red('Error copying MCP documentation:'), error);
83
+ console.error(safe_1.default.red('=> ✨ Error copying MCP documentation:'), error);
47
84
  throw error;
48
85
  }
49
86
  }
@@ -20,7 +20,7 @@ async function isValidMCPRepository(directoryPath) {
20
20
  return false;
21
21
  // Check for some key files/directories that should exist in the repository
22
22
  // This helps verify it's a valid repository and not just an empty or corrupted directory
23
- const expectedFiles = ['README.md', 'docs', 'package.json'];
23
+ const expectedFiles = ['settings.js', 'package.json'];
24
24
  for (const file of expectedFiles) {
25
25
  try {
26
26
  await promises_1.default.access(path_1.default.join(directoryPath, file));
@@ -37,7 +37,7 @@ async function isValidMCPRepository(directoryPath) {
37
37
  // If the version in the file doesn't match the current version,
38
38
  // consider the repository outdated
39
39
  if (versionContent.trim() !== consts_1.MCP_VERSION) {
40
- console.log(safe_1.default.yellow(`MCP version mismatch: installed=${versionContent.trim()}, required=${consts_1.MCP_VERSION}`));
40
+ console.log(safe_1.default.yellow(`=> ✨ MCP version mismatch: installed=${versionContent.trim()}, required=${consts_1.MCP_VERSION}`));
41
41
  return false;
42
42
  }
43
43
  }
@@ -7,13 +7,17 @@ const safe_1 = __importDefault(require("colors/safe"));
7
7
  const runner_1 = require("./runner");
8
8
  const watchAndCompile_1 = __importDefault(require("./watchAndCompile"));
9
9
  const copyCursorRule_1 = require("./copyCursorRule");
10
+ const copyMCP_1 = require("./copyMCP");
10
11
  async function default_1(options) {
11
12
  console.log(safe_1.default.bold('\nOrionjs App ' + safe_1.default.green(safe_1.default.bold('V3\n'))));
12
13
  if (!options.omitCursorRule) {
13
- (0, copyCursorRule_1.copyCursorRule)().catch(console.error);
14
+ await ((0, copyCursorRule_1.copyCursorRule)().catch(console.error));
14
15
  }
15
16
  if (!options.omitMcpServer) {
16
- // await copyMcpServer()
17
+ await ((0, copyMCP_1.copyMCP)().catch(console.error));
18
+ }
19
+ if (!options.omitMcpServer && !options.omitCursorRule) {
20
+ console.log(safe_1.default.bold(`=> ✨ Orionjs AI is ready\n`));
17
21
  }
18
22
  const runner = (0, runner_1.getRunner)(options);
19
23
  (0, watchAndCompile_1.default)(runner);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/core",
3
- "version": "3.11.10",
3
+ "version": "3.11.12",
4
4
  "main": "index.js",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "engines": {
37
37
  "node": ">=14.0.0"
38
38
  },
39
- "gitHead": "231fd9e0f484cc902d4e0cd7058cc6ce6479ddca",
39
+ "gitHead": "35293b72df2bdd2009a969e024be6367a4921e2d",
40
40
  "devDependencies": {
41
41
  "@shelf/jest-mongodb": "^2.1.0",
42
42
  "@types/prompts": "^2.4.2",