Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
6d4a9752
U
uni-app
项目概览
genary
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d4a9752
编写于
5月 06, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): cli
上级
4980fea9
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
164 addition
and
79 deletion
+164
-79
.gitignore
.gitignore
+1
-0
packages/uni-app-plus/bin/uts.js
packages/uni-app-plus/bin/uts.js
+3
-0
packages/uni-app-plus/package.json
packages/uni-app-plus/package.json
+6
-1
packages/uni-app-vite/bin/uts.js
packages/uni-app-vite/bin/uts.js
+0
-2
packages/uni-app-vite/package.json
packages/uni-app-vite/package.json
+0
-9
packages/uni-app-vite/src/uts/index.ts
packages/uni-app-vite/src/uts/index.ts
+0
-43
packages/uts/dist/types.d.ts
packages/uts/dist/types.d.ts
+1
-0
packages/uts/package.json
packages/uts/package.json
+8
-0
packages/uts/src/cli/action.ts
packages/uts/src/cli/action.ts
+111
-0
packages/uts/src/cli/index.ts
packages/uts/src/cli/index.ts
+18
-13
packages/uts/src/types.ts
packages/uts/src/types.ts
+3
-1
pnpm-lock.yaml
pnpm-lock.yaml
+13
-10
未找到文件。
.gitignore
浏览文件 @
6d4a9752
...
...
@@ -7,6 +7,7 @@ packages/uni-mp-vite/dist
packages/uni-mp-compiler/dist
packages/uni-nvue-styler/dist
packages/vite-plugin-uni/dist
packages/uts/dist
.DS_Store
node_modules
...
...
packages/uni-app-plus/bin/uts.js
0 → 100755
浏览文件 @
6d4a9752
#!/usr/bin/env node
/* eslint-disable no-restricted-globals */
require
(
'
@dcloudio/uts/dist/cli/index.js
'
)
packages/uni-app-plus/package.json
浏览文件 @
6d4a9752
...
...
@@ -2,7 +2,11 @@
"name"
:
"@dcloudio/uni-app-plus"
,
"version"
:
"3.0.0-alpha-3040820220424001"
,
"description"
:
"@dcloudio/uni-app-plus"
,
"bin"
:
{
"uts"
:
"bin/uts.js"
},
"files"
:
[
"bin"
,
"dist"
,
"lib"
,
"style"
...
...
@@ -40,6 +44,7 @@
},
"dependencies"
:
{
"@dcloudio/uni-app-vite"
:
"3.0.0-alpha-3040820220424001"
,
"@dcloudio/uni-app-vue"
:
"3.0.0-alpha-3040820220424001"
"@dcloudio/uni-app-vue"
:
"3.0.0-alpha-3040820220424001"
,
"@dcloudio/uts"
:
"3.0.0-alpha-3040820220424001"
}
}
packages/uni-app-vite/bin/uts.js
已删除
100755 → 0
浏览文件 @
4980fea9
#!/usr/bin/env node
require
(
'
../dist/uts/cli.js
'
)
packages/uni-app-vite/package.json
浏览文件 @
6d4a9752
...
...
@@ -2,9 +2,6 @@
"name"
:
"@dcloudio/uni-app-vite"
,
"version"
:
"3.0.0-alpha-3040820220424001"
,
"description"
:
"uni-app-vite"
,
"bin"
:
{
"uts"
:
"bin/uts.js"
},
"main"
:
"dist/index.js"
,
"types"
:
"dist/index.d.ts"
,
"files"
:
[
...
...
@@ -32,10 +29,7 @@
"@vitejs/plugin-vue"
:
"^2.3.2"
,
"@vue/compiler-dom"
:
"3.2.33"
,
"@vue/compiler-sfc"
:
"3.2.33"
,
"cac"
:
"6.7.9"
,
"chokidar"
:
"^3.5.3"
,
"debug"
:
"^4.3.3"
,
"fast-glob"
:
"^3.2.11"
,
"fs-extra"
:
"^10.0.0"
,
"picocolors"
:
"^1.0.0"
,
"rollup"
:
"^2.59.0"
...
...
@@ -46,8 +40,5 @@
"@vue/compiler-core"
:
"3.2.33"
,
"esbuild"
:
"^0.14.27"
,
"postcss"
:
"^8.4.13"
},
"optionalDependencies"
:
{
"@dcloudio/uts-darwin-arm64"
:
"3.0.0-alpha-3040820220424001"
}
}
packages/uni-app-vite/src/uts/index.ts
已删除
100644 → 0
浏览文件 @
4980fea9
import
fs
from
'
fs
'
import
path
from
'
path
'
import
glob
from
'
fast-glob
'
// import { toKotlin } from '@dcloudio/uts'
import
{
normalizePath
}
from
'
@dcloudio/uni-cli-shared
'
interface
ToOptions
{
watch
?:
boolean
input
:
{
dir
:
string
}
output
:
{
dir
:
string
sourceMap
?:
boolean
}
}
interface
ToKotlinOptions
extends
ToOptions
{}
function
parseKotlinOptions
(
opts
:
Partial
<
ToKotlinOptions
>
)
{
const
{
input
,
output
}
=
opts
if
(
!
input
?.
dir
)
{
throw
new
Error
(
`input.dir is required`
)
}
if
(
!
output
?.
dir
)
{
throw
new
Error
(
`output.dir is required`
)
}
if
(
!
fs
.
existsSync
(
input
.
dir
))
{
throw
new
Error
(
`
${
input
}
is not found`
)
}
return
opts
as
ToKotlinOptions
}
function
watchKotlin
(
opts
:
ToKotlinOptions
)
{}
function
buildKotlin
({
input
:
{
dir
:
inputDir
}
}:
ToKotlinOptions
)
{
const
files
=
glob
.
sync
(
normalizePath
(
path
.
join
(
inputDir
,
'
**/*.uts
'
)))
console
.
log
(
files
)
}
export
function
toKotlin
(
opts
:
ToKotlinOptions
)
{
opts
=
parseKotlinOptions
(
opts
)
return
opts
.
watch
?
watchKotlin
(
opts
)
:
buildKotlin
(
opts
)
}
packages/uts/dist/types.d.ts
浏览文件 @
6d4a9752
...
...
@@ -41,4 +41,5 @@ export interface UtsSwiftOptions {
output
:
OutputSwiftOptions
;
}
export
interface
UtsResult
{
filename
?:
string
;
}
packages/uts/package.json
浏览文件 @
6d4a9752
...
...
@@ -11,5 +11,13 @@
"type"
:
"git"
,
"url"
:
"git+https://github.com/dcloudio/uni-app.git"
,
"directory"
:
"packages/uts"
},
"dependencies"
:
{
"cac"
:
"6.7.9"
,
"chokidar"
:
"^3.5.3"
,
"fast-glob"
:
"^3.2.11"
},
"optionalDependencies"
:
{
"@dcloudio/uts-darwin-arm64"
:
"3.0.0-alpha-3040820220424001"
}
}
packages/uts/src/cli/action.ts
0 → 100644
浏览文件 @
6d4a9752
import
fs
from
'
fs
'
import
path
from
'
path
'
import
glob
from
'
fast-glob
'
import
{
InputKotlinOptions
,
toKotlin
}
from
'
../index
'
import
{
OutputKotlinOptions
}
from
'
../types
'
export
interface
ToOptions
{
watch
?:
boolean
input
:
{
dir
:
string
extname
?:
string
}
output
:
{
dir
:
string
sourceMap
:
boolean
|
string
}
}
interface
ToKotlinOptions
extends
ToOptions
{}
interface
ToSwiftOptions
extends
ToOptions
{}
function
resolveDefaultOutputDir
(
inputDir
:
string
)
{
return
path
.
resolve
(
inputDir
,
'
../dist/kotlin
'
)
}
function
parseOptions
(
opts
:
Partial
<
ToKotlinOptions
>
)
{
const
{
input
}
=
opts
if
(
!
input
?.
dir
)
{
throw
new
Error
(
`input.dir is required`
)
}
if
(
!
fs
.
existsSync
(
input
.
dir
))
{
throw
new
Error
(
`
${
input
}
is not found`
)
}
if
(
!
opts
.
output
)
{
opts
.
output
=
{
dir
:
''
,
sourceMap
:
false
,
}
}
if
(
!
opts
.
output
.
dir
)
{
opts
.
output
.
dir
=
resolveDefaultOutputDir
(
input
.
dir
)
}
return
opts
as
ToKotlinOptions
}
function
watchSwift
(
_
:
ToSwiftOptions
)
{}
function
buildSwift
(
_
:
ToSwiftOptions
)
{}
function
watchKotlin
(
_
:
ToKotlinOptions
)
{}
function
buildKotlin
({
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
},
}:
ToKotlinOptions
)
{
const
files
=
glob
.
sync
(
'
**/*
'
+
(
extname
||
'
.uts
'
),
{
absolute
:
true
,
cwd
:
inputDir
,
ignore
:
[
'
**/*.d
'
+
(
extname
||
'
.uts
'
)],
})
const
input
:
InputKotlinOptions
=
{
root
:
inputDir
,
filename
:
''
,
}
const
output
:
OutputKotlinOptions
=
{
outDir
:
outputDir
,
sourceMap
,
}
return
Promise
.
all
(
files
.
map
((
filename
)
=>
buildKotlinFile
(
filename
,
input
,
output
))
)
}
function
buildKotlinFile
(
filename
:
string
,
input
:
InputKotlinOptions
,
output
:
OutputKotlinOptions
)
{
const
label
=
path
.
posix
.
relative
(
input
.
root
,
filename
)
console
.
time
(
label
)
return
toKotlin
({
input
:
{
...
input
,
filename
,
namespace
:
''
,
},
output
:
{
...
output
,
},
}).
then
((
res
)
=>
{
console
.
timeEnd
(
label
)
})
}
export
function
runDev
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
)
{
opts
=
parseOptions
(
opts
)
switch
(
target
)
{
case
'
kotlin
'
:
return
watchKotlin
(
opts
)
case
'
swift
'
:
return
watchSwift
(
opts
)
}
}
export
function
runBuild
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
)
{
opts
=
parseOptions
(
opts
)
switch
(
target
)
{
case
'
kotlin
'
:
return
buildKotlin
(
opts
)
case
'
swift
'
:
return
buildSwift
(
opts
)
}
}
packages/u
ni-app-vite/src/uts/cli
.ts
→
packages/u
ts/src/cli/index
.ts
浏览文件 @
6d4a9752
import
{
cac
}
from
'
cac
'
import
{
toKotlin
}
from
'
.
'
import
{
runBuild
,
runDev
,
ToOptions
}
from
'
./action
'
const
cli
=
cac
(
'
uts
'
)
...
...
@@ -8,6 +8,7 @@ export interface CliOptions {
output
:
string
sourcemap
:
boolean
watch
:
boolean
extname
:
string
}
cli
...
...
@@ -22,20 +23,24 @@ cli
.
option
(
'
-w, --watch
'
,
`[boolean] rebuilds when uts have changed on disk`
,
{
default
:
false
,
})
.
option
(
'
-e, --extname [extname]
'
,
`[string] extname`
,
{
default
:
'
.uts
'
,
})
.
action
((
root
,
opts
:
CliOptions
)
=>
{
console
.
log
(
'
opts
'
,
root
,
opts
)
if
(
opts
.
target
===
'
kotlin
'
)
{
toKotlin
({
watch
:
opts
.
watch
,
input
:
{
dir
:
root
,
},
output
:
{
dir
:
opts
.
output
,
sourceMap
:
opts
.
sourcemap
,
},
})
const
toOptions
:
ToOptions
=
{
watch
:
opts
.
watch
,
input
:
{
dir
:
root
,
extname
:
opts
.
extname
,
},
output
:
{
dir
:
opts
.
output
,
sourceMap
:
opts
.
sourcemap
,
},
}
return
opts
.
watch
?
runDev
(
opts
.
target
,
toOptions
)
:
runBuild
(
opts
.
target
,
toOptions
)
})
cli
.
help
()
...
...
packages/uts/src/types.ts
浏览文件 @
6d4a9752
...
...
@@ -57,4 +57,6 @@ export interface UtsSwiftOptions {
output
:
OutputSwiftOptions
}
export
interface
UtsResult
{}
export
interface
UtsResult
{
filename
?:
string
}
pnpm-lock.yaml
浏览文件 @
6d4a9752
...
...
@@ -183,6 +183,7 @@ importers:
'
@dcloudio/uni-h5'
:
3.0.0-alpha-3040820220424001
'
@dcloudio/uni-i18n'
:
3.0.0-alpha-3040820220424001
'
@dcloudio/uni-shared'
:
3.0.0-alpha-3040820220424001
'
@dcloudio/uts'
:
3.0.0-alpha-3040820220424001
'
@types/pako'
:
1.0.2
'
@vue/compiler-sfc'
:
3.2.33
pako
:
^1.0.11
...
...
@@ -190,6 +191,7 @@ importers:
dependencies
:
'
@dcloudio/uni-app-vite'
:
link:../uni-app-vite
'
@dcloudio/uni-app-vue'
:
link:../uni-app-vue
'
@dcloudio/uts'
:
link:../uts
devDependencies
:
'
@dcloudio/uni-cli-shared'
:
link:../uni-cli-shared
'
@dcloudio/uni-components'
:
link:../uni-components
...
...
@@ -208,7 +210,6 @@ importers:
'
@dcloudio/uni-nvue-styler'
:
3.0.0-alpha-3040820220424001
'
@dcloudio/uni-shared'
:
3.0.0-alpha-3040820220424001
'
@dcloudio/uts'
:
3.0.0-alpha-3040820220424001
'
@dcloudio/uts-darwin-arm64'
:
3.0.0-alpha-3040820220424001
'
@rollup/pluginutils'
:
^4.2.0
'
@types/debug'
:
^4.1.7
'
@types/fs-extra'
:
^9.0.13
...
...
@@ -216,11 +217,8 @@ importers:
'
@vue/compiler-core'
:
3.2.33
'
@vue/compiler-dom'
:
3.2.33
'
@vue/compiler-sfc'
:
3.2.33
cac
:
6.7.9
chokidar
:
^3.5.3
debug
:
^4.3.3
esbuild
:
^0.14.27
fast-glob
:
^3.2.11
fs-extra
:
^10.0.0
picocolors
:
^1.0.0
postcss
:
^8.4.13
...
...
@@ -235,15 +233,10 @@ importers:
'
@vitejs/plugin-vue'
:
2.3.2
'
@vue/compiler-dom'
:
3.2.33
'
@vue/compiler-sfc'
:
3.2.33
cac
:
6.7.9
chokidar
:
3.5.3
debug
:
4.3.4
fast-glob
:
3.2.11
fs-extra
:
10.1.0
picocolors
:
1.0.0
rollup
:
2.72.0
optionalDependencies
:
'
@dcloudio/uts-darwin-arm64'
:
link:../uts-darwin-arm64
devDependencies
:
'
@types/debug'
:
4.1.7
'
@types/fs-extra'
:
9.0.13
...
...
@@ -775,7 +768,17 @@ importers:
'
@dcloudio/uni-shared'
:
link:../uni-shared
packages/uts
:
specifiers
:
{}
specifiers
:
'
@dcloudio/uts-darwin-arm64'
:
3.0.0-alpha-3040820220424001
cac
:
6.7.9
chokidar
:
^3.5.3
fast-glob
:
^3.2.11
dependencies
:
cac
:
6.7.9
chokidar
:
3.5.3
fast-glob
:
3.2.11
optionalDependencies
:
'
@dcloudio/uts-darwin-arm64'
:
link:../uts-darwin-arm64
packages/uts-darwin-arm64
:
specifiers
:
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录