create-threlte
Advanced tools
Comparing version 1.0.0-next.14 to 1.0.0-next.15
# create-threlte | ||
## 1.0.0-next.15 | ||
### Minor Changes | ||
- 6b219b5: Updated create-svelte, added options to initialize a git repository and install dependencies via preferred package manager. | ||
## 1.0.0-next.14 | ||
@@ -4,0 +10,0 @@ |
#!/usr/bin/env node | ||
import * as p from '@clack/prompts'; | ||
import { create as createSvelteKitApp } from 'create-svelte'; | ||
import { execa } from 'execa'; | ||
import { copy } from 'fs-extra'; | ||
import { Merger } from 'json-merger'; | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import * as p from '@clack/prompts'; | ||
import { bold, cyan, grey } from 'kleur/colors'; | ||
import { bold, cyan, grey, red } from 'kleur/colors'; | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import path, { dirname } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import detectPackageManager from 'which-pm-runs'; | ||
const print = console.log; | ||
@@ -40,2 +41,3 @@ const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8')); | ||
} | ||
const pkgManager = detectPackageManager()?.name ?? 'npm'; | ||
const options = await p.group({ | ||
@@ -104,2 +106,10 @@ types: () => p.select({ | ||
] | ||
}), | ||
git: () => p.confirm({ | ||
message: 'Initialize a git repository?', | ||
initialValue: true | ||
}), | ||
install: () => p.confirm({ | ||
message: `Install dependencies using ${pkgManager}?`, | ||
initialValue: true | ||
}) | ||
@@ -173,2 +183,28 @@ }, { onCancel: () => process.exit(1) }); | ||
} | ||
if (options.git) { | ||
// initialize git repository | ||
await execa('git', ['init'], { cwd, stdio: 'ignore' }); | ||
await execa('git', ['add', '-A'], { cwd, stdio: 'ignore' }); | ||
await execa('git', [ | ||
'commit', | ||
'-m', | ||
'Initial commit', | ||
'--author="threlte-bot <threlte-bot@users.noreply.github.com>"' | ||
], { cwd, stdio: 'ignore' }); | ||
} | ||
if (options.install) { | ||
const s = p.spinner(); | ||
try { | ||
// Install dependencies | ||
s.start(`Installing dependencies using ${pkgManager}`); | ||
await execa(pkgManager, ['install'], { cwd, stdio: 'ignore' }); | ||
s.stop(`Installed dependencies using ${pkgManager}`); | ||
} | ||
catch (error) { | ||
s.stop(red('Failed to install dependencies')); | ||
p.note('You can install them manually.'); | ||
// This will show install instructions later on | ||
options.install = false; | ||
} | ||
} | ||
p.outro('Your project is ready!'); | ||
@@ -216,5 +252,9 @@ if (options.types === 'typescript') { | ||
print(bold('✔ Model Pipeline')); | ||
print(cyan(' npm run model-pipeline:run')); | ||
print(cyan(' https://next.threlte.xyz/docs/reference/gltf/getting-started')); | ||
print(cyan(` ${pkgManager} run model-pipeline:run`)); | ||
print(cyan(' https://next.threlte.xyz/docs/reference/gltf/getting-started\n')); | ||
} | ||
if (options.git) { | ||
print(bold('✔ Git')); | ||
print(cyan(' Initialized a git repository.')); | ||
} | ||
print('\nNext steps:'); | ||
@@ -226,6 +266,9 @@ let step = 1; | ||
} | ||
print(` ${step++}: ${bold(cyan('npm install'))} (or pnpm install, etc)`); | ||
if (!options.install) { | ||
print(` ${step++}: ${bold(cyan(`${pkgManager} install`))}`); | ||
} | ||
// prettier-ignore | ||
print(` ${step++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional)`); | ||
print(` ${step++}: ${bold(cyan('npm run dev -- --open'))}`); | ||
if (!options.git) | ||
print(` ${step++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional)`); | ||
print(` ${step++}: ${bold(cyan(`${pkgManager} run dev -- --open`))}`); | ||
print(`\nTo close the dev server, hit ${bold(cyan('Ctrl-C'))}`); | ||
@@ -232,0 +275,0 @@ print(`\nStuck? Visit us at ${cyan('https://chat.threlte.xyz')}`); |
{ | ||
"name": "create-threlte", | ||
"version": "1.0.0-next.14", | ||
"version": "1.0.0-next.15", | ||
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)", | ||
@@ -10,2 +10,3 @@ "license": "MIT", | ||
"@types/node": "^20.3.1", | ||
"@types/which-pm-runs": "^1.0.0", | ||
"cpy-cli": "^4.2.0", | ||
@@ -19,6 +20,9 @@ "rimraf": "^5.0.1", | ||
"@clack/prompts": "^0.6.3", | ||
"create-svelte": "^5.0.1", | ||
"@expo/spawn-async": "^1.7.2", | ||
"create-svelte": "^5.0.2", | ||
"execa": "^7.1.1", | ||
"fs-extra": "^9.0.1", | ||
"json-merger": "^1.1.10", | ||
"kleur": "^4.1.5" | ||
"kleur": "^4.1.5", | ||
"which-pm-runs": "^1.1.0" | ||
}, | ||
@@ -25,0 +29,0 @@ "scripts": { |
#!/usr/bin/env node | ||
import * as p from '@clack/prompts' | ||
import { create as createSvelteKitApp } from 'create-svelte' | ||
import { execa } from 'execa' | ||
import { copy } from 'fs-extra' | ||
import { Merger } from 'json-merger' | ||
import { dirname } from 'path' | ||
import { fileURLToPath } from 'url' | ||
import * as p from '@clack/prompts' | ||
import { bold, cyan, grey } from 'kleur/colors' | ||
import { bold, cyan, grey, red } from 'kleur/colors' | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import path, { dirname } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import detectPackageManager from 'which-pm-runs' | ||
@@ -52,2 +53,4 @@ const print = console.log | ||
const pkgManager = detectPackageManager()?.name ?? 'npm' | ||
const options = await p.group( | ||
@@ -95,2 +98,3 @@ { | ||
}), | ||
threltePackages: () => | ||
@@ -122,2 +126,14 @@ p.multiselect({ | ||
] | ||
}), | ||
git: () => | ||
p.confirm({ | ||
message: 'Initialize a git repository?', | ||
initialValue: true | ||
}), | ||
install: () => | ||
p.confirm({ | ||
message: `Install dependencies using ${pkgManager}?`, | ||
initialValue: true | ||
}) | ||
@@ -206,2 +222,33 @@ }, | ||
if (options.git) { | ||
// initialize git repository | ||
await execa('git', ['init'], { cwd, stdio: 'ignore' }) | ||
await execa('git', ['add', '-A'], { cwd, stdio: 'ignore' }) | ||
await execa( | ||
'git', | ||
[ | ||
'commit', | ||
'-m', | ||
'Initial commit', | ||
'--author="threlte-bot <threlte-bot@users.noreply.github.com>"' | ||
], | ||
{ cwd, stdio: 'ignore' } | ||
) | ||
} | ||
if (options.install) { | ||
const s = p.spinner() | ||
try { | ||
// Install dependencies | ||
s.start(`Installing dependencies using ${pkgManager}`) | ||
await execa(pkgManager, ['install'], { cwd, stdio: 'ignore' }) | ||
s.stop(`Installed dependencies using ${pkgManager}`) | ||
} catch (error) { | ||
s.stop(red('Failed to install dependencies')) | ||
p.note('You can install them manually.') | ||
// This will show install instructions later on | ||
options.install = false | ||
} | ||
} | ||
p.outro('Your project is ready!') | ||
@@ -254,5 +301,9 @@ | ||
print(bold('✔ Model Pipeline')) | ||
print(cyan(' npm run model-pipeline:run')) | ||
print(cyan(' https://next.threlte.xyz/docs/reference/gltf/getting-started')) | ||
print(cyan(` ${pkgManager} run model-pipeline:run`)) | ||
print(cyan(' https://next.threlte.xyz/docs/reference/gltf/getting-started\n')) | ||
} | ||
if (options.git) { | ||
print(bold('✔ Git')) | ||
print(cyan(' Initialized a git repository.')) | ||
} | ||
@@ -267,7 +318,11 @@ print('\nNext steps:') | ||
print(` ${step++}: ${bold(cyan('npm install'))} (or pnpm install, etc)`) | ||
if (!options.install) { | ||
print(` ${step++}: ${bold(cyan(`${pkgManager} install`))}`) | ||
} | ||
// prettier-ignore | ||
print(` ${step++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional)`); | ||
print(` ${step++}: ${bold(cyan('npm run dev -- --open'))}`) | ||
if (!options.git) print(` ${step++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional)`); | ||
print(` ${step++}: ${bold(cyan(`${pkgManager} run dev -- --open`))}`) | ||
print(`\nTo close the dev server, hit ${bold(cyan('Ctrl-C'))}`) | ||
@@ -274,0 +329,0 @@ print(`\nStuck? Visit us at ${cyan('https://chat.threlte.xyz')}`) |
Sorry, the diff of this file is not supported yet
77602
1056
8
7
+ Added@expo/spawn-async@^1.7.2
+ Addedexeca@^7.1.1
+ Addedwhich-pm-runs@^1.1.0
+ Added@expo/spawn-async@1.7.2(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addedexeca@7.2.0(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@4.3.1(transitive)
+ Addedis-stream@3.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@4.0.0(transitive)
+ Addednpm-run-path@5.3.0(transitive)
+ Addedonetime@6.0.0(transitive)
+ Addedpath-key@3.1.14.0.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-final-newline@3.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedwhich-pm-runs@1.1.0(transitive)
Updatedcreate-svelte@^5.0.2