Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit f447797

Browse files
committed
feat: Add js cli
1 parent d49a44c commit f447797

File tree

10 files changed

+279
-9
lines changed

10 files changed

+279
-9
lines changed

cli/package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "squid-cli",
3+
"version": "0.2.0-canary",
4+
"description": "The CLI for Squid.",
5+
"author": {
6+
"email": "[email protected]",
7+
"name": "QuiiBz",
8+
"url": "https://github.com/QuiiBz"
9+
},
10+
"license": "MIT",
11+
"repository": "https://github.com/squidjs/terminal",
12+
"main": "dist/index.js",
13+
"scripts": {
14+
"start": "tsc && node dist/index.js",
15+
"dist": "webpack"
16+
},
17+
"dependencies": {
18+
"yargs": "^16.2.0"
19+
},
20+
"devDependencies": {
21+
"@types/yargs": "^16.0.0",
22+
"ts-node": "^9.1.1",
23+
"typescript": "^4.2.3"
24+
}
25+
}

cli/src/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import yargs from 'yargs/yargs';
2+
import { hideBin } from 'yargs/helpers';
3+
4+
yargs(hideBin(process.argv))
5+
.command('curl <url>', 'fetch the contents of the URL', () => null, (argv) => {
6+
console.info(argv)
7+
})
8+
.demandCommand(1)
9+
.argv;

cli/tsconfig.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "Node",
4+
"target": "ES5",
5+
"outDir": "dist",
6+
"allowSyntheticDefaultImports": true,
7+
"esModuleInterop": true,
8+
"baseUrl": ".",
9+
"paths": {
10+
"@cli/*": [
11+
"src/*"
12+
]
13+
}
14+
},
15+
"include": [
16+
"src/**/*"
17+
]
18+
}

cli/webpack.config.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
resolve: {
5+
alias: {
6+
'@cli': path.resolve(__dirname, 'src'),
7+
},
8+
extensions: ['.js', '.ts'],
9+
mainFields: ['main'],
10+
},
11+
target: 'node',
12+
entry: './src',
13+
output: {
14+
path: path.join(__dirname, '..', 'resources', 'cli'),
15+
filename: 'cli.js',
16+
},
17+
module: {
18+
rules: [
19+
{
20+
test: /\.(js|ts)$/,
21+
exclude: /node_modules/,
22+
loader: 'babel-loader'
23+
},
24+
]
25+
},
26+
}

cli/yarn.lock

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@types/yargs-parser@*":
6+
version "20.2.0"
7+
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.0.tgz#dd3e6699ba3237f0348cd085e4698780204842f9"
8+
integrity sha512-37RSHht+gzzgYeobbG+KWryeAW8J33Nhr69cjTqSYymXVZEN9NbRYWoYlRtDhHKPVT1FyNKwaTPC1NynKZpzRA==
9+
10+
"@types/yargs@^16.0.0":
11+
version "16.0.0"
12+
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-16.0.0.tgz#0e033b23452da5d61b6c44747612cb80ac528751"
13+
integrity sha512-2nN6AGeMwe8+O6nO9ytQfbMQOJy65oi1yK2y/9oReR08DaXSGtMsrLyCM1ooKqfICpCx4oITaR4LkOmdzz41Ww==
14+
dependencies:
15+
"@types/yargs-parser" "*"
16+
17+
ansi-regex@^5.0.0:
18+
version "5.0.0"
19+
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
20+
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
21+
22+
ansi-styles@^4.0.0:
23+
version "4.3.0"
24+
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
25+
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
26+
dependencies:
27+
color-convert "^2.0.1"
28+
29+
arg@^4.1.0:
30+
version "4.1.3"
31+
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
32+
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
33+
34+
buffer-from@^1.0.0:
35+
version "1.1.1"
36+
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
37+
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
38+
39+
cliui@^7.0.2:
40+
version "7.0.4"
41+
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
42+
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
43+
dependencies:
44+
string-width "^4.2.0"
45+
strip-ansi "^6.0.0"
46+
wrap-ansi "^7.0.0"
47+
48+
color-convert@^2.0.1:
49+
version "2.0.1"
50+
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
51+
integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
52+
dependencies:
53+
color-name "~1.1.4"
54+
55+
color-name@~1.1.4:
56+
version "1.1.4"
57+
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
58+
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
59+
60+
create-require@^1.1.0:
61+
version "1.1.1"
62+
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
63+
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
64+
65+
diff@^4.0.1:
66+
version "4.0.2"
67+
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
68+
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
69+
70+
emoji-regex@^8.0.0:
71+
version "8.0.0"
72+
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
73+
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
74+
75+
escalade@^3.1.1:
76+
version "3.1.1"
77+
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
78+
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==
79+
80+
get-caller-file@^2.0.5:
81+
version "2.0.5"
82+
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
83+
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
84+
85+
is-fullwidth-code-point@^3.0.0:
86+
version "3.0.0"
87+
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
88+
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
89+
90+
make-error@^1.1.1:
91+
version "1.3.6"
92+
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
93+
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
94+
95+
require-directory@^2.1.1:
96+
version "2.1.1"
97+
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
98+
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
99+
100+
source-map-support@^0.5.17:
101+
version "0.5.19"
102+
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
103+
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
104+
dependencies:
105+
buffer-from "^1.0.0"
106+
source-map "^0.6.0"
107+
108+
source-map@^0.6.0:
109+
version "0.6.1"
110+
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
111+
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
112+
113+
string-width@^4.1.0, string-width@^4.2.0:
114+
version "4.2.2"
115+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
116+
integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==
117+
dependencies:
118+
emoji-regex "^8.0.0"
119+
is-fullwidth-code-point "^3.0.0"
120+
strip-ansi "^6.0.0"
121+
122+
strip-ansi@^6.0.0:
123+
version "6.0.0"
124+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
125+
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
126+
dependencies:
127+
ansi-regex "^5.0.0"
128+
129+
ts-node@^9.1.1:
130+
version "9.1.1"
131+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.1.1.tgz#51a9a450a3e959401bda5f004a72d54b936d376d"
132+
integrity sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==
133+
dependencies:
134+
arg "^4.1.0"
135+
create-require "^1.1.0"
136+
diff "^4.0.1"
137+
make-error "^1.1.1"
138+
source-map-support "^0.5.17"
139+
yn "3.1.1"
140+
141+
typescript@^4.2.3:
142+
version "4.2.3"
143+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
144+
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
145+
146+
wrap-ansi@^7.0.0:
147+
version "7.0.0"
148+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
149+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
150+
dependencies:
151+
ansi-styles "^4.0.0"
152+
string-width "^4.1.0"
153+
strip-ansi "^6.0.0"
154+
155+
y18n@^5.0.5:
156+
version "5.0.5"
157+
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.5.tgz#8769ec08d03b1ea2df2500acef561743bbb9ab18"
158+
integrity sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==
159+
160+
yargs-parser@^20.2.2:
161+
version "20.2.7"
162+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.7.tgz#61df85c113edfb5a7a4e36eb8aa60ef423cbc90a"
163+
integrity sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==
164+
165+
yargs@^16.2.0:
166+
version "16.2.0"
167+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
168+
integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
169+
dependencies:
170+
cliui "^7.0.2"
171+
escalade "^3.1.1"
172+
get-caller-file "^2.0.5"
173+
require-directory "^2.1.1"
174+
string-width "^4.2.0"
175+
y18n "^5.0.5"
176+
yargs-parser "^20.2.2"
177+
178+
179+
version "3.1.1"
180+
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
181+
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "squid",
33
"version": "0.2.0-canary",
4-
"description": "The Shell and SSH terminal for everyone",
4+
"description": "The extendible Shell and SSH terminal, with E2E encryption in the cloud.",
55
"author": {
66
"email": "[email protected]",
77
"name": "QuiiBz",
@@ -11,11 +11,13 @@
1111
"repository": "https://github.com/squidjs/terminal",
1212
"scripts": {
1313
"dev": "electron-webpack dev",
14-
"compile": "yarn setupIcon && electron-webpack",
14+
"cli": "cd cli && yarn start",
15+
"compile": "yarn setupIcon && yarn dist:cli && electron-webpack",
1516
"dist": "yarn compile && electron-builder",
1617
"dist:win": "yarn compile && electron-builder -w -p onTagOrDraft",
1718
"dist:mac": "yarn compile && electron-builder -m -p onTagOrDraft",
1819
"dist:linux": "yarn compile && electron-builder -l -p onTagOrDraft",
20+
"dist:cli": "cd cli && yarn dist",
1921
"rebuild": "electron-rebuild",
2022
"rebuild:arm64": "electron-rebuild -a arm64",
2123
"lint": "eslint . --ext .ts,.tsx",
@@ -46,7 +48,7 @@
4648
"devDependencies": {
4749
"@babel/preset-react": "^7.12.10",
4850
"@types/keytar": "^4.4.2",
49-
"@types/node": "^12.13.0",
51+
"@types/node": "^14.14.35",
5052
"@types/react": "^17.0.0",
5153
"@types/react-dom": "^17.0.0",
5254
"@types/ssh2": "^0.5.46",

resources/bin/squid-mac

+8-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
echo Hello world
1+
#!/usr/bin/env bash
2+
# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/darwin/bin/code.sh
3+
4+
PATH="/Applications/Squid.app/Contents"
5+
ELECTRON="$PATH/MacOS/Squid"
6+
CLI="$PATH/Resources/cli/cli.js"
7+
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
8+
exit $?

resources/cli/cli.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"ui/*"
1818
]
1919
}
20-
}
20+
},
21+
"exclude": ["cli/**/*"]
2122
}

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,10 @@
10951095
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.34.tgz#0a5d6ae5d22612f0cf5f10320e1fc5d2a745dcb8"
10961096
integrity sha512-BneGN0J9ke24lBRn44hVHNeDlrXRYF+VRp0HbSUNnEZahXGAysHZIqnf/hER6aabdBgzM4YOV4jrR8gj4Zfi0g==
10971097

1098-
"@types/node@^12.13.0":
1099-
version "12.19.12"
1100-
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.12.tgz#04793c2afa4ce833a9972e4c476432e30f9df47b"
1101-
integrity sha512-UwfL2uIU9arX/+/PRcIkT08/iBadGN2z6ExOROA2Dh5mAuWTBj6iJbQX4nekiV5H8cTrEG569LeX+HRco9Cbxw==
1098+
"@types/node@^14.14.35":
1099+
version "14.14.35"
1100+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.35.tgz#42c953a4e2b18ab931f72477e7012172f4ffa313"
1101+
integrity sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag==
11021102

11031103
"@types/plist@^3.0.1":
11041104
version "3.0.2"

0 commit comments

Comments
 (0)