@uniformdev/cli 20.76.2 → 20.77.0

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.
@@ -5,7 +5,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
5
5
  throw Error('Dynamic require of "' + x + '" is not supported');
6
6
  });
7
7
 
8
- // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.58.9_@types+node@26.0.0__jiti@2.7.0_postcss@8.5.1_7017c7d2ba4cec51f3116591eb787c26/node_modules/tsup/assets/esm_shims.js
8
+ // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.58.9_@types+node@26.0.0__jiti@2.7.0_postcss@8.5.2_1593607ac254a0f78ffdb743585a4e57/node_modules/tsup/assets/esm_shims.js
9
9
  import path from "path";
10
10
  import { fileURLToPath } from "url";
11
11
  var getFilename = () => fileURLToPath(import.meta.url);
@@ -21,7 +21,7 @@ import { dirname, extname, isAbsolute, resolve, sep } from "path";
21
21
  // package.json
22
22
  var package_default = {
23
23
  name: "@uniformdev/cli",
24
- version: "20.76.2",
24
+ version: "20.77.0",
25
25
  description: "Uniform command line interface tool",
26
26
  license: "SEE LICENSE IN LICENSE.txt",
27
27
  main: "./cli.js",
@@ -68,7 +68,7 @@ var package_default = {
68
68
  "fs-jetpack": "5.1.0",
69
69
  "image-size": "2.0.2",
70
70
  "isomorphic-git": "1.38.5",
71
- "js-yaml": "^4.2.0",
71
+ "js-yaml": "^4.3.1",
72
72
  jsonwebtoken: "9.0.3",
73
73
  mitt: "^3.0.1",
74
74
  "normalize-newline": "^4.1.0",
@@ -80,7 +80,7 @@ var package_default = {
80
80
  "registry-url": "^6.0.0",
81
81
  slugify: "1.6.9",
82
82
  svix: "^1.96.0",
83
- undici: "^7.28.0",
83
+ undici: "^7.29.0",
84
84
  yargs: "^18.0.0",
85
85
  zod: "4.4.3"
86
86
  },
@@ -1,4 +1,4 @@
1
- import "./chunk-ILUO7HJ5.mjs";
1
+ import "./chunk-4FPNEXON.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  withFormatOptions,
24
24
  withProjectOptions,
25
25
  withTeamOptions
26
- } from "./chunk-ILUO7HJ5.mjs";
26
+ } from "./chunk-4FPNEXON.mjs";
27
27
 
28
28
  // src/index.ts
29
29
  import * as dotenv from "dotenv";
@@ -286,6 +286,11 @@ var ENVIRONMENT_HOSTS = {
286
286
  api: "https://eu.uniform.app",
287
287
  global: "https://eu.uniform.global",
288
288
  ai: "https://ai.eu.uniform.global"
289
+ },
290
+ eu2: {
291
+ api: "https://eu2.uniform.app",
292
+ global: "https://eu2.uniform.global",
293
+ ai: "https://ai.eu2.uniform.global"
289
294
  }
290
295
  };
291
296
  async function selectEnvironment(explicitParams) {
@@ -305,6 +310,10 @@ async function selectEnvironment(explicitParams) {
305
310
  {
306
311
  name: "EU (eu.uniform.app)",
307
312
  value: "eu"
313
+ },
314
+ {
315
+ name: "EU2 (eu2.uniform.app)",
316
+ value: "eu2"
308
317
  }
309
318
  ],
310
319
  default: "usa"
@@ -2741,9 +2750,32 @@ var writeResponseBodyToFile = async (response, filePath) => {
2741
2750
  throw error;
2742
2751
  }
2743
2752
  };
2753
+ var getFileMetadata = async ({
2754
+ fileClient,
2755
+ fileId,
2756
+ fileUrl
2757
+ }) => {
2758
+ if (fileId) {
2759
+ const fileById = await fileClient.get({ id: fileId }).catch(() => null);
2760
+ if (fileById) {
2761
+ return fileById;
2762
+ }
2763
+ }
2764
+ return fileClient.get({ url: fileUrl }).catch(() => null);
2765
+ };
2766
+ var logDownloadFailure = ({
2767
+ fileUrl,
2768
+ filePath,
2769
+ status
2770
+ }) => {
2771
+ console.warn(
2772
+ `Failed to download file ${fileUrl} (HTTP status: ${status}; expected local path: ${filePath})`
2773
+ );
2774
+ };
2744
2775
  var downloadFile = async ({
2745
2776
  fileClient,
2746
2777
  fileUrl,
2778
+ fileId,
2747
2779
  directory
2748
2780
  }) => {
2749
2781
  const writeDirectory = getFilesDirectory(directory);
@@ -2752,14 +2784,10 @@ var downloadFile = async ({
2752
2784
  const filePath = join10(filesDirectory, fileName);
2753
2785
  const fileAlreadyExists = await fsj2.existsAsync(filePath);
2754
2786
  if (fileAlreadyExists) {
2755
- return { url: fileUrl };
2787
+ return { id: fileId, url: fileUrl };
2756
2788
  }
2757
- const file = await fileClient.get({ url: fileUrl }).catch(() => null);
2758
- if (!file) {
2759
- console.warn(`Skipping file ${fileUrl} as it does not exist in the project anymore`);
2760
- return null;
2761
- }
2762
- if (file.sourceId) {
2789
+ const file = await getFileMetadata({ fileClient, fileId, fileUrl });
2790
+ if (file?.sourceId) {
2763
2791
  const sourceId = file.sourceId;
2764
2792
  try {
2765
2793
  const downloadedFilePaths = await getDownloadedFilePathCache(filesDirectory);
@@ -2770,17 +2798,36 @@ var downloadFile = async ({
2770
2798
  }
2771
2799
  }
2772
2800
  const fetchUrl = `${fileUrl}?format=original`;
2773
- const response = await fetch(fetchUrl);
2801
+ const preserveWarningOnlyFailure = !file;
2802
+ let response;
2803
+ try {
2804
+ response = await fetch(fetchUrl);
2805
+ } catch (error) {
2806
+ logDownloadFailure({ fileUrl, filePath, status: "unavailable" });
2807
+ if (preserveWarningOnlyFailure) {
2808
+ return null;
2809
+ }
2810
+ throw error;
2811
+ }
2774
2812
  if (!response.ok) {
2813
+ logDownloadFailure({ fileUrl, filePath, status: response.status });
2775
2814
  return null;
2776
2815
  }
2777
- await writeResponseBodyToFile(response, filePath);
2816
+ try {
2817
+ await writeResponseBodyToFile(response, filePath);
2818
+ } catch (error) {
2819
+ logDownloadFailure({ fileUrl, filePath, status: response.status });
2820
+ if (preserveWarningOnlyFailure) {
2821
+ return null;
2822
+ }
2823
+ throw error;
2824
+ }
2778
2825
  const downloadedFilePathCache = downloadedFilePathCacheByDirectory.get(filesDirectory);
2779
2826
  if (downloadedFilePathCache) {
2780
2827
  const downloadedFilePaths = await downloadedFilePathCache;
2781
2828
  downloadedFilePaths.add(fileName);
2782
2829
  }
2783
- return { id: file.id, url: fileUrl };
2830
+ return { id: file?.id ?? fileId, url: fileUrl };
2784
2831
  };
2785
2832
 
2786
2833
  // src/files/uploadFile.ts
@@ -2795,11 +2842,24 @@ import PQueue2 from "p-queue";
2795
2842
  import { join as join11 } from "path";
2796
2843
  var uploadQueueByKey = /* @__PURE__ */ new Map();
2797
2844
  var fileUploadQueue = new PQueue2({ concurrency: 10 });
2845
+ var IMAGE_SIZE_SAFE_MEDIA_TYPES = /* @__PURE__ */ new Set([
2846
+ "image/png",
2847
+ "image/apng",
2848
+ "image/jpeg",
2849
+ "image/jpg",
2850
+ "image/jfif",
2851
+ "image/pjpeg",
2852
+ "image/pjp",
2853
+ "image/gif",
2854
+ "image/webp",
2855
+ "image/svg+xml"
2856
+ ]);
2798
2857
  var uploadFile = async ({
2799
2858
  fileClient,
2800
2859
  fileUrl,
2801
2860
  directory,
2802
- fileId
2861
+ fileId,
2862
+ warnIfLocalCopyMissing = true
2803
2863
  }) => {
2804
2864
  const key = `${fileId}-${fileUrl}`;
2805
2865
  if (uploadQueueByKey.has(key)) {
@@ -2822,9 +2882,11 @@ var uploadFile = async ({
2822
2882
  const expectedFilePath = join11(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
2823
2883
  const fileInspect = await fsj3.inspectAsync(expectedFilePath);
2824
2884
  if (fileInspect?.type !== "file") {
2825
- console.warn(
2826
- `Skipping file ${fileUrl} as we couldn't find a local copy (looked at ${expectedFilePath})`
2827
- );
2885
+ if (warnIfLocalCopyMissing) {
2886
+ console.warn(
2887
+ `Skipping file ${fileUrl} as we couldn't find a local copy (looked at ${expectedFilePath})`
2888
+ );
2889
+ }
2828
2890
  return null;
2829
2891
  }
2830
2892
  const fileName = getFileNameFromUrl(fileUrl);
@@ -2856,7 +2918,7 @@ var uploadFile = async ({
2856
2918
  uploadBody = createReadStream(expectedFilePath);
2857
2919
  }
2858
2920
  const { width, height } = await (async () => {
2859
- if (!mimeType.startsWith("image/")) {
2921
+ if (!IMAGE_SIZE_SAFE_MEDIA_TYPES.has(mimeType)) {
2860
2922
  return {
2861
2923
  width: void 0,
2862
2924
  height: void 0
@@ -2985,27 +3047,37 @@ var downloadFileForAsset = async ({
2985
3047
  directory,
2986
3048
  fileClient
2987
3049
  }) => {
2988
- if (asset.asset.fields?.file?.value === void 0 || asset.asset.fields.url?.value === void 0) {
3050
+ const fields = asset.asset.fields;
3051
+ if (!fields) {
2989
3052
  return null;
2990
3053
  }
2991
- const fileId = asset.asset.fields?.file?.value;
2992
- const fileUrl = asset.asset.fields.url?.value;
2993
- if (fileId === "" || fileUrl === "") {
3054
+ const fileId = fields.file?.value;
3055
+ if (!fileId) {
2994
3056
  return null;
2995
3057
  }
2996
- return downloadFile({ fileUrl, directory, fileClient });
3058
+ const fileUrl = fields.url?.value;
3059
+ if (!fileUrl) {
3060
+ return null;
3061
+ }
3062
+ return downloadFile({ fileUrl, fileId, directory, fileClient });
2997
3063
  };
2998
3064
  var uploadFileForAsset = async ({
2999
3065
  asset,
3000
3066
  directory,
3001
3067
  fileClient
3002
3068
  }) => {
3003
- if (asset.asset.fields?.file?.value === void 0 || asset.asset.fields.url?.value === void 0) {
3069
+ const fileId = asset.asset.fields?.file?.value;
3070
+ const fileUrl = asset.asset.fields?.url?.value;
3071
+ if (fileId === void 0 || !fileUrl) {
3004
3072
  return null;
3005
3073
  }
3006
- const fileUrl = asset.asset.fields.url.value;
3007
- const fileId = asset.asset.fields.file.value;
3008
- return uploadFile({ fileUrl, directory, fileClient, fileId });
3074
+ return uploadFile({
3075
+ fileUrl,
3076
+ directory,
3077
+ fileClient,
3078
+ fileId,
3079
+ warnIfLocalCopyMissing: false
3080
+ });
3009
3081
  };
3010
3082
  var removeUrlsFromAssetParameters = (entity) => {
3011
3083
  const treeWalker = ({ node }) => {
@@ -3307,6 +3379,25 @@ function writeCanvasPackage(filename, packageContents) {
3307
3379
 
3308
3380
  // src/commands/canvas/commands/asset/pull.ts
3309
3381
  var ASSET_PULL_ACTION_CONCURRENCY = 10;
3382
+ var prepareAssetForPull = async ({
3383
+ sourceObject,
3384
+ directory,
3385
+ fileClient
3386
+ }) => {
3387
+ delete sourceObject.object.asset._author;
3388
+ if (!sourceObject.object.asset.fields?.file) {
3389
+ return sourceObject;
3390
+ }
3391
+ const downloadedFile = await downloadFileForAsset({
3392
+ asset: sourceObject.object,
3393
+ directory,
3394
+ fileClient
3395
+ });
3396
+ if (downloadedFile?.id) {
3397
+ sourceObject.object.asset.fields.file.value = downloadedFile.id;
3398
+ }
3399
+ return sourceObject;
3400
+ };
3310
3401
  var AssetPullModule = {
3311
3402
  command: "pull <directory>",
3312
3403
  describe: "Pulls all assets to local files in a directory",
@@ -3413,27 +3504,70 @@ var AssetPullModule = {
3413
3504
  return sourceObject;
3414
3505
  },
3415
3506
  compareContents: compareAssetsWithoutUrls,
3416
- onBeforeWriteObject: async (sourceObject) => {
3417
- delete sourceObject.object.asset._author;
3418
- if (!sourceObject.object.asset.fields?.file) {
3419
- return sourceObject;
3420
- }
3421
- const downloadedFile = await downloadFileForAsset({
3422
- asset: sourceObject.object,
3423
- directory,
3424
- fileClient
3425
- });
3426
- if (downloadedFile?.id) {
3427
- sourceObject.object.asset.fields.file.value = downloadedFile.id;
3428
- }
3429
- return sourceObject;
3430
- }
3507
+ onBeforeWriteObject: (sourceObject) => prepareAssetForPull({
3508
+ sourceObject,
3509
+ directory,
3510
+ fileClient
3511
+ })
3431
3512
  });
3432
3513
  }
3433
3514
  };
3434
3515
 
3435
3516
  // src/commands/canvas/commands/asset/push.ts
3517
+ import { join as join13 } from "path";
3436
3518
  var ASSET_PUSH_ACTION_CONCURRENCY = 10;
3519
+ var getExpectedFilePath = (directory, fileUrl) => {
3520
+ if (!fileUrl) {
3521
+ return "Unavailable because the asset has no file URL";
3522
+ }
3523
+ try {
3524
+ return join13(getFilesDirectory(directory), FILES_DIRECTORY_NAME, urlToFileName(fileUrl));
3525
+ } catch {
3526
+ return "Unavailable because the asset file URL is invalid";
3527
+ }
3528
+ };
3529
+ var prepareAssetForPush = async ({
3530
+ sourceObject,
3531
+ directory,
3532
+ fileClient,
3533
+ targetProjectId
3534
+ }) => {
3535
+ const fields = sourceObject.object.asset.fields;
3536
+ const fileId = fields?.file?.value;
3537
+ if (!fields || !fileId) {
3538
+ return sourceObject;
3539
+ }
3540
+ const uploadedFile = await uploadFileForAsset({
3541
+ asset: sourceObject.object,
3542
+ directory,
3543
+ fileClient
3544
+ });
3545
+ if (!uploadedFile) {
3546
+ const assetId = sourceObject.object.asset._id;
3547
+ const fileUrl = fields.url?.value;
3548
+ const expectedFilePath = getExpectedFilePath(directory, fileUrl);
3549
+ throw new Error(
3550
+ [
3551
+ `Unable to push asset "${sourceObject.displayName ?? assetId}" (${assetId}) because its file could not be uploaded.`,
3552
+ `Source project ID: ${sourceObject.object.projectId ?? "Unavailable"}`,
3553
+ `Target project ID: ${targetProjectId}`,
3554
+ `File ID: ${fileId}`,
3555
+ `File URL: ${fileUrl || "Missing"}`,
3556
+ `Expected local path: ${expectedFilePath}`,
3557
+ `Remove the asset with the ID ${assetId} before pushing again.`
3558
+ ].join("\n")
3559
+ );
3560
+ }
3561
+ fields.file = {
3562
+ type: "file",
3563
+ value: uploadedFile.id
3564
+ };
3565
+ fields.url = {
3566
+ type: "text",
3567
+ value: uploadedFile.url
3568
+ };
3569
+ return sourceObject;
3570
+ };
3437
3571
  var AssetPushModule = {
3438
3572
  command: "push <directory>",
3439
3573
  describe: "Pushes all assets from files in a directory to Uniform",
@@ -3519,27 +3653,12 @@ var AssetPushModule = {
3519
3653
  return sourceObject;
3520
3654
  },
3521
3655
  compareContents: compareAssetsWithoutUrls,
3522
- onBeforeWriteObject: async (sourceObject) => {
3523
- const uploadedFile = await uploadFileForAsset({
3524
- asset: sourceObject.object,
3525
- directory,
3526
- fileClient
3527
- });
3528
- if (uploadedFile !== null) {
3529
- if (sourceObject.object.asset.fields === void 0) {
3530
- sourceObject.object.asset.fields = {};
3531
- }
3532
- sourceObject.object.asset.fields.file = {
3533
- type: "file",
3534
- value: uploadedFile.id
3535
- };
3536
- sourceObject.object.asset.fields.url = {
3537
- type: "text",
3538
- value: uploadedFile.url
3539
- };
3540
- }
3541
- return sourceObject;
3542
- }
3656
+ onBeforeWriteObject: (sourceObject) => prepareAssetForPush({
3657
+ sourceObject,
3658
+ directory,
3659
+ fileClient,
3660
+ targetProjectId: projectId
3661
+ })
3543
3662
  });
3544
3663
  }
3545
3664
  };
@@ -12069,7 +12188,7 @@ var PolicyDocumentsPullModule = {
12069
12188
  // src/commands/policy-documents/commands/push.ts
12070
12189
  import { existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
12071
12190
  import { readdir as readdir2 } from "fs/promises";
12072
- import { extname as extname3, join as join13 } from "path";
12191
+ import { extname as extname3, join as join14 } from "path";
12073
12192
  async function readLocalPolicyDocuments(directory, format, verbose) {
12074
12193
  const files = await readdir2(directory);
12075
12194
  const policyDocuments = {};
@@ -12079,7 +12198,7 @@ async function readLocalPolicyDocuments(directory, format, verbose) {
12079
12198
  if (ext !== `.${format}` && ext !== ".yaml" && ext !== ".yml" && ext !== ".json") {
12080
12199
  continue;
12081
12200
  }
12082
- const filePath = join13(directory, filename);
12201
+ const filePath = join14(directory, filename);
12083
12202
  try {
12084
12203
  let roleId = filename.replace(ext, "");
12085
12204
  const fileContent = readFileToObject(filePath);
@@ -14087,14 +14206,14 @@ import { existsSync as existsSync9, promises as fs8 } from "fs";
14087
14206
  import { get as getHttp } from "http";
14088
14207
  import { get as getHttps } from "https";
14089
14208
  import { tmpdir as tmpdir2 } from "os";
14090
- import { join as join14 } from "path";
14209
+ import { join as join15 } from "path";
14091
14210
  import registryUrl from "registry-url";
14092
14211
  import { URL as URL2 } from "url";
14093
14212
  var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
14094
14213
  var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
14095
14214
  var getFile = async (details, distTag) => {
14096
14215
  const rootDir = tmpdir2();
14097
- const subDir = join14(rootDir, "update-check");
14216
+ const subDir = join15(rootDir, "update-check");
14098
14217
  if (!existsSync9(subDir)) {
14099
14218
  await fs8.mkdir(subDir);
14100
14219
  }
@@ -14102,7 +14221,7 @@ var getFile = async (details, distTag) => {
14102
14221
  if (details.scope) {
14103
14222
  name = `${details.scope}-${name}`;
14104
14223
  }
14105
- return join14(subDir, name);
14224
+ return join15(subDir, name);
14106
14225
  };
14107
14226
  var evaluateCache = async (file, time, interval) => {
14108
14227
  if (existsSync9(file)) {
@@ -14257,7 +14376,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
14257
14376
 
14258
14377
  // src/middleware/checkLocalDepsVersionsMiddleware.ts
14259
14378
  import { magenta, red as red8 } from "colorette";
14260
- import { join as join15 } from "path";
14379
+ import { join as join16 } from "path";
14261
14380
  var uniformStrictVersions = [
14262
14381
  "@uniformdev/canvas",
14263
14382
  "@uniformdev/canvas-next",
@@ -14279,7 +14398,7 @@ var checkLocalDepsVersions = async (args) => {
14279
14398
  try {
14280
14399
  let isOutside = false;
14281
14400
  let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
14282
- const localPackages = await tryReadJSON(join15(process.cwd(), "package.json"));
14401
+ const localPackages = await tryReadJSON(join16(process.cwd(), "package.json"));
14283
14402
  if (!localPackages) return;
14284
14403
  let firstVersion;
14285
14404
  const allDependencies = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.76.2",
3
+ "version": "20.77.0",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -27,14 +27,14 @@
27
27
  "dependencies": {
28
28
  "@inquirer/prompts": "^8.5.2",
29
29
  "@thi.ng/mime": "^2.2.23",
30
- "@uniformdev/assets": "20.76.2",
31
- "@uniformdev/automations-sdk": "20.76.2",
32
- "@uniformdev/canvas": "20.76.2",
33
- "@uniformdev/context": "20.76.2",
34
- "@uniformdev/files": "20.76.2",
35
- "@uniformdev/project-map": "20.76.2",
36
- "@uniformdev/redirect": "20.76.2",
37
- "@uniformdev/richtext": "20.76.2",
30
+ "@uniformdev/assets": "20.77.0",
31
+ "@uniformdev/automations-sdk": "20.77.0",
32
+ "@uniformdev/canvas": "20.77.0",
33
+ "@uniformdev/context": "20.77.0",
34
+ "@uniformdev/files": "20.77.0",
35
+ "@uniformdev/project-map": "20.77.0",
36
+ "@uniformdev/redirect": "20.77.0",
37
+ "@uniformdev/richtext": "20.77.0",
38
38
  "call-bind": "^1.0.2",
39
39
  "colorette": "2.0.20",
40
40
  "cosmiconfig": "9.0.2",
@@ -47,7 +47,7 @@
47
47
  "fs-jetpack": "5.1.0",
48
48
  "image-size": "2.0.2",
49
49
  "isomorphic-git": "1.38.5",
50
- "js-yaml": "^4.2.0",
50
+ "js-yaml": "^4.3.1",
51
51
  "jsonwebtoken": "9.0.3",
52
52
  "mitt": "^3.0.1",
53
53
  "normalize-newline": "^4.1.0",
@@ -59,7 +59,7 @@
59
59
  "registry-url": "^6.0.0",
60
60
  "slugify": "1.6.9",
61
61
  "svix": "^1.96.0",
62
- "undici": "^7.28.0",
62
+ "undici": "^7.29.0",
63
63
  "yargs": "^18.0.0",
64
64
  "zod": "4.4.3"
65
65
  },
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "d977f0afc2aa754b18053d9455e007712e712dbb"
81
+ "gitHead": "f994c88e282d803eae476fb5078e106ab66c38e0"
82
82
  }