@cnpx/cnpx 0.0.5-dev.20260405075059 → 0.0.5-dev.20260405084610
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 +4 -4
- package/out/main.js +3 -3
- package/out/main.mjs +3 -3
- package/out/offlineRunner.d.mts +8 -0
- package/out/offlineRunner.d.ts +8 -0
- package/out/offlineRunner.js +4 -0
- package/out/offlineRunner.mjs +4 -0
- package/out/showHelp.js +10 -9
- package/out/showHelp.mjs +10 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ cnpx
|
|
|
65
65
|
Or skip straight to a known template with flags:
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
cnpx --name my-app --template
|
|
68
|
+
cnpx --name my-app --template backend/fastify
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
---
|
|
@@ -92,13 +92,13 @@ cnpx
|
|
|
92
92
|
cnpx --name my-project
|
|
93
93
|
|
|
94
94
|
# Slash syntax — sets both category and template
|
|
95
|
-
cnpx -t
|
|
95
|
+
cnpx -t backend/fastify
|
|
96
96
|
|
|
97
97
|
# Category and template as separate flags
|
|
98
|
-
cnpx --category
|
|
98
|
+
cnpx --category backend --template fastify
|
|
99
99
|
|
|
100
100
|
# All flags — no prompts at all
|
|
101
|
-
cnpx -n my-app -t
|
|
101
|
+
cnpx -n my-app -t backend/fastify -f
|
|
102
102
|
|
|
103
103
|
# Print help
|
|
104
104
|
cnpx --help
|
package/out/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var prompts=require('@clack/prompts'),isValidDirectoryName=require('./isValidDirectoryName'),getPackageManager=require('./getPackageManager'),colorette=require('colorette'),checkForUpdate=require('./checkForUpdate'),isInvalidPath=require('./isInvalidPath'),getCategories=require('./getCategories'),getTemplates=require('./getTemplates'),node_util=require('node:util'),clone=require('./clone'),node_path=require('node:path');async function
|
|
1
|
+
'use strict';var prompts=require('@clack/prompts'),isValidDirectoryName=require('./isValidDirectoryName'),getPackageManager=require('./getPackageManager'),colorette=require('colorette'),checkForUpdate=require('./checkForUpdate'),isInvalidPath=require('./isInvalidPath'),getCategories=require('./getCategories'),offlineRunner=require('./offlineRunner'),getTemplates=require('./getTemplates'),node_util=require('node:util'),clone=require('./clone'),node_path=require('node:path');async function J(){prompts.intro(colorette.blue("cnpx - Create a new project from a template"));const r=["",""],{values:t}=node_util.parseArgs({args:process.argv.slice(2),strict:false,options:{category:{type:"string",short:"c"},template:{type:"string",short:"t"},name:{type:"string",short:"n"},force:{type:"boolean",short:"f"},offline:{type:"boolean",short:"o"}}});if(t.offline===true)return await offlineRunner.offlineRunner({...t});if(typeof t.name=="string"){const e=isValidDirectoryName.isValidDirectoryName(t.name);if(typeof e=="string")return prompts.cancel(e),process.exit(1)}if(typeof t.category=="string"&&(r[0]=t.category),typeof t.template=="string")if(t.template.includes("/")){const[e,n]=t.template.split("/");r[0]=e,r[1]=n;}else r[1]=t.template;await checkForUpdate.checkForUpdate();const o=typeof t.name=="string"?t.name:await prompts.text({message:"Project Name",placeholder:"my-project",defaultValue:"my-project",validate:e=>{if(!e)return;const n=isValidDirectoryName.isValidDirectoryName(e);if(typeof n=="string")return new Error(n)}});if(prompts.isCancel(o))return prompts.cancel("Operation cancelled"),process.exit(0);const p=isInvalidPath.isInvalidPath(node_path.join(process.cwd(),o));let m=typeof t.force=="boolean"?t.force:false;if(p!==null)if(p){if(t.force!==true){const e=await prompts.confirm({message:`Directory ${colorette.green(o)} already exists. Do you want to overwrite it?`});if(prompts.isCancel(e)||!e)return prompts.cancel("Operation cancelled"),process.exit(0)}m=true;}else return prompts.cancel(`${colorette.green(o)} is a file. Please choose a different project name.`),process.exit(1);const d=await getCategories.getCategories(),s=r[0]||await prompts.select({message:"Select a category",options:d.map(e=>({name:e.name,value:e.name}))});if(prompts.isCancel(s))return prompts.cancel("Operation cancelled"),process.exit(0);r[0]=s;const w=await getTemplates.getTemplates(s),l=r[1]||await prompts.select({message:"Select a template",options:w.map(e=>({name:e.name,value:e.name}))});if(prompts.isCancel(l))return prompts.cancel("Operation cancelled"),process.exit(0);if(r[1]=l,t.force!==true){const e=await prompts.confirm({message:`Create project with name: ${colorette.bold(o)}, category: ${colorette.bold(r[0])}, template: ${colorette.bold(r[1])}?`});if(prompts.isCancel(e)||!e)return prompts.cancel("Operation cancelled"),process.exit(0)}await clone.clone(o,`${r.join("/")}`,m),prompts.note(`cd ${o}
|
|
2
2
|
${getPackageManager.getPackageManager()} install
|
|
3
|
-
node --run dev`,"To get started, run:"),prompts.outro(`Thanks for using cnpx!
|
|
4
|
-
exports.main=
|
|
3
|
+
node --run dev`,"To get started, run:"),prompts.outro(`Thanks for using cnpx! If you have any issues or feedback, please open an issue at ${colorette.gray("https://github.com/xcfio/template/issues")}`);}
|
|
4
|
+
exports.main=J;
|
package/out/main.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import'./chunk-A7RKGLUR.mjs';import {intro,cancel,text,isCancel,confirm,select,note,outro}from'@clack/prompts';import {isValidDirectoryName}from'./isValidDirectoryName';import {getPackageManager}from'./getPackageManager';import {blue,green,bold,
|
|
1
|
+
import'./chunk-A7RKGLUR.mjs';import {intro,cancel,text,isCancel,confirm,select,note,outro}from'@clack/prompts';import {isValidDirectoryName}from'./isValidDirectoryName';import {getPackageManager}from'./getPackageManager';import {blue,green,bold,gray}from'colorette';import {checkForUpdate}from'./checkForUpdate';import {isInvalidPath}from'./isInvalidPath';import {getCategories}from'./getCategories';import {offlineRunner}from'./offlineRunner';import {getTemplates}from'./getTemplates';import {parseArgs}from'node:util';import {clone}from'./clone';import {join}from'node:path';async function J(){intro(blue("cnpx - Create a new project from a template"));const r=["",""],{values:t}=parseArgs({args:process.argv.slice(2),strict:false,options:{category:{type:"string",short:"c"},template:{type:"string",short:"t"},name:{type:"string",short:"n"},force:{type:"boolean",short:"f"},offline:{type:"boolean",short:"o"}}});if(t.offline===true)return await offlineRunner({...t});if(typeof t.name=="string"){const e=isValidDirectoryName(t.name);if(typeof e=="string")return cancel(e),process.exit(1)}if(typeof t.category=="string"&&(r[0]=t.category),typeof t.template=="string")if(t.template.includes("/")){const[e,n]=t.template.split("/");r[0]=e,r[1]=n;}else r[1]=t.template;await checkForUpdate();const o=typeof t.name=="string"?t.name:await text({message:"Project Name",placeholder:"my-project",defaultValue:"my-project",validate:e=>{if(!e)return;const n=isValidDirectoryName(e);if(typeof n=="string")return new Error(n)}});if(isCancel(o))return cancel("Operation cancelled"),process.exit(0);const p=isInvalidPath(join(process.cwd(),o));let m=typeof t.force=="boolean"?t.force:false;if(p!==null)if(p){if(t.force!==true){const e=await confirm({message:`Directory ${green(o)} already exists. Do you want to overwrite it?`});if(isCancel(e)||!e)return cancel("Operation cancelled"),process.exit(0)}m=true;}else return cancel(`${green(o)} is a file. Please choose a different project name.`),process.exit(1);const d=await getCategories(),s=r[0]||await select({message:"Select a category",options:d.map(e=>({name:e.name,value:e.name}))});if(isCancel(s))return cancel("Operation cancelled"),process.exit(0);r[0]=s;const w=await getTemplates(s),l=r[1]||await select({message:"Select a template",options:w.map(e=>({name:e.name,value:e.name}))});if(isCancel(l))return cancel("Operation cancelled"),process.exit(0);if(r[1]=l,t.force!==true){const e=await confirm({message:`Create project with name: ${bold(o)}, category: ${bold(r[0])}, template: ${bold(r[1])}?`});if(isCancel(e)||!e)return cancel("Operation cancelled"),process.exit(0)}await clone(o,`${r.join("/")}`,m),note(`cd ${o}
|
|
2
2
|
${getPackageManager()} install
|
|
3
|
-
node --run dev`,"To get started, run:"),outro(`Thanks for using cnpx!
|
|
4
|
-
export{
|
|
3
|
+
node --run dev`,"To get started, run:"),outro(`Thanks for using cnpx! If you have any issues or feedback, please open an issue at ${gray("https://github.com/xcfio/template/issues")}`);}
|
|
4
|
+
export{J as main};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
'use strict';var prompts=require('@clack/prompts'),isValidDirectoryName=require('./isValidDirectoryName'),getPackageManager=require('./getPackageManager'),colorette=require('colorette'),clone=require('./clone');async function k({category:c,template:o,name:r,force:i}){prompts.note("Running in offline mode. Make sure you have cached templates available.","Warning");const t=["",""];if(i=!!i,typeof r=="string"){const e=isValidDirectoryName.isValidDirectoryName(r);if(typeof e=="string")return prompts.cancel(e),process.exit(1)}else {const e=await prompts.text({message:"Project Name",placeholder:"my-project",defaultValue:"my-project",validate:n=>{if(!n)return;const l=isValidDirectoryName.isValidDirectoryName(n);if(typeof l=="string")return new Error(l)}});if(prompts.isCancel(e))return prompts.cancel("Operation cancelled"),process.exit(0);r=e;}if(typeof c=="string"&&(t[0]=c),typeof o=="string")if(o.includes("/")){const[e,n]=o.split("/");t[0]=e,t[1]=n;}else t[1]=o;if(!t[0]||!t[1])return prompts.cancel("Offline mode requires a specific template."),process.exit(1);if(i!==true){const e=await prompts.confirm({message:`Create project with name: ${colorette.bold(r)}, category: ${colorette.bold(t[0])}, template: ${colorette.bold(t[1])}?`});if(prompts.isCancel(e)||!e)return prompts.cancel("Operation cancelled"),process.exit(0)}await clone.clone(r,`${t.join("/")}`,i),prompts.note(`cd ${r}
|
|
2
|
+
${getPackageManager.getPackageManager()} install
|
|
3
|
+
node --run dev`,"To get started, run:"),prompts.outro(`Thanks for using cnpx! If you have any issues or feedback, please open an issue at ${colorette.gray("https://github.com/xcfio/template/issues")}`);}
|
|
4
|
+
exports.offlineRunner=k;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import'./chunk-A7RKGLUR.mjs';import {note,cancel,text,isCancel,confirm,outro}from'@clack/prompts';import {isValidDirectoryName}from'./isValidDirectoryName';import {getPackageManager}from'./getPackageManager';import {bold,gray}from'colorette';import {clone}from'./clone';async function k({category:c,template:o,name:r,force:i}){note("Running in offline mode. Make sure you have cached templates available.","Warning");const t=["",""];if(i=!!i,typeof r=="string"){const e=isValidDirectoryName(r);if(typeof e=="string")return cancel(e),process.exit(1)}else {const e=await text({message:"Project Name",placeholder:"my-project",defaultValue:"my-project",validate:n=>{if(!n)return;const l=isValidDirectoryName(n);if(typeof l=="string")return new Error(l)}});if(isCancel(e))return cancel("Operation cancelled"),process.exit(0);r=e;}if(typeof c=="string"&&(t[0]=c),typeof o=="string")if(o.includes("/")){const[e,n]=o.split("/");t[0]=e,t[1]=n;}else t[1]=o;if(!t[0]||!t[1])return cancel("Offline mode requires a specific template."),process.exit(1);if(i!==true){const e=await confirm({message:`Create project with name: ${bold(r)}, category: ${bold(t[0])}, template: ${bold(t[1])}?`});if(isCancel(e)||!e)return cancel("Operation cancelled"),process.exit(0)}await clone(r,`${t.join("/")}`,i),note(`cd ${r}
|
|
2
|
+
${getPackageManager()} install
|
|
3
|
+
node --run dev`,"To get started, run:"),outro(`Thanks for using cnpx! If you have any issues or feedback, please open an issue at ${gray("https://github.com/xcfio/template/issues")}`);}
|
|
4
|
+
export{k as offlineRunner};
|
package/out/showHelp.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
'use strict';var colorette=require('colorette');function
|
|
2
|
-
|
|
1
|
+
'use strict';var colorette=require('colorette');function a(){console.log(`
|
|
2
|
+
${colorette.blue(colorette.bold("cnpx"))} - Create a new project from a template
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
${colorette.bold("Options:")}
|
|
5
|
+
${colorette.green("-n, --name")} ${colorette.dim("Project name")}
|
|
6
|
+
${colorette.green("-c, --category")} ${colorette.dim("Template category")}
|
|
7
|
+
${colorette.green("-t, --template")} ${colorette.dim("Template name")}
|
|
8
|
+
${colorette.green("-f, --force")} ${colorette.dim("Overwrite existing directory")}
|
|
9
|
+
${colorette.green("-o, --offline")} ${colorette.dim("Run in offline mode (using cached templates)")}
|
|
10
|
+
${colorette.green("-h, --help")} ${colorette.dim("Show help")}
|
|
11
|
+
`),process.exit(0);}exports.showHelp=a;
|
package/out/showHelp.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import'./chunk-A7RKGLUR.mjs';import {blue,bold,green,dim}from'colorette';function
|
|
2
|
-
|
|
1
|
+
import'./chunk-A7RKGLUR.mjs';import {blue,bold,green,dim}from'colorette';function a(){console.log(`
|
|
2
|
+
${blue(bold("cnpx"))} - Create a new project from a template
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
${bold("Options:")}
|
|
5
|
+
${green("-n, --name")} ${dim("Project name")}
|
|
6
|
+
${green("-c, --category")} ${dim("Template category")}
|
|
7
|
+
${green("-t, --template")} ${dim("Template name")}
|
|
8
|
+
${green("-f, --force")} ${dim("Overwrite existing directory")}
|
|
9
|
+
${green("-o, --offline")} ${dim("Run in offline mode (using cached templates)")}
|
|
10
|
+
${green("-h, --help")} ${dim("Show help")}
|
|
11
|
+
`),process.exit(0);}export{a as showHelp};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnpx/cnpx",
|
|
3
|
-
"version": "0.0.5-dev.
|
|
3
|
+
"version": "0.0.5-dev.20260405084610",
|
|
4
4
|
"description": "An interactive CLI tool for creating new projects from curated templates hosted on GitHub. Pick a category, pick a template, and get coding.",
|
|
5
5
|
"author": "xcfio",
|
|
6
6
|
"homepage": "https://github.com/xcfio/template/tree/main/cnpx/cnpx#readme",
|