stacktape 2.24.0-beta.25 → 2.24.0-rc.2

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.
Files changed (2) hide show
  1. package/bin/stacktape.js +16 -43
  2. package/package.json +1 -1
package/bin/stacktape.js CHANGED
@@ -1,22 +1,20 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable */
2
3
 
3
4
  /**
4
5
  * Stacktape CLI launcher
5
6
  * Downloads and caches the platform-specific binary on first run
6
7
  */
7
-
8
8
  const { spawnSync, execSync } = require('node:child_process');
9
9
  const { createWriteStream, existsSync, chmodSync, mkdirSync } = require('node:fs');
10
10
  const { get: httpsGet } = require('node:https');
11
11
  const { platform, arch, homedir } = require('node:os');
12
12
  const { join } = require('node:path');
13
13
 
14
- // Get version from package.json
15
14
  const PACKAGE_VERSION = require('../package.json').version;
16
15
 
17
16
  const GITHUB_REPO = 'stacktape/stacktape';
18
17
 
19
- // Platform detection and mapping
20
18
  const PLATFORM_MAP = {
21
19
  'win32-x64': { fileName: 'windows.zip', extract: extractZip },
22
20
  'linux-x64': { fileName: 'linux.tar.gz', extract: extractTarGz },
@@ -26,10 +24,7 @@ const PLATFORM_MAP = {
26
24
  'linux-x64-musl': { fileName: 'alpine.tar.gz', extract: extractTarGz }
27
25
  };
28
26
 
29
- /**
30
- * Detects the current platform
31
- */
32
- function detectPlatform() {
27
+ const detectPlatform = () => {
33
28
  const currentPlatform = platform();
34
29
  const currentArch = arch();
35
30
 
@@ -57,12 +52,9 @@ function detectPlatform() {
57
52
  }
58
53
 
59
54
  return platformKey;
60
- }
55
+ };
61
56
 
62
- /**
63
- * Downloads a file from a URL with retry logic
64
- */
65
- async function downloadFile(url, destPath, retries = 3) {
57
+ const downloadFile = async (url, destPath, retries = 3) => {
66
58
  for (let i = 0; i < retries; i++) {
67
59
  try {
68
60
  await new Promise((resolve, reject) => {
@@ -127,32 +119,25 @@ async function downloadFile(url, destPath, retries = 3) {
127
119
  console.info(`\nRetrying download (${i + 1}/${retries})...`);
128
120
  }
129
121
  }
130
- }
122
+ };
131
123
 
132
- /**
133
- * Extracts a tar.gz archive
134
- */
135
- async function extractTarGz(archivePath, destDir) {
124
+ // lazy load only when needed
125
+ const extractTarGz = async (archivePath, destDir) => {
136
126
  const tar = require('tar');
137
127
  await tar.x({
138
128
  file: archivePath,
139
129
  cwd: destDir
140
130
  });
141
- }
131
+ };
142
132
 
143
- /**
144
- * Extracts a zip archive
145
- */
146
- async function extractZip(archivePath, destDir) {
133
+ // lazy load only when needed
134
+ const extractZip = async (archivePath, destDir) => {
147
135
  const AdmZip = require('adm-zip');
148
136
  const zip = new AdmZip(archivePath);
149
137
  zip.extractAllTo(destDir, true);
150
- }
138
+ };
151
139
 
152
- /**
153
- * Sets executable permissions on Unix systems
154
- */
155
- function setExecutablePermissions(binDir) {
140
+ const setExecutablePermissions = (binDir) => {
156
141
  if (platform() === 'win32') {
157
142
  return; // Windows doesn't need chmod
158
143
  }
@@ -174,54 +159,42 @@ function setExecutablePermissions(binDir) {
174
159
  }
175
160
  }
176
161
  }
177
- }
162
+ };
178
163
 
179
- /**
180
- * Ensures the binary is downloaded and cached
181
- */
182
- async function ensureBinary() {
164
+ const ensureBinary = async () => {
183
165
  const platformKey = detectPlatform();
184
166
  const platformInfo = PLATFORM_MAP[platformKey];
185
167
  const version = PACKAGE_VERSION;
186
168
 
187
- // Cache directory: ~/.stacktape/bin/{version}/
188
169
  const cacheDir = join(homedir(), '.stacktape', 'bin', version);
189
170
  const binaryName = platform() === 'win32' ? 'stacktape.exe' : 'stacktape';
190
171
  const binaryPath = join(cacheDir, binaryName);
191
172
 
192
- // Check if binary is already cached
193
173
  if (existsSync(binaryPath)) {
194
174
  return binaryPath;
195
175
  }
196
176
 
197
- console.info(`Installing Stacktape ${version} for ${platformKey}...`);
177
+ console.info(`Stacktape binary not found. Installing version ${version} for ${platformKey}...`);
198
178
 
199
- // Create cache directory
200
179
  if (!existsSync(cacheDir)) {
201
180
  mkdirSync(cacheDir, { recursive: true });
202
181
  }
203
182
 
204
- // Download URL
205
183
  const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/${version}/${platformInfo.fileName}`;
206
184
  const archivePath = join(cacheDir, platformInfo.fileName);
207
185
 
208
186
  try {
209
- // Download the archive
210
187
  console.info(`Downloading from ${downloadUrl}...`);
211
188
  await downloadFile(downloadUrl, archivePath);
212
189
 
213
- // Extract the archive
214
190
  console.info('Extracting...');
215
191
  await platformInfo.extract(archivePath, cacheDir);
216
192
 
217
- // Set executable permissions
218
193
  setExecutablePermissions(cacheDir);
219
194
 
220
- // Remove the archive
221
195
  const { unlinkSync } = require('node:fs');
222
196
  unlinkSync(archivePath);
223
197
 
224
- // Verify the binary exists
225
198
  if (!existsSync(binaryPath)) {
226
199
  throw new Error(`Binary not found after extraction: ${binaryPath}`);
227
200
  }
@@ -238,7 +211,7 @@ You can also install Stacktape directly using:
238
211
  ${getManualInstallCommand(platformKey)}`);
239
212
  process.exit(1);
240
213
  }
241
- }
214
+ };
242
215
 
243
216
  /**
244
217
  * Gets the manual installation command for the platform
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stacktape",
3
- "version": "2.24.0-beta.25",
3
+ "version": "2.24.0-rc.2",
4
4
  "description": "PaaS 2.0 that deploys to your own AWS account.",
5
5
  "author": "Stacktape team <support@stacktape.com>",
6
6
  "license": "MIT",