Created VSCode snippet data
Also some minor changes and updates to files all over the place
This commit is contained in:
@ -14,6 +14,7 @@ script:
|
||||
- npm run packager
|
||||
- npm run tester
|
||||
- npm run extractor
|
||||
- npm run vscoder
|
||||
- npm run glossary:keymaker
|
||||
- npm run webber
|
||||
- npm run builder
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
"webber": "node ./scripts/web.js",
|
||||
"tester": "node ./scripts/tdd.js",
|
||||
"extractor": "node ./scripts/extract.js",
|
||||
"vscoder": "node ./scripts/vscodegen.js",
|
||||
"packager": "node ./scripts/module.js",
|
||||
"localizer": "node ./scripts/localize.js",
|
||||
"test": "jest --verbose"
|
||||
|
||||
@ -90,5 +90,5 @@ let listingData = {
|
||||
fs.writeFileSync(path.join(OUTPUT_PATH, 'snippets.json'), JSON.stringify(completeData, null, 2));
|
||||
fs.writeFileSync(path.join(OUTPUT_PATH, 'snippetList.json'), JSON.stringify(listingData, null, 2));
|
||||
// Display messages and time
|
||||
console.log(`${chalk.green('SUCCESS!')} snippets.json and snippetsArchive.json files generated!`);
|
||||
console.log(`${chalk.green('SUCCESS!')} snippets.json and snippetList.json files generated!`);
|
||||
console.timeEnd('Extractor');
|
||||
|
||||
@ -131,7 +131,7 @@ const getCodeBlocks = str => {
|
||||
results = results.map(v => v.replace(/```js([\s\S]*?)```/g, '$1').trim());
|
||||
return {
|
||||
es6: results[0],
|
||||
es5: babel.transformSync(results[0], { presets: ['@babel/preset-env'] }).code,
|
||||
es5: babel.transformSync(results[0], { presets: ['@babel/preset-env'] }).code.replace('"use strict";\n\n',''),
|
||||
example: results[1]
|
||||
}
|
||||
};
|
||||
|
||||
33
scripts/vscodegen.js
Normal file
33
scripts/vscodegen.js
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
This is the VSCode generator script that generates the vscode_snippets/snippets.json file.
|
||||
Run using `npm run vscoder`.
|
||||
*/
|
||||
// Load modules
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
let snippetsData = require('../snippet_data/snippets.json');
|
||||
// Paths
|
||||
const OUTPUT_PATH = './vscode_snippets';
|
||||
console.time('VSCoder');
|
||||
// Read and format data
|
||||
let vscodeData = snippetsData.data.filter(v => !v.meta.archived ).reduce((acc,v) => {
|
||||
acc[v.id] = {
|
||||
prefix: `30s_${v.id}`,
|
||||
body: v.attributes.codeBlocks.es6.replace(/\r/g,'').split('\n'),
|
||||
description: v.attributes.text.slice(0, v.attributes.text.indexOf('\r\n\r\n'))
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
// Write data
|
||||
fs.writeFileSync(
|
||||
path.join(OUTPUT_PATH, 'snippets.json'),
|
||||
JSON.stringify(vscodeData, null, 2)
|
||||
);
|
||||
// Display messages and time
|
||||
console.log(
|
||||
`${chalk.green(
|
||||
'SUCCESS!'
|
||||
)} vscode_snippets/snippets.json file generated!`
|
||||
);
|
||||
console.timeEnd('VSCoder');
|
||||
@ -897,7 +897,7 @@
|
||||
"archived": false
|
||||
},
|
||||
"meta": {
|
||||
"hash": "91e05fa632509c91fad4770339e0f8a4ffc5d0c3a90694f2fd59af2321cac9fb"
|
||||
"hash": "9bbacd07c7a1d66b521b98d192f21964ab2cc33a6a62e18314d9dae5ec51a270"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -1118,7 +1118,7 @@
|
||||
"archived": false
|
||||
},
|
||||
"meta": {
|
||||
"hash": "683bb22450b09dc717ef83b36ffcc6729a48891fcc47bab587b389f232597563"
|
||||
"hash": "50b2980119026b898646420c2dc3cf2f394f5162f1a336cf64bc8d0244e54f26"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -3289,7 +3289,7 @@
|
||||
"archived": false
|
||||
},
|
||||
"meta": {
|
||||
"hash": "12276cbe7dde6659e4ab67ed3fbe81ac57d1e7766b41dc879f946f226b7b76ab"
|
||||
"hash": "6a7d303a9761c57b32f977b8068de4fd9bd9ea72167df268220d13250d1483e5"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -3661,7 +3661,7 @@
|
||||
"archived": false
|
||||
},
|
||||
"meta": {
|
||||
"hash": "5aac190c69a2a7d42dd4f17caabe760270ac8c82b8b54b760d3d6b1de86362d7"
|
||||
"hash": "7a8643d6d71023c773ccb63efe25e4c9fe0bdd976a8a8f76f6f6a0abb928eaf1"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -7,4 +7,5 @@
|
||||
|
||||
## Credits
|
||||
|
||||
*Logos made by [Angelos Chalaris](https://github.com/Chalarangelo) are licensed under the [MIT](https://opensource.org/licenses/MIT) license.*
|
||||
*This README is built using [markdown-builder](https://github.com/30-seconds/markdown-builder).*
|
||||
|
||||
@ -11,8 +11,7 @@
|
||||
* Use <kbd>Ctrl</kbd> + <kbd>F</kbd> or <kbd>command</kbd> + <kbd>F</kbd> to search for a snippet.
|
||||
* Contributions welcome, please read the [contribution guide](CONTRIBUTING.md).
|
||||
* Snippets are written in ES6, use the [Babel transpiler](https://babeljs.io/) to ensure backwards-compatibility.
|
||||
* You can import these snippets into your text editor of choice (VSCode, Atom, Sublime), using the files found in [this repo](https://github.com/Rob-Rychs/30-seconds-of-code-texteditorsnippets).
|
||||
* You can import these snippets into Alfred 3, using [this file](https://github.com/lslvxy/30-seconds-of-code-alfredsnippets).
|
||||
* You can import these snippets into VSCode, by following the instruction found [here](https://github.com/30-seconds/30-seconds-of-code/tree/master/vscode_snippets).
|
||||
* You can search, view and copy these snippets from a terminal, using the CLI application from [this repo](https://github.com/sQVe/30s).
|
||||
* If you want to follow 30-seconds-of-code on social media, you can find us on [Facebook](https://www.facebook.com/30secondsofcode), [Instagram](https://www.instagram.com/30secondsofcode) and [Twitter](https://twitter.com/30secondsofcode).
|
||||
|
||||
@ -38,10 +37,7 @@ npm install 30-seconds-of-code
|
||||
yarn add 30-seconds-of-code
|
||||
```
|
||||
|
||||
CDN links
|
||||
|
||||
* [ES2017 Full (UMD)](https://unpkg.com/30-seconds-of-code)
|
||||
* [ES5 Minified (UMD)](https://unpkg.com/30-seconds-of-code/dist/_30s.es5.min.js)
|
||||
[CDN link](https://unpkg.com/30-seconds-of-code/)
|
||||
|
||||
<details>
|
||||
<summary>Details</summary>
|
||||
|
||||
7
vscode_snippets/README.md
Normal file
7
vscode_snippets/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Importing 30-seconds-of-code snippets to VSCode
|
||||
|
||||
1. Open Visual Studio Code.
|
||||
2. Use <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> or <kbd>command</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> to open the Command Palette.
|
||||
3. Search for `Preferences: Configure User Snippets` and then `New Global Snippets file...`.
|
||||
4. Select a name and save in the default snippets directory.
|
||||
5. Copy and paste the content of `snippets.json` from the `vscode_snippets` folder to the file you previously created.
|
||||
3334
vscode_snippets/snippets.json
Normal file
3334
vscode_snippets/snippets.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user