@uniformdev/cli 19.10.0 → 19.11.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 +62 -57
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -21,33 +21,34 @@ async function createArraySyncEngineDataSource({
|
|
|
21
21
|
selectDisplayName: selectDisplayName12 = selectIdentifier12,
|
|
22
22
|
onSyncComplete
|
|
23
23
|
}) {
|
|
24
|
-
const objectIndex = objects.reduce(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
if (result[identifier]) {
|
|
32
|
-
throw new Error(`Identifier ${identifier} was not unique.`);
|
|
24
|
+
const objectIndex = objects.reduce(
|
|
25
|
+
(result, current) => {
|
|
26
|
+
const rawIdentifiers = selectIdentifier12(current);
|
|
27
|
+
const identifiers = Array.isArray(rawIdentifiers) ? rawIdentifiers : [rawIdentifiers];
|
|
28
|
+
const existingResult = identifiers.find((id) => result[id]);
|
|
29
|
+
if (existingResult) {
|
|
30
|
+
throw new Error(`Identifier(s) ${identifiers} was not unique.`);
|
|
33
31
|
}
|
|
34
32
|
const displayName = selectDisplayName12(current);
|
|
35
|
-
result[
|
|
36
|
-
id:
|
|
33
|
+
result[identifiers[0]] = {
|
|
34
|
+
id: identifiers,
|
|
37
35
|
object: current,
|
|
38
|
-
providerId:
|
|
36
|
+
providerId: identifiers[0],
|
|
39
37
|
displayName: Array.isArray(displayName) ? displayName[0] : displayName
|
|
40
38
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
identifiers.slice(1).forEach((id) => result[id] = identifiers[0]);
|
|
40
|
+
return result;
|
|
41
|
+
},
|
|
42
|
+
{}
|
|
43
|
+
);
|
|
44
44
|
async function* getObjects() {
|
|
45
45
|
for (const item of Object.values(objectIndex)) {
|
|
46
|
-
|
|
46
|
+
if (typeof item === "object")
|
|
47
|
+
yield item;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
function extractCurrent() {
|
|
50
|
-
return Object.entries(objectIndex).sort((a, b) => a[0].localeCompare(b[0])).map((entry) => entry[1].object);
|
|
51
|
+
return Object.entries(objectIndex).filter((entry) => typeof entry[1] === "object").sort((a, b) => a[0].localeCompare(b[0])).map((entry) => entry[1].object);
|
|
51
52
|
}
|
|
52
53
|
return {
|
|
53
54
|
objects: getObjects(),
|
|
@@ -57,7 +58,7 @@ async function createArraySyncEngineDataSource({
|
|
|
57
58
|
writeObject: async (objectToWrite) => {
|
|
58
59
|
const id = selectIdentifier12(objectToWrite.object);
|
|
59
60
|
if (Array.isArray(id)) {
|
|
60
|
-
|
|
61
|
+
objectIndex[id[0]] = objectToWrite;
|
|
61
62
|
} else {
|
|
62
63
|
objectIndex[id] = objectToWrite;
|
|
63
64
|
}
|
|
@@ -68,7 +69,7 @@ async function createArraySyncEngineDataSource({
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
// src/sync/fileSyncEngineDataSource.ts
|
|
71
|
-
import
|
|
72
|
+
import ansicolors from "ansi-colors";
|
|
72
73
|
import { existsSync, mkdirSync } from "fs";
|
|
73
74
|
import { readdir, unlink } from "fs/promises";
|
|
74
75
|
import { extname as extname2, join } from "path";
|
|
@@ -218,6 +219,7 @@ async function* paginateAsync(fetchPage, options) {
|
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
// src/sync/fileSyncEngineDataSource.ts
|
|
222
|
+
var { red } = ansicolors;
|
|
221
223
|
async function createFileSyncEngineDataSource({
|
|
222
224
|
directory,
|
|
223
225
|
format = "yaml",
|
|
@@ -242,16 +244,17 @@ async function createFileSyncEngineDataSource({
|
|
|
242
244
|
for (const filename of filenames) {
|
|
243
245
|
const fullFilename = join(directory, filename);
|
|
244
246
|
try {
|
|
245
|
-
const contents =
|
|
247
|
+
const contents = readFileToObject(fullFilename);
|
|
248
|
+
const displayName = selectDisplayName12(contents);
|
|
246
249
|
const object = {
|
|
247
250
|
id: selectIdentifier12(contents),
|
|
248
|
-
displayName:
|
|
251
|
+
displayName: Array.isArray(displayName) ? displayName[0] : displayName,
|
|
249
252
|
providerId: fullFilename,
|
|
250
253
|
object: omit(contents, ["$schema"])
|
|
251
254
|
};
|
|
252
255
|
yield object;
|
|
253
256
|
} catch (e) {
|
|
254
|
-
console.error(
|
|
257
|
+
console.error(red(`Failed to read ${fullFilename}, data is likely invalid.
|
|
255
258
|
${e == null ? void 0 : e.message}`));
|
|
256
259
|
throw e;
|
|
257
260
|
}
|
|
@@ -302,7 +305,7 @@ async function syncEngine({
|
|
|
302
305
|
return isEqualWith(
|
|
303
306
|
source2.object,
|
|
304
307
|
target2.object,
|
|
305
|
-
(_a, _b, key) => key === "created" || key === "modified" ? true : void 0
|
|
308
|
+
(_a, _b, key) => key === "created" || key === "modified" || key === "updated" ? true : void 0
|
|
306
309
|
);
|
|
307
310
|
},
|
|
308
311
|
mode,
|
|
@@ -348,7 +351,7 @@ async function syncEngine({
|
|
|
348
351
|
sourceHasItems = true;
|
|
349
352
|
const ids = Array.isArray(sourceObject.id) ? sourceObject.id : [sourceObject.id];
|
|
350
353
|
const targetObject = targetItems.get(ids[0]);
|
|
351
|
-
const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) => o !== targetObject);
|
|
354
|
+
const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) => (o == null ? void 0 : o.object) !== (targetObject == null ? void 0 : targetObject.object));
|
|
352
355
|
if (targetObject && invalidTargetObjects.length == 0) {
|
|
353
356
|
if (!compareContents(sourceObject, targetObject)) {
|
|
354
357
|
if (mode === "createOrUpdate" || mode === "mirror") {
|
|
@@ -392,12 +395,10 @@ async function syncEngine({
|
|
|
392
395
|
});
|
|
393
396
|
};
|
|
394
397
|
if (invalidTargetObjects.length > 0) {
|
|
395
|
-
[...invalidTargetObjects, targetObject].forEach(
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
);
|
|
398
|
+
[...invalidTargetObjects, targetObject].forEach((o) => {
|
|
399
|
+
var _a2;
|
|
400
|
+
(_a2 = Array.isArray(o == null ? void 0 : o.id) ? o == null ? void 0 : o.id : [o == null ? void 0 : o.id]) == null ? void 0 : _a2.forEach((i) => i && targetItems.delete(i));
|
|
401
|
+
});
|
|
401
402
|
const deletes = invalidTargetObjects.filter((io) => typeof io !== "undefined").map(async (io) => {
|
|
402
403
|
await processDelete(io);
|
|
403
404
|
});
|
|
@@ -437,36 +438,37 @@ ${innerError}`
|
|
|
437
438
|
};
|
|
438
439
|
|
|
439
440
|
// src/sync/syncEngineConsoleLogger.ts
|
|
440
|
-
import
|
|
441
|
+
import ansicolors2 from "ansi-colors";
|
|
442
|
+
var { gray, green, red: red2, white, yellow } = ansicolors2;
|
|
441
443
|
function createSyncEngineConsoleLogger(options) {
|
|
442
444
|
const { diffMode = "off", indent, prefix } = options ?? {};
|
|
443
445
|
return function syncEngineConsoleLogger({ action, displayName, whatIf, diff }) {
|
|
444
446
|
let actionTag = "";
|
|
445
447
|
switch (action) {
|
|
446
448
|
case "create":
|
|
447
|
-
actionTag =
|
|
449
|
+
actionTag = green("[A]");
|
|
448
450
|
break;
|
|
449
451
|
case "update":
|
|
450
|
-
actionTag =
|
|
452
|
+
actionTag = white("[U]");
|
|
451
453
|
break;
|
|
452
454
|
case "delete":
|
|
453
|
-
actionTag =
|
|
455
|
+
actionTag = yellow("[D]");
|
|
454
456
|
break;
|
|
455
457
|
}
|
|
456
458
|
let diffString = "";
|
|
457
459
|
if (diffMode === "on" || diffMode === "update" && action === "update") {
|
|
458
460
|
diffString = "\n" + diff.map((change) => {
|
|
459
461
|
if (change.added) {
|
|
460
|
-
return
|
|
462
|
+
return green(change.value);
|
|
461
463
|
}
|
|
462
464
|
if (change.removed) {
|
|
463
|
-
return
|
|
465
|
+
return red2(change.value);
|
|
464
466
|
}
|
|
465
467
|
return change.value;
|
|
466
468
|
}).join("");
|
|
467
469
|
}
|
|
468
470
|
console.log(
|
|
469
|
-
`${indent ?? ""}${whatIf ?
|
|
471
|
+
`${indent ?? ""}${whatIf ? gray("[WHATIF]") : ""}${actionTag}${prefix ?? ""} ${displayName}${diffString}`
|
|
470
472
|
);
|
|
471
473
|
};
|
|
472
474
|
}
|
|
@@ -2149,9 +2151,10 @@ import yargs7 from "yargs";
|
|
|
2149
2151
|
|
|
2150
2152
|
// src/commands/context/commands/manifest/get.ts
|
|
2151
2153
|
import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
|
|
2152
|
-
import
|
|
2154
|
+
import ansicolors3 from "ansi-colors";
|
|
2153
2155
|
import { writeFile } from "fs";
|
|
2154
2156
|
import { exit } from "process";
|
|
2157
|
+
var { gray: gray2, green: green2, red: red3 } = ansicolors3;
|
|
2155
2158
|
var ManifestGetModule = {
|
|
2156
2159
|
command: "get [output]",
|
|
2157
2160
|
aliases: ["dl", "download"],
|
|
@@ -2190,7 +2193,7 @@ var ManifestGetModule = {
|
|
|
2190
2193
|
`, error);
|
|
2191
2194
|
exit(1);
|
|
2192
2195
|
}
|
|
2193
|
-
console.log(
|
|
2196
|
+
console.log(green2(`\u2705 ${output} has been updated from ${apiHost}`));
|
|
2194
2197
|
});
|
|
2195
2198
|
} else {
|
|
2196
2199
|
console.log(text);
|
|
@@ -2205,8 +2208,8 @@ var ManifestGetModule = {
|
|
|
2205
2208
|
} else {
|
|
2206
2209
|
message = e.toString();
|
|
2207
2210
|
}
|
|
2208
|
-
console.error(
|
|
2209
|
-
console.error(
|
|
2211
|
+
console.error(red3(`\u26A0 Error fetching Context manifest`));
|
|
2212
|
+
console.error(gray2(` \u2757 ${message}`));
|
|
2210
2213
|
exit(1);
|
|
2211
2214
|
}
|
|
2212
2215
|
}
|
|
@@ -2214,8 +2217,9 @@ var ManifestGetModule = {
|
|
|
2214
2217
|
|
|
2215
2218
|
// src/commands/context/commands/manifest/publish.ts
|
|
2216
2219
|
import { ApiClientError as ApiClientError2, UncachedManifestClient as UncachedManifestClient2 } from "@uniformdev/context/api";
|
|
2217
|
-
import
|
|
2220
|
+
import ansicolors4 from "ansi-colors";
|
|
2218
2221
|
import { exit as exit2 } from "process";
|
|
2222
|
+
var { gray: gray3, red: red4 } = ansicolors4;
|
|
2219
2223
|
var ManifestPublishModule = {
|
|
2220
2224
|
command: "publish",
|
|
2221
2225
|
describe: "Publish the Uniform Context manifest for a project",
|
|
@@ -2240,8 +2244,8 @@ var ManifestPublishModule = {
|
|
|
2240
2244
|
} else {
|
|
2241
2245
|
message = e.toString();
|
|
2242
2246
|
}
|
|
2243
|
-
console.error(
|
|
2244
|
-
console.error(
|
|
2247
|
+
console.error(red4(`\u26A0 Error publishing Context manifest`));
|
|
2248
|
+
console.error(gray3(` \u2757 ${message}`));
|
|
2245
2249
|
exit2(1);
|
|
2246
2250
|
}
|
|
2247
2251
|
}
|
|
@@ -3098,7 +3102,7 @@ import { PostHog } from "posthog-node";
|
|
|
3098
3102
|
// package.json
|
|
3099
3103
|
var package_default = {
|
|
3100
3104
|
name: "@uniformdev/cli",
|
|
3101
|
-
version: "19.
|
|
3105
|
+
version: "19.11.0",
|
|
3102
3106
|
description: "Uniform command line interface tool",
|
|
3103
3107
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
3104
3108
|
main: "./cli.js",
|
|
@@ -3118,7 +3122,7 @@ var package_default = {
|
|
|
3118
3122
|
"@uniformdev/context": "workspace:*",
|
|
3119
3123
|
"@uniformdev/project-map": "workspace:*",
|
|
3120
3124
|
"@uniformdev/redirect": "workspace:*",
|
|
3121
|
-
|
|
3125
|
+
"ansi-colors": "^4.1.3",
|
|
3122
3126
|
diff: "^5.0.0",
|
|
3123
3127
|
dotenv: "^16.0.3",
|
|
3124
3128
|
execa: "5.1.1",
|
|
@@ -3126,7 +3130,7 @@ var package_default = {
|
|
|
3126
3130
|
graphql: "16.6.0",
|
|
3127
3131
|
"graphql-request": "6.0.0",
|
|
3128
3132
|
"https-proxy-agent": "^5.0.1",
|
|
3129
|
-
inquirer: "9.2.
|
|
3133
|
+
inquirer: "9.2.3",
|
|
3130
3134
|
"isomorphic-git": "1.21.0",
|
|
3131
3135
|
"isomorphic-unfetch": "^3.1.0",
|
|
3132
3136
|
"js-yaml": "^4.1.0",
|
|
@@ -3145,7 +3149,7 @@ var package_default = {
|
|
|
3145
3149
|
"@types/js-yaml": "4.0.5",
|
|
3146
3150
|
"@types/jsonwebtoken": "9.0.2",
|
|
3147
3151
|
"@types/lodash.isequalwith": "4.4.7",
|
|
3148
|
-
"@types/node": "18.16.
|
|
3152
|
+
"@types/node": "18.16.9",
|
|
3149
3153
|
"@types/yargs": "17.0.24"
|
|
3150
3154
|
},
|
|
3151
3155
|
bin: {
|
|
@@ -3674,7 +3678,7 @@ var query = gql`
|
|
|
3674
3678
|
info: identities_by_pk(subject: $subject) {
|
|
3675
3679
|
name
|
|
3676
3680
|
email_address
|
|
3677
|
-
teams: organizations_identities {
|
|
3681
|
+
teams: organizations_identities(order_by: { organization: { name: asc } }) {
|
|
3678
3682
|
team: organization {
|
|
3679
3683
|
name
|
|
3680
3684
|
id
|
|
@@ -4127,7 +4131,7 @@ import yargs13 from "yargs";
|
|
|
4127
4131
|
import yargs12 from "yargs";
|
|
4128
4132
|
|
|
4129
4133
|
// src/commands/optimize/manifest/download.ts
|
|
4130
|
-
import
|
|
4134
|
+
import ansicolors5 from "ansi-colors";
|
|
4131
4135
|
import { writeFile as writeFile2 } from "fs";
|
|
4132
4136
|
import fetch2 from "isomorphic-unfetch";
|
|
4133
4137
|
import { exit as exit3 } from "process";
|
|
@@ -4136,6 +4140,7 @@ import { exit as exit3 } from "process";
|
|
|
4136
4140
|
var UniformBaseUrl = "https://uniform.app";
|
|
4137
4141
|
|
|
4138
4142
|
// src/commands/optimize/manifest/download.ts
|
|
4143
|
+
var { gray: gray4, green: green3, red: red5, yellow: yellow2 } = ansicolors5;
|
|
4139
4144
|
var module = {
|
|
4140
4145
|
command: "download [output]",
|
|
4141
4146
|
describe: "Download intent manifest",
|
|
@@ -4167,12 +4172,12 @@ var module = {
|
|
|
4167
4172
|
);
|
|
4168
4173
|
if (isLegacyApiKey) {
|
|
4169
4174
|
console.error(
|
|
4170
|
-
|
|
4175
|
+
yellow2(
|
|
4171
4176
|
"WARNING: you appear to be using a deprecated type of API key. Keys like this will stop working soon; please create new keys on uniform.app."
|
|
4172
4177
|
)
|
|
4173
4178
|
);
|
|
4174
4179
|
} else if (!project) {
|
|
4175
|
-
console.error(
|
|
4180
|
+
console.error(red5("You must specify the project ID"));
|
|
4176
4181
|
exit3(1);
|
|
4177
4182
|
}
|
|
4178
4183
|
const baseUrl = resolveBaseUrl();
|
|
@@ -4198,16 +4203,16 @@ var module = {
|
|
|
4198
4203
|
throw `${fetchResponse.status} ${fetchResponse.statusText}, content ${await fetchResponse.text()}`;
|
|
4199
4204
|
}
|
|
4200
4205
|
} catch (e) {
|
|
4201
|
-
console.error(
|
|
4202
|
-
console.error(
|
|
4206
|
+
console.error(red5(`\u26A0 Error fetching intent manifest ${manifestUrl}`));
|
|
4207
|
+
console.error(gray4(` \u2757 ${e}`));
|
|
4203
4208
|
exit3(1);
|
|
4204
4209
|
}
|
|
4205
4210
|
let json;
|
|
4206
4211
|
try {
|
|
4207
4212
|
json = await fetchResponse.json();
|
|
4208
4213
|
} catch (e) {
|
|
4209
|
-
console.error(
|
|
4210
|
-
console.error(
|
|
4214
|
+
console.error(red5(`\u26A0 Error parsing intent manifest ${manifestUrl}`));
|
|
4215
|
+
console.error(gray4(` \u2757 ${e}`));
|
|
4211
4216
|
console.error(`Response: ${await fetchResponse.text()}`);
|
|
4212
4217
|
exit3(1);
|
|
4213
4218
|
}
|
|
@@ -4219,7 +4224,7 @@ var module = {
|
|
|
4219
4224
|
`, error);
|
|
4220
4225
|
exit3(1);
|
|
4221
4226
|
}
|
|
4222
|
-
console.log(
|
|
4227
|
+
console.log(green3(`\u2705 ${output} has been updated from ${manifestUrl}`));
|
|
4223
4228
|
});
|
|
4224
4229
|
} else {
|
|
4225
4230
|
console.log(text);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/cli",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.11.0",
|
|
4
4
|
"description": "Uniform command line interface tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./cli.js",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@uniformdev/canvas": "19.
|
|
20
|
-
"@uniformdev/context": "19.
|
|
21
|
-
"@uniformdev/project-map": "19.
|
|
22
|
-
"@uniformdev/redirect": "19.
|
|
23
|
-
"
|
|
19
|
+
"@uniformdev/canvas": "19.11.0",
|
|
20
|
+
"@uniformdev/context": "19.11.0",
|
|
21
|
+
"@uniformdev/project-map": "19.11.0",
|
|
22
|
+
"@uniformdev/redirect": "19.11.0",
|
|
23
|
+
"ansi-colors": "^4.1.3",
|
|
24
24
|
"diff": "^5.0.0",
|
|
25
25
|
"dotenv": "^16.0.3",
|
|
26
26
|
"execa": "5.1.1",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"graphql": "16.6.0",
|
|
29
29
|
"graphql-request": "6.0.0",
|
|
30
30
|
"https-proxy-agent": "^5.0.1",
|
|
31
|
-
"inquirer": "9.2.
|
|
31
|
+
"inquirer": "9.2.3",
|
|
32
32
|
"isomorphic-git": "1.21.0",
|
|
33
33
|
"isomorphic-unfetch": "^3.1.0",
|
|
34
34
|
"js-yaml": "^4.1.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/js-yaml": "4.0.5",
|
|
48
48
|
"@types/jsonwebtoken": "9.0.2",
|
|
49
49
|
"@types/lodash.isequalwith": "4.4.7",
|
|
50
|
-
"@types/node": "18.16.
|
|
50
|
+
"@types/node": "18.16.9",
|
|
51
51
|
"@types/yargs": "17.0.24"
|
|
52
52
|
},
|
|
53
53
|
"bin": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "25d492fe923f313b517cbc70d3ff13fdcf97fa34"
|
|
63
63
|
}
|