@fnd-platform/cli 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +224 -0
- package/lib/bin/fnd.d.ts +3 -0
- package/lib/bin/fnd.d.ts.map +1 -0
- package/lib/bin/fnd.js +9 -0
- package/lib/bin/fnd.js.map +1 -0
- package/lib/commands/add.d.ts +28 -0
- package/lib/commands/add.d.ts.map +1 -0
- package/lib/commands/add.js +547 -0
- package/lib/commands/add.js.map +1 -0
- package/lib/commands/build.d.ts +62 -0
- package/lib/commands/build.d.ts.map +1 -0
- package/lib/commands/build.js +155 -0
- package/lib/commands/build.js.map +1 -0
- package/lib/commands/deploy.d.ts +67 -0
- package/lib/commands/deploy.d.ts.map +1 -0
- package/lib/commands/deploy.js +160 -0
- package/lib/commands/deploy.js.map +1 -0
- package/lib/commands/index.d.ts +6 -0
- package/lib/commands/index.d.ts.map +1 -0
- package/lib/commands/index.js +14 -0
- package/lib/commands/index.js.map +1 -0
- package/lib/commands/new.d.ts +47 -0
- package/lib/commands/new.d.ts.map +1 -0
- package/lib/commands/new.js +199 -0
- package/lib/commands/new.js.map +1 -0
- package/lib/commands/synth.d.ts +39 -0
- package/lib/commands/synth.d.ts.map +1 -0
- package/lib/commands/synth.js +72 -0
- package/lib/commands/synth.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +43 -0
- package/lib/index.js.map +1 -0
- package/lib/lib/infra-generator.d.ts +24 -0
- package/lib/lib/infra-generator.d.ts.map +1 -0
- package/lib/lib/infra-generator.js +193 -0
- package/lib/lib/infra-generator.js.map +1 -0
- package/lib/lib/logger.d.ts +50 -0
- package/lib/lib/logger.d.ts.map +1 -0
- package/lib/lib/logger.js +102 -0
- package/lib/lib/logger.js.map +1 -0
- package/lib/lib/nx-stats.d.ts +69 -0
- package/lib/lib/nx-stats.d.ts.map +1 -0
- package/lib/lib/nx-stats.js +117 -0
- package/lib/lib/nx-stats.js.map +1 -0
- package/lib/lib/project.d.ts +17 -0
- package/lib/lib/project.d.ts.map +1 -0
- package/lib/lib/project.js +49 -0
- package/lib/lib/project.js.map +1 -0
- package/lib/lib/templates.d.ts +16 -0
- package/lib/lib/templates.d.ts.map +1 -0
- package/lib/lib/templates.js +42 -0
- package/lib/lib/templates.js.map +1 -0
- package/lib/lib/timer.d.ts +120 -0
- package/lib/lib/timer.d.ts.map +1 -0
- package/lib/lib/timer.js +127 -0
- package/lib/lib/timer.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.js","sourceRoot":"","sources":["../../src/commands/new.ts"],"names":[],"mappings":";;;AAqCA,gCAUC;AAiBD,sCAoGC;AApKD,yCAAoC;AACpC,iDAAyC;AACzC,2BAAkE;AAClE,+BAAqC;AACrC,gDAA0C;AAC1C,sDAAiF;AACjF,8CAAmD;AAEnD;;;GAGG;AACH,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAwNxC,oDAAoB;AA7M7B;;;;;;;;;;;;;GAaG;AACH,SAAgB,UAAU;IACxB,OAAO,IAAI,mBAAO,CAAC,KAAK,CAAC;SACtB,WAAW,CAAC,4CAA4C,CAAC;SACzD,QAAQ,CAAC,QAAQ,EAAE,oDAAoD,CAAC;SACxE,MAAM,CAAC,wBAAwB,EAAE,uCAAuC,EAAE,MAAM,CAAC;SACjF,MAAM,CAAC,UAAU,EAAE,oCAAoC,CAAC;SACxD,MAAM,CAAC,cAAc,EAAE,8BAA8B,CAAC;SACtD,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,OAA0B,EAAE,EAAE;QACzD,MAAM,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACI,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,OAA0B;IAC1E,kCAAkC;IACl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C/B,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the synth command.
|
|
4
|
+
*/
|
|
5
|
+
interface SynthCommandOptions {
|
|
6
|
+
watch?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates the `fnd synth` command.
|
|
10
|
+
*
|
|
11
|
+
* @returns Commander command instance
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { synthCommand } from '@fnd-platform/cli';
|
|
16
|
+
*
|
|
17
|
+
* const program = new Command();
|
|
18
|
+
* program.addCommand(synthCommand());
|
|
19
|
+
* program.parse(['node', 'fnd', 'synth']);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function synthCommand(): Command;
|
|
23
|
+
/**
|
|
24
|
+
* Runs Projen synthesis.
|
|
25
|
+
*
|
|
26
|
+
* @param options - Command options
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // Run synthesis with default options
|
|
31
|
+
* await runSynth({});
|
|
32
|
+
*
|
|
33
|
+
* // Run synthesis with watch mode (when implemented)
|
|
34
|
+
* await runSynth({ watch: true });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function runSynth(options: SynthCommandOptions): Promise<void>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=synth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synth.d.ts","sourceRoot":"","sources":["../../src/commands/synth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC;;GAEG;AACH,UAAU,mBAAmB;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAOtC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B1E"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.synthCommand = synthCommand;
|
|
4
|
+
exports.runSynth = runSynth;
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const project_js_1 = require("../lib/project.js");
|
|
8
|
+
const logger_js_1 = require("../lib/logger.js");
|
|
9
|
+
/**
|
|
10
|
+
* Creates the `fnd synth` command.
|
|
11
|
+
*
|
|
12
|
+
* @returns Commander command instance
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { synthCommand } from '@fnd-platform/cli';
|
|
17
|
+
*
|
|
18
|
+
* const program = new Command();
|
|
19
|
+
* program.addCommand(synthCommand());
|
|
20
|
+
* program.parse(['node', 'fnd', 'synth']);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
function synthCommand() {
|
|
24
|
+
return new commander_1.Command('synth')
|
|
25
|
+
.description('Synthesize project configuration using Projen')
|
|
26
|
+
.option('--watch', 'Watch for changes and re-synthesize (not yet implemented)')
|
|
27
|
+
.action(async (options) => {
|
|
28
|
+
await runSynth(options);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Runs Projen synthesis.
|
|
33
|
+
*
|
|
34
|
+
* @param options - Command options
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Run synthesis with default options
|
|
39
|
+
* await runSynth({});
|
|
40
|
+
*
|
|
41
|
+
* // Run synthesis with watch mode (when implemented)
|
|
42
|
+
* await runSynth({ watch: true });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
async function runSynth(options) {
|
|
46
|
+
let projectRoot;
|
|
47
|
+
try {
|
|
48
|
+
projectRoot = (0, project_js_1.requireProjectRoot)();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
logger_js_1.logger.error(error.message);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
logger_js_1.logger.info('Synthesizing project configuration...');
|
|
55
|
+
logger_js_1.logger.debug(`Project root: ${projectRoot}`);
|
|
56
|
+
if (options.watch) {
|
|
57
|
+
logger_js_1.logger.warn('Watch mode is not yet implemented');
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
(0, child_process_1.execSync)('npx projen', {
|
|
61
|
+
cwd: projectRoot,
|
|
62
|
+
stdio: 'inherit',
|
|
63
|
+
});
|
|
64
|
+
logger_js_1.logger.success('Synthesis complete');
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
logger_js_1.logger.error('Synthesis failed');
|
|
68
|
+
logger_js_1.logger.debug(`Error: ${error.message}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=synth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synth.js","sourceRoot":"","sources":["../../src/commands/synth.ts"],"names":[],"mappings":";;AA0BA,oCAOC;AAgBD,4BA4BC;AA7ED,yCAAoC;AACpC,iDAAyC;AACzC,kDAAuD;AACvD,gDAA0C;AAS1C;;;;;;;;;;;;;GAaG;AACH,SAAgB,YAAY;IAC1B,OAAO,IAAI,mBAAO,CAAC,OAAO,CAAC;SACxB,WAAW,CAAC,+CAA+C,CAAC;SAC5D,M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tool for scaffolding and managing fnd-platform projects.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Runs the fnd CLI.
|
|
10
|
+
*
|
|
11
|
+
* @param args - Command line arguments (defaults to process.argv)
|
|
12
|
+
* @returns Promise that resolves when command completes
|
|
13
|
+
*/
|
|
14
|
+
export declare function run(args?: string[]): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBtE"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fnd-platform/cli
|
|
4
|
+
*
|
|
5
|
+
* CLI tool for scaffolding and managing fnd-platform projects.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.run = run;
|
|
11
|
+
const commander_1 = require("commander");
|
|
12
|
+
const index_js_1 = require("./commands/index.js");
|
|
13
|
+
/**
|
|
14
|
+
* CLI version - should match package.json.
|
|
15
|
+
*/
|
|
16
|
+
const VERSION = '0.1.0';
|
|
17
|
+
/**
|
|
18
|
+
* Runs the fnd CLI.
|
|
19
|
+
*
|
|
20
|
+
* @param args - Command line arguments (defaults to process.argv)
|
|
21
|
+
* @returns Promise that resolves when command completes
|
|
22
|
+
*/
|
|
23
|
+
async function run(args = process.argv) {
|
|
24
|
+
const program = new commander_1.Command();
|
|
25
|
+
program
|
|
26
|
+
.name('fnd')
|
|
27
|
+
.description('fnd-platform CLI - Scaffold AWS-native TypeScript monorepo projects')
|
|
28
|
+
.version(VERSION, '-v, --version', 'Display version number');
|
|
29
|
+
// Register commands
|
|
30
|
+
program.addCommand((0, index_js_1.newCommand)());
|
|
31
|
+
program.addCommand((0, index_js_1.synthCommand)());
|
|
32
|
+
program.addCommand((0, index_js_1.buildCommand)());
|
|
33
|
+
program.addCommand((0, index_js_1.addCommand)());
|
|
34
|
+
program.addCommand((0, index_js_1.deployCommand)());
|
|
35
|
+
// Handle unknown commands
|
|
36
|
+
program.on('command:*', () => {
|
|
37
|
+
console.error(`Invalid command: ${program.args.join(' ')}\n` +
|
|
38
|
+
'See --help for a list of available commands.');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
|
41
|
+
await program.parseAsync(args);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAsBH,kBAyBC;AA7CD,yCAAoC;AACpC,kDAM6B;AAE7B;;GAEG;AACH,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB;;;;;GAKG;AACI,KAAK,UAAU,GAAG,CAAC,OAAiB,OAAO,CAAC,IAAI;IACrD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,KAAK,CAAC;SACX,WAAW,CAAC,qEAAqE,CAAC;SAClF,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,wBAAwB,CAAC,CAAC;IAE/D,oBAAoB;IACpB,OAAO,CAAC,UAAU,CAAC,IAAA,qBAAU,GAAE,CAAC,CAAC;IACjC,OAAO,CAAC,UAAU,CAAC,IAAA,uBAAY,GAAE,CAAC,CAAC;IACnC,OAAO,CAAC,UAAU,CAAC,IAAA,uBAAY,GAAE,CAAC,CAAC;IACnC,OAAO,CAAC,UAAU,CAAC,IAAA,qBAAU,GAAE,CAAC,CAAC;IACjC,OAAO,CAAC,UAAU,CAAC,IAAA,wBAAa,GAAE,CAAC,CAAC;IAEpC,0BAA0B;IAC1B,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;QAC3B,OAAO,CAAC,KAAK,CACX,oBAAoB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;YAC5C,8CAA8C,CACjD,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for generating the infrastructure package.
|
|
3
|
+
*/
|
|
4
|
+
export interface InfraGeneratorOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Project root directory.
|
|
7
|
+
*/
|
|
8
|
+
projectRoot: string;
|
|
9
|
+
/**
|
|
10
|
+
* Project name (from package.json or .projenrc.ts).
|
|
11
|
+
*/
|
|
12
|
+
projectName: string;
|
|
13
|
+
/**
|
|
14
|
+
* Name of the API package.
|
|
15
|
+
*/
|
|
16
|
+
apiPackageName: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates the infrastructure package for CDK deployment.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Generation options
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateInfraPackage(options: InfraGeneratorOptions): void;
|
|
24
|
+
//# sourceMappingURL=infra-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-generator.d.ts","sourceRoot":"","sources":["../../src/lib/infra-generator.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA2BzE"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateInfraPackage = generateInfraPackage;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const logger_js_1 = require("./logger.js");
|
|
7
|
+
/**
|
|
8
|
+
* Generates the infrastructure package for CDK deployment.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Generation options
|
|
11
|
+
*/
|
|
12
|
+
function generateInfraPackage(options) {
|
|
13
|
+
const infraDir = (0, path_1.join)(options.projectRoot, 'packages/infra');
|
|
14
|
+
// Check if infra already exists
|
|
15
|
+
if ((0, fs_1.existsSync)(infraDir)) {
|
|
16
|
+
logger_js_1.logger.warn('Infrastructure package already exists at packages/infra');
|
|
17
|
+
logger_js_1.logger.info('Skipping infra generation. Manually add constructs if needed.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
logger_js_1.logger.info('Generating infrastructure package...');
|
|
21
|
+
// Create directory structure
|
|
22
|
+
(0, fs_1.mkdirSync)((0, path_1.join)(infraDir, 'src/stacks'), { recursive: true });
|
|
23
|
+
// Generate files
|
|
24
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(infraDir, 'package.json'), getPackageJsonTemplate(options));
|
|
25
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(infraDir, 'tsconfig.json'), getTsconfigTemplate());
|
|
26
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(infraDir, 'cdk.json'), getCdkJsonTemplate());
|
|
27
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(infraDir, 'src/app.ts'), getAppTemplate(options));
|
|
28
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(infraDir, 'src/stacks/api-stack.ts'), getApiStackTemplate(options));
|
|
29
|
+
logger_js_1.logger.success('Infrastructure package generated at packages/infra');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the package.json template.
|
|
33
|
+
*/
|
|
34
|
+
function getPackageJsonTemplate(options) {
|
|
35
|
+
const packageName = `@${options.projectName}/infra`;
|
|
36
|
+
return JSON.stringify({
|
|
37
|
+
name: packageName,
|
|
38
|
+
version: '0.1.0',
|
|
39
|
+
private: true,
|
|
40
|
+
scripts: {
|
|
41
|
+
build: 'tsc',
|
|
42
|
+
synth: 'cdk synth',
|
|
43
|
+
deploy: 'cdk deploy',
|
|
44
|
+
destroy: 'cdk destroy',
|
|
45
|
+
diff: 'cdk diff',
|
|
46
|
+
},
|
|
47
|
+
dependencies: {
|
|
48
|
+
'@fnd-platform/constructs': 'workspace:*',
|
|
49
|
+
'aws-cdk-lib': '^2.130.0',
|
|
50
|
+
constructs: '^10.3.0',
|
|
51
|
+
},
|
|
52
|
+
devDependencies: {
|
|
53
|
+
'@types/node': '^20.0.0',
|
|
54
|
+
'aws-cdk': '^2.130.0',
|
|
55
|
+
typescript: '^5.6.3',
|
|
56
|
+
},
|
|
57
|
+
}, null, 2);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the tsconfig.json template.
|
|
61
|
+
*/
|
|
62
|
+
function getTsconfigTemplate() {
|
|
63
|
+
return JSON.stringify({
|
|
64
|
+
extends: '../../tsconfig.base.json',
|
|
65
|
+
compilerOptions: {
|
|
66
|
+
outDir: 'lib',
|
|
67
|
+
rootDir: 'src',
|
|
68
|
+
declaration: true,
|
|
69
|
+
declarationMap: true,
|
|
70
|
+
},
|
|
71
|
+
include: ['src/**/*'],
|
|
72
|
+
exclude: ['node_modules', 'lib', 'cdk.out'],
|
|
73
|
+
}, null, 2);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the cdk.json template.
|
|
77
|
+
*/
|
|
78
|
+
function getCdkJsonTemplate() {
|
|
79
|
+
return JSON.stringify({
|
|
80
|
+
app: 'npx ts-node src/app.ts',
|
|
81
|
+
watch: {
|
|
82
|
+
include: ['**'],
|
|
83
|
+
exclude: [
|
|
84
|
+
'README.md',
|
|
85
|
+
'cdk*.json',
|
|
86
|
+
'**/*.d.ts',
|
|
87
|
+
'**/*.js',
|
|
88
|
+
'tsconfig.json',
|
|
89
|
+
'package*.json',
|
|
90
|
+
'node_modules',
|
|
91
|
+
'cdk.out',
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
context: {
|
|
95
|
+
'@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId': true,
|
|
96
|
+
'@aws-cdk/core:stackRelativeExports': true,
|
|
97
|
+
'@aws-cdk/aws-lambda:recognizeLayerVersion': true,
|
|
98
|
+
'@aws-cdk/core:validateSnapshotRemovalPolicy': true,
|
|
99
|
+
},
|
|
100
|
+
}, null, 2);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns the app.ts template.
|
|
104
|
+
*/
|
|
105
|
+
function getAppTemplate(options) {
|
|
106
|
+
// Convert project name to PascalCase for class naming
|
|
107
|
+
const stackClassName = toPascalCase(options.projectName) + 'Api';
|
|
108
|
+
return `#!/usr/bin/env npx ts-node
|
|
109
|
+
import { App } from 'aws-cdk-lib';
|
|
110
|
+
import { ApiStack } from './stacks/api-stack.js';
|
|
111
|
+
|
|
112
|
+
const app = new App();
|
|
113
|
+
|
|
114
|
+
// Get stage from context (default to 'dev')
|
|
115
|
+
const stage = app.node.tryGetContext('stage') || 'dev';
|
|
116
|
+
|
|
117
|
+
new ApiStack(app, '${stackClassName}', {
|
|
118
|
+
stage,
|
|
119
|
+
env: {
|
|
120
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
121
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
app.synth();
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Returns the api-stack.ts template.
|
|
130
|
+
*/
|
|
131
|
+
function getApiStackTemplate(options) {
|
|
132
|
+
const apiName = options.projectName.replace(/-/g, '_');
|
|
133
|
+
return `import {
|
|
134
|
+
FndApiStack,
|
|
135
|
+
FndApiStackProps,
|
|
136
|
+
FndLambdaFunction,
|
|
137
|
+
FndApiGateway,
|
|
138
|
+
} from '@fnd-platform/constructs';
|
|
139
|
+
import { Construct } from 'constructs';
|
|
140
|
+
import * as path from 'path';
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* API Stack for ${options.projectName}.
|
|
144
|
+
*
|
|
145
|
+
* This stack creates:
|
|
146
|
+
* - Lambda functions for API handlers
|
|
147
|
+
* - API Gateway REST API with routes
|
|
148
|
+
*/
|
|
149
|
+
export class ApiStack extends FndApiStack {
|
|
150
|
+
constructor(scope: Construct, id: string, props: FndApiStackProps) {
|
|
151
|
+
super(scope, id, props);
|
|
152
|
+
|
|
153
|
+
// Path to the API package
|
|
154
|
+
const apiPackagePath = path.resolve(__dirname, '../../${options.apiPackageName}');
|
|
155
|
+
|
|
156
|
+
// Health check handler
|
|
157
|
+
const healthHandler = new FndLambdaFunction(this, 'HealthHandler', {
|
|
158
|
+
entry: path.join(apiPackagePath, 'src/handlers/health.ts'),
|
|
159
|
+
stage: this.stage,
|
|
160
|
+
description: 'Health check endpoint',
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// API Gateway
|
|
164
|
+
const api = new FndApiGateway(this, 'Api', {
|
|
165
|
+
name: '${apiName}',
|
|
166
|
+
stage: this.stage,
|
|
167
|
+
routes: [
|
|
168
|
+
{
|
|
169
|
+
method: 'GET',
|
|
170
|
+
path: '/health',
|
|
171
|
+
handler: healthHandler.function,
|
|
172
|
+
requiresAuth: false,
|
|
173
|
+
},
|
|
174
|
+
// Add more routes here as you create handlers
|
|
175
|
+
],
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Stack outputs
|
|
179
|
+
this.addOutput('ApiUrl', api.url, 'API Gateway URL');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Converts a string to PascalCase.
|
|
186
|
+
*/
|
|
187
|
+
function toPascalCase(str) {
|
|
188
|
+
return str
|
|
189
|
+
.split(/[-_\s]+/)
|
|
190
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
191
|
+
.join('');
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=infra-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infra-generator.js","sourceRoot":"","sources":["../../src/lib/infra-generator.ts"],"names":[],"mappings":";;AA6BA,oDA2BC;AAxDD,2BAA0D;AAC1D,+BAA4B;AAC5B,2CAAqC;AAsBrC;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,OAA8B;IACjE,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAE7D,gCAAgC;IAChC,IAAI,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,kBAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;QACvE,kBAAM,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAC7E,OAAO;IACT,CAAC;IAED,kBAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IAEpD,6BAA6B;IAC7B,IAAA,cAAS,EAAC,IAAA,WAAI,EAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,iBAAiB;IACjB,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,QAAQ,EAAE,cAAc,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE/E,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,QAAQ,EAAE,eAAe,CAAC,EAAE,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AI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SACzE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ProfileReport } from './timer.js';
|
|
2
|
+
import type { NxCacheStats } from './nx-stats.js';
|
|
3
|
+
/**
|
|
4
|
+
* Logging utility with colored output for CLI feedback.
|
|
5
|
+
* Uses chalk for terminal styling.
|
|
6
|
+
*/
|
|
7
|
+
export declare const logger: {
|
|
8
|
+
/**
|
|
9
|
+
* Log informational messages (blue).
|
|
10
|
+
* @param msg - Message to log
|
|
11
|
+
*/
|
|
12
|
+
info: (msg: string) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Log success messages (green).
|
|
15
|
+
* @param msg - Message to log
|
|
16
|
+
*/
|
|
17
|
+
success: (msg: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Log warning messages (yellow).
|
|
20
|
+
* @param msg - Message to log
|
|
21
|
+
*/
|
|
22
|
+
warn: (msg: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Log error messages (red).
|
|
25
|
+
* @param msg - Message to log
|
|
26
|
+
*/
|
|
27
|
+
error: (msg: string) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Log debug messages (gray), only when DEBUG env var is set.
|
|
30
|
+
* @param msg - Message to log
|
|
31
|
+
*/
|
|
32
|
+
debug: (msg: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Log timing information (cyan), only when FND_PROFILE=true.
|
|
35
|
+
* @param name - Name of the timed operation
|
|
36
|
+
* @param durationMs - Duration in milliseconds
|
|
37
|
+
*/
|
|
38
|
+
timing: (name: string, durationMs: number) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Log a complete profile report, only when FND_PROFILE=true.
|
|
41
|
+
* @param report - Profile report to display
|
|
42
|
+
*/
|
|
43
|
+
report: (report: ProfileReport) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Log NX cache statistics, only when FND_PROFILE=true.
|
|
46
|
+
* @param stats - Cache statistics to display
|
|
47
|
+
*/
|
|
48
|
+
cacheStats: (stats: NxCacheStats) => void;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB;;;OAGG;gBACS,MAAM,KAAG,IAAI;IAIzB;;;OAGG;mBACY,MAAM,KAAG,IAAI;IAI5B;;;OAGG;gBACS,MAAM,KAAG,IAAI;IAIzB;;;OAGG;iBACU,MAAM,KAAG,IAAI;IAI1B;;;OAGG;iBACU,MAAM,KAAG,IAAI;IAM1B;;;;OAIG;mBACY,MAAM,cAAc,MAAM,KAAG,IAAI;IAQhD;;;OAGG;qBACc,aAAa,KAAG,IAAI;IAsBrC;;;OAGG;wBACiB,YAAY,KAAG,IAAI;CAcxC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.logger = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
/**
|
|
9
|
+
* Logging utility with colored output for CLI feedback.
|
|
10
|
+
* Uses chalk for terminal styling.
|
|
11
|
+
*/
|
|
12
|
+
exports.logger = {
|
|
13
|
+
/**
|
|
14
|
+
* Log informational messages (blue).
|
|
15
|
+
* @param msg - Message to log
|
|
16
|
+
*/
|
|
17
|
+
info: (msg) => {
|
|
18
|
+
console.log(chalk_1.default.blue('info'), msg);
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* Log success messages (green).
|
|
22
|
+
* @param msg - Message to log
|
|
23
|
+
*/
|
|
24
|
+
success: (msg) => {
|
|
25
|
+
console.log(chalk_1.default.green('success'), msg);
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Log warning messages (yellow).
|
|
29
|
+
* @param msg - Message to log
|
|
30
|
+
*/
|
|
31
|
+
warn: (msg) => {
|
|
32
|
+
console.log(chalk_1.default.yellow('warn'), msg);
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Log error messages (red).
|
|
36
|
+
* @param msg - Message to log
|
|
37
|
+
*/
|
|
38
|
+
error: (msg) => {
|
|
39
|
+
console.log(chalk_1.default.red('error'), msg);
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* Log debug messages (gray), only when DEBUG env var is set.
|
|
43
|
+
* @param msg - Message to log
|
|
44
|
+
*/
|
|
45
|
+
debug: (msg) => {
|
|
46
|
+
if (process.env.DEBUG || process.env.FND_LOG_LEVEL === 'debug') {
|
|
47
|
+
console.log(chalk_1.default.gray('debug'), msg);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Log timing information (cyan), only when FND_PROFILE=true.
|
|
52
|
+
* @param name - Name of the timed operation
|
|
53
|
+
* @param durationMs - Duration in milliseconds
|
|
54
|
+
*/
|
|
55
|
+
timing: (name, durationMs) => {
|
|
56
|
+
if (process.env.FND_PROFILE === 'true' || process.env.FND_PROFILE === '1') {
|
|
57
|
+
const formatted = durationMs < 1000 ? `${Math.round(durationMs)}ms` : `${(durationMs / 1000).toFixed(2)}s`;
|
|
58
|
+
console.log(chalk_1.default.cyan('timing'), `${name}: ${formatted}`);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Log a complete profile report, only when FND_PROFILE=true.
|
|
63
|
+
* @param report - Profile report to display
|
|
64
|
+
*/
|
|
65
|
+
report: (report) => {
|
|
66
|
+
if (process.env.FND_PROFILE === 'true' || process.env.FND_PROFILE === '1') {
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log(chalk_1.default.cyan.bold('─── Performance Report ───'));
|
|
69
|
+
console.log(chalk_1.default.cyan(`Command: ${report.command}`));
|
|
70
|
+
console.log(chalk_1.default.cyan(`Status: ${report.success ? chalk_1.default.green('SUCCESS') : chalk_1.default.red('FAILED')}`));
|
|
71
|
+
console.log(chalk_1.default.cyan(`Total: ${report.totalDurationFormatted}`));
|
|
72
|
+
if (report.timings.length > 0) {
|
|
73
|
+
console.log(chalk_1.default.cyan('\nPhase Breakdown:'));
|
|
74
|
+
for (const timing of report.timings) {
|
|
75
|
+
const percentage = ((timing.durationMs / report.totalDurationMs) * 100).toFixed(1);
|
|
76
|
+
console.log(chalk_1.default.cyan(` ${timing.name}: ${timing.durationFormatted} (${percentage}%)`));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
console.log(chalk_1.default.cyan.bold('──────────────────────────'));
|
|
80
|
+
console.log('');
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Log NX cache statistics, only when FND_PROFILE=true.
|
|
85
|
+
* @param stats - Cache statistics to display
|
|
86
|
+
*/
|
|
87
|
+
cacheStats: (stats) => {
|
|
88
|
+
if (process.env.FND_PROFILE === 'true' || process.env.FND_PROFILE === '1') {
|
|
89
|
+
console.log('');
|
|
90
|
+
console.log(chalk_1.default.cyan.bold('─── NX Cache Statistics ───'));
|
|
91
|
+
console.log(chalk_1.default.cyan(`Total tasks: ${stats.totalTasks}`));
|
|
92
|
+
console.log(chalk_1.default.cyan(`Cache hits: ${stats.cacheHits}`));
|
|
93
|
+
console.log(chalk_1.default.cyan(`Cache misses: ${stats.cacheMisses}`));
|
|
94
|
+
console.log(chalk_1.default.cyan(`Hit ratio: ${stats.hitRatioFormatted}`));
|
|
95
|
+
const targetStatus = stats.meetsTarget ? chalk_1.default.green('PASS') : chalk_1.default.yellow('FAIL');
|
|
96
|
+
console.log(chalk_1.default.cyan(`Target >80%: ${targetStatus}`));
|
|
97
|
+
console.log(chalk_1.default.cyan.bold('────────────────────────────'));
|
|
98
|
+
console.log('');
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAI1B;;;GAGG;AACU,QAAA,MAAM,GAAG;IACpB;;;OAGG;IACH,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,OAAO,EAAE,CAAC,GAAW,EAAQ,EAAE;QAC7B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACH,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,KAAK,EAAE,CAAC,GAAW,EAAQ,EAAE;QAC3B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,KAAK,EAAE,CAAC,GAAW,EAAQ,EAAE;QAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,K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AC,UAAU,EAAE,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YAC9D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;YACpE,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,eAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACpF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NX cache statistics for build performance analysis.
|
|
3
|
+
*/
|
|
4
|
+
export interface NxCacheStats {
|
|
5
|
+
/**
|
|
6
|
+
* Total number of tasks executed.
|
|
7
|
+
*/
|
|
8
|
+
totalTasks: number;
|
|
9
|
+
/**
|
|
10
|
+
* Number of tasks served from cache.
|
|
11
|
+
*/
|
|
12
|
+
cacheHits: number;
|
|
13
|
+
/**
|
|
14
|
+
* Number of tasks that had to be computed.
|
|
15
|
+
*/
|
|
16
|
+
cacheMisses: number;
|
|
17
|
+
/**
|
|
18
|
+
* Cache hit ratio as a decimal (0.0 to 1.0).
|
|
19
|
+
*/
|
|
20
|
+
hitRatio: number;
|
|
21
|
+
/**
|
|
22
|
+
* Cache hit ratio as a percentage string.
|
|
23
|
+
*/
|
|
24
|
+
hitRatioFormatted: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the cache hit ratio meets the target (>80%).
|
|
27
|
+
*/
|
|
28
|
+
meetsTarget: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Target cache hit ratio (80%).
|
|
32
|
+
*/
|
|
33
|
+
export declare const CACHE_HIT_TARGET = 0.8;
|
|
34
|
+
/**
|
|
35
|
+
* Parses NX output to extract cache statistics.
|
|
36
|
+
*
|
|
37
|
+
* @param output - NX command output
|
|
38
|
+
* @returns Cache statistics or null if parsing fails
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const output = `
|
|
43
|
+
* > NX Successfully ran target build for 5 projects (234ms)
|
|
44
|
+
*
|
|
45
|
+
* Nx read the output from the cache instead of running the command for 4 out of 5 tasks.
|
|
46
|
+
* `;
|
|
47
|
+
* const stats = parseNxOutput(output);
|
|
48
|
+
* // { totalTasks: 5, cacheHits: 4, cacheMisses: 1, hitRatio: 0.8, ... }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseNxOutput(output: string): NxCacheStats | null;
|
|
52
|
+
/**
|
|
53
|
+
* Gets cache statistics from the NX cache directory.
|
|
54
|
+
*
|
|
55
|
+
* @param projectRoot - Root directory of the project
|
|
56
|
+
* @returns Cache statistics based on cache directory analysis
|
|
57
|
+
*/
|
|
58
|
+
export declare function getCacheDirectoryStats(projectRoot: string): {
|
|
59
|
+
cacheEntries: number;
|
|
60
|
+
cacheSizeMB: number;
|
|
61
|
+
} | null;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a formatted report of NX cache statistics.
|
|
64
|
+
*
|
|
65
|
+
* @param stats - Cache statistics to report
|
|
66
|
+
* @returns Formatted string for display
|
|
67
|
+
*/
|
|
68
|
+
export declare function formatCacheStats(stats: NxCacheStats): string;
|
|
69
|
+
//# sourceMappingURL=nx-stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-stats.d.ts","sourceRoot":"","sources":["../../src/lib/nx-stats.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAuCjE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAClB;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAgCtD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAU5D"}
|