@aigne/doc-smith 0.8.14-beta → 0.8.14-beta.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.14-beta.1](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.14-beta...v0.8.14-beta.1) (2025-10-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* doc review and update ([#199](https://github.com/AIGNE-io/aigne-doc-smith/issues/199)) ([0061323](https://github.com/AIGNE-io/aigne-doc-smith/commit/006132345a17a7fae10a803656b731144ecc54c9))
|
|
9
|
+
* respect env vars for publish and improve reliability ([#204](https://github.com/AIGNE-io/aigne-doc-smith/issues/204)) ([bd14c2a](https://github.com/AIGNE-io/aigne-doc-smith/commit/bd14c2af54ebca89c8edb5861e3b1a6e3f76e92e))
|
|
10
|
+
|
|
3
11
|
## [0.8.14-beta](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.13...v0.8.14-beta) (2025-10-16)
|
|
4
12
|
|
|
5
13
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { checkContent } from "../../utils/d2-utils.mjs";
|
|
2
2
|
|
|
3
|
-
export default async function checkD2DiagramIsValid({
|
|
3
|
+
export default async function checkD2DiagramIsValid({ diagramSourceCode }) {
|
|
4
4
|
try {
|
|
5
|
-
await checkContent({ content:
|
|
5
|
+
await checkContent({ content: diagramSourceCode });
|
|
6
6
|
return {
|
|
7
7
|
isValid: true,
|
|
8
8
|
};
|
|
@@ -17,12 +17,12 @@ export default async function checkD2DiagramIsValid({ output }) {
|
|
|
17
17
|
checkD2DiagramIsValid.input_schema = {
|
|
18
18
|
type: "object",
|
|
19
19
|
properties: {
|
|
20
|
-
|
|
20
|
+
diagramSourceCode: {
|
|
21
21
|
type: "string",
|
|
22
22
|
description: "Source code of d2 diagram",
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
-
required: ["
|
|
25
|
+
required: ["diagramSourceCode"],
|
|
26
26
|
};
|
|
27
27
|
checkD2DiagramIsValid.output_schema = {
|
|
28
28
|
type: "object",
|
|
@@ -4,11 +4,11 @@ export default async function wrapDiagramCode({ diagramSourceCode }) {
|
|
|
4
4
|
try {
|
|
5
5
|
const result = await wrapCode({ content: diagramSourceCode });
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
diagramSourceCode: result,
|
|
8
8
|
};
|
|
9
9
|
} catch {
|
|
10
10
|
return {
|
|
11
|
-
|
|
11
|
+
diagramSourceCode,
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -26,10 +26,10 @@ wrapDiagramCode.input_schema = {
|
|
|
26
26
|
wrapDiagramCode.output_schema = {
|
|
27
27
|
type: "object",
|
|
28
28
|
properties: {
|
|
29
|
-
|
|
29
|
+
diagramSourceCode: {
|
|
30
30
|
type: "string",
|
|
31
31
|
description: "Source code of d2 diagram",
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
-
required: ["
|
|
34
|
+
required: ["diagramSourceCode"],
|
|
35
35
|
};
|
|
@@ -57,29 +57,27 @@ export default async function publishDocs(
|
|
|
57
57
|
|
|
58
58
|
// ----------------- main publish process flow -----------------------------
|
|
59
59
|
// Check if DOC_DISCUSS_KIT_URL is set in environment variables
|
|
60
|
-
const
|
|
61
|
-
const useEnvAppUrl = !!envAppUrl;
|
|
62
|
-
|
|
63
|
-
// Use environment variable if available, otherwise use the provided appUrl
|
|
64
|
-
if (useEnvAppUrl) {
|
|
65
|
-
appUrl = envAppUrl;
|
|
66
|
-
}
|
|
60
|
+
const useEnvAppUrl = !!(process.env.DOC_DISCUSS_KIT_URL || appUrl);
|
|
67
61
|
|
|
68
62
|
// Check if appUrl is default and not saved in config (only when not using env variable)
|
|
69
63
|
const config = await loadConfigFromFile();
|
|
70
|
-
|
|
71
|
-
const
|
|
64
|
+
appUrl = process.env.DOC_DISCUSS_KIT_URL || appUrl || config?.appUrl;
|
|
65
|
+
const hasInputAppUrl = !!appUrl;
|
|
72
66
|
|
|
67
|
+
let shouldSyncBranding = void 0;
|
|
73
68
|
let token = "";
|
|
69
|
+
let client = null;
|
|
70
|
+
let authToken = null;
|
|
71
|
+
let sessionId = null;
|
|
74
72
|
|
|
75
|
-
if (!
|
|
76
|
-
|
|
73
|
+
if (!hasInputAppUrl) {
|
|
74
|
+
authToken = await getOfficialAccessToken(BASE_URL, false);
|
|
77
75
|
|
|
78
|
-
|
|
76
|
+
sessionId = "";
|
|
79
77
|
let paymentLink = "";
|
|
80
78
|
|
|
81
79
|
if (authToken) {
|
|
82
|
-
|
|
80
|
+
client = new BrokerClient({ baseUrl: BASE_URL, authToken });
|
|
83
81
|
const info = await client.checkCacheSession({
|
|
84
82
|
needShortUrl: true,
|
|
85
83
|
sessionId: config?.checkoutId,
|
|
@@ -135,29 +133,60 @@ export default async function publishDocs(
|
|
|
135
133
|
// Ensure appUrl has protocol
|
|
136
134
|
appUrl = userInput.includes("://") ? userInput : `https://${userInput}`;
|
|
137
135
|
} else if (["new-instance", "new-instance-continue"].includes(choice)) {
|
|
138
|
-
|
|
139
|
-
shouldWithBranding = await options.prompts.confirm({
|
|
140
|
-
message: "Would you like to update the project branding (title, description, logo)?",
|
|
141
|
-
default: true,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// Deploy a new Discuss Kit service
|
|
145
|
-
let id = "";
|
|
146
|
-
let paymentUrl = "";
|
|
136
|
+
// resume previous website setup
|
|
147
137
|
if (choice === "new-instance-continue") {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
console.log(`\nCreating a new website for your documentation...`);
|
|
138
|
+
shouldSyncBranding = config?.shouldSyncBranding ?? void 0;
|
|
139
|
+
if (shouldSyncBranding !== void 0) {
|
|
140
|
+
shouldWithBranding = shouldWithBranding ?? shouldSyncBranding;
|
|
141
|
+
}
|
|
153
142
|
}
|
|
154
|
-
const { appUrl: homeUrl, token: ltToken } = (await deploy(id, paymentUrl)) || {};
|
|
155
143
|
|
|
156
|
-
|
|
157
|
-
|
|
144
|
+
if (options?.prompts?.confirm) {
|
|
145
|
+
if (shouldSyncBranding === void 0) {
|
|
146
|
+
shouldSyncBranding = await options.prompts.confirm({
|
|
147
|
+
message: "Would you like to update the project branding (title, description, logo)?",
|
|
148
|
+
default: true,
|
|
149
|
+
});
|
|
150
|
+
await saveValueToConfig(
|
|
151
|
+
"shouldSyncBranding",
|
|
152
|
+
shouldSyncBranding,
|
|
153
|
+
"Should sync branding for documentation",
|
|
154
|
+
);
|
|
155
|
+
shouldWithBranding = shouldSyncBranding;
|
|
156
|
+
} else {
|
|
157
|
+
console.log(
|
|
158
|
+
`Would you like to update the project branding (title, description, logo)? ${chalk.cyan(shouldSyncBranding ? "Yes" : "No")}`,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
let id = "";
|
|
165
|
+
if (choice === "new-instance-continue") {
|
|
166
|
+
id = sessionId;
|
|
167
|
+
console.log(`\nResuming your previous website setup...`);
|
|
168
|
+
} else {
|
|
169
|
+
console.log(`\nCreating a new website for your documentation...`);
|
|
170
|
+
}
|
|
171
|
+
const { appUrl: homeUrl, token: ltToken } = (await deploy(id, paymentLink)) || {};
|
|
172
|
+
|
|
173
|
+
appUrl = homeUrl;
|
|
174
|
+
token = ltToken;
|
|
175
|
+
} catch (error) {
|
|
176
|
+
const errorMsg = error?.message || "Unknown error occurred";
|
|
177
|
+
return { message: `${chalk.red("❌ Failed to create website:")} ${errorMsg}` };
|
|
178
|
+
}
|
|
158
179
|
}
|
|
159
180
|
}
|
|
160
181
|
|
|
182
|
+
if (sessionId) {
|
|
183
|
+
authToken = await getOfficialAccessToken(BASE_URL, false);
|
|
184
|
+
client = client || new BrokerClient({ baseUrl: BASE_URL, authToken });
|
|
185
|
+
|
|
186
|
+
const { vendors } = await client.getSessionDetail(sessionId, false);
|
|
187
|
+
token = vendors?.find((vendor) => vendor.vendorType === "launcher" && vendor.token)?.token;
|
|
188
|
+
}
|
|
189
|
+
|
|
161
190
|
console.log(`\nPublishing your documentation to ${chalk.cyan(appUrl)}\n`);
|
|
162
191
|
|
|
163
192
|
const accessToken = await getAccessToken(appUrl, token);
|
|
@@ -237,6 +266,7 @@ export default async function publishDocs(
|
|
|
237
266
|
}
|
|
238
267
|
message = `✅ Documentation published successfully!`;
|
|
239
268
|
await saveValueToConfig("checkoutId", "", "Checkout ID for document deployment service");
|
|
269
|
+
await saveValueToConfig("shouldSyncBranding", "", "Should sync branding for documentation");
|
|
240
270
|
} else {
|
|
241
271
|
// If the error is 401 or 403, it means the access token is invalid
|
|
242
272
|
if (error?.includes("401") || error?.includes("403")) {
|
|
@@ -271,7 +301,6 @@ publishDocs.input_schema = {
|
|
|
271
301
|
appUrl: {
|
|
272
302
|
type: "string",
|
|
273
303
|
description: "The URL of the app.",
|
|
274
|
-
default: CLOUD_SERVICE_URL_PROD,
|
|
275
304
|
},
|
|
276
305
|
boardId: {
|
|
277
306
|
type: "string",
|
|
@@ -25,6 +25,18 @@ export default async function updateBranding({ appUrl, projectInfo, accessToken,
|
|
|
25
25
|
const componentInfo = await getComponentInfoWithMountPoint(origin, DISCUSS_KIT_DID);
|
|
26
26
|
const mountPoint = componentInfo.mountPoint || "/";
|
|
27
27
|
|
|
28
|
+
if (projectInfo.name.length > 40) {
|
|
29
|
+
console.warn(
|
|
30
|
+
`⚠️ Name is too long, it should be less than 40 characters\nWill be truncated to 40 characters`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (projectInfo.description.length > 160) {
|
|
35
|
+
console.warn(
|
|
36
|
+
`⚠️ Description is too long, it should be less than 160 characters\nWill be truncated to 160 characters`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
const res = await requestWithAuthToken(
|
|
29
41
|
joinURL(origin, mountPoint, "/api/branding"),
|
|
30
42
|
{
|
|
@@ -33,8 +45,8 @@ export default async function updateBranding({ appUrl, projectInfo, accessToken,
|
|
|
33
45
|
"Content-Type": "application/json",
|
|
34
46
|
},
|
|
35
47
|
body: JSON.stringify({
|
|
36
|
-
appName: projectInfo.name,
|
|
37
|
-
appDescription: projectInfo.description,
|
|
48
|
+
appName: projectInfo.name.slice(0, 40),
|
|
49
|
+
appDescription: projectInfo.description.slice(0, 160),
|
|
38
50
|
}),
|
|
39
51
|
},
|
|
40
52
|
accessToken,
|
package/package.json
CHANGED
package/utils/deploy.mjs
CHANGED
|
@@ -42,11 +42,6 @@ export async function deploy(id, cachedUrl) {
|
|
|
42
42
|
sessionId,
|
|
43
43
|
"Checkout ID for document deployment website",
|
|
44
44
|
);
|
|
45
|
-
await saveValueToConfig(
|
|
46
|
-
"paymentUrl",
|
|
47
|
-
paymentUrl,
|
|
48
|
-
"Payment URL for document deployment website",
|
|
49
|
-
);
|
|
50
45
|
|
|
51
46
|
if (!isResuming) {
|
|
52
47
|
await open(paymentUrl);
|