@arcteninc/core 0.0.58 → 0.0.60

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.
@@ -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: \x1b[36mnpx arcten update\x1b[0m`);
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,124 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Manual update command for @arcteninc/core
4
+ * Usage: arcten update
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 to \x1b[32m^${latestVersion}\x1b[0m in package.json\n`);
68
+ return true;
69
+ }
70
+
71
+ return false;
72
+ }
73
+
74
+ function main() {
75
+ const packageJsonPath = findPackageJson();
76
+ if (!packageJsonPath) {
77
+ console.error('❌ Could not find package.json');
78
+ process.exit(1);
79
+ }
80
+
81
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
82
+ const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
83
+ const currentVersion = deps['@arcteninc/core'];
84
+
85
+ if (!currentVersion) {
86
+ console.error('❌ @arcteninc/core not found in dependencies');
87
+ process.exit(1);
88
+ }
89
+
90
+ const latestVersion = getLatestVersion();
91
+ if (!latestVersion) {
92
+ process.exit(1);
93
+ }
94
+
95
+ const currentVersionMatch = currentVersion.match(/(\d+\.\d+\.\d+)/);
96
+ if (!currentVersionMatch) {
97
+ console.error('❌ Invalid version format:', currentVersion);
98
+ process.exit(1);
99
+ }
100
+
101
+ const current = currentVersionMatch[1];
102
+
103
+ if (current === latestVersion) {
104
+ console.log(`\n✅ Already on latest version: \x1b[32m${latestVersion}\x1b[0m\n`);
105
+ return;
106
+ }
107
+
108
+ console.log(`\n📦 Updating @arcteninc/core\n`);
109
+ console.log(` Current: \x1b[33m${current}\x1b[0m`);
110
+ console.log(` Latest: \x1b[32m${latestVersion}\x1b[0m\n`);
111
+
112
+ if (updateVersion(packageJsonPath, packageJson, latestVersion)) {
113
+ console.log(`💡 Next steps:`);
114
+ console.log(` 1. Review the changes in package.json`);
115
+ console.log(` 2. Run \x1b[36mnpm install\x1b[0m to install the update\n`);
116
+ }
117
+ }
118
+
119
+ if (require.main === module) {
120
+ main();
121
+ }
122
+
123
+ module.exports = { main };
124
+