@faable/faable 1.4.0 → 1.4.2
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.
|
@@ -27,10 +27,12 @@ const entrypoint_template = Handlebars.compile(entrypoint);
|
|
|
27
27
|
const bundle_docker = async (props) => {
|
|
28
28
|
const { app, workdir, template_context } = props;
|
|
29
29
|
const entrypoint_custom = entrypoint_template(template_context);
|
|
30
|
+
const start_command = Configuration.instance().startCommand;
|
|
31
|
+
log.info(`⚙️ Start command: ${start_command}`);
|
|
30
32
|
const dockerfile = docker_template({
|
|
31
33
|
from: template_context.from,
|
|
32
34
|
entry_script: entrypoint_custom,
|
|
33
|
-
start_command
|
|
35
|
+
start_command,
|
|
34
36
|
});
|
|
35
37
|
log.info(`📦 Packaging inside a docker image`);
|
|
36
38
|
// Build options
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,27 @@ import { deploy } from './commands/deploy/index.js';
|
|
|
6
6
|
import { log } from './log.js';
|
|
7
7
|
import { init } from './commands/init/index.js';
|
|
8
8
|
import { version } from './config.js';
|
|
9
|
+
import { Configuration } from './lib/Configuration.js';
|
|
9
10
|
|
|
10
11
|
const yg = yargs();
|
|
11
12
|
yg.scriptName("faable")
|
|
12
13
|
.middleware(function (argv) {
|
|
13
14
|
console.log(`Faable CLI ${version}`);
|
|
15
|
+
}, true)
|
|
16
|
+
.option("c", {
|
|
17
|
+
alias: "config",
|
|
18
|
+
description: "Path to the local `faable.json` file",
|
|
19
|
+
string: true,
|
|
20
|
+
})
|
|
21
|
+
.middleware(function (argv) {
|
|
22
|
+
if (argv.config) {
|
|
23
|
+
Configuration.instance().setConfigFile(argv.config, {
|
|
24
|
+
ignoreWarnings: false,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
Configuration.instance();
|
|
29
|
+
}
|
|
14
30
|
}, true)
|
|
15
31
|
.command(deploy)
|
|
16
32
|
.command(apps)
|
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
import path__default from 'path';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
|
+
import { log } from '../log.js';
|
|
3
4
|
|
|
4
5
|
class Configuration {
|
|
5
6
|
static _instance;
|
|
6
|
-
config;
|
|
7
|
+
config = {};
|
|
7
8
|
constructor() {
|
|
8
|
-
|
|
9
|
+
// Try to read default config file
|
|
10
|
+
this.setConfigFile("faable.json", { ignoreWarnings: true });
|
|
11
|
+
}
|
|
12
|
+
setConfigFile(file, options) {
|
|
13
|
+
const config_file = path__default.join(process.cwd(), file);
|
|
9
14
|
if (fs.existsSync(config_file)) {
|
|
10
15
|
this.config = fs.readJSONSync(config_file);
|
|
16
|
+
log.info(`Loaded configuration from: ${file}`);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
if (!options.ignoreWarnings) {
|
|
20
|
+
log.warn(`Cannot read Faable config file ${file}`);
|
|
21
|
+
}
|
|
11
22
|
}
|
|
12
23
|
}
|
|
13
24
|
static instance() {
|
|
14
|
-
if (Configuration._instance) {
|
|
15
|
-
|
|
25
|
+
if (!Configuration._instance) {
|
|
26
|
+
Configuration._instance = new Configuration();
|
|
16
27
|
}
|
|
17
|
-
return
|
|
28
|
+
return Configuration._instance;
|
|
18
29
|
}
|
|
19
30
|
get startCommand() {
|
|
20
|
-
return this.config
|
|
31
|
+
return this.config.startCommand || "npm run start";
|
|
21
32
|
}
|
|
22
33
|
get buildCommand() {
|
|
23
|
-
return this.config
|
|
34
|
+
return this.config.buildCommand;
|
|
24
35
|
}
|
|
25
36
|
}
|
|
26
37
|
|