@arcteninc/core 0.0.57 → 0.0.59
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/components/ArctenAgent.d.ts.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.mjs +2211 -2278
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/package.json +8 -4
- package/scripts/cli-extract-types-auto.js +93 -93
- package/scripts/cli-extract-types-auto.ts +45 -19
- package/scripts/postinstall-check-version.js +157 -0
- package/scripts/update-core.js +125 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/lib/useAgent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAGf,MAAM,oBAAoB,CAAC;AAoE5B,wBAAgB,QAAQ,CAAC,EACvB,UAAqC,EACrC,aAAmC,EACnC,WAAW,EAAE,aAAa,EAC1B,cAAsB,EACtB,IAAI,EACJ,KAAU,EACV,SAAc,EACd,YAAY,EACZ,YAAiB,EACjB,eAAoB,EACpB,cAAc,EAAE,qBAAqB,EACrC,UAAU,EACV,QAAQ,EACR,UAAU,GACX,GAAE,eAAoB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/lib/useAgent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAGf,MAAM,oBAAoB,CAAC;AAoE5B,wBAAgB,QAAQ,CAAC,EACvB,UAAqC,EACrC,aAAmC,EACnC,WAAW,EAAE,aAAa,EAC1B,cAAsB,EACtB,IAAI,EACJ,KAAU,EACV,SAAc,EACd,YAAY,EACZ,YAAiB,EACjB,eAAoB,EACpB,cAAc,EAAE,qBAAqB,EACrC,UAAU,EACV,QAAQ,EACR,UAAU,GACX,GAAE,eAAoB,GAAG,cAAc,CAuZvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcteninc/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,17 +20,21 @@
|
|
|
20
20
|
},
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"bin": {
|
|
23
|
-
"arcten-extract-types": "./scripts/cli-extract-types-auto.js"
|
|
23
|
+
"arcten-extract-types": "./scripts/cli-extract-types-auto.js",
|
|
24
|
+
"arcten-update-core": "./scripts/update-core.js"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"dist",
|
|
27
28
|
"scripts/cli-extract-types-auto.ts",
|
|
28
|
-
"scripts/cli-extract-types-auto.js"
|
|
29
|
+
"scripts/cli-extract-types-auto.js",
|
|
30
|
+
"scripts/postinstall-check-version.js",
|
|
31
|
+
"scripts/update-core.js"
|
|
29
32
|
],
|
|
30
33
|
"scripts": {
|
|
31
34
|
"dev": "vite build --watch",
|
|
32
35
|
"build": "vite build",
|
|
33
|
-
"prepublishOnly": "bun run build"
|
|
36
|
+
"prepublishOnly": "bun run build",
|
|
37
|
+
"postinstall": "node scripts/postinstall-check-version.js"
|
|
34
38
|
},
|
|
35
39
|
"peerDependencies": {
|
|
36
40
|
"ai": "^6.0.0-beta.94",
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Wrapper script to run the TypeScript CLI
|
|
4
|
-
* Works with Node.js - no bun required!
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { spawn } from 'child_process';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
import { dirname, resolve } from 'path';
|
|
10
|
-
import { existsSync } from 'fs';
|
|
11
|
-
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = dirname(__filename);
|
|
14
|
-
|
|
15
|
-
// Path to the TypeScript script - resolve relative to this wrapper
|
|
16
|
-
const tsScript = resolve(__dirname, 'cli-extract-types-auto.ts');
|
|
17
|
-
|
|
18
|
-
// Check if a command is available
|
|
19
|
-
function checkCommand(cmd) {
|
|
20
|
-
return new Promise((resolve) => {
|
|
21
|
-
const check = spawn(cmd, ['--version'], { stdio: 'ignore', shell: true });
|
|
22
|
-
check.on('close', (code) => {
|
|
23
|
-
resolve(code === 0);
|
|
24
|
-
});
|
|
25
|
-
check.on('error', () => {
|
|
26
|
-
resolve(false);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function main() {
|
|
32
|
-
if (!existsSync(tsScript)) {
|
|
33
|
-
console.error(`❌ Error: Script not found at ${tsScript}`);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const args = process.argv.slice(2);
|
|
38
|
-
|
|
39
|
-
// Check for bun first (faster and preferred if available)
|
|
40
|
-
const hasBun = await checkCommand('bun');
|
|
41
|
-
|
|
42
|
-
if (hasBun) {
|
|
43
|
-
// Use bun directly - it's faster and can run TypeScript natively
|
|
44
|
-
const bunProcess = spawn('bun', [tsScript, ...args], {
|
|
45
|
-
stdio: 'inherit',
|
|
46
|
-
shell: true
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
bunProcess.on('close', (code) => {
|
|
50
|
-
process.exit(code || 0);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
bunProcess.on('error', (err) => {
|
|
54
|
-
// If bun fails, try tsx as fallback
|
|
55
|
-
tryTsxFallback(args);
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
// Fallback to tsx via npx if bun isn't available
|
|
59
|
-
tryTsxFallback(args);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function tryTsxFallback(args) {
|
|
64
|
-
const hasNpx = await checkCommand('npx');
|
|
65
|
-
|
|
66
|
-
if (hasNpx) {
|
|
67
|
-
// Use tsx via npx - it's lightweight and works great with Node.js
|
|
68
|
-
const tsxProcess = spawn('npx', ['-y', 'tsx', tsScript, ...args], {
|
|
69
|
-
stdio: 'inherit',
|
|
70
|
-
shell: true
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
tsxProcess.on('close', (code) => {
|
|
74
|
-
process.exit(code || 0);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
tsxProcess.on('error', (err) => {
|
|
78
|
-
console.error('❌ Error: Could not run script');
|
|
79
|
-
console.error('Please ensure you have Node.js (with npx) or bun installed');
|
|
80
|
-
process.exit(1);
|
|
81
|
-
});
|
|
82
|
-
} else {
|
|
83
|
-
console.error('❌ Error: Could not find a TypeScript runner');
|
|
84
|
-
console.error('');
|
|
85
|
-
console.error('Please install one of the following:');
|
|
86
|
-
console.error(' - bun: curl -fsSL https://bun.sh/install | bash (recommended)');
|
|
87
|
-
console.error(' - Node.js (comes with npx)');
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
main();
|
|
93
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper script to run the TypeScript CLI
|
|
4
|
+
* Works with Node.js - no bun required!
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { spawn } from 'child_process';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname, resolve } from 'path';
|
|
10
|
+
import { existsSync } from 'fs';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
|
|
15
|
+
// Path to the TypeScript script - resolve relative to this wrapper
|
|
16
|
+
const tsScript = resolve(__dirname, 'cli-extract-types-auto.ts');
|
|
17
|
+
|
|
18
|
+
// Check if a command is available
|
|
19
|
+
function checkCommand(cmd) {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
const check = spawn(cmd, ['--version'], { stdio: 'ignore', shell: true });
|
|
22
|
+
check.on('close', (code) => {
|
|
23
|
+
resolve(code === 0);
|
|
24
|
+
});
|
|
25
|
+
check.on('error', () => {
|
|
26
|
+
resolve(false);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function main() {
|
|
32
|
+
if (!existsSync(tsScript)) {
|
|
33
|
+
console.error(`❌ Error: Script not found at ${tsScript}`);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const args = process.argv.slice(2);
|
|
38
|
+
|
|
39
|
+
// Check for bun first (faster and preferred if available)
|
|
40
|
+
const hasBun = await checkCommand('bun');
|
|
41
|
+
|
|
42
|
+
if (hasBun) {
|
|
43
|
+
// Use bun directly - it's faster and can run TypeScript natively
|
|
44
|
+
const bunProcess = spawn('bun', [tsScript, ...args], {
|
|
45
|
+
stdio: 'inherit',
|
|
46
|
+
shell: true
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
bunProcess.on('close', (code) => {
|
|
50
|
+
process.exit(code || 0);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
bunProcess.on('error', (err) => {
|
|
54
|
+
// If bun fails, try tsx as fallback
|
|
55
|
+
tryTsxFallback(args);
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
// Fallback to tsx via npx if bun isn't available
|
|
59
|
+
tryTsxFallback(args);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function tryTsxFallback(args) {
|
|
64
|
+
const hasNpx = await checkCommand('npx');
|
|
65
|
+
|
|
66
|
+
if (hasNpx) {
|
|
67
|
+
// Use tsx via npx - it's lightweight and works great with Node.js
|
|
68
|
+
const tsxProcess = spawn('npx', ['-y', 'tsx', tsScript, ...args], {
|
|
69
|
+
stdio: 'inherit',
|
|
70
|
+
shell: true
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
tsxProcess.on('close', (code) => {
|
|
74
|
+
process.exit(code || 0);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
tsxProcess.on('error', (err) => {
|
|
78
|
+
console.error('❌ Error: Could not run script');
|
|
79
|
+
console.error('Please ensure you have Node.js (with npx) or bun installed');
|
|
80
|
+
process.exit(1);
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
console.error('❌ Error: Could not find a TypeScript runner');
|
|
84
|
+
console.error('');
|
|
85
|
+
console.error('Please install one of the following:');
|
|
86
|
+
console.error(' - bun: curl -fsSL https://bun.sh/install | bash (recommended)');
|
|
87
|
+
console.error(' - Node.js (comes with npx)');
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main();
|
|
93
|
+
|
|
@@ -192,25 +192,10 @@ function extractToolNamesFromExpression(
|
|
|
192
192
|
const callExpr = node.expression;
|
|
193
193
|
if (ts.isIdentifier(callExpr)) {
|
|
194
194
|
const funcName = callExpr.text;
|
|
195
|
-
if (funcName === 'useMemo'
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (ts.isBlock(firstArg.body)) {
|
|
200
|
-
// Block body: () => { return [...] }
|
|
201
|
-
for (const stmt of firstArg.body.statements) {
|
|
202
|
-
if (ts.isReturnStatement(stmt) && stmt.expression) {
|
|
203
|
-
extractFromExpr(stmt.expression);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
// Expression body: () => [...]
|
|
208
|
-
extractFromExpr(firstArg.body);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
// Regular function call: useMemo(fn, [])
|
|
212
|
-
else if (ts.isFunctionExpression(firstArg) || ts.isArrowFunction(firstArg)) {
|
|
213
|
-
// Can't easily extract from function body without more analysis
|
|
195
|
+
if (funcName === 'useMemo') {
|
|
196
|
+
const memoizedExpr = extractToolsFromUseMemo(node, sourceFile, variableMap);
|
|
197
|
+
if (memoizedExpr) {
|
|
198
|
+
extractFromExpr(memoizedExpr);
|
|
214
199
|
}
|
|
215
200
|
}
|
|
216
201
|
}
|
|
@@ -230,6 +215,7 @@ function extractToolNamesFromExpression(
|
|
|
230
215
|
|
|
231
216
|
/**
|
|
232
217
|
* Build a map of variable declarations in the file
|
|
218
|
+
* Handles: const x = [...], const x = useMemo(...), etc.
|
|
233
219
|
*/
|
|
234
220
|
function buildVariableMap(sourceFile: ts.SourceFile): Map<string, ts.Expression> {
|
|
235
221
|
const variableMap = new Map<string, ts.Expression>();
|
|
@@ -258,6 +244,46 @@ function buildVariableMap(sourceFile: ts.SourceFile): Map<string, ts.Expression>
|
|
|
258
244
|
return variableMap;
|
|
259
245
|
}
|
|
260
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Extract tools from useMemo callback, handling both arrow functions and regular functions
|
|
249
|
+
*/
|
|
250
|
+
function extractToolsFromUseMemo(
|
|
251
|
+
useMemoCall: ts.CallExpression,
|
|
252
|
+
sourceFile: ts.SourceFile,
|
|
253
|
+
variableMap: Map<string, ts.Expression>
|
|
254
|
+
): ts.Expression | null {
|
|
255
|
+
if (useMemoCall.arguments.length === 0) return null;
|
|
256
|
+
|
|
257
|
+
const firstArg = useMemoCall.arguments[0];
|
|
258
|
+
|
|
259
|
+
// Arrow function: () => [...]
|
|
260
|
+
if (ts.isArrowFunction(firstArg)) {
|
|
261
|
+
if (firstArg.body) {
|
|
262
|
+
if (ts.isBlock(firstArg.body)) {
|
|
263
|
+
// Block body: () => { return [...] }
|
|
264
|
+
for (const stmt of firstArg.body.statements) {
|
|
265
|
+
if (ts.isReturnStatement(stmt) && stmt.expression) {
|
|
266
|
+
return stmt.expression;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
// Expression body: () => [...]
|
|
271
|
+
return firstArg.body;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// Regular function: function() { return [...] }
|
|
276
|
+
else if (ts.isFunctionExpression(firstArg) && firstArg.body) {
|
|
277
|
+
for (const stmt of firstArg.body.statements) {
|
|
278
|
+
if (ts.isReturnStatement(stmt) && stmt.expression) {
|
|
279
|
+
return stmt.expression;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
|
|
261
287
|
/**
|
|
262
288
|
* Extract tool names from ArctenAgent or useAgent usage
|
|
263
289
|
*/
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script to check and optionally update @arcteninc/core version
|
|
4
|
+
* This helps users stay on the latest version without manually updating package.json
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const { execSync } = require('child_process');
|
|
10
|
+
|
|
11
|
+
function findPackageJson(startPath = process.cwd()) {
|
|
12
|
+
let currentPath = startPath;
|
|
13
|
+
|
|
14
|
+
// Start from current directory and walk up to find package.json
|
|
15
|
+
// Skip node_modules directories
|
|
16
|
+
while (currentPath !== path.dirname(currentPath)) {
|
|
17
|
+
// Skip if we're in a node_modules directory
|
|
18
|
+
if (currentPath.includes('node_modules')) {
|
|
19
|
+
currentPath = path.dirname(currentPath);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const packageJsonPath = path.join(currentPath, 'package.json');
|
|
24
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
25
|
+
// Make sure this isn't @arcteninc/core's own package.json
|
|
26
|
+
try {
|
|
27
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
28
|
+
if (pkg.name === '@arcteninc/core') {
|
|
29
|
+
// This is the core package itself, go up one level
|
|
30
|
+
currentPath = path.dirname(currentPath);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// Invalid JSON, skip
|
|
35
|
+
currentPath = path.dirname(currentPath);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return packageJsonPath;
|
|
40
|
+
}
|
|
41
|
+
currentPath = path.dirname(currentPath);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getLatestVersion() {
|
|
48
|
+
try {
|
|
49
|
+
const output = execSync('npm view @arcteninc/core version', { encoding: 'utf-8', stdio: 'pipe' });
|
|
50
|
+
return output.trim();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.warn('⚠️ Could not check latest version:', error.message);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getInstalledVersion() {
|
|
58
|
+
try {
|
|
59
|
+
const packageJsonPath = findPackageJson();
|
|
60
|
+
if (!packageJsonPath) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
65
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
66
|
+
const version = deps['@arcteninc/core'];
|
|
67
|
+
|
|
68
|
+
return version ? { version, packageJsonPath, packageJson } : null;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Removed auto-update function - users should update manually
|
|
75
|
+
|
|
76
|
+
function main() {
|
|
77
|
+
// Find the user's project root (not node_modules/@arcteninc/core)
|
|
78
|
+
// Walk up from current directory to find package.json that uses @arcteninc/core
|
|
79
|
+
let projectRoot = process.cwd();
|
|
80
|
+
|
|
81
|
+
// If we're in node_modules/@arcteninc/core, go up to project root
|
|
82
|
+
if (projectRoot.includes('node_modules')) {
|
|
83
|
+
// Find the project root by looking for package.json that's not @arcteninc/core
|
|
84
|
+
const parts = projectRoot.split(path.sep);
|
|
85
|
+
const nodeModulesIndex = parts.indexOf('node_modules');
|
|
86
|
+
if (nodeModulesIndex !== -1) {
|
|
87
|
+
projectRoot = parts.slice(0, nodeModulesIndex).join(path.sep);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Change to project root to find package.json
|
|
92
|
+
const originalCwd = process.cwd();
|
|
93
|
+
try {
|
|
94
|
+
process.chdir(projectRoot);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
// Can't change directory, use original
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Only run if we're in a project that uses @arcteninc/core
|
|
100
|
+
const installed = getInstalledVersion();
|
|
101
|
+
if (!installed) {
|
|
102
|
+
process.chdir(originalCwd);
|
|
103
|
+
return; // Not installed, nothing to do
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const latestVersion = getLatestVersion();
|
|
107
|
+
if (!latestVersion) {
|
|
108
|
+
try {
|
|
109
|
+
process.chdir(originalCwd);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
// Ignore
|
|
112
|
+
}
|
|
113
|
+
return; // Couldn't check, skip
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Extract current version number (remove ^, ~, etc.)
|
|
117
|
+
const currentVersionMatch = installed.version.match(/(\d+\.\d+\.\d+)/);
|
|
118
|
+
if (!currentVersionMatch) {
|
|
119
|
+
try {
|
|
120
|
+
process.chdir(originalCwd);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
// Ignore
|
|
123
|
+
}
|
|
124
|
+
return; // Invalid version format
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const currentVersion = currentVersionMatch[1];
|
|
128
|
+
|
|
129
|
+
if (currentVersion !== latestVersion) {
|
|
130
|
+
console.log(`\n📦 @arcteninc/core update available:`);
|
|
131
|
+
console.log(` Current: ${currentVersion}`);
|
|
132
|
+
console.log(` Latest: ${latestVersion}`);
|
|
133
|
+
|
|
134
|
+
if (installed.version.startsWith('^') || installed.version.startsWith('~')) {
|
|
135
|
+
console.log(` Run 'npm update @arcteninc/core' to update within your version range`);
|
|
136
|
+
} else {
|
|
137
|
+
console.log(` Consider updating to '^${latestVersion}' in package.json`);
|
|
138
|
+
console.log(` Then run 'npm install' to get the latest version`);
|
|
139
|
+
}
|
|
140
|
+
console.log(` Or use: npx arcten-update-core`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Restore original directory
|
|
144
|
+
try {
|
|
145
|
+
process.chdir(originalCwd);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
// Ignore
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Only run if called directly (not when required)
|
|
152
|
+
if (require.main === module) {
|
|
153
|
+
main();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = { main, getLatestVersion, getInstalledVersion, findPackageJson };
|
|
157
|
+
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Manual update command for @arcteninc/core
|
|
4
|
+
* Usage: npx arcten-update-core
|
|
5
|
+
*
|
|
6
|
+
* This allows users to explicitly update their package.json
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { execSync } = require('child_process');
|
|
12
|
+
|
|
13
|
+
function findPackageJson(startPath = process.cwd()) {
|
|
14
|
+
let currentPath = startPath;
|
|
15
|
+
|
|
16
|
+
while (currentPath !== path.dirname(currentPath)) {
|
|
17
|
+
if (currentPath.includes('node_modules')) {
|
|
18
|
+
currentPath = path.dirname(currentPath);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const packageJsonPath = path.join(currentPath, 'package.json');
|
|
23
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
24
|
+
try {
|
|
25
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
26
|
+
if (pkg.name === '@arcteninc/core') {
|
|
27
|
+
currentPath = path.dirname(currentPath);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
} catch (e) {
|
|
31
|
+
currentPath = path.dirname(currentPath);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return packageJsonPath;
|
|
36
|
+
}
|
|
37
|
+
currentPath = path.dirname(currentPath);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getLatestVersion() {
|
|
44
|
+
try {
|
|
45
|
+
const output = execSync('npm view @arcteninc/core version', { encoding: 'utf-8', stdio: 'pipe' });
|
|
46
|
+
return output.trim();
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('❌ Could not check latest version:', error.message);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function updateVersion(packageJsonPath, packageJson, latestVersion) {
|
|
54
|
+
let updated = false;
|
|
55
|
+
|
|
56
|
+
if (packageJson.dependencies && packageJson.dependencies['@arcteninc/core']) {
|
|
57
|
+
packageJson.dependencies['@arcteninc/core'] = `^${latestVersion}`;
|
|
58
|
+
updated = true;
|
|
59
|
+
}
|
|
60
|
+
if (packageJson.devDependencies && packageJson.devDependencies['@arcteninc/core']) {
|
|
61
|
+
packageJson.devDependencies['@arcteninc/core'] = `^${latestVersion}`;
|
|
62
|
+
updated = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (updated) {
|
|
66
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
67
|
+
console.log(`✅ Updated @arcteninc/core to ^${latestVersion} in package.json`);
|
|
68
|
+
console.log(` Run 'npm install' to install the latest version`);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function main() {
|
|
76
|
+
const packageJsonPath = findPackageJson();
|
|
77
|
+
if (!packageJsonPath) {
|
|
78
|
+
console.error('❌ Could not find package.json');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
83
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
84
|
+
const currentVersion = deps['@arcteninc/core'];
|
|
85
|
+
|
|
86
|
+
if (!currentVersion) {
|
|
87
|
+
console.error('❌ @arcteninc/core not found in dependencies');
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const latestVersion = getLatestVersion();
|
|
92
|
+
if (!latestVersion) {
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const currentVersionMatch = currentVersion.match(/(\d+\.\d+\.\d+)/);
|
|
97
|
+
if (!currentVersionMatch) {
|
|
98
|
+
console.error('❌ Invalid version format:', currentVersion);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const current = currentVersionMatch[1];
|
|
103
|
+
|
|
104
|
+
if (current === latestVersion) {
|
|
105
|
+
console.log(`✅ Already on latest version: ${latestVersion}`);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log(`📦 Updating @arcteninc/core:`);
|
|
110
|
+
console.log(` Current: ${current}`);
|
|
111
|
+
console.log(` Latest: ${latestVersion}`);
|
|
112
|
+
|
|
113
|
+
if (updateVersion(packageJsonPath, packageJson, latestVersion)) {
|
|
114
|
+
console.log(`\n💡 Next steps:`);
|
|
115
|
+
console.log(` 1. Review the changes in package.json`);
|
|
116
|
+
console.log(` 2. Run 'npm install' to install the update`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (require.main === module) {
|
|
121
|
+
main();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = { main };
|
|
125
|
+
|