create-croissant 0.1.0
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 +9 -0
- package/package.json +35 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{Command as w}from"commander";import o from"chalk";import k from"inquirer";import t from"fs-extra";import r from"path";import{fileURLToPath as v}from"url";import d from"ora";import{execa as j}from"execa";var S=v(import.meta.url),f=r.dirname(S),g=new w;g.name("create-croissant").description("Scaffold a new project using the Croissant Stack").argument("[project-name]","Name of the project").action(async i=>{console.log(o.bold.yellow(`
|
|
3
|
+
\u{1F950} Welcome to the Croissant Stack!
|
|
4
|
+
`));let l=await k.prompt([{type:"input",name:"name",message:"What is your project named?",default:i||"my-croissant-app",when:!i},{type:"confirm",name:"install",message:"Would you like to install dependencies?",default:!0}]),a=i||l.name,n=r.resolve(process.cwd(),a);t.existsSync(n)&&(console.error(o.red(`
|
|
5
|
+
Error: Directory ${a} already exists.
|
|
6
|
+
`)),process.exit(1));let p=d("Scaffolding your project...").start();try{await t.ensureDir(n);let s=r.join(f,"..","template");if(await t.pathExists(s))await t.copy(s,n);else{let e=r.resolve(f,"../../.."),m=["node_modules","dist",".git","packages/create-croissant",".turbo","package-lock.json"];await t.copy(e,n,{filter:u=>{let y=r.relative(e,u);return!m.some(h=>y.startsWith(h))}})}let c=r.join(n,"package.json");if(await t.pathExists(c)){let e=await t.readJson(c);e.name=a,e.version="0.1.0",delete e.private,await t.writeJson(c,e,{spaces:2})}if(p.succeed(o.green(`Project ${a} created at ${n}`)),l.install){let e=d("Installing dependencies...").start();try{await j("npm",["install"],{cwd:n}),e.succeed(o.green("Dependencies installed!"))}catch{e.fail(o.red("Failed to install dependencies. You may need to run npm install manually."))}}console.log(o.bold.cyan(`
|
|
7
|
+
Next steps:`)),console.log(` cd ${a}`),console.log(" npm run db:up # Start your PostgreSQL database"),console.log(` npm run dev # Start development server
|
|
8
|
+
`),console.log(o.yellow(`Happy hacking! \u{1F950}
|
|
9
|
+
`))}catch(s){p.fail(o.red("An error occurred during scaffolding.")),console.error(s),process.exit(1)}});g.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-croissant",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffold a new project using the Croissant Stack",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-croissant": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"template"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup src/index.ts --format esm --clean --minify",
|
|
16
|
+
"dev": "tsup src/index.ts --format esm --watch",
|
|
17
|
+
"lint": "eslint src",
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"chalk": "^5.3.0",
|
|
22
|
+
"commander": "^12.1.0",
|
|
23
|
+
"execa": "^9.3.0",
|
|
24
|
+
"fs-extra": "^11.2.0",
|
|
25
|
+
"inquirer": "^10.1.8",
|
|
26
|
+
"ora": "^8.0.1"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/fs-extra": "^11.0.4",
|
|
30
|
+
"@types/inquirer": "^9.0.7",
|
|
31
|
+
"@types/node": "^20.14.9",
|
|
32
|
+
"tsup": "^8.1.0",
|
|
33
|
+
"typescript": "^5.5.2"
|
|
34
|
+
}
|
|
35
|
+
}
|