Skip to content

Commit bbeb194

Browse files
authored
Merge pull request #147 from akamai/bugfix/fix-windows-issues
Bugfix/fix windows issues
2 parents ed6ca52 + 1210531 commit bbeb194

6 files changed

Lines changed: 42 additions & 32 deletions

File tree

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "akamai-sandbox-cli",
3-
"version": "1.8.0",
3+
"version": "1.8.1",
44
"description": "A tool that makes it easier to manage Akamai Sandboxes. Call the Sandbox API from the command line.",
55
"repository": "https://github.com/akamai/cli-sandbox",
66
"license": "Apache-2.0",
@@ -28,7 +28,7 @@
2828
"easy-table": "1.2.0",
2929
"find-java-home": "2.0.0",
3030
"fs-extra": "^11.3.0",
31-
"glob": "^11.0.3",
31+
"glob": "^11.1.0",
3232
"got": "^14.4.7",
3333
"inquirer": "^12.9.1",
3434
"jsonschema": "1.5.0",
@@ -38,7 +38,7 @@
3838
"shelljs": "0.9.2",
3939
"untildify": "5.0.0",
4040
"uuid": "11.1.0",
41-
"validator": "13.15.0"
41+
"validator": "13.15.23"
4242
},
4343
"devDependencies": {
4444
"@types/lodash": "4.17.16",

src/cli-main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,9 @@ async function pullEdgeWorkerFromSandbox(sandboxId, edgeworkerId) {
645645

646646
async function makeFileForEdgeworker(edgeworkerId, hexFile) {
647647
let edgeworkerFolder = path.join(CLI_CACHE_PATH!,
648-
`sandbox-cli/sandboxes`,
648+
'sandbox-cli', 'sandboxes',
649649
sandboxClientManager.getCurrentSandboxName()!,
650-
'edgeworkers/');
650+
'edgeworkers');
651651
if (!fs.existsSync(edgeworkerFolder)) {
652652
fs.mkdirSync(edgeworkerFolder);
653653
}

src/service/sandbox-client-manager.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ if (!fs.existsSync(CLI_CACHE_PATH)) {
2424
}
2525

2626
const GITHUB_API_URL = 'https://api.github.com/repos/akamai/sandbox-client/releases/latest';
27-
const SANDBOX_CLI_HOME = path.join(CLI_CACHE_PATH, '/sandbox-cli/');
28-
const DOWNLOAD_DIR = path.join(SANDBOX_CLI_HOME, '/downloads/');
29-
const SANDBOXES_DIR = path.join(SANDBOX_CLI_HOME, '/sandboxes/');
30-
const DATASTORE_FILE_PATH = path.join(SANDBOX_CLI_HOME + '.datastore');
27+
const SANDBOX_CLI_HOME = path.join(CLI_CACHE_PATH, 'sandbox-cli');
28+
const DOWNLOAD_DIR = path.join(SANDBOX_CLI_HOME, 'downloads');
29+
const SANDBOXES_DIR = path.join(SANDBOX_CLI_HOME, 'sandboxes');
30+
const DATASTORE_FILE_PATH = path.join(SANDBOX_CLI_HOME, '.datastore');
3131

3232
let cachedGithubResponse: any | null = null;
3333

@@ -82,7 +82,7 @@ async function findLatestJar(): Promise<{ path: string; version: string } | null
8282
'sandbox-client-*-RELEASE',
8383
'lib',
8484
'sandbox-client-*-RELEASE.jar'
85-
);
85+
).replace(/\\/g, '/');
8686

8787
const matches = await glob(pattern);
8888
if (matches.length === 0) return null;
@@ -151,11 +151,18 @@ export async function downloadClient() {
151151
}
152152

153153

154-
function unzipClient(filePath:string) {
155-
const CLIENT_INSTALL_PATH = filePath.replace("download/", '').replace("-default.zip", "");
154+
function unzipClient(filePath: string) {
155+
// Extract the version from the filename
156+
const match = filePath.match(/sandbox-client-(\d+\.\d+\.\d+)-RELEASE-default\.zip$/);
157+
if (!match) {
158+
cliUtils.logAndExit(1, `Could not determine client version from file name: ${filePath}`);
159+
}
160+
const version = match[1];
161+
const CLIENT_INSTALL_PATH = path.join(SANDBOX_CLI_HOME, `sandbox-client-${version}-RELEASE`);
156162
console.log(`Installing to ${CLIENT_INSTALL_PATH}`);
157-
return decompress(filePath, SANDBOX_CLI_HOME, {
158-
filter: file => !file.path.endsWith('/') // skip listing directories: https://github.com/kevva/decompress/issues/46
163+
// Filter out directories when decompressing. See https://github.com/kevva/decompress/issues/46
164+
return decompress(filePath, CLIENT_INSTALL_PATH, {
165+
filter: file => !file.path.endsWith('/')
159166
});
160167
}
161168

@@ -237,7 +244,7 @@ export function getSandboxLocalData(sandboxId: string) {
237244
}
238245

239246
function getLogPath() {
240-
return path.join(getCurrentSandboxFolder(), '/logs')
247+
return path.join(getCurrentSandboxFolder(), 'logs')
241248
}
242249

243250
export function flushLocalSandbox(sandboxId: string) {
@@ -277,7 +284,10 @@ export async function executeSandboxClient(printLogs) {
277284
const loggingPath = getLogPath();
278285
const loggingFilePath = path.join(loggingPath, 'sandbox-client.log');
279286
const configPath = path.join(getCurrentSandboxFolder(), 'config.json');
280-
const latestJar = (await findLatestJar())!;
287+
const latestJar = await findLatestJar();
288+
if (!latestJar) {
289+
cliUtils.logAndExit(1, 'Unable to find Sandbox Client JAR file. Please try to reinstall sandbox-cli and contact support.');
290+
}
281291
const loggingConfigPath = path.join(path.dirname(path.dirname(latestJar.path)), 'conf', 'logback.xml');
282292

283293
const springProfiles:string[] = [];

src/service/sandbox-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class SandboxConfig {
1717

1818
constructor(sandboxesBaseDir: string, sandboxName: string) {
1919
this.sandboxesDirectory = path.join(sandboxesBaseDir, sandboxName);
20-
this.configPath = path.join(this.sandboxesDirectory, '/config.json');
20+
this.configPath = path.join(this.sandboxesDirectory, 'config.json');
2121
}
2222

2323
useClientConfig(config: any) {

src/utils/env-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function getJavaHome() {
6767

6868
export async function getJavaExecutablePath() {
6969
const home = await getJavaHome();
70-
return path.join(home, '/bin/java');
70+
return path.join(home, 'bin', 'java');
7171
}
7272

7373
export async function getJavaVersion() {

0 commit comments

Comments
 (0)