yargs-file-commands 0.0.13 → 0.0.15

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/CHANGELOG.md CHANGED
@@ -1,42 +1,52 @@
1
1
  # yargs-file-commands
2
2
 
3
- ## 0.0.13
3
+ ## 0.0.15
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - Throw if a command exports unrecognized names, catches a lot of bugs.
7
8
  - More explicit exceptions when bad parameters are passed in
8
9
  - Validate that provided command directories are aboslute
9
10
  - More robust parameter checking and logging
10
11
  - Improved debugging logging
11
12
  - More robust debug messages
12
13
 
13
- ## 0.0.12
14
+ ## 0.0.14
14
15
 
15
16
  ### Patch Changes
16
17
 
17
18
  - More explicit exceptions when bad parameters are passed in
19
+ - Validate that provided command directories are aboslute
18
20
  - More robust parameter checking and logging
19
21
  - Improved debugging logging
20
22
  - More robust debug messages
21
23
 
24
+ ## 0.0.13
25
+
26
+ ### Patch Changes
27
+
28
+ - Validate that provided command directories are aboslute
29
+
30
+ ## 0.0.12
31
+
32
+ ### Patch Changes
33
+
34
+ - More robust parameter checking and logging
35
+
22
36
  ## 0.0.11
23
37
 
24
38
  ### Patch Changes
25
39
 
26
40
  - More explicit exceptions when bad parameters are passed in
27
- - Improved debugging logging
28
- - More robust debug messages
29
41
 
30
42
  ## 0.0.10
31
43
 
32
44
  ### Patch Changes
33
45
 
34
46
  - Improved debugging logging
35
- - More robust debug messages
36
47
 
37
48
  ## 0.0.9
38
49
 
39
50
  ### Patch Changes
40
51
 
41
- - Improved debugging logging
42
52
  - More robust debug messages
@@ -29,6 +29,18 @@ export const importCommandFromFile = async (filePath, name, options) => {
29
29
  // null implementation
30
30
  })
31
31
  };
32
+ const supportedNames = [
33
+ 'describe',
34
+ 'alias',
35
+ 'builder',
36
+ 'deprecated',
37
+ 'handler'
38
+ ];
39
+ const module = handlerModule;
40
+ const unsupportedExports = Object.keys(module).filter((key) => !supportedNames.includes(key));
41
+ if (unsupportedExports.length > 0) {
42
+ throw new Error(`Command module ${name} in ${filePath} has some unsupported exports, probably a misspelling: ${unsupportedExports.join(', ')}`);
43
+ }
32
44
  if (logLevel === 'debug') {
33
45
  console.debug('Importing command from', filePath, 'as', name, 'with description', command.describe);
34
46
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yargs-file-commands",
3
3
  "description": "A yargs helper function that lets you define your commands structure via directory and file naming conventions.",
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -55,7 +55,6 @@
55
55
  "typecheck": "tsc --noEmit",
56
56
  "test": "tsc && node --test dist/**/*.test.js --test-concurrency=1",
57
57
  "lint": "eslint --fix \"src/**/*.{ts,tsx}\"",
58
- "format": "prettier \"src/**/*.{js,jsx,css,md,html,ts,tsx,json,yaml}\" --check",
59
- "prePublishOnly": "pnpm build && pnpm test"
58
+ "format": "prettier \"src/**/*.{js,jsx,css,md,html,ts,tsx,json,yaml}\" --check"
60
59
  }
61
60
  }
@@ -108,6 +108,25 @@ export const importCommandFromFile = async (
108
108
  })
109
109
  } as CommandModule;
110
110
 
111
+ const supportedNames = [
112
+ 'describe',
113
+ 'alias',
114
+ 'builder',
115
+ 'deprecated',
116
+ 'handler'
117
+ ];
118
+ const module = handlerModule as Record<string, any>;
119
+ const unsupportedExports = Object.keys(module).filter(
120
+ (key) => !supportedNames.includes(key)
121
+ );
122
+ if (unsupportedExports.length > 0) {
123
+ throw new Error(
124
+ `Command module ${name} in ${filePath} has some unsupported exports, probably a misspelling: ${unsupportedExports.join(
125
+ ', '
126
+ )}`
127
+ );
128
+ }
129
+
111
130
  if (logLevel === 'debug') {
112
131
  console.debug(
113
132
  'Importing command from',
@@ -118,5 +137,6 @@ export const importCommandFromFile = async (
118
137
  command.describe
119
138
  );
120
139
  }
140
+
121
141
  return command;
122
142
  };