@faable/faable 1.4.0 → 1.4.1

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/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,13 +1,24 @@
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
7
  config;
7
8
  constructor() {
8
- const config_file = path__default.join(process.cwd(), "faable.json");
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() {
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "yaml": "^2.2.2",
15
15
  "yargs": "^17.6.2"
16
16
  },
17
- "version": "1.4.0",
17
+ "version": "1.4.1",
18
18
  "bin": {
19
19
  "faable": "bin/faable.js"
20
20
  },