@gapi/gcli 1.8.134 → 1.8.136

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.
@@ -3,6 +3,13 @@
3
3
  "editor.codeActionsOnSave": {
4
4
  "source.fixAll.eslint": true
5
5
  },
6
+ "editor.formatOnSave": true,
7
+ "[javascript]": {
8
+ "editor.formatOnSave": false
9
+ },
10
+ "[typescript]": {
11
+ "editor.formatOnSave": false
12
+ },
6
13
  "files.exclude": {
7
14
  "**/.classpath": true,
8
15
  "**/.factorypath": true,
@@ -13,4 +20,4 @@
13
20
  "**/*.d.ts": false,
14
21
  "**/*.map": true
15
22
  }
16
- }
23
+ }
package/README.md CHANGED
@@ -120,3 +120,11 @@ gcli lambda:get
120
120
  ```bash
121
121
  gcli lambda:test --queryParams '?test=1&proba=1&dada=5' --pathParams 'proba=5;test=7'
122
122
  ```
123
+
124
+ #### Default long lived token for CI/CD using github actions
125
+
126
+ Can be set using environment variable called `GCLI_AUTH_TOKEN`
127
+
128
+ ```
129
+ export GCLI_AUTH_TOKEN='my-generated-token'
130
+ ```
package/build.js ADDED
@@ -0,0 +1,21 @@
1
+ const dotenvLoad = require('dotenv-load');
2
+ dotenvLoad(process.env.NODE_ENV);
3
+
4
+ require('esbuild')
5
+ .build({
6
+ entryPoints: ['./src/main.ts'],
7
+ bundle: true,
8
+ platform: 'node',
9
+ target: 'node14.4',
10
+ outfile: './release/index.js',
11
+ define: {
12
+ 'process.env.MONGODB_URI': `'${process.env.MONGODB_URI}'`,
13
+ 'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
14
+ 'process.env.PORT': `9000`,
15
+ },
16
+ })
17
+ .then((data) => console.log('SUCCESS', data))
18
+ .catch((e) => {
19
+ console.error(e);
20
+ process.exit(1);
21
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/gcli",
3
- "version": "1.8.134",
3
+ "version": "1.8.136",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/gapi.git"
@@ -15,6 +15,7 @@
15
15
  "lint-fix": "npx eslint . --fix --ext .ts",
16
16
  "build:release": "gapi build --single-executable && cp ./dist/gcli-linux ./release && cp ./dist/index.js ./release",
17
17
  "build": "echo BUILD",
18
+ "esbuild": "node build.js",
18
19
  "introspect": "gapi schema introspect --collect-documents --collect-types"
19
20
  },
20
21
  "author": {
@@ -59,7 +60,9 @@
59
60
  "node-fetch": "^2.1.2",
60
61
  "rxjs": "6.5.2",
61
62
  "stream-to-buffer": "^0.1.0",
62
- "@rxdi/compressor": "^0.7.136"
63
+ "@rxdi/compressor": "^0.7.136",
64
+ "dotenv-load": "^2.0.1",
65
+ "esbuild": "0.15.18"
63
66
  },
64
67
  "bin": {
65
68
  "gcli": "./release/index.js"
package/release/index.js CHANGED
@@ -16750,6 +16750,7 @@ function registerAuthCommands(program) {
16750
16750
  .description('Login to graphql-server')
16751
16751
  .option('-k, --key <key>', 'Specify api key')
16752
16752
  .option('-uu, --uploadUrl <key>', 'Specify upload server')
16753
+ .option('-i, --integration <key>', 'Initialize directories for CI/CD purposes')
16753
16754
  .option('-t, --token <token>', 'Specify custom token generated from the website')
16754
16755
  .option('-u, --url <url>', 'Specify api url')
16755
16756
  .action(helpers_1.lazy(() => Promise.resolve().then(() => __webpack_require__(875)).then((m) => m.default)));
@@ -44629,23 +44630,26 @@ function gql(...args) {
44629
44630
  exports.gql = gql;
44630
44631
  class GraphqlClienAPI {
44631
44632
  static query({ query, variables, }) {
44632
- return this.getConfig().pipe(operators_1.switchMap(({ token, url }) => rxjs_1.from(fetch(url, {
44633
- method: 'POST',
44634
- headers: {
44635
- 'Content-Type': 'application/json',
44636
- authorization: token,
44637
- Accept: 'application/json',
44638
- },
44639
- body: JSON.stringify({ query, variables }),
44640
- })).pipe(operators_1.switchMap((res) => res.json()), operators_1.map(({ data, errors }) => {
44641
- if (errors === null || errors === void 0 ? void 0 : errors.length) {
44642
- throw new Error(JSON.stringify(errors, null, 2));
44643
- }
44644
- if (!data) {
44645
- throw new Error('missing-entry');
44646
- }
44647
- return data;
44648
- }))));
44633
+ return this.getConfig().pipe(operators_1.switchMap(({ token, url }) => {
44634
+ var _a;
44635
+ return rxjs_1.from(fetch(url, {
44636
+ method: 'POST',
44637
+ headers: {
44638
+ 'Content-Type': 'application/json',
44639
+ authorization: (_a = process.env.GCLI_AUTH_TOKEN) !== null && _a !== void 0 ? _a : token,
44640
+ Accept: 'application/json',
44641
+ },
44642
+ body: JSON.stringify({ query, variables }),
44643
+ })).pipe(operators_1.switchMap((res) => res.json()), operators_1.map(({ data, errors }) => {
44644
+ if (errors === null || errors === void 0 ? void 0 : errors.length) {
44645
+ throw new Error(JSON.stringify(errors, null, 2));
44646
+ }
44647
+ if (!data) {
44648
+ throw new Error('missing-entry');
44649
+ }
44650
+ return data;
44651
+ }));
44652
+ }));
44649
44653
  }
44650
44654
  static getLambda(lambdaId, fragments) {
44651
44655
  return this.query({
@@ -54510,14 +54514,23 @@ exports.default = (cmd) => rxjs_1.of(gql_client_1.GraphqlClienAPI.init(cmd.key))
54510
54514
  encoding: 'utf-8',
54511
54515
  }),
54512
54516
  ])))
54513
- .pipe(operators_1.switchMap(() => gql_client_1.GraphqlClienAPI.signIn(cmd.token).toPromise()), operators_1.switchMap(({ user, refresh, token }) => rxjs_1.combineLatest([
54517
+ .pipe(operators_1.switchMap(() => cmd.integration
54518
+ ? rxjs_1.of({
54519
+ user: {
54520
+ displayName: 'Integration Account for CI/CD',
54521
+ email: 'support@graphql-server.com',
54522
+ },
54523
+ refresh: '',
54524
+ token: '',
54525
+ })
54526
+ : gql_client_1.GraphqlClienAPI.signIn(cmd.token).toPromise()), operators_1.switchMap(({ user, refresh, token }) => rxjs_1.combineLatest([
54514
54527
  util_1.promisify(fs_1.writeFile)(types_1.tokenDirectory, token, {
54515
54528
  encoding: 'utf-8',
54516
54529
  }),
54517
54530
  util_1.promisify(fs_1.writeFile)(types_1.refreshTokenDirectory, refresh, {
54518
54531
  encoding: 'utf-8',
54519
54532
  }),
54520
- ]).pipe(operators_1.map(() => user))), operators_1.tap((user) => console.log('Logged in as', `"${user.displayName}"`, 'with email', `"${user.email}"`)))))
54533
+ ]).pipe(operators_1.map(() => user))), operators_1.tap((user) => console.log('Logged in as', `"${user === null || user === void 0 ? void 0 : user.displayName}"`, 'with email', `"${user === null || user === void 0 ? void 0 : user.email}"`)))))
54521
54534
  .toPromise();
54522
54535
 
54523
54536