@terros-inc/cli 1.0.1 → 1.0.3
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/auth.js +12 -1
- package/dist/crud/index.js +5 -1
- package/package.json +1 -1
package/dist/commands/auth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { signInToAuth0 } from "../auth/auth0.js";
|
|
2
|
-
import { saveTokens } from "../auth/tokens.js";
|
|
2
|
+
import { getTokens, saveTokens } from "../auth/tokens.js";
|
|
3
3
|
export const authCommands = {
|
|
4
4
|
login: {
|
|
5
5
|
description: 'Sign in to Terros',
|
|
@@ -9,4 +9,15 @@ export const authCommands = {
|
|
|
9
9
|
console.log('Signed in successfully');
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
|
+
token: {
|
|
13
|
+
description: 'Get Terros API Token',
|
|
14
|
+
async run() {
|
|
15
|
+
const tokens = await getTokens();
|
|
16
|
+
if (tokens === null) {
|
|
17
|
+
console.error('CLI not authorized. Run \`terros auth login\` to authenticate.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
console.log(tokens.access_token);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
12
23
|
};
|
package/dist/crud/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
2
4
|
import { parse } from 'yaml';
|
|
3
5
|
import { getPathParts } from "./util.js";
|
|
4
6
|
import { getEndpointParameters } from "./parameters.js";
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
5
9
|
export function loadEndpoints() {
|
|
6
|
-
const file = readFileSync('
|
|
10
|
+
const file = readFileSync(resolve(__dirname, '../../terros.yml'), 'utf-8');
|
|
7
11
|
const data = parse(file);
|
|
8
12
|
const entries = Object.entries(data.paths);
|
|
9
13
|
const endpoints = {};
|