@dereekb/dbx-cli 13.11.15 → 13.11.17
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/firebase-api-manifest/package.json +1 -1
- package/generate-firestore-indexes/main.js +2202 -0
- package/generate-firestore-indexes/package.json +9 -0
- package/lint-cache/package.json +2 -2
- package/manifest-extract/package.json +1 -1
- package/package.json +9 -5
- package/src/lib/scan-helpers/scan-extract-utils.d.ts +85 -0
- package/src/lib/scan-helpers/scan-io.d.ts +130 -0
- package/test/package.json +9 -9
package/lint-cache/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli-lint-cache",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.17",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@dereekb/util": "13.11.
|
|
7
|
+
"@dereekb/util": "13.11.17",
|
|
8
8
|
"eslint": "10.4.0",
|
|
9
9
|
"yargs": "^18.0.0",
|
|
10
10
|
"@types/yargs": "^17.0.35"
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.17",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"dbx-cli-generate-firebase-api-manifest": "firebase-api-manifest/main.js",
|
|
7
|
+
"dbx-cli-generate-firestore-indexes": "generate-firestore-indexes/main.js",
|
|
7
8
|
"dbx-cli-lint-cache": "lint-cache/main.js"
|
|
8
9
|
},
|
|
9
10
|
"exports": {
|
|
10
11
|
"./firebase-api-manifest": {
|
|
11
12
|
"default": "./firebase-api-manifest/main.js"
|
|
12
13
|
},
|
|
14
|
+
"./generate-firestore-indexes": {
|
|
15
|
+
"default": "./generate-firestore-indexes/main.js"
|
|
16
|
+
},
|
|
13
17
|
"./lint-cache": {
|
|
14
18
|
"default": "./lint-cache/main.js"
|
|
15
19
|
},
|
|
@@ -34,10 +38,10 @@
|
|
|
34
38
|
}
|
|
35
39
|
},
|
|
36
40
|
"peerDependencies": {
|
|
37
|
-
"@dereekb/date": "13.11.
|
|
38
|
-
"@dereekb/firebase": "13.11.
|
|
39
|
-
"@dereekb/nestjs": "13.11.
|
|
40
|
-
"@dereekb/util": "13.11.
|
|
41
|
+
"@dereekb/date": "13.11.17",
|
|
42
|
+
"@dereekb/firebase": "13.11.17",
|
|
43
|
+
"@dereekb/nestjs": "13.11.17",
|
|
44
|
+
"@dereekb/util": "13.11.17",
|
|
41
45
|
"arktype": "^2.2.0",
|
|
42
46
|
"yargs": "^18.0.0"
|
|
43
47
|
},
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AST/JSDoc helpers used by the per-domain `*-extract.ts` modules.
|
|
3
|
+
*
|
|
4
|
+
* Each extractor walks ts-morph nodes the same way to read JSDoc tag bodies,
|
|
5
|
+
* unwrap fenced code blocks, split list-style tag text, inspect Angular
|
|
6
|
+
* `@Directive`/`@Component` decorators, and decide whether a class member is
|
|
7
|
+
* publicly visible. Centralising these helpers avoids byte-identical
|
|
8
|
+
* duplication across `actions-extract.ts`, `filters-extract.ts`,
|
|
9
|
+
* `pipes-extract.ts`, `ui-components-extract.ts`, and
|
|
10
|
+
* `forge-fields-extract.ts`.
|
|
11
|
+
*/
|
|
12
|
+
import { type ClassDeclaration, type Decorator, type ObjectLiteralExpression, type PropertyDeclaration } from 'ts-morph';
|
|
13
|
+
/**
|
|
14
|
+
* Strips a leading and trailing triple-backtick fence (and optional language
|
|
15
|
+
* marker) from a JSDoc `@example` body. Falls through to the trimmed input
|
|
16
|
+
* when the fence pattern doesn't match.
|
|
17
|
+
*
|
|
18
|
+
* @param text - The raw `@example` body to unwrap.
|
|
19
|
+
* @returns The body with surrounding code fence removed, or the trimmed input when no fence is present.
|
|
20
|
+
*/
|
|
21
|
+
export declare function unwrapFenced(text: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Splits a list-style tag body (whitespace or comma separated) into trimmed,
|
|
24
|
+
* non-empty pieces.
|
|
25
|
+
*
|
|
26
|
+
* @param text - The raw tag body to split.
|
|
27
|
+
* @returns Trimmed, non-empty tokens preserved in source order.
|
|
28
|
+
*/
|
|
29
|
+
export declare function splitListTagText(text: string): readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Flattens an array of list-style tag bodies into a single trimmed,
|
|
32
|
+
* non-empty array of pieces.
|
|
33
|
+
*
|
|
34
|
+
* @param values - Multiple raw tag bodies whose pieces should be merged.
|
|
35
|
+
* @returns Every trimmed, non-empty token from every body, in source order.
|
|
36
|
+
*/
|
|
37
|
+
export declare function flattenList(values: readonly string[]): readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* Reads a string-literal property from an object literal. Returns `undefined`
|
|
40
|
+
* when the property is missing, isn't a property assignment, or when the
|
|
41
|
+
* initializer isn't a (non-substitution) string literal.
|
|
42
|
+
*
|
|
43
|
+
* @param obj - The object literal expression to inspect.
|
|
44
|
+
* @param propName - The property name whose string-literal value to read.
|
|
45
|
+
* @returns The string value, or `undefined` if the property is missing or not a string literal.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readStringProperty(obj: ObjectLiteralExpression, propName: string): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Reads the `selector` string from the first object-literal argument of an
|
|
50
|
+
* `@Directive()` / `@Component()` decorator call. Returns `undefined` when
|
|
51
|
+
* the decorator has no call expression, no first argument, or the first
|
|
52
|
+
* argument isn't an object literal with a string `selector`.
|
|
53
|
+
*
|
|
54
|
+
* @param decorator - The Angular decorator node to read.
|
|
55
|
+
* @returns The selector string, or `undefined` if absent.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readSelector(decorator: Decorator): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Walks the supplied class's decorators looking for the first
|
|
60
|
+
* `@Directive()` / `@Component()` whose object literal includes a
|
|
61
|
+
* `selector`. Returns `undefined` when no qualifying decorator is found.
|
|
62
|
+
*
|
|
63
|
+
* @param decl - The class declaration to inspect.
|
|
64
|
+
* @returns An object containing the discovered selector, or `undefined` if no qualifying decorator is present.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readDirectiveDecorator(decl: ClassDeclaration): {
|
|
67
|
+
readonly selector: string;
|
|
68
|
+
} | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Returns `true` when the property has neither `private` nor `protected`
|
|
71
|
+
* modifiers. Used as the default visibility filter when extracting Angular
|
|
72
|
+
* inputs/outputs.
|
|
73
|
+
*
|
|
74
|
+
* @param property - The property declaration to inspect.
|
|
75
|
+
* @returns `true` if the property is publicly visible.
|
|
76
|
+
*/
|
|
77
|
+
export declare function isVisibleProperty(property: PropertyDeclaration): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Joins every JSDoc description block on the property with `\n\n`. Returns
|
|
80
|
+
* an empty string when the property has no JSDoc or only blank descriptions.
|
|
81
|
+
*
|
|
82
|
+
* @param property - The property declaration whose JSDoc descriptions to collect.
|
|
83
|
+
* @returns The concatenated description text, or an empty string when none is present.
|
|
84
|
+
*/
|
|
85
|
+
export declare function readPropertyDescription(property: PropertyDeclaration): string;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared I/O primitives for the build-manifest pipelines.
|
|
3
|
+
*
|
|
4
|
+
* Every scanner needs the same file-reading, glob-matching, exclude-filtering,
|
|
5
|
+
* and package-name-loading logic, so it lives here once. Individual
|
|
6
|
+
* `*-build-manifest.ts` modules import these and supply their own schema
|
|
7
|
+
* validation / entry assembly.
|
|
8
|
+
*/
|
|
9
|
+
import { Project } from 'ts-morph';
|
|
10
|
+
/**
|
|
11
|
+
* Function shape used to read text files. Defaults to
|
|
12
|
+
* `node:fs/promises.readFile(path, 'utf-8')`.
|
|
13
|
+
*/
|
|
14
|
+
export type ScanReadFile = (absolutePath: string) => Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Function shape used to resolve include/exclude globs against the project
|
|
17
|
+
* root. Defaults to `node:fs/promises.glob` filtered through a regex-derived
|
|
18
|
+
* exclude check.
|
|
19
|
+
*/
|
|
20
|
+
export type ScanGlobber = (input: {
|
|
21
|
+
readonly projectRoot: string;
|
|
22
|
+
readonly include: readonly string[];
|
|
23
|
+
readonly exclude: readonly string[];
|
|
24
|
+
}) => Promise<readonly string[]>;
|
|
25
|
+
export declare const defaultReadFile: ScanReadFile;
|
|
26
|
+
export declare const defaultGlobber: ScanGlobber;
|
|
27
|
+
/**
|
|
28
|
+
* Shared outcome kinds for the `no-package` / `invalid-package` error
|
|
29
|
+
* paths. Every build-manifest outcome type includes these same two
|
|
30
|
+
* variants, so the shared loader can return a compatible discriminated
|
|
31
|
+
* union.
|
|
32
|
+
*/
|
|
33
|
+
export type LoadPackageNameResult = {
|
|
34
|
+
readonly kind: 'ok';
|
|
35
|
+
readonly packageName: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'fail';
|
|
38
|
+
readonly outcome: {
|
|
39
|
+
readonly kind: 'no-package';
|
|
40
|
+
readonly packagePath: string;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'invalid-package';
|
|
43
|
+
readonly packagePath: string;
|
|
44
|
+
readonly error: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Reads `package.json` at the supplied path and returns its `name` field, normalising file/parse errors into a discriminated outcome compatible with `*-build-manifest.ts` callers.
|
|
49
|
+
*
|
|
50
|
+
* @param packagePath - Absolute path to `package.json`.
|
|
51
|
+
* @param readFile - File-reader injected by the scan runtime.
|
|
52
|
+
* @returns Either the parsed package name or a discriminated failure outcome.
|
|
53
|
+
*/
|
|
54
|
+
export declare function loadPackageName(packagePath: string, readFile: ScanReadFile): Promise<LoadPackageNameResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Failure variants surfaced by {@link loadScanSection}. Every per-cluster
|
|
57
|
+
* `Build*ManifestOutcome` includes these same two variants so the shared
|
|
58
|
+
* loader can return a value the caller forwards directly.
|
|
59
|
+
*/
|
|
60
|
+
export type ScanConfigFailureOutcome = {
|
|
61
|
+
readonly kind: 'no-config';
|
|
62
|
+
readonly configPath: string;
|
|
63
|
+
} | {
|
|
64
|
+
readonly kind: 'invalid-scan-config';
|
|
65
|
+
readonly configPath: string;
|
|
66
|
+
readonly error: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Discriminated outcome from {@link loadScanSection}. On success carries the
|
|
70
|
+
* cluster's already-validated section; on failure carries an outcome the
|
|
71
|
+
* caller forwards as its own `Build*ManifestOutcome`.
|
|
72
|
+
*/
|
|
73
|
+
export type LoadScanSectionResult<TSection> = {
|
|
74
|
+
readonly kind: 'ok';
|
|
75
|
+
readonly section: TSection;
|
|
76
|
+
} | {
|
|
77
|
+
readonly kind: 'fail';
|
|
78
|
+
readonly outcome: ScanConfigFailureOutcome;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Reads `dbx-mcp.scan.json` at {@link configPath}, parses it as JSON, and
|
|
82
|
+
* hands the parsed object to {@link parseSection} for cluster-specific
|
|
83
|
+
* arktype validation. Centralises the missing-file / bad-JSON / invalid-
|
|
84
|
+
* schema branches that every `*-build-manifest.ts` repeats verbatim.
|
|
85
|
+
*
|
|
86
|
+
* @param input - Config path, file reader, and the cluster-specific parse callback used to validate the section.
|
|
87
|
+
* @param input.configPath - Absolute path to the `dbx-mcp.scan.json` file to read.
|
|
88
|
+
* @param input.readFile - File-reader injected by the scan runtime; defaults to `node:fs/promises.readFile` in production callers.
|
|
89
|
+
* @param input.parseSection - Cluster-specific parser that validates the parsed JSON and extracts the relevant sub-section (typically wraps an arktype validator).
|
|
90
|
+
* @returns Either the validated section or a forwardable failure outcome (`no-config` or `invalid-scan-config`).
|
|
91
|
+
*/
|
|
92
|
+
export declare function loadScanSection<TSection>(input: {
|
|
93
|
+
readonly configPath: string;
|
|
94
|
+
readonly readFile: ScanReadFile;
|
|
95
|
+
readonly parseSection: (parsed: unknown) => {
|
|
96
|
+
readonly ok: true;
|
|
97
|
+
readonly section: TSection;
|
|
98
|
+
} | {
|
|
99
|
+
readonly ok: false;
|
|
100
|
+
readonly error: string;
|
|
101
|
+
};
|
|
102
|
+
}): Promise<LoadScanSectionResult<TSection>>;
|
|
103
|
+
/**
|
|
104
|
+
* Builds an in-memory ts-morph {@link Project} populated with the supplied
|
|
105
|
+
* relative file paths. Resolves every path against {@link projectRoot},
|
|
106
|
+
* reads it via {@link readFile}, and adds it to the project as a source
|
|
107
|
+
* file. Used by every `*-build-manifest.ts` orchestrator before handing
|
|
108
|
+
* the project to its cluster-specific extractor.
|
|
109
|
+
*
|
|
110
|
+
* @param input - Project root, relative file paths to load, and the file reader used to fetch each file's contents.
|
|
111
|
+
* @param input.projectRoot - Absolute path used as the base for resolving each entry in `filePaths`.
|
|
112
|
+
* @param input.filePaths - Relative file paths to add to the in-memory project, resolved against `projectRoot`.
|
|
113
|
+
* @param input.readFile - File-reader used to fetch each file's contents before adding it to the project.
|
|
114
|
+
* @returns The populated ts-morph project ready for entry extraction.
|
|
115
|
+
*/
|
|
116
|
+
export declare function buildScanProject(input: {
|
|
117
|
+
readonly projectRoot: string;
|
|
118
|
+
readonly filePaths: readonly string[];
|
|
119
|
+
readonly readFile: ScanReadFile;
|
|
120
|
+
}): Promise<Project>;
|
|
121
|
+
/**
|
|
122
|
+
* Translates a glob pattern into a RegExp suitable for testing
|
|
123
|
+
* `relative(projectRoot, file)` paths. Supports `**`, `*`, and `?`
|
|
124
|
+
* wildcards. Used by the default globber to filter exclude patterns
|
|
125
|
+
* — the matching logic intentionally mirrors `node:fs/promises.glob`.
|
|
126
|
+
*
|
|
127
|
+
* @param pattern - A glob pattern (no character classes)
|
|
128
|
+
* @returns A RegExp that matches paths satisfying the glob.
|
|
129
|
+
*/
|
|
130
|
+
export declare function globToRegex(pattern: string): RegExp;
|
package/test/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-cli/test",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.17",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/date": "13.11.
|
|
6
|
-
"@dereekb/dbx-cli": "13.11.
|
|
7
|
-
"@dereekb/firebase": "13.11.
|
|
8
|
-
"@dereekb/firebase-server/test": "13.11.
|
|
9
|
-
"@dereekb/model": "13.11.
|
|
10
|
-
"@dereekb/nestjs": "13.11.
|
|
11
|
-
"@dereekb/rxjs": "13.11.
|
|
12
|
-
"@dereekb/util": "13.11.
|
|
5
|
+
"@dereekb/date": "13.11.17",
|
|
6
|
+
"@dereekb/dbx-cli": "13.11.17",
|
|
7
|
+
"@dereekb/firebase": "13.11.17",
|
|
8
|
+
"@dereekb/firebase-server/test": "13.11.17",
|
|
9
|
+
"@dereekb/model": "13.11.17",
|
|
10
|
+
"@dereekb/nestjs": "13.11.17",
|
|
11
|
+
"@dereekb/rxjs": "13.11.17",
|
|
12
|
+
"@dereekb/util": "13.11.17",
|
|
13
13
|
"@nestjs/common": "^11.1.19",
|
|
14
14
|
"arktype": "^2.2.0",
|
|
15
15
|
"yargs": "^18.0.0"
|