-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
297 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules | |
.vscode | ||
.vscode-test | ||
*.md | ||
.travis.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1 @@ | ||
module.exports = { | ||
printWidth: 120, | ||
singleQuote: false, | ||
trailingComma: "es5", | ||
bracketSpacing: true, | ||
jsxBracketSameLine: true, | ||
semi: true, | ||
requirePragma: false, | ||
proseWrap: "preserve", | ||
arrowParens: "avoid", | ||
}; | ||
module.exports = require('@kokororin/prettierrc'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,84 @@ | ||
import path from "path"; | ||
import fs from "fs"; | ||
import os from "os"; | ||
import Transformations from "../src/Transformations"; | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import os from 'os'; | ||
import Transformations from '../src/Transformations'; | ||
|
||
const pkg: any = require("pjson"); | ||
const pkg: any = require('pjson'); | ||
|
||
const readmePath: string = path.join(__dirname, "/../README.md"); | ||
const readmePath: string = path.join(__dirname, '/../README.md'); | ||
|
||
const configuration: any = pkg.contributes.configuration; | ||
|
||
let config: string = | ||
"| Key | Type | Description | Default |" + os.EOL + "| -------- | ----------- | ----------- | ----------- |" + os.EOL; | ||
'| Key | Type | Description | Default |' + | ||
os.EOL + | ||
'| -------- | ----------- | ----------- | ----------- |' + | ||
os.EOL; | ||
|
||
for (const configKey of Object.keys(configuration.properties)) { | ||
const configValue = configuration.properties[configKey]; | ||
config += `| ${configKey} | `; | ||
|
||
if (typeof configValue.type === "string") { | ||
if (typeof configValue.type === 'string') { | ||
config += `\`${configValue.type}\``; | ||
} else if (Array.isArray(configValue.type)) { | ||
config += `\`${configValue.type.join(" \\| ")}\``; | ||
config += `\`${configValue.type.join(' \\| ')}\``; | ||
} | ||
config += ` | ${configValue.description}`; | ||
|
||
if (typeof configValue.default === "string") { | ||
if (typeof configValue.default === 'string') { | ||
config += ` | "${configValue.default}"`; | ||
} else if (typeof configValue.default === "number") { | ||
} else if (typeof configValue.default === 'number') { | ||
config += ` | ${configValue.default}`; | ||
} else if (Array.isArray(configValue.default) || typeof configValue.default === "boolean") { | ||
} else if ( | ||
Array.isArray(configValue.default) || | ||
typeof configValue.default === 'boolean' | ||
) { | ||
config += ` | ${JSON.stringify(configValue.default)}`; | ||
} else { | ||
throw new Error("uncovered type"); | ||
throw new Error('uncovered type'); | ||
} | ||
|
||
config += " | " + os.EOL; | ||
config += ' | ' + os.EOL; | ||
} | ||
|
||
let readmeContent = fs.readFileSync(readmePath).toString(); | ||
readmeContent = readmeContent.replace(/<!-- Configuration START -->([\s\S]*)<!-- Configuration END -->/, () => { | ||
return "<!-- Configuration START -->" + os.EOL + config + os.EOL + "<!-- Configuration END -->"; | ||
}); | ||
readmeContent = readmeContent.replace( | ||
/<!-- Configuration START -->([\s\S]*)<!-- Configuration END -->/, | ||
() => { | ||
return ( | ||
'<!-- Configuration START -->' + | ||
os.EOL + | ||
config + | ||
os.EOL + | ||
'<!-- Configuration END -->' | ||
); | ||
} | ||
); | ||
|
||
readmeContent = readmeContent.replace(/<!-- Transformations START -->([\s\S]*)<!-- Transformations END -->/, () => { | ||
return ( | ||
"<!-- Transformations START -->" + | ||
os.EOL + | ||
"| Key | Description |" + | ||
os.EOL + | ||
"| -------- | ----------- |" + | ||
os.EOL + | ||
new Transformations("php") | ||
.getTransformations() | ||
.map(item => { | ||
let row = `| ${item.key} | `; | ||
row += item.description; | ||
row += " |"; | ||
return row; | ||
}) | ||
.join(os.EOL) + | ||
os.EOL + | ||
"<!-- Transformations END -->" | ||
); | ||
}); | ||
readmeContent = readmeContent.replace( | ||
/<!-- Transformations START -->([\s\S]*)<!-- Transformations END -->/, | ||
() => { | ||
return ( | ||
'<!-- Transformations START -->' + | ||
os.EOL + | ||
'| Key | Description |' + | ||
os.EOL + | ||
'| -------- | ----------- |' + | ||
os.EOL + | ||
new Transformations('php') | ||
.getTransformations() | ||
.map(item => { | ||
let row = `| ${item.key} | `; | ||
row += item.description; | ||
row += ' |'; | ||
return row; | ||
}) | ||
.join(os.EOL) + | ||
os.EOL + | ||
'<!-- Transformations END -->' | ||
); | ||
} | ||
); | ||
|
||
fs.writeFileSync(readmePath, readmeContent); |
Oops, something went wrong.