-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathsync.js
76 lines (71 loc) · 3.16 KB
/
sync.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const path = require('path')
const fs = require('fs-extra')
const { sync } = require('fast-glob')
const { config } = require('dotenv')
config()
if (process.env.UNI_APP_SYNTAX_DIR) {
fs.copySync(path.resolve(process.env.UNI_APP_SYNTAX_DIR, 'uts/common'), path.resolve(__dirname, '../packages/uni-uts-v1/lib/uts/types/uts/common'))
fs.copySync(path.resolve(process.env.UNI_APP_SYNTAX_DIR, 'uts/app-android'), path.resolve(__dirname, '../packages/uni-uts-v1/lib/uts/types/uni-x/app-android'))
fs.copySync(path.resolve(process.env.UNI_APP_SYNTAX_DIR, 'uts/app-ios'), path.resolve(__dirname, '../packages/uni-uts-v1/lib/uts/types/uni-x/app-ios'))
fs.copySync(path.resolve(process.env.UNI_APP_SYNTAX_DIR, 'uts/app-js'), path.resolve(__dirname, '../packages/uni-uts-v1/lib/uts/types/uni-x/app-js'))
}
if (process.env.UNI_APP_VUE_TYPES_DIR) {
['reactivity', 'runtime-core', 'shared'].forEach(pkg => {
const fileName = pkg + '/dist/' + pkg + '.d.ts'
fs.copySync(
path.resolve(process.env.UNI_APP_VUE_TYPES_DIR, 'packages', fileName),
path.resolve(__dirname, '../packages/uni-uts-v1/lib/uts/types/uni-x/@vue', fileName)
)
})
}
// if (process.env.UNI_APsP_ANDROID_TYPES_DIR) {
// const globals = ['kotlin/Comparable', 'kotlin/Byte', 'kotlin/UByte', 'kotlin/Short', 'kotlin/UShort', 'kotlin/Int', 'kotlin/UInt', 'kotlin/Long', 'kotlin/ULong', 'kotlin/Float', 'kotlin/Double']
// const inputDir = path.resolve(process.env.UNI_APP_ANDROID_TYPES_DIR)
// const outputDir = path.resolve(__dirname, '../packages/uni-uts-v1/lib/uts/types/uni-x/app-android/global')
// let references = []
// globals.forEach(g => {
// references.push(g + '.d.ts');
// [g, g + '.d.ts'].forEach(file => {
// const inputFile = path.resolve(inputDir, file)
// const outputFile = path.resolve(outputDir, file)
// if (fs.existsSync(inputFile)) {
// fs.copySync(inputFile, outputFile)
// }
// })
// })
// fs.outputFileSync(
// path.resolve(outputDir, 'index.d.ts'),
// `${references.map(r => `/// <reference path="./${r}" />`).join('\n')}
// `
// )
// }
// process.env.UNI_APP_TYPES_APP_ANDROID = '/Applications/HBuilderX-Dev.app/Contents/HBuilderX/plugins/uts-development-android/uts-types/app-android'
// const androidPaths = {}
// sync('**/*.d.ts', {
// cwd: process.env.UNI_APP_TYPES_APP_ANDROID, ignore: [
// // '*.d.ts',
// // 'uts',
// // 'dc',
// // 'io',
// // '**/dcloud/**/*',
// // '**/weex/**/*',
// // '**/bindingx/**/*',
// ]
// })
// .forEach(file => {
// const dirname = path.dirname(file).replace(/\\/g, '/')
// // 白名单:
// if (!['android', 'androidx', 'java', 'javax', 'kotlin', 'kotlinx'].some((name) => dirname.startsWith(name + '/'))) {
// return
// }
// const packageName = dirname.replace(/\//g, '.')
// if (androidPaths[packageName]) {
// return
// }
// androidPaths[packageName + '.*'] = [`${dirname}/*.d.ts`]
// })
// console.log('app-android paths', Object.keys(androidPaths).length)
// fs.outputFileSync(
// path.resolve(__dirname, '../packages/uni-uts-v1/lib/uts/types/uni-x/app-android/paths.json'),
// JSON.stringify(androidPaths, null, 2)
// )