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

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

Open
rabi84 opened this issue Mar 22, 2024 · 5 comments
Open

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

rabi84 opened this issue Mar 22, 2024 · 5 comments
Labels
bug Something isn't working information required Further information is required

Comments

@rabi84
Copy link

rabi84 commented Mar 22, 2024

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
@rabi84 rabi84 added bug Something isn't working needs triage Needs to be investigated and confirmed as a valid issue that is not a duplicate labels Mar 22, 2024
@RandomByte
Copy link
Member

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.

@RandomByte RandomByte added the information required Further information is required label Mar 22, 2024
@flovogt flovogt removed the needs triage Needs to be investigated and confirmed as a valid issue that is not a duplicate label Mar 22, 2024
@rabi84
Copy link
Author

rabi84 commented Mar 23, 2024

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});
}

@RandomByte
Copy link
Member

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?

@rabi84
Copy link
Author

rabi84 commented Mar 26, 2024

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();
}
});
});
}

@RandomByte
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working information required Further information is required
Projects
None yet
Development

No branches or pull requests

3 participants