Skip to content

Commit e7c696b

Browse files
committedMay 12, 2024
Removed the token CLI command.
* Added the id CLI command.
1 parent 04df464 commit e7c696b

File tree

4 files changed

+42
-38
lines changed

4 files changed

+42
-38
lines changed
 

‎ving.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ const main = defineCommand({
1111
cache: () => import('#ving/cli/cache.mjs').then((r) => r.default),
1212
drizzle: () => import('#ving/cli/drizzle.mjs').then((r) => r.default),
1313
email: () => import('#ving/cli/email.mjs').then((r) => r.default),
14+
id: () => import('#ving/cli/id.mjs').then((r) => r.default),
1415
jobs: () => import('#ving/cli/jobs.mjs').then((r) => r.default),
1516
messagebus: () => import('#ving/cli/messagebus.mjs').then((r) => r.default),
1617
record: () => import('#ving/cli/record.mjs').then((r) => r.default),
1718
schema: () => import('#ving/cli/schema.mjs').then((r) => r.default),
18-
token: () => import('#ving/cli/token.mjs').then((r) => r.default),
1919
user: () => import('#ving/cli/user.mjs').then((r) => r.default),
2020
},
2121
});

‎ving/cli/id.mjs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { defineCommand, showUsage } from "citty";
2+
import ving from '#ving/index.mjs';
3+
import { stringifyId, parseId } from '#ving/utils/int2str.mjs';
4+
5+
export default defineCommand({
6+
meta: {
7+
name: "id",
8+
description: "Convert an ID between integer and string.",
9+
},
10+
cleanup: ving.close,
11+
args: {
12+
makeString: {
13+
type: "number",
14+
description: "Encrypt integer into string",
15+
alias: "s",
16+
},
17+
makeInteger: {
18+
type: "string",
19+
description: "Decrypt string into integer",
20+
alias: "i",
21+
},
22+
},
23+
async run({ args, cmd }) {
24+
try {
25+
if (args.makeString) {
26+
console.log(`${args.makeString} becomes ${stringifyId(args.makeString)}`);
27+
}
28+
else if (args.makeInteger) {
29+
console.log(`${args.makeInteger} back to ${parseId(args.makeInteger)}`);
30+
}
31+
else {
32+
await showUsage(cmd, { meta: { name: 'ving.mjs' } });
33+
}
34+
}
35+
catch (e) {
36+
ving.log('cli').error(e.message);
37+
}
38+
},
39+
});

‎ving/cli/token.mjs

-37
This file was deleted.

‎ving/docs/change-log.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ outline: deep
1010
* NOTE: You should run `npm i` as we've added skip32 as a new required module.
1111
* Fixed some email verification corner case problems.
1212
* Removed the findObject() utility as Array.prototype.find() essentially works the same way, and this forces better error handling.
13+
* Removed the token CLI command.
14+
* Added the id CLI command.
1315

1416
## 2024-05-06
1517
* Updated useVingRecord() to allow for extended actions.

0 commit comments

Comments
 (0)
Please sign in to comment.