Skip to content

Instantly share code, notes, and snippets.

@rahulsivalenka
Last active September 28, 2019 15:19
Show Gist options
  • Save rahulsivalenka/f6c71162d28c7b52ffe18da4d4d45bae to your computer and use it in GitHub Desktop.
Save rahulsivalenka/f6c71162d28c7b52ffe18da4d4d45bae to your computer and use it in GitHub Desktop.
VS Code Customizations
// @ts-check
const fs = require('fs');
const path = require('path');
const args = process.argv;
const EXTENSION_PATH_FLAG = '--ext-path';
const SETTINGS_PATH_FLAG = '--settings-path';
const INSIDERS_FLAG = '--insiders';
const flags = [EXTENSION_PATH_FLAG, SETTINGS_PATH_FLAG, INSIDERS_FLAG];
const USERPROFILE = process.env['USERPROFILE'];
const APPDATA = process.env['APPDATA'];
const INSIDERS_DEFAULT_EXT_PATH = path.join(
USERPROFILE,
`.vscode-insiders/extensions`
);
const INSIDERS_DEFAULT_SETTINGS_PATH = path.join(
APPDATA,
`Code - Insiders/User/settings.json`
);
const DEFAULT_EXT_PATH = path.join(USERPROFILE, `.vscode/extensions`);
const DEFAULT_SETTINGS_PATH = path.join(APPDATA, `Code/User/settings.json`);
let isInsiders = false;
let extPath = DEFAULT_EXT_PATH;
let settingsPath = DEFAULT_SETTINGS_PATH;
if (args.indexOf(INSIDERS_FLAG) > -1) {
extPath = INSIDERS_DEFAULT_EXT_PATH;
settingsPath = INSIDERS_DEFAULT_SETTINGS_PATH;
isInsiders = true;
} else {
for (let i = 0; i < args.length; i++) {
const arg = args[i];
if (flags.indexOf(arg) > -1) {
switch (arg) {
case EXTENSION_PATH_FLAG:
if (flags.indexOf(args[i + 1]) < 0) {
extPath = args[i + 1];
}
break;
case SETTINGS_PATH_FLAG:
if (flags.indexOf(args[i + 1]) < 0) {
settingsPath = args[i + 1];
}
break;
}
}
}
}
console.log(`Using `, extPath, settingsPath);
const extensions = fs
.readdirSync(extPath)
.filter(f => fs.lstatSync(path.join(extPath, f)).isDirectory())
.reduce((a, d) => {
try {
const packageFilePath = path.join(extPath, d, 'package.json');
const json = JSON.parse(fs.readFileSync(packageFilePath).toString());
a.push(json);
} catch (error) {}
return a;
}, [])
.map(json => {
return `* [${json.displayName}](${json.homepage ||
(json.repository && json.repository.url)})`;
});
const settings = JSON.parse(fs.readFileSync(settingsPath).toString());
const mdContent = `# VS Code ${isInsiders ? 'Insiders ' : ''}Customizations
## Extensions
${extensions.join('\n')}
## User Settings (settings.json)
\`\`\`javascript
${JSON.stringify(settings, null, 2)}
\`\`\`
`;
console.log('TCL: mdContent', mdContent);
fs.writeFileSync(
`VSCodeCustomizations${isInsiders ? '-Insiders' : ''}.md`,
mdContent
);

VS Code Insiders Customizations

Extensions

User Settings (settings.json)

{
  "workbench.colorTheme": "Nord",
  "editor.fontFamily": "'Fira Code Light', Consolas, 'Courier New', monospace",
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  "files.autoSave": "onWindowChange",
  "git.enableSmartCommit": true,
  "editor.tabSize": 2,
  "typescript.updateImportsOnFileMove.enabled": "always",
  "typescript.preferences.quoteStyle": "single",
  "[typescript]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  },
  "git.autofetch": true,
  "window.zoomLevel": 0,
  "editor.wordWrap": "on",
  "html.format.wrapAttributes": "force-aligned",
  "javascript.updateImportsOnFileMove.enabled": "always",
  "npm.enableScriptExplorer": true,
  "gitlens.settings.mode": "advanced",
  "gitlens.views.repositories.location": "scm",
  "gitlens.views.fileHistory.location": "explorer",
  "gitlens.views.lineHistory.location": "explorer",
  "gitlens.views.compare.location": "gitlens",
  "gitlens.views.search.location": "gitlens",
  "editor.fontLigatures": true,
  "prettier.jsxSingleQuote": true,
  "prettier.singleQuote": true,
  "prettier.trailingComma": "es5",
  "editor.formatOnSave": true,
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  }
}

VS Code Customizations

Extensions

User Settings (settings.json)

{
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  "files.autoSave": "onWindowChange",
  "git.enableSmartCommit": true,
  "editor.tabSize": 2,
  "typescript.updateImportsOnFileMove.enabled": "always",
  "typescript.preferences.quoteStyle": "single",
  "[typescript]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  },
  "git.autofetch": true,
  "window.zoomLevel": 0,
  "editor.wordWrap": "on",
  "html.format.wrapAttributes": "force-aligned",
  "javascript.updateImportsOnFileMove.enabled": "always",
  "npm.enableScriptExplorer": true,
  "gitlens.settings.mode": "advanced",
  "gitlens.views.repositories.location": "scm",
  "gitlens.views.fileHistory.location": "explorer",
  "gitlens.views.lineHistory.location": "explorer",
  "gitlens.views.compare.location": "gitlens",
  "gitlens.views.search.location": "gitlens",
  "editor.fontFamily": "'Fira Code Light', Consolas, 'Courier New', monospace",
  "editor.fontLigatures": true,
  "prettier.jsxSingleQuote": true,
  "prettier.singleQuote": true,
  "prettier.trailingComma": "es5",
  "editor.formatOnSave": true,
  "workbench.colorTheme": "Cobalt Next",
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment