rosetack 0.0.0 → 0.1.0

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 (50) hide show
  1. package/.github/workflows/ci.yml +72 -0
  2. package/.github/workflows/release.yml +122 -0
  3. package/LICENSE +21 -0
  4. package/benchmark.ts +227 -0
  5. package/deploy/Dockerfile.node +25 -0
  6. package/deploy/Dockerfile.static +34 -0
  7. package/deploy/api/rosetack.ts +29 -0
  8. package/deploy/docker-compose.yml +33 -0
  9. package/deploy/fly.toml +28 -0
  10. package/deploy/vercel.json +13 -0
  11. package/example/public/favicon.ico +0 -0
  12. package/example/public/logo.svg +148 -0
  13. package/example/public/rose-mark-black.png +0 -0
  14. package/example/public/rose-mark.png +0 -0
  15. package/example/public/rose-mono.png +0 -0
  16. package/example/rosetack.config.js +10 -0
  17. package/example/src/locales/en.json +8 -0
  18. package/example/src/locales/zh.json +8 -0
  19. package/example/src/pages/404.rose +15 -0
  20. package/example/src/pages/500.rose +10 -0
  21. package/example/src/pages/[lang]/about.rose +40 -0
  22. package/example/src/pages/_layout.rose +33 -0
  23. package/example/src/pages/_middleware.rose +37 -0
  24. package/example/src/pages/about.rose +67 -0
  25. package/example/src/pages/admin.rose +27 -0
  26. package/example/src/pages/api/hello.rose +19 -0
  27. package/example/src/pages/api/login.rose +55 -0
  28. package/example/src/pages/api/posts.rose +80 -0
  29. package/example/src/pages/api/secret.rose +14 -0
  30. package/example/src/pages/blog/[id].rose +25 -0
  31. package/example/src/pages/broken.rose +16 -0
  32. package/example/src/pages/fresh.rose +22 -0
  33. package/example/src/pages/garden.rose +27 -0
  34. package/example/src/pages/index.rose +84 -0
  35. package/example/src/pages/sign.rose +45 -0
  36. package/example/src/pages/thorn.rose +23 -0
  37. package/example/src/pages/vault.rose +14 -0
  38. package/go.mod +3 -0
  39. package/main.go +470 -0
  40. package/package.json +32 -11
  41. package/src/FRAMEWORK_VERSION +1 -0
  42. package/src/cli/edge.ts +127 -0
  43. package/src/cli/index.ts +777 -0
  44. package/src/cli/shell.ts +284 -0
  45. package/src/compiler/index.ts +1990 -0
  46. package/src/runtime/index.ts +624 -0
  47. package/tools/release-notes.mjs +113 -0
  48. package/tsconfig.json +17 -0
  49. package/README.md +0 -3
  50. package/index.js +0 -12
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env node
2
+ // Release body from conventional commit subjects. feat(export): add the native target
3
+ // emitters -> "- Add the native target emitters in export (`abc1234`)" Grouped under h2 …
4
+ import { execFileSync } from 'node:child_process';
5
+
6
+ const REPO = process.env.GITHUB_REPOSITORY || 'xdunli/rosetack';
7
+ const BASE = `https://github.com/${REPO}`;
8
+
9
+ const git = (args) => execFileSync('git', args, { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }).replace(/\r\n/g, '\n');
10
+ const tag = process.argv[2] || process.env.GITHUB_REF_NAME;
11
+ if (!tag) {
12
+ console.error('usage: node tools/release-notes.mjs <tag> [previous-tag] [--author]');
13
+ process.exit(1);
14
+ }
15
+ const withAuthor = process.argv.includes('--author');
16
+
17
+ let prev = process.argv[3] && !process.argv[3].startsWith('--') ? process.argv[3] : '';
18
+ if (!prev) {
19
+ const tags = git(['tag', '--sort=-v:refname']).split('\n').map((s) => s.trim()).filter(Boolean);
20
+ const i = tags.indexOf(tag);
21
+ if (i >= 0 && tags[i + 1]) prev = tags[i + 1];
22
+ }
23
+
24
+ // The first release compares against the root commit, not a tag - and its
25
+ // changelog link is the root commit's own history, not a compare range.
26
+ const root = git(['log', '--reverse', '--format=%H', tag]).split('\n').map((s) => s.trim()).filter(Boolean)[0];
27
+ const base = prev || root;
28
+
29
+ const raw = git(['log', '--no-merges', '--format=%H%x1f%an%x1f%s%x1f%b%x1e', `${base}..${tag}`]);
30
+
31
+ const SECTIONS = [
32
+ ['feat', 'Features'],
33
+ ['fix', 'Bug Fixes'],
34
+ ['perf', 'Performance'],
35
+ ['refactor', 'Changes'],
36
+ ['docs', 'Documentation'],
37
+ ['revert', 'Reverts'],
38
+ ['security', 'Security'],
39
+ ['build', 'Build'],
40
+ ['ci', 'CI'],
41
+ ['test', 'Tests'],
42
+ ['style', 'Styling'],
43
+ ];
44
+
45
+ const buckets = new Map();
46
+ const other = [];
47
+
48
+ // Only capitalize plain words: never touch `__rosetackAuth`, `post.reads`, `src/cli`.
49
+ const sentence = (s) => {
50
+ const first = s.split(/\s+/)[0] || '';
51
+ return /^[a-z]/.test(s) && !/[._/]/.test(first) ? s[0].toUpperCase() + s.slice(1) : s;
52
+ };
53
+
54
+ for (const record of raw.split('\x1e')) {
55
+ const trimmed = record.trim();
56
+ if (!trimmed) continue;
57
+ const [sha, author, subject, body = ''] = trimmed.split('\x1f');
58
+ if (!subject) continue;
59
+
60
+ const m = /^([a-z]+)(?:\(([^)]+)\))?!?:\s*(.+)$/.exec(subject);
61
+ const type = m ? m[1] : '';
62
+ const scope = m && m[3] !== undefined ? m[2] || '' : '';
63
+ let subjectText = m ? m[3] || m[2] : subject;
64
+ if (type === 'chore' && scope === 'release' && /^bump version\b/.test(subjectText)) continue;
65
+
66
+ // Issue / PR references: "(#123)" or a trailing " #123".
67
+ const refs = [];
68
+ subjectText = subjectText
69
+ .replace(/\(\s*(?:#(\d+)(?:\s*,?\s*|\s+|$))+\)/g, (whole) => {
70
+ for (const r of whole.matchAll(/#(\d+)/g)) refs.push(r[1]);
71
+ return '';
72
+ })
73
+ .replace(/\s+#(\d+)\b/g, (_w, n) => {
74
+ refs.push(n);
75
+ return '';
76
+ })
77
+ .trim();
78
+ // The body usually carries "Closes #12"; only when the subject had none.
79
+ if (!refs.length) {
80
+ const closes = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/i.exec(body);
81
+ if (closes) refs.push(closes[1]);
82
+ }
83
+ if (!subjectText) continue;
84
+
85
+ const text = sentence(subjectText);
86
+ const tail = (withAuthor ? ` by @${author}` : '')
87
+ + (refs.length ? ' ' + refs.map((n) => `([#${n}](${BASE}/issues/${n}))`).join(' ') : '')
88
+ + ` ([\`${sha.slice(0, 7)}\`](${BASE}/commit/${sha}))`;
89
+ const bullet = scope ? `- ${text} in ${scope}${tail}` : `- ${text}${tail}`;
90
+
91
+ const section = SECTIONS.find(([t]) => t === type);
92
+ if (section) {
93
+ if (!buckets.has(section[1])) buckets.set(section[1], []);
94
+ buckets.get(section[1]).push(bullet);
95
+ } else {
96
+ other.push(bullet);
97
+ }
98
+ }
99
+
100
+ const lines = [`# rosetack ${tag}`, ''];
101
+ for (const [, title] of SECTIONS) {
102
+ const items = buckets.get(title);
103
+ if (!items || !items.length) continue;
104
+ // Oldest first: a release reads as the story of the range.
105
+ lines.push(`## ${title}`, '', ...items.reverse(), '');
106
+ }
107
+ if (other.length) lines.push('## Changes', '', ...other.reverse(), '');
108
+ lines.push(
109
+ prev
110
+ ? `**Full Changelog**: ${BASE}/compare/${prev}...${tag}`
111
+ : `**Full Changelog**: ${BASE}/commits/${root}`,
112
+ );
113
+ process.stdout.write(`${lines.join('\n')}\n`);
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "outDir": "./dist",
13
+ "rootDir": "./src"
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "dist"]
17
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- ## License
2
-
3
- MIT
package/index.js DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * rosetack
3
- * @version 0.0.0
4
- * @license MIT
5
- * @repository https://github.com/neodunli/rosetack
6
- */
7
-
8
- 'use strict';
9
-
10
- module.exports = {
11
- version: '0.0.0',
12
- };