defang 0.5.15 → 0.5.18

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/cli.js CHANGED
@@ -18,10 +18,17 @@ function getPathToExecutable() {
18
18
  }
19
19
  }
20
20
  function run() {
21
- const args = process.argv.slice(2);
22
- const processResult = child_process.spawnSync(getPathToExecutable(), args, {
23
- stdio: "inherit",
24
- });
25
- process.exit(processResult.status ?? 0);
21
+ try {
22
+ const args = process.argv.slice(2);
23
+ const processResult = child_process.spawnSync(getPathToExecutable(), args, {
24
+ stdio: "inherit",
25
+ });
26
+ processResult.error && console.error(processResult.error);
27
+ process.exitCode = processResult.status ?? 1;
28
+ }
29
+ catch (error) {
30
+ console.error(error);
31
+ process.exitCode = 2;
32
+ }
26
33
  }
27
34
  run();
package/bin/installer.js CHANGED
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs = require("graceful-fs");
4
3
  const os = require("os");
5
4
  const path = require("path");
6
5
  const tar = require("tar");
7
6
  const AdmZip = require("adm-zip");
8
7
  const axios_1 = require("axios");
8
+ const fs_1 = require("fs");
9
9
  async function downloadAppArchive(version, archiveFilename, outputPath) {
10
- const repo = "defang-io/defang";
10
+ const repo = "DefangLabs/defang";
11
11
  const downloadUrl = `https://github.com/${repo}/releases/download/v${version}/${archiveFilename}`;
12
12
  const downloadTargetFile = path.join(outputPath, archiveFilename);
13
13
  return downloadFile(downloadUrl, downloadTargetFile);
14
14
  }
15
15
  async function downloadFile(downloadUrl, downloadTargetFile) {
16
16
  try {
17
- const writeFileStream = fs.createWriteStream(downloadTargetFile);
18
17
  console.log(`Downloading ${downloadUrl}`);
19
18
  const response = await axios_1.default.get(downloadUrl, {
20
19
  responseType: "arraybuffer",
@@ -25,12 +24,12 @@ async function downloadFile(downloadUrl, downloadTargetFile) {
25
24
  if (response?.data === undefined) {
26
25
  throw new Error(`Failed to download ${downloadUrl}. No data in response.`);
27
26
  }
28
- fs.writeFileSync(downloadTargetFile, response.data);
27
+ await fs_1.promises.writeFile(downloadTargetFile, response.data);
29
28
  return downloadTargetFile;
30
29
  }
31
30
  catch (error) {
32
- console.error(`Failed to download ${downloadUrl}. ${error}`);
33
- fs.unlinkSync(downloadTargetFile);
31
+ console.error(error);
32
+ await fs_1.promises.unlink(downloadTargetFile);
34
33
  return "";
35
34
  }
36
35
  }
@@ -76,11 +75,11 @@ function extractTarGz(tarGzFilePath, outputPath) {
76
75
  return false;
77
76
  }
78
77
  }
79
- function deleteArchive(archiveFilePath) {
80
- fs.unlinkSync(archiveFilePath);
78
+ async function deleteArchive(archiveFilePath) {
79
+ await fs_1.promises.unlink(archiveFilePath);
81
80
  }
82
- function getVersion(filename) {
83
- const data = fs.readFileSync(filename, "utf8");
81
+ async function getVersion(filename) {
82
+ const data = await fs_1.promises.readFile(filename, "utf8");
84
83
  const pkg = JSON.parse(data);
85
84
  return pkg.version;
86
85
  }
@@ -118,7 +117,7 @@ function getAppArchiveFilename(version, platform, arch) {
118
117
  async function install() {
119
118
  try {
120
119
  console.log(`Starting install of defang cli`);
121
- const version = getVersion("package.json");
120
+ const version = await getVersion("package.json");
122
121
  const filename = getAppArchiveFilename(version, os.platform(), os.arch());
123
122
  const archiveFile = await downloadAppArchive(version, filename, __dirname);
124
123
  if (archiveFile.length === 0) {
@@ -129,11 +128,10 @@ async function install() {
129
128
  throw new Error(`Failed to install binaries!`);
130
129
  }
131
130
  console.log(`Successfully installed defang cli!`);
132
- deleteArchive(archiveFile);
131
+ await deleteArchive(archiveFile);
133
132
  }
134
133
  catch (error) {
135
134
  console.error(error);
136
- process.exit(1);
137
135
  }
138
136
  }
139
137
  install();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "defang",
3
- "version": "0.5.15",
3
+ "version": "0.5.18",
4
4
  "author": "Defang Software Labs Inc.",
5
5
  "description": "CLI for the Defang Opinionated Platform",
6
6
  "license": "MIT",
@@ -8,13 +8,13 @@
8
8
  "defang": "./bin/cli.js"
9
9
  },
10
10
  "keywords": [],
11
- "homepage": "https://github.com/defang-io/defang#readme",
11
+ "homepage": "https://github.com/DefangLabs/defang#readme",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/defang-io/defang.git"
14
+ "url": "git+https://github.com/DefangLabs/defang.git"
15
15
  },
16
16
  "bugs": {
17
- "url": "https://github.com/defang-io/defang/issues"
17
+ "url": "https://github.com/DefangLabs/defang/issues"
18
18
  },
19
19
  "scripts": {
20
20
  "build": "tsc",
@@ -23,14 +23,12 @@
23
23
  "dependencies": {
24
24
  "adm-zip": "^0.5.12",
25
25
  "axios": "^1.6.8",
26
- "graceful-fs": "^4.2.11",
27
26
  "https": "^1.0.0",
28
27
  "os": "^0.1.2",
29
28
  "tar": "^7.0.1"
30
29
  },
31
30
  "devDependencies": {
32
31
  "@types/adm-zip": "^0.5.5",
33
- "@types/graceful-fs": "^4.1.9",
34
32
  "@types/node": "^20.12.7",
35
33
  "@types/tar": "^6.1.13",
36
34
  "typescript": "^5.4.5"