Compare commits

..
Author SHA1 Message Date
ShareVB 34f25fa0e8 fix: remove top level await and copy plugin 2024-11-11 19:16:14 +01:00
ShareVB 94acc0decc fix: make vite copy tree sitter 2024-11-11 19:06:56 +01:00
sharevb 02593d869a feat(new tool): curl converter
Generate curl version for common coding languages
Fix #830
2024-11-10 21:05:02 +01:00
23 changed files with 254 additions and 878 deletions

No files matched your search

+5 -8
View File
@@ -64,6 +64,7 @@ declare module '@vue/runtime-core' {
'CTextCopyable.demo': typeof import('./src/ui/c-text-copyable/c-text-copyable.demo.vue')['default']
CTooltip: typeof import('./src/ui/c-tooltip/c-tooltip.vue')['default']
'CTooltip.demo': typeof import('./src/ui/c-tooltip/c-tooltip.demo.vue')['default']
CurlConverter: typeof import('./src/tools/curl-converter/curl-converter.vue')['default']
DateTimeConverter: typeof import('./src/tools/date-time-converter/date-time-converter.vue')['default']
'DemoHome.page': typeof import('./src/ui/demo/demo-home.page.vue')['default']
DemoWrapper: typeof import('./src/ui/demo/demo-wrapper.vue')['default']
@@ -72,7 +73,6 @@ declare module '@vue/runtime-core' {
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
EmailNormalizer: typeof import('./src/tools/email-normalizer/email-normalizer.vue')['default']
EmojiCard: typeof import('./src/tools/emoji-picker/emoji-card.vue')['default']
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
EmojiPicker: typeof import('./src/tools/emoji-picker/emoji-picker.vue')['default']
@@ -111,7 +111,6 @@ declare module '@vue/runtime-core' {
JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default']
JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default']
JsonToToml: typeof import('./src/tools/json-to-toml/json-to-toml.vue')['default']
JsonToXml: typeof import('./src/tools/json-to-xml/json-to-xml.vue')['default']
JsonToYaml: typeof import('./src/tools/json-to-yaml-converter/json-to-yaml.vue')['default']
JsonViewer: typeof import('./src/tools/json-viewer/json-viewer.vue')['default']
JwtParser: typeof import('./src/tools/jwt-parser/jwt-parser.vue')['default']
@@ -129,25 +128,24 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NCheckbox: typeof import('naive-ui')['NCheckbox']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
NGrid: typeof import('naive-ui')['NGrid']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLabel: typeof import('naive-ui')['NLabel']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpin: typeof import('naive-ui')['NSpin']
NTable: typeof import('naive-ui')['NTable']
NSlider: typeof import('naive-ui')['NSlider']
NSwitch: typeof import('naive-ui')['NSwitch']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
@@ -189,7 +187,6 @@ declare module '@vue/runtime-core' {
UuidGenerator: typeof import('./src/tools/uuid-generator/uuid-generator.vue')['default']
WifiQrCodeGenerator: typeof import('./src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue')['default']
XmlFormatter: typeof import('./src/tools/xml-formatter/xml-formatter.vue')['default']
XmlToJson: typeof import('./src/tools/xml-to-json/xml-to-json.vue')['default']
YamlToJson: typeof import('./src/tools/yaml-to-json-converter/yaml-to-json.vue')['default']
YamlToToml: typeof import('./src/tools/yaml-to-toml/yaml-to-toml.vue')['default']
YamlViewer: typeof import('./src/tools/yaml-viewer/yaml-viewer.vue')['default']
+2 -4
View File
@@ -55,9 +55,9 @@
"cron-validator": "^1.3.1",
"cronstrue": "^2.26.0",
"crypto-js": "^4.1.1",
"curlconverter": "^4.10.1",
"date-fns": "^2.29.3",
"dompurify": "^3.0.6",
"email-normalizer": "^1.0.0",
"emojilib": "^3.0.10",
"figlet": "^1.7.0",
"figue": "^1.2.0",
@@ -93,7 +93,6 @@
"vue-router": "^4.1.6",
"vue-tsc": "^1.8.1",
"xml-formatter": "^3.3.2",
"xml-js": "^1.6.11",
"yaml": "^2.2.1"
},
"devDependencies": {
@@ -140,6 +139,5 @@
"vitest": "^0.34.0",
"workbox-window": "^7.0.0",
"zx": "^7.2.1"
},
"packageManager": "pnpm@8.15.3"
}
}
+77 -33
View File
@@ -65,15 +65,15 @@ dependencies:
crypto-js:
specifier: ^4.1.1
version: 4.1.1
curlconverter:
specifier: ^4.10.1
version: 4.10.1
date-fns:
specifier: ^2.29.3
version: 2.29.3
dompurify:
specifier: ^3.0.6
version: 3.0.6
email-normalizer:
specifier: ^1.0.0
version: 1.0.0
emojilib:
specifier: ^3.0.10
version: 3.0.10
@@ -179,9 +179,6 @@ dependencies:
xml-formatter:
specifier: ^3.3.2
version: 3.3.2
xml-js:
specifier: ^1.6.11
version: 1.6.11
yaml:
specifier: ^2.2.1
version: 2.2.1
@@ -3360,7 +3357,7 @@ packages:
dependencies:
'@unhead/dom': 0.5.1
'@unhead/schema': 0.5.1
'@vueuse/shared': 10.11.1(vue@3.3.4)
'@vueuse/shared': 11.2.0(vue@3.3.4)
unhead: 0.5.1
vue: 3.3.4
transitivePeerDependencies:
@@ -3993,19 +3990,19 @@ packages:
- vue
dev: false
/@vueuse/shared@10.11.1(vue@3.3.4):
resolution: {integrity: sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==}
/@vueuse/shared@10.3.0(vue@3.3.4):
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
dependencies:
vue-demi: 0.14.10(vue@3.3.4)
vue-demi: 0.14.5(vue@3.3.4)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
dev: false
/@vueuse/shared@10.3.0(vue@3.3.4):
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
/@vueuse/shared@11.2.0(vue@3.3.4):
resolution: {integrity: sha512-VxFjie0EanOudYSgMErxXfq6fo8vhr5ICI+BuE3I9FnX7ePllEsVrRQ7O6Q1TLgApeLuPKcHQxAXpP+KnlrJsg==}
dependencies:
vue-demi: 0.14.5(vue@3.3.4)
vue-demi: 0.14.10(vue@3.3.4)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
@@ -4721,6 +4718,20 @@ packages:
/csstype@3.1.2:
resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==}
/curlconverter@4.10.1:
resolution: {integrity: sha512-cMV9ZsIBgZCeKiTqOvxtBGB58heQbrulPvtff4IbFunbDIuGWu8ZCDlCIEr74aNGCOfQRv9aery8I2GpYGBzyw==}
hasBin: true
dependencies:
jsesc: 3.0.2
lossless-json: 4.0.1
tree-sitter: 0.21.1
tree-sitter-bash: 0.21.0(tree-sitter@0.21.1)
web-tree-sitter: 0.22.6
yamljs: 0.3.0
transitivePeerDependencies:
- tree_sitter
dev: false
/dash-get@1.0.2:
resolution: {integrity: sha512-4FbVrHDwfOASx7uQVxeiCTo7ggSdYZbqs8lH+WU6ViypPlDbe9y6IP5VVUDQBv9DcnyaiPT5XT0UWHgJ64zLeQ==}
dev: false
@@ -4979,12 +4990,6 @@ packages:
/electron-to-chromium@1.4.572:
resolution: {integrity: sha512-RlFobl4D3ieetbnR+2EpxdzFl9h0RAJkPK3pfiwMug2nhBin2ZCsGIAJWdpNniLz43sgXam/CgipOmvTA+rUiA==}
/email-normalizer@1.0.0:
resolution: {integrity: sha512-wZYuuMtL4kUOmg/TPtCrf9hAZjbFq+FcjWA85Z5nr2lGllRnWJPxCJw3gy4Cx+adMoyVw4VJfGGvt/OHgIW+qg==}
dependencies:
typescript: 5.5.4
dev: false
/emitter-component@1.1.1:
resolution: {integrity: sha512-G+mpdiAySMuB7kesVRLuyvYRqDmshB7ReKEVuyBPkzQlmiDiLrt7hHHIy4Aff552bgknVN7B2/d3lzhGO5dvpQ==}
dev: false
@@ -6578,7 +6583,6 @@ packages:
resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==}
engines: {node: '>=6'}
hasBin: true
dev: true
/json-parse-even-better-errors@2.3.1:
resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
@@ -6732,6 +6736,10 @@ packages:
is-unicode-supported: 0.1.0
dev: true
/lossless-json@4.0.1:
resolution: {integrity: sha512-l0L+ppmgPDnb+JGxNLndPtJZGNf6+ZmVaQzoxQm3u6TXmhdnsA+YtdVR8DjzZd/em58686CQhOFDPewfJ4l7MA==}
dev: false
/loupe@2.3.6:
resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==}
dependencies:
@@ -7062,6 +7070,15 @@ packages:
tslib: 2.5.0
dev: false
/node-addon-api@7.1.1:
resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==}
dev: false
/node-addon-api@8.1.0:
resolution: {integrity: sha512-yBY+qqWSv3dWKGODD6OGE6GnTX7Q2r+4+DfpqxHSHh8x0B4EKP9+wVGLS6U/AM1vxSNNmUEuIV5EGhYwPpfOwQ==}
engines: {node: ^18 || ^20 || >= 21}
dev: false
/node-domexception@1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
@@ -7085,6 +7102,11 @@ packages:
engines: {node: '>= 6.13.0'}
dev: false
/node-gyp-build@4.8.1:
resolution: {integrity: sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==}
hasBin: true
dev: false
/node-releases@2.0.12:
resolution: {integrity: sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ==}
dev: true
@@ -7971,6 +7993,8 @@ packages:
/sax@1.2.4:
resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==}
requiresBuild: true
dev: true
optional: true
/saxes@6.0.0:
resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}
@@ -8498,6 +8522,30 @@ packages:
punycode: 2.3.0
dev: true
/tree-sitter-bash@0.21.0(tree-sitter@0.21.1):
resolution: {integrity: sha512-UuXf+wliu1mmS/O2Iz7OQghExM4a+lk+GaVPndZVpAJnFuzanaN33UcHOsrmngHxaOXHz5JSZrwp6i2qM/PKag==}
requiresBuild: true
peerDependencies:
tree-sitter: ^0.21.0
tree_sitter: '*'
peerDependenciesMeta:
tree_sitter:
optional: true
dependencies:
node-addon-api: 7.1.1
node-gyp-build: 4.8.1
tree-sitter: 0.21.1
web-tree-sitter: 0.21.0
dev: false
/tree-sitter@0.21.1:
resolution: {integrity: sha512-7dxoA6kYvtgWw80265MyqJlkRl4yawIjO7S5MigytjELkX43fV2WsAXzsNfO7sBpPPCF5Gp0+XzHk0DwLCq3xQ==}
requiresBuild: true
dependencies:
node-addon-api: 8.1.0
node-gyp-build: 4.8.1
dev: false
/treemate@0.3.11:
resolution: {integrity: sha512-M8RGFoKtZ8dF+iwJfAJTOH/SM4KluKOKRJpjCMhI8bG3qB74zrFoArKZ62ll0Fr3mqkMJiQOmWYkdYgDeITYQg==}
dev: false
@@ -8613,12 +8661,6 @@ packages:
engines: {node: '>=14.17'}
hasBin: true
/typescript@5.5.4:
resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==}
engines: {node: '>=14.17'}
hasBin: true
dev: false
/ua-parser-js@1.0.35:
resolution: {integrity: sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA==}
dev: false
@@ -9292,6 +9334,14 @@ packages:
engines: {node: '>= 8'}
dev: true
/web-tree-sitter@0.21.0:
resolution: {integrity: sha512-iJ+QJ6ikN9D9cG7Kh6q3KtAstYFUQbYZ8OjuPEJYWfj2kLrmp5I3C2n6WjE1Y3jvj7nJbkcrJytJGWUEhCxn+g==}
dev: false
/web-tree-sitter@0.22.6:
resolution: {integrity: sha512-hS87TH71Zd6mGAmYCvlgxeGDjqd9GTeqXNqTT+u0Gs51uIozNIaaq/kUAbV/Zf56jb2ZOyG8BxZs2GG9wbLi6Q==}
dev: false
/webidl-conversions@4.0.2:
resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==}
dev: true
@@ -9566,13 +9616,6 @@ packages:
xml-parser-xo: 4.0.5
dev: false
/xml-js@1.6.11:
resolution: {integrity: sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==}
hasBin: true
dependencies:
sax: 1.2.4
dev: false
/xml-name-validator@4.0.0:
resolution: {integrity: sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==}
engines: {node: '>=12'}
@@ -9616,6 +9659,7 @@ packages:
/yamljs@0.3.0:
resolution: {integrity: sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==}
hasBin: true
dependencies:
argparse: 1.0.10
glob: 7.2.3
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
-21
View File
@@ -1,21 +0,0 @@
import _ from 'lodash';
function useDebouncedRef<T>(initialValue: T, delay: number, immediate: boolean = false) {
const state = ref(initialValue);
const debouncedRef = customRef((track, trigger) => ({
get() {
track();
return state.value;
},
set: _.debounce(
(value) => {
state.value = value;
trigger();
},
delay,
{ leading: immediate },
),
}));
return debouncedRef;
}
export default useDebouncedRef;
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { computeChmodOctalRepresentation, computeChmodSymbolicRepresentation, computePermissionsFromChmodOctalRepresentation, computePermissionsFromChmodSymbolicRepresentation, computeUmaskRepresentation } from './chmod-calculator.service';
import { computeChmodOctalRepresentation, computeChmodSymbolicRepresentation } from './chmod-calculator.service';
describe('chmod-calculator', () => {
describe('computeChmodOctalRepresentation', () => {
@@ -10,7 +10,6 @@ describe('chmod-calculator', () => {
owner: { read: true, write: true, execute: true },
group: { read: true, write: true, execute: true },
public: { read: true, write: true, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('777');
@@ -21,7 +20,6 @@ describe('chmod-calculator', () => {
owner: { read: false, write: false, execute: false },
group: { read: false, write: false, execute: false },
public: { read: false, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('000');
@@ -32,7 +30,6 @@ describe('chmod-calculator', () => {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: true },
public: { read: true, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('235');
@@ -43,7 +40,6 @@ describe('chmod-calculator', () => {
owner: { read: true, write: false, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('421');
@@ -54,7 +50,6 @@ describe('chmod-calculator', () => {
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('124');
@@ -65,57 +60,11 @@ describe('chmod-calculator', () => {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('222');
expect(
computeChmodOctalRepresentation({
permissions: {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: true, setgid: true, stickybit: true },
},
}),
).to.eql('7222');
expect(
computeChmodOctalRepresentation({
permissions: {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: true, setgid: false, stickybit: false },
},
}),
).to.eql('4222');
expect(
computeChmodOctalRepresentation({
permissions: {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: true, stickybit: false },
},
}),
).to.eql('2222');
expect(
computeChmodOctalRepresentation({
permissions: {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: false, stickybit: true },
},
}),
).to.eql('1222');
});
});
describe('computeChmodSymbolicRepresentation', () => {
it('get the symbolic representation from permissions', () => {
expect(
computeChmodSymbolicRepresentation({
@@ -123,7 +72,6 @@ describe('chmod-calculator', () => {
owner: { read: true, write: true, execute: true },
group: { read: true, write: true, execute: true },
public: { read: true, write: true, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('rwxrwxrwx');
@@ -134,7 +82,6 @@ describe('chmod-calculator', () => {
owner: { read: false, write: false, execute: false },
group: { read: false, write: false, execute: false },
public: { read: false, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('---------');
@@ -145,7 +92,6 @@ describe('chmod-calculator', () => {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: true },
public: { read: true, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('-w--wxr-x');
@@ -156,7 +102,6 @@ describe('chmod-calculator', () => {
owner: { read: true, write: false, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('r---w---x');
@@ -167,7 +112,6 @@ describe('chmod-calculator', () => {
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('--x-w-r--');
@@ -178,382 +122,9 @@ describe('chmod-calculator', () => {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('-w--w--w-');
expect(
computeChmodSymbolicRepresentation({
permissions: {
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: true },
},
}),
).to.eql('--x-w-r-t');
expect(
computeChmodSymbolicRepresentation({
permissions: {
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: true, stickybit: true },
},
}),
).to.eql('--x-wsr-t');
expect(
computeChmodSymbolicRepresentation({
permissions: {
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: true, setgid: true, stickybit: true },
},
}),
).to.eql('--s-wsr-t');
expect(
computeChmodSymbolicRepresentation({
permissions: {
owner: { read: true, write: false, execute: true },
group: { read: true, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.eql('r-xrw-r--');
expect(
computeChmodSymbolicRepresentation({
permissions: {
owner: { read: true, write: true, execute: true },
group: { read: true, write: true, execute: true },
public: { read: true, write: true, execute: true },
flags: { setuid: true, setgid: true, stickybit: true },
},
}),
).to.eql('rwsrwsrwt');
});
});
describe('computePermissionsFromChmodOctalRepresentation', () => {
it('throws on invalid octal values', () => {
expect(() => computePermissionsFromChmodOctalRepresentation('12')).to.throw();
expect(() => computePermissionsFromChmodOctalRepresentation('12345')).to.throw();
expect(() => computePermissionsFromChmodOctalRepresentation('999')).to.throw();
expect(() => computePermissionsFromChmodOctalRepresentation('9999')).to.throw();
});
it('get permissions from octal representation', () => {
expect(
computePermissionsFromChmodOctalRepresentation('777'),
).to.eql({
owner: { read: true, write: true, execute: true },
group: { read: true, write: true, execute: true },
public: { read: true, write: true, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('000'),
).to.eql({
owner: { read: false, write: false, execute: false },
group: { read: false, write: false, execute: false },
public: { read: false, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('235'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: true },
public: { read: true, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('421'),
).to.eql({
owner: { read: true, write: false, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('124'),
).to.eql({
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('222'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('7222'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: true, setgid: true, stickybit: true },
});
expect(
computePermissionsFromChmodOctalRepresentation('4222'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: true, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('2222'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: true, stickybit: false },
});
expect(
computePermissionsFromChmodOctalRepresentation('1222'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: false, stickybit: true },
});
});
});
describe('computePermissionsFromChmodSymbolicRepresentation', () => {
it('throws on invalid symbolic values', () => {
expect(() => computePermissionsFromChmodSymbolicRepresentation('rr---')).to.throw();
expect(() => computePermissionsFromChmodSymbolicRepresentation('rwxrwx--w')).to.throw();
});
it('get permissions from symbolic representation', () => {
expect(
computePermissionsFromChmodSymbolicRepresentation('dr-xr-xr-x'),
).to.eql({
owner: { read: true, write: false, execute: true },
group: { read: true, write: false, execute: true },
public: { read: true, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('-rw-r--r--'),
).to.eql({
owner: { read: true, write: true, execute: false },
group: { read: true, write: false, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('rwxrwxrwx'),
).to.eql({
owner: { read: true, write: true, execute: true },
group: { read: true, write: true, execute: true },
public: { read: true, write: true, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('---------'),
).to.eql({
owner: { read: false, write: false, execute: false },
group: { read: false, write: false, execute: false },
public: { read: false, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('r---wxr-x'),
).to.eql({
owner: { read: true, write: false, execute: false },
group: { read: false, write: true, execute: true },
public: { read: true, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('r---w---x'),
).to.eql({
owner: { read: true, write: false, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('--x-w-r--'),
).to.eql({
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('-w--w--w-'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('-ws-ws-wt'),
).to.eql({
owner: { read: false, write: true, execute: true },
group: { read: false, write: true, execute: true },
public: { read: false, write: true, execute: true },
flags: { setuid: true, setgid: true, stickybit: true },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('-ws-w--w-'),
).to.eql({
owner: { read: false, write: true, execute: true },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: true, setgid: false, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('-w--ws-w-'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: true },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: true, stickybit: false },
});
expect(
computePermissionsFromChmodSymbolicRepresentation('-w--w--wt'),
).to.eql({
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: true },
flags: { setuid: false, setgid: false, stickybit: true },
});
});
});
describe('computeUmaskRepresentation', () => {
it('get the umask from permissions', () => {
expect(
computeUmaskRepresentation({
permissions: {
owner: { read: true, write: true, execute: true },
group: { read: true, write: true, execute: true },
public: { read: true, write: true, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.deep.eq({
octal: '000',
symbolic: 'umask u=rwx,g=rwx,o=rwx',
});
expect(
computeUmaskRepresentation({
permissions: {
owner: { read: false, write: false, execute: false },
group: { read: false, write: false, execute: false },
public: { read: false, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.deep.eq({
octal: '777',
symbolic: 'umask u=,g=,o=',
});
expect(
computeUmaskRepresentation({
permissions: {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: true },
public: { read: true, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.deep.eq({
octal: '542',
symbolic: 'umask u=w,g=wx,o=rx',
});
expect(
computeUmaskRepresentation({
permissions: {
owner: { read: true, write: false, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: false, execute: true },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.deep.eq({
octal: '356',
symbolic: 'umask u=r,g=w,o=x',
});
expect(
computeUmaskRepresentation({
permissions: {
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.deep.eq({
octal: '653',
symbolic: 'umask u=x,g=w,o=r',
});
expect(
computeUmaskRepresentation({
permissions: {
owner: { read: false, write: true, execute: false },
group: { read: false, write: true, execute: false },
public: { read: false, write: true, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
},
}),
).to.deep.eq({
octal: '555',
symbolic: 'umask u=w,g=w,o=w',
});
expect(
computeUmaskRepresentation({
permissions: {
owner: { read: false, write: false, execute: true },
group: { read: false, write: true, execute: false },
public: { read: true, write: false, execute: false },
flags: { setuid: true, setgid: true, stickybit: true },
},
}),
).to.deep.eq({
octal: '653',
symbolic: 'umask u=x,g=w,o=r',
});
});
});
});
@@ -1,21 +1,15 @@
import _ from 'lodash';
import type { GroupPermissions, Permissions, SpecialPermissions } from './chmod-calculator.types';
import type { GroupPermissions, Permissions } from './chmod-calculator.types';
export { computeUmaskRepresentation, computeChmodOctalRepresentation, computeChmodSymbolicRepresentation, computePermissionsFromChmodOctalRepresentation, computePermissionsFromChmodSymbolicRepresentation };
export { computeChmodOctalRepresentation, computeChmodSymbolicRepresentation };
function computeChmodOctalRepresentation({ permissions }: { permissions: Permissions }): string {
const permissionValue = { read: 4, write: 2, execute: 1 };
const specialPermissionValue = { setuid: 4, setgid: 2, stickybit: 1 };
const getGroupPermissionValue = (permission: GroupPermissions) =>
_.reduce(permission, (acc, isPermSet, key) => acc + (isPermSet ? _.get(permissionValue, key, 0) : 0), 0);
const getSpecialPermissionValue = (permission: SpecialPermissions) => {
const octalValue = _.reduce(permission, (acc, isPermSet, key) => acc + (isPermSet ? _.get(specialPermissionValue, key, 0) : 0), 0);
return octalValue > 0 ? octalValue.toString() : '';
};
return [
getSpecialPermissionValue(permissions.flags || { setuid: false, setgid: false, stickybit: false }),
getGroupPermissionValue(permissions.owner),
getGroupPermissionValue(permissions.group),
getGroupPermissionValue(permissions.public),
@@ -24,92 +18,13 @@ function computeChmodOctalRepresentation({ permissions }: { permissions: Permiss
function computeChmodSymbolicRepresentation({ permissions }: { permissions: Permissions }): string {
const permissionValue = { read: 'r', write: 'w', execute: 'x' };
const specialFlagPermission = 'execute';
const getGroupPermissionValue = (permission: GroupPermissions, specialFlag: null | 's' | 't') =>
_.reduce(permission, (acc, isPermSet, key) => acc + ((key === specialFlagPermission ? specialFlag : undefined)
|| (isPermSet ? _.get(permissionValue, key, '') : '-')), '');
const getGroupPermissionValue = (permission: GroupPermissions) =>
_.reduce(permission, (acc, isPermSet, key) => acc + (isPermSet ? _.get(permissionValue, key, '') : '-'), '');
return [
getGroupPermissionValue(permissions.owner, permissions.flags?.setuid ? 's' : null),
getGroupPermissionValue(permissions.group, permissions.flags?.setgid ? 's' : null),
getGroupPermissionValue(permissions.public, permissions.flags?.stickybit ? 't' : null),
getGroupPermissionValue(permissions.owner),
getGroupPermissionValue(permissions.group),
getGroupPermissionValue(permissions.public),
].join('');
}
function computePermissionsFromChmodOctalRepresentation(octalPermissions: string): Permissions {
const permissionValue = { read: 4, write: 2, execute: 1 };
const specialPermissionValue = { setuid: 4, setgid: 2, stickybit: 1 };
if (!octalPermissions || !octalPermissions.match(/^[0-7]{3,4}$/)) {
throw new Error(`Invalid octal permissions (must be 3 or 4 octal digits): ${octalPermissions}`);
}
const fullOctalPermissions = octalPermissions.length === 3 ? `0${octalPermissions}` : octalPermissions;
const hasSet = (position: number, flagValue: number) => (Number(fullOctalPermissions[position]) & flagValue) === flagValue;
function computePermissionObject<T>(permissionSet: object, position: number): T {
return _.reduce(permissionSet, (acc, flag, key) => ({ ...acc, [key]: hasSet(position, flag) }), {}) as T;
}
const flagsPosition = 0;
const ownerPosition = 1;
const groupPosition = 2;
const publicPosition = 3;
return {
owner: computePermissionObject(permissionValue, ownerPosition),
group: computePermissionObject(permissionValue, groupPosition),
public: computePermissionObject(permissionValue, publicPosition),
flags: computePermissionObject(specialPermissionValue, flagsPosition),
};
}
function computePermissionsFromChmodSymbolicRepresentation(symbolicPermissions: string): Permissions {
const formatRegex = /^[-dlbcsp]?([r-])([w-])([xs-])([r-])([w-])([xs-])([r-])([w-])([xt-])$/;
if (!symbolicPermissions || !symbolicPermissions.match(formatRegex)) {
throw new Error(`Invalid string permissions (must be in form 'rwxrwxrwx'): ${symbolicPermissions}`);
}
const [_, rOwner, wOwner, xOwner, rGroup, wGroup, xGroup, rAll, wAll, xAll] = formatRegex.exec(symbolicPermissions) || [];
const getOctal = (flag: string, flagLetter: string, flagValue: number) => flag === flagLetter ? flagValue : 0;
const owner = getOctal(rOwner, 'r', 4)
+ getOctal(wOwner, 'w', 2)
+ getOctal(xOwner, 'x', 1) + getOctal(xOwner, 's', 1);
const groups = getOctal(rGroup, 'r', 4)
+ getOctal(wGroup, 'w', 2)
+ getOctal(xGroup, 'x', 1) + getOctal(xGroup, 's', 1);
const all = getOctal(rAll, 'r', 4)
+ getOctal(wAll, 'w', 2)
+ getOctal(xAll, 'x', 1) + getOctal(xAll, 't', 1);
const flags = getOctal(xOwner, 's', 4)
+ getOctal(xGroup, 's', 2)
+ getOctal(xAll, 't', 1);
const octalString = `${(flags > 0 ? flags : '')}${owner}${groups}${all}`;
return computePermissionsFromChmodOctalRepresentation(octalString);
}
function computeUmaskRepresentation({ permissions }: { permissions: Permissions }): {
octal: string
symbolic: string
} {
const permissionValue = { read: 'r', write: 'w', execute: 'x' };
const getGroupPermissionValue = (permission: GroupPermissions) =>
_.reduce(permission, (acc, isPermSet, key) => acc + ((isPermSet ? _.get(permissionValue, key, '') : '')), '');
const symbolic = `umask u=${getGroupPermissionValue(permissions.owner)},g=${getGroupPermissionValue(permissions.group)},o=${getGroupPermissionValue(permissions.public)}`;
const octal = (0o777 - Number.parseInt(
computeChmodOctalRepresentation({
permissions:
{
owner: permissions.owner,
group: permissions.group,
public: permissions.public,
flags: { setuid: false, setgid: false, stickybit: false },
},
}), 8))
.toString(8)
.padStart(3, '0');
return {
symbolic, octal,
};
}
@@ -1,17 +1,10 @@
export type Scope = 'read' | 'write' | 'execute';
export type Group = 'owner' | 'group' | 'public';
export type SpecialFlags = 'setuid' | 'setgid' | 'stickybit';
export type GroupPermissions = {
[k in Scope]: boolean;
};
export type SpecialPermissions = {
[k in SpecialFlags]: boolean;
};
export type Permissions = {
[k in Group]: GroupPermissions;
} & {
flags: SpecialPermissions
};
@@ -2,10 +2,9 @@
import { useThemeVars } from 'naive-ui';
import InputCopyable from '../../components/InputCopyable.vue';
import { computeChmodOctalRepresentation, computeChmodSymbolicRepresentation, computePermissionsFromChmodOctalRepresentation, computePermissionsFromChmodSymbolicRepresentation, computeUmaskRepresentation } from './chmod-calculator.service';
import { computeChmodOctalRepresentation, computeChmodSymbolicRepresentation } from './chmod-calculator.service';
import type { Group, Scope } from './chmod-calculator.types';
import { useValidation } from '@/composable/validation';
const themeVars = useThemeVars();
@@ -20,92 +19,14 @@ const permissions = ref({
owner: { read: false, write: false, execute: false },
group: { read: false, write: false, execute: false },
public: { read: false, write: false, execute: false },
flags: { setuid: false, setgid: false, stickybit: false },
});
const octalPermissionsInput = ref('000');
const octalPermissionsInputValidation = useValidation({
source: octalPermissionsInput,
rules: [
{
message: 'Invalid octal permission string',
validator: (value) => {
try {
computePermissionsFromChmodOctalRepresentation(value.trim());
return true;
}
catch {
return false;
}
},
},
],
});
watch(
octalPermissionsInput,
(newPermissions) => {
if (!octalPermissionsInputValidation.isValid) {
return;
}
permissions.value = computePermissionsFromChmodOctalRepresentation(newPermissions.trim());
},
);
const symbolicPermissionsInput = ref('---------');
const symbolicPermissionsInputValidation = useValidation({
source: symbolicPermissionsInput,
rules: [
{
message: 'Invalid symbolic permission string',
validator: (value) => {
try {
computePermissionsFromChmodSymbolicRepresentation(value.trim());
return true;
}
catch {
return false;
}
},
},
],
});
watch(
symbolicPermissionsInput,
(newPermissions) => {
if (!symbolicPermissionsInputValidation.isValid) {
return;
}
permissions.value = computePermissionsFromChmodSymbolicRepresentation(newPermissions.trim());
},
);
const octal = computed(() => computeChmodOctalRepresentation({ permissions: permissions.value }));
const symbolic = computed(() => computeChmodSymbolicRepresentation({ permissions: permissions.value }));
const umask = computed(() => computeUmaskRepresentation({ permissions: permissions.value }));
</script>
<template>
<div>
<c-input-text
v-model:value="octalPermissionsInput"
placeholder="Put your octal permissions here..."
label="Copy your octal permissions"
:validation="octalPermissionsInputValidation"
mb-2
/>
<n-divider />
<c-input-text
v-model:value="symbolicPermissionsInput"
placeholder="Put your symbolic permissions here..."
label="Copy your symbolic permissions"
:validation="symbolicPermissionsInputValidation"
mb-2
/>
<n-divider />
<n-table :bordered="false" :bottom-bordered="false" single-column class="permission-table">
<thead>
<tr>
@@ -131,20 +52,6 @@ const umask = computed(() => computeUmaskRepresentation({ permissions: permissio
<n-checkbox v-model:checked="permissions[group][scope]" size="large" />
</td>
</tr>
<tr>
<td class="line-header">
Flags
</td>
<td class="text-center">
<n-checkbox v-model:checked="permissions.flags.setuid" size="large" />
</td>
<td class="text-center">
<n-checkbox v-model:checked="permissions.flags.setgid" size="large" />
</td>
<td class="text-center">
<n-checkbox v-model:checked="permissions.flags.stickybit" size="large" />
</td>
</tr>
</tbody>
</n-table>
@@ -156,11 +63,6 @@ const umask = computed(() => computeUmaskRepresentation({ permissions: permissio
</div>
<InputCopyable :value="`chmod ${octal} path`" readonly />
<c-card title="Umask">
<InputCopyable :value="umask.octal" readonly />
<InputCopyable :value="umask.symbolic" readonly />
</c-card>
</div>
</template>
+3 -3
View File
@@ -1,10 +1,11 @@
import { FileInvoice } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: 'Chmod calculator',
name: translate('tools.chmod-calculator.title'),
path: '/chmod-calculator',
description: 'Compute your chmod permissions and commands with this online chmod calculator.',
description: translate('tools.chmod-calculator.description'),
keywords: [
'chmod',
'calculator',
@@ -16,7 +17,6 @@ export const tool = defineTool({
'recursive',
'generator',
'octal',
'umask',
],
component: () => import('./chmod-calculator.vue'),
icon: FileInvoice,
+133
View File
@@ -0,0 +1,133 @@
<script setup lang="ts">
import {
type Warnings, toAnsible, toAnsibleWarn, toCFML, toCFMLWarn, toCSharp,
toCSharpWarn, toClojure, toClojureWarn, toDart, toDartWarn, toElixir, toElixirWarn, toGo,
toGoWarn, toHTTP, toHTTPWarn, toHarString, toHarStringWarn, toHttpie, toHttpieWarn, toJava,
toJavaHttpUrlConnection, toJavaHttpUrlConnectionWarn, toJavaJsoup, toJavaJsoupWarn, toJavaOkHttp,
toJavaOkHttpWarn, toJavaScript, toJavaScriptJquery, toJavaScriptJqueryWarn, toJavaScriptWarn, toJavaScriptXHR,
toJavaScriptXHRWarn, toJavaWarn, toJsonString, toJsonStringWarn, toJulia, toJuliaWarn, toKotlin, toKotlinWarn, toLua,
toLuaWarn, toMATLAB, toMATLABWarn, toNode, toNodeAxios, toNodeAxiosWarn, toNodeGot, toNodeGotWarn, toNodeHttp,
toNodeHttpWarn, toNodeKy, toNodeKyWarn, toNodeRequest, toNodeRequestWarn, toNodeSuperAgent, toNodeSuperAgentWarn,
toNodeWarn, toOCaml, toOCamlWarn, toObjectiveC, toObjectiveCWarn, toPerl, toPerlWarn, toPhp, toPhpGuzzle,
toPhpGuzzleWarn, toPhpRequests, toPhpRequestsWarn, toPhpWarn, toPowershellRestMethod,
toPowershellRestMethodWarn, toPowershellWebRequest, toPowershellWebRequestWarn, toPython, toPythonHttp, toPythonHttpWarn, toPythonWarn,
toR, toRWarn, toRuby, toRubyWarn, toRust, toRustWarn, toSwift, toSwiftWarn, toWget,
toWgetWarn,
} from 'curlconverter';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const translate = {
'ansible': [toAnsible, toAnsibleWarn],
'cfml': [toCFML, toCFMLWarn],
'clojure': [toClojure, toClojureWarn],
'csharp': [toCSharp, toCSharpWarn],
'c#': [toCSharp, toCSharpWarn],
'browser': [toJavaScript, toJavaScriptWarn],
'dart': [toDart, toDartWarn],
'elixir': [toElixir, toElixirWarn],
'go': [toGo, toGoWarn],
'golang': [toGo, toGoWarn],
'har': [toHarString, toHarStringWarn],
'http': [toHTTP, toHTTPWarn],
'httpie': [toHttpie, toHttpieWarn],
'java': [toJava, toJavaWarn],
'java-httpurlconnection': [
toJavaHttpUrlConnection,
toJavaHttpUrlConnectionWarn,
],
'java-jsoup': [toJavaJsoup, toJavaJsoupWarn],
'java-okhttp': [toJavaOkHttp, toJavaOkHttpWarn],
'javascript': [toJavaScript, toJavaScriptWarn],
'javascript-axios': [toNodeAxios, toNodeAxiosWarn],
'javascript-fetch': [toJavaScript, toJavaScriptWarn],
'javascript-got': [toNodeGot, toNodeGotWarn],
'javascript-ky': [toNodeKy, toNodeKyWarn],
'javascript-jquery': [toJavaScriptJquery, toJavaScriptJqueryWarn],
'javascript-request': [toNodeRequest, toNodeRequestWarn],
'javascript-superagent': [toNodeSuperAgent, toNodeSuperAgentWarn],
'javascript-xhr': [toJavaScriptXHR, toJavaScriptXHRWarn],
'json': [toJsonString, toJsonStringWarn],
'julia': [toJulia, toJuliaWarn],
'kotlin': [toKotlin, toKotlinWarn],
'lua': [toLua, toLuaWarn],
'matlab': [toMATLAB, toMATLABWarn],
'node': [toNode, toNodeWarn],
'nodejs': [toNode, toNodeWarn],
'nodejs-axios': [toNodeAxios, toNodeAxiosWarn],
'nodejs-got': [toNodeGot, toNodeGotWarn],
'nodejs-http': [toNodeHttp, toNodeHttpWarn],
'nodejs-ky': [toNodeKy, toNodeKyWarn],
'nodejs-jquery': [toJavaScriptJquery, toJavaScriptJqueryWarn],
'nodejs-request': [toNodeRequest, toNodeRequestWarn],
'nodejs-superagent': [toNodeSuperAgent, toNodeSuperAgentWarn],
'nodejs-xhr': [toJavaScriptXHR, toJavaScriptXHRWarn],
'objc': [toObjectiveC, toObjectiveCWarn],
'objective-c': [toObjectiveC, toObjectiveCWarn],
'ocaml': [toOCaml, toOCamlWarn],
'perl': [toPerl, toPerlWarn],
'php': [toPhp, toPhpWarn],
'php-guzzle': [toPhpGuzzle, toPhpGuzzleWarn],
'php-requests': [toPhpRequests, toPhpRequestsWarn],
'powershell': [toPowershellRestMethod, toPowershellRestMethodWarn],
'powershell-webrequest': [
toPowershellWebRequest,
toPowershellWebRequestWarn,
],
'python': [toPython, toPythonWarn],
'python-http': [toPythonHttp, toPythonHttpWarn],
'r': [toR, toRWarn],
'ruby': [toRuby, toRubyWarn],
'rust': [toRust, toRustWarn],
'swift': [toSwift, toSwiftWarn],
'wget': [toWget, toWgetWarn],
};
const language = ref('python');
const curl = ref('curl --data "hello=world" example.com');
const inlang = computed(() => {
try {
let curlCommand = curl.value;
if (!curlCommand.startsWith('curl ')) {
curlCommand = `curl ${curlCommand}`;
}
const [translated, warnings] = translate[language.value as (keyof typeof translate)][1](curlCommand);
return {
translated,
warnings,
};
}
catch (e: any) {
return {
translated: e.toString(),
warnings: [],
};
}
});
</script>
<template>
<div>
<c-input-text
v-model:value="curl"
size="large"
placeholder="Your curl command"
mb-3
/>
<c-select
v-model:value="language"
searchable
label="Language:"
:options="Object.keys(translate)"
/>
<n-divider />
<n-form-item label="Curl language equivalent:">
<TextareaCopyable :value="inlang.translated as string" />
</n-form-item>
<n-form-item label="Warnings:">
<TextareaCopyable style="color: red" :value="(inlang.warnings as Warnings || []).map(w => w[1]).join('\n')" />
</n-form-item>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { ExternalLink } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Curl Converter',
path: '/curl-converter',
description: 'Generate common coding languages version of provided curl command line',
keywords: ['curl', 'code', 'language', 'generator'],
component: () => import('./curl-converter.vue'),
icon: ExternalLink,
createdAt: new Date('2024-04-20'),
});
@@ -1,65 +0,0 @@
<script setup lang="ts">
import { normalizeEmail } from 'email-normalizer';
import { withDefaultOnError } from '@/utils/defaults';
import { useCopy } from '@/composable/copy';
const emails = ref('');
const normalizedEmails = computed(() => {
if (!emails.value) {
return '';
}
return emails.value
.split('\n')
.map((email) => {
return withDefaultOnError(() => normalizeEmail({ email }), `Unable to parse email: ${email}`);
})
.join('\n');
});
const { copy } = useCopy({ source: normalizedEmails, text: 'Normalized emails copied to the clipboard', createToast: true });
</script>
<template>
<div>
<div class="mb-2">
Raw emails to normalize:
</div>
<c-input-text
v-model:value="emails"
placeholder="Put your emails here (one per line)..."
rows="3"
multiline
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
autofocus
monospace
/>
<div class="mb-2 mt-4">
Normalized emails:
</div>
<c-input-text
:value="normalizedEmails"
placeholder="Normalized emails will appear here..."
rows="3"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
multiline
readonly
monospace
/>
<div class="mt-4 flex justify-center gap-2">
<c-button @click="emails = ''">
Clear emails
</c-button>
<c-button :disabled="!normalizedEmails" @click="copy()">
Copy normalized emails
</c-button>
</div>
</div>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { Mail } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Email normalizer',
path: '/email-normalizer',
description: 'Normalize email addresses to a standard format for easier comparison. Useful for deduplication and data cleaning.',
keywords: ['email', 'normalizer'],
component: () => import('./email-normalizer.vue'),
icon: Mail,
createdAt: new Date('2024-08-15'),
});
+1 -2
View File
@@ -4,7 +4,6 @@ import emojiKeywords from 'emojilib';
import _ from 'lodash';
import type { EmojiInfo } from './emoji.types';
import { useFuzzySearch } from '@/composable/fuzzySearch';
import useDebouncedRef from '@/composable/debouncedref';
const escapeUnicode = ({ emoji }: { emoji: string }) => emoji.split('').map(unit => `\\u${unit.charCodeAt(0).toString(16).padStart(4, '0')}`).join('');
const getEmojiCodePoints = ({ emoji }: { emoji: string }) => emoji.codePointAt(0) ? `0x${emoji.codePointAt(0)?.toString(16)}` : undefined;
@@ -24,7 +23,7 @@ const emojisGroups: { emojiInfos: EmojiInfo[]; group: string }[] = _
.map((emojiInfos, group) => ({ group, emojiInfos }))
.value();
const searchQuery = useDebouncedRef('', 500);
const searchQuery = ref('');
const { searchResult } = useFuzzySearch({
search: searchQuery,
+2 -6
View File
@@ -1,14 +1,12 @@
import { tool as base64FileConverter } from './base64-file-converter';
import { tool as base64StringConverter } from './base64-string-converter';
import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as emailNormalizer } from './email-normalizer';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as xmlToJson } from './xml-to-json';
import { tool as jsonToXml } from './json-to-xml';
import { tool as curlConverter } from './curl-converter';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -110,8 +108,6 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
xmlToJson,
jsonToXml,
],
},
{
@@ -153,7 +149,7 @@ export const toolsByCategory: ToolCategory[] = [
dockerRunToDockerComposeConverter,
xmlFormatter,
yamlViewer,
emailNormalizer,
curlConverter,
],
},
{
-12
View File
@@ -1,12 +0,0 @@
import { Braces } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'JSON to XML',
path: '/json-to-xml',
description: 'Convert JSON to XML',
keywords: ['json', 'xml'],
component: () => import('./json-to-xml.vue'),
icon: Braces,
createdAt: new Date('2024-08-09'),
});
-32
View File
@@ -1,32 +0,0 @@
<script setup lang="ts">
import convert from 'xml-js';
import JSON5 from 'json5';
import { withDefaultOnError } from '@/utils/defaults';
import type { UseValidationRule } from '@/composable/validation';
const defaultValue = '{"a":{"_attributes":{"x":"1.234","y":"It\'s"}}}';
function transformer(value: string) {
return withDefaultOnError(() => {
return convert.js2xml(JSON5.parse(value), { compact: true });
}, '');
}
const rules: UseValidationRule<string>[] = [
{
validator: (v: string) => v === '' || JSON5.parse(v),
message: 'Provided JSON is not valid.',
},
];
</script>
<template>
<format-transformer
input-label="Your JSON content"
:input-default="defaultValue"
input-placeholder="Paste your JSON content here..."
output-label="Converted XML"
output-language="xml"
:transformer="transformer"
:input-validation-rules="rules"
/>
</template>
@@ -2,7 +2,6 @@
import { generateLoremIpsum } from './lorem-ipsum-generator.service';
import { useCopy } from '@/composable/copy';
import { randIntFromInterval } from '@/utils/random';
import { computedRefreshable } from '@/composable/computedRefreshable';
const paragraphs = ref(1);
const sentences = ref([3, 8]);
@@ -10,7 +9,7 @@ const words = ref([8, 15]);
const startWithLoremIpsum = ref(true);
const asHTML = ref(false);
const [loremIpsumText, refreshLoremIpsum] = computedRefreshable(() =>
const loremIpsumText = computed(() =>
generateLoremIpsum({
paragraphCount: paragraphs.value,
asHTML: asHTML.value,
@@ -19,7 +18,6 @@ const [loremIpsumText, refreshLoremIpsum] = computedRefreshable(() =>
startWithLoremIpsum: startWithLoremIpsum.value,
}),
);
const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to the clipboard' });
</script>
@@ -43,13 +41,10 @@ const { copy } = useCopy({ source: loremIpsumText, text: 'Lorem ipsum copied to
<c-input-text :value="loremIpsumText" multiline placeholder="Your lorem ipsum..." readonly mt-5 rows="5" />
<div mt-5 flex justify-center gap-3>
<div mt-5 flex justify-center>
<c-button autofocus @click="copy()">
Copy
</c-button>
<c-button @click="refreshLoremIpsum">
Refresh
</c-button>
</div>
</c-card>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { Braces } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'XML to JSON',
path: '/xml-to-json',
description: 'Convert XML to JSON',
keywords: ['xml', 'json'],
component: () => import('./xml-to-json.vue'),
icon: Braces,
createdAt: new Date('2024-08-09'),
});
-32
View File
@@ -1,32 +0,0 @@
<script setup lang="ts">
import convert from 'xml-js';
import { isValidXML } from '../xml-formatter/xml-formatter.service';
import { withDefaultOnError } from '@/utils/defaults';
import type { UseValidationRule } from '@/composable/validation';
const defaultValue = '<a x="1.234" y="It\'s"/>';
function transformer(value: string) {
return withDefaultOnError(() => {
return JSON.stringify(convert.xml2js(value, { compact: true }), null, 2);
}, '');
}
const rules: UseValidationRule<string>[] = [
{
validator: isValidXML,
message: 'Provided XML is not valid.',
},
];
</script>
<template>
<format-transformer
input-label="Your XML content"
:input-default="defaultValue"
input-placeholder="Paste your XML content here..."
output-label="Converted JSON"
output-language="json"
:transformer="transformer"
:input-validation-rules="rules"
/>
</template>
+7
View File
@@ -113,4 +113,11 @@ export default defineConfig({
build: {
target: 'esnext',
},
optimizeDeps: {
esbuildOptions: {
supported: {
'top-level-await': true,
},
},
},
});