@faable/faable 1.3.2 → 1.3.4

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.
@@ -5,18 +5,34 @@ import { check_environment } from './check_environment.js';
5
5
  import { analyze_package } from './analyze_package.js';
6
6
  import { context } from '../../api/context.js';
7
7
  import { build_project } from './build_project.js';
8
+ import fs from 'fs-extra';
9
+ import path__default from 'path';
8
10
 
11
+ const get_app = async (api, app_slug, workdir) => {
12
+ let slug;
13
+ if (app_slug) {
14
+ slug = app_slug;
15
+ }
16
+ else {
17
+ const packageJSONFile = path__default.join(workdir, "package.json");
18
+ if (!fs.existsSync(packageJSONFile)) {
19
+ throw new Error("Not found package.json");
20
+ }
21
+ const { name } = fs.readJSONSync(packageJSONFile);
22
+ if (!name) {
23
+ throw new Error("Missing name in package.json");
24
+ }
25
+ slug = name;
26
+ }
27
+ return api.getBySlug(slug);
28
+ };
9
29
  const deploy_command = async (args) => {
10
- const app_slug = args.app_slug;
11
30
  const workdir = args.workdir || process.cwd();
12
- if (!app_slug) {
13
- throw new Error("Missing app name");
14
- }
15
- // Check if we can build docker images
16
- await check_environment();
17
31
  // Get registry data from api.faable.com
18
32
  const { api } = await context();
19
- const app = await api.getBySlug(app_slug);
33
+ const app = await get_app(api, args.app_slug, workdir);
34
+ // Check if we can build docker images
35
+ await check_environment();
20
36
  log.info(`🚀 Preparing to build ${app.name} [${app.id}]`);
21
37
  // Analyze package.json to check if build is needed
22
38
  const { build_script } = await analyze_package({ workdir });
@@ -34,6 +50,7 @@ const deploy_command = async (args) => {
34
50
  });
35
51
  // Upload to Faable registry
36
52
  await upload_tag({ app, api, tagname });
53
+ log.info(`🌍 Deployed on https://${app.url}`);
37
54
  };
38
55
 
39
56
  export { deploy_command };
@@ -1,4 +1,3 @@
1
- import fs from 'fs-extra';
2
1
  import { deploy_command } from './deploy_command.js';
3
2
 
4
3
  const deploy = {
@@ -9,10 +8,6 @@ const deploy = {
9
8
  .positional("app_slug", {
10
9
  type: "string",
11
10
  description: "App name to build for",
12
- default: (s) => {
13
- const { name } = fs.readJSONSync("./package.json");
14
- return name;
15
- },
16
11
  })
17
12
  .option("workdir", {
18
13
  alias: "w",
@@ -15,7 +15,6 @@ const upload_tag = async (args) => {
15
15
  // Upload the image to faable registry
16
16
  await cmd("docker", ["push", image_tag]);
17
17
  log.info(`✅ Upload completed.`);
18
- log.info(`🌍 Deployed on ${app.url}`);
19
18
  };
20
19
 
21
20
  export { upload_tag };
package/package.json CHANGED
@@ -26,5 +26,5 @@
26
26
  "access": "public"
27
27
  },
28
28
  "homepage": "https://github.com/faablecloud/faable#readme",
29
- "version": "1.3.2"
29
+ "version": "1.3.4"
30
30
  }