@uniformdev/cli 19.45.0 → 19.45.1
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 +397 -27
- package/package.json +10 -6
package/dist/index.mjs
CHANGED
|
@@ -411,7 +411,9 @@ async function syncEngine({
|
|
|
411
411
|
whatIf = false,
|
|
412
412
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
413
413
|
log = () => {
|
|
414
|
-
}
|
|
414
|
+
},
|
|
415
|
+
onBeforeCompareObjects,
|
|
416
|
+
onBeforeWriteObject
|
|
415
417
|
}) {
|
|
416
418
|
var _a, _b;
|
|
417
419
|
const targetItems = /* @__PURE__ */ new Map();
|
|
@@ -445,18 +447,20 @@ async function syncEngine({
|
|
|
445
447
|
}
|
|
446
448
|
const actions = [];
|
|
447
449
|
let sourceHasItems = false;
|
|
448
|
-
for await (
|
|
450
|
+
for await (let sourceObject of source.objects) {
|
|
449
451
|
sourceHasItems = true;
|
|
450
452
|
const ids = Array.isArray(sourceObject.id) ? sourceObject.id : [sourceObject.id];
|
|
451
453
|
const targetObject = targetItems.get(ids[0]);
|
|
452
454
|
const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) => (o == null ? void 0 : o.object) !== (targetObject == null ? void 0 : targetObject.object));
|
|
453
455
|
if (targetObject && invalidTargetObjects.length == 0) {
|
|
456
|
+
sourceObject = onBeforeCompareObjects ? await onBeforeCompareObjects(sourceObject, targetObject) : sourceObject;
|
|
454
457
|
if (!compareContents(sourceObject, targetObject)) {
|
|
455
458
|
if (mode === "createOrUpdate" || mode === "mirror") {
|
|
456
459
|
const process2 = async (sourceObject2, targetObject2) => {
|
|
457
460
|
if (!whatIf) {
|
|
458
461
|
try {
|
|
459
|
-
await
|
|
462
|
+
const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2, targetObject2) : sourceObject2;
|
|
463
|
+
await target.writeObject(finalSourceObject, targetObject2);
|
|
460
464
|
} catch (e) {
|
|
461
465
|
throw new SyncEngineError(e, sourceObject2);
|
|
462
466
|
}
|
|
@@ -478,7 +482,8 @@ async function syncEngine({
|
|
|
478
482
|
const process2 = async (sourceObject2, id) => {
|
|
479
483
|
if (!whatIf) {
|
|
480
484
|
try {
|
|
481
|
-
await
|
|
485
|
+
const finalSourceObject = onBeforeWriteObject ? await onBeforeWriteObject(sourceObject2) : sourceObject2;
|
|
486
|
+
await target.writeObject(finalSourceObject);
|
|
482
487
|
} catch (e) {
|
|
483
488
|
throw new SyncEngineError(e, sourceObject2);
|
|
484
489
|
}
|
|
@@ -1403,13 +1408,13 @@ function createComponentInstanceEngineDataSource({
|
|
|
1403
1408
|
// src/commands/canvas/commands/composition/publish.ts
|
|
1404
1409
|
var CompositionPublishModule = {
|
|
1405
1410
|
command: "publish [ids]",
|
|
1406
|
-
describe: "Publishes
|
|
1411
|
+
describe: "Publishes composition(s)",
|
|
1407
1412
|
builder: (yargs23) => withConfiguration(
|
|
1408
1413
|
withApiOptions(
|
|
1409
1414
|
withProjectOptions(
|
|
1410
1415
|
withDiffOptions(
|
|
1411
1416
|
yargs23.positional("ids", {
|
|
1412
|
-
describe: "Publishes composition
|
|
1417
|
+
describe: "Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
|
|
1413
1418
|
type: "string"
|
|
1414
1419
|
}).option("all", {
|
|
1415
1420
|
alias: ["a"],
|
|
@@ -1421,12 +1426,32 @@ var CompositionPublishModule = {
|
|
|
1421
1426
|
describe: "What-if mode reports what would be done but does not perform any publishing",
|
|
1422
1427
|
default: false,
|
|
1423
1428
|
type: "boolean"
|
|
1429
|
+
}).option("onlyCompositions", {
|
|
1430
|
+
describe: "Only publishing compositions and not patterns",
|
|
1431
|
+
default: false,
|
|
1432
|
+
type: "boolean"
|
|
1433
|
+
}).option("onlyPatterns", {
|
|
1434
|
+
describe: "Only pulling patterns and not compositions",
|
|
1435
|
+
default: false,
|
|
1436
|
+
type: "boolean",
|
|
1437
|
+
hidden: true
|
|
1424
1438
|
})
|
|
1425
1439
|
)
|
|
1426
1440
|
)
|
|
1427
1441
|
)
|
|
1428
1442
|
),
|
|
1429
|
-
handler: async ({
|
|
1443
|
+
handler: async ({
|
|
1444
|
+
apiHost,
|
|
1445
|
+
apiKey,
|
|
1446
|
+
proxy,
|
|
1447
|
+
ids,
|
|
1448
|
+
all,
|
|
1449
|
+
whatIf,
|
|
1450
|
+
project: projectId,
|
|
1451
|
+
diff: diffMode,
|
|
1452
|
+
onlyCompositions,
|
|
1453
|
+
onlyPatterns
|
|
1454
|
+
}) => {
|
|
1430
1455
|
if (!all && !ids || all && ids) {
|
|
1431
1456
|
console.error(`Specify --all or composition ID(s) to publish.`);
|
|
1432
1457
|
process.exit(1);
|
|
@@ -1437,17 +1462,22 @@ var CompositionPublishModule = {
|
|
|
1437
1462
|
const source = createComponentInstanceEngineDataSource({
|
|
1438
1463
|
client,
|
|
1439
1464
|
state: "preview",
|
|
1440
|
-
compositionIDs: compositionIDsArray
|
|
1465
|
+
compositionIDs: compositionIDsArray,
|
|
1466
|
+
onlyCompositions,
|
|
1467
|
+
onlyPatterns
|
|
1441
1468
|
});
|
|
1442
1469
|
const target = createComponentInstanceEngineDataSource({
|
|
1443
1470
|
client,
|
|
1444
1471
|
state: "published",
|
|
1445
|
-
compositionIDs: compositionIDsArray
|
|
1472
|
+
compositionIDs: compositionIDsArray,
|
|
1473
|
+
onlyCompositions,
|
|
1474
|
+
onlyPatterns
|
|
1446
1475
|
});
|
|
1447
1476
|
await syncEngine({
|
|
1448
1477
|
source,
|
|
1449
1478
|
target,
|
|
1450
|
-
|
|
1479
|
+
// Publishing is one-direction operation, so no need to support automatic un-publishing
|
|
1480
|
+
mode: "createOrUpdate",
|
|
1451
1481
|
whatIf,
|
|
1452
1482
|
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1453
1483
|
});
|
|
@@ -1456,6 +1486,180 @@ var CompositionPublishModule = {
|
|
|
1456
1486
|
|
|
1457
1487
|
// src/commands/canvas/commands/composition/pull.ts
|
|
1458
1488
|
import { UncachedCanvasClient as UncachedCanvasClient10 } from "@uniformdev/canvas";
|
|
1489
|
+
|
|
1490
|
+
// src/files/index.ts
|
|
1491
|
+
import { preferredType } from "@thi.ng/mime";
|
|
1492
|
+
import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files-sdk";
|
|
1493
|
+
import { createHash } from "crypto";
|
|
1494
|
+
import fsj from "fs-jetpack";
|
|
1495
|
+
import sizeOf from "image-size";
|
|
1496
|
+
import PQueue from "p-queue";
|
|
1497
|
+
import { join as join2 } from "path";
|
|
1498
|
+
var FILES_DIRECTORY_NAME = "files";
|
|
1499
|
+
var urlToHash = (url) => {
|
|
1500
|
+
const hash = createHash("sha256");
|
|
1501
|
+
hash.update(url);
|
|
1502
|
+
return hash.digest("hex");
|
|
1503
|
+
};
|
|
1504
|
+
var urlToFileName = (url) => {
|
|
1505
|
+
const fileName = urlToHash(url);
|
|
1506
|
+
const fileNameChunks = url.split(".");
|
|
1507
|
+
const fileExtension = fileNameChunks.length > 1 ? fileNameChunks.at(-1) : "";
|
|
1508
|
+
return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
|
|
1509
|
+
};
|
|
1510
|
+
var extractAndDownloadUniformFilesForObject = async (object, options) => {
|
|
1511
|
+
const objectAsString = JSON.stringify(object);
|
|
1512
|
+
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1513
|
+
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1514
|
+
);
|
|
1515
|
+
if (uniformFileUrlMatches) {
|
|
1516
|
+
const fileDownloadQueue = new PQueue({ concurrency: 10 });
|
|
1517
|
+
for (const match of uniformFileUrlMatches) {
|
|
1518
|
+
const url = match[1];
|
|
1519
|
+
fileDownloadQueue.add(async () => {
|
|
1520
|
+
try {
|
|
1521
|
+
const fileName = urlToFileName(url);
|
|
1522
|
+
const fileAlreadyExists = await fsj.existsAsync(
|
|
1523
|
+
join2(options.directory, FILES_DIRECTORY_NAME, fileName)
|
|
1524
|
+
);
|
|
1525
|
+
if (fileAlreadyExists) {
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
const response = await fetch(url);
|
|
1529
|
+
if (!response.ok) {
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
const fileBuffer = await response.arrayBuffer();
|
|
1533
|
+
await fsj.writeAsync(
|
|
1534
|
+
join2(options.directory, FILES_DIRECTORY_NAME, fileName),
|
|
1535
|
+
Buffer.from(fileBuffer)
|
|
1536
|
+
);
|
|
1537
|
+
} catch {
|
|
1538
|
+
console.warn(`Failed to download file ${url}`);
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
await fileDownloadQueue.onIdle();
|
|
1543
|
+
}
|
|
1544
|
+
return object;
|
|
1545
|
+
};
|
|
1546
|
+
var extractAndUploadUniformFilesForObject = async (object, options) => {
|
|
1547
|
+
let objectAsString = JSON.stringify(object);
|
|
1548
|
+
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1549
|
+
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1550
|
+
);
|
|
1551
|
+
if (uniformFileUrlMatches) {
|
|
1552
|
+
const fileUploadQueue = new PQueue({ concurrency: 3 });
|
|
1553
|
+
for (const match of uniformFileUrlMatches) {
|
|
1554
|
+
const url = match[1];
|
|
1555
|
+
const hash = urlToHash(url);
|
|
1556
|
+
fileUploadQueue.add(async () => {
|
|
1557
|
+
try {
|
|
1558
|
+
const fileAlreadyExistsChecks = await Promise.all([
|
|
1559
|
+
options.fileClient.getFile({ projectId: options.projectId, url }).catch(() => null),
|
|
1560
|
+
options.fileClient.getFile({ projectId: options.projectId, sourceId: hash }).catch(() => null)
|
|
1561
|
+
]);
|
|
1562
|
+
if (fileAlreadyExistsChecks.some((check) => check !== null)) {
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
const localFileName = urlToFileName(url);
|
|
1566
|
+
const fileExistsLocally = await fsj.existsAsync(
|
|
1567
|
+
join2(options.directory, FILES_DIRECTORY_NAME, localFileName)
|
|
1568
|
+
);
|
|
1569
|
+
if (!fileExistsLocally) {
|
|
1570
|
+
console.warn(`Skipping file ${url} as we couldn't find a local copy`);
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
const fileBuffer = await fsj.readAsync(
|
|
1574
|
+
join2(options.directory, FILES_DIRECTORY_NAME, localFileName),
|
|
1575
|
+
"buffer"
|
|
1576
|
+
);
|
|
1577
|
+
if (!fileBuffer) {
|
|
1578
|
+
console.warn(`Skipping file ${url} as we couldn't read it`);
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
const fileName = getFileNameFromUrl(url);
|
|
1582
|
+
const { width, height } = (() => {
|
|
1583
|
+
try {
|
|
1584
|
+
return sizeOf(fileBuffer);
|
|
1585
|
+
} catch {
|
|
1586
|
+
return {
|
|
1587
|
+
width: void 0,
|
|
1588
|
+
height: void 0
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
})();
|
|
1592
|
+
const { id, method, uploadUrl } = await options.fileClient.createNewProjectFile({
|
|
1593
|
+
name: fileName,
|
|
1594
|
+
mediaType: preferredType(url.split(".").at(-1) ?? ""),
|
|
1595
|
+
size: fileBuffer.length,
|
|
1596
|
+
width,
|
|
1597
|
+
height,
|
|
1598
|
+
projectId: options.projectId,
|
|
1599
|
+
sourceId: hash
|
|
1600
|
+
});
|
|
1601
|
+
const uploadResponse = await fetch(uploadUrl, {
|
|
1602
|
+
method,
|
|
1603
|
+
body: fileBuffer
|
|
1604
|
+
});
|
|
1605
|
+
if (!uploadResponse.ok) {
|
|
1606
|
+
console.warn(`Failed to upload file ${url}`);
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
const checkForFile = async () => {
|
|
1610
|
+
const file = await options.fileClient.getFile({ id });
|
|
1611
|
+
if (!file || file.state !== FILE_READY_STATE) {
|
|
1612
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1613
|
+
return checkForFile();
|
|
1614
|
+
}
|
|
1615
|
+
return file.url;
|
|
1616
|
+
};
|
|
1617
|
+
const abortTimeout = setTimeout(() => {
|
|
1618
|
+
throw new Error(`Failed to upload file ${url}`);
|
|
1619
|
+
}, 1e4);
|
|
1620
|
+
const uploadedFileUrl = await checkForFile();
|
|
1621
|
+
clearTimeout(abortTimeout);
|
|
1622
|
+
objectAsString = objectAsString.replaceAll(`"${url}"`, `"${uploadedFileUrl}"`);
|
|
1623
|
+
} catch {
|
|
1624
|
+
console.warn(`Failed to upload file ${url}`);
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
await fileUploadQueue.onIdle();
|
|
1629
|
+
}
|
|
1630
|
+
return JSON.parse(objectAsString);
|
|
1631
|
+
};
|
|
1632
|
+
var swapOutUniformFileUrlsForTargetProject = async (object, options) => {
|
|
1633
|
+
let objectAsString = JSON.stringify(object);
|
|
1634
|
+
const uniformFileUrlMatches = objectAsString.matchAll(
|
|
1635
|
+
/"(https:\/\/(.*)?img\.uniform\.(rocks|global)\/(.*?))"/g
|
|
1636
|
+
);
|
|
1637
|
+
if (uniformFileUrlMatches) {
|
|
1638
|
+
const fileUrlReplacementQueue = new PQueue({ concurrency: 3 });
|
|
1639
|
+
for (const match of uniformFileUrlMatches) {
|
|
1640
|
+
const url = match[1];
|
|
1641
|
+
const hash = urlToHash(url);
|
|
1642
|
+
fileUrlReplacementQueue.add(async () => {
|
|
1643
|
+
try {
|
|
1644
|
+
const fileAlreadyExistsChecks = await Promise.all([
|
|
1645
|
+
options.fileClient.getFile({ projectId: options.projectId, url }).catch(() => null),
|
|
1646
|
+
options.fileClient.getFile({ projectId: options.projectId, sourceId: hash }).catch(() => null)
|
|
1647
|
+
]);
|
|
1648
|
+
const file = fileAlreadyExistsChecks.find((check) => check !== null);
|
|
1649
|
+
if (!file) {
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
objectAsString = objectAsString.replaceAll(`"${url}"`, `"${file.url}"`);
|
|
1653
|
+
} catch {
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
await fileUrlReplacementQueue.onIdle();
|
|
1658
|
+
}
|
|
1659
|
+
return JSON.parse(objectAsString);
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1662
|
+
// src/commands/canvas/commands/composition/pull.ts
|
|
1459
1663
|
var CompositionPullModule = {
|
|
1460
1664
|
command: "pull <directory>",
|
|
1461
1665
|
describe: "Pulls all compositions to local files in a directory",
|
|
@@ -1542,13 +1746,19 @@ var CompositionPullModule = {
|
|
|
1542
1746
|
target,
|
|
1543
1747
|
mode,
|
|
1544
1748
|
whatIf,
|
|
1545
|
-
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1749
|
+
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
1750
|
+
onBeforeWriteObject: async (sourceObject) => {
|
|
1751
|
+
return extractAndDownloadUniformFilesForObject(sourceObject, {
|
|
1752
|
+
directory
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1546
1755
|
});
|
|
1547
1756
|
}
|
|
1548
1757
|
};
|
|
1549
1758
|
|
|
1550
1759
|
// src/commands/canvas/commands/composition/push.ts
|
|
1551
1760
|
import { UncachedCanvasClient as UncachedCanvasClient11 } from "@uniformdev/canvas";
|
|
1761
|
+
import { FileClient as FileClient2 } from "@uniformdev/files-sdk";
|
|
1552
1762
|
var CompositionPushModule = {
|
|
1553
1763
|
command: "push <directory>",
|
|
1554
1764
|
describe: "Pushes all compositions from files in a directory to Uniform Canvas",
|
|
@@ -1618,12 +1828,26 @@ var CompositionPushModule = {
|
|
|
1618
1828
|
});
|
|
1619
1829
|
}
|
|
1620
1830
|
const target = createComponentInstanceEngineDataSource({ client, state, onlyCompositions, onlyPatterns });
|
|
1831
|
+
const fileClient = new FileClient2({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
1621
1832
|
await syncEngine({
|
|
1622
1833
|
source,
|
|
1623
1834
|
target,
|
|
1624
1835
|
mode,
|
|
1625
1836
|
whatIf,
|
|
1626
|
-
log: createSyncEngineConsoleLogger({ diffMode })
|
|
1837
|
+
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
1838
|
+
onBeforeCompareObjects: async (sourceObject) => {
|
|
1839
|
+
return swapOutUniformFileUrlsForTargetProject(sourceObject, {
|
|
1840
|
+
fileClient,
|
|
1841
|
+
projectId
|
|
1842
|
+
});
|
|
1843
|
+
},
|
|
1844
|
+
onBeforeWriteObject: async (sourceObject) => {
|
|
1845
|
+
return extractAndUploadUniformFilesForObject(sourceObject, {
|
|
1846
|
+
directory,
|
|
1847
|
+
fileClient,
|
|
1848
|
+
projectId
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1627
1851
|
});
|
|
1628
1852
|
}
|
|
1629
1853
|
};
|
|
@@ -1650,23 +1874,99 @@ var CompositionRemoveModule = {
|
|
|
1650
1874
|
|
|
1651
1875
|
// src/commands/canvas/commands/composition/unpublish.ts
|
|
1652
1876
|
import { CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE2, UncachedCanvasClient as UncachedCanvasClient13 } from "@uniformdev/canvas";
|
|
1877
|
+
import { diffJson as diffJson2 } from "diff";
|
|
1653
1878
|
var CompositionUnpublishModule = {
|
|
1654
|
-
command: "unpublish
|
|
1655
|
-
describe: "Unpublish a composition",
|
|
1879
|
+
command: "unpublish [ids]",
|
|
1880
|
+
describe: "Unpublish a composition(s)",
|
|
1656
1881
|
builder: (yargs23) => withConfiguration(
|
|
1657
1882
|
withApiOptions(
|
|
1658
1883
|
withProjectOptions(
|
|
1659
|
-
yargs23.positional("
|
|
1660
|
-
|
|
1661
|
-
|
|
1884
|
+
yargs23.positional("ids", {
|
|
1885
|
+
describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
|
|
1886
|
+
type: "string"
|
|
1887
|
+
}).option("all", {
|
|
1888
|
+
alias: ["a"],
|
|
1889
|
+
describe: "Un-publishes all compositions. Use compositionId to publish one instead.",
|
|
1890
|
+
default: false,
|
|
1891
|
+
type: "boolean"
|
|
1892
|
+
}).option("what-if", {
|
|
1893
|
+
alias: ["w"],
|
|
1894
|
+
describe: "What-if mode reports what would be done but does not perform any publishing",
|
|
1895
|
+
default: false,
|
|
1896
|
+
type: "boolean"
|
|
1897
|
+
}).option("onlyCompositions", {
|
|
1898
|
+
describe: "Only publishing compositions and not patterns",
|
|
1899
|
+
default: false,
|
|
1900
|
+
type: "boolean"
|
|
1901
|
+
}).option("onlyPatterns", {
|
|
1902
|
+
describe: "Only pulling patterns and not compositions",
|
|
1903
|
+
default: false,
|
|
1904
|
+
type: "boolean",
|
|
1905
|
+
hidden: true
|
|
1662
1906
|
})
|
|
1663
1907
|
)
|
|
1664
1908
|
)
|
|
1665
1909
|
),
|
|
1666
|
-
handler: async ({
|
|
1910
|
+
handler: async ({
|
|
1911
|
+
apiHost,
|
|
1912
|
+
apiKey,
|
|
1913
|
+
proxy,
|
|
1914
|
+
ids,
|
|
1915
|
+
all,
|
|
1916
|
+
onlyCompositions,
|
|
1917
|
+
onlyPatterns,
|
|
1918
|
+
project: projectId,
|
|
1919
|
+
diff,
|
|
1920
|
+
whatIf
|
|
1921
|
+
}) => {
|
|
1922
|
+
if (!all && !ids || all && ids) {
|
|
1923
|
+
console.error(`Specify --all or composition ID(s) to publish.`);
|
|
1924
|
+
process.exit(1);
|
|
1925
|
+
}
|
|
1926
|
+
const compositionIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
|
|
1927
|
+
const targetItems = /* @__PURE__ */ new Map();
|
|
1667
1928
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1668
1929
|
const client = new UncachedCanvasClient13({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
1669
|
-
|
|
1930
|
+
const source = createComponentInstanceEngineDataSource({
|
|
1931
|
+
client,
|
|
1932
|
+
state: "published",
|
|
1933
|
+
compositionIDs: compositionIDsArray,
|
|
1934
|
+
onlyCompositions,
|
|
1935
|
+
onlyPatterns
|
|
1936
|
+
});
|
|
1937
|
+
const target = createComponentInstanceEngineDataSource({
|
|
1938
|
+
client,
|
|
1939
|
+
state: "preview",
|
|
1940
|
+
compositionIDs: compositionIDsArray,
|
|
1941
|
+
onlyCompositions,
|
|
1942
|
+
onlyPatterns
|
|
1943
|
+
});
|
|
1944
|
+
const actions = [];
|
|
1945
|
+
const log = createSyncEngineConsoleLogger({ diffMode: diff });
|
|
1946
|
+
for await (const obj of target.objects) {
|
|
1947
|
+
if (Array.isArray(obj.id)) {
|
|
1948
|
+
obj.id.forEach((o) => targetItems.set(o, obj));
|
|
1949
|
+
} else {
|
|
1950
|
+
targetItems.set(obj.id, obj);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
for await (const sourceObject of source.objects) {
|
|
1954
|
+
const id = Array.isArray(sourceObject.id) ? sourceObject.id[0] : sourceObject.id;
|
|
1955
|
+
const targetObject = targetItems.get(id);
|
|
1956
|
+
if (!targetObject) {
|
|
1957
|
+
console.log(`Composition ${id} was not found`);
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
actions.push(client.removeComposition({ compositionId: id, state: CANVAS_PUBLISHED_STATE2 }));
|
|
1961
|
+
log({
|
|
1962
|
+
action: "update",
|
|
1963
|
+
id,
|
|
1964
|
+
providerId: sourceObject.providerId,
|
|
1965
|
+
displayName: sourceObject.displayName ?? sourceObject.providerId,
|
|
1966
|
+
whatIf,
|
|
1967
|
+
diff: diffJson2(targetObject.object, sourceObject.object)
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1670
1970
|
}
|
|
1671
1971
|
};
|
|
1672
1972
|
|
|
@@ -2050,7 +2350,43 @@ var PatternListModule = {
|
|
|
2050
2350
|
// src/commands/canvas/commands/pattern/publish.ts
|
|
2051
2351
|
var PatternPublishModule = {
|
|
2052
2352
|
...CompositionPublishModule,
|
|
2053
|
-
describe: "Publishes
|
|
2353
|
+
describe: "Publishes pattern(s)",
|
|
2354
|
+
builder: (yargs23) => withConfiguration(
|
|
2355
|
+
withApiOptions(
|
|
2356
|
+
withProjectOptions(
|
|
2357
|
+
withDiffOptions(
|
|
2358
|
+
yargs23.positional("ids", {
|
|
2359
|
+
describe: "Publishes pattern(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
|
|
2360
|
+
type: "string"
|
|
2361
|
+
}).option("all", {
|
|
2362
|
+
alias: ["a"],
|
|
2363
|
+
describe: "Publishes all patterns. Use compositionId to publish one instead.",
|
|
2364
|
+
default: false,
|
|
2365
|
+
type: "boolean"
|
|
2366
|
+
}).option("what-if", {
|
|
2367
|
+
alias: ["w"],
|
|
2368
|
+
describe: "What-if mode reports what would be done but does not perform any un-publishing",
|
|
2369
|
+
default: false,
|
|
2370
|
+
type: "boolean"
|
|
2371
|
+
}).option("publishingState", {
|
|
2372
|
+
describe: 'Publishing state to update to. Can be "published" or "preview".',
|
|
2373
|
+
default: "published",
|
|
2374
|
+
type: "string",
|
|
2375
|
+
hidden: true
|
|
2376
|
+
}).option("onlyCompositions", {
|
|
2377
|
+
describe: "Only publishing compositions and not patterns",
|
|
2378
|
+
default: false,
|
|
2379
|
+
type: "boolean"
|
|
2380
|
+
}).option("onlyPatterns", {
|
|
2381
|
+
describe: "Only pulling patterns and not compositions",
|
|
2382
|
+
default: true,
|
|
2383
|
+
type: "boolean",
|
|
2384
|
+
hidden: true
|
|
2385
|
+
})
|
|
2386
|
+
)
|
|
2387
|
+
)
|
|
2388
|
+
)
|
|
2389
|
+
)
|
|
2054
2390
|
};
|
|
2055
2391
|
|
|
2056
2392
|
// src/commands/canvas/commands/pattern/pull.ts
|
|
@@ -2141,8 +2477,38 @@ var PatternRemoveModule = {
|
|
|
2141
2477
|
|
|
2142
2478
|
// src/commands/canvas/commands/pattern/unpublish.ts
|
|
2143
2479
|
var PatternUnpublishModule = {
|
|
2144
|
-
|
|
2145
|
-
describe: "Unpublish a pattern"
|
|
2480
|
+
command: "unpublish [ids]",
|
|
2481
|
+
describe: "Unpublish a pattern(s)",
|
|
2482
|
+
builder: (yargs23) => withConfiguration(
|
|
2483
|
+
withApiOptions(
|
|
2484
|
+
withProjectOptions(
|
|
2485
|
+
yargs23.positional("ids", {
|
|
2486
|
+
describe: "Un-publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
|
|
2487
|
+
type: "string"
|
|
2488
|
+
}).option("all", {
|
|
2489
|
+
alias: ["a"],
|
|
2490
|
+
describe: "Un-pPublishes all compositions. Use compositionId to publish one instead.",
|
|
2491
|
+
default: false,
|
|
2492
|
+
type: "boolean"
|
|
2493
|
+
}).option("what-if", {
|
|
2494
|
+
alias: ["w"],
|
|
2495
|
+
describe: "What-if mode reports what would be done but does not perform any publishing",
|
|
2496
|
+
default: false,
|
|
2497
|
+
type: "boolean"
|
|
2498
|
+
}).option("onlyCompositions", {
|
|
2499
|
+
describe: "Only publishing compositions and not patterns",
|
|
2500
|
+
default: false,
|
|
2501
|
+
type: "boolean"
|
|
2502
|
+
}).option("onlyPatterns", {
|
|
2503
|
+
describe: "Only pulling patterns and not compositions",
|
|
2504
|
+
default: true,
|
|
2505
|
+
type: "boolean",
|
|
2506
|
+
hidden: true
|
|
2507
|
+
})
|
|
2508
|
+
)
|
|
2509
|
+
)
|
|
2510
|
+
),
|
|
2511
|
+
handler: CompositionUnpublishModule.handler
|
|
2146
2512
|
};
|
|
2147
2513
|
|
|
2148
2514
|
// src/commands/canvas/commands/pattern/update.ts
|
|
@@ -3775,7 +4141,7 @@ import { PostHog } from "posthog-node";
|
|
|
3775
4141
|
// package.json
|
|
3776
4142
|
var package_default = {
|
|
3777
4143
|
name: "@uniformdev/cli",
|
|
3778
|
-
version: "19.45.
|
|
4144
|
+
version: "19.45.1",
|
|
3779
4145
|
description: "Uniform command line interface tool",
|
|
3780
4146
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
3781
4147
|
main: "./cli.js",
|
|
@@ -3791,8 +4157,10 @@ var package_default = {
|
|
|
3791
4157
|
format: 'prettier --write "src/**/*.{js,ts,tsx}"'
|
|
3792
4158
|
},
|
|
3793
4159
|
dependencies: {
|
|
4160
|
+
"@thi.ng/mime": "^2.2.23",
|
|
3794
4161
|
"@uniformdev/canvas": "workspace:*",
|
|
3795
4162
|
"@uniformdev/context": "workspace:*",
|
|
4163
|
+
"@uniformdev/files-sdk": "workspace:*",
|
|
3796
4164
|
"@uniformdev/project-map": "workspace:*",
|
|
3797
4165
|
"@uniformdev/redirect": "workspace:*",
|
|
3798
4166
|
colorette: "2.0.20",
|
|
@@ -3805,6 +4173,7 @@ var package_default = {
|
|
|
3805
4173
|
graphql: "16.7.1",
|
|
3806
4174
|
"graphql-request": "6.1.0",
|
|
3807
4175
|
"https-proxy-agent": "^7.0.0",
|
|
4176
|
+
"image-size": "^1.0.2",
|
|
3808
4177
|
inquirer: "9.2.10",
|
|
3809
4178
|
"isomorphic-git": "1.24.5",
|
|
3810
4179
|
"isomorphic-unfetch": "^3.1.0",
|
|
@@ -3813,6 +4182,7 @@ var package_default = {
|
|
|
3813
4182
|
"lodash.isequalwith": "^4.4.0",
|
|
3814
4183
|
open: "9.1.0",
|
|
3815
4184
|
ora: "6.3.1",
|
|
4185
|
+
"p-queue": "7.3.4",
|
|
3816
4186
|
"posthog-node": "3.1.1",
|
|
3817
4187
|
slugify: "1.6.6",
|
|
3818
4188
|
"update-check": "^1.5.4",
|
|
@@ -4150,7 +4520,7 @@ ${err.message}`);
|
|
|
4150
4520
|
// src/projects/cloneStarter.ts
|
|
4151
4521
|
import crypto2 from "crypto";
|
|
4152
4522
|
import fs3 from "fs";
|
|
4153
|
-
import
|
|
4523
|
+
import fsj2 from "fs-jetpack";
|
|
4154
4524
|
import * as git from "isomorphic-git";
|
|
4155
4525
|
import * as http from "isomorphic-git/http/node/index.js";
|
|
4156
4526
|
import os from "os";
|
|
@@ -4181,7 +4551,7 @@ async function cloneStarter({
|
|
|
4181
4551
|
throw new Error(`"${targetDir}" is not empty`);
|
|
4182
4552
|
}
|
|
4183
4553
|
const starterDir = path.join(cloneDir, ...pathSegments);
|
|
4184
|
-
|
|
4554
|
+
fsj2.copy(starterDir, targetDir, { overwrite: true });
|
|
4185
4555
|
if (dotEnvFile) {
|
|
4186
4556
|
fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
|
|
4187
4557
|
}
|
|
@@ -6085,7 +6455,7 @@ async function checkForUpdateMiddleware() {
|
|
|
6085
6455
|
|
|
6086
6456
|
// src/middleware/checkLocalDepsVersionsMiddleware.ts
|
|
6087
6457
|
import { magenta, red as red6 } from "colorette";
|
|
6088
|
-
import { join as
|
|
6458
|
+
import { join as join3 } from "path";
|
|
6089
6459
|
|
|
6090
6460
|
// src/fs.ts
|
|
6091
6461
|
import { promises as fs5 } from "fs";
|
|
@@ -6124,7 +6494,7 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
6124
6494
|
try {
|
|
6125
6495
|
let isOutside = false;
|
|
6126
6496
|
let warning = `${magenta("Warning:")} Installed Uniform packages should be the same version`;
|
|
6127
|
-
const localPackages = await tryReadJSON(
|
|
6497
|
+
const localPackages = await tryReadJSON(join3(process.cwd(), "package.json"));
|
|
6128
6498
|
if (!localPackages)
|
|
6129
6499
|
return;
|
|
6130
6500
|
let firstVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "19.45.
|
|
3
|
+
"version": "19.45.1",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@uniformdev/
|
|
21
|
-
"@uniformdev/
|
|
22
|
-
"@uniformdev/
|
|
19
|
+
"@thi.ng/mime": "^2.2.23",
|
|
20
|
+
"@uniformdev/canvas": "19.45.1",
|
|
21
|
+
"@uniformdev/context": "19.45.1",
|
|
22
|
+
"@uniformdev/files-sdk": "19.45.1",
|
|
23
|
+
"@uniformdev/project-map": "19.45.1",
|
|
24
|
+
"@uniformdev/redirect": "19.45.1",
|
|
23
25
|
"colorette": "2.0.20",
|
|
24
26
|
"cosmiconfig": "8.2.0",
|
|
25
27
|
"cosmiconfig-typescript-loader": "5.0.0",
|
|
@@ -30,6 +32,7 @@
|
|
|
30
32
|
"graphql": "16.7.1",
|
|
31
33
|
"graphql-request": "6.1.0",
|
|
32
34
|
"https-proxy-agent": "^7.0.0",
|
|
35
|
+
"image-size": "^1.0.2",
|
|
33
36
|
"inquirer": "9.2.10",
|
|
34
37
|
"isomorphic-git": "1.24.5",
|
|
35
38
|
"isomorphic-unfetch": "^3.1.0",
|
|
@@ -38,6 +41,7 @@
|
|
|
38
41
|
"lodash.isequalwith": "^4.4.0",
|
|
39
42
|
"open": "9.1.0",
|
|
40
43
|
"ora": "6.3.1",
|
|
44
|
+
"p-queue": "7.3.4",
|
|
41
45
|
"posthog-node": "3.1.1",
|
|
42
46
|
"slugify": "1.6.6",
|
|
43
47
|
"update-check": "^1.5.4",
|
|
@@ -62,5 +66,5 @@
|
|
|
62
66
|
"publishConfig": {
|
|
63
67
|
"access": "public"
|
|
64
68
|
},
|
|
65
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "27d329b913db64152e9d49bcfa7dddf8b3b31bb6"
|
|
66
70
|
}
|