@sylphai/adal-cli 0.5.0-beta.2 → 0.5.0-beta.3

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/bin/adal-cli.js CHANGED
@@ -52,8 +52,18 @@ function loadCachedPath() {
52
52
  try {
53
53
  if (fs.existsSync(cacheFile)) {
54
54
  const cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
55
- // Verify the cached path still exists
55
+ // Verify the cached path still exists AND points to wrapper (not adal-cli.js)
56
+ const expectedWrapper = platform === 'win32' ? 'adal.cmd' : 'adal';
56
57
  if (cache.path && fs.existsSync(cache.path)) {
58
+ // CRITICAL: Reject cache if it points to adal-cli.js (stale Bun migration cache)
59
+ if (cache.path.endsWith('adal-cli.js')) {
60
+ // Stale cache from before Bun migration - must find wrapper instead
61
+ return null;
62
+ }
63
+ // Verify path ends with expected wrapper name
64
+ if (!cache.path.endsWith(expectedWrapper)) {
65
+ return null;
66
+ }
57
67
  // Check if it's been less than 30 days since last cache
58
68
  const cacheAge = Date.now() - cache.timestamp;
59
69
  if (cacheAge < 30 * 24 * 60 * 60 * 1000) { // 30 days in milliseconds
@@ -69,6 +79,7 @@ function loadCachedPath() {
69
79
 
70
80
  // Save path to cache
71
81
  function saveCachedPath(platformPath) {
82
+ const expectedWrapper = platform === 'win32' ? 'adal.cmd' : 'adal';
72
83
  try {
73
84
  if (!fs.existsSync(cacheDir)) {
74
85
  fs.mkdirSync(cacheDir, { recursive: true });
@@ -77,6 +88,7 @@ function saveCachedPath(platformPath) {
77
88
  path: platformPath,
78
89
  platform: platformKey,
79
90
  package: packageName,
91
+ wrapperType: expectedWrapper,
80
92
  timestamp: Date.now()
81
93
  }, null, 2));
82
94
  } catch (e) {
@@ -100,15 +112,13 @@ function findPlatformPackage() {
100
112
  // Look for the 'adal' wrapper script (not adal-cli.js) which uses bundled Bun
101
113
  const wrapperName = platform === 'win32' ? 'adal.cmd' : 'adal';
102
114
  const possiblePaths = [
103
- // When installed globally
104
- path.join(__dirname, '..', '..', packageName, wrapperName),
115
+ // When installed globally - platform package is in main package's node_modules
116
+ path.join(__dirname, '..', 'node_modules', packageName, wrapperName),
105
117
  // When installed locally in a project
106
118
  path.join(process.cwd(), 'node_modules', packageName, wrapperName),
107
- // When running from development
108
- path.join(__dirname, '..', 'node_modules', packageName, wrapperName),
109
- // Alternative global location
110
- require.resolve.paths(packageName).map(p => path.join(p, packageName, wrapperName)).filter(Boolean)
111
- ].flat();
119
+ // Alternative: sibling in global node_modules (flat install)
120
+ path.join(__dirname, '..', '..', '..', packageName, wrapperName),
121
+ ];
112
122
 
113
123
  for (const testPath of possiblePaths) {
114
124
  if (fs.existsSync(testPath)) {
@@ -35,30 +35,20 @@ const cacheFile = path.join(cacheDir, 'platform-path.json');
35
35
 
36
36
  // Find the platform package during installation
37
37
  function findAndCachePlatformPackage() {
38
+ // Look for wrapper script (uses bundled Bun), not adal-cli.js
39
+ const wrapperName = platform === 'win32' ? 'adal.cmd' : 'adal';
38
40
  const possiblePaths = [
39
- // When installed globally
40
- path.join(__dirname, '..', '..', packageName, 'adal-cli.js'),
41
+ // When installed globally - platform package is in main package's node_modules
42
+ path.join(__dirname, '..', 'node_modules', packageName, wrapperName),
41
43
  // When installed locally in a project
42
- path.join(process.cwd(), 'node_modules', packageName, 'adal-cli.js'),
43
- // When running from development
44
- path.join(__dirname, '..', 'node_modules', packageName, 'adal-cli.js'),
44
+ path.join(process.cwd(), 'node_modules', packageName, wrapperName),
45
+ // Alternative: sibling in global node_modules (flat install)
46
+ path.join(__dirname, '..', '..', '..', packageName, wrapperName),
45
47
  ];
46
48
 
47
- // Also check require.resolve paths
48
- try {
49
- const resolvePaths = require.resolve.paths(packageName);
50
- if (resolvePaths) {
51
- resolvePaths.forEach(p => {
52
- possiblePaths.push(path.join(p, packageName, 'adal-cli.js'));
53
- });
54
- }
55
- } catch (e) {
56
- // Ignore errors
57
- }
58
-
59
49
  for (const testPath of possiblePaths) {
60
50
  if (fs.existsSync(testPath)) {
61
- // Found the platform package, cache it
51
+ // Found the platform wrapper, cache it
62
52
  try {
63
53
  if (!fs.existsSync(cacheDir)) {
64
54
  fs.mkdirSync(cacheDir, { recursive: true });
@@ -67,13 +57,14 @@ function findAndCachePlatformPackage() {
67
57
  path: testPath,
68
58
  platform: platformKey,
69
59
  package: packageName,
60
+ wrapperType: wrapperName,
70
61
  timestamp: Date.now(),
71
62
  installedAt: new Date().toISOString()
72
63
  }, null, 2));
73
- console.log(`✅ Cached platform package path: ${packageName}`);
64
+ console.log(`✅ Cached platform wrapper path: ${packageName}/${wrapperName}`);
74
65
  } catch (e) {
75
66
  // Cache write failed, not critical
76
- console.log(`⚠️ Could not cache platform package path: ${e.message}`);
67
+ console.log(`⚠️ Could not cache platform wrapper path: ${e.message}`);
77
68
  }
78
69
  return;
79
70
  }
@@ -82,7 +73,7 @@ function findAndCachePlatformPackage() {
82
73
  // Try using require.resolve as last resort
83
74
  try {
84
75
  const packagePath = require.resolve(`${packageName}/package.json`);
85
- const platformBinary = path.join(path.dirname(packagePath), 'adal-cli.js');
76
+ const platformBinary = path.join(path.dirname(packagePath), wrapperName);
86
77
  if (fs.existsSync(platformBinary)) {
87
78
  // Cache the found path
88
79
  if (!fs.existsSync(cacheDir)) {
@@ -92,10 +83,11 @@ function findAndCachePlatformPackage() {
92
83
  path: platformBinary,
93
84
  platform: platformKey,
94
85
  package: packageName,
86
+ wrapperType: wrapperName,
95
87
  timestamp: Date.now(),
96
88
  installedAt: new Date().toISOString()
97
89
  }, null, 2));
98
- console.log(`✅ Cached platform package path: ${packageName}`);
90
+ console.log(`✅ Cached platform wrapper path: ${packageName}/${wrapperName}`);
99
91
  }
100
92
  } catch (e) {
101
93
  // Platform package not found during install, will be found at runtime
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphai/adal-cli",
3
- "version": "0.5.0-beta.2",
3
+ "version": "0.5.0-beta.3",
4
4
  "description": "AI-powered CLI for development and research tasks",
5
5
  "bin": {
6
6
  "adal": "bin/adal-cli.js"
@@ -9,10 +9,10 @@
9
9
  "postinstall": "node lib/setup-cache.js"
10
10
  },
11
11
  "optionalDependencies": {
12
- "@sylphai/adal-cli-darwin-arm64": "0.5.0-beta.2",
13
- "@sylphai/adal-cli-darwin-x64": "0.5.0-beta.2",
14
- "@sylphai/adal-cli-linux-x64": "0.5.0-beta.2",
15
- "@sylphai/adal-cli-win32-x64": "0.5.0-beta.2"
12
+ "@sylphai/adal-cli-darwin-arm64": "0.5.0-beta.3",
13
+ "@sylphai/adal-cli-darwin-x64": "0.5.0-beta.3",
14
+ "@sylphai/adal-cli-linux-x64": "0.5.0-beta.3",
15
+ "@sylphai/adal-cli-win32-x64": "0.5.0-beta.3"
16
16
  },
17
17
  "files": [
18
18
  "bin/",