@uniformdev/cli 19.9.2-alpha.3 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +37 -34
  2. package/package.json +8 -8
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((result, current) => {
25
- const rawIdentifiers = selectIdentifier12(current);
26
- const identifiers = Array.isArray(rawIdentifiers) ? rawIdentifiers : [rawIdentifiers];
27
- while (identifiers.length > 0) {
28
- const identifier = identifiers.pop();
29
- if (!identifier)
30
- continue;
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[identifier] = {
36
- id: identifier,
33
+ result[identifiers[0]] = {
34
+ id: identifiers,
37
35
  object: current,
38
- providerId: identifier,
36
+ providerId: identifiers[0],
39
37
  displayName: Array.isArray(displayName) ? displayName[0] : displayName
40
38
  };
41
- }
42
- return result;
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
- yield item;
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
- id.forEach((i) => objectIndex[i] = objectToWrite);
61
+ objectIndex[id[0]] = objectToWrite;
61
62
  } else {
62
63
  objectIndex[id] = objectToWrite;
63
64
  }
@@ -81,6 +82,9 @@ var omit = (object, keys) => {
81
82
  }, object);
82
83
  return result;
83
84
  };
85
+ var cleanFileName = (proposedFileName) => {
86
+ return proposedFileName.replace(/[/<>$+%>!`&*'|{}?"=:\\@]/g, "-");
87
+ };
84
88
 
85
89
  // src/sync/util.ts
86
90
  import { readFileSync, writeFileSync } from "fs";
@@ -240,10 +244,11 @@ async function createFileSyncEngineDataSource({
240
244
  for (const filename of filenames) {
241
245
  const fullFilename = join(directory, filename);
242
246
  try {
243
- const contents = await readFileToObject(fullFilename);
247
+ const contents = readFileToObject(fullFilename);
248
+ const displayName = selectDisplayName12(contents);
244
249
  const object = {
245
250
  id: selectIdentifier12(contents),
246
- displayName: selectDisplayName12(contents)[0],
251
+ displayName: Array.isArray(displayName) ? displayName[0] : displayName,
247
252
  providerId: fullFilename,
248
253
  object: omit(contents, ["$schema"])
249
254
  };
@@ -300,7 +305,7 @@ async function syncEngine({
300
305
  return isEqualWith(
301
306
  source2.object,
302
307
  target2.object,
303
- (_a, _b, key) => key === "created" || key === "modified" ? true : void 0
308
+ (_a, _b, key) => key === "created" || key === "modified" || key === "updated" ? true : void 0
304
309
  );
305
310
  },
306
311
  mode,
@@ -346,7 +351,7 @@ async function syncEngine({
346
351
  sourceHasItems = true;
347
352
  const ids = Array.isArray(sourceObject.id) ? sourceObject.id : [sourceObject.id];
348
353
  const targetObject = targetItems.get(ids[0]);
349
- 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));
350
355
  if (targetObject && invalidTargetObjects.length == 0) {
351
356
  if (!compareContents(sourceObject, targetObject)) {
352
357
  if (mode === "createOrUpdate" || mode === "mirror") {
@@ -390,12 +395,10 @@ async function syncEngine({
390
395
  });
391
396
  };
392
397
  if (invalidTargetObjects.length > 0) {
393
- [...invalidTargetObjects, targetObject].forEach(
394
- (o) => {
395
- var _a2;
396
- return (_a2 = o == null ? void 0 : o.id) == null ? void 0 : _a2.forEach((i) => targetItems.delete(i));
397
- }
398
- );
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
+ });
399
402
  const deletes = invalidTargetObjects.filter((io) => typeof io !== "undefined").map(async (io) => {
400
403
  await processDelete(io);
401
404
  });
@@ -3099,7 +3102,7 @@ import { PostHog } from "posthog-node";
3099
3102
  // package.json
3100
3103
  var package_default = {
3101
3104
  name: "@uniformdev/cli",
3102
- version: "19.9.1",
3105
+ version: "19.11.0",
3103
3106
  description: "Uniform command line interface tool",
3104
3107
  license: "SEE LICENSE IN LICENSE.txt",
3105
3108
  main: "./cli.js",
@@ -3127,7 +3130,7 @@ var package_default = {
3127
3130
  graphql: "16.6.0",
3128
3131
  "graphql-request": "6.0.0",
3129
3132
  "https-proxy-agent": "^5.0.1",
3130
- inquirer: "9.2.1",
3133
+ inquirer: "9.2.3",
3131
3134
  "isomorphic-git": "1.21.0",
3132
3135
  "isomorphic-unfetch": "^3.1.0",
3133
3136
  "js-yaml": "^4.1.0",
@@ -3146,7 +3149,7 @@ var package_default = {
3146
3149
  "@types/js-yaml": "4.0.5",
3147
3150
  "@types/jsonwebtoken": "9.0.2",
3148
3151
  "@types/lodash.isequalwith": "4.4.7",
3149
- "@types/node": "18.16.8",
3152
+ "@types/node": "18.16.9",
3150
3153
  "@types/yargs": "17.0.24"
3151
3154
  },
3152
3155
  bin: {
@@ -3675,7 +3678,7 @@ var query = gql`
3675
3678
  info: identities_by_pk(subject: $subject) {
3676
3679
  name
3677
3680
  email_address
3678
- teams: organizations_identities {
3681
+ teams: organizations_identities(order_by: { organization: { name: asc } }) {
3679
3682
  team: organization {
3680
3683
  name
3681
3684
  id
@@ -4598,7 +4601,7 @@ var selectIdentifier10 = (source, projectId) => [
4598
4601
  projectId + source.projectMapId + source.id,
4599
4602
  projectId + source.projectMapId + source.path
4600
4603
  ];
4601
- var selectFilename = (source) => `${source.pathSegment}_${source.id}`;
4604
+ var selectFilename = (source) => cleanFileName(`${source.pathSegment}_${source.id}`);
4602
4605
  var selectDisplayName10 = (source) => `${source.name} (pid: ${source.id})`;
4603
4606
 
4604
4607
  // src/commands/project-map/ProjectMapNodeEngineDataSource.ts
@@ -4912,7 +4915,7 @@ function writeContextPackage3(filename, packageContents) {
4912
4915
  var selectIdentifier11 = (source) => source.redirect.id;
4913
4916
  var selectFilename2 = (source) => {
4914
4917
  const index = source.redirect.sourceUrl.lastIndexOf("/");
4915
- return source.redirect.sourceUrl.substring(index + 1).replace(/[/<>$+%>!`&*'|{}?"=:\\@]/g, "-") + `_${source.redirect.id}`;
4918
+ return cleanFileName(source.redirect.sourceUrl.substring(index + 1)) + `_${source.redirect.id}`;
4916
4919
  };
4917
4920
  var selectDisplayName11 = (source) => {
4918
4921
  let pathName = source.redirect.sourceUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "19.9.2-alpha.3+547c8b11d",
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,10 +16,10 @@
16
16
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
17
17
  },
18
18
  "dependencies": {
19
- "@uniformdev/canvas": "19.9.2-alpha.3+547c8b11d",
20
- "@uniformdev/context": "19.9.2-alpha.3+547c8b11d",
21
- "@uniformdev/project-map": "19.9.2-alpha.3+547c8b11d",
22
- "@uniformdev/redirect": "19.9.2-alpha.3+547c8b11d",
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
23
  "ansi-colors": "^4.1.3",
24
24
  "diff": "^5.0.0",
25
25
  "dotenv": "^16.0.3",
@@ -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.1",
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.8",
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": "547c8b11d4655b34250c2fbe3f016c9bc12c3905"
62
+ "gitHead": "25d492fe923f313b517cbc70d3ff13fdcf97fa34"
63
63
  }