@uniformdev/cli 19.42.1-alpha.6 → 19.45.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.
- package/dist/index.mjs +12 -167
- package/package.json +8 -12
package/dist/index.mjs
CHANGED
|
@@ -411,8 +411,7 @@ async function syncEngine({
|
|
|
411
411
|
whatIf = false,
|
|
412
412
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
413
413
|
log = () => {
|
|
414
|
-
}
|
|
415
|
-
onBeforeWriteObject
|
|
414
|
+
}
|
|
416
415
|
}) {
|
|
417
416
|
var _a, _b;
|
|
418
417
|
const targetItems = /* @__PURE__ */ new Map();
|
|
@@ -457,8 +456,7 @@ async function syncEngine({
|
|
|
457
456
|
const process2 = async (sourceObject2, targetObject2) => {
|
|
458
457
|
if (!whatIf) {
|
|
459
458
|
try {
|
|
460
|
-
|
|
461
|
-
await target.writeObject(finalSourceObject, targetObject2);
|
|
459
|
+
await target.writeObject(sourceObject2, targetObject2);
|
|
462
460
|
} catch (e) {
|
|
463
461
|
throw new SyncEngineError(e, sourceObject2);
|
|
464
462
|
}
|
|
@@ -480,8 +478,7 @@ async function syncEngine({
|
|
|
480
478
|
const process2 = async (sourceObject2, id) => {
|
|
481
479
|
if (!whatIf) {
|
|
482
480
|
try {
|
|
483
|
-
|
|
484
|
-
await target.writeObject(finalSourceObject);
|
|
481
|
+
await target.writeObject(sourceObject2);
|
|
485
482
|
} catch (e) {
|
|
486
483
|
throw new SyncEngineError(e, sourceObject2);
|
|
487
484
|
}
|
|
@@ -1459,141 +1456,6 @@ var CompositionPublishModule = {
|
|
|
1459
1456
|
|
|
1460
1457
|
// src/commands/canvas/commands/composition/pull.ts
|
|
1461
1458
|
import { UncachedCanvasClient as UncachedCanvasClient10 } from "@uniformdev/canvas";
|
|
1462
|
-
|
|
1463
|
-
// src/files/index.ts
|
|
1464
|
-
import { preferredType } from "@thi.ng/mime";
|
|
1465
|
-
import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files-sdk";
|
|
1466
|
-
import { createHash } from "crypto";
|
|
1467
|
-
import fsj from "fs-jetpack";
|
|
1468
|
-
import sizeOf from "image-size";
|
|
1469
|
-
import PQueue from "p-queue";
|
|
1470
|
-
import { join as join2 } from "path";
|
|
1471
|
-
var FILES_DIRECTORY_NAME = "files";
|
|
1472
|
-
var urlToFileName = (url) => {
|
|
1473
|
-
const hash = createHash("sha256");
|
|
1474
|
-
hash.update(url);
|
|
1475
|
-
const fileName = hash.digest("hex");
|
|
1476
|
-
const fileExtension = url.split(".").pop();
|
|
1477
|
-
return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
|
|
1478
|
-
};
|
|
1479
|
-
var extractAndDownloadUniformFilesForObject = async (object, options) => {
|
|
1480
|
-
const objectAsString = JSON.stringify(object);
|
|
1481
|
-
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1482
|
-
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1483
|
-
);
|
|
1484
|
-
if (uniformFileUrlMatches) {
|
|
1485
|
-
const fileDownloadQueue = new PQueue({ concurrency: 10 });
|
|
1486
|
-
for (const match of uniformFileUrlMatches) {
|
|
1487
|
-
const url = match[1];
|
|
1488
|
-
fileDownloadQueue.add(async () => {
|
|
1489
|
-
try {
|
|
1490
|
-
const fileName = urlToFileName(url);
|
|
1491
|
-
const fileAlreadyExists = await fsj.existsAsync(
|
|
1492
|
-
join2(options.directory, FILES_DIRECTORY_NAME, fileName)
|
|
1493
|
-
);
|
|
1494
|
-
if (fileAlreadyExists) {
|
|
1495
|
-
return;
|
|
1496
|
-
}
|
|
1497
|
-
const response = await fetch(url);
|
|
1498
|
-
if (!response.ok) {
|
|
1499
|
-
return;
|
|
1500
|
-
}
|
|
1501
|
-
const fileBuffer = await response.arrayBuffer();
|
|
1502
|
-
await fsj.writeAsync(
|
|
1503
|
-
join2(options.directory, FILES_DIRECTORY_NAME, fileName),
|
|
1504
|
-
Buffer.from(fileBuffer)
|
|
1505
|
-
);
|
|
1506
|
-
} catch {
|
|
1507
|
-
console.warn(`Failed to download file ${url}`);
|
|
1508
|
-
}
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
await fileDownloadQueue.onIdle();
|
|
1512
|
-
}
|
|
1513
|
-
return object;
|
|
1514
|
-
};
|
|
1515
|
-
var extractAndUploadUniformFilesForObject = async (object, options) => {
|
|
1516
|
-
let objectAsString = JSON.stringify(object);
|
|
1517
|
-
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1518
|
-
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1519
|
-
);
|
|
1520
|
-
if (uniformFileUrlMatches) {
|
|
1521
|
-
const fileUploadQueue = new PQueue({ concurrency: 5 });
|
|
1522
|
-
for (const match of uniformFileUrlMatches) {
|
|
1523
|
-
const url = match[1];
|
|
1524
|
-
fileUploadQueue.add(async () => {
|
|
1525
|
-
try {
|
|
1526
|
-
const fileAlreadyExists = await options.fileClient.getFile({ url }).catch(() => null);
|
|
1527
|
-
if (fileAlreadyExists) {
|
|
1528
|
-
return;
|
|
1529
|
-
}
|
|
1530
|
-
const localFileName = urlToFileName(url);
|
|
1531
|
-
const fileExistsLocally = await fsj.existsAsync(
|
|
1532
|
-
join2(options.directory, FILES_DIRECTORY_NAME, localFileName)
|
|
1533
|
-
);
|
|
1534
|
-
if (!fileExistsLocally) {
|
|
1535
|
-
console.warn(`Skipping file ${url} as we couldn't find a local copy`);
|
|
1536
|
-
return;
|
|
1537
|
-
}
|
|
1538
|
-
const fileBuffer = await fsj.readAsync(
|
|
1539
|
-
join2(options.directory, FILES_DIRECTORY_NAME, localFileName),
|
|
1540
|
-
"buffer"
|
|
1541
|
-
);
|
|
1542
|
-
if (!fileBuffer) {
|
|
1543
|
-
console.warn(`Skipping file ${url} as we couldn't read it`);
|
|
1544
|
-
return;
|
|
1545
|
-
}
|
|
1546
|
-
const fileName = getFileNameFromUrl(url);
|
|
1547
|
-
const { width, height } = (() => {
|
|
1548
|
-
try {
|
|
1549
|
-
return sizeOf(fileBuffer);
|
|
1550
|
-
} catch {
|
|
1551
|
-
return {
|
|
1552
|
-
width: void 0,
|
|
1553
|
-
height: void 0
|
|
1554
|
-
};
|
|
1555
|
-
}
|
|
1556
|
-
})();
|
|
1557
|
-
const { id, method, uploadUrl } = await options.fileClient.createNewProjectFile({
|
|
1558
|
-
name: fileName,
|
|
1559
|
-
mediaType: preferredType(url.split(".").at(-1) ?? ""),
|
|
1560
|
-
size: fileBuffer.length,
|
|
1561
|
-
width,
|
|
1562
|
-
height
|
|
1563
|
-
});
|
|
1564
|
-
const uploadResponse = await fetch(uploadUrl, {
|
|
1565
|
-
method,
|
|
1566
|
-
body: fileBuffer
|
|
1567
|
-
});
|
|
1568
|
-
if (!uploadResponse.ok) {
|
|
1569
|
-
console.warn(`Failed to upload file ${url}`);
|
|
1570
|
-
return;
|
|
1571
|
-
}
|
|
1572
|
-
const checkForFile = async () => {
|
|
1573
|
-
const file = await options.fileClient.getFile({ id });
|
|
1574
|
-
if (!file || file.state !== FILE_READY_STATE) {
|
|
1575
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1576
|
-
return checkForFile();
|
|
1577
|
-
}
|
|
1578
|
-
return file.url;
|
|
1579
|
-
};
|
|
1580
|
-
const abortTimeout = setTimeout(() => {
|
|
1581
|
-
throw new Error(`Failed to upload file ${url}`);
|
|
1582
|
-
}, 1e4);
|
|
1583
|
-
const uploadedFileUrl = await checkForFile();
|
|
1584
|
-
clearTimeout(abortTimeout);
|
|
1585
|
-
objectAsString = objectAsString.replaceAll(`"${url}"`, `"${uploadedFileUrl}"`);
|
|
1586
|
-
} catch {
|
|
1587
|
-
console.warn(`Failed to upload file ${url}`);
|
|
1588
|
-
}
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
await fileUploadQueue.onIdle();
|
|
1592
|
-
}
|
|
1593
|
-
return JSON.parse(objectAsString);
|
|
1594
|
-
};
|
|
1595
|
-
|
|
1596
|
-
// src/commands/canvas/commands/composition/pull.ts
|
|
1597
1459
|
var CompositionPullModule = {
|
|
1598
1460
|
command: "pull <directory>",
|
|
1599
1461
|
describe: "Pulls all compositions to local files in a directory",
|
|
@@ -1680,19 +1542,13 @@ var CompositionPullModule = {
|
|
|
1680
1542
|
target,
|
|
1681
1543
|
mode,
|
|
1682
1544
|
whatIf,
|
|
1683
|
-
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1684
|
-
onBeforeWriteObject: async (sourceObject) => {
|
|
1685
|
-
return extractAndDownloadUniformFilesForObject(sourceObject, {
|
|
1686
|
-
directory
|
|
1687
|
-
});
|
|
1688
|
-
}
|
|
1545
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1689
1546
|
});
|
|
1690
1547
|
}
|
|
1691
1548
|
};
|
|
1692
1549
|
|
|
1693
1550
|
// src/commands/canvas/commands/composition/push.ts
|
|
1694
1551
|
import { UncachedCanvasClient as UncachedCanvasClient11 } from "@uniformdev/canvas";
|
|
1695
|
-
import { FileClient as FileClient2 } from "@uniformdev/files-sdk";
|
|
1696
1552
|
var CompositionPushModule = {
|
|
1697
1553
|
command: "push <directory>",
|
|
1698
1554
|
describe: "Pushes all compositions from files in a directory to Uniform Canvas",
|
|
@@ -1762,19 +1618,12 @@ var CompositionPushModule = {
|
|
|
1762
1618
|
});
|
|
1763
1619
|
}
|
|
1764
1620
|
const target = createComponentInstanceEngineDataSource({ client, state, onlyCompositions, onlyPatterns });
|
|
1765
|
-
const fileClient = new FileClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
1766
1621
|
await syncEngine({
|
|
1767
1622
|
source,
|
|
1768
1623
|
target,
|
|
1769
1624
|
mode,
|
|
1770
1625
|
whatIf,
|
|
1771
|
-
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1772
|
-
onBeforeWriteObject: async (sourceObject) => {
|
|
1773
|
-
return extractAndUploadUniformFilesForObject(sourceObject, {
|
|
1774
|
-
directory,
|
|
1775
|
-
fileClient
|
|
1776
|
-
});
|
|
1777
|
-
}
|
|
1626
|
+
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1778
1627
|
});
|
|
1779
1628
|
}
|
|
1780
1629
|
};
|
|
@@ -3926,7 +3775,7 @@ import { PostHog } from "posthog-node";
|
|
|
3926
3775
|
// package.json
|
|
3927
3776
|
var package_default = {
|
|
3928
3777
|
name: "@uniformdev/cli",
|
|
3929
|
-
version: "19.
|
|
3778
|
+
version: "19.45.0",
|
|
3930
3779
|
description: "Uniform command line interface tool",
|
|
3931
3780
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
3932
3781
|
main: "./cli.js",
|
|
@@ -3942,10 +3791,8 @@ var package_default = {
|
|
|
3942
3791
|
format: 'prettier --write "src/**/*.{js,ts,tsx}"'
|
|
3943
3792
|
},
|
|
3944
3793
|
dependencies: {
|
|
3945
|
-
"@thi.ng/mime": "^2.2.23",
|
|
3946
3794
|
"@uniformdev/canvas": "workspace:*",
|
|
3947
3795
|
"@uniformdev/context": "workspace:*",
|
|
3948
|
-
"@uniformdev/files-sdk": "workspace:*",
|
|
3949
3796
|
"@uniformdev/project-map": "workspace:*",
|
|
3950
3797
|
"@uniformdev/redirect": "workspace:*",
|
|
3951
3798
|
colorette: "2.0.20",
|
|
@@ -3958,8 +3805,7 @@ var package_default = {
|
|
|
3958
3805
|
graphql: "16.7.1",
|
|
3959
3806
|
"graphql-request": "6.1.0",
|
|
3960
3807
|
"https-proxy-agent": "^7.0.0",
|
|
3961
|
-
|
|
3962
|
-
inquirer: "9.2.9",
|
|
3808
|
+
inquirer: "9.2.10",
|
|
3963
3809
|
"isomorphic-git": "1.24.5",
|
|
3964
3810
|
"isomorphic-unfetch": "^3.1.0",
|
|
3965
3811
|
"js-yaml": "^4.1.0",
|
|
@@ -3967,7 +3813,6 @@ var package_default = {
|
|
|
3967
3813
|
"lodash.isequalwith": "^4.4.0",
|
|
3968
3814
|
open: "9.1.0",
|
|
3969
3815
|
ora: "6.3.1",
|
|
3970
|
-
"p-queue": "7.3.4",
|
|
3971
3816
|
"posthog-node": "3.1.1",
|
|
3972
3817
|
slugify: "1.6.6",
|
|
3973
3818
|
"update-check": "^1.5.4",
|
|
@@ -3980,7 +3825,7 @@ var package_default = {
|
|
|
3980
3825
|
"@types/js-yaml": "4.0.5",
|
|
3981
3826
|
"@types/jsonwebtoken": "9.0.2",
|
|
3982
3827
|
"@types/lodash.isequalwith": "4.4.7",
|
|
3983
|
-
"@types/node": "18.17.
|
|
3828
|
+
"@types/node": "18.17.5",
|
|
3984
3829
|
"@types/yargs": "17.0.24"
|
|
3985
3830
|
},
|
|
3986
3831
|
bin: {
|
|
@@ -4305,7 +4150,7 @@ ${err.message}`);
|
|
|
4305
4150
|
// src/projects/cloneStarter.ts
|
|
4306
4151
|
import crypto2 from "crypto";
|
|
4307
4152
|
import fs3 from "fs";
|
|
4308
|
-
import
|
|
4153
|
+
import fsj from "fs-jetpack";
|
|
4309
4154
|
import * as git from "isomorphic-git";
|
|
4310
4155
|
import * as http from "isomorphic-git/http/node/index.js";
|
|
4311
4156
|
import os from "os";
|
|
@@ -4336,7 +4181,7 @@ async function cloneStarter({
|
|
|
4336
4181
|
throw new Error(`"${targetDir}" is not empty`);
|
|
4337
4182
|
}
|
|
4338
4183
|
const starterDir = path.join(cloneDir, ...pathSegments);
|
|
4339
|
-
|
|
4184
|
+
fsj.copy(starterDir, targetDir, { overwrite: true });
|
|
4340
4185
|
if (dotEnvFile) {
|
|
4341
4186
|
fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
|
|
4342
4187
|
}
|
|
@@ -6240,7 +6085,7 @@ async function checkForUpdateMiddleware() {
|
|
|
6240
6085
|
|
|
6241
6086
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
6242
6087
|
import { magenta, red as red6 } from "colorette";
|
|
6243
|
-
import { join as
|
|
6088
|
+
import { join as join2 } from "path";
|
|
6244
6089
|
|
|
6245
6090
|
// src/fs.ts
|
|
6246
6091
|
import { promises as fs5 } from "fs";
|
|
@@ -6279,7 +6124,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
6279
6124
|
try {
|
|
6280
6125
|
let isOutside = false;
|
|
6281
6126
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
6282
|
-
const localPackages = await tryReadJSON(
|
|
6127
|
+
const localPackages = await tryReadJSON(join2(process.cwd(), "package.json"));
|
|
6283
6128
|
if (!localPackages)
|
|
6284
6129
|
return;
|
|
6285
6130
|
let firstVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.45.0",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@uniformdev/
|
|
21
|
-
"@uniformdev/
|
|
22
|
-
"@uniformdev/
|
|
23
|
-
"@uniformdev/project-map": "19.42.1-alpha.6+8511a0877",
|
|
24
|
-
"@uniformdev/redirect": "19.42.1-alpha.6+8511a0877",
|
|
19
|
+
"@uniformdev/canvas": "19.45.0",
|
|
20
|
+
"@uniformdev/context": "19.45.0",
|
|
21
|
+
"@uniformdev/project-map": "19.45.0",
|
|
22
|
+
"@uniformdev/redirect": "19.45.0",
|
|
25
23
|
"colorette": "2.0.20",
|
|
26
24
|
"cosmiconfig": "8.2.0",
|
|
27
25
|
"cosmiconfig-typescript-loader": "5.0.0",
|
|
@@ -32,8 +30,7 @@
|
|
|
32
30
|
"graphql": "16.7.1",
|
|
33
31
|
"graphql-request": "6.1.0",
|
|
34
32
|
"https-proxy-agent": "^7.0.0",
|
|
35
|
-
"
|
|
36
|
-
"inquirer": "9.2.9",
|
|
33
|
+
"inquirer": "9.2.10",
|
|
37
34
|
"isomorphic-git": "1.24.5",
|
|
38
35
|
"isomorphic-unfetch": "^3.1.0",
|
|
39
36
|
"js-yaml": "^4.1.0",
|
|
@@ -41,7 +38,6 @@
|
|
|
41
38
|
"lodash.isequalwith": "^4.4.0",
|
|
42
39
|
"open": "9.1.0",
|
|
43
40
|
"ora": "6.3.1",
|
|
44
|
-
"p-queue": "7.3.4",
|
|
45
41
|
"posthog-node": "3.1.1",
|
|
46
42
|
"slugify": "1.6.6",
|
|
47
43
|
"update-check": "^1.5.4",
|
|
@@ -54,7 +50,7 @@
|
|
|
54
50
|
"@types/js-yaml": "4.0.5",
|
|
55
51
|
"@types/jsonwebtoken": "9.0.2",
|
|
56
52
|
"@types/lodash.isequalwith": "4.4.7",
|
|
57
|
-
"@types/node": "18.17.
|
|
53
|
+
"@types/node": "18.17.5",
|
|
58
54
|
"@types/yargs": "17.0.24"
|
|
59
55
|
},
|
|
60
56
|
"bin": {
|
|
@@ -66,5 +62,5 @@
|
|
|
66
62
|
"publishConfig": {
|
|
67
63
|
"access": "public"
|
|
68
64
|
},
|
|
69
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "ff90cd6bd6d9db14f0d3a2ba8bd4db538b66548c"
|
|
70
66
|
}
|