@uniformdev/cli 20.76.3-alpha.7.sha-dd3877d123 → 20.77.1-alpha.10.sha-3381091ae6
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.
- package/dist/{chunk-BO22W54V.mjs → chunk-4FPNEXON.mjs} +1 -1
- package/dist/defaultConfig.mjs +1 -1
- package/dist/index.mjs +165 -67
- package/package.json +10 -10
|
@@ -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.
|
|
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",
|
package/dist/defaultConfig.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
withFormatOptions,
|
|
24
24
|
withProjectOptions,
|
|
25
25
|
withTeamOptions
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4FPNEXON.mjs";
|
|
27
27
|
|
|
28
28
|
// src/index.ts
|
|
29
29
|
import * as dotenv from "dotenv";
|
|
@@ -2750,9 +2750,32 @@ var writeResponseBodyToFile = async (response, filePath) => {
|
|
|
2750
2750
|
throw error;
|
|
2751
2751
|
}
|
|
2752
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
|
+
};
|
|
2753
2775
|
var downloadFile = async ({
|
|
2754
2776
|
fileClient,
|
|
2755
2777
|
fileUrl,
|
|
2778
|
+
fileId,
|
|
2756
2779
|
directory
|
|
2757
2780
|
}) => {
|
|
2758
2781
|
const writeDirectory = getFilesDirectory(directory);
|
|
@@ -2761,14 +2784,10 @@ var downloadFile = async ({
|
|
|
2761
2784
|
const filePath = join10(filesDirectory, fileName);
|
|
2762
2785
|
const fileAlreadyExists = await fsj2.existsAsync(filePath);
|
|
2763
2786
|
if (fileAlreadyExists) {
|
|
2764
|
-
return { url: fileUrl };
|
|
2765
|
-
}
|
|
2766
|
-
const file = await fileClient.get({ url: fileUrl }).catch(() => null);
|
|
2767
|
-
if (!file) {
|
|
2768
|
-
console.warn(`Skipping file ${fileUrl} as it does not exist in the project anymore`);
|
|
2769
|
-
return null;
|
|
2787
|
+
return { id: fileId, url: fileUrl };
|
|
2770
2788
|
}
|
|
2771
|
-
|
|
2789
|
+
const file = await getFileMetadata({ fileClient, fileId, fileUrl });
|
|
2790
|
+
if (file?.sourceId) {
|
|
2772
2791
|
const sourceId = file.sourceId;
|
|
2773
2792
|
try {
|
|
2774
2793
|
const downloadedFilePaths = await getDownloadedFilePathCache(filesDirectory);
|
|
@@ -2779,17 +2798,36 @@ var downloadFile = async ({
|
|
|
2779
2798
|
}
|
|
2780
2799
|
}
|
|
2781
2800
|
const fetchUrl = `${fileUrl}?format=original`;
|
|
2782
|
-
const
|
|
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
|
+
}
|
|
2783
2812
|
if (!response.ok) {
|
|
2813
|
+
logDownloadFailure({ fileUrl, filePath, status: response.status });
|
|
2784
2814
|
return null;
|
|
2785
2815
|
}
|
|
2786
|
-
|
|
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
|
+
}
|
|
2787
2825
|
const downloadedFilePathCache = downloadedFilePathCacheByDirectory.get(filesDirectory);
|
|
2788
2826
|
if (downloadedFilePathCache) {
|
|
2789
2827
|
const downloadedFilePaths = await downloadedFilePathCache;
|
|
2790
2828
|
downloadedFilePaths.add(fileName);
|
|
2791
2829
|
}
|
|
2792
|
-
return { id: file
|
|
2830
|
+
return { id: file?.id ?? fileId, url: fileUrl };
|
|
2793
2831
|
};
|
|
2794
2832
|
|
|
2795
2833
|
// src/files/uploadFile.ts
|
|
@@ -2820,7 +2858,8 @@ var uploadFile = async ({
|
|
|
2820
2858
|
fileClient,
|
|
2821
2859
|
fileUrl,
|
|
2822
2860
|
directory,
|
|
2823
|
-
fileId
|
|
2861
|
+
fileId,
|
|
2862
|
+
warnIfLocalCopyMissing = true
|
|
2824
2863
|
}) => {
|
|
2825
2864
|
const key = `${fileId}-${fileUrl}`;
|
|
2826
2865
|
if (uploadQueueByKey.has(key)) {
|
|
@@ -2843,9 +2882,11 @@ var uploadFile = async ({
|
|
|
2843
2882
|
const expectedFilePath = join11(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
|
|
2844
2883
|
const fileInspect = await fsj3.inspectAsync(expectedFilePath);
|
|
2845
2884
|
if (fileInspect?.type !== "file") {
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2885
|
+
if (warnIfLocalCopyMissing) {
|
|
2886
|
+
console.warn(
|
|
2887
|
+
`Skipping file ${fileUrl} as we couldn't find a local copy (looked at ${expectedFilePath})`
|
|
2888
|
+
);
|
|
2889
|
+
}
|
|
2849
2890
|
return null;
|
|
2850
2891
|
}
|
|
2851
2892
|
const fileName = getFileNameFromUrl(fileUrl);
|
|
@@ -3006,27 +3047,37 @@ var downloadFileForAsset = async ({
|
|
|
3006
3047
|
directory,
|
|
3007
3048
|
fileClient
|
|
3008
3049
|
}) => {
|
|
3009
|
-
|
|
3050
|
+
const fields = asset.asset.fields;
|
|
3051
|
+
if (!fields) {
|
|
3010
3052
|
return null;
|
|
3011
3053
|
}
|
|
3012
|
-
const fileId =
|
|
3013
|
-
|
|
3014
|
-
if (fileId === "" || fileUrl === "") {
|
|
3054
|
+
const fileId = fields.file?.value;
|
|
3055
|
+
if (!fileId) {
|
|
3015
3056
|
return null;
|
|
3016
3057
|
}
|
|
3017
|
-
|
|
3058
|
+
const fileUrl = fields.url?.value;
|
|
3059
|
+
if (!fileUrl) {
|
|
3060
|
+
return null;
|
|
3061
|
+
}
|
|
3062
|
+
return downloadFile({ fileUrl, fileId, directory, fileClient });
|
|
3018
3063
|
};
|
|
3019
3064
|
var uploadFileForAsset = async ({
|
|
3020
3065
|
asset,
|
|
3021
3066
|
directory,
|
|
3022
3067
|
fileClient
|
|
3023
3068
|
}) => {
|
|
3024
|
-
|
|
3069
|
+
const fileId = asset.asset.fields?.file?.value;
|
|
3070
|
+
const fileUrl = asset.asset.fields?.url?.value;
|
|
3071
|
+
if (fileId === void 0 || !fileUrl) {
|
|
3025
3072
|
return null;
|
|
3026
3073
|
}
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3074
|
+
return uploadFile({
|
|
3075
|
+
fileUrl,
|
|
3076
|
+
directory,
|
|
3077
|
+
fileClient,
|
|
3078
|
+
fileId,
|
|
3079
|
+
warnIfLocalCopyMissing: false
|
|
3080
|
+
});
|
|
3030
3081
|
};
|
|
3031
3082
|
var removeUrlsFromAssetParameters = (entity) => {
|
|
3032
3083
|
const treeWalker = ({ node }) => {
|
|
@@ -3328,6 +3379,25 @@ function writeCanvasPackage(filename, packageContents) {
|
|
|
3328
3379
|
|
|
3329
3380
|
// src/commands/canvas/commands/asset/pull.ts
|
|
3330
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
|
+
};
|
|
3331
3401
|
var AssetPullModule = {
|
|
3332
3402
|
command: "pull <directory>",
|
|
3333
3403
|
describe: "Pulls all assets to local files in a directory",
|
|
@@ -3434,27 +3504,70 @@ var AssetPullModule = {
|
|
|
3434
3504
|
return sourceObject;
|
|
3435
3505
|
},
|
|
3436
3506
|
compareContents: compareAssetsWithoutUrls,
|
|
3437
|
-
onBeforeWriteObject:
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
const downloadedFile = await downloadFileForAsset({
|
|
3443
|
-
asset: sourceObject.object,
|
|
3444
|
-
directory,
|
|
3445
|
-
fileClient
|
|
3446
|
-
});
|
|
3447
|
-
if (downloadedFile?.id) {
|
|
3448
|
-
sourceObject.object.asset.fields.file.value = downloadedFile.id;
|
|
3449
|
-
}
|
|
3450
|
-
return sourceObject;
|
|
3451
|
-
}
|
|
3507
|
+
onBeforeWriteObject: (sourceObject) => prepareAssetForPull({
|
|
3508
|
+
sourceObject,
|
|
3509
|
+
directory,
|
|
3510
|
+
fileClient
|
|
3511
|
+
})
|
|
3452
3512
|
});
|
|
3453
3513
|
}
|
|
3454
3514
|
};
|
|
3455
3515
|
|
|
3456
3516
|
// src/commands/canvas/commands/asset/push.ts
|
|
3517
|
+
import { join as join13 } from "path";
|
|
3457
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
|
+
};
|
|
3458
3571
|
var AssetPushModule = {
|
|
3459
3572
|
command: "push <directory>",
|
|
3460
3573
|
describe: "Pushes all assets from files in a directory to Uniform",
|
|
@@ -3540,27 +3653,12 @@ var AssetPushModule = {
|
|
|
3540
3653
|
return sourceObject;
|
|
3541
3654
|
},
|
|
3542
3655
|
compareContents: compareAssetsWithoutUrls,
|
|
3543
|
-
onBeforeWriteObject:
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
if (uploadedFile !== null) {
|
|
3550
|
-
if (sourceObject.object.asset.fields === void 0) {
|
|
3551
|
-
sourceObject.object.asset.fields = {};
|
|
3552
|
-
}
|
|
3553
|
-
sourceObject.object.asset.fields.file = {
|
|
3554
|
-
type: "file",
|
|
3555
|
-
value: uploadedFile.id
|
|
3556
|
-
};
|
|
3557
|
-
sourceObject.object.asset.fields.url = {
|
|
3558
|
-
type: "text",
|
|
3559
|
-
value: uploadedFile.url
|
|
3560
|
-
};
|
|
3561
|
-
}
|
|
3562
|
-
return sourceObject;
|
|
3563
|
-
}
|
|
3656
|
+
onBeforeWriteObject: (sourceObject) => prepareAssetForPush({
|
|
3657
|
+
sourceObject,
|
|
3658
|
+
directory,
|
|
3659
|
+
fileClient,
|
|
3660
|
+
targetProjectId: projectId
|
|
3661
|
+
})
|
|
3564
3662
|
});
|
|
3565
3663
|
}
|
|
3566
3664
|
};
|
|
@@ -12090,7 +12188,7 @@ var PolicyDocumentsPullModule = {
|
|
|
12090
12188
|
// src/commands/policy-documents/commands/push.ts
|
|
12091
12189
|
import { existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
|
|
12092
12190
|
import { readdir as readdir2 } from "fs/promises";
|
|
12093
|
-
import { extname as extname3, join as
|
|
12191
|
+
import { extname as extname3, join as join14 } from "path";
|
|
12094
12192
|
async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
12095
12193
|
const files = await readdir2(directory);
|
|
12096
12194
|
const policyDocuments = {};
|
|
@@ -12100,7 +12198,7 @@ async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
|
12100
12198
|
if (ext !== `.${format}` && ext !== ".yaml" && ext !== ".yml" && ext !== ".json") {
|
|
12101
12199
|
continue;
|
|
12102
12200
|
}
|
|
12103
|
-
const filePath =
|
|
12201
|
+
const filePath = join14(directory, filename);
|
|
12104
12202
|
try {
|
|
12105
12203
|
let roleId = filename.replace(ext, "");
|
|
12106
12204
|
const fileContent = readFileToObject(filePath);
|
|
@@ -14108,14 +14206,14 @@ import { existsSync as existsSync9, promises as fs8 } from "fs";
|
|
|
14108
14206
|
import { get as getHttp } from "http";
|
|
14109
14207
|
import { get as getHttps } from "https";
|
|
14110
14208
|
import { tmpdir as tmpdir2 } from "os";
|
|
14111
|
-
import { join as
|
|
14209
|
+
import { join as join15 } from "path";
|
|
14112
14210
|
import registryUrl from "registry-url";
|
|
14113
14211
|
import { URL as URL2 } from "url";
|
|
14114
14212
|
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
14115
14213
|
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
14116
14214
|
var getFile = async (details, distTag) => {
|
|
14117
14215
|
const rootDir = tmpdir2();
|
|
14118
|
-
const subDir =
|
|
14216
|
+
const subDir = join15(rootDir, "update-check");
|
|
14119
14217
|
if (!existsSync9(subDir)) {
|
|
14120
14218
|
await fs8.mkdir(subDir);
|
|
14121
14219
|
}
|
|
@@ -14123,7 +14221,7 @@ var getFile = async (details, distTag) => {
|
|
|
14123
14221
|
if (details.scope) {
|
|
14124
14222
|
name = `${details.scope}-${name}`;
|
|
14125
14223
|
}
|
|
14126
|
-
return
|
|
14224
|
+
return join15(subDir, name);
|
|
14127
14225
|
};
|
|
14128
14226
|
var evaluateCache = async (file, time, interval) => {
|
|
14129
14227
|
if (existsSync9(file)) {
|
|
@@ -14278,7 +14376,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
|
|
|
14278
14376
|
|
|
14279
14377
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
14280
14378
|
import { magenta, red as red8 } from "colorette";
|
|
14281
|
-
import { join as
|
|
14379
|
+
import { join as join16 } from "path";
|
|
14282
14380
|
var uniformStrictVersions = [
|
|
14283
14381
|
"@uniformdev/canvas",
|
|
14284
14382
|
"@uniformdev/canvas-next",
|
|
@@ -14300,7 +14398,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
14300
14398
|
try {
|
|
14301
14399
|
let isOutside = false;
|
|
14302
14400
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
14303
|
-
const localPackages = await tryReadJSON(
|
|
14401
|
+
const localPackages = await tryReadJSON(join16(process.cwd(), "package.json"));
|
|
14304
14402
|
if (!localPackages) return;
|
|
14305
14403
|
let firstVersion;
|
|
14306
14404
|
const allDependencies = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.77.1-alpha.10.sha-3381091ae6",
|
|
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.
|
|
31
|
-
"@uniformdev/automations-sdk": "20.
|
|
32
|
-
"@uniformdev/canvas": "20.
|
|
33
|
-
"@uniformdev/context": "20.
|
|
34
|
-
"@uniformdev/files": "20.
|
|
35
|
-
"@uniformdev/project-map": "20.
|
|
36
|
-
"@uniformdev/redirect": "20.
|
|
37
|
-
"@uniformdev/richtext": "20.
|
|
30
|
+
"@uniformdev/assets": "20.77.1-alpha.10.sha-3381091ae6",
|
|
31
|
+
"@uniformdev/automations-sdk": "20.77.1-alpha.10.sha-3381091ae6",
|
|
32
|
+
"@uniformdev/canvas": "20.77.1-alpha.10.sha-3381091ae6",
|
|
33
|
+
"@uniformdev/context": "20.77.1-alpha.10.sha-3381091ae6",
|
|
34
|
+
"@uniformdev/files": "20.77.1-alpha.10.sha-3381091ae6",
|
|
35
|
+
"@uniformdev/project-map": "20.77.1-alpha.10.sha-3381091ae6",
|
|
36
|
+
"@uniformdev/redirect": "20.77.1-alpha.10.sha-3381091ae6",
|
|
37
|
+
"@uniformdev/richtext": "20.77.1-alpha.10.sha-3381091ae6",
|
|
38
38
|
"call-bind": "^1.0.2",
|
|
39
39
|
"colorette": "2.0.20",
|
|
40
40
|
"cosmiconfig": "9.0.2",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "3381091ae65d8f50effdea93e6971c369203ecaf"
|
|
82
82
|
}
|