@papit/create 0.0.1

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.
Files changed (141) hide show
  1. package/README.md +198 -0
  2. package/asset/component-templates/browser/src/component.ts +7 -0
  3. package/asset/component-templates/browser/src/index.ts +3 -0
  4. package/asset/component-templates/browser/src/types.ts +1 -0
  5. package/asset/component-templates/browser/tests/index.html +15 -0
  6. package/asset/component-templates/browser/tests/main.js +1 -0
  7. package/asset/component-templates/browser/tests/public/icons/.gitkeep +0 -0
  8. package/asset/component-templates/browser/tests/public/images/.gitkeep +0 -0
  9. package/asset/component-templates/browser/tests/public/translations/en.json +7 -0
  10. package/asset/component-templates/browser/tests/snapshot.test.ts +12 -0
  11. package/asset/component-templates/browser/tests/unit.test.ts +69 -0
  12. package/asset/component-templates/browser/views/index.html +29 -0
  13. package/asset/component-templates/browser/views/main.js +13 -0
  14. package/asset/component-templates/browser/views/public/icons/.gitkeep +0 -0
  15. package/asset/component-templates/browser/views/public/images/.gitkeep +0 -0
  16. package/asset/component-templates/browser/views/public/translations/en.json +7 -0
  17. package/asset/component-templates/browser/views/style.css +28 -0
  18. package/asset/component-templates/game/src/component.ts +7 -0
  19. package/asset/component-templates/game/src/index.ts +3 -0
  20. package/asset/component-templates/game/src/types.ts +1 -0
  21. package/asset/component-templates/game/tests/index.html +15 -0
  22. package/asset/component-templates/game/tests/main.js +34 -0
  23. package/asset/component-templates/game/tests/public/models/.gitkeep +0 -0
  24. package/asset/component-templates/game/tests/public/textures/.gitkeep +0 -0
  25. package/asset/component-templates/game/tests/public/translations/en.json +7 -0
  26. package/asset/component-templates/game/tests/snapshot.test.ts +12 -0
  27. package/asset/component-templates/game/tests/unit.test.ts +18 -0
  28. package/asset/component-templates/game/views/index.html +22 -0
  29. package/asset/component-templates/game/views/main.js +34 -0
  30. package/asset/component-templates/game/views/public/models/.gitkeep +0 -0
  31. package/asset/component-templates/game/views/public/textures/.gitkeep +0 -0
  32. package/asset/component-templates/game/views/public/translations/en.json +7 -0
  33. package/asset/component-templates/game/views/style.css +9 -0
  34. package/asset/component-templates/node/src/component.ts +7 -0
  35. package/asset/component-templates/node/src/index.ts +3 -0
  36. package/asset/component-templates/node/src/types.ts +1 -0
  37. package/asset/component-templates/node/tests/unit.test.js +10 -0
  38. package/asset/component-templates/theme/lib/theme.css +80 -0
  39. package/asset/component-templates/theme/src/theme.css +205 -0
  40. package/asset/component-templates/theme/tests/index.html +15 -0
  41. package/asset/component-templates/theme/tests/main.js +1 -0
  42. package/asset/component-templates/theme/tests/public/icons/.gitkeep +0 -0
  43. package/asset/component-templates/theme/tests/public/images/.gitkeep +0 -0
  44. package/asset/component-templates/theme/tests/public/translations/en.json +7 -0
  45. package/asset/component-templates/theme/tests/snapshot.test.ts +12 -0
  46. package/asset/component-templates/theme/tests/unit.test.ts +67 -0
  47. package/asset/component-templates/theme/views/index.html +110 -0
  48. package/asset/component-templates/theme/views/main.js +14 -0
  49. package/asset/component-templates/theme/views/style.css +241 -0
  50. package/asset/component-templates/web-component/src/component.ts +31 -0
  51. package/asset/component-templates/web-component/src/index.ts +15 -0
  52. package/asset/component-templates/web-component/src/style.css +4 -0
  53. package/asset/component-templates/web-component/src/types.ts +1 -0
  54. package/asset/component-templates/web-component/tests/index.html +17 -0
  55. package/asset/component-templates/web-component/tests/main.js +1 -0
  56. package/asset/component-templates/web-component/tests/public/icons/.gitkeep +0 -0
  57. package/asset/component-templates/web-component/tests/public/images/.gitkeep +0 -0
  58. package/asset/component-templates/web-component/tests/public/translations/en.json +7 -0
  59. package/asset/component-templates/web-component/tests/snapshot.test.ts +12 -0
  60. package/asset/component-templates/web-component/tests/unit.test.ts +69 -0
  61. package/asset/component-templates/web-component/views/index.html +28 -0
  62. package/asset/component-templates/web-component/views/main.js +14 -0
  63. package/asset/component-templates/web-component/views/public/icons/.gitkeep +0 -0
  64. package/asset/component-templates/web-component/views/public/images/.gitkeep +0 -0
  65. package/asset/component-templates/web-component/views/public/translations/en.json +7 -0
  66. package/asset/component-templates/web-component/views/style.css +28 -0
  67. package/asset/package-templates/browser/README.md +44 -0
  68. package/asset/package-templates/browser/asset/icons/.gitkeep +0 -0
  69. package/asset/package-templates/browser/asset/images/.gitkeep +0 -0
  70. package/asset/package-templates/browser/asset/translations/en.json +7 -0
  71. package/asset/package-templates/browser/package.json +76 -0
  72. package/asset/package-templates/browser/src/.gitkeep +0 -0
  73. package/asset/package-templates/browser/tests/playwright.config.ts +81 -0
  74. package/asset/package-templates/browser/tests/tsconfig.json +9 -0
  75. package/asset/package-templates/browser/tsconfig.json +41 -0
  76. package/asset/package-templates/browser/tsconfig.prod.json +9 -0
  77. package/asset/package-templates/game/README.md +40 -0
  78. package/asset/package-templates/game/asset/models/.gitkeep +0 -0
  79. package/asset/package-templates/game/asset/textures/.gitkeep +0 -0
  80. package/asset/package-templates/game/asset/translations/en.json +7 -0
  81. package/asset/package-templates/game/package.json +78 -0
  82. package/asset/package-templates/game/src/.gitkeep +0 -0
  83. package/asset/package-templates/game/tests/playwright.config.ts +80 -0
  84. package/asset/package-templates/game/tests/tsconfig.json +9 -0
  85. package/asset/package-templates/game/tsconfig.json +41 -0
  86. package/asset/package-templates/game/tsconfig.prod.json +9 -0
  87. package/asset/package-templates/game/views/.gitkeep +0 -0
  88. package/asset/package-templates/game/views/tsconfig.json +9 -0
  89. package/asset/package-templates/node/README.md +40 -0
  90. package/asset/package-templates/node/asset/translations/en.json +7 -0
  91. package/asset/package-templates/node/package.json +70 -0
  92. package/asset/package-templates/node/src/.gitkeep +0 -0
  93. package/asset/package-templates/node/tests/.gitkeep +0 -0
  94. package/asset/package-templates/node/tests/tsconfig.json +9 -0
  95. package/asset/package-templates/node/tsconfig.json +38 -0
  96. package/asset/package-templates/node/tsconfig.prod.json +9 -0
  97. package/asset/package-templates/theme/README.md +44 -0
  98. package/asset/package-templates/theme/asset/icons/.gitkeep +0 -0
  99. package/asset/package-templates/theme/asset/images/.gitkeep +0 -0
  100. package/asset/package-templates/theme/asset/translations/en.json +7 -0
  101. package/asset/package-templates/theme/package.json +70 -0
  102. package/asset/package-templates/theme/tests/playwright.config.ts +81 -0
  103. package/asset/package-templates/theme/tsconfig.json +39 -0
  104. package/asset/package-templates/theme/tsconfig.prod.json +9 -0
  105. package/asset/package-templates/web-component/README.md +55 -0
  106. package/asset/package-templates/web-component/asset/icons/.gitkeep +0 -0
  107. package/asset/package-templates/web-component/asset/images/.gitkeep +0 -0
  108. package/asset/package-templates/web-component/asset/translations/en.json +7 -0
  109. package/asset/package-templates/web-component/package.json +79 -0
  110. package/asset/package-templates/web-component/src/global-css.d.ts +4 -0
  111. package/asset/package-templates/web-component/tests/playwright.config.ts +81 -0
  112. package/asset/package-templates/web-component/tests/tsconfig.json +9 -0
  113. package/asset/package-templates/web-component/tsconfig.json +42 -0
  114. package/asset/package-templates/web-component/tsconfig.prod.json +9 -0
  115. package/asset/package-templates/web-component/views/.gitkeep +0 -0
  116. package/asset/package-templates/web-component/views/tsconfig.json +9 -0
  117. package/asset/project-template/.eslintrc +26 -0
  118. package/asset/project-template/.gitattributes +1 -0
  119. package/asset/project-template/.github/ISSUE_TEMPLATE/CONTRIBUTING.md +101 -0
  120. package/asset/project-template/.github/workflows/build-cache.yml +30 -0
  121. package/asset/project-template/.github/workflows/initialise.yml +49 -0
  122. package/asset/project-template/.github/workflows/publish.yml +59 -0
  123. package/asset/project-template/.github/workflows/pull-request.yml +73 -0
  124. package/asset/project-template/.github/workflows/update-snapshots.yml +80 -0
  125. package/asset/project-template/.nvmrc +1 -0
  126. package/asset/project-template/.vscode/settings.json +19 -0
  127. package/asset/project-template/.vscode/web-components.code-workspace +25 -0
  128. package/asset/project-template/README.md +45 -0
  129. package/asset/project-template/bin/clean.mjs +28 -0
  130. package/asset/project-template/bin/runners/example-runner/runner.js +4 -0
  131. package/asset/project-template/bin/spawn-command.mjs +31 -0
  132. package/asset/project-template/bin/test.mjs +94 -0
  133. package/asset/project-template/package.json +42 -0
  134. package/asset/project-template/packages/atoms/.gitkeep +0 -0
  135. package/asset/project-template/packages/molecules/.gitkeep +0 -0
  136. package/asset/project-template/packages/organisms/.gitkeep +0 -0
  137. package/asset/project-template/packages/pages/.gitkeep +0 -0
  138. package/asset/project-template/packages/templates/.gitkeep +0 -0
  139. package/lib/bundle.d.ts +1 -0
  140. package/lib/bundle.js +4 -0
  141. package/package.json +72 -0
@@ -0,0 +1,30 @@
1
+ name: Update Cache
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ playwright-cache:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v4
11
+
12
+ # setup node
13
+ - name: Setup Node.js environment
14
+ uses: actions/setup-node@v4
15
+ with:
16
+ node-version-file: .nvmrc
17
+
18
+ # caching: package builds
19
+ - name: Cache Playwright binaries
20
+ uses: actions/cache@v4
21
+ id: playwright-cache
22
+ with:
23
+ path: ~/.cache/ms-playwright
24
+ key: ${{ runner.os }}-playwright
25
+ restore-keys: ${{ runner.os }}-playwright
26
+
27
+ # this should still respect the cached binary files for playwright but also just "install" them
28
+ - name: Installing Playwright
29
+ run: npx playwright install --with-deps
30
+
@@ -0,0 +1,49 @@
1
+ name: Initialise Packages
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ force_build:
7
+ description: 'Force build?'
8
+ required: false
9
+ default: false
10
+ type: boolean
11
+
12
+ jobs:
13
+ build:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ # setup node
19
+ - name: Setup Node.js environment
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version-file: .nvmrc
23
+
24
+ # caching: node_modules
25
+ - name: Cache node modules
26
+ uses: actions/cache@v4
27
+ with:
28
+ path: 'node_modules'
29
+ key: ${{ runner.os }}-modules
30
+ restore-keys: ${{ runner.os }}-modules
31
+
32
+ # caching: package builds
33
+ - name: Cache build artifacts
34
+ uses: actions/cache@v4
35
+ with:
36
+ path: packages/**/lib
37
+ key: ${{ runner.os }}-build
38
+ restore-keys: ${{ runner.os }}-build
39
+
40
+ # Building and Installing packages
41
+ - name: Build & Install Packages
42
+ id: build-and-install
43
+ env:
44
+ CI: true
45
+ FORCE: ${{ inputs.force_build || false }}
46
+ run: npm run build -- --packages --verbose
47
+
48
+ # install packages to make sure they are propperly added to node_modules
49
+ - run: npm ci
@@ -0,0 +1,59 @@
1
+ name: Publish Packages to npmjs
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch: # Allows manual triggering
7
+ inputs:
8
+ force_build:
9
+ description: 'Force build?'
10
+ required: false
11
+ default: false
12
+ type: boolean
13
+
14
+ permissions:
15
+ id-token: write # Required for OIDC
16
+ contents: read
17
+
18
+ jobs:
19
+ initialise:
20
+ uses: ./.github/workflows/initialise.yml
21
+ with:
22
+ force_build: ${{ github.event.inputs.force_build || false }}
23
+
24
+ publish:
25
+ runs-on: ubuntu-latest
26
+ needs: initialise
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ # setup node
31
+ - name: Setup Node.js environment
32
+ uses: actions/setup-node@v4
33
+ with:
34
+ node-version-file: .nvmrc
35
+ registry-url: 'https://registry.npmjs.org'
36
+ always-auth: true
37
+
38
+ # caching: node_modules
39
+ - name: Cache node modules
40
+ uses: actions/cache@v4
41
+ with:
42
+ path: 'node_modules'
43
+ key: ${{ runner.os }}-modules
44
+ restore-keys: ${{ runner.os }}-modules
45
+
46
+ # caching: package builds
47
+ - name: Cache build artifacts
48
+ uses: actions/cache@v4
49
+ with:
50
+ path: packages/**/lib
51
+ key: ${{ runner.os }}-build
52
+ restore-keys: ${{ runner.os }}-build
53
+
54
+ # Publish to npm
55
+ - name: Publish to npmjs.com
56
+ run: npm run publish -- --ci --verbose
57
+ env:
58
+ CI: true
59
+
@@ -0,0 +1,73 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ main, master ]
6
+
7
+ jobs:
8
+ initialise:
9
+ if: "!contains(github.event.pull_request.title, 'wip:')"
10
+ uses: ./.github/workflows/initialise.yml
11
+ with:
12
+ force_build: ${{ github.event.inputs.force_build || false }}
13
+
14
+ test:
15
+ needs: initialise
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ # setup node
21
+ - name: Setup Node.js environment
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version-file: .nvmrc
25
+
26
+ # caching: node_modules
27
+ - name: Cache node modules
28
+ uses: actions/cache@v4
29
+ with:
30
+ path: 'node_modules'
31
+ key: ${{ runner.os }}-modules
32
+ restore-keys: ${{ runner.os }}-modules
33
+
34
+ # caching: package builds
35
+ - name: Cache build artifacts
36
+ uses: actions/cache@v4
37
+ with:
38
+ path: packages/**/lib
39
+ key: ${{ runner.os }}-build
40
+ restore-keys: ${{ runner.os }}-build
41
+
42
+ # caching: package builds
43
+ - name: Cache Playwright binaries
44
+ uses: actions/cache@v4
45
+ id: playwright-cache
46
+ with:
47
+ path: ~/.cache/ms-playwright
48
+ key: ${{ runner.os }}-playwright
49
+ restore-keys: ${{ runner.os }}-playwright
50
+
51
+ # this should still respect the cached binary files for playwright but also just "install" them
52
+ - name: Installing Playwright
53
+ run: npx playwright install --with-deps
54
+
55
+ - name: Conditionally Update Screenshots
56
+ if: ${{ github.event.inputs.update_snapshots == 'true' }}
57
+ run: npm test -- --update-snapshots
58
+
59
+ # Run tests
60
+ - name: Running Tests
61
+ run: npm test
62
+
63
+ - name: Upload Playwright artifacts
64
+ if: failure()
65
+ # continue-on-error: true
66
+ uses: actions/upload-artifact@v4
67
+ with:
68
+ name: playwright-artifacts
69
+ overwrite: true # Allow overwriting of artifacts with the same name
70
+ path: |
71
+ ./packages/**/*/tests/test-results
72
+ ./packages/**/*/tests/snapshots
73
+ retention-days: 3 # Optional: specify how long to keep artifacts
@@ -0,0 +1,80 @@
1
+ name: Update Snapshots
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ update_snapshots:
7
+ description: 'Force update of snapshots?'
8
+ required: true
9
+ default: false
10
+ type: boolean
11
+
12
+ jobs:
13
+ initialise:
14
+ uses: ./.github/workflows/initialise.yml
15
+
16
+ build:
17
+ needs: initialise
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+
22
+ # setup node
23
+ - name: Setup Node.js environment
24
+ uses: actions/setup-node@v4
25
+ with:
26
+ node-version-file: .nvmrc
27
+
28
+ # caching: node_modules
29
+ - name: Cache node modules
30
+ uses: actions/cache@v4
31
+ with:
32
+ path: 'node_modules'
33
+ key: ${{ runner.os }}-modules
34
+ restore-keys: ${{ runner.os }}-modules
35
+
36
+ # caching: package builds
37
+ - name: Cache build artifacts
38
+ uses: actions/cache@v4
39
+ with:
40
+ path: packages/**/lib
41
+ key: ${{ runner.os }}-build
42
+ restore-keys: ${{ runner.os }}-build
43
+
44
+ # caching: package builds
45
+ - name: Cache Playwright binaries
46
+ uses: actions/cache@v4
47
+ id: playwright-cache
48
+ with:
49
+ path: ~/.cache/ms-playwright
50
+ key: ${{ runner.os }}-playwright
51
+ restore-keys: ${{ runner.os }}-playwright
52
+
53
+ # this should still respect the cached binary files for playwright but also just "install" them
54
+ - name: Installing Playwright
55
+ run: npx playwright install --with-deps
56
+
57
+ - name: Conditionally Update Screenshots
58
+ if: ${{ github.event.inputs.update_snapshots == 'true' }}
59
+ run: npm test -- --update-snapshots
60
+
61
+ # Run tests
62
+ - name: Running Tests
63
+ run: npm test
64
+
65
+ - name: Commit and Push Changes
66
+ continue-on-error: true
67
+ run: |
68
+ git fetch origin
69
+ git checkout main
70
+ git add ./packages/**/*/tests/snapshots
71
+
72
+ if [[ -n $(git status -s) ]]; then
73
+ git status -s
74
+
75
+ git config user.name "GitHub Actions"
76
+ git config user.email "actions@github.com"
77
+ git commit -m "add: github-runner snapshots"
78
+
79
+ git push --force-with-lease
80
+ fi
@@ -0,0 +1 @@
1
+ v25.2.1
@@ -0,0 +1,19 @@
1
+ {
2
+ "editor.tabSize": 4,
3
+ "editor.formatOnSave": true,
4
+ "editor.detectIndentation": false,
5
+ "editor.codeActionsOnSave": {
6
+ "source.fixAll.eslint": "explicit"
7
+ },
8
+ "eslint.validate": [
9
+ "javascript",
10
+ "typescript",
11
+ ],
12
+ "[javascript]": {
13
+ "editor.defaultFormatter": "vscode.typescript-language-features"
14
+ },
15
+ "typescript.format.placeOpenBraceOnNewLineForFunctions": false,
16
+ "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
17
+ "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
18
+ "files.associations": { "*.json": "jsonc" },
19
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "../"
5
+ }
6
+ ],
7
+ "settings": {
8
+ "files.exclude": {
9
+ "**/node_modules": true,
10
+ "**/.git": true,
11
+ "**/.temp": true,
12
+ "**/lib": true,
13
+ "**/.gitignore": true,
14
+ "**/tsconfig*.json": true,
15
+ ".vscode": true,
16
+ ".github": true,
17
+ "*-temp/": true,
18
+ ".eslintrc": true,
19
+ "asset": true,
20
+ "docs": true,
21
+ "CONTRIBUTING.md": true,
22
+ "LICENSE": true,
23
+ },
24
+ }
25
+ }
@@ -0,0 +1,45 @@
1
+ # VARIABLE_NAME
2
+
3
+ ![Logo](VARIABLE_GITHUB_REPO/blob/main/asset/logo.svg)
4
+
5
+ ## Introduction
6
+
7
+ [Provide a brief description of your project. Explain what it does and what makes it unique or valuable. Mention the key features and any important technologies used.]
8
+
9
+ ## Getting Started
10
+
11
+ ### Prerequisites
12
+
13
+ - [List any prerequisites needed to run your project, like Node.js, npm, etc.]
14
+ - [Include any other requirements, like a specific browser or environment.]
15
+
16
+ ### Installation
17
+
18
+ 1. Clone the repo:
19
+ 2. Install NPM packages:
20
+
21
+ ## Usage
22
+
23
+ [Provide instructions on how to use your project. This could include steps to run it, how to navigate the interface, or examples of its functionality.]
24
+
25
+ ## Important Commands
26
+
27
+ - `command1`: [Explain what this command does.]
28
+ - `command2`: [Explain what this command does.]
29
+ - [Include as many commands as necessary, providing clear explanations for each.]
30
+
31
+ ## Contributing
32
+
33
+ [If you're open to contributions, explain how others can contribute to your project. Provide any guidelines or rules for contributing.]
34
+
35
+ ## License
36
+
37
+ [Specify the type of license under which your project is released, if applicable.]
38
+
39
+ ## Contact
40
+
41
+ [Provide your contact information or the contact information of the project maintainer.]
42
+
43
+ ---
44
+
45
+ [Feel free to include any additional sections that are relevant to your project, such as 'Acknowledgements', 'Credits', 'Known Issues', etc.]
@@ -0,0 +1,28 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { spawnCommand } from "./spawn-command.mjs";
4
+
5
+ (async function () {
6
+
7
+ const folders = fs.globSync("packages/**/package.json", {
8
+ cwd: process.cwd(),
9
+ absolute: true,
10
+ ignore: [
11
+ "packages/**/asset/**", // unforthunally does not work
12
+ ],
13
+ });
14
+
15
+ let finds = 0; // if the ignore was to work we could avoid doing like this
16
+ for (const dir of folders)
17
+ {
18
+ if (/packages.*\/asset.*/.test(dir)) continue;
19
+ finds++;
20
+
21
+ const dirname = path.dirname(dir);
22
+ fs.rmSync(path.join(dirname, ".temp"), { recursive: true, force: true });
23
+ fs.rmSync(path.join(dirname, "lib"), { recursive: true, force: true });
24
+ }
25
+
26
+ if (finds > 0)
27
+ await spawnCommand("npm install", process.cwd());
28
+ }())
@@ -0,0 +1,4 @@
1
+
2
+ export default async function (info, args) {
3
+ console.log('im a example runner', info, args);
4
+ }
@@ -0,0 +1,31 @@
1
+ import { spawn } from "node:child_process";
2
+
3
+ export function spawnCommand(command, cwd, args = []) {
4
+ const [cmd, ..._args] = command.split(" ");
5
+
6
+ return new Promise((resolve, reject) => {
7
+ const full = [cmd, ..._args.concat(args)].join(" ");
8
+
9
+ const child = spawn(full, {
10
+ cwd,
11
+ stdio: "pipe",
12
+ shell: true,
13
+ env: { ...process.env },
14
+ });
15
+
16
+ child.stdout.on("data", data => {
17
+ // process.stdout.write(data);
18
+ });
19
+ child.stderr.on("data", data => {
20
+ process.stderr.write(data);
21
+ });
22
+
23
+ child.on("close", code => {
24
+ if (code === 0) resolve();
25
+ else
26
+ {
27
+ reject(new Error("code: " + code));
28
+ }
29
+ });
30
+ });
31
+ }
@@ -0,0 +1,94 @@
1
+ import path from "node:path";
2
+ import {Arguments} from "@papit/arguments";
3
+ import {Information} from "@papit/information";
4
+ import {Terminal} from "@papit/terminal";
5
+ import {setup, close} from "@papit/server";
6
+
7
+ function runner(node) {
8
+ return new Promise(async resolve => {
9
+ const {close, update} = Terminal.loading(
10
+ `${Terminal.dim("testing")} ${node.name}`,
11
+ 80,
12
+ frame => {
13
+ if (frame === 50) update(`${Terminal.dim("testing")} ${node.name} ${Terminal.dim("- so slow..")}`)
14
+ if (frame === 100) update(`${Terminal.dim("testing")} ${node.name} ${Terminal.dim("- jeez")}`)
15
+ if (frame === 250) update(`${Terminal.dim("testing")} ${node.name} ${Terminal.dim("- yeah this is borked")}`)
16
+ }
17
+ );
18
+
19
+ let buffer = "";
20
+ process.env.LOCATION = path.relative(Information.root.location, node.location);
21
+ const child = Terminal.spawn("npm test", {
22
+ cwd: node.location,
23
+ args: process.argv.slice(2),
24
+ onData: text => (buffer += text),
25
+ onError: text => (buffer += text),
26
+ });
27
+
28
+ child.on("close", code => {
29
+ close();
30
+ resolve({code, buffer});
31
+ });
32
+ });
33
+ }
34
+
35
+ (async function () {
36
+ Arguments.set("port", 3500);
37
+ Arguments.set("root", true);
38
+ if (Arguments.has("ci")) Arguments.set("remote", true);
39
+ if (Arguments.has("ci")) process.env.CI = true;
40
+
41
+ await setup();
42
+ const secondchance = [];
43
+
44
+ const batches = Information.getBatches();
45
+ for (const batch of batches)
46
+ {
47
+ for (const node of batch)
48
+ {
49
+ if (Arguments.has("ci"))
50
+ {
51
+ const remote = await node.remote();
52
+ if (node.version === remote && remote)
53
+ {
54
+ Terminal.write(Terminal.blue("●"), node.name, Terminal.green("skipped"));
55
+ continue;
56
+ }
57
+ }
58
+
59
+ const {code} = await runner(node);
60
+
61
+ if (code === 0)
62
+ {
63
+ Terminal.write(Terminal.green("●"), node.name, Terminal.green("passed"));
64
+ }
65
+ else
66
+ {
67
+ Terminal.write(Terminal.red("●"), node.name, Terminal.red("failed"));
68
+ secondchance.push(node);
69
+ }
70
+ }
71
+ }
72
+
73
+ if (secondchance.length > 0)
74
+ {
75
+ Terminal.write(Terminal.dim("\nRunning Second Chance"));
76
+ }
77
+ for (const node of secondchance)
78
+ {
79
+ const {code, buffer} = await runner(node);
80
+
81
+ if (code === 0)
82
+ {
83
+ Terminal.write(Terminal.yellow("✅"), node.name, Terminal.green("passed"));
84
+ }
85
+ else
86
+ {
87
+ Terminal.write(Terminal.yellow("❌"), node.name, Terminal.red("failed"));
88
+ Terminal.write(buffer)
89
+ process.exit(1);
90
+ }
91
+ }
92
+
93
+ close();
94
+ }());
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "VARIABLE_NAME",
3
+ "version": "0.0.0",
4
+ "description": "VARIABLE_DESCRIPTION",
5
+ "private": true,
6
+ "scripts": {
7
+ "analyse": "to come",
8
+ "publish": "to come",
9
+ "clean": "node bin/clean.mjs",
10
+ "build": "npx @papit/build",
11
+ "test": "node bin/test.mjs",
12
+ "create": "npm create @papit -- --package",
13
+ "start": "npx @papit/server --serve --info"
14
+ },
15
+ "keywords": [
16
+ "typescript"
17
+ ],
18
+ "packageManager": "npm@11.6.2",
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "author": "VARIABLE_USER",
23
+ "license": "VARIABLE_PROJECTLICENSE",
24
+ "workspaces": [
25
+ "packages/**/*",
26
+ "!packages/**/asset/**"
27
+ ],
28
+ "devDependencies": {
29
+ "esbuild": "0.27.2",
30
+ "typescript": "5.9.3",
31
+ "@papit/bundle-ts": "0.0.1",
32
+ "@papit/bundle-js": "0.0.1",
33
+ "@papit/arguments": "0.0.1",
34
+ "@papit/terminal": "0.0.1",
35
+ "@papit/information": "0.0.1",
36
+ "@papit/build": "0.0.1",
37
+ "@papit/server": "0.0.1",
38
+ "@papit/create": "0.0.1",
39
+ "@papit/version": "0.0.1"
40
+ },
41
+ "papit": {}
42
+ }
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export { }
package/lib/bundle.js ADDED
@@ -0,0 +1,4 @@
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}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 Q}from"@papit/information";import{Arguments as w}from"@papit/arguments";import L from"node:path";import P from"node:fs";import{Information as R}from"@papit/information";import{Terminal as u}from"@papit/terminal";import{Arguments as _}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 a=I.join(e,n);return!(!j.statSync(a).isDirectory()||oe.search(a))})}async function X(){return E.sessionBlock(async()=>{let e=I.join(W.root.location,"packages"),n=e;for(;e;){let a=E.createSession(),s=re(e);E.write("Current: ",e.replace(W.root.location,W.scope)),E.write();let l=await E.option([["Choose Folder","Create Folder"],e===n?s:["..",...s]]);if(l.index===0)break;if(l.index===1){let c=await E.prompt("folder name",!1,e),r=I.join(e,c.input);await ae(r)&&(e=I.join(e,c.input))}else l.index===2&&e!==n?e=I.resolve(e,".."):e=I.join(e,s[l.index-(e===n?2:3)]);E.clearSession(a)}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 b(e,n,a){j.mkdirSync(n,{recursive:!0});let s=j.readdirSync(e,{withFileTypes:!0});for(let l of s){let c=I.join(e,l.name),r=I.join(n,l.name);if(l.isDirectory()){await b(c,r,a);continue}if(typeof a!="function"){j.copyFileSync(c,r);continue}let p=j.readFileSync(c,"utf-8"),t=await a(p,c,r);t!==!1&&(j.copyFileSync(c,r),j.writeFileSync(r,t,"utf-8"))}}function J(e){if(!e)return;let n=e.split(/[ |-]/),a=n.join("-");return{className:Y(n.map(Y).join("")),name:a.toLowerCase()}}function Y(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}function se(e){try{return P.readdirSync(e).length>0}catch{return!1}}function ce(e){P.existsSync(e)&&P.statSync(e).isDirectory()||P.mkdirSync(e)}async function U(e,n,a){let s=L.join(n?.destination??R.package.location,"package.json"),l=n?JSON.parse(P.readFileSync(s,{encoding:"utf-8"})):R.package.packageJSON;l==null&&(u.error("could not find package's package.json file"),process.exit(1)),l.name===R.root.name&&(u.error("cannot create a component to root"),process.exit(1));let c=l,r=N(L.join(e,"asset/component-templates")),p=new Set;try{N(L.join(R.root.location,"bin/runners/component")).forEach(f=>{r.push(f),p.add(f)})}catch{}let t={index:r.findIndex(f=>f===c.papit?.type),text:""};if(t.text=r[t.index],t.index<0){let f=_.string("package")??_.string("type");t.index=r.findIndex(g=>g===f),t.index<0&&(u.createSession(),u.write("type of component"),t=await u.option(r),u.clearSession())}let x=_.string("html-prefix")??n?.htmlprefix??R.package.packageJSON.papit.htmlprefix??R.root.packageJSON.papit.htmlprefix;if(x?.trim()===""&&(x=void 0),x===void 0&&/web-components?/i.test(t.text)){let f=u.createSession();for(;;){let g;if(x!==void 0?(g=(await u.prompt(`use default "${x}" or override?`)).input,g||(g=x)):g=(await u.prompt("html prefix",!0)).input,g){x=g;break}else u.clearSession(),u.write("you must use a html-prefix for web-components")}u.clearSession(f)}let y=n?.nameInfo;for(;!y;){u.clearSession();let f=_.string("name");if(f||(f=(await u.prompt("(component) name",!0)).input),y=J(f),!y){u.write("name missing, try again");continue}if(c.papit.components[y.name]){u.write("name already exist, try again");continue}break}u.createSession();let $=n?.shouldCommit??_.true("agree")??_.true("commit")??await u.confirm("git commit",!0);u.clearSession();let V=p.has(t.text)?L.join(R.root.location,"bin","runners","component",t.text):L.join(e,"asset","component-templates",t.text),S=N(V);c.papit.components[y.name]={className:y.className,htmlprefix:x},P.writeFileSync(s,JSON.stringify(c,null,2),{encoding:"utf-8"}),$&&await u.execute(`git add ${s}`,R.root.location);for(let f of S){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,y.name)):d=L.join(g,y.name),ce(g),a&&(d=a(d,f)),await b(G,d,H=>H.replace(/VARIABLE_NAME/g,y.name).replace(/VARIABLE_FULL_NAME/g,c.name).replace(/VARIABLE_HTML_NAME/g,`${x}-${y.name}`).replace(/VARIABLE_CLASS_NAME/g,y.className)),$)try{await u.execute(`git add ${d}`,R.root.location)}catch{u.warn(`"git add ${d}" failed`)}}!n?.shouldCommit&&$&&await u.execute(`git commit -m "add: ${y.name} component"`,R.root.location)}async function Z(e){let n=i.createSession(),a=F.root.packageJSON;a===null&&(i.error("root package.json not found"),process.exit(1));let s=await X(),l=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"))&&(l.push(o),c.add(o))})}catch{}let r=w.string("package")??w.string("type"),p={index:l.findIndex(o=>o===r),text:""};p.text=l[p.index],p.index<0&&(i.write("type of package"),p=await i.option(l)),i.clearSession();let t=w.string("html-prefix");if(t?.trim()===""&&(t=void 0),!t&&/web-components?/i.test(p.text)){for(t||(t=a.papit?.htmlprefix),w.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,a.papit?.htmlprefix||await i.confirm(`you wish to set "${o}" as the default html-prefix?`)&&(a.papit.htmlprefix=o,v.writeFileSync(k.join(F.root.location,"package.json"),JSON.stringify(a,null,2),{encoding:"utf-8"}))),o){t=o;break}else w.info||i.clearSession(),i.warn("you must use a html-prefix for web-components")}w.info||i.clearSession()}let x=k.relative(F.root.location,s),y=k.basename(s);a.repository?.url||(i.error("root package.json does not have 'repository.url'"),process.exit(1));let $=a.repository.url.replace(/\.git$/,""),V=k.join(F.root.location,"package-lock.json");i.clearSession(n);let S,f;for(;f===void 0||S===void 0;){i.clearSession();let o=w.string("name");if(o||(o=(await i.prompt("(package) name",!0)).input),S=J(o),!S){i.write("name missing, try again");continue}let h=`${F.scope}/${S.name}`;Q.get(h)?i.write("package already exists, try again"):f=h}let g=w.string("description");g||(g=(await i.prompt("description",!0)).input),i.write(),i.createSession();let d=k.join(s,S.name),G=o=>o.replace(/\\/g,"/"),H=c.has(p.text)?k.join(F.root.location,"bin","runners","package",p.text):k.join(e,"asset","package-templates",p.text);await b(H,d,async(o,h)=>h.endsWith(".gitkeep")?!1:o.replace(/VARIABLE_NAME/g,S.name).replace(/VARIABLE_FULL_NAME/g,f).replace(/VARIABLE_DESCRIPTION/g,g).replace(/VARIABLE_LAYER_FOLDER/g,y).replace(/VARIABLE_PROJECTLICENSE/g,a.license||"MIT").replace(/VARIABLE_GITHUB_REPO/g,$).replace(/VARIABLE_LOCAL_DESTINATION/g,G(k.join(x,S.name))).replace(/VARIABLE_CLASS_NAME/g,S.className).replace(/VARIABLE_HTML_PREFIX/g,t??"").replace(/VARIABLE_HTML_NAME/g,`${t}-${S.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:S.name,components:{},publish:!0,type:p.text}),Q.add(d);let T=!1;w.has("no")?T=!1:w.has("yes")?T=!0:T=w.true("agree")||w.true("commit")||await i.confirm("git commit",!0),await U(e,{destination:d,nameInfo:S,htmlprefix:t,shouldCommit:T},(o,h)=>(h==="src"&&(o=o.replace(/[/\\]components[/\\].*/,"")),h==="lib"&&(o=o.replace(new RegExp(S.name+"$"),"")),h==="views"&&(o=o.replace(new RegExp(S.name+"$"),"experiment")),w.debug&&i.info(JSON.stringify({dest:o,folder:h})),o));let q=k.join(d,"src","components");v.existsSync(q)&&v.rmdirSync(q),i.createSession();let M=!1;if(w.has("no")?M=!1:w.has("yes")?M=!0:M=w.true("agree")||w.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 ee from"node:path";import B from"node:fs";import{Arguments as C}from"@papit/arguments";import{Terminal as m}from"@papit/terminal";async function te(e){m.write(`Project Creation
4
+ `),m.createSession();let n=!1,a=C.string("name");a===void 0&&(a=(await m.prompt("name",!0)).input,n=!0);let s=C.string("location");s===void 0&&(n&&m.write(),s=(await m.prompt("location")).path,n=!0),await m.sessionBlock(async()=>{if(n&&m.write(),!B.existsSync(s))return;await m.confirm("confirm to remove it")?B.rmSync(s,{recursive:!0,force:!0}):(m.error("must choose a empty location"),process.exit(1))}),n&&m.write(),await m.confirm(m.blue("confirm")+` [${m.yellow(s)}]`,!0)||(m.warn("abort"),process.exit(0)),B.mkdirSync(s,{recursive:!0});let c=C.string("description");c===void 0&&(n&&m.write(),c=(await m.prompt("description")).input,n=!0);let r=C.string("license");if(r===void 0&&(n&&m.write(),r=(await m.prompt("license (default MIT)")).input,n=!0),r){let t=C.string("license-file-location");t===void 0&&(n&&m.write(),t=(await m.prompt("license file location")).input,n=!0),B.existsSync(t)&&B.copyFileSync(t,ee.join(s,"LICENSE"))}m.clearSession();let p=C.has("git")||await m.confirm("init with git?");p&&await m.execute("git init",{cwd:s}),await b(ee.join(e,"asset/project-template"),s,async(t,x)=>x.endsWith(".gitkeep")?!1:t.replace(/VARIABLE_NAME/g,`@${a}/root`).replace(/VARIABLE_DESCRIPTION/g,c).replace(/VARIABLE_PROJECTLICENSE/g,r||"MIT").replace(/VARIABLE_USER/g,process.env.USER??"anonymous")),p&&(await m.execute("git add .",{cwd:s}),await m.execute(`git commit -m "init: ${a} initialized"`,{cwd:s}))}(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 r=await A.prompt("your name",!0);process.env.USER=r.input,A.clearSession()}A.write(),A.write("@papit/create",A.yellow(n.version),"- running"),A.write();let a=new Set,s=O.join(le.root.location,"bin/runners"),l=["package","component","project","showcase"];try{N(s).forEach(p=>{if(l.includes(p))return;let t=O.join(s,p,"runner.js");ne.existsSync(t)&&(a.add(p),l.push(p))})}catch{}let c=null;for(let r=0;r<l.length;r++)if(D.has(l[r])){c={index:r,text:l[r]};break}switch(c===null&&(A.createSession(),c=await A.option(l),A.clearSession()),c.index){case 0:await Z(e);break;case 1:await U(e);break;case 2:await te(e);break;default:{a.has(c.text)||(A.error("requested a runner that doesnt exist"),process.exit(1));let r=O.join(s,c.text,"runner.js");D.verbose&&A.write(`running local runner "${c.text}"`);let{default:p}=await import(r);await p();break}}process.exit()})();