@faable/faable 1.5.4 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ function handleError(message) {
24
24
  };
25
25
  };
26
26
  }
27
- const paginate = async (res) => {
27
+ const firstPage = async (res) => {
28
28
  const items = (await res).results;
29
29
  return items;
30
30
  };
@@ -41,7 +41,7 @@ class FaableApi {
41
41
  return new FaableApi(config);
42
42
  }
43
43
  async list() {
44
- return paginate(data(this.client.get(`/app`)));
44
+ return firstPage(data(this.client.get(`/app`)));
45
45
  }
46
46
  async getBySlug(slug) {
47
47
  return data(this.client.get(`/app/slug/${slug}`));
@@ -52,6 +52,9 @@ class FaableApi {
52
52
  async createDeployment(params) {
53
53
  return data(this.client.post(`/deployment`, params));
54
54
  }
55
+ async getAppSecrets(app_id) {
56
+ return firstPage(data(this.client.get(`/secret/${app_id}`)));
57
+ }
55
58
  }
56
59
  __decorate([
57
60
  handleError()
@@ -65,5 +68,8 @@ __decorate([
65
68
  __decorate([
66
69
  handleError()
67
70
  ], FaableApi.prototype, "createDeployment", null);
71
+ __decorate([
72
+ handleError()
73
+ ], FaableApi.prototype, "getAppSecrets", null);
68
74
 
69
75
  export { FaableApi };
@@ -19,12 +19,15 @@ const deploy_command = async (args) => {
19
19
  const app = await api.getBySlug(name);
20
20
  // Check if we can build docker images
21
21
  await check_environment();
22
- log.info(`🚀 Deploying ${app.name} (${app.id}) runtime=${runtime.name}-${runtime.version} `);
22
+ log.info(`🚀 Deploying ${app.name} (${app.id}) runtime=${runtime.name}-${runtime.version}`);
23
+ // get environment variables
24
+ const env_vars = await api.getAppSecrets(app.id);
23
25
  let type;
24
26
  if (runtime.name == "node") {
25
27
  const node_result = await build_node(app, {
26
28
  workdir,
27
29
  runtime,
30
+ env_vars,
28
31
  });
29
32
  type = node_result.type;
30
33
  }
@@ -24,7 +24,7 @@ Handlebars.registerHelper("escape", function (variable) {
24
24
  // Docker template file
25
25
  const docker_template = Handlebars.compile(dockerfile);
26
26
  const entrypoint_template = Handlebars.compile(entrypoint);
27
- const bundle_docker = async (props) => {
27
+ const build_docker = async (props) => {
28
28
  const { app, workdir, template_context } = props;
29
29
  const entrypoint_custom = entrypoint_template(template_context);
30
30
  const start_command = Configuration.instance().startCommand;
@@ -45,4 +45,4 @@ const bundle_docker = async (props) => {
45
45
  await cmd(`docker build -t ${app.id} ${workdir} -f -<<EOF\n${dockerfile}\nEOF`, { timeout, enableOutput: true });
46
46
  };
47
47
 
48
- export { bundle_docker };
48
+ export { build_docker };
@@ -1,18 +1,24 @@
1
- import { bundle_docker } from './bundle_docker.js';
1
+ import { build_docker } from './build_docker.js';
2
2
  import { analyze_package } from './analyze_package.js';
3
3
  import { build_project } from './build_project.js';
4
+ import * as R from 'ramda';
5
+ import { log } from '../../../log.js';
4
6
 
5
7
  const build_node = async (app, options) => {
6
8
  // log.info(`🚀 Build Toolchain ${app.name} [${app.id}]`);
7
- const { workdir, runtime } = options;
9
+ const { workdir, runtime, env_vars } = options;
8
10
  if (!runtime.version) {
9
11
  throw new Error("Runtime version not specified for node");
10
12
  }
11
13
  // Analyze package.json to check if build is needed
12
14
  const { build_script, type } = await analyze_package({ workdir });
13
- await build_project({ build_script });
15
+ // Environment variables
16
+ const env = R.fromPairs(env_vars.map((e) => [e.name, e.value]));
17
+ log.info(`Building with env variables ${Object.keys(env).join(",")}`);
18
+ // Do build
19
+ await build_project({ build_script});
14
20
  // Bundle project inside a docker image
15
- await bundle_docker({
21
+ await build_docker({
16
22
  app,
17
23
  workdir,
18
24
  template_context: {
@@ -22,7 +22,7 @@ const strategy_nodejs = async (workdir) => {
22
22
  try {
23
23
  const check_cmd = `npm view node@"${engines.node}" version | tail -n 1 | cut -d "'" -f2`;
24
24
  const out = await cmd(check_cmd);
25
- runtime_version = out.stdout.toString();
25
+ runtime_version = out.stdout.toString().trim();
26
26
  log.info(`Using node@${runtime_version} from engines in package.json (${engines.node})`);
27
27
  }
28
28
  catch (e) {
package/dist/lib/cmd.js CHANGED
@@ -10,6 +10,7 @@ const cmd = async (cmd, config) => {
10
10
  stdio: enableOutput ? "inherit" : "pipe",
11
11
  timeout,
12
12
  cwd,
13
+ env: config.env,
13
14
  });
14
15
  const out_data = [];
15
16
  child.stderr?.on("data", (data) => {
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "yaml": "^2.8.2",
15
15
  "yargs": "^18.0.0"
16
16
  },
17
- "version": "1.5.4",
17
+ "version": "1.5.6",
18
18
  "bin": {
19
19
  "faable": "bin/faable.js"
20
20
  },