@contello/client 1.0.1 → 1.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2026 entwico GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
  var command = process.argv[2];
5
5
  switch (command) {
6
6
  case "generate":
7
- await import("./generate-QAYD35FG.js");
7
+ await import("./generate-KEYVGQHL.js");
8
8
  break;
9
9
  default:
10
10
  console.error(command ? `unknown command: ${command}` : "usage: contello-client <command>");
@@ -3,7 +3,7 @@
3
3
  // src/generate/index.ts
4
4
  import { mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
5
5
  import { glob } from "fs/promises";
6
- import { dirname, resolve as resolve2 } from "path";
6
+ import { dirname, relative, resolve as resolve2 } from "path";
7
7
  import { parse as parse2 } from "graphql";
8
8
 
9
9
  // src/generate/config.ts
@@ -764,23 +764,33 @@ function transformFragment(schema, fragment, fragments) {
764
764
  }
765
765
 
766
766
  // src/generate/index.ts
767
+ var ctrlSeq = "\x1B[";
768
+ var styled = (s, pre, post) => `${ctrlSeq}${pre}${s}${ctrlSeq}${post}`;
769
+ var dim = (s) => styled(s, "2m", "22m");
770
+ var bold = (s) => styled(s, "1m", "22m");
771
+ var green = (s) => styled(s, "32m", "39m");
772
+ var yellow = (s) => styled(s, "33m", "39m");
773
+ var cyan = (s) => styled(s, "36m", "39m");
767
774
  async function main() {
768
775
  const cwd = process.cwd();
769
776
  const config = await loadConfig(cwd);
777
+ console.log("");
778
+ console.log(`${bold("@contello/client")} ${dim("generate")}`);
779
+ console.log("");
770
780
  for (const project of config.projects) {
771
- console.log(`generating types for project "${project.project}"...`);
781
+ const start = performance.now();
782
+ console.log(`${cyan("\u25CF")} ${bold(project.project)}`);
772
783
  rmSync(resolve2(cwd, project.output), { force: true });
773
784
  const schema = await introspectSchema(project.url, project.project, project.token);
774
785
  const patterns = Array.isArray(project.documents) ? project.documents : [project.documents];
775
786
  const documentPaths = (await Promise.all(patterns.map((p) => Array.fromAsync(glob(p, { cwd }))))).flat().sort();
776
787
  if (documentPaths.length === 0) {
777
- console.warn(` no documents found matching "${project.documents}"`);
788
+ console.warn(` ${yellow("\u26A0")} no documents found matching "${project.documents}"`);
778
789
  continue;
779
790
  }
780
791
  const documents = documentPaths.map((p) => parse2(readFileSync(resolve2(cwd, p), "utf-8")));
781
792
  const fragments = collectFragments(documents);
782
793
  const operations = collectOperations(documents);
783
- console.log(` found ${operations.length} operations, ${fragments.size} fragments`);
784
794
  const transformedFragments = new Map(
785
795
  [...fragments].map(([name, frag]) => [name, transformFragment(schema, frag, fragments)])
786
796
  );
@@ -811,9 +821,11 @@ ${indented}
811
821
  const outputPath = resolve2(cwd, project.output);
812
822
  mkdirSync(dirname(outputPath), { recursive: true });
813
823
  writeFileSync(outputPath, output, "utf-8");
814
- console.log(` wrote ${outputPath}`);
824
+ const elapsed = Math.round(performance.now() - start);
825
+ console.log(` ${green("\u2713")} ${relative(cwd, outputPath)} ${dim(`${elapsed}ms`)}`);
826
+ console.log(` ${dim("operations")} ${operations.length} ${dim("fragments")} ${fragments.size}`);
827
+ console.log("");
815
828
  }
816
- console.log("done");
817
829
  }
818
830
  main().catch((err) => {
819
831
  console.error(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contello/client",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "GraphQL client for Contello CMS with WebSocket transport, connection pooling, and built-in codegen",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,12 +10,6 @@
10
10
  "url": "https://github.com/entwico/contello-js",
11
11
  "directory": "packages/client"
12
12
  },
13
- "scripts": {
14
- "build": "tsup",
15
- "lint": "eslint .",
16
- "lint:fix": "eslint . --fix",
17
- "typecheck": "tsc --noEmit"
18
- },
19
13
  "dependencies": {
20
14
  "graphql": "^16.13.1",
21
15
  "graphql-ws": "^6.0.7"
@@ -42,5 +36,11 @@
42
36
  "publishConfig": {
43
37
  "access": "public",
44
38
  "registry": "https://registry.npmjs.org"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "lint": "eslint .",
43
+ "lint:fix": "eslint . --fix",
44
+ "typecheck": "tsc --noEmit"
45
45
  }
46
- }
46
+ }