Skip to content

Commit

Permalink
Merge pull request #1 from CobusKruger/master
Browse files Browse the repository at this point in the history
Version 2
  • Loading branch information
CobusKruger authored Mar 27, 2019
2 parents 9288384 + ba29292 commit 7076856
Show file tree
Hide file tree
Showing 14 changed files with 922 additions and 4,671 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ out
node_modules
.vscode-test/
*.vsix
.vscode
51 changes: 15 additions & 36 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,20 @@
// 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

// To debug the extension:
// 1. please install the "SQL Operations Studio Debug" extension into VSCode
// 2. Ensure sqlops is added to your path:
// - open SQL Operations Studio
// - run the command "Install 'sqlops' command in PATH"
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "sqlopsExtensionHost",
"request": "launch",
"runtimeExecutable": "sqlops",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
},
{
"name": "Extension Tests",
"type": "sqlopsExtensionHost",
"request": "launch",
"runtimeExecutable": "sqlops",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
}
"configurations": [{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
}
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
}
},
"cSpell.words": [
"combinefilesrc",
"vsix"
]
}
47 changes: 44 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
# Change Log
All notable changes to the "create-combined-script" extension will be documented in this file.
All notable changes to this project will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Initial release

* Nothing for now.

## [2.0.0] - 2019-03-27

### Overview
This is almost a complete rewrite of the extension, and it's much more customizable and capable than before.

### Added
1. Instead of being hard-coded to work with `.sql` files, that is now only one possible configuration and you can specify any glob pattern you choose.
2. A table of contents, showing line numbers for each file.
3. Customizable headers and footers for the TOC, the individual script files and the output file itself.
4. You can optionally specify an output filename, instead of having output dumped into a temporary file.
5. Multiple file groups, all with either shared or distinctive headers, footers and more.
6. Multiple output files. You can, for example, have one file for table changes, and another for data changes.
7. Run the extension directly from the command palette to include all the files in the workspace, or using multi-select from the explorer.
8. Configured directly in the Azure Data Studio user or workspace settings, or you can add a configuration file in the workspace root.

## [1.3.0] - 2018-07-20

### Changed

* Added GO statements after the PRINT statements, to ensure each statement is properly isolated.

## [1.2.0] - 2018-07-18

### Changed

* Added back the menu item.

## [1.1.0] - 2018-07-13

### Changed

* Small update to add print statements, so you can see the start and end of scripts as they execute.
* Also added an icon.

## [1.0.0] - 2018-07-11

* This is the initial release. Super excited.

95 changes: 85 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,96 @@
# Combine Scripts
# Combine Scripts for Azure Data Studio

Ever needed to execute several scripts spread over several folders? Now you can select several files and folders and generate a single combined file to execute or ab/use any way you choose.
Combines several files spread over several folders. This is useful in many cases.

1. Combine SQL scripts from your repo into a single file you can use for deployment.
2. Easily create an API doc from Markdown files stored in a folder structure.
3. You get the idea.

## Features

A simple need with a simple solution.
Just use `Ctrl` and `Shift` to select multiple files and folders, then right-click and choose *Combine Files*.

If you select a folder, all matching files in subfolders will also be included.

The result will be a single file containing the content of all the selected files. By default, there will also be headers and footers for each included file, as well as a table of contents at the top. You can configure all of this either in user settings, or a configuration file.

## Installation

Search for *Combine Files* in the VS Code extensions marketplace.

Alternatively, you can install it from this link: [Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=BateleurIO.vscode-combine-scripts)

## Configuration

You can change the default configuration in user/workspace settings, or you can place a configuration file named `.combinefilesrc.json` in the workspace root.

The file looks like this:

Just use `Ctrl` and `Shift` to select multiple files and folders, then right-click and choose *Combine Scripts*.
```json
{
"fileGroups": [/*...*/]
}
```

If you select a folder, all SQL files in subfolders will also be included.
Each entry in `fileGroups` can have one or more of the following properties:

The start and end of each script is clearly commented and scripts are separated with `GO` statements.
* `groupName` - Not used. Use this to label multiple configurations.
* `outputFileName` - The name of the output file. If this is not specified, a temporary file is created.
* `fileGlobs` - A list of glob patterns to match. A file is included if it matches *any* glob pattern. Defaults to `**/*.sql` if none is specified.
* `fileHeader` - The lines of text to be placed at the beginning of the output.
* `fileFooter` - The lines of text to be placed at the end of the output.
* `includeToc` - A table of contents will be written after `fileHeader` but before the first `entryHeader` if this is `true`. Defaults to `false`.
* `tocHeader` - If `includeToc === true`, the lines of text to be placed after the `fileHeader`, but before the first `tocEntry`.
* `tocEntry` - If `includeToc === true`, the single line of text that is added once for each included file. Defaults to `'\t${lineNo}\t\t${entryPath}'`, which will show the line number and original file name for each entry.
* `tocFooter` - If `includeToc === true`, the lines of text to be placed after the last `tocEntry`, but before the first `entryHeader`.
* `entryHeader` - The lines of text to be placed at the beginning of each file entry. You can also include the `${entryPath}` variable anywhere in this value.
* `entryFooter` - The lines of text to be placed at the end of each file entry. You can also include the `${entryPath}` variable anywhere in this value.

## Release Notes
For an example, here is the default configuration for SQL files:

### 1.0.0
#### 2018-07-11
```json
{
"fileGroups": [{
"fileGlobs": [
"**/*.sql"
],
"fileHeader": [
"/**********************************************************************************",
"* This is a concatenation of all the selected files, including files in subfolders.",
"* The start and end of each file contains a comment with its name, as well as a",
"* print statement.",
"***********************************************************************************"
],
"includeToc": true,
"tocHeader": [
"* These are the line numbers for the included files:"
],
"tocEntry": "* ${lineNo}\t\t${entryPath}",
"tocFooter": [
"***********************************************************************************/"
],
"entryHeader": [
"/*********************************************************************************",
"* Start: ${entryPath}",
"**********************************************************************************/",
"print 'Start: ${entryPath}'",
"GO"
],
"entryFooter": [
"GO",
"/*********************************************************************************",
"* End: ${entryPath}",
"**********************************************************************************/",
"print 'End: ${entryPath}'",
"GO",
"/*********************************************************************************/"
],
"fileFooter": []
}]
}
```

Initial release. It all works perfectly, of course.
## See Also

- [Combine Scripts for Azure Data Studio](https://github.com/BateleurIO/azuredatastudio-combine-scripts) is the Azure Data Studio version of this extension. The two are nearly identical, except that the Azure Data Studio version comes configured with defaults for `.sql` files. You can use it to combine other types as well.
- [Combine Files NPM Package](https://www.npmjs.com/package/@cobuskruger/combine-files) [(GitHub)](https://github.com/BateleurIO/combine-files) is an NPM package that combines files with all the same features as this extension.
Loading

0 comments on commit 7076856

Please sign in to comment.