create-bubbles 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -3
- package/package.json +1 -1
- package/template-taro-vue-eslint/.editorconfig +12 -0
- package/template-taro-vue-eslint/.env +3 -0
- package/template-taro-vue-eslint/.env.development +5 -0
- package/template-taro-vue-eslint/.env.production +5 -0
- package/template-taro-vue-eslint/.vscode/settings.json +57 -0
- package/template-taro-vue-eslint/babel.config.js +12 -0
- package/template-taro-vue-eslint/commitlint.config.mjs +1 -0
- package/template-taro-vue-eslint/config/dev.ts +27 -0
- package/template-taro-vue-eslint/config/index.ts +129 -0
- package/template-taro-vue-eslint/config/output-root.ts +11 -0
- package/template-taro-vue-eslint/config/prod.ts +39 -0
- package/template-taro-vue-eslint/config/release.ts +113 -0
- package/template-taro-vue-eslint/eslint.config.mjs +22 -0
- package/template-taro-vue-eslint/lefthook.yaml +13 -0
- package/template-taro-vue-eslint/package.json +115 -0
- package/template-taro-vue-eslint/patches/@tarojs__plugin-mini-ci.patch +13 -0
- package/template-taro-vue-eslint/pnpm-workspace.yaml +2 -0
- package/template-taro-vue-eslint/project.config.json +16 -0
- package/template-taro-vue-eslint/src/api/common/upload.ts +53 -0
- package/template-taro-vue-eslint/src/app.config.ts +19 -0
- package/template-taro-vue-eslint/src/app.ts +14 -0
- package/template-taro-vue-eslint/src/assets/image/.gitkeep +0 -0
- package/template-taro-vue-eslint/src/index.html +17 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.config.ts +3 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.module.scss +4 -0
- package/template-taro-vue-eslint/src/pages/example/upload/index.vue +71 -0
- package/template-taro-vue-eslint/src/pages/index/index.config.ts +3 -0
- package/template-taro-vue-eslint/src/pages/index/index.module.scss +4 -0
- package/template-taro-vue-eslint/src/pages/index/index.vue +71 -0
- package/template-taro-vue-eslint/src/store/index.ts +10 -0
- package/template-taro-vue-eslint/src/store/modules/user.ts +15 -0
- package/template-taro-vue-eslint/src/store/taroStorage.ts +7 -0
- package/template-taro-vue-eslint/src/styles/index.css +1 -0
- package/template-taro-vue-eslint/src/styles/nut-theme.css +4 -0
- package/template-taro-vue-eslint/src/utils/env.ts +13 -0
- package/template-taro-vue-eslint/src/utils/index.ts +40 -0
- package/template-taro-vue-eslint/src/utils/request/core/index.ts +193 -0
- package/template-taro-vue-eslint/src/utils/request/core/utils.ts +30 -0
- package/template-taro-vue-eslint/src/utils/request/index.ts +73 -0
- package/template-taro-vue-eslint/tsconfig.json +30 -0
- package/template-taro-vue-eslint/types/components.d.ts +12 -0
- package/template-taro-vue-eslint/types/global.d.ts +31 -0
- package/template-taro-vue-eslint/types/vue.d.ts +10 -0
- package/template-taro-vue-eslint/unocss.config.ts +38 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"node:fs";import t from"node:path";import
|
|
1
|
+
import e from"node:fs";import t from"node:path";import{fileURLToPath as n}from"node:url";import*as r from"@clack/prompts";import i from"cross-spawn";import a from"gradient-string";import o from"mri";const s={vue:a([`#42B883`,`#42B883`]),react:a([`#087EA4`,`#087EA4`]),taro:a([`#0000C2`,`#fff`]),others:a([`#8B5CF6`,`#A855F7`])},c=o(process.argv.slice(2),{alias:{h:`help`,t:`template`},boolean:[`help`,`overwrite`],string:[`template`]}),l=process.cwd(),u=`\
|
|
2
2
|
Usage: create-bubbles [OPTION]... [DIRECTORY]
|
|
3
3
|
|
|
4
4
|
Create a new Bubbles project in JavaScript or TypeScript.
|
|
@@ -10,8 +10,9 @@ Options:
|
|
|
10
10
|
Available templates:
|
|
11
11
|
${s.vue(`vue-rsbuild-biome vue`)}
|
|
12
12
|
${s.vue(`vue-rolldown-oxc vue`)}
|
|
13
|
+
${s.taro(`taro-vue-eslint taro`)}
|
|
13
14
|
${s.react(`react-rsbuild-biome react`)}
|
|
14
|
-
${s.react(`react-rolldown-oxc react`)}`,d=e=>e.trim().replace(/\/+$/g,``),f=e=>{if(!e)return;let t=e.split(` `)[0].split(`/`);return{name:t[0],version:t[1]}},p=t=>{let n=e.readdirSync(t);return n.length===0||n.length===1&&n[0]===`.git`},m=async n=>{await Promise.all(e.readdirSync(n).filter(e=>e!==`.git`).map(r=>e.promises.rm(t.resolve(n,r),{recursive:!0,force:!0})))},h=e=>/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e),g=e=>e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/^[._]/,``).replace(/[^a-z\d\-~]+g/,`-`),_=[{name:`vue`,display:`Vue`,color:s.vue,variants:[{name:`vue-vite-eslint`,display:`vite + eslint`,color:s.vue},{name:`vue-rsbuild-biome`,display:`rsbuild + biome`,color:s.vue},{name:`vue-vite-oxc`,display:`rolldown + oxc`,color:s.vue},{name:`vue-vite-biome`,display:`vite + biome`,color:s.vue}]},{name:`react`,display:`React`,color:s.react,variants:[{name:`react-rsbuild-biome`,display:`rsbuild-biome`,color:s.react}]},{name:`others`,display:`Others`,color:s.others,variants:[{name:`create-eletron-vite`,display:`Electron ↗`,color:s.others,customCommand:`pnpm create electron-vite@latest TARGET_DIR`}]}],v=_.map(e=>e.variants.map(e=>`${e.name}`)).reduce((e,t)=>e.concat(t),[]),y=(e,t)=>{console.log(`💦customCommand`,e,t);let n=t?t.name:`npm`,r=n===`yarn`&&t?.version.startsWith(`1.`);return e.replace(/^npm create (?:-- )?/,()=>n===`bun`?`bun x create-`:n===`pnpm`?`pnpm create `:e.startsWith(`npm create -- `)?`${n} create -- `:`${n} create `).replace(`@latest`,()=>r?``:`@latest`).replace(/^npm exec/,()=>n===`pnpm`?`pnpm dlx`:n===`yarn`&&!r?`yarn dlx`:n===`bun`?`bun x`:`npm exec`)},b={_gitignore:`.gitignore`},x=(n,r)=>{e.mkdirSync(r,{recursive:!0});for(let i of e.readdirSync(n))S(t.resolve(n,i),t.resolve(r,i))},S=(t,n)=>{e.statSync(t).isDirectory()?x(t,n):e.copyFileSync(t,n)},C=(t,n)=>{let r=e.readFileSync(t,`utf-8`);e.writeFileSync(t,n(r),`utf-8`)},w=(e,n)=>{C(t.resolve(e,`package.json`),e=>e.replace(/"@vitejs\/plugin-react": ".+?"/,`"@vitejs/plugin-react-swc": "^4.0.1"`)),C(t.resolve(e,`vite.config.${n?`ts`:`js`}`),e=>e.replace(`@vitejs/plugin-react`,`@vitejs/plugin-react-swc`))};(async()=>{console.log(c);let
|
|
15
|
+
${s.react(`react-rolldown-oxc react`)}`,d=e=>e.trim().replace(/\/+$/g,``),f=e=>{if(!e)return;let t=e.split(` `)[0].split(`/`);return{name:t[0],version:t[1]}},p=t=>{let n=e.readdirSync(t);return n.length===0||n.length===1&&n[0]===`.git`},m=async n=>{await Promise.all(e.readdirSync(n).filter(e=>e!==`.git`).map(r=>e.promises.rm(t.resolve(n,r),{recursive:!0,force:!0})))},h=e=>/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e),g=e=>e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/^[._]/,``).replace(/[^a-z\d\-~]+g/,`-`),_=[{name:`vue`,display:`Vue`,color:s.vue,variants:[{name:`vue-vite-eslint`,display:`vite + eslint`,color:s.vue},{name:`vue-rsbuild-biome`,display:`rsbuild + biome`,color:s.vue},{name:`vue-vite-oxc`,display:`rolldown + oxc`,color:s.vue},{name:`vue-vite-biome`,display:`vite + biome`,color:s.vue}]},{name:`react`,display:`React`,color:s.react,variants:[{name:`react-rsbuild-biome`,display:`rsbuild-biome`,color:s.react}]},{name:`taro`,display:`Taro`,color:s.taro,variants:[{name:`taro-vue-eslint`,display:`taro-vue + eslint`,color:s.taro}]},{name:`others`,display:`Others`,color:s.others,variants:[{name:`create-eletron-vite`,display:`Electron ↗`,color:s.others,customCommand:`pnpm create electron-vite@latest TARGET_DIR`}]}],v=_.map(e=>e.variants.map(e=>`${e.name}`)).reduce((e,t)=>e.concat(t),[]),y=(e,t)=>{console.log(`💦customCommand`,e,t);let n=t?t.name:`npm`,r=n===`yarn`&&t?.version.startsWith(`1.`);return e.replace(/^npm create (?:-- )?/,()=>n===`bun`?`bun x create-`:n===`pnpm`?`pnpm create `:e.startsWith(`npm create -- `)?`${n} create -- `:`${n} create `).replace(`@latest`,()=>r?``:`@latest`).replace(/^npm exec/,()=>n===`pnpm`?`pnpm dlx`:n===`yarn`&&!r?`yarn dlx`:n===`bun`?`bun x`:`npm exec`)},b={_gitignore:`.gitignore`},x=(n,r)=>{e.mkdirSync(r,{recursive:!0});for(let i of e.readdirSync(n))S(t.resolve(n,i),t.resolve(r,i))},S=(t,n)=>{e.statSync(t).isDirectory()?x(t,n):e.copyFileSync(t,n)},C=(t,n)=>{let r=e.readFileSync(t,`utf-8`);e.writeFileSync(t,n(r),`utf-8`)},w=(e,n)=>{C(t.resolve(e,`package.json`),e=>e.replace(/"@vitejs\/plugin-react": ".+?"/,`"@vitejs/plugin-react-swc": "^4.0.1"`)),C(t.resolve(e,`vite.config.${n?`ts`:`js`}`),e=>e.replace(`@vitejs/plugin-react`,`@vitejs/plugin-react-swc`))};(async()=>{console.log(c);let o=c._[0]?d(c._[0]):void 0,x=c.template,C=c.overwrite,T=`bubbles-project`;if(c.help){console.log(u);return}let E=f(process.env.npm_config_user_agent),D=()=>r.cancel(`Operation cancelled`),O=o;if(!O){let e=await r.text({message:`Project name`,defaultValue:T,placeholder:T,validate:e=>e.length===0||d(e).length>0?void 0:`Invalid project name`});if(r.isCancel(e))return D();O=d(e)}if(e.existsSync(O)&&!p(O)){let e=C?`yes`:await r.select({message:O===`.`?`Current directory`:`Target directory "${O}" is not empty. Please choose how to proceed:`,options:[{label:`${s.vue(`Cancel operation`)}`,value:`no`},{label:`Remove existing files and continue`,value:`yes`},{label:`Ignore files and continue`,value:`ignore`}]});if(r.isCancel(e))return D();switch(e){case`yes`:m(O);break;case`no`:D();return}}let k=t.basename(t.resolve(O));if(!h(k)){let e=await r.text({message:`Package name is invalid. please input again:`,defaultValue:g(k),placeholder:g(k),validate(e){if(!h(e))return`Invalid package.json name`}});if(r.isCancel(e))return D();k=e}let A=x,j=!1;if(x&&!v.includes(x)&&(A=void 0,j=!0),!A){let e=await r.select({message:j?`"${x}" isn't a valia template. please choose from below:`:`Select a framework`,options:_.map(e=>{let t=e.color;return{label:t(e.display),value:e}})});if(r.isCancel(e))return D();console.log(`💦pkgInfo`,E);let t=await r.select({message:`Select a variant:`,options:e.variants.map(e=>{let t=e.color,n=e.customCommand?y(e.customCommand,E).replace(/ TARGET_DIR$/,``):void 0;return{label:t(e.display||e.name),value:e.name,hint:n}})});if(r.isCancel(t))return D();A=t}let M=t.join(l,O);e.mkdirSync(M,{recursive:!0});let N=!1;A.includes(`-swc`)&&(N=!0,A=A.replace(`-swc`,``));let P=E?E.name:`npm`,{customCommand:F}=_.flatMap(e=>e.variants).find(e=>e.name===A)??{};if(F){let[e,...t]=y(F,E).split(` `),n=t.map(e=>e.replace(`TARGET_DIR`,()=>O));console.log(`💦replacedArgs`,n);let{status:r}=i.sync(e,n,{stdio:`inherit`});process.exit(r??0)}r.log.step(`scaffolding project in ${M}...`);let I=t.resolve(n(import.meta.url),`../..`,`template-${A}`),L=(n,r)=>{let i=t.join(M,b[n]??n);r?e.writeFileSync(i,r):S(t.join(I,n),i)},R=e.readdirSync(I);for(let e of R)e!==`package.json`&&L(e);let z=JSON.parse(e.readFileSync(t.join(I,`package.json`),`utf-8`));z.name=k,L(`package.json`,`${JSON.stringify(z,null,2)}\n`),N&&w(M,A.endsWith(`-ts`));let B=``,V=t.relative(l,M);switch(console.log(`💦cwd`,l),console.log(`💦root`,M),console.log(`💦cdProjectName`,V),B+=`Done. Now run:
|
|
15
16
|
`,M!==l&&(B+=`\n cd ${V.includes(` `)?`"${V}"`:V} `),P){case`yarn`:B+=`
|
|
16
17
|
yarn`,B+=`
|
|
17
|
-
yarn dev`;break;default:B+=
|
|
18
|
+
yarn dev`;break;default:B+=a([`pink`,`white`])(`\n ${P} install`),B+=a([`pink`,`white`])(`\n ${P} run dev`);break}r.outro(B)})().catch(e=>{console.error(`💦`,e)});export{};
|
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Disable the default formatter, use eslint instead
|
|
3
|
+
"oxc.enable": false,
|
|
4
|
+
"biome.enabled": false,
|
|
5
|
+
"prettier.enable": false,
|
|
6
|
+
"editor.formatOnSave": false,
|
|
7
|
+
|
|
8
|
+
// Auto fix
|
|
9
|
+
"editor.codeActionsOnSave": {
|
|
10
|
+
"source.fixAll.eslint": "explicit",
|
|
11
|
+
"source.organizeImports": "never"
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
// Silent the stylistic rules in your IDE, but still auto fix them
|
|
15
|
+
"eslint.rules.customizations": [
|
|
16
|
+
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
17
|
+
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
18
|
+
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
19
|
+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
20
|
+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
21
|
+
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
22
|
+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
23
|
+
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
24
|
+
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
25
|
+
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
// Enable eslint for all supported languages
|
|
29
|
+
"eslint.validate": [
|
|
30
|
+
"javascript",
|
|
31
|
+
"javascriptreact",
|
|
32
|
+
"typescript",
|
|
33
|
+
"typescriptreact",
|
|
34
|
+
"vue",
|
|
35
|
+
"html",
|
|
36
|
+
"markdown",
|
|
37
|
+
"json",
|
|
38
|
+
"json5",
|
|
39
|
+
"jsonc",
|
|
40
|
+
"yaml",
|
|
41
|
+
"toml",
|
|
42
|
+
"xml",
|
|
43
|
+
"gql",
|
|
44
|
+
"graphql",
|
|
45
|
+
"astro",
|
|
46
|
+
"svelte",
|
|
47
|
+
"css",
|
|
48
|
+
"less",
|
|
49
|
+
"scss",
|
|
50
|
+
"pcss",
|
|
51
|
+
"postcss"
|
|
52
|
+
],
|
|
53
|
+
"cSpell.words": [
|
|
54
|
+
"Alova",
|
|
55
|
+
"tarojs"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// babel-preset-taro 更多选项和默认值:
|
|
2
|
+
// https://docs.taro.zone/docs/next/babel-config
|
|
3
|
+
module.exports = {
|
|
4
|
+
presets: [
|
|
5
|
+
['taro', {
|
|
6
|
+
framework: 'vue3',
|
|
7
|
+
ts: true,
|
|
8
|
+
compiler: 'webpack5',
|
|
9
|
+
useBuiltIns: process.env.TARO_ENV === 'h5' ? 'usage' : false
|
|
10
|
+
}]
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default { extends: ["@commitlint/config-conventional"] };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UserConfigExport } from '@tarojs/cli'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
logger: {
|
|
5
|
+
quiet: false,
|
|
6
|
+
stats: true,
|
|
7
|
+
},
|
|
8
|
+
mini: {},
|
|
9
|
+
h5: {
|
|
10
|
+
devServer: {
|
|
11
|
+
open: false,
|
|
12
|
+
port: 9970,
|
|
13
|
+
proxy: {
|
|
14
|
+
[`/${process.env.TARO_APP_API_AFFIX}`]: {
|
|
15
|
+
target: process.env.TARO_APP_API_URL,
|
|
16
|
+
changeOrigin: true,
|
|
17
|
+
secure: false,
|
|
18
|
+
},
|
|
19
|
+
[`/${process.env.TARO_APP_UPLOAD_API_AFFIX}`]: {
|
|
20
|
+
target: process.env.TARO_APP_API_URL,
|
|
21
|
+
changeOrigin: true,
|
|
22
|
+
secure: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} satisfies UserConfigExport<'webpack5'>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { UserConfigExport } from '@tarojs/cli'
|
|
2
|
+
import process from 'node:process'
|
|
3
|
+
import NutUIResolver from '@nutui/auto-import-resolver'
|
|
4
|
+
import { defineConfig } from '@tarojs/cli'
|
|
5
|
+
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
|
|
6
|
+
import UnoCSS from 'unocss/webpack'
|
|
7
|
+
import Components from 'unplugin-vue-components/webpack'
|
|
8
|
+
import devConfig from './dev'
|
|
9
|
+
import { outputRootMap } from './output-root'
|
|
10
|
+
import prodConfig from './prod'
|
|
11
|
+
import { CIPluginFn } from './release'
|
|
12
|
+
|
|
13
|
+
// https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
|
|
14
|
+
export default defineConfig<'webpack5'>(async (merge, { command, mode }) => {
|
|
15
|
+
const baseConfig: UserConfigExport<'webpack5'> = {
|
|
16
|
+
projectName: 'myApp',
|
|
17
|
+
date: '2026-2-24',
|
|
18
|
+
designWidth: (input: any) => {
|
|
19
|
+
// 配置 NutUI 375 尺寸
|
|
20
|
+
if (input?.file?.replace(/\\+/g, '/').indexOf('@nutui') > -1) {
|
|
21
|
+
return 375
|
|
22
|
+
}
|
|
23
|
+
// 全局使用 Taro 默认的 750 尺寸
|
|
24
|
+
return 750
|
|
25
|
+
},
|
|
26
|
+
deviceRatio: {
|
|
27
|
+
640: 2.34 / 2,
|
|
28
|
+
750: 1,
|
|
29
|
+
375: 2,
|
|
30
|
+
828: 1.81 / 2,
|
|
31
|
+
},
|
|
32
|
+
sourceRoot: 'src',
|
|
33
|
+
outputRoot: outputRootMap[process.env.TARO_ENV] || 'dist/other',
|
|
34
|
+
plugins: [
|
|
35
|
+
'@tarojs/plugin-generator',
|
|
36
|
+
'@tarojs/plugin-html',
|
|
37
|
+
['@tarojs/plugin-mini-ci', CIPluginFn],
|
|
38
|
+
],
|
|
39
|
+
defineConstants: {
|
|
40
|
+
},
|
|
41
|
+
copy: {
|
|
42
|
+
patterns: [
|
|
43
|
+
],
|
|
44
|
+
options: {
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
framework: 'vue3',
|
|
48
|
+
compiler: 'webpack5',
|
|
49
|
+
cache: {
|
|
50
|
+
enable: false, // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
|
|
51
|
+
},
|
|
52
|
+
mini: {
|
|
53
|
+
postcss: {
|
|
54
|
+
pxtransform: {
|
|
55
|
+
enable: true,
|
|
56
|
+
config: {
|
|
57
|
+
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
cssModules: {
|
|
61
|
+
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
|
|
62
|
+
config: {
|
|
63
|
+
namingPattern: 'module', // 转换模式,取值为 global/module
|
|
64
|
+
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
webpackChain(chain) {
|
|
69
|
+
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
|
|
70
|
+
chain.plugin('unplugin-vue-components').use(Components({
|
|
71
|
+
resolvers: [NutUIResolver({ taro: true })],
|
|
72
|
+
dts: './types/components.d.ts',
|
|
73
|
+
}))
|
|
74
|
+
chain.plugin('unocss').use(UnoCSS())
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
h5: {
|
|
78
|
+
publicPath: '/',
|
|
79
|
+
staticDirectory: 'static',
|
|
80
|
+
output: {
|
|
81
|
+
filename: 'js/[name].[hash:8].js',
|
|
82
|
+
chunkFilename: 'js/[name].[chunkhash:8].js',
|
|
83
|
+
},
|
|
84
|
+
miniCssExtractPluginOption: {
|
|
85
|
+
ignoreOrder: true,
|
|
86
|
+
filename: 'css/[name].[hash].css',
|
|
87
|
+
chunkFilename: 'css/[name].[chunkhash].css',
|
|
88
|
+
},
|
|
89
|
+
postcss: {
|
|
90
|
+
autoprefixer: {
|
|
91
|
+
enable: true,
|
|
92
|
+
config: {},
|
|
93
|
+
},
|
|
94
|
+
cssModules: {
|
|
95
|
+
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
|
|
96
|
+
config: {
|
|
97
|
+
namingPattern: 'module', // 转换模式,取值为 global/module
|
|
98
|
+
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
webpackChain(chain) {
|
|
103
|
+
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
|
|
104
|
+
chain.plugin('unplugin-vue-components').use(Components({
|
|
105
|
+
resolvers: [NutUIResolver({ taro: true })],
|
|
106
|
+
dts: './types/components.d.ts',
|
|
107
|
+
}))
|
|
108
|
+
chain.plugin('unocss').use(UnoCSS())
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
rn: {
|
|
112
|
+
appName: 'taroDemo',
|
|
113
|
+
postcss: {
|
|
114
|
+
cssModules: {
|
|
115
|
+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
process.env.BROWSERSLIST_ENV = process.env.NODE_ENV
|
|
122
|
+
|
|
123
|
+
if (process.env.NODE_ENV === 'development') {
|
|
124
|
+
// 本地开发构建配置(不混淆压缩)
|
|
125
|
+
return merge({}, baseConfig, devConfig)
|
|
126
|
+
}
|
|
127
|
+
// 生产构建配置(默认开启压缩混淆等)
|
|
128
|
+
return merge({}, baseConfig, prodConfig)
|
|
129
|
+
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { UserConfigExport } from '@tarojs/cli'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mini: {},
|
|
5
|
+
h5: {
|
|
6
|
+
compile: {
|
|
7
|
+
include: [
|
|
8
|
+
// 确保产物为 es5
|
|
9
|
+
filename => /node_modules\/(?!(@babel|core-js|style-loader|css-loader|react|react-dom))/.test(filename),
|
|
10
|
+
],
|
|
11
|
+
},
|
|
12
|
+
/**
|
|
13
|
+
* WebpackChain 插件配置
|
|
14
|
+
* @docs https://github.com/neutrinojs/webpack-chain
|
|
15
|
+
*/
|
|
16
|
+
// webpackChain (chain) {
|
|
17
|
+
// /**
|
|
18
|
+
// * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
|
|
19
|
+
// * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
|
|
20
|
+
// */
|
|
21
|
+
// chain.plugin('analyzer')
|
|
22
|
+
// .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
|
|
23
|
+
// /**
|
|
24
|
+
// * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
|
|
25
|
+
// * @docs https://github.com/chrisvfritz/prerender-spa-plugin
|
|
26
|
+
// */
|
|
27
|
+
// const path = require('path')
|
|
28
|
+
// const Prerender = require('prerender-spa-plugin')
|
|
29
|
+
// const staticDir = path.join(__dirname, '..', 'dist')
|
|
30
|
+
// chain
|
|
31
|
+
// .plugin('prerender')
|
|
32
|
+
// .use(new Prerender({
|
|
33
|
+
// staticDir,
|
|
34
|
+
// routes: [ '/pages/index/index' ],
|
|
35
|
+
// postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
|
|
36
|
+
// }))
|
|
37
|
+
// }
|
|
38
|
+
},
|
|
39
|
+
} satisfies UserConfigExport<'webpack5'>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import * as fs from 'node:fs'
|
|
3
|
+
import * as path from 'node:path'
|
|
4
|
+
import process from 'node:process'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 获取package.json中的版本号
|
|
8
|
+
*/
|
|
9
|
+
function getPackageVersion(): string {
|
|
10
|
+
try {
|
|
11
|
+
const packagePath = path.join(process.cwd(), 'package.json')
|
|
12
|
+
const packageContent = fs.readFileSync(packagePath, 'utf8')
|
|
13
|
+
const packageData = JSON.parse(packageContent)
|
|
14
|
+
return packageData.version || '1.0.0'
|
|
15
|
+
} catch {
|
|
16
|
+
console.warn('⚠️ 获取package.json版本号失败,使用默认版本 1.0.0')
|
|
17
|
+
return '1.0.0'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 获取最新的Git提交信息
|
|
23
|
+
*/
|
|
24
|
+
function getLatestCommitMessage(): string {
|
|
25
|
+
try {
|
|
26
|
+
const message = execSync('git log -1 --pretty=%B', { encoding: 'utf8' }).trim()
|
|
27
|
+
return message || '版本更新'
|
|
28
|
+
} catch {
|
|
29
|
+
console.warn('⚠️ 获取Git提交信息失败,使用默认描述')
|
|
30
|
+
return '版本更新'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 获取当前分支名
|
|
36
|
+
*/
|
|
37
|
+
function getCurrentBranch(): string {
|
|
38
|
+
try {
|
|
39
|
+
return execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf8' }).trim()
|
|
40
|
+
} catch {
|
|
41
|
+
return 'unknown'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 获取提交者信息
|
|
47
|
+
*/
|
|
48
|
+
function getCommitAuthor(): string {
|
|
49
|
+
try {
|
|
50
|
+
return execSync('git log -1 --pretty=%an', { encoding: 'utf8' }).trim()
|
|
51
|
+
} catch {
|
|
52
|
+
return 'unknown'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* CI插件配置函数
|
|
58
|
+
* 自动读取版本号和提交信息
|
|
59
|
+
* @returns CIOptions配置
|
|
60
|
+
*/
|
|
61
|
+
export async function CIPluginFn() {
|
|
62
|
+
// 动态获取版本信息
|
|
63
|
+
const version = getPackageVersion()
|
|
64
|
+
const commitMessage = getLatestCommitMessage()
|
|
65
|
+
const branch = getCurrentBranch()
|
|
66
|
+
const author = getCommitAuthor()
|
|
67
|
+
|
|
68
|
+
// 构建发布描述
|
|
69
|
+
const desc = `${commitMessage}\n\n📦 版本: ${version}\n🌿 分支: ${branch}\n👤 提交者: ${author}\n⏰ 发布时间: ${new Date().toLocaleString('zh-CN')}`
|
|
70
|
+
|
|
71
|
+
console.warn('🚀 CI发布配置:')
|
|
72
|
+
console.warn(`📦 版本号: ${version}`)
|
|
73
|
+
console.warn(`📝 提交信息: ${commitMessage}`)
|
|
74
|
+
console.warn(`🌿 分支: ${branch}`)
|
|
75
|
+
console.warn(`👤 提交者: ${author}`)
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @typedef { import("@tarojs/plugin-mini-ci").CIOptions } CIOptions
|
|
79
|
+
* @type {CIOptions}
|
|
80
|
+
*/
|
|
81
|
+
return {
|
|
82
|
+
weapp: {
|
|
83
|
+
appid: process.env.TARO_APP_MODE === 'development' ? 'abc' : 'abc',
|
|
84
|
+
privateKeyPath:
|
|
85
|
+
process.env.TARO_APP_MODE === 'development' ? 'key/private.abc.key' : 'key/private.abc.key',
|
|
86
|
+
devToolsInstallPath: `C:\\Program Files (x86)\\Tencent\\微信web开发者工具`,
|
|
87
|
+
},
|
|
88
|
+
// tt: {
|
|
89
|
+
// email: '字节小程序邮箱',
|
|
90
|
+
// password: '字节小程序密码',
|
|
91
|
+
// },
|
|
92
|
+
// alipay: {
|
|
93
|
+
// appid: '支付宝小程序appid',
|
|
94
|
+
// toolId: '工具id',
|
|
95
|
+
// privateKeyPath: '密钥文件相对项目根目录的相对路径,例如 key/pkcs8-private-pem',
|
|
96
|
+
// },
|
|
97
|
+
// dd: {
|
|
98
|
+
// appid: '钉钉小程序appid,即钉钉开放平台后台应用管理的 MiniAppId 选项',
|
|
99
|
+
// token: '令牌,从钉钉后台获取',
|
|
100
|
+
// },
|
|
101
|
+
// swan: {
|
|
102
|
+
// token: '鉴权需要的token令牌',
|
|
103
|
+
// },
|
|
104
|
+
// 动态版本号
|
|
105
|
+
version,
|
|
106
|
+
// 动态版本发布描述
|
|
107
|
+
desc,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// export const config = {
|
|
112
|
+
// plugin: [['@tarojs/plugin-mini-ci', CIPluginFn]],
|
|
113
|
+
// }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import antfu from '@antfu/eslint-config'
|
|
2
|
+
|
|
3
|
+
export default antfu(
|
|
4
|
+
{
|
|
5
|
+
extends: ['taro/vue3'],
|
|
6
|
+
formatters: true,
|
|
7
|
+
unocss: true,
|
|
8
|
+
vue: true,
|
|
9
|
+
typescript: true,
|
|
10
|
+
stylistic: {
|
|
11
|
+
indent: 2, // 4, or 'tab'
|
|
12
|
+
quotes: 'single', // or 'double'
|
|
13
|
+
},
|
|
14
|
+
// Parse the `.gitignore` file to get the ignores, on by default
|
|
15
|
+
gitignore: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
rules: {
|
|
19
|
+
'n/prefer-global/process': 'off',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bubbles-project",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "vue-taro-eslint",
|
|
6
|
+
"author": "",
|
|
7
|
+
"templateInfo": {
|
|
8
|
+
"name": "default",
|
|
9
|
+
"typescript": true,
|
|
10
|
+
"css": "Sass",
|
|
11
|
+
"framework": "Vue3"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"new": "taro new",
|
|
15
|
+
"build:weapp": "taro build --type weapp --open",
|
|
16
|
+
"build:swan": "taro build --type swan",
|
|
17
|
+
"build:alipay": "taro build --type alipay",
|
|
18
|
+
"build:tt": "taro build --type tt",
|
|
19
|
+
"build:h5": "taro build --type h5",
|
|
20
|
+
"build:h5:prod": "taro build --type h5 --mode production",
|
|
21
|
+
"build:rn": "taro build --type rn",
|
|
22
|
+
"build:qq": "taro build --type qq",
|
|
23
|
+
"build:jd": "taro build --type jd",
|
|
24
|
+
"build:harmony-hybrid": "taro build --type harmony-hybrid",
|
|
25
|
+
"dev:weapp": "npm run build:weapp -- --watch",
|
|
26
|
+
"dev:swan": "npm run build:swan -- --watch",
|
|
27
|
+
"dev:alipay": "npm run build:alipay -- --watch",
|
|
28
|
+
"dev:tt": "npm run build:tt -- --watch",
|
|
29
|
+
"dev:h5": "npm run build:h5 -- --watch",
|
|
30
|
+
"dev:rn": "npm run build:rn -- --watch",
|
|
31
|
+
"dev:qq": "npm run build:qq -- --watch",
|
|
32
|
+
"dev:jd": "npm run build:jd -- --watch",
|
|
33
|
+
"dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch",
|
|
34
|
+
"prepare": "lefthook install",
|
|
35
|
+
"lint": "eslint",
|
|
36
|
+
"lint:fix": "eslint --fix"
|
|
37
|
+
},
|
|
38
|
+
"browserslist": {
|
|
39
|
+
"development": [
|
|
40
|
+
"defaults and fully supports es6-module",
|
|
41
|
+
"maintained node versions"
|
|
42
|
+
],
|
|
43
|
+
"production": [
|
|
44
|
+
"last 3 versions",
|
|
45
|
+
"Android >= 4.1",
|
|
46
|
+
"ios >= 8"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@alova/adapter-taro": "^2.0.14",
|
|
51
|
+
"@babel/runtime": "^7.24.4",
|
|
52
|
+
"@nutui/nutui-taro": "^4.3.14",
|
|
53
|
+
"@nutui/touch-emulator": "^1.0.0",
|
|
54
|
+
"@tarojs/components": "4.1.11",
|
|
55
|
+
"@tarojs/helper": "4.1.11",
|
|
56
|
+
"@tarojs/plugin-framework-vue3": "4.1.11",
|
|
57
|
+
"@tarojs/plugin-html": "4.1.11",
|
|
58
|
+
"@tarojs/plugin-platform-alipay": "4.1.11",
|
|
59
|
+
"@tarojs/plugin-platform-h5": "4.1.11",
|
|
60
|
+
"@tarojs/plugin-platform-harmony-hybrid": "4.1.11",
|
|
61
|
+
"@tarojs/plugin-platform-jd": "4.1.11",
|
|
62
|
+
"@tarojs/plugin-platform-qq": "4.1.11",
|
|
63
|
+
"@tarojs/plugin-platform-swan": "4.1.11",
|
|
64
|
+
"@tarojs/plugin-platform-tt": "4.1.11",
|
|
65
|
+
"@tarojs/plugin-platform-weapp": "4.1.11",
|
|
66
|
+
"@tarojs/runtime": "4.1.11",
|
|
67
|
+
"@tarojs/shared": "4.1.11",
|
|
68
|
+
"@tarojs/taro": "4.1.11",
|
|
69
|
+
"alova": "^3.5.0",
|
|
70
|
+
"pinia": "^3.0.4",
|
|
71
|
+
"pinia-plugin-persistedstate": "^4.7.1",
|
|
72
|
+
"spark-md5": "^3.0.2",
|
|
73
|
+
"vue": "^3.0.0"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@antfu/eslint-config": "^7.4.3",
|
|
77
|
+
"@babel/core": "^7.24.4",
|
|
78
|
+
"@babel/plugin-transform-class-properties": "7.25.9",
|
|
79
|
+
"@commitlint/cli": "^20.4.2",
|
|
80
|
+
"@commitlint/config-conventional": "^20.4.2",
|
|
81
|
+
"@nutui/auto-import-resolver": "^1.0.0",
|
|
82
|
+
"@tarojs/cli": "4.1.11",
|
|
83
|
+
"@tarojs/plugin-generator": "4.1.11",
|
|
84
|
+
"@tarojs/plugin-mini-ci": "^4.1.11",
|
|
85
|
+
"@tarojs/taro-loader": "4.1.11",
|
|
86
|
+
"@tarojs/test-utils-vue3": "^0.1.1",
|
|
87
|
+
"@tarojs/webpack5-runner": "4.1.11",
|
|
88
|
+
"@types/minimatch": "^5",
|
|
89
|
+
"@types/node": "^18",
|
|
90
|
+
"@types/webpack-env": "^1.13.6",
|
|
91
|
+
"@unocss/eslint-plugin": "^66.6.2",
|
|
92
|
+
"@unocss/webpack": "0.58.9",
|
|
93
|
+
"@vue/babel-plugin-jsx": "^1.2.2",
|
|
94
|
+
"@vue/compiler-sfc": "^3.0.0",
|
|
95
|
+
"autoprefixer": "^10.4.24",
|
|
96
|
+
"babel-preset-taro": "4.1.11",
|
|
97
|
+
"css-loader": "^7.1.1",
|
|
98
|
+
"eslint": "^10.0.2",
|
|
99
|
+
"eslint-config-taro": "4.1.11",
|
|
100
|
+
"eslint-plugin-format": "^1.4.0",
|
|
101
|
+
"eslint-plugin-vue": "^9.17.0",
|
|
102
|
+
"lefthook": "^2.1.1",
|
|
103
|
+
"miniprogram-ci": "^2.1.26",
|
|
104
|
+
"postcss": "^8.5.6",
|
|
105
|
+
"sass": "^1.75.0",
|
|
106
|
+
"style-loader": "^3.3.4",
|
|
107
|
+
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
108
|
+
"typescript": "^5.9.3",
|
|
109
|
+
"unocss": "0.58.9",
|
|
110
|
+
"unocss-preset-weapp": "0.58.8",
|
|
111
|
+
"unplugin-vue-components": "^0.26.0",
|
|
112
|
+
"vue-loader": "^17.4.2",
|
|
113
|
+
"webpack": "5.91.0"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/dist/WeappCI.js b/dist/WeappCI.js
|
|
2
|
+
index 778b65b4f366611ed3c577d3d470da391c3ca879..f6049120970a60a1cd9bbc420a7b835ea2056a49 100644
|
|
3
|
+
--- a/dist/WeappCI.js
|
|
4
|
+
+++ b/dist/WeappCI.js
|
|
5
|
+
@@ -67,7 +67,7 @@ class WeappCI extends BaseCi_1.default {
|
|
6
|
+
printLog("error" /* processTypeEnum.ERROR */, '命令行工具路径不存在', cliPath);
|
|
7
|
+
}
|
|
8
|
+
printLog("start" /* processTypeEnum.START */, '微信开发者工具...', this.projectPath);
|
|
9
|
+
- shell.exec(`${cliPath} open --project ${this.projectPath}`);
|
|
10
|
+
+ shell.exec(`"${cliPath}" open --project "${this.projectPath}"`, { encoding: 'utf8' });
|
|
11
|
+
}
|
|
12
|
+
async preview() {
|
|
13
|
+
const { chalk, printLog, processTypeEnum } = this.ctx.helper;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"miniprogramRoot": "./dist/weapp",
|
|
3
|
+
"projectname": "myApp",
|
|
4
|
+
"description": "vue-taro-eslint",
|
|
5
|
+
"appid": "wxac3f99d8814754aa",
|
|
6
|
+
"setting": {
|
|
7
|
+
"urlCheck": true,
|
|
8
|
+
"es6": false,
|
|
9
|
+
"enhance": false,
|
|
10
|
+
"compileHotReLoad": false,
|
|
11
|
+
"postcss": false,
|
|
12
|
+
"minified": false,
|
|
13
|
+
"minifyWXML": true
|
|
14
|
+
},
|
|
15
|
+
"compileType": "miniprogram"
|
|
16
|
+
}
|