@modern-js/app-tools 2.62.1-alpha.0 → 2.62.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/bin/modern.js +2 -2
- package/dist/cjs/index.js +142 -4
- package/dist/esm/index.js +248 -2
- package/dist/esm-node/index.js +130 -2
- package/dist/types/index.d.ts +6 -2
- package/package.json +18 -26
- package/dist/cjs/new/compat/hooks.js +0 -160
- package/dist/cjs/new/compat/index.js +0 -52
- package/dist/cjs/new/compat/utils.js +0 -95
- package/dist/cjs/new/constants.js +0 -37
- package/dist/cjs/new/context.js +0 -63
- package/dist/cjs/new/getConfigFile.js +0 -41
- package/dist/cjs/new/index.js +0 -76
- package/dist/cjs/new/loadPlugins.js +0 -57
- package/dist/cjs/new/run.js +0 -66
- package/dist/cjs/new/types/index.js +0 -16
- package/dist/cjs/new/utils/index.js +0 -34
- package/dist/cjs/old.js +0 -179
- package/dist/esm/new/compat/hooks.js +0 -418
- package/dist/esm/new/compat/index.js +0 -30
- package/dist/esm/new/compat/utils.js +0 -69
- package/dist/esm/new/constants.js +0 -10
- package/dist/esm/new/context.js +0 -30
- package/dist/esm/new/getConfigFile.js +0 -11
- package/dist/esm/new/index.js +0 -52
- package/dist/esm/new/loadPlugins.js +0 -94
- package/dist/esm/new/run.js +0 -79
- package/dist/esm/new/types/index.js +0 -0
- package/dist/esm/new/utils/index.js +0 -33
- package/dist/esm/old.js +0 -258
- package/dist/esm-node/new/compat/hooks.js +0 -135
- package/dist/esm-node/new/compat/index.js +0 -28
- package/dist/esm-node/new/compat/utils.js +0 -69
- package/dist/esm-node/new/constants.js +0 -10
- package/dist/esm-node/new/context.js +0 -29
- package/dist/esm-node/new/getConfigFile.js +0 -7
- package/dist/esm-node/new/index.js +0 -49
- package/dist/esm-node/new/loadPlugins.js +0 -33
- package/dist/esm-node/new/run.js +0 -42
- package/dist/esm-node/new/types/index.js +0 -0
- package/dist/esm-node/new/utils/index.js +0 -10
- package/dist/esm-node/old.js +0 -140
- package/dist/types/new/compat/hooks.d.ts +0 -8
- package/dist/types/new/compat/index.d.ts +0 -4
- package/dist/types/new/compat/utils.d.ts +0 -6
- package/dist/types/new/constants.d.ts +0 -4
- package/dist/types/new/context.d.ts +0 -32
- package/dist/types/new/getConfigFile.d.ts +0 -1
- package/dist/types/new/index.d.ts +0 -15
- package/dist/types/new/loadPlugins.d.ts +0 -9
- package/dist/types/new/run.d.ts +0 -13
- package/dist/types/new/types/index.d.ts +0 -89
- package/dist/types/new/utils/index.d.ts +0 -1
- package/dist/types/old.d.ts +0 -20
@@ -1,418 +0,0 @@
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
3
|
-
import { transformHookParams, transformHookResult, transformHookRunner } from "./utils";
|
4
|
-
function getHookRunners(context) {
|
5
|
-
var hooks = context.hooks;
|
6
|
-
return {
|
7
|
-
/**
|
8
|
-
* app tools hooks
|
9
|
-
*/
|
10
|
-
beforeConfig: /* @__PURE__ */ _async_to_generator(function() {
|
11
|
-
return _ts_generator(this, function(_state) {
|
12
|
-
return [
|
13
|
-
2,
|
14
|
-
hooks.onBeforeConfig.call()
|
15
|
-
];
|
16
|
-
});
|
17
|
-
}),
|
18
|
-
afterPrepare: /* @__PURE__ */ _async_to_generator(function() {
|
19
|
-
return _ts_generator(this, function(_state) {
|
20
|
-
return [
|
21
|
-
2,
|
22
|
-
hooks.onAfterPrepare.call()
|
23
|
-
];
|
24
|
-
});
|
25
|
-
}),
|
26
|
-
deploy: /* @__PURE__ */ _async_to_generator(function() {
|
27
|
-
return _ts_generator(this, function(_state) {
|
28
|
-
return [
|
29
|
-
2,
|
30
|
-
hooks.deploy.call()
|
31
|
-
];
|
32
|
-
});
|
33
|
-
}),
|
34
|
-
_internalRuntimePlugins: function() {
|
35
|
-
var _ref = _async_to_generator(function(params) {
|
36
|
-
return _ts_generator(this, function(_state) {
|
37
|
-
return [
|
38
|
-
2,
|
39
|
-
hooks._internalRuntimePlugins.call(params)
|
40
|
-
];
|
41
|
-
});
|
42
|
-
});
|
43
|
-
return function(params) {
|
44
|
-
return _ref.apply(this, arguments);
|
45
|
-
};
|
46
|
-
}(),
|
47
|
-
_internalServerPlugins: function() {
|
48
|
-
var _ref = _async_to_generator(function(params) {
|
49
|
-
return _ts_generator(this, function(_state) {
|
50
|
-
return [
|
51
|
-
2,
|
52
|
-
hooks._internalServerPlugins.call(params)
|
53
|
-
];
|
54
|
-
});
|
55
|
-
});
|
56
|
-
return function(params) {
|
57
|
-
return _ref.apply(this, arguments);
|
58
|
-
};
|
59
|
-
}(),
|
60
|
-
checkEntryPoint: function() {
|
61
|
-
var _ref = _async_to_generator(function(params) {
|
62
|
-
return _ts_generator(this, function(_state) {
|
63
|
-
return [
|
64
|
-
2,
|
65
|
-
hooks.checkEntryPoint.call(params)
|
66
|
-
];
|
67
|
-
});
|
68
|
-
});
|
69
|
-
return function(params) {
|
70
|
-
return _ref.apply(this, arguments);
|
71
|
-
};
|
72
|
-
}(),
|
73
|
-
modifyEntrypoints: function() {
|
74
|
-
var _ref = _async_to_generator(function(params) {
|
75
|
-
return _ts_generator(this, function(_state) {
|
76
|
-
return [
|
77
|
-
2,
|
78
|
-
hooks.modifyEntrypoints.call(params)
|
79
|
-
];
|
80
|
-
});
|
81
|
-
});
|
82
|
-
return function(params) {
|
83
|
-
return _ref.apply(this, arguments);
|
84
|
-
};
|
85
|
-
}(),
|
86
|
-
modifyFileSystemRoutes: function() {
|
87
|
-
var _ref = _async_to_generator(function(params) {
|
88
|
-
return _ts_generator(this, function(_state) {
|
89
|
-
return [
|
90
|
-
2,
|
91
|
-
hooks.modifyFileSystemRoutes.call(params)
|
92
|
-
];
|
93
|
-
});
|
94
|
-
});
|
95
|
-
return function(params) {
|
96
|
-
return _ref.apply(this, arguments);
|
97
|
-
};
|
98
|
-
}(),
|
99
|
-
modifyServerRoutes: function() {
|
100
|
-
var _ref = _async_to_generator(function(params) {
|
101
|
-
return _ts_generator(this, function(_state) {
|
102
|
-
return [
|
103
|
-
2,
|
104
|
-
hooks.modifyServerRoutes.call(params)
|
105
|
-
];
|
106
|
-
});
|
107
|
-
});
|
108
|
-
return function(params) {
|
109
|
-
return _ref.apply(this, arguments);
|
110
|
-
};
|
111
|
-
}(),
|
112
|
-
generateEntryCode: function() {
|
113
|
-
var _ref = _async_to_generator(function(params) {
|
114
|
-
return _ts_generator(this, function(_state) {
|
115
|
-
return [
|
116
|
-
2,
|
117
|
-
hooks.generateEntryCode.call(params)
|
118
|
-
];
|
119
|
-
});
|
120
|
-
});
|
121
|
-
return function(params) {
|
122
|
-
return _ref.apply(this, arguments);
|
123
|
-
};
|
124
|
-
}(),
|
125
|
-
beforeGenerateRoutes: function() {
|
126
|
-
var _ref = _async_to_generator(function(params) {
|
127
|
-
return _ts_generator(this, function(_state) {
|
128
|
-
return [
|
129
|
-
2,
|
130
|
-
hooks.onBeforeGenerateRoutes.call(params)
|
131
|
-
];
|
132
|
-
});
|
133
|
-
});
|
134
|
-
return function(params) {
|
135
|
-
return _ref.apply(this, arguments);
|
136
|
-
};
|
137
|
-
}(),
|
138
|
-
beforePrintInstructions: function() {
|
139
|
-
var _ref = _async_to_generator(function(params) {
|
140
|
-
return _ts_generator(this, function(_state) {
|
141
|
-
return [
|
142
|
-
2,
|
143
|
-
hooks.onBeforePrintInstructions.call(params)
|
144
|
-
];
|
145
|
-
});
|
146
|
-
});
|
147
|
-
return function(params) {
|
148
|
-
return _ref.apply(this, arguments);
|
149
|
-
};
|
150
|
-
}(),
|
151
|
-
/**
|
152
|
-
* common hooks
|
153
|
-
*/
|
154
|
-
config: /* @__PURE__ */ _async_to_generator(function() {
|
155
|
-
return _ts_generator(this, function(_state) {
|
156
|
-
return [
|
157
|
-
2,
|
158
|
-
hooks.config.call()
|
159
|
-
];
|
160
|
-
});
|
161
|
-
}),
|
162
|
-
resolvedConfig: function(params) {
|
163
|
-
return hooks.modifyResolvedConfig.call(params);
|
164
|
-
},
|
165
|
-
htmlPartials: function() {
|
166
|
-
var _ref = _async_to_generator(function(params) {
|
167
|
-
return _ts_generator(this, function(_state) {
|
168
|
-
return [
|
169
|
-
2,
|
170
|
-
hooks.modifyHtmlPartials.call(params)
|
171
|
-
];
|
172
|
-
});
|
173
|
-
});
|
174
|
-
return function(params) {
|
175
|
-
return _ref.apply(this, arguments);
|
176
|
-
};
|
177
|
-
}(),
|
178
|
-
commands: function() {
|
179
|
-
var _ref = _async_to_generator(function(params) {
|
180
|
-
return _ts_generator(this, function(_state) {
|
181
|
-
return [
|
182
|
-
2,
|
183
|
-
hooks.addCommand.call(params)
|
184
|
-
];
|
185
|
-
});
|
186
|
-
});
|
187
|
-
return function(params) {
|
188
|
-
return _ref.apply(this, arguments);
|
189
|
-
};
|
190
|
-
}(),
|
191
|
-
watchFiles: /* @__PURE__ */ _async_to_generator(function() {
|
192
|
-
return _ts_generator(this, function(_state) {
|
193
|
-
return [
|
194
|
-
2,
|
195
|
-
hooks.addWatchFiles.call()
|
196
|
-
];
|
197
|
-
});
|
198
|
-
}),
|
199
|
-
prepare: /* @__PURE__ */ _async_to_generator(function() {
|
200
|
-
return _ts_generator(this, function(_state) {
|
201
|
-
return [
|
202
|
-
2,
|
203
|
-
hooks.onPrepare.call()
|
204
|
-
];
|
205
|
-
});
|
206
|
-
}),
|
207
|
-
filedChange: function() {
|
208
|
-
var _ref = _async_to_generator(function(params) {
|
209
|
-
return _ts_generator(this, function(_state) {
|
210
|
-
return [
|
211
|
-
2,
|
212
|
-
hooks.onFileChanged.call(params)
|
213
|
-
];
|
214
|
-
});
|
215
|
-
});
|
216
|
-
return function(params) {
|
217
|
-
return _ref.apply(this, arguments);
|
218
|
-
};
|
219
|
-
}(),
|
220
|
-
beforeCreateCompiler: function() {
|
221
|
-
var _ref = _async_to_generator(function(params) {
|
222
|
-
return _ts_generator(this, function(_state) {
|
223
|
-
return [
|
224
|
-
2,
|
225
|
-
hooks.onBeforeCreateCompiler.call(params)
|
226
|
-
];
|
227
|
-
});
|
228
|
-
});
|
229
|
-
return function(params) {
|
230
|
-
return _ref.apply(this, arguments);
|
231
|
-
};
|
232
|
-
}(),
|
233
|
-
afterCreateCompiler: function() {
|
234
|
-
var _ref = _async_to_generator(function(params) {
|
235
|
-
return _ts_generator(this, function(_state) {
|
236
|
-
return [
|
237
|
-
2,
|
238
|
-
hooks.onAfterCreateCompiler.call(params)
|
239
|
-
];
|
240
|
-
});
|
241
|
-
});
|
242
|
-
return function(params) {
|
243
|
-
return _ref.apply(this, arguments);
|
244
|
-
};
|
245
|
-
}(),
|
246
|
-
beforeBuild: function() {
|
247
|
-
var _ref = _async_to_generator(function(params) {
|
248
|
-
return _ts_generator(this, function(_state) {
|
249
|
-
return [
|
250
|
-
2,
|
251
|
-
hooks.onBeforeBuild.call(params)
|
252
|
-
];
|
253
|
-
});
|
254
|
-
});
|
255
|
-
return function(params) {
|
256
|
-
return _ref.apply(this, arguments);
|
257
|
-
};
|
258
|
-
}(),
|
259
|
-
afterBuild: function() {
|
260
|
-
var _ref = _async_to_generator(function(params) {
|
261
|
-
return _ts_generator(this, function(_state) {
|
262
|
-
return [
|
263
|
-
2,
|
264
|
-
hooks.onAfterBuild.call(params)
|
265
|
-
];
|
266
|
-
});
|
267
|
-
});
|
268
|
-
return function(params) {
|
269
|
-
return _ref.apply(this, arguments);
|
270
|
-
};
|
271
|
-
}(),
|
272
|
-
beforeDev: /* @__PURE__ */ _async_to_generator(function() {
|
273
|
-
return _ts_generator(this, function(_state) {
|
274
|
-
return [
|
275
|
-
2,
|
276
|
-
hooks.onBeforeDev.call()
|
277
|
-
];
|
278
|
-
});
|
279
|
-
}),
|
280
|
-
afterDev: function() {
|
281
|
-
var _ref = _async_to_generator(function(params) {
|
282
|
-
return _ts_generator(this, function(_state) {
|
283
|
-
return [
|
284
|
-
2,
|
285
|
-
hooks.onAfterDev.call(params)
|
286
|
-
];
|
287
|
-
});
|
288
|
-
});
|
289
|
-
return function(params) {
|
290
|
-
return _ref.apply(this, arguments);
|
291
|
-
};
|
292
|
-
}(),
|
293
|
-
beforeDeploy: /* @__PURE__ */ _async_to_generator(function() {
|
294
|
-
return _ts_generator(this, function(_state) {
|
295
|
-
return [
|
296
|
-
2,
|
297
|
-
hooks.onBeforeDeploy.call()
|
298
|
-
];
|
299
|
-
});
|
300
|
-
}),
|
301
|
-
afterDeploy: /* @__PURE__ */ _async_to_generator(function() {
|
302
|
-
return _ts_generator(this, function(_state) {
|
303
|
-
return [
|
304
|
-
2,
|
305
|
-
hooks.onAfterDeploy.call()
|
306
|
-
];
|
307
|
-
});
|
308
|
-
}),
|
309
|
-
beforeExit: /* @__PURE__ */ _async_to_generator(function() {
|
310
|
-
return _ts_generator(this, function(_state) {
|
311
|
-
return [
|
312
|
-
2,
|
313
|
-
hooks.onBeforeExit.call()
|
314
|
-
];
|
315
|
-
});
|
316
|
-
}),
|
317
|
-
beforeRestart: /* @__PURE__ */ _async_to_generator(function() {
|
318
|
-
return _ts_generator(this, function(_state) {
|
319
|
-
return [
|
320
|
-
2,
|
321
|
-
hooks.onBeforeRestart.call()
|
322
|
-
];
|
323
|
-
});
|
324
|
-
}),
|
325
|
-
/**
|
326
|
-
* @deprecated
|
327
|
-
*/
|
328
|
-
registerDev: function() {
|
329
|
-
var _ref = _async_to_generator(function(params) {
|
330
|
-
return _ts_generator(this, function(_state) {
|
331
|
-
return [
|
332
|
-
2,
|
333
|
-
hooks.registerDev.call(params)
|
334
|
-
];
|
335
|
-
});
|
336
|
-
});
|
337
|
-
return function(params) {
|
338
|
-
return _ref.apply(this, arguments);
|
339
|
-
};
|
340
|
-
}(),
|
341
|
-
/**
|
342
|
-
* @deprecated
|
343
|
-
*/
|
344
|
-
registerBuildPlatform: function() {
|
345
|
-
var _ref = _async_to_generator(function(params) {
|
346
|
-
return _ts_generator(this, function(_state) {
|
347
|
-
return [
|
348
|
-
2,
|
349
|
-
hooks.registerBuildPlatform.call(params)
|
350
|
-
];
|
351
|
-
});
|
352
|
-
});
|
353
|
-
return function(params) {
|
354
|
-
return _ref.apply(this, arguments);
|
355
|
-
};
|
356
|
-
}(),
|
357
|
-
/**
|
358
|
-
* @deprecated
|
359
|
-
*/
|
360
|
-
addRuntimeExports: function() {
|
361
|
-
var _ref = _async_to_generator(function(params) {
|
362
|
-
return _ts_generator(this, function(_state) {
|
363
|
-
return [
|
364
|
-
2,
|
365
|
-
hooks.addRuntimeExports.call(params)
|
366
|
-
];
|
367
|
-
});
|
368
|
-
});
|
369
|
-
return function(params) {
|
370
|
-
return _ref.apply(this, arguments);
|
371
|
-
};
|
372
|
-
}()
|
373
|
-
};
|
374
|
-
}
|
375
|
-
function handleSetupResult(setupResult, api) {
|
376
|
-
if (!setupResult) {
|
377
|
-
return;
|
378
|
-
}
|
379
|
-
Object.keys(setupResult).forEach(function(key) {
|
380
|
-
var fn = setupResult[key];
|
381
|
-
if (typeof fn === "function") {
|
382
|
-
var newAPI = transformHookRunner(key);
|
383
|
-
if (api[newAPI]) {
|
384
|
-
api[newAPI](function() {
|
385
|
-
var _ref = _async_to_generator(function(params) {
|
386
|
-
var _tmp;
|
387
|
-
return _ts_generator(this, function(_state) {
|
388
|
-
switch (_state.label) {
|
389
|
-
case 0:
|
390
|
-
_tmp = [
|
391
|
-
key
|
392
|
-
];
|
393
|
-
return [
|
394
|
-
4,
|
395
|
-
fn(transformHookParams(key, params))
|
396
|
-
];
|
397
|
-
case 1:
|
398
|
-
return [
|
399
|
-
2,
|
400
|
-
transformHookResult.apply(void 0, _tmp.concat([
|
401
|
-
_state.sent()
|
402
|
-
]))
|
403
|
-
];
|
404
|
-
}
|
405
|
-
});
|
406
|
-
});
|
407
|
-
return function(params) {
|
408
|
-
return _ref.apply(this, arguments);
|
409
|
-
};
|
410
|
-
}());
|
411
|
-
}
|
412
|
-
}
|
413
|
-
});
|
414
|
-
}
|
415
|
-
export {
|
416
|
-
getHookRunners,
|
417
|
-
handleSetupResult
|
418
|
-
};
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import { getHookRunners } from "./hooks";
|
2
|
-
var compatPlugin = function() {
|
3
|
-
return {
|
4
|
-
name: "@modern-js/app-tools-compat",
|
5
|
-
registryApi: function(context, updateAppContext) {
|
6
|
-
return {
|
7
|
-
useAppContext: function() {
|
8
|
-
return context;
|
9
|
-
},
|
10
|
-
setAppContext: function(context2) {
|
11
|
-
return updateAppContext(context2);
|
12
|
-
},
|
13
|
-
useConfigContext: function() {
|
14
|
-
return context.config;
|
15
|
-
},
|
16
|
-
useResolvedConfigContext: function() {
|
17
|
-
return context.normalizedConfig;
|
18
|
-
},
|
19
|
-
useHookRunners: function() {
|
20
|
-
return getHookRunners(context);
|
21
|
-
}
|
22
|
-
};
|
23
|
-
},
|
24
|
-
setup: function(_api) {
|
25
|
-
}
|
26
|
-
};
|
27
|
-
};
|
28
|
-
export {
|
29
|
-
compatPlugin
|
30
|
-
};
|
@@ -1,69 +0,0 @@
|
|
1
|
-
function transformHookRunner(hookRunnerName) {
|
2
|
-
switch (hookRunnerName) {
|
3
|
-
case "beforeConfig":
|
4
|
-
return "onBeforeConfig";
|
5
|
-
case "prepare":
|
6
|
-
return "onPrepare";
|
7
|
-
case "afterPrepare":
|
8
|
-
return "onAfterPrepare";
|
9
|
-
case "beforeGenerateRoutes":
|
10
|
-
return "onBeforeGenerateRoutes";
|
11
|
-
case "beforePrintInstructions":
|
12
|
-
return "onBeforePrintInstructions";
|
13
|
-
case "resolvedConfig":
|
14
|
-
return "modifyResolvedConfig";
|
15
|
-
case "commands":
|
16
|
-
return "addCommand";
|
17
|
-
case "watchFiles":
|
18
|
-
return "addWatchFiles";
|
19
|
-
case "filedChange":
|
20
|
-
return "onFileChanged";
|
21
|
-
case "beforeCreateCompiler":
|
22
|
-
return "onBeforeCreateCompiler";
|
23
|
-
case "afterCreateCompiler":
|
24
|
-
return "onAfterCreateCompiler";
|
25
|
-
case "beforeBuild":
|
26
|
-
return "onBeforeBuild";
|
27
|
-
case "afterBuild":
|
28
|
-
return "onAfterBuild";
|
29
|
-
case "beforeDev":
|
30
|
-
return "onBeforeDev";
|
31
|
-
case "afterDev":
|
32
|
-
return "onAfterDev";
|
33
|
-
case "beforeDeploy":
|
34
|
-
return "onBeforeDeploy";
|
35
|
-
case "afterDeploy":
|
36
|
-
return "onAfterDeploy";
|
37
|
-
case "beforeExit":
|
38
|
-
return "onBeforeExit";
|
39
|
-
case "beforeRestart":
|
40
|
-
return "onBeforeRestart";
|
41
|
-
case "htmlPartials":
|
42
|
-
return "modifyHtmlPartials";
|
43
|
-
default:
|
44
|
-
return hookRunnerName;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
function transformHookParams(hookRunnerName, params) {
|
48
|
-
switch (hookRunnerName) {
|
49
|
-
case "resolvedConfig":
|
50
|
-
return {
|
51
|
-
resolved: params
|
52
|
-
};
|
53
|
-
default:
|
54
|
-
return params;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
function transformHookResult(hookRunnerName, result) {
|
58
|
-
switch (hookRunnerName) {
|
59
|
-
case "resolvedConfig":
|
60
|
-
return result.resolved;
|
61
|
-
default:
|
62
|
-
return result;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
export {
|
66
|
-
transformHookParams,
|
67
|
-
transformHookResult,
|
68
|
-
transformHookRunner
|
69
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
var PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
2
|
-
var DEFAULT_CONFIG_FILE = "modern.config";
|
3
|
-
var DEFAULT_SERVER_CONFIG_FILE = "modern.server-runtime.config";
|
4
|
-
var DEFAULT_RUNTIME_CONFIG_FILE = "modern.runtime";
|
5
|
-
export {
|
6
|
-
DEFAULT_CONFIG_FILE,
|
7
|
-
DEFAULT_RUNTIME_CONFIG_FILE,
|
8
|
-
DEFAULT_SERVER_CONFIG_FILE,
|
9
|
-
PACKAGE_JSON_CONFIG_NAME
|
10
|
-
};
|
package/dist/esm/new/context.js
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { address } from "@modern-js/utils";
|
3
|
-
var initAppContext = function(param) {
|
4
|
-
var appDirectory = param.appDirectory, runtimeConfigFile = param.runtimeConfigFile, options = param.options, serverConfigFile = param.serverConfigFile;
|
5
|
-
var _ref = options || {}, _ref_metaName = _ref.metaName, metaName = _ref_metaName === void 0 ? "modern-js" : _ref_metaName, _ref_apiDir = _ref.apiDir, apiDir = _ref_apiDir === void 0 ? "api" : _ref_apiDir, _ref_distDir = _ref.distDir, distDir = _ref_distDir === void 0 ? "" : _ref_distDir, _ref_sharedDir = _ref.sharedDir, sharedDir = _ref_sharedDir === void 0 ? "shared" : _ref_sharedDir;
|
6
|
-
return {
|
7
|
-
metaName,
|
8
|
-
runtimeConfigFile,
|
9
|
-
serverConfigFile,
|
10
|
-
ip: address.ip(),
|
11
|
-
port: 0,
|
12
|
-
moduleType: require(path.resolve(appDirectory, "./package.json")).type || "commonjs",
|
13
|
-
apiDirectory: path.resolve(appDirectory, apiDir),
|
14
|
-
lambdaDirectory: path.resolve(appDirectory, apiDir, "lambda"),
|
15
|
-
sharedDirectory: path.resolve(appDirectory, sharedDir),
|
16
|
-
distDirectory: distDir,
|
17
|
-
serverPlugins: [],
|
18
|
-
internalDirectory: path.resolve(appDirectory, "./node_modules/.".concat(metaName)),
|
19
|
-
htmlTemplates: {},
|
20
|
-
serverRoutes: [],
|
21
|
-
entrypoints: [],
|
22
|
-
checkedEntries: [],
|
23
|
-
apiOnly: false,
|
24
|
-
internalDirAlias: "@_".concat(metaName.replace(/-/g, "_"), "_internal"),
|
25
|
-
internalSrcAlias: "@_".concat(metaName.replace(/-/g, "_"), "_src")
|
26
|
-
};
|
27
|
-
};
|
28
|
-
export {
|
29
|
-
initAppContext
|
30
|
-
};
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import path from "path";
|
2
|
-
import { CONFIG_FILE_EXTENSIONS, findExists } from "@modern-js/utils";
|
3
|
-
import { DEFAULT_CONFIG_FILE } from "./constants";
|
4
|
-
var getConfigFile = function(configFile) {
|
5
|
-
return findExists(CONFIG_FILE_EXTENSIONS.map(function(extension) {
|
6
|
-
return path.resolve(process.cwd(), "".concat(configFile || DEFAULT_CONFIG_FILE).concat(extension));
|
7
|
-
}));
|
8
|
-
};
|
9
|
-
export {
|
10
|
-
getConfigFile
|
11
|
-
};
|
package/dist/esm/new/index.js
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
import { createAsyncHook } from "@modern-js/plugin-v2";
|
2
|
-
import { appTools as oldAppTools } from "../old";
|
3
|
-
import { compatPlugin } from "./compat";
|
4
|
-
import { DEFAULT_RUNTIME_CONFIG_FILE, DEFAULT_SERVER_CONFIG_FILE } from "./constants";
|
5
|
-
import { initAppContext } from "./context";
|
6
|
-
export * from "../defineConfig";
|
7
|
-
var appTools = function() {
|
8
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
9
|
-
// default webpack to be compatible with original projects
|
10
|
-
bundler: "webpack"
|
11
|
-
};
|
12
|
-
return {
|
13
|
-
name: "@modern-js/app-tools",
|
14
|
-
usePlugins: [
|
15
|
-
compatPlugin(),
|
16
|
-
oldAppTools(options)
|
17
|
-
],
|
18
|
-
post: [
|
19
|
-
"@modern-js/app-tools-old"
|
20
|
-
],
|
21
|
-
registryHooks: {
|
22
|
-
onBeforeConfig: createAsyncHook(),
|
23
|
-
onAfterPrepare: createAsyncHook(),
|
24
|
-
deploy: createAsyncHook(),
|
25
|
-
_internalRuntimePlugins: createAsyncHook(),
|
26
|
-
_internalServerPlugins: createAsyncHook(),
|
27
|
-
checkEntryPoint: createAsyncHook(),
|
28
|
-
modifyEntrypoints: createAsyncHook(),
|
29
|
-
modifyFileSystemRoutes: createAsyncHook(),
|
30
|
-
modifyServerRoutes: createAsyncHook(),
|
31
|
-
generateEntryCode: createAsyncHook(),
|
32
|
-
onBeforeGenerateRoutes: createAsyncHook(),
|
33
|
-
onBeforePrintInstructions: createAsyncHook(),
|
34
|
-
registerDev: createAsyncHook(),
|
35
|
-
registerBuildPlatform: createAsyncHook(),
|
36
|
-
addRuntimeExports: createAsyncHook()
|
37
|
-
},
|
38
|
-
setup: function(api) {
|
39
|
-
var context = api.getAppContext();
|
40
|
-
api.updateAppContext(initAppContext({
|
41
|
-
appDirectory: context.appDirectory,
|
42
|
-
options: {},
|
43
|
-
serverConfigFile: DEFAULT_SERVER_CONFIG_FILE,
|
44
|
-
runtimeConfigFile: DEFAULT_RUNTIME_CONFIG_FILE
|
45
|
-
}));
|
46
|
-
}
|
47
|
-
};
|
48
|
-
};
|
49
|
-
export {
|
50
|
-
appTools,
|
51
|
-
initAppContext
|
52
|
-
};
|