in src/commands/createAction.ts [23:71]
export async function createAction(entity: WskPackage | WskNamespace) {
const actionName = await vscode.window.showInputBox({
ignoreFocusOut: true,
prompt: 'Create new action',
placeHolder: 'Enter action name here',
});
if (!actionName) {
return;
}
// prepend package name
let name = actionName;
if (entity instanceof WskPackage) {
name = `${entity.packageDesc.name}/${actionName}`;
}
// show runtime kind list
const items: vscode.QuickPickItem[] = [];
runtimes.forEach((r) => {
r.versions.forEach((version) => {
items.push({
label: `${r.kind}:${version}`,
});
});
});
const kind = await vscode.window.showQuickPick(items, {
canPickMany: false,
placeHolder: 'Select runtime',
});
if (kind) {
const kindWithoutVersion = kind.label.split(':')[0];
const codePath = sampleCodePath[kindWithoutVersion];
const content = fs.readFileSync(codePath, { encoding: 'utf8' });
try {
await entity.client.actions.create({
name: name,
action: content,
// @ts-ignore
kind: kind.label,
});
} catch (e) {
if (e.error && e.error.error) {
vscode.window.showErrorMessage(e.error.error);
}
}
}
}