Skip to content

Commit 590385e

Browse files
committed
refactor: move to esm
1 parent 835252e commit 590385e

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "jike-cli",
33
"version": "0.0.4",
44
"description": "Jike CLI",
5+
"type": "module",
56
"homepage": "https://github.com/open-jike/jike-cli#readme",
67
"bugs": {
78
"url": "https://github.com/open-jike/jike-cli#issues"
@@ -21,7 +22,7 @@
2122
"access": "public"
2223
},
2324
"scripts": {
24-
"dev": "esno src/index.ts",
25+
"dev": "esmo src/index.ts",
2526
"lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx",
2627
"lint:fix": "eslint . --fix --ext .vue,.js,.ts,.jsx,.tsx",
2728
"build": "tsup",
@@ -42,7 +43,7 @@
4243
"bumpp": "^7.1.1",
4344
"eslint": "^8.11.0",
4445
"eslint-define-config": "^1.3.0",
45-
"esno": "^0.14.1",
46+
"esmo": "^0.14.1",
4647
"fast-glob": "^3.2.11",
4748
"prettier": "^2.6.0",
4849
"tsup": "^5.12.1",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/modules/user/login.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { randomUUID } from 'crypto'
2-
import { prompt } from 'enquirer'
2+
import enquirer from 'enquirer'
33
import { logger } from '@poppinss/cliui'
4+
import { JikeClient } from 'jike-sdk/node'
45
import { errorAndExit } from '../../utils/log'
56
import { config, isSameUser } from '../../utils/config'
6-
import type { JikeClient } from 'jike-sdk/node'
77
import type { ConfigUser } from '../../utils/config'
88

99
export const login = async () => {
10-
const apiConfig = await prompt<{
10+
const apiConfig = await enquirer.prompt<{
1111
endpointId: string
1212
endpointUrl: string
1313
bundleId: string
@@ -53,8 +53,6 @@ export const login = async () => {
5353
},
5454
])
5555

56-
const { JikeClient } = await import('jike-sdk/node')
57-
5856
const deviceId = randomUUID()
5957
const idfv = randomUUID()
6058

@@ -65,7 +63,7 @@ export const login = async () => {
6563
})
6664

6765
type LoginMethod = 'mobile-password' | 'mobile-sms'
68-
const { loginMethod } = await prompt<{ loginMethod: LoginMethod }>({
66+
const { loginMethod } = await enquirer.prompt<{ loginMethod: LoginMethod }>({
6967
name: 'loginMethod',
7068
message: 'What is your preferred login method?',
7169
type: 'select',
@@ -86,7 +84,7 @@ export const login = async () => {
8684
errorAndExit(new Error('Unknown login method'))
8785
}
8886

89-
const { alias } = await prompt<{ alias: string }>({
87+
const { alias } = await enquirer.prompt<{ alias: string }>({
9088
type: 'input',
9189
name: 'alias',
9290
message: 'Do you want to set an alias for this user? (not required)',
@@ -139,7 +137,7 @@ const loginWithPassword = async (client: JikeClient) => {
139137
password: string
140138
}
141139

142-
const { areaCode, mobile, password } = await prompt<Auth>([
140+
const { areaCode, mobile, password } = await enquirer.prompt<Auth>([
143141
questions.areaCode,
144142
questions.mobile,
145143
{
@@ -156,7 +154,7 @@ const loginWithPassword = async (client: JikeClient) => {
156154
}
157155

158156
const loginWithSms = async (client: JikeClient) => {
159-
const { areaCode, mobile } = await prompt<{
157+
const { areaCode, mobile } = await enquirer.prompt<{
160158
areaCode: string
161159
mobile: string
162160
}>([questions.areaCode, questions.mobile])
@@ -167,7 +165,7 @@ const loginWithSms = async (client: JikeClient) => {
167165

168166
logger.success('SMS code sent!')
169167

170-
const { smsCode } = await prompt<{ smsCode: string }>({
168+
const { smsCode } = await enquirer.prompt<{ smsCode: string }>({
171169
type: 'input',
172170
name: 'smsCode',
173171
message: 'What is the SMS code?',

src/modules/user/renew.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { logger } from '@poppinss/cliui'
2+
import { JikeClient } from 'jike-sdk/node'
23
import { filterUsers } from '../../utils/options'
34

45
export const renew = async () => {
5-
const { JikeClient } = await import('jike-sdk/node')
6-
76
const users = filterUsers()
87

98
for (const user of users) {

tsup.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { defineConfig } from 'tsup'
22

33
export default defineConfig({
44
entry: ['./src/index.ts'],
5-
format: ['cjs'],
5+
format: ['esm'],
66
target: 'node12',
77
clean: true,
8+
platform: 'node',
89
})

0 commit comments

Comments
 (0)