@oclif/plugin-command-snapshot 5.2.28 → 5.2.30
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.
|
@@ -6,7 +6,7 @@ import fs from 'node:fs';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import * as semver from 'semver';
|
|
8
8
|
import SnapshotCommand from '../../snapshot-command.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getAllFiles, getKeyNameFromFilename, GLOB_PATTERNS } from '../../util.js';
|
|
10
10
|
import { SchemaGenerator } from './generate.js';
|
|
11
11
|
function isNumber(n) {
|
|
12
12
|
return Number.isInteger(Number(n));
|
|
@@ -24,6 +24,7 @@ export default class SchemaCompare extends SnapshotCommand {
|
|
|
24
24
|
description: 'path of the generated snapshot file',
|
|
25
25
|
}),
|
|
26
26
|
};
|
|
27
|
+
// eslint-disable-next-line complexity
|
|
27
28
|
async run() {
|
|
28
29
|
const strategy = typeof this.config.pjson.oclif?.commands === 'string' ? 'pattern' : this.config.pjson.oclif?.commands?.strategy;
|
|
29
30
|
const commandsDir = typeof this.config.pjson.oclif?.commands === 'string'
|
|
@@ -68,10 +69,6 @@ export default class SchemaCompare extends SnapshotCommand {
|
|
|
68
69
|
const lastElementIsNum = isNumber(lastPathElement);
|
|
69
70
|
const basePath = lastElementIsNum ? readablePath.replace(`.${lastPathElement}`, '') : readablePath;
|
|
70
71
|
switch (change.op) {
|
|
71
|
-
case 'replace': {
|
|
72
|
-
humanReadableChanges[commandId].push(`${underline(readablePath)} was changed from ${cyan(existing)} to ${cyan(latest)}`);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
72
|
case 'add': {
|
|
76
73
|
humanReadableChanges[commandId].push(lastElementIsNum
|
|
77
74
|
? `Array item at ${underline(basePath)} was ${cyan('added')} to latest schema`
|
|
@@ -84,6 +81,10 @@ export default class SchemaCompare extends SnapshotCommand {
|
|
|
84
81
|
: `${underline(readablePath)} was ${cyan('not found')} in latest schema`);
|
|
85
82
|
break;
|
|
86
83
|
}
|
|
84
|
+
case 'replace': {
|
|
85
|
+
humanReadableChanges[commandId].push(`${underline(readablePath)} was changed from ${cyan(existing)} to ${cyan(latest)}`);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
87
88
|
default: {
|
|
88
89
|
break;
|
|
89
90
|
}
|
|
@@ -103,7 +104,7 @@ export default class SchemaCompare extends SnapshotCommand {
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
this.log();
|
|
106
|
-
const bin = process.platform === 'win32' ?
|
|
107
|
+
const bin = process.platform === 'win32' ? String.raw `bin\dev.cmd` : 'bin/dev.js';
|
|
107
108
|
this.log('If intended, please update the schema file(s) and run again:', bold(`${bin} ${toConfiguredId('schema:generate', this.config)}`));
|
|
108
109
|
process.exitCode = 1;
|
|
109
110
|
return changes;
|
|
@@ -5,7 +5,7 @@ import fs from 'node:fs';
|
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { createGenerator } from 'ts-json-schema-generator';
|
|
7
7
|
import SnapshotCommand from '../../snapshot-command.js';
|
|
8
|
-
import {
|
|
8
|
+
import { getAllFiles, getSchemaFileName, GLOB_PATTERNS } from '../../util.js';
|
|
9
9
|
export class SchemaGenerator {
|
|
10
10
|
base;
|
|
11
11
|
classToId = {};
|
|
@@ -4,12 +4,12 @@ interface Change {
|
|
|
4
4
|
name: string;
|
|
5
5
|
removed?: boolean;
|
|
6
6
|
}
|
|
7
|
-
type CommandChange = {
|
|
7
|
+
type CommandChange = Change & {
|
|
8
8
|
alias: Change[];
|
|
9
9
|
chars: Change[];
|
|
10
10
|
flags: Change[];
|
|
11
11
|
plugin: string;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
export type CompareResponse = {
|
|
14
14
|
addedCommands?: string[];
|
|
15
15
|
diffCommands?: CommandChange[];
|
|
@@ -30,7 +30,7 @@ export default class Compare extends SnapshotCommand {
|
|
|
30
30
|
compareSnapshot(initialCommands: SnapshotEntry[], updatedCommands: CommandChange[]): Promise<CompareResponse>;
|
|
31
31
|
/**
|
|
32
32
|
* compares two command's properties to each other
|
|
33
|
-
* @
|
|
33
|
+
* @returns a list of added, removed, updated, and changed properties
|
|
34
34
|
* @param initial initial command property to compare against
|
|
35
35
|
* @param updated generated command property to compare with
|
|
36
36
|
*/
|
|
@@ -107,7 +107,7 @@ export default class Compare extends SnapshotCommand {
|
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* compares two command's properties to each other
|
|
110
|
-
* @
|
|
110
|
+
* @returns a list of added, removed, updated, and changed properties
|
|
111
111
|
* @param initial initial command property to compare against
|
|
112
112
|
* @param updated generated command property to compare with
|
|
113
113
|
*/
|
|
@@ -16,7 +16,7 @@ export default class Generate extends SnapshotCommand {
|
|
|
16
16
|
throw new Error(`Command "${duplicatedChar.command}" has duplicate short-flag characters "${duplicatedChar.flagChars.filter((item, index) => duplicatedChar.flagChars.indexOf(item) !== index)}"`);
|
|
17
17
|
}
|
|
18
18
|
const charConflictCommand = resultCommands.find((command) => command.flags.length > 1 &&
|
|
19
|
-
new Set([...command.
|
|
19
|
+
new Set([...command.flagAliases, ...command.flagChars, ...command.flags]).size !==
|
|
20
20
|
[...command.flags, ...command.flagChars, ...command.flagAliases].length);
|
|
21
21
|
if (charConflictCommand) {
|
|
22
22
|
const conflictFlags = [
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/plugin-command-snapshot",
|
|
3
3
|
"description": "generates and compares OCLIF plugins snapshot files",
|
|
4
|
-
"version": "5.2.
|
|
4
|
+
"version": "5.2.30",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/plugin-command-snapshot/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@oclif/core": "^4",
|
|
9
|
-
"ansis": "^3.
|
|
9
|
+
"ansis": "^3.10.0",
|
|
10
10
|
"globby": "^14.0.2",
|
|
11
11
|
"just-diff": "^5.2.0",
|
|
12
12
|
"lodash.difference": "^4.5.0",
|
|
13
13
|
"lodash.get": "^4.4.2",
|
|
14
14
|
"lodash.sortby": "^4.7.0",
|
|
15
|
-
"semver": "^7.
|
|
15
|
+
"semver": "^7.7.0",
|
|
16
16
|
"ts-json-schema-generator": "^1.5.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@commitlint/config-conventional": "^19",
|
|
20
|
+
"@eslint/compat": "^1.2.6",
|
|
20
21
|
"@oclif/plugin-help": "^6",
|
|
21
22
|
"@oclif/prettier-config": "^0.2.1",
|
|
22
23
|
"@oclif/test": "^4",
|
|
@@ -30,15 +31,14 @@
|
|
|
30
31
|
"@types/sinon": "^17.0.3",
|
|
31
32
|
"chai": "^4",
|
|
32
33
|
"commitlint": "^19",
|
|
33
|
-
"eslint": "^
|
|
34
|
-
"eslint-config-oclif": "^
|
|
35
|
-
"eslint-config-
|
|
36
|
-
"eslint-config-prettier": "^9.1.0",
|
|
34
|
+
"eslint": "^9.19.0",
|
|
35
|
+
"eslint-config-oclif": "^6.0.0",
|
|
36
|
+
"eslint-config-prettier": "^10.0.1",
|
|
37
37
|
"husky": "^9.1.7",
|
|
38
|
-
"lint-staged": "^15.3
|
|
38
|
+
"lint-staged": "^15.4.3",
|
|
39
39
|
"mocha": "^10.8.2",
|
|
40
40
|
"nyc": "^15",
|
|
41
|
-
"oclif": "^4.17.
|
|
41
|
+
"oclif": "^4.17.17",
|
|
42
42
|
"prettier": "^3.4.2",
|
|
43
43
|
"shx": "^0.3.4",
|
|
44
44
|
"sinon": "^18.0.1",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"build": "shx rm -rf lib && tsc",
|
|
82
82
|
"clean": "shx rm -f oclif.manifest.json",
|
|
83
83
|
"compile": "tsc",
|
|
84
|
-
"lint": "eslint
|
|
84
|
+
"lint": "eslint",
|
|
85
85
|
"postpack": "yarn run clean",
|
|
86
86
|
"posttest": "yarn lint",
|
|
87
87
|
"prepack": "yarn build && oclif manifest && oclif readme",
|