@memberjunction/cli 4.3.1 → 5.0.0
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/README.md +130 -0
- package/bin/dev.cmd +2 -2
- package/bin/run.cmd +3 -3
- package/dist/commands/clean/index.d.ts +0 -2
- package/dist/commands/clean/index.d.ts.map +1 -1
- package/dist/commands/clean/index.js +31 -19
- package/dist/commands/clean/index.js.map +1 -1
- package/dist/commands/codegen/5-0-fix-entity-names.d.ts +17 -0
- package/dist/commands/codegen/5-0-fix-entity-names.d.ts.map +1 -0
- package/dist/commands/codegen/5-0-fix-entity-names.js +104 -0
- package/dist/commands/codegen/5-0-fix-entity-names.js.map +1 -0
- package/dist/commands/codegen/5-0-fix-html-entity-names.d.ts +17 -0
- package/dist/commands/codegen/5-0-fix-html-entity-names.d.ts.map +1 -0
- package/dist/commands/codegen/5-0-fix-html-entity-names.js +92 -0
- package/dist/commands/codegen/5-0-fix-html-entity-names.js.map +1 -0
- package/dist/commands/codegen/5-0-fix-metadata-names.d.ts +17 -0
- package/dist/commands/codegen/5-0-fix-metadata-names.d.ts.map +1 -0
- package/dist/commands/codegen/5-0-fix-metadata-names.js +93 -0
- package/dist/commands/codegen/5-0-fix-metadata-names.js.map +1 -0
- package/dist/commands/codegen/index.d.ts +4 -1
- package/dist/commands/codegen/index.d.ts.map +1 -1
- package/dist/commands/codegen/index.js +30 -5
- package/dist/commands/codegen/index.js.map +1 -1
- package/dist/commands/codegen/manifest.d.ts +4 -1
- package/dist/commands/codegen/manifest.d.ts.map +1 -1
- package/dist/commands/codegen/manifest.js +34 -11
- package/dist/commands/codegen/manifest.js.map +1 -1
- package/dist/commands/migrate/index.d.ts +5 -1
- package/dist/commands/migrate/index.d.ts.map +1 -1
- package/dist/commands/migrate/index.js +102 -229
- package/dist/commands/migrate/index.js.map +1 -1
- package/dist/commands/sync/init.js +1 -1
- package/dist/commands/sync/init.js.map +1 -1
- package/dist/commands/sync/pull.js +4 -4
- package/dist/commands/sync/pull.js.map +1 -1
- package/dist/config.d.ts +15 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +50 -48
- package/dist/config.js.map +1 -1
- package/dist/light-commands.d.ts +1 -1
- package/dist/light-commands.js +2 -2
- package/dist/light-commands.js.map +1 -1
- package/oclif.manifest.json +425 -181
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -135,6 +135,136 @@ mj codegen manifest
|
|
|
135
135
|
mj codegen manifest --exclude-packages @memberjunction --output ./src/generated/manifest.ts
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
+
#### v5.0 Entity Name Migration Commands
|
|
139
|
+
|
|
140
|
+
Starting in MemberJunction v5.0, all 272 core entity names are being normalized with the `"MJ: "` prefix to prevent naming collisions on client systems (e.g., `"Actions"` becomes `"MJ: Actions"`). The database migration handles the rename automatically, but hardcoded entity name strings in your TypeScript source, Angular HTML templates, and metadata JSON files also need updating. These three commands automate that process.
|
|
141
|
+
|
|
142
|
+
All three commands share the same workflow:
|
|
143
|
+
1. **Dry-run first** (default) -- scans and reports what would change, without modifying any files.
|
|
144
|
+
2. **Fix mode** (`--fix`) -- applies the changes in place.
|
|
145
|
+
3. **Rename map** -- built dynamically by parsing `@RegisterClass(BaseEntity, 'MJ: XYZ')` decorators from `entity_subclasses.ts`. No hardcoded list to maintain.
|
|
146
|
+
|
|
147
|
+
> These commands will be kept for 1-2 years to support the v5.0 upgrade window, then removed.
|
|
148
|
+
|
|
149
|
+
##### mj codegen 5-0-fix-entity-names
|
|
150
|
+
|
|
151
|
+
Scans **TypeScript source files** (`.ts`) using the TypeScript compiler AST to find hardcoded entity names that need the `"MJ: "` prefix. This is the most comprehensive scanner -- it understands code context, not just string matching.
|
|
152
|
+
|
|
153
|
+
**Detected patterns:**
|
|
154
|
+
|
|
155
|
+
| Pattern | Example |
|
|
156
|
+
|---------|---------|
|
|
157
|
+
| `GetEntityObject` calls | `md.GetEntityObject<T>('Actions')` |
|
|
158
|
+
| `OpenEntityRecord` calls | `this.OpenEntityRecord('Entities', id)` |
|
|
159
|
+
| `navigateToEntity` calls | `navigateToEntity('Templates')` |
|
|
160
|
+
| `BuildRelationshipViewParamsByEntityName` calls | `BuildRelationshipViewParamsByEntityName('Roles')` |
|
|
161
|
+
| `NewRecordValues` calls | `NewRecordValues('Users')` |
|
|
162
|
+
| `IsCurrentTab` calls | `IsCurrentTab('Queries')` |
|
|
163
|
+
| `EntityName:` property assignments | `EntityName: 'AI Agent Examples'` |
|
|
164
|
+
| `.Name ===` / `.Entity ===` comparisons | `entity.Name === 'Actions'` |
|
|
165
|
+
| `@RegisterClass` decorator (BaseEntity) | `@RegisterClass(BaseEntity, 'Actions')` |
|
|
166
|
+
|
|
167
|
+
**Default exclusions:** `node_modules`, `dist`, `build`, `.git`, `__tests__`, `*.d.ts`, `*.spec.ts`, `*.test.ts`, `generated/`, `Demos/`
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Dry-run: scan entire packages/ directory
|
|
171
|
+
mj codegen 5-0-fix-entity-names --path packages/
|
|
172
|
+
|
|
173
|
+
# Dry-run: scan a single file
|
|
174
|
+
mj codegen 5-0-fix-entity-names --path packages/Angular/Explorer/dashboards/src/Actions/components/actions-overview.component.ts
|
|
175
|
+
|
|
176
|
+
# Apply fixes
|
|
177
|
+
mj codegen 5-0-fix-entity-names --path packages/ --fix
|
|
178
|
+
|
|
179
|
+
# Custom entity_subclasses.ts location
|
|
180
|
+
mj codegen 5-0-fix-entity-names --path packages/ --entity-subclasses ./path/to/entity_subclasses.ts
|
|
181
|
+
|
|
182
|
+
# Quiet mode (summary only)
|
|
183
|
+
mj codegen 5-0-fix-entity-names --path packages/ -q
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
##### mj codegen 5-0-fix-html-entity-names
|
|
187
|
+
|
|
188
|
+
Scans **Angular HTML template files** (`.html`) using targeted regex patterns for entity name references in template expressions and attribute values.
|
|
189
|
+
|
|
190
|
+
**Detected patterns:**
|
|
191
|
+
|
|
192
|
+
| Pattern | Example |
|
|
193
|
+
|---------|---------|
|
|
194
|
+
| Method calls in event/property bindings | `(click)="navigateToEntity('Actions')"` |
|
|
195
|
+
| `OpenEntityRecord` / `openEntityRecord` | `(click)="OpenEntityRecord('Entities', id)"` |
|
|
196
|
+
| `BuildRelationshipViewParamsByEntityName` | `[Params]="BuildRelationshipViewParamsByEntityName('Roles')"` |
|
|
197
|
+
| `RowsEntityName` attribute | `RowsEntityName="Users"` |
|
|
198
|
+
| `JoinEntityName` attribute | `JoinEntityName="Roles"` |
|
|
199
|
+
|
|
200
|
+
**Default exclusions:** `node_modules`, `dist`, `build`, `.git`, `generated/`, `Demos/`
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Dry-run: scan Angular templates
|
|
204
|
+
mj codegen 5-0-fix-html-entity-names --path packages/Angular/
|
|
205
|
+
|
|
206
|
+
# Apply fixes
|
|
207
|
+
mj codegen 5-0-fix-html-entity-names --path packages/Angular/ --fix
|
|
208
|
+
|
|
209
|
+
# Verbose output showing individual file progress
|
|
210
|
+
mj codegen 5-0-fix-html-entity-names --path packages/ -v
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
##### mj codegen 5-0-fix-metadata-names
|
|
214
|
+
|
|
215
|
+
Scans **metadata JSON files** (including dotfiles like `.mj-sync.json`) for entity name references that need the `"MJ: "` prefix. Targets the `metadata/` directory used by `mj sync`.
|
|
216
|
+
|
|
217
|
+
**Detected patterns:**
|
|
218
|
+
|
|
219
|
+
| Pattern | Example |
|
|
220
|
+
|---------|---------|
|
|
221
|
+
| `@lookup:` entity name | `@lookup:Entities.Name=Dashboards` |
|
|
222
|
+
| `@lookup:` value (in Entities lookups) | `@lookup:MJ: Entities.Name=Actions` |
|
|
223
|
+
| Folder config `entity`/`entityName` | `.mj-sync.json` with `"entity": "Dashboards"` |
|
|
224
|
+
| `relatedEntities` object keys | `"relatedEntities": { "Actions": [...] }` |
|
|
225
|
+
| `fields.Name` in Entities folders | Entity record data files where Name is the entity name |
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Dry-run: scan metadata directory
|
|
229
|
+
mj codegen 5-0-fix-metadata-names --path metadata/
|
|
230
|
+
|
|
231
|
+
# Apply fixes
|
|
232
|
+
mj codegen 5-0-fix-metadata-names --path metadata/ --fix
|
|
233
|
+
|
|
234
|
+
# Scan a specific subdirectory
|
|
235
|
+
mj codegen 5-0-fix-metadata-names --path metadata/resource-types
|
|
236
|
+
|
|
237
|
+
# Scan and fix a single file
|
|
238
|
+
mj codegen 5-0-fix-metadata-names --path metadata/entities/.audit-related-entities.json --fix
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
##### Common flags (all three commands)
|
|
242
|
+
|
|
243
|
+
| Flag | Short | Description |
|
|
244
|
+
|------|-------|-------------|
|
|
245
|
+
| `--path <dir\|file>` | `-p` | File or directory to scan. Defaults to current directory. |
|
|
246
|
+
| `--fix` | | Apply fixes in place. Without this flag, runs in dry-run mode. |
|
|
247
|
+
| `--entity-subclasses <path>` | | Path to `entity_subclasses.ts`. Auto-detected if omitted. |
|
|
248
|
+
| `--quiet` | `-q` | Suppress detailed output, show summary only. |
|
|
249
|
+
| `--verbose` | `-v` | Show detailed progress for each file scanned. |
|
|
250
|
+
|
|
251
|
+
##### Recommended migration workflow
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# 1. Scan everything first (dry-run)
|
|
255
|
+
mj codegen 5-0-fix-entity-names --path packages/
|
|
256
|
+
mj codegen 5-0-fix-html-entity-names --path packages/
|
|
257
|
+
mj codegen 5-0-fix-metadata-names --path metadata/
|
|
258
|
+
|
|
259
|
+
# 2. Review the output, then apply
|
|
260
|
+
mj codegen 5-0-fix-entity-names --path packages/ --fix
|
|
261
|
+
mj codegen 5-0-fix-html-entity-names --path packages/ --fix
|
|
262
|
+
mj codegen 5-0-fix-metadata-names --path metadata/ --fix
|
|
263
|
+
|
|
264
|
+
# 3. Build and test
|
|
265
|
+
npm run build
|
|
266
|
+
```
|
|
267
|
+
|
|
138
268
|
### mj sync
|
|
139
269
|
|
|
140
270
|
Metadata synchronization between JSON files and the database.
|
package/bin/dev.cmd
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
3
|
node "%~dp0\dev" %*
|
package/bin/run.cmd
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
|
|
3
|
-
node "%~dp0\run" %*
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
node "%~dp0\run" %*
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import type { ParserOutput } from '@oclif/core/lib/interfaces/parser';
|
|
3
2
|
export default class Clean extends Command {
|
|
4
3
|
static description: string;
|
|
5
4
|
static examples: string[];
|
|
6
5
|
static flags: {
|
|
7
6
|
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
7
|
};
|
|
9
|
-
flags: ParserOutput<Clean>['flags'];
|
|
10
8
|
run(): Promise<void>;
|
|
11
9
|
}
|
|
12
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/clean/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/clean/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAK7C,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,MAAM,CAAC,WAAW,SAAoE;IAEtF,MAAM,CAAC,QAAQ,WAGb;IAEF,MAAM,CAAC,KAAK;;MAEV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyC3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import {
|
|
3
|
-
import { getValidatedConfig, getFlywayConfig } from '../../config.js';
|
|
2
|
+
import { Skyway } from '@memberjunction/skyway-core';
|
|
4
3
|
import ora from 'ora-classic';
|
|
4
|
+
import { getValidatedConfig, getSkywayConfig } from '../../config.js';
|
|
5
5
|
export default class Clean extends Command {
|
|
6
6
|
static { this.description = 'Resets the MemberJunction database to a pre-installation state'; }
|
|
7
7
|
static { this.examples = [
|
|
@@ -12,30 +12,42 @@ export default class Clean extends Command {
|
|
|
12
12
|
verbose: Flags.boolean({ char: 'v', description: 'Enable additional logging' }),
|
|
13
13
|
}; }
|
|
14
14
|
async run() {
|
|
15
|
-
const
|
|
16
|
-
this.flags = parsed.flags;
|
|
15
|
+
const { flags } = await this.parse(Clean);
|
|
17
16
|
const config = getValidatedConfig();
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (config.cleanDisabled !== false) {
|
|
18
|
+
this.error('Clean is disabled. Set cleanDisabled: false in mj.config.cjs to enable.');
|
|
19
|
+
}
|
|
20
|
+
const skywayConfig = await getSkywayConfig(config);
|
|
21
|
+
const skyway = new Skyway(skywayConfig);
|
|
20
22
|
this.log('Resetting MJ database to pre-installation state');
|
|
21
23
|
this.log('Note that users and roles have not been dropped');
|
|
22
24
|
const spinner = ora('Cleaning up...');
|
|
23
25
|
spinner.start();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
try {
|
|
27
|
+
const result = await skyway.Clean();
|
|
28
|
+
if (result.Success) {
|
|
29
|
+
spinner.succeed();
|
|
30
|
+
this.log(`The database has been reset. ${result.ObjectsDropped} objects dropped.`);
|
|
31
|
+
if (result.DroppedObjects.length > 0) {
|
|
32
|
+
this.log(`Objects dropped:\n\t- ${result.DroppedObjects.join('\n\t- ')}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
spinner.fail();
|
|
37
|
+
this.logToStderr(`\nClean failed: ${result.ErrorMessage ?? 'unknown error'}`);
|
|
38
|
+
if (flags.verbose && result.DroppedObjects.length > 0) {
|
|
39
|
+
this.logToStderr(`Partial cleanup:\n\t- ${result.DroppedObjects.join('\n\t- ')}`);
|
|
36
40
|
}
|
|
41
|
+
this.error('Command failed');
|
|
37
42
|
}
|
|
38
|
-
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
spinner.fail();
|
|
46
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
47
|
+
this.error(`Clean error: ${message}`);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
await skyway.Close();
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/clean/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/clean/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEnE,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;aACjC,gBAAW,GAAG,gEAAgE,CAAC;aAE/E,aAAQ,GAAG;QAChB;CACH;KACE,CAAC;aAEK,UAAK,GAAG;QACb,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,E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I,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtD,IAAI,CAAC,WAAW,CAAC,yBAAyB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACpF,CAAC;gBACD,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,IAAI,CAAC,KAAK,CAAC,gBAAgB,OAAO,EAAE,CAAC,CAAC;QACxC,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class V50FixEntityNames extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: {
|
|
5
|
+
description: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}[];
|
|
8
|
+
static flags: {
|
|
9
|
+
path: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
fix: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'entity-subclasses': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=5-0-fix-entity-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5-0-fix-entity-names.d.ts","sourceRoot":"","sources":["../../../src/commands/codegen/5-0-fix-entity-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,OAAO;IAClD,MAAM,CAAC,WAAW,SASgF;IAElG,MAAM,CAAC,QAAQ;;;QAiBb;IAEF,MAAM,CAAC,KAAK;;;;;;MAsBV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsD7B"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
export default class V50FixEntityNames extends Command {
|
|
3
|
+
static { this.description = `[v5.0 Migration] Scan TypeScript files for entity names AND class names that need updating.
|
|
4
|
+
|
|
5
|
+
Three strategies are applied:
|
|
6
|
+
1. Class name renames (regex) — ActionEntity -> MJActionEntity, ActionSchema -> MJActionSchema, etc.
|
|
7
|
+
2. Multi-word entity name renames (regex) — 'AI Models' -> 'MJ: AI Models'
|
|
8
|
+
3. Single-word entity name renames (AST) — 'Actions' -> 'MJ: Actions' in GetEntityObject, OpenEntityRecord,
|
|
9
|
+
navigateToEntity, EntityName: assignments, .Name === comparisons, @RegisterClass decorators.
|
|
10
|
+
|
|
11
|
+
The rename map (272 entries) is built from entity_subclasses.ts @RegisterClass decorators plus
|
|
12
|
+
an embedded rename map for class name prefixes. Runs in dry-run mode by default; use --fix to apply.`; }
|
|
13
|
+
static { this.examples = [
|
|
14
|
+
{
|
|
15
|
+
description: 'Dry-run scan of the packages directory',
|
|
16
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
description: 'Scan a single file',
|
|
20
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/Angular/Explorer/dashboards/src/Actions/components/actions-overview.component.ts',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
description: 'Apply fixes across the codebase',
|
|
24
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/ --fix',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
description: 'Quiet mode (summary only)',
|
|
28
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/ -q',
|
|
29
|
+
},
|
|
30
|
+
]; }
|
|
31
|
+
static { this.flags = {
|
|
32
|
+
path: Flags.string({
|
|
33
|
+
char: 'p',
|
|
34
|
+
description: 'File or directory to scan. Accepts a single .ts file or a directory (scanned recursively). Defaults to the current working directory.',
|
|
35
|
+
}),
|
|
36
|
+
fix: Flags.boolean({
|
|
37
|
+
description: 'Apply fixes in place. Without this flag, the command runs in dry-run mode and only reports findings.',
|
|
38
|
+
default: false,
|
|
39
|
+
}),
|
|
40
|
+
'entity-subclasses': Flags.string({
|
|
41
|
+
description: 'Explicit path to entity_subclasses.ts for building the rename map. If omitted, the tool searches common locations relative to the target path.',
|
|
42
|
+
}),
|
|
43
|
+
quiet: Flags.boolean({
|
|
44
|
+
char: 'q',
|
|
45
|
+
description: 'Suppress detailed per-file output; only show the final summary counts.',
|
|
46
|
+
default: false,
|
|
47
|
+
}),
|
|
48
|
+
verbose: Flags.boolean({
|
|
49
|
+
char: 'v',
|
|
50
|
+
description: 'Show detailed progress including each file being scanned.',
|
|
51
|
+
default: false,
|
|
52
|
+
}),
|
|
53
|
+
}; }
|
|
54
|
+
async run() {
|
|
55
|
+
const { scanEntityNames } = await import('@memberjunction/codegen-lib');
|
|
56
|
+
const { flags } = await this.parse(V50FixEntityNames);
|
|
57
|
+
const result = await scanEntityNames({
|
|
58
|
+
TargetPath: flags.path || process.cwd(),
|
|
59
|
+
Fix: flags.fix,
|
|
60
|
+
EntitySubclassesPath: flags['entity-subclasses'],
|
|
61
|
+
Verbose: flags.verbose,
|
|
62
|
+
});
|
|
63
|
+
if (!result.Success) {
|
|
64
|
+
this.error(`Scan failed:\n${result.Errors.map((e) => ` - ${e}`).join('\n')}`);
|
|
65
|
+
}
|
|
66
|
+
if (!flags.quiet) {
|
|
67
|
+
this.log(`\nScanned ${result.FilesScanned} files, found ${result.Findings.length} reference(s) needing update`);
|
|
68
|
+
this.log(`Rename map: ${result.RenameMapSize} entity name mappings loaded`);
|
|
69
|
+
if (result.Findings.length > 0) {
|
|
70
|
+
// Strategy breakdown
|
|
71
|
+
const classNameCount = result.Findings.filter((f) => f.PatternKind === 'ClassName').length;
|
|
72
|
+
const multiWordCount = result.Findings.filter((f) => f.PatternKind === 'MultiWordEntityName').length;
|
|
73
|
+
const astCount = result.Findings.length - classNameCount - multiWordCount;
|
|
74
|
+
this.log(`\n Strategy breakdown:`);
|
|
75
|
+
if (classNameCount > 0)
|
|
76
|
+
this.log(` Class name renames: ${classNameCount}`);
|
|
77
|
+
if (multiWordCount > 0)
|
|
78
|
+
this.log(` Multi-word entity names: ${multiWordCount}`);
|
|
79
|
+
if (astCount > 0)
|
|
80
|
+
this.log(` Single-word entity names: ${astCount}`);
|
|
81
|
+
// Group by file for readable output
|
|
82
|
+
const byFile = new Map();
|
|
83
|
+
for (const f of result.Findings) {
|
|
84
|
+
if (!byFile.has(f.FilePath))
|
|
85
|
+
byFile.set(f.FilePath, []);
|
|
86
|
+
byFile.get(f.FilePath).push(f);
|
|
87
|
+
}
|
|
88
|
+
for (const [file, findings] of byFile) {
|
|
89
|
+
this.log(`\n ${file}:`);
|
|
90
|
+
for (const f of findings) {
|
|
91
|
+
this.log(` Line ${f.Line}: '${f.OldName}' -> '${f.NewName}' [${f.PatternKind}]`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (flags.fix) {
|
|
96
|
+
this.log(`\nFixed ${result.FixedFiles.length} file(s)`);
|
|
97
|
+
}
|
|
98
|
+
else if (result.Findings.length > 0) {
|
|
99
|
+
this.log(`\nRun with --fix to apply these changes`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=5-0-fix-entity-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5-0-fix-entity-names.js","sourceRoot":"","sources":["../../../src/commands/codegen/5-0-fix-entity-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,OAAO;aAC3C,gBAAW,GAAG;;;;;;;;;qGAS4E,CAAC;aAE3F,aAAQ,GAAG;QACd;YACI,WAAW,EAAE,wCAAwC;YACrD,OAAO,EAAE,sDAAsD;SAClE;QACD;YACI,WAAW,EAAE,oBAAoB;YACjC,OAAO,EAAE,sIAAsI;SAClJ;QACD;YACI,WAAW,EAAE,iCAAiC;YAC9C,OAAO,EAAE,4DAA4D;SACxE;QACD;YACI,WAAW,EAAE,2BAA2B;YACxC,OAAO,EAAE,yDAAyD;SACrE;KACJ,CAAC;aAEK,UAAK,GAAG;QACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,uIAAuI;SACvJ,CAAC;QACF,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;YACf,WAAW,EAAE,sGAAsG;YACnH,OAAO,EAAE,KAAK;SACjB,CAAC;QACF,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC;YAC9B,WAAW,EAAE,gJAAgJ;SAChK,CAAC;QACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;YACjB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,wEAAwE;YACrF,OAAO,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;YACnB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,2DAA2D;YACxE,OAAO,EAAE,KAAK;SACjB,CAAC;KACL,CAAC;IAEF,KAAK,CAAC,GAAG;Q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GAAG,EAAE,CAAC;gBACZ,IAAI,CAAC,GAAG,CAAC,WAAW,MAAM,CAAC,UAAU,CAAC,MAAM,UAAU,CAAC,CAAC;YAC5D,CAAC;iBAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;YACxD,CAAC;QACL,CAAC;IACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class V50FixHtmlEntityNames extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: {
|
|
5
|
+
description: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}[];
|
|
8
|
+
static flags: {
|
|
9
|
+
path: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
fix: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'entity-subclasses': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=5-0-fix-html-entity-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5-0-fix-html-entity-names.d.ts","sourceRoot":"","sources":["../../../src/commands/codegen/5-0-fix-html-entity-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,OAAO;IACtD,MAAM,CAAC,WAAW,SAQ4C;IAE9D,MAAM,CAAC,QAAQ;;;QAiBb;IAEF,MAAM,CAAC,KAAK;;;;;;MAsBV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4C7B"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
export default class V50FixHtmlEntityNames extends Command {
|
|
3
|
+
static { this.description = `[v5.0 Migration] Scan Angular HTML template files for hardcoded entity names that need "MJ: " prefix updates.
|
|
4
|
+
|
|
5
|
+
Uses targeted regex patterns to find entity name references in template expressions
|
|
6
|
+
and attribute values. Detects method calls like navigateToEntity('Actions'),
|
|
7
|
+
OpenEntityRecord('Entities', id), and attribute values like RowsEntityName="Users".
|
|
8
|
+
Runs in dry-run mode by default; use --fix to apply.
|
|
9
|
+
|
|
10
|
+
The rename map is built dynamically from entity_subclasses.ts by parsing all
|
|
11
|
+
@RegisterClass(BaseEntity, 'MJ: XYZ') decorators (~272 entries).`; }
|
|
12
|
+
static { this.examples = [
|
|
13
|
+
{
|
|
14
|
+
description: 'Dry-run scan of Angular templates',
|
|
15
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/Angular/',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
description: 'Apply fixes to HTML templates',
|
|
19
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/Angular/ --fix',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
description: 'Scan with verbose output',
|
|
23
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/ -v',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
description: 'Scan a single template file',
|
|
27
|
+
command: '<%= config.bin %> <%= command.id %> --path packages/Angular/Explorer/dashboards/src/Actions/actions-dashboard.component.html',
|
|
28
|
+
},
|
|
29
|
+
]; }
|
|
30
|
+
static { this.flags = {
|
|
31
|
+
path: Flags.string({
|
|
32
|
+
char: 'p',
|
|
33
|
+
description: 'File or directory to scan. Accepts a single .html file or a directory (scanned recursively). Defaults to the current working directory.',
|
|
34
|
+
}),
|
|
35
|
+
fix: Flags.boolean({
|
|
36
|
+
description: 'Apply fixes in place. Without this flag, the command runs in dry-run mode and only reports findings.',
|
|
37
|
+
default: false,
|
|
38
|
+
}),
|
|
39
|
+
'entity-subclasses': Flags.string({
|
|
40
|
+
description: 'Explicit path to entity_subclasses.ts for building the rename map. If omitted, the tool searches common locations relative to the target path.',
|
|
41
|
+
}),
|
|
42
|
+
quiet: Flags.boolean({
|
|
43
|
+
char: 'q',
|
|
44
|
+
description: 'Suppress detailed per-file output; only show the final summary counts.',
|
|
45
|
+
default: false,
|
|
46
|
+
}),
|
|
47
|
+
verbose: Flags.boolean({
|
|
48
|
+
char: 'v',
|
|
49
|
+
description: 'Show detailed progress including each file being scanned.',
|
|
50
|
+
default: false,
|
|
51
|
+
}),
|
|
52
|
+
}; }
|
|
53
|
+
async run() {
|
|
54
|
+
const { scanHtmlEntityNames } = await import('@memberjunction/codegen-lib');
|
|
55
|
+
const { flags } = await this.parse(V50FixHtmlEntityNames);
|
|
56
|
+
const result = await scanHtmlEntityNames({
|
|
57
|
+
TargetPath: flags.path || process.cwd(),
|
|
58
|
+
Fix: flags.fix,
|
|
59
|
+
EntitySubclassesPath: flags['entity-subclasses'],
|
|
60
|
+
Verbose: flags.verbose,
|
|
61
|
+
});
|
|
62
|
+
if (!result.Success) {
|
|
63
|
+
this.error(`Scan failed:\n${result.Errors.map((e) => ` - ${e}`).join('\n')}`);
|
|
64
|
+
}
|
|
65
|
+
if (!flags.quiet) {
|
|
66
|
+
this.log(`\nScanned ${result.FilesScanned} files, found ${result.Findings.length} entity name(s) needing update`);
|
|
67
|
+
this.log(`Rename map: ${result.RenameMapSize} entity name mappings loaded`);
|
|
68
|
+
if (result.Findings.length > 0) {
|
|
69
|
+
// Group by file for readable output
|
|
70
|
+
const byFile = new Map();
|
|
71
|
+
for (const f of result.Findings) {
|
|
72
|
+
if (!byFile.has(f.FilePath))
|
|
73
|
+
byFile.set(f.FilePath, []);
|
|
74
|
+
byFile.get(f.FilePath).push(f);
|
|
75
|
+
}
|
|
76
|
+
for (const [file, findings] of byFile) {
|
|
77
|
+
this.log(`\n ${file}:`);
|
|
78
|
+
for (const f of findings) {
|
|
79
|
+
this.log(` Line ${f.Line}: '${f.OldName}' -> '${f.NewName}' [${f.PatternKind}]`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (flags.fix) {
|
|
84
|
+
this.log(`\nFixed ${result.FixedFiles.length} file(s)`);
|
|
85
|
+
}
|
|
86
|
+
else if (result.Findings.length > 0) {
|
|
87
|
+
this.log(`\nRun with --fix to apply these changes`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=5-0-fix-html-entity-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5-0-fix-html-entity-names.js","sourceRoot":"","sources":["../../../src/commands/codegen/5-0-fix-html-entity-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,OAAO;aAC/C,gBAAW,GAAG;;;;;;;;iEAQwC,CAAC;aAEvD,aAAQ,GAAG;QACd;YACI,WAAW,EAAE,mCAAmC;YAChD,OAAO,EAAE,8DAA8D;SAC1E;QACD;YACI,WAAW,EAAE,+BAA+B;YAC5C,OAAO,EAAE,oEAAoE;SAChF;QACD;YACI,WAAW,EAAE,0BAA0B;YACvC,OAAO,EAAE,yDAAyD;SACrE;QACD;YACI,WAAW,EAAE,6BAA6B;YAC1C,OAAO,EAAE,8HAA8H;SAC1I;KACJ,CAAC;aAEK,UAAK,GAAG;QACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,yIAAyI;SACzJ,CAAC;QACF,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;YACf,WAAW,EAAE,sGAAsG;YACn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|
+
export default class V50FixMetadataNames extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: {
|
|
5
|
+
description: string;
|
|
6
|
+
command: string;
|
|
7
|
+
}[];
|
|
8
|
+
static flags: {
|
|
9
|
+
path: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
fix: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'entity-subclasses': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=5-0-fix-metadata-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5-0-fix-metadata-names.d.ts","sourceRoot":"","sources":["../../../src/commands/codegen/5-0-fix-metadata-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,OAAO;IACpD,MAAM,CAAC,WAAW,SAS4C;IAE9D,MAAM,CAAC,QAAQ;;;QAiBb;IAEF,MAAM,CAAC,KAAK;;;;;;MAsBV;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4C7B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
export default class V50FixMetadataNames extends Command {
|
|
3
|
+
static { this.description = `[v5.0 Migration] Scan metadata JSON files for entity names that need "MJ: " prefix updates.
|
|
4
|
+
|
|
5
|
+
Targets the metadata/ directory used by "mj sync". Detects entity name references in
|
|
6
|
+
@lookup: directives (both the entity name and lookup value), .mj-sync.json and
|
|
7
|
+
.mj-folder.json config files (entity/entityName fields), relatedEntities object keys,
|
|
8
|
+
and fields.Name values in Entities-managing folders. Runs in dry-run mode by default;
|
|
9
|
+
use --fix to apply.
|
|
10
|
+
|
|
11
|
+
The rename map is built dynamically from entity_subclasses.ts by parsing all
|
|
12
|
+
@RegisterClass(BaseEntity, 'MJ: XYZ') decorators (~272 entries).`; }
|
|
13
|
+
static { this.examples = [
|
|
14
|
+
{
|
|
15
|
+
description: 'Dry-run scan of the metadata directory',
|
|
16
|
+
command: '<%= config.bin %> <%= command.id %> --path metadata/',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
description: 'Apply fixes to metadata files',
|
|
20
|
+
command: '<%= config.bin %> <%= command.id %> --path metadata/ --fix',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
description: 'Scan a specific subdirectory',
|
|
24
|
+
command: '<%= config.bin %> <%= command.id %> --path metadata/resource-types',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
description: 'Scan and fix a single metadata file',
|
|
28
|
+
command: '<%= config.bin %> <%= command.id %> --path metadata/entities/.audit-related-entities.json --fix',
|
|
29
|
+
},
|
|
30
|
+
]; }
|
|
31
|
+
static { this.flags = {
|
|
32
|
+
path: Flags.string({
|
|
33
|
+
char: 'p',
|
|
34
|
+
description: 'File or directory to scan. Accepts a single .json file or a directory (scanned recursively, including dotfiles like .mj-sync.json). Defaults to the current working directory.',
|
|
35
|
+
}),
|
|
36
|
+
fix: Flags.boolean({
|
|
37
|
+
description: 'Apply fixes in place. Without this flag, the command runs in dry-run mode and only reports findings.',
|
|
38
|
+
default: false,
|
|
39
|
+
}),
|
|
40
|
+
'entity-subclasses': Flags.string({
|
|
41
|
+
description: 'Explicit path to entity_subclasses.ts for building the rename map. If omitted, the tool searches common locations relative to the target path.',
|
|
42
|
+
}),
|
|
43
|
+
quiet: Flags.boolean({
|
|
44
|
+
char: 'q',
|
|
45
|
+
description: 'Suppress detailed per-file output; only show the final summary counts.',
|
|
46
|
+
default: false,
|
|
47
|
+
}),
|
|
48
|
+
verbose: Flags.boolean({
|
|
49
|
+
char: 'v',
|
|
50
|
+
description: 'Show detailed progress including each file being scanned.',
|
|
51
|
+
default: false,
|
|
52
|
+
}),
|
|
53
|
+
}; }
|
|
54
|
+
async run() {
|
|
55
|
+
const { scanMetadataNames } = await import('@memberjunction/codegen-lib');
|
|
56
|
+
const { flags } = await this.parse(V50FixMetadataNames);
|
|
57
|
+
const result = await scanMetadataNames({
|
|
58
|
+
TargetPath: flags.path || process.cwd(),
|
|
59
|
+
Fix: flags.fix,
|
|
60
|
+
EntitySubclassesPath: flags['entity-subclasses'],
|
|
61
|
+
Verbose: flags.verbose,
|
|
62
|
+
});
|
|
63
|
+
if (!result.Success) {
|
|
64
|
+
this.error(`Scan failed:\n${result.Errors.map((e) => ` - ${e}`).join('\n')}`);
|
|
65
|
+
}
|
|
66
|
+
if (!flags.quiet) {
|
|
67
|
+
this.log(`\nScanned ${result.FilesScanned} files, found ${result.Findings.length} entity name(s) needing update`);
|
|
68
|
+
this.log(`Rename map: ${result.RenameMapSize} entity name mappings loaded`);
|
|
69
|
+
if (result.Findings.length > 0) {
|
|
70
|
+
// Group by file for readable output
|
|
71
|
+
const byFile = new Map();
|
|
72
|
+
for (const f of result.Findings) {
|
|
73
|
+
if (!byFile.has(f.FilePath))
|
|
74
|
+
byFile.set(f.FilePath, []);
|
|
75
|
+
byFile.get(f.FilePath).push(f);
|
|
76
|
+
}
|
|
77
|
+
for (const [file, findings] of byFile) {
|
|
78
|
+
this.log(`\n ${file}:`);
|
|
79
|
+
for (const f of findings) {
|
|
80
|
+
this.log(` Line ${f.Line}: '${f.OldName}' -> '${f.NewName}' [${f.PatternKind}]`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (flags.fix) {
|
|
85
|
+
this.log(`\nFixed ${result.FixedFiles.length} file(s)`);
|
|
86
|
+
}
|
|
87
|
+
else if (result.Findings.length > 0) {
|
|
88
|
+
this.log(`\nRun with --fix to apply these changes`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=5-0-fix-metadata-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5-0-fix-metadata-names.js","sourceRoot":"","sources":["../../../src/commands/codegen/5-0-fix-metadata-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,OAAO;aAC7C,gBAAW,GAAG;;;;;;;;;iEASwC,CAAC;aAEvD,aAAQ,GAAG;QACd;YACI,WAAW,EAAE,wCAAwC;YACrD,OAAO,EAAE,sDAAsD;SAClE;QACD;YACI,WAAW,EAAE,+BAA+B;YAC5C,OAAO,EAAE,4DAA4D;SACxE;QACD;YACI,WAAW,EAAE,8BAA8B;YAC3C,OAAO,EAAE,oEAAoE;SAChF;QACD;YACI,WAAW,EAAE,qCAAqC;YAClD,OAAO,EAAE,iGAAiG;SAC7G;KACJ,CAAC;aAEK,UAAK,GAAG;QACX,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,gLAAgL;SAChM,CAAC;QACF,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;YACf,WAAW,EAAE,sGAAsG;YACnH,OAAO,EAAE,KAAK;SACjB,CAAC;QACF,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC;YAC9B,WAAW,EAAE,gJAAgJ;SAChK,CAAC;QACF,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;YACjB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,wEAAwE;YACrF,OAAO,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;YACnB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,2D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