@uniformdev/cli 19.86.1-alpha.15 → 19.88.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.d.mts +10 -3
- package/dist/index.mjs +37 -13
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
type CLICompositionState = 'preview' | 'published' | number;
|
|
3
|
+
type StateArgs = {
|
|
4
|
+
state: CLICompositionState;
|
|
5
|
+
};
|
|
6
|
+
|
|
2
7
|
type SyncMode = 'mirror' | 'createOrUpdate' | 'create';
|
|
3
8
|
type EntityTypes = 'category' | 'dataType' | 'quirk' | 'test' | 'signal' | 'enrichment' | 'aggregate' | 'component' | 'composition' | 'pattern' | 'projectMapDefinition' | 'projectMapNode' | 'redirect' | 'entry' | 'contentType' | 'asset';
|
|
4
9
|
type SyncFileFormat = 'yaml' | 'json';
|
|
@@ -8,7 +13,8 @@ type EntityConfiguration = {
|
|
|
8
13
|
format?: SyncFileFormat;
|
|
9
14
|
disabled?: true;
|
|
10
15
|
};
|
|
11
|
-
type
|
|
16
|
+
type EntityWithStateConfiguration = EntityConfiguration & Partial<StateArgs>;
|
|
17
|
+
type PublishableEntitiesConfiguration = EntityWithStateConfiguration & {
|
|
12
18
|
publish?: boolean;
|
|
13
19
|
};
|
|
14
20
|
type SerializationConfiguration = {
|
|
@@ -16,8 +22,9 @@ type SerializationConfiguration = {
|
|
|
16
22
|
pull?: EntityConfiguration;
|
|
17
23
|
push?: EntityConfiguration;
|
|
18
24
|
} & EntityConfiguration> & {
|
|
19
|
-
composition?:
|
|
20
|
-
pattern?:
|
|
25
|
+
composition?: PublishableEntitiesConfiguration;
|
|
26
|
+
pattern?: PublishableEntitiesConfiguration;
|
|
27
|
+
entry?: EntityWithStateConfiguration;
|
|
21
28
|
}>;
|
|
22
29
|
directory: string;
|
|
23
30
|
mode: SyncMode;
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
// ../../node_modules/.pnpm/tsup@8.0.1_@microsoft+api-extractor@7.
|
|
10
|
+
// ../../node_modules/.pnpm/tsup@8.0.1_@microsoft+api-extractor@7.38.3_postcss@8.4.32_typescript@5.3.2/node_modules/tsup/assets/esm_shims.js
|
|
11
11
|
import { fileURLToPath } from "url";
|
|
12
12
|
import path from "path";
|
|
13
13
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
@@ -674,6 +674,7 @@ import { UncachedFileClient } from "@uniformdev/files";
|
|
|
674
674
|
// src/files/index.ts
|
|
675
675
|
import { preferredType } from "@thi.ng/mime";
|
|
676
676
|
import { FILE_READY_STATE, getFileNameFromUrl } from "@uniformdev/files";
|
|
677
|
+
import { createHash } from "crypto";
|
|
677
678
|
import fsj from "fs-jetpack";
|
|
678
679
|
import sizeOf from "image-size";
|
|
679
680
|
import PQueue from "p-queue";
|
|
@@ -794,33 +795,39 @@ var extractAndUploadUniformFilesForObject = async (object, options) => {
|
|
|
794
795
|
let objectAsString = JSON.stringify(object);
|
|
795
796
|
const uniformFileUrlMatches = getUniformFileUrlMatches(objectAsString);
|
|
796
797
|
const writeDirectory = getFilesDirectory(options.directory);
|
|
798
|
+
const isPackage = isPathAPackageFile(options.directory);
|
|
799
|
+
const legacyWriteDirectory = isPackage ? dirname2(options.directory) : options.directory;
|
|
797
800
|
if (uniformFileUrlMatches) {
|
|
798
801
|
const fileUploadQueue = new PQueue({ concurrency: 3 });
|
|
799
802
|
for (const match of uniformFileUrlMatches) {
|
|
800
803
|
const url = match[1];
|
|
801
804
|
const hash = urlToHash(url);
|
|
805
|
+
const legacyHash = legacyUrlToHash(url);
|
|
802
806
|
fileUploadQueue.add(async () => {
|
|
803
807
|
try {
|
|
804
808
|
const fileAlreadyExistsChecks = await Promise.all([
|
|
805
809
|
options.fileClient.get({ url }).catch(() => null),
|
|
806
|
-
options.fileClient.get({ sourceId: hash }).catch(() => null)
|
|
810
|
+
options.fileClient.get({ sourceId: hash }).catch(() => null),
|
|
811
|
+
options.fileClient.get({ sourceId: legacyHash }).catch(() => null)
|
|
807
812
|
]);
|
|
808
813
|
if (fileAlreadyExistsChecks.some((check) => check !== null)) {
|
|
809
814
|
return;
|
|
810
815
|
}
|
|
811
816
|
const localFileName = urlToFileName(url);
|
|
812
|
-
|
|
813
|
-
|
|
817
|
+
let expectedFilePath = join2(writeDirectory, FILES_DIRECTORY_NAME, localFileName);
|
|
818
|
+
let fileExistsLocally = await fsj.existsAsync(expectedFilePath);
|
|
819
|
+
if (!fileExistsLocally) {
|
|
820
|
+
const localFileName2 = legacyUrlToFileName(url);
|
|
821
|
+
expectedFilePath = join2(legacyWriteDirectory, FILES_DIRECTORY_NAME, localFileName2);
|
|
822
|
+
fileExistsLocally = await fsj.existsAsync(expectedFilePath);
|
|
823
|
+
}
|
|
814
824
|
if (!fileExistsLocally) {
|
|
815
825
|
console.warn(
|
|
816
826
|
`Skipping file ${url} as we couldn't find a local copy (looked at ${expectedFilePath})`
|
|
817
827
|
);
|
|
818
828
|
return;
|
|
819
829
|
}
|
|
820
|
-
const fileBuffer = await fsj.readAsync(
|
|
821
|
-
join2(writeDirectory, FILES_DIRECTORY_NAME, localFileName),
|
|
822
|
-
"buffer"
|
|
823
|
-
);
|
|
830
|
+
const fileBuffer = await fsj.readAsync(expectedFilePath, "buffer");
|
|
824
831
|
if (!fileBuffer) {
|
|
825
832
|
console.warn(`Skipping file ${url} as we couldn't read it`);
|
|
826
833
|
return;
|
|
@@ -888,11 +895,13 @@ var swapOutUniformFileUrlsForTargetProject = async (object, options) => {
|
|
|
888
895
|
for (const match of uniformFileUrlMatches) {
|
|
889
896
|
const url = match[1];
|
|
890
897
|
const hash = urlToHash(url);
|
|
898
|
+
const legacyHash = legacyUrlToHash(url);
|
|
891
899
|
fileUrlReplacementQueue.add(async () => {
|
|
892
900
|
try {
|
|
893
901
|
const fileAlreadyExistsChecks = await Promise.all([
|
|
894
902
|
options.fileClient.get({ url }).catch(() => null),
|
|
895
|
-
options.fileClient.get({ sourceId: hash }).catch(() => null)
|
|
903
|
+
options.fileClient.get({ sourceId: hash }).catch(() => null),
|
|
904
|
+
options.fileClient.get({ sourceId: legacyHash }).catch(() => null)
|
|
896
905
|
]);
|
|
897
906
|
const file = fileAlreadyExistsChecks.find((check) => check !== null);
|
|
898
907
|
if (!file) {
|
|
@@ -965,6 +974,16 @@ var updateAssetFileIdBasedOnUrl = async (asset, options) => {
|
|
|
965
974
|
};
|
|
966
975
|
return asset;
|
|
967
976
|
};
|
|
977
|
+
var legacyUrlToHash = (url) => {
|
|
978
|
+
const hash = createHash("sha256");
|
|
979
|
+
hash.update(url);
|
|
980
|
+
return hash.digest("hex");
|
|
981
|
+
};
|
|
982
|
+
var legacyUrlToFileName = (url) => {
|
|
983
|
+
const fileName = legacyUrlToHash(url);
|
|
984
|
+
const fileExtension = urlToFileExtension(url);
|
|
985
|
+
return `${fileName}${fileExtension ? `.${fileExtension}` : ""}`;
|
|
986
|
+
};
|
|
968
987
|
|
|
969
988
|
// src/commands/canvas/assetEngineDataSource.ts
|
|
970
989
|
import { convertAssetToPutAsset } from "@uniformdev/assets";
|
|
@@ -5604,7 +5623,7 @@ import { PostHog } from "posthog-node";
|
|
|
5604
5623
|
// package.json
|
|
5605
5624
|
var package_default = {
|
|
5606
5625
|
name: "@uniformdev/cli",
|
|
5607
|
-
version: "19.
|
|
5626
|
+
version: "19.88.0",
|
|
5608
5627
|
description: "Uniform command line interface tool",
|
|
5609
5628
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
5610
5629
|
main: "./cli.js",
|
|
@@ -7728,6 +7747,7 @@ var SyncPullModule = {
|
|
|
7728
7747
|
)
|
|
7729
7748
|
),
|
|
7730
7749
|
handler: async ({ serialization, ...otherParams }) => {
|
|
7750
|
+
var _a;
|
|
7731
7751
|
const config2 = serialization;
|
|
7732
7752
|
const enabledEntities = Object.entries({
|
|
7733
7753
|
asset: AssetPullModule,
|
|
@@ -7748,8 +7768,8 @@ var SyncPullModule = {
|
|
|
7748
7768
|
entry: EntryPullModule,
|
|
7749
7769
|
contentType: ContentTypePullModule
|
|
7750
7770
|
}).filter(([entityType]) => {
|
|
7751
|
-
var
|
|
7752
|
-
return Boolean((
|
|
7771
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
7772
|
+
return Boolean((_a2 = config2.entitiesConfig) == null ? void 0 : _a2[entityType]) && ((_c = (_b = config2.entitiesConfig) == null ? void 0 : _b[entityType]) == null ? void 0 : _c.disabled) !== true && ((_f = (_e = (_d = config2.entitiesConfig) == null ? void 0 : _d[entityType]) == null ? void 0 : _e.pull) == null ? void 0 : _f.disabled) !== true;
|
|
7753
7773
|
});
|
|
7754
7774
|
if (enabledEntities.length === 0) {
|
|
7755
7775
|
throw new Error(
|
|
@@ -7758,10 +7778,14 @@ var SyncPullModule = {
|
|
|
7758
7778
|
}
|
|
7759
7779
|
for (const [entityType, module3] of enabledEntities) {
|
|
7760
7780
|
const spinner = spin(entityType);
|
|
7781
|
+
const entityConfigSupportsPullState = (entityConfig2) => {
|
|
7782
|
+
return entityConfig2 !== void 0 && "state" in entityConfig2;
|
|
7783
|
+
};
|
|
7784
|
+
const entityConfig = (_a = config2.entitiesConfig) == null ? void 0 : _a[entityType];
|
|
7761
7785
|
try {
|
|
7762
7786
|
await module3.handler({
|
|
7763
7787
|
...otherParams,
|
|
7764
|
-
state: 0,
|
|
7788
|
+
state: entityConfigSupportsPullState(entityConfig) ? entityConfig.state ?? 0 : 0,
|
|
7765
7789
|
format: getFormat(entityType, config2),
|
|
7766
7790
|
onlyCompositions: entityType === "composition" ? true : void 0,
|
|
7767
7791
|
onlyPatterns: entityType === "pattern" ? true : void 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.88.0",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@thi.ng/mime": "^2.2.23",
|
|
20
|
-
"@uniformdev/assets": "19.
|
|
21
|
-
"@uniformdev/canvas": "19.
|
|
22
|
-
"@uniformdev/context": "19.
|
|
23
|
-
"@uniformdev/files": "19.
|
|
24
|
-
"@uniformdev/project-map": "19.
|
|
25
|
-
"@uniformdev/redirect": "19.
|
|
20
|
+
"@uniformdev/assets": "19.88.0",
|
|
21
|
+
"@uniformdev/canvas": "19.88.0",
|
|
22
|
+
"@uniformdev/context": "19.88.0",
|
|
23
|
+
"@uniformdev/files": "19.88.0",
|
|
24
|
+
"@uniformdev/project-map": "19.88.0",
|
|
25
|
+
"@uniformdev/redirect": "19.88.0",
|
|
26
26
|
"call-bind": "^1.0.2",
|
|
27
27
|
"colorette": "2.0.20",
|
|
28
28
|
"cosmiconfig": "8.3.6",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "0a02f919a6b0f0c41307f120adada2e5d45a947b"
|
|
73
73
|
}
|