@faable/faable 1.5.32 → 1.5.33
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.
|
@@ -29,6 +29,10 @@ const deploy = {
|
|
|
29
29
|
const workdir = args.workdir || process.cwd();
|
|
30
30
|
const ctx = await context();
|
|
31
31
|
const { api } = ctx;
|
|
32
|
+
if (!api) {
|
|
33
|
+
log.error("❌ Not logged in. Run 'faable login' first.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
32
36
|
// Resolve runtime
|
|
33
37
|
const { runtime } = await runtime_detection(workdir);
|
|
34
38
|
// app_id resolution (the user never has to look one up):
|
|
@@ -61,6 +61,10 @@ const link = {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
const { api } = await context();
|
|
64
|
+
if (!api) {
|
|
65
|
+
log.error("❌ Not logged in. Run 'faable login' first.");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
64
68
|
log.info("Checking local git repository...");
|
|
65
69
|
const gitUrl = await getGitRemoteUrl(workdir);
|
|
66
70
|
const apps = await api.list();
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import { log } from '../../log.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getMe } from '../../api/auth.js';
|
|
3
|
+
import { CredentialsStore } from '../../lib/CredentialsStore.js';
|
|
3
4
|
|
|
4
5
|
const whoami = {
|
|
5
6
|
command: "whoami",
|
|
6
7
|
describe: "Display the current logged in user",
|
|
7
8
|
handler: async () => {
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const store = new CredentialsStore();
|
|
10
|
+
const config = await store.loadCredentials();
|
|
11
|
+
// Bearer token from the environment (CI) or a local `faable login`.
|
|
12
|
+
const token = process.env.FAABLE_TOKEN || config?.token;
|
|
13
|
+
if (!token) {
|
|
14
|
+
// API-key sessions can't be introspected at the auth server's /me; fall
|
|
15
|
+
// back to the email captured at login time.
|
|
16
|
+
if (config?.apikey && config.email) {
|
|
17
|
+
log.info(`Logged in as: ${config.email} (API key)`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
10
20
|
log.error("❌ Not logged in. Run 'faable login' first.");
|
|
11
21
|
process.exit(1);
|
|
12
22
|
}
|
|
13
23
|
try {
|
|
14
|
-
|
|
24
|
+
// Validate against the Auth server (it issued the token); the deploy API
|
|
25
|
+
// has no /me route.
|
|
26
|
+
const me = await getMe(token);
|
|
15
27
|
log.info(`Logged in as: ${me.email}`);
|
|
16
28
|
}
|
|
17
29
|
catch {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
2
|
import { hideBin } from 'yargs/helpers';
|
|
3
3
|
import { deploy } from './commands/deploy/index.js';
|
|
4
|
-
import { init } from './commands/init/index.js';
|
|
5
4
|
import { link } from './commands/link/index.js';
|
|
6
5
|
import { login } from './commands/login/index.js';
|
|
7
6
|
import { logout } from './commands/logout/index.js';
|
|
@@ -34,7 +33,6 @@ yg.scriptName('faable')
|
|
|
34
33
|
.command(login)
|
|
35
34
|
.command(logout)
|
|
36
35
|
.command(whoami)
|
|
37
|
-
.command(init)
|
|
38
36
|
.command(link)
|
|
39
37
|
.demandCommand(1)
|
|
40
38
|
.help()
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
import { CredentialsStore } from '../../lib/CredentialsStore.js';
|
|
3
|
-
|
|
4
|
-
const init = {
|
|
5
|
-
command: 'init',
|
|
6
|
-
describe: 'Initialize Faable with API Key',
|
|
7
|
-
builder: yargs => {
|
|
8
|
-
return yargs.showHelpOnFail(false);
|
|
9
|
-
},
|
|
10
|
-
handler: async () => {
|
|
11
|
-
const store = new CredentialsStore();
|
|
12
|
-
const creds = await store.loadCredentials();
|
|
13
|
-
if (creds?.apikey) {
|
|
14
|
-
const { overwrite } = await prompts({
|
|
15
|
-
type: 'confirm',
|
|
16
|
-
name: 'overwrite',
|
|
17
|
-
message: 'An API key already exists. Do you want to overwrite it?',
|
|
18
|
-
initial: false
|
|
19
|
-
});
|
|
20
|
-
if (!overwrite) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const { apikey } = await prompts([
|
|
25
|
-
{
|
|
26
|
-
type: 'text',
|
|
27
|
-
name: 'apikey',
|
|
28
|
-
message: 'What is your Faable ApiKey?'
|
|
29
|
-
}
|
|
30
|
-
]);
|
|
31
|
-
await store.saveCredentials({ apikey });
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export { init };
|