@rushstack/rundown 1.1.3 → 1.1.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Rundown.js","sourceRoot":"","sources":["../src/Rundown.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,oEAAyF;AACzF,6DAA+C;AAC/C,2CAA6B;AAC7B,8DAAqC;AAIrC,MAAa,OAAO;IAApB;QACE,yCAAyC;QACjC,uBAAkB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAqI9D,CAAC;IAnIQ,KAAK,CAAC,WAAW,CACtB,UAAkB,EAClB,IAAwB,EACxB,KAAc,EACd,cAAuB;QAEvB,IAAI,CAAC,8BAAU,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,UAAU,CAAC,CAAC;SAC5E;QACD,MAAM,kBAAkB,GAAW,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE5D,MAAM,YAAY,GAAa,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,CAAC;QAE1E,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,CAAC,kBAAkB,EAAE,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACpF,OAAO,CAAC,GAAG,EAAE,CAAC;QAEd,wBAAwB;QACxB,0EAA0E;QAC1E,MAAM,QAAQ,GAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,CAAC;QAEtG,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;QAEhE,IAAI,CA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K,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC;SACjG,CAAC,CAAC;QAEH,IAAI,iBAAiB,GAAY,KAAK,CAAC;QAEvC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAmB,EAAQ,EAAE;YACvD,QAAQ,OAAO,CAAC,EAAE,EAAE;gBAClB,KAAK,OAAO;oBACV,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE;wBACpC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;qBAC1E;oBACD,MAAM;gBACR,KAAK,MAAM;oBACT,iBAAiB,GAAG,IAAI,CAAC;oBACzB,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;aACtE;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1C,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAmB,EAAE,MAAqB,EAAQ,EAAE;gBAC3E,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE;oBACjC,MAAM,CAAC,IAAI,KAAK,CAAC,0CAA0C,GAAG,IAAI,CAAC,CAAC,CAAC;iBACtE;qBAAM,IAAI,CAAC,iBAAiB,EAAE;oBAC7B,MAAM,CAAC,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC,CAAC;iBAChF;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvID,0BAuIC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { FileSystem, PackageJsonLookup, Sort, Text } from '@rushstack/node-core-library';\nimport * as child_process from 'child_process';\nimport * as path from 'path';\nimport stringArgv from 'string-argv';\n\nimport { IpcMessage } from './LauncherTypes';\n\nexport class Rundown {\n // Map from required path --> caller path\n private _importedModuleMap: Map<string, string> = new Map();\n\n public async invokeAsync(\n scriptPath: string,\n args: string | undefined,\n quiet: boolean,\n ignoreExitCode: boolean\n ): Promise<void> {\n if (!FileSystem.exists(scriptPath)) {\n throw new Error('The specified script path does not exist: ' + scriptPath);\n }\n const absoluteScriptPath: string = path.resolve(scriptPath);\n\n const expandedArgs: string[] = args === undefined ? [] : stringArgv(args);\n\n console.log('Starting process: ' + [absoluteScriptPath, ...expandedArgs].join(' '));\n console.log();\n\n // Example process.argv:\n // [\"path/to/launcher.js\", \"path/to/target-script.js\", \"first-target-arg\"]\n const nodeArgs: string[] = [path.join(__dirname, 'launcher.js'), absoluteScriptPath, ...expandedArgs];\n\n await this._spawnLauncherAsync(nodeArgs, quiet, ignoreExitCode);\n\n if (!quiet) {\n console.log();\n }\n }\n\n public writeSnapshotReport(): void {\n const reportPath: string = 'rundown-snapshot.log';\n console.log('Writing report file: ' + reportPath);\n\n const packageJsonLookup: PackageJsonLookup = new PackageJsonLookup();\n const importedPaths: string[] = [...this._importedModuleMap.keys()];\n const importedPackageFolders: Set<string> = new Set();\n\n for (const importedPath of importedPaths) {\n const importedPackageFolder: string | undefined =\n packageJsonLookup.tryGetPackageFolderFor(importedPath);\n if (importedPackageFolder) {\n if (/[\\\\/]node_modules[\\\\/]/i.test(importedPackageFolder)) {\n importedPackageFolders.add(path.basename(importedPackageFolder));\n } else {\n const relativePath: string = path.relative(process.cwd(), importedPackageFolder);\n importedPackageFolders.add(Text.replaceAll(relativePath, '\\\\', '/'));\n }\n } else {\n // If the importedPath does not belong to an NPM package, then rundown-snapshot.log can ignore it.\n // In other words, treat it the same way as the local project's source files.\n }\n }\n\n Sort.sortSet(importedPackageFolders);\n const data: string = [...importedPackageFolders].join('\\n') + '\\n';\n\n FileSystem.writeFile(reportPath, data);\n }\n\n public writeInspectReport(traceImports: boolean): void {\n const reportPath: string = 'rundown-inspect.log';\n console.log('Writing report file: ' + reportPath);\n\n const importedPaths: string[] = [...this._importedModuleMap.keys()];\n importedPaths.sort();\n\n let data: string = '';\n\n if (traceImports) {\n for (const importedPath of importedPaths) {\n data += importedPath + '\\n';\n\n let current: string = importedPath;\n const visited: Set<string> = new Set();\n for (;;) {\n const callerPath: string | undefined = this._importedModuleMap.get(current);\n if (!callerPath) {\n break;\n }\n if (visited.has(callerPath)) {\n break;\n }\n visited.add(callerPath);\n data += ' imported by ' + callerPath + '\\n';\n current = callerPath;\n }\n data += '\\n';\n }\n } else {\n data = importedPaths.join('\\n') + '\\n';\n }\n\n FileSystem.writeFile(reportPath, data);\n }\n\n private async _spawnLauncherAsync(\n nodeArgs: string[],\n quiet: boolean,\n ignoreExitCode: boolean\n ): Promise<void> {\n const childProcess: child_process.ChildProcess = child_process.spawn(process.execPath, nodeArgs, {\n stdio: quiet ? ['inherit', 'ignore', 'ignore', 'ipc'] : ['inherit', 'inherit', 'inherit', 'ipc']\n });\n\n let completedNormally: boolean = false;\n\n childProcess.on('message', (message: IpcMessage): void => {\n switch (message.id) {\n case 'trace':\n for (const record of message.records) {\n this._importedModuleMap.set(record.importedModule, record.callingModule);\n }\n break;\n case 'done':\n completedNormally = true;\n break;\n default:\n throw new Error('Unknown IPC message: ' + JSON.stringify(message));\n }\n });\n\n await new Promise<void>((resolve, reject) => {\n childProcess.on('exit', (code: number | null, signal: string | null): void => {\n if (code !== 0 && !ignoreExitCode) {\n reject(new Error('Child process terminated with exit code ' + code));\n } else if (!completedNormally) {\n reject(new Error('Child process terminated without completing IPC handshake'));\n } else {\n resolve();\n }\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"Rundown.js","sourceRoot":"","sources":["../src/Rundown.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;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,KAAK,OAAO;oBACV,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE;wBACpC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;qBAC1E;oBACD,MAAM;gBACR,KAAK,MAAM;oBACT,iBAAiB,GAAG,IAAI,CAAC;oBACzB,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;aACtE;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1C,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAmB,EAAE,MAAqB,EAAQ,EAAE;gBAC3E,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE;oBACjC,MAAM,CAAC,IAAI,KAAK,CAAC,0CAA0C,GAAG,IAAI,CAAC,CAAC,CAAC;iBACtE;qBAAM,IAAI,CAAC,iBAAiB,EAAE;oBAC7B,MAAM,CAAC,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC,CAAC;iBAChF;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvID,0BAuIC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { FileSystem, PackageJsonLookup, Sort, Text } from '@rushstack/node-core-library';\nimport * as child_process from 'child_process';\nimport * as path from 'path';\nimport stringArgv from 'string-argv';\n\nimport type { IpcMessage } from './LauncherTypes';\n\nexport class Rundown {\n // Map from required path --> caller path\n private _importedModuleMap: Map<string, string> = new Map();\n\n public async invokeAsync(\n scriptPath: string,\n args: string | undefined,\n quiet: boolean,\n ignoreExitCode: boolean\n ): Promise<void> {\n if (!FileSystem.exists(scriptPath)) {\n throw new Error('The specified script path does not exist: ' + scriptPath);\n }\n const absoluteScriptPath: string = path.resolve(scriptPath);\n\n const expandedArgs: string[] = args === undefined ? [] : stringArgv(args);\n\n console.log('Starting process: ' + [absoluteScriptPath, ...expandedArgs].join(' '));\n console.log();\n\n // Example process.argv:\n // [\"path/to/launcher.js\", \"path/to/target-script.js\", \"first-target-arg\"]\n const nodeArgs: string[] = [path.join(__dirname, 'launcher.js'), absoluteScriptPath, ...expandedArgs];\n\n await this._spawnLauncherAsync(nodeArgs, quiet, ignoreExitCode);\n\n if (!quiet) {\n console.log();\n }\n }\n\n public writeSnapshotReport(): void {\n const reportPath: string = 'rundown-snapshot.log';\n console.log('Writing report file: ' + reportPath);\n\n const packageJsonLookup: PackageJsonLookup = new PackageJsonLookup();\n const importedPaths: string[] = [...this._importedModuleMap.keys()];\n const importedPackageFolders: Set<string> = new Set();\n\n for (const importedPath of importedPaths) {\n const importedPackageFolder: string | undefined =\n packageJsonLookup.tryGetPackageFolderFor(importedPath);\n if (importedPackageFolder) {\n if (/[\\\\/]node_modules[\\\\/]/i.test(importedPackageFolder)) {\n importedPackageFolders.add(path.basename(importedPackageFolder));\n } else {\n const relativePath: string = path.relative(process.cwd(), importedPackageFolder);\n importedPackageFolders.add(Text.replaceAll(relativePath, '\\\\', '/'));\n }\n } else {\n // If the importedPath does not belong to an NPM package, then rundown-snapshot.log can ignore it.\n // In other words, treat it the same way as the local project's source files.\n }\n }\n\n Sort.sortSet(importedPackageFolders);\n const data: string = [...importedPackageFolders].join('\\n') + '\\n';\n\n FileSystem.writeFile(reportPath, data);\n }\n\n public writeInspectReport(traceImports: boolean): void {\n const reportPath: string = 'rundown-inspect.log';\n console.log('Writing report file: ' + reportPath);\n\n const importedPaths: string[] = [...this._importedModuleMap.keys()];\n importedPaths.sort();\n\n let data: string = '';\n\n if (traceImports) {\n for (const importedPath of importedPaths) {\n data += importedPath + '\\n';\n\n let current: string = importedPath;\n const visited: Set<string> = new Set();\n for (;;) {\n const callerPath: string | undefined = this._importedModuleMap.get(current);\n if (!callerPath) {\n break;\n }\n if (visited.has(callerPath)) {\n break;\n }\n visited.add(callerPath);\n data += ' imported by ' + callerPath + '\\n';\n current = callerPath;\n }\n data += '\\n';\n }\n } else {\n data = importedPaths.join('\\n') + '\\n';\n }\n\n FileSystem.writeFile(reportPath, data);\n }\n\n private async _spawnLauncherAsync(\n nodeArgs: string[],\n quiet: boolean,\n ignoreExitCode: boolean\n ): Promise<void> {\n const childProcess: child_process.ChildProcess = child_process.spawn(process.execPath, nodeArgs, {\n stdio: quiet ? ['inherit', 'ignore', 'ignore', 'ipc'] : ['inherit', 'inherit', 'inherit', 'ipc']\n });\n\n let completedNormally: boolean = false;\n\n childProcess.on('message', (message: IpcMessage): void => {\n switch (message.id) {\n case 'trace':\n for (const record of message.records) {\n this._importedModuleMap.set(record.importedModule, record.callingModule);\n }\n break;\n case 'done':\n completedNormally = true;\n break;\n default:\n throw new Error('Unknown IPC message: ' + JSON.stringify(message));\n }\n });\n\n await new Promise<void>((resolve, reject) => {\n childProcess.on('exit', (code: number | null, signal: string | null): void => {\n if (code !== 0 && !ignoreExitCode) {\n reject(new Error('Child process terminated with exit code ' + code));\n } else if (!completedNormally) {\n reject(new Error('Child process terminated without completing IPC handshake'));\n } else {\n resolve();\n }\n });\n });\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { CommandLineAction, ICommandLineActionOptions, CommandLineStringParameter, CommandLineFlagParameter } from '@rushstack/ts-command-line';
1
+ import { CommandLineAction, type ICommandLineActionOptions, type CommandLineStringParameter, type CommandLineFlagParameter } from '@rushstack/ts-command-line';
2
2
  export declare abstract class BaseReportAction extends CommandLineAction {
3
3
  protected readonly scriptParameter: CommandLineStringParameter;
4
4
  protected readonly argsParameter: CommandLineStringParameter;
@@ -1 +1 @@
1
- {"version":3,"file":"BaseReportAction.d.ts","sourceRoot":"","sources":["../../src/cli/BaseReportAction.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,8BAAsB,gBAAiB,SAAQ,iBAAiB;IAC9D,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,0BAA0B,CAAC;IAC/D,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,0BAA0B,CAAC;IAC7D,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,wBAAwB,CAAC;IAC5D,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;gBAElD,OAAO,EAAE,yBAAyB;CA8BtD"}
1
+ {"version":3,"file":"BaseReportAction.d.ts","sourceRoot":"","sources":["../../src/cli/BaseReportAction.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EACjB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC9B,MAAM,4BAA4B,CAAC;AAEpC,8BAAsB,gBAAiB,SAAQ,iBAAiB;IAC9D,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,0BAA0B,CAAC;IAC/D,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,0BAA0B,CAAC;IAC7D,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,wBAAwB,CAAC;IAC5D,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,wBAAwB,CAAC;gBAElD,OAAO,EAAE,yBAAyB;CA8BtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"BaseReportAction.js","sourceRoot":"","sources":["../../src/cli/BaseReportAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,4FAA4F;AAC5F,2DAA2D;AAE3D,gEAKoC;AAEpC,MAAsB,gBAAiB,SAAQ,mCAAiB;IAM9D,YAAmB,OAAkC;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAChD,iBAAiB,EAAE,UAAU;YAC7B,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,MAAM;YACpB,WAAW,EAAE,oFAAoF;YACjG,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAC9C,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,QAAQ;YACtB,WAAW,EACT,yFAAyF;gBACzF,sDAAsD;gBACtD,+EAA+E;SAClF,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC;YAC7C,iBAAiB,EAAE,SAAS;YAC5B,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,uDAAuD;SACrE,CAAC,CAAC;QACH,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,CAAC;YACtD,iBAAiB,EAAE,oBAAoB;YACvC,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,kFAAkF;SAChG,CAAC,CAAC;IACL,CAAC;CACF;AApCD,4CAoCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport {\n CommandLineAction,\n ICommandLineActionOptions,\n CommandLineStringParameter,\n CommandLineFlagParameter\n} from '@rushstack/ts-command-line';\n\nexport abstract class BaseReportAction extends CommandLineAction {\n protected readonly scriptParameter: CommandLineStringParameter;\n protected readonly argsParameter: CommandLineStringParameter;\n protected readonly quietParameter: CommandLineFlagParameter;\n protected readonly ignoreExitCodeParameter: CommandLineFlagParameter;\n\n public constructor(options: ICommandLineActionOptions) {\n super(options);\n\n this.scriptParameter = this.defineStringParameter({\n parameterLongName: '--script',\n parameterShortName: '-s',\n argumentName: 'PATH',\n description: 'The path to a .js file that will be the entry point for the target Node.js process',\n required: true\n });\n this.argsParameter = this.defineStringParameter({\n parameterLongName: '--args',\n parameterShortName: '-a',\n argumentName: 'STRING',\n description:\n 'Specifies command-line arguments to be passed to the target Node.js process. The value' +\n ' should be a single text string delimited by spaces.' +\n ' Example: rundown inspect --scripts ./example.js --args=\"--flag --option=123\"'\n });\n this.quietParameter = this.defineFlagParameter({\n parameterLongName: '--quiet',\n parameterShortName: '-q',\n description: 'Suppress STDOUT/STDERR for the target Node.js process'\n });\n this.ignoreExitCodeParameter = this.defineFlagParameter({\n parameterLongName: '--ignore-exit-code',\n parameterShortName: '-i',\n description: 'Do not report an error if the target Node.js process returns a nonzero exit code'\n });\n }\n}\n"]}
1
+ {"version":3,"file":"BaseReportAction.js","sourceRoot":"","sources":["../../src/cli/BaseReportAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,4FAA4F;AAC5F,2DAA2D;AAE3D,gEAKoC;AAEpC,MAAsB,gBAAiB,SAAQ,mCAAiB;IAM9D,YAAmB,OAAkC;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAChD,iBAAiB,EAAE,UAAU;YAC7B,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,MAAM;YACpB,WAAW,EAAE,oFAAoF;YACjG,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAC9C,iBAAiB,EAAE,QAAQ;YAC3B,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,QAAQ;YACtB,WAAW,EACT,yFAAyF;gBACzF,sDAAsD;gBACtD,+EAA+E;SAClF,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC;YAC7C,iBAAiB,EAAE,SAAS;YAC5B,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,uDAAuD;SACrE,CAAC,CAAC;QACH,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,CAAC;YACtD,iBAAiB,EAAE,oBAAoB;YACvC,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,kFAAkF;SAChG,CAAC,CAAC;IACL,CAAC;CACF;AApCD,4CAoCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport {\n CommandLineAction,\n type ICommandLineActionOptions,\n type CommandLineStringParameter,\n type CommandLineFlagParameter\n} from '@rushstack/ts-command-line';\n\nexport abstract class BaseReportAction extends CommandLineAction {\n protected readonly scriptParameter: CommandLineStringParameter;\n protected readonly argsParameter: CommandLineStringParameter;\n protected readonly quietParameter: CommandLineFlagParameter;\n protected readonly ignoreExitCodeParameter: CommandLineFlagParameter;\n\n public constructor(options: ICommandLineActionOptions) {\n super(options);\n\n this.scriptParameter = this.defineStringParameter({\n parameterLongName: '--script',\n parameterShortName: '-s',\n argumentName: 'PATH',\n description: 'The path to a .js file that will be the entry point for the target Node.js process',\n required: true\n });\n this.argsParameter = this.defineStringParameter({\n parameterLongName: '--args',\n parameterShortName: '-a',\n argumentName: 'STRING',\n description:\n 'Specifies command-line arguments to be passed to the target Node.js process. The value' +\n ' should be a single text string delimited by spaces.' +\n ' Example: rundown inspect --scripts ./example.js --args=\"--flag --option=123\"'\n });\n this.quietParameter = this.defineFlagParameter({\n parameterLongName: '--quiet',\n parameterShortName: '-q',\n description: 'Suppress STDOUT/STDERR for the target Node.js process'\n });\n this.ignoreExitCodeParameter = this.defineFlagParameter({\n parameterLongName: '--ignore-exit-code',\n parameterShortName: '-i',\n description: 'Do not report an error if the target Node.js process returns a nonzero exit code'\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"InspectAction.js","sourceRoot":"","sources":["../../src/cli/InspectAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,yDAAsD;AACtD,wCAAqC;AAErC,MAAa,aAAc,SAAQ,mCAAgB;IAGjD;QACE,KAAK,CAAC;YACJ,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,iEAAiE;YAC1E,aAAa,EACX,wFAAwF;gBACxF,sCAAsC;SACzC,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC;YAC9C,iBAAiB,EAAE,iBAAiB;YACpC,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,0EAA0E;SACxF,CAAC,CAAC;IACL,CAAC;IAES,KAAK,CAAC,SAAS;QACvB,MAAM,OAAO,GAAY,IAAI,iBAAO,EAAE,CAAC;QACvC,MAAM,OAAO,CAAC,WAAW,CACvB,IAAI,CAAC,eAAe,CAAC,KAAM,EAC3B,IAAI,CAAC,aAAa,CAAC,KAAK,EACxB,IAAI,CAAC,cAAc,CAAC,KAAO,EAC3B,IAAI,CAAC,uBAAuB,CAAC,KAAO,CACrC,CAAC;QACF,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,KAAO,CAAC,CAAC;IAC3D,CAAC;CACF;AA7BD,sCA6BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { CommandLineFlagParameter } from '@rushstack/ts-command-line';\n\nimport { BaseReportAction } from './BaseReportAction';\nimport { Rundown } from '../Rundown';\n\nexport class InspectAction extends BaseReportAction {\n private readonly _traceParameter: CommandLineFlagParameter;\n\n public constructor() {\n super({\n actionName: 'inspect',\n summary: 'Invoke a Node.js script and generate detailed diagnostic output',\n documentation:\n 'Invoke a Node.js script and generate detailed diagnostic output. This command is used' +\n ' to inspect performance regressions.'\n });\n\n this._traceParameter = this.defineFlagParameter({\n parameterLongName: '--trace-imports',\n parameterShortName: '-t',\n description: 'Reports the call chain for each module path, showing how it was imported'\n });\n }\n\n protected async onExecute(): Promise<void> {\n const rundown: Rundown = new Rundown();\n await rundown.invokeAsync(\n this.scriptParameter.value!,\n this.argsParameter.value,\n this.quietParameter.value!!,\n this.ignoreExitCodeParameter.value!!\n );\n rundown.writeInspectReport(this._traceParameter.value!!);\n }\n}\n"]}
1
+ {"version":3,"file":"InspectAction.js","sourceRoot":"","sources":["../../src/cli/InspectAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,yDAAsD;AACtD,wCAAqC;AAErC,MAAa,aAAc,SAAQ,mCAAgB;IAGjD;QACE,KAAK,CAAC;YACJ,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,iEAAiE;YAC1E,aAAa,EACX,wFAAwF;gBACxF,sCAAsC;SACzC,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC;YAC9C,iBAAiB,EAAE,iBAAiB;YACpC,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,0EAA0E;SACxF,CAAC,CAAC;IACL,CAAC;IAES,KAAK,CAAC,SAAS;QACvB,MAAM,OAAO,GAAY,IAAI,iBAAO,EAAE,CAAC;QACvC,MAAM,OAAO,CAAC,WAAW,CACvB,IAAI,CAAC,eAAe,CAAC,KAAM,EAC3B,IAAI,CAAC,aAAa,CAAC,KAAK,EACxB,IAAI,CAAC,cAAc,CAAC,KAAO,EAC3B,IAAI,CAAC,uBAAuB,CAAC,KAAO,CACrC,CAAC;QACF,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,KAAO,CAAC,CAAC;IAC3D,CAAC;CACF;AA7BD,sCA6BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { CommandLineFlagParameter } from '@rushstack/ts-command-line';\n\nimport { BaseReportAction } from './BaseReportAction';\nimport { Rundown } from '../Rundown';\n\nexport class InspectAction extends BaseReportAction {\n private readonly _traceParameter: CommandLineFlagParameter;\n\n public constructor() {\n super({\n actionName: 'inspect',\n summary: 'Invoke a Node.js script and generate detailed diagnostic output',\n documentation:\n 'Invoke a Node.js script and generate detailed diagnostic output. This command is used' +\n ' to inspect performance regressions.'\n });\n\n this._traceParameter = this.defineFlagParameter({\n parameterLongName: '--trace-imports',\n parameterShortName: '-t',\n description: 'Reports the call chain for each module path, showing how it was imported'\n });\n }\n\n protected async onExecute(): Promise<void> {\n const rundown: Rundown = new Rundown();\n await rundown.invokeAsync(\n this.scriptParameter.value!,\n this.argsParameter.value,\n this.quietParameter.value!!,\n this.ignoreExitCodeParameter.value!!\n );\n rundown.writeInspectReport(this._traceParameter.value!!);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rundown",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Detect load time regressions by running an app, tracing require() calls, and generating a deterministic report",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,12 +18,11 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "string-argv": "~0.3.1",
21
- "@rushstack/node-core-library": "3.60.0",
22
- "@rushstack/ts-command-line": "4.16.0"
21
+ "@rushstack/node-core-library": "3.60.1",
22
+ "@rushstack/ts-command-line": "4.16.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@rushstack/eslint-config": "3.3.4",
26
- "@rushstack/heft": "0.61.1",
25
+ "@rushstack/heft": "0.61.2",
27
26
  "local-node-rig": "1.0.0"
28
27
  },
29
28
  "scripts": {