@adep/cli 0.1.14 → 0.1.15
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/dist/index.js +16 -3
- package/dist/vite.js +20 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -577,11 +577,23 @@ var init_http_envelope = __esm({
|
|
|
577
577
|
});
|
|
578
578
|
|
|
579
579
|
// packages/runtime/src/functions/domain.ts
|
|
580
|
-
|
|
580
|
+
function flatEntryCandidates(name) {
|
|
581
|
+
return ENTRY_SOURCE_EXTS.map((ext) => `${name}${ext}`);
|
|
582
|
+
}
|
|
583
|
+
function resolveDraftEntry(name, files) {
|
|
584
|
+
if (files[ENTRY_FILE] !== void 0) return ENTRY_FILE;
|
|
585
|
+
for (const candidate of flatEntryCandidates(name)) {
|
|
586
|
+
if (files[candidate] !== void 0) return candidate;
|
|
587
|
+
}
|
|
588
|
+
return null;
|
|
589
|
+
}
|
|
590
|
+
var MAX_TOTAL_SOURCE_BYTES, ENTRY_FILE, ENTRY_SOURCE_EXTS, FnError;
|
|
581
591
|
var init_domain = __esm({
|
|
582
592
|
"packages/runtime/src/functions/domain.ts"() {
|
|
583
593
|
"use strict";
|
|
584
594
|
MAX_TOTAL_SOURCE_BYTES = 256 * 1024;
|
|
595
|
+
ENTRY_FILE = "index.ts";
|
|
596
|
+
ENTRY_SOURCE_EXTS = [".ts", ".js", ".mjs", ".cjs"];
|
|
585
597
|
FnError = class extends Error {
|
|
586
598
|
status;
|
|
587
599
|
code;
|
|
@@ -759,6 +771,7 @@ var init_worker_executor = __esm({
|
|
|
759
771
|
"use strict";
|
|
760
772
|
init_executor();
|
|
761
773
|
init_resolve();
|
|
774
|
+
init_domain();
|
|
762
775
|
WorkerFunctionExecutor = class {
|
|
763
776
|
depsConfig;
|
|
764
777
|
fetchConfig;
|
|
@@ -769,7 +782,7 @@ var init_worker_executor = __esm({
|
|
|
769
782
|
async execute(input) {
|
|
770
783
|
const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
771
784
|
const memoryLimitMb = input.memoryLimitMb ?? DEFAULT_MEMORY_LIMIT_MB;
|
|
772
|
-
const entry = input.entry ?? "index.ts";
|
|
785
|
+
const entry = input.entry ?? resolveDraftEntry(input.fn.name, input.files) ?? "index.ts";
|
|
773
786
|
const deps = this.depsConfig === void 0 ? void 0 : resolveExecutionDeps(this.depsConfig, input.project.id, input.files["package.json"]);
|
|
774
787
|
const logs = [];
|
|
775
788
|
return new Promise((resolve15, reject) => {
|
|
@@ -6051,7 +6064,7 @@ async function collectFunctionFiles(functionsDir) {
|
|
|
6051
6064
|
if (conflicting.length > 0) throw new AmbiguousFunctionError(functionsDir, conflicting);
|
|
6052
6065
|
const out = {};
|
|
6053
6066
|
for (const name of flatNames) {
|
|
6054
|
-
out[name] = {
|
|
6067
|
+
out[name] = { [`${name}.ts`]: await readFile12(join15(functionsDir, `${name}.ts`), "utf8") };
|
|
6055
6068
|
}
|
|
6056
6069
|
for (const name of dirNames) {
|
|
6057
6070
|
const files = await collectFunctionDir(join15(functionsDir, name));
|
package/dist/vite.js
CHANGED
|
@@ -94,6 +94,18 @@ import { createHash } from "node:crypto";
|
|
|
94
94
|
|
|
95
95
|
// packages/runtime/src/functions/domain.ts
|
|
96
96
|
var MAX_TOTAL_SOURCE_BYTES = 256 * 1024;
|
|
97
|
+
var ENTRY_FILE = "index.ts";
|
|
98
|
+
var ENTRY_SOURCE_EXTS = [".ts", ".js", ".mjs", ".cjs"];
|
|
99
|
+
function flatEntryCandidates(name) {
|
|
100
|
+
return ENTRY_SOURCE_EXTS.map((ext) => `${name}${ext}`);
|
|
101
|
+
}
|
|
102
|
+
function resolveDraftEntry(name, files) {
|
|
103
|
+
if (files[ENTRY_FILE] !== void 0) return ENTRY_FILE;
|
|
104
|
+
for (const candidate of flatEntryCandidates(name)) {
|
|
105
|
+
if (files[candidate] !== void 0) return candidate;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
97
109
|
var FnError = class extends Error {
|
|
98
110
|
status;
|
|
99
111
|
code;
|
|
@@ -254,7 +266,7 @@ var WorkerFunctionExecutor = class {
|
|
|
254
266
|
async execute(input) {
|
|
255
267
|
const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
256
268
|
const memoryLimitMb = input.memoryLimitMb ?? DEFAULT_MEMORY_LIMIT_MB;
|
|
257
|
-
const entry = input.entry ?? "index.ts";
|
|
269
|
+
const entry = input.entry ?? resolveDraftEntry(input.fn.name, input.files) ?? "index.ts";
|
|
258
270
|
const deps = this.depsConfig === void 0 ? void 0 : resolveExecutionDeps(this.depsConfig, input.project.id, input.files["package.json"]);
|
|
259
271
|
const logs = [];
|
|
260
272
|
return new Promise((resolve3, reject) => {
|
|
@@ -4443,12 +4455,15 @@ async function startDevServer(options) {
|
|
|
4443
4455
|
|
|
4444
4456
|
// packages/cli/src/vite.ts
|
|
4445
4457
|
import {
|
|
4458
|
+
createAdepAutomationScriptMiddleware,
|
|
4446
4459
|
createAdepFnProxyScriptMiddleware,
|
|
4447
4460
|
createAdepProxyMiddleware,
|
|
4448
4461
|
FN_FETCH_INTERCEPTOR_SCRIPT,
|
|
4462
|
+
injectAutomationScriptTag,
|
|
4449
4463
|
injectFnProxyScriptTag,
|
|
4450
4464
|
isAddrInUse,
|
|
4451
|
-
normalizeFunctionPrefix
|
|
4465
|
+
normalizeFunctionPrefix,
|
|
4466
|
+
PREVIEW_AUTOMATION_SCRIPT
|
|
4452
4467
|
} from "@adep/vite-plugin";
|
|
4453
4468
|
var createDevServer = (opts) => startDevServer({ cwd: opts.cwd, port: opts.port, prefix: opts.prefix, log: opts.log });
|
|
4454
4469
|
var loadConfig2 = (cwd) => loadAdepConfigModule(cwd);
|
|
@@ -4458,10 +4473,13 @@ function adepVitePlugin(options = {}) {
|
|
|
4458
4473
|
var vite_default = adepVitePlugin;
|
|
4459
4474
|
export {
|
|
4460
4475
|
FN_FETCH_INTERCEPTOR_SCRIPT,
|
|
4476
|
+
PREVIEW_AUTOMATION_SCRIPT,
|
|
4461
4477
|
adepVitePlugin,
|
|
4478
|
+
createAdepAutomationScriptMiddleware,
|
|
4462
4479
|
createAdepFnProxyScriptMiddleware,
|
|
4463
4480
|
createAdepProxyMiddleware,
|
|
4464
4481
|
vite_default as default,
|
|
4482
|
+
injectAutomationScriptTag,
|
|
4465
4483
|
injectFnProxyScriptTag,
|
|
4466
4484
|
isAddrInUse,
|
|
4467
4485
|
normalizeFunctionPrefix
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adep/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "`adep` 命令行工具包位:登录 / 初始化 / 本地调试 / 部署 / 数据库维护 / 云存储 / 静态托管 / 微前端组件(widget),实现见任务单 CLI-001 ~ CLI-003 与 FE-002;子路径 `@adep/cli/vite` 提供云函数 vite 插件(CLI-014)",
|
|
6
6
|
"bin": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"commander": "14.0.2",
|
|
22
22
|
"esbuild": "0.25.12",
|
|
23
23
|
"@adep/cf-compat": "0.1.1",
|
|
24
|
-
"@adep/vite-plugin": "0.1.
|
|
24
|
+
"@adep/vite-plugin": "0.1.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@adep/
|
|
28
|
-
"@adep/
|
|
27
|
+
"@adep/runtime": "0.2.6",
|
|
28
|
+
"@adep/types": "0.2.3"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"test": "vitest run",
|