mercur-cli 0.1.7 → 0.1.8
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/README.md +11 -0
- package/cli/full-install.js +17 -1
- package/cli/mercur-versions.js +28 -0
- package/cli/pull-and-install.js +6 -1
- package/index.js +9 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,6 +76,16 @@ mercur-cli dev
|
|
|
76
76
|
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
## Options
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Specify backend version to be installed
|
|
83
|
+
mercur-cli install --mercur-version <version>
|
|
84
|
+
|
|
85
|
+
# List available backend versions
|
|
86
|
+
mercur-cli versions
|
|
87
|
+
```
|
|
88
|
+
|
|
79
89
|
|
|
80
90
|
|
|
81
91
|
## Prerequisites
|
|
@@ -83,6 +93,7 @@ mercur-cli dev
|
|
|
83
93
|
- Node.js v20+
|
|
84
94
|
- PostgreSQL
|
|
85
95
|
- Git CLI
|
|
96
|
+
- Yarn
|
|
86
97
|
|
|
87
98
|
# Resources
|
|
88
99
|
|
package/cli/full-install.js
CHANGED
|
@@ -7,8 +7,23 @@ import {
|
|
|
7
7
|
vendorPanelSetup,
|
|
8
8
|
adminPanelSetup,
|
|
9
9
|
} from "./frontend-setup.js";
|
|
10
|
+
import { getMercurVersions } from "./mercur-versions.js";
|
|
11
|
+
|
|
12
|
+
export async function fullInstall(options) {
|
|
13
|
+
const availableVersions = await getMercurVersions();
|
|
14
|
+
const providedVersion = options.mercurVersion;
|
|
15
|
+
|
|
16
|
+
if (
|
|
17
|
+
providedVersion !== "latest" &&
|
|
18
|
+
!availableVersions.includes(providedVersion)
|
|
19
|
+
) {
|
|
20
|
+
console.error(chalk.red(`Invalid Mercur version: ${providedVersion}`));
|
|
21
|
+
console.log(
|
|
22
|
+
`Available versions: ${availableVersions.reverse().join(", ")}`
|
|
23
|
+
);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
10
26
|
|
|
11
|
-
export async function fullInstall() {
|
|
12
27
|
const { project_name } = await inquirer.prompt({
|
|
13
28
|
type: "input",
|
|
14
29
|
name: "project_name",
|
|
@@ -70,6 +85,7 @@ export async function fullInstall() {
|
|
|
70
85
|
directory: project_name,
|
|
71
86
|
install_storefront,
|
|
72
87
|
install_vendor,
|
|
88
|
+
mercur_version: providedVersion,
|
|
73
89
|
});
|
|
74
90
|
console.log(chalk.blue("Setting up Mercur"));
|
|
75
91
|
const publishableKey = await backendSetup({
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
|
|
5
|
+
export async function getMercurVersions() {
|
|
6
|
+
const result = await execa("yarn", ["info", "@mercurjs/framework", "--json"]);
|
|
7
|
+
const data = JSON.parse(result.stdout);
|
|
8
|
+
return data.data.versions;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function displayMercurVersions() {
|
|
12
|
+
const spinner = ora("Getting Mercur versions...").start();
|
|
13
|
+
const versions = await getMercurVersions();
|
|
14
|
+
spinner.stop();
|
|
15
|
+
console.log(`Available Mercur backend versions:`);
|
|
16
|
+
|
|
17
|
+
console.log(
|
|
18
|
+
versions
|
|
19
|
+
.reverse()
|
|
20
|
+
.map(
|
|
21
|
+
(version, index) =>
|
|
22
|
+
`${
|
|
23
|
+
index == 0 ? chalk.bold.greenBright(version) : chalk.gray(version)
|
|
24
|
+
}`
|
|
25
|
+
)
|
|
26
|
+
.join(", ")
|
|
27
|
+
);
|
|
28
|
+
}
|
package/cli/pull-and-install.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
export async function pullAndInstall(options) {
|
|
12
12
|
const targetDir = path.resolve(process.cwd(), options.directory);
|
|
13
|
+
const mercurVersion = options.mercur_version;
|
|
13
14
|
|
|
14
15
|
const spinner = ora("Setting up Mercur...").start();
|
|
15
16
|
await fs.ensureDir(targetDir);
|
|
@@ -23,7 +24,11 @@ export async function pullAndInstall(options) {
|
|
|
23
24
|
}
|
|
24
25
|
);
|
|
25
26
|
|
|
26
|
-
for (
|
|
27
|
+
for (let dependency of b2cDependencies) {
|
|
28
|
+
if (mercurVersion !== "latest") {
|
|
29
|
+
dependency = `${dependency}@${mercurVersion}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
await execa("yarn", ["add", dependency], {
|
|
28
33
|
cwd: path.join(targetDir, "backend"),
|
|
29
34
|
});
|
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import chalk from "chalk";
|
|
|
4
4
|
import { program } from "commander";
|
|
5
5
|
import { fullInstall } from "./cli/full-install.js";
|
|
6
6
|
import { startAll } from "./cli/start.js";
|
|
7
|
+
import { displayMercurVersions } from "./cli/mercur-versions.js";
|
|
7
8
|
|
|
8
9
|
console.log(
|
|
9
10
|
chalk.blue(`
|
|
@@ -11,19 +12,16 @@ console.log(
|
|
|
11
12
|
║ ║
|
|
12
13
|
║ ${chalk.bold("Mercur - Open Source Marketplace Platform")} ║
|
|
13
14
|
║ ║
|
|
15
|
+
║ ${chalk.bold("CLI Version:")} 0.1.8 ║
|
|
14
16
|
╚═══════════════════════════════════════════════╝
|
|
15
17
|
`)
|
|
16
18
|
);
|
|
17
19
|
|
|
18
|
-
program.option("-v, --version", "Show version").action(() => {
|
|
19
|
-
console.log(chalk.blue(`Mercur CLI v0.1.7`));
|
|
20
|
-
process.exit(0);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
20
|
program
|
|
24
21
|
.command("install")
|
|
25
22
|
.version("1.1.0")
|
|
26
23
|
.description("Perform full installation of Mercur")
|
|
24
|
+
.option("-mv, --mercur-version <mercur_version>", "Mercur version", "latest")
|
|
27
25
|
.action(fullInstall);
|
|
28
26
|
|
|
29
27
|
program
|
|
@@ -32,4 +30,10 @@ program
|
|
|
32
30
|
.description("Start all Mercur components")
|
|
33
31
|
.action(startAll);
|
|
34
32
|
|
|
33
|
+
program
|
|
34
|
+
.command("versions")
|
|
35
|
+
.version("1.0.0")
|
|
36
|
+
.description("Show versions")
|
|
37
|
+
.action(displayMercurVersions);
|
|
38
|
+
|
|
35
39
|
program.parse(process.argv);
|