@toptal/davinci-cli-shared 2.3.1-alpha-CRT-5891-create-coverage-command-3e3ae146.46 → 2.3.1

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,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2021](https://github.com/toptal/davinci/pull/2021) [`97abce92`](https://github.com/toptal/davinci/commit/97abce922d3a0720e0806ae9cd2f2866f355a1bc) Thanks [@dmaklygin](https://github.com/dmaklygin)!
8
+
9
+ ---
10
+
11
+ - remove legacy command builder
12
+
3
13
  ## 2.3.0
4
14
 
5
15
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-cli-shared",
3
- "version": "2.3.1-alpha-CRT-5891-create-coverage-command-3e3ae146.46+3e3ae146",
3
+ "version": "2.3.1",
4
4
  "description": "Shared CLI code and CLI engine for davinci",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,21 +23,20 @@
23
23
  "dependencies": {
24
24
  "analytics-node": "^6.2.0",
25
25
  "chalk": "^4.1.2",
26
- "commander": "^10.0.0",
27
26
  "execa": "^5.1.1",
28
27
  "find-yarn-workspace-root": "^2.0.0",
29
- "gradient-string": "^2.0.0",
30
28
  "inquirer": "^8.2.0",
31
29
  "isomorphic-git": "^1.21.0",
32
30
  "js-yaml": "^4.1.0",
33
31
  "lodash": "^4.17.21",
34
- "ora": "^5.4.1",
35
32
  "proper-lockfile": "^4.1.2",
36
33
  "read-pkg-up": "7.0.1",
37
- "semver": "^7.3.7"
34
+ "semver": "^7.3.7",
35
+ "commander": "^10.0.0",
36
+ "gradient-string": "^2.0.0",
37
+ "ora": "^5.4.1"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@jest/globals": "^29.4.2"
41
- },
42
- "gitHead": "3e3ae146eca363a09b91658e20d7295f9934b977"
41
+ }
43
42
  }
@@ -1,4 +1,4 @@
1
- import { Argument, Command } from 'commander'
1
+ import { Command } from 'commander'
2
2
 
3
3
  import { createMetricsSidecar } from '../utils/metrics/sidecar.js'
4
4
 
@@ -54,51 +54,10 @@ class DavinciCommand extends Command {
54
54
  return new DavinciCommand(name, this._packageName)
55
55
  }
56
56
 
57
- /**
58
- * Creates a new command from legacy data.
59
- *
60
- * @param {Object} data The legacy data for the new command
61
- * @returns {DavinciCommand} The newly created `DavinciCommand` instance
62
- */
63
- createCommandFromLegacy({
64
- command,
65
- description = '',
66
- args = [],
67
- options = [],
68
- allowUnknownOptions = false,
69
- action,
70
- isDefault = false,
71
- }) {
72
- const currentCommand = this.command(command, { isDefault })
73
-
74
- args.forEach(argument => {
75
- if (argument instanceof Argument) {
76
- currentCommand.addArgument(argument)
77
- } else {
78
- currentCommand.argument(...argument)
79
- }
80
- })
81
-
82
- options.forEach(option =>
83
- currentCommand.option(option.name, option.label, option.default)
84
- )
85
-
86
- if (allowUnknownOptions) {
87
- currentCommand.allowUnknownOption()
88
- }
89
-
90
- currentCommand.description(description).action(action)
91
-
92
- return currentCommand
93
- }
94
-
95
57
  createCommands(commandCreators) {
96
58
  commandCreators.forEach(commandCreator => {
97
59
  if (typeof commandCreator === 'function') {
98
60
  this.addCommand(commandCreator(this))
99
- } else if (!(commandCreator instanceof Command)) {
100
- // legacy
101
- this.createCommandFromLegacy(commandCreator)
102
61
  } else {
103
62
  this.addCommand(commandCreator)
104
63
  }
@@ -1,5 +1,4 @@
1
1
  import { jest } from '@jest/globals'
2
- import { createArgument } from 'commander'
3
2
 
4
3
  jest.unstable_mockModule('../utils/metrics/sidecar.js', () => ({
5
4
  createMetricsSidecar: jest.fn(),
@@ -78,30 +77,4 @@ describe('DavinciCommand', () => {
78
77
  expect(childCommand.getPackageName()).toBe('foo')
79
78
  })
80
79
  })
81
-
82
- describe('createCommandFromLegacy', () => {
83
- it('creates a new command from legacy data', () => {
84
- const parentCommand = new DavinciCommand('parent')
85
- const command = parentCommand.createCommandFromLegacy({
86
- command: 'child',
87
- description: 'description',
88
- args: [
89
- createArgument('<templateName>', 'Name of template').choices([
90
- 'component',
91
- 'page',
92
- ]),
93
- [
94
- '<appName>',
95
- 'Application Name: folder name for the new application',
96
- ],
97
- ],
98
- options: [{ name: '-f, --flag', label: 'description', default: false }],
99
- allowUnknownOptions: true,
100
- action: jest.fn(),
101
- isDefault: true,
102
- })
103
-
104
- expect(command).toMatchSnapshot()
105
- })
106
- })
107
80
  })
@@ -1,166 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`DavinciCommand createCommandFromLegacy creates a new command from legacy data 1`] = `
4
- DavinciCommand {
5
- "_actionHandler": [Function],
6
- "_addImplicitHelpCommand": undefined,
7
- "_aliases": [],
8
- "_allowExcessArguments": true,
9
- "_allowUnknownOption": true,
10
- "_args": [
11
- Argument {
12
- "_name": "templateName",
13
- "argChoices": [
14
- "component",
15
- "page",
16
- ],
17
- "defaultValue": undefined,
18
- "defaultValueDescription": undefined,
19
- "description": "Name of template",
20
- "parseArg": [Function],
21
- "required": true,
22
- "variadic": false,
23
- },
24
- Argument {
25
- "_name": "appName",
26
- "argChoices": undefined,
27
- "defaultValue": undefined,
28
- "defaultValueDescription": undefined,
29
- "description": "Application Name: folder name for the new application",
30
- "parseArg": undefined,
31
- "required": true,
32
- "variadic": false,
33
- },
34
- ],
35
- "_argsDescription": undefined,
36
- "_combineFlagAndOptionalValue": true,
37
- "_defaultCommandName": null,
38
- "_description": "description",
39
- "_enablePositionalOptions": false,
40
- "_events": {
41
- "option:flag": [Function],
42
- },
43
- "_eventsCount": 1,
44
- "_executableDir": null,
45
- "_executableFile": null,
46
- "_executableHandler": false,
47
- "_exitCallback": null,
48
- "_hasHelpOption": true,
49
- "_helpCommandDescription": "display help for command",
50
- "_helpCommandName": "help",
51
- "_helpCommandnameAndArgs": "help [command]",
52
- "_helpConfiguration": {},
53
- "_helpDescription": "display help for command",
54
- "_helpFlags": "-h, --help",
55
- "_helpLongFlag": "--help",
56
- "_helpShortFlag": "-h",
57
- "_hidden": false,
58
- "_lifeCycleHooks": {},
59
- "_maxListeners": undefined,
60
- "_name": "child",
61
- "_optionValueSources": {
62
- "flag": "default",
63
- },
64
- "_optionValues": {
65
- "flag": false,
66
- },
67
- "_outputConfiguration": {
68
- "getErrHelpWidth": [Function],
69
- "getOutHelpWidth": [Function],
70
- "outputError": [Function],
71
- "writeErr": [Function],
72
- "writeOut": [Function],
73
- },
74
- "_packageName": null,
75
- "_passThroughOptions": false,
76
- "_scriptPath": null,
77
- "_showHelpAfterError": false,
78
- "_showSuggestionAfterError": true,
79
- "_storeOptionsAsProperties": false,
80
- "_summary": "",
81
- "args": [],
82
- "commands": [],
83
- "options": [
84
- Option {
85
- "argChoices": undefined,
86
- "conflictsWith": [],
87
- "defaultValue": false,
88
- "defaultValueDescription": undefined,
89
- "description": "description",
90
- "envVar": undefined,
91
- "flags": "-f, --flag",
92
- "hidden": false,
93
- "implied": undefined,
94
- "long": "--flag",
95
- "mandatory": false,
96
- "negate": false,
97
- "optional": false,
98
- "parseArg": undefined,
99
- "presetArg": undefined,
100
- "required": false,
101
- "short": "-f",
102
- "variadic": false,
103
- },
104
- ],
105
- "parent": DavinciCommand {
106
- "_actionHandler": null,
107
- "_addImplicitHelpCommand": undefined,
108
- "_aliases": [],
109
- "_allowExcessArguments": true,
110
- "_allowUnknownOption": false,
111
- "_args": [],
112
- "_argsDescription": undefined,
113
- "_combineFlagAndOptionalValue": true,
114
- "_defaultCommandName": "child",
115
- "_description": "",
116
- "_enablePositionalOptions": false,
117
- "_events": {},
118
- "_eventsCount": 0,
119
- "_executableDir": null,
120
- "_executableFile": null,
121
- "_executableHandler": false,
122
- "_exitCallback": null,
123
- "_hasHelpOption": true,
124
- "_helpCommandDescription": "display help for command",
125
- "_helpCommandName": "help",
126
- "_helpCommandnameAndArgs": "help [command]",
127
- "_helpConfiguration": {},
128
- "_helpDescription": "display help for command",
129
- "_helpFlags": "-h, --help",
130
- "_helpLongFlag": "--help",
131
- "_helpShortFlag": "-h",
132
- "_hidden": false,
133
- "_lifeCycleHooks": {},
134
- "_maxListeners": undefined,
135
- "_name": "parent",
136
- "_optionValueSources": {},
137
- "_optionValues": {},
138
- "_outputConfiguration": {
139
- "getErrHelpWidth": [Function],
140
- "getOutHelpWidth": [Function],
141
- "outputError": [Function],
142
- "writeErr": [Function],
143
- "writeOut": [Function],
144
- },
145
- "_packageName": null,
146
- "_passThroughOptions": false,
147
- "_scriptPath": null,
148
- "_showHelpAfterError": false,
149
- "_showSuggestionAfterError": true,
150
- "_storeOptionsAsProperties": false,
151
- "_summary": "",
152
- "args": [],
153
- "commands": [
154
- [Circular],
155
- ],
156
- "options": [],
157
- "parent": null,
158
- "processedArgs": [],
159
- "rawArgs": [],
160
- Symbol(kCapture): false,
161
- },
162
- "processedArgs": [],
163
- "rawArgs": [],
164
- Symbol(kCapture): false,
165
- }
166
- `;