@uniformdev/cli 20.75.1-alpha.16 → 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.
- package/dist/index.mjs +136 -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 };
|
|
2778
|
+
return { id: fileId, url: fileUrl };
|
|
2756
2779
|
}
|
|
2757
|
-
const file = await
|
|
2758
|
-
if (
|
|
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
|
|
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
|
-
|
|
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) {
|
|
2989
3028
|
return null;
|
|
2990
3029
|
}
|
|
2991
|
-
const fileId =
|
|
2992
|
-
|
|
2993
|
-
if (fileId === "" || fileUrl === "") {
|
|
3030
|
+
const fileId = fields.file?.value;
|
|
3031
|
+
if (!fileId) {
|
|
2994
3032
|
return null;
|
|
2995
3033
|
}
|
|
2996
|
-
|
|
3034
|
+
const fileUrl = fields.url?.value;
|
|
3035
|
+
if (!fileUrl) {
|
|
3036
|
+
return null;
|
|
3037
|
+
}
|
|
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,59 @@ 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 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
|
+
};
|
|
3437
3530
|
var AssetPushModule = {
|
|
3438
3531
|
command: "push <directory>",
|
|
3439
3532
|
describe: "Pushes all assets from files in a directory to Uniform",
|
|
@@ -3519,27 +3612,12 @@ var AssetPushModule = {
|
|
|
3519
3612
|
return sourceObject;
|
|
3520
3613
|
},
|
|
3521
3614
|
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
|
-
}
|
|
3615
|
+
onBeforeWriteObject: (sourceObject) => prepareAssetForPush({
|
|
3616
|
+
sourceObject,
|
|
3617
|
+
directory,
|
|
3618
|
+
fileClient,
|
|
3619
|
+
targetProjectId: projectId
|
|
3620
|
+
})
|
|
3543
3621
|
});
|
|
3544
3622
|
}
|
|
3545
3623
|
};
|
|
@@ -12069,7 +12147,7 @@ var PolicyDocumentsPullModule = {
|
|
|
12069
12147
|
// src/commands/policy-documents/commands/push.ts
|
|
12070
12148
|
import { existsSync as existsSync8, mkdirSync as mkdirSync4 } from "fs";
|
|
12071
12149
|
import { readdir as readdir2 } from "fs/promises";
|
|
12072
|
-
import { extname as extname3, join as
|
|
12150
|
+
import { extname as extname3, join as join14 } from "path";
|
|
12073
12151
|
async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
12074
12152
|
const files = await readdir2(directory);
|
|
12075
12153
|
const policyDocuments = {};
|
|
@@ -12079,7 +12157,7 @@ async function readLocalPolicyDocuments(directory, format, verbose) {
|
|
|
12079
12157
|
if (ext !== `.${format}` && ext !== ".yaml" && ext !== ".yml" && ext !== ".json") {
|
|
12080
12158
|
continue;
|
|
12081
12159
|
}
|
|
12082
|
-
const filePath =
|
|
12160
|
+
const filePath = join14(directory, filename);
|
|
12083
12161
|
try {
|
|
12084
12162
|
let roleId = filename.replace(ext, "");
|
|
12085
12163
|
const fileContent = readFileToObject(filePath);
|
|
@@ -14087,14 +14165,14 @@ import { existsSync as existsSync9, promises as fs8 } from "fs";
|
|
|
14087
14165
|
import { get as getHttp } from "http";
|
|
14088
14166
|
import { get as getHttps } from "https";
|
|
14089
14167
|
import { tmpdir as tmpdir2 } from "os";
|
|
14090
|
-
import { join as
|
|
14168
|
+
import { join as join15 } from "path";
|
|
14091
14169
|
import registryUrl from "registry-url";
|
|
14092
14170
|
import { URL as URL2 } from "url";
|
|
14093
14171
|
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
14094
14172
|
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
14095
14173
|
var getFile = async (details, distTag) => {
|
|
14096
14174
|
const rootDir = tmpdir2();
|
|
14097
|
-
const subDir =
|
|
14175
|
+
const subDir = join15(rootDir, "update-check");
|
|
14098
14176
|
if (!existsSync9(subDir)) {
|
|
14099
14177
|
await fs8.mkdir(subDir);
|
|
14100
14178
|
}
|
|
@@ -14102,7 +14180,7 @@ var getFile = async (details, distTag) => {
|
|
|
14102
14180
|
if (details.scope) {
|
|
14103
14181
|
name = `${details.scope}-${name}`;
|
|
14104
14182
|
}
|
|
14105
|
-
return
|
|
14183
|
+
return join15(subDir, name);
|
|
14106
14184
|
};
|
|
14107
14185
|
var evaluateCache = async (file, time, interval) => {
|
|
14108
14186
|
if (existsSync9(file)) {
|
|
@@ -14257,7 +14335,7 @@ var checkForUpdateMiddleware = async ({ verbose }) => {
|
|
|
14257
14335
|
|
|
14258
14336
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
14259
14337
|
import { magenta, red as red8 } from "colorette";
|
|
14260
|
-
import { join as
|
|
14338
|
+
import { join as join16 } from "path";
|
|
14261
14339
|
var uniformStrictVersions = [
|
|
14262
14340
|
"@uniformdev/canvas",
|
|
14263
14341
|
"@uniformdev/canvas-next",
|
|
@@ -14279,7 +14357,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
14279
14357
|
try {
|
|
14280
14358
|
let isOutside = false;
|
|
14281
14359
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
14282
|
-
const localPackages = await tryReadJSON(
|
|
14360
|
+
const localPackages = await tryReadJSON(join16(process.cwd(), "package.json"));
|
|
14283
14361
|
if (!localPackages) return;
|
|
14284
14362
|
let firstVersion;
|
|
14285
14363
|
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.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.
|
|
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.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",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "28f494b01a1b988afdf9f7e3ecf6fad402bb3777"
|
|
82
82
|
}
|