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

Fixes devcontainer-feature.json with comment #214

Merged
merged 1 commit into from
Feb 16, 2024
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
10 changes: 8 additions & 2 deletions __tests__/examples/simple/src/hello/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// comment out of the object
{
// single line comment
"name": "Hello, World!",
"id": "hello",
"version": "1.0.2",
/*
multi line comment
你好世界
*/
"id": "hello", // comment at end
"version": /* inline comment */ "1.0.2",
"description": "A hello world feature",
"options": {
"greeting": {
Expand Down
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build": "ncc build ./src/main.ts",
"test": "jest",
"fetch-schemas": "wget https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json -O src/schemas/devContainerFeature.schema.json"

},
"repository": {
"type": "git",
Expand All @@ -31,21 +30,15 @@
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"ajv": "^8.11.2",
"jsonc-parser": "^3.2.0"
"json5": "^2.2.3"
},
"devDependencies": {
"@types/ajv": "^1.0.0",
"@types/node": "^18.11.18",
"@vercel/ncc": "^0.34.0",
"copyfiles": "^2.4.1",
"eslint": "^8.32.0",
"glob": "^8.0.3",
"handlebars": "^4.7.7",
"jest": "^28.1.3",
"js-yaml": "^4.1.0",
"jsonc": "^2.0.0",
"prettier": "2.8.3",
"rimraf": "^3.0.2",
"ts-jest": "^28.0.8",
"typescript": "^4.9.4"
}
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface GitHubMetadata {

export interface PublishResult {
publishedTags: string[];
digest: string;
version: string;
digest: string;
version: string;
}
export interface DevContainerCollectionMetadata {
sourceInformation: GitHubMetadata;
Expand Down
4 changes: 3 additions & 1 deletion src/generateDocs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from 'fs';
import * as core from '@actions/core';
import * as path from 'path';
import JSON from 'json5';
import { getGitHubMetadata } from './utils';

const FEATURES_README_TEMPLATE = `
Expand Down Expand Up @@ -141,7 +142,8 @@ async function _generateDocumentation(basePath: string, readmeTemplate: string,
if (parsedJson?.customizations?.vscode?.extensions) {
const extensionsList = parsedJson.customizations.vscode.extensions;
if (extensionsList && extensionsList.length > 0) {
extensions = '\n## Customizations\n\n### VS Code Extensions\n\n' + extensionsList.map((ext: string) => `- \`${ext}\``).join('\n') +'\n';
extensions =
'\n## Customizations\n\n### VS Code Extensions\n\n' + extensionsList.map((ext: string) => `- \`${ext}\``).join('\n') + '\n';
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as path from 'path';
import JSON from 'json5';

import { PublishResult } from './contracts/collection';
import { generateFeaturesDocumentation, generateTemplateDocumentation } from './generateDocs';
Expand Down Expand Up @@ -67,9 +68,8 @@ async function run(): Promise<void> {
if (shouldPublishFeatures || validateOnly) {
core.info('Validating Feature metadata...');
if (!(await prePublish('feature', featuresBasePath))) {

if (disableSchemaValidationAsError) {
core.warning('Failed to validate Feature metadata. NOTE: This warning will be a fatal error in future releases.')
core.warning('Failed to validate Feature metadata. NOTE: This warning will be a fatal error in future releases.');
} else {
core.setFailed('(!) Failed to validate Feature metadata.');
return;
Expand Down Expand Up @@ -144,7 +144,7 @@ async function prePublish(collectionType: 'feature' | 'template', basePath: stri
const pathToArtifact = path.join(basePath, folder);

if (collectionType === 'feature') {
if (!await validateFeatureSchema(pathToArtifact)) {
if (!(await validateFeatureSchema(pathToArtifact))) {
hasFailed = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec';
import Ajv from 'ajv';
import * as path from 'path';
import JSON from 'json5';

import { promisify } from 'util';
import { GitHubMetadata } from './contracts/collection';
Expand Down
Loading
Loading