aboutsummaryrefslogtreecommitdiff
path: root/.github/devcontainers-action/dist/index.js
diff options
context:
space:
mode:
Diffstat (limited to '.github/devcontainers-action/dist/index.js')
-rw-r--r--.github/devcontainers-action/dist/index.js34
1 files changed, 24 insertions, 10 deletions
diff --git a/.github/devcontainers-action/dist/index.js b/.github/devcontainers-action/dist/index.js
index 1162cbb..a120d4d 100644
--- a/.github/devcontainers-action/dist/index.js
+++ b/.github/devcontainers-action/dist/index.js
@@ -197,14 +197,17 @@ function run() {
const shouldPublishFeatures = core.getInput('publish-features').toLowerCase() === 'true';
const shouldPublishTemplate = core.getInput('publish-templates').toLowerCase() === 'true';
const shouldGenerateDocumentation = core.getInput('generate-docs').toLowerCase() === 'true';
+ let featuresMetadata = undefined;
+ let templatesMetadata = undefined;
if (shouldPublishFeatures) {
core.info('Publishing features...');
const featuresBasePath = core.getInput('base-path-to-features');
- yield packageFeatures(featuresBasePath);
+ featuresMetadata = yield packageFeatures(featuresBasePath);
}
if (shouldPublishTemplate) {
core.info('Publishing template...');
const basePathToDefinitions = core.getInput('base-path-to-templates');
+ templatesMetadata = undefined; // TODO
yield packageTemplates(basePathToDefinitions);
}
if (shouldGenerateDocumentation) {
@@ -220,20 +223,23 @@ function run() {
}
// TODO: Programatically add feature/template fino with relevant metadata for UX clients.
core.info('Generation metadata file: devcontainer-collection.json');
- yield (0, utils_1.addCollectionsMetadataFile)();
+ yield (0, utils_1.addCollectionsMetadataFile)(featuresMetadata, templatesMetadata);
});
}
function packageFeatures(basePath) {
return __awaiter(this, void 0, void 0, function* () {
try {
core.info(`Archiving all features in ${basePath}`);
- yield (0, utils_1.getFeaturesAndPackage)(basePath);
+ const metadata = yield (0, utils_1.getFeaturesAndPackage)(basePath);
core.info('Packaging features has finished.');
+ return metadata;
}
catch (error) {
- if (error instanceof Error)
+ if (error instanceof Error) {
core.setFailed(error.message);
+ }
}
+ return;
});
}
function packageTemplates(basePath) {
@@ -323,7 +329,7 @@ function tarDirectory(path, tgzName) {
});
}
exports.tarDirectory = tarDirectory;
-function addCollectionsMetadataFile() {
+function addCollectionsMetadataFile(featuresMetadata, templatesMetadata) {
return __awaiter(this, void 0, void 0, function* () {
const p = path_1.default.join('.', 'devcontainer-collection.json');
// Insert github repo metadata
@@ -342,8 +348,8 @@ function addCollectionsMetadataFile() {
}
const metadata = {
sourceInformation,
- features: [],
- templates: []
+ features: featuresMetadata || [],
+ templates: templatesMetadata || []
};
// Write to the file
yield (0, exports.writeLocalFile)(p, JSON.stringify(metadata, undefined, 4));
@@ -352,7 +358,7 @@ function addCollectionsMetadataFile() {
exports.addCollectionsMetadataFile = addCollectionsMetadataFile;
function getFeaturesAndPackage(basePath) {
return __awaiter(this, void 0, void 0, function* () {
- let archives = [];
+ let metadatas = [];
fs.readdir(basePath, (err, files) => {
if (err) {
core.error(err.message);
@@ -362,13 +368,21 @@ function getFeaturesAndPackage(basePath) {
files.forEach(file => {
core.info(`feature ==> ${file}`);
if (file !== '.' && file !== '..') {
+ const featureFolder = path_1.default.join(basePath, file);
const archiveName = `${file}.tgz`;
tarDirectory(`${basePath}/${file}`, archiveName);
- archives.push(archiveName);
+ const featureJsonPath = path_1.default.join(featureFolder, "devcontainer-feature.json");
+ if (!fs.existsSync(featureJsonPath)) {
+ core.error(`Feature ${file} is missing a devcontainer-feature.json`);
+ core.setFailed('All features must have a devcontainer-feature.json');
+ return;
+ }
+ const featureMetadata = JSON.parse(fs.readFileSync(featureJsonPath, "utf8"));
+ metadatas.push(featureMetadata);
}
});
});
- return archives;
+ return metadatas;
});
}
exports.getFeaturesAndPackage = getFeaturesAndPackage;