@uniformdev/cli 20.75.1-alpha.15.sha-b6ff05804e → 20.75.1-alpha.6

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.2_1593607ac254a0f78ffdb743585a4e57/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.1_7017c7d2ba4cec51f3116591eb787c26/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.0",
24
+ version: "20.75.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.3.1",
71
+ "js-yaml": "^4.2.0",
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.29.0",
83
+ undici: "^7.28.0",
84
84
  yargs: "^18.0.0",
85
85
  zod: "4.4.3"
86
86
  },
@@ -1,4 +1,4 @@
1
- import "./chunk-CGMR2SR6.mjs";
1
+ import "./chunk-GIRIO3PU.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-CGMR2SR6.mjs";
26
+ } from "./chunk-GIRIO3PU.mjs";
27
27
 
28
28
  // src/index.ts
29
29
  import * as dotenv from "dotenv";
@@ -2741,9 +2741,32 @@ var writeResponseBodyToFile = async (response, filePath) => {
2741
2741
  throw error;
2742
2742
  }
2743
2743
  };
2744
+ var getFileMetadata = async ({
2745
+ fileClient,
2746
+ fileId,
2747
+ fileUrl
2748
+ }) => {
2749
+ if (fileId) {
2750
+ const fileById = await fileClient.get({ id: fileId }).catch(() => null);
2751
+ if (fileById) {
2752
+ return fileById;
2753
+ }
2754
+ }
2755
+ return fileClient.get({ url: fileUrl }).catch(() => null);
2756
+ };
2757
+ var logDownloadFailure = ({
2758
+ fileUrl,
2759
+ filePath,
2760
+ status
2761
+ }) => {
2762
+ console.warn(
2763
+ `Failed to download file ${fileUrl} (HTTP status: ${status}; expected local path: ${filePath})`
2764
+ );
2765
+ };
2744
2766
  var downloadFile = async ({
2745
2767
  fileClient,
2746
2768
  fileUrl,
2769
+ fileId,
2747
2770
  directory
2748
2771
  }) => {
2749
2772
  const writeDirectory = getFilesDirectory(directory);
@@ -2752,14 +2775,10 @@ var downloadFile = async ({
2752
2775
  const filePath = join10(filesDirectory, fileName);
2753
2776
  const fileAlreadyExists = await fsj2.existsAsync(filePath);
2754
2777
  if (fileAlreadyExists) {
2755
- return { url: fileUrl };
2778
+ return { id: fileId, url: fileUrl };
2756
2779
  }
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) {
2780
+ const file = await getFileMetadata({ fileClient, fileId, fileUrl });
2781
+ if (file?.sourceId) {
2763
2782
  const sourceId = file.sourceId;
2764
2783
  try {
2765
2784
  const downloadedFilePaths = await getDownloadedFilePathCache(filesDirectory);
@@ -2770,17 +2789,36 @@ var downloadFile = async ({
2770
2789
  }
2771
2790
  }
2772
2791
  const fetchUrl = `${fileUrl}?format=original`;
2773
- const response = await fetch(fetchUrl);
2792
+ const preserveWarningOnlyFailure = Boolean(fileId) || !file;
2793
+ let response;
2794
+ try {
2795
+ response = await fetch(fetchUrl);
2796
+ } catch (error) {
2797
+ logDownloadFailure({ fileUrl, filePath, status: "unavailable" });
2798
+ if (preserveWarningOnlyFailure) {
2799
+ return null;
2800
+ }
2801
+ throw error;
2802
+ }
2774
2803
  if (!response.ok) {
2804
+ logDownloadFailure({ fileUrl, filePath, status: response.status });
2775
2805
  return null;
2776
2806
  }
2777
- await writeResponseBodyToFile(response, filePath);
2807
+ try {
2808
+ await writeResponseBodyToFile(response, filePath);
2809
+ } catch (error) {
2810
+ logDownloadFailure({ fileUrl, filePath, status: response.status });
2811
+ if (preserveWarningOnlyFailure) {
2812
+ return null;
2813
+ }
2814
+ throw error;
2815
+ }
2778
2816
  const downloadedFilePathCache = downloadedFilePathCacheByDirectory.get(filesDirectory);
2779
2817
  if (downloadedFilePathCache) {
2780
2818
  const downloadedFilePaths = await downloadedFilePathCache;
2781
2819
  downloadedFilePaths.add(fileName);
2782
2820
  }
2783
- return { id: file.id, url: fileUrl };
2821
+ return { id: file?.id ?? fileId, url: fileUrl };
2784
2822
  };
2785
2823
 
2786
2824
  // src/files/uploadFile.ts
@@ -2795,18 +2833,6 @@ import PQueue2 from "p-queue";
2795
2833
  import { join as join11 } from "path";
2796
2834
  var uploadQueueByKey = /* @__PURE__ */ new Map();
2797
2835
  var fileUploadQueue = new PQueue2({ concurrency: 10 });
2798
- var IMAGE_SIZE_SAFE_MEDIA_TYPES = /* @__PURE__ */ new Set([
2799
- "image/png",
2800
- "image/apng",
2801
- "image/jpeg",
2802
- "image/jpg",
2803
- "image/jfif",
2804
- "image/pjpeg",
2805
- "image/pjp",
2806
- "image/gif",
2807
- "image/webp",
2808
- "image/svg+xml"
2809
- ]);
2810
2836
  var uploadFile = async ({
2811
2837
  fileClient,
2812
2838
  fileUrl,
@@ -2868,7 +2894,7 @@ var uploadFile = async ({
2868
2894
  uploadBody = createReadStream(expectedFilePath);
2869
2895
  }
2870
2896
  const { width, height } = await (async () => {
2871
- if (!IMAGE_SIZE_SAFE_MEDIA_TYPES.has(mimeType)) {
2897
+ if (!mimeType.startsWith("image/")) {
2872
2898
  return {
2873
2899
  width: void 0,
2874
2900
  height: void 0
@@ -2997,15 +3023,19 @@ var downloadFileForAsset = async ({
2997
3023
  directory,
2998
3024
  fileClient
2999
3025
  }) => {
3000
- if (asset.asset.fields?.file?.value === void 0 || asset.asset.fields.url?.value === void 0) {
3026
+ const fields = asset.asset.fields;
3027
+ if (!fields) {
3001
3028
  return null;
3002
3029
  }
3003
- const fileId = asset.asset.fields?.file?.value;
3004
- const fileUrl = asset.asset.fields.url?.value;
3005
- if (fileId === "" || fileUrl === "") {
3030
+ const fileId = fields.file?.value;
3031
+ if (!fileId) {
3006
3032
  return null;
3007
3033
  }
3008
- return downloadFile({ fileUrl, directory, fileClient });
3034
+ const fileUrl = fields.url?.value;
3035
+ if (!fileUrl) {
3036
+ return null;
3037
+ }
3038
+ return downloadFile({ fileUrl, fileId, directory, fileClient });
3009
3039
  };
3010
3040
  var uploadFileForAsset = async ({
3011
3041
  asset,
@@ -3319,6 +3349,25 @@ function writeCanvasPackage(filename, packageContents) {
3319
3349
 
3320
3350
  // src/commands/canvas/commands/asset/pull.ts
3321
3351
  var ASSET_PULL_ACTION_CONCURRENCY = 10;
3352
+ var prepareAssetForPull = async ({
3353
+ sourceObject,
3354
+ directory,
3355
+ fileClient
3356
+ }) => {
3357
+ delete sourceObject.object.asset._author;
3358
+ if (!sourceObject.object.asset.fields?.file) {
3359
+ return sourceObject;
3360
+ }
3361
+ const downloadedFile = await downloadFileForAsset({
3362
+ asset: sourceObject.object,
3363
+ directory,
3364
+ fileClient
3365
+ });
3366
+ if (downloadedFile?.id) {
3367
+ sourceObject.object.asset.fields.file.value = downloadedFile.id;
3368
+ }
3369
+ return sourceObject;
3370
+ };
3322
3371
  var AssetPullModule = {
3323
3372
  command: "pull <directory>",
3324
3373
  describe: "Pulls all assets to local files in a directory",
@@ -3425,27 +3474,59 @@ var AssetPullModule = {
3425
3474
  return sourceObject;
3426
3475
  },
3427
3476
  compareContents: compareAssetsWithoutUrls,
3428
- onBeforeWriteObject: async (sourceObject) => {
3429
- delete sourceObject.object.asset._author;
3430
- if (!sourceObject.object.asset.fields?.file) {
3431
- return sourceObject;
3432
- }
3433
- const downloadedFile = await downloadFileForAsset({
3434
- asset: sourceObject.object,
3435
- directory,
3436
- fileClient
3437
- });
3438
- if (downloadedFile?.id) {
3439
- sourceObject.object.asset.fields.file.value = downloadedFile.id;
3440
- }
3441
- return sourceObject;
3442
- }
3477
+ onBeforeWriteObject: (sourceObject) => prepareAssetForPull({
3478
+ sourceObject,
3479
+ directory,
3480
+ fileClient
3481
+ })
3443
3482
  });
3444
3483
  }
3445
3484
  };
3446
3485
 
3447
3486
  // src/commands/canvas/commands/asset/push.ts
3487
+ import { join as join13 } from "path";
3448
3488
  var ASSET_PUSH_ACTION_CONCURRENCY = 10;
3489
+ var prepareAssetForPush = async ({
3490
+ sourceObject,
3491
+ directory,
3492
+ fileClient,
3493
+ targetProjectId
3494
+ }) => {
3495
+ const fields = sourceObject.object.asset.fields;
3496
+ const fileId = fields?.file?.value;
3497
+ if (!fields || !fileId) {
3498
+ return sourceObject;
3499
+ }
3500
+ const uploadedFile = await uploadFileForAsset({
3501
+ asset: sourceObject.object,
3502
+ directory,
3503
+ fileClient
3504
+ });
3505
+ if (!uploadedFile) {
3506
+ const fileUrl = fields.url?.value;
3507
+ const expectedFilePath = fileUrl ? join13(getFilesDirectory(directory), FILES_DIRECTORY_NAME, urlToFileName(fileUrl)) : "Unavailable because the asset has no file URL";
3508
+ throw new Error(
3509
+ [
3510
+ `Unable to push asset "${sourceObject.displayName ?? sourceObject.providerId}" (${sourceObject.providerId}) because its file could not be uploaded.`,
3511
+ `Source project ID: ${sourceObject.object.projectId}`,
3512
+ `Target project ID: ${targetProjectId}`,
3513
+ `File ID: ${fileId}`,
3514
+ `File URL: ${fileUrl ?? "Missing"}`,
3515
+ `Expected local path: ${expectedFilePath}`,
3516
+ `Remove the asset with the ID ${sourceObject.providerId} before pushing again.`
3517
+ ].join("\n")
3518
+ );
3519
+ }
3520
+ fields.file = {
3521
+ type: "file",
3522
+ value: uploadedFile.id
3523
+ };
3524
+ fields.url = {
3525
+ type: "text",
3526
+ value: uploadedFile.url
3527
+ };
3528
+ return sourceObject;
3529
+ };
3449
3530
  var AssetPushModule = {
3450
3531
  command: "push <directory>",
3451
3532
  describe: "Pushes all assets from files in a directory to Uniform",
@@ -3531,27 +3612,12 @@ var AssetPushModule = {
3531
3612
  return sourceObject;
3532
3613
  },
3533
3614
  compareContents: compareAssetsWithoutUrls,
3534
- onBeforeWriteObject: async (sourceObject) => {
3535
- const uploadedFile = await uploadFileForAsset({
3536
- asset: sourceObject.object,
3537
- directory,
3538
- fileClient
3539
- });
3540
- if (uploadedFile !== null) {
3541
- if (sourceObject.object.asset.fields === void 0) {
3542
- sourceObject.object.asset.fields = {};
3543
- }
3544
- sourceObject.object.asset.fields.file = {
3545
- type: "file",
3546
- value: uploadedFile.id
3547
- };
3548
- sourceObject.object.asset.fields.url = {
3549
- type: "text",
3550
- value: uploadedFile.url
3551
- };
3552
- }
3553
- return sourceObject;
3554
- }
3615
+ onBeforeWriteObject: (sourceObject) => prepareAssetForPush({
3616
+ sourceObject,
3617
+ directory,
3618
+ fileClient,
3619
+ targetProjectId: projectId
3620
+ })
3555
3621
  });
3556
3622
  }
3557
3623
  };
@@ -12081,7 +12147,7 @@ var PolicyDocumentsPullModule = {
12081
12147
  // src/commands/policy-documents/commands/push.ts
12082
12148
  import { existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
12083
12149
  import { readdir as readdir2 } from "fs/promises";
12084
- import { extname as extname3, join as join13 } from "path";
12150
+ import { extname as extname3, join as join14 } from "path";
12085
12151
  async function readLocalPolicyDocuments(directory, format, verbose) {
12086
12152
  const files = await readdir2(directory);
12087
12153
  const policyDocuments = {};
@@ -12091,7 +12157,7 @@ async function readLocalPolicyDocuments(directory, format, verbose) {
12091
12157
  if (ext !== `.${format}` && ext !== ".yaml" && ext !== ".yml" && ext !== ".json") {
12092
12158
  continue;
12093
12159
  }
12094
- const filePath = join13(directory, filename);
12160
+ const filePath = join14(directory, filename);
12095
12161
  try {
12096
12162
  let roleId = filename.replace(ext, "");
12097
12163
  const fileContent = readFileToObject(filePath);
@@ -14099,14 +14165,14 @@ import { existsSync as existsSync9, promises as fs8 } from "fs";
14099
14165
  import { get as getHttp } from "http";
14100
14166
  import { get as getHttps } from "https";
14101
14167
  import { tmpdir as tmpdir2 } from "os";
14102
- import { join as join14 } from "path";
14168
+ import { join as join15 } from "path";
14103
14169
  import registryUrl from "registry-url";
14104
14170
  import { URL as URL2 } from "url";
14105
14171
  var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
14106
14172
  var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
14107
14173
  var getFile = async (details, distTag) => {
14108
14174
  const rootDir = tmpdir2();
14109
- const subDir = join14(rootDir, "update-check");
14175
+ const subDir = join15(rootDir, "update-check");
14110
14176
  if (!existsSync9(subDir)) {
14111
14177
  await fs8.mkdir(subDir);
14112
14178
  }
@@ -14114,7 +14180,7 @@ var getFile = async (details, distTag) => {
14114
14180
  if (details.scope) {
14115
14181
  name = `${details.scope}-${name}`;
14116
14182
  }
14117
- return join14(subDir, name);
14183
+ return join15(subDir, name);
14118
14184
  };
14119
14185
  var evaluateCache = async (file, time, interval) => {
14120
14186
  if (existsSync9(file)) {
@@ -14269,7 +14335,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
14269
14335
 
14270
14336
  // src/middleware/checkLocalDepsVersionsMiddleware.ts
14271
14337
  import { magenta, red as red8 } from "colorette";
14272
- import { join as join15 } from "path";
14338
+ import { join as join16 } from "path";
14273
14339
  var uniformStrictVersions = [
14274
14340
  "@uniformdev/canvas",
14275
14341
  "@uniformdev/canvas-next",
@@ -14291,7 +14357,7 @@ var checkLocalDepsVersions = async (args) => {
14291
14357
  try {
14292
14358
  let isOutside = false;
14293
14359
  let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
14294
- const localPackages = await tryReadJSON(join15(process.cwd(), "package.json"));
14360
+ const localPackages = await tryReadJSON(join16(process.cwd(), "package.json"));
14295
14361
  if (!localPackages) return;
14296
14362
  let firstVersion;
14297
14363
  const allDependencies = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.75.1-alpha.15.sha-b6ff05804e",
3
+ "version": "20.75.1-alpha.6+28f494b01a",
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.75.1-alpha.15.sha-b6ff05804e",
31
- "@uniformdev/automations-sdk": "20.75.1-alpha.15.sha-b6ff05804e",
32
- "@uniformdev/canvas": "20.75.1-alpha.15.sha-b6ff05804e",
33
- "@uniformdev/context": "20.75.1-alpha.15.sha-b6ff05804e",
34
- "@uniformdev/files": "20.75.1-alpha.15.sha-b6ff05804e",
35
- "@uniformdev/project-map": "20.75.1-alpha.15.sha-b6ff05804e",
36
- "@uniformdev/redirect": "20.75.1-alpha.15.sha-b6ff05804e",
37
- "@uniformdev/richtext": "20.75.1-alpha.15.sha-b6ff05804e",
30
+ "@uniformdev/assets": "20.75.1-alpha.6+28f494b01a",
31
+ "@uniformdev/automations-sdk": "20.75.1-alpha.6+28f494b01a",
32
+ "@uniformdev/canvas": "20.75.1-alpha.6+28f494b01a",
33
+ "@uniformdev/context": "20.75.1-alpha.6+28f494b01a",
34
+ "@uniformdev/files": "20.75.1-alpha.6+28f494b01a",
35
+ "@uniformdev/project-map": "20.75.1-alpha.6+28f494b01a",
36
+ "@uniformdev/redirect": "20.75.1-alpha.6+28f494b01a",
37
+ "@uniformdev/richtext": "20.75.1-alpha.6+28f494b01a",
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.3.1",
50
+ "js-yaml": "^4.2.0",
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.29.0",
62
+ "undici": "^7.28.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": "b6ff05804e8d082bdd9563566f9eda24d999a771"
81
+ "gitHead": "28f494b01a1b988afdf9f7e3ecf6fad402bb3777"
82
82
  }