@papit/create 0.0.4 → 0.0.6
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.
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"build": "npx @papit/build",
|
|
11
11
|
"test": "node bin/test.mjs",
|
|
12
12
|
"create": "npm create @papit -- --package",
|
|
13
|
-
"start": "npx @papit/server --serve --info"
|
|
13
|
+
"start": "npx @papit/server --serve --info",
|
|
14
|
+
"version:reset": "npx @papit/version --reset",
|
|
15
|
+
"version:sync": "npx @papit/version --sync"
|
|
14
16
|
},
|
|
15
17
|
"keywords": [
|
|
16
18
|
"typescript"
|
|
@@ -28,15 +30,15 @@
|
|
|
28
30
|
"devDependencies": {
|
|
29
31
|
"esbuild": "0.27.2",
|
|
30
32
|
"typescript": "5.9.3",
|
|
31
|
-
"@papit/bundle-ts": "
|
|
32
|
-
"@papit/bundle-js": "
|
|
33
|
-
"@papit/arguments": "
|
|
34
|
-
"@papit/terminal": "
|
|
35
|
-
"@papit/information": "
|
|
36
|
-
"@papit/build": "
|
|
37
|
-
"@papit/server": "
|
|
38
|
-
"@papit/create": "
|
|
39
|
-
"@papit/version": "
|
|
33
|
+
"@papit/bundle-ts": "*",
|
|
34
|
+
"@papit/bundle-js": "*",
|
|
35
|
+
"@papit/arguments": "*",
|
|
36
|
+
"@papit/terminal": "*",
|
|
37
|
+
"@papit/information": "*",
|
|
38
|
+
"@papit/build": "*",
|
|
39
|
+
"@papit/server": "*",
|
|
40
|
+
"@papit/create": "*",
|
|
41
|
+
"@papit/version": "*"
|
|
40
42
|
},
|
|
41
43
|
"papit": {}
|
|
42
44
|
}
|
package/lib/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import O from"node:path";import ne from"node:fs";import{Arguments as D}from"@papit/arguments";import{Information as le,PackageGraph as pe}from"@papit/information";import{Terminal as A}from"@papit/terminal";import k from"node:path";import v from"node:fs";import{Terminal as i}from"@papit/terminal";import{Information as F,PackageGraph as
|
|
3
|
-
`)}import
|
|
4
|
-
`),
|
|
2
|
+
import O from"node:path";import ne from"node:fs";import{Arguments as D}from"@papit/arguments";import{Information as le,PackageGraph as pe}from"@papit/information";import{Terminal as A}from"@papit/terminal";import k from"node:path";import v from"node:fs";import{Terminal as i}from"@papit/terminal";import{Information as F,PackageGraph as ee}from"@papit/information";import{Arguments as S}from"@papit/arguments";import L from"node:path";import $ from"node:fs";import{Information as R}from"@papit/information";import{Terminal as u}from"@papit/terminal";import{Arguments as b}from"@papit/arguments";import{Arguments as ie}from"@papit/arguments";import{Information as W,PackageGraph as oe}from"@papit/information";import{Terminal as E}from"@papit/terminal";import j from"node:fs";import I from"node:path";function N(e){return j.readdirSync(e).filter(n=>j.statSync(I.join(e,n)).isDirectory())}function re(e){return j.readdirSync(e).filter(n=>{let r=I.join(e,n);return!(!j.statSync(r).isDirectory()||oe.search(r))})}async function Q(){return E.sessionBlock(async()=>{let e=I.join(W.root.location,"packages"),n=e;for(;e;){let r=E.createSession(),s=re(e);E.write("Current: ",e.replace(W.root.location,W.scope)),E.write();let p=await E.option([["Choose Folder","Create Folder"],e===n?s:["..",...s]]);if(p.index===0)break;if(p.index===1){let c=await E.prompt("folder name",!1,e),a=I.join(e,c.input);await ae(a)&&(e=I.join(e,c.input))}else p.index===2&&e!==n?e=I.resolve(e,".."):e=I.join(e,s[p.index-(e===n?2:3)]);E.clearSession(r)}return e})}async function ae(e){return E.createSession(),E.write(`[${e}]`),ie.has("agree")||await E.confirm("confirm folder creation",!0)?(j.mkdirSync(e,{recursive:!0}),E.clearSession(),!0):!1}async function _(e,n,r){j.mkdirSync(n,{recursive:!0});let s=j.readdirSync(e,{withFileTypes:!0});for(let p of s){let c=I.join(e,p.name),a=I.join(n,p.name);if(p.isDirectory()){await _(c,a,r);continue}if(typeof r!="function"){j.copyFileSync(c,a);continue}let m=j.readFileSync(c,"utf-8"),t=await r(m,c,a);t!==!1&&(j.copyFileSync(c,a),j.writeFileSync(a,t,"utf-8"))}}function J(e){if(!e)return;let n=e.split(/[ |-]/),r=n.join("-");return{className:Z(n.map(Z).join("")),name:r.toLowerCase()}}function Z(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}function se(e){try{return $.readdirSync(e).length>0}catch{return!1}}function ce(e){$.existsSync(e)&&$.statSync(e).isDirectory()||$.mkdirSync(e)}async function U(e,n,r){let s=L.join(n?.destination??R.package.location,"package.json"),p=n?JSON.parse($.readFileSync(s,{encoding:"utf-8"})):R.package.packageJSON;p==null&&(u.error("could not find package's package.json file"),process.exit(1)),p.name===R.root.name&&(u.error("cannot create a component to root"),process.exit(1));let c=p,a=N(L.join(e,"asset/component-templates")),m=new Set;try{N(L.join(R.root.location,"bin/runners/component")).forEach(f=>{a.push(f),m.add(f)})}catch{}let t={index:a.findIndex(f=>f===c.papit?.type),text:""};if(t.text=a[t.index],t.index<0){let f=b.string("package")??b.string("type");t.index=a.findIndex(g=>g===f),t.index<0&&(u.createSession(),u.write("type of component"),t=await u.option(a),u.clearSession())}let y=b.string("html-prefix")??n?.htmlprefix??R.package.packageJSON.papit.htmlprefix??R.root.packageJSON.papit.htmlprefix;if(y?.trim()===""&&(y=void 0),y===void 0&&/web-components?/i.test(t.text)){let f=u.createSession();for(;;){let g;if(y!==void 0?(g=(await u.prompt(`use default "${y}" or override?`)).input,g||(g=y)):g=(await u.prompt("html prefix",!0)).input,g){y=g;break}else u.clearSession(),u.write("you must use a html-prefix for web-components")}u.clearSession(f)}let w=n?.nameInfo;for(;!w;){u.clearSession();let f=b.string("name");if(f||(f=(await u.prompt("(component) name",!0)).input),w=J(f),!w){u.write("name missing, try again");continue}if(c.papit.components[w.name]){u.write("name already exist, try again");continue}break}u.createSession();let P=n?.shouldCommit??b.true("agree")??b.true("commit")??await u.confirm("git commit",!0);u.clearSession();let V=m.has(t.text)?L.join(R.root.location,"bin","runners","component",t.text):L.join(e,"asset","component-templates",t.text),x=N(V);c.papit.components[w.name]={className:w.className,htmlprefix:y},$.writeFileSync(s,JSON.stringify(c,null,2),{encoding:"utf-8"}),P&&await u.execute(`git add ${s}`,R.root.location);for(let f of x){let g=L.join(n?.destination??R.package.location,f),d=g,G=L.join(V,f);if(f==="src"?se(g)&&(g=L.join(g,"components"),d=L.join(g,w.name)):d=L.join(g,w.name),ce(g),r&&(d=r(d,f)),await _(G,d,H=>H.replace(/VARIABLE_NAME/g,w.name).replace(/VARIABLE_FULL_NAME/g,c.name).replace(/VARIABLE_HTML_NAME/g,`${y}-${w.name}`).replace(/VARIABLE_CLASS_NAME/g,w.className)),P)try{await u.execute(`git add ${d}`,R.root.location)}catch{u.warn(`"git add ${d}" failed`)}}!n?.shouldCommit&&P&&await u.execute(`git commit -m "add: ${w.name} component"`,R.root.location)}async function te(e){let n=i.createSession(),r=F.root.packageJSON;r===null&&(i.error("root package.json not found"),process.exit(1));let s=await Q(),p=N(k.join(e,"asset","package-templates")),c=new Set;try{N(k.join(F.root.location,"bin","runners","package")).forEach(o=>{v.existsSync(k.join(F.root.location,"bin","runners","package",o,"package.json"))&&(p.push(o),c.add(o))})}catch{}let a=S.string("package")??S.string("type"),m={index:p.findIndex(o=>o===a),text:""};m.text=p[m.index],m.index<0&&(i.write("type of package"),m=await i.option(p)),i.clearSession();let t=S.string("html-prefix");if(t?.trim()===""&&(t=void 0),!t&&/web-components?/i.test(m.text)){for(t||(t=r.papit?.htmlprefix),S.info||i.createSession();;){let o;if(t?(o=(await i.prompt(`use default "${t}" or override?`)).input,o||(o=t)):(o=(await i.prompt("html prefix",!0)).input,r.papit?.htmlprefix||await i.confirm(`you wish to set "${o}" as the default html-prefix?`)&&(r.papit.htmlprefix=o,v.writeFileSync(k.join(F.root.location,"package.json"),JSON.stringify(r,null,2),{encoding:"utf-8"}))),o){t=o;break}else S.info||i.clearSession(),i.warn("you must use a html-prefix for web-components")}S.info||i.clearSession()}let y=k.relative(F.root.location,s),w=k.basename(s);r.repository?.url||(i.error("root package.json does not have 'repository.url'"),process.exit(1));let P=r.repository.url.replace(/\.git$/,""),V=k.join(F.root.location,"package-lock.json");i.clearSession(n);let x,f;for(;f===void 0||x===void 0;){i.clearSession();let o=S.string("name");if(o||(o=(await i.prompt("(package) name",!0)).input),x=J(o),!x){i.write("name missing, try again");continue}let h=`${F.scope}/${x.name}`;ee.get(h)?i.write("package already exists, try again"):f=h}let g=S.string("description");g||(g=(await i.prompt("description",!0)).input),i.write(),i.createSession();let d=k.join(s,x.name),G=o=>o.replace(/\\/g,"/"),H=c.has(m.text)?k.join(F.root.location,"bin","runners","package",m.text):k.join(e,"asset","package-templates",m.text);await _(H,d,async(o,h)=>h.endsWith(".gitkeep")?!1:o.replace(/VARIABLE_NAME/g,x.name).replace(/VARIABLE_FULL_NAME/g,f).replace(/VARIABLE_DESCRIPTION/g,g).replace(/VARIABLE_LAYER_FOLDER/g,w).replace(/VARIABLE_PROJECTLICENSE/g,r.license||"MIT").replace(/VARIABLE_GITHUB_REPO/g,P).replace(/VARIABLE_LOCAL_DESTINATION/g,G(k.join(y,x.name))).replace(/VARIABLE_CLASS_NAME/g,x.className).replace(/VARIABLE_HTML_PREFIX/g,t??"").replace(/VARIABLE_HTML_NAME/g,`${t}-${x.name}`).replace(/VARIABLE_USER/g,process.env.USER??"anonymous"));let z=JSON.parse(v.readFileSync(k.join(d,"package.json"),{encoding:"utf-8"}));z||(i.error(`package.json not found at "${d}"`),process.exit(1)),z.papit||(z.papit={main:x.name,components:{},publish:!0,type:m.text}),ee.add(d),i.createSession();let T=!1;S.has("no")?T=!1:S.has("yes")?T=!0:T=S.true("agree")||S.true("commit")||await i.confirm("git commit",!0),i.clearSession(),await U(e,{destination:d,nameInfo:x,htmlprefix:t,shouldCommit:T},(o,h)=>(h==="src"&&(o=o.replace(/[/\\]components[/\\].*/,"")),h==="lib"&&(o=o.replace(new RegExp(x.name+"$"),"")),h==="views"&&(o=o.replace(new RegExp(x.name+"$"),"experiment")),S.debug&&i.info(JSON.stringify({dest:o,folder:h})),o));let X=k.join(d,"src","components");v.existsSync(X)&&v.rmdirSync(X),i.createSession();let M=!1;if(S.has("no")?M=!1:S.has("yes")?M=!0:M=S.true("agree")||S.true("install")||await i.confirm("install package",!0),M){let{close:o}=i.loading("installing");try{await i.execute("npm install",g)}catch(h){i.warn("error during install"),console.log(h),i.createSession()}finally{o(),i.clearSession()}}else i.clearSession();if(T)try{await i.execute(`git add ${V}`,d),await i.execute(`git add ${d}`,d),await i.execute(`git commit -m "add: ${f} package"`,d)}catch{i.warn("error during commit")}i.write(`${f} created
|
|
3
|
+
`)}import q from"node:path";import B from"node:fs";import{Arguments as C}from"@papit/arguments";import{Terminal as l}from"@papit/terminal";async function K(e){l.write(`Project Creation
|
|
4
|
+
`),l.createSession();let n=!1,r=C.string("name");r===void 0&&(r=(await l.prompt("name",!0)).input,n=!0);let s=C.string("location");if(s===void 0){n&&l.write(),l.write(`[${process.cwd()}]`);let t=await l.prompt("location",!1,process.cwd());s=q.join(t.path,r),n=!0}await l.sessionBlock(async()=>{if(n&&l.write(),!B.existsSync(s))return;await l.confirm(`confirm to remove it [${s}]`)?B.rmSync(s,{recursive:!0,force:!0}):(l.error("must choose a empty location"),process.exit(1))}),n&&l.write(),await l.confirm(`confirm location [${l.yellow(s)}]`,!0)||(l.warn("abort"),process.exit(0)),B.mkdirSync(s,{recursive:!0});let c=C.string("description");c===void 0&&(n&&l.write(),c=(await l.prompt("description")).input,n=!0);let a=C.string("license");if(a===void 0&&(n&&l.write(),a=(await l.prompt("license (default MIT)")).input,n=!0),a){let t=C.string("license-file-location");t===void 0&&(n&&l.write(),t=(await l.prompt("license file location")).input,n=!0),B.existsSync(t)&&B.copyFileSync(t,q.join(s,"LICENSE"))}l.clearSession();let m=C.has("git")||await l.confirm("init with git?");if(m){let{close:t,update:y}=l.loading("git init",3e3,w=>{w>400?y("runnign slow"):w>800?y("something seems wrong"):w>1500&&y("yeah somethign is very wrong")});await l.execute("git init",{cwd:s}),l.clearSession(),t()}await _(q.join(e,"asset/project-template"),s,async(t,y)=>y.endsWith(".gitkeep")?!1:t.replace(/VARIABLE_NAME/g,`@${r}/root`).replace(/VARIABLE_DESCRIPTION/g,c).replace(/VARIABLE_PROJECTLICENSE/g,a||"MIT").replace(/VARIABLE_USER/g,process.env.USER??"anonymous")),m&&(await l.execute("git add .",{cwd:s}),await l.execute(`git commit -m "init: ${r} initialized"`,{cwd:s})),l.write("project initialized"),process.exit(0)}(async function(){D.init(process.argv,["install","commit","agree"]),D.verbose&&(process.env.verbose="true");let e=O.dirname(import.meta.dirname),n=JSON.parse(ne.readFileSync(O.join(e,"package.json"),{encoding:"utf-8"}));if(n||(A.error("could not find @papit/create package.json"),process.exit(1)),!process.env.USER){A.createSession();let a=await A.prompt("your name",!0);process.env.USER=a.input,A.clearSession()}A.write(),A.write("@papit/create",A.yellow(n.version),"- running"),A.write();let r=new Set;if(pe.ERROR){await K(e);return}let s=O.join(le.root.location,"bin/runners"),p=["package","component","project","showcase"];try{N(s).forEach(m=>{if(p.includes(m))return;let t=O.join(s,m,"runner.js");ne.existsSync(t)&&(r.add(m),p.push(m))})}catch{}let c=null;for(let a=0;a<p.length;a++)if(D.has(p[a])){c={index:a,text:p[a]};break}switch(c===null&&(A.createSession(),c=await A.option(p),A.clearSession()),c.index){case 0:await te(e);break;case 1:await U(e);break;case 2:await K(e);break;default:{r.has(c.text)||(A.error("requested a runner that doesnt exist"),process.exit(1));let a=O.join(s,c.text,"runner.js");D.verbose&&A.write(`running local runner "${c.text}"`);let{default:m}=await import(a);await m();break}}process.exit()})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papit/create",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npx @papit/build -- --error --ancestors",
|
|
7
7
|
"watch": "tsc -w",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@papit/arguments": "0.0.1",
|
|
52
|
-
"@papit/information": "0.0.
|
|
53
|
-
"@papit/terminal": "0.0.
|
|
52
|
+
"@papit/information": "0.0.4",
|
|
53
|
+
"@papit/terminal": "0.0.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "22.10.2",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
},
|
|
70
70
|
"components": {}
|
|
71
71
|
},
|
|
72
|
-
"remoteVersion": "0.0.
|
|
72
|
+
"remoteVersion": "0.0.5"
|
|
73
73
|
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
@layer theme {
|
|
2
|
-
:root {
|
|
3
|
-
color-scheme: light;
|
|
4
|
-
[data-theme="opposite"], .theme-opposite { color-scheme: dark; }
|
|
5
|
-
|
|
6
|
-
@media (prefers-color-scheme: dark) {
|
|
7
|
-
color-scheme: dark;
|
|
8
|
-
[data-theme="opposite"], .theme-opposite { color-scheme: light; }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* Brand */
|
|
12
|
-
--primary: light-dark(oklch(14% 0 0), oklch(92% 0 0)); /* near black */
|
|
13
|
-
--secondary: light-dark(oklch(80% 0 0), oklch(28% 0 0)); /* near #ccc */
|
|
14
|
-
--tertiary: light-dark(oklch(55% 0 0), oklch(55% 0 0)); /* mid grey */
|
|
15
|
-
|
|
16
|
-
/* Semantic — vivid, same hues in both modes */
|
|
17
|
-
--success: light-dark(oklch(72% 0.22 145), oklch(76% 0.22 145)); /* spring green */
|
|
18
|
-
--info: light-dark(oklch(52% 0.22 262), oklch(58% 0.22 262)); /* deep blue */
|
|
19
|
-
--warning: light-dark(oklch(78% 0.19 68), oklch(82% 0.19 68)); /* orange-yellow */
|
|
20
|
-
--error: light-dark(oklch(53% 0.24 24), oklch(58% 0.24 24)); /* fire red */
|
|
21
|
-
|
|
22
|
-
/* Backgrounds — near white → mid grey */
|
|
23
|
-
--background-lightest: light-dark(oklch(100% 0 0), oklch(32% 0 0));
|
|
24
|
-
--background-lighter: light-dark(oklch(98% 0 0), oklch(24% 0 0));
|
|
25
|
-
--background-light: light-dark(oklch(95% 0 0), oklch(20% 0 0));
|
|
26
|
-
--background: light-dark(oklch(92% 0 0), oklch(16% 0 0));
|
|
27
|
-
--background-dark: light-dark(oklch(86% 0 0), oklch(12% 0 0));
|
|
28
|
-
--background-darker: light-dark(oklch(78% 0 0), oklch(8% 0 0));
|
|
29
|
-
--background-darkest: light-dark(oklch(68% 0 0), oklch(4% 0 0));
|
|
30
|
-
|
|
31
|
-
/* Foregrounds — mid grey → near black */
|
|
32
|
-
--foreground-lightest: light-dark(oklch(52% 0 0), oklch(100% 0 0));
|
|
33
|
-
--foreground-lighter: light-dark(oklch(40% 0 0), oklch(97% 0 0));
|
|
34
|
-
--foreground-light: light-dark(oklch(28% 0 0), oklch(92% 0 0));
|
|
35
|
-
--foreground: light-dark(oklch(16% 0 0), oklch(86% 0 0));
|
|
36
|
-
--foreground-dark: light-dark(oklch(10% 0 0), oklch(74% 0 0));
|
|
37
|
-
--foreground-darker: light-dark(oklch(6% 0 0), oklch(62% 0 0));
|
|
38
|
-
--foreground-darkest: light-dark(oklch(2% 0 0), oklch(48% 0 0));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
[data-theme="light"], .theme-light {
|
|
42
|
-
color-scheme: light;
|
|
43
|
-
[data-theme="opposite"], .theme-opposite { color-scheme: dark; }
|
|
44
|
-
}
|
|
45
|
-
[data-theme="dark"], .theme-dark {
|
|
46
|
-
color-scheme: dark;
|
|
47
|
-
[data-theme="opposite"], .theme-opposite { color-scheme: light; }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/* == UNITS == */
|
|
52
|
-
:root {
|
|
53
|
-
--base-unit: 0.25rem;
|
|
54
|
-
--space-1: calc(var(--base-unit) * 1); /* 0.25rem - 4px */
|
|
55
|
-
--space-2: calc(var(--base-unit) * 2); /* 0.5rem - 8px */
|
|
56
|
-
--space-3: calc(var(--base-unit) * 3); /* 0.75rem - 12px */
|
|
57
|
-
--space-4: calc(var(--base-unit) * 4); /* 1rem - 16px */
|
|
58
|
-
--space-5: calc(var(--base-unit) * 5); /* 1.25rem - 20px */
|
|
59
|
-
--space-6: calc(var(--base-unit) * 6); /* 1.5rem - 24px */
|
|
60
|
-
--space-7: calc(var(--base-unit) * 7); /* 1.75rem - 28px */
|
|
61
|
-
--space-8: calc(var(--base-unit) * 8); /* 2rem - 32px */
|
|
62
|
-
--space-9: calc(var(--base-unit) * 9); /* 2.25rem - 36px */
|
|
63
|
-
--space-10: calc(var(--base-unit) * 10); /* 2.5rem - 40px */
|
|
64
|
-
--space-11: calc(var(--base-unit) * 11); /* 2.75rem - 44px */
|
|
65
|
-
--space-12: calc(var(--base-unit) * 12); /* 3rem - 48px */
|
|
66
|
-
--space-13: calc(var(--base-unit) * 13); /* 3.25rem - 52px */
|
|
67
|
-
--space-14: calc(var(--base-unit) * 14); /* 3.5rem - 56px */
|
|
68
|
-
--space-15: calc(var(--base-unit) * 15); /* 3.75rem - 60px */
|
|
69
|
-
--space-16: calc(var(--base-unit) * 16); /* 4rem - 64px */
|
|
70
|
-
--space-17: calc(var(--base-unit) * 17); /* 4.25rem - 68px */
|
|
71
|
-
--space-18: calc(var(--base-unit) * 18); /* 4.5rem - 72px */
|
|
72
|
-
--space-19: calc(var(--base-unit) * 19); /* 4.75rem - 76px */
|
|
73
|
-
--space-20: calc(var(--base-unit) * 20); /* 5rem - 80px */
|
|
74
|
-
|
|
75
|
-
--radius-small: var(--space-2);
|
|
76
|
-
--radius-medium: var(--space-4);
|
|
77
|
-
--radius-large: var(--space-8);
|
|
78
|
-
--radius-full: 100vh;
|
|
79
|
-
}
|
|
80
|
-
}
|