create-instant-app 0.22.182 → 0.22.183
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 +19 -18
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as
|
|
2
|
+
import{Command as Fe,Option as l}from"commander";import*as B from"@clack/prompts";import{spawn as Ce}from"child_process";import{execa as Oe}from"execa";async function $(){return new Promise(e=>{let t=process.env.SHELL||"/bin/bash",n=Ce(t,["-i","-c","which claude"],{stdio:["ignore","pipe","ignore"]}),r="";n.stdout.on("data",a=>{r+=a.toString()}),n.on("close",a=>{if(a===0){let o=r.trim();o.includes("aliased to ")?e(o.split("aliased to ")[1]||null):e(o)}else e(null)})})}var K=async(e,t)=>{let n=await $();if(!n)throw new Error("Claude not found in path");await Oe(n,[e],{stdio:"inherit",cwd:t})};import{version as Re}from"@instantdb/version";import H from"path";var Y=e=>(e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e),je=/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,q=e=>{let n=Y(e).split("/"),r=n[n.length-1];if(r==="."){let i=H.resolve(process.cwd());r=H.basename(i)}let a=n.findIndex(i=>i.startsWith("@"));n.findIndex(i=>i.startsWith("@"))!==-1&&(r=n.slice(a).join("/"));let o=n.filter(i=>!i.startsWith("@")).join("/");return[r,o]},E=e=>e.trim(),D=e=>{let t=Y(e),n=t.split("/"),r=n.findIndex(o=>o.startsWith("@")),a=n[n.length-1];if(n.findIndex(o=>o.startsWith("@"))!==-1&&(a=n.slice(r).join("/")),!(t==="."||je.test(a??"")))return"App name must consist of only lowercase alphanumeric characters, '-', and '_'"};import{renderUnwrap as v,UI as f}from"instant-cli/ui";var C={base:"next-js-app-dir",appName:"Awesome Todos",ruleFiles:null,createRepo:!0,prompt:null,app:null,token:null,yes:!1},X=e=>e.base||e.vanilla&&"vite-vanilla"||e.next&&"next-js-app-dir"||e.expo&&"expo"||e.sv&&"sveltekit"||null,Z=e=>e.cursor&&"cursor"||e.claude&&"claude"||e.codex&&"codex"||e.gemini&&"gemini"||e.rules&&"codex"||null,Q=async()=>{let e=C,t=new Fe().name("Create Instant App").description("A CLI for creating web/mobile applications with InstantDB").argument("[dir]","The name of the application, as well as the name of the directory to create").addOption(new l("-b --base <template>","The base template to scaffold from").choices(["next-js-app-dir","vite-vanilla","expo","bun-react","tanstack-start","tanstack-start-with-tanstack-query","solidjs-vite","sveltekit","vercel-ai-sdk","ai-chat"])).addOption(new l("-g --git","Create a git repo in the new project").default(!0)).addOption(new l("--expo","Use the Expo starter template").default(!1)).addOption(new l("--next","Use the NextJS starter template").default(!1)).addOption(new l("--vanilla","Use the vanilla JS starter template").default(!1)).addOption(new l("--sv","Use the SvelteKit starter template").default(!1)).addOption(new l("--no-git","Don't create a git repo in the new project")).addOption(new l("--cursor","Include a Cursor rules file in the scaffold")).addOption(new l("--claude","Include a CLAUDE.md file in the scaffold")).addOption(new l("--codex","Include an AGENTS.md file in the scaffold")).addOption(new l("--gemini","Include a GEMINI.md file in the scaffold")).addOption(new l("--rules","Include an AGENTS.md file in the scaffold")).addOption(new l("--ai","Create a new InstantDB app based off of a prompt. (requires Claude Code)")).addOption(new l("-a --app <app-id>","Link to an existing InstantDB app by ID (requires login or --token)")).addOption(new l("-t --token <token>","Auth token override (use with --app when not logged in)")).addOption(new l("-y --yes","Use all defaults (requires project name as first argument)").default(!1)).version(Re).parse(process.argv),n=t.args[0]&&E(t.args[0]);if(n){let o=D(n);if(o)throw new Error("Invalid app name: "+o);e.appName=n}let r=t.opts();if(r.yes){if(r.ai)throw new Error("--yes is not supported with --ai");if(!n)throw new Error(`When using --yes, you must specify a project name as the first argument.
|
|
3
|
+
Usage: npx create-instant-app my-app --yes`);return{...C,appName:n,base:X(r)??C.base,ruleFiles:Z(r)??"claude",createRepo:r.git??C.createRepo,app:r.app??null,token:r.token??null,yes:!0}}if(r.ai&&!await $())throw new Error("--ai only works with Claude Code, but we couldn't find it in your machine. Install it first, and run it again : ). Alternatively you can scaffold out a project without --ai");return{...await B.group({appName:async()=>{if(n)return n.trim();let o=await v(new f.TextInput({prompt:"What will your project/folder be called?",placeholder:"awesome-todos",defaultValue:"awesome-todos",validate:s=>D(E(s)),modifyOutput:f.ciaModifier()}));return E(o)},prompt:async()=>r.ai?await v(new f.TextInput({prompt:"What would you like to create?",placeholder:"Create an app that...",modifyOutput:f.modifiers.piped([f.ciaModifier()])})):null,base:async({results:o})=>{let i=X(r);return i||(o.prompt?v(new f.Select({promptText:"What framework would you like to use?",options:[{value:"next-js-app-dir",label:"Next.js"},{value:"expo",label:"Expo: React Native"}],defaultValue:"next-js-app-dir",modifyOutput:f.modifiers.piped([f.ciaModifier()])})):v(new f.Select({promptText:"What framework would you like to use?",options:[{value:"next-js-app-dir",label:"Web: Next.js"},{value:"expo",label:"Mobile: Expo"},{value:"vite-vanilla",label:"Vite: Vanilla TS",secondary:!0},{value:"tanstack-start",label:"Tanstack Start",secondary:!0},{value:"bun-react",label:"Bun + React",secondary:!0},{value:"solidjs-vite",label:"Vite: SolidJS",secondary:!0},{value:"sveltekit",label:"SvelteKit",secondary:!0},{value:"vercel-ai-sdk",label:"Vercel AI SDK App Builder + SSR",secondary:!0},{value:"ai-chat",label:"Vercel AI SDK Chat App",secondary:!0}],defaultValue:"next-js-app-dir",modifyOutput:f.modifiers.piped([f.ciaModifier()])})))},ruleFiles:async({results:o})=>{if(o.prompt)return"claude";let i=Z(r);return i||v(new f.Select({promptText:"Which AI tool would you like to add rule files for?",options:[{value:"claude",label:"Claude"},{value:"cursor",label:"Cursor"},{value:"codex",label:"Codex"},{value:"gemini",label:"Gemini"},{value:"zed",label:"Zed"},{value:"windsurf",label:"Windsurf"},{value:null,label:"None"}],defaultValue:"claude",modifyOutput:f.ciaModifier()}))},createRepo:async()=>r.git!==void 0?r.git:!0},{onCancel(){process.exit(1)}}),app:r.app??null,token:r.token??null,yes:!1}};import ve from"path";import Ae from"fs-extra";import{log as Ne,outro as _t}from"@clack/prompts";import{intro as Me}from"@clack/prompts";import ee from"chalk";var $e=` _ _ _
|
|
3
4
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 (_) | | | |
|
|
4
5
|
\u2588 \u2588\u2588\u2588\u2588 _ _ __ ___| |_ __ _ _ _ _| |_
|
|
5
6
|
\u2588 \u2588\u2588\u2588\u2588 | | '_ \\/ __| __/ _\\\`| '_ \\| __|
|
|
6
7
|
\u2588 \u2588\u2588\u2588\u2588 | | | | \\__ \\ || (_| | | | | |_
|
|
7
|
-
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 |_|_| |_|___/\\__\\__,_|_| |_|\\__|`,
|
|
8
|
-
|
|
9
|
-
`).map(e=>`${
|
|
10
|
-
`))};import d from"path";import
|
|
11
|
-
enable-pre-post-scripts=true`),e.base==="expo"){let
|
|
12
|
-
Using git to clone from main...`),
|
|
8
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 |_|_| |_|___/\\__\\__,_|_| |_|\\__|`,te=()=>{Me(`
|
|
9
|
+
`+$e.split(`
|
|
10
|
+
`).map(e=>`${ee.gray("\u2502")}${ee.hex("#EA580D").bold(" "+e)}`).join(`
|
|
11
|
+
`))};import d from"path";import Ge from"degit";import c from"fs-extra";import ne from"path";import{fileURLToPath as De}from"url";var Be=De(import.meta.url),Ue=ne.dirname(Be),w=ne.join(Ue,"../");import _ from"chalk";var k=e=>{if(e==="bun-react")return"bun";let t=process.env.npm_config_user_agent;return t?t.startsWith("yarn")?"yarn":t.startsWith("pnpm")?"pnpm":t.startsWith("bun")?"bun":"npm":"npm"};import{renderUnwrap as re,UI as y}from"instant-cli/ui";import Le from"slugify";import Ve from"ignore";var oe=async(e,t)=>{let n=d.resolve(process.cwd(),t);if(c.existsSync(n))if(c.readdirSync(n).length===0)y.log(`${_.cyan.bold(e.appName)} exists but is empty, continuing...`,y.ciaModifier(null));else{let o=await re(new y.Select({promptText:_.redBright(`${_.bold("Warning:")} ${_.bold(e.appName)} already exists and isn't empty. How would you like to proceed?`),options:[{label:"Abort installation",value:"abort"},{label:"Clear the directory and continue installation",value:"clear"}],defaultValue:"abort",modifyOutput:y.ciaModifier()}));o==="abort"&&(y.log("Aborting installation..."),process.exit(1)),o==="clear"&&c.emptyDirSync(n)}let r=Je({projectDir:n,baseTemplateName:e.base}),a=e.appName==="."?"App":_.hex("#EA570B").bold(e.appName);if(await re(new y.Spinner({promise:r,workingText:"Scaffolding project files...",doneText:`Successfully scaffolded ${a}!`,errorText:"Error scaffolding project files",modifyOutput:y.ciaModifier(null)})),c.pathExistsSync(d.join(n,"pnpm-lock.yaml"))&&c.removeSync(d.join(n,"pnpm-lock.yaml")),c.pathExistsSync(d.join(n,"bun.lock"))&&c.removeSync(d.join(n,"bun.lock")),k(e.base)==="pnpm"&&e.base==="expo"&&await c.appendFile(d.join(n,".npmrc"),`node-linker=hoisted
|
|
12
|
+
enable-pre-post-scripts=true`),e.base==="expo"){let o=Le.default(t);U(d.join(n,"app.json"),'"name": "expo-template"',`"name": "${t}"`),U(d.join(n,"app.json"),'"slug": "expo-template"',`"slug": "${o}"`),U(d.join(n,"app/_layout.tsx"),'"My Instant App"',`"${t}"`)}return n},U=(e,t,n)=>{let a=c.readFileSync(e,"utf8").replaceAll(t,n);c.writeFileSync(e,a)},We=async({projectDir:e,baseTemplateName:t})=>{let n=`instantdb/instant/examples/${t}`;await Ge(n,{mode:"tar",cache:!1}).clone(e)};async function ze(e,t){let n=Ve();n.add(".git");try{let r=d.join(e,".gitignore"),a=await c.readFile(r,"utf8");n.add(a)}catch{}await c.copy(e,t,{filter:r=>{let a=d.relative(e,r);return a===""?!0:!n.ignores(a)}})}var Je=async({projectDir:e,baseTemplateName:t})=>{let n=d.join(w,`template/base/${t}`),r=!!process.env.INSTANT_CLI_DEV&&!!process.env.INSTANT_REPO_FOLDER,a=c.pathExistsSync(n),o=r?"dev":a?"bundled-template":"degit";if(o==="bundled-template"){c.copySync(n,e);let i=d.join(e,"_gitignore"),s=d.join(e,".gitignore");c.pathExistsSync(i)&&c.renameSync(i,s);return}if(o==="dev"){let i=process.env.INSTANT_REPO_FOLDER;if(!i)throw new Error("INSTANT_REPO_FOLDER is required when using repo-examples scaffolding.");let s=d.join(i,"examples",t);await ze(s,e);return}process.env.INSTANT_CLI_DEV&&!process.env.INSTANT_REPO_FOLDER&&y.log(_.bold.yellowBright(`WARNING: INSTANT_CLI_DEV is TRUE but no INSTANT_REPO_FOLDER is set.
|
|
13
|
+
Using git to clone from main...`),y.ciaModifier(null)),await We({projectDir:e,baseTemplateName:t})};import{execa as Ke}from"execa";import{renderUnwrap as He,UI as O}from"instant-cli/ui";var ae=async(e,t)=>{let n=Ke(e,["install"],{cwd:t}),r=await He(new O.Spinner({promise:n,workingText:`Installing dependencies with ${e}...`,doneText:"Successfully installed dependencies!",modifyOutput:O.ciaModifier(null)}));r.exitCode!==0&&(O.log(r.stderr,O.ciaModifier(null)),process.exit(1))};import It from"chalk";import T from"fs-extra";import u from"path";var ie=({projectDir:e,ruleFilesToAdd:t})=>{if(t!==null)switch(t){case"cursor":T.ensureDirSync(u.join(e,".cursor/rules")),T.copyFileSync(u.join(w,"template/rules/cursor-rules.md"),u.join(e,".cursor/rules/instant.mdc"));break;case"claude":T.copyFileSync(u.join(w,"template/rules/AGENTS.md"),u.join(e,"CLAUDE.md"));break;case"codex":T.copyFileSync(u.join(w,"template/rules/AGENTS.md"),u.join(e,"AGENTS.md"));break;case"gemini":T.copyFileSync(u.join(w,"template/rules/AGENTS.md"),u.join(e,"GEMINI.md"));break;case"zed":T.copyFileSync(u.join(w,"template/rules/AGENTS.md"),u.join(e,"AGENTS.md"));break;case"windsurf":T.ensureDirSync(u.join(e,".windsurf/rules")),T.copyFileSync(u.join(w,"template/rules/windsurf-rules.md"),u.join(e,".windsurf/rules/instant.md"));break}};import{execSync as L}from"child_process";import G from"path";import*as pe from"@clack/prompts";import j from"chalk";import{execa as S}from"execa";import le from"fs-extra";import{renderUnwrap as se,UI as I}from"instant-cli/ui";var Ye=e=>{try{return L("git --version",{cwd:e}),!0}catch{return!1}},qe=e=>le.existsSync(G.join(e,".git")),Xe=async e=>{try{return await S("git",["rev-parse","--is-inside-work-tree"],{cwd:e,stdout:"ignore"}),!0}catch{return!1}},Ze=()=>{let t=L("git --version").toString().trim().split(" ")[2],n=t?.split(".")[0],r=t?.split(".")[1];return{major:Number(n),minor:Number(r)}},Qe=()=>L("git config --global init.defaultBranch || echo main").toString().trim(),ce=async e=>{if(!Ye(e)){pe.log.warn("Git is not installed. Skipping Git initialization.");return}let t=qe(e),n=await Xe(e),r=G.parse(e).name;if(n&&t){if(!await se(new I.Confirmation({promptText:`${j.redBright.bold("Warning:")} Git is already initialized in "${r}". Initializing a new git repository would delete the previous history. Would you like to continue anyways?`,defaultValue:!1,modifyOutput:I.ciaModifier()})))return;le.removeSync(G.join(e,".git"))}else if(n&&!t&&!await se(new I.Confirmation({promptText:`${j.redBright.bold("Warning:")} "${r}" is already in a git worktree.
|
|
13
14
|
Would you still like to initialize a new git repository in this directory?
|
|
14
|
-
`,defaultValue:!1,modifyOutput:
|
|
15
|
-
INSTANT_APP_ADMIN_TOKEN=${
|
|
16
|
-
`),
|
|
15
|
+
`,defaultValue:!1,modifyOutput:I.ciaModifier()})))return;try{let a=Qe(),{major:o,minor:i}=Ze();o<2||o==2&&i<28?(await S("git",["init"],{cwd:e}),await S("git",["symbolic-ref","HEAD",`refs/heads/${a}`],{cwd:e})):await S("git",["init",`--initial-branch=${a}`],{cwd:e}),await S("git",["add","."],{cwd:e}),await S("git",["commit","-m","Initial commit (create-instant-app)"],{cwd:e}),I.log(j.dim(`${j.green("\u2713")} Git repository initialized successfully.`),I.ciaModifier(null))}catch{}};import tt from"env-paths";import{mkdir as nt,readFile as rt,writeFile as ot}from"node:fs/promises";import at from"open";import{join as it}from"node:path";import{randomUUID as me}from"node:crypto";import{version as et}from"@instantdb/version";var de=!!process.env.INSTANT_CLI_DEV,ue=de?"http://localhost:3000":"https://instantdb.com",V=process.env.INSTANT_CLI_API_URI||(de?"http://localhost:8888":"https://api.instantdb.com");async function b({path:e,body:t,method:n="GET",authToken:r,metadata:a}){let i={"Content-Type":"application/json","X-Instant-Source":"create-instant-app","X-Instant-Version":et,"X-Instant-Command":"create"};r&&(i.Authorization=`Bearer ${r}`),a&&(i["X-Instant-Metadata"]=JSON.stringify(a));let s=await fetch(`${V}${e}`,{method:n??"GET",headers:i,body:t?JSON.stringify(t):void 0,signal:AbortSignal.timeout(3e5)}),p;try{p=await s.json()}catch{p=null}if(!s.ok){let g=p.message||p.hint?.errors?.[0]?.message||"There was an error";throw new Error(g)}return p}import{renderUnwrap as R,UI as m}from"instant-cli/ui";function F(e){return e.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}var st=!!process.env.INSTANT_CLI_DEV,pt=!!process.env.INSTANT_CLI_FORCE_EPHEMERAL;function ge(){let e=`instantdb-${st?"dev":"prod"}`,{config:t}=tt(e);return{authConfigFilePath:it(t,"a"),appConfigDirPath:t}}var fe=async(e,t,n,r)=>{let a=me(),o=me(),i={id:a,title:e,admin_token:o,org_id:n};return r?.rules&&(i.rules=r.rules),r?.schema&&(i.schema=r.schema),await b({method:"POST",authToken:t,path:"/dash/apps",body:i,metadata:r}),{appID:a,adminToken:o,source:"created"}},W=(e,t,n)=>{b({method:"POST",path:`/dash/apps/${e}/track-import`,authToken:t,metadata:n}).catch(()=>{})},he=async e=>await b({method:"GET",path:"/dash",authToken:e}),we=async(e,t)=>await b({method:"GET",path:`/dash/orgs/${t}`,authToken:e});var lt=async(e,t)=>{try{let n=await he(e),r=n.apps.find(a=>a.id===t);if(r)return{appId:r.id,adminToken:r.admin_token};for(let a of n.orgs){let{apps:o}=await we(e,a.id),i=o.find(s=>s.id===t);if(i)return{appId:i.id,adminToken:i.admin_token}}return null}catch{return null}},ct=async(e,t)=>{try{return await b({method:"GET",path:`/dash/apps/${e}/schema/pull`,authToken:t}),!0}catch{return!1}},dt=async()=>pt?null:process.env.INSTANT_CLI_AUTH_TOKEN?process.env.INSTANT_CLI_AUTH_TOKEN:await rt(ge().authConfigFilePath,"utf-8").catch(()=>null),z=async(e,t)=>{let n=await b({authToken:null,method:"POST",path:"/dash/apps/ephemeral",body:{title:e,rules:{$users:{view:"true"},$files:{allow:{view:"true",create:"true",delete:"true"}}}},metadata:t});return{appId:n.app.id,adminToken:n.app["admin-token"]}},ye=async(e,t,n)=>{let r=await dt();if(t?.yes&&!t?.app)if(r){let{appID:s,adminToken:p}=await fe(F(e),r,void 0,n);return{appId:s,adminToken:p,approach:"create"}}else{let{appId:s,adminToken:p}=await z(F(e),n);return{appId:s,adminToken:p,approach:"ephemeral"}}if(t?.app){if(t.token){if(!await ct(t.app,t.token))throw new Error("Invalid app ID and token combination. Please verify both the app ID and token are correct.");return m.log(`Linking to app: ${t.app}`,m.ciaModifier(null)),W(t.app,t.token,n),{appId:t.app,adminToken:t.token,approach:"import"}}if(r){let s=await lt(r,t.app);if(!s)throw new Error(`You don't have access to app "${t.app}". Please check the app ID or use --token to provide a token.`);return m.log(`Linking to app: ${t.app}`,m.ciaModifier(null)),W(s.appId,r,n),{appId:s.appId,adminToken:s.adminToken,approach:"import"}}throw new Error(`You must be logged in or provide --token when using --app. Either run 'npx instant-cli login' first, or use: --app ${t.app} --token <token>`)}if(!r){let s=await R(new m.Select({promptText:"You are not logged in.",options:[{label:"Login to your Instant account",value:"login"},{label:"Create a temporary app",value:"ephemeral"},{label:"Create an app later",value:"skip"}],modifyOutput:m.ciaModifier()}));if(s==="login"){let p=await b({authToken:null,method:"POST",path:"/dash/cli/auth/register"}).catch(Ee=>{throw new Error("Failed to register",{cause:Ee})}),{secret:g,ticket:h}=p;at(`${ue}/dash?ticket=${h}`);let M=mt({secret:g}),J=await R(new m.Spinner({promise:M,workingText:"Waiting for login in browser",disappearWhenDone:!0,modifyOutput:m.ciaModifier(null)}));await ft(J.token),r=J.token}if(s==="skip")return m.log("Skipping app link step",m.ciaModifier(null)),null;if(s==="ephemeral"){let p=await R(new m.TextInput({defaultValue:"my-cool-app",prompt:"Enter a name for your temporary app:",placeholder:"my-cool-app",modifyOutput:m.ciaModifier()}));return{...await z(p,n),approach:"ephemeral"}}}if(!r)return null;let a=await he(r).catch(s=>{throw new Error("Failed to fetch dashboard",{cause:s})}),o=a.orgs.filter(s=>s.role!=="app-member");a.orgs=o;let i=await R(new m.AppSelector({startingMenuIndex:0,defaultAppName:F(e),allowCreate:!0,allowEphemeral:!0,api:{getDash(){return a},createEphemeralApp(s){return z(s,n)},getAppsForOrg:async s=>{let{apps:p}=await we(r,s);return{apps:p}},createApp:async(s,p)=>{let{appID:g,adminToken:h}=await fe(s,r,p,n);return{appId:g,adminToken:h}}},modifyOutput:m.ciaModifier()}));return i?.approach==="import"&&W(i.appId,r,n),i};function ut(e){return new Promise(t=>setTimeout(t,e))}async function mt({secret:e}){for(let t=1;t<=120;t++){await ut(1e3);let n=await fetch(`${V}/dash/cli/auth/check`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:e})});if(!(!n.ok&&(await n.json()).hint.errors?.[0]?.issue==="waiting-for-user")&&n.ok)return n.json()}throw new Error("Timed out waiting for login")}async function ft(e){let t=ge();return await nt(t.appConfigDirPath,{recursive:!0}),ot(t.authConfigFilePath,e,"utf-8")}import gt from"fs-extra";import ht from"path";var wt={"next-js-app-dir":"NEXT_PUBLIC_INSTANT_APP_ID","vite-vanilla":"VITE_INSTANT_APP_ID",expo:"EXPO_PUBLIC_INSTANT_APP_ID","tanstack-start":"VITE_INSTANT_APP_ID","bun-react":"BUN_PUBLIC_INSTANT_APP_ID","solidjs-vite":"VITE_INSTANT_APP_ID",sveltekit:"VITE_INSTANT_APP_ID","tanstack-start-with-tanstack-query":"VITE_INSTANT_APP_ID","vercel-ai-sdk":"NEXT_PUBLIC_INSTANT_APP_ID","ai-chat":"NEXT_PUBLIC_INSTANT_APP_ID"},Te=(e,t,n,r)=>{let a=ht.join(t,".env"),i=`${wt[e.base]}=${n}
|
|
16
|
+
INSTANT_APP_ADMIN_TOKEN=${r}`;gt.writeFileSync(a,i)};import{stdin as x,stdout as be}from"process";import{setRawModeWindowsFriendly as ke}from"instant-cli/ui";async function yt(){return new Promise(e=>{if(!be.isTTY||!x.isTTY){e(null);return}let t=x.isRaw;t||ke(x,!0);let n=setTimeout(()=>{a(),e(null)},100),r="",a=()=>{clearTimeout(n),x.removeListener("data",o),!t&&x.isTTY&&ke(x,!1)},o=i=>{let s=i.toString();r+=s;let p=r.match(/\x1b\]11;rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)(?:\x1b\\|\x07)/);if(p){a();let[,g,h,M]=p;e(`rgb:${g}/${h}/${M}`)}};x.on("data",o),be.write("\x1B]11;?\x1B\\")})}function Tt(e){let t=e.match(/rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(!t)return null;let[,n,r,a]=t,o=Math.round(parseInt(n,16)/257),i=Math.round(parseInt(r,16)/257),s=Math.round(parseInt(a,16)/257);return{r:o,g:i,b:s}}function bt(e){return(.299*e.r+.587*e.g+.114*e.b)/255>.5}async function xe(){try{let e=await yt();if(!e)return"unknown";let t=Tt(e);return t?bt(t)?"light":"dark":"unknown"}catch(e){return console.error("Error detecting terminal theme:",e),"unknown"}}import A from"chalk";var P=(e,t)=>e==="light"?A.bgYellowBright(t):A.bgBlackBright(t),_e=(e,t=console.log,n=!1)=>{let r=(process.stdout.columns||80)-4,a=e.split(`
|
|
17
|
+
`),o=!0;a.forEach(i=>{if(i.length===0){o?(t(""),o=!1):console.log(A.gray("\u2502"));return}for(let s=0;s<i.length;s+=r){let p=i.slice(s,s+r);s+r<i.length&&p.length===r&&(p=p+"-"),o?(t(p),o=!1):console.log(A.gray("\u2502 ")+p)}}),n&&console.log(A.gray("\u2502"))};var N="\x1B[?25h";import{execa as St}from"execa";import Ie from"fs-extra";import{permsTypescriptFileToCode as kt,schemaTypescriptFileToInstantSchema as xt}from"@instantdb/platform";function Se(e){for(let t of["src/instant.perms.ts","instant.perms.ts"])try{let n=Ie.readFileSync(`${e}/${t}`,"utf8");return{code:kt(n,t)}}catch{}return null}function Pe(e){for(let t of["src/instant.schema.ts","instant.schema.ts"])try{let n=Ie.readFileSync(`${e}/${t}`,"utf8");return xt(n,t)}catch{}return null}var Pt=async()=>{process.argv.some(h=>["-h","--help","--version","-V"].includes(h))||te();let e=await xe(),t=await Q(),[n,r]=q(t.appName),a=k(t.base),o=await oe(t,r);ie({projectDir:o,ruleFilesToAdd:t.ruleFiles});let i={template:t.base,aiTool:t.ruleFiles??"none",usedAiPrompt:!!t.prompt,rules:Se(o),schema:Pe(o)},s=await ye(r==="."?n:r,t,i);s&&Te(t,o,s.appId,s.adminToken);let p=Ae.readJSONSync(ve.join(o,"package.json"));if(p.name=n,a!=="bun"){let{stdout:h}=await St(a,["-v"],{cwd:o});p.packageManager=`${a}@${h.trim()}`}Ae.writeJSONSync(ve.join(o,"package.json"),p,{spaces:2}),await ae(k(t.base),o),t.createRepo&&await ce(o),t.prompt&&(await K(t.prompt,o),process.stdout.write(N)),_t("Done!");let g=t.base==="expo"?"start":"dev";s?(console.log(`
|
|
17
18
|
\u{1F389} Success! Your project is ready to go!
|
|
18
19
|
|
|
19
20
|
To get started:
|
|
20
|
-
1. ${
|
|
21
|
-
2. ${
|
|
22
|
-
`),
|
|
21
|
+
1. ${P(e,"cd "+r)}
|
|
22
|
+
2. ${P(e,k(t.base)+" run "+g)}
|
|
23
|
+
`),s.approach==="ephemeral"&&console.log(`
|
|
23
24
|
An ephemeral app has been created and added to your .env file.
|
|
24
|
-
It will expire in two weeks. For a permanent app, sign in and use ${
|
|
25
|
+
It will expire in two weeks. For a permanent app, sign in and use ${P(e,"npx instant-cli claim")}
|
|
25
26
|
`)):console.log(`
|
|
26
27
|
\u{1F389} Success! Your project is ready to go!
|
|
27
28
|
|
|
28
29
|
To get started:
|
|
29
|
-
1. ${
|
|
30
|
-
2. Create a new app on ${
|
|
30
|
+
1. ${P(e,"cd "+r)}
|
|
31
|
+
2. Create a new app on ${It.underline("www.instantdb.com")}
|
|
31
32
|
3. Add your APP_ID to the .env file
|
|
32
|
-
4. ${
|
|
33
|
-
`),process.stdout.write(
|
|
33
|
+
4. ${P(e,k(t.base)+" run "+g)}
|
|
34
|
+
`),process.stdout.write(N),process.exit(0)};Pt().catch(e=>{Ne.error("Aborting installation..."),_e(e.message,Ne.error),process.stdout.write(N),process.exit(1)});process.on("SIGINT",()=>{process.stdout.write(N),process.exit(0)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-instant-app",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.183",
|
|
4
4
|
"description": "Scaffold a new web/mobile app with InstantDB",
|
|
5
5
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/create-instant-app",
|
|
6
6
|
"repository": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"ora": "6.3.1",
|
|
37
37
|
"slugify": "^1.6.6",
|
|
38
38
|
"sort-package-json": "^2.10.0",
|
|
39
|
-
"@instantdb/version": "0.22.
|
|
40
|
-
"@instantdb/platform": "0.22.
|
|
41
|
-
"instant-cli": "0.22.
|
|
39
|
+
"@instantdb/version": "0.22.183",
|
|
40
|
+
"@instantdb/platform": "0.22.183",
|
|
41
|
+
"instant-cli": "0.22.183"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@anthropic-ai/sdk": "^0.60.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"author": "",
|
|
53
53
|
"license": "ISC",
|
|
54
54
|
"scripts": {
|
|
55
|
-
"typecheck": "tsc",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
56
|
"prebuild": "pnpm run copy-examples",
|
|
57
57
|
"build": "tsup",
|
|
58
58
|
"dev": "tsup --watch",
|