kitstore-cli 1.0.97 → 1.0.103

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/dist/config.js CHANGED
@@ -46,26 +46,174 @@ const CONFIG_DIR = process.env.KITSTORE_CONFIG_DIR || path.join(os.homedir(), '.
46
46
  const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
47
47
  async function loadBundledDefaultConfig() {
48
48
  try {
49
- // Try multiple path resolution strategies to work in both development and npm-installed contexts,
50
- // in a deterministic order that favors the actual npm package layout used by npx / CI.
51
- //
52
- // Strategy 1: Use require.resolve for package.json (most reliable for npm-installed / npx contexts)
53
- // - When running from npm cache or node_modules, this finds the real package root.
54
- // - default-config.json lives at that package root.
49
+ console.log('🔧 DEBUG loadBundledDefaultConfig: Starting resolution strategies...');
50
+ console.log('🔧 DEBUG Environment info:');
51
+ console.log('🔧 DEBUG __filename:', __filename);
52
+ console.log('🔧 DEBUG __dirname:', __dirname);
53
+ console.log('🔧 DEBUG process.cwd():', process.cwd());
54
+ console.log('🔧 DEBUG process.execPath:', process.execPath);
55
+ console.log('🔧 DEBUG process.argv[0]:', process.argv[0]);
56
+ console.log('🔧 DEBUG process.argv[1]:', process.argv[1]);
57
+ // Strategy 0: Direct node_modules lookup (most reliable for npm-installed contexts)
55
58
  try {
59
+ const nodeModulesPath = path.join(process.cwd(), 'node_modules', 'kitstore-cli', 'default-config.json');
60
+ console.log('🔧 DEBUG Strategy 0: Checking', nodeModulesPath);
61
+ console.log('🔧 DEBUG Strategy 0: process.cwd() is:', process.cwd());
62
+ console.log('🔧 DEBUG Strategy 0: Directory exists:', await fs.pathExists(path.dirname(nodeModulesPath)));
63
+ console.log('🔧 DEBUG Strategy 0: node_modules exists:', await fs.pathExists(path.join(process.cwd(), 'node_modules')));
64
+ console.log('🔧 DEBUG Strategy 0: kitstore-cli dir exists:', await fs.pathExists(path.join(process.cwd(), 'node_modules', 'kitstore-cli')));
65
+ if (await fs.pathExists(nodeModulesPath)) {
66
+ const defaultConfig = await fs.readJson(nodeModulesPath);
67
+ console.log('🔧 DEBUG Strategy 0: Found config:', defaultConfig ? { server: defaultConfig.server } : null);
68
+ if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
69
+ console.log('🔧 DEBUG Strategy 0: SUCCESS');
70
+ return defaultConfig;
71
+ }
72
+ }
73
+ else {
74
+ console.log('🔧 DEBUG Strategy 0: File not found at', nodeModulesPath);
75
+ }
76
+ }
77
+ catch (err) {
78
+ console.log('🔧 DEBUG Strategy 0: Failed with error:', err instanceof Error ? err.message : String(err));
79
+ }
80
+ // Strategy 1: Use require.resolve for package.json (works in most npm-installed contexts)
81
+ try {
82
+ console.log('🔧 DEBUG Strategy 1: Trying require.resolve...');
56
83
  const packageJsonPath = require.resolve('kitstore-cli/package.json');
57
84
  const packageDir = path.dirname(packageJsonPath);
58
85
  const defaultConfigPath = path.join(packageDir, 'default-config.json');
86
+ console.log('🔧 DEBUG Strategy 1: Resolved to', packageJsonPath);
87
+ console.log('🔧 DEBUG Strategy 1: Package dir:', packageDir);
88
+ console.log('🔧 DEBUG Strategy 1: Config path:', defaultConfigPath);
59
89
  if (await fs.pathExists(defaultConfigPath)) {
60
90
  const defaultConfig = await fs.readJson(defaultConfigPath);
91
+ console.log('🔧 DEBUG Strategy 1: Found config:', defaultConfig ? { server: defaultConfig.server } : null);
61
92
  if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
93
+ console.log('🔧 DEBUG Strategy 1: SUCCESS');
62
94
  return defaultConfig;
63
95
  }
64
96
  }
97
+ else {
98
+ console.log('🔧 DEBUG Strategy 1: Config file not found at', defaultConfigPath);
99
+ console.log('🔧 DEBUG Strategy 1: Package dir contents:', await fs.readdir(packageDir).catch(() => 'unable to read'));
100
+ }
65
101
  }
66
102
  catch (err) {
67
- // Strategy 1 failed, try Strategy 1.5
68
- // Strategy 1 failed, try Strategy 2
103
+ console.log('🔧 DEBUG Strategy 1: Failed - require.resolve error:', err instanceof Error ? err.message : String(err));
104
+ }
105
+ // Strategy 2: Walk up from current file location (__filename)
106
+ try {
107
+ console.log('🔧 DEBUG Strategy 2: Walking up from __filename...');
108
+ let currentDir = path.dirname(path.dirname(__filename)); // cli/dist -> cli/
109
+ let attempts = 0;
110
+ const maxAttempts = 10;
111
+ console.log('🔧 DEBUG Strategy 2: Starting from', currentDir);
112
+ while (currentDir !== path.dirname(currentDir) && attempts < maxAttempts) {
113
+ const packageJsonPath = path.join(currentDir, 'package.json');
114
+ const defaultConfigPath = path.join(currentDir, 'default-config.json');
115
+ console.log('🔧 DEBUG Strategy 2: Checking dir', currentDir, 'attempt', attempts);
116
+ console.log('🔧 DEBUG Strategy 2: package.json exists:', await fs.pathExists(packageJsonPath));
117
+ console.log('🔧 DEBUG Strategy 2: default-config.json exists:', await fs.pathExists(defaultConfigPath));
118
+ if (await fs.pathExists(packageJsonPath) && await fs.pathExists(defaultConfigPath)) {
119
+ try {
120
+ const packageJson = await fs.readJson(packageJsonPath);
121
+ console.log('🔧 DEBUG Strategy 2: Found package.json with name:', packageJson.name);
122
+ if (packageJson.name === 'kitstore-cli') {
123
+ const defaultConfig = await fs.readJson(defaultConfigPath);
124
+ console.log('🔧 DEBUG Strategy 2: Found config:', defaultConfig ? { server: defaultConfig.server } : null);
125
+ if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
126
+ console.log('🔧 DEBUG Strategy 2: SUCCESS');
127
+ return defaultConfig;
128
+ }
129
+ }
130
+ }
131
+ catch (readErr) {
132
+ console.log('🔧 DEBUG Strategy 2: Read error:', readErr instanceof Error ? readErr.message : String(readErr));
133
+ }
134
+ }
135
+ currentDir = path.dirname(currentDir);
136
+ attempts++;
137
+ }
138
+ console.log('🔧 DEBUG Strategy 2: No kitstore-cli package found after', attempts, 'attempts');
139
+ console.log('🔧 DEBUG Strategy 2: Ended at', currentDir);
140
+ }
141
+ catch (err) {
142
+ console.log('🔧 DEBUG Strategy 2: Failed with error:', err instanceof Error ? err.message : String(err));
143
+ }
144
+ // Strategy 3: Check npm global installation directories
145
+ try {
146
+ console.log('🔧 DEBUG Strategy 3: Checking npm global directories...');
147
+ const npmPaths = [];
148
+ // Try to get npm prefix
149
+ try {
150
+ const { execSync } = require('child_process');
151
+ const npmPrefix = execSync('npm config get prefix').toString().trim();
152
+ console.log('🔧 DEBUG Strategy 3: npm prefix:', npmPrefix);
153
+ npmPaths.push(path.join(npmPrefix, 'lib', 'node_modules', 'kitstore-cli', 'default-config.json'));
154
+ }
155
+ catch (e) {
156
+ console.log('🔧 DEBUG Strategy 3: Could not get npm prefix:', e instanceof Error ? e.message : String(e));
157
+ }
158
+ // Common global installation paths
159
+ npmPaths.push('/usr/local/lib/node_modules/kitstore-cli/default-config.json');
160
+ npmPaths.push('/usr/lib/node_modules/kitstore-cli/default-config.json');
161
+ npmPaths.push(path.join(os.homedir(), '.npm-global', 'lib', 'node_modules', 'kitstore-cli', 'default-config.json'));
162
+ console.log('🔧 DEBUG Strategy 3: Will check paths:', npmPaths);
163
+ for (const configPath of npmPaths) {
164
+ console.log('🔧 DEBUG Strategy 3: Checking', configPath);
165
+ try {
166
+ const exists = await fs.pathExists(configPath);
167
+ console.log('🔧 DEBUG Strategy 3: Path exists:', exists);
168
+ if (exists) {
169
+ const defaultConfig = await fs.readJson(configPath);
170
+ console.log('🔧 DEBUG Strategy 3: Found config:', defaultConfig ? { server: defaultConfig.server } : null);
171
+ if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
172
+ console.log('🔧 DEBUG Strategy 3: SUCCESS');
173
+ return defaultConfig;
174
+ }
175
+ }
176
+ }
177
+ catch (e) {
178
+ console.log('🔧 DEBUG Strategy 3: Error checking path:', e instanceof Error ? e.message : String(e));
179
+ }
180
+ }
181
+ console.log('🔧 DEBUG Strategy 3: No config found in global directories');
182
+ }
183
+ catch (err) {
184
+ console.log('🔧 DEBUG Strategy 3: Failed with error:', err instanceof Error ? err.message : String(err));
185
+ }
186
+ // Strategy 4: Try to find via npm list or npm root
187
+ try {
188
+ console.log('🔧 DEBUG Strategy 4: Trying npm root resolution...');
189
+ const { execSync } = require('child_process');
190
+ try {
191
+ // Try npm root for kitstore-cli
192
+ console.log('🔧 DEBUG Strategy 4: Running npm root kitstore-cli...');
193
+ const npmRoot = execSync('npm root kitstore-cli 2>/dev/null || npm root').toString().trim();
194
+ console.log('🔧 DEBUG Strategy 4: npm root result:', npmRoot);
195
+ const configPath = path.join(npmRoot, 'kitstore-cli', 'default-config.json');
196
+ console.log('🔧 DEBUG Strategy 4: Checking npm root path:', configPath);
197
+ console.log('🔧 DEBUG Strategy 4: npm root dir exists:', await fs.pathExists(npmRoot));
198
+ console.log('🔧 DEBUG Strategy 4: kitstore-cli in npm root exists:', await fs.pathExists(path.join(npmRoot, 'kitstore-cli')));
199
+ if (await fs.pathExists(configPath)) {
200
+ const defaultConfig = await fs.readJson(configPath);
201
+ console.log('🔧 DEBUG Strategy 4: Found config:', defaultConfig ? { server: defaultConfig.server } : null);
202
+ if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
203
+ console.log('🔧 DEBUG Strategy 4: SUCCESS');
204
+ return defaultConfig;
205
+ }
206
+ }
207
+ else {
208
+ console.log('🔧 DEBUG Strategy 4: Config file not found at npm root path');
209
+ }
210
+ }
211
+ catch (e) {
212
+ console.log('🔧 DEBUG Strategy 4: npm root command failed:', e instanceof Error ? e.message : String(e));
213
+ }
214
+ }
215
+ catch (err) {
216
+ console.log('🔧 DEBUG Strategy 4: Failed with error:', err instanceof Error ? err.message : String(err));
69
217
  }
70
218
  // Strategy 1.5: Try to find package.json by walking up from __dirname
71
219
  // This handles cases where require.resolve doesn't work in some npm/npx contexts
@@ -144,10 +292,29 @@ async function loadBundledDefaultConfig() {
144
292
  catch (err) {
145
293
  // Strategy 4 failed, continue
146
294
  }
295
+ // Strategy 5: Try to find the config relative to the CLI's installation directory
296
+ // This works when the CLI is globally installed or run via npx
297
+ try {
298
+ // Get the directory where this config.js file is located
299
+ const cliDistDir = path.dirname(__filename);
300
+ // Go up to find the package root (dist -> kitstore-cli package root)
301
+ const packageRoot = path.dirname(cliDistDir);
302
+ const defaultConfigPath = path.join(packageRoot, 'default-config.json');
303
+ if (await fs.pathExists(defaultConfigPath)) {
304
+ const defaultConfig = await fs.readJson(defaultConfigPath);
305
+ if (defaultConfig && typeof defaultConfig === 'object' && defaultConfig.server) {
306
+ return defaultConfig;
307
+ }
308
+ }
309
+ }
310
+ catch (err) {
311
+ // Strategy 5 failed, continue
312
+ }
147
313
  }
148
314
  catch (err) {
149
- // Ignore errors - bundled config may not exist
315
+ console.log('🔧 DEBUG loadBundledDefaultConfig: Outer catch - ignoring error');
150
316
  }
317
+ console.log('🔧 DEBUG loadBundledDefaultConfig: All strategies failed, returning null');
151
318
  return null;
152
319
  }
153
320
  async function getConfig() {
package/dist/index.js CHANGED
@@ -4,6 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ // DIAGNOSTIC: Log execution environment before any config loading
8
+ console.log('🔧 DIAGNOSTIC: CLI Execution Environment:');
9
+ console.log('🔧 __filename:', __filename);
10
+ console.log('🔧 __dirname:', __dirname);
11
+ console.log('🔧 process.cwd():', process.cwd());
12
+ console.log('🔧 process.execPath:', process.execPath);
13
+ console.log('🔧 process.argv:', JSON.stringify(process.argv));
14
+ console.log('🔧 process.env.NODE_ENV:', process.env.NODE_ENV);
15
+ console.log('🔧 process.env.npm_config_prefix:', process.env.npm_config_prefix);
16
+ console.log('🔧 process.env.PATH (first 200 chars):', process.env.PATH?.substring(0, 200) + '...');
7
17
  const commander_1 = require("commander");
8
18
  const login_1 = require("./commands/login");
9
19
  const install_1 = require("./commands/install");
@@ -32,7 +42,7 @@ program
32
42
  .description('Login to Cursor Kit backend')
33
43
  .option('-e, --email <email>', 'Email address')
34
44
  .option('-p, --password <password>', 'Password')
35
- .option('-s, --server <url>', 'Backend server URL', 'http://localhost:3000')
45
+ .option('-s, --server <url>', 'Backend server URL')
36
46
  .action(login_1.loginCommand);
37
47
  program
38
48
  .command('install')
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "kitstore-cli",
3
- "version": "1.0.97",
3
+ "version": "1.0.103",
4
4
  "description": "CLI tool for Cursor Kit",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
- "kitstore": "./dist/index.js"
7
+ "kitstore": "dist/index.js"
8
8
  },
9
9
  "files": [
10
10
  "dist/",
11
11
  "default-config.json"
12
12
  ],
13
13
  "scripts": {
14
- "build": "tsc",
14
+ "build": "tsc && chmod +x dist/index.js",
15
15
  "dev": "tsx src/index.ts",
16
16
  "start": "node dist/index.js",
17
17
  "generate:api": "openapi-generator-cli generate -i ../backend/openapi/openapi.json -g typescript-axios -o src/api/generated --additional-properties=supportsES6=true,withInterfaces=true",
@@ -28,7 +28,8 @@
28
28
  "test:regression:cov": "jest tests/regression/ --coverage --coveragePathIgnorePatterns=node_modules",
29
29
  "test:all": "npm run test:unit && npm run test:e2e && npm run test:published",
30
30
  "test:watch": "jest --watch",
31
- "test:cov": "jest --coverage"
31
+ "test:cov": "jest --coverage",
32
+ "postinstall": "chmod +x dist/index.js || true"
32
33
  },
33
34
  "dependencies": {
34
35
  "axios": "^1.6.2",