@sugarcube-org/cli 0.0.0-alpha.11 → 0.0.0-alpha.12
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.mjs +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -39,4 +39,4 @@ Caused by:`,e.cause)}else C.error(`An unexpected error occurred: ${e instanceof
|
|
|
39
39
|
If this issue persists, please report it: ${u.cyanBright("https://github.com/sugarcube-org/sugarcube/issues")}`),process.env.DEBUG&&C.info(`
|
|
40
40
|
Error details:`,e);C.break(),process.exit(0)}l(q,"handleError");const nt=new M().name("init").description("Initialize a new project").action(async()=>{try{Qe(),(await He()).shouldProceed||process.exit(0),V("Step 1. Set up tokens");const n=await Ae();let t;switch(n){case"starter":const r=await A();r||(Y("Failed to fetch starter kit list"),process.exit(1));const p=await Oe(r),h=await ue(),k=await Re();try{t=await Ke(p,h,k)}catch(b){Y(`Failed to initialize starter kit: ${b instanceof Error?b.message:"Unknown error"}`),process.exit(1)}break;case"existing":t=await Ye({});break}V("Step 2. Add style system");const o=await Me();V("Step 3. Add components");const s=await me();let i=[];if(s!=="skip"){const r=await A();r||(Y("Failed to fetch component list"),process.exit(1));const p=await de(r,s),h=await fe(),k=await ve({components:p,componentType:s,componentsOutputDirectory:h});if(k.length>0){const b=k.join(", ");await ne(`The following components already exist and will be overwritten: ${b}. Continue?`,!1)}if(p.length>0){const b=ee();b.start("Installing components...");try{const{createdFiles:x,npmDependencies:D}=await be({registryIndex:r,selectedComponents:p,componentType:s,componentsOutputDirectory:h,cssOutputDirectory:t.config.output.directories.css});i=x,b.stop("Components installed successfully")}catch(x){throw b.stop("Installation failed"),x}}}V("Step 4. Set up index.css");const c=await Ge();t.config.output.css.manageIndex=c,V("Step 5. Generating files");try{if(await te.mkdir(t.tokensDir,{recursive:!0}),await te.mkdir(t.config.output.directories.css,{recursive:!0}),n==="starter"){if(!t.tokenFiles||t.tokenFiles.length===0)throw new d("Failed to generate token content for starter kit");for(const r of t.tokenFiles)await te.writeFile(r.path,r.content)}}catch(r){const p=r instanceof Error?`: ${r.message}`:"";throw new d(`Failed to create project files${p}`)}let a=[];const{trees:f,resolved:g}=await B(t.config);a=await he(f,g,t.config);let y=[];o&&(y=await et(t.config.output.directories.css)),t.config.output.css.manageIndex&&await X({cssOutputDirectory:t.config.output.directories.css,files:[...a.map(r=>r.path),...i.filter(r=>r.endsWith(".css")),...y]}),await re(t.config),H({config:"sugarcube.config.json",tokens:n==="starter"?t.tokens:[],generated:[...a.map(r=>r.path),...y,...i,...t.config.output.css.manageIndex?["index.css"]:[]]}),z(u.greenBright("Success! Project initialized \u2728"))}catch(e){q(e)}}),st=new M().name("generate").description("Generate CSS from your design tokens").option("--force","Skip confirmation when deleting stale files").action(async e=>{try{if(J(u.inverse(" Generate CSS variables from your design tokens ")),!T("sugarcube.config.json"))throw new d("This command requires a sugarcube project. Run 'npx make-sugarcube init' first.");const n=await G(),{trees:t,resolved:o}=await B(n),s=await he(t,o,n);n.output.css.manageIndex&&await X({cssOutputDirectory:n.output.directories.css,files:s.map(i=>i.path)}),H({generated:[...s.map(i=>i.path),...n.output.css.manageIndex?["index.css"]:[]]}),z(u.greenBright("Success! CSS variables generated successfully. \u2728"))}catch(n){q(n)}}),ot=new M().name("validate").description("Validate design token files").argument("[paths...]","Token files or directories to validate (e.g., tokens.json or ./tokens)").action(async e=>{try{if(J(u.inverse(" Validate design tokens ")),T("sugarcube.config.json")&&!e.length){const s=await G();await B(s),z(u.greenBright("All tokens are valid \u2728"));return}if(!e.length)throw new d("No paths specified. Please provide files/directories to validate, or run this in a Sugarcube project directory.");const n=e.map(s=>m.normalize(s));for(const s of n)if(!T(s))throw new d(`Path not found: ${s}
|
|
41
41
|
Please check that the specified files or directories exist`);const t=await pe(n.map(s=>s.endsWith(".json")?s:m.join(s,"**/*.json")));if(t.length===0)throw new d(`No JSON files found in the specified paths
|
|
42
|
-
Please ensure the paths contain .json files`);const o=T("sugarcube.config.json")?await G():{output:{directories:{tokens:".",css:"."},css:{separate:!1}}};await B({...o,tokens:{type:"custom",source:t.map(s=>m.relative(process.cwd(),s))}}),z(u.greenBright("All tokens are valid \u2728"))}catch(n){q(n)}}),rt=new M().name("components").description("Add components to your project").argument("[components...]","Components to add (e.g., button card)").option("-f, --framework <type>","Framework to use (react, astro, nunjucks)").option("-s, --silent","Suppress logs and prompts").action(async(e,n)=>{try{if(n.silent||J(u.inverse(" Add components ")),!T("sugarcube.config.json"))throw new d("This command requires a sugarcube project. Run 'npx make-sugarcube init' first.");let t=await G(),o,s=[],i;if(e.length>0){if(!n.framework)throw new d("Framework must be specified in non-interactive mode (--framework)");const f=["react","astro","nunjucks"];if(!f.includes(n.framework))throw new d(`Invalid framework. Must be one of: ${f.join(", ")}`);if(i=n.framework,s=e,!t.output.directories.components)throw new d("Components directory must be configured in non-interactive mode. Please run without arguments first.");o=m.resolve(process.cwd(),t.output.directories.components)}else{i=await me(!1);const f=await A();if(f||(Y("Failed to fetch component list"),process.exit(1)),s=await de(f,i),t.output.directories.components)o=m.resolve(process.cwd(),t.output.directories.components);else{const g=await fe();o=m.resolve(process.cwd(),g),t.output.directories.components=m.relative(process.cwd(),o),await re(t)}}const c=await ve({components:s,componentType:i,componentsOutputDirectory:o});if(c.length>0&&!n.silent){const f=c.join(", ");await ne(`The following components already exist and will be overwritten: ${f}. Continue?`,!1)}let a;n.silent||(a=ee(),a.start("Installing components..."));try{const f=await A(),{createdFiles:g,npmDependencies:y}=await be({registryIndex:f,selectedComponents:s,componentType:i,componentsOutputDirectory:o,cssOutputDirectory:t.output.directories.css});t.output.css.manageIndex&&await X({cssOutputDirectory:t.output.directories.css,files:g}),n.silent||(a?.stop("Components installed successfully"),H({generated:g}),z(u.greenBright("Success! Components installed \u2728")))}catch(f){throw n.silent||a?.stop("Installation failed"),f}}catch(t){q(t)}}),it=new M().name("cube").description("Add CUBE CSS to your project").option("-s, --silent","Suppress logs and prompts").action(async e=>{const n=[];try{if(!T("sugarcube.config.json"))throw new d("This command requires a sugarcube project. Run 'npx make-sugarcube init' first.");e.silent||J(u.inverse(" Add CUBE CSS "));const t=await G(),o=m.resolve(process.cwd(),t.output.directories.css);try{await P(o,{recursive:!0})}catch(c){const a=c instanceof Error?`: ${c.message}`:"";throw new d(`Failed to create output directory${a}`)}const i=(await A()).filter(c=>c.type==="cube").map(c=>c.name);for(const c of i){const a=await Q({type:"cube",name:c});for(const f of a.files){if(!f)continue;const g=f.path.replace(/^styles\//,""),y=m.join(o,g),r=m.dirname(y);try{await P(r,{recursive:!0}),await _(y,f.content),n.push(y)}catch(p){const h=p instanceof Error?`: ${p.message}`:"";throw new d(`Failed to write CUBE CSS file ${y}${h}`)}}}t.output.css.manageIndex&&await X({cssOutputDirectory:o,files:n}),await re(t),!e.silent&&n.length>0&&(H({generated:n}),z(u.greenBright("Success! CUBE CSS added successfully. \u2728")))}catch(t){q(t)}});var at="@sugarcube-org/cli",ct="0.0.0-alpha.
|
|
42
|
+
Please ensure the paths contain .json files`);const o=T("sugarcube.config.json")?await G():{output:{directories:{tokens:".",css:"."},css:{separate:!1}}};await B({...o,tokens:{type:"custom",source:t.map(s=>m.relative(process.cwd(),s))}}),z(u.greenBright("All tokens are valid \u2728"))}catch(n){q(n)}}),rt=new M().name("components").description("Add components to your project").argument("[components...]","Components to add (e.g., button card)").option("-f, --framework <type>","Framework to use (react, astro, nunjucks)").option("-s, --silent","Suppress logs and prompts").action(async(e,n)=>{try{if(n.silent||J(u.inverse(" Add components ")),!T("sugarcube.config.json"))throw new d("This command requires a sugarcube project. Run 'npx make-sugarcube init' first.");let t=await G(),o,s=[],i;if(e.length>0){if(!n.framework)throw new d("Framework must be specified in non-interactive mode (--framework)");const f=["react","astro","nunjucks"];if(!f.includes(n.framework))throw new d(`Invalid framework. Must be one of: ${f.join(", ")}`);if(i=n.framework,s=e,!t.output.directories.components)throw new d("Components directory must be configured in non-interactive mode. Please run without arguments first.");o=m.resolve(process.cwd(),t.output.directories.components)}else{i=await me(!1);const f=await A();if(f||(Y("Failed to fetch component list"),process.exit(1)),s=await de(f,i),t.output.directories.components)o=m.resolve(process.cwd(),t.output.directories.components);else{const g=await fe();o=m.resolve(process.cwd(),g),t.output.directories.components=m.relative(process.cwd(),o),await re(t)}}const c=await ve({components:s,componentType:i,componentsOutputDirectory:o});if(c.length>0&&!n.silent){const f=c.join(", ");await ne(`The following components already exist and will be overwritten: ${f}. Continue?`,!1)}let a;n.silent||(a=ee(),a.start("Installing components..."));try{const f=await A(),{createdFiles:g,npmDependencies:y}=await be({registryIndex:f,selectedComponents:s,componentType:i,componentsOutputDirectory:o,cssOutputDirectory:t.output.directories.css});t.output.css.manageIndex&&await X({cssOutputDirectory:t.output.directories.css,files:g}),n.silent||(a?.stop("Components installed successfully"),H({generated:g}),z(u.greenBright("Success! Components installed \u2728")))}catch(f){throw n.silent||a?.stop("Installation failed"),f}}catch(t){q(t)}}),it=new M().name("cube").description("Add CUBE CSS to your project").option("-s, --silent","Suppress logs and prompts").action(async e=>{const n=[];try{if(!T("sugarcube.config.json"))throw new d("This command requires a sugarcube project. Run 'npx make-sugarcube init' first.");e.silent||J(u.inverse(" Add CUBE CSS "));const t=await G(),o=m.resolve(process.cwd(),t.output.directories.css);try{await P(o,{recursive:!0})}catch(c){const a=c instanceof Error?`: ${c.message}`:"";throw new d(`Failed to create output directory${a}`)}const i=(await A()).filter(c=>c.type==="cube").map(c=>c.name);for(const c of i){const a=await Q({type:"cube",name:c});for(const f of a.files){if(!f)continue;const g=f.path.replace(/^styles\//,""),y=m.join(o,g),r=m.dirname(y);try{await P(r,{recursive:!0}),await _(y,f.content),n.push(y)}catch(p){const h=p instanceof Error?`: ${p.message}`:"";throw new d(`Failed to write CUBE CSS file ${y}${h}`)}}}t.output.css.manageIndex&&await X({cssOutputDirectory:o,files:n}),await re(t),!e.silent&&n.length>0&&(H({generated:n}),z(u.greenBright("Success! CUBE CSS added successfully. \u2728")))}catch(t){q(t)}});var at="@sugarcube-org/cli",ct="0.0.0-alpha.12",lt={access:"public"},pt="A CLI for scaffolding sugarcube applications",ut="AGPL-3.0",ft="Mark Tomlinson",mt={type:"git",url:"https://github.com/sugarcube-org/sugarcube"},dt={url:"https://github.com/sugarcube-org/sugarcube/issues"},gt=["cli","design-system","components","CUBE CSS","react","sugarcube"],ht=["dist","README.md","LICENSE.md"],wt="module",yt="./dist/index.mjs",ie={".":"./dist/index.mjs"},kt={sugarcube:"./dist/index.mjs"},bt={build:"pkgroll --minify",dev:"cross-env REGISTRY_URL=http://localhost:8787/registry tsx src/index.ts",test:"vitest","type-check":"tsc --noEmit",start:"cross-env REGISTRY_URL=https://sugarcube-registry.mark-tomlinson3.workers.dev/registry tsx src/index.ts",prepublishOnly:"pnpm up @sugarcube-org/core --filter @sugarcube-org/cli && pnpm build"},vt={"@antfu/ni":"^23.3.0","@clack/prompts":"^0.9.1","@sugarcube-org/core":"workspace:*",commander:"^12.1.0","cross-env":"^7.0.3",execa:"^9.5.2","fast-glob":"^3.3.2","fs-extra":"^11.2.0","lucide-react":"^0.468.0","node-fetch":"^3.3.0",picocolors:"^1.1.1",prompts:"^2.4.2",zod:"^3.23.8"},St={"@types/fs-extra":"^11.0.4","@types/prompts":"^2.4.9",pkgroll:"^2.5.1",tsx:"^4.19.2"},xt={name:at,version:ct,publishConfig:lt,description:pt,license:ut,author:ft,repository:mt,bugs:dt,keywords:gt,files:ht,type:wt,main:yt,exports:ie,bin:kt,scripts:bt,dependencies:vt,devDependencies:St};process.on("SIGINT",()=>process.exit(0)),process.on("SIGTERM",()=>process.exit(0));async function Ct(){const e=new M().name("sugarcube").description("CLI for scaffolding sugarcube applications").version(xt.version,"-v, --version","display the version number");e.addCommand(nt).addCommand(st).addCommand(ot).addCommand(rt).addCommand(it),e.parse()}l(Ct,"main"),Ct()});export default $t();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sugarcube-org/cli",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"picocolors": "^1.1.1",
|
|
49
49
|
"prompts": "^2.4.2",
|
|
50
50
|
"zod": "^3.23.8",
|
|
51
|
-
"@sugarcube-org/core": "0.0.1-alpha.
|
|
51
|
+
"@sugarcube-org/core": "0.0.1-alpha.4"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/fs-extra": "^11.0.4",
|