Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 3579ad5

Browse files
author
Christopher Anderson
authored
Merge pull request #27 from Azure/dev
Add Ignore module support
2 parents 0a0386b + a40c57d commit 3579ad5

File tree

12 files changed

+109
-17
lines changed

12 files changed

+109
-17
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
coverage/
22
node_modules/
33
npm-debug.log
4+
5+
lib
6+
7+
**/*.csv

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ Usage: pack [options] <path>
7474
-o, --output <path> Path for output directory
7575
```
7676

77+
### funcpack.config.json
78+
79+
Pack will optionally take in a config file that will let you further customize the behavior. The config file must be in the directory you run the command from and named `funcpack.config.json`.
80+
81+
Here are all the supported options:
82+
83+
```
84+
{
85+
"ignoredModules":["chai"]
86+
}
87+
```
88+
7789
## License
7890

7991
[MIT](LICENSE)

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "azure-functions-pack",
3-
"version": "0.1.2",
3+
"version": "0.2.2",
44
"description": "azure-functions-pack",
55
"license": "MIT",
66
"repository": "https://github.com/christopheranderson/azure-functions-pack",
@@ -26,28 +26,28 @@
2626
"e2etst": "npm run "
2727
},
2828
"dependencies": {
29-
"commander": "^2.9.0",
30-
"debug": "^2.6.1",
31-
"rimraf": "^2.5.4",
29+
"commander": "~2.9.0",
30+
"debug": "~2.6.1",
31+
"rimraf": "~2.5.4",
3232
"webpack": "fulls1z3/webpack#v2.2.1-harmony",
33-
"winston": "^2.3.1"
33+
"winston": "~2.3.1"
3434
},
3535
"devDependencies": {
36-
"@types/chai": "^3.0.0",
37-
"@types/commander": "^2.3.31",
36+
"@types/chai": "3.5.0",
37+
"@types/commander": "~2.3.31",
3838
"@types/debug": "0.0.29",
39-
"@types/mocha": "^2.0.0",
39+
"@types/mocha": "2.2.41",
4040
"@types/node": "6.0.31",
4141
"@types/rimraf": "0.0.28",
42-
"@types/webpack": "^2.2.5",
43-
"@types/winston": "^2.2.0",
44-
"chai": "^3.0.0",
45-
"mocha": "^3.0.0",
46-
"ts-node": "^1.0.0",
47-
"tslint": "^4.0.0",
48-
"typescript": "^2.0.0"
42+
"@types/webpack": "~2.2.5",
43+
"@types/winston": "~2.2.0",
44+
"chai": "~3.5.0",
45+
"mocha": "~3.0.0",
46+
"ts-node": "~1.0.0",
47+
"tslint": "~4.0.0",
48+
"typescript": "~2.2.0"
4949
},
5050
"engines": {
51-
"node": ">=4.0.0"
51+
"node": ">=6.5.0"
5252
}
5353
}

sample/excluded/function.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"disabled": false,
3+
"bindings": [
4+
{
5+
"authLevel": "function",
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"name": "req"
9+
},
10+
{
11+
"type": "http",
12+
"direction": "out",
13+
"name": "$return"
14+
}
15+
],
16+
"scriptFile": "index.js"
17+
}

sample/excluded/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(false) { // never called
2+
require('chai');
3+
}
4+
5+
module.exports = function (context, req) {
6+
context.log('"simple" function called');
7+
const res = {
8+
body: {
9+
"success":true
10+
}
11+
}
12+
context.done(null, res);
13+
};

sample/funcpack.config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ignoredModules":[
3+
"chai"
4+
]
5+
}

sample/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
"azure": "^1.2.0-preview",
1313
"lodash": "^4.17.4",
1414
"tedious": "^1.14.0"
15+
},
16+
"devDependencies": {
17+
"chai":"3.5.0"
1518
}
1619
}

src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import * as program from "commander";
44
import * as path from "path";
55
import * as winston from "winston";
66
import { PackhostGenerator, Unpacker, WebpackRunner } from "./";
7+
import { ConfigLoader, IFuncpackConfig } from "./utils";
78

89
async function runCli() {
910
const p = program
10-
.version("0.1.2")
11+
.version("0.2.2")
1112
.option("-d, --debug", "Emits debug messages");
1213

1314
p.command("unpack <path>")
@@ -66,6 +67,13 @@ async function unpack(name: string, options: any) {
6667
}
6768

6869
async function pack(name: string, options: any) {
70+
// TBD - allow loadConfig to get a filename from options
71+
let config: IFuncpackConfig = await ConfigLoader.loadConfig();
72+
73+
config = config || {
74+
ignoredModules: [],
75+
};
76+
6977
if (options.debug) {
7078
process.env.DEBUG = "*";
7179
}
@@ -121,6 +129,7 @@ async function pack(name: string, options: any) {
121129
projectRootPath,
122130
uglify,
123131
outputPath,
132+
ignoredModules: config.ignoredModules,
124133
});
125134
} catch (error) {
126135
winston.error(error);

src/utils/config-loader.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
FileHelper,
3+
} from "./index";
4+
5+
import * as path from "path";
6+
7+
export class ConfigLoader {
8+
public static async loadConfig(filename?: string): Promise<IFuncpackConfig> {
9+
const pathToFile = path.join(process.cwd(), (filename || "funcpack.config.json"));
10+
if (await FileHelper.exists(pathToFile)) {
11+
return await FileHelper.readFileAsJSON(pathToFile);
12+
}
13+
}
14+
}
15+
16+
export interface IFuncpackConfig {
17+
ignoredModules?: string[];
18+
}

src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from "./fs-helper";
2+
export * from "./config-loader";

0 commit comments

Comments
 (0)