@uniformdev/cli 20.75.1-alpha.16 → 20.75.1-alpha.7
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/index.mjs +146 -58
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -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 };
|
|
2756
|
-
}
|
|
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;
|
|
2778
|
+
return { id: fileId, url: fileUrl };
|
|
2761
2779
|
}
|
|
2762
|
-
|
|
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
|
|
2792
|
+
const preserveWarningOnlyFailure = !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
|
-
|
|
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
|
|
2821
|
+
return { id: file?.id ?? fileId, url: fileUrl };
|
|
2784
2822
|
};
|
|
2785
2823
|
|
|
2786
2824
|
// src/files/uploadFile.ts
|
|
@@ -2985,15 +3023,19 @@ var downloadFileForAsset = async ({
|
|
|
2985
3023
|
directory,
|
|
2986
3024
|
fileClient
|
|
2987
3025
|
}) => {
|
|
2988
|
-
|
|
3026
|
+
const fields = asset.asset.fields;
|
|
3027
|
+
if (!fields) {
|
|
3028
|
+
return null;
|
|
3029
|
+
}
|
|
3030
|
+
const fileId = fields.file?.value;
|
|
3031
|
+
if (!fileId) {
|
|
2989
3032
|
return null;
|
|
2990
3033
|
}
|
|
2991
|
-
const
|
|
2992
|
-
|
|
2993
|
-
if (fileId === "" || fileUrl === "") {
|
|
3034
|
+
const fileUrl = fields.url?.value;
|
|
3035
|
+
if (!fileUrl) {
|
|
2994
3036
|
return null;
|
|
2995
3037
|
}
|
|
2996
|
-
return downloadFile({ fileUrl, directory, fileClient });
|
|
3038
|
+
return downloadFile({ fileUrl, fileId, directory, fileClient });
|
|
2997
3039
|
};
|
|
2998
3040
|
var uploadFileForAsset = async ({
|
|
2999
3041
|
asset,
|
|
@@ -3307,6 +3349,25 @@ function writeCanvasPackage(filename, packageContents) {
|
|
|
3307
3349
|
|
|
3308
3350
|
// src/commands/canvas/commands/asset/pull.ts
|
|
3309
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
|
+
};
|
|
3310
3371
|
var AssetPullModule = {
|
|
3311
3372
|
command: "pull <directory>",
|
|
3312
3373
|
describe: "Pulls all assets to local files in a directory",
|
|
@@ -3413,27 +3474,69 @@ var AssetPullModule = {
|
|
|
3413
3474
|
return sourceObject;
|
|
3414
3475
|
},
|
|
3415
3476
|
compareContents: compareAssetsWithoutUrls,
|
|
3416
|
-
onBeforeWriteObject:
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
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
|
-
}
|
|
3477
|
+
onBeforeWriteObject: (sourceObject) => prepareAssetForPull({
|
|
3478
|
+
sourceObject,
|
|
3479
|
+
directory,
|
|
3480
|
+
fileClient
|
|
3481
|
+
})
|
|
3431
3482
|
});
|
|
3432
3483
|
}
|
|
3433
3484
|
};
|
|
3434
3485
|
|
|
3435
3486
|
// src/commands/canvas/commands/asset/push.ts
|
|
3487
|
+
import { join as join13 } from "path";
|
|
3436
3488
|
var ASSET_PUSH_ACTION_CONCURRENCY = 10;
|
|
3489
|
+
var getExpectedFilePath = (directory, fileUrl) => {
|
|
3490
|
+
if (!fileUrl) {
|
|
3491
|
+
return "Unavailable because the asset has no file URL";
|
|
3492
|
+
}
|
|
3493
|
+
try {
|
|
3494
|
+
return join13(getFilesDirectory(directory), FILES_DIRECTORY_NAME, urlToFileName(fileUrl));
|
|
3495
|
+
} catch {
|
|
3496
|
+
return "Unavailable because the asset file URL is invalid";
|
|
3497
|
+
}
|
|
3498
|
+
};
|
|
3499
|
+
var prepareAssetForPush = async ({
|
|
3500
|
+
sourceObject,
|
|
3501
|
+
directory,
|
|
3502
|
+
fileClient,
|
|
3503
|
+
targetProjectId
|
|
3504
|
+
}) => {
|
|
3505
|
+
const fields = sourceObject.object.asset.fields;
|
|
3506
|
+
const fileId = fields?.file?.value;
|
|
3507
|
+
if (!fields || !fileId) {
|
|
3508
|
+
return sourceObject;
|
|
3509
|
+
}
|
|
3510
|
+
const uploadedFile = await uploadFileForAsset({
|
|
3511
|
+
asset: sourceObject.object,
|
|
3512
|
+
directory,
|
|
3513
|
+
fileClient
|
|
3514
|
+
});
|
|
3515
|
+
if (!uploadedFile) {
|
|
3516
|
+
const fileUrl = fields.url?.value;
|
|
3517
|
+
const expectedFilePath = getExpectedFilePath(directory, fileUrl);
|
|
3518
|
+
throw new Error(
|
|
3519
|
+
[
|
|
3520
|
+
`Unable to push asset "${sourceObject.displayName ?? sourceObject.providerId}" (${sourceObject.providerId}) because its file could not be uploaded.`,
|
|
3521
|
+
`Source project ID: ${sourceObject.object.projectId}`,
|
|
3522
|
+
`Target project ID: ${targetProjectId}`,
|
|
3523
|
+
`File ID: ${fileId}`,
|
|
3524
|
+
`File URL: ${fileUrl ?? "Missing"}`,
|
|
3525
|
+
`Expected local path: ${expectedFilePath}`,
|
|
3526
|
+
`Remove the asset with the ID ${sourceObject.providerId} before pushing again.`
|
|
3527
|
+
].join("\n")
|
|
3528
|
+
);
|
|
3529
|
+
}
|
|
3530
|
+
fields.file = {
|
|
3531
|
+
type: "file",
|
|
3532
|
+
value: uploadedFile.id
|
|
3533
|
+
};
|
|
3534
|
+
fields.url = {
|
|
3535
|
+
type: "text",
|
|
3536
|
+
value: uploadedFile.url
|
|
3537
|
+
};
|
|
3538
|
+
return sourceObject;
|
|
3539
|
+
};
|
|
3437
3540
|
var AssetPushModule = {
|
|
3438
3541
|
command: "push <directory>",
|
|
3439
3542
|
describe: "Pushes all assets from files in a directory to Uniform",
|
|
@@ -3519,27 +3622,12 @@ var AssetPushModule = {
|
|
|
3519
3622
|
return sourceObject;
|
|
3520
3623
|
},
|
|
3521
3624
|
compareContents: compareAssetsWithoutUrls,
|
|
3522
|
-
onBeforeWriteObject:
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
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
|
-
}
|
|
3625
|
+
onBeforeWriteObject: (sourceObject) => prepareAssetForPush({
|
|
3626
|
+
sourceObject,
|
|
3627
|
+
directory,
|
|
3628
|
+
fileClient,
|
|
3629
|
+
targetProjectId: projectId
|
|
3630
|
+
})
|
|
3543
3631
|
});
|
|
3544
3632
|
}
|
|
3545
3633
|
};
|
|
@@ -12069,7 +12157,7 @@ var PolicyDocumentsPullModule = {
|
|
|
12069
12157
|
// src/commands/policy-documents/commands/push.ts
|
|
12070
12158
|
import { existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
|
|
12071
12159
|
import { readdir as readdir2 } from "fs/promises";
|
|
12072
|
-
import { extname as extname3, join as
|
|
12160
|
+
import { extname as extname3, join as join14 } from "path";
|
|
12073
12161
|
async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
12074
12162
|
const files = await readdir2(directory);
|
|
12075
12163
|
const policyDocuments = {};
|
|
@@ -12079,7 +12167,7 @@ async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
|
12079
12167
|
if (ext !== `.${format}` && ext !== ".yaml" && ext !== ".yml" && ext !== ".json") {
|
|
12080
12168
|
continue;
|
|
12081
12169
|
}
|
|
12082
|
-
const filePath =
|
|
12170
|
+
const filePath = join14(directory, filename);
|
|
12083
12171
|
try {
|
|
12084
12172
|
let roleId = filename.replace(ext, "");
|
|
12085
12173
|
const fileContent = readFileToObject(filePath);
|
|
@@ -14087,14 +14175,14 @@ import { existsSync as existsSync9, promises as fs8 } from "fs";
|
|
|
14087
14175
|
import { get as getHttp } from "http";
|
|
14088
14176
|
import { get as getHttps } from "https";
|
|
14089
14177
|
import { tmpdir as tmpdir2 } from "os";
|
|
14090
|
-
import { join as
|
|
14178
|
+
import { join as join15 } from "path";
|
|
14091
14179
|
import registryUrl from "registry-url";
|
|
14092
14180
|
import { URL as URL2 } from "url";
|
|
14093
14181
|
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
14094
14182
|
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
14095
14183
|
var getFile = async (details, distTag) => {
|
|
14096
14184
|
const rootDir = tmpdir2();
|
|
14097
|
-
const subDir =
|
|
14185
|
+
const subDir = join15(rootDir, "update-check");
|
|
14098
14186
|
if (!existsSync9(subDir)) {
|
|
14099
14187
|
await fs8.mkdir(subDir);
|
|
14100
14188
|
}
|
|
@@ -14102,7 +14190,7 @@ var getFile = async (details, distTag) => {
|
|
|
14102
14190
|
if (details.scope) {
|
|
14103
14191
|
name = `${details.scope}-${name}`;
|
|
14104
14192
|
}
|
|
14105
|
-
return
|
|
14193
|
+
return join15(subDir, name);
|
|
14106
14194
|
};
|
|
14107
14195
|
var evaluateCache = async (file, time, interval) => {
|
|
14108
14196
|
if (existsSync9(file)) {
|
|
@@ -14257,7 +14345,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
|
|
|
14257
14345
|
|
|
14258
14346
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
14259
14347
|
import { magenta, red as red8 } from "colorette";
|
|
14260
|
-
import { join as
|
|
14348
|
+
import { join as join16 } from "path";
|
|
14261
14349
|
var uniformStrictVersions = [
|
|
14262
14350
|
"@uniformdev/canvas",
|
|
14263
14351
|
"@uniformdev/canvas-next",
|
|
@@ -14279,7 +14367,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
14279
14367
|
try {
|
|
14280
14368
|
let isOutside = false;
|
|
14281
14369
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
14282
|
-
const localPackages = await tryReadJSON(
|
|
14370
|
+
const localPackages = await tryReadJSON(join16(process.cwd(), "package.json"));
|
|
14283
14371
|
if (!localPackages) return;
|
|
14284
14372
|
let firstVersion;
|
|
14285
14373
|
const allDependencies = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "20.75.1-alpha.
|
|
3
|
+
"version": "20.75.1-alpha.7+ad3780cc13",
|
|
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.
|
|
31
|
-
"@uniformdev/automations-sdk": "20.75.1-alpha.
|
|
32
|
-
"@uniformdev/canvas": "20.75.1-alpha.
|
|
33
|
-
"@uniformdev/context": "20.75.1-alpha.
|
|
34
|
-
"@uniformdev/files": "20.75.1-alpha.
|
|
35
|
-
"@uniformdev/project-map": "20.75.1-alpha.
|
|
36
|
-
"@uniformdev/redirect": "20.75.1-alpha.
|
|
37
|
-
"@uniformdev/richtext": "20.75.1-alpha.
|
|
30
|
+
"@uniformdev/assets": "20.75.1-alpha.7+ad3780cc13",
|
|
31
|
+
"@uniformdev/automations-sdk": "20.75.1-alpha.7+ad3780cc13",
|
|
32
|
+
"@uniformdev/canvas": "20.75.1-alpha.7+ad3780cc13",
|
|
33
|
+
"@uniformdev/context": "20.75.1-alpha.7+ad3780cc13",
|
|
34
|
+
"@uniformdev/files": "20.75.1-alpha.7+ad3780cc13",
|
|
35
|
+
"@uniformdev/project-map": "20.75.1-alpha.7+ad3780cc13",
|
|
36
|
+
"@uniformdev/redirect": "20.75.1-alpha.7+ad3780cc13",
|
|
37
|
+
"@uniformdev/richtext": "20.75.1-alpha.7+ad3780cc13",
|
|
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": "ad3780cc13fc3e5f328db96ccd428109e09248ae"
|
|
82
82
|
}
|