Skip to content

Commit 5e57a2c

Browse files
authored
Fixes devcontainer-feature.json with comment (#214)
1 parent a1930bf commit 5e57a2c

7 files changed

Lines changed: 28 additions & 242 deletions

File tree

__tests__/examples/simple/src/hello/devcontainer-feature.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
// comment out of the object
12
{
3+
// single line comment
24
"name": "Hello, World!",
3-
"id": "hello",
4-
"version": "1.0.2",
5+
/*
6+
multi line comment
7+
你好世界
8+
*/
9+
"id": "hello", // comment at end
10+
"version": /* inline comment */ "1.0.2",
511
"description": "A hello world feature",
612
"options": {
713
"greeting": {

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"build": "ncc build ./src/main.ts",
1111
"test": "jest",
1212
"fetch-schemas": "wget https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json -O src/schemas/devContainerFeature.schema.json"
13-
1413
},
1514
"repository": {
1615
"type": "git",
@@ -31,21 +30,15 @@
3130
"@actions/exec": "^1.1.1",
3231
"@actions/github": "^5.1.1",
3332
"ajv": "^8.11.2",
34-
"jsonc-parser": "^3.2.0"
33+
"json5": "^2.2.3"
3534
},
3635
"devDependencies": {
3736
"@types/ajv": "^1.0.0",
3837
"@types/node": "^18.11.18",
3938
"@vercel/ncc": "^0.34.0",
40-
"copyfiles": "^2.4.1",
4139
"eslint": "^8.32.0",
42-
"glob": "^8.0.3",
43-
"handlebars": "^4.7.7",
4440
"jest": "^28.1.3",
45-
"js-yaml": "^4.1.0",
46-
"jsonc": "^2.0.0",
4741
"prettier": "2.8.3",
48-
"rimraf": "^3.0.2",
4942
"ts-jest": "^28.0.8",
5043
"typescript": "^4.9.4"
5144
}

src/contracts/collection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export interface GitHubMetadata {
1111

1212
export interface PublishResult {
1313
publishedTags: string[];
14-
digest: string;
15-
version: string;
14+
digest: string;
15+
version: string;
1616
}
1717
export interface DevContainerCollectionMetadata {
1818
sourceInformation: GitHubMetadata;

src/generateDocs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as fs from 'fs';
22
import * as core from '@actions/core';
33
import * as path from 'path';
4+
import JSON from 'json5';
45
import { getGitHubMetadata } from './utils';
56

67
const FEATURES_README_TEMPLATE = `
@@ -141,7 +142,8 @@ async function _generateDocumentation(basePath: string, readmeTemplate: string,
141142
if (parsedJson?.customizations?.vscode?.extensions) {
142143
const extensionsList = parsedJson.customizations.vscode.extensions;
143144
if (extensionsList && extensionsList.length > 0) {
144-
extensions = '\n## Customizations\n\n### VS Code Extensions\n\n' + extensionsList.map((ext: string) => `- \`${ext}\``).join('\n') +'\n';
145+
extensions =
146+
'\n## Customizations\n\n### VS Code Extensions\n\n' + extensionsList.map((ext: string) => `- \`${ext}\``).join('\n') + '\n';
145147
}
146148
}
147149

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import * as core from '@actions/core';
77
import * as exec from '@actions/exec';
88
import * as path from 'path';
9+
import JSON from 'json5';
910

1011
import { PublishResult } from './contracts/collection';
1112
import { generateFeaturesDocumentation, generateTemplateDocumentation } from './generateDocs';
@@ -67,9 +68,8 @@ async function run(): Promise<void> {
6768
if (shouldPublishFeatures || validateOnly) {
6869
core.info('Validating Feature metadata...');
6970
if (!(await prePublish('feature', featuresBasePath))) {
70-
7171
if (disableSchemaValidationAsError) {
72-
core.warning('Failed to validate Feature metadata. NOTE: This warning will be a fatal error in future releases.')
72+
core.warning('Failed to validate Feature metadata. NOTE: This warning will be a fatal error in future releases.');
7373
} else {
7474
core.setFailed('(!) Failed to validate Feature metadata.');
7575
return;
@@ -144,7 +144,7 @@ async function prePublish(collectionType: 'feature' | 'template', basePath: stri
144144
const pathToArtifact = path.join(basePath, folder);
145145

146146
if (collectionType === 'feature') {
147-
if (!await validateFeatureSchema(pathToArtifact)) {
147+
if (!(await validateFeatureSchema(pathToArtifact))) {
148148
hasFailed = true;
149149
}
150150
}

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as core from '@actions/core';
44
import * as exec from '@actions/exec';
55
import Ajv from 'ajv';
66
import * as path from 'path';
7+
import JSON from 'json5';
78

89
import { promisify } from 'util';
910
import { GitHubMetadata } from './contracts/collection';

0 commit comments

Comments
 (0)