Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Define repo on add/remove commands + guarding #57

Merged
merged 11 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions codewind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ commands:
- init
- $subtype
- none
- name: onRepositoryAdd
command: appsody
args:
- repo
- add
- $id
- $url,.yaml
- name: onRepositoryRemove
command: appsody
args:
- repo
- remove
- $id
detection: .appsody-config.yaml
config:
containerAppRoot: /project/user-app
needsMount: true
style: Appsody
78 changes: 45 additions & 33 deletions templatesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,33 @@ module.exports = {
getRepositories: async function() {

const repos = [];

const result = await exec(`${__dirname}/appsody repo list -o json`);
const json = JSON.parse(result.stdout);

try {
const result = await exec(`${__dirname}/appsody repo list -o json`);
const json = JSON.parse(result.stdout);

for (const repo of json.repositories) {
for (const repo of json.repositories) {

const name = repo.name;
let url = repo.url;
const name = repo.name;
let url = repo.url;

if (name != 'experimental' && url.endsWith('index.yaml')) {
if (name != 'experimental' && url.endsWith('index.yaml')) {

url = url.substring(0, url.length - 10) + 'index.json';
url = url.substring(0, url.length - 10) + 'index.json';

repos.push({
id: name,
name: `Appsody Stacks - ${name}`,
description: 'Use Appsody in Codewind to develop applications with sharable technology stacks.',
url
});
repos.push({
id: name,
name: `Appsody Stacks - ${name}`,
description: 'Use Appsody in Codewind to develop applications with sharable technology stacks.',
url
});
}
}
}
catch (err) {
console.error('Appsody extension: failed to retrieve repositories');
console.error(err.message);
}

return repos;
},
Expand All @@ -72,27 +78,33 @@ module.exports = {

const projectTypes = [];

const result = await exec(`${__dirname}/appsody list ${id} -o json`);
const json = JSON.parse(result.stdout);

for (const repo of json.repositories) {

for (const stack of repo.stacks) {

projectTypes.push({
projectType: 'appsodyExtension',
projectSubtypes: {
label: 'Appsody stack',
items: [{
id: `${repo.repositoryName}/${stack.id}`,
version: stack.version,
label: `Appsody ${stack.id}`,
description: stack.description
}]
}
});
try {
const result = await exec(`${__dirname}/appsody list ${id} -o json`);
const json = JSON.parse(result.stdout);

for (const repo of json.repositories) {

for (const stack of repo.stacks) {

projectTypes.push({
projectType: 'appsodyExtension',
projectSubtypes: {
label: 'Appsody stack',
items: [{
id: `${repo.repositoryName}/${stack.id}`,
version: stack.version,
label: `Appsody ${stack.id}`,
description: stack.description
}]
}
});
}
}
}
catch (err) {
console.error('Appsody extension: failed to retrieve project types');
console.error(err.message);
}

return projectTypes;
}
Expand Down