Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Commit 11c846c

Browse files
authored
Merge pull request #58 from SqueezerIO/nickfix
fixed major dependencies parsing bugs
2 parents 2af11ce + 36003fd commit 11c846c

10 files changed

Lines changed: 75 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v1.1.22 - 2017-12-16
2+
- fixed major dependencies parsing bugs
3+
## v1.1.21 - 2017-12-02
4+
- fixed packages issues
5+
16
## v1.1.20 - 2017-11-24
27
- fixed functions checksum file deps
38

lib/common/checksums/index.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class Checksums {
8484

8585
if (!_.has(this.tree.functions, functionName)) {
8686
this.tree.functions[functionName] = {
87-
deps: []
87+
deps: [],
88+
packages : []
8889
};
8990
}
9091

@@ -106,28 +107,33 @@ class Checksums {
106107
}
107108

108109
parseFile(file, functionName) {
109-
const stat = fs.statSync(file);
110+
if (fs.existsSync(file)) {
111+
const stat = fs.statSync(file);
110112

111-
if (!_.includes(this.tree.functions[functionName].deps, file)) {
112-
this.tree.functions[functionName].deps.push(file);
113-
}
113+
if (!_.includes(this.tree.functions[functionName].deps, file)) {
114+
this.tree.functions[functionName].deps.push(file);
115+
}
114116

115-
if (this.tree.files[file] && this.tree.files[file].mtimeMs === stat.mtimeMs) {
116-
return;
117-
}
117+
if (this.tree.files[file] && this.tree.files[file].mtimeMs === stat.mtimeMs
118+
&& this.tree.functions[functionName].deps[file]) {
119+
return;
120+
}
118121

119-
const data = fs.readFileSync(file, 'utf8');
120-
const md5 = crypto.createHash('md5').update(data).digest('hex');
121-
const deps = this.deps.crawl(data, file);
122+
const data = fs.readFileSync(file, 'utf8');
123+
const md5 = crypto.createHash('md5').update(data).digest('hex');
124+
const deps = this.deps.crawl(data, file);
122125

123-
this.tree.files[file] = {
124-
md5: md5,
125-
mtimeMs: stat.mtimeMs
126-
};
126+
this.tree.files[file] = {
127+
md5: md5,
128+
mtimeMs: stat.mtimeMs
129+
};
127130

128-
_.forEach(deps, (dep) => {
129-
this.parseFile(dep, functionName);
130-
});
131+
_.forEach(deps.files, (dep) => {
132+
this.parseFile(dep, functionName);
133+
});
134+
135+
this.tree.functions[functionName].packages = _.unionBy(deps.packages, this.tree.functions[functionName].packages, 'pkg');
136+
}
131137
}
132138
}
133139

lib/common/checksums/lib/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Data {
3737
const key = this.getKey();
3838
const apiBaseUrl = this.sqz.vars.apiBaseUrl;
3939
const endpoint = `${apiBaseUrl}/rest/v1/deployment/${key}`;
40-
40+
resolve();
4141
if (key) {
4242
request.get(endpoint, { json: true }, (error, response, body) => {
4343
if (!error && response.statusCode === 200 && body.message === 'success') {

lib/common/checksums/lib/deps.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class Deps {
2525
javascriptCrawler(data, dir) {
2626
const localRegex = /^.\.\/|^.\/|^\//;
2727

28-
const deps = [];
28+
const files = [];
29+
const packages = [];
2930

3031
const umdData = precinct(data);
3132

@@ -38,13 +39,25 @@ class Deps {
3839

3940
_.forEach(permutations, (permutation) => {
4041
if (fs.existsSync(permutation)) {
41-
deps.push(permutation);
42+
files.push(permutation);
4243
}
4344
});
45+
} else {
46+
if (!this.packages) {
47+
this.packages = JSON.parse(fs.readFileSync(path.join(this.sqz.vars.project.path, 'package.json'))).dependencies;
48+
}
49+
50+
packages.push({
51+
pkg : val,
52+
version : this.packages[val]
53+
});
4454
}
4555
});
4656

47-
return deps;
57+
return {
58+
files : files,
59+
packages : packages
60+
};
4861
}
4962
}
5063

lib/plugins/compile/lib/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Compile {
1919
const compileFunctions = new CompileFunctions(this.sqz);
2020
let compileType = 'development' || this.options.cloud;
2121

22-
let stage = this.options.stage;
22+
let stage = this.options.stage || 'local';
2323

2424
if (_.has(this.options, 'cloud')) {
2525
compileType = 'cloud';

lib/plugins/functions/lib/compile/lib/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,21 @@ class Compile {
8484
this.sqz.yaml.parse(functionHook, options)
8585
);
8686

87+
if (this.compileType === 'cloud') {
88+
const treeData = JSON.parse(fs.readFileSync(path.join(projectPath, '.build', 'tree.json')));
89+
_.forEach(treeData.functions[functionObject.name].packages, (obj) => {
90+
const functionPackagesHook = path.join(projectPath, 'lib', 'hooks', 'commands', 'compile', this.compileType, 'package.yml');
91+
92+
compileCmds = _.concat(
93+
compileCmds,
94+
this.sqz.yaml.parse(functionPackagesHook, Object.assign(options, {
95+
pkg : obj.pkg,
96+
version : obj.version
97+
}))
98+
);
99+
});
100+
}
101+
87102
if (!_.isEmpty(compileCmds)) {
88103
this.sqz.cli.log.info(`Compiling function "${colors.blue.bold(functionObject.name)}"`);
89104
}

lib/plugins/run/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PluginRun {
1212
lifecycle : [
1313
'project:validate',
1414
'functions:load',
15+
'compile:run',
1516
'function:run'
1617
],
1718
options : {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- description: Installing package ${pkg}
2+
bin: npm
3+
args:
4+
- 'install'
5+
- '--silent'
6+
- '--prefix'
7+
- '${output}'
8+
- '${pkg}@${version}'

lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/cloud.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
const nodeExternals = require('webpack-node-externals');
2+
13
module.exports = {
24
target: 'node',
5+
externals: [nodeExternals()],
36
module: {
47
loaders: [{
58
test: /\.js$/,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "squeezer-cli",
3-
"version": "1.1.20",
3+
"version": "1.1.22",
44
"preferGlobal": true,
55
"description": "Event-driven APIs & Web apps on functions, serverless ! Squeezer is a framework designed to help developers to get a better architecture on serverless zero-administration compute platforms with code that runs into cloud functions like [AWS Lambda](https://aws.amazon.com/documentation/lambda/) , [Azure Functions](https://azure.microsoft.com/en-us/services/functions/) , [Google Cloud Functions](https://cloud.google.com/functions/docs/) and [IBM OpenWhisk](https://developer.ibm.com/openwhisk/) .",
66
"homepage": "https://squeezer.io/",

0 commit comments

Comments
 (0)