5htp 0.6.3 → 0.6.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.
- package/app/index.ts +8 -2
- package/cli.js +13 -0
- package/commands/build.ts +35 -8
- package/commands/refresh.ts +18 -0
- package/compiler/client/index.ts +5 -7
- package/compiler/common/babel/index.ts +0 -10
- package/compiler/common/babel/plugins/services.ts +263 -13
- package/compiler/common/babel/routes/routes.ts +500 -13
- package/compiler/common/index.ts +9 -13
- package/compiler/index.ts +32 -17
- package/compiler/server/index.ts +6 -3
- package/index.ts +5 -3
- package/package.json +3 -4
- package/readme.md +14 -2
- package/compiler/common/babel/plugins/form.ts +0 -191
- package/compiler/common/babel/plugins/icones-svg.ts +0 -376
- package/compiler/common/babel/plugins/injection-dependances/index.ts +0 -225
- package/compiler/common/babel/plugins/injection-dependances/remplacerFonction.ts +0 -226
- package/compiler/common/babel/plugins/queries/index.ts +0 -166
- package/compiler/common/plugins/indexage/_utils/Stringify.ts +0 -72
- package/compiler/common/plugins/indexage/_utils/annotations.ts +0 -88
- package/compiler/common/plugins/indexage/_utils/iterateur.ts +0 -52
- package/compiler/common/plugins/indexage/icones-svg/index.ts +0 -207
- package/compiler/common/plugins/indexage/index.ts +0 -134
- package/compiler/common/plugins/indexage/indexeur.ts +0 -13
- package/compiler/common/plugins/indexage/injection-dependances/index.ts +0 -68
package/compiler/index.ts
CHANGED
|
@@ -273,17 +273,14 @@ export default class Compiler {
|
|
|
273
273
|
|
|
274
274
|
import { ${appClassIdentifier} as ${appClassIdentifier}Client } from "@/client";
|
|
275
275
|
import ${appClassIdentifier}Server from "@/server/.generated/app";
|
|
276
|
-
|
|
277
|
-
import { ApplicationProperties as ClientApplicationProperties } from "@client/app";
|
|
278
|
-
import { ApplicationProperties as ServerApplicationProperties } from "@server/app";
|
|
279
|
-
|
|
280
|
-
type ClientServices = Omit<${appClassIdentifier}Client, ClientApplicationProperties>;
|
|
281
|
-
type ServerServices = Omit<${appClassIdentifier}Server, ServerApplicationProperties | keyof ClientServices>;
|
|
282
276
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
277
|
+
export const Router: ${appClassIdentifier}Client['Router'];
|
|
278
|
+
|
|
279
|
+
${sortedServices.map(service => service.name !== 'Router'
|
|
280
|
+
? `export const ${service.name}: ${appClassIdentifier}Server["${service.name}"];`
|
|
281
|
+
: ''
|
|
282
|
+
).join('\n')}
|
|
283
|
+
|
|
287
284
|
}
|
|
288
285
|
|
|
289
286
|
declare module '@models/types' {
|
|
@@ -344,13 +341,15 @@ export default (): ClientContext => React.useContext<ClientContext>(ReactClientC
|
|
|
344
341
|
// @/server/.generated/app.ts
|
|
345
342
|
fs.outputFileSync(
|
|
346
343
|
path.join( app.paths.server.generated, 'app.ts'),
|
|
347
|
-
`
|
|
344
|
+
`
|
|
345
|
+
import { Application } from '@server/app/index';
|
|
346
|
+
import { ServicesContainer } from '@server/app/service/container';
|
|
348
347
|
|
|
349
348
|
${imported.join('\n')}
|
|
350
349
|
|
|
351
|
-
export default class ${appClassIdentifier} extends Application {
|
|
350
|
+
export default class ${appClassIdentifier} extends Application<ServicesContainer, CurrentUser> {
|
|
352
351
|
|
|
353
|
-
//
|
|
352
|
+
// Make sure the services typigs are reflecting the config and referring to the app
|
|
354
353
|
${sortedServices.map(service =>
|
|
355
354
|
`public ${service.name}!: ReturnType<${appClassIdentifier}["registered"]["${service.id}"]["start"]>;`
|
|
356
355
|
).join('\n')}
|
|
@@ -461,15 +460,31 @@ declare module '@models/types' {
|
|
|
461
460
|
);
|
|
462
461
|
}
|
|
463
462
|
|
|
464
|
-
public async
|
|
463
|
+
public async refreshGeneratedTypings({
|
|
464
|
+
cleanup = false,
|
|
465
|
+
fixNpmLinkIssues = false,
|
|
466
|
+
}: {
|
|
467
|
+
cleanup?: boolean,
|
|
468
|
+
fixNpmLinkIssues?: boolean,
|
|
469
|
+
} = {}) {
|
|
465
470
|
|
|
466
471
|
await app.warmup();
|
|
467
472
|
|
|
468
|
-
|
|
473
|
+
if (cleanup)
|
|
474
|
+
this.cleanup();
|
|
469
475
|
|
|
470
|
-
|
|
476
|
+
if (fixNpmLinkIssues)
|
|
477
|
+
this.fixNpmLinkIssues();
|
|
471
478
|
|
|
472
479
|
this.indexServices();
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
public async create() {
|
|
483
|
+
|
|
484
|
+
await this.refreshGeneratedTypings({
|
|
485
|
+
cleanup: true,
|
|
486
|
+
fixNpmLinkIssues: true,
|
|
487
|
+
});
|
|
473
488
|
|
|
474
489
|
// Create compilers
|
|
475
490
|
const multiCompiler = webpack([
|
|
@@ -530,4 +545,4 @@ declare module '@models/types' {
|
|
|
530
545
|
|
|
531
546
|
}
|
|
532
547
|
|
|
533
|
-
}
|
|
548
|
+
}
|
package/compiler/server/index.ts
CHANGED
|
@@ -43,6 +43,7 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
43
43
|
|
|
44
44
|
debug && console.info(`Creating compiler for server (${mode}).`);
|
|
45
45
|
const dev = mode === 'dev';
|
|
46
|
+
const buildCheck = dev && cli.commandName === 'build';
|
|
46
47
|
|
|
47
48
|
const commonConfig = createCommonConfig(app, 'server', mode);
|
|
48
49
|
const { aliases } = app.aliases.server.forWebpack({
|
|
@@ -69,7 +70,7 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
69
70
|
|
|
70
71
|
output: {
|
|
71
72
|
|
|
72
|
-
pathinfo: dev,
|
|
73
|
+
pathinfo: dev && !buildCheck,
|
|
73
74
|
|
|
74
75
|
libraryTarget: 'commonjs2',
|
|
75
76
|
|
|
@@ -198,7 +199,9 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
198
199
|
},
|
|
199
200
|
|
|
200
201
|
// https://webpack.js.org/configuration/devtool/#devtool
|
|
201
|
-
devtool:
|
|
202
|
+
devtool: buildCheck
|
|
203
|
+
? false
|
|
204
|
+
: dev
|
|
202
205
|
? 'eval-source-map' // Recommended choice for development builds with high quality SourceMaps.
|
|
203
206
|
: 'source-map', // Recommended choice for production builds with high quality SourceMaps.
|
|
204
207
|
|
|
@@ -209,4 +212,4 @@ export default function createCompiler( app: App, mode: TCompileMode ): webpack.
|
|
|
209
212
|
};
|
|
210
213
|
|
|
211
214
|
return config;
|
|
212
|
-
};
|
|
215
|
+
};
|
package/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env -S npx ts-node
|
|
2
|
-
|
|
3
1
|
process.traceDeprecation = true;
|
|
4
2
|
|
|
5
3
|
/*----------------------------------
|
|
@@ -35,6 +33,8 @@ export class CLI {
|
|
|
35
33
|
|
|
36
34
|
// Context
|
|
37
35
|
public args: TArgsObject = {};
|
|
36
|
+
|
|
37
|
+
public commandName: string | null = null;
|
|
38
38
|
|
|
39
39
|
public debug: boolean = false;
|
|
40
40
|
|
|
@@ -61,6 +61,7 @@ export class CLI {
|
|
|
61
61
|
public commands: { [name: string]: TCliCommand } = {
|
|
62
62
|
"init": () => import('./commands/init'),
|
|
63
63
|
"dev": () => import('./commands/dev'),
|
|
64
|
+
"refresh": () => import('./commands/refresh'),
|
|
64
65
|
"build": () => import('./commands/build'),
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -113,6 +114,7 @@ export class CLI {
|
|
|
113
114
|
|
|
114
115
|
public async runCommand(command: string) {
|
|
115
116
|
|
|
117
|
+
this.commandName = command;
|
|
116
118
|
this.debug && console.info(`Running command ${command}`, this.args);
|
|
117
119
|
|
|
118
120
|
// Check existance
|
|
@@ -186,4 +188,4 @@ export class CLI {
|
|
|
186
188
|
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
export default new CLI()
|
|
191
|
+
export default new CLI()
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.4",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp.git",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"bin": {
|
|
9
|
-
"5htp": "
|
|
9
|
+
"5htp": "cli.js"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=
|
|
12
|
+
"node": ">=18.20.0",
|
|
13
13
|
"npm": ">=3.10.10"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"@babel/preset-react": "^7.14.5",
|
|
27
27
|
"@babel/preset-typescript": "^7.15.0",
|
|
28
28
|
"@prefresh/webpack": "^3.3.2",
|
|
29
|
-
"@squoosh/lib": "^0.4.0",
|
|
30
29
|
"@tailwindcss/postcss": "^4.1.17",
|
|
31
30
|
"@types/babel__core": "^7.1.16",
|
|
32
31
|
"@types/cookie": "^0.4.1",
|
package/readme.md
CHANGED
|
@@ -22,6 +22,8 @@ Full Stack Typescript framework designed for **developers and users experience**
|
|
|
22
22
|
|
|
23
23
|
## Get Started
|
|
24
24
|
|
|
25
|
+
Requires Node.js `18.20+` or any compatible `20.x` release.
|
|
26
|
+
|
|
25
27
|
1. Install:
|
|
26
28
|
|
|
27
29
|
`npm i -g 5htp`
|
|
@@ -34,10 +36,20 @@ Full Stack Typescript framework designed for **developers and users experience**
|
|
|
34
36
|
|
|
35
37
|
`5htp dev`
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
Dev compilation output is written to `bin-dev`.
|
|
40
|
+
|
|
41
|
+
4. Build output files with the development config:
|
|
38
42
|
|
|
39
43
|
`5htp build`
|
|
40
44
|
|
|
45
|
+
`5htp build dev`
|
|
46
|
+
|
|
47
|
+
5. Build for production:
|
|
48
|
+
|
|
49
|
+
`5htp build prod`
|
|
50
|
+
|
|
51
|
+
Build output is written to `bin`.
|
|
52
|
+
|
|
41
53
|
## To be done:
|
|
42
54
|
|
|
43
55
|
- [ ] Update templates & documentation
|
|
@@ -57,4 +69,4 @@ Full Stack Typescript framework designed for **developers and users experience**
|
|
|
57
69
|
- [ ] Improve ORM: make definition based on code instead of database structure
|
|
58
70
|
- [ ] Automatically generates types that associate api routes urls to their return types
|
|
59
71
|
- [ ] Allow to create CLI apps
|
|
60
|
-
- [ ] Fix Typescript errors
|
|
72
|
+
- [ ] Fix Typescript errors
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/*----------------------------------
|
|
2
|
-
- DEPENDANCES
|
|
3
|
-
----------------------------------*/
|
|
4
|
-
|
|
5
|
-
import { PluginObj } from '@babel/core';
|
|
6
|
-
|
|
7
|
-
import * as types from '@babel/types'
|
|
8
|
-
import generate from '@babel/generator';
|
|
9
|
-
|
|
10
|
-
/*----------------------------------
|
|
11
|
-
- WEBPACK RULE
|
|
12
|
-
----------------------------------*/
|
|
13
|
-
module.exports = {
|
|
14
|
-
test: "**/client/**/*.tsx",
|
|
15
|
-
plugins: [
|
|
16
|
-
[Plugin]
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const debug = false
|
|
21
|
-
|
|
22
|
-
/*----------------------------------
|
|
23
|
-
- PLUGIN
|
|
24
|
-
----------------------------------*/
|
|
25
|
-
function Plugin (babel) {
|
|
26
|
-
|
|
27
|
-
const t = babel.types as typeof types;
|
|
28
|
-
|
|
29
|
-
const plugin: PluginObj<{
|
|
30
|
-
fichier: string,
|
|
31
|
-
cancel: boolean
|
|
32
|
-
}> = {
|
|
33
|
-
pre(state) {
|
|
34
|
-
|
|
35
|
-
this.fichier = state.opts.filename as string;
|
|
36
|
-
|
|
37
|
-
if (!('useForm' in state.scope.bindings))
|
|
38
|
-
this.cancel = true;
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
visitor: {
|
|
42
|
-
JSXElement(instruction) {
|
|
43
|
-
|
|
44
|
-
if (this.cancel === true)
|
|
45
|
-
return;
|
|
46
|
-
|
|
47
|
-
const balise = instruction.node.openingElement;
|
|
48
|
-
|
|
49
|
-
/*
|
|
50
|
-
<Champs.metas.titre className="full" attrsChamp={{ className: "h1" }} />
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
if (!(
|
|
54
|
-
balise.selfClosing === true
|
|
55
|
-
&&
|
|
56
|
-
balise.name.type === 'JSXMemberExpression'
|
|
57
|
-
&&
|
|
58
|
-
balise.name.property.type === 'JSXIdentifier'
|
|
59
|
-
))
|
|
60
|
-
return;
|
|
61
|
-
|
|
62
|
-
debug && console.log(`[compilation][babel][form] Original: `, generate(instruction.node).code);
|
|
63
|
-
|
|
64
|
-
// Si le premier element du memberexpression est Champ
|
|
65
|
-
let nomA: types.JSXMemberExpression | types.JSXIdentifier = balise.name;
|
|
66
|
-
while (nomA.type === 'JSXMemberExpression')
|
|
67
|
-
nomA = nomA.object;
|
|
68
|
-
if (!nomA.name.startsWith('Champs'))
|
|
69
|
-
return;
|
|
70
|
-
|
|
71
|
-
// Ne pas parcourir les élements enfant
|
|
72
|
-
// Avec .stop, babel arrête d'itérer les élements voisins à partir du 6ème - 7ème
|
|
73
|
-
//instruction.stop();
|
|
74
|
-
instruction.skip();
|
|
75
|
-
|
|
76
|
-
// Transformation de la lste des attributs en un objet
|
|
77
|
-
/*
|
|
78
|
-
className="full" attrsChamp={{ className: "h1" }}
|
|
79
|
-
|
|
80
|
-
=>
|
|
81
|
-
|
|
82
|
-
{ className: "full", attrsChamp: { className: "h1" } }
|
|
83
|
-
*/
|
|
84
|
-
let objAttributs: types.ObjectProperty[] = [];
|
|
85
|
-
for (const attribut of balise.attributes)
|
|
86
|
-
if (
|
|
87
|
-
attribut.type === 'JSXAttribute' &&
|
|
88
|
-
attribut.value !== undefined &&
|
|
89
|
-
typeof attribut.name.name === "string"
|
|
90
|
-
) {
|
|
91
|
-
|
|
92
|
-
let propValue: types.ObjectProperty["value"];
|
|
93
|
-
if (attribut.value === null) // <Champ.titre autoFocus />
|
|
94
|
-
propValue = t.booleanLiteral(true);
|
|
95
|
-
else if (attribut.value.type !== 'JSXExpressionContainer')
|
|
96
|
-
propValue = attribut.value;
|
|
97
|
-
else if (attribut.value.expression.type !== 'JSXEmptyExpression')
|
|
98
|
-
propValue = attribut.value.expression;
|
|
99
|
-
else
|
|
100
|
-
propValue = t.nullLiteral();
|
|
101
|
-
|
|
102
|
-
objAttributs.push(
|
|
103
|
-
t.objectProperty(
|
|
104
|
-
t.identifier( attribut.name.name ),
|
|
105
|
-
propValue
|
|
106
|
-
)
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Traverse chaque branche du chemin du champ, dans l'ordre inverse
|
|
111
|
-
// NOTE: on aurai pu reconstituer le chemin et créer les memberexpressions en une seule itération
|
|
112
|
-
// Mais le fait d ele faire en deux itérations rend le code plus claire et maintenable
|
|
113
|
-
let cheminComposant: string[] = []
|
|
114
|
-
let brancheA: types.JSXMemberExpression | types.JSXIdentifier = balise.name;
|
|
115
|
-
while (brancheA.type === 'JSXMemberExpression') {
|
|
116
|
-
|
|
117
|
-
const { property } = brancheA;
|
|
118
|
-
|
|
119
|
-
cheminComposant.unshift(property.name)
|
|
120
|
-
brancheA = brancheA.object;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
let cheminSchema: types.MemberExpression | types.OptionalMemberExpression = t.memberExpression(
|
|
124
|
-
t.identifier('Champs'),
|
|
125
|
-
t.identifier('schema')
|
|
126
|
-
);
|
|
127
|
-
let cheminDonnees: types.MemberExpression | types.OptionalMemberExpression = t.memberExpression(
|
|
128
|
-
t.identifier('Champs'),
|
|
129
|
-
t.identifier('data')
|
|
130
|
-
);
|
|
131
|
-
const iDerniereBranche = cheminComposant.length - 1
|
|
132
|
-
for (let iBranche = iDerniereBranche; iBranche >= 0; iBranche--) {
|
|
133
|
-
|
|
134
|
-
const branche = cheminComposant[ iBranche ];
|
|
135
|
-
|
|
136
|
-
cheminSchema = t.optionalMemberExpression(
|
|
137
|
-
cheminSchema,
|
|
138
|
-
t.identifier( branche ),
|
|
139
|
-
undefined,
|
|
140
|
-
true
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
if (iBranche !== iDerniereBranche)
|
|
144
|
-
cheminDonnees = t.optionalMemberExpression(
|
|
145
|
-
cheminDonnees,
|
|
146
|
-
t.identifier(branche),
|
|
147
|
-
undefined,
|
|
148
|
-
true
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Remplacement
|
|
154
|
-
/*
|
|
155
|
-
{Champs._render( Champs.metas?.titre, Champs._data.metas?.titre, 'metas.titre', {
|
|
156
|
-
className: "full",
|
|
157
|
-
attrsChamp: { className: "h1" }
|
|
158
|
-
})}
|
|
159
|
-
*/
|
|
160
|
-
const remplacement = t.callExpression(
|
|
161
|
-
|
|
162
|
-
// Champs.render
|
|
163
|
-
t.memberExpression(
|
|
164
|
-
t.identifier('Champs'),
|
|
165
|
-
t.identifier('render')
|
|
166
|
-
),
|
|
167
|
-
[
|
|
168
|
-
// Champs.<chemin>
|
|
169
|
-
cheminSchema,
|
|
170
|
-
|
|
171
|
-
// Champs._data.<chemin>
|
|
172
|
-
cheminDonnees,
|
|
173
|
-
|
|
174
|
-
// Chemin
|
|
175
|
-
t.stringLiteral( cheminComposant.join('.') ),
|
|
176
|
-
|
|
177
|
-
// { <attrs> }
|
|
178
|
-
t.objectExpression(objAttributs)
|
|
179
|
-
]
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
debug && console.log(`[compilation][babel][form] Remplacement: `, generate(remplacement).code );
|
|
183
|
-
|
|
184
|
-
instruction.replaceWith(remplacement);
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
return plugin;
|
|
191
|
-
}
|