@faable/faable 1.4.4 → 1.4.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.
- package/dist/commands/deploy/deploy_command.js +9 -6
- package/dist/commands/deploy/node-pipeline/index.js +6 -2
- package/dist/commands/deploy/runtime-detect/strategies/docker.js +3 -2
- package/dist/commands/deploy/runtime-detect/strategies/nodejs.js +12 -3
- package/dist/commands/deploy/runtime-detect/strategies/python.js +4 -2
- package/dist/commands/init/ConfigurationHelper.js +1 -1
- package/dist/lib/CredentialsStore.js +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ const deploy_command = async (args) => {
|
|
|
10
10
|
const workdir = args.workdir || process.cwd();
|
|
11
11
|
const { api } = await context();
|
|
12
12
|
// Resolve runtime
|
|
13
|
-
const { app_name, runtime
|
|
13
|
+
const { app_name, runtime } = await runtime_detection(workdir);
|
|
14
14
|
const name = args.app_slug || app_name;
|
|
15
15
|
if (!name) {
|
|
16
16
|
throw new Error("Missing <app_name>");
|
|
@@ -19,20 +19,23 @@ 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
|
|
22
|
+
log.info(`🚀 Deploying ${app.name} (${app.id}) runtime=${runtime.name}-${runtime.version} `);
|
|
23
23
|
let type;
|
|
24
|
-
if (runtime == "node") {
|
|
25
|
-
const node_result = await build_node(app,
|
|
24
|
+
if (runtime.name == "node") {
|
|
25
|
+
const node_result = await build_node(app, {
|
|
26
|
+
workdir,
|
|
27
|
+
runtime,
|
|
28
|
+
});
|
|
26
29
|
type = node_result.type;
|
|
27
30
|
}
|
|
28
|
-
else if (runtime == "docker") {
|
|
31
|
+
else if (runtime.name == "docker") {
|
|
29
32
|
type = "node";
|
|
30
33
|
await cmd(`docker build -t ${app.id} .`, {
|
|
31
34
|
enableOutput: true,
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
else {
|
|
35
|
-
throw new Error(`No build pipeline for runtime=${runtime}`);
|
|
38
|
+
throw new Error(`No build pipeline for runtime=${runtime.name}`);
|
|
36
39
|
}
|
|
37
40
|
// Upload to Faable registry
|
|
38
41
|
const { upload_tagname } = await upload_tag({ app, api });
|
|
@@ -2,8 +2,12 @@ import { bundle_docker } from './bundle_docker.js';
|
|
|
2
2
|
import { analyze_package } from './analyze_package.js';
|
|
3
3
|
import { build_project } from './build_project.js';
|
|
4
4
|
|
|
5
|
-
const build_node = async (app,
|
|
5
|
+
const build_node = async (app, options) => {
|
|
6
6
|
// log.info(`🚀 Build Toolchain ${app.name} [${app.id}]`);
|
|
7
|
+
const { workdir, runtime } = options;
|
|
8
|
+
if (!runtime.version) {
|
|
9
|
+
throw new Error("Runtime version not specified for node");
|
|
10
|
+
}
|
|
7
11
|
// Analyze package.json to check if build is needed
|
|
8
12
|
const { build_script, type } = await analyze_package({ workdir });
|
|
9
13
|
await build_project({ app, build_script });
|
|
@@ -12,7 +16,7 @@ const build_node = async (app, workdir) => {
|
|
|
12
16
|
app,
|
|
13
17
|
workdir,
|
|
14
18
|
template_context: {
|
|
15
|
-
from:
|
|
19
|
+
from: `node:${runtime.version}`,
|
|
16
20
|
},
|
|
17
21
|
});
|
|
18
22
|
return { type };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path__default from 'path';
|
|
3
|
+
import { cmd } from '../../../../lib/cmd.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Strategy to detect app name from package.json
|
|
@@ -10,14 +11,22 @@ import path__default from 'path';
|
|
|
10
11
|
const strategy_nodejs = async (workdir) => {
|
|
11
12
|
const packageJSONFile = path__default.join(workdir, "package.json");
|
|
12
13
|
// Check we have a valid name
|
|
13
|
-
const { name } = fs.readJSONSync(packageJSONFile);
|
|
14
|
+
const { name, engines } = fs.readJSONSync(packageJSONFile);
|
|
14
15
|
if (!name) {
|
|
15
16
|
throw new Error("Missing name in package.json");
|
|
16
17
|
}
|
|
18
|
+
// Use engines.node if found
|
|
19
|
+
let runtime_version = "18.19.0";
|
|
20
|
+
if (engines?.node) {
|
|
21
|
+
const out = await cmd(`npm view node@20.8 version | tail -n 1 | cut -d "'" -f2`);
|
|
22
|
+
runtime_version = out.stdout.toString();
|
|
23
|
+
}
|
|
17
24
|
return {
|
|
18
25
|
app_name: name,
|
|
19
|
-
runtime:
|
|
20
|
-
|
|
26
|
+
runtime: {
|
|
27
|
+
name: "node",
|
|
28
|
+
version: runtime_version,
|
|
29
|
+
},
|
|
21
30
|
};
|
|
22
31
|
};
|
|
23
32
|
|