create-tauri-ui 1.0.1 → 1.0.3
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/assets/release.yml.tmpl +4 -5
- package/dist/index.mjs +16 -20
- package/package.json +1 -1
package/assets/release.yml.tmpl
CHANGED
|
@@ -41,11 +41,11 @@ jobs:
|
|
|
41
41
|
sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf
|
|
42
42
|
|
|
43
43
|
- name: Install frontend dependencies
|
|
44
|
-
run: bun install
|
|
44
|
+
run: bun install
|
|
45
45
|
|
|
46
46
|
- name: Build and publish
|
|
47
47
|
id: tauri
|
|
48
|
-
uses: tauri-apps/tauri-action@
|
|
48
|
+
uses: tauri-apps/tauri-action@action-v0.6.2
|
|
49
49
|
env:
|
|
50
50
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
51
51
|
with:
|
|
@@ -57,9 +57,8 @@ jobs:
|
|
|
57
57
|
generateReleaseNotes: true
|
|
58
58
|
retryAttempts: 2
|
|
59
59
|
args: ${{ matrix.args }}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
uploadUpdaterSignatures: false
|
|
60
|
+
assetNamePattern: "[name]-[version]-[platform]-[arch][ext]"
|
|
61
|
+
includeUpdaterJson: false
|
|
63
62
|
|
|
64
63
|
- name: Release summary
|
|
65
64
|
if: steps.tauri.outputs.releaseHtmlUrl != ''
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import s from"node:fs";import a from"node:path";import S from"node:process";import{text as _,confirm as P,select as we,multiselect as ve,isCancel as xe,cancel as W,log as h,intro as ye,spinner as be,outro as ke,note as K}from"@clack/prompts";import A from"picocolors";import z from"node:os";import{execFile as
|
|
2
|
-
`)}async function C(e,t,r){return await new Promise((n,i)=>{
|
|
1
|
+
import s from"node:fs";import a from"node:path";import S from"node:process";import{text as _,confirm as P,select as we,multiselect as ve,isCancel as xe,cancel as W,log as h,intro as ye,spinner as be,outro as ke,note as K}from"@clack/prompts";import A from"picocolors";import z from"node:os";import{execFile as $e}from"node:child_process";import{fileURLToPath as I}from"node:url";const D=new Set;let Y=!1,X=!1;class L extends Error{constructor(t,r,n,i){super(t),this.stdout=r,this.stderr=n,this.code=i}}class w extends Error{constructor(t,r,n){super(r),this.tool=t,this.stderr=n}}class u extends Error{constructor(t,r){super(r),this.file=t}}function Ee(e){return e?.trim().replace(/\/+$/g,"")}function q(e,t){s.statSync(e).isDirectory()?Z(e,t):(s.mkdirSync(a.dirname(t),{recursive:!0}),s.copyFileSync(e,t))}function R(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function J(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function Z(e,t){s.mkdirSync(t,{recursive:!0});for(const r of s.readdirSync(e)){const n=a.resolve(e,r),i=a.resolve(t,r);q(n,i)}}function je(e){const t=s.readdirSync(e);return t.length===0||t.length===1&&t[0]===".git"}function l(e,t){const r=s.readFileSync(e,"utf-8");s.writeFileSync(e,t(r),"utf-8")}function m(e,t){const r=JSON.parse(s.readFileSync(e,"utf-8")),n=t(r);s.writeFileSync(e,JSON.stringify(n,null,2)+`
|
|
2
|
+
`)}async function C(e,t,r){return await new Promise((n,i)=>{$e(e,t,{cwd:r?.cwd,env:{...process.env,...r?.env},maxBuffer:1024*1024*10},(o,c,N)=>{if(o){i(new L(`Command failed: ${e} ${t.join(" ")}`,c,N,typeof o.code=="number"?o.code:null));return}n(c.trim())})})}function Q(e){return s.mkdtempSync(a.join(z.tmpdir(),e))}function O(e){D.add(e)}function f(e){D.delete(e)}function g(e){s.existsSync(e)&&s.rmSync(e,{recursive:!0,force:!0})}function Se(){const e=[...D].sort((t,r)=>r.length-t.length);for(const t of e)try{g(t)}catch{}finally{D.delete(t)}}function _e(){if(Y)return;Y=!0;const e=(t,r)=>{X&&process.exit(r),X=!0,Se(),process.exit(r)};process.once("SIGINT",()=>e("SIGINT",130)),process.once("SIGTERM",()=>e("SIGTERM",143))}function Pe(e){return e.replace(/^@[^/]+\//,"").replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")}const De={name:"astro",async apply(e,t){l(a.join(e,"astro.config.mjs"),r=>{if(r.includes("server: {"))return r;const n=r.lastIndexOf(`
|
|
3
3
|
})`);if(n===-1)throw new u("astro.config.mjs","Could not find the Astro config closing brace.");return`${r.slice(0,n)}
|
|
4
4
|
server: {
|
|
5
5
|
port: 1420,
|
|
@@ -121,13 +121,11 @@ ${re}`)),!i.includes(ne.trim())&&i.includes(` let _ = webview.ope
|
|
|
121
121
|
`)),!i.includes(ie.trim())&&i.includes(` let _ = webview.window().show();
|
|
122
122
|
`)&&(i=i.replace(` let _ = webview.window().show();
|
|
123
123
|
`,`${ie} let _ = webview.window().show();
|
|
124
|
-
`)),i})}function it(e,t){const r=a.join(e,"src/main.tsx"),n=x(t);l(r,i=>{let o=i;if(o.includes(`import { DebugPanel } from "${n}"`)||(o=o.replace(
|
|
125
|
-
`,`import { ExternalLinkGuard } from "./components/external-link-guard.tsx"
|
|
124
|
+
`)),i})}function it(e,t){const r=a.join(e,"src/main.tsx"),n=x(t);l(r,i=>{let o=i;if(o.includes(`import { DebugPanel } from "${n}"`)||(o=o.replace(/import { ExternalLinkGuard } from "\.\/components\/external-link-guard\.tsx"\r?\n/,`import { ExternalLinkGuard } from "./components/external-link-guard.tsx"
|
|
126
125
|
import { DebugPanel } from "${n}"
|
|
127
|
-
`)),o.includes("<DebugPanel />"))return o;const c=o.replace(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<main><App /></main>`);if(c===o)throw new u(r,"Could not mount DebugPanel in the Vite entrypoint.");return c})}function at(e,t){const r=a.join(e,"app/layout.tsx"),n=x(t);l(r,i=>{let o=i;if(o.includes(`import { DebugPanel } from "${n}"`)||(o.includes(`import { ExternalLinkGuard } from "@/components/external-link-guard"
|
|
126
|
+
`)),o.includes("<DebugPanel />"))return o;const c=o.replace(/<ExternalLinkGuard \/>\r?\n(\s*)<main><App \/><\/main>/,`<ExternalLinkGuard />
|
|
127
|
+
$1{import.meta.env.DEV ? <DebugPanel /> : null}
|
|
128
|
+
$1<main><App /></main>`);if(c===o)throw new u(r,"Could not mount DebugPanel in the Vite entrypoint.");return c})}function at(e,t){const r=a.join(e,"app/layout.tsx"),n=x(t);l(r,i=>{let o=i;if(o.includes(`import { DebugPanel } from "${n}"`)||(o.includes(`import { ExternalLinkGuard } from "@/components/external-link-guard"
|
|
131
129
|
`)?o=o.replace(`import { ExternalLinkGuard } from "@/components/external-link-guard"
|
|
132
130
|
`,`import { ExternalLinkGuard } from "@/components/external-link-guard"
|
|
133
131
|
import { DebugPanel } from "${n}"
|
|
@@ -282,13 +280,11 @@ ${U}
|
|
|
282
280
|
${n}`),!n.includes("fn external_navigation_plugin<R: tauri::Runtime>()")){if(!n.includes("#[cfg_attr(mobile, tauri::mobile_entry_point)]"))throw new u(t,"Could not find the Tauri entry point while inserting the external navigation plugin.");n=n.replace("#[cfg_attr(mobile, tauri::mobile_entry_point)]",`${ut}#[cfg_attr(mobile, tauri::mobile_entry_point)]`)}if(!n.includes(".plugin(external_navigation_plugin())")){if(!n.includes(".plugin(tauri_plugin_opener::init())"))throw new u(t,"Could not find the opener plugin while inserting the external navigation guard.");n=n.replace(` .plugin(tauri_plugin_opener::init())
|
|
283
281
|
`,` .plugin(tauri_plugin_opener::init())
|
|
284
282
|
.plugin(external_navigation_plugin())
|
|
285
|
-
`)}return n})}function mt(e){const t=a.join(e,"src/components/external-link-guard.tsx"),r=a.join(e,"src/main.tsx");y(t),l(r,n=>{let i=n;if(i.includes('import { ExternalLinkGuard } from "./components/external-link-guard.tsx"')||(i=i.replace(
|
|
286
|
-
`,`import { ThemeProvider } from "@/components/theme-provider.tsx"
|
|
283
|
+
`)}return n})}function mt(e){const t=a.join(e,"src/components/external-link-guard.tsx"),r=a.join(e,"src/main.tsx");y(t),l(r,n=>{let i=n;if(i.includes('import { ExternalLinkGuard } from "./components/external-link-guard.tsx"')||(i=i.replace(/import { ThemeProvider } from "@\/components\/theme-provider\.tsx"\r?\n/,`import { ThemeProvider } from "@/components/theme-provider.tsx"
|
|
287
284
|
import { ExternalLinkGuard } from "./components/external-link-guard.tsx"
|
|
288
|
-
`)),i.includes("<ExternalLinkGuard />"))return i;const o=i.replace(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
<main><App /></main>`);if(o===i)throw new u(r,"Could not mount ExternalLinkGuard in the Vite entrypoint.");return o})}function ft(e){const t=a.join(e,"components/external-link-guard.tsx"),r=a.join(e,"app/layout.tsx");y(t),l(r,n=>{let i=n;if(i.includes('import { ExternalLinkGuard } from "@/components/external-link-guard"')||(i.includes(`import { TooltipProvider } from "@/components/ui/tooltip"
|
|
285
|
+
`)),i.includes("<ExternalLinkGuard />"))return i;const o=i.replace(/<ThemeProvider>\r?\n(\s*)<main><App \/><\/main>/,`<ThemeProvider>
|
|
286
|
+
$1<ExternalLinkGuard />
|
|
287
|
+
$1<main><App /></main>`);if(o===i)throw new u(r,"Could not mount ExternalLinkGuard in the Vite entrypoint.");return o})}function ft(e){const t=a.join(e,"components/external-link-guard.tsx"),r=a.join(e,"app/layout.tsx");y(t),l(r,n=>{let i=n;if(i.includes('import { ExternalLinkGuard } from "@/components/external-link-guard"')||(i.includes(`import { TooltipProvider } from "@/components/ui/tooltip"
|
|
292
288
|
`)?i=i.replace(`import { TooltipProvider } from "@/components/ui/tooltip"
|
|
293
289
|
`,`import { TooltipProvider } from "@/components/ui/tooltip"
|
|
294
290
|
import { ExternalLinkGuard } from "@/components/external-link-guard"
|
|
@@ -320,7 +316,7 @@ import { ExternalLinkGuard } from "@/components/external-link-guard"
|
|
|
320
316
|
`)?n=n.replace(`use tauri::Manager;
|
|
321
317
|
`,`${V}
|
|
322
318
|
`):n=`${V}
|
|
323
|
-
${n}`),n.includes(".on_page_load("))return n;const i=n.replace(" .run(tauri::generate_context!())",`${xt} .run(tauri::generate_context!())`);if(i===n)throw new u(t,"Could not insert the startup flash-prevention page-load hook.");return i})}function bt(){const e=a.dirname(I(import.meta.url)),t=[a.resolve(e,"../assets"),a.resolve(e,"../../assets")];return t.find(r=>s.existsSync(r))??t[0]}const kt=bt();async function
|
|
319
|
+
${n}`),n.includes(".on_page_load("))return n;const i=n.replace(" .run(tauri::generate_context!())",`${xt} .run(tauri::generate_context!())`);if(i===n)throw new u(t,"Could not insert the startup flash-prevention page-load hook.");return i})}function bt(){const e=a.dirname(I(import.meta.url)),t=[a.resolve(e,"../assets"),a.resolve(e,"../../assets")];return t.find(r=>s.existsSync(r))??t[0]}const kt=bt();async function $t(e){q(a.join(kt,"app-icon.png"),a.join(e,"app-icon.png"))}function Et(e){return`"use client"
|
|
324
320
|
|
|
325
321
|
import { useState } from "react"
|
|
326
322
|
import { Button } from "${e}components/ui/button"
|
|
@@ -402,7 +398,7 @@ function Home() {
|
|
|
402
398
|
</div>
|
|
403
399
|
)
|
|
404
400
|
}
|
|
405
|
-
`}function se(e,t){switch(e){case"next":return a.join(t,"app/page.tsx");case"vite":return a.join(t,"src/App.tsx");case"start":return a.join(t,"src/routes/index.tsx");case"react-router":return a.join(t,"app/routes/home.tsx");case"astro":return a.join(t,"src/pages/index.astro")}}function _t(e,t){switch(e){case"next":return a.join(t,"components/greet.tsx");case"vite":case"start":case"astro":return a.join(t,"src/components/greet.tsx");case"react-router":return a.join(t,"app/components/greet.tsx")}}async function Pt(e,t){t.includeStarterUI||await te(e,"input");const r=t.template==="react-router"?"~/":"@/";if(s.writeFileSync(_t(t.template,e)
|
|
401
|
+
`}function se(e,t){switch(e){case"next":return a.join(t,"app/page.tsx");case"vite":return a.join(t,"src/App.tsx");case"start":return a.join(t,"src/routes/index.tsx");case"react-router":return a.join(t,"app/routes/home.tsx");case"astro":return a.join(t,"src/pages/index.astro")}}function _t(e,t){switch(e){case"next":return a.join(t,"components/greet.tsx");case"vite":case"start":case"astro":return a.join(t,"src/components/greet.tsx");case"react-router":return a.join(t,"app/components/greet.tsx")}}async function Pt(e,t){t.includeStarterUI||await te(e,"input");const r=t.template==="react-router"?"~/":"@/";if(s.writeFileSync(_t(t.template,e),Et(r)),t.includeStarterUI)return;if(t.template==="astro"){s.writeFileSync(se(t.template,e),`---
|
|
406
402
|
import Layout from "@/layouts/main.astro"
|
|
407
403
|
import { Greet } from "@/components/greet"
|
|
408
404
|
---
|
|
@@ -441,7 +437,7 @@ main {
|
|
|
441
437
|
height: 100%;
|
|
442
438
|
}
|
|
443
439
|
`;function k(e,t){l(e,r=>r.includes("overscroll-behavior: none;")?r:`${r.trimEnd()}
|
|
444
|
-
${t}`)}function
|
|
440
|
+
${t}`)}function $(e,t,r){l(e,n=>{if(n.includes("<main>"))return n;const i=n.replace(t,r);if(i===n)throw new u(e,"Could not insert the scroll container <main> wrapper.");return i})}async function Lt(e,t){switch(t.template){case"next":k(a.join(e,"app/globals.css"),b),$(a.join(e,"app/layout.tsx"),/\{children\}/,"<main>{children}</main>");return;case"vite":k(a.join(e,"src/index.css"),`${b}${Dt}`),$(a.join(e,"src/main.tsx"),/<App \/>/,"<main><App /></main>");return;case"start":k(a.join(e,"src/styles.css"),b),$(a.join(e,"src/routes/__root.tsx"),/\{children\}/,"<main>{children}</main>");return;case"react-router":k(a.join(e,"app/app.css"),b),$(a.join(e,"app/root.tsx"),/return <Outlet \/>/,"return <main><Outlet /></main>");return;case"astro":k(a.join(e,"src/styles/global.css"),b),$(a.join(e,"src/layouts/main.astro"),/<slot \/>/,"<main><slot /></main>");return;default:throw new u(e,`No scroll container battery implementation exists for template "${t.template}".`)}}const E=`
|
|
445
441
|
@layer base {
|
|
446
442
|
body {
|
|
447
443
|
@apply select-none;
|
|
@@ -462,10 +458,10 @@ ${t}`)}function E(e,t,r){l(e,n=>{if(n.includes("<main>"))return n;const i=n.repl
|
|
|
462
458
|
}
|
|
463
459
|
}
|
|
464
460
|
`;function j(e,t){l(e,r=>r.includes(".ui-selectable")?r:`${r.trimEnd()}
|
|
465
|
-
${t}`)}async function Ct(e,t){switch(t.template){case"next":j(a.join(e,"app/globals.css")
|
|
461
|
+
${t}`)}async function Ct(e,t){switch(t.template){case"next":j(a.join(e,"app/globals.css"),E);return;case"vite":j(a.join(e,"src/index.css"),E);return;case"start":j(a.join(e,"src/styles.css"),E);return;case"react-router":j(a.join(e,"app/app.css"),E);return;case"astro":j(a.join(e,"src/styles/global.css"),E);return;default:throw new u(e,`No selection behavior battery implementation exists for template "${t.template}".`)}}function Tt(){const e=a.dirname(I(import.meta.url)),t=[a.resolve(e,"../assets"),a.resolve(e,"../../assets")];return t.find(r=>s.existsSync(r))??t[0]}const Gt=Tt();function Nt(e){const t=[];for(const r of e){if(r==="macos-latest"){t.push({name:"macOS Apple Silicon",platform:"macos-latest",args:"--target aarch64-apple-darwin"},{name:"macOS Intel",platform:"macos-latest",args:"--target x86_64-apple-darwin"});continue}if(r==="ubuntu-latest"){t.push({name:"Linux",platform:"ubuntu-22.04",args:""});continue}t.push({name:"Windows",platform:r,args:""})}return t.map(r=>` - name: "${r.name}"
|
|
466
462
|
platform: "${r.platform}"
|
|
467
463
|
args: "${r.args}"`).join(`
|
|
468
|
-
`)}async function At(e,t){const r=s.readFileSync(a.join(Gt,"release.yml.tmpl"),"utf-8").replace("{{PLATFORMS}}",Nt(t.targetOS)),n=a.join(e,".github/workflows");s.mkdirSync(n,{recursive:!0}),s.writeFileSync(a.join(n,"release.yml"),r)}const It=1400,Rt=918;async function Ot(e,t,r){Z(a.join(t,"src-tauri"),a.join(e,"src-tauri")),m(a.join(e,"package.json"),o=>(o.name=r.packageName,o.dependencies=o.dependencies||{},o.dependencies["@tauri-apps/api"]="^2",o.dependencies["@tauri-apps/plugin-opener"]="^2",o.devDependencies=o.devDependencies||{},o.devDependencies["@tauri-apps/cli"]="^2",o.scripts=o.scripts||{},o.scripts.tauri="tauri",o));const n=Pe(r.packageName),i=`${n}_lib`;l(a.join(e,"src-tauri/Cargo.toml"),o=>o.replace(/^name = "tauri-app"$/m,`name = "${n}"`).replace(/^name = "tauri_app_lib"$/m,`name = "${i}"`)),l(a.join(e,"src-tauri/src/main.rs"),o=>o.replace("tauri_app_lib::run()",`${i}::run()`))}async function Ft(e,t,r){m(a.join(e,"src-tauri/tauri.conf.json"),n=>{n.productName=t.projectName,n.identifier=t.identifier,n.build={...n.build,...r},n.app=n.app||{},n.app.windows=Array.isArray(n.app.windows)?n.app.windows:[{}];const i=n.app.windows[0]||{};return n.app.windows[0]={...i,title:t.projectName,center:!0,width:It,height:Rt},n})}const B=["vite","next","start","react-router","astro"],M=["windows-latest","macos-latest","ubuntu-latest"],ce="tauri-ui",le="b0",Ut={vite:"Vite",next:"Next.js",start:"TanStack Start","react-router":"React Router",astro:"Astro"};function p(e,t="Operation cancelled"){if(xe(e))throw new Error(t);return e}function Vt(e){if(B.includes(e))return e;throw new Error(`Unsupported template "${e}". Expected one of: ${B.join(", ")}`)}function ue(e){try{return`com.${J(z.userInfo().username)||"example"}.${e}`}catch{return`com.example.${e}`}}function G(e){return{placeholder:e,defaultValue:e}}async function Bt(e,t=process.cwd()){let r
|
|
464
|
+
`)}async function At(e,t){const r=s.readFileSync(a.join(Gt,"release.yml.tmpl"),"utf-8").replace("{{PLATFORMS}}",Nt(t.targetOS)),n=a.join(e,".github/workflows");s.mkdirSync(n,{recursive:!0}),s.writeFileSync(a.join(n,"release.yml"),r)}const It=1400,Rt=918;async function Ot(e,t,r){Z(a.join(t,"src-tauri"),a.join(e,"src-tauri")),m(a.join(e,"package.json"),o=>(o.name=r.packageName,o.dependencies=o.dependencies||{},o.dependencies["@tauri-apps/api"]="^2",o.dependencies["@tauri-apps/plugin-opener"]="^2",o.devDependencies=o.devDependencies||{},o.devDependencies["@tauri-apps/cli"]="^2",o.scripts=o.scripts||{},o.scripts.tauri="tauri",o));const n=Pe(r.packageName),i=`${n}_lib`;l(a.join(e,"src-tauri/Cargo.toml"),o=>o.replace(/^name = "tauri-app"$/m,`name = "${n}"`).replace(/^name = "tauri_app_lib"$/m,`name = "${i}"`)),l(a.join(e,"src-tauri/src/main.rs"),o=>o.replace("tauri_app_lib::run()",`${i}::run()`))}async function Ft(e,t,r){m(a.join(e,"src-tauri/tauri.conf.json"),n=>{n.productName=t.projectName,n.identifier=t.identifier,n.build={...n.build,...r},n.app=n.app||{},n.app.windows=Array.isArray(n.app.windows)?n.app.windows:[{}];const i=n.app.windows[0]||{};return n.app.windows[0]={...i,title:t.projectName,center:!0,width:It,height:Rt},n})}const B=["vite","next","start","react-router","astro"],M=["windows-latest","macos-latest","ubuntu-latest"],ce="tauri-ui",le="b0",Ut={vite:"Vite",next:"Next.js",start:"TanStack Start","react-router":"React Router",astro:"Astro"};function p(e,t="Operation cancelled"){if(xe(e))throw new Error(t);return e}function Vt(e){if(B.includes(e))return e;throw new Error(`Unsupported template "${e}". Expected one of: ${B.join(", ")}`)}function ue(e){try{return`com.${J(z.userInfo().username)||"example"}.${e}`}catch{return`com.example.${e}`}}function G(e){return{placeholder:e,defaultValue:e}}async function Bt(e,t=process.cwd()){let r=Ee(e.targetDir);if(r||(r=p(await _({message:"Project name",...G(ce)}))),r||(r=ce),r===".")throw new Error("Scaffolding into the current directory is not supported yet.");const n=a.resolve(t,r),i=a.basename(n),o=R(i)?i:J(i);if(s.existsSync(n)&&!je(n))if(e.force)s.rmSync(n,{recursive:!0,force:!0});else{if(e.yes)throw new Error(`Target directory "${r}" is not empty. Re-run with --force to overwrite it.`);if(!p(await P({message:`Target directory "${r}" is not empty. Remove it and continue?`,initialValue:!1})))throw new Error("Operation cancelled");s.rmSync(n,{recursive:!0,force:!0})}let c=o;R(i)||(e.yes?c=o:c=p(await _({message:"Package name",...G(o),validate(d){if(!d||!R(d))return"Enter a valid package.json name"}})));const N=e.template?Vt(e.template):e.yes?"vite":p(await we({message:"Frontend template",initialValue:"vite",options:B.map(d=>({value:d,label:Ut[d]}))})),de=e.identifier?e.identifier:e.yes?ue(c):p(await _({message:"App identifier",...G(ue(c))})),me=e.preset?e.preset:e.yes?le:p(await _({message:"shadcn preset",...G(le)})),fe=e.includeStarterUI??(e.yes?!0:p(await P({message:"Include starter UI?",initialValue:!0}))),ge=e.includeInvokeExample??(e.yes?!0:p(await P({message:"Include Rust invoke example?",initialValue:!0}))),H=e.includeWorkflow??(e.yes?!0:p(await P({message:"Include GitHub release workflow?",initialValue:!0}))),he=H?e.yes?[...M]:p(await ve({message:"Target operating systems",initialValues:[...M],required:!0,options:M.map(d=>({value:d,label:d}))})):[];return{projectName:i,packageName:c,template:N,identifier:de,preset:me,includeStarterUI:fe,includeInvokeExample:ge,includeWorkflow:H,targetOS:he,targetDir:n}}function Mt(){console.log(`Usage: create-tauri-ui [target-dir] [options]
|
|
469
465
|
|
|
470
466
|
Options:
|
|
471
467
|
-t, --template <name> vite | next | start | react-router | astro
|
|
@@ -480,4 +476,4 @@ Options:
|
|
|
480
476
|
-f, --force overwrite an existing target directory
|
|
481
477
|
-y, --yes accept defaults
|
|
482
478
|
-h, --help display help`)}function Ht(e){const t={},r=[],n=(i,o)=>{const c=e[i+1];if(!c||c.startsWith("-"))throw new Error(`Missing value for ${o}`);return c};for(let i=0;i<e.length;i+=1){const o=e[i];switch(o){case"-h":case"--help":t.help=!0;break;case"-t":case"--template":t.template=n(i,o),i+=1;break;case"--identifier":t.identifier=n(i,o),i+=1;break;case"--preset":t.preset=n(i,o),i+=1;break;case"--starter":t.includeStarterUI=!0;break;case"--no-starter":t.includeStarterUI=!1;break;case"--invoke-example":case"--example":t.includeInvokeExample=!0;break;case"--no-invoke-example":case"--no-example":t.includeInvokeExample=!1;break;case"--workflow":t.includeWorkflow=!0;break;case"--no-workflow":t.includeWorkflow=!1;break;case"-f":case"--force":t.force=!0;break;case"-y":case"--yes":t.yes=!0;break;default:if(o.startsWith("-"))throw new Error(`Unknown flag: ${o}`);r.push(o)}}if(r.length>1)throw new Error("Only one target directory may be provided.");return r[0]&&(t.targetDir=r[0]),t}function Wt(e){const t=a.relative(S.cwd(),e)||".";return t.includes(" ")?`"${t}"`:t}function Kt(e){s.rmSync(a.join(e,"node_modules"),{recursive:!0,force:!0})}function zt(e,t){const r=[`cd ${Wt(e)}`,"bun install","bun run tauri dev","bunx tauri icon app-icon.png"];K(r.join(`
|
|
483
|
-
`),"Next steps"),t&&K("Configure the GitHub release workflow secrets before publishing builds.","Release workflow")}async function Yt(){try{await C("bun",["--version"])}catch{throw new Error("bun is required. Install it from https://bun.sh.")}}function pe(e){return e instanceof w?{message:e.message,detail:e.stderr.trim()}:e instanceof Error?{message:e.message,detail:""}:{message:"An unknown error occurred.",detail:""}}async function Xt(){const e=Ht(S.argv.slice(2));if(e.help){Mt();return}ye(A.bold("create-tauri-ui")),await Yt();const t=await Bt(e);_e(),O(t.targetDir);const r=be();let n;try{r.start("Creating the shadcn frontend scaffold"),await We(t),r.message("Creating the Tauri native scaffold");const i=await Ke(t);n=i.tempDir,r.message("Merging the native layer into the frontend project"),await Ot(t.targetDir,i.projectDir,t);const o=Oe(t.template);r.message(`Patching the ${t.template} project for Tauri`);try{await o.apply(t.targetDir,t)}catch(c){if(c instanceof u)h.warn(`${c.message} (${c.file})`);else throw c}if(await Ft(t.targetDir,t,o.tauriConfig()),r.message("Applying the startup flash-prevention battery"),await yt(t.targetDir),r.message("Applying the desktop scroll container battery"),await Lt(t.targetDir,t),r.message("Applying the external link guard battery"),await vt(t.targetDir,t),r.message("Applying the development debug panel battery"),await lt(t.targetDir,t),r.message("Applying the desktop selection-behavior battery"),await Ct(t.targetDir,t),t.includeStarterUI){r.message("Installing the starter dashboard");try{await ze(t.targetDir,t)}catch(c){if(c instanceof w)h.warn(c.message),c.stderr.trim()&&h.message(c.stderr.trim());else throw c}}t.includeInvokeExample&&(r.message("Adding the Rust invoke example"),await Pt(t.targetDir,t)),t.includeWorkflow&&(r.message("Writing the GitHub release workflow"),await At(t.targetDir,t)),r.message("Copying the app icon source"),await
|
|
479
|
+
`),"Next steps"),t&&K("Configure the GitHub release workflow secrets before publishing builds.","Release workflow")}async function Yt(){try{await C("bun",["--version"])}catch{throw new Error("bun is required. Install it from https://bun.sh.")}}function pe(e){return e instanceof w?{message:e.message,detail:e.stderr.trim()}:e instanceof Error?{message:e.message,detail:""}:{message:"An unknown error occurred.",detail:""}}async function Xt(){const e=Ht(S.argv.slice(2));if(e.help){Mt();return}ye(A.bold("create-tauri-ui")),await Yt();const t=await Bt(e);_e(),O(t.targetDir);const r=be();let n;try{r.start("Creating the shadcn frontend scaffold"),await We(t),r.message("Creating the Tauri native scaffold");const i=await Ke(t);n=i.tempDir,r.message("Merging the native layer into the frontend project"),await Ot(t.targetDir,i.projectDir,t);const o=Oe(t.template);r.message(`Patching the ${t.template} project for Tauri`);try{await o.apply(t.targetDir,t)}catch(c){if(c instanceof u)h.warn(`${c.message} (${c.file})`);else throw c}if(await Ft(t.targetDir,t,o.tauriConfig()),r.message("Applying the startup flash-prevention battery"),await yt(t.targetDir),r.message("Applying the desktop scroll container battery"),await Lt(t.targetDir,t),r.message("Applying the external link guard battery"),await vt(t.targetDir,t),r.message("Applying the development debug panel battery"),await lt(t.targetDir,t),r.message("Applying the desktop selection-behavior battery"),await Ct(t.targetDir,t),t.includeStarterUI){r.message("Installing the starter dashboard");try{await ze(t.targetDir,t)}catch(c){if(c instanceof w)h.warn(c.message),c.stderr.trim()&&h.message(c.stderr.trim());else throw c}}t.includeInvokeExample&&(r.message("Adding the Rust invoke example"),await Pt(t.targetDir,t)),t.includeWorkflow&&(r.message("Writing the GitHub release workflow"),await At(t.targetDir,t)),r.message("Copying the app icon source"),await $t(t.targetDir),Kt(t.targetDir),f(t.targetDir),r.stop("Project ready"),zt(t.targetDir,t.includeWorkflow),ke(`Scaffolded ${A.cyan(t.projectName)} in ${A.dim(t.targetDir)}`)}catch(i){const o=pe(i);r.error("Scaffolding failed"),W(o.message),o.detail&&h.message(o.detail),S.exitCode=1}finally{if(n){f(n);try{g(n)}catch{}}}}Xt().catch(e=>{const t=pe(e);W(t.message),t.detail&&h.message(t.detail),S.exit(1)});
|