skillverse 0.1.2 → 0.1.4

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/bin.js CHANGED
@@ -60,6 +60,77 @@ var init_db = __esm({
60
60
  }
61
61
  });
62
62
 
63
+ // src/lib/initDb.ts
64
+ import { existsSync as existsSync2 } from "fs";
65
+ import { join as join2, dirname as dirname2 } from "path";
66
+ import { fileURLToPath as fileURLToPath2 } from "url";
67
+ import { spawnSync } from "child_process";
68
+ function getSchemaPath() {
69
+ const possiblePaths = [
70
+ // Prod: dist/bin.js -> dist/../prisma/schema.prisma (i.e. ROOT/prisma/schema.prisma)
71
+ join2(__dirname2, "../prisma/schema.prisma"),
72
+ // Dev: src/lib/initDb.ts -> src/prisma/schema.prisma ? No, src/../prisma -> server/prisma
73
+ // If __dirname is src/lib: ../../prisma/schema.prisma
74
+ join2(__dirname2, "../../prisma/schema.prisma"),
75
+ // Fallbacks
76
+ join2(process.cwd(), "prisma/schema.prisma"),
77
+ join2(process.cwd(), "server/prisma/schema.prisma")
78
+ ];
79
+ return possiblePaths.find((p) => existsSync2(p)) || null;
80
+ }
81
+ async function ensureDatabaseInitialized() {
82
+ try {
83
+ try {
84
+ await prisma.skill.count();
85
+ return;
86
+ } catch (error) {
87
+ if (error.code === "P2021" || error.message.includes("table") || error.message.includes("does not exist")) {
88
+ console.log("\u{1F4E6} Initializing database...");
89
+ await initializeDatabase();
90
+ } else {
91
+ throw error;
92
+ }
93
+ }
94
+ } catch (error) {
95
+ throw error;
96
+ }
97
+ }
98
+ async function initializeDatabase() {
99
+ const schemaPath = getSchemaPath();
100
+ if (!schemaPath) {
101
+ throw new Error("Could not find schema.prisma");
102
+ }
103
+ const possiblePrismaBins = [
104
+ join2(__dirname2, "../node_modules/.bin/prisma"),
105
+ join2(__dirname2, "../../node_modules/.bin/prisma"),
106
+ join2(__dirname2, "../../../node_modules/.bin/prisma"),
107
+ join2(process.cwd(), "node_modules/.bin/prisma")
108
+ ];
109
+ const prismaBin = possiblePrismaBins.find((p) => existsSync2(p)) || "prisma";
110
+ console.log(` Using schema: ${schemaPath}`);
111
+ const result = spawnSync(prismaBin, ["db", "push", "--schema", schemaPath], {
112
+ stdio: "inherit",
113
+ env: { ...process.env }
114
+ // Ensure env vars (DATABASE_URL) are passed
115
+ });
116
+ if (result.error) {
117
+ throw result.error;
118
+ }
119
+ if (result.status !== 0) {
120
+ throw new Error(`Database initialization failed with status ${result.status}`);
121
+ }
122
+ console.log("\u2705 Database initialized successfully");
123
+ }
124
+ var __filename2, __dirname2;
125
+ var init_initDb = __esm({
126
+ "src/lib/initDb.ts"() {
127
+ "use strict";
128
+ init_db();
129
+ __filename2 = fileURLToPath2(import.meta.url);
130
+ __dirname2 = dirname2(__filename2);
131
+ }
132
+ });
133
+
63
134
  // ../shared/dist/index.js
64
135
  var WORKSPACE_SKILLS_PATHS, ErrorCode;
65
136
  var init_dist = __esm({
@@ -1948,9 +2019,10 @@ async function initializeStorage() {
1948
2019
  }
1949
2020
  }
1950
2021
  }
1951
- async function startServer(port = parseInt(process.env.PORT || "3001")) {
2022
+ async function startServer(port = 3001) {
1952
2023
  try {
1953
2024
  await initializeStorage();
2025
+ await ensureDatabaseInitialized();
1954
2026
  return new Promise((resolve) => {
1955
2027
  app.listen(port, () => {
1956
2028
  console.log(`\u{1F680} SkillVerse server running on http://localhost:${port}`);
@@ -1973,6 +2045,7 @@ var init_index = __esm({
1973
2045
  init_dashboard();
1974
2046
  init_errorHandler();
1975
2047
  init_logger();
2048
+ init_initDb();
1976
2049
  dotenv2.config();
1977
2050
  __filename3 = fileURLToPath3(import.meta.url);
1978
2051
  __dirname3 = dirname3(__filename3);
@@ -2020,77 +2093,14 @@ var init_index = __esm({
2020
2093
 
2021
2094
  // src/bin.ts
2022
2095
  init_config();
2096
+ init_initDb();
2097
+ init_skillService();
2098
+ init_workspaceService();
2023
2099
  import { program } from "commander";
2024
2100
  import open from "open";
2025
2101
  import { existsSync as existsSync9, readFileSync, writeFileSync } from "fs";
2026
2102
  import { join as join8 } from "path";
2027
2103
  import readline from "readline";
2028
-
2029
- // src/lib/initDb.ts
2030
- init_db();
2031
- import { existsSync as existsSync2 } from "fs";
2032
- import { join as join2, dirname as dirname2 } from "path";
2033
- import { fileURLToPath as fileURLToPath2 } from "url";
2034
- import { spawnSync } from "child_process";
2035
- var __filename2 = fileURLToPath2(import.meta.url);
2036
- var __dirname2 = dirname2(__filename2);
2037
- function getSchemaPath() {
2038
- const possiblePaths = [
2039
- join2(__dirname2, "../../prisma/schema.prisma"),
2040
- // From dist/lib or src/lib
2041
- join2(__dirname2, "../../../prisma/schema.prisma"),
2042
- join2(process.cwd(), "prisma/schema.prisma"),
2043
- // Fallback
2044
- join2(process.cwd(), "server/prisma/schema.prisma")
2045
- ];
2046
- return possiblePaths.find((p) => existsSync2(p)) || null;
2047
- }
2048
- async function ensureDatabaseInitialized() {
2049
- try {
2050
- try {
2051
- await prisma.skill.count();
2052
- return;
2053
- } catch (error) {
2054
- if (error.code === "P2021" || error.message.includes("table") || error.message.includes("does not exist")) {
2055
- console.log("\u{1F4E6} Initializing database...");
2056
- await initializeDatabase();
2057
- } else {
2058
- throw error;
2059
- }
2060
- }
2061
- } catch (error) {
2062
- throw error;
2063
- }
2064
- }
2065
- async function initializeDatabase() {
2066
- const schemaPath = getSchemaPath();
2067
- if (!schemaPath) {
2068
- throw new Error("Could not find schema.prisma");
2069
- }
2070
- const possiblePrismaBins = [
2071
- join2(__dirname2, "../../node_modules/.bin/prisma"),
2072
- join2(__dirname2, "../../../node_modules/.bin/prisma"),
2073
- join2(process.cwd(), "node_modules/.bin/prisma")
2074
- ];
2075
- const prismaBin = possiblePrismaBins.find((p) => existsSync2(p)) || "prisma";
2076
- console.log(` Using schema: ${schemaPath}`);
2077
- const result = spawnSync(prismaBin, ["db", "push", "--schema", schemaPath], {
2078
- stdio: "inherit",
2079
- env: { ...process.env }
2080
- // Ensure env vars (DATABASE_URL) are passed
2081
- });
2082
- if (result.error) {
2083
- throw result.error;
2084
- }
2085
- if (result.status !== 0) {
2086
- throw new Error(`Database initialization failed with status ${result.status}`);
2087
- }
2088
- console.log("\u2705 Database initialized successfully");
2089
- }
2090
-
2091
- // src/bin.ts
2092
- init_skillService();
2093
- init_workspaceService();
2094
2104
  var { skillverseHome: SKILLVERSE_HOME2 } = config;
2095
2105
  var AUTH_FILE = join8(SKILLVERSE_HOME2, "auth.json");
2096
2106
  var CONFIG_FILE = join8(SKILLVERSE_HOME2, "config.json");
@@ -2152,8 +2162,8 @@ async function prompt(question, hidden = false) {
2152
2162
  });
2153
2163
  }
2154
2164
  program.name("skillverse").description("SkillVerse - Local-first skill management platform for AI coding assistants").version("0.1.0");
2155
- program.command("start").description("Start the SkillVerse local server").option("-p, --port <number>", "Port to run server on", "3001").option("--no-open", "Do not open browser on start").action(async (options) => {
2156
- const port = parseInt(options.port, 10);
2165
+ program.command("start").description("Start the SkillVerse local server").option("--no-open", "Do not open browser on start").action(async (options) => {
2166
+ const port = 3001;
2157
2167
  console.log("");
2158
2168
  console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
2159
2169
  console.log(" \u2551 \u{1F680} SkillVerse CLI \u2551");