@limecloud/agent-app-studio 0.1.2 → 0.1.3
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.md +1 -1
- package/package.json +1 -1
- package/src/cli.mjs +8 -2
- package/src/core/packager.mjs +12 -6
- package/src/core/publisher.mjs +5 -1
- package/src/server.mjs +2 -2
package/APP.md
CHANGED
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -19,7 +19,13 @@ export async function runCli(argv) {
|
|
|
19
19
|
case "project inspect":
|
|
20
20
|
return printJson(await inspectProject(options.appDir || "."));
|
|
21
21
|
case "package":
|
|
22
|
-
return printJson(
|
|
22
|
+
return printJson(
|
|
23
|
+
await packageProject({
|
|
24
|
+
appDir: options.appDir || ".",
|
|
25
|
+
outDir: options.outDir,
|
|
26
|
+
includeNodeModules: Boolean(options.includeNodeModules),
|
|
27
|
+
})
|
|
28
|
+
);
|
|
23
29
|
case "publish": {
|
|
24
30
|
const auth = await resolveAuthContext(options);
|
|
25
31
|
return printJson(
|
|
@@ -83,7 +89,7 @@ Usage:
|
|
|
83
89
|
lime-agent-app-studio auth login --tenant-id <id> --token <token> [--api-base <url>]
|
|
84
90
|
lime-agent-app-studio auth status --tenant-id <id>
|
|
85
91
|
lime-agent-app-studio project inspect --app-dir <path>
|
|
86
|
-
lime-agent-app-studio package --app-dir <path> [--out-dir <path>]
|
|
92
|
+
lime-agent-app-studio package --app-dir <path> [--out-dir <path>] [--include-node-modules]
|
|
87
93
|
lime-agent-app-studio publish --app-dir <path> --app-id <id> --tenant-id <id> --channel beta --dry-run
|
|
88
94
|
lime-agent-app-studio publish --app-dir <path> --app-id <id> --tenant-id <id> --channel stable --publish
|
|
89
95
|
lime-agent-app-studio studio --port 4177
|
package/src/core/packager.mjs
CHANGED
|
@@ -27,7 +27,9 @@ export async function packageProject(options = {}) {
|
|
|
27
27
|
await mkdir(outDir, { recursive: true });
|
|
28
28
|
const packageName = `${inspection.appId}-${inspection.version}.lapp`;
|
|
29
29
|
const packagePath = join(outDir, packageName);
|
|
30
|
-
const files = await collectPackageFiles(appDir
|
|
30
|
+
const files = await collectPackageFiles(appDir, {
|
|
31
|
+
includeNodeModules: Boolean(options.includeNodeModules),
|
|
32
|
+
});
|
|
31
33
|
await writeZip(appDir, files, packagePath);
|
|
32
34
|
|
|
33
35
|
const packageHash = await sha256File(packagePath);
|
|
@@ -44,23 +46,27 @@ export async function packageProject(options = {}) {
|
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
export async function collectPackageFiles(appDir) {
|
|
49
|
+
export async function collectPackageFiles(appDir, options = {}) {
|
|
48
50
|
const root = resolve(appDir);
|
|
49
51
|
const result = [];
|
|
50
|
-
|
|
52
|
+
const excludes = new Set(defaultExcludes);
|
|
53
|
+
if (options.includeNodeModules) {
|
|
54
|
+
excludes.delete("node_modules");
|
|
55
|
+
}
|
|
56
|
+
await walk(root, root, result, excludes);
|
|
51
57
|
result.sort((a, b) => a.localeCompare(b));
|
|
52
58
|
return result;
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
async function walk(root, current, result) {
|
|
61
|
+
async function walk(root, current, result, excludes) {
|
|
56
62
|
const entries = await readdir(current, { withFileTypes: true });
|
|
57
63
|
for (const entry of entries) {
|
|
58
|
-
if (
|
|
64
|
+
if (excludes.has(entry.name)) continue;
|
|
59
65
|
if (entry.name === "dist-package") continue;
|
|
60
66
|
const fullPath = join(current, entry.name);
|
|
61
67
|
const rel = relative(root, fullPath).replace(/\\/g, "/");
|
|
62
68
|
if (entry.isDirectory()) {
|
|
63
|
-
await walk(root, fullPath, result);
|
|
69
|
+
await walk(root, fullPath, result, excludes);
|
|
64
70
|
continue;
|
|
65
71
|
}
|
|
66
72
|
if (entry.isFile()) result.push(rel);
|
package/src/core/publisher.mjs
CHANGED
|
@@ -42,7 +42,11 @@ export async function publishProject(options = {}) {
|
|
|
42
42
|
if (profile.status !== "approved") {
|
|
43
43
|
throw new Error(`当前账号未完成开发者认证:${profile.status}`);
|
|
44
44
|
}
|
|
45
|
-
const packaged = await packageProject({
|
|
45
|
+
const packaged = await packageProject({
|
|
46
|
+
appDir: options.appDir,
|
|
47
|
+
outDir: options.outDir,
|
|
48
|
+
includeNodeModules: Boolean(options.includeNodeModules),
|
|
49
|
+
});
|
|
46
50
|
const upload = await uploadDeveloperAgentAppPackage({ ...options, appId: plan.appId, packagePath: packaged.packagePath });
|
|
47
51
|
const releasePayload = {
|
|
48
52
|
version: options.version || upload.version || packaged.version,
|
package/src/server.mjs
CHANGED
|
@@ -5,8 +5,6 @@ import { createServer } from "node:http";
|
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { extname, join } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
import { inspectProject } from "./core/project.mjs";
|
|
9
|
-
import { publishProject } from "./core/publisher.mjs";
|
|
10
8
|
import { resolveAuthContext } from "./core/config.mjs";
|
|
11
9
|
|
|
12
10
|
const root = fileURLToPath(new URL("..", import.meta.url));
|
|
@@ -25,11 +23,13 @@ export async function startStudioServer(options = {}) {
|
|
|
25
23
|
}
|
|
26
24
|
if (req.method === "POST" && req.url === "/api/inspect") {
|
|
27
25
|
const body = await readJson(req);
|
|
26
|
+
const { inspectProject } = await import("./core/project.mjs");
|
|
28
27
|
return sendJson(res, await inspectProject(body.appDir || "."));
|
|
29
28
|
}
|
|
30
29
|
if (req.method === "POST" && req.url === "/api/publish") {
|
|
31
30
|
const body = await readJson(req);
|
|
32
31
|
const auth = await resolveAuthContext(body);
|
|
32
|
+
const { publishProject } = await import("./core/publisher.mjs");
|
|
33
33
|
return sendJson(res, await publishProject({ ...body, ...auth }));
|
|
34
34
|
}
|
|
35
35
|
return serveStatic(req, res);
|