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

Commit bb5eba0

Browse files
authored
Merge pull request #59 from SqueezerIO/nickfix
Nickfix
2 parents 11c846c + 32d8f49 commit bb5eba0

14 files changed

Lines changed: 80 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v1.1.24 - 2018-01-25
2+
- disabled functions compiling when changing "squeezer.yml" vars on local development
3+
- added yarn to install the functions packages
4+
5+
## v1.1.22 - 2017-12-18
6+
- fixed packages parsing issue
7+
18
## v1.1.22 - 2017-12-16
29
- fixed major dependencies parsing bugs
310
## v1.1.21 - 2017-12-02

docs/development/function.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Any function can be trigger by a specific event .
99
`FUNCTION/squeezer.yml`
1010

1111
```yaml
12+
name: hello
13+
1214
event:
1315
type: http
1416
path: /rest/v1/hello

lib/common/checksums/lib/deps.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ class Deps {
4747
this.packages = JSON.parse(fs.readFileSync(path.join(this.sqz.vars.project.path, 'package.json'))).dependencies;
4848
}
4949

50+
const formattedVal = val.split('/')[0];
51+
5052
packages.push({
51-
pkg : val,
52-
version : this.packages[val]
53+
pkg : formattedVal,
54+
version : this.packages[formattedVal]
5355
});
5456
}
5557
});

lib/common/functions/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ class Functions {
88
this.sqz = sqz;
99
}
1010

11-
add(functionName, functionPath, functionService) {
11+
add(functionPath, functionService) {
1212
const options = this.sqz.cli.params.get().options;
1313
const configFilePath = path.join(functionPath, 'squeezer.yml');
1414
const functionObject = this.sqz.yaml.parse(configFilePath);
15+
const functionName = functionObject.name;
1516
const functionIdentifier = this.sqz.utils.getIdentifier(functionName);
1617
const functionOpt = options.function || null;
1718

1819
let flagged = true;
1920
let force = false;
2021

22+
if (!functionName) {
23+
this.sqz.cli.log.error(`Missing function name on ${configFilePath}`);
24+
}
25+
2126
if (functionOpt && functionName !== functionOpt) {
2227
flagged = false;
2328
}

lib/plugins/compile/hooks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
- identifier : 'compile:run'
22
path : 'lib/compile'
33
function : 'run'
4+
- identifier : 'compile:vars'
5+
path : 'lib/compile'
6+
function : 'vars'

lib/plugins/compile/lib/compile.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ class Compile {
4343
});
4444
}
4545

46+
vars() {
47+
return new Promise((resolve) => {
48+
this.buildMainVars('local', 'development').then((mainVars) => {
49+
this.buildFunctionsVars(mainVars);
50+
resolve();
51+
});
52+
});
53+
}
54+
4655
buildMainVars(stage, compileType) {
4756
return new Promise((resolve) => {
4857
const projectVars = this.sqz.vars.project.vars;

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

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class Compile {
6363
compileFunction(functionObject) {
6464
return new Promise((resolve) => {
6565
const projectPath = path.normalize(this.sqz.vars.project.path);
66+
const projectRuntime = this.sqz.vars.project.runtime;
6667
const source = path.join(functionObject.path, 'src');
6768
const output = path.join(projectPath, '.build', this.compileType, 'functions', functionObject.identifier);
6869

@@ -86,17 +87,26 @@ class Compile {
8687

8788
if (this.compileType === 'cloud') {
8889
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-
});
90+
91+
if (projectRuntime === 'nodejs') {
92+
const packagesData = {
93+
license : 'UNLICENSED',
94+
dependencies : {}
95+
};
96+
97+
_.forEach(treeData.functions[functionObject.name].packages, (obj) => {
98+
packagesData.dependencies[obj.pkg] = obj.version;
99+
});
100+
101+
fs.writeFileSync(path.join(output, 'package.json'), JSON.stringify(packagesData, null, 2));
102+
}
103+
104+
const functionPackagesHook = path.join(projectPath, 'lib', 'hooks', 'commands', 'compile', this.compileType, 'package.yml');
105+
106+
compileCmds = _.concat(
107+
compileCmds,
108+
this.sqz.yaml.parse(functionPackagesHook, options)
109+
);
100110
}
101111

102112
if (!_.isEmpty(compileCmds)) {

lib/plugins/functions/lib/load/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class loadFunctions {
2929
const walkService = (service) => {
3030
const servicePath = path.join(projectPath, 'services', service);
3131

32-
fs.readdirSync(servicePath).forEach((functionName) => {
33-
const functionPath = path.join(servicePath, functionName);
34-
this.sqz.functions.add(functionName, functionPath, service);
32+
fs.readdirSync(servicePath).forEach((functionDir) => {
33+
const functionPath = path.join(servicePath, functionDir);
34+
this.sqz.functions.add(functionPath, service);
3535
});
3636
};
3737

lib/plugins/templates/lib/samples/api-nodejs/data/services/my-service/hello/squeezer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: hello
2+
13
event:
24
type: http
35
path: /rest/v1/hello/*

lib/plugins/templates/lib/samples/api-nodejs/data/services/my-service/hello/src/handler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

33
import event from 'squeezer-event-node';
4-
import vars from './.vars';
4+
import fs from 'fs';
5+
6+
const vars = JSON.parse(fs.readFileSync('.vars.json', 'utf8'));
57

68
exports.handler = (...args) => event(vars, (req, res) => {
79
res.json(200, {

0 commit comments

Comments
 (0)