@solcreek/dew 0.1.0 → 0.3.0
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/package.json +2 -3
- package/scripts/postinstall.js +54 -31
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solcreek/dew",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Ultra-lightweight VM
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Ultra-lightweight VM + deploy tool. One Go binary for local dev and production.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/solcreek/dew"
|
|
9
9
|
},
|
|
10
|
-
"os": ["darwin"],
|
|
11
10
|
"bin": {
|
|
12
11
|
"dew": "bin/dew"
|
|
13
12
|
},
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,26 +1,56 @@
|
|
|
1
1
|
const { execSync } = require("child_process");
|
|
2
|
-
const { existsSync, writeFileSync, mkdirSync } = require("fs");
|
|
2
|
+
const { existsSync, writeFileSync, mkdirSync, chmodSync } = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const os = require("os");
|
|
5
5
|
|
|
6
|
-
if (os.platform() !== "darwin") {
|
|
7
|
-
console.log("dew: skipping codesign (not macOS)");
|
|
8
|
-
process.exit(0);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
6
|
const binDir = path.join(__dirname, "..", "bin");
|
|
12
7
|
const binary = path.join(binDir, "dew");
|
|
13
8
|
|
|
9
|
+
if (!existsSync(binDir)) {
|
|
10
|
+
mkdirSync(binDir, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
|
|
14
13
|
if (!existsSync(binary)) {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const platform = os.platform();
|
|
15
|
+
const arch = os.arch() === "arm64" ? "arm64" : "amd64";
|
|
16
|
+
const repo = "solcreek/dew";
|
|
17
|
+
const pkg = require("../package.json");
|
|
18
|
+
const tag = `v${pkg.version}`;
|
|
19
|
+
|
|
20
|
+
let asset;
|
|
21
|
+
if (platform === "darwin") {
|
|
22
|
+
asset = `dew-darwin-${arch}`;
|
|
23
|
+
} else if (platform === "linux") {
|
|
24
|
+
asset = `dew-serve-linux-${arch}`;
|
|
25
|
+
} else if (platform === "win32") {
|
|
26
|
+
asset = `dew-windows-x86_64.exe`;
|
|
27
|
+
} else {
|
|
28
|
+
console.log(`dew: unsupported platform ${platform}`);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const url = `https://github.com/${repo}/releases/download/${tag}/${asset}`;
|
|
33
|
+
console.log(`dew: downloading ${asset}...`);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
execSync(`curl -fsSL -o "${binary}" "${url}"`, { stdio: "pipe" });
|
|
37
|
+
chmodSync(binary, 0o755);
|
|
38
|
+
console.log("dew: installed");
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.log(`dew: download failed from ${url}`);
|
|
41
|
+
console.log(" GitHub Release may not exist yet.");
|
|
42
|
+
console.log(" Install manually: https://github.com/solcreek/dew/releases");
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
17
45
|
}
|
|
18
46
|
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
47
|
+
// macOS: codesign with virtualization entitlement
|
|
48
|
+
if (os.platform() === "darwin" && existsSync(binary)) {
|
|
49
|
+
const entitlements = path.join(__dirname, "entitlements.plist");
|
|
50
|
+
if (!existsSync(entitlements)) {
|
|
51
|
+
writeFileSync(
|
|
52
|
+
entitlements,
|
|
53
|
+
`<?xml version="1.0" encoding="UTF-8"?>
|
|
24
54
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
25
55
|
<plist version="1.0">
|
|
26
56
|
<dict>
|
|
@@ -28,23 +58,16 @@ if (!existsSync(entitlements)) {
|
|
|
28
58
|
<true/>
|
|
29
59
|
</dict>
|
|
30
60
|
</plist>`
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
execSync(
|
|
36
|
-
`codesign --entitlements "${entitlements}" --force -s - "${binary}"`,
|
|
37
|
-
{ stdio: "pipe" }
|
|
38
|
-
);
|
|
39
|
-
console.log("dew: signed with virtualization entitlement");
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.log("dew: codesign failed (may need manual signing)");
|
|
42
|
-
console.log(` run: codesign --entitlements "${entitlements}" --force -s - "${binary}"`);
|
|
43
|
-
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
44
63
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
try {
|
|
65
|
+
execSync(
|
|
66
|
+
`codesign --entitlements "${entitlements}" --force -s - "${binary}"`,
|
|
67
|
+
{ stdio: "pipe" }
|
|
68
|
+
);
|
|
69
|
+
console.log("dew: signed with virtualization entitlement");
|
|
70
|
+
} catch (e) {
|
|
71
|
+
console.log("dew: codesign failed (may need manual signing)");
|
|
72
|
+
}
|
|
50
73
|
}
|