-
Notifications
You must be signed in to change notification settings - Fork 2
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
0 parents
commit 205f79e
Showing
15 changed files
with
4,158 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
*.log | ||
out |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"ms-vscode.vscode-typescript-tslint-plugin" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// A launch configuration that compiles the extension and then opens it inside a new window | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [{ | ||
"name": "Run Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/out/**/*.js" | ||
], | ||
"preLaunchTask": "npm: watch" | ||
}, | ||
{ | ||
"name": "Extension Tests", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}", | ||
"--extensionTestsPath=${workspaceFolder}/out/test" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/out/test/**/*.js" | ||
], | ||
"preLaunchTask": "npm: watch" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"out": false // set this to true to hide the "out" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true // set this to false to include "out" folder in search results | ||
}, | ||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
"typescript.tsc.autoDetect": "off" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "watch", | ||
"problemMatcher": "$tsc-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
out/test/** | ||
src/** | ||
.gitignore | ||
vsc-extension-quickstart.md | ||
**/tsconfig.json | ||
**/tslint.json | ||
**/*.map | ||
**/*.ts |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Jay Fong <fjc0kb@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Generate Index | ||
|
||
Generating file indexes easily. | ||
|
||
## Wherever | ||
|
||
In any file, simply invoke command `Generate Index` to generate a file list. | ||
|
||
- Example 1: `src/index.js` | ||
|
||
```js | ||
export { default as module1 } from './module1' | ||
export { default as module2 } from './module2' | ||
``` | ||
|
||
- Example 2: `utils.ts` | ||
|
||
```js | ||
// @index('../utils/*.ts') | ||
export { default as util1 } from '../utils/util1' | ||
export { default as util2 } from '../utils/util1' | ||
``` | ||
|
||
- Example 3: `styles/components.scss` | ||
|
||
```scss | ||
// @index('./components/*.scss', pp => `@import '${pp.path}';`) | ||
@import './components/component1'; | ||
@import './components/component2'; | ||
``` | ||
|
||
- Example 4: `assets/index.ts` | ||
|
||
```js | ||
// @index('./*.{png,jpg,svg}', pp => `export { default as ${pp.name} } from '${pp.path}${pp.extension}'`) | ||
export { default as image1 } from './image1.png' | ||
export { default as image2 } from './image2.jpg' | ||
export { default as image3 } from './image3.svg' | ||
``` | ||
|
||
## Markers | ||
|
||
You can use markers (`@index()` and `@endindex`) to tell where the index should be built, instead of replacing the entire file: | ||
|
||
```js | ||
// This line will remain in the file. | ||
|
||
// @index() | ||
|
||
// ... The index will be (re)placed here. | ||
|
||
// @endindex | ||
|
||
// This line will remain in the file. | ||
``` | ||
|
||
## @index() | ||
|
||
`index` is a function (type: `Index`): | ||
|
||
```ts | ||
import * as lodash from 'lodash' | ||
|
||
interface ParsedPath { | ||
/** The relative file path without extension, such as `./api` */ | ||
path: string, | ||
/** The file name without extension, such as `api` */ | ||
name: string, | ||
/** The file extension, such as `.js`*/ | ||
extension: string, | ||
} | ||
|
||
type Pattern = string | ||
|
||
type CodeGenerator = ( | ||
parsedPath: ParsedPath, | ||
lodash: lodash.LoDashStatic, | ||
) => string | ||
|
||
type Index = ( | ||
patterns: Pattern | Pattern[], | ||
codeGenerator: CodeGenerator, | ||
) => string | ||
``` | ||
## Patterns | ||
See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage). | ||
## Indentation | ||
You can make an index indented by indenting the start marker, e.g. | ||
```js | ||
module.exports = { | ||
// @index('./*.js', pp => `${pp.name}: require('${pp.path}'),`) | ||
// @endindex | ||
} | ||
``` | ||
|
||
The produced index like as: | ||
|
||
```js | ||
module.exports = { | ||
// @index('./*.js', pp => `${pp.name}: require('${pp.path}'),`) | ||
module1: require('./module1'), | ||
module2: require('./module2'), | ||
// @endindex | ||
} | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"name": "generate-index", | ||
"displayName": "Generate Index", | ||
"description": "Generating file indexes easily.", | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"publisher": "JayFong", | ||
"engines": { | ||
"vscode": "^1.32.0" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fjc0k/vscode-generate-index" | ||
}, | ||
"activationEvents": [ | ||
"onCommand:extension.generateIndex" | ||
], | ||
"main": "./out/extension.js", | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": "extension.generateIndex", | ||
"title": "Generate Index" | ||
} | ||
], | ||
"configuration": { | ||
"title": "Generate Index", | ||
"properties": { | ||
"generateIndex.defaultPatterns": { | ||
"type": "string", | ||
"default": "['./*.{js,jsx,ts,tsx}']", | ||
"description": "<Array> The default patterns to use when exporting files." | ||
}, | ||
"generateIndex.defaultCodeGenerator": { | ||
"type": "string", | ||
"default": "(parsedPath, lodash) => `export { default as ${parsedPath.name} } from '${parsedPath.path}'`", | ||
"description": "<Function> The default code generator to use when generating indexes." | ||
} | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "yarn run compile", | ||
"compile": "tsc -p ./", | ||
"watch": "tsc -watch -p ./", | ||
"postinstall": "node ./node_modules/vscode/bin/install", | ||
"test": "yarn run compile && node ./node_modules/vscode/bin/test", | ||
"release": "standard-version -a && git push --follow-tags origin master && vsce publish" | ||
}, | ||
"eslintConfig": { | ||
"root": true, | ||
"extends": "io", | ||
"rules": { | ||
"import/no-unresolved": [ | ||
2, | ||
{ | ||
"ignore": [ | ||
"vscode" | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"eslintIgnore": [ | ||
"out" | ||
], | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.123", | ||
"@types/mocha": "^2.2.42", | ||
"@types/node": "^10.12.21", | ||
"eslint": "^5.15.1", | ||
"eslint-config-io": "^0.1.1", | ||
"standard-version": "^5.0.1", | ||
"typescript": "^3.3.1", | ||
"vscode": "^1.1.28" | ||
}, | ||
"dependencies": { | ||
"globby": "^9.1.0", | ||
"lodash": "^4.17.11" | ||
} | ||
} |
Oops, something went wrong.