@envsync-cloud/deploy-cli 0.8.9 → 0.8.10

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 +54 -6
  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}`,
@@ -5153,6 +5160,8 @@ var LICENSE_BUNDLE_FILE = path3.join(LICENSE_ROOT, "enterprise-license-bundle.js
5153
5160
  var LICENSE_CERT_FILE = path3.join(LICENSE_ROOT, "enterprise-cert.pem");
5154
5161
  var LICENSE_KEY_FILE = path3.join(LICENSE_ROOT, "enterprise-key.pem");
5155
5162
  var LICENSE_ROOT_CA_FILE = path3.join(LICENSE_ROOT, "root-ca.pem");
5163
+ var LICENSE_FILE_MODE = 420;
5164
+ var LICENSE_DIR_MODE = 493;
5156
5165
  var VERSIONS_LOCK = path3.join(DEPLOY_ROOT, "versions.lock.json");
5157
5166
  var STACK_FILE = path3.join(DEPLOY_ROOT, "docker-stack.yaml");
5158
5167
  var BOOTSTRAP_BASE_STACK_FILE = path3.join(DEPLOY_ROOT, "docker-stack.bootstrap.base.yaml");
@@ -5370,6 +5379,27 @@ function writeFileMaybe(target, content, mode) {
5370
5379
  }
5371
5380
  writeFile(target, content, mode);
5372
5381
  }
5382
+ function ensureEnterpriseLicenseFilesReadable() {
5383
+ if (exists2(LICENSE_ROOT)) {
5384
+ try {
5385
+ fs3.chmodSync(LICENSE_ROOT, LICENSE_DIR_MODE);
5386
+ } catch {
5387
+ throw new Error(
5388
+ `Cannot update directory mode for ${LICENSE_ROOT}. Fix by running: chmod ${LICENSE_DIR_MODE.toString(8)} ${LICENSE_ROOT}`
5389
+ );
5390
+ }
5391
+ }
5392
+ for (const filePath of [LICENSE_BUNDLE_FILE, LICENSE_CERT_FILE, LICENSE_KEY_FILE, LICENSE_ROOT_CA_FILE]) {
5393
+ if (!exists2(filePath)) continue;
5394
+ try {
5395
+ fs3.chmodSync(filePath, LICENSE_FILE_MODE);
5396
+ } catch {
5397
+ throw new Error(
5398
+ `Cannot update file mode for ${filePath}. Fix by running: chmod ${LICENSE_FILE_MODE.toString(8)} ${filePath}`
5399
+ );
5400
+ }
5401
+ }
5402
+ }
5373
5403
  function exists2(target) {
5374
5404
  return fs3.existsSync(target);
5375
5405
  }
@@ -5767,6 +5797,7 @@ function normalizeConfig(raw) {
5767
5797
  key: raw.license.key,
5768
5798
  install_fingerprint: raw.license.install_fingerprint ?? deterministicInstallFingerprint(rootDomain, stackName),
5769
5799
  certificate_bundle_file: raw.license.certificate_bundle_file,
5800
+ lease_ttl_seconds: raw.license.lease_ttl_seconds,
5770
5801
  certificate_validity_days: raw.license.certificate_validity_days
5771
5802
  } : raw.edition === "oss" ? void 0 : {
5772
5803
  install_fingerprint: deterministicInstallFingerprint(rootDomain, stackName),
@@ -7351,6 +7382,9 @@ async function cmdDeploy() {
7351
7382
  logSection("Deploy");
7352
7383
  const { config, generated } = loadState();
7353
7384
  logReleaseContext(config);
7385
+ if (!isOssConfig2(config)) {
7386
+ ensureEnterpriseLicenseFilesReadable();
7387
+ }
7354
7388
  assertSwarmManager();
7355
7389
  assertBootstrapState(generated);
7356
7390
  if (!currentOptions.dryRun) {
@@ -7701,6 +7735,9 @@ async function cmdUpgrade(targetVersion) {
7701
7735
  ref: `v${desiredVersion}`
7702
7736
  };
7703
7737
  logReleaseContext(config);
7738
+ if (!isOssConfig2(config) && !currentOptions.dryRun) {
7739
+ ensureEnterpriseLicenseFilesReadable();
7740
+ }
7704
7741
  config.images = {
7705
7742
  ...config.images,
7706
7743
  ...versionedImages(desiredVersion)
@@ -7792,16 +7829,25 @@ async function requestEnterpriseLicenseCertificate(config, route) {
7792
7829
  return parseEnterpriseLicenseBundle(body.bundle);
7793
7830
  }
7794
7831
  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);
7832
+ writeFileMaybe(LICENSE_BUNDLE_FILE, JSON.stringify(bundle, null, 2) + "\n", LICENSE_FILE_MODE);
7833
+ writeFileMaybe(
7834
+ LICENSE_CERT_FILE,
7835
+ bundle.certificate_pem.endsWith("\n") ? bundle.certificate_pem : `${bundle.certificate_pem}
7836
+ `,
7837
+ LICENSE_FILE_MODE
7838
+ );
7839
+ writeFileMaybe(
7840
+ LICENSE_KEY_FILE,
7841
+ bundle.private_key_pem.endsWith("\n") ? bundle.private_key_pem : `${bundle.private_key_pem}
7842
+ `,
7843
+ LICENSE_FILE_MODE
7844
+ );
7800
7845
  writeFileMaybe(LICENSE_ROOT_CA_FILE, bundle.root_ca_pem.endsWith("\n") ? bundle.root_ca_pem : `${bundle.root_ca_pem}
7801
- `, 420);
7846
+ `, LICENSE_FILE_MODE);
7802
7847
  }
7803
7848
  async function ensureEnterpriseCertificateBundle(config) {
7804
7849
  if (isOssConfig2(config)) return;
7850
+ ensureEnterpriseLicenseFilesReadable();
7805
7851
  if (exists2(LICENSE_BUNDLE_FILE) && exists2(LICENSE_CERT_FILE) && exists2(LICENSE_KEY_FILE) && exists2(LICENSE_ROOT_CA_FILE)) {
7806
7852
  validateEnterpriseLicenseBundleFiles(config, false);
7807
7853
  return;
@@ -7860,6 +7906,7 @@ async function cmdLicense(action = "validate-cert") {
7860
7906
  logInfo("OSS deployments do not require license verification.");
7861
7907
  return;
7862
7908
  }
7909
+ ensureEnterpriseLicenseFilesReadable();
7863
7910
  if (action === "issue-cert" || action === "renew-cert") {
7864
7911
  const route = action === "renew-cert" ? "renew" : "issue";
7865
7912
  if (currentOptions.dryRun) {
@@ -8101,6 +8148,7 @@ async function cmdRestore(archivePath, autoDeploy = false) {
8101
8148
  if (exists2(restoredLicenseRoot)) {
8102
8149
  fs3.rmSync(LICENSE_ROOT, { recursive: true, force: true });
8103
8150
  fs3.cpSync(restoredLicenseRoot, LICENSE_ROOT, { recursive: true });
8151
+ ensureEnterpriseLicenseFilesReadable();
8104
8152
  }
8105
8153
  const config = loadConfig();
8106
8154
  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.10",
4
4
  "description": "CLI for self-hosted EnvSync deployment on Docker Swarm",
5
5
  "type": "module",
6
6
  "bin": {