@uniformdev/cli 18.24.1-alpha.1 → 18.26.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 +43 -15
  2. package/package.json +7 -7
package/dist/index.mjs CHANGED
@@ -88,6 +88,15 @@ import { existsSync, mkdirSync } from "fs";
88
88
  import { readdir, unlink } from "fs/promises";
89
89
  import { extname as extname2, join } from "path";
90
90
 
91
+ // src/util.ts
92
+ var omit = (object, keys) => {
93
+ const result = keys.reduce((current, key) => {
94
+ const { [key]: _, ...rest } = current;
95
+ return rest;
96
+ }, object);
97
+ return result;
98
+ };
99
+
91
100
  // src/sync/util.ts
92
101
  import { readFileSync, writeFileSync } from "fs";
93
102
  import httpsProxyAgent from "https-proxy-agent";
@@ -189,6 +198,10 @@ function emitWithFormat(object, format, filename) {
189
198
  break;
190
199
  case "yaml":
191
200
  content = dump(object);
201
+ if ("$schema" in object) {
202
+ content = `# yaml-language-server: $schema=<${object["$schema"]}>
203
+ ${content}`;
204
+ }
192
205
  break;
193
206
  default:
194
207
  throw new Error(`Unsupported format: ${format}`);
@@ -222,7 +235,8 @@ async function createFileSyncEngineDataSource({
222
235
  format = "yaml",
223
236
  selectIdentifier: selectIdentifier11,
224
237
  selectDisplayName: selectDisplayName11 = selectIdentifier11,
225
- selectFilename: selectFilename2
238
+ selectFilename: selectFilename2,
239
+ selectSchemaUrl: selectSchemaUrl2
226
240
  }) {
227
241
  const dirExists = existsSync(directory);
228
242
  if (!dirExists) {
@@ -245,7 +259,7 @@ async function createFileSyncEngineDataSource({
245
259
  id: selectIdentifier11(contents),
246
260
  displayName: selectDisplayName11(contents),
247
261
  providerId: fullFilename,
248
- object: contents
262
+ object: omit(contents, ["$schema"])
249
263
  };
250
264
  yield object;
251
265
  } catch (e) {
@@ -261,11 +275,15 @@ ${e == null ? void 0 : e.message}`));
261
275
  await unlink(providerId);
262
276
  },
263
277
  writeObject: async (object) => {
264
- if (selectFilename2) {
265
- emitWithFormat(object.object, format, join(directory, `${selectFilename2(object.object)}.${format}`));
266
- } else {
267
- emitWithFormat(object.object, format, getFullFilename(object.id));
278
+ const filename = selectFilename2 ? join(directory, `${selectFilename2(object.object)}.${format}`) : getFullFilename(object.id);
279
+ let contents = object.object;
280
+ if (selectSchemaUrl2) {
281
+ contents = {
282
+ $schema: selectSchemaUrl2(object.object),
283
+ ...object.object
284
+ };
268
285
  }
286
+ emitWithFormat(contents, format, filename);
269
287
  }
270
288
  };
271
289
  }
@@ -440,6 +458,11 @@ function createSyncEngineConsoleLogger(options) {
440
458
  };
441
459
  }
442
460
 
461
+ // src/commands/canvas/commands/component/_util.ts
462
+ var selectIdentifier = (component) => component.id;
463
+ var selectDisplayName = (component) => `${component.name} (pid: ${component.id})`;
464
+ var selectSchemaUrl = () => "/schemas/json-schema/component-definition/v1.json";
465
+
443
466
  // src/commands/canvas/commands/component/get.ts
444
467
  var ComponentGetModule = {
445
468
  command: "get <id>",
@@ -459,7 +482,14 @@ var ComponentGetModule = {
459
482
  console.error("Component did not exist");
460
483
  process.exit(1);
461
484
  } else {
462
- emitWithFormat(res.componentDefinitions[0], format, filename);
485
+ emitWithFormat(
486
+ {
487
+ $schema: new URL(selectSchemaUrl(), apiHost).toString(),
488
+ ...res.componentDefinitions[0]
489
+ },
490
+ format,
491
+ filename
492
+ );
463
493
  }
464
494
  }
465
495
  };
@@ -491,10 +521,6 @@ var ComponentListModule = {
491
521
  // src/commands/canvas/commands/component/pull.ts
492
522
  import { UncachedCanvasClient as UncachedCanvasClient3 } from "@uniformdev/canvas";
493
523
 
494
- // src/commands/canvas/commands/component/_util.ts
495
- var selectIdentifier = (component) => component.id;
496
- var selectDisplayName = (component) => `${component.name} (pid: ${component.id})`;
497
-
498
524
  // src/commands/canvas/componentDefinitionEngineDataSource.ts
499
525
  function createComponentDefinitionEngineDataSource({
500
526
  client
@@ -740,6 +766,7 @@ var ComponentPullModule = {
740
766
  directory,
741
767
  selectIdentifier,
742
768
  selectDisplayName,
769
+ selectSchemaUrl: () => new URL(selectSchemaUrl(), apiHost).toString(),
743
770
  format
744
771
  });
745
772
  }
@@ -804,7 +831,8 @@ var ComponentPushModule = {
804
831
  source = await createFileSyncEngineDataSource({
805
832
  directory,
806
833
  selectIdentifier,
807
- selectDisplayName
834
+ selectDisplayName,
835
+ selectSchemaUrl
808
836
  });
809
837
  }
810
838
  const target = createComponentDefinitionEngineDataSource({ client });
@@ -3162,7 +3190,7 @@ import { PostHog } from "posthog-node";
3162
3190
  // package.json
3163
3191
  var package_default = {
3164
3192
  name: "@uniformdev/cli",
3165
- version: "18.24.0",
3193
+ version: "18.26.0",
3166
3194
  description: "Uniform command line interface tool",
3167
3195
  license: "SEE LICENSE IN LICENSE.txt",
3168
3196
  main: "./cli.js",
@@ -3208,8 +3236,8 @@ var package_default = {
3208
3236
  "@types/js-yaml": "4.0.5",
3209
3237
  "@types/jsonwebtoken": "9.0.1",
3210
3238
  "@types/lodash.isequalwith": "4.4.7",
3211
- "@types/node": "18.15.2",
3212
- "@types/yargs": "17.0.22",
3239
+ "@types/node": "18.15.5",
3240
+ "@types/yargs": "17.0.23",
3213
3241
  "p-limit": "4.0.0"
3214
3242
  },
3215
3243
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "18.24.1-alpha.1+65e77b560",
3
+ "version": "18.26.0",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -16,9 +16,9 @@
16
16
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
17
17
  },
18
18
  "dependencies": {
19
- "@uniformdev/canvas": "18.24.1-alpha.1+65e77b560",
20
- "@uniformdev/context": "18.24.1-alpha.1+65e77b560",
21
- "@uniformdev/project-map": "18.24.1-alpha.1+65e77b560",
19
+ "@uniformdev/canvas": "18.26.0",
20
+ "@uniformdev/context": "18.26.0",
21
+ "@uniformdev/project-map": "18.26.0",
22
22
  "chalk": "^5.2.0",
23
23
  "diff": "^5.0.0",
24
24
  "dotenv": "^16.0.3",
@@ -46,8 +46,8 @@
46
46
  "@types/js-yaml": "4.0.5",
47
47
  "@types/jsonwebtoken": "9.0.1",
48
48
  "@types/lodash.isequalwith": "4.4.7",
49
- "@types/node": "18.15.2",
50
- "@types/yargs": "17.0.22",
49
+ "@types/node": "18.15.5",
50
+ "@types/yargs": "17.0.23",
51
51
  "p-limit": "4.0.0"
52
52
  },
53
53
  "bin": {
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "gitHead": "65e77b56039b0c688518358a8402acd84686e9e0"
62
+ "gitHead": "776654d5b12c24cf597acd66cde039d6b0111419"
63
63
  }