okai 0.0.2 → 0.0.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/dist/index.d.ts +2 -0
- package/dist/index.js +38 -35
- package/dist/okai.d.ts +5 -0
- package/dist/okai.js +11181 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -10943,34 +10943,49 @@ function camelToKebabCase(str) {
|
|
10943
10943
|
}
|
10944
10944
|
|
10945
10945
|
// src/index.ts
|
10946
|
-
|
10947
|
-
|
10948
|
-
|
10949
|
-
|
10950
|
-
|
10946
|
+
async function cli(args) {
|
10947
|
+
const text = args.join(" ");
|
10948
|
+
if (text.trim() === "init") {
|
10949
|
+
let info = {};
|
10950
|
+
try {
|
10951
|
+
info = projectInfo(process.cwd());
|
10952
|
+
} catch (err) {
|
10953
|
+
info = {
|
10954
|
+
projectName: "",
|
10955
|
+
sln: "",
|
10956
|
+
slnDir: "",
|
10957
|
+
hostDir: "",
|
10958
|
+
migrationsDir: "",
|
10959
|
+
serviceModelDir: "",
|
10960
|
+
serviceInterfaceDir: ""
|
10961
|
+
};
|
10962
|
+
}
|
10963
|
+
fs2.writeFileSync("okai.json", JSON.stringify(info, undefined, 2));
|
10964
|
+
process.exit(0);
|
10965
|
+
}
|
10966
|
+
const baseUrl = process.env.OKAI_URL || "https://okai.servicestack.com";
|
10951
10967
|
try {
|
10952
|
-
info = projectInfo(
|
10968
|
+
const info = projectInfo(process.cwd());
|
10969
|
+
if (!info.serviceModelDir)
|
10970
|
+
throw new Error("Could not find ServiceModel directory");
|
10971
|
+
console.log(`Generating new APIs and Tables for: ${text}...`);
|
10972
|
+
const gist = await fetchGistFiles(baseUrl, text);
|
10973
|
+
const projectGist = convertToProjectGist(info, gist);
|
10974
|
+
const ctx = await createGistPreview(text, projectGist);
|
10975
|
+
ctx.screen.key("a", () => applyGist(ctx, info, projectGist, { accept: true }));
|
10976
|
+
ctx.screen.key("d", () => applyGist(ctx, info, projectGist, { discard: true }));
|
10977
|
+
ctx.screen.key("S-a", () => applyGist(ctx, info, projectGist, { acceptAll: true }));
|
10978
|
+
ctx.screen.render();
|
10953
10979
|
} catch (err) {
|
10954
|
-
|
10955
|
-
projectName: "",
|
10956
|
-
sln: "",
|
10957
|
-
slnDir: "",
|
10958
|
-
hostDir: "",
|
10959
|
-
migrationsDir: "",
|
10960
|
-
serviceModelDir: "",
|
10961
|
-
serviceInterfaceDir: ""
|
10962
|
-
};
|
10980
|
+
console.error(err);
|
10963
10981
|
}
|
10964
|
-
fs2.writeFileSync("okai.json", JSON.stringify(info, undefined, 2));
|
10965
|
-
process.exit(0);
|
10966
10982
|
}
|
10967
|
-
|
10968
|
-
async function fetchGistFiles(text2) {
|
10983
|
+
async function fetchGistFiles(baseUrl, text) {
|
10969
10984
|
const url = new URL("/gist", baseUrl);
|
10970
10985
|
if (process.env.OKAI_CACHED) {
|
10971
10986
|
url.searchParams.append("cached", `1`);
|
10972
10987
|
}
|
10973
|
-
url.searchParams.append("text",
|
10988
|
+
url.searchParams.append("text", text);
|
10974
10989
|
const res = await fetch(url);
|
10975
10990
|
if (!res.ok) {
|
10976
10991
|
throw new Error(`Failed to generate files: ${res.statusText}`);
|
@@ -11157,18 +11172,6 @@ function applyGist(ctx, info, gist, { accept = false, acceptAll = false, discard
|
|
11157
11172
|
exit(screen, info, gist);
|
11158
11173
|
}
|
11159
11174
|
}
|
11160
|
-
|
11161
|
-
|
11162
|
-
|
11163
|
-
throw new Error("Could not find ServiceModel directory");
|
11164
|
-
console.log(`Generating new APIs and Tables for: ${text}...`);
|
11165
|
-
const gist = await fetchGistFiles(text);
|
11166
|
-
const projectGist = convertToProjectGist(info, gist);
|
11167
|
-
const ctx = await createGistPreview(text, projectGist);
|
11168
|
-
ctx.screen.key("a", () => applyGist(ctx, info, projectGist, { accept: true }));
|
11169
|
-
ctx.screen.key("d", () => applyGist(ctx, info, projectGist, { discard: true }));
|
11170
|
-
ctx.screen.key("S-a", () => applyGist(ctx, info, projectGist, { acceptAll: true }));
|
11171
|
-
ctx.screen.render();
|
11172
|
-
} catch (err) {
|
11173
|
-
console.error(err);
|
11174
|
-
}
|
11175
|
+
export {
|
11176
|
+
cli
|
11177
|
+
};
|