@semiont/cli 0.2.38 → 0.2.39

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +86 -23
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -15816,7 +15816,7 @@ var init_graph_check = __esm({
15816
15816
  // src/platforms/posix/handlers/backend-paths.ts
15817
15817
  import * as path10 from "path";
15818
15818
  import { createRequire } from "module";
15819
- function resolveNpmPackage() {
15819
+ function resolveBackendNpmPackage() {
15820
15820
  try {
15821
15821
  const require2 = createRequire(import.meta.url);
15822
15822
  const pkgPath = require2.resolve("@semiont/backend/package.json");
@@ -15831,7 +15831,7 @@ function getBackendPaths(context) {
15831
15831
  const sourceDir = path10.join(semiontRepo, "apps", "backend");
15832
15832
  return buildPaths(sourceDir, false);
15833
15833
  }
15834
- const npmDir = resolveNpmPackage();
15834
+ const npmDir = resolveBackendNpmPackage();
15835
15835
  if (npmDir) {
15836
15836
  return buildPaths(npmDir, true);
15837
15837
  }
@@ -16016,7 +16016,7 @@ var init_backend_check = __esm({
16016
16016
  // src/platforms/posix/handlers/frontend-paths.ts
16017
16017
  import * as path11 from "path";
16018
16018
  import { createRequire as createRequire2 } from "module";
16019
- function resolveNpmPackage2() {
16019
+ function resolveFrontendNpmPackage() {
16020
16020
  try {
16021
16021
  const require2 = createRequire2(import.meta.url);
16022
16022
  const pkgPath = require2.resolve("@semiont/frontend/package.json");
@@ -16031,7 +16031,7 @@ function getFrontendPaths(context) {
16031
16031
  const sourceDir = path11.join(semiontRepo, "apps", "frontend");
16032
16032
  return buildPaths2(sourceDir, false);
16033
16033
  }
16034
- const npmDir = resolveNpmPackage2();
16034
+ const npmDir = resolveFrontendNpmPackage();
16035
16035
  if (npmDir) {
16036
16036
  return buildPaths2(npmDir, true);
16037
16037
  }
@@ -17984,15 +17984,27 @@ var init_backend_provision = __esm({
17984
17984
  provisionBackendService = async (context) => {
17985
17985
  const { service, options } = context;
17986
17986
  const config2 = service.config;
17987
+ if (!context.options?.semiontRepo && !resolveBackendNpmPackage()) {
17988
+ if (!service.quiet) {
17989
+ printInfo("Installing @semiont/backend...");
17990
+ }
17991
+ try {
17992
+ execSync11("npm install -g @semiont/backend", {
17993
+ stdio: service.verbose ? "inherit" : "pipe"
17994
+ });
17995
+ if (!service.quiet) {
17996
+ printSuccess("Installed @semiont/backend");
17997
+ }
17998
+ } catch (error46) {
17999
+ return {
18000
+ success: false,
18001
+ error: `Failed to install @semiont/backend: ${error46}`,
18002
+ metadata: { serviceType: "backend" }
18003
+ };
18004
+ }
18005
+ }
17987
18006
  const paths = getBackendPaths(context);
17988
18007
  const { sourceDir: backendSourceDir, envFile, logsDir, tmpDir } = paths;
17989
- if (!fs22.existsSync(backendSourceDir)) {
17990
- return {
17991
- success: false,
17992
- error: `Backend source not found at ${backendSourceDir}`,
17993
- metadata: { serviceType: "backend" }
17994
- };
17995
- }
17996
18008
  if (!service.quiet) {
17997
18009
  printInfo(`Provisioning backend service ${service.name}...`);
17998
18010
  if (paths.fromNpmPackage) {
@@ -18338,15 +18350,27 @@ var init_frontend_provision = __esm({
18338
18350
  init_preflight_utils();
18339
18351
  provisionFrontendService = async (context) => {
18340
18352
  const { service } = context;
18353
+ if (!context.options?.semiontRepo && !resolveFrontendNpmPackage()) {
18354
+ if (!service.quiet) {
18355
+ printInfo("Installing @semiont/frontend...");
18356
+ }
18357
+ try {
18358
+ execSync12("npm install -g @semiont/frontend", {
18359
+ stdio: service.verbose ? "inherit" : "pipe"
18360
+ });
18361
+ if (!service.quiet) {
18362
+ printSuccess("Installed @semiont/frontend");
18363
+ }
18364
+ } catch (error46) {
18365
+ return {
18366
+ success: false,
18367
+ error: `Failed to install @semiont/frontend: ${error46}`,
18368
+ metadata: { serviceType: "frontend" }
18369
+ };
18370
+ }
18371
+ }
18341
18372
  const paths = getFrontendPaths(context);
18342
18373
  const { sourceDir: frontendSourceDir, logsDir, tmpDir, envLocalFile: envFile } = paths;
18343
- if (!fs23.existsSync(frontendSourceDir)) {
18344
- return {
18345
- success: false,
18346
- error: `Frontend source not found at ${frontendSourceDir}`,
18347
- metadata: { serviceType: "frontend" }
18348
- };
18349
- }
18350
18374
  if (!service.quiet) {
18351
18375
  printInfo(`Provisioning frontend service ${service.name}...`);
18352
18376
  if (paths.fromNpmPackage) {
@@ -42383,7 +42407,7 @@ var require_package = __commonJS({
42383
42407
  "package.json"(exports, module) {
42384
42408
  module.exports = {
42385
42409
  name: "@semiont/cli",
42386
- version: "0.2.38",
42410
+ version: "0.2.39",
42387
42411
  description: "Semiont CLI - Unified environment management tool",
42388
42412
  _comment: "AWS SDK dependencies (@aws-sdk/*) are only used by platforms/aws",
42389
42413
  type: "module",
@@ -42448,8 +42472,8 @@ var require_package = __commonJS({
42448
42472
  "@aws-sdk/client-sts": "^3.859.0",
42449
42473
  "@aws-sdk/client-wafv2": "^3.859.0",
42450
42474
  "@prisma/client": "^6.13.0",
42451
- "@semiont/api-client": "^0.2.38",
42452
- "@semiont/core": "^0.2.38",
42475
+ "@semiont/api-client": "^0.2.39",
42476
+ "@semiont/core": "^0.2.39",
42453
42477
  "@testcontainers/postgresql": "^11.5.1",
42454
42478
  arg: "^5.0.2",
42455
42479
  argon2: "^0.43.0",
@@ -43520,9 +43544,29 @@ init_zod();
43520
43544
  init_command_definition();
43521
43545
  init_base_options_schema();
43522
43546
  init_cli_logger();
43547
+ init_config_loader();
43523
43548
  import * as crypto4 from "crypto";
43524
43549
  import * as argon2 from "argon2";
43525
- import { PrismaClient } from "@prisma/client";
43550
+ import { createRequire as createRequire3 } from "module";
43551
+ function loadPrismaClient() {
43552
+ try {
43553
+ const req = createRequire3(import.meta.url);
43554
+ const backendPkgPath = req.resolve("@semiont/backend/package.json");
43555
+ const backendReq = createRequire3(backendPkgPath);
43556
+ const mod = backendReq("@prisma/client");
43557
+ return mod.PrismaClient;
43558
+ } catch {
43559
+ }
43560
+ try {
43561
+ const req = createRequire3(import.meta.url);
43562
+ const mod = req("@prisma/client");
43563
+ return mod.PrismaClient;
43564
+ } catch {
43565
+ throw new Error(
43566
+ '@prisma/client not initialized. Run "semiont provision" first, or run "prisma generate" in the backend directory.'
43567
+ );
43568
+ }
43569
+ }
43526
43570
  var UseraddOptionsSchema = BaseOptionsSchema.extend({
43527
43571
  email: external_exports.string().email().min(1, "Email is required"),
43528
43572
  name: external_exports.string().optional(),
@@ -43559,7 +43603,26 @@ function generatePassword() {
43559
43603
  }
43560
43604
  async function useradd(options) {
43561
43605
  const startTime = Date.now();
43562
- const prisma = new PrismaClient();
43606
+ const projectRoot = process.env.SEMIONT_ROOT || findProjectRoot();
43607
+ const environment = options.environment;
43608
+ const envConfig = loadEnvironmentConfig(projectRoot, environment);
43609
+ const dbConfig = envConfig.services?.database;
43610
+ if (!dbConfig?.environment) {
43611
+ throw new Error("Database configuration not found in environment file");
43612
+ }
43613
+ const dbUser = dbConfig.environment.POSTGRES_USER;
43614
+ const dbPassword = dbConfig.environment.POSTGRES_PASSWORD;
43615
+ const dbName = dbConfig.environment.POSTGRES_DB;
43616
+ const dbPort = dbConfig.port;
43617
+ const dbHost = dbConfig.host || "localhost";
43618
+ if (!dbUser || !dbPassword || !dbName || !dbPort) {
43619
+ throw new Error("Incomplete database configuration: need POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, and port");
43620
+ }
43621
+ const databaseUrl = `postgresql://${dbUser}:${dbPassword}@${dbHost}:${dbPort}/${dbName}`;
43622
+ const PrismaClient = loadPrismaClient();
43623
+ const prisma = new PrismaClient({
43624
+ datasources: { db: { url: databaseUrl } }
43625
+ });
43563
43626
  try {
43564
43627
  validateEmail(options.email);
43565
43628
  const domain2 = extractDomain(options.email);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semiont/cli",
3
- "version": "0.2.38",
3
+ "version": "0.2.39",
4
4
  "description": "Semiont CLI - Unified environment management tool",
5
5
  "_comment": "AWS SDK dependencies (@aws-sdk/*) are only used by platforms/aws",
6
6
  "type": "module",
@@ -65,8 +65,8 @@
65
65
  "@aws-sdk/client-sts": "^3.859.0",
66
66
  "@aws-sdk/client-wafv2": "^3.859.0",
67
67
  "@prisma/client": "^6.13.0",
68
- "@semiont/api-client": "0.2.38",
69
- "@semiont/core": "0.2.38",
68
+ "@semiont/api-client": "0.2.39",
69
+ "@semiont/core": "0.2.39",
70
70
  "@testcontainers/postgresql": "^11.5.1",
71
71
  "arg": "^5.0.2",
72
72
  "argon2": "^0.43.0",