@tntstack/create-app 0.1.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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @tntstack/create
2
+
3
+ The official scaffolding CLI for [**TNT Stack**](https://tnt.odest.tech). The ultimate stack for building cross-platform apps. Write your code once and deploy to Web, Windows, macOS, Linux, and Android.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npm create @tntstack/app@latest
9
+ ```
10
+
11
+ Or with other package managers:
12
+
13
+ ```bash
14
+ pnpm create @tntstack/app@latest
15
+ yarn create @tntstack/app
16
+ npx @tntstack/create-app
17
+ bunx @tntstack/create-app
18
+ ```
19
+
20
+ ### Non-interactive
21
+
22
+ ```bash
23
+ npm create @tntstack/app@latest -- --name my-app --github-user myuser --no-install
24
+ ```
25
+
26
+ ### Options
27
+
28
+ | Flag | Description |
29
+ | -------------------------- | -------------------------------- |
30
+ | `-n, --name <name>` | Project name |
31
+ | `-d, --directory <dir>` | Output directory |
32
+ | `-g, --github-user <user>` | GitHub username / org (optional) |
33
+ | `-i, --identifier <id>` | App identifier (reverse-domain) |
34
+ | `-v, --app-version <ver>` | Initial version |
35
+ | `--no-install` | Skip dependency installation |
36
+
37
+ ## What it does
38
+
39
+ 1. Downloads the TNTStack core files from GitHub
40
+ 2. Replaces all project identifiers with your values
41
+ 3. Sets up Android package structure
42
+ 4. Initialises a fresh git repository
43
+ 5. Installs dependencies
44
+
45
+ ## Links
46
+
47
+ - [Documentation](https://tnt.odest.tech/docs)
48
+ - [GitHub](https://github.com/odest/tntstack)
49
+ - [Issues](https://github.com/odest/tntstack/issues)
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'module';const require = createRequire(import.meta.url);
3
+ import{Command as Q}from"commander";import x from"picocolors";import*as h from"@clack/prompts";import*as s from"@clack/prompts";import g from"picocolors";var b="github:odest/tntstack#master",w="0.1.0",u={name:"tntstack",namePascal:"TNTStack",identifier:"com.tntstack.app",githubUser:"odest"};var C=["node_modules",".git","target","dist",".turbo",".next","*.png","*.ico","*.icns","*.webp","*.woff","*.woff2","*.ttf","*.eot","*.jar","*.so","*.dylib","*.exe","*.dll","pnpm-lock.yaml"],N=["CHANGELOG.md","init-project.ps1","init-project.sh","packages/cli",".github/FUNDING.yml",".github/workflows/publish-cli.yml"],$=["release-please-config.json",".release-please-manifest.json"];function y(e){if(!e||e.length===0)return"Project name cannot be empty.";if(!/^[a-z0-9-_]+$/.test(e))return"Use only lowercase letters, numbers, hyphens, and underscores.";if(e.startsWith("-")||e.endsWith("-")||e.startsWith("_")||e.endsWith("_"))return"Cannot start or end with a hyphen or underscore."}function S(e){if(e&&!/^\d+\.\d+\.\d+$/.test(e))return"Must be a valid semver version (e.g. 0.1.0)."}function v(e){return e.replace(/-/g,"_")}function j(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}async function T(e){for(;;){let t=await s.text({message:"What is your project name?",placeholder:"my-awesome-app",validate:y});s.isCancel(t)&&(s.cancel("Setup cancelled."),process.exit(0));let n=e??`./${t}`,i=await s.text({message:"GitHub username / org (optional)?",placeholder:"your-github-username",defaultValue:"your-github-username"});s.isCancel(i)&&(s.cancel("Setup cancelled."),process.exit(0));let o=await s.text({message:"Initial version?",placeholder:w,defaultValue:w,validate:S});s.isCancel(o)&&(s.cancel("Setup cancelled."),process.exit(0));let c=await s.confirm({message:"Install dependencies?",initialValue:!0});s.isCancel(c)&&(s.cancel("Setup cancelled."),process.exit(0));let p={projectName:t,projectNamePascal:j(t),projectNameSnake:v(t),directory:n,githubUser:i,identifier:`com.${t}.app`,version:o,installDeps:c};s.note([`${g.bold("Project")} ${p.projectName}`,`${g.bold("Directory")} ${p.directory}`,`${g.bold("GitHub user")} ${p.githubUser}`,`${g.bold("Identifier")} ${p.identifier}`,`${g.bold("Version")} ${p.version}`,`${g.bold("Install deps")} ${p.installDeps?"yes":"no"}`].join(`
4
+ `),"Summary");let r=await s.confirm({message:"Proceed with these settings?",initialValue:!0});if(s.isCancel(r)&&(s.cancel("Setup cancelled."),process.exit(0)),r)return p;s.log.info("Let's try that again...")}}import*as l from"@clack/prompts";import q from"path";import H from"fs-extra";import{downloadTemplate as M}from"giget";async function F(e){let{dir:t}=await M(b,{dir:e,force:!0});return t}import m from"path";import a from"fs-extra";import*as d from"@clack/prompts";function W(e){return[[u.identifier,e.identifier],["tntstack_lib",`${e.projectNameSnake}_lib`],[u.namePascal,e.projectNamePascal],[u.githubUser,e.githubUser],[u.name,e.projectName]]}function _(e){let t=e.replace(/\\/g,"/"),n=m.basename(e);return C.some(i=>i.startsWith("*.")?n.endsWith(i.slice(1)):n===i||t.includes(`/${i}/`))}async function O(e){let t=[],n=await a.readdir(e,{withFileTypes:!0});for(let i of n){let o=m.join(e,i.name);_(o)||(i.isDirectory()?t.push(...await O(o)):i.isFile()&&t.push(o))}return t}function z(e,t){let n=e;for(let[i,o]of t)n=n.replaceAll(i,o);return n}async function D(e,t){let n=W(t),i=await O(e);for(let o of i)try{let c=await a.readFile(o,"utf-8"),p=z(c,n);p!==c&&await a.writeFile(o,p,"utf-8")}catch(c){c instanceof Error&&!c.message.includes("is not valid UTF-8")&&d.log.warn(`Could not rename contents of ${o}: ${c.message}`)}await B(e,t),await K(e,t)}async function B(e,t){let n=u.identifier.split("."),i=t.identifier.split("."),o=m.join(e,"apps","native","src-tauri","gen","android");if(!await a.pathExists(o))return;let c=await R(o,"java");for(let p of c){let r=m.join(p,...n);if(!await a.pathExists(r))continue;let f=m.join(p,...i);await a.ensureDir(m.dirname(f)),await a.move(r,f,{overwrite:!0}),await I(m.dirname(r),p)}}async function R(e,t){let n=[],i=await a.readdir(e,{withFileTypes:!0});for(let o of i){if(!o.isDirectory())continue;let c=m.join(e,o.name);o.name===t?n.push(c):n.push(...await R(c,t))}return n}async function I(e,t){if(!(e===t||!e.startsWith(t)))try{(await a.readdir(e)).length===0&&(await a.rmdir(e),await I(m.dirname(e),t))}catch{}}async function K(e,t){let n=await A(e,"package.json");for(let r of n)try{let f=await a.readJson(r);f.version&&(f.version=t.version,await a.writeJson(r,f,{spaces:2}))}catch(f){d.log.warn(`Failed to update version in ${r}: ${f instanceof Error?f.message:String(f)}`)}let i=m.join(e,".release-please-manifest.json");if(await a.pathExists(i))try{let r=await a.readJson(i);for(let f of Object.keys(r))r[f]=t.version;await a.writeJson(i,r,{spaces:2})}catch(r){d.log.warn(`Failed to update .release-please-manifest.json: ${r instanceof Error?r.message:String(r)}`)}let o=m.join(e,"apps","native","src-tauri","Cargo.toml");if(await a.pathExists(o))try{let r=await a.readFile(o,"utf-8");r=r.replace(/^version\s*=\s*"[^"]*"/m,`version = "${t.version}"`),await a.writeFile(o,r,"utf-8")}catch(r){d.log.warn(`Failed to update Cargo.toml: ${r instanceof Error?r.message:String(r)}`)}let c=m.join(e,"apps","native","src-tauri","Cargo.lock");if(await a.pathExists(c))try{let r=await a.readFile(c,"utf-8"),f=new RegExp(`(name = "${t.projectName}"\\s+version = )([^\\s]+)`,"g");r=r.replace(f,`$1"${t.version}"`),await a.writeFile(c,r,"utf-8")}catch(r){d.log.warn(`Failed to update Cargo.lock: ${r instanceof Error?r.message:String(r)}`)}let p=m.join(e,"apps","native","src-tauri","tauri.conf.json");if(await a.pathExists(p))try{let r=await a.readJson(p);r.version&&(r.version=t.version),await a.writeJson(p,r,{spaces:2})}catch(r){d.log.warn(`Failed to update tauri.conf.json: ${r instanceof Error?r.message:String(r)}`)}}async function A(e,t){let n=[],i=await a.readdir(e,{withFileTypes:!0});for(let o of i){let c=m.join(e,o.name);if(o.isDirectory()){if(_(c))continue;n.push(...await A(c,t))}else o.name===t&&n.push(c)}return n}import U from"path";import k from"fs-extra";import*as L from"@clack/prompts";async function V(e){for(let t of N)await k.remove(U.join(e,t));for(let t of $){let n=U.join(e,t);if(await k.pathExists(n))try{let i=await k.readJson(n),o=!1;i.packages&&typeof i.packages=="object"&&i.packages["packages/cli"]&&(delete i.packages["packages/cli"],o=!0),i["packages/cli"]&&(delete i["packages/cli"],o=!0),o&&await k.writeJson(n,i,{spaces:2})}catch(i){L.log.warn(`Failed to clean JSON config at ${n}: ${i instanceof Error?i.message:String(i)}`)}}}import{execa as E}from"execa";async function G(e){await E("git",["init"],{cwd:e}),await E("git",["add","."],{cwd:e}),await E("git",["commit","-m","chore: initialize project using @tntstack/create-app"],{cwd:e})}import{execa as Y}from"execa";async function J(e){await Y("pnpm",["install"],{cwd:e})}async function P(e){let t=q.resolve(e.directory);if(await H.pathExists(t)&&(await H.readdir(t)).length>0){let o=await l.confirm({message:`Directory ${e.directory} is not empty. Overwrite?`,initialValue:!1});(l.isCancel(o)||!o)&&(l.cancel("Setup cancelled."),process.exit(1))}let n=l.spinner();n.start("Downloading TNTStack core files\u2026");try{await F(t)}catch(i){n.stop("Download failed."),l.cancel(i instanceof Error?i.message:"Failed to download core files."),process.exit(1)}n.stop("Core files downloaded."),n.start("Configuring project\u2026"),await D(t,e),n.stop("Project configured."),n.start("Cleaning up\u2026"),await V(t),n.stop("Done."),n.start("Initialising git\u2026");try{await G(t),n.stop("Git ready.")}catch(i){n.stop("Skipped git init."),l.log.warn(`Could not initialize git: ${i instanceof Error?i.message:String(i)}`)}if(e.installDeps){n.start("Installing dependencies\u2026");try{await J(t),n.stop("Dependencies installed.")}catch(i){n.stop("Dependency installation failed."),l.log.warn(`Could not install dependencies: ${i instanceof Error?i.message:String(i)}`)}}l.note([`cd ${e.directory}`,e.installDeps?"":"pnpm install","pnpm dev"].filter(Boolean).join(`
5
+ `),"Next steps"),l.outro("Your TNTStack project is ready! \u{1F680}")}var X=`
6
+ \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557
7
+ \u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D
8
+ \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255D
9
+ \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2588\u2588\u2557
10
+ \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2557
11
+ \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
12
+ `,Z=new Q().name("tntstack").description("Scaffold a new TNTStack project").version("0.1.2").option("-n, --name <name>","Project name").option("-d, --directory <dir>","Output directory").option("-g, --github-user <user>","GitHub username / org").option("-i, --identifier <id>","App identifier (reverse-domain)").option("-v, --app-version <ver>","Initial version").option("--no-install","Skip dependency installation").action(async e=>{if(console.clear(),console.log(x.cyan(X)),h.intro(x.bold(x.green("TNTStack Scaffold Tool"))),e.name){let t=y(e.name);if(t&&(h.cancel(t),process.exit(1)),e.appVersion){let n=S(e.appVersion);n&&(h.cancel(n),process.exit(1))}await P({projectName:e.name,projectNamePascal:j(e.name),projectNameSnake:v(e.name),directory:e.directory??`./${e.name}`,githubUser:e.githubUser??"your-github-username",identifier:e.identifier??`com.${e.name}.app`,version:e.appVersion??w,installDeps:e.install??!0})}else{let t=await T(e.directory);await P(t)}});Z.parse();
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@tntstack/create-app",
3
+ "version": "0.1.3",
4
+ "description": "Scaffolding CLI for TNT Stack",
5
+ "license": "GPL-3.0",
6
+ "author": "odest",
7
+ "keywords": [
8
+ "tntstack",
9
+ "tauri",
10
+ "nextjs",
11
+ "turborepo",
12
+ "scaffold",
13
+ "create",
14
+ "cli",
15
+ "monorepo",
16
+ "template"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/odest/tntstack.git",
21
+ "directory": "packages/cli"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/odest/tntstack/issues"
25
+ },
26
+ "homepage": "https://tnt.odest.tech",
27
+ "type": "module",
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "bin": {
32
+ "tntstack": "./dist/index.js"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "dev": "tsup --watch",
40
+ "start": "node ./dist/index.js",
41
+ "lint": "eslint .",
42
+ "clean": "rm -rf dist"
43
+ },
44
+ "dependencies": {
45
+ "@clack/prompts": "^1.1.0",
46
+ "commander": "^14.0.3",
47
+ "execa": "^9.6.1",
48
+ "fs-extra": "^11.3.4",
49
+ "giget": "^3.1.2",
50
+ "picocolors": "^1.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/fs-extra": "^11.0.4",
54
+ "@types/node": "^20.0.0",
55
+ "@workspace/eslint-config": "workspace:*",
56
+ "@workspace/typescript-config": "workspace:*",
57
+ "eslint": "^9.39.4",
58
+ "tsup": "^8.0.2",
59
+ "typescript": "^5.3.3"
60
+ }
61
+ }