@quantum-hub/qhubctl 1.10.0 → 1.12.0
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/init.js
CHANGED
|
@@ -7,34 +7,13 @@ import { cloneRepository } from '../lib/repository.js';
|
|
|
7
7
|
import { error, stdout } from '../lib/output.js';
|
|
8
8
|
import { Runtime } from '../model/managed-service-config.js';
|
|
9
9
|
import { writeServiceConfig } from '../service/service-config-service.js';
|
|
10
|
-
import { getUserConfig } from '../model/command.js';
|
|
11
|
-
/**
|
|
12
|
-
* Environment variable name for providing a personal access token.
|
|
13
|
-
* This can be used as an alternative to the `login` command for CI/CD scenarios.
|
|
14
|
-
*/
|
|
15
|
-
const ENV_PERSONAL_ACCESS_TOKEN = 'KQH_PERSONAL_ACCESS_TOKEN';
|
|
16
|
-
/**
|
|
17
|
-
* Gets the API key with the following priority:
|
|
18
|
-
* 1. CLI parameter (if provided)
|
|
19
|
-
* 2. KQH_PERSONAL_ACCESS_TOKEN environment variable
|
|
20
|
-
* 3. Stored config (from `login` command)
|
|
21
|
-
*/
|
|
22
|
-
function getApiKey(tokenParam) {
|
|
23
|
-
if (tokenParam) {
|
|
24
|
-
return tokenParam;
|
|
25
|
-
}
|
|
26
|
-
const userConfig = getUserConfig();
|
|
27
|
-
return process.env[ENV_PERSONAL_ACCESS_TOKEN] ?? userConfig.auth?.value;
|
|
28
|
-
}
|
|
29
10
|
const EXAMPLES = `
|
|
30
11
|
Examples:
|
|
31
12
|
$ qhubctl init
|
|
32
|
-
$ qhubctl init --
|
|
33
|
-
$ qhubctl init --non-interactive --token <personal access token>`;
|
|
13
|
+
$ qhubctl init --non-interactive`;
|
|
34
14
|
export const initCommand = new Command('init')
|
|
35
15
|
.description('Bootstrap project to create a service.')
|
|
36
16
|
.option('--name <value>', 'The name of the service')
|
|
37
|
-
.option('-t, --token <value>', 'Personal access token for authentication')
|
|
38
17
|
.option('--non-interactive', 'Run it in non-interactive mode', false)
|
|
39
18
|
.addHelpText('after', EXAMPLES)
|
|
40
19
|
.action(async (opts) => {
|
|
@@ -73,11 +52,7 @@ export const initCommand = new Command('init')
|
|
|
73
52
|
}
|
|
74
53
|
writeServiceConfig(targetDirectory, serviceConfig);
|
|
75
54
|
if (input.starter) {
|
|
76
|
-
|
|
77
|
-
if (!apiKey) {
|
|
78
|
-
error(`Starter templates require authentication. Provide a token via --token, use the "login" command, or set the ${ENV_PERSONAL_ACCESS_TOKEN} environment variable.`);
|
|
79
|
-
}
|
|
80
|
-
await cloneRepository(input.starter.url, targetDirectory, apiKey);
|
|
55
|
+
await cloneRepository(input.starter.url, targetDirectory);
|
|
81
56
|
}
|
|
82
57
|
stdout('\u{1F389} Initialized project. Happy hacking!');
|
|
83
58
|
if (input.starter) {
|
|
@@ -30,6 +30,13 @@ export const promptUserInput = async (defaultName) => {
|
|
|
30
30
|
runtime: Runtime.DOCKER,
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Service Demo Starter (full-stack example with frontend accessing a service)',
|
|
35
|
+
value: {
|
|
36
|
+
url: 'https://repository.hub.kipu-quantum.com/cec4a31d-5856-4387-b4cf-718345803558/qhub-starter-service-demo.git',
|
|
37
|
+
runtime: Runtime.DOCKER,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
33
40
|
{ name: 'None (creates "qhub.json" in current directory)', value: undefined },
|
|
34
41
|
],
|
|
35
42
|
default: DEFAULT_STARTER,
|
package/dist/lib/repository.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Clones a git repository (shallow, depth=1) into targetDirectory and removes
|
|
3
3
|
* the .git metadata afterwards, leaving only the working-tree files.
|
|
4
|
-
*
|
|
5
|
-
* Authentication uses HTTP Basic Auth with username "qhubctl" and the provided
|
|
6
|
-
* API key as the password.
|
|
7
4
|
*/
|
|
8
|
-
export declare const cloneRepository: (url: string, targetDirectory: string
|
|
5
|
+
export declare const cloneRepository: (url: string, targetDirectory: string) => Promise<void>;
|
package/dist/lib/repository.js
CHANGED
|
@@ -5,12 +5,8 @@ import nodeFs from 'node:fs';
|
|
|
5
5
|
/**
|
|
6
6
|
* Clones a git repository (shallow, depth=1) into targetDirectory and removes
|
|
7
7
|
* the .git metadata afterwards, leaving only the working-tree files.
|
|
8
|
-
*
|
|
9
|
-
* Authentication uses HTTP Basic Auth with username "qhubctl" and the provided
|
|
10
|
-
* API key as the password.
|
|
11
8
|
*/
|
|
12
|
-
export const cloneRepository = async (url, targetDirectory
|
|
13
|
-
const credentials = Buffer.from(`qhubctl:${apiKey}`).toString('base64');
|
|
9
|
+
export const cloneRepository = async (url, targetDirectory) => {
|
|
14
10
|
try {
|
|
15
11
|
await git.clone({
|
|
16
12
|
fs: nodeFs,
|
|
@@ -19,14 +15,11 @@ export const cloneRepository = async (url, targetDirectory, apiKey) => {
|
|
|
19
15
|
url,
|
|
20
16
|
depth: 1,
|
|
21
17
|
singleBranch: true,
|
|
22
|
-
// Inject Authorization on every request so the proxy doesn't need to
|
|
23
|
-
// issue a 401 challenge first (onAuth is only triggered after a 401).
|
|
24
|
-
headers: { 'Authorization': `Basic ${credentials}` },
|
|
25
18
|
});
|
|
26
19
|
}
|
|
27
20
|
catch (error) {
|
|
28
21
|
console.error(error);
|
|
29
|
-
throw new Error('Failed to download starter template.
|
|
22
|
+
throw new Error('Failed to download starter template.');
|
|
30
23
|
}
|
|
31
24
|
// Remove git metadata so the project directory is a clean working tree
|
|
32
25
|
await fs.remove(`${targetDirectory}/.git`);
|