Skip to content

Commit 2cde8fb

Browse files
committed
Correct pass along actions commands
Signed-off-by: worksofliam <[email protected]>
1 parent 8cd1ec8 commit 2cde8fb

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

cli/src/builders/actions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class ProjectActions {
6161
const actionFile = path.join(parent, `actions.json`);
6262

6363
if (this.actions[actionFile]) {
64-
allPossibleActions = allPossibleActions.concat(this.actions[actionFile]);
64+
allPossibleActions.push(...this.actions[actionFile]);
6565
}
6666

6767
if (parent === `.`) {

cli/src/builders/iProject.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { fromCl } from "../utils";
2-
import { CompileData, CommandParameters, CompileAttribute, getDefaultCompiles, Action, getObjectType } from "./environment";
1+
import { CommandParameters, CompileAttribute, getDefaultCompiles } from "./environment";
32

43
export class iProject {
54
includePaths?: string[] = [];

cli/src/builders/make/index.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ import { ProjectActions } from '../actions';
1414
export class MakeProject {
1515
private noChildren: boolean = false;
1616
private settings: iProject = new iProject();
17-
private actions: ProjectActions;
17+
private projectActions: ProjectActions;
1818

1919
private folderSettings: {[folder: string]: FolderOptions} = {};
2020

2121
constructor(private cwd: string, private targets: Targets, private rfs: ReadFileSystem) {
22-
this.actions = new ProjectActions(this.targets, this.rfs);
22+
this.projectActions = new ProjectActions(this.targets, this.rfs);
2323
}
2424

2525
public setNoChildrenInBuild(noChildren: boolean) {
2626
this.noChildren = noChildren;
2727
}
2828

2929
async setupSettings() {
30+
await this.projectActions.loadAllActions();
31+
3032
// First, let's setup the project settings
3133
try {
3234
const content = await this.rfs.readFile(path.join(this.cwd, `iproj.json`));
@@ -41,8 +43,6 @@ export class MakeProject {
4143
this.folderSettings = getFolderOptions(this.cwd);
4244

4345
readAllRules(this.targets, this);
44-
45-
await this.actions.loadAllActions();
4646
}
4747

4848
public getSettings() {
@@ -222,7 +222,7 @@ export class MakeProject {
222222
let customAttributes = this.getObjectAttributes(data, possibleTarget);
223223

224224
if (ileObject.relativePath) {
225-
const possibleAction = this.actions.getActionForPath(ileObject.relativePath);
225+
const possibleAction = this.projectActions.getActionForPath(ileObject.relativePath);
226226
if (possibleAction) {
227227
const clData = fromCl(possibleAction.command);
228228
// If there is an action for this object, we want to apply the action's parameters
@@ -231,9 +231,7 @@ export class MakeProject {
231231
data = {
232232
...data,
233233
command: clData.command,
234-
parameters: {
235-
...data.parameters,
236-
}
234+
parameters: clData.parameters
237235
}
238236
}
239237
}

cli/test/cs_srvpgm.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe(`pseudo tests`, () => {
7878

7979
test('makefile', async () => {
8080
const makefile = new MakeProject(targets.getCwd(), targets, fs);
81-
await make.setupSettings();
81+
await makefile.setupSettings();
8282

8383
const contents = makefile.getMakefile().join(`\n`);
8484

@@ -87,6 +87,9 @@ describe(`pseudo tests`, () => {
8787

8888
expect(contents).not.toContain(`EMPDET.SRVPGM`); // Ensure no service program is created
8989
expect(contents).toContain(`EMPDET.MODULE`);
90+
91+
// As picked up from the actions.json
92+
expect(contents).toContain(`system "CRTBNDRPG THEPARM('''cooldude''')" > .logs/mypgm.splf`);
9093
});
9194

9295
test('there are actions', async () => {
@@ -106,14 +109,14 @@ describe(`pseudo tests`, () => {
106109
const actionB = actions.getActionForPath(ddsSrcB);
107110

108111
expect(actionA).toBeDefined();
109-
expect(actionA?.command).toBe(`RUNSQLSTM`);
112+
expect(actionA?.command).toBe(`RUNSQLSTM SRCSTMF('&RELATIVEPATH')`);
110113

111114
expect(actionB).toBeDefined();
112-
expect(actionB?.command).toBe(`RUNSQL`);
115+
expect(actionB?.command).toBe(`RUNSQL SRCSTMF('&RELATIVEPATH')`);
113116

114117
const rpgleSrc = path.join(`qrpglesrc`, `mypgm.pgm.rpgle`);
115118
const actionC = actions.getActionForPath(rpgleSrc);
116119
expect(actionC).toBeDefined();
117-
expect(actionC?.command).toBe(`CRTBNDRPG`);
120+
expect(actionC?.command).toBe(`CRTBNDRPG THEPARM('cooldude')`);
118121
});
119122
});

cli/test/fixtures/cs_srvpgm/.vscode/actions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"extensions": [
66
"rpgle"
77
],
8-
"command": "CRTBNDRPG"
8+
"command": "CRTBNDRPG THEPARM('cooldude')"
99
},
1010
{
1111
"name": "Global run SQL",
1212
"environment": "ile",
1313
"extensions": [
1414
"sql"
1515
],
16-
"command": "RUNSQL"
16+
"command": "RUNSQL SRCSTMF('&RELATIVEPATH')"
1717
}
1818
]

cli/test/fixtures/cs_srvpgm/qddssrc/actions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"extensions": [
66
"sql", "table"
77
],
8-
"command": "RUNSQLSTM"
8+
"command": "RUNSQLSTM SRCSTMF('&RELATIVEPATH')"
99
}
1010
]

0 commit comments

Comments
 (0)