@envsync-cloud/deploy-cli 0.8.9 → 0.8.11

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/index.js +56 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4398,6 +4398,8 @@ function buildRuntimeEnv2(config, generated) {
4398
4398
  const hosts = domainMap(config.domain.root_domain);
4399
4399
  const bucketName = "envsync-bucket";
4400
4400
  const oss = isOssConfig(config);
4401
+ const enterprise = !oss;
4402
+ const license = config.license ?? {};
4401
4403
  return {
4402
4404
  NODE_ENV: "production",
4403
4405
  ENVSYNC_EDITION: oss ? "oss" : "enterprise",
@@ -4410,6 +4412,11 @@ function buildRuntimeEnv2(config, generated) {
4410
4412
  ENVSYNC_LICENSE_CERT_PATH: oss ? "" : "/etc/envsync/license/enterprise-cert.pem",
4411
4413
  ENVSYNC_LICENSE_KEY_PATH: oss ? "" : "/etc/envsync/license/enterprise-key.pem",
4412
4414
  ENVSYNC_LICENSE_ROOT_CA_CERT_PATH: oss ? "" : "/etc/envsync/license/root-ca.pem",
4415
+ ENVSYNC_LICENSE_SERVER_URL: enterprise ? license.server_url ?? "" : "",
4416
+ ENVSYNC_LICENSE_KEY: enterprise ? license.key ?? "" : "",
4417
+ ENVSYNC_INSTALL_FINGERPRINT: enterprise ? license.install_fingerprint ?? "" : "",
4418
+ ENVSYNC_LICENSE_LEASE_TTL_SECONDS: String(license.lease_ttl_seconds ?? 300),
4419
+ ENVSYNC_STACK_NAME: config.services.stack_name,
4413
4420
  DB_AUTO_MIGRATE: "false",
4414
4421
  PORT: `${config.services.api_port}`,
4415
4422
  MANAGEMENT_API_PORT: `${config.services.management_api_port}`,
@@ -4728,8 +4735,9 @@ function renderApiMaintenanceConf() {
4728
4735
  function renderFrontendRuntimeConfig(config, generated) {
4729
4736
  const hosts = domainMap(config.domain.root_domain);
4730
4737
  const otelEndpoint = publicHttpsUrl(config, hosts.obs);
4738
+ const managementApiEnabled = !isOssConfig(config);
4731
4739
  const activeReleaseVersion = generated.deployment.slots[generated.deployment.active_slot].release_version || config.release.version;
4732
- const managementApiUrl = config.edition === "enterprise" ? publicHttpsUrl(config, hosts.manage_api) : "";
4740
+ const managementApiUrl = managementApiEnabled ? publicHttpsUrl(config, hosts.manage_api) : "";
4733
4741
  return `window.__ENVSYNC_RUNTIME_CONFIG__ = ${JSON.stringify({
4734
4742
  apiBaseUrl: publicHttpsUrl(config, hosts.api),
4735
4743
  appBaseUrl: publicHttpsUrl(config, hosts.app),
@@ -5153,6 +5161,8 @@ var LICENSE_BUNDLE_FILE = path3.join(LICENSE_ROOT, "enterprise-license-bundle.js
5153
5161
  var LICENSE_CERT_FILE = path3.join(LICENSE_ROOT, "enterprise-cert.pem");
5154
5162
  var LICENSE_KEY_FILE = path3.join(LICENSE_ROOT, "enterprise-key.pem");
5155
5163
  var LICENSE_ROOT_CA_FILE = path3.join(LICENSE_ROOT, "root-ca.pem");
5164
+ var LICENSE_FILE_MODE = 420;
5165
+ var LICENSE_DIR_MODE = 493;
5156
5166
  var VERSIONS_LOCK = path3.join(DEPLOY_ROOT, "versions.lock.json");
5157
5167
  var STACK_FILE = path3.join(DEPLOY_ROOT, "docker-stack.yaml");
5158
5168
  var BOOTSTRAP_BASE_STACK_FILE = path3.join(DEPLOY_ROOT, "docker-stack.bootstrap.base.yaml");
@@ -5370,6 +5380,27 @@ function writeFileMaybe(target, content, mode) {
5370
5380
  }
5371
5381
  writeFile(target, content, mode);
5372
5382
  }
5383
+ function ensureEnterpriseLicenseFilesReadable() {
5384
+ if (exists2(LICENSE_ROOT)) {
5385
+ try {
5386
+ fs3.chmodSync(LICENSE_ROOT, LICENSE_DIR_MODE);
5387
+ } catch {
5388
+ throw new Error(
5389
+ `Cannot update directory mode for ${LICENSE_ROOT}. Fix by running: chmod ${LICENSE_DIR_MODE.toString(8)} ${LICENSE_ROOT}`
5390
+ );
5391
+ }
5392
+ }
5393
+ for (const filePath of [LICENSE_BUNDLE_FILE, LICENSE_CERT_FILE, LICENSE_KEY_FILE, LICENSE_ROOT_CA_FILE]) {
5394
+ if (!exists2(filePath)) continue;
5395
+ try {
5396
+ fs3.chmodSync(filePath, LICENSE_FILE_MODE);
5397
+ } catch {
5398
+ throw new Error(
5399
+ `Cannot update file mode for ${filePath}. Fix by running: chmod ${LICENSE_FILE_MODE.toString(8)} ${filePath}`
5400
+ );
5401
+ }
5402
+ }
5403
+ }
5373
5404
  function exists2(target) {
5374
5405
  return fs3.existsSync(target);
5375
5406
  }
@@ -5767,6 +5798,7 @@ function normalizeConfig(raw) {
5767
5798
  key: raw.license.key,
5768
5799
  install_fingerprint: raw.license.install_fingerprint ?? deterministicInstallFingerprint(rootDomain, stackName),
5769
5800
  certificate_bundle_file: raw.license.certificate_bundle_file,
5801
+ lease_ttl_seconds: raw.license.lease_ttl_seconds,
5770
5802
  certificate_validity_days: raw.license.certificate_validity_days
5771
5803
  } : raw.edition === "oss" ? void 0 : {
5772
5804
  install_fingerprint: deterministicInstallFingerprint(rootDomain, stackName),
@@ -7351,6 +7383,9 @@ async function cmdDeploy() {
7351
7383
  logSection("Deploy");
7352
7384
  const { config, generated } = loadState();
7353
7385
  logReleaseContext(config);
7386
+ if (!isOssConfig2(config)) {
7387
+ ensureEnterpriseLicenseFilesReadable();
7388
+ }
7354
7389
  assertSwarmManager();
7355
7390
  assertBootstrapState(generated);
7356
7391
  if (!currentOptions.dryRun) {
@@ -7701,6 +7736,9 @@ async function cmdUpgrade(targetVersion) {
7701
7736
  ref: `v${desiredVersion}`
7702
7737
  };
7703
7738
  logReleaseContext(config);
7739
+ if (!isOssConfig2(config) && !currentOptions.dryRun) {
7740
+ ensureEnterpriseLicenseFilesReadable();
7741
+ }
7704
7742
  config.images = {
7705
7743
  ...config.images,
7706
7744
  ...versionedImages(desiredVersion)
@@ -7792,16 +7830,25 @@ async function requestEnterpriseLicenseCertificate(config, route) {
7792
7830
  return parseEnterpriseLicenseBundle(body.bundle);
7793
7831
  }
7794
7832
  function writeEnterpriseLicenseBundle(bundle) {
7795
- writeFileMaybe(LICENSE_BUNDLE_FILE, JSON.stringify(bundle, null, 2) + "\n", 384);
7796
- writeFileMaybe(LICENSE_CERT_FILE, bundle.certificate_pem.endsWith("\n") ? bundle.certificate_pem : `${bundle.certificate_pem}
7797
- `, 384);
7798
- writeFileMaybe(LICENSE_KEY_FILE, bundle.private_key_pem.endsWith("\n") ? bundle.private_key_pem : `${bundle.private_key_pem}
7799
- `, 384);
7833
+ writeFileMaybe(LICENSE_BUNDLE_FILE, JSON.stringify(bundle, null, 2) + "\n", LICENSE_FILE_MODE);
7834
+ writeFileMaybe(
7835
+ LICENSE_CERT_FILE,
7836
+ bundle.certificate_pem.endsWith("\n") ? bundle.certificate_pem : `${bundle.certificate_pem}
7837
+ `,
7838
+ LICENSE_FILE_MODE
7839
+ );
7840
+ writeFileMaybe(
7841
+ LICENSE_KEY_FILE,
7842
+ bundle.private_key_pem.endsWith("\n") ? bundle.private_key_pem : `${bundle.private_key_pem}
7843
+ `,
7844
+ LICENSE_FILE_MODE
7845
+ );
7800
7846
  writeFileMaybe(LICENSE_ROOT_CA_FILE, bundle.root_ca_pem.endsWith("\n") ? bundle.root_ca_pem : `${bundle.root_ca_pem}
7801
- `, 420);
7847
+ `, LICENSE_FILE_MODE);
7802
7848
  }
7803
7849
  async function ensureEnterpriseCertificateBundle(config) {
7804
7850
  if (isOssConfig2(config)) return;
7851
+ ensureEnterpriseLicenseFilesReadable();
7805
7852
  if (exists2(LICENSE_BUNDLE_FILE) && exists2(LICENSE_CERT_FILE) && exists2(LICENSE_KEY_FILE) && exists2(LICENSE_ROOT_CA_FILE)) {
7806
7853
  validateEnterpriseLicenseBundleFiles(config, false);
7807
7854
  return;
@@ -7860,6 +7907,7 @@ async function cmdLicense(action = "validate-cert") {
7860
7907
  logInfo("OSS deployments do not require license verification.");
7861
7908
  return;
7862
7909
  }
7910
+ ensureEnterpriseLicenseFilesReadable();
7863
7911
  if (action === "issue-cert" || action === "renew-cert") {
7864
7912
  const route = action === "renew-cert" ? "renew" : "issue";
7865
7913
  if (currentOptions.dryRun) {
@@ -8101,6 +8149,7 @@ async function cmdRestore(archivePath, autoDeploy = false) {
8101
8149
  if (exists2(restoredLicenseRoot)) {
8102
8150
  fs3.rmSync(LICENSE_ROOT, { recursive: true, force: true });
8103
8151
  fs3.cpSync(restoredLicenseRoot, LICENSE_ROOT, { recursive: true });
8152
+ ensureEnterpriseLicenseFilesReadable();
8104
8153
  }
8105
8154
  const config = loadConfig();
8106
8155
  for (const volume of STACK_VOLUMES) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envsync-cloud/deploy-cli",
3
- "version": "0.8.9",
3
+ "version": "0.8.11",
4
4
  "description": "CLI for self-hosted EnvSync deployment on Docker Swarm",
5
5
  "type": "module",
6
6
  "bin": {