create-tinybase 0.2.3 → 0.2.4

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/README.md CHANGED
@@ -47,9 +47,6 @@ npm install
47
47
  npm run dev
48
48
  ```
49
49
 
50
- You can also concurrently run both client and server using `npm run dev` in the
51
- parent directory.
52
-
53
50
  Your app should look something like this:
54
51
 
55
52
  ### Todo App
package/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{existsSync as v}from"fs";import{dirname as y,join as p}from"path";import{createCLI as f}from"tinycreate";import{fileURLToPath as h}from"url";const w=y(h(import.meta.url)),j={welcomeMessage:`\u{1F389} Welcome to TinyBase!
3
- `,questions:[{type:"text",name:"projectName",message:"Project name:",initial:"my-tinybase-app",validate:e=>{if(e.length===0)return"Project name is required";const t=p(process.cwd(),e);return v(t)?`Directory "${e}" already exists. Please choose a different name.`:!0}},{type:"select",name:"language",message:"Language:",choices:[{title:"TypeScript",value:"typescript"},{title:"JavaScript",value:"javascript"}],initial:0},{type:"select",name:"framework",message:"Framework:",choices:[{title:"React",value:"react"},{title:"Vanilla",value:"vanilla"}],initial:0},{type:"select",name:"appType",message:"App type:",choices:[{title:"Todo app",value:"todos"},{title:"Chat app",value:"chat"},{title:"Drawing app",value:"drawing"},{title:"Tic-tac-toe game",value:"game"}],initial:0},{type:(e,t)=>t.language==="typescript"?"confirm":null,name:"schemas",message:"Include store schemas?",initial:!1},{type:"confirm",name:"sync",message:"Enable synchronization?",initial:!0},{type:(e,t)=>t.sync?"confirm":null,name:"server",message:"Add code for server?",initial:!1},{type:(e,t)=>t.server?"select":null,name:"serverType",message:"Server type:",choices:[{title:"Node",value:"node"},{title:"Durable Objects",value:"durable-objects"}],initial:0},{type:"confirm",name:"prettier",message:"Include Prettier?",initial:!1},{type:"confirm",name:"eslint",message:"Include ESLint?",initial:!1}],createContext:e=>{const{projectName:t,language:s,framework:n,appType:r,prettier:m,eslint:u,schemas:o,sync:c,server:l,serverType:g}=e,a=s==="typescript",d=!a,i=n==="react";return{projectName:t,language:s,framework:n,appType:r,prettier:m,eslint:u,schemas:a&&(o===!0||o==="true"),sync:c===!0||c==="true",server:l===!0||l==="true",serverType:g||"node",typescript:a,javascript:d,react:i,ext:a?i?"tsx":"ts":i?"jsx":"js"}},createDirectories:async(e,t)=>{const{mkdir:s}=await import("fs/promises"),{join:n}=await import("path"),r=t.server;await s(n(e,"client/src"),{recursive:!0}),await s(n(e,"client/public"),{recursive:!0}),r&&await s(n(e,"server"),{recursive:!0})},getFiles:e=>{const t=e.server,s=[{template:"README.md.hbs",output:"README.md",prettier:!0},{template:"client/package.json.hbs",output:"client/package.json",prettier:!0}];return t&&s.push({template:"package.json.hbs",output:"package.json",prettier:!0}),s},processIncludedFile:(e,t)=>{const{javascript:s}=t,n=e.prettier??/\.(js|jsx|ts|tsx|css|json|html|md)$/.test(e.output),r=e.transpile??(/\.(ts|tsx)\.hbs$/.test(e.template)&&s===!0);return{...e,prettier:n,transpile:r}},templateRoot:p(w,"templates"),installCommand:"{pm} install",devCommand:"{pm} run dev",onSuccess:e=>{console.log("Next steps:"),console.log(` cd ${e}/client`),console.log(" npm install"),console.log(" npm run dev")}};f(j).catch(e=>{console.error(e),process.exit(1)});
2
+ import{existsSync as y}from"fs";import{dirname as w,join as u}from"path";import{createCLI as f,detectPackageManager as h}from"tinycreate";import{fileURLToPath as k}from"url";const j=w(k(import.meta.url)),x={welcomeMessage:`\u{1F389} Welcome to TinyBase!
3
+ `,questions:[{type:"text",name:"projectName",message:"Project name:",initial:"my-tinybase-app",validate:e=>{if(e.length===0)return"Project name is required";const t=u(process.cwd(),e);return y(t)?`Directory "${e}" already exists. Please choose a different name.`:!0}},{type:"select",name:"appType",message:"App type:",choices:[{title:"Todo app",value:"todos"},{title:"Chat app",value:"chat"},{title:"Drawing app",value:"drawing"},{title:"Tic-tac-toe game",value:"game"}],initial:0},{type:"select",name:"language",message:"Language:",choices:[{title:"TypeScript",value:"typescript"},{title:"JavaScript",value:"javascript"}],initial:0},{type:"select",name:"framework",message:"Framework:",choices:[{title:"React",value:"react"},{title:"Vanilla",value:"vanilla"}],initial:0},{type:(e,t)=>t.language==="typescript"?"confirm":null,name:"schemas",message:"Include store schemas?",initial:!1},{type:"confirm",name:"sync",message:"Enable synchronization?",initial:!0},{type:(e,t)=>t.sync?"confirm":null,name:"server",message:"Add code for server?",initial:!1},{type:(e,t)=>t.server?"select":null,name:"serverType",message:"Server type:",choices:[{title:"Node",value:"node"},{title:"Durable Objects",value:"durable-objects"}],initial:0},{type:"confirm",name:"prettier",message:"Include Prettier?",initial:!0},{type:"confirm",name:"eslint",message:"Include ESLint?",initial:!0},{type:(e,t)=>t.server?null:"confirm",name:"installAndRun",message:"Install dependencies and start dev server?",initial:!0}],createContext:e=>{const{projectName:t,language:s,framework:n,appType:r,prettier:m,eslint:g,schemas:i,sync:c,server:l,serverType:d,installAndRun:p}=e,a=s==="typescript",v=!a,o=n==="react";return{projectName:t,language:s,framework:n,appType:r,prettier:m,eslint:g,schemas:a&&(i===!0||i==="true"),sync:c===!0||c==="true",server:l===!0||l==="true",serverType:d||"node",installAndRun:p===!0||p==="true",typescript:a,javascript:v,react:o,ext:a?o?"tsx":"ts":o?"jsx":"js"}},createDirectories:async(e,t)=>{const{mkdir:s}=await import("fs/promises"),{join:n}=await import("path"),r=t.server;await s(n(e,"client/src"),{recursive:!0}),await s(n(e,"client/public"),{recursive:!0}),r&&await s(n(e,"server"),{recursive:!0})},getFiles:()=>[{template:"README.md.hbs",output:"README.md",prettier:!0}],processIncludedFile:(e,t)=>{const{javascript:s}=t,n=e.prettier??/\.(js|jsx|ts|tsx|css|json|html|md)$/.test(e.output),r=e.transpile??(/\.(ts|tsx)\.hbs$/.test(e.template)&&s===!0);return{...e,prettier:n,transpile:r}},templateRoot:u(j,"templates"),installCommand:"{pm} install",devCommand:"{pm} run dev",onSuccess:(e,t)=>{const s=t.server,n=h();console.log("Next steps:"),console.log(),s&&(console.log("To run the server:"),console.log(` cd ${e}/server`),console.log(` ${n} install`),console.log(` ${n} run dev`),console.log()),console.log("To run the client:"),console.log(` cd ${e}/client`),console.log(` ${n} install`),console.log(` ${n} run dev`)}};f(x).catch(e=>{console.error(e),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-tinybase",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "author": "jamesgpearce",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "create-tinybase": "cli.js"
24
24
  },
25
25
  "dependencies": {
26
- "tinycreate": "^1.0.0"
26
+ "tinycreate": "^1.0.2"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=18.0.0"
Binary file
Binary file
@@ -1,15 +1,41 @@
1
+ {{includeFile template="client/package.json.hbs" output="client/package.json"}}
2
+ {{#if server}}
3
+ {{includeFile template="server/package.json.hbs" output="server/package.json"}}
4
+ {{/if}}
5
+
1
6
  # {{projectName}}
2
7
 
3
- A TinyBase app built with {{#if typescript}}TypeScript{{else}}JavaScript{{/if}} and {{#if react}}React{{else}}Vanilla JS{{/if}}.
8
+ A TinyBase app built with {{#if typescript}}TypeScript{{else}}JavaScript{{/if}}
9
+ and {{#if react}}React{{else}}Vanilla JS{{/if}}.
4
10
 
5
11
  ## Getting Started
6
12
 
13
+ Alongside this file, you will see a directory called `client` (and optionally
14
+ one called `server` if you included server code).
15
+
16
+ To start the web client with Vite, run the following commands:
17
+
7
18
  ```bash
8
19
  cd client
9
20
  npm install
10
21
  npm run dev
11
22
  ```
12
23
 
24
+ PNPM, Yarn, and Bun should also work. Your app will be available at
25
+ `http://localhost:5173`, or whichever port Vite specifies in the console.
26
+
27
+ If you included server code, start the server in a separate terminal, ideally
28
+ before starting the client:
29
+
30
+ ```bash
31
+ # In a separate terminal
32
+ cd server
33
+ npm install
34
+ npm run dev
35
+ ```
36
+
37
+ After that, start hacking!
38
+
13
39
  ## Learn More
14
40
 
15
41
  - [TinyBase Documentation](https://tinybase.org)
@@ -1,38 +0,0 @@
1
- {{includeFile template="README.md.hbs" output="README.md"}}
2
- {
3
- "name": "{{projectName}}",
4
- "version": "1.0.0",
5
- "private": true,
6
- "scripts": {
7
- {{#list}}
8
- {{#if server}}
9
- "dev": "concurrently \"npm run dev -w client\" \"npm run dev -w server\""
10
- "dev:client": "npm run dev -w client"
11
- "dev:server": "npm run dev -w server"
12
- {{else}}
13
- "dev": "npm run dev -w client"
14
- {{/if}}
15
- "build": "npm run build -w client"
16
- "preview": "npm run preview -w client"
17
- {{/list}}
18
- },
19
- {{#if server}}
20
- "workspaces": ["client", "server"],
21
- {{else}}
22
- "workspaces": ["client"],
23
- {{/if}}
24
- "devDependencies": {
25
- {{#list}}
26
- {{#if server}}
27
- "concurrently": "^9.1.2"
28
- {{/if}}
29
- {{/list}}
30
- }
31
- }
32
- {{#if server}}
33
- {{includeFile template="server/package.json.hbs" output="server/package.json"}}
34
- {{/if}}
35
- {{#if prettier}}
36
- {{includeFile template="client/.prettierrc.hbs" output=".prettierrc"}}
37
- {{/if}}
38
- {{includeFile template="client/package.json.hbs" output="client/package.json"}}