create-harper 1.6.4 → 1.7.1
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/lib/constants/defaultEnv.js +0 -12
- package/lib/constants/helpMessage.js +1 -3
- package/lib/init.js +1 -1
- package/lib/steps/getEnvVars.js +19 -74
- package/lib/steps/parseArgv.js +0 -4
- package/lib/steps/scaffoldProject.js +0 -2
- package/package.json +1 -1
- package/template-react/_env +0 -2
- package/template-react/_env.example +0 -2
- package/template-react/package.json +1 -3
- package/template-react-ts/_env +0 -2
- package/template-react-ts/_env.example +0 -2
- package/template-react-ts/package.json +1 -3
- package/template-vanilla/_env +0 -2
- package/template-vanilla/_env.example +0 -2
- package/template-vanilla/package.json +1 -3
- package/template-vanilla-ts/_env +0 -2
- package/template-vanilla-ts/_env.example +0 -2
- package/template-vanilla-ts/package.json +1 -3
- package/template-vue/_env +0 -2
- package/template-vue/_env.example +0 -2
- package/template-vue/package.json +1 -3
- package/template-vue-ts/_env +0 -2
- package/template-vue-ts/_env.example +0 -2
- package/template-vue-ts/package.json +1 -3
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default username for the HarperDB cluster.
|
|
3
|
-
* @type {string}
|
|
4
|
-
*/
|
|
5
|
-
export const defaultUsername = 'YOUR_CLUSTER_USERNAME';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Default password for the HarperDB cluster.
|
|
9
|
-
* @type {string}
|
|
10
|
-
*/
|
|
11
|
-
export const defaultPassword = 'YOUR_CLUSTER_PASSWORD';
|
|
12
|
-
|
|
13
1
|
/**
|
|
14
2
|
* Default target URL for the HarperDB cluster.
|
|
15
3
|
* @type {string}
|
|
@@ -27,9 +27,7 @@ All options are optional:
|
|
|
27
27
|
|
|
28
28
|
If you are going to deploy your application to https://fabric.harper.fast/, you can choose to specify your:
|
|
29
29
|
-c, --deploymentURL The https://fabric.harper.fast/ URL where you will host your application
|
|
30
|
-
|
|
31
|
-
The cluster password can be set in interactive mode.
|
|
32
|
-
In non-interactive, remember to update the .env file CLI_TARGET_PASSWORD.
|
|
30
|
+
For authentication, use "harper login" in your project directory.
|
|
33
31
|
|
|
34
32
|
Available templates:
|
|
35
33
|
${yellow('vanilla-ts vanilla')}
|
package/lib/init.js
CHANGED
|
@@ -57,7 +57,7 @@ export async function init() {
|
|
|
57
57
|
const { template } = templateResult;
|
|
58
58
|
|
|
59
59
|
// Get environment variables for .env file
|
|
60
|
-
const envVarsResult = await getEnvVars(interactive, template, args.
|
|
60
|
+
const envVarsResult = await getEnvVars(interactive, template, args.deploymentURL);
|
|
61
61
|
if (envVarsResult.cancelled) { return cancel(); }
|
|
62
62
|
const { envVars } = envVarsResult;
|
|
63
63
|
|
package/lib/steps/getEnvVars.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as prompts from '@clack/prompts';
|
|
2
|
+
import spawn from 'cross-spawn';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import colors from 'picocolors';
|
|
6
|
-
import {
|
|
7
|
+
import { defaultTarget } from '../constants/defaultEnv.js';
|
|
7
8
|
|
|
8
9
|
const {
|
|
9
10
|
gray,
|
|
@@ -12,9 +13,7 @@ const {
|
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @typedef {Object} EnvVars
|
|
15
|
-
* @property {string} [username] - The HarperDB cluster username.
|
|
16
16
|
* @property {string} [target] - The HarperDB cluster URL.
|
|
17
|
-
* @property {string} [password] - The HarperDB cluster password.
|
|
18
17
|
*/
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -22,11 +21,10 @@ const {
|
|
|
22
21
|
*
|
|
23
22
|
* @param {boolean} interactive - Whether the CLI is running in interactive mode.
|
|
24
23
|
* @param {string} template - The selected template name.
|
|
25
|
-
* @param {string} [argDeploymentUsername] - The deployment username specified in the command line args.
|
|
26
24
|
* @param {string} [argDeploymentURL] - The deployment URL specified in the command line args.
|
|
27
25
|
* @returns {Promise<{envVars: EnvVars, cancelled: boolean}>} - The environment variables and cancellation status.
|
|
28
26
|
*/
|
|
29
|
-
export async function getEnvVars(interactive, template,
|
|
27
|
+
export async function getEnvVars(interactive, template, argDeploymentURL) {
|
|
30
28
|
const templateDir = path.resolve(
|
|
31
29
|
fileURLToPath(import.meta.url),
|
|
32
30
|
'..',
|
|
@@ -43,42 +41,14 @@ export async function getEnvVars(interactive, template, argDeploymentUsername, a
|
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
let username = argDeploymentUsername;
|
|
47
44
|
let target = argDeploymentURL;
|
|
48
|
-
let password = '';
|
|
49
45
|
|
|
50
46
|
const prefix = gray('https://') + magenta('fabric.harper.fast') + gray('/') + ' Cluster ';
|
|
51
47
|
|
|
52
48
|
if (interactive) {
|
|
53
|
-
if (!
|
|
54
|
-
prompts.note(
|
|
55
|
-
'Harper apps can be deployed to Fabric for free, where one runtime can house your app, database, cache and messaging.'
|
|
56
|
-
+ '\n\nhttps://fabric.harper.fast/'
|
|
57
|
-
+ '\n\nIf you create a cluster, you can enter your credentials here. They will be saved in a .env file that will be used to "npm run deploy" later.',
|
|
58
|
-
);
|
|
59
|
-
const usernameResult = await prompts.text({
|
|
60
|
-
message: prefix + 'Username (optional):',
|
|
61
|
-
placeholder: defaultUsername,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (prompts.isCancel(usernameResult)) {
|
|
65
|
-
return { envVars: {}, cancelled: true };
|
|
66
|
-
}
|
|
67
|
-
username = usernameResult;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const passwordResult = username && await prompts.password({
|
|
71
|
-
message: prefix + 'Password:',
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
if (prompts.isCancel(passwordResult)) {
|
|
75
|
-
return { envVars: {}, cancelled: true };
|
|
76
|
-
}
|
|
77
|
-
password = passwordResult;
|
|
78
|
-
|
|
79
|
-
if (!target && username) {
|
|
49
|
+
if (!target) {
|
|
80
50
|
const targetResult = await prompts.text({
|
|
81
|
-
message: prefix + 'URL:',
|
|
51
|
+
message: prefix + 'URL (Optional):',
|
|
82
52
|
placeholder: 'YOUR_CLUSTER_URL_HERE',
|
|
83
53
|
});
|
|
84
54
|
|
|
@@ -87,8 +57,6 @@ export async function getEnvVars(interactive, template, argDeploymentUsername, a
|
|
|
87
57
|
}
|
|
88
58
|
target = targetResult;
|
|
89
59
|
}
|
|
90
|
-
} else {
|
|
91
|
-
prompts.log.warn('Non-interactive mode: Please update your .env to add your CLI_TARGET_PASSWORD on your own.');
|
|
92
60
|
}
|
|
93
61
|
|
|
94
62
|
if (target) {
|
|
@@ -109,54 +77,31 @@ export async function getEnvVars(interactive, template, argDeploymentUsername, a
|
|
|
109
77
|
if (!target.endsWith('/')) {
|
|
110
78
|
target = target + '/';
|
|
111
79
|
}
|
|
80
|
+
}
|
|
112
81
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
82
|
+
if (interactive) {
|
|
83
|
+
if (target && target !== defaultTarget) {
|
|
84
|
+
const loginResult = await prompts.confirm({
|
|
85
|
+
message: 'Would you like to login to this cluster now?',
|
|
86
|
+
initialValue: true,
|
|
87
|
+
});
|
|
117
88
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
username && username !== defaultUsername && password && password !== defaultPassword
|
|
122
|
-
) {
|
|
123
|
-
const authResponse = await fetch(`${base}/`, {
|
|
124
|
-
method: 'POST',
|
|
125
|
-
headers: {
|
|
126
|
-
'Content-Type': 'application/json',
|
|
127
|
-
Authorization: `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`,
|
|
128
|
-
},
|
|
129
|
-
body: JSON.stringify({
|
|
130
|
-
operation: 'user_info',
|
|
131
|
-
}),
|
|
132
|
-
});
|
|
89
|
+
if (prompts.isCancel(loginResult)) {
|
|
90
|
+
return { envVars: {}, cancelled: true };
|
|
91
|
+
}
|
|
133
92
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
'Failed to authenticate with your cluster. Please check your credentials in the .env file.',
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
prompts.log.error(
|
|
144
|
-
'Could not reach your cluster health endpoint. Please check your credentials in the .env file.',
|
|
145
|
-
);
|
|
93
|
+
if (loginResult) {
|
|
94
|
+
const loginProcess = spawn.sync('harper', ['login', target], { stdio: 'inherit' });
|
|
95
|
+
if (loginProcess.status !== 0) {
|
|
96
|
+
prompts.log.error('Failed to login to Harper. You can try again later with "harper login".');
|
|
146
97
|
}
|
|
147
|
-
} catch {
|
|
148
|
-
prompts.log.error(
|
|
149
|
-
'An error occurred while connecting to your cluster. Please check your credentials in the .env file.',
|
|
150
|
-
);
|
|
151
98
|
}
|
|
152
99
|
}
|
|
153
100
|
}
|
|
154
101
|
|
|
155
102
|
return {
|
|
156
103
|
envVars: {
|
|
157
|
-
username: username || defaultUsername,
|
|
158
104
|
target: target || defaultTarget,
|
|
159
|
-
password: password || defaultPassword,
|
|
160
105
|
},
|
|
161
106
|
cancelled: false,
|
|
162
107
|
};
|
package/lib/steps/parseArgv.js
CHANGED
|
@@ -15,7 +15,6 @@ export function parseArgv(rawArgv) {
|
|
|
15
15
|
string: [
|
|
16
16
|
'agents',
|
|
17
17
|
'deploymentURL',
|
|
18
|
-
'deploymentUsername',
|
|
19
18
|
'skills',
|
|
20
19
|
'template',
|
|
21
20
|
],
|
|
@@ -23,7 +22,6 @@ export function parseArgv(rawArgv) {
|
|
|
23
22
|
a: 'agents',
|
|
24
23
|
c: 'deploymentURL',
|
|
25
24
|
'deployment-url': 'deploymentURL',
|
|
26
|
-
'deployment-username': 'deploymentUsername',
|
|
27
25
|
h: 'help',
|
|
28
26
|
i: 'immediate',
|
|
29
27
|
o: 'overwrite',
|
|
@@ -31,7 +29,6 @@ export function parseArgv(rawArgv) {
|
|
|
31
29
|
'skip-install': 'skipInstall',
|
|
32
30
|
'skip-skills': 'skipSkills',
|
|
33
31
|
t: 'template',
|
|
34
|
-
u: 'deploymentUsername',
|
|
35
32
|
v: 'version',
|
|
36
33
|
},
|
|
37
34
|
});
|
|
@@ -56,7 +53,6 @@ export function parseArgv(rawArgv) {
|
|
|
56
53
|
return {
|
|
57
54
|
agents: argv.agents,
|
|
58
55
|
deploymentURL: argv.deploymentURL,
|
|
59
|
-
deploymentUsername: argv.deploymentUsername,
|
|
60
56
|
help: argv.help,
|
|
61
57
|
immediate: argv.immediate,
|
|
62
58
|
interactive: argv.interactive ?? process.stdin.isTTY,
|
|
@@ -20,8 +20,6 @@ export function scaffoldProject(root, projectName, packageName, template, envVar
|
|
|
20
20
|
const substitutions = {
|
|
21
21
|
'your-project-name-here': projectName || 'your-project-name-here',
|
|
22
22
|
'your-package-name-here': packageName || 'your-package-name-here',
|
|
23
|
-
'your-cluster-username-here': envVars?.username || 'your-cluster-username-here',
|
|
24
|
-
'your-cluster-password-here': envVars?.password || 'your-cluster-password-here',
|
|
25
23
|
'your-fabric.harper.fast-cluster-url-here': envVars?.target || 'your-fabric.harper.fast-cluster-url-here',
|
|
26
24
|
'\n\t"repository": "github:HarperFast/create-harper",': '',
|
|
27
25
|
};
|
package/package.json
CHANGED
package/template-react/_env
CHANGED
|
@@ -13,15 +13,13 @@
|
|
|
13
13
|
"test": "node --test test/*.test.js",
|
|
14
14
|
"test:watch": "node --watch --test test/*.test.js",
|
|
15
15
|
"build": "vite build",
|
|
16
|
-
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ &&
|
|
17
|
-
"deploy:component": "(cd deploy && harper deploy_component . project=web restart=rolling replicated=true)"
|
|
16
|
+
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ && (cd deploy && harper deploy_component . project=web restart=true replicated=true) && rm -Rf deploy"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"@eslint/js": "^10.0.1",
|
|
21
20
|
"@harperfast/schema-codegen": "^1.0.10",
|
|
22
21
|
"@harperfast/vite-plugin": "^0.2.1",
|
|
23
22
|
"@vitejs/plugin-react": "^6.0.1",
|
|
24
|
-
"dotenv-cli": "^11.0.0",
|
|
25
23
|
"eslint": "^10.0.2",
|
|
26
24
|
"globals": "^17.4.0",
|
|
27
25
|
"prettier": "^3.8.1",
|
package/template-react-ts/_env
CHANGED
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"test": "node --test test/*.test.ts",
|
|
14
14
|
"test:watch": "node --watch --test test/*.test.ts",
|
|
15
15
|
"build": "vite build",
|
|
16
|
-
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ &&
|
|
17
|
-
"deploy:component": "(cd deploy && harper deploy_component . project=web restart=rolling replicated=true)"
|
|
16
|
+
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ && (cd deploy && harper deploy_component . project=web restart=true replicated=true) && rm -Rf deploy"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"@eslint/js": "^10.0.1",
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
"@types/react": "^19.2.10",
|
|
25
24
|
"@types/react-dom": "^19.2.3",
|
|
26
25
|
"@vitejs/plugin-react": "^6.0.1",
|
|
27
|
-
"dotenv-cli": "^11.0.0",
|
|
28
26
|
"eslint": "^10.0.2",
|
|
29
27
|
"globals": "^17.4.0",
|
|
30
28
|
"prettier": "^3.8.1",
|
package/template-vanilla/_env
CHANGED
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
"format": "prettier --write .",
|
|
13
13
|
"test": "node --test test/*.test.js",
|
|
14
14
|
"test:watch": "node --watch --test test/*.test.js",
|
|
15
|
-
"deploy": "
|
|
16
|
-
"deploy:component": "harper deploy_component . restart=rolling replicated=true"
|
|
15
|
+
"deploy": "harper deploy_component . restart=true replicated=true"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@eslint/js": "^10.0.1",
|
|
20
19
|
"@harperfast/schema-codegen": "^1.0.10",
|
|
21
|
-
"dotenv-cli": "^11.0.0",
|
|
22
20
|
"eslint": "^10.0.2",
|
|
23
21
|
"globals": "^17.4.0",
|
|
24
22
|
"prettier": "^3.8.1"
|
package/template-vanilla-ts/_env
CHANGED
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
"format": "prettier --write .",
|
|
13
13
|
"test": "node --test test/*.test.js",
|
|
14
14
|
"test:watch": "node --watch --test test/*.test.js",
|
|
15
|
-
"deploy": "
|
|
16
|
-
"deploy:component": "harper deploy_component . restart=rolling replicated=true"
|
|
15
|
+
"deploy": "harper deploy_component . restart=true replicated=true"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@eslint/js": "^10.0.1",
|
|
20
19
|
"@harperfast/schema-codegen": "^1.0.10",
|
|
21
|
-
"dotenv-cli": "^11.0.0",
|
|
22
20
|
"eslint": "^10.0.2",
|
|
23
21
|
"globals": "^17.4.0",
|
|
24
22
|
"prettier": "^3.8.1"
|
package/template-vue/_env
CHANGED
|
@@ -13,15 +13,13 @@
|
|
|
13
13
|
"test": "node --test test/*.test.js",
|
|
14
14
|
"test:watch": "node --watch --test test/*.test.js",
|
|
15
15
|
"build": "vite build",
|
|
16
|
-
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ &&
|
|
17
|
-
"deploy:component": "(cd deploy && harper deploy_component . project=web restart=rolling replicated=true)"
|
|
16
|
+
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ && (cd deploy && harper deploy_component . project=web restart=true replicated=true) && rm -Rf deploy"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"@eslint/js": "^10.0.1",
|
|
21
20
|
"@harperfast/schema-codegen": "^1.0.10",
|
|
22
21
|
"@harperfast/vite-plugin": "^0.2.1",
|
|
23
22
|
"@vitejs/plugin-vue": "^6.0.5",
|
|
24
|
-
"dotenv-cli": "^11.0.0",
|
|
25
23
|
"eslint": "^10.0.2",
|
|
26
24
|
"globals": "^17.4.0",
|
|
27
25
|
"prettier": "^3.8.1",
|
package/template-vue-ts/_env
CHANGED
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"test": "node --test test/*.test.ts",
|
|
14
14
|
"test:watch": "node --watch --test test/*.test.ts",
|
|
15
15
|
"build": "vite build",
|
|
16
|
-
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ &&
|
|
17
|
-
"deploy:component": "(cd deploy && harper deploy_component . project=web restart=rolling replicated=true)"
|
|
16
|
+
"deploy": "rm -Rf deploy && npm run build && mkdir deploy && mv web deploy/ && cp -R deploy-template/* deploy/ && cp -R schemas resources deploy/ && (cd deploy && harper deploy_component . project=web restart=true replicated=true) && rm -Rf deploy"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"@eslint/js": "^10.0.1",
|
|
@@ -22,7 +21,6 @@
|
|
|
22
21
|
"@harperfast/vite-plugin": "^0.2.1",
|
|
23
22
|
"@types/node": "^24.10.1",
|
|
24
23
|
"@vitejs/plugin-vue": "^6.0.5",
|
|
25
|
-
"dotenv-cli": "^11.0.0",
|
|
26
24
|
"eslint": "^10.0.2",
|
|
27
25
|
"globals": "^17.4.0",
|
|
28
26
|
"prettier": "^3.8.1",
|