b-gsdk 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -45,7 +45,18 @@ async function main() {
45
45
  createDirIfDoesNotExist(`${bgsdkDirectoryPath}/generated`);
46
46
  fs_1.default.writeFileSync(path_1.default.join(bgsdkDirectoryPath, "generated/graphql.schema.json"), schemaCodegen.content);
47
47
  fs_1.default.writeFileSync(path_1.default.join(bgsdkDirectoryPath, "generated/index.ts"), sdkCodegen.content);
48
- fs_1.default.writeFileSync(path_1.default.join(bgsdkDirectoryPath, "sdk.ts"), sdkFileContents);
48
+ const skdFilePath = path_1.default.join(bgsdkDirectoryPath, "sdk.ts");
49
+ if (!fs_1.default.existsSync(skdFilePath)) {
50
+ fs_1.default.writeFileSync(skdFilePath, sdkFileContents);
51
+ }
52
+ const gitignorePath = path_1.default.join(process.cwd(), ".gitignore");
53
+ if (fs_1.default.existsSync(gitignorePath)) {
54
+ const gitignore = fs_1.default.readFileSync(gitignorePath, "utf8");
55
+ if (!gitignore.includes("generated")) {
56
+ fs_1.default.appendFileSync(gitignorePath, "\ngenerated/");
57
+ console.log('Added "generated/" to .gitignore');
58
+ }
59
+ }
49
60
  console.log("Done ✨");
50
61
  }
51
62
  exports.main = main;
@@ -75,4 +86,9 @@ export const createBGsdk = ({ endpoint, headers }: CreateBGsdkClientParams) => {
75
86
 
76
87
  return { ...generatedSdk, rawClient: graphQLClient }
77
88
  }
89
+
90
+ // You can then create the sdk with the endpoint and headers set up and export it.
91
+ // For example like this:
92
+ // export const bgsdk = createBGsdk({ })
93
+
78
94
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b-gsdk",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A GraphQL Codegen that outputs a TypeScript SDK.",
5
5
  "author": "Julian Benegas",
6
6
  "license": "MIT",
@@ -8,7 +8,6 @@
8
8
  "bin": "dist/bin.js",
9
9
  "dependencies": {
10
10
  "@graphql-codegen/cli": "^2.6.2",
11
- "@graphql-codegen/core": "^2.5.1",
12
11
  "@graphql-codegen/introspection": "^2.1.0",
13
12
  "@graphql-codegen/typescript": "^2.4.1",
14
13
  "@graphql-codegen/typescript-graphql-request": "^4.3.2",
package/src/index.ts CHANGED
@@ -55,7 +55,20 @@ export async function main() {
55
55
  path.join(bgsdkDirectoryPath, "generated/index.ts"),
56
56
  sdkCodegen.content
57
57
  );
58
- fs.writeFileSync(path.join(bgsdkDirectoryPath, "sdk.ts"), sdkFileContents);
58
+ const skdFilePath = path.join(bgsdkDirectoryPath, "sdk.ts");
59
+ if (!fs.existsSync(skdFilePath)) {
60
+ fs.writeFileSync(skdFilePath, sdkFileContents);
61
+ }
62
+
63
+ const gitignorePath = path.join(process.cwd(), ".gitignore");
64
+ if (fs.existsSync(gitignorePath)) {
65
+ const gitignore = fs.readFileSync(gitignorePath, "utf8");
66
+ if (!gitignore.includes("generated")) {
67
+ fs.appendFileSync(gitignorePath, "\ngenerated/");
68
+ console.log('Added "generated/" to .gitignore');
69
+ }
70
+ }
71
+
59
72
  console.log("Done ✨");
60
73
  }
61
74
 
@@ -86,4 +99,9 @@ export const createBGsdk = ({ endpoint, headers }: CreateBGsdkClientParams) => {
86
99
 
87
100
  return { ...generatedSdk, rawClient: graphQLClient }
88
101
  }
102
+
103
+ // You can then create the sdk with the endpoint and headers set up and export it.
104
+ // For example like this:
105
+ // export const bgsdk = createBGsdk({ })
106
+
89
107
  `;