Skip to content

Commit

Permalink
Check plugman-cli in cordova requirements command (#1023)
Browse files Browse the repository at this point in the history
* Update cordova hostname customization support

* Update requestArgs.ts

* Update jsDebugConfigAdapter.ts

* Gulp format

* Revert gulp format

* Update pathMapping hostname value

* Validation argument correction

* Check plugman via cordovaRequirements.ts

* Add plugman environment verification to cordova requirements

* Update cordovaRequirements.ts

---------

Co-authored-by: Rodolfo Liberado (BEYONDSOFT CONSULTING INC) <[email protected]>
Co-authored-by: Ezio Li <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent 12c5300 commit ae3f4e2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 9 deletions.
27 changes: 26 additions & 1 deletion src/utils/cordovaAndroidEnvironmentHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import { window } from "vscode";
export class CordovaAndroidEnvironmentHelper {
public static checkEnvironment(cwd: string, env: any, logger: any): Promise<void> {
logger.log("Requirements check results for android:");
return Promise.all([checkJava(cwd, env), checkAndroidSDK(cwd, env), checkGradle(cwd, env)])
return Promise.all([
checkJava(cwd, env),
checkAndroidSDK(cwd, env),
checkGradle(cwd, env),
checkPlugman(cwd, env),
])
.then(() => {
logger.log("Environment checks completed.");
})
Expand Down Expand Up @@ -71,5 +76,25 @@ export class CordovaAndroidEnvironmentHelper {
});
});
}

function checkPlugman(cwd: string, env: any): Promise<void> {
return new Promise((resolve, reject) => {
child_process.exec(
"npm list -g plugman --depth=0",
{
cwd,
env,
},
(error, stdout, stderr) => {
if (error) {
logger.log(`Plugman not found: ${stderr}`);
return reject(error);
}
logger.log(`Plugman: ${stdout.match(/plugman@(\d+\.\d+\.\d+)/)[1]}`);
resolve();
},
);
});
}
}
}
40 changes: 32 additions & 8 deletions src/utils/cordovaCommandHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,38 @@ export class CordovaCommandHelper {
});

process.stdout.on("close", () => {
logger.log(
localize(
"FinishedExecuting",
"########### FINISHED EXECUTING: {0} ###########",
commandToExecute,
),
);
resolve({});
// Workaround for dealing with plugman environment verification
if (command === "requirements") {
process = child_process.exec("npm list -g plugman --depth=0", {
cwd: projectRoot,
env,
});

process.stdout.on("data", (e: string) => {
const match = e.match(/\d+\.\d+\.\d+/);
logger.log(`Plugman: ${match[0]}`);
});

process.stdout.on("close", () => {
logger.log(
localize(
"FinishedExecuting",
"########### FINISHED EXECUTING: {0} ###########",
commandToExecute,
),
);
resolve({});
});
} else {
logger.log(
localize(
"FinishedExecuting",
"########### FINISHED EXECUTING: {0} ###########",
commandToExecute,
),
);
resolve({});
}
});
}
});
Expand Down

0 comments on commit ae3f4e2

Please sign in to comment.