5htp 0.3.8 → 0.3.9
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/package.json +1 -1
- package/src/compiler/index.ts +34 -12
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.9",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp.git",
|
|
7
7
|
"license": "MIT",
|
package/src/compiler/index.ts
CHANGED
|
@@ -19,6 +19,14 @@ import { TCompileMode } from './common';
|
|
|
19
19
|
|
|
20
20
|
type TCompilerCallback = (compiler: webpack.Compiler) => void
|
|
21
21
|
|
|
22
|
+
type TServiceMetas = {
|
|
23
|
+
id: string,
|
|
24
|
+
name: string,
|
|
25
|
+
parent: string,
|
|
26
|
+
dependences: string,
|
|
27
|
+
importationPath: string
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
/*----------------------------------
|
|
23
31
|
- FONCTION
|
|
24
32
|
----------------------------------*/
|
|
@@ -93,7 +101,7 @@ export default class Compiler {
|
|
|
93
101
|
|
|
94
102
|
private findServices( dir: string ) {
|
|
95
103
|
|
|
96
|
-
const blacklist = ['node_modules', '5htp-core']
|
|
104
|
+
const blacklist = ['node_modules', '5htp-core', '5htp']
|
|
97
105
|
const files: string[] = [];
|
|
98
106
|
const dirents = fs.readdirSync(dir, { withFileTypes: true });
|
|
99
107
|
|
|
@@ -135,37 +143,51 @@ export default class Compiler {
|
|
|
135
143
|
|
|
136
144
|
// Index services
|
|
137
145
|
const searchDirs = {
|
|
146
|
+
// The less priority is the first
|
|
147
|
+
// The last override the first if there are duplicates
|
|
138
148
|
'@server/services/': path.join(cli.paths.core.src, 'server', 'services'),
|
|
139
149
|
'@/server/services/': path.join(app.paths.src, 'server', 'services'),
|
|
140
150
|
'': path.join(app.paths.root, 'node_modules'),
|
|
141
151
|
}
|
|
142
152
|
|
|
153
|
+
const servicesIndex: {[id: string]: TServiceMetas} = {};
|
|
143
154
|
for (const importationPrefix in searchDirs) {
|
|
144
155
|
|
|
145
156
|
const searchDir = searchDirs[ importationPrefix ];
|
|
146
157
|
const services = this.findServices(searchDir);
|
|
147
158
|
|
|
148
159
|
for (const serviceDir of services) {
|
|
149
|
-
|
|
150
160
|
const metasFile = path.join( serviceDir, 'service.json');
|
|
151
|
-
const { id, name, parent, dependences } = require(metasFile);
|
|
152
161
|
|
|
153
162
|
// The +1 is to remove the slash
|
|
154
163
|
const importationPath = importationPrefix + serviceDir.substring( searchDir.length + 1 );
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
|
|
165
|
+
const serviceMetas = require(metasFile);
|
|
166
|
+
|
|
167
|
+
servicesIndex[ metasFile ] = {
|
|
168
|
+
...serviceMetas,
|
|
169
|
+
importationPath
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Create importation directives
|
|
175
|
+
for (const serviceId in servicesIndex) {
|
|
176
|
+
|
|
177
|
+
const { id, name, parent, dependences, importationPath } = servicesIndex[ serviceId ];
|
|
178
|
+
|
|
179
|
+
// Generate index & typings
|
|
180
|
+
imported.push(`import type ${name} from "${importationPath}";`);
|
|
181
|
+
exportedType.push(`'${id}': ${name},`);
|
|
182
|
+
// NOTE: only import enabled packages to optimize memory
|
|
183
|
+
// TODO: don't index non-setuped packages in the exported metas
|
|
184
|
+
exportedMetas.push(`'${id}': {
|
|
162
185
|
class: () => require("${importationPath}"),
|
|
163
186
|
id: "${id}",
|
|
164
187
|
name: "${name}",
|
|
165
188
|
parent: "${parent}",
|
|
166
189
|
dependences: ${JSON.stringify(dependences)},
|
|
167
|
-
|
|
168
|
-
}
|
|
190
|
+
},`);
|
|
169
191
|
}
|
|
170
192
|
|
|
171
193
|
// Define the app class identifier
|