@papit/create 0.0.10 → 0.0.11
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 +0 -21
- package/asset/component-templates/browser/views/style.css +1 -1
- package/asset/component-templates/game/views/main.js +11 -12
- package/asset/component-templates/web-component/src/component.ts +1 -1
- package/asset/component-templates/web-component/views/style.css +1 -1
- package/asset/package-templates/browser/README.md +1 -9
- package/asset/package-templates/game/README.md +0 -8
- package/asset/package-templates/game/package.json +1 -2
- package/asset/package-templates/node/README.md +0 -8
- package/asset/package-templates/theme/README.md +1 -9
- package/asset/package-templates/web-component/README.md +1 -10
- package/asset/project-template/.vscode/settings.json +6 -1
- package/asset/showcase-templates/global/index.html +33 -0
- package/asset/showcase-templates/global/main.js +24 -0
- package/asset/showcase-templates/global/public/icons/.gitkeep +0 -0
- package/asset/showcase-templates/global/public/images/.gitkeep +0 -0
- package/asset/showcase-templates/global/public/translations/en.json +7 -0
- package/asset/showcase-templates/global/style.css +9 -0
- package/asset/showcase-templates/individual/index.html +35 -0
- package/asset/showcase-templates/individual/main.js +24 -0
- package/asset/showcase-templates/individual/public/icons/.gitkeep +0 -0
- package/asset/showcase-templates/individual/public/images/.gitkeep +0 -0
- package/asset/showcase-templates/individual/public/translations/en.json +7 -0
- package/asset/showcase-templates/individual/style.css +9 -0
- package/lib/bundle.js +3 -3
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -162,20 +162,6 @@ Licensing is handled interactively. You may provide an existing license file or
|
|
|
162
162
|
|
|
163
163
|
---
|
|
164
164
|
|
|
165
|
-
## Contributing
|
|
166
|
-
|
|
167
|
-
Contributions are welcome.
|
|
168
|
-
|
|
169
|
-
Please ensure that:
|
|
170
|
-
|
|
171
|
-
- Templates follow Papit conventions
|
|
172
|
-
- Runners remain deterministic
|
|
173
|
-
- Interactive prompts stay minimal
|
|
174
|
-
|
|
175
|
-
Open a pull request when ready 🚀
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
165
|
## License
|
|
180
166
|
|
|
181
167
|
Licensed under the **@Papit License 1.0**
|
|
@@ -189,10 +175,3 @@ Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
|
189
175
|
- ❌ Cannot resell the component itself as a standalone product
|
|
190
176
|
|
|
191
177
|
See the [LICENSE](https://github.com/onkelhoy/papit/blob/main/LICENSE) file for full details.
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
|
-
## Support
|
|
196
|
-
|
|
197
|
-
For issues, questions, or contributions, please visit the
|
|
198
|
-
[GitHub repository](https://github.com/onkelhoy/papit).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
body {
|
|
4
4
|
background-color: var(--background, light-dark(oklch(96% 0 0), oklch(17% 0 0)));
|
|
5
|
-
color: var(--
|
|
5
|
+
color: contrast-color(var(--background));
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
gap: var(--space-4, 16px);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// core
|
|
2
|
-
import { Engine } from '@papit/game-engine';
|
|
3
|
-
import { InputEvents } from "@papit/game-input-events";
|
|
2
|
+
import { Engine, InputEvents } from '@papit/game-engine';
|
|
4
3
|
|
|
5
4
|
// component
|
|
6
5
|
import 'VARIABLE_FULL_NAME';
|
|
@@ -8,27 +7,27 @@ import 'VARIABLE_FULL_NAME';
|
|
|
8
7
|
let engine, events;
|
|
9
8
|
|
|
10
9
|
window.onload = () => {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
engine = new Engine("canvas");
|
|
11
|
+
events = new InputEvents(engine.canvas, { mouse: { pointerlock: false } });
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
events.on("mouse-up", handlemouseup);
|
|
14
|
+
events.on("mouse-down", handlemousedown);
|
|
15
|
+
events.on("mouse-move", handlemousemove);
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
engine.loop(draw); // cool function
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
function draw() {
|
|
22
|
-
|
|
21
|
+
engine.ctx.clearRect(0, 0, engine.width, engine.height);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
// event handlers
|
|
26
25
|
function handlemousemove(e) {
|
|
27
|
-
|
|
26
|
+
// mouse move
|
|
28
27
|
}
|
|
29
28
|
function handlemousedown(e) {
|
|
30
|
-
|
|
29
|
+
// mouse down
|
|
31
30
|
}
|
|
32
31
|
function handlemouseup(e) {
|
|
33
|
-
|
|
32
|
+
// mouse up
|
|
34
33
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { CustomElement, html, property } from "@papit/web-component";
|
|
4
4
|
|
|
5
5
|
// local
|
|
6
|
-
import sheet from "./style.css"
|
|
6
|
+
import sheet from "./style.css" with { type: "css" };
|
|
7
7
|
import { ClickEvent } from "./types";
|
|
8
8
|
|
|
9
9
|
export class VARIABLE_CLASS_NAME extends CustomElement {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
body {
|
|
4
4
|
background-color: var(--background, light-dark(oklch(96% 0 0), oklch(17% 0 0)));
|
|
5
|
-
color: var(--
|
|
5
|
+
color: contrast-color(var(--background));
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
gap: var(--space-4, 16px);
|
|
@@ -18,10 +18,6 @@ VARIABLE_DESCRIPTION
|
|
|
18
18
|
npm install VARIABLE_FULL_NAME
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Contributing
|
|
22
|
-
|
|
23
|
-
Contributions are welcome! Please follow the development guidelines above and ensure all tests pass before submitting a pull request.
|
|
24
|
-
|
|
25
21
|
## License
|
|
26
22
|
|
|
27
23
|
Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
@@ -37,8 +33,4 @@ See the [LICENSE](https://github.com/onkelhoy/papit/blob/main/LICENSE) file for
|
|
|
37
33
|
|
|
38
34
|
## Related Components
|
|
39
35
|
|
|
40
|
-
- [@papit/web-component](https://github.com/onkelhoy/papit/tree/main/packages/
|
|
41
|
-
|
|
42
|
-
## Support
|
|
43
|
-
|
|
44
|
-
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/onkelhoy/papit).
|
|
36
|
+
- [@papit/web-component](https://github.com/onkelhoy/papit/tree/main/packages/web/engines/web-component): Core utilities, decorators, and base component class
|
|
@@ -18,10 +18,6 @@ VARIABLE_DESCRIPTION
|
|
|
18
18
|
npm install VARIABLE_FULL_NAME
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Contributing
|
|
22
|
-
|
|
23
|
-
Contributions are welcome! Please follow the development guidelines above and ensure all tests pass before submitting a pull request.
|
|
24
|
-
|
|
25
21
|
## License
|
|
26
22
|
|
|
27
23
|
Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
@@ -34,7 +30,3 @@ Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
|
34
30
|
- ❌ Cannot resell the component itself as a standalone product
|
|
35
31
|
|
|
36
32
|
See the [LICENSE](https://github.com/onkelhoy/papit/blob/main/LICENSE) file for full details.
|
|
37
|
-
|
|
38
|
-
## Support
|
|
39
|
-
|
|
40
|
-
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/onkelhoy/papit).
|
|
@@ -18,10 +18,6 @@ VARIABLE_DESCRIPTION
|
|
|
18
18
|
npm install VARIABLE_FULL_NAME
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Contributing
|
|
22
|
-
|
|
23
|
-
Contributions are welcome! Please follow the development guidelines above and ensure all tests pass before submitting a pull request.
|
|
24
|
-
|
|
25
21
|
## License
|
|
26
22
|
|
|
27
23
|
Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
@@ -34,7 +30,3 @@ Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
|
34
30
|
- ❌ Cannot resell the component itself as a standalone product
|
|
35
31
|
|
|
36
32
|
See the [LICENSE](https://github.com/onkelhoy/papit/blob/main/LICENSE) file for full details.
|
|
37
|
-
|
|
38
|
-
## Support
|
|
39
|
-
|
|
40
|
-
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/onkelhoy/papit).
|
|
@@ -18,10 +18,6 @@ VARIABLE_DESCRIPTION
|
|
|
18
18
|
npm install VARIABLE_FULL_NAME
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Contributing
|
|
22
|
-
|
|
23
|
-
Contributions are welcome! Please follow the development guidelines above and ensure all tests pass before submitting a pull request.
|
|
24
|
-
|
|
25
21
|
## License
|
|
26
22
|
|
|
27
23
|
Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
@@ -37,8 +33,4 @@ See the [LICENSE](https://github.com/onkelhoy/papit/blob/main/LICENSE) file for
|
|
|
37
33
|
|
|
38
34
|
## Related Components
|
|
39
35
|
|
|
40
|
-
- [@papit/web-component](https://github.com/onkelhoy/papit/tree/main/packages/
|
|
41
|
-
|
|
42
|
-
## Support
|
|
43
|
-
|
|
44
|
-
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/onkelhoy/papit).
|
|
36
|
+
- [@papit/web-component](https://github.com/onkelhoy/papit/tree/main/packages/web/engines/web-component): Core utilities, decorators, and base component class
|
|
@@ -28,11 +28,6 @@ npm install VARIABLE_FULL_NAME
|
|
|
28
28
|
<VARIABLE_HTML_NAME></VARIABLE_HTML_NAME>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
## Contributing
|
|
33
|
-
|
|
34
|
-
Contributions are welcome! Please follow the development guidelines above and ensure all tests pass before submitting a pull request.
|
|
35
|
-
|
|
36
31
|
## License
|
|
37
32
|
|
|
38
33
|
Licensed under the @Papit License 1.0 - Copyright (c) 2024 Henry Pap (@onkelhoy)
|
|
@@ -48,8 +43,4 @@ See the [LICENSE](https://github.com/onkelhoy/papit/blob/main/LICENSE) file for
|
|
|
48
43
|
|
|
49
44
|
## Related Components
|
|
50
45
|
|
|
51
|
-
- [@papit/web-component](https://github.com/onkelhoy/papit/tree/main/packages/
|
|
52
|
-
|
|
53
|
-
## Support
|
|
54
|
-
|
|
55
|
-
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/onkelhoy/papit).
|
|
46
|
+
- [@papit/web-component](https://github.com/onkelhoy/papit/tree/main/packages/web/engines/web-component): Core utilities, decorators, and base component class
|
|
@@ -15,5 +15,10 @@
|
|
|
15
15
|
"typescript.format.placeOpenBraceOnNewLineForFunctions": false,
|
|
16
16
|
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
|
|
17
17
|
"javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
|
|
18
|
-
"files.associations": {
|
|
18
|
+
"files.associations": {
|
|
19
|
+
"*.json": "jsonc"
|
|
20
|
+
},
|
|
21
|
+
"lit-plugin.rules": {
|
|
22
|
+
"no-incompatible-type-binding": "off"
|
|
23
|
+
}
|
|
19
24
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
+
<title>VARIABLE_TITLE</title>
|
|
9
|
+
|
|
10
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
11
|
+
|
|
12
|
+
<!-- Styles -->
|
|
13
|
+
<link rel="stylesheet" href="style.css" />
|
|
14
|
+
|
|
15
|
+
<script defer type="module" src="main.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
<pap-sidebar>
|
|
20
|
+
<h2 slot="header">Showcase</h2>
|
|
21
|
+
VARIABLE_SIDEBAR_CONTENT
|
|
22
|
+
</pap-sidebar>
|
|
23
|
+
|
|
24
|
+
<pap-router>
|
|
25
|
+
VARIABLE_ROUTER_PATHS
|
|
26
|
+
</pap-router>
|
|
27
|
+
|
|
28
|
+
<footer>
|
|
29
|
+
Footer
|
|
30
|
+
</footer>
|
|
31
|
+
</body>
|
|
32
|
+
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// core
|
|
2
|
+
import { translator } from '@papit/translator';
|
|
3
|
+
import "@papit/codeblock";
|
|
4
|
+
import "@papit/tabs";
|
|
5
|
+
import "@papit/router";
|
|
6
|
+
|
|
7
|
+
// component
|
|
8
|
+
import 'VARIABLE_NAME';
|
|
9
|
+
|
|
10
|
+
window.onload = () => {
|
|
11
|
+
console.log('[demo]: window loaded');
|
|
12
|
+
|
|
13
|
+
translator.add({ id: "en", url: "/en.json" });
|
|
14
|
+
translator.change("en");
|
|
15
|
+
|
|
16
|
+
const tabs = document.querySelector("pap-tabs.individual-showcase");
|
|
17
|
+
const router = document.querySelector("pap-router.individual-showcase");
|
|
18
|
+
|
|
19
|
+
tabs.addEventListener("change", e => {
|
|
20
|
+
console.log(tabs, e.target.value);
|
|
21
|
+
router.url = e.target.value;
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
8
|
+
<title>VARIABLE_CLASS_NAME</title>
|
|
9
|
+
|
|
10
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
11
|
+
|
|
12
|
+
<!-- Styles -->
|
|
13
|
+
<link rel="stylesheet" href="style.css" />
|
|
14
|
+
|
|
15
|
+
<script defer type="module" src="main.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
<article>
|
|
20
|
+
<pap-tabs class="individual-showcase" value="VARIABLE_SELECTED_TAB">
|
|
21
|
+
|
|
22
|
+
<header>
|
|
23
|
+
<h1>VARIABLE_CLASS_NAME</h1>
|
|
24
|
+
|
|
25
|
+
VARIABLE_TABS_TAB
|
|
26
|
+
</header>
|
|
27
|
+
|
|
28
|
+
<pap-router class="individual-showcase">
|
|
29
|
+
VARIABLE_TABS_CONTENT
|
|
30
|
+
</pap-router>
|
|
31
|
+
</pap-tabs>
|
|
32
|
+
</article>
|
|
33
|
+
</body>
|
|
34
|
+
|
|
35
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// core
|
|
2
|
+
import { translator } from '@papit/translator';
|
|
3
|
+
import "@papit/codeblock";
|
|
4
|
+
import "@papit/tabs";
|
|
5
|
+
import "@papit/router";
|
|
6
|
+
|
|
7
|
+
// component
|
|
8
|
+
import 'VARIABLE_NAME';
|
|
9
|
+
|
|
10
|
+
window.onload = () => {
|
|
11
|
+
console.log('[demo]: window loaded');
|
|
12
|
+
|
|
13
|
+
translator.add({ id: "en", url: "/en.json" });
|
|
14
|
+
translator.change("en");
|
|
15
|
+
|
|
16
|
+
const tabs = document.querySelector("pap-tabs.individual-showcase");
|
|
17
|
+
const router = document.querySelector("pap-router.individual-showcase");
|
|
18
|
+
|
|
19
|
+
tabs.addEventListener("change", e => {
|
|
20
|
+
console.log(tabs, e.target.value);
|
|
21
|
+
router.url = e.target.value;
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
File without changes
|
|
File without changes
|
package/lib/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
`)}import
|
|
4
|
-
`),
|
|
2
|
+
import G from"node:path";import se from"node:fs";import{Arguments as K}from"@papit/arguments";import{Information as ye,PackageGraph as he}from"@papit/information";import{Terminal as E}from"@papit/terminal";import k from"node:path";import U from"node:fs";import{Terminal as i}from"@papit/terminal";import{Information as P,PackageGraph as ie}from"@papit/information";import{Arguments as x}from"@papit/arguments";import v from"node:path";import C from"node:fs";import{Information as b}from"@papit/information";import{Terminal as d}from"@papit/terminal";import{Arguments as T}from"@papit/arguments";import{Arguments as ce}from"@papit/arguments";import{Information as X,PackageGraph as pe}from"@papit/information";import{Terminal as N}from"@papit/terminal";import L from"node:fs";import I from"node:path";function _(e){return L.readdirSync(e).filter(n=>L.statSync(I.join(e,n)).isDirectory())}function le(e){return L.readdirSync(e).filter(n=>{let a=I.join(e,n);return!(!L.statSync(a).isDirectory()||pe.search(a))})}async function te(){return N.sessionBlock(async()=>{let e=I.join(X.root.location,"packages"),n=e;for(;e;){let a=N.createSession(),o=le(e);N.write("Current: ",e.replace(X.root.location,X.scope)),N.write();let p=await N.option([["Choose Folder","Create Folder"],e===n?o:["..",...o]]);if(p.index===0)break;if(p.index===1){let s=await N.prompt("folder name",!1,e),r=I.join(e,s.input);await me(r)&&(e=I.join(e,s.input))}else p.index===2&&e!==n?e=I.resolve(e,".."):e=I.join(e,o[p.index-(e===n?2:3)]);N.clearSession(a)}return e})}async function me(e){return N.createSession(),N.write(`[${e}]`),ce.has("agree")||await N.confirm("confirm folder creation",!0)?(L.mkdirSync(e,{recursive:!0}),N.clearSession(),!0):!1}async function F(e,n,a){L.mkdirSync(n,{recursive:!0});let o=L.readdirSync(e,{withFileTypes:!0});for(let p of o){let s=I.join(e,p.name),r=I.join(n,p.name);if(p.isDirectory()){await F(s,r,a);continue}if(typeof a!="function"){L.copyFileSync(s,r);continue}let f=L.readFileSync(s,"utf-8"),t=await a(f,s,r);t!==!1&&(L.copyFileSync(s,r),L.writeFileSync(r,t,"utf-8"))}}function $(e){if(!e)return;let n=e.split(/[ |-]/),a=n.join("-");return{className:ne(n.map(ne).join("")),name:a.toLowerCase()}}function ne(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}function fe(e){try{return C.readdirSync(e).length>0}catch{return!1}}function ue(e){C.existsSync(e)&&C.statSync(e).isDirectory()||C.mkdirSync(e)}async function W(e,n,a){let o=v.join(n?.destination??b.package.location,"package.json"),p=n?JSON.parse(C.readFileSync(o,{encoding:"utf-8"})):b.package.packageJSON;p==null&&(d.error("could not find package's package.json file"),process.exit(1)),p.name===b.root.name&&(d.error("cannot create a component to root"),process.exit(1));let s=p,r=_(v.join(e,"asset/component-templates")),f=new Set;try{_(v.join(b.root.location,"bin/runners/component")).forEach(m=>{r.push(m),f.add(m)})}catch{}let t={index:r.findIndex(m=>m===s.papit?.type),text:""};if(t.text=r[t.index],t.index<0){let m=T.string("package")??T.string("type");t.index=r.findIndex(u=>u===m),t.index<0&&(d.createSession(),d.write("type of component"),t=await d.option(r),d.clearSession())}let w=T.string("html-prefix")??n?.htmlprefix??b.package.packageJSON.papit.htmlprefix??b.root.packageJSON.papit.htmlprefix;if(w?.trim()===""&&(w=void 0),w===void 0&&/web-components?/i.test(t.text)){let m=d.createSession();for(;;){let u;if(w!==void 0?(u=(await d.prompt(`use default "${w}" or override?`)).input,u||(u=w)):u=(await d.prompt("html prefix",!0)).input,u){w=u;break}else d.clearSession(),d.write("you must use a html-prefix for web-components")}d.clearSession(m)}let y=n?.nameInfo;for(;!y;){d.clearSession();let m=T.string("name");if(m||(m=(await d.prompt("(component) name",!0)).input),y=$(m),!y){d.write("name missing, try again");continue}if(s.papit.components[y.name]){d.write("name already exist, try again");continue}break}d.createSession();let R=n?.shouldCommit??T.true("agree")??T.true("commit")??await d.confirm("git commit",!0);d.clearSession();let V=f.has(t.text)?v.join(b.root.location,"bin","runners","component",t.text):v.join(e,"asset","component-templates",t.text),h=_(V);s.papit.components[y.name]={className:y.className,htmlprefix:w},C.writeFileSync(o,JSON.stringify(s,null,2),{encoding:"utf-8"}),R&&await d.execute(`git add ${o}`,b.root.location);for(let m of h){let u=v.join(n?.destination??b.package.location,m),g=u,S=v.join(V,m);if(m==="src"?fe(u)&&(u=v.join(u,"components"),g=v.join(u,y.name)):g=v.join(u,y.name),ue(u),a&&(g=a(g,m)),await F(S,g,M=>M.replace(/VARIABLE_NAME/g,y.name).replace(/VARIABLE_FULL_NAME/g,s.name).replace(/VARIABLE_HTML_NAME/g,`${w}-${y.name}`).replace(/VARIABLE_CLASS_NAME/g,y.className)),R)try{await d.execute(`git add ${g}`,b.root.location)}catch{d.warn(`"git add ${g}" failed`)}}!n?.shouldCommit&&R&&await d.execute(`git commit -m "add: ${y.name} component"`,b.root.location)}async function oe(e){let n=i.createSession(),a=P.root.packageJSON;a===null&&(i.error("root package.json not found"),process.exit(1));let o=await te(),p=_(k.join(e,"asset","package-templates")),s=new Set;try{_(k.join(P.root.location,"bin","runners","package")).forEach(c=>{U.existsSync(k.join(P.root.location,"bin","runners","package",c,"package.json"))&&(p.push(c),s.add(c))})}catch{}let r=x.string("package")??x.string("type"),f={index:p.findIndex(c=>c===r),text:""};f.text=p[f.index],f.index<0&&(i.write("type of package"),f=await i.option(p)),i.clearSession();let t=x.string("html-prefix");if(t?.trim()===""&&(t=void 0),!t&&/web-components?/i.test(f.text)){for(t||(t=a.papit?.htmlprefix),x.info||i.createSession();;){let c;if(t?(c=(await i.prompt(`use default "${t}" or override?`)).input,c||(c=t)):(c=(await i.prompt("html prefix",!0)).input,a.papit?.htmlprefix||await i.confirm(`you wish to set "${c}" as the default html-prefix?`)&&(a.papit.htmlprefix=c,U.writeFileSync(k.join(P.root.location,"package.json"),JSON.stringify(a,null,2),{encoding:"utf-8"}))),c){t=c;break}else x.info||i.clearSession(),i.warn("you must use a html-prefix for web-components")}x.info||i.clearSession()}let w=k.relative(P.root.location,o),y=k.basename(o);a.repository?.url||i.warn("root package.json does not have 'repository.url'");let R=(a.repository?.url??"").replace(/\.git$/,"").replace(/^git\+/,""),V=k.join(P.root.location,"package-lock.json");i.clearSession(n);let h,m;for(;m===void 0||h===void 0;){i.clearSession();let c=x.string("name");if(c||(c=(await i.prompt("(package) name",!0)).input),h=$(c),!h){i.write("name missing, try again");continue}let j=`${P.scope}/${h.name}`;ie.get(j)?i.write("package already exists, try again"):m=j}let u=x.string("description");u||(u=(await i.prompt("description",!0)).input),i.write(),i.createSession();let g=k.join(o,h.name),S=c=>c.replace(/\\/g,"/"),M=s.has(f.text)?k.join(P.root.location,"bin","runners","package",f.text):k.join(e,"asset","package-templates",f.text);await F(M,g,async(c,j)=>j.endsWith(".gitkeep")?!1:c.replace(/VARIABLE_NAME/g,h.name).replace(/VARIABLE_FULL_NAME/g,m).replace(/VARIABLE_DESCRIPTION/g,u).replace(/VARIABLE_LAYER_FOLDER/g,y).replace(/VARIABLE_PROJECTLICENSE/g,a.license||"MIT").replace(/VARIABLE_GITHUB_REPO/g,R).replace(/VARIABLE_LOCAL_DESTINATION/g,S(k.join(w,h.name))).replace(/VARIABLE_CLASS_NAME/g,h.className).replace(/VARIABLE_HTML_PREFIX/g,t??"").replace(/VARIABLE_HTML_NAME/g,`${t}-${h.name}`).replace(/VARIABLE_USER/g,process.env.USER??"anonymous"));let B=JSON.parse(U.readFileSync(k.join(g,"package.json"),{encoding:"utf-8"}));B||(i.error(`package.json not found at "${g}"`),process.exit(1)),B.papit||(B.papit={main:h.name,components:{},publish:!0,type:f.text}),ie.add(g),i.createSession();let J=!1;x.has("no")?J=!1:x.has("yes")?J=!0:J=x.true("agree")||x.true("commit")||await i.confirm("git commit",!0),i.clearSession(),await W(e,{destination:g,nameInfo:h,htmlprefix:t,shouldCommit:J},(c,j)=>(j==="src"&&(c=c.replace(/[/\\]components[/\\].*/,"")),j==="lib"&&(c=c.replace(new RegExp(h.name+"$"),"")),j==="views"&&(c=c.replace(new RegExp(h.name+"$"),"experiment")),x.debug&&i.info(JSON.stringify({dest:c,folder:j})),c));let Z=k.join(g,"src","components");U.existsSync(Z)&&U.rmdirSync(Z),i.createSession();let z=!1;if(x.has("no")?z=!1:x.has("yes")?z=!0:z=x.true("agree")||x.true("install")||await i.confirm("install package",!0),z){let{close:c}=i.loading("installing");try{await i.execute("npm install",u)}catch(j){i.warn("error during install"),console.log(j),i.createSession()}finally{c(),i.clearSession()}}else i.clearSession();if(J)try{await i.execute(`git add ${V}`,g),await i.execute(`git add ${g}`,g),await i.execute(`git commit -m "add: ${m} package"`,g)}catch{i.warn("error during commit")}i.write(i.yellow(k.relative(P.root.location,g))),i.write(`${m} created
|
|
3
|
+
`)}import ae from"node:path";import Y from"node:fs";import{Arguments as D}from"@papit/arguments";import{Terminal as l}from"@papit/terminal";async function Q(e){l.write(`Project Creation
|
|
4
|
+
`),l.createSession();let n=D.string("name");n===void 0&&(n=(await l.prompt("name",!0)).input);let a=D.string("description");a===void 0&&(a=(await l.prompt("description",!0)).input);let o=D.string("location");if(o===void 0){let t=await l.prompt(process.cwd(),!0,process.cwd());o=ae.join(t.path,n)}l.write(),l.createSession(),await l.sessionBlock(async()=>{if(!Y.existsSync(o))return;await l.confirm(`confirm to remove it [${o}]`)?Y.rmSync(o,{recursive:!0,force:!0}):(l.error("must choose a empty location"),process.exit(1))}),await l.confirm(`confirm location [${l.yellow(o)}]`,!0)||(l.warn("abort"),process.exit(0)),Y.mkdirSync(o,{recursive:!0}),l.clearSession(),l.write();let s=D.string("license")??"MIT";s===void 0&&(s=(await l.prompt("license (default MIT)")).input),l.clearSession();let r=!D.has("skip-git");if(r){let{close:t,update:w}=l.loading("git init",3e3,y=>{y>400?w("runnign slow"):y>800?w("something seems wrong"):y>1500&&w("yeah somethign is very wrong")});await l.execute("git init",{cwd:o}),l.clearSession(),t()}await F(ae.join(e,"asset/project-template"),o,async(t,w)=>w.endsWith(".gitkeep")?!1:t.replace(/VARIABLE_NAME/g,`@${n}/root`).replace(/VARIABLE_DESCRIPTION/g,a).replace(/VARIABLE_PROJECTLICENSE/g,s||"MIT").replace(/VARIABLE_USER/g,process.env.USER??"anonymous")),r&&(await l.execute("git add .",{cwd:o}),await l.execute(`git commit -m "init: ${n} initialized"`,{cwd:o}));let{close:f}=l.loading("installing",2e4);await l.execute("npm install",{cwd:o}),f(),l.clearSession(),l.write(),l.write("project initialized"),l.write("try it:"),l.write(" (1)",l.yellow(`cd ${o}`)),l.write(" (2)",l.yellow("npm start")),process.exit(0)}import q from"node:fs";import A from"node:path";import{meta as ge}from"@papit/server";import{Arguments as O}from"@papit/arguments";import{Information as H}from"@papit/information";async function re(e){let{importmap:n}=await ge(),a=A.join(e,"asset","showcase-templates"),o=O.string("output");o&&q.existsSync(o)||O.debug&&console.log("no output argument provided");let p=we(["web-component","game","theme"]),s=new Map,r=[];for(let f of p)for(let t of f){let w=A.relative(A.join(H.root.location,"packages"),t.location),y=A.dirname(w);s.set(y,(s.get(y)??[]).concat([t]));let R=O.get("view-filter")??["showcase","raw","experiment"];try{let h=A.join(t.location,"views"),m=q.readdirSync(h).map(S=>A.join(h,S)).filter(S=>q.statSync(S).isDirectory()&&q.existsSync(A.join(S,"index.html"))&&R.includes(A.basename(S))).map(S=>A.basename(S)).sort((S,M)=>(R.findIndex(B=>B===S)??R.length)-(R.findIndex(B=>B===M)??R.length)),u=m.at(0);u!=="showcase"&&(O.debug&&console.log("no showcase view folder, showcase view generated"),await de(t,m,a));let g={realpath:A.join(w,"views/:view"),path:A.join(w,":view"),view:u?A.join(w,"views",u):""};for(let S=1;S<m.length;S++)g[`fallback-view${S!==1?S:""}`]=m[S];r.push()}catch{}let V=[]}}async function de(e,n,a){let o=$(e.name.replace(H.scope+"/",""))??{name:e.name,className:e.name},p=O.string("html-prefix")??e.packageJSON.papit.htmlprefix??H.root.packageJSON.papit.htmlprefix;await F(A.join(a,"individual"),A.join(e.location,"views/showcase"),s=>s.replace(/VARIABLE_NAME/g,e.name).replace(/VARIABLE_HTML_NAME/g,`${p}-${o.name}`).replace(/VARIABLE_CLASS_NAME/g,o.className).replace(/VARIABLE_TABS_TAB/g,'<pap-tab slot="tab" value="showcase">showcase</pap-tab>'+n.map(r=>`<pap-tab slot="tab" value="${r}">${r}</pap-tab>`).join(" ")).replace(/VARIABLE_TABS_CONTENT/g,['<pap-tabpanel value="showcase" path=":view" view="showcase" realpath="views/:view"></pap-tabpanel>',n.map(r=>`<pap-tabpanel value="${r}" path=":view" view="${r}" realpath="views/:view"></pap-tabpanel>`).join(" ")].join(" ")).replace(/VARIABLE_SELECTED_TAB/g,"showcase"))}function we(e){return H.getPriorityBatches(O.instance,n=>n.name.startsWith(H.scope)).map(n=>n.filter(a=>{if(a.packageJSON.papit.skip)return!1;if(typeof a.packageJSON.papit.type=="string"){if(!e.includes(a.packageJSON.papit.type))return!1}else{let o=a.packageJSON.papit.type,p=!1;for(let s in o)if(e.includes(o[s])){p=!0;break}if(!p)return!1}return!0}))}(async function(){K.init(process.argv,["install","commit","agree"]),K.verbose&&(process.env.verbose="true");let e=G.dirname(import.meta.dirname),n=JSON.parse(se.readFileSync(G.join(e,"package.json"),{encoding:"utf-8"}));if(n||(E.error("could not find @papit/create package.json"),process.exit(1)),!process.env.USER){E.createSession();let r=await E.prompt("your name",!0);process.env.USER=r.input,E.clearSession()}E.write(),E.write("@papit/create",E.yellow(n.version),"- running"),E.write();let a=new Set;if(he.ERROR){await Q(e);return}let o=G.join(ye.root.location,"bin/runners"),p=["package","component","project","showcase"];try{_(o).forEach(f=>{if(p.includes(f))return;let t=G.join(o,f,"runner.js");se.existsSync(t)&&(a.add(f),p.push(f))})}catch{}let s=null;for(let r=0;r<p.length;r++)if(K.has(p[r])){s={index:r,text:p[r]};break}switch(s===null&&(E.createSession(),s=await E.option(p),E.clearSession()),s.index){case 0:await oe(e);break;case 1:await W(e);break;case 2:await Q(e);break;case 3:await re(e);break;default:{a.has(s.text)||(E.error("requested a runner that doesnt exist"),process.exit(1));let r=G.join(o,s.text,"runner.js");K.verbose&&E.write(`running local runner "${s.text}"`);let{default:f}=await import(r);await f();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.11",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npx @papit/build -- --error --ancestors",
|
|
7
7
|
"watch": "tsc -w",
|
|
@@ -49,7 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@papit/arguments": "0.0.1",
|
|
52
|
-
"@papit/information": "0.0.
|
|
52
|
+
"@papit/information": "0.0.8",
|
|
53
|
+
"@papit/server": "1.0.7",
|
|
53
54
|
"@papit/terminal": "0.0.2"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
@@ -69,5 +70,5 @@
|
|
|
69
70
|
},
|
|
70
71
|
"components": {}
|
|
71
72
|
},
|
|
72
|
-
"remoteVersion": "0.0.
|
|
73
|
+
"remoteVersion": "0.0.10"
|
|
73
74
|
}
|