Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Callback must be a function. Received undefined." when trying to build #10

Open
ArmedVeteran opened this issue May 7, 2020 · 7 comments

Comments

@ArmedVeteran
Copy link

ArmedVeteran commented May 7, 2020

Hey! I just found your addon and it looks promising, but I have stumbled upon this issue. First when I run Configure on my existing project I got this:

[02:28:28.622][Error] TypeError: Cannot read property 'postProcess' of undefined [02:31:39.666][Error] Invalid steam path: E:\SteamGames\

I have corrected the Steam path, as your addon detected my Steam Games repository on another hard drive (I use D: for most games and that's where Steam is installed and E: for Arma). Anyway, I've filled the json properties and run Arma 3: Build, but then I got this error:

[Error] TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined

and I'm unable to solve this issue by myself :/

@ole1986
Copy link
Owner

ole1986 commented May 7, 2020

Did you already configured your project using Arma 3: Configure. If so, can you please post your configuration file?

@ArmedVeteran
Copy link
Author

ArmedVeteran commented May 7, 2020

Sure thing, here it is (and yes, I've run Arma 3: Configure):
image

And here's how it looks like on my P: drive:
image

(ignore HEMTT stuff, as I've tried to use that build system after yours)

@ole1986
Copy link
Owner

ole1986 commented May 7, 2020

Hm you might need to setup the ´serverDirsandclientDirs`properly.
Check out the configuration where i already use ArmaDev

See here: https://github.com/ole1986/a3-admintoolkit/blob/master/.vscode/arma-dev.json

and if necessary download and try to build it

@mrzachhigginsofficial
Copy link
Contributor

Hi there, I'm having the same issue. Are you still supporting this extension?

This is my arma-dev.json.

{
	"title": "Project Abaddon",
	"name": "Project Abaddon",
	"author": "BigZancho",
	"version": "0.0.1",
	"buildPath": "./",
	"privateKey": "project abaddon.biprivatekey",
	"serverDirs": [
		"src\\abaddon_server_core"
	],
	"serverUse32bit": false,
	"clientDirs": [
		"src\\abaddon_client_core"
	],
	"clientMods": [],
	"ftpConnection": {}
}

This is a fresh project. Opened the P: drive and ran >Arma 3: Configure

image

@mrzachhigginsofficial
Copy link
Contributor

Quick addition - I removed the space in my signing keys, no changed. Silly oversight, but I dont think I'm stuck there.

I checked the source real quick...

In armaTools.js it looks like we're only checking for $PBOPREFIX$. The tutorial says you can use just $PREFIX$. Once I changed that, everything worked as expected.

function getPrefixFromFile(relPath) {
    let prefixFile = path.join(workingDir, relPath, '$PBOPREFIX$');
    if (!fs.existsSync(prefixFile)) {
        return '';
    }
    return fs.readFileSync(prefixFile, 'UTF-8');
}

Below is the output I get after making the change:

[00:19:16.865][Debug] Packing src\abaddon_server_core using FileBank (prefix: Project_Abaddon_Server)
[00:19:16.869][Debug] Packing src\abaddon_client_core using AddonBuilder
[00:19:16.874][Error] TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined

Will send another update once I have progressed to level 3.

@mrzachhigginsofficial
Copy link
Contributor

mrzachhigginsofficial commented Jul 19, 2020

Think I'm going to call it for tonight and will tackle this in the morning. I'm able to generate a PBO using the Arma tools Addon Builder. I bring this up because it looks like I'm stuck at this code based on the console output
[00:43:34.980][Debug] Packing src\abaddon_client_core using AddonBuilder
[00:43:34.985][Error] TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
:

            child_process_1.spawn(addonBuilderPath, args, { cwd: workingDir }).on('error', (err) => reject(err.message)).on('close', (code) => {
                resolve(code === 0);
            });

Here's the PBO Addon Builder Config (saying that I think there is some sort of dependency that I'm missing that's undocumented):

image

Final config for the night looks like this:

{
	"title": "ProjectAbaddon",
	"name": "ProjectAbaddon",
	"author": "BigZancho",
	"version": "0.0.1",
	"buildPath": "./build",
	"privateKey": "project_abaddon.biprivatekey",
	"serverDirs": [
		"src\\abaddon_server_core"
	],
	"clientDirs": [
		"src\\abaddon_client_core"
	],
	"serverUse32bit": false,
	"clientMods": [],
	"ftpConnection": {}
}

image

@mrzachhigginsofficial
Copy link
Contributor

mrzachhigginsofficial commented Jul 19, 2020

My last issue appears to be due to the -packonly argument, so I think you can safely ignore that issue since I reproduced the issue outside of this extension.

I do think it would be worth considering adding some additional console output to these methods (I know it can be sloppy, but it helped me troubleshoot the issue).

Example of the packWithAddonBuilder function:

function packWithAddonBuilder(folderDir, binarize, sign) {
    return __awaiter(this, void 0, void 0, function* () {
        let config = armadev_1.ArmaDev.Self.Config;
        let addonBuilderPath = path.join(steamPath, Arma3Tools, 'AddonBuilder', 'AddonBuilder.exe');
        let privateKey = config.privateKey.toLowerCase();
        let fullFolderPath = path.join(workingDir, folderDir);
        let fullBuildPath = path.join(workingDir, config.buildPath, armadev_1.ArmaDev.Self.ModClientName, 'addons');
        let fullPrivateKeyPath = path.join(workingDir, privateKey);
		logger.logDebug('Working Dir: ' + workingDir);
		logger.logDebug('Config Build Path:' + config.buildPath);
		logger.logDebug('Mod Name: ' + armadev_1.ArmaDev.Self.ModClientName);
        return new Promise((resolve, reject) => {
            if (!fs.existsSync(addonBuilderPath)) {
                reject('AddonBuilder not found');
                return;
            }
            let prefixValue = getPrefixFromFile(folderDir);
            if (prefixValue === '') {
                reject('No $PBOPREFIX$ file found');
                return;
            }
            let args = [];
            args.push(fullFolderPath, fullBuildPath);
            args.push('-clear');
            args.push('-packonly');
            args.push('-prefix=' + prefixValue);
            if (sign && privateKey && fs.existsSync(fullPrivateKeyPath)) {
                args.push('-sign=' + fullPrivateKeyPath);
            }
            else {
                vscode.window.showWarningMessage('No private key found.\nCheck the privateKey path in arma-dev.json or use "Arma 3: Generate Key"');
            }
            logger.logDebug('Packing ' + folderDir + ' using AddonBuilder');
			logger.logDebug('Starting Addon Builder...');
			logger.logDebug('addonBuilderPath: ' + addonBuilderPath);
			logger.logDebug('args: ' + args);
			logger.logDebug('workingDir: ' + workingDir);
            child_process_1.spawn(addonBuilderPath, args, { cwd: workingDir }).on('error', (err) => reject(err.message)).on('close', (code) => {
                resolve(code === 0);
            });
			logger.logDebug('Addon packed successfully.');
        });
    });
}

Primarily the last bit that outputs the parameters used to spawn the child process so it can be tested locally.

Anyway, seems like a cool addon, will do my best to break it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants