@ms-cloudpack/cli 0.73.5 → 0.73.7
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/lib/commands/init/InitSummaryData.d.ts +25 -5
- package/lib/commands/init/InitSummaryData.d.ts.map +1 -1
- package/lib/commands/init/InitSummaryData.js +31 -10
- package/lib/commands/init/InitSummaryData.js.map +1 -1
- package/lib/commands/init/formatInitSummary.d.ts +1 -2
- package/lib/commands/init/formatInitSummary.d.ts.map +1 -1
- package/lib/commands/init/formatInitSummary.js +102 -61
- package/lib/commands/init/formatInitSummary.js.map +1 -1
- package/lib/commands/init/types/GeneratedChange.d.ts +5 -0
- package/lib/commands/init/types/GeneratedChange.d.ts.map +1 -1
- package/lib/commands/init/types/GeneratedChange.js +9 -0
- package/lib/commands/init/types/GeneratedChange.js.map +1 -1
- package/lib/commands/init/types/InitSummary.d.ts +9 -1
- package/lib/commands/init/types/InitSummary.d.ts.map +1 -1
- package/lib/commands/init/types/InitSummary.js.map +1 -1
- package/lib/utilities/readLocalConfigs.d.ts.map +1 -1
- package/lib/utilities/readRemoteConfigs.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -3,6 +3,7 @@ import type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js
|
|
|
3
3
|
import type { InitPackageResult } from './types/InitPackageResult.js';
|
|
4
4
|
import type { InitOptions } from './types/InitOptions.js';
|
|
5
5
|
import type { BundleMessage } from '@ms-cloudpack/common-types';
|
|
6
|
+
import { type GeneratedChange } from './types/GeneratedChange.js';
|
|
6
7
|
import type { EnsurePackageBundledResult } from '@ms-cloudpack/api-server';
|
|
7
8
|
/**
|
|
8
9
|
* Creates a summary tracking helper for the `init` verb to use to record statistics about results and needed
|
|
@@ -13,7 +14,9 @@ import type { EnsurePackageBundledResult } from '@ms-cloudpack/api-server';
|
|
|
13
14
|
export declare class InitSummaryData {
|
|
14
15
|
/** Set this to indicate that the generated config was deleted. */
|
|
15
16
|
deletedGeneratedConfig: boolean;
|
|
17
|
+
/** Mapping from absolute package path to results */
|
|
16
18
|
private _packageResults;
|
|
19
|
+
/** Mapping from absolute package path to generated config updates */
|
|
17
20
|
private _generatedUpdates;
|
|
18
21
|
private _startTime;
|
|
19
22
|
private _appPath;
|
|
@@ -26,17 +29,22 @@ export declare class InitSummaryData {
|
|
|
26
29
|
*/
|
|
27
30
|
hasChanges(): boolean;
|
|
28
31
|
/**
|
|
29
|
-
* Saves a package result.
|
|
32
|
+
* Saves a package bundle result. Overwrites the previous result if there was one.
|
|
33
|
+
* @param packagePath - Absolute package path
|
|
30
34
|
*/
|
|
31
35
|
recordResult(packagePath: string, result: Pick<EnsurePackageBundledResult, 'name' | 'version' | 'info' | 'outputPath' | 'errors' | 'warnings'>): void;
|
|
32
36
|
/**
|
|
33
37
|
* Record an exception for a given package path.
|
|
34
38
|
* This creates a bundle message like "Error thrown while (context): (error)".
|
|
39
|
+
*
|
|
35
40
|
* (Unlike `addErrors`, this will create an overall package result if one doesn't exist yet.)
|
|
36
41
|
*/
|
|
37
42
|
recordException(params: {
|
|
43
|
+
/** Absolute package path */
|
|
38
44
|
packagePath: string;
|
|
45
|
+
/** Error object or other caught item */
|
|
39
46
|
error: unknown;
|
|
47
|
+
/** Bundler or step that generated this message. */
|
|
40
48
|
source: string;
|
|
41
49
|
/** Description of the context in which the error was thrown, e.g. "evaluating package" */
|
|
42
50
|
context: string;
|
|
@@ -47,20 +55,27 @@ export declare class InitSummaryData {
|
|
|
47
55
|
}): void;
|
|
48
56
|
/**
|
|
49
57
|
* Record more errors for a given package path.
|
|
58
|
+
* @param packagePath - Absolute package path
|
|
50
59
|
*/
|
|
51
60
|
addErrors(packagePath: string, errors: BundleMessage[]): void;
|
|
52
61
|
/**
|
|
53
62
|
* Record more warnings for a given package path.
|
|
63
|
+
* @param packagePath - Absolute package path
|
|
54
64
|
*/
|
|
55
65
|
addWarnings(packagePath: string, warnings: BundleMessage[]): void;
|
|
56
66
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @returns
|
|
67
|
+
* Get the recorded package results.
|
|
68
|
+
* @returns Mapping from absolute package path to results
|
|
59
69
|
*/
|
|
60
70
|
getResults(): Record<string, InitPackageResult>;
|
|
61
71
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
72
|
+
* Get the recorded generated config updates.
|
|
73
|
+
* @returns Mapping from absolute package path to generated config updates
|
|
74
|
+
*/
|
|
75
|
+
getGeneratedChanges(): Record<string, GeneratedPackageChanges>;
|
|
76
|
+
/**
|
|
77
|
+
* Save generated config updates, potentially from multiple packages.
|
|
78
|
+
* @param allChanges - The generated config update to save.
|
|
64
79
|
*/
|
|
65
80
|
recordGeneratedChanges(allChanges: GeneratedPackageChanges[]): void;
|
|
66
81
|
/**
|
|
@@ -68,4 +83,9 @@ export declare class InitSummaryData {
|
|
|
68
83
|
*/
|
|
69
84
|
summarize(): InitSummary;
|
|
70
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Sort generated changes in-place alphabetically by `.change` (description).
|
|
88
|
+
* Returns the array for convenience (though it's the same object).
|
|
89
|
+
*/
|
|
90
|
+
export declare function sortChanges(changes: GeneratedChange[]): GeneratedChange[];
|
|
71
91
|
//# sourceMappingURL=InitSummaryData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitSummaryData.d.ts","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"InitSummaryData.d.ts","sourceRo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F,OAAO,EAAE,MAAM,CAAC;QAChB,4EAA4E;QAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,+EAA+E;QAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI;IAUR;;;OAGG;IACI,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI;IASpE;;;OAGG;IACI,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI;IASxE;;;OAGG;IACI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAItD;;;OAGG;IACI,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC;IAIrE;;;OAGG;IACI,sBAAsB,CAAC,UAAU,EAAE,uBAAuB,EAAE,GAAG,IAAI;IAY1E;;OAEG;IACI,SAAS,IAAI,WAAW;CAgDhC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,eAAe,EAAE,CAEzE"}
|
|
@@ -8,7 +8,9 @@ import { requiredChangeTypes } from './types/GeneratedChange.js';
|
|
|
8
8
|
export class InitSummaryData {
|
|
9
9
|
/** Set this to indicate that the generated config was deleted. */
|
|
10
10
|
deletedGeneratedConfig = false;
|
|
11
|
+
/** Mapping from absolute package path to results */
|
|
11
12
|
_packageResults;
|
|
13
|
+
/** Mapping from absolute package path to generated config updates */
|
|
12
14
|
_generatedUpdates;
|
|
13
15
|
_startTime;
|
|
14
16
|
_appPath;
|
|
@@ -27,22 +29,25 @@ export class InitSummaryData {
|
|
|
27
29
|
return Object.values(this._generatedUpdates).length > 0;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
|
-
* Saves a package result.
|
|
32
|
+
* Saves a package bundle result. Overwrites the previous result if there was one.
|
|
33
|
+
* @param packagePath - Absolute package path
|
|
31
34
|
*/
|
|
32
35
|
recordResult(packagePath, result) {
|
|
33
36
|
this._packageResults[packagePath] = {
|
|
34
37
|
path: packagePath,
|
|
35
38
|
name: result.name,
|
|
36
39
|
version: result.version,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
// this is mainly for easier testing: don't set properties if they'll be undefined
|
|
41
|
+
...(result.info && { info: result.info }),
|
|
42
|
+
...(result.outputPath && { outputPath: result.outputPath }),
|
|
43
|
+
...(result.errors && { errors: result.errors }),
|
|
44
|
+
...(result.warnings && { warnings: result.warnings }),
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Record an exception for a given package path.
|
|
45
49
|
* This creates a bundle message like "Error thrown while (context): (error)".
|
|
50
|
+
*
|
|
46
51
|
* (Unlike `addErrors`, this will create an overall package result if one doesn't exist yet.)
|
|
47
52
|
*/
|
|
48
53
|
recordException(params) {
|
|
@@ -55,6 +60,7 @@ export class InitSummaryData {
|
|
|
55
60
|
}
|
|
56
61
|
/**
|
|
57
62
|
* Record more errors for a given package path.
|
|
63
|
+
* @param packagePath - Absolute package path
|
|
58
64
|
*/
|
|
59
65
|
addErrors(packagePath, errors) {
|
|
60
66
|
const packageResult = this._packageResults[packagePath];
|
|
@@ -65,6 +71,7 @@ export class InitSummaryData {
|
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* Record more warnings for a given package path.
|
|
74
|
+
* @param packagePath - Absolute package path
|
|
68
75
|
*/
|
|
69
76
|
addWarnings(packagePath, warnings) {
|
|
70
77
|
const packageResult = this._packageResults[packagePath];
|
|
@@ -74,15 +81,22 @@ export class InitSummaryData {
|
|
|
74
81
|
packageResult.warnings = [...(packageResult.warnings || []), ...warnings];
|
|
75
82
|
}
|
|
76
83
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @returns
|
|
84
|
+
* Get the recorded package results.
|
|
85
|
+
* @returns Mapping from absolute package path to results
|
|
79
86
|
*/
|
|
80
87
|
getResults() {
|
|
81
88
|
return this._packageResults;
|
|
82
89
|
}
|
|
83
90
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @
|
|
91
|
+
* Get the recorded generated config updates.
|
|
92
|
+
* @returns Mapping from absolute package path to generated config updates
|
|
93
|
+
*/
|
|
94
|
+
getGeneratedChanges() {
|
|
95
|
+
return this._generatedUpdates;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Save generated config updates, potentially from multiple packages.
|
|
99
|
+
* @param allChanges - The generated config update to save.
|
|
86
100
|
*/
|
|
87
101
|
recordGeneratedChanges(allChanges) {
|
|
88
102
|
for (const update of allChanges) {
|
|
@@ -123,7 +137,7 @@ export class InitSummaryData {
|
|
|
123
137
|
for (const updates of sortedUpdates) {
|
|
124
138
|
totalChanges += updates.changes.length;
|
|
125
139
|
totalRequiredChanges += updates.changes.filter((u) => requiredChangeTypes[u.type]).length;
|
|
126
|
-
updates.changes
|
|
140
|
+
sortChanges(updates.changes);
|
|
127
141
|
}
|
|
128
142
|
return {
|
|
129
143
|
appPath: this._appPath,
|
|
@@ -142,4 +156,11 @@ export class InitSummaryData {
|
|
|
142
156
|
};
|
|
143
157
|
}
|
|
144
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Sort generated changes in-place alphabetically by `.change` (description).
|
|
161
|
+
* Returns the array for convenience (though it's the same object).
|
|
162
|
+
*/
|
|
163
|
+
export function sortChanges(changes) {
|
|
164
|
+
return changes.sort((a, b) => a.change.localeCompare(b.change));
|
|
165
|
+
}
|
|
145
166
|
//# sourceMappingURL=InitSummaryData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitSummaryData.js","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAC1B,kEAAkE;IAC3D,sBAAsB,GAAG,KAAK,CAAC;IAE9B,eAAe,CAAoC;IACnD,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AAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAEzG,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;YACpC,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;YAC1F,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ;YACR,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM;YACvD,YAAY;YACZ,WAAW;YACX,aAAa;YACb,YAAY;YACZ,oBAAoB;YACpB,MAAM,EAAE,WAAW,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,oBAAoB,GAAG,CAAC,CAAC;YACpE,kBAAkB;YAClB,oBAAoB;YACpB,oBAAoB,EAAE,aAAa;YACnC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;SACpD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { InitSummary } from './types/InitSummary.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport type {\n InitPackageResult,\n InitPackageResultErrors,\n InitPackageResultWarnings,\n} from './types/InitPackageResult.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { BundleMessage } from '@ms-cloudpack/common-types';\nimport { requiredChangeTypes } from './types/GeneratedChange.js';\nimport type { EnsurePackageBundledResult } from '@ms-cloudpack/api-server';\n\n/**\n * Creates a summary tracking helper for the `init` verb to use to record statistics about results and needed\n * changes. The `record*` methods of the returned object will be used within init to add the stats, and the\n * `summarize` method will return the final tally. The resulting `InitSummary` object can be used in the\n * `formatInitSummary` helper to convert it to a string for the user.\n */\nexport class InitSummaryData {\n /** Set this to indicate that the generated config was deleted. */\n public deletedGeneratedConfig = false;\n\n private _packageResults: Record<string, InitPackageResult>;\n private _generatedUpdates: Record<string, GeneratedPackageChanges>;\n private _startTime: number;\n private _appPath: string;\n private _check: boolean;\n\n constructor(\n params: Pick<InitOptions, 'check'> & {\n appPath: string;\n },\n ) {\n this._packageResults = {};\n this._generatedUpdates = {};\n this._startTime = Date.now();\n this._appPath = params.appPath;\n this._check = !!params.check;\n }\n\n /**\n * Returns whether any generated changes have been recorded.\n */\n public hasChanges(): boolean {\n return Object.values(this._generatedUpdates).length > 0;\n }\n\n /**\n * Saves a package result.\n */\n public recordResult(\n packagePath: string,\n result: Pick<EnsurePackageBundledResult, 'name' | 'version' | 'info' | 'outputPath' | 'errors' | 'warnings'>,\n ): void {\n this._packageResults[packagePath] = {\n path: packagePath,\n name: result.name,\n version: result.version,\n info: result.info,\n outputPath: result.outputPath,\n errors: result.errors,\n warnings: result.warnings,\n };\n }\n\n /**\n * Record an exception for a given package path.\n * This creates a bundle message like \"Error thrown while (context): (error)\".\n * (Unlike `addErrors`, this will create an overall package result if one doesn't exist yet.)\n */\n public recordException(params: {\n packagePath: string;\n error: unknown;\n source: string;\n /** Description of the context in which the error was thrown, e.g. \"evaluating package\" */\n context: string;\n /** Package name in case no result has been recorded for this package yet */\n name?: string;\n /** Package version in case no result has been recorded for this package yet */\n version?: string;\n }): void {\n const { packagePath, error, source, context, name = '<unknown>', version = '<unknown>' } = params;\n if (!this._packageResults[packagePath]) {\n this.recordResult(packagePath, { name, version });\n }\n\n const text = `Error thrown while ${context}: ${(error as Error).stack || error}`;\n this.addErrors(packagePath, [{ text, source }]);\n }\n\n /**\n * Record more errors for a given package path.\n */\n public addErrors(packagePath: string, errors: BundleMessage[]): void {\n const packageResult = this._packageResults[packagePath];\n if (!packageResult) {\n throw new Error(`Package result not found for path ${packagePath}`);\n }\n\n packageResult.errors = [...(packageResult.errors || []), ...errors];\n }\n\n /**\n * Record more warnings for a given package path.\n */\n public addWarnings(packagePath: string, warnings: BundleMessage[]): void {\n const packageResult = this._packageResults[packagePath];\n if (!packageResult) {\n throw new Error(`Package result not found for path ${packagePath}`);\n }\n\n packageResult.warnings = [...(packageResult.warnings || []), ...warnings];\n }\n\n /**\n * Returns the package results.\n * @returns The package results.\n */\n public getResults(): Record<string, InitPackageResult> {\n return this._packageResults;\n }\n\n /**\n * Saves a generated file update.\n * @param allChanges - The generated file update to save.\n */\n public recordGeneratedChanges(allChanges: GeneratedPackageChanges[]): void {\n for (const update of allChanges) {\n const { name, version, path, changes } = update;\n // Only record changes if there are any, so that hasChanges() is accurate.\n if (changes.length) {\n const updatesForPackage = (this._generatedUpdates[path] ??= { name, version, path, changes: [] });\n\n updatesForPackage.changes.push(...changes);\n }\n }\n }\n\n /**\n * Returns the summary of the results.\n */\n public summarize(): InitSummary {\n const duration = Date.now() - this._startTime;\n let totalSuccess = 0;\n let totalErrors = 0;\n let totalWarnings = 0;\n let totalChanges = 0;\n let totalRequiredChanges = 0;\n const packagesWithErrors: InitPackageResultErrors[] = [];\n const packagesWithWarnings: InitPackageResultWarnings[] = [];\n\n for (const packageResult of Object.values(this._packageResults)) {\n if (packageResult.errors?.length) {\n packagesWithErrors.push(packageResult as InitPackageResultErrors);\n totalErrors += packageResult.errors.length;\n } else {\n totalSuccess++;\n }\n\n if (packageResult.warnings?.length) {\n packagesWithWarnings.push(packageResult as InitPackageResultWarnings);\n totalWarnings += packageResult.warnings.length;\n }\n }\n\n const sortedUpdates = Object.values(this._generatedUpdates).sort((a, b) => a.path.localeCompare(b.path));\n\n for (const updates of sortedUpdates) {\n totalChanges += updates.changes.length;\n totalRequiredChanges += updates.changes.filter((u) => requiredChangeTypes[u.type]).length;\n updates.changes = updates.changes.sort((a, b) => a.change.localeCompare(b.change));\n }\n\n return {\n appPath: this._appPath,\n duration,\n totalPackages: Object.keys(this._packageResults).length,\n totalSuccess,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n failed: totalErrors > 0 || (this._check && totalRequiredChanges > 0),\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates: sortedUpdates,\n deletedGeneratedConfig: this.deletedGeneratedConfig,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InitSummaryData.js","sourceRoot":"","sources":["../../../src/commands/init/InitSummaryData.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAwB,MAAM,4BAA4B,CAAC;AAGvF;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAC1B,kEAAkE;IAC3D,sBAAsB,GAAG,KAAK,CAAC;IAEtC,oDAAoD;IAC5C,eAAe,CAAoC;IAC3D,qEAAqE;IAC7D,iBAAiB,CAA0C;IAC3D,UAAU,CAAS;IACnB,QAAQ,CAAS;IACjB,MAAM,CAAU;IAExB,YACE,MAEC;QAED,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACI,YAAY,CACjB,WAAmB,EACnB,MAA4G;QAE5G,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG;YAClC,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;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QAC/B,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ;YACR,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM;YACvD,YAAY;YACZ,WAAW;YACX,aAAa;YACb,YAAY;YACZ,oBAAoB;YACpB,MAAM,EAAE,WAAW,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,oBAAoB,GAAG,CAAC,CAAC;YACpE,kBAAkB;YAClB,oBAAoB;YACpB,oBAAoB,EAAE,aAAa;YACnC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;SACpD,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAA0B;IACpD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { InitSummary } from './types/InitSummary.js';\nimport type { GeneratedPackageChanges } from './types/GeneratedPackageChanges.js';\nimport type {\n InitPackageResult,\n InitPackageResultErrors,\n InitPackageResultWarnings,\n} from './types/InitPackageResult.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { BundleMessage } from '@ms-cloudpack/common-types';\nimport { requiredChangeTypes, type GeneratedChange } from './types/GeneratedChange.js';\nimport type { EnsurePackageBundledResult } from '@ms-cloudpack/api-server';\n\n/**\n * Creates a summary tracking helper for the `init` verb to use to record statistics about results and needed\n * changes. The `record*` methods of the returned object will be used within init to add the stats, and the\n * `summarize` method will return the final tally. The resulting `InitSummary` object can be used in the\n * `formatInitSummary` helper to convert it to a string for the user.\n */\nexport class InitSummaryData {\n /** Set this to indicate that the generated config was deleted. */\n public deletedGeneratedConfig = false;\n\n /** Mapping from absolute package path to results */\n private _packageResults: Record<string, InitPackageResult>;\n /** Mapping from absolute package path to generated config updates */\n private _generatedUpdates: Record<string, GeneratedPackageChanges>;\n private _startTime: number;\n private _appPath: string;\n private _check: boolean;\n\n constructor(\n params: Pick<InitOptions, 'check'> & {\n appPath: string;\n },\n ) {\n this._packageResults = {};\n this._generatedUpdates = {};\n this._startTime = Date.now();\n this._appPath = params.appPath;\n this._check = !!params.check;\n }\n\n /**\n * Returns whether any generated changes have been recorded.\n */\n public hasChanges(): boolean {\n return Object.values(this._generatedUpdates).length > 0;\n }\n\n /**\n * Saves a package bundle result. Overwrites the previous result if there was one.\n * @param packagePath - Absolute package path\n */\n public recordResult(\n packagePath: string,\n result: Pick<EnsurePackageBundledResult, 'name' | 'version' | 'info' | 'outputPath' | 'errors' | 'warnings'>,\n ): void {\n this._packageResults[packagePath] = {\n path: packagePath,\n name: result.name,\n version: result.version,\n // this is mainly for easier testing: don't set properties if they'll be undefined\n ...(result.info && { info: result.info }),\n ...(result.outputPath && { outputPath: result.outputPath }),\n ...(result.errors && { errors: result.errors }),\n ...(result.warnings && { warnings: result.warnings }),\n };\n }\n\n /**\n * Record an exception for a given package path.\n * This creates a bundle message like \"Error thrown while (context): (error)\".\n *\n * (Unlike `addErrors`, this will create an overall package result if one doesn't exist yet.)\n */\n public recordException(params: {\n /** Absolute package path */\n packagePath: string;\n /** Error object or other caught item */\n error: unknown;\n /** Bundler or step that generated this message. */\n source: string;\n /** Description of the context in which the error was thrown, e.g. \"evaluating package\" */\n context: string;\n /** Package name in case no result has been recorded for this package yet */\n name?: string;\n /** Package version in case no result has been recorded for this package yet */\n version?: string;\n }): void {\n const { packagePath, error, source, context, name = '<unknown>', version = '<unknown>' } = params;\n if (!this._packageResults[packagePath]) {\n this.recordResult(packagePath, { name, version });\n }\n\n const text = `Error thrown while ${context}: ${(error as Error).stack || error}`;\n this.addErrors(packagePath, [{ text, source }]);\n }\n\n /**\n * Record more errors for a given package path.\n * @param packagePath - Absolute package path\n */\n public addErrors(packagePath: string, errors: BundleMessage[]): void {\n const packageResult = this._packageResults[packagePath];\n if (!packageResult) {\n throw new Error(`Package result not found for path ${packagePath}`);\n }\n\n packageResult.errors = [...(packageResult.errors || []), ...errors];\n }\n\n /**\n * Record more warnings for a given package path.\n * @param packagePath - Absolute package path\n */\n public addWarnings(packagePath: string, warnings: BundleMessage[]): void {\n const packageResult = this._packageResults[packagePath];\n if (!packageResult) {\n throw new Error(`Package result not found for path ${packagePath}`);\n }\n\n packageResult.warnings = [...(packageResult.warnings || []), ...warnings];\n }\n\n /**\n * Get the recorded package results.\n * @returns Mapping from absolute package path to results\n */\n public getResults(): Record<string, InitPackageResult> {\n return this._packageResults;\n }\n\n /**\n * Get the recorded generated config updates.\n * @returns Mapping from absolute package path to generated config updates\n */\n public getGeneratedChanges(): Record<string, GeneratedPackageChanges> {\n return this._generatedUpdates;\n }\n\n /**\n * Save generated config updates, potentially from multiple packages.\n * @param allChanges - The generated config update to save.\n */\n public recordGeneratedChanges(allChanges: GeneratedPackageChanges[]): void {\n for (const update of allChanges) {\n const { name, version, path, changes } = update;\n // Only record changes if there are any, so that hasChanges() is accurate.\n if (changes.length) {\n const updatesForPackage = (this._generatedUpdates[path] ??= { name, version, path, changes: [] });\n\n updatesForPackage.changes.push(...changes);\n }\n }\n }\n\n /**\n * Returns the summary of the results.\n */\n public summarize(): InitSummary {\n const duration = Date.now() - this._startTime;\n let totalSuccess = 0;\n let totalErrors = 0;\n let totalWarnings = 0;\n let totalChanges = 0;\n let totalRequiredChanges = 0;\n const packagesWithErrors: InitPackageResultErrors[] = [];\n const packagesWithWarnings: InitPackageResultWarnings[] = [];\n\n for (const packageResult of Object.values(this._packageResults)) {\n if (packageResult.errors?.length) {\n packagesWithErrors.push(packageResult as InitPackageResultErrors);\n totalErrors += packageResult.errors.length;\n } else {\n totalSuccess++;\n }\n\n if (packageResult.warnings?.length) {\n packagesWithWarnings.push(packageResult as InitPackageResultWarnings);\n totalWarnings += packageResult.warnings.length;\n }\n }\n\n const sortedUpdates = Object.values(this._generatedUpdates).sort((a, b) => a.path.localeCompare(b.path));\n\n for (const updates of sortedUpdates) {\n totalChanges += updates.changes.length;\n totalRequiredChanges += updates.changes.filter((u) => requiredChangeTypes[u.type]).length;\n sortChanges(updates.changes);\n }\n\n return {\n appPath: this._appPath,\n duration,\n totalPackages: Object.keys(this._packageResults).length,\n totalSuccess,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n failed: totalErrors > 0 || (this._check && totalRequiredChanges > 0),\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates: sortedUpdates,\n deletedGeneratedConfig: this.deletedGeneratedConfig,\n };\n }\n}\n\n/**\n * Sort generated changes in-place alphabetically by `.change` (description).\n * Returns the array for convenience (though it's the same object).\n */\nexport function sortChanges(changes: GeneratedChange[]): GeneratedChange[] {\n return changes.sort((a, b) => a.change.localeCompare(b.change));\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InitOptions } from './types/InitOptions.js';
|
|
2
2
|
import type { InitSummary } from './types/InitSummary.js';
|
|
3
|
-
interface FormatSummaryParams extends Pick<InitOptions, 'check'> {
|
|
3
|
+
export interface FormatSummaryParams extends Pick<InitOptions, 'check'> {
|
|
4
4
|
summary: InitSummary;
|
|
5
5
|
isMultiApp?: boolean;
|
|
6
6
|
verb: 'init' | 'bundle';
|
|
@@ -10,5 +10,4 @@ interface FormatSummaryParams extends Pick<InitOptions, 'check'> {
|
|
|
10
10
|
* Given a summary and options, returns a formatted string message to display to the user via console.
|
|
11
11
|
*/
|
|
12
12
|
export declare function formatInitSummary(params: FormatSummaryParams): string;
|
|
13
|
-
export {};
|
|
14
13
|
//# sourceMappingURL=formatInitSummary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInitSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI1D,
|
|
1
|
+
{"version":3,"file":"formatInitSummary.d.ts","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI1D,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC;IACrE,OAAO,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAsBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAuHrE"}
|
|
@@ -12,83 +12,103 @@ const statusByType = {
|
|
|
12
12
|
add: '+',
|
|
13
13
|
success: prefixCharacters.complete,
|
|
14
14
|
};
|
|
15
|
+
/** "cloudpack.generated.json" with color */
|
|
16
|
+
const generatedConfigFile = cyan('cloudpack.generated.json');
|
|
17
|
+
/** "cloudpack init" with color and quotes */
|
|
18
|
+
const cloudpackInit = `"${yellow('cloudpack init')}"`;
|
|
15
19
|
/**
|
|
16
20
|
* Given a summary and options, returns a formatted string message to display to the user via console.
|
|
17
21
|
*/
|
|
18
22
|
export function formatInitSummary(params) {
|
|
19
23
|
const { summary, check, isInterrupted, isMultiApp, verb } = params;
|
|
20
|
-
|
|
24
|
+
/** Sections of the summary that will be joined with two newlines */
|
|
25
|
+
const summarySections = [];
|
|
21
26
|
const { totalPackages, totalErrors, totalWarnings, totalChanges, totalRequiredChanges, packagesWithErrors, packagesWithWarnings, generatedFileUpdates, deletedGeneratedConfig, } = summary;
|
|
27
|
+
// With --check, show required changes even if there are errors.
|
|
28
|
+
// Otherwise, skip since they'll be applied automatically once errors are fixed.
|
|
29
|
+
const showRequiredChanges = !!(totalRequiredChanges && (!totalErrors || check));
|
|
22
30
|
const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
summaryString.push(formatPackageUpdates({ generatedFileUpdates, check }));
|
|
31
|
+
let warnings;
|
|
32
|
+
let generatedChanges;
|
|
33
|
+
// In single-app mode, report packages with warnings.
|
|
34
|
+
if (!isMultiApp && packagesWithWarnings.length) {
|
|
35
|
+
warnings = formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' });
|
|
29
36
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
// Report required changes if appropriate (see showRequiredChanges)
|
|
38
|
+
if (showRequiredChanges) {
|
|
39
|
+
generatedChanges = formatPackageUpdates({ generatedFileUpdates, check, hasErrors: !!totalErrors });
|
|
40
|
+
}
|
|
41
|
+
if (check) {
|
|
42
|
+
// With --check, it's most helpful to show warnings then generated changes. Required changes
|
|
43
|
+
// are errors in that context, and if they're listed above warnings, it's easy to miss them,
|
|
44
|
+
// which might lead to confusion.
|
|
45
|
+
warnings && summarySections.push(warnings);
|
|
46
|
+
generatedChanges && summarySections.push(generatedChanges);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Without --check, show generated changes first, then warnings. In this case, any generated
|
|
50
|
+
// change listing is just informational (the changes were already made), but the warnings
|
|
51
|
+
// require manual intervention if the user wants to fix them.
|
|
52
|
+
generatedChanges && summarySections.push(generatedChanges);
|
|
53
|
+
warnings && summarySections.push(warnings);
|
|
35
54
|
}
|
|
36
55
|
// Report packages with errors.
|
|
37
56
|
if (packagesWithErrors.length) {
|
|
38
|
-
|
|
57
|
+
summarySections.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }));
|
|
39
58
|
}
|
|
40
59
|
if (deletedGeneratedConfig) {
|
|
41
|
-
|
|
60
|
+
summarySections.push(`Deleted the ${generatedConfigFile} file because it is no longer needed.`);
|
|
42
61
|
}
|
|
43
62
|
if (totalPackages > 1 || verb === 'init') {
|
|
63
|
+
// Report totals
|
|
44
64
|
const action = verb === 'init' ? 'evaluated' : 'bundled';
|
|
45
|
-
|
|
65
|
+
const totalLines = [
|
|
66
|
+
`${cyan(plural(totalPackages, 'total package'))} ${action} in ${formatTime(summary.duration)}${incompleteText}`,
|
|
67
|
+
];
|
|
46
68
|
const errorPkgCount = packagesWithErrors.length;
|
|
47
69
|
const succesPkgCount = totalPackages - errorPkgCount;
|
|
48
70
|
const warningPkgCount = packagesWithWarnings.length;
|
|
49
71
|
const optionalChangesCount = totalChanges - totalRequiredChanges;
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
// + 2 changes made to generated config
|
|
53
|
-
// ! 3 packages with warnings (5 total warnings)
|
|
54
|
-
// ✗ 1 package with errors (2 total errors)
|
|
55
|
-
// With --check:
|
|
56
|
-
// ✓ 5 packages evaluated without errors
|
|
57
|
-
// ! 2 optional changes could be made to generated config
|
|
58
|
-
// ! 3 packages with warnings (5 total warnings)
|
|
59
|
-
// ✗ 1 required change missing from generated config
|
|
60
|
-
// ✗ 1 package with errors (2 total errors)
|
|
61
|
-
// (bundle will only ever show the main warnings)
|
|
62
|
-
summaryString.push(...[
|
|
72
|
+
// See snapshots for examples of this output
|
|
73
|
+
totalLines.push(...[
|
|
63
74
|
// "without errors" because they might have warnings
|
|
64
75
|
formatCount('success', succesPkgCount, 'package', `${action} without errors`),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
!errorPkgCount &&
|
|
77
|
+
(check
|
|
78
|
+
? // For --check, only show optional changes if there are no errors, and format the
|
|
79
|
+
// optional changes as warnings. (required changes will be shown below)
|
|
80
|
+
formatCount('warn', optionalChangesCount, 'optional change', 'could be made to generated config')
|
|
81
|
+
: // If updating, show the total changes made.
|
|
82
|
+
formatCount('add', totalChanges, 'change', 'made to generated config')),
|
|
71
83
|
formatCount('warn', warningPkgCount, 'package', 'with warnings', totalWarnings, 'total warning'),
|
|
84
|
+
// For --check, show required changes as errors.
|
|
72
85
|
check && formatCount('error', totalRequiredChanges, 'required change', 'missing from generated config'),
|
|
73
86
|
formatCount('error', errorPkgCount, 'package', 'with errors', totalErrors, 'total error'),
|
|
74
87
|
].filter(Boolean));
|
|
88
|
+
if (totalLines.length > 1) {
|
|
89
|
+
// add a colon to the first line if there are other lines
|
|
90
|
+
totalLines[0] += ':';
|
|
91
|
+
}
|
|
92
|
+
summarySections.push(totalLines.join('\n'));
|
|
75
93
|
}
|
|
76
94
|
if (isInterrupted) {
|
|
77
|
-
|
|
95
|
+
summarySections.push(yellow(bold('Process was interrupted before all tasks could complete.')));
|
|
78
96
|
}
|
|
79
|
-
else if (check && totalRequiredChanges) {
|
|
80
|
-
|
|
97
|
+
else if (check && totalRequiredChanges && !totalErrors) {
|
|
98
|
+
// Skip the instruction to update the generated config if there were errors.
|
|
99
|
+
summarySections.push(`Run ${cloudpackInit} in ${summary.appPath} to apply missing changes to the ${generatedConfigFile} file.`);
|
|
81
100
|
}
|
|
82
101
|
// Skip the header if there was nothing to report.
|
|
83
|
-
if (
|
|
102
|
+
if (summarySections.length) {
|
|
84
103
|
// For bundle, we just say "summary" since `appPath` might not actually be the path that was bundled.
|
|
85
|
-
|
|
86
|
-
summaryString.push('\n');
|
|
104
|
+
summarySections.unshift(bold(`==== ${verb === 'bundle' ? 'Summary' : `Summary for ${summary.appPath}`} ====`));
|
|
87
105
|
}
|
|
88
|
-
|
|
89
|
-
.join('\n')
|
|
106
|
+
const summaryString = summarySections
|
|
107
|
+
.join('\n\n')
|
|
90
108
|
// replace >= 3 newlines with 2 newlines
|
|
91
|
-
.replace(/\n{3,}/g, '\n\n')
|
|
109
|
+
.replace(/\n{3,}/g, '\n\n');
|
|
110
|
+
// Ensure a final newline for readability, unless it's empty.
|
|
111
|
+
return !summaryString || summaryString.endsWith('\n') ? summaryString : summaryString + '\n';
|
|
92
112
|
}
|
|
93
113
|
/**
|
|
94
114
|
* If `count > 0`, return a pluralized formatted string like "+ 5 items description"
|
|
@@ -109,27 +129,44 @@ function formatCount(type, count, item, description, extraCount, extraItem) {
|
|
|
109
129
|
return undefined;
|
|
110
130
|
}
|
|
111
131
|
function formatPackageUpdates(params) {
|
|
112
|
-
const { generatedFileUpdates, check, isInterrupted } = params;
|
|
132
|
+
const { generatedFileUpdates, check, isInterrupted, hasErrors } = params;
|
|
133
|
+
// mapping from change type to [description, optional plural description]
|
|
113
134
|
const descriptions = {
|
|
114
|
-
'added-export': `path$s ${check ? 'missing from' : 'added to'} exports map
|
|
115
|
-
'included-dependency-required': 'dependency
|
|
116
|
-
'changed-export': 'previously unused export path
|
|
117
|
-
'added-dynamic-import': 'dynamic import$s added',
|
|
135
|
+
'added-export': [`path$s ${check ? 'missing from' : 'added to'} exports map`],
|
|
136
|
+
'included-dependency-required': ['dependency required to be included', 'dependencies required to be included'],
|
|
137
|
+
'changed-export': ['previously unused export path$s now used'],
|
|
138
|
+
'added-dynamic-import': ['dynamic import$s added'],
|
|
118
139
|
};
|
|
119
140
|
const summaryString = [];
|
|
120
141
|
for (const packageUpdates of generatedFileUpdates) {
|
|
142
|
+
// list of update type descriptions and updates of that type
|
|
143
|
+
const updates = [];
|
|
121
144
|
for (const type of Object.keys(descriptions)) {
|
|
122
145
|
const typeUpdates = packageUpdates.changes.filter((u) => u.type === type);
|
|
123
146
|
if (typeUpdates.length) {
|
|
124
|
-
const description = plural(typeUpdates.length, descriptions[type]);
|
|
125
|
-
|
|
126
|
-
const issueType = check ? 'warn' : 'add';
|
|
127
|
-
summaryString.push(formatPackageHeader({ ...packageUpdates, issueType, description }), bulletedList(typeUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)), '');
|
|
147
|
+
const description = plural(typeUpdates.length, ...descriptions[type]);
|
|
148
|
+
updates.push([description, typeUpdates]);
|
|
128
149
|
}
|
|
129
150
|
}
|
|
151
|
+
if (updates.length) {
|
|
152
|
+
summaryString.push(formatPackageHeader(packageUpdates));
|
|
153
|
+
for (const [description, typeUpdates] of updates) {
|
|
154
|
+
summaryString.push(
|
|
155
|
+
// If updates are required, format them as errors.
|
|
156
|
+
formatPackageSubhead({ issueType: check ? 'error' : 'add', description }), bulletedList(typeUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)));
|
|
157
|
+
}
|
|
158
|
+
summaryString.push('');
|
|
159
|
+
}
|
|
130
160
|
}
|
|
131
161
|
if (summaryString.length) {
|
|
132
|
-
|
|
162
|
+
const needsUpdates = check || isInterrupted;
|
|
163
|
+
const extraInstructions = needsUpdates
|
|
164
|
+
? hasErrors
|
|
165
|
+
? `fix errors first, then run ${cloudpackInit}`
|
|
166
|
+
: `run ${cloudpackInit} to fix`
|
|
167
|
+
: '';
|
|
168
|
+
summaryString.unshift(bold(`Updates ${needsUpdates ? 'needed for' : 'made to'} ${generatedConfigFile}`) +
|
|
169
|
+
`${extraInstructions ? ` (${extraInstructions})` : ''}:\n`);
|
|
133
170
|
}
|
|
134
171
|
return summaryString.join('\n');
|
|
135
172
|
}
|
|
@@ -149,7 +186,7 @@ function formatPackageResults(params) {
|
|
|
149
186
|
continue;
|
|
150
187
|
}
|
|
151
188
|
const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');
|
|
152
|
-
summaryString.push(formatPackageHeader(
|
|
189
|
+
summaryString.push(formatPackageHeader(result), formatPackageSubhead({ issueType, description }));
|
|
153
190
|
const messages = unformattedMessages.map(({ location, text, source }) => {
|
|
154
191
|
// Show the whole path so it can be easily opened with ctrl+click.
|
|
155
192
|
// NOTE: location.file should be relative to the package path, not the app path.
|
|
@@ -162,16 +199,20 @@ function formatPackageResults(params) {
|
|
|
162
199
|
return summaryString.join('\n');
|
|
163
200
|
}
|
|
164
201
|
/**
|
|
165
|
-
* Helper to format the
|
|
166
|
-
* status character, `name@version`, issue description, package path.
|
|
202
|
+
* Helper to format the package `name@version` and output path.
|
|
167
203
|
*/
|
|
168
204
|
function formatPackageHeader(params) {
|
|
169
|
-
const { name, version, path: packagePath, outputPath
|
|
205
|
+
const { name, version, path: packagePath, outputPath } = params;
|
|
206
|
+
const packageName = bold(lightCyan(`${name}@${version}`));
|
|
207
|
+
return `${packageName} - ${packagePath}${outputPath ? '\n' + darkGrey(`(output: ${outputPath})`) : ''}`;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Add a status character and formatting to the subhead description.
|
|
211
|
+
*/
|
|
212
|
+
function formatPackageSubhead(params) {
|
|
213
|
+
const { description, issueType } = params;
|
|
170
214
|
const color = colorsByType[issueType];
|
|
171
215
|
const statusChar = bold(color(statusByType[issueType]));
|
|
172
|
-
|
|
173
|
-
return (`${packageName} - ${packagePath}\n` +
|
|
174
|
-
(outputPath ? darkGrey(`(output: ${outputPath})\n`) : '') +
|
|
175
|
-
`${statusChar} ${bold(color(description))}`);
|
|
216
|
+
return `${statusChar} ${bold(color(description))}`;
|
|
176
217
|
}
|
|
177
218
|
//# sourceMappingURL=formatInitSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,gBAAgB,EAChB,MAAM,GACP,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAY9D,MAAM,YAAY,GAAgD;IAChE,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,WAAW;IAC9B,OAAO,EAAE,KAAK;C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EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,MAGC;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IACxF,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC;IAEzE,OAAO,CACL,GAAG,WAAW,MAAM,WAAW,IAAI;QACnC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAC5C,CAAC;AACJ,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n darkGrey,\n indent,\n lightCyan,\n plural,\n red,\n prefixCharacters,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\nimport type { RequiredGeneratedChangeType } from './types/GeneratedChange.js';\n\ninterface FormatSummaryParams extends Pick<InitOptions, 'check'> {\n summary: InitSummary;\n isMultiApp?: boolean;\n verb: 'init' | 'bundle';\n isInterrupted?: boolean;\n}\n\n/** Result types with different colors and symbols for logging purposes */\ntype ResultType = 'error' | 'warn' | 'add' | 'success';\nconst colorsByType: Record<ResultType, (str: string) => string> = {\n error: red,\n warn: yellow,\n add: (str) => str, // no color\n success: green,\n};\nconst statusByType: Record<ResultType, string> = {\n error: prefixCharacters.error,\n warn: prefixCharacters.warn,\n add: '+',\n success: prefixCharacters.complete,\n};\n\n/**\n * Given a summary and options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatSummaryParams): string {\n const { summary, check, isInterrupted, isMultiApp, verb } = params;\n const summaryString: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n // If there are required changes, updates will be \"made\" or \"needed\" with check,\n // else if the changes are not required, only report work done when updates are \"made\" (check is disabled).\n const updatesRequired = totalRequiredChanges || (totalChanges && !check);\n\n // Report updates that were or should be added to the generated config.\n if (!packagesWithErrors.length && updatesRequired) {\n summaryString.push(formatPackageUpdates({ generatedFileUpdates, check }));\n }\n\n if (!isMultiApp) {\n // Report packages with warnings.\n if (packagesWithWarnings.length) {\n summaryString.push(formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' }), '');\n }\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summaryString.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }), '');\n }\n\n if (deletedGeneratedConfig) {\n summaryString.push(`Deleted the ${cyan('cloudpack.generated.json')} file because it is no longer needed.`, '');\n }\n\n if (totalPackages > 1 || verb === 'init') {\n const action = verb === 'init' ? 'evaluated' : 'bundled';\n summaryString.push(\n `${cyan(plural(totalPackages, 'total package'))} ${action} in ${formatTime(summary.duration)}${incompleteText}:`,\n );\n\n const errorPkgCount = packagesWithErrors.length;\n const succesPkgCount = totalPackages - errorPkgCount;\n const warningPkgCount = packagesWithWarnings.length;\n const optionalChangesCount = totalChanges - totalRequiredChanges;\n\n // Add totals. Without --check:\n // ✓ 5 packages evaluated without errors\n // + 2 changes made to generated config\n // ! 3 packages with warnings (5 total warnings)\n // ✗ 1 package with errors (2 total errors)\n // With --check:\n // ✓ 5 packages evaluated without errors\n // ! 2 optional changes could be made to generated config\n // ! 3 packages with warnings (5 total warnings)\n // ✗ 1 required change missing from generated config\n // ✗ 1 package with errors (2 total errors)\n // (bundle will only ever show the main warnings)\n summaryString.push(\n ...([\n // \"without errors\" because they might have warnings\n formatCount('success', succesPkgCount, 'package', `${action} without errors`),\n // For check, show optional changes as warnings. (required changes will be shown below)\n // If updating, show the total changes made.\n // (these messages won't show for bundle since the change counts there are 0)\n check\n ? formatCount('warn', optionalChangesCount, 'optional change', 'could be made to generated config')\n : formatCount('add', totalChanges, 'change', 'made to generated config'),\n formatCount('warn', warningPkgCount, 'package', 'with warnings', totalWarnings, 'total warning'),\n check && formatCount('error', totalRequiredChanges, 'required change', 'missing from generated config'),\n formatCount('error', errorPkgCount, 'package', 'with errors', totalErrors, 'total error'),\n ].filter(Boolean) as string[]),\n );\n }\n\n if (isInterrupted) {\n summaryString.push('', yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (check && totalRequiredChanges) {\n summaryString.push(\n `Run \"${yellow('cloudpack init')}\" in your application folder to apply changes to the ${cyan(\n 'cloudpack.generated.json',\n )} file.`,\n );\n }\n\n // Skip the header if there was nothing to report.\n if (summaryString.length) {\n // For bundle, we just say \"summary\" since `appPath` might not actually be the path that was bundled.\n summaryString.unshift(bold(`==== ${verb === 'bundle' ? 'Summary' : `Summary for ${summary.appPath}`} ====`));\n summaryString.push('\\n');\n }\n\n return (\n summaryString\n .join('\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n')\n );\n}\n\n/**\n * If `count > 0`, return a pluralized formatted string like \"+ 5 items description\"\n * (otherwise ignore). `type` determines the status character used, and the color for the\n * status character and item count.\n *\n * `extraCount` and `extraItem` are optional and will be added to the end in parentheses\n * if both are provided.\n */\nfunction formatCount(\n type: ResultType,\n count: number,\n item: string,\n description: string,\n extraCount?: number,\n extraItem?: string,\n): string | undefined {\n if (count > 0) {\n const color = colorsByType[type];\n const statusChar = bold(color(statusByType[type]));\n const itemCount = color(plural(count, item));\n const extra = extraCount && extraItem ? ` (${plural(extraCount, extraItem)})` : '';\n return ` ${statusChar} ${itemCount} ${description}${extra}`;\n }\n return undefined;\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> & Pick<FormatSummaryParams, 'isInterrupted' | 'check'>,\n): string {\n const { generatedFileUpdates, check, isInterrupted } = params;\n\n const descriptions: Record<RequiredGeneratedChangeType, string> = {\n 'added-export': `path$s ${check ? 'missing from' : 'added to'} exports map`,\n 'included-dependency-required': 'dependency$s required to be included',\n 'changed-export': 'previously unused export path(s) are now used',\n 'added-dynamic-import': 'dynamic import$s added',\n };\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n for (const type of Object.keys(descriptions) as RequiredGeneratedChangeType[]) {\n const typeUpdates = packageUpdates.changes.filter((u) => u.type === type);\n\n if (typeUpdates.length) {\n const description = plural(typeUpdates.length, descriptions[type]);\n // If we already made the updates, don't make them look like warnings.\n const issueType = check ? 'warn' : 'add';\n summaryString.push(\n formatPackageHeader({ ...packageUpdates, issueType, description }),\n bulletedList(typeUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n '',\n );\n }\n }\n }\n\n if (summaryString.length) {\n summaryString.unshift(\n bold(`Updates ${check || isInterrupted ? 'needed for' : 'made to'} ${cyan(`cloudpack.generated.json`)}:\\n`),\n );\n }\n return summaryString.join('\\n');\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }): string {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(prefixCharacters[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader({ ...result, issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\n/**\n * Helper to format the header for a list of issues in a package:\n * status character, `name@version`, issue description, package path.\n */\nfunction formatPackageHeader(\n params: InitPackageResult & {\n description: string;\n issueType: 'error' | 'warn' | 'add';\n },\n): string {\n const { name, version, path: packagePath, outputPath, description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n const packageName = bold(lightCyan(`${name}@${version || `<unknown>`}`));\n\n return (\n `${packageName} - ${packagePath}\\n` +\n (outputPath ? darkGrey(`(output: ${outputPath})\\n`) : '') +\n `${statusChar} ${bold(color(description))}`\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,gBAAgB,EAChB,MAAM,GACP,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAY9D,MAAM,YAAY,GAAgD;I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,CAAC,CAAC,EAAE,CAAC;AACrD,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n darkGrey,\n indent,\n lightCyan,\n plural,\n red,\n prefixCharacters,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\nimport type { GeneratedChange, RequiredGeneratedChangeType } from './types/GeneratedChange.js';\n\nexport interface FormatSummaryParams extends Pick<InitOptions, 'check'> {\n summary: InitSummary;\n isMultiApp?: boolean;\n verb: 'init' | 'bundle';\n isInterrupted?: boolean;\n}\n\n/** Result types with different colors and symbols for logging purposes */\ntype ResultType = 'error' | 'warn' | 'add' | 'success';\nconst colorsByType: Record<ResultType, (str: string) => string> = {\n error: red,\n warn: yellow,\n add: (str) => str, // no color\n success: green,\n};\nconst statusByType: Record<ResultType, string> = {\n error: prefixCharacters.error,\n warn: prefixCharacters.warn,\n add: '+',\n success: prefixCharacters.complete,\n};\n\n/** \"cloudpack.generated.json\" with color */\nconst generatedConfigFile = cyan('cloudpack.generated.json');\n/** \"cloudpack init\" with color and quotes */\nconst cloudpackInit = `\"${yellow('cloudpack init')}\"`;\n\n/**\n * Given a summary and options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatSummaryParams): string {\n const { summary, check, isInterrupted, isMultiApp, verb } = params;\n /** Sections of the summary that will be joined with two newlines */\n const summarySections: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n\n // With --check, show required changes even if there are errors.\n // Otherwise, skip since they'll be applied automatically once errors are fixed.\n const showRequiredChanges = !!(totalRequiredChanges && (!totalErrors || check));\n\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n let warnings: string | undefined;\n let generatedChanges: string | undefined;\n\n // In single-app mode, report packages with warnings.\n if (!isMultiApp && packagesWithWarnings.length) {\n warnings = formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' });\n }\n\n // Report required changes if appropriate (see showRequiredChanges)\n if (showRequiredChanges) {\n generatedChanges = formatPackageUpdates({ generatedFileUpdates, check, hasErrors: !!totalErrors });\n }\n\n if (check) {\n // With --check, it's most helpful to show warnings then generated changes. Required changes\n // are errors in that context, and if they're listed above warnings, it's easy to miss them,\n // which might lead to confusion.\n warnings && summarySections.push(warnings);\n generatedChanges && summarySections.push(generatedChanges);\n } else {\n // Without --check, show generated changes first, then warnings. In this case, any generated\n // change listing is just informational (the changes were already made), but the warnings\n // require manual intervention if the user wants to fix them.\n generatedChanges && summarySections.push(generatedChanges);\n warnings && summarySections.push(warnings);\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summarySections.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }));\n }\n\n if (deletedGeneratedConfig) {\n summarySections.push(`Deleted the ${generatedConfigFile} file because it is no longer needed.`);\n }\n\n if (totalPackages > 1 || verb === 'init') {\n // Report totals\n const action = verb === 'init' ? 'evaluated' : 'bundled';\n const totalLines = [\n `${cyan(plural(totalPackages, 'total package'))} ${action} in ${formatTime(summary.duration)}${incompleteText}`,\n ];\n\n const errorPkgCount = packagesWithErrors.length;\n const succesPkgCount = totalPackages - errorPkgCount;\n const warningPkgCount = packagesWithWarnings.length;\n const optionalChangesCount = totalChanges - totalRequiredChanges;\n\n // See snapshots for examples of this output\n totalLines.push(\n ...([\n // \"without errors\" because they might have warnings\n formatCount('success', succesPkgCount, 'package', `${action} without errors`),\n !errorPkgCount &&\n (check\n ? // For --check, only show optional changes if there are no errors, and format the\n // optional changes as warnings. (required changes will be shown below)\n formatCount('warn', optionalChangesCount, 'optional change', 'could be made to generated config')\n : // If updating, show the total changes made.\n formatCount('add', totalChanges, 'change', 'made to generated config')),\n formatCount('warn', warningPkgCount, 'package', 'with warnings', totalWarnings, 'total warning'),\n // For --check, show required changes as errors.\n check && formatCount('error', totalRequiredChanges, 'required change', 'missing from generated config'),\n formatCount('error', errorPkgCount, 'package', 'with errors', totalErrors, 'total error'),\n ].filter(Boolean) as string[]),\n );\n\n if (totalLines.length > 1) {\n // add a colon to the first line if there are other lines\n totalLines[0] += ':';\n }\n\n summarySections.push(totalLines.join('\\n'));\n }\n\n if (isInterrupted) {\n summarySections.push(yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (check && totalRequiredChanges && !totalErrors) {\n // Skip the instruction to update the generated config if there were errors.\n summarySections.push(\n `Run ${cloudpackInit} in ${summary.appPath} to apply missing changes to the ${generatedConfigFile} file.`,\n );\n }\n\n // Skip the header if there was nothing to report.\n if (summarySections.length) {\n // For bundle, we just say \"summary\" since `appPath` might not actually be the path that was bundled.\n summarySections.unshift(bold(`==== ${verb === 'bundle' ? 'Summary' : `Summary for ${summary.appPath}`} ====`));\n }\n\n const summaryString = summarySections\n .join('\\n\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n');\n // Ensure a final newline for readability, unless it's empty.\n return !summaryString || summaryString.endsWith('\\n') ? summaryString : summaryString + '\\n';\n}\n\n/**\n * If `count > 0`, return a pluralized formatted string like \"+ 5 items description\"\n * (otherwise ignore). `type` determines the status character used, and the color for the\n * status character and item count.\n *\n * `extraCount` and `extraItem` are optional and will be added to the end in parentheses\n * if both are provided.\n */\nfunction formatCount(\n type: ResultType,\n count: number,\n item: string,\n description: string,\n extraCount?: number,\n extraItem?: string,\n): string | undefined {\n if (count > 0) {\n const color = colorsByType[type];\n const statusChar = bold(color(statusByType[type]));\n const itemCount = color(plural(count, item));\n const extra = extraCount && extraItem ? ` (${plural(extraCount, extraItem)})` : '';\n return ` ${statusChar} ${itemCount} ${description}${extra}`;\n }\n return undefined;\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<FormatSummaryParams, 'isInterrupted' | 'check'> & {\n hasErrors: boolean;\n },\n): string {\n const { generatedFileUpdates, check, isInterrupted, hasErrors } = params;\n\n // mapping from change type to [description, optional plural description]\n const descriptions: Record<RequiredGeneratedChangeType, [string, string?]> = {\n 'added-export': [`path$s ${check ? 'missing from' : 'added to'} exports map`],\n 'included-dependency-required': ['dependency required to be included', 'dependencies required to be included'],\n 'changed-export': ['previously unused export path$s now used'],\n 'added-dynamic-import': ['dynamic import$s added'],\n };\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n // list of update type descriptions and updates of that type\n const updates: [string, GeneratedChange[]][] = [];\n for (const type of Object.keys(descriptions) as RequiredGeneratedChangeType[]) {\n const typeUpdates = packageUpdates.changes.filter((u) => u.type === type);\n\n if (typeUpdates.length) {\n const description = plural(typeUpdates.length, ...descriptions[type]);\n updates.push([description, typeUpdates]);\n }\n }\n\n if (updates.length) {\n summaryString.push(formatPackageHeader(packageUpdates));\n for (const [description, typeUpdates] of updates) {\n summaryString.push(\n // If updates are required, format them as errors.\n formatPackageSubhead({ issueType: check ? 'error' : 'add', description }),\n bulletedList(typeUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n );\n }\n summaryString.push('');\n }\n }\n\n if (summaryString.length) {\n const needsUpdates = check || isInterrupted;\n const extraInstructions = needsUpdates\n ? hasErrors\n ? `fix errors first, then run ${cloudpackInit}`\n : `run ${cloudpackInit} to fix`\n : '';\n summaryString.unshift(\n bold(`Updates ${needsUpdates ? 'needed for' : 'made to'} ${generatedConfigFile}`) +\n `${extraInstructions ? ` (${extraInstructions})` : ''}:\\n`,\n );\n }\n return summaryString.join('\\n');\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }): string {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(prefixCharacters[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader(result), formatPackageSubhead({ issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\n/**\n * Helper to format the package `name@version` and output path.\n */\nfunction formatPackageHeader(params: InitPackageResult): string {\n const { name, version, path: packagePath, outputPath } = params;\n const packageName = bold(lightCyan(`${name}@${version}`));\n\n return `${packageName} - ${packagePath}${outputPath ? '\\n' + darkGrey(`(output: ${outputPath})`) : ''}`;\n}\n\n/**\n * Add a status character and formatting to the subhead description.\n */\nfunction formatPackageSubhead(params: { description: string; issueType: ResultType }): string {\n const { description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n return `${statusChar} ${bold(color(description))}`;\n}\n"]}
|
|
@@ -12,4 +12,9 @@ export interface GeneratedChange {
|
|
|
12
12
|
* (Keys for non-required change types will be undefined.)
|
|
13
13
|
*/
|
|
14
14
|
export declare const requiredChangeTypes: Partial<Record<GeneratedChangeType, true>>;
|
|
15
|
+
/**
|
|
16
|
+
* Mapping of optional change types to true.
|
|
17
|
+
* (Keys for required change types will be undefined.)
|
|
18
|
+
*/
|
|
19
|
+
export declare const optionalChangeTypes: Partial<Record<GeneratedChangeType, true>>;
|
|
15
20
|
//# sourceMappingURL=GeneratedChange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedChange.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GACnC,gBAAgB,GAChB,cAAc,GACd,sBAAsB,GACtB,8BAA8B,CAAC;AAEnC,MAAM,MAAM,mBAAmB,GAC3B,2BAA2B,GAC3B,8BAA8B,GAC9B,qBAAqB,GACrB,6BAA6B,CAAC;AAElC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AAGH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAKtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"GeneratedChange.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GACnC,gBAAgB,GAChB,cAAc,GACd,sBAAsB,GACtB,8BAA8B,CAAC;AAEnC,MAAM,MAAM,mBAAmB,GAC3B,2BAA2B,GAC3B,8BAA8B,GAC9B,qBAAqB,GACrB,6BAA6B,CAAC;AAElC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AAGH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAKtB,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAIQ,CAAC"}
|
|
@@ -10,4 +10,13 @@ export const requiredChangeTypes = {
|
|
|
10
10
|
'added-dynamic-import': true,
|
|
11
11
|
'included-dependency-required': true,
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Mapping of optional change types to true.
|
|
15
|
+
* (Keys for required change types will be undefined.)
|
|
16
|
+
*/
|
|
17
|
+
export const optionalChangeTypes = {
|
|
18
|
+
'included-dependency-optional': true,
|
|
19
|
+
'excluded-dependency': true,
|
|
20
|
+
'removed-excluded-dependency': true,
|
|
21
|
+
};
|
|
13
22
|
//# sourceMappingURL=GeneratedChange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedChange.js","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,uFAAuF;AACvF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mBAAmB,GAA+C;IAC7E,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,sBAAsB,EAAE,IAAI;IAC5B,8BAA8B,EAAE,IAAI;CACe,CAAC","sourcesContent":["export type RequiredGeneratedChangeType =\n | 'changed-export'\n | 'added-export'\n | 'added-dynamic-import'\n | 'included-dependency-required';\n\nexport type GeneratedChangeType =\n | RequiredGeneratedChangeType\n | 'included-dependency-optional'\n | 'excluded-dependency'\n | 'removed-excluded-dependency';\n\nexport interface GeneratedChange {\n type: GeneratedChangeType;\n /** Item that changed, such as the dependency name, export path, or bundler type */\n change: string;\n /** Additional explanation */\n reason?: string;\n}\n\n/**\n * Mapping of required change types to true.\n * (Keys for non-required change types will be undefined.)\n */\n// It's easier to ensure this stays up to date by using an object rather than an array.\n// Any GeneratedChangeType is allowed as a lookup key to make usage easier.\nexport const requiredChangeTypes: Partial<Record<GeneratedChangeType, true>> = {\n 'changed-export': true,\n 'added-export': true,\n 'added-dynamic-import': true,\n 'included-dependency-required': true,\n} satisfies Record<RequiredGeneratedChangeType, true>;\n"]}
|
|
1
|
+
{"version":3,"file":"GeneratedChange.js","sourceRoot":"","sources":["../../../../src/commands/init/types/GeneratedChange.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,uFAAuF;AACvF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,mBAAmB,GAA+C;IAC7E,gBAAgB,EAAE,IAAI;IACtB,cAAc,EAAE,IAAI;IACpB,sBAAsB,EAAE,IAAI;IAC5B,8BAA8B,EAAE,IAAI;CACe,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA+C;IAC7E,8BAA8B,EAAE,IAAI;IACpC,qBAAqB,EAAE,IAAI;IAC3B,6BAA6B,EAAE,IAAI;CAC8C,CAAC","sourcesContent":["export type RequiredGeneratedChangeType =\n | 'changed-export'\n | 'added-export'\n | 'added-dynamic-import'\n | 'included-dependency-required';\n\nexport type GeneratedChangeType =\n | RequiredGeneratedChangeType\n | 'included-dependency-optional'\n | 'excluded-dependency'\n | 'removed-excluded-dependency';\n\nexport interface GeneratedChange {\n type: GeneratedChangeType;\n /** Item that changed, such as the dependency name, export path, or bundler type */\n change: string;\n /** Additional explanation */\n reason?: string;\n}\n\n/**\n * Mapping of required change types to true.\n * (Keys for non-required change types will be undefined.)\n */\n// It's easier to ensure this stays up to date by using an object rather than an array.\n// Any GeneratedChangeType is allowed as a lookup key to make usage easier.\nexport const requiredChangeTypes: Partial<Record<GeneratedChangeType, true>> = {\n 'changed-export': true,\n 'added-export': true,\n 'added-dynamic-import': true,\n 'included-dependency-required': true,\n} satisfies Record<RequiredGeneratedChangeType, true>;\n\n/**\n * Mapping of optional change types to true.\n * (Keys for required change types will be undefined.)\n */\nexport const optionalChangeTypes: Partial<Record<GeneratedChangeType, true>> = {\n 'included-dependency-optional': true,\n 'excluded-dependency': true,\n 'removed-excluded-dependency': true,\n} satisfies Record<Exclude<GeneratedChangeType, RequiredGeneratedChangeType>, true>;\n"]}
|
|
@@ -3,9 +3,15 @@ import type { InitPackageResultErrors, InitPackageResultWarnings } from './InitP
|
|
|
3
3
|
export interface InitSummary {
|
|
4
4
|
appPath: string;
|
|
5
5
|
duration: number;
|
|
6
|
+
/** True if there were errors, or if `check` was set and there were required changes. */
|
|
7
|
+
failed: boolean;
|
|
8
|
+
/** Total number of packages */
|
|
6
9
|
totalPackages: number;
|
|
10
|
+
/** Total packages without errors (doesn't consider required config changes) */
|
|
7
11
|
totalSuccess: number;
|
|
12
|
+
/** Total number of errors (doesn't include required config changes) */
|
|
8
13
|
totalErrors: number;
|
|
14
|
+
/** Total number of warnings (doesn't include config changes) */
|
|
9
15
|
totalWarnings: number;
|
|
10
16
|
/** Total number of changes made to the generated config */
|
|
11
17
|
totalChanges: number;
|
|
@@ -14,11 +20,13 @@ export interface InitSummary {
|
|
|
14
20
|
* This will cause `init --check` to fail if it's not 0.
|
|
15
21
|
*/
|
|
16
22
|
totalRequiredChanges: number;
|
|
17
|
-
failed: boolean;
|
|
18
23
|
/** If true, the generated config previously existed but is now not needed and was deleted */
|
|
19
24
|
deletedGeneratedConfig?: boolean;
|
|
25
|
+
/** Updates made to the generated config */
|
|
20
26
|
generatedFileUpdates: GeneratedPackageChanges[];
|
|
27
|
+
/** Results for each package with errors (doesn't include required config changes) */
|
|
21
28
|
packagesWithErrors: InitPackageResultErrors[];
|
|
29
|
+
/** Results for each package with warnings (doesn't include config changes) */
|
|
22
30
|
packagesWithWarnings: InitPackageResultWarnings[];
|
|
23
31
|
}
|
|
24
32
|
//# sourceMappingURL=InitSummary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitSummary.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEjG,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B,
|
|
1
|
+
{"version":3,"file":"InitSummary.d.ts","sourceRoot":"","sources":["../../../../src/commands/init/types/InitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEjG,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,MAAM,EAAE,OAAO,CAAC;IAChB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B,6FAA6F;IAC7F,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,2CAA2C;IAC3C,oBAAoB,EAAE,uBAAuB,EAAE,CAAC;IAChD,qFAAqF;IACrF,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;IAC9C,8EAA8E;IAC9E,oBAAoB,EAAE,yBAAyB,EAAE,CAAC;CACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitSummary.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitSummary.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratedPackageChanges } from './GeneratedPackageChanges.js';\nimport type { InitPackageResultErrors, InitPackageResultWarnings } from './InitPackageResult.js';\n\nexport interface InitSummary {\n appPath: string;\n duration: number;\n totalPackages: number;\n totalSuccess: number;\n totalErrors: number;\n totalWarnings: number;\n /** Total number of changes made to the generated config */\n totalChanges: number;\n /**\n * Total number of required changes made to the generated config.\n * This will cause `init --check` to fail if it's not 0.\n */\n totalRequiredChanges: number;\n
|
|
1
|
+
{"version":3,"file":"InitSummary.js","sourceRoot":"","sources":["../../../../src/commands/init/types/InitSummary.ts"],"names":[],"mappings":"","sourcesContent":["import type { GeneratedPackageChanges } from './GeneratedPackageChanges.js';\nimport type { InitPackageResultErrors, InitPackageResultWarnings } from './InitPackageResult.js';\n\nexport interface InitSummary {\n appPath: string;\n duration: number;\n /** True if there were errors, or if `check` was set and there were required changes. */\n failed: boolean;\n /** Total number of packages */\n totalPackages: number;\n /** Total packages without errors (doesn't consider required config changes) */\n totalSuccess: number;\n /** Total number of errors (doesn't include required config changes) */\n totalErrors: number;\n /** Total number of warnings (doesn't include config changes) */\n totalWarnings: number;\n /** Total number of changes made to the generated config */\n totalChanges: number;\n /**\n * Total number of required changes made to the generated config.\n * This will cause `init --check` to fail if it's not 0.\n */\n totalRequiredChanges: number;\n /** If true, the generated config previously existed but is now not needed and was deleted */\n deletedGeneratedConfig?: boolean;\n /** Updates made to the generated config */\n generatedFileUpdates: GeneratedPackageChanges[];\n /** Results for each package with errors (doesn't include required config changes) */\n packagesWithErrors: InitPackageResultErrors[];\n /** Results for each package with warnings (doesn't include config changes) */\n packagesWithWarnings: InitPackageResultWarnings[];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readLocalConfigs.d.ts","sourceRoot":"","sources":["../../src/utilities/readLocalConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"readLocalConfigs.d.ts","sourceRoot":"","sources":["../../src/utilities/readLocalConfigs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAAE,EAClB,mBAAmB,iBAAiB,KACnC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAgBzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readRemoteConfigs.d.ts","sourceRoot":"","sources":["../../src/utilities/readRemoteConfigs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGvF,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"readRemoteConfigs.d.ts","sourceRoot":"","sources":["../../src/utilities/readRemoteConfigs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGvF,eAAO,MAAM,iBAAiB,GAC5B,UAAU,MAAM,EAAE,EAClB,mBAAmB,iBAAiB,KACnC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAezC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.73.
|
|
3
|
+
"version": "0.73.7",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.61.
|
|
14
|
-
"@ms-cloudpack/app-server": "^0.17.
|
|
15
|
-
"@ms-cloudpack/bundler": "^0.24.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.61.35",
|
|
14
|
+
"@ms-cloudpack/app-server": "^0.17.89",
|
|
15
|
+
"@ms-cloudpack/bundler": "^0.24.30",
|
|
16
16
|
"@ms-cloudpack/common-types": "^0.24.16",
|
|
17
17
|
"@ms-cloudpack/config": "^0.35.0",
|
|
18
18
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
19
19
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
20
|
-
"@ms-cloudpack/link-proxy": "^0.1.
|
|
21
|
-
"@ms-cloudpack/overlay": "^0.17.
|
|
20
|
+
"@ms-cloudpack/link-proxy": "^0.1.7",
|
|
21
|
+
"@ms-cloudpack/overlay": "^0.17.168",
|
|
22
22
|
"@ms-cloudpack/package-utilities": "^12.3.3",
|
|
23
23
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
24
24
|
"@ms-cloudpack/path-utilities": "^3.1.0",
|
|
25
|
-
"@ms-cloudpack/remote-cache": "^0.11.
|
|
25
|
+
"@ms-cloudpack/remote-cache": "^0.11.12",
|
|
26
26
|
"@ms-cloudpack/setup-utilities": "^0.5.23",
|
|
27
27
|
"@ms-cloudpack/task-reporter": "^0.16.2",
|
|
28
28
|
"@ms-cloudpack/telemetry": "^0.11.15",
|