Skip to content

Commit

Permalink
Initial version of kudu and appservice packages
Browse files Browse the repository at this point in the history
These primarily just support start/stop and v1 of zip deploy
  • Loading branch information
ejizba committed Oct 13, 2017
1 parent c0d99e0 commit 37f5ab0
Show file tree
Hide file tree
Showing 25 changed files with 8,021 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,8 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs

node_modules
lib
package-lock.json
*.tgz
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: node_js

node_js:
- 'stable'

addons:
apt:
packages:
- libunwind8

env:
- PACKAGE_DIR=appservice
- PACKAGE_DIR=kudu

script:
- cd $PACKAGE_DIR
- npm install
- npm run build
- npm run lint

notifications:
email:
on_success: never
on_failure: always
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

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
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# VSCode Azure SDK for Node.js

# Contributing
This project provides Node.js packages that make it easy to consume and manage Azure Services in Visual Studio Code.

## Modules

* [Azure Kudu](kudu/)
* [Azure App Service](appservice/)

## Developing locally

In order to quickly develop and debug these packages locally, follow these instructions:
1. Navigate to the package you are developing and run `npm install`, `npm run build`, and `npm link`
1. Navigate to the project you want to reference the package and run `npm link <name of package>`

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
Expand All @@ -12,3 +26,6 @@ provided by the bot. You will only need to do this once across all repos using o
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

## License
[MIT](LICENSE.md)
6 changes: 6 additions & 0 deletions appservice/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
.vscode/
src/
tsconfig.json
tslint.json
*.tgz
33 changes: 33 additions & 0 deletions appservice/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": "2.0.0",
"tasks": [
{
"taskName": "npm",
"type": "shell",
"command": "npm",
"group": {
"kind": "build",
"isDefault": true
},
"args": [
"run",
"compile",
"--loglevel",
"silent"
],
"isBackground": true,
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$tsc-watch"
},
{
"type": "npm",
"script": "lint",
"problemMatcher": {
"base": "$tslint5",
"fileLocation": "absolute"
}
}
]
}
21 changes: 21 additions & 0 deletions appservice/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

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
4 changes: 4 additions & 0 deletions appservice/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# VSCode Azure SDK for Node.js - App Service Tools

## License
[MIT](LICENSE.md)
48 changes: 48 additions & 0 deletions appservice/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "vscode-azureappservice",
"author": "Microsoft Corporation",
"version": "0.1.0",
"description": "Common tools for developing Azure App Service extensions for VS Code",
"tags": [
"azure",
"vscode"
],
"keywords": [
"azure",
"vscode"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-azuretools"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-azuretools/issues"
},
"homepage": "https://github.com/Microsoft/vscode-azuretools/blob/master/appservice/README.md",
"scripts": {
"build": "tsc -p ./",
"compile": "tsc -watch -p ./",
"lint": "tslint --project tsconfig.json -e src/*.d.ts --type-check -t verbose",
"prepare": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"archiver": "^2.0.3",
"azure-arm-website": "^1.0.0-preview",
"vscode-azurekudu": "0.1.0",
"ms-rest": "^2.2.2",
"ms-rest-azure": "^2.4.0"
},
"devDependencies": {
"@types/archiver": "^2.0.0",
"typescript": "^2.5.3",
"tslint": "^5.7.0",
"tslint-microsoft-contrib": "5.0.1",
"vscode": "^1.1.5"
},
"engines": {
"vscode": "^1.16.0"
}
}
68 changes: 68 additions & 0 deletions appservice/src/FileUtilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as archiver from 'archiver';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';

export function getFileExtension(fsPath: string): string | undefined {
return fsPath.split('.').pop();
}

export async function isDirectory(fsPath: string): Promise<boolean> {
const fsStats: fs.Stats = await new Promise((resolve: (s?: fs.Stats) => void, reject: (e: Error) => void): void => {
fs.lstat(fsPath, (err?: Error, stats?: fs.Stats) => {
if (err) {
reject(err);
} else {
resolve(stats);
}
});
});

return fsStats.isDirectory();
}

export async function deleteFile(fsPath: string): Promise<void> {
await new Promise((resolve: () => void, reject: (err: Error) => void): void => {
fs.unlink(fsPath, (err?: Error) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}

export async function zipDirectory(folderPath: string): Promise<string> {
if (!folderPath.endsWith(path.sep)) {
folderPath += path.sep;
}

const zipFilePath: string = path.join(os.tmpdir(), `${randomFileName()}.zip`);
await new Promise((resolve: () => void, reject: (err: Error) => void): void => {
const zipOutput: fs.WriteStream = fs.createWriteStream(zipFilePath);
zipOutput.on('close', resolve);

const zipper: archiver.Archiver = archiver('zip', { zlib: { level: 9 } });
zipper.on('error', reject);
zipper.pipe(zipOutput);
zipper.glob('**/*', {
cwd: folderPath,
dot: true,
ignore: 'node_modules{,/**}'
});
void zipper.finalize();
});

return zipFilePath;
}

export function randomFileName(): string {
// tslint:disable-next-line:insecure-random
return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 10);
}
Loading

0 comments on commit 37f5ab0

Please sign in to comment.