kitstore-cli 1.0.90 → 1.0.92

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.
@@ -7,18 +7,17 @@ async function createApi(options) {
7
7
  // If server is explicitly provided in options, use it (highest priority)
8
8
  // Otherwise, get config and use its server (which should have default-config loaded)
9
9
  // Only fall back to localhost if all else fails
10
+ const cfg = await (0, config_1.getConfig)();
10
11
  let basePath;
11
12
  if (options?.server) {
12
13
  // Explicit server option takes highest priority
13
14
  basePath = options.server;
14
15
  }
15
16
  else {
16
- // Get config to resolve server (will use default-config if available)
17
- const cfg = await (0, config_1.getConfig)();
17
+ // Use server from config (will use default-config if available)
18
18
  basePath = cfg.server || 'http://localhost:3000';
19
19
  }
20
20
  // Get token from options or config
21
- const cfg = await (0, config_1.getConfig)();
22
21
  const token = options?.token || cfg.token;
23
22
  const configuration = new generated_1.Configuration({
24
23
  basePath,
package/dist/config.js CHANGED
@@ -47,37 +47,39 @@ const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
47
47
  async function loadBundledDefaultConfig() {
48
48
  try {
49
49
  // Try multiple path resolution strategies to work in both development and npm-installed contexts
50
- // Strategy 1: Use require.resolve to find package.json, then resolve config relative to it
51
- // This works reliably in npm-installed packages where the package is in node_modules
50
+ // Strategy 1: Use __dirname relative path (works in development/local builds and npm-installed packages)
51
+ // When running from source or local tarball, __dirname points to dist/ directory
52
+ // When running from npm-installed package, __dirname also points to dist/ directory
53
+ // default-config.json is at package root, so go up one level from dist/
54
+ const defaultConfigPath = path.join(__dirname, '..', 'default-config.json');
55
+ if (await fs.pathExists(defaultConfigPath)) {
56
+ const defaultConfig = await fs.readJson(defaultConfigPath);
57
+ // Validate that defaultConfig has a server property
58
+ if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
59
+ return defaultConfig;
60
+ }
61
+ }
62
+ // Strategy 2: Use require.resolve to find the current module, then resolve config relative to it
63
+ // This works when the package is installed via npm and we can resolve our own module
52
64
  try {
53
- // Try to resolve the package.json from the installed package
54
- // This will work when the package is installed via npm
55
- const packageJsonPath = require.resolve('kitstore-cli/package.json');
56
- const packageDir = path.dirname(packageJsonPath);
57
- const defaultConfigPath = path.join(packageDir, 'default-config.json');
65
+ // Resolve the current module (config.js) to get its location
66
+ const currentModulePath = require.resolve('./config');
67
+ const currentModuleDir = path.dirname(currentModulePath);
68
+ // Go up to package root (from dist/ to package root)
69
+ const packageRoot = path.dirname(currentModuleDir);
70
+ const defaultConfigPath = path.join(packageRoot, 'default-config.json');
58
71
  if (await fs.pathExists(defaultConfigPath)) {
59
72
  const defaultConfig = await fs.readJson(defaultConfigPath);
60
- // Validate that defaultConfig has a server property
61
73
  if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
62
74
  return defaultConfig;
63
75
  }
64
76
  }
65
77
  }
66
78
  catch (err) {
67
- // Strategy 1 failed (package not in node_modules or not installed), try Strategy 2
68
- }
69
- // Strategy 2: Use __dirname relative path (works in development/local builds)
70
- // When running from source or local tarball, __dirname points to dist/ directory
71
- const defaultConfigPath = path.join(__dirname, '..', 'default-config.json');
72
- if (await fs.pathExists(defaultConfigPath)) {
73
- const defaultConfig = await fs.readJson(defaultConfigPath);
74
- // Validate that defaultConfig has a server property
75
- if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
76
- return defaultConfig;
77
- }
79
+ // Strategy 2 failed, try Strategy 3
78
80
  }
79
81
  // Strategy 3: Try to find default-config.json in process.cwd()/node_modules/kitstore-cli/
80
- // This is a fallback for cases where require.resolve doesn't work
82
+ // This works when running from a project that has kitstore-cli installed locally
81
83
  try {
82
84
  const nodeModulesPath = path.join(process.cwd(), 'node_modules', 'kitstore-cli', 'default-config.json');
83
85
  if (await fs.pathExists(nodeModulesPath)) {
@@ -90,6 +92,21 @@ async function loadBundledDefaultConfig() {
90
92
  catch (err) {
91
93
  // Strategy 3 failed, continue
92
94
  }
95
+ // Strategy 4: Try require.resolve for package.json (works when package is in node_modules)
96
+ try {
97
+ const packageJsonPath = require.resolve('kitstore-cli/package.json');
98
+ const packageDir = path.dirname(packageJsonPath);
99
+ const defaultConfigPath = path.join(packageDir, 'default-config.json');
100
+ if (await fs.pathExists(defaultConfigPath)) {
101
+ const defaultConfig = await fs.readJson(defaultConfigPath);
102
+ if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
103
+ return defaultConfig;
104
+ }
105
+ }
106
+ }
107
+ catch (err) {
108
+ // Strategy 4 failed, continue
109
+ }
93
110
  }
94
111
  catch (err) {
95
112
  // Ignore errors - bundled config may not exist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitstore-cli",
3
- "version": "1.0.90",
3
+ "version": "1.0.92",
4
4
  "description": "CLI tool for Cursor Kit",
5
5
  "main": "dist/index.js",
6
6
  "bin": {