defang 3.5.2 → 3.5.5
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/clilib.js +16 -21
- package/package.json +10 -25
package/bin/clilib.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import AdmZip from "adm-zip";
|
|
2
|
-
import axios from "axios";
|
|
3
2
|
import * as child_process from "child_process";
|
|
4
3
|
import * as fs from "fs";
|
|
5
4
|
import * as path from "path";
|
|
6
5
|
import * as tar from "tar";
|
|
7
6
|
import { promisify } from "util";
|
|
8
|
-
import { dirname } from 'path';
|
|
9
7
|
import { fileURLToPath } from 'url';
|
|
10
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const __dirname = dirname(__filename);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
12
10
|
const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
13
11
|
const EXECUTABLE = "defang";
|
|
14
12
|
const URL_LATEST_RELEASE = "https://api.github.com/repos/DefangLabs/defang/releases/latest";
|
|
15
|
-
const
|
|
16
|
-
const exec = promisify(child_process.exec);
|
|
13
|
+
const execFile = promisify(child_process.execFile);
|
|
17
14
|
async function getLatestVersion() {
|
|
18
|
-
const response = await
|
|
19
|
-
if (response.
|
|
15
|
+
const response = await fetch(URL_LATEST_RELEASE);
|
|
16
|
+
if (!response.ok) {
|
|
20
17
|
throw new Error(`Failed to get latest version from GitHub. Status code: ${response.status}`);
|
|
21
18
|
}
|
|
22
|
-
|
|
19
|
+
const data = await response.json();
|
|
20
|
+
const version = data.tag_name?.trim().replace(/^v/, "");
|
|
21
|
+
return version && SEMVER_REGEX.test(version) ? version : undefined;
|
|
23
22
|
}
|
|
24
23
|
async function downloadAppArchive(archiveFilename, outputPath) {
|
|
25
24
|
const downloadUrl = `https://s.defang.io/${archiveFilename}?x-defang-source=npm`;
|
|
@@ -28,21 +27,17 @@ async function downloadAppArchive(archiveFilename, outputPath) {
|
|
|
28
27
|
}
|
|
29
28
|
async function downloadFile(downloadUrl, downloadTargetFile) {
|
|
30
29
|
try {
|
|
31
|
-
const response = await
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"Content-Type": "application/octet-stream",
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
if (response.data == null) {
|
|
38
|
-
throw new Error(`Failed to download ${downloadUrl}. No data in response.`);
|
|
30
|
+
const response = await fetch(downloadUrl);
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(`Failed to download ${downloadUrl}. Status code: ${response.status}`);
|
|
39
33
|
}
|
|
40
|
-
|
|
34
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
35
|
+
await fs.promises.writeFile(downloadTargetFile, buffer);
|
|
41
36
|
return downloadTargetFile;
|
|
42
37
|
}
|
|
43
38
|
catch (error) {
|
|
44
39
|
console.error(error);
|
|
45
|
-
await fs.promises.
|
|
40
|
+
await fs.promises.rm(downloadTargetFile, { force: true });
|
|
46
41
|
return null;
|
|
47
42
|
}
|
|
48
43
|
}
|
|
@@ -70,7 +65,7 @@ async function extractZip(zipPath, outputPath) {
|
|
|
70
65
|
}
|
|
71
66
|
const executableFullName = EXECUTABLE + extension;
|
|
72
67
|
const result = zip.extractEntryTo(executableFullName, outputPath, true, true);
|
|
73
|
-
await fs.promises.chmod(path.join(outputPath, executableFullName),
|
|
68
|
+
await fs.promises.chmod(path.join(outputPath, executableFullName), 0o755);
|
|
74
69
|
return result;
|
|
75
70
|
}
|
|
76
71
|
catch (error) {
|
|
@@ -165,9 +160,9 @@ async function getVersionInfo() {
|
|
|
165
160
|
const execPath = getPathToExecutable();
|
|
166
161
|
if (!execPath) {
|
|
167
162
|
const latestVersion = await getLatestVersion();
|
|
168
|
-
return { current: null, latest: latestVersion };
|
|
163
|
+
return { current: null, latest: latestVersion ?? null };
|
|
169
164
|
}
|
|
170
|
-
const versionInfo = await
|
|
165
|
+
const versionInfo = await execFile(execPath, ["version"]);
|
|
171
166
|
const verInfo = extractCLIVersions(versionInfo.stdout);
|
|
172
167
|
result.current = verInfo.defangCLI;
|
|
173
168
|
result.latest = verInfo.latestCLI;
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "defang",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.5",
|
|
4
4
|
"author": "Defang Software Labs Inc.",
|
|
5
5
|
"description": "CLI to take your app from Docker Compose to a secure and scalable deployment on your favorite cloud in minutes",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"ts-node": {
|
|
9
|
-
"esm": true
|
|
10
|
-
},
|
|
11
8
|
"bin": {
|
|
12
9
|
"defang": "bin/cli.js"
|
|
13
10
|
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18.0.0"
|
|
13
|
+
},
|
|
14
14
|
"keywords": [],
|
|
15
15
|
"homepage": "https://defang.io",
|
|
16
16
|
"repository": {
|
|
@@ -20,19 +20,6 @@
|
|
|
20
20
|
"bugs": {
|
|
21
21
|
"url": "https://github.com/DefangLabs/defang/issues"
|
|
22
22
|
},
|
|
23
|
-
"mocha": {
|
|
24
|
-
"require": [
|
|
25
|
-
"ts-node/register"
|
|
26
|
-
],
|
|
27
|
-
"extension": [
|
|
28
|
-
"ts",
|
|
29
|
-
"js"
|
|
30
|
-
],
|
|
31
|
-
"spec": [
|
|
32
|
-
"test/**/*.spec.ts"
|
|
33
|
-
],
|
|
34
|
-
"recursive": true
|
|
35
|
-
},
|
|
36
23
|
"scripts": {
|
|
37
24
|
"build": "tsc -p tsconfig.json",
|
|
38
25
|
"postbuild": "chmod +x bin/cli.js",
|
|
@@ -40,7 +27,6 @@
|
|
|
40
27
|
},
|
|
41
28
|
"dependencies": {
|
|
42
29
|
"adm-zip": "^0.5.14",
|
|
43
|
-
"axios": "^1.8.2",
|
|
44
30
|
"tar": "^7.0.1"
|
|
45
31
|
},
|
|
46
32
|
"devDependencies": {
|
|
@@ -48,16 +34,15 @@
|
|
|
48
34
|
"@types/chai": "^5.1.1",
|
|
49
35
|
"@types/chai-as-promised": "^8.0.0",
|
|
50
36
|
"@types/mocha": "^10.0.10",
|
|
51
|
-
"@types/node": "^
|
|
52
|
-
"@types/sinon": "^
|
|
37
|
+
"@types/node": "^24.12.0",
|
|
38
|
+
"@types/sinon": "^21.0.1",
|
|
53
39
|
"@types/tar": "^6.1.13",
|
|
54
|
-
"chai": "^
|
|
40
|
+
"chai": "^6.2.2",
|
|
55
41
|
"chai-as-promised": "^8.0.0",
|
|
56
|
-
"mocha": "^
|
|
57
|
-
"sinon": "^
|
|
58
|
-
"ts-node": "^10.9.2",
|
|
42
|
+
"mocha": "^11.3.0",
|
|
43
|
+
"sinon": "^21.0.3",
|
|
59
44
|
"tsx": "^4.19.3",
|
|
60
|
-
"typescript": "^
|
|
45
|
+
"typescript": "^6.0.2"
|
|
61
46
|
},
|
|
62
47
|
"main": "./bin/cli.js"
|
|
63
48
|
}
|