@idajs/create-mod 0.1.44-dev.52 → 0.1.45

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.
Files changed (2) hide show
  1. package/install.js +27 -27
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -4,37 +4,21 @@ const fs = require("fs");
4
4
  const path = require("path");
5
5
  const { exec } = require("child_process");
6
6
 
7
- // Function to find the Ida root directory by searching upward
8
- function findIdaRoot(startDir) {
9
- let currentDir = startDir;
10
-
11
- while (currentDir !== path.dirname(currentDir)) {
12
- // Check if this directory contains characteristic Ida files
13
- if (
14
- fs.existsSync(path.join(currentDir, "version.js")) &&
15
- fs.existsSync(path.join(currentDir, "srcjs", "create-mod"))
16
- ) {
17
- return currentDir;
18
- }
19
- currentDir = path.dirname(currentDir);
20
- }
21
-
22
- console.error("Error: Could not find Ida root directory");
23
- process.exit(1);
24
- }
25
-
26
7
  // Get configuration from arguments or defaults
27
8
  const args = process.argv.slice(2);
28
9
  const targetDirArg = args.find((arg) => !arg.startsWith("--"));
29
10
  const skipInstall = args.includes("--skip-install");
11
+ const idaRootArg = args.find((arg) => arg.startsWith("--ida-root="));
30
12
 
31
13
  // Get the directory where this script was called from or use provided argument
32
14
  const targetDir = targetDirArg ? path.resolve(targetDirArg) : process.cwd();
33
15
 
34
- // Find Ida root directory
35
- const idaRoot = findIdaRoot(__dirname);
36
- const configDir = path.join(idaRoot, "srcjs", "create-mod", "_project.config");
37
- const versionScriptPath = path.join(idaRoot, "version.js");
16
+ // Configuration directory is in the same directory as this script
17
+ const configDir = path.join(__dirname, "_project.config");
18
+
19
+ // Get idaRoot from argument or assume standalone mode
20
+ const idaRoot = idaRootArg ? path.resolve(idaRootArg.split("=")[1]) : null;
21
+ const versionScriptPath = idaRoot ? path.join(idaRoot, "version.js") : null;
38
22
 
39
23
  const isTypeScriptProject = (() => {
40
24
  // Check if there are any .ts files in src/
@@ -48,7 +32,11 @@ const isTypeScriptProject = (() => {
48
32
  })();
49
33
 
50
34
  console.log(`Installing development environment in: ${targetDir}`);
51
- console.log(`Ida root: ${idaRoot}`);
35
+ if (idaRoot) {
36
+ console.log(`Ida root: ${idaRoot}`);
37
+ } else {
38
+ console.log(`Running in standalone mode`);
39
+ }
52
40
 
53
41
  // Step 1: Merge package.template.json files to create package.json
54
42
  function mergePackageJson() {
@@ -72,16 +60,28 @@ function mergePackageJson() {
72
60
  const packageJson = JSON.parse(fs.readFileSync(globalTemplatePath, "utf8"));
73
61
  const sampleTemplate = JSON.parse(fs.readFileSync(sampleTemplatePath, "utf8"));
74
62
 
75
- // Get version from version.js
63
+ // Get version from version.js or package.json (standalone mode)
76
64
  let version = null;
77
- if (fs.existsSync(versionScriptPath)) {
65
+ if (versionScriptPath && fs.existsSync(versionScriptPath)) {
78
66
  try {
79
67
  const { execSync } = require("child_process");
80
68
  version = execSync(`node "${versionScriptPath}"`, { encoding: "utf8" }).trim();
81
- console.log(`Using version: ${version}`);
69
+ console.log(`Using version from version.js: ${version}`);
82
70
  } catch (error) {
83
71
  console.warn("Warning: Could not read version from version.js");
84
72
  }
73
+ } else {
74
+ // Standalone mode: get version from package.json in the same directory as this script
75
+ const localPackagePath = path.join(__dirname, "package.json");
76
+ if (fs.existsSync(localPackagePath)) {
77
+ try {
78
+ const localPackage = JSON.parse(fs.readFileSync(localPackagePath, "utf8"));
79
+ version = localPackage.version;
80
+ console.log(`Using version from package.json: ${version}`);
81
+ } catch (error) {
82
+ console.warn("Warning: Could not read version from package.json");
83
+ }
84
+ }
85
85
  }
86
86
 
87
87
  // Set version if available
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idajs/create-mod",
3
- "version": "0.1.44-dev.52",
3
+ "version": "0.1.45",
4
4
  "description": "Scaffolding tool for creating IdaJS game mods for Little Big Adventure 2. Use with: npx @idajs/create-mod",
5
5
  "author": "Andriy Tevelyev",
6
6
  "license": "GPL-2.0",