@graphql-codegen/cli 2.13.5 → 2.13.7-alpha-20221013153308-fa93b73b2

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/cjs/hooks.js CHANGED
@@ -4,6 +4,7 @@ exports.lifecycleHooks = void 0;
4
4
  const debugging_js_1 = require("./utils/debugging.js");
5
5
  const child_process_1 = require("child_process");
6
6
  const path_1 = require("path");
7
+ const shell_quote_1 = require("shell-quote");
7
8
  const DEFAULT_HOOKS = {
8
9
  afterStart: [],
9
10
  beforeDone: [],
@@ -63,10 +64,11 @@ function execShellCommand(cmd) {
63
64
  }
64
65
  async function executeHooks(hookName, scripts = [], args = []) {
65
66
  (0, debugging_js_1.debugLog)(`Running lifecycle hook "${hookName}" scripts...`);
67
+ const quotedArgs = (0, shell_quote_1.quote)(args);
66
68
  for (const script of scripts) {
67
69
  if (typeof script === 'string') {
68
- (0, debugging_js_1.debugLog)(`Running lifecycle hook "${hookName}" script: ${script} with args: ${args.join(' ')}...`);
69
- await execShellCommand(`${script} ${args.join(' ')}`);
70
+ (0, debugging_js_1.debugLog)(`Running lifecycle hook "${hookName}" script: ${script} with args: ${quotedArgs}...`);
71
+ await execShellCommand(`${script} ${quotedArgs}`);
70
72
  }
71
73
  else {
72
74
  (0, debugging_js_1.debugLog)(`Running lifecycle hook "${hookName}" script: ${script.name} with args: ${args.join(' ')}...`);
@@ -79,7 +81,7 @@ const lifecycleHooks = (_hooks = {}) => {
79
81
  return {
80
82
  afterStart: async () => executeHooks('afterStart', hooks.afterStart),
81
83
  onWatchTriggered: async (event, path) => executeHooks('onWatchTriggered', hooks.onWatchTriggered, [event, path]),
82
- onError: async (error) => executeHooks('onError', hooks.onError, [`"${error}"`]),
84
+ onError: async (error) => executeHooks('onError', hooks.onError, [error]),
83
85
  afterOneFileWrite: async (path) => executeHooks('afterOneFileWrite', hooks.afterOneFileWrite, [path]),
84
86
  afterAllFileWrite: async (paths) => executeHooks('afterAllFileWrite', hooks.afterAllFileWrite, paths),
85
87
  beforeOneFileWrite: async (path) => executeHooks('beforeOneFileWrite', hooks.beforeOneFileWrite, [path]),
@@ -67,7 +67,11 @@ function getQuestions(possibleTargets) {
67
67
  type: 'input',
68
68
  name: 'config',
69
69
  message: 'How to name the config file?',
70
- default: answers => answers.targets.includes(types_js_1.Tags.client) || answers.targets.includes(types_js_1.Tags.angular) ? 'codegen.ts' : 'codegen.yml',
70
+ default: answers => answers.targets.includes(types_js_1.Tags.client) ||
71
+ answers.targets.includes(types_js_1.Tags.typescript) ||
72
+ answers.targets.includes(types_js_1.Tags.angular)
73
+ ? 'codegen.ts'
74
+ : 'codegen.yml',
71
75
  validate: (str) => {
72
76
  const isNotEmpty = str.length > 0;
73
77
  const hasCorrectExtension = ['json', 'yml', 'yaml', 'js', 'ts'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
package/esm/hooks.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { debugLog } from './utils/debugging.js';
2
2
  import { exec } from 'child_process';
3
3
  import { delimiter, sep } from 'path';
4
+ import { quote } from 'shell-quote';
4
5
  const DEFAULT_HOOKS = {
5
6
  afterStart: [],
6
7
  beforeDone: [],
@@ -60,10 +61,11 @@ function execShellCommand(cmd) {
60
61
  }
61
62
  async function executeHooks(hookName, scripts = [], args = []) {
62
63
  debugLog(`Running lifecycle hook "${hookName}" scripts...`);
64
+ const quotedArgs = quote(args);
63
65
  for (const script of scripts) {
64
66
  if (typeof script === 'string') {
65
- debugLog(`Running lifecycle hook "${hookName}" script: ${script} with args: ${args.join(' ')}...`);
66
- await execShellCommand(`${script} ${args.join(' ')}`);
67
+ debugLog(`Running lifecycle hook "${hookName}" script: ${script} with args: ${quotedArgs}...`);
68
+ await execShellCommand(`${script} ${quotedArgs}`);
67
69
  }
68
70
  else {
69
71
  debugLog(`Running lifecycle hook "${hookName}" script: ${script.name} with args: ${args.join(' ')}...`);
@@ -76,7 +78,7 @@ export const lifecycleHooks = (_hooks = {}) => {
76
78
  return {
77
79
  afterStart: async () => executeHooks('afterStart', hooks.afterStart),
78
80
  onWatchTriggered: async (event, path) => executeHooks('onWatchTriggered', hooks.onWatchTriggered, [event, path]),
79
- onError: async (error) => executeHooks('onError', hooks.onError, [`"${error}"`]),
81
+ onError: async (error) => executeHooks('onError', hooks.onError, [error]),
80
82
  afterOneFileWrite: async (path) => executeHooks('afterOneFileWrite', hooks.afterOneFileWrite, [path]),
81
83
  afterAllFileWrite: async (paths) => executeHooks('afterAllFileWrite', hooks.afterAllFileWrite, paths),
82
84
  beforeOneFileWrite: async (path) => executeHooks('beforeOneFileWrite', hooks.beforeOneFileWrite, [path]),
@@ -64,7 +64,11 @@ export function getQuestions(possibleTargets) {
64
64
  type: 'input',
65
65
  name: 'config',
66
66
  message: 'How to name the config file?',
67
- default: answers => answers.targets.includes(Tags.client) || answers.targets.includes(Tags.angular) ? 'codegen.ts' : 'codegen.yml',
67
+ default: answers => answers.targets.includes(Tags.client) ||
68
+ answers.targets.includes(Tags.typescript) ||
69
+ answers.targets.includes(Tags.angular)
70
+ ? 'codegen.ts'
71
+ : 'codegen.yml',
68
72
  validate: (str) => {
69
73
  const isNotEmpty = str.length > 0;
70
74
  const hasCorrectExtension = ['json', 'yml', 'yaml', 'js', 'ts'].some(ext => str.toLocaleLowerCase().endsWith(`.${ext}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.13.5",
3
+ "version": "2.13.7-alpha-20221013153308-fa93b73b2",
4
4
  "peerDependencies": {
5
5
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
6
6
  },
@@ -35,6 +35,7 @@
35
35
  "listr2": "^4.0.5",
36
36
  "log-symbols": "^4.0.0",
37
37
  "mkdirp": "^1.0.4",
38
+ "shell-quote": "^1.7.3",
38
39
  "string-env-interpolation": "^1.0.1",
39
40
  "ts-log": "^2.2.3",
40
41
  "tslib": "^2.4.0",