SAP/ui5-tooling

ui5/cli 3.* - existing script is not working

rabi84 opened this issue · 6 comments

Expected Behavior:

The below code should work.
const ui5cli = require.resolve('@ui5/cli/bin/ui5.js');
await executeScript(ui5cli, ['build', '--include-task=generateManifestBundle', 'generateCachebusterInfo']);

Current Behavior

this is not working using ui5/cli 3.* version
const ui5cli = require.resolve('@ui5/cli/bin/ui5.cjs');
await executeScript(ui5cli, ['build', '--include-task=generateManifestBundle', 'generateCachebusterInfo']);

but this is working using ui5/cli 3.* version
const ui5cli = require.resolve('@ui5/cli/bin/ui5.cjs');
await shellExecute('node ' + ui5cli, ['build', '--include-task=generateManifestBundle', 'generateCachebusterInfo']);

Steps to Reproduce the Issue

execute below command using gulp and it is not completing, it is getting hung up in cleanupjobs
await executeScript(ui5cli, ['build', '--include-task=generateManifestBundle', 'generateCachebusterInfo']);

Context

  • UI5 Module Version 1.120
  • Node.js Version: 18.17.1
  • npm Version: 9.6.7
  • OS/Platform: mac
  • Browser (if relevant): chrome
  • Other information regarding your environment (optional): nothing
image

With version 3 of @ui5/cli, bin/ui5.js got renamed to bin/ui5.cjs.

From your description, it's unclear to me what the functions executeScript and shellExecute are doing. Would it be possible to provide a reproducible example?

You might also want to consider switching to the Node.js API instead of invoking the CLI: https://sap.github.io/ui5-tooling/stable/#nodejs-api

Also, please provide the exact version of the @ui5/cli package you are using.

yes you are right with 3.* version it should be bin/ui5.cjs, I updated it as well.
We are using 3.9.1 version of Ui5/cli
my bad I did not add the functions, here are they

async function executeScript(script, args, cwd) {
if (typeof args === 'string') {
cwd = args;
args = undefined;
}
await run('fork', script, args, {cwd});
},

async function shellExecute(command, args, cwd) {
if (typeof args === 'string') {
cwd = args;
args = undefined;
}
await run('spawn', command, args, {cwd, shell: true});
}

Thank you for sharing some more code. However, it's still not enough for us to reproduce the behavior you are reporting.

Would it be possible for you to share a working script that shows the issue?

Hi ,
I am not allowed to share the project code, but let me give the details how it is working
inside run method, we are doing as below
function run(type, command, args, options) {

if (type === 'fork') {
commandLine = 'node ' + commandLine;
}
//we are preparing command line, argv, program and options in our private functions and then calling child process in promise
return new Promise(function (resolve, reject) {
const baseOptions = {
env: Object.assign({}, process.env),
stdio: 'inherit'
};
let child = childProcess[type](program, argv, Object.assign(baseOptions, options));
child.on('error', reject);
child.on('exit', function (code, signal) {
if (signal) {
reject(new Error(${commandLine} exited on ${signal}));
}
else if (code) {
reject(new Error(${commandLine} failed with status ${code}));
}
else {
resolve();
}
});
});
}

If you are an SAP customer, please feel free to raise an incident for us at https://support.sap.com/ if that allows you to share your project with us.

I'm afraid we need an example project containing your custom script in order to reliably reproduce and analyze this issue.

This issue has been automatically marked as stale because it has been open for 60 days with no activity. It will be closed in 10 days if no further activity occurs.