Skip to content

Commit

Permalink
feat: add rn
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyatong committed Sep 25, 2024
1 parent 471061b commit 3dc0d74
Show file tree
Hide file tree
Showing 13 changed files with 3,735 additions and 319 deletions.
23 changes: 17 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ console.log(argvs, 'argvs')
// 监视频率 https://www.martin-brennan.com/gulp-watch-high-cpu-usage/
const interval = { interval: 500 }
// 监视文件变化
gulp.task('watch', function () {
gulp.task('watch', () => {
argvs.forEach((argv) => {
gulp.watch(
`src/packages/${argv}/demos/taro/*`,
Expand All @@ -42,6 +42,11 @@ gulp.task('watch', function () {
interval,
gulp.series(`${argv}copyTaro`)
)
gulp.watch(
`src/packages/${argv}/${argv}.rn.tsx`,
interval,
gulp.series(`${argv}copyRN`)
)
})
const watchTasks = []
// eslint-disable-next-line array-callback-return
Expand All @@ -60,14 +65,14 @@ gulp.task('watch', function () {
})
argvs.forEach((argv) => {
const targetBaseUrl = `${process.cwd()}/packages/nutui-taro-demo/nutui-react/packages/${argv}`
gulp.task(`${argv}copyDemo`, function (path) {
gulp.task(`${argv}copyDemo`, (path) => {
console.log(path, 'path')
return gulp
.src(`src/packages/${argv}/demos/taro/*`)
.pipe(gulp.dest(`${targetBaseUrl}/demos/taro/`))
})

gulp.task(`${argv}sass`, function () {
gulp.task(`${argv}sass`, () => {
return gulp
.src([`src/packages/${argv}/${argv}.scss`])
.pipe(
Expand All @@ -94,7 +99,7 @@ argvs.forEach((argv) => {
.pipe(gulp.dest(`src/packages/${argv}/`))
})

gulp.task(`${argv}copyCss`, function () {
gulp.task(`${argv}copyCss`, () => {
return gulp
.src([
`src/packages/${argv}/*.scss`,
Expand All @@ -103,17 +108,23 @@ argvs.forEach((argv) => {
.pipe(gulp.dest(`${targetBaseUrl}/`))
})

gulp.task(`${argv}copyTaroDemo`, function () {
gulp.task(`${argv}copyTaroDemo`, () => {
return gulp
.src(`src/packages/${argv}/demo.taro.tsx`)
.pipe(insert.prepend(`import '../../../styles/demo.scss';\n`))
.pipe(gulp.dest(`${targetBaseUrl}/`))
})

gulp.task(`${argv}copyTaro`, function () {
gulp.task(`${argv}copyTaro`, () => {
return gulp
.src(`src/packages/${argv}/${argv}.taro.tsx`)
.pipe(insert.prepend(`import "./${argv}.harmony.css";\n`))
.pipe(gulp.dest(`${targetBaseUrl}/`))
})
gulp.task(`${argv}copyRN`, () => {
return gulp
.src(`src/packages/${argv}/${argv}.rn.tsx`)
.pipe(insert.prepend(`import "./${argv}.harmony.css";\n`))
.pipe(gulp.dest(`${targetBaseUrl}/`))
})
})
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"@swc/core": "^1.4.8",
"@tarojs/components": "^4.0.0-alpha.34",
"@tarojs/plugin-platform-alipay": "^4.0.0-alpha.34",
"@tarojs/plugin-platform-weapp": "^4.0.0-alpha.34",
"@tarojs/react": "^4.0.0-alpha.34",
"@tarojs/taro": "^4.0.0-alpha.34",
"@tarojs/components": "4.0.2",
"@tarojs/plugin-platform-alipay": "4.0.2",
"@tarojs/plugin-platform-weapp": "4.0.2",
"@tarojs/react": "4.0.2",
"@tarojs/taro": "4.0.2",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^16.0.0",
"@types/fs-extra": "^11.0.4",
Expand Down Expand Up @@ -194,6 +194,7 @@
"react-color": "^2.19.3",
"react-dom": "^18.2.0",
"react-markdown": "^9.0.1",
"react-native": "0.72.3",
"react-refresh": "^0.14.0",
"react-router-dom": "^6.22.1",
"react-syntax-highlighter": "^15.5.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/nutui-taro-demo/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ const config = {
'@/utils': path.resolve(__dirname, '../nutui-react/utils'),
'@nutui/nutui-react-taro': path.resolve(
__dirname,
'../nutui-react/packages/nutui.react.taro.ts'
'../nutui-react/packages/nutui.react.rn.ts'
),
'@nutui/icons-react-taro': path.resolve(
__dirname,
'../nutui-react/packages/nutui.react.taro.ts'
'../nutui-react/packages/nutui.react.rn.ts'
),
'@styles': path.resolve(__dirname, '../styles'),
}
Expand Down
57 changes: 18 additions & 39 deletions packages/nutui-taro-demo/scripts/taro/generate-nutui-taro.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var glob = require('glob')
const path = require('path')
const fs = require('fs-extra')
let importStr = ``
let importRNStr = ``
let importMarkdownStr = ``
let importScssStr = `\n`
const packages = []
Expand All @@ -12,14 +13,17 @@ const raws = []

config.nav.map((item) => {
item.packages.forEach((element) => {
let { name, show, type, taro, exportEmpty, exclude, version } = element
let { name, show, type, taro, exportEmpty, exclude, version, rn } = element
if (exclude) return
if (version !== '3.0.0') return // 不显示的不导出
if (version !== '3.0.0') return

importStr += `import ${name} from '@/packages/${name.toLowerCase()}/index.taro'\n`
importStr += `export * from '@/packages/${name.toLowerCase()}/index.taro'\n`
importRNStr += `import ${name} from '@/packages/${name.toLowerCase()}/index.${rn?'rn':'taro'}'\n`
importRNStr += `export * from '@/packages/${name.toLowerCase()}/index.${rn?'rn':'taro'}'\n`
importScssStr += `import '@/packages/${name.toLowerCase()}/${name.toLowerCase()}.harmony.css'\n`
packages.push(name)

glob
.sync(
path.join(__dirname, `../../nutui-react/packages/${name.toLowerCase()}/`) +
Expand All @@ -41,18 +45,6 @@ config.nav.map((item) => {
})
})

// let fileStrBuild = `${importStr}
// export { ${packages.join(',')} };`

// fs.outputFile(
// path.resolve(__dirname, '../../nutui-react/packages/nutui.react.build.taro.ts'),
// fileStrBuild,
// 'utf8',
// (error) => {
// if (error) throw error
// }
// )

let fileStr = `${importStr}
${importScssStr}
export { ${packages.join(',')} };`
Expand All @@ -65,6 +57,18 @@ fs.outputFile(
}
)

let fileRNStr = `${importRNStr}
${importScssStr}
export { ${packages.join(',')} };`
fs.outputFile(
path.resolve(__dirname, '../../nutui-react/packages/nutui.react.rn.ts'),
fileRNStr,
'utf8',
(error) => {
if (error) throw error
}
)

let taroScssfileStr = `
${importScssStr}
export default { "NutUI":"NutUI-Taro" };`
Expand All @@ -76,28 +80,3 @@ fs.outputFile(
if (error) throw error
}
)

// fs.outputFile(
// path.resolve(__dirname, '../../nutui-react/packages/nutui.react.scss.ts'),
// importScssStr,
// 'utf8',
// (error) => {
// if (error) throw error
// }
// )

// let mdFileStr = `${importMarkdownStr}
// export const routers = [${mds.map((m) => `'${m}'`)}]
// export const raws = {${raws.join(',')}}
// `

// fs.outputFile(
// path.resolve(__dirname, '../../src/sites/doc/docs.taro.ts'),
// mdFileStr,
// 'utf8',
// (error) => {
// if (error) throw error
// }
// )


Loading

0 comments on commit 3dc0d74

Please sign in to comment.