ardent-cli 0.0.44 → 0.0.45

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 +46 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -478,6 +478,37 @@ async function resolveCurrentConnectorId() {
478
478
  );
479
479
  }
480
480
 
481
+ // src/lib/resource_name_validation.ts
482
+ var RESERVED_SUFFIXES = ["pooler", "readonly", "direct"];
483
+ var MAX_RESOURCE_NAME_LENGTH = 100;
484
+ var ALLOWED_CHARS = /^[a-z0-9-]+$/;
485
+ function validateResourceName(name) {
486
+ const length = name ? Array.from(name).length : 0;
487
+ if (!name || length > MAX_RESOURCE_NAME_LENGTH) {
488
+ throw new Error(
489
+ `Resource name must be 1-${MAX_RESOURCE_NAME_LENGTH} characters, got ${length}`
490
+ );
491
+ }
492
+ if (!ALLOWED_CHARS.test(name)) {
493
+ throw new Error(
494
+ `Resource name must contain only lowercase letters, digits, and hyphens: '${name}'`
495
+ );
496
+ }
497
+ if (name.startsWith("-") || name.endsWith("-")) {
498
+ throw new Error(`Resource name must not start or end with a hyphen: '${name}'`);
499
+ }
500
+ if (name.includes("--")) {
501
+ throw new Error(`Resource name must not contain consecutive hyphens: '${name}'`);
502
+ }
503
+ for (const suffix of RESERVED_SUFFIXES) {
504
+ if (name.endsWith(`-${suffix}`)) {
505
+ throw new Error(
506
+ `Resource name must not end with reserved suffix '-${suffix}': '${name}'`
507
+ );
508
+ }
509
+ }
510
+ }
511
+
481
512
  // src/lib/telemetry.ts
482
513
  import { randomUUID } from "crypto";
483
514
  function getAnonymousId() {
@@ -626,6 +657,21 @@ async function createAction(name, options) {
626
657
  process.exit(2);
627
658
  }
628
659
  const mode = modeResolution.mode;
660
+ try {
661
+ validateResourceName(name);
662
+ } catch (validationError) {
663
+ const message = validationError instanceof Error ? validationError.message : String(validationError);
664
+ trackEvent("CLI: branch create failed", {
665
+ reason: "invalid_name",
666
+ output_mode: mode
667
+ });
668
+ if (mode === "json") {
669
+ process.stdout.write(renderBranchJsonError("invalid_name", message));
670
+ process.exit(1);
671
+ }
672
+ console.error(`\u2717 ${message}`);
673
+ process.exit(1);
674
+ }
629
675
  try {
630
676
  const startTime = performance.now();
631
677
  const connectorId = await resolveCurrentConnectorId();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ardent-cli",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "Git for Data infrastructure",
5
5
  "type": "module",
6
6
  "bin": {