@open-mercato/cli 0.10.1-develop.7994.1.c9f31972aa → 0.10.1-develop.8004.1.a8a79ee43f
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/build.mjs +1 -0
- package/dist/agentic/guides/module-facts.json +162 -162
- package/dist/agentic/guides/module-facts.v2.json +162 -162
- package/dist/agentic/guides/modules/agent_orchestrator/index.md +1 -1
- package/dist/agentic/guides/modules/ai_assistant/index.md +1 -1
- package/dist/agentic/guides/modules/api_docs/index.md +1 -1
- package/dist/agentic/guides/modules/api_keys/index.md +1 -1
- package/dist/agentic/guides/modules/attachments/index.md +1 -1
- package/dist/agentic/guides/modules/audit_logs/index.md +1 -1
- package/dist/agentic/guides/modules/auth/index.md +1 -1
- package/dist/agentic/guides/modules/availability/index.md +1 -1
- package/dist/agentic/guides/modules/business_rules/index.md +1 -1
- package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
- package/dist/agentic/guides/modules/cart/index.md +1 -1
- package/dist/agentic/guides/modules/catalog/index.md +1 -1
- package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
- package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
- package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
- package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
- package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
- package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
- package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
- package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
- package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
- package/dist/agentic/guides/modules/checkout/index.md +1 -1
- package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
- package/dist/agentic/guides/modules/configs/index.md +1 -1
- package/dist/agentic/guides/modules/content/index.md +1 -1
- package/dist/agentic/guides/modules/currencies/index.md +1 -1
- package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
- package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
- package/dist/agentic/guides/modules/customers/index.md +1 -1
- package/dist/agentic/guides/modules/dashboards/index.md +1 -1
- package/dist/agentic/guides/modules/data_sync/index.md +1 -1
- package/dist/agentic/guides/modules/design_system/index.md +1 -1
- package/dist/agentic/guides/modules/devices/index.md +1 -1
- package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
- package/dist/agentic/guides/modules/directory/index.md +1 -1
- package/dist/agentic/guides/modules/documents/index.md +1 -1
- package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
- package/dist/agentic/guides/modules/entities/index.md +1 -1
- package/dist/agentic/guides/modules/eudr/index.md +1 -1
- package/dist/agentic/guides/modules/events/index.md +1 -1
- package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
- package/dist/agentic/guides/modules/forms/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
- package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
- package/dist/agentic/guides/modules/generators/index.md +1 -1
- package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
- package/dist/agentic/guides/modules/integrations/index.md +1 -1
- package/dist/agentic/guides/modules/messages/index.md +1 -1
- package/dist/agentic/guides/modules/notifications/index.md +1 -1
- package/dist/agentic/guides/modules/onboarding/index.md +1 -1
- package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
- package/dist/agentic/guides/modules/perspectives/index.md +1 -1
- package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
- package/dist/agentic/guides/modules/planner/index.md +1 -1
- package/dist/agentic/guides/modules/portal/index.md +1 -1
- package/dist/agentic/guides/modules/progress/index.md +1 -1
- package/dist/agentic/guides/modules/promotions/index.md +1 -1
- package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
- package/dist/agentic/guides/modules/query_index/index.md +1 -1
- package/dist/agentic/guides/modules/record_locks/index.md +1 -1
- package/dist/agentic/guides/modules/resources/index.md +1 -1
- package/dist/agentic/guides/modules/sales/index.md +1 -1
- package/dist/agentic/guides/modules/scheduler/index.md +1 -1
- package/dist/agentic/guides/modules/search/index.md +1 -1
- package/dist/agentic/guides/modules/security/index.md +1 -1
- package/dist/agentic/guides/modules/seeds/index.md +1 -1
- package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
- package/dist/agentic/guides/modules/sso/index.md +1 -1
- package/dist/agentic/guides/modules/staff/index.md +1 -1
- package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
- package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
- package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
- package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
- package/dist/agentic/guides/modules/telemetry/index.md +1 -1
- package/dist/agentic/guides/modules/tillio/index.md +1 -1
- package/dist/agentic/guides/modules/translations/index.md +1 -1
- package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
- package/dist/agentic/guides/modules/webhooks/index.md +1 -1
- package/dist/agentic/guides/modules/wms/index.md +1 -1
- package/dist/agentic/guides/modules/workflows/index.md +1 -1
- package/dist/agentic/guides/reference-module-facts.json +1 -1
- package/dist/agentic/guides/upstream/BACKWARD_COMPATIBILITY.md +4 -0
- package/dist/agentic/guides/upstream/manifest.json +2 -2
- package/dist/i18n/de.json +4 -0
- package/dist/i18n/en.json +4 -0
- package/dist/i18n/es.json +4 -0
- package/dist/i18n/ko.json +4 -0
- package/dist/i18n/pl.json +4 -0
- package/dist/lib/__fixtures__/module-search/built-in.json +235 -0
- package/dist/lib/__fixtures__/module-search/catalog-parity.json +4076 -0
- package/dist/lib/__fixtures__/module-search/modules-index.json +1980 -0
- package/dist/lib/__fixtures__/official-module-package/package.json +33 -0
- package/dist/lib/init-secrets.js +33 -1
- package/dist/lib/init-secrets.js.map +2 -2
- package/dist/mercato.js +3 -14
- package/dist/mercato.js.map +2 -2
- package/package.json +7 -7
- package/src/__tests__/mercato.test.ts +57 -0
- package/src/i18n/de.json +4 -0
- package/src/i18n/en.json +4 -0
- package/src/i18n/es.json +4 -0
- package/src/i18n/ko.json +4 -0
- package/src/i18n/pl.json +4 -0
- package/src/lib/__tests__/init-secrets.test.ts +85 -1
- package/src/lib/init-secrets.ts +37 -0
- package/src/mercato.ts +4 -20
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@open-mercato/test-package",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./*": {
|
|
10
|
+
"types": "./src/*.ts",
|
|
11
|
+
"default": "./dist/*.js"
|
|
12
|
+
},
|
|
13
|
+
"./*/*": {
|
|
14
|
+
"types": "./src/*/*.ts",
|
|
15
|
+
"default": "./dist/*/*.js"
|
|
16
|
+
},
|
|
17
|
+
"./*/*/*": {
|
|
18
|
+
"types": "./src/*/*/*.ts",
|
|
19
|
+
"default": "./dist/*/*/*.js"
|
|
20
|
+
},
|
|
21
|
+
"./*/*/*/*": {
|
|
22
|
+
"types": "./src/*/*/*/*.ts",
|
|
23
|
+
"default": "./dist/*/*/*/*.js"
|
|
24
|
+
},
|
|
25
|
+
"./*/*/*/*/*": {
|
|
26
|
+
"types": "./src/*/*/*/*/*.ts",
|
|
27
|
+
"default": "./dist/*/*/*/*/*.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@open-mercato/core": ">=0.4.7 <0.5.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/dist/lib/init-secrets.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { parseBooleanToken } from "@open-mercato/shared/lib/boolean";
|
|
2
|
+
import { getPasswordPolicy, validatePassword } from "@open-mercato/shared/lib/auth/passwordPolicy";
|
|
2
3
|
import { randomBytes } from "node:crypto";
|
|
4
|
+
import { createTranslator } from "@open-mercato/shared/lib/i18n/translate";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
const requireLocale = createRequire(import.meta.url);
|
|
7
|
+
function initTranslator(env) {
|
|
8
|
+
const locale = (env.LC_ALL || env.LC_MESSAGES || env.LANG || "en").split(/[_.-]/)[0].toLowerCase();
|
|
9
|
+
const supportedLocale = ["en", "pl", "es", "de", "ko"].includes(locale) ? locale : "en";
|
|
10
|
+
const dictionary = requireLocale(`../i18n/${supportedLocale}.json`);
|
|
11
|
+
return createTranslator(dictionary);
|
|
12
|
+
}
|
|
3
13
|
function readEnvValue(env, key) {
|
|
4
14
|
const value = env[key];
|
|
5
15
|
if (typeof value !== "string") return void 0;
|
|
@@ -40,7 +50,29 @@ function resolveInitDerivedSecrets(options) {
|
|
|
40
50
|
employeePassword: resolvePassword("OM_INIT_EMPLOYEE_PASSWORD", employeeEmail)
|
|
41
51
|
};
|
|
42
52
|
}
|
|
53
|
+
function resolveInitSuperadminCredentials(args, env = process.env) {
|
|
54
|
+
const argValue = (name) => args.find((arg) => arg.startsWith(`${name}=`))?.slice(name.length + 1) || void 0;
|
|
55
|
+
const email = argValue("--email") ?? readEnvValue(env, "OM_INIT_SUPERADMIN_EMAIL") ?? "superadmin@acme.com";
|
|
56
|
+
const suppliedPassword = argValue("--password") ?? readEnvValue(env, "OM_INIT_SUPERADMIN_PASSWORD");
|
|
57
|
+
const isProduction = (env.NODE_ENV ?? "").trim().toLowerCase() === "production";
|
|
58
|
+
const skipPolicyArg = args.find(
|
|
59
|
+
(arg) => arg === "--skip-password-policy" || arg.startsWith("--skip-password-policy=") || arg === "--allow-weak-password" || arg.startsWith("--allow-weak-password=")
|
|
60
|
+
);
|
|
61
|
+
const skipPasswordPolicy = !isProduction && (skipPolicyArg ? parseBooleanToken(skipPolicyArg.split("=")[1] ?? "true") ?? true : true);
|
|
62
|
+
if (isProduction) {
|
|
63
|
+
const t = initTranslator(env);
|
|
64
|
+
const placeholder = suppliedPassword?.trim().toLowerCase();
|
|
65
|
+
if (!suppliedPassword || !placeholder || ["secret", "password", "changeme", "change-me", "change_me", "replace-me", "replace_me"].includes(placeholder)) {
|
|
66
|
+
throw new Error(t("cli.init.errors.superadminPasswordRequired"));
|
|
67
|
+
}
|
|
68
|
+
if (!validatePassword(suppliedPassword, getPasswordPolicy(env)).ok) {
|
|
69
|
+
throw new Error(t("cli.init.errors.superadminPasswordPolicy"));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { email, password: suppliedPassword ?? "secret", skipPasswordPolicy };
|
|
73
|
+
}
|
|
43
74
|
export {
|
|
44
|
-
resolveInitDerivedSecrets
|
|
75
|
+
resolveInitDerivedSecrets,
|
|
76
|
+
resolveInitSuperadminCredentials
|
|
45
77
|
};
|
|
46
78
|
//# sourceMappingURL=init-secrets.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/init-secrets.ts"],
|
|
4
|
-
"sourcesContent": ["import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { randomBytes } from 'node:crypto'\n\ntype EnvReader = (key: string) => string | undefined\n\nfunction readEnvValue(env: NodeJS.ProcessEnv, key: string): string | undefined {\n const value = env[key]\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction resolveEmailFromDomain(domain: string | undefined, prefix: string): string | null {\n if (!domain) return null\n return `${prefix}@${domain}`\n}\n\nexport type InitDerivedSecrets = {\n adminEmail: string | null\n employeeEmail: string | null\n adminPassword: string | null\n employeePassword: string | null\n}\n\n// Well-known dev/demo password baked into local bootstrap flows so developers\n// keep the documented \"log in as admin@<domain> with password 'secret'\" UX.\n// Only used when NODE_ENV !== 'production' and the OM_INIT_*_PASSWORD env vars\n// are unset \u2014 production paths always use a random 96-bit secret.\nconst DEMO_DERIVED_PASSWORD = 'secret'\n\nlet warnedAboutDeprecatedRandomToggle = false\n\nexport function resolveInitDerivedSecrets(options: {\n email: string\n env?: NodeJS.ProcessEnv\n randomSource?: (size: number) => Buffer\n}): InitDerivedSecrets {\n const env = options.env ?? process.env\n const envRead: EnvReader = (key) => readEnvValue(env, key)\n const [, domain] = String(options.email ?? '').split('@')\n const adminEmail = envRead('OM_INIT_ADMIN_EMAIL') ?? resolveEmailFromDomain(domain, 'admin')\n const employeeEmail = envRead('OM_INIT_EMPLOYEE_EMAIL') ?? resolveEmailFromDomain(domain, 'employee')\n // OM_INIT_GENERATE_RANDOM_PASSWORD used to be an opt-in toggle for random\n // derived secrets; in production it is now the unconditional behaviour when\n // no override is set. Surface a one-time deprecation warning so existing\n // operators notice their config is no longer required.\n if (parseBooleanToken(envRead('OM_INIT_GENERATE_RANDOM_PASSWORD') ?? '') === true && !warnedAboutDeprecatedRandomToggle) {\n warnedAboutDeprecatedRandomToggle = true\n console.warn(\n '\u26A0\uFE0F OM_INIT_GENERATE_RANDOM_PASSWORD is deprecated and no longer required: derived admin/employee passwords are always randomized in production when overrides are unset.',\n )\n }\n const isProduction = (env.NODE_ENV ?? '').trim().toLowerCase() === 'production'\n const randomize = options.randomSource ?? randomBytes\n const randomSecret = () => randomize(12).toString('base64url')\n const resolvePassword = (key: string, emailValue: string | null) => {\n if (!emailValue) return null\n const envValue = envRead(key)\n if (envValue) return envValue\n // Non-production (dev/test/staging defaults): seed the documented demo\n // password so `yarn dev` / `mercato init` workflows stay predictable.\n // Production: generate a fresh random secret so credentials are never\n // hardcoded and the operator-facing CLI prints the value once.\n return isProduction ? randomSecret() : DEMO_DERIVED_PASSWORD\n }\n\n return {\n adminEmail,\n employeeEmail,\n adminPassword: resolvePassword('OM_INIT_ADMIN_PASSWORD', adminEmail),\n employeePassword: resolvePassword('OM_INIT_EMPLOYEE_PASSWORD', employeeEmail),\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;
|
|
4
|
+
"sourcesContent": ["import { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { getPasswordPolicy, validatePassword } from '@open-mercato/shared/lib/auth/passwordPolicy'\nimport { randomBytes } from 'node:crypto'\nimport { createTranslator } from '@open-mercato/shared/lib/i18n/translate'\nimport { createRequire } from 'node:module'\n\nconst requireLocale = createRequire(import.meta.url)\n\nfunction initTranslator(env: NodeJS.ProcessEnv) {\n const locale = (env.LC_ALL || env.LC_MESSAGES || env.LANG || 'en').split(/[_.-]/)[0].toLowerCase()\n const supportedLocale = ['en', 'pl', 'es', 'de', 'ko'].includes(locale) ? locale : 'en'\n const dictionary: Record<string, string> = requireLocale(`../i18n/${supportedLocale}.json`)\n return createTranslator(dictionary)\n}\n\ntype EnvReader = (key: string) => string | undefined\n\nfunction readEnvValue(env: NodeJS.ProcessEnv, key: string): string | undefined {\n const value = env[key]\n if (typeof value !== 'string') return undefined\n const trimmed = value.trim()\n return trimmed.length > 0 ? trimmed : undefined\n}\n\nfunction resolveEmailFromDomain(domain: string | undefined, prefix: string): string | null {\n if (!domain) return null\n return `${prefix}@${domain}`\n}\n\nexport type InitDerivedSecrets = {\n adminEmail: string | null\n employeeEmail: string | null\n adminPassword: string | null\n employeePassword: string | null\n}\n\n// Well-known dev/demo password baked into local bootstrap flows so developers\n// keep the documented \"log in as admin@<domain> with password 'secret'\" UX.\n// Only used when NODE_ENV !== 'production' and the OM_INIT_*_PASSWORD env vars\n// are unset \u2014 production paths always use a random 96-bit secret.\nconst DEMO_DERIVED_PASSWORD = 'secret'\n\nlet warnedAboutDeprecatedRandomToggle = false\n\nexport function resolveInitDerivedSecrets(options: {\n email: string\n env?: NodeJS.ProcessEnv\n randomSource?: (size: number) => Buffer\n}): InitDerivedSecrets {\n const env = options.env ?? process.env\n const envRead: EnvReader = (key) => readEnvValue(env, key)\n const [, domain] = String(options.email ?? '').split('@')\n const adminEmail = envRead('OM_INIT_ADMIN_EMAIL') ?? resolveEmailFromDomain(domain, 'admin')\n const employeeEmail = envRead('OM_INIT_EMPLOYEE_EMAIL') ?? resolveEmailFromDomain(domain, 'employee')\n // OM_INIT_GENERATE_RANDOM_PASSWORD used to be an opt-in toggle for random\n // derived secrets; in production it is now the unconditional behaviour when\n // no override is set. Surface a one-time deprecation warning so existing\n // operators notice their config is no longer required.\n if (parseBooleanToken(envRead('OM_INIT_GENERATE_RANDOM_PASSWORD') ?? '') === true && !warnedAboutDeprecatedRandomToggle) {\n warnedAboutDeprecatedRandomToggle = true\n console.warn(\n '\u26A0\uFE0F OM_INIT_GENERATE_RANDOM_PASSWORD is deprecated and no longer required: derived admin/employee passwords are always randomized in production when overrides are unset.',\n )\n }\n const isProduction = (env.NODE_ENV ?? '').trim().toLowerCase() === 'production'\n const randomize = options.randomSource ?? randomBytes\n const randomSecret = () => randomize(12).toString('base64url')\n const resolvePassword = (key: string, emailValue: string | null) => {\n if (!emailValue) return null\n const envValue = envRead(key)\n if (envValue) return envValue\n // Non-production (dev/test/staging defaults): seed the documented demo\n // password so `yarn dev` / `mercato init` workflows stay predictable.\n // Production: generate a fresh random secret so credentials are never\n // hardcoded and the operator-facing CLI prints the value once.\n return isProduction ? randomSecret() : DEMO_DERIVED_PASSWORD\n }\n\n return {\n adminEmail,\n employeeEmail,\n adminPassword: resolvePassword('OM_INIT_ADMIN_PASSWORD', adminEmail),\n employeePassword: resolvePassword('OM_INIT_EMPLOYEE_PASSWORD', employeeEmail),\n }\n}\n\nexport function resolveInitSuperadminCredentials(args: string[], env: NodeJS.ProcessEnv = process.env) {\n const argValue = (name: string) => args.find((arg) => arg.startsWith(`${name}=`))?.slice(name.length + 1) || undefined\n const email = argValue('--email') ?? readEnvValue(env, 'OM_INIT_SUPERADMIN_EMAIL') ?? 'superadmin@acme.com'\n const suppliedPassword = argValue('--password') ?? readEnvValue(env, 'OM_INIT_SUPERADMIN_PASSWORD')\n const isProduction = (env.NODE_ENV ?? '').trim().toLowerCase() === 'production'\n const skipPolicyArg = args.find((arg) =>\n arg === '--skip-password-policy' || arg.startsWith('--skip-password-policy=') ||\n arg === '--allow-weak-password' || arg.startsWith('--allow-weak-password='),\n )\n const skipPasswordPolicy = !isProduction && (skipPolicyArg\n ? parseBooleanToken(skipPolicyArg.split('=')[1] ?? 'true') ?? true\n : true)\n if (isProduction) {\n const t = initTranslator(env)\n const placeholder = suppliedPassword?.trim().toLowerCase()\n if (!suppliedPassword || !placeholder || ['secret', 'password', 'changeme', 'change-me', 'change_me', 'replace-me', 'replace_me'].includes(placeholder)) {\n throw new Error(t('cli.init.errors.superadminPasswordRequired'))\n }\n if (!validatePassword(suppliedPassword, getPasswordPolicy(env)).ok) {\n throw new Error(t('cli.init.errors.superadminPasswordPolicy'))\n }\n }\n return { email, password: suppliedPassword ?? 'secret', skipPasswordPolicy }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mercato.js
CHANGED
|
@@ -5,7 +5,7 @@ import { parseBooleanToken } from "@open-mercato/shared/lib/boolean";
|
|
|
5
5
|
import { getSslConfig } from "@open-mercato/shared/lib/db/ssl";
|
|
6
6
|
import { getRedisUrl, getRedisUrlOrThrow, parseRedisUrl } from "@open-mercato/shared/lib/redis/connection";
|
|
7
7
|
import { formatInitSummary } from "./lib/init-summary.js";
|
|
8
|
-
import { resolveInitDerivedSecrets } from "./lib/init-secrets.js";
|
|
8
|
+
import { resolveInitDerivedSecrets, resolveInitSuperadminCredentials } from "./lib/init-secrets.js";
|
|
9
9
|
import { decideExistingDatabase, formatSkipIfInitializedMessage } from "./lib/init-existing-database.js";
|
|
10
10
|
import {
|
|
11
11
|
resolveAutoSpawnWorkersMode,
|
|
@@ -766,6 +766,7 @@ async function run(argv = process.argv) {
|
|
|
766
766
|
delete process.env.OM_INIT_REINSTALL;
|
|
767
767
|
}
|
|
768
768
|
const skipIfInitialized = initArgs.includes("--skip-if-initialized");
|
|
769
|
+
const credentials = skipIfInitialized && !reinstall ? void 0 : resolveInitSuperadminCredentials(initArgs);
|
|
769
770
|
const skipExamples = initArgs.includes("--no-examples");
|
|
770
771
|
const skipDemoUsers = initArgs.includes("--no-demo-users");
|
|
771
772
|
const stressTestEnabled = initArgs.includes("--stresstest") || initArgs.includes("--stress-test");
|
|
@@ -934,6 +935,7 @@ async function run(argv = process.argv) {
|
|
|
934
935
|
}
|
|
935
936
|
}
|
|
936
937
|
}
|
|
938
|
+
const { email, password, skipPasswordPolicy } = credentials ?? resolveInitSuperadminCredentials(initArgs);
|
|
937
939
|
console.log("\u{1F527} Preparing modules (registry, entities, DI)...");
|
|
938
940
|
const { createResolver } = await import("./lib/resolver.js");
|
|
939
941
|
const { generateEntityIds, generateModuleRegistries, generateModuleEntities, generateModuleDi, generateModulePackageSources, generateOpenApi, generateWebResearchAdapters } = await import("./lib/generators/index.js");
|
|
@@ -969,16 +971,7 @@ async function run(argv = process.argv) {
|
|
|
969
971
|
}
|
|
970
972
|
return fallback;
|
|
971
973
|
};
|
|
972
|
-
const readEnvDefault = (key) => {
|
|
973
|
-
const value = process.env[key];
|
|
974
|
-
if (typeof value === "string" && value.trim().length > 0) return value.trim();
|
|
975
|
-
return void 0;
|
|
976
|
-
};
|
|
977
|
-
const defaultEmail = readEnvDefault("OM_INIT_SUPERADMIN_EMAIL") ?? "superadmin@acme.com";
|
|
978
|
-
const defaultPassword = readEnvDefault("OM_INIT_SUPERADMIN_PASSWORD") ?? "secret";
|
|
979
974
|
const orgName = findArgValue(["--org=", "--orgName="], "Acme Corp");
|
|
980
|
-
const email = findArgValue(["--email="], defaultEmail);
|
|
981
|
-
const password = findArgValue(["--password="], defaultPassword);
|
|
982
975
|
const derivedSecrets = resolveInitDerivedSecrets({ email, env: process.env });
|
|
983
976
|
const adminEmailDerived = derivedSecrets.adminEmail;
|
|
984
977
|
const employeeEmailDerived = derivedSecrets.employeeEmail;
|
|
@@ -996,10 +989,6 @@ async function run(argv = process.argv) {
|
|
|
996
989
|
process.env.OM_INIT_EMPLOYEE_EMAIL = employeeEmailDerived;
|
|
997
990
|
}
|
|
998
991
|
const roles = findArgValue(["--roles="], "superadmin,admin,employee");
|
|
999
|
-
const skipPasswordPolicyRaw = initArgs.find(
|
|
1000
|
-
(arg) => arg === "--skip-password-policy" || arg.startsWith("--skip-password-policy=") || arg === "--allow-weak-password" || arg.startsWith("--allow-weak-password=")
|
|
1001
|
-
);
|
|
1002
|
-
const skipPasswordPolicy = skipPasswordPolicyRaw ? parseBooleanToken(skipPasswordPolicyRaw.split("=")[1] ?? "true") ?? true : true;
|
|
1003
992
|
console.log("\u{1F510} Setting up RBAC and users...");
|
|
1004
993
|
const setupArgs = [
|
|
1005
994
|
"--orgName",
|