@bleedingdev/modern-js-create 3.2.0-ultramodern.11 → 3.2.0-ultramodern.110

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 (95) hide show
  1. package/README.md +158 -35
  2. package/bin/run.js +0 -0
  3. package/dist/cjs/index.cjs +1040 -0
  4. package/dist/cjs/locale/en.cjs +97 -0
  5. package/dist/cjs/locale/index.cjs +50 -0
  6. package/dist/cjs/locale/zh.cjs +97 -0
  7. package/dist/cjs/ultramodern-checks/cli/i18n-check.cjs +73 -0
  8. package/dist/cjs/ultramodern-checks/cli/oxlint.cjs +174 -0
  9. package/dist/cjs/ultramodern-checks/cli/workspace-source-check.cjs +179 -0
  10. package/dist/cjs/ultramodern-checks/index.cjs +58 -0
  11. package/dist/cjs/ultramodern-checks/oxlint-plugin.cjs +354 -0
  12. package/dist/cjs/ultramodern-package-source.cjs +133 -0
  13. package/dist/cjs/ultramodern-workspace.cjs +5616 -0
  14. package/dist/esm/index.js +1002 -0
  15. package/dist/esm/locale/en.js +59 -0
  16. package/dist/esm/locale/index.js +9 -0
  17. package/dist/esm/locale/zh.js +59 -0
  18. package/dist/esm/ultramodern-checks/cli/i18n-check.js +26 -0
  19. package/dist/esm/ultramodern-checks/cli/oxlint.js +118 -0
  20. package/dist/esm/ultramodern-checks/cli/workspace-source-check.js +124 -0
  21. package/dist/esm/ultramodern-checks/index.js +3 -0
  22. package/dist/esm/ultramodern-checks/oxlint-plugin.js +316 -0
  23. package/dist/esm/ultramodern-package-source.js +61 -0
  24. package/dist/esm/ultramodern-workspace.js +5554 -0
  25. package/dist/esm-node/index.js +1003 -0
  26. package/dist/esm-node/locale/en.js +60 -0
  27. package/dist/esm-node/locale/index.js +10 -0
  28. package/dist/esm-node/locale/zh.js +60 -0
  29. package/dist/esm-node/ultramodern-checks/cli/i18n-check.js +27 -0
  30. package/dist/esm-node/ultramodern-checks/cli/oxlint.js +119 -0
  31. package/dist/esm-node/ultramodern-checks/cli/workspace-source-check.js +125 -0
  32. package/dist/esm-node/ultramodern-checks/index.js +4 -0
  33. package/dist/esm-node/ultramodern-checks/oxlint-plugin.js +317 -0
  34. package/dist/esm-node/ultramodern-package-source.js +62 -0
  35. package/dist/esm-node/ultramodern-workspace.js +5555 -0
  36. package/dist/types/locale/en.d.ts +3 -0
  37. package/dist/types/locale/index.d.ts +117 -2
  38. package/dist/types/locale/zh.d.ts +3 -0
  39. package/dist/types/ultramodern-checks/cli/i18n-check.d.ts +9 -0
  40. package/dist/types/ultramodern-checks/cli/oxlint.d.ts +22 -0
  41. package/dist/types/ultramodern-checks/cli/workspace-source-check.d.ts +8 -0
  42. package/dist/types/ultramodern-checks/index.d.ts +3 -0
  43. package/dist/types/ultramodern-checks/oxlint-plugin.d.ts +63 -0
  44. package/dist/types/ultramodern-package-source.d.ts +28 -0
  45. package/dist/types/ultramodern-workspace.d.ts +12 -2
  46. package/package.json +52 -11
  47. package/template/.codex/hooks.json +16 -0
  48. package/template/.github/renovate.json +53 -0
  49. package/template/.github/workflows/ultramodern-gates.yml.handlebars +34 -10
  50. package/template/.mise.toml.handlebars +2 -0
  51. package/template/AGENTS.md +9 -6
  52. package/template/README.md +66 -34
  53. package/template/api/effect/index.ts.handlebars +20 -9
  54. package/template/api/lambda/hello.ts.handlebars +5 -5
  55. package/template/config/favicon.svg +5 -0
  56. package/template/config/public/assets/ultramodern-logo.svg +6 -0
  57. package/template/config/public/locales/cs/translation.json +44 -0
  58. package/template/config/public/locales/en/translation.json +44 -0
  59. package/template/lefthook.yml +10 -0
  60. package/template/modern.config.ts.handlebars +35 -3
  61. package/template/oxfmt.config.ts +8 -1
  62. package/template/oxlint.config.ts +8 -1
  63. package/template/package.json.handlebars +36 -30
  64. package/template/pnpm-workspace.yaml +34 -0
  65. package/template/rstest.config.mts +5 -0
  66. package/template/scripts/bootstrap-agent-skills.mjs +148 -15
  67. package/template/scripts/check-i18n-strings.mjs +3 -0
  68. package/template/scripts/validate-ultramodern.mjs.handlebars +494 -3
  69. package/template/src/modern-app-env.d.ts +2 -0
  70. package/template/src/modern.runtime.ts.handlebars +17 -1
  71. package/template/src/routes/[lang]/page.tsx.handlebars +209 -0
  72. package/template/src/routes/index.css.handlebars +192 -55
  73. package/template/src/routes/layout.tsx.handlebars +2 -1
  74. package/template/tailwind.config.ts.handlebars +1 -1
  75. package/template/tests/tsconfig.json +7 -0
  76. package/template/tests/ultramodern.contract.test.ts.handlebars +160 -0
  77. package/template/tsconfig.json +2 -1
  78. package/template-workspace/.agents/agent-reference-repos.json +24 -0
  79. package/template-workspace/.agents/skills-lock.json +19 -0
  80. package/template-workspace/.codex/hooks.json +16 -0
  81. package/template-workspace/.github/renovate.json +29 -0
  82. package/template-workspace/.github/workflows/ultramodern-workspace-gates.yml.handlebars +54 -0
  83. package/template-workspace/.gitignore.handlebars +5 -0
  84. package/template-workspace/.mise.toml.handlebars +2 -0
  85. package/template-workspace/AGENTS.md +36 -5
  86. package/template-workspace/README.md.handlebars +70 -11
  87. package/template-workspace/lefthook.yml +10 -0
  88. package/template-workspace/oxfmt.config.ts +1 -0
  89. package/template-workspace/oxlint.config.ts +1 -0
  90. package/template-workspace/pnpm-workspace.yaml +31 -8
  91. package/template-workspace/scripts/bootstrap-agent-skills.mjs +190 -21
  92. package/template-workspace/scripts/setup-agent-reference-repos.mjs +370 -0
  93. package/dist/index.js +0 -2474
  94. package/template/src/routes/page.tsx.handlebars +0 -136
  95. package/template-workspace/scripts/validate-ultramodern-workspace.mjs.handlebars +0 -405
@@ -17,16 +17,113 @@ const run = (command, args, options = {}) =>
17
17
  stdio: options.stdio ?? ['ignore', 'pipe', 'pipe'],
18
18
  });
19
19
 
20
+ const commandExists = (command) => {
21
+ try {
22
+ run(command, ['--version'], { stdio: 'ignore' });
23
+ return true;
24
+ } catch {
25
+ return false;
26
+ }
27
+ };
28
+
29
+ const runShell = (script) =>
30
+ run('sh', ['-lc', script], {
31
+ stdio: 'inherit',
32
+ });
33
+
34
+ const installGit = () => {
35
+ if (commandExists('git')) {
36
+ return;
37
+ }
38
+
39
+ if (commandExists('brew')) {
40
+ run('brew', ['install', 'git'], { stdio: 'inherit' });
41
+ } else if (process.platform === 'linux' && commandExists('apt-get')) {
42
+ const sudo = typeof process.getuid === 'function' && process.getuid() === 0 ? '' : 'sudo ';
43
+ runShell(`${sudo}apt-get update && ${sudo}apt-get install -y git`);
44
+ } else if (process.platform === 'linux' && commandExists('dnf')) {
45
+ const sudo = typeof process.getuid === 'function' && process.getuid() === 0 ? '' : 'sudo ';
46
+ runShell(`${sudo}dnf install -y git`);
47
+ } else if (process.platform === 'linux' && commandExists('yum')) {
48
+ const sudo = typeof process.getuid === 'function' && process.getuid() === 0 ? '' : 'sudo ';
49
+ runShell(`${sudo}yum install -y git`);
50
+ } else if (process.platform === 'linux' && commandExists('apk')) {
51
+ runShell('apk add --no-cache git');
52
+ }
53
+
54
+ if (!commandExists('git')) {
55
+ throw new Error(
56
+ 'Git is required for UltraModern setup. Install git and run pnpm skills:install again.',
57
+ );
58
+ }
59
+ };
60
+
61
+ const isInsideGitWorkTree = () => {
62
+ try {
63
+ return run('git', ['rev-parse', '--is-inside-work-tree']).trim() === 'true';
64
+ } catch {
65
+ return false;
66
+ }
67
+ };
68
+
69
+ const initializeGitRepository = () => {
70
+ if (isInsideGitWorkTree()) {
71
+ return;
72
+ }
73
+
74
+ try {
75
+ run('git', ['init', '-b', 'main'], { stdio: 'inherit' });
76
+ } catch {
77
+ run('git', ['init'], { stdio: 'inherit' });
78
+ run('git', ['branch', '-M', 'main'], { stdio: 'inherit' });
79
+ }
80
+ };
81
+
82
+ const installLefthook = () => {
83
+ try {
84
+ run('lefthook', ['install'], { stdio: 'inherit' });
85
+ } catch (error) {
86
+ console.warn(`Unable to install lefthook hooks: ${error.message}`);
87
+ }
88
+ };
89
+
90
+ const removeTree = (dir) =>
91
+ fs.rmSync(dir, {
92
+ force: true,
93
+ maxRetries: 5,
94
+ recursive: true,
95
+ retryDelay: 100,
96
+ });
97
+
20
98
  const cloneSource = (source, targetDir) => {
99
+ if (source.commit) {
100
+ run('git', ['init', targetDir]);
101
+ run('git', ['remote', 'add', 'origin', source.repository], {
102
+ cwd: targetDir,
103
+ });
104
+ run('git', ['fetch', '--depth', '1', '--quiet', 'origin', source.commit], {
105
+ cwd: targetDir,
106
+ });
107
+ run(
108
+ 'git',
109
+ [
110
+ '-c',
111
+ 'advice.detachedHead=false',
112
+ 'checkout',
113
+ '--detach',
114
+ '--quiet',
115
+ 'FETCH_HEAD',
116
+ ],
117
+ { cwd: targetDir },
118
+ );
119
+ return;
120
+ }
121
+
21
122
  const repo = source.repository.replace(/^https:\/\/github.com\//u, '');
22
123
  try {
23
- run('gh', ['repo', 'clone', repo, targetDir, '--', '--depth', '1'], {
24
- stdio: 'inherit',
25
- });
124
+ run('gh', ['repo', 'clone', repo, targetDir, '--', '--depth', '1', '--quiet']);
26
125
  } catch {
27
- run('git', ['clone', '--depth', '1', source.repository, targetDir], {
28
- stdio: 'inherit',
29
- });
126
+ run('git', ['clone', '--depth', '1', '--quiet', source.repository, targetDir]);
30
127
  }
31
128
  };
32
129
 
@@ -47,32 +144,65 @@ if (!fs.existsSync(lockPath)) {
47
144
 
48
145
  const lock = readJson(lockPath);
49
146
  const installDir = path.join(root, lock.installDir ?? '.agents/skills');
50
- const privateSources = (lock.sources ?? []).filter(
147
+ const sources = lock.sources ?? [];
148
+ const requiredCloneSources = sources.filter((source) => source.install === 'clone');
149
+ const optionalCloneSources = sources.filter(
51
150
  (source) => source.install === 'clone-if-authorized',
52
151
  );
152
+ const requiredSkills = [
153
+ ...(lock.baseline ?? []),
154
+ ...requiredCloneSources.flatMap((source) => source.baseline ?? []),
155
+ ].filter(
156
+ (skill, index, skills) =>
157
+ skills.findIndex((candidate) => candidate.name === skill.name) === index,
158
+ );
53
159
 
54
160
  if (checkOnly) {
55
- const missing = privateSources.flatMap((source) =>
161
+ const missingRequired = requiredSkills
162
+ .map((skill) => skill.name)
163
+ .filter((skillName) => !fs.existsSync(path.join(installDir, skillName, 'SKILL.md')));
164
+ const missingOptional = optionalCloneSources.flatMap((source) =>
56
165
  (source.baseline ?? [])
57
166
  .map((skill) => skill.name)
58
167
  .filter((skillName) => !fs.existsSync(path.join(installDir, skillName, 'SKILL.md'))),
59
168
  );
60
- if (missing.length > 0) {
169
+
170
+ if (missingRequired.length > 0) {
171
+ console.error(
172
+ `Required agent skills not installed: ${missingRequired.join(', ')}. Run pnpm skills:install.`,
173
+ );
174
+ process.exit(1);
175
+ }
176
+
177
+ if (missingOptional.length > 0) {
61
178
  console.warn(
62
- `Private skills not installed: ${missing.join(', ')}. Run pnpm skills:install if you have access.`,
179
+ `Private skills not installed: ${missingOptional.join(', ')}. Run pnpm skills:install if you have access.`,
63
180
  );
64
181
  } else {
65
- console.log('Agent skills are installed.');
182
+ console.log('Required and private agent skills are installed.');
183
+ process.exit(0);
66
184
  }
185
+ console.log('Required agent skills are installed.');
67
186
  process.exit(0);
68
187
  }
69
188
 
70
189
  fs.mkdirSync(installDir, { recursive: true });
190
+ installGit();
71
191
 
72
- for (const source of privateSources) {
192
+ for (const source of [...requiredCloneSources, ...optionalCloneSources]) {
73
193
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ultramodern-skills-'));
74
194
  try {
75
- cloneSource(source, tempDir);
195
+ try {
196
+ cloneSource(source, tempDir);
197
+ } catch (error) {
198
+ if (source.install === 'clone-if-authorized') {
199
+ console.warn(
200
+ `Skipping ${source.repository}; current developer may not have access.`,
201
+ );
202
+ continue;
203
+ }
204
+ throw error;
205
+ }
76
206
  for (const skill of source.baseline ?? []) {
77
207
  const sourceSkillDir = resolveSkillDir(tempDir, skill.name);
78
208
  if (!sourceSkillDir) {
@@ -84,12 +214,15 @@ for (const source of privateSources) {
84
214
  console.log(`Skipping existing ${skill.name}`);
85
215
  continue;
86
216
  }
87
- fs.rmSync(targetSkillDir, { force: true, recursive: true });
217
+ removeTree(targetSkillDir);
88
218
  }
89
219
  fs.cpSync(sourceSkillDir, targetSkillDir, { recursive: true });
90
220
  console.log(`Installed ${skill.name}`);
91
221
  }
92
222
  } finally {
93
- fs.rmSync(tempDir, { force: true, recursive: true });
223
+ removeTree(tempDir);
94
224
  }
95
225
  }
226
+
227
+ initializeGitRepository();
228
+ installLefthook();
@@ -0,0 +1,3 @@
1
+ import { runSingleAppI18nCheck } from '@modern-js/create/ultramodern-checks';
2
+
3
+ process.exitCode = runSingleAppI18nCheck();