@faable/faable 1.5.17 → 1.5.18
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/link/index.js +30 -19
- package/dist/lib/Configuration.js +3 -0
- package/package.json +1 -1
|
@@ -23,10 +23,14 @@ const getGitRemoteUrl = async (workdir) => {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
const link = {
|
|
26
|
-
command: "link",
|
|
26
|
+
command: "link [app_id]",
|
|
27
27
|
describe: "Link the local repository with a Faable app",
|
|
28
28
|
builder: (yargs) => {
|
|
29
29
|
return yargs
|
|
30
|
+
.positional("app_id", {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "app_id to link this repository",
|
|
33
|
+
})
|
|
30
34
|
.option("workdir", {
|
|
31
35
|
alias: "w",
|
|
32
36
|
type: "string",
|
|
@@ -36,9 +40,10 @@ const link = {
|
|
|
36
40
|
},
|
|
37
41
|
handler: async (args) => {
|
|
38
42
|
const workdir = args.workdir || process.cwd();
|
|
43
|
+
const { app_id } = args;
|
|
39
44
|
const config = Configuration.instance();
|
|
40
|
-
if (config.
|
|
41
|
-
log.info(`This repository is already linked to app: ${config.app_slug}`);
|
|
45
|
+
if (config.app_id) {
|
|
46
|
+
log.info(`This repository is already linked to app: "${config.app_slug}" (${config.app_id})`);
|
|
42
47
|
const { relink } = await prompts({
|
|
43
48
|
type: "toggle",
|
|
44
49
|
name: "relink",
|
|
@@ -54,35 +59,41 @@ const link = {
|
|
|
54
59
|
const { api } = await context();
|
|
55
60
|
log.info("Checking local git repository...");
|
|
56
61
|
const gitUrl = await getGitRemoteUrl(workdir);
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
let selectedApp;
|
|
63
|
+
if (!app_id) {
|
|
64
|
+
const apps = await api.list();
|
|
65
|
+
if (apps.length === 0) {
|
|
66
|
+
log.error("No apps found in your account. Create one first at https://faable.com");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
selectedApp = await prompts({
|
|
70
|
+
type: "select",
|
|
71
|
+
name: "selectedApp",
|
|
72
|
+
message: "Select the Faable app to link with this repository:",
|
|
73
|
+
choices: apps.map((app) => ({
|
|
74
|
+
title: `${app.name} (${app.url})`,
|
|
75
|
+
value: app,
|
|
76
|
+
})),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
selectedApp = await api.getApp(app_id);
|
|
61
81
|
}
|
|
62
|
-
const { selectedApp } = await prompts({
|
|
63
|
-
type: "select",
|
|
64
|
-
name: "selectedApp",
|
|
65
|
-
message: "Select the Faable app to link with this repository:",
|
|
66
|
-
choices: apps.map((app) => ({
|
|
67
|
-
title: `${app.name} (${app.url})`,
|
|
68
|
-
value: app,
|
|
69
|
-
})),
|
|
70
|
-
});
|
|
71
82
|
if (!selectedApp) {
|
|
72
83
|
log.info("Link cancelled.");
|
|
73
84
|
return;
|
|
74
85
|
}
|
|
75
|
-
log.info(`Linking to ${selectedApp.name}...`);
|
|
86
|
+
log.info(`Linking to "${selectedApp.name}" (${selectedApp.id})...`);
|
|
76
87
|
// Update the app in the API
|
|
77
88
|
if (gitUrl) {
|
|
78
89
|
await api.updateApp(selectedApp.id, { github_repo: gitUrl });
|
|
79
|
-
log.info(`Updated app
|
|
90
|
+
log.info(`Updated app with github_repo: ${gitUrl}`);
|
|
80
91
|
}
|
|
81
92
|
else {
|
|
82
93
|
log.warn("No git remote URL detected. Skipping API update for github_repo.");
|
|
83
94
|
}
|
|
84
95
|
// Save locally for CLI convenience
|
|
85
|
-
Configuration.instance().saveConfig({ app_slug: selectedApp.name });
|
|
96
|
+
Configuration.instance().saveConfig({ app_slug: selectedApp.name, app_id: selectedApp.id });
|
|
86
97
|
log.info(`Successfully linked local repository to ${selectedApp.name}.`);
|
|
87
98
|
},
|
|
88
99
|
};
|