@scriptdb/server 1.0.0 → 1.0.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/dist/index.js +39 -38
- package/package.json +6 -9
package/dist/index.js
CHANGED
|
@@ -4357,9 +4357,10 @@ import fs3 from "node:fs";
|
|
|
4357
4357
|
import { spawn } from "node:child_process";
|
|
4358
4358
|
import Storage from "@scriptdb/storage";
|
|
4359
4359
|
var pkgData = `{
|
|
4360
|
-
"name": "
|
|
4360
|
+
"name": "scriptdb-workspace",
|
|
4361
4361
|
"version": "1.0.0",
|
|
4362
|
-
"description": "",
|
|
4362
|
+
"description": "ScriptDB workspace for custom scripts, services, and databases",
|
|
4363
|
+
"private": true,
|
|
4363
4364
|
"devDependencies": {
|
|
4364
4365
|
"@types/bun": "^1.3.2",
|
|
4365
4366
|
"@types/node": "^20.0.0",
|
|
@@ -4416,10 +4417,10 @@ var configDefault = {
|
|
|
4416
4417
|
logLevel: "info",
|
|
4417
4418
|
DB_USERNAME: "admin",
|
|
4418
4419
|
DB_PASSWORD: "password",
|
|
4419
|
-
GITHUB_USERNAME: "
|
|
4420
|
-
GITHUB_EMAIL: "
|
|
4421
|
-
GITHUB_URL: "
|
|
4422
|
-
GITHUB_TOKEN: "
|
|
4420
|
+
GITHUB_USERNAME: "",
|
|
4421
|
+
GITHUB_EMAIL: "",
|
|
4422
|
+
GITHUB_URL: "",
|
|
4423
|
+
GITHUB_TOKEN: "",
|
|
4423
4424
|
GITHUB_BRANCH: "main",
|
|
4424
4425
|
users: [
|
|
4425
4426
|
{
|
|
@@ -4469,16 +4470,23 @@ async function setupStorage(scriptdbDir) {
|
|
|
4469
4470
|
const config = JSON.parse(configStr);
|
|
4470
4471
|
await storage.initialize(scriptdbDir);
|
|
4471
4472
|
console.log("Storage initialized");
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4473
|
+
if (config.GITHUB_USERNAME && config.GITHUB_EMAIL) {
|
|
4474
|
+
const gitConfig = {
|
|
4475
|
+
userName: config.GITHUB_USERNAME,
|
|
4476
|
+
userEmail: config.GITHUB_EMAIL
|
|
4477
|
+
};
|
|
4478
|
+
await storage.setConfig(gitConfig);
|
|
4479
|
+
console.log("Git config set");
|
|
4480
|
+
} else {
|
|
4481
|
+
console.log("Git config not set (configure later with 'scriptdb config')");
|
|
4482
|
+
}
|
|
4478
4483
|
if (config.GITHUB_URL && isGitUrl(config.GITHUB_URL)) {
|
|
4479
4484
|
const remoteUrl = injectGitToken(config.GITHUB_URL, config.GITHUB_TOKEN);
|
|
4480
4485
|
await storage.addRemote("origin", config.GITHUB_TOKEN ? remoteUrl : config.GITHUB_URL);
|
|
4481
4486
|
await storage.pull("origin", config.GITHUB_BRANCH || "main");
|
|
4487
|
+
console.log("Remote repository configured");
|
|
4488
|
+
} else {
|
|
4489
|
+
console.log("Remote repository not configured (configure later with 'scriptdb config')");
|
|
4482
4490
|
}
|
|
4483
4491
|
console.log("Storage setup complete");
|
|
4484
4492
|
} catch (err) {
|
|
@@ -4488,12 +4496,13 @@ async function setupStorage(scriptdbDir) {
|
|
|
4488
4496
|
async function setupDir() {
|
|
4489
4497
|
const scriptdbDir = path2.join(getHomeDir(), ".scriptdb");
|
|
4490
4498
|
const databasesDir = path2.join(scriptdbDir, "databases");
|
|
4491
|
-
const pluginsDir = path2.join(scriptdbDir, "plugins");
|
|
4492
4499
|
const servicesDir = path2.join(scriptdbDir, "services");
|
|
4493
4500
|
const clientsDir = path2.join(scriptdbDir, "clients");
|
|
4494
4501
|
const configFile = path2.join(scriptdbDir, "config.json");
|
|
4495
4502
|
const gitignoreFile = path2.join(scriptdbDir, ".gitignore");
|
|
4496
|
-
const
|
|
4503
|
+
const packageJsonFile = path2.join(scriptdbDir, "package.json");
|
|
4504
|
+
const tsconfigFile = path2.join(scriptdbDir, "tsconfig.json");
|
|
4505
|
+
const isFullySetup = fs3.existsSync(scriptdbDir) && fs3.existsSync(databasesDir) && fs3.existsSync(servicesDir) && fs3.existsSync(clientsDir) && fs3.existsSync(configFile) && fs3.existsSync(gitignoreFile) && fs3.existsSync(packageJsonFile) && fs3.existsSync(tsconfigFile);
|
|
4497
4506
|
if (isFullySetup) {
|
|
4498
4507
|
console.log("ScriptDB directory already fully configured:", scriptdbDir);
|
|
4499
4508
|
return;
|
|
@@ -4504,21 +4513,14 @@ async function setupDir() {
|
|
|
4504
4513
|
fs3.mkdirSync(databasesDir, { recursive: true });
|
|
4505
4514
|
fs3.mkdirSync(servicesDir, { recursive: true });
|
|
4506
4515
|
fs3.mkdirSync(clientsDir, { recursive: true });
|
|
4507
|
-
fs3.
|
|
4508
|
-
fs3.writeFileSync(configFile, JSON.stringify(configDefault), "utf8");
|
|
4516
|
+
fs3.writeFileSync(configFile, JSON.stringify(configDefault, null, 2), "utf8");
|
|
4509
4517
|
fs3.writeFileSync(gitignoreFile, dotGitignoreData, "utf8");
|
|
4510
|
-
fs3.writeFileSync(
|
|
4511
|
-
fs3.writeFileSync(
|
|
4518
|
+
fs3.writeFileSync(packageJsonFile, pkgData, "utf8");
|
|
4519
|
+
fs3.writeFileSync(tsconfigFile, tsconfigData, "utf8");
|
|
4512
4520
|
console.log("Created:", scriptdbDir);
|
|
4513
4521
|
await installPackage(scriptdbDir);
|
|
4514
4522
|
await setupStorage(scriptdbDir);
|
|
4515
4523
|
} else {
|
|
4516
|
-
if (!fs3.existsSync(configFile)) {
|
|
4517
|
-
fs3.writeFileSync(configFile, JSON.stringify(configDefault), "utf8");
|
|
4518
|
-
}
|
|
4519
|
-
if (!fs3.existsSync(gitignoreFile)) {
|
|
4520
|
-
fs3.writeFileSync(gitignoreFile, dotGitignoreData, "utf8");
|
|
4521
|
-
}
|
|
4522
4524
|
if (!fs3.existsSync(databasesDir)) {
|
|
4523
4525
|
fs3.mkdirSync(databasesDir, { recursive: true });
|
|
4524
4526
|
}
|
|
@@ -4528,21 +4530,20 @@ async function setupDir() {
|
|
|
4528
4530
|
if (!fs3.existsSync(clientsDir)) {
|
|
4529
4531
|
fs3.mkdirSync(clientsDir, { recursive: true });
|
|
4530
4532
|
}
|
|
4531
|
-
if (!fs3.existsSync(
|
|
4532
|
-
fs3.
|
|
4533
|
-
|
|
4534
|
-
|
|
4533
|
+
if (!fs3.existsSync(configFile)) {
|
|
4534
|
+
fs3.writeFileSync(configFile, JSON.stringify(configDefault, null, 2), "utf8");
|
|
4535
|
+
}
|
|
4536
|
+
if (!fs3.existsSync(gitignoreFile)) {
|
|
4537
|
+
fs3.writeFileSync(gitignoreFile, dotGitignoreData, "utf8");
|
|
4538
|
+
}
|
|
4539
|
+
if (!fs3.existsSync(packageJsonFile)) {
|
|
4540
|
+
fs3.writeFileSync(packageJsonFile, pkgData, "utf8");
|
|
4541
|
+
}
|
|
4542
|
+
if (!fs3.existsSync(tsconfigFile)) {
|
|
4543
|
+
fs3.writeFileSync(tsconfigFile, tsconfigData, "utf8");
|
|
4544
|
+
}
|
|
4545
|
+
if (!fs3.existsSync(path2.join(scriptdbDir, "node_modules"))) {
|
|
4535
4546
|
await installPackage(scriptdbDir);
|
|
4536
|
-
} else {
|
|
4537
|
-
if (!fs3.existsSync(path2.join(scriptdbDir, "package.json"))) {
|
|
4538
|
-
fs3.writeFileSync(path2.join(scriptdbDir, "package.json"), pkgData, "utf8");
|
|
4539
|
-
}
|
|
4540
|
-
if (!fs3.existsSync(path2.join(scriptdbDir, "tsconfig.json"))) {
|
|
4541
|
-
fs3.writeFileSync(path2.join(scriptdbDir, "tsconfig.json"), tsconfigData, "utf8");
|
|
4542
|
-
}
|
|
4543
|
-
if (!fs3.existsSync(path2.join(scriptdbDir, "node_modules"))) {
|
|
4544
|
-
await installPackage(scriptdbDir);
|
|
4545
|
-
}
|
|
4546
4547
|
}
|
|
4547
4548
|
console.log("Setup complete");
|
|
4548
4549
|
await setupStorage(scriptdbDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scriptdb/server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "server module resolver for script database",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
|
-
"dev": "bun --watch src/index.ts --watch ../
|
|
19
|
+
"dev": "bun --watch src/index.ts --watch ../vm/src --watch ../storage/src --watch ../system-modules/src",
|
|
20
20
|
"build": "bun build src/index.ts --outdir dist --target node --format esm --splitting --external '@scriptdb/*' --external bcryptjs --external bottleneck --external jsonwebtoken --external lru-cache",
|
|
21
21
|
"build:cjs": "bun build src/index.ts --outdir dist --target node --format cjs --outfile dist/index.js --external '@scriptdb/*' --external bcryptjs --external bottleneck --external jsonwebtoken --external lru-cache",
|
|
22
22
|
"build:types": "tsc --emitDeclarationOnly",
|
|
@@ -41,18 +41,15 @@
|
|
|
41
41
|
"typescript": "^5.0.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@scriptdb/client": "^1.0.
|
|
45
|
-
"@scriptdb/
|
|
46
|
-
"@scriptdb/
|
|
47
|
-
"@scriptdb/
|
|
48
|
-
"@scriptdb/system-modules": "^1.0.0",
|
|
49
|
-
"@scriptdb/vm": "^1.0.0",
|
|
44
|
+
"@scriptdb/client": "^1.0.1",
|
|
45
|
+
"@scriptdb/storage": "^1.0.1",
|
|
46
|
+
"@scriptdb/system-modules": "^1.0.1",
|
|
47
|
+
"@scriptdb/vm": "^1.0.1",
|
|
50
48
|
"@types/ws": "^8.18.1",
|
|
51
49
|
"bcryptjs": "^3.0.3",
|
|
52
50
|
"bottleneck": "^2.19.5",
|
|
53
51
|
"jsonwebtoken": "^9.0.2",
|
|
54
52
|
"lru-cache": "^11.2.2",
|
|
55
|
-
"node": "^25.2.0",
|
|
56
53
|
"ws": "^8.18.3"
|
|
57
54
|
}
|
|
58
55
|
}
|