proteum 1.0.2 → 2.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.
- package/AGENTS.md +101 -0
- package/agents/codex/AGENTS.md +95 -0
- package/agents/codex/CODING_STYLE.md +71 -0
- package/agents/codex/agents.md.zip +0 -0
- package/agents/codex/client/AGENTS.md +102 -0
- package/agents/codex/client/pages/AGENTS.md +35 -0
- package/agents/codex/server/routes/AGENTS.md +12 -0
- package/agents/codex/server/services/AGENTS.md +137 -0
- package/agents/codex/tests/AGENTS.md +8 -0
- package/cli/app/config.ts +13 -11
- package/cli/app/index.ts +74 -82
- package/cli/bin.js +1 -1
- package/cli/commands/build.ts +51 -14
- package/cli/commands/check.ts +19 -0
- package/cli/commands/deploy/app.ts +4 -8
- package/cli/commands/deploy/web.ts +16 -20
- package/cli/commands/dev.ts +189 -64
- package/cli/commands/devEvents.ts +106 -0
- package/cli/commands/init.ts +63 -57
- package/cli/commands/lint.ts +21 -0
- package/cli/commands/refresh.ts +18 -0
- package/cli/commands/typecheck.ts +18 -0
- package/cli/compiler/client/identite.ts +80 -53
- package/cli/compiler/client/index.ts +139 -213
- package/cli/compiler/common/bundleAnalysis.ts +94 -0
- package/cli/compiler/common/clientManifest.ts +67 -0
- package/cli/compiler/common/controllers.ts +288 -0
- package/cli/compiler/common/files/autres.ts +7 -18
- package/cli/compiler/common/files/images.ts +40 -37
- package/cli/compiler/common/files/style.ts +11 -22
- package/cli/compiler/common/generatedRouteModules.ts +368 -0
- package/cli/compiler/common/index.ts +31 -65
- package/cli/compiler/common/loaders/forbid-ssr-import.js +13 -0
- package/cli/compiler/common/rspackAliases.ts +13 -0
- package/cli/compiler/common/scripts.ts +37 -0
- package/cli/compiler/index.ts +781 -230
- package/cli/compiler/server/index.ts +59 -75
- package/cli/compiler/writeIfChanged.ts +21 -0
- package/cli/index.ts +71 -72
- package/cli/paths.ts +51 -57
- package/cli/print.ts +17 -11
- package/cli/tsconfig.json +5 -4
- package/cli/utils/agents.ts +100 -0
- package/cli/utils/check.ts +71 -0
- package/cli/utils/index.ts +1 -3
- package/cli/utils/keyboard.ts +8 -25
- package/cli/utils/runProcess.ts +30 -0
- package/client/app/component.tsx +29 -29
- package/client/app/index.ts +36 -57
- package/client/app/service.ts +7 -12
- package/client/app.tsconfig.json +2 -2
- package/client/components/Dialog/Manager.ssr.tsx +40 -0
- package/client/components/Dialog/Manager.tsx +119 -150
- package/client/components/Dialog/status.tsx +3 -3
- package/client/components/index.ts +1 -1
- package/client/components/types.d.ts +1 -3
- package/client/dev/hmr.ts +65 -0
- package/client/global.d.ts +2 -2
- package/client/hooks.ts +6 -9
- package/client/index.ts +2 -1
- package/client/islands/index.ts +7 -0
- package/client/islands/useDeferredModule.ts +199 -0
- package/client/pages/_layout/index.tsx +4 -12
- package/client/pages/useHeader.tsx +14 -21
- package/client/router.ts +27 -0
- package/client/services/router/components/Link.tsx +34 -27
- package/client/services/router/components/Page.tsx +6 -14
- package/client/services/router/components/router.ssr.tsx +36 -0
- package/client/services/router/components/router.tsx +63 -83
- package/client/services/router/index.tsx +185 -220
- package/client/services/router/request/api.ts +97 -119
- package/client/services/router/request/history.ts +2 -2
- package/client/services/router/request/index.ts +13 -12
- package/client/services/router/request/multipart.ts +72 -62
- package/client/services/router/response/index.tsx +68 -61
- package/client/services/router/response/page.ts +28 -32
- package/client/utils/dom.ts +17 -33
- package/common/app/index.ts +3 -3
- package/common/data/chaines/index.ts +22 -23
- package/common/data/dates.ts +35 -70
- package/common/data/markdown.ts +42 -39
- package/common/dev/serverHotReload.ts +26 -0
- package/common/errors/index.tsx +110 -142
- package/common/router/contracts.ts +29 -0
- package/common/router/index.ts +89 -108
- package/common/router/layouts.ts +34 -47
- package/common/router/pageSetup.ts +50 -0
- package/common/router/register.ts +53 -24
- package/common/router/request/api.ts +30 -36
- package/common/router/request/index.ts +2 -8
- package/common/router/response/index.ts +8 -15
- package/common/router/response/page.ts +70 -58
- package/common/utils.ts +1 -1
- package/doc/TODO.md +1 -1
- package/eslint.js +62 -0
- package/package.json +14 -49
- package/prettier.config.cjs +9 -0
- package/scripts/cleanup-generated-controllers.ts +62 -0
- package/scripts/fix-reference-app-typing.ts +490 -0
- package/scripts/refactor-client-app-imports.ts +244 -0
- package/scripts/refactor-client-pages.ts +587 -0
- package/scripts/refactor-server-controllers.ts +470 -0
- package/scripts/refactor-server-runtime-aliases.ts +360 -0
- package/scripts/restore-client-app-import-files.ts +41 -0
- package/scripts/restore-files-from-git-head.ts +20 -0
- package/scripts/update-codex-agents.ts +35 -0
- package/server/app/commands.ts +35 -64
- package/server/app/container/config.ts +48 -59
- package/server/app/container/console/index.ts +202 -248
- package/server/app/container/index.ts +33 -71
- package/server/app/controller/index.ts +61 -0
- package/server/app/index.ts +39 -105
- package/server/app/service/container.ts +41 -42
- package/server/app/service/index.ts +120 -147
- package/server/context.ts +1 -1
- package/server/index.ts +25 -1
- package/server/services/auth/index.ts +75 -115
- package/server/services/auth/router/index.ts +31 -32
- package/server/services/auth/router/request.ts +14 -16
- package/server/services/cron/CronTask.ts +13 -26
- package/server/services/cron/index.ts +14 -36
- package/server/services/disks/driver.ts +40 -58
- package/server/services/disks/drivers/local/index.ts +79 -90
- package/server/services/disks/drivers/s3/index.ts +116 -163
- package/server/services/disks/index.ts +23 -38
- package/server/services/email/index.ts +45 -104
- package/server/services/email/utils.ts +14 -27
- package/server/services/fetch/index.ts +53 -85
- package/server/services/prisma/Facet.ts +39 -91
- package/server/services/prisma/index.ts +74 -110
- package/server/services/router/generatedRuntime.ts +29 -0
- package/server/services/router/http/index.ts +78 -73
- package/server/services/router/http/multipart.ts +19 -42
- package/server/services/router/index.ts +378 -365
- package/server/services/router/request/api.ts +26 -25
- package/server/services/router/request/index.ts +44 -51
- package/server/services/router/request/service.ts +7 -11
- package/server/services/router/request/validation/zod.ts +111 -148
- package/server/services/router/response/index.ts +110 -125
- package/server/services/router/response/mask/Filter.ts +31 -72
- package/server/services/router/response/mask/index.ts +8 -15
- package/server/services/router/response/mask/selecteurs.ts +11 -25
- package/server/services/router/response/page/clientManifest.ts +25 -0
- package/server/services/router/response/page/document.tsx +199 -127
- package/server/services/router/response/page/index.tsx +89 -94
- package/server/services/router/service.ts +13 -15
- package/server/services/schema/index.ts +17 -26
- package/server/services/schema/request.ts +19 -33
- package/server/services/schema/router/index.ts +8 -11
- package/server/services/security/encrypt/aes/index.ts +15 -35
- package/server/utils/slug.ts +29 -35
- package/skills/clean-project-code/SKILL.md +63 -0
- package/skills/clean-project-code/agents/openai.yaml +4 -0
- package/tsconfig.common.json +4 -3
- package/tsconfig.json +4 -1
- package/types/aliases.d.ts +17 -21
- package/types/controller-input.test.ts +48 -0
- package/types/express-extra.d.ts +6 -0
- package/types/global/constants.d.ts +13 -0
- package/types/global/express-extra.d.ts +6 -0
- package/types/global/modules.d.ts +13 -16
- package/types/global/utils.d.ts +17 -49
- package/types/global/vendors.d.ts +62 -0
- package/types/icons.d.ts +65 -1
- package/types/uuid.d.ts +3 -0
- package/types/vendors.d.ts +62 -0
- package/cli/compiler/common/babel/index.ts +0 -170
- package/cli/compiler/common/babel/plugins/index.ts +0 -0
- package/cli/compiler/common/babel/plugins/services.ts +0 -586
- package/cli/compiler/common/babel/routes/imports.ts +0 -127
- package/cli/compiler/common/babel/routes/routes.ts +0 -1130
- package/client/services/captcha/index.ts +0 -67
- package/client/services/socket/index.ts +0 -147
- package/common/data/rte/nodes.ts +0 -83
- package/common/data/stats.ts +0 -90
- package/common/utils/rte.ts +0 -183
- package/server/services/auth/old.ts +0 -277
- package/server/services/cache/commands.ts +0 -41
- package/server/services/cache/index.ts +0 -297
- package/server/services/cache/service.json +0 -6
- package/server/services/socket/index.ts +0 -162
- package/server/services/socket/scope.ts +0 -226
- package/server/services/socket/service.json +0 -6
- package/server/services_old/SocketClient.ts +0 -92
- package/server/services_old/Token.old.ts +0 -97
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { parse } from '@babel/parser';
|
|
4
|
+
import traverse, { NodePath } from '@babel/traverse';
|
|
5
|
+
import generate from '@babel/generator';
|
|
6
|
+
import * as types from '@babel/types';
|
|
7
|
+
|
|
8
|
+
const findFiles = (dir: string): string[] => {
|
|
9
|
+
if (!fs.existsSync(dir)) return [];
|
|
10
|
+
|
|
11
|
+
const files: string[] = [];
|
|
12
|
+
|
|
13
|
+
for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
14
|
+
const filepath = path.join(dir, dirent.name);
|
|
15
|
+
|
|
16
|
+
if (dirent.isDirectory()) {
|
|
17
|
+
files.push(...findFiles(filepath));
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (dirent.isFile() && /\.(tsx?|jsx?)$/.test(filepath)) files.push(filepath);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return files;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const isFunctionLikePath = (path: NodePath) =>
|
|
28
|
+
path.isFunctionDeclaration() ||
|
|
29
|
+
path.isFunctionExpression() ||
|
|
30
|
+
path.isArrowFunctionExpression() ||
|
|
31
|
+
path.isObjectMethod() ||
|
|
32
|
+
path.isClassMethod();
|
|
33
|
+
|
|
34
|
+
const getOutermostFunctionPath = (path: NodePath) => {
|
|
35
|
+
let current: NodePath | null = path;
|
|
36
|
+
let lastFunctionPath: NodePath | null = null;
|
|
37
|
+
|
|
38
|
+
while (current && !current.isProgram()) {
|
|
39
|
+
if (isFunctionLikePath(current)) lastFunctionPath = current;
|
|
40
|
+
|
|
41
|
+
current = current.parentPath;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return lastFunctionPath;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const ensureUseContextImport = (programPath: NodePath<types.Program>) => {
|
|
48
|
+
for (const statement of programPath.node.body) {
|
|
49
|
+
if (
|
|
50
|
+
statement.type === 'ImportDeclaration' &&
|
|
51
|
+
statement.source.value === '@/client/context' &&
|
|
52
|
+
statement.specifiers.some(
|
|
53
|
+
(specifier) => specifier.type === 'ImportDefaultSpecifier' && specifier.local.name === 'useContext',
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
programPath.unshiftContainer(
|
|
60
|
+
'body',
|
|
61
|
+
types.importDeclaration(
|
|
62
|
+
[types.importDefaultSpecifier(types.identifier('useContext'))],
|
|
63
|
+
types.stringLiteral('@/client/context'),
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const ensureBlockBody = (functionPath: NodePath) => {
|
|
69
|
+
if (functionPath.isArrowFunctionExpression() && functionPath.node.body.type !== 'BlockStatement') {
|
|
70
|
+
functionPath.node.body = types.blockStatement([types.returnStatement(functionPath.node.body)]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return functionPath.get('body') as NodePath<types.BlockStatement>;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const hasExistingUseContextDeclaration = (bodyPath: NodePath<types.BlockStatement>, names: string[]) => {
|
|
77
|
+
return bodyPath.node.body.some(
|
|
78
|
+
(statement) =>
|
|
79
|
+
statement.type === 'VariableDeclaration' &&
|
|
80
|
+
statement.declarations.some(
|
|
81
|
+
(declaration) =>
|
|
82
|
+
declaration.id.type === 'ObjectPattern' &&
|
|
83
|
+
declaration.init?.type === 'CallExpression' &&
|
|
84
|
+
declaration.init.callee.type === 'Identifier' &&
|
|
85
|
+
declaration.init.callee.name === 'useContext' &&
|
|
86
|
+
names.every((name) =>
|
|
87
|
+
declaration.id.properties.some(
|
|
88
|
+
(property) =>
|
|
89
|
+
property.type === 'ObjectProperty' &&
|
|
90
|
+
property.key.type === 'Identifier' &&
|
|
91
|
+
property.key.name === name,
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const objectPatternHasProperty = (pattern: types.ObjectPattern, localName: string) =>
|
|
99
|
+
pattern.properties.some(
|
|
100
|
+
(property) =>
|
|
101
|
+
property.type === 'ObjectProperty' &&
|
|
102
|
+
property.value.type === 'Identifier' &&
|
|
103
|
+
property.value.name === localName,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const addObjectPatternProperty = (pattern: types.ObjectPattern, keyName: string, localName: string = keyName) => {
|
|
107
|
+
if (objectPatternHasProperty(pattern, localName)) return;
|
|
108
|
+
|
|
109
|
+
pattern.properties.push(
|
|
110
|
+
types.objectProperty(types.identifier(keyName), types.identifier(localName), false, keyName === localName),
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const getUseContextStatements = (bodyPath: NodePath<types.BlockStatement>) => {
|
|
115
|
+
return bodyPath
|
|
116
|
+
.get('body')
|
|
117
|
+
.filter(
|
|
118
|
+
(statementPath) =>
|
|
119
|
+
statementPath.isVariableDeclaration() &&
|
|
120
|
+
statementPath.node.declarations.length === 1 &&
|
|
121
|
+
statementPath.node.declarations[0].id.type === 'ObjectPattern' &&
|
|
122
|
+
statementPath.node.declarations[0].init?.type === 'CallExpression' &&
|
|
123
|
+
statementPath.node.declarations[0].init.callee.type === 'Identifier' &&
|
|
124
|
+
statementPath.node.declarations[0].init.callee.name === 'useContext',
|
|
125
|
+
) as NodePath<types.VariableDeclaration>[];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const repoRoots = process.argv.slice(2);
|
|
129
|
+
if (!repoRoots.length)
|
|
130
|
+
throw new Error('Usage: ts-node scripts/refactor-client-app-imports.ts <repo-root> [repo-root...]');
|
|
131
|
+
|
|
132
|
+
for (const repoRoot of repoRoots) {
|
|
133
|
+
const clientRoot = path.join(repoRoot, 'client');
|
|
134
|
+
const files = findFiles(clientRoot).filter((filepath) => !filepath.includes('/client/pages/'));
|
|
135
|
+
let changedFiles = 0;
|
|
136
|
+
|
|
137
|
+
for (const filepath of files) {
|
|
138
|
+
const code = fs.readFileSync(filepath, 'utf8');
|
|
139
|
+
if (!code.includes('@app') && !code.includes('"@app"')) continue;
|
|
140
|
+
|
|
141
|
+
const ast = parse(code, {
|
|
142
|
+
sourceType: 'module',
|
|
143
|
+
plugins: ['typescript', 'jsx', 'decorators-legacy', 'classProperties'],
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const importedNames = new Set<string>();
|
|
147
|
+
const functionBindings = new Map<NodePath, Set<string>>();
|
|
148
|
+
let hasAppImport = false;
|
|
149
|
+
|
|
150
|
+
traverse(ast, {
|
|
151
|
+
ImportDeclaration(path) {
|
|
152
|
+
if (path.node.source.value !== '@app') return;
|
|
153
|
+
|
|
154
|
+
hasAppImport = true;
|
|
155
|
+
|
|
156
|
+
for (const specifier of path.node.specifiers) {
|
|
157
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier')
|
|
158
|
+
importedNames.add(specifier.local.name);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
Identifier(path) {
|
|
162
|
+
if (!importedNames.has(path.node.name)) return;
|
|
163
|
+
|
|
164
|
+
if (!path.isReferencedIdentifier()) return;
|
|
165
|
+
|
|
166
|
+
const binding = path.scope.getBinding(path.node.name);
|
|
167
|
+
if (!binding?.path.isImportSpecifier()) return;
|
|
168
|
+
|
|
169
|
+
const functionPath = getOutermostFunctionPath(path);
|
|
170
|
+
if (!functionPath) return;
|
|
171
|
+
|
|
172
|
+
const names = functionBindings.get(functionPath) || new Set<string>();
|
|
173
|
+
names.add(path.node.name);
|
|
174
|
+
functionBindings.set(functionPath, names);
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
if (!hasAppImport) continue;
|
|
179
|
+
|
|
180
|
+
traverse(ast, {
|
|
181
|
+
Program(programPath) {
|
|
182
|
+
for (const statementPath of programPath.get('body')) {
|
|
183
|
+
if (!statementPath.isImportDeclaration()) continue;
|
|
184
|
+
|
|
185
|
+
if (statementPath.node.source.value === '@app') statementPath.remove();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
ensureUseContextImport(programPath);
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
for (const [functionPath, namesSet] of functionBindings) {
|
|
193
|
+
const names = [...namesSet].sort((a, b) => a.localeCompare(b));
|
|
194
|
+
const bodyPath = ensureBlockBody(functionPath);
|
|
195
|
+
const useContextStatements = getUseContextStatements(bodyPath);
|
|
196
|
+
|
|
197
|
+
if (hasExistingUseContextDeclaration(bodyPath, names)) continue;
|
|
198
|
+
|
|
199
|
+
if (useContextStatements.length) {
|
|
200
|
+
const primaryDeclaration = useContextStatements[0].node.declarations[0];
|
|
201
|
+
const primaryPattern = primaryDeclaration.id as types.ObjectPattern;
|
|
202
|
+
|
|
203
|
+
for (const statementPath of useContextStatements.slice(1)) {
|
|
204
|
+
const declaration = statementPath.node.declarations[0];
|
|
205
|
+
const pattern = declaration.id as types.ObjectPattern;
|
|
206
|
+
|
|
207
|
+
for (const property of pattern.properties) {
|
|
208
|
+
if (
|
|
209
|
+
property.type === 'ObjectProperty' &&
|
|
210
|
+
property.key.type === 'Identifier' &&
|
|
211
|
+
property.value.type === 'Identifier'
|
|
212
|
+
)
|
|
213
|
+
addObjectPatternProperty(primaryPattern, property.key.name, property.value.name);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
statementPath.remove();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
for (const name of names) addObjectPatternProperty(primaryPattern, name);
|
|
220
|
+
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
bodyPath.unshiftContainer(
|
|
225
|
+
'body',
|
|
226
|
+
types.variableDeclaration('const', [
|
|
227
|
+
types.variableDeclarator(
|
|
228
|
+
types.objectPattern(
|
|
229
|
+
names.map((name) =>
|
|
230
|
+
types.objectProperty(types.identifier(name), types.identifier(name), false, true),
|
|
231
|
+
),
|
|
232
|
+
),
|
|
233
|
+
types.callExpression(types.identifier('useContext'), []),
|
|
234
|
+
),
|
|
235
|
+
]),
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
fs.writeFileSync(filepath, generate(ast, {}, code).code);
|
|
240
|
+
changedFiles++;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
console.log(`[refactor-client-app-imports] ${repoRoot}: changed ${changedFiles} files`);
|
|
244
|
+
}
|