@papit/create 0.0.3 → 0.0.4

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.
@@ -1,59 +1,42 @@
1
- name: Publish Packages to npmjs
2
-
1
+ name: publish
3
2
  on:
4
3
  release:
5
4
  types: [published]
6
- workflow_dispatch: # Allows manual triggering
5
+ workflow_dispatch:
7
6
  inputs:
8
- force_build:
9
- description: 'Force build?'
7
+ dry_run:
8
+ description: 'dry-run mode'
10
9
  required: false
11
10
  default: false
12
- type: boolean
11
+ type: boolean
12
+ env:
13
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
13
14
 
14
15
  permissions:
15
- id-token: write # Required for OIDC
16
+ id-token: write
16
17
  contents: read
17
-
18
18
  jobs:
19
- initialise:
20
- uses: ./.github/workflows/initialise.yml
21
- with:
22
- force_build: ${{ github.event.inputs.force_build || false }}
23
-
24
19
  publish:
25
20
  runs-on: ubuntu-latest
26
- needs: initialise
21
+ environment: npm
27
22
  steps:
28
23
  - uses: actions/checkout@v4
29
-
30
- # setup node
31
- - name: Setup Node.js environment
24
+ - name: Setup Node.js
32
25
  uses: actions/setup-node@v4
33
26
  with:
34
27
  node-version-file: .nvmrc
28
+ cache: npm
35
29
  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
30
+
31
+ - name: Install dependencies
32
+ run: npm ci
45
33
 
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
34
+ - name: Build
35
+ env:
36
+ CI: true
37
+ run: npm run build -- --ci --remote
53
38
 
54
- # Publish to npm
55
39
  - name: Publish to npmjs.com
56
- run: npm run publish -- --ci --verbose
40
+ run: npm run publish -- --provenance ${{ github.event.inputs.dry_run == 'true' && '--dry-run' || '' }}
57
41
  env:
58
- CI: true
59
-
42
+ CI: true
@@ -1,73 +1,69 @@
1
- name: Tests
1
+ name: pull-request
2
2
 
3
3
  on:
4
4
  pull_request:
5
- branches: [ main, master ]
5
+ branches: [main, master]
6
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 }}
7
+ concurrency:
8
+ group: pr-${{ github.ref }}
9
+ cancel-in-progress: true
13
10
 
11
+ env:
12
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
13
+
14
+ jobs:
14
15
  test:
15
- needs: initialise
16
16
  runs-on: ubuntu-latest
17
+
17
18
  steps:
18
19
  - uses: actions/checkout@v4
19
20
 
20
- # setup node
21
- - name: Setup Node.js environment
21
+ - name: Setup Node.js
22
22
  uses: actions/setup-node@v4
23
23
  with:
24
24
  node-version-file: .nvmrc
25
+ cache: npm
25
26
 
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
27
+ # Short-lived build cache (retry helper only)
28
+ - name: Cache build output
36
29
  uses: actions/cache@v4
37
30
  with:
38
31
  path: packages/**/lib
39
- key: ${{ runner.os }}-build
40
- restore-keys: ${{ runner.os }}-build
32
+ key: build-${{ runner.os }}-${{ github.run_attempt }}
33
+ restore-keys: |
34
+ build-${{ runner.os }}-
35
+
36
+ - name: Install dependencies
37
+ run: npm ci
38
+
39
+ - name: Build
40
+ env:
41
+ CI: true
42
+ run: npm run build -- --ci --remote
41
43
 
42
- # caching: package builds
43
- - name: Cache Playwright binaries
44
+ # Long-lived Playwright cache (read-only in PRs)
45
+ - name: Restore Playwright cache
44
46
  uses: actions/cache@v4
45
- id: playwright-cache
46
47
  with:
47
48
  path: ~/.cache/ms-playwright
48
49
  key: ${{ runner.os }}-playwright
49
- restore-keys: ${{ runner.os }}-playwright
50
+ restore-keys: |
51
+ ${{ runner.os }}-playwright
50
52
 
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
53
+ - name: Install Playwright
54
+ run: npx playwright install --with-deps
58
55
 
59
- # Run tests
60
- - name: Running Tests
61
- run: npm test
56
+ - name: Run tests
57
+ env:
58
+ CI: true
59
+ run: npm test -- --ci --remote
62
60
 
63
61
  - name: Upload Playwright artifacts
64
62
  if: failure()
65
- # continue-on-error: true
66
63
  uses: actions/upload-artifact@v4
67
64
  with:
68
65
  name: playwright-artifacts
69
- overwrite: true # Allow overwriting of artifacts with the same name
70
66
  path: |
71
- ./packages/**/*/tests/test-results
72
- ./packages/**/*/tests/snapshots
73
- retention-days: 3 # Optional: specify how long to keep artifacts
67
+ packages/**/tests/test-results
68
+ packages/**/tests/snapshots
69
+ retention-days: 3
@@ -0,0 +1,31 @@
1
+ name: update-playwright-cache
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ env:
7
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
8
+
9
+ jobs:
10
+ playwright-cache:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Setup Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version-file: .nvmrc
20
+ cache: npm
21
+
22
+ - name: Restore Playwright cache
23
+ uses: actions/cache@v4
24
+ with:
25
+ path: ~/.cache/ms-playwright
26
+ key: ${{ runner.os }}-playwright
27
+ restore-keys: |
28
+ ${{ runner.os }}-playwright
29
+
30
+ - name: Install Playwright
31
+ run: npx playwright install --with-deps
@@ -1,80 +1,59 @@
1
- name: Update Snapshots
2
-
1
+ name: Update Snapshots
3
2
  on:
4
- workflow_dispatch:
3
+ workflow_dispatch:
5
4
  inputs:
6
5
  update_snapshots:
7
6
  description: 'Force update of snapshots?'
8
7
  required: true
9
8
  default: false
10
9
  type: boolean
11
-
10
+ env:
11
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
12
12
  jobs:
13
- initialise:
14
- uses: ./.github/workflows/initialise.yml
15
-
16
- build:
17
- needs: initialise
13
+ update-snapshots:
18
14
  runs-on: ubuntu-latest
19
15
  steps:
20
16
  - uses: actions/checkout@v4
17
+ with:
18
+ ref: ${{ github.ref }}
21
19
 
22
- # setup node
23
- - name: Setup Node.js environment
20
+ - name: Setup Node.js
24
21
  uses: actions/setup-node@v4
25
22
  with:
26
23
  node-version-file: .nvmrc
24
+ cache: npm
27
25
 
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
26
+ - name: Install dependencies
27
+ run: npm ci
35
28
 
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
29
+ - name: Build
30
+ env:
31
+ CI: true
32
+ run: npm run build -- --ci
43
33
 
44
- # caching: package builds
45
- - name: Cache Playwright binaries
34
+ - name: Restore Playwright cache
46
35
  uses: actions/cache@v4
47
- id: playwright-cache
48
36
  with:
49
37
  path: ~/.cache/ms-playwright
50
38
  key: ${{ runner.os }}-playwright
51
39
  restore-keys: ${{ runner.os }}-playwright
52
40
 
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
41
+ - name: Install Playwright
42
+ run: npx playwright install --with-deps
60
43
 
61
- # Run tests
62
- - name: Running Tests
63
- run: npm test
44
+ - name: Run tests
45
+ env:
46
+ CI: true
47
+ run: npm test -- --ci ${{ github.event.inputs.update_snapshots == 'true' && '--update-snapshots' || '' }}
64
48
 
65
- - name: Commit and Push Changes
49
+ - name: Commit and push snapshot changes
66
50
  continue-on-error: true
67
51
  run: |
68
52
  git fetch origin
69
- git checkout main
70
- git add ./packages/**/*/tests/snapshots
71
-
53
+ git add ./packages/**/tests/snapshots
72
54
  if [[ -n $(git status -s) ]]; then
73
- git status -s
74
-
75
55
  git config user.name "GitHub Actions"
76
56
  git config user.email "actions@github.com"
77
57
  git commit -m "add: github-runner snapshots"
78
-
79
58
  git push --force-with-lease
80
59
  fi
@@ -4,25 +4,34 @@ import { spawnCommand } from "./spawn-command.mjs";
4
4
 
5
5
  (async function () {
6
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
- });
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
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++;
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
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
- }
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
+ fs.rmSync(path.join(dirname, "reports"), { recursive: true, force: true });
25
+ fs.rmSync(path.join(dirname, "node_modules"), { recursive: true, force: true }); // windows seemed to have issue ?
25
26
 
26
- if (finds > 0)
27
- await spawnCommand("npm install", process.cwd());
27
+ if (process.argv.some(a => /--?t(ests?)?/.test(a)))
28
+ {
29
+ fs.rmSync(path.join(dirname, "tests/snapshots"), { recursive: true, force: true });
30
+ fs.rmSync(path.join(dirname, "tests/test-reports"), { recursive: true, force: true });
31
+ fs.rmSync(path.join(dirname, "tests/test-results"), { recursive: true, force: true });
32
+ }
33
+ }
34
+
35
+ if (finds > 0)
36
+ await spawnCommand("npm install", process.cwd());
28
37
  }())
@@ -0,0 +1,74 @@
1
+ import path from "node:path";
2
+
3
+ import { Arguments } from "@papit/arguments";
4
+ import { Information } from "@papit/information";
5
+ import { Terminal } from "@papit/terminal";
6
+
7
+ function runner(node, extraEnv = {}, extraArgs = []) {
8
+ return new Promise(resolve => {
9
+ const { close, update } = Terminal.loading(
10
+ `${Terminal.dim("publishing")} ${node.name}`,
11
+ 80,
12
+ frame => {
13
+ if (frame === 50) update(`${Terminal.dim("publishing")} ${node.name} ${Terminal.dim("- so slow..")}`);
14
+ if (frame === 150) update(`${Terminal.dim("publishing")} ${node.name} ${Terminal.dim("- jeez")}`);
15
+ if (frame === 400) update(`${Terminal.dim("publishing")} ${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
+
22
+ const dryRun = Arguments.has("dry-run") ? "--dry-run" : "";
23
+ const child = Terminal.spawn(`npm publish --access public --loglevel verbose --provenance ${dryRun}`, {
24
+ cwd: node.location,
25
+ args: [...process.argv.slice(2), ...extraArgs],
26
+ env: { ...process.env, ...extraEnv },
27
+ onData: text => (buffer += text),
28
+ onError: text => (buffer += text),
29
+ });
30
+
31
+ child.on("close", code => {
32
+ close();
33
+ resolve({ code, buffer });
34
+ });
35
+ });
36
+ }
37
+
38
+ (async function () {
39
+
40
+ const batches = Information.getBatches();
41
+
42
+ for (const batch of batches)
43
+ {
44
+ for (const node of batch)
45
+ {
46
+ // Skip unchanged packages in CI
47
+ if (Arguments.has("ci") || process.env.CI)
48
+ {
49
+ const remote = await node.remote() ?? node.packageJSON.remoteVersion;
50
+ if (node.packageJSON.version === remote && remote)
51
+ {
52
+ Terminal.write(Terminal.blue("●"), node.name, Terminal.green("skipped"));
53
+ continue;
54
+ }
55
+ }
56
+
57
+ const { code, buffer } = await runner(node);
58
+
59
+ if (code === 0)
60
+ {
61
+ Terminal.write(Terminal.green("●"), node.name, Terminal.green("passed"));
62
+ }
63
+ else
64
+ {
65
+ Terminal.write(Terminal.red("●"), node.name, Terminal.red("failed"));
66
+ // only print lines that look like actual errors
67
+ const errors = buffer.split("\n").filter(line => line.includes("npm error") || line.includes("ERR!"));
68
+ Terminal.write(errors.join("\n") || buffer);
69
+ }
70
+ }
71
+ }
72
+
73
+ process.exit(0);
74
+ }());
@@ -8,17 +8,23 @@ export function spawnCommand(command, cwd, args = []) {
8
8
 
9
9
  const child = spawn(full, {
10
10
  cwd,
11
- stdio: "pipe",
11
+ stdio: process.env.CI ? "inherit" : "pipe",
12
12
  shell: true,
13
13
  env: { ...process.env },
14
14
  });
15
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
- });
16
+ if (child.stdout)
17
+ {
18
+ child.stdout.on("data", data => {
19
+ // process.stdout.write(data);
20
+ });
21
+ }
22
+ if (child.stderr)
23
+ {
24
+ child.stderr.on("data", data => {
25
+ process.stderr.write(data);
26
+ });
27
+ }
22
28
 
23
29
  child.on("close", code => {
24
30
  if (code === 0) resolve();
@@ -28,4 +34,4 @@ export function spawnCommand(command, cwd, args = []) {
28
34
  }
29
35
  });
30
36
  });
31
- }
37
+ }
@@ -1,33 +1,56 @@
1
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(
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+
5
+ import { Arguments } from "@papit/arguments";
6
+ import { Information } from "@papit/information";
7
+ import { Terminal } from "@papit/terminal";
8
+ import { setup, close } from "@papit/server";
9
+
10
+ function isPlaywright(node) {
11
+ return (
12
+ fs.existsSync(path.join(node.location, "playwright.config.ts")) ||
13
+ fs.existsSync(path.join(node.location, "playwright.config.js"))
14
+ );
15
+ }
16
+
17
+ function hasSnapshots(node) {
18
+ const dir = path.join(node.location, "tests", "snapshots");
19
+ try
20
+ {
21
+ return fs.readdirSync(dir).some(f => f.endsWith(os.platform + ".png"));
22
+ } catch
23
+ {
24
+ return false;
25
+ }
26
+ }
27
+
28
+ function runner(node, extraEnv = {}, extraArgs = []) {
29
+ return new Promise(resolve => {
30
+ const { close, update } = Terminal.loading(
10
31
  `${Terminal.dim("testing")} ${node.name}`,
11
32
  80,
12
33
  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")}`)
34
+ if (frame === 50) update(`${Terminal.dim("testing")} ${node.name} ${Terminal.dim("- so slow..")}`);
35
+ if (frame === 150) update(`${Terminal.dim("testing")} ${node.name} ${Terminal.dim("- jeez")}`);
36
+ if (frame === 400) update(`${Terminal.dim("testing")} ${node.name} ${Terminal.dim("- yeah this is borked")}`);
16
37
  }
17
38
  );
18
39
 
19
40
  let buffer = "";
20
41
  process.env.LOCATION = path.relative(Information.root.location, node.location);
42
+
21
43
  const child = Terminal.spawn("npm test", {
22
44
  cwd: node.location,
23
- args: process.argv.slice(2),
45
+ args: [...process.argv.slice(2), ...extraArgs],
46
+ env: { ...process.env, ...extraEnv },
24
47
  onData: text => (buffer += text),
25
48
  onError: text => (buffer += text),
26
49
  });
27
50
 
28
51
  child.on("close", code => {
29
52
  close();
30
- resolve({code, buffer});
53
+ resolve({ code, buffer });
31
54
  });
32
55
  });
33
56
  }
@@ -36,59 +59,103 @@ function runner(node) {
36
59
  Arguments.set("port", 3500);
37
60
  Arguments.set("root", true);
38
61
  if (Arguments.has("ci")) Arguments.set("remote", true);
39
- if (Arguments.has("ci")) process.env.CI = true;
62
+ if (Arguments.has("ci")) process.env.CI = "true";
63
+
64
+ const summery = [];
40
65
 
41
66
  await setup();
42
- const secondchance = [];
43
67
 
68
+ const force = Arguments.has("force");
44
69
  const batches = Information.getBatches();
70
+
71
+
72
+ const testresult_location = path.join(Information.root.location, "test-result.log");
73
+ if (!Arguments.has("ci") && fs.existsSync(testresult_location)) fs.rmSync(testresult_location);
74
+ const testresultstream = Arguments.has("ci") ? null : fs.createWriteStream(testresult_location, { flags: "a" }); // append mode
75
+
76
+ if (!Arguments.has("ci"))
77
+ {
78
+ testresultstream.write("# Test Results\n");
79
+ testresultstream.write("\n==== Meta Information ====\n")
80
+ testresultstream.write("\nmachine: " + os.machine)
81
+ testresultstream.write("\nplatform: " + os.platform)
82
+ testresultstream.write("\ntimestamp: " + new Date().toISOString());
83
+ testresultstream.write("\n\n==== (meta end) ====\n\n")
84
+ }
85
+
45
86
  for (const batch of batches)
46
87
  {
47
88
  for (const node of batch)
48
89
  {
49
- if (Arguments.has("ci"))
90
+ // Skip unchanged packages in CI
91
+ if (Arguments.has("ci") || process.env.CI)
50
92
  {
51
- const remote = await node.remote();
52
- if (node.version === remote && remote)
93
+ const remote = await node.remote() ?? node.packageJSON.remoteVersion;
94
+ if (node.packageJSON.version === remote && remote)
53
95
  {
54
96
  Terminal.write(Terminal.blue("●"), node.name, Terminal.green("skipped"));
97
+ log({ name: node.name, status: "skipped" }, testresultstream);
55
98
  continue;
56
99
  }
57
100
  }
58
101
 
59
- const {code} = await runner(node);
102
+ const playwright = isPlaywright(node);
103
+ const skipSnapshots = !force && playwright && !hasSnapshots(node);
104
+ const extraEnv = skipSnapshots ? { SKIP_SNAPSHOTS: "true" } : {};
105
+
106
+ if (skipSnapshots)
107
+ {
108
+ Terminal.write(Terminal.dim("○"), node.name, Terminal.dim("no snapshots — skipping snapshot.test.ts"));
109
+ }
110
+
111
+ const { code, buffer } = await runner(node, extraEnv);
60
112
 
61
113
  if (code === 0)
62
114
  {
63
115
  Terminal.write(Terminal.green("●"), node.name, Terminal.green("passed"));
116
+ log({ name: node.name, status: "passed", buffer }, testresultstream);
117
+ continue;
64
118
  }
65
- else
119
+
120
+ // Retry — last-failed for playwright, full rerun for node
121
+ if (Arguments.has("ci")) Terminal.write(Terminal.yellow("●"), node.name, Terminal.yellow("failed — retrying"));
122
+
123
+ const retryArgs = playwright ? ["--last-failed"] : [];
124
+ const { code: code2, buffer: buffer2 } = await runner(node, extraEnv, retryArgs);
125
+
126
+ if (code2 === 0)
127
+ {
128
+ if (Arguments.has("ci")) Terminal.write(Terminal.green("●"), node.name, Terminal.green("passed (flaky)"));
129
+ else Terminal.write(Terminal.green("●"), node.name, Terminal.green("passed"));
130
+
131
+ log({ name: node.name, status: "passed", buffer: buffer2 }, testresultstream);
132
+ }
133
+ else
66
134
  {
67
135
  Terminal.write(Terminal.red("●"), node.name, Terminal.red("failed"));
68
- secondchance.push(node);
136
+ log({ name: node.name, status: "failed", buffer: buffer2 }, testresultstream);
137
+ close();
138
+
139
+ if (Arguments.has("ci")) process.exit(1);
69
140
  }
70
141
  }
71
142
  }
72
143
 
73
- if (secondchance.length > 0)
144
+ close();
145
+
146
+ if (!Arguments.has("ci"))
74
147
  {
75
- Terminal.write(Terminal.dim("\nRunning Second Chance"));
148
+ testresultstream.end();
149
+ Terminal.write(`\ncheck the test-results at: "${testresult_location}"`)
76
150
  }
77
- for (const node of secondchance)
78
- {
79
- const {code, buffer} = await runner(node);
151
+ process.exit(0);
152
+ }());
80
153
 
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
- }
154
+ function log(note, testresultstream) {
155
+ if (Arguments.has("ci")) return;
92
156
 
93
- close();
94
- }());
157
+ let output = Arguments.get("output")?.includes("terminal") ? Terminal : testresultstream;
158
+ output.write(`\n● ${note.name} - ${note.status}`);
159
+ output.write(`\n==== ${note.name} - logs ====\n`)
160
+ output.write(note.buffer);
161
+ }
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}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 C 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 C.readdirSync(e).length>0}catch{return!1}}function ce(e){C.existsSync(e)&&C.statSync(e).isDirectory()||C.mkdirSync(e)}async function U(e,n,a){let s=L.join(n?.destination??R.package.location,"package.json"),l=n?JSON.parse(C.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},C.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
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 Q}from"@papit/information";import{Arguments as w}from"@papit/arguments";import L from"node:path";import C 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 C.readdirSync(e).length>0}catch{return!1}}function ce(e){C.existsSync(e)&&C.statSync(e).isDirectory()||C.mkdirSync(e)}async function U(e,n,a){let s=L.join(n?.destination??R.package.location,"package.json"),l=n?JSON.parse(C.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},C.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),i.createSession();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),i.clearSession(),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
3
  `)}import ee from"node:path";import B from"node:fs";import{Arguments as P}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=P.string("name");a===void 0&&(a=(await m.prompt("name",!0)).input,n=!0);let s=P.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=P.string("description");c===void 0&&(n&&m.write(),c=(await m.prompt("description")).input,n=!0);let r=P.string("license");if(r===void 0&&(n&&m.write(),r=(await m.prompt("license (default MIT)")).input,n=!0),r){let t=P.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=P.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()})();
4
+ `),m.createSession();let n=!1,a=P.string("name");a===void 0&&(a=(await m.prompt("name",!0)).input,n=!0);let s=P.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=P.string("description");c===void 0&&(n&&m.write(),c=(await m.prompt("description")).input,n=!0);let r=P.string("license");if(r===void 0&&(n&&m.write(),r=(await m.prompt("license (default MIT)")).input,n=!0),r){let t=P.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=P.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=pe.ERROR?{index:2,text:"project"}: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()})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@papit/create",
3
3
  "description": "",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "scripts": {
6
6
  "build": "npx @papit/build -- --error --ancestors",
7
7
  "watch": "tsc -w",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@papit/arguments": "0.0.1",
52
- "@papit/information": "0.0.2",
52
+ "@papit/information": "0.0.3",
53
53
  "@papit/terminal": "0.0.1"
54
54
  },
55
55
  "devDependencies": {
@@ -69,5 +69,5 @@
69
69
  },
70
70
  "components": {}
71
71
  },
72
- "remoteVersion": "0.0.1"
72
+ "remoteVersion": "0.0.3"
73
73
  }
@@ -1,30 +0,0 @@
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
-
@@ -1,49 +0,0 @@
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