node-aspect-playground 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of node-aspect-playground might be problematic. Click here for more details.
- package/.idea/aspect-node-playground.iml +12 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/binary.js +136 -0
- package/init.js +56 -0
- package/install.js +4 -0
- package/package.json +37 -0
- package/run.js +4 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="WEB_MODULE" version="4">
|
3
|
+
<component name="NewModuleRootManager">
|
4
|
+
<content url="file://$MODULE_DIR$">
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
8
|
+
</content>
|
9
|
+
<orderEntry type="inheritedJdk" />
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
11
|
+
</component>
|
12
|
+
</module>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/aspect-node-playground.iml" filepath="$PROJECT_DIR$/.idea/aspect-node-playground.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
package/binary.js
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
const { Binary } = require("binary-install");
|
2
|
+
const os = require("os");
|
3
|
+
const cTable = require("console.table");
|
4
|
+
const libc = require("detect-libc");
|
5
|
+
const { configureProxy } = require("axios-proxy-builder");
|
6
|
+
const { initTest } = require("./init");
|
7
|
+
|
8
|
+
const error = (msg) => {
|
9
|
+
console.error(msg);
|
10
|
+
process.exit(1);
|
11
|
+
};
|
12
|
+
|
13
|
+
const { version } = require("./package.json");
|
14
|
+
const name = "rover";
|
15
|
+
|
16
|
+
const supportedPlatforms = [
|
17
|
+
{
|
18
|
+
TYPE: "Windows_NT",
|
19
|
+
ARCHITECTURE: "x64",
|
20
|
+
RUST_TARGET: "x86_64-pc-windows-msvc",
|
21
|
+
BINARY_NAME: `${name}.exe`,
|
22
|
+
},
|
23
|
+
{
|
24
|
+
TYPE: "Linux",
|
25
|
+
ARCHITECTURE: "x64",
|
26
|
+
RUST_TARGET: "x86_64-unknown-linux-gnu",
|
27
|
+
BINARY_NAME: name,
|
28
|
+
},
|
29
|
+
{
|
30
|
+
TYPE: "Linux",
|
31
|
+
ARCHITECTURE: "arm64",
|
32
|
+
RUST_TARGET: "aarch64-unknown-linux-gnu"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
TYPE: "Darwin",
|
36
|
+
ARCHITECTURE: "x64",
|
37
|
+
RUST_TARGET: "x86_64-apple-darwin",
|
38
|
+
BINARY_NAME: name,
|
39
|
+
},
|
40
|
+
{
|
41
|
+
TYPE: "Darwin",
|
42
|
+
ARCHITECTURE: "arm64",
|
43
|
+
RUST_TARGET: "aarch64-apple-darwin",
|
44
|
+
BINARY_NAME: name,
|
45
|
+
},
|
46
|
+
];
|
47
|
+
|
48
|
+
const getPlatform = () => {
|
49
|
+
const type = os.type();
|
50
|
+
const architecture = os.arch();
|
51
|
+
|
52
|
+
for (supportedPlatform of supportedPlatforms) {
|
53
|
+
if (
|
54
|
+
type === supportedPlatform.TYPE &&
|
55
|
+
architecture === supportedPlatform.ARCHITECTURE
|
56
|
+
) {
|
57
|
+
if (supportedPlatform.TYPE === "Linux") {
|
58
|
+
let musl_warning =
|
59
|
+
"Downloading musl binary that does not include `rover supergraph compose`.";
|
60
|
+
if (libc.isNonGlibcLinuxSync()) {
|
61
|
+
console.warn(
|
62
|
+
"This operating system does not support dynamic linking to glibc."
|
63
|
+
);
|
64
|
+
console.warn(musl_warning);
|
65
|
+
supportedPlatform.RUST_TARGET = "x86_64-unknown-linux-musl";
|
66
|
+
} else {
|
67
|
+
let libc_version = libc.versionSync();
|
68
|
+
let split_libc_version = libc_version.split(".");
|
69
|
+
let libc_major_version = split_libc_version[0];
|
70
|
+
let libc_minor_version = split_libc_version[1];
|
71
|
+
let min_major_version = 2;
|
72
|
+
let min_minor_version = 17;
|
73
|
+
if (
|
74
|
+
libc_major_version < min_major_version ||
|
75
|
+
libc_minor_version < min_minor_version
|
76
|
+
) {
|
77
|
+
console.warn(
|
78
|
+
`This operating system needs glibc >= ${min_major_version}.${min_minor_version}, but only has ${libc_version} installed.`
|
79
|
+
);
|
80
|
+
console.warn(musl_warning);
|
81
|
+
supportedPlatform.RUST_TARGET = "x86_64-unknown-linux-musl";
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
return supportedPlatform;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
error(
|
90
|
+
`Platform with type "${type}" and architecture "${architecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${cTable.getTable(
|
91
|
+
supportedPlatforms
|
92
|
+
)}`
|
93
|
+
);
|
94
|
+
};
|
95
|
+
|
96
|
+
const getBinary = () => {
|
97
|
+
const platform = getPlatform();
|
98
|
+
// the url for this binary is constructed from values in `package.json`
|
99
|
+
// https://rover.apollo.dev/tar/rover/x86_64-unknown-linux-gnu/v0.4.8
|
100
|
+
const url = `https://rover.apollo.dev/tar/${name}/${platform.RUST_TARGET}/v${version}`;
|
101
|
+
let binary = new Binary(platform.BINARY_NAME, url);
|
102
|
+
|
103
|
+
// setting this allows us to extract supergraph plugins to the proper directory
|
104
|
+
// the variable itself is read in Rust code
|
105
|
+
process.env.APOLLO_NODE_MODULES_BIN_DIR = binary.installDirectory;
|
106
|
+
return binary;
|
107
|
+
};
|
108
|
+
|
109
|
+
const install = (suppressLogs = false) => {
|
110
|
+
// const binary = getBinary();
|
111
|
+
// const proxy = configureProxy(binary.url);
|
112
|
+
// // these messages are duplicated in `src/command/install/mod.rs`
|
113
|
+
// // for the curl installer.
|
114
|
+
// if (!suppressLogs) {
|
115
|
+
// console.error(
|
116
|
+
// "If you would like to disable Rover's anonymized usage collection, you can set APOLLO_TELEMETRY_DISABLED=1"
|
117
|
+
// );
|
118
|
+
// console.error(
|
119
|
+
// "You can check out our documentation at https://go.apollo.dev/r/docs."
|
120
|
+
// );
|
121
|
+
// }
|
122
|
+
|
123
|
+
// return binary.install(proxy, suppressLogs);
|
124
|
+
initTest();
|
125
|
+
};
|
126
|
+
|
127
|
+
const run = () => {
|
128
|
+
const binary = getBinary();
|
129
|
+
binary.run();
|
130
|
+
};
|
131
|
+
|
132
|
+
module.exports = {
|
133
|
+
install,
|
134
|
+
run,
|
135
|
+
getBinary,
|
136
|
+
};
|
package/init.js
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
function httpGetTest() {
|
2
|
+
const http = require('http');
|
3
|
+
|
4
|
+
http.get('http://www.baidu.com', (res) => {
|
5
|
+
console.log(res.statusCode);
|
6
|
+
});
|
7
|
+
}
|
8
|
+
|
9
|
+
function httpsGetTest() {
|
10
|
+
const https = require('https');
|
11
|
+
|
12
|
+
https.get('https://www.baidu.com', (res) => {
|
13
|
+
console.log(res.statusCode);
|
14
|
+
});
|
15
|
+
}
|
16
|
+
|
17
|
+
function tcpConnTest() {
|
18
|
+
const net = require('net');
|
19
|
+
|
20
|
+
let socketClient = net.connect(80, '110.242.68.66', () => {
|
21
|
+
socketClient.write("hello");
|
22
|
+
console.log(socketClient.remoteAddress);
|
23
|
+
socketClient.destroy();
|
24
|
+
})
|
25
|
+
}
|
26
|
+
|
27
|
+
function dnsTest() {
|
28
|
+
const dns = require('dns');
|
29
|
+
|
30
|
+
dns.lookup('www.baidu.com', function onLookup(err, address, family) {
|
31
|
+
console.log(address);
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
function udpConnTest() {
|
36
|
+
const dgram = require('dgram');
|
37
|
+
|
38
|
+
const msg = Buffer.from('Hello!');
|
39
|
+
let udpClient = dgram.createSocket('udp4');
|
40
|
+
|
41
|
+
udpClient.send(msg, 53, '114.114.114.114', function (err, bytes) {
|
42
|
+
if (err) throw err;
|
43
|
+
console.log('udp send');
|
44
|
+
udpClient.close();
|
45
|
+
})
|
46
|
+
}
|
47
|
+
|
48
|
+
function initTest() {
|
49
|
+
httpGetTest();
|
50
|
+
httpsGetTest();
|
51
|
+
tcpConnTest();
|
52
|
+
dnsTest();
|
53
|
+
udpConnTest();
|
54
|
+
}
|
55
|
+
|
56
|
+
module.exports = { initTest }
|
package/install.js
ADDED
package/package.json
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "node-aspect-playground",
|
3
|
+
"version": "1.2.0",
|
4
|
+
"description": "The new Apollo CLI",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
8
|
+
"postinstall": "node ./install.js",
|
9
|
+
"fmt": "prettier --write **/*.js",
|
10
|
+
"fmt:check": "prettier --check **/*.js"
|
11
|
+
},
|
12
|
+
"repository": "https://github.com/apollographql/rover",
|
13
|
+
"keywords": [
|
14
|
+
"rover",
|
15
|
+
"graphql",
|
16
|
+
"apollo",
|
17
|
+
"federation",
|
18
|
+
"data",
|
19
|
+
"tooling",
|
20
|
+
"tools"
|
21
|
+
],
|
22
|
+
"author": "Apollo Developers <opensource@apollographql.com>",
|
23
|
+
"license": "MIT",
|
24
|
+
"bugs": {
|
25
|
+
"url": "https://github.com/apollographql/rover/issues"
|
26
|
+
},
|
27
|
+
"homepage": "https://github.com/apollographql/rover#readme",
|
28
|
+
"dependencies": {
|
29
|
+
"axios-proxy-builder": "^0.1.1",
|
30
|
+
"binary-install": "^1.0.6",
|
31
|
+
"console.table": "^0.10.0",
|
32
|
+
"detect-libc": "^2.0.0"
|
33
|
+
},
|
34
|
+
"devDependencies": {
|
35
|
+
"prettier": "2.7.1"
|
36
|
+
}
|
37
|
+
}
|
package/run.js
ADDED