diff --git a/cli/src/builders/imd.ts b/cli/src/builders/imd.ts index fe03c39..96d9065 100644 --- a/cli/src/builders/imd.ts +++ b/cli/src/builders/imd.ts @@ -180,7 +180,7 @@ export class ImpactMarkdown { this.targets.getResolvedObjects().forEach(ileObject => { - let logs = this.targets.logger.getLogsFor(ileObject.relativePath); + let logs = this.targets.logger.getLogsFor(ileObject.relativePath) || []; let parents = this.targets.getTargets().filter(t => t.deps.some(d => d.systemName === ileObject.systemName && d.type === ileObject.type)); let children = this.targets.getTarget(ileObject)?.deps || []; diff --git a/cli/src/builders/make/index.ts b/cli/src/builders/make/index.ts index 4981610..bd5cf39 100644 --- a/cli/src/builders/make/index.ts +++ b/cli/src/builders/make/index.ts @@ -12,7 +12,7 @@ import { iProject } from '../iProject'; export class MakeProject { private noChildren: boolean = false; private settings: iProject = new iProject(); - private folderSettings: {[folder: string]: FolderOptions} = {}; + private folderSettings: { [folder: string]: FolderOptions } = {}; constructor(private cwd: string, private targets: Targets) { this.setupSettings(); @@ -207,32 +207,30 @@ export class MakeProject { if (objects.length > 0) { for (const ileObject of objects) { if (ileObject.reference) continue; - - // This is used when your object really has source + // This is used when your object really has source const possibleTarget: ILEObjectTarget = this.targets.getTarget(ileObject) || (ileObject as ILEObjectTarget); const customAttributes = this.getObjectAttributes(data, possibleTarget); - lines.push(...MakeProject.generateSpecificTarget(data, possibleTarget, customAttributes)); } } else - if (data.sourceOptional) { - // This is usually used as a generic target. - lines.push( - `$(PREPATH)/%.${data.becomes}: ${data.targetSource ? asPosix(data.targetSource) : ``}`, - ...(data.preCommands ? data.preCommands.map(cmd => `\t${cmd}`) : []), - ...(data.command ? - [ - `\tliblist -c $(BIN_LIB);\\`, - `\tliblist -a $(LIBL);\\`, - `\tsystem "${toCl(data.command, data.parameters)}"` // TODO: write the spool file somewhere? - ] - : [] - ), - ...(data.postCommands ? data.postCommands.map(cmd => `\t${cmd}`) : []), - ); - } + if (data.sourceOptional) { + // This is usually used as a generic target. + lines.push( + `$(PREPATH)/%.${data.becomes}: ${data.targetSource ? asPosix(data.targetSource) : ``}`, + ...(data.preCommands ? data.preCommands.map(cmd => `\t${cmd}`) : []), + ...(data.command ? + [ + `\tliblist -c $(BIN_LIB);\\`, + `\tliblist -a $(LIBL);\\`, + `\tsystem "${toCl(data.command, data.parameters)}"` // TODO: write the spool file somewhere? + ] + : [] + ), + ...(data.postCommands ? data.postCommands.map(cmd => `\t${cmd}`) : []), + ); + } } lines.push(``); @@ -249,6 +247,19 @@ export class MakeProject { const qsysTempName: string | undefined = (parentName && parentName.length > 10 ? parentName.substring(0, 10) : parentName); const resolve = (command: string) => { + + if (ileObject.overrides) { + for (const [key, value] of Object.entries(ileObject.overrides)) { + const regex = new RegExp(`(${key.toUpperCase()}.*)\\$[\\*<]`, `g`); + const match = regex.exec(command); + if (match) + command = command.replace(regex, `$1${value}`); + else { + command = `${command} ${key.toUpperCase()}(${value})`; + } + } + } + command = command.replace(new RegExp(`\\*CURLIB`, `g`), `$(BIN_LIB)`); command = command.replace(new RegExp(`\\$\\*`, `g`), ileObject.systemName); command = command.replace(new RegExp(`\\$<`, `g`), asPosix(ileObject.relativePath)); @@ -263,13 +274,11 @@ export class MakeProject { command = command.replace(new RegExp(`\\*${objType}S`, `g`), specificDeps.map(d => d.systemName).join(` `)); } } - return command; } // TODO: resolve the parameters from the Rules.mk const objectKey = `${ileObject.systemName}.${ileObject.type}`; - if (customAttributes) { data.parameters = { ...data.parameters, @@ -278,7 +287,6 @@ export class MakeProject { } let sourceFileCcsid = `*JOB`; - if (data.parameters.memberCcsid) { sourceFileCcsid = data.parameters.memberCcsid; delete data.parameters.memberCcsid; diff --git a/cli/src/targets.ts b/cli/src/targets.ts index 659b984..aecc19e 100644 --- a/cli/src/targets.ts +++ b/cli/src/targets.ts @@ -5,7 +5,7 @@ import fss from 'fs'; import Cache from "vscode-rpgle/language/models/cache"; import { IncludeStatement } from "vscode-rpgle/language/parserTypes"; import { infoOut, warningOut } from './cli'; -import { DefinitionType, File, Module, CLParser } from 'vscode-clle/language'; +import { DefinitionType, File, Module, CLParser, Token } from 'vscode-clle/language'; import { DisplayFile as dds } from "vscode-displayfile/src/dspf"; import Document from "vscode-db2i/src/language/sql/document"; import { ObjectRef, StatementType } from 'vscode-db2i/src/language/sql/types'; @@ -33,6 +33,10 @@ const sqlTypeExtension = { const bindingDirectoryTarget: ILEObject = { systemName: `$(APP_BNDDIR)`, type: `BNDDIR` }; const TextRegex = /\%TEXT.*(?=\n|\*)/gm +const ParameterRegexs = [ + /\%(PGM)(.*)(?=\n|\*)/gm, + /\%(VLDCKR)(.*)(?=\n|\*)/gm +]; export interface ILEObject { systemName: string; @@ -55,6 +59,7 @@ export interface ILEObject { export interface ILEObjectTarget extends ILEObject { deps: ILEObject[]; + overrides?: CommandParameters; } export interface TargetSuggestions { @@ -77,6 +82,11 @@ interface FileOptions { text?: string; } +interface CommandParameters { + pgm?: string; + vldckr?: string; +} + /** * This class is responsible for storing all the targets * and their dependencies. It also handles the parsing @@ -337,6 +347,7 @@ export class Targets { try { [textMatch] = content.match(TextRegex); if (textMatch) { + console.log(textMatch); if (textMatch.startsWith(`%TEXT`)) textMatch = textMatch.substring(5); if (textMatch.endsWith(`*`)) textMatch = textMatch.substring(0, textMatch.length - 1); textMatch = textMatch.trim(); @@ -392,7 +403,7 @@ export class Targets { this.createSrvPgmTarget(filePath, module, options); } else if (cmdExtensions.includes(ext)) { - this.createCmdTarget(filePath, options); + this.createCmdTarget(filePath, content, options); } } catch (e) { this.logger.fileLog(relative, { @@ -415,10 +426,53 @@ export class Targets { } - private createCmdTarget(localPath, options: FileOptions = {}) { - this.resolvePathToObject(localPath, options.text); + private createCmdTarget(localPath: string, content: string, options: FileOptions = {}) { + const ileObject = this.resolvePathToObject(localPath, options.text); + const target: ILEObjectTarget = { + ...ileObject, + deps: [] + }; + const params: CommandParameters = {}; + const clDocs = new CLParser(); + const tokens = clDocs.parseDocument(content); + + ParameterRegexs.forEach((regex) => { + try { + const match = regex.exec(content); + if (match) { + console.log(`Parameter match: ${match}`); + params[match[1].toLowerCase()] = match[2].trim() ?? ''; + } + } catch (e) { } + }); + + if (params?.pgm) { + const possibleChildObject = this.searchForObject({ systemName: params.pgm, type: `PGM` }); + if (possibleChildObject) target.deps.push(this.createOrAppend(possibleChildObject)); + }; - // Since cmd source doesn't explicity contains deps, we resolve later on + if (params?.vldckr) { + const possibleChildObject = this.searchForObject({ systemName: params.vldckr, type: `PGM` }); + if (possibleChildObject) target.deps.push(this.createOrAppend(possibleChildObject)); + } else { + // Get program dependency from VLDCKR parameter in the command definition + tokens.forEach((token, index) => { + if (token.type === 'parameter' && token.value === 'VLDCKR') { + const firstBlockToken = tokens.slice(index + 1).find(token => token.type === 'block'); + if (firstBlockToken) { + const wordToken = firstBlockToken.block.find(token => token.type === 'word'); + if (wordToken && wordToken.value) { + const possibleChildObject = this.searchForObject({ systemName: wordToken.value, type: `PGM` }); + if (possibleChildObject) + target.deps.push(this.createOrAppend(possibleChildObject)); + } + } + } + }); + } + + target.overrides = params; + this.addNewTarget(target); } private createSrvPgmTarget(localPath: string, module: Module, options: FileOptions = {}) { @@ -716,10 +770,6 @@ export class Targets { } }); - // We also look to see if there is a `.cmd` object with the same name - const possibleCommandObject = this.searchForObject({ systemName: ileObject.systemName, type: `CMD` }); - if (possibleCommandObject) this.createOrAppend(possibleCommandObject, target); - if (target.deps.length > 0) infoOut(`Depends on: ${target.deps.map(d => `${d.systemName}.${d.type}`).join(` `)}`); @@ -989,7 +1039,7 @@ export class Targets { if (cache.includes && cache.includes.length > 0) { ileObject.headers = []; - + cache.includes.forEach((include: IncludeStatement) => { // RPGLE includes are always returned as posix paths // even on Windows. We need to do some magic to convert here for Windows systems @@ -1054,6 +1104,9 @@ export class Targets { deps: [] }; + // const target = this.createOrAppend(ileObject); + + // This usually means .pgm is in the name if (ileObject.type === `PGM` && cache.keyword[`NOMAIN`]) { const possibleName = pathDetail.name.toLowerCase().endsWith(`.pgm`) ? pathDetail.name.substring(0, pathDetail.name.length - 4) : pathDetail.name; @@ -1301,15 +1354,14 @@ export class Targets { }); } - // TODO: did we duplicate this? - // We also look to see if there is a `.cmd` object with the same name - const resolvedObject = this.searchForObject({ systemName: ileObject.systemName, type: `CMD` }); - if (resolvedObject) this.createOrAppend(resolvedObject, target); - if (target.deps.length > 0) infoOut(`Depends on: ${target.deps.map(d => `${d.systemName}.${d.type}`).join(` `)}`); - this.addNewTarget(target); + // For each target dep call createOrAppend + const currentTarget = this.createOrAppend(target); + + // Merge dependencies into the current target + this.mergeDependencies(currentTarget, target.deps); } getTarget(object: ILEObject): ILEObjectTarget | undefined { @@ -1450,15 +1502,20 @@ export class Targets { ...cmdObject, deps: [programObject] } - this.addNewTarget(newTarget); } else { - - this.removeObject(cmdObject); - this.logger.fileLog(cmdObject.relativePath, { - message: `Removed as target because no program was found with a matching name.`, - type: `info` - }); + const commandObject = this.getTarget(cmdObject); + // Check if command object has no deps defined or deps count is 0 + if (commandObject?.overrides?.pgm) + continue; + else { + // If no program is found, we remove the command object + this.removeObject(cmdObject); + this.logger.fileLog(cmdObject.relativePath, { + message: `Removed as target because no program was found with a matching name.`, + type: `info` + }); + } } } } @@ -1515,6 +1572,26 @@ export class Targets { return existingTarget; } + public mergeDependencies(parentObject: ILEObject, deps: ILEObject[]) { + let existingTarget = this.targets[`${parentObject.systemName}.${parentObject.type}`]; + + if (!existingTarget) { + existingTarget = { + ...parentObject, + deps: [] + }; + + this.addNewTarget(existingTarget); + } + + // We need to make sure we don't add duplicates + for (const dep of deps) { + if (!existingTarget.deps.some(d => d.systemName === dep.systemName && d.type === dep.type)) { + existingTarget.deps.push(dep); + } + } + } + private addNewTarget(dep: ILEObjectTarget) { this.targets[`${dep.systemName}.${dep.type}`] = dep; } diff --git a/cli/test/fixtures/company_system/qcmdsrc/mycmd.cmd b/cli/test/fixtures/company_system/qcmdsrc/mycmd.cmd new file mode 100644 index 0000000..697de48 --- /dev/null +++ b/cli/test/fixtures/company_system/qcmdsrc/mycmd.cmd @@ -0,0 +1,6 @@ + /* %PGM MYPGM */ + /* %VLDCKR VMYCMD */ + /* %TEXT Text of my command */ + + CMD PROMPT('My command') + PARM KWD(MODE) TYPE(*CHAR) LEN(50) \ No newline at end of file diff --git a/cli/test/fixtures/company_system/qrpglesrc/vmycmd.pgm.rpgle b/cli/test/fixtures/company_system/qrpglesrc/vmycmd.pgm.rpgle new file mode 100644 index 0000000..38fc98b --- /dev/null +++ b/cli/test/fixtures/company_system/qrpglesrc/vmycmd.pgm.rpgle @@ -0,0 +1,18 @@ +**free + +ctl-opt dftactgrp(*no); + +/INCLUDE 'qrpgleref/constants.rpgleinc' + +dcl-s mytext char(50); + +Dcl-PR printf Int(10) extproc('printf'); + input Pointer value options(*string); +End-PR; + +mytext = 'Hello to all you people'; +printf(mytext); + +dsply mytext; + +return; \ No newline at end of file diff --git a/cli/test/project.test.ts b/cli/test/project.test.ts index 17ad72f..f7ec539 100644 --- a/cli/test/project.test.ts +++ b/cli/test/project.test.ts @@ -17,7 +17,7 @@ let files = getFiles(cwd, scanGlob); describe.skipIf(files.length === 0)(`company_system tests`, () => { const targets = new Targets(cwd); - + beforeAll(async () => { targets.loadObjectsFromPaths(files); const parsePromises = files.map(f => targets.parseFile(f)); @@ -28,22 +28,23 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check objects are generated`, async () => { - expect(targets.getResolvedObjects().length).toBe(14); - expect(targets.getTargets().length).toBe(15); + expect(targets.getResolvedObjects().length).toBe(16); + expect(targets.getTargets().length).toBe(17); expect(targets.getTargetsOfType(`FILE`).length).toBe(4); - expect(targets.getTargetsOfType(`PGM`).length).toBe(4); + expect(targets.getTargetsOfType(`PGM`).length).toBe(5); expect(targets.getTargetsOfType(`MODULE`).length).toBe(2); + expect(targets.getTargetsOfType(`CMD`).length).toBe(1); expect(targets.getTargetsOfType(`SRVPGM`).length).toBe(4); }); test(`Check mypgm`, async () => { - const myPgm = targets.getTarget({systemName: `MYPGM`, type: `PGM`}); + const myPgm = targets.getTarget({ systemName: `MYPGM`, type: `PGM` }); expect(myPgm.relativePath).toBe(path.join(`qrpglesrc`, `mypgm.pgm.rpgle`)); expect(myPgm.deps.length).toBe(0); }); test(`Check employees`, async () => { - const myPgm = targets.getTarget({systemName: `EMPLOYEES`, type: `PGM`}); + const myPgm = targets.getTarget({ systemName: `EMPLOYEES`, type: `PGM` }); expect(myPgm.relativePath).toBe(path.join(`qrpglesrc`, `employees.pgm.sqlrpgle`)); expect(myPgm.deps.length).toBe(2); @@ -60,7 +61,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check depts`, async () => { - const myPgm = targets.getTarget({systemName: `DEPTS`, type: `PGM`}); + const myPgm = targets.getTarget({ systemName: `DEPTS`, type: `PGM` }); expect(myPgm.relativePath).toBe(path.join(`qrpglesrc`, `depts.pgm.sqlrpgle`)); expect(myPgm.text).toBe(`This is the text for this program`); @@ -92,7 +93,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check utils`, async () => { - const myPgm = targets.getTarget({systemName: `UTILS`, type: `SRVPGM`}); + const myPgm = targets.getTarget({ systemName: `UTILS`, type: `SRVPGM` }); expect(myPgm.relativePath).toBe(path.join(`qsrvsrc`, `utils.bnd`)); expect(myPgm.deps.length).toBe(1); @@ -104,7 +105,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check getDouble`, async () => { - const theObj = targets.getTarget({systemName: `GETDOUBLE`, type: `SRVPGM`}); + const theObj = targets.getTarget({ systemName: `GETDOUBLE`, type: `SRVPGM` }); expect(theObj.relativePath).toBe(path.join(`qsqlsrc`, `getDouble.sql`)); expect(theObj.deps.length).toBe(1); @@ -121,7 +122,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check binding directory`, async () => { - const myBinder = targets.getTarget({systemName: `$(APP_BNDDIR)`, type: `BNDDIR`}); + const myBinder = targets.getTarget({ systemName: `$(APP_BNDDIR)`, type: `BNDDIR` }); expect(myBinder.relativePath).toBeUndefined(); expect(myBinder.deps.length).toBe(2); @@ -138,16 +139,22 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check employee table`, async () => { - const empTable = targets.getTarget({systemName: `EMPLOYEE`, type: `FILE`}); + const empTable = targets.getTarget({ systemName: `EMPLOYEE`, type: `FILE` }); expect(empTable.relativePath).toBe(path.join(`qddssrc`, `employee.table`)); expect(empTable.text).toBe(`Employee File`); - + + }); + + test(`Check mycmd`, async () => { + const myCmd = targets.getTarget({ systemName: `MYCMD`, type: `CMD` }); + expect(myCmd.relativePath).toBe(path.join(`qcmdsrc`, `mycmd.cmd`)); + expect(myCmd.deps.length).toBe(2); }); test(`Testing removing and adding an object`, async () => { // First, let's delete the object internally - let deptsPgm = targets.getTarget({systemName: `DEPTS`, type: `PGM`}); - let deptsFile = targets.getTarget({systemName: `DEPTS`, type: `FILE`}); + let deptsPgm = targets.getTarget({ systemName: `DEPTS`, type: `PGM` }); + let deptsFile = targets.getTarget({ systemName: `DEPTS`, type: `FILE` }); const deptsFilePath = path.join(cwd, deptsFile.relativePath); const deptsPgmPath = path.join(cwd, deptsPgm.relativePath); @@ -159,14 +166,14 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { expect(impacted.length).toBe(1); expect(impacted[0].systemName).toBe(`DEPTS`); expect(impacted[0].type).toBe(`PGM`); - + const logs = targets.logger.getLogsFor(deptsPgm.relativePath); expect(logs.length).toBe(3); expect(logs[0].message).toBe(`Include at line 14 found, to path 'qrpgleref/utils.rpgleinc'`); expect(logs[1].message).toBe(`Include at line 13 found, to path 'qrpgleref/constants.rpgleinc'`); expect(logs[2].message).toBe(`This object depended on DEPTS.FILE before it was deleted.`); - expect(targets.getTarget({systemName: `DEPTS`, type: `FILE`})).toBeUndefined(); + expect(targets.getTarget({ systemName: `DEPTS`, type: `FILE` })).toBeUndefined(); targets.resolveBinder(); @@ -174,7 +181,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { await targets.parseFile(deptsFilePath); - deptsFile = targets.getTarget({systemName: `DEPTS`, type: `FILE`}); + deptsFile = targets.getTarget({ systemName: `DEPTS`, type: `FILE` }); expect(deptsFile).toBeDefined(); // Just because we re-handle the path, doesn't mean it's picked up again in other places where it was before @@ -182,24 +189,24 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { await targets.parseFile(deptsPgmPath); // We have to fetch the dep again because the old reference is lost since we parsed again - deptsPgm = targets.getTarget({systemName: `DEPTS`, type: `PGM`}); + deptsPgm = targets.getTarget({ systemName: `DEPTS`, type: `PGM` }); expect(deptsPgm.deps.find(d => d.systemName === `DEPTS` && d.type === `FILE`)).toBeDefined(); }); test(`Double resolve binder test`, async () => { targets.resolveBinder(); - let deptsPgm = targets.getTarget({systemName: `DEPTS`, type: `PGM`}); + let deptsPgm = targets.getTarget({ systemName: `DEPTS`, type: `PGM` }); expect(deptsPgm.deps.length).toBe(4); targets.resolveBinder(); - deptsPgm = targets.getTarget({systemName: `DEPTS`, type: `PGM`}); + deptsPgm = targets.getTarget({ systemName: `DEPTS`, type: `PGM` }); expect(deptsPgm.deps.length).toBe(4); }); test(`Check mypgm RPGLE target`, async () => { - const myPgm = targets.getTarget({systemName: `MYPGM`, type: `PGM`}); + const myPgm = targets.getTarget({ systemName: `MYPGM`, type: `PGM` }); const lines = MakeProject.generateSpecificTarget(compileDefaults[`pgm.rpgle`], myPgm); expect(lines.join()).toBe([ @@ -214,7 +221,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check depts SQLRPGLE target (with CHGATR)`, async () => { - const myPgm = targets.getTarget({systemName: `DEPTS`, type: `PGM`}); + const myPgm = targets.getTarget({ systemName: `DEPTS`, type: `PGM` }); const lines = MakeProject.generateSpecificTarget(compileDefaults[`pgm.sqlrpgle`], myPgm); expect(lines.join()).toBe([ @@ -228,8 +235,22 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { ].join()); }); + test(`Check depts CMD target (with overrides)`, async () => { + const myCmd = targets.getTarget({ systemName: `MYCMD`, type: `CMD` }); + const lines = MakeProject.generateSpecificTarget(compileDefaults[`cmd`], myCmd); + + expect(lines.join()).toBe([ + '$(PREPATH)/MYCMD.CMD: qcmdsrc/mycmd.cmd', + '\t-system -qi \"CRTSRCPF FILE($(BIN_LIB)/qcmdsrc) RCDLEN(112) CCSID(*JOB)"', + `\tsystem \"CPYFRMSTMF FROMSTMF('qcmdsrc/mycmd.cmd') TOMBR('$(PREPATH)/qcmdsrc.FILE/MYCMD.MBR') MBROPT(*REPLACE)"`, + '\tliblist -c $(BIN_LIB);\\', + '\tliblist -a $(LIBL);\\', + `\tsystem \"CRTCMD CMD($(BIN_LIB)/MYCMD) PGM($(BIN_LIB)/MYPGM) SRCFILE($(BIN_LIB)/qcmdsrc) OPTION(*EVENTF) VLDCKR(VMYCMD)\" > .logs/mycmd.splf || \\\n\t(system \"CPYTOSTMF FROMMBR('$(PREPATH)/EVFEVENT.FILE/MYCMD.MBR') TOSTMF('.evfevent/mycmd.evfevent') DBFCCSID(*FILE) STMFCCSID(1208) STMFOPT(*REPLACE)\"; $(SHELL) -c 'exit 1')`, + ].join()); + }); + test(`Check depts DSPF target (member)`, async () => { - const myPgm = targets.getTarget({systemName: `DEPTS`, type: `FILE`}); + const myPgm = targets.getTarget({ systemName: `DEPTS`, type: `FILE` }); const lines = MakeProject.generateSpecificTarget(compileDefaults[`dspf`], myPgm); expect(lines.join()).toBe([ @@ -246,7 +267,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check utils SRVPGM target (from binder source, *MODULES variable)`, async () => { - const myPgm = targets.getTarget({systemName: `UTILS`, type: `SRVPGM`}); + const myPgm = targets.getTarget({ systemName: `UTILS`, type: `SRVPGM` }); const lines = MakeProject.generateSpecificTarget(compileDefaults[`bnd`], myPgm); expect(lines.join()).toBe([ @@ -260,7 +281,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Check banking SRVPGM target (no binder source)`, async () => { - const myPgm = targets.getTarget({systemName: `BANKING`, type: `SRVPGM`}); + const myPgm = targets.getTarget({ systemName: `BANKING`, type: `SRVPGM` }); const lines = MakeProject.generateSpecificTarget(compileDefaults[`srvpgm`], myPgm); expect(lines.join()).toBe([ @@ -306,7 +327,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { test(`Makefile targets for partial build (DEPTS display file)`, () => { const project = new MakeProject(cwd, targets); - const deptsFile = targets.getTarget({systemName: `DEPTS`, type: `FILE`}); + const deptsFile = targets.getTarget({ systemName: `DEPTS`, type: `FILE` }); // Generate targets on it's own will have BNDDIR, PGM, etc const headerContent = project.generateTargets([deptsFile]); @@ -320,7 +341,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { test(`Makefile targets for partial build (EMPLOYEE table)`, () => { const project = new MakeProject(cwd, targets); - const deptsFile = targets.getTarget({systemName: `EMPLOYEE`, type: `FILE`}); + const deptsFile = targets.getTarget({ systemName: `EMPLOYEE`, type: `FILE` }); // Generate targets on it's own will have BNDDIR, PGM, etc const headerContent = project.generateTargets([deptsFile]); @@ -338,7 +359,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { expect(allTargets).toContain(`$(PREPATH)/DEPTS.PGM`); expect(allTargets).toContain(`$(PREPATH)/SHOWEMPS.PGM`); expect(allTargets).toContain(`$(PREPATH)/GETTOTSAL.SRVPGM`); - + const deptsTargetDeps = headerContent.find(l => l.startsWith(`$(PREPATH)/DEPTS.PGM:`)); expect(deptsTargetDeps).toBeDefined(); @@ -349,7 +370,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { const project = new MakeProject(cwd, targets); project.setNoChildrenInBuild(true); - const deptsFile = targets.getTarget({systemName: `EMPLOYEE`, type: `FILE`}); + const deptsFile = targets.getTarget({ systemName: `EMPLOYEE`, type: `FILE` }); // Generate targets on it's own will have BNDDIR, PGM, etc const headerContent = project.generateTargets([deptsFile]); @@ -367,13 +388,13 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { expect(allTargets).toContain(`$(PREPATH)/DEPTS.PGM`); expect(allTargets).toContain(`$(PREPATH)/SHOWEMPS.PGM`); expect(allTargets).toContain(`$(PREPATH)/GETTOTSAL.SRVPGM`); - + const deptsTargetDeps = headerContent.find(l => l.startsWith(`$(PREPATH)/DEPTS.PGM:`)); expect(deptsTargetDeps).toBeUndefined(); }); test(`Impact of EMPLOYEES`, () => { - const empPgm = targets.getTarget({systemName: `EMPLOYEES`, type: `PGM`}); + const empPgm = targets.getTarget({ systemName: `EMPLOYEES`, type: `PGM` }); expect(empPgm.relativePath).toBe(path.join(`qrpglesrc`, `employees.pgm.sqlrpgle`)); const impactTree = targets.getImpactFor(empPgm); @@ -388,7 +409,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { }); test(`Impact of UTILS`, () => { - const utilsModule = targets.getTarget({systemName: `UTILS`, type: `MODULE`}); + const utilsModule = targets.getTarget({ systemName: `UTILS`, type: `MODULE` }); expect(utilsModule.relativePath).toBe(path.join(`qrpglesrc`, `utils.sqlrpgle`)); const impactTree = targets.getImpactFor(utilsModule); @@ -425,7 +446,7 @@ describe.skipIf(files.length === 0)(`company_system tests`, () => { // We have a test for this as SQL objects are created a little different // from regular objects. - const resolvedObject = targets.getTarget({systemName: `GETTOTSAL`, type: `SRVPGM`}); + const resolvedObject = targets.getTarget({ systemName: `GETTOTSAL`, type: `SRVPGM` }); expect(resolvedObject.relativePath).toBe(path.join(`qsqlsrc`, `getTotalSalary.sqludf`)); expect(resolvedObject).toBeDefined();