mercur-cli 0.1.7 → 0.1.9
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/.github/dependabot.yml +11 -0
- 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 +42 -37
- package/index.js +20 -16
- package/package.json +5 -12
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
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
|
@@ -1,104 +1,109 @@
|
|
|
1
|
-
import { execa } from
|
|
2
|
-
import fs from
|
|
3
|
-
import path from
|
|
4
|
-
import ora from
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import ora from 'ora';
|
|
5
5
|
import {
|
|
6
6
|
b2cDependencies,
|
|
7
7
|
b2cMedusaConfigTemplate,
|
|
8
8
|
getSeedScript,
|
|
9
|
-
} from
|
|
9
|
+
} from './data.js';
|
|
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
|
-
const spinner = ora(
|
|
15
|
+
const spinner = ora('Setting up Mercur...').start();
|
|
15
16
|
await fs.ensureDir(targetDir);
|
|
16
17
|
|
|
17
|
-
spinner.text =
|
|
18
|
+
spinner.text = 'Installing Mercur backend...';
|
|
18
19
|
await execa(
|
|
19
|
-
|
|
20
|
-
[
|
|
20
|
+
'git',
|
|
21
|
+
['clone', 'https://github.com/mercurjs/clean-medusa-starter', 'backend'],
|
|
21
22
|
{
|
|
22
23
|
cwd: targetDir,
|
|
23
24
|
}
|
|
24
25
|
);
|
|
25
26
|
|
|
26
|
-
for (
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
for (let dependency of b2cDependencies) {
|
|
28
|
+
if (mercurVersion !== 'latest') {
|
|
29
|
+
dependency = `${dependency}@${mercurVersion}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await execa('yarn', ['add', dependency], {
|
|
33
|
+
cwd: path.join(targetDir, 'backend'),
|
|
29
34
|
});
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
await fs.remove(path.join(targetDir,
|
|
37
|
+
await fs.remove(path.join(targetDir, 'backend/medusa-config.ts'));
|
|
33
38
|
|
|
34
39
|
await fs.writeFile(
|
|
35
|
-
path.join(targetDir,
|
|
40
|
+
path.join(targetDir, 'backend/medusa-config.ts'),
|
|
36
41
|
b2cMedusaConfigTemplate
|
|
37
42
|
);
|
|
38
43
|
|
|
39
44
|
const seedScript = await getSeedScript();
|
|
40
45
|
|
|
41
46
|
await fs.writeFile(
|
|
42
|
-
path.join(targetDir,
|
|
47
|
+
path.join(targetDir, 'backend/src/scripts/seed.ts'),
|
|
43
48
|
seedScript.seedScript
|
|
44
49
|
);
|
|
45
50
|
|
|
46
|
-
await fs.mkdir(path.join(targetDir,
|
|
51
|
+
await fs.mkdir(path.join(targetDir, 'backend/src/scripts/seed'));
|
|
47
52
|
await fs.writeFile(
|
|
48
|
-
path.join(targetDir,
|
|
53
|
+
path.join(targetDir, 'backend/src/scripts/seed/seed-functions.ts'),
|
|
49
54
|
seedScript.seedFunctions
|
|
50
55
|
);
|
|
51
56
|
|
|
52
57
|
await fs.writeFile(
|
|
53
|
-
path.join(targetDir,
|
|
58
|
+
path.join(targetDir, 'backend/src/scripts/seed/seed-products.ts'),
|
|
54
59
|
seedScript.seedProducts
|
|
55
60
|
);
|
|
56
61
|
|
|
57
|
-
await execa(
|
|
62
|
+
await execa('yarn', ['install'], { cwd: path.join(targetDir, 'backend') });
|
|
58
63
|
|
|
59
|
-
spinner.text =
|
|
64
|
+
spinner.text = 'Installing Mercur admin panel...';
|
|
60
65
|
await execa(
|
|
61
|
-
|
|
62
|
-
[
|
|
66
|
+
'git',
|
|
67
|
+
['clone', 'https://github.com/mercurjs/admin-panel.git', 'admin-panel'],
|
|
63
68
|
{
|
|
64
69
|
cwd: targetDir,
|
|
65
70
|
}
|
|
66
71
|
);
|
|
67
|
-
await execa(
|
|
68
|
-
cwd: path.join(targetDir,
|
|
72
|
+
await execa('yarn', ['install'], {
|
|
73
|
+
cwd: path.join(targetDir, 'admin-panel'),
|
|
69
74
|
});
|
|
70
75
|
|
|
71
76
|
if (options.install_storefront) {
|
|
72
|
-
spinner.text =
|
|
77
|
+
spinner.text = 'Installing Mercur storefront...';
|
|
73
78
|
await execa(
|
|
74
|
-
|
|
79
|
+
'git',
|
|
75
80
|
[
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
'clone',
|
|
82
|
+
'https://github.com/mercurjs/b2c-marketplace-storefront.git',
|
|
83
|
+
'storefront',
|
|
79
84
|
],
|
|
80
85
|
{
|
|
81
86
|
cwd: targetDir,
|
|
82
87
|
}
|
|
83
88
|
);
|
|
84
|
-
await execa(
|
|
85
|
-
cwd: path.join(targetDir,
|
|
89
|
+
await execa('yarn', ['install'], {
|
|
90
|
+
cwd: path.join(targetDir, 'storefront'),
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
if (options.install_vendor) {
|
|
90
|
-
spinner.text =
|
|
95
|
+
spinner.text = 'Installing Mercur vendor panel...';
|
|
91
96
|
await execa(
|
|
92
|
-
|
|
93
|
-
[
|
|
97
|
+
'git',
|
|
98
|
+
['clone', 'https://github.com/mercurjs/vendor-panel.git', 'vendor-panel'],
|
|
94
99
|
{
|
|
95
100
|
cwd: targetDir,
|
|
96
101
|
}
|
|
97
102
|
);
|
|
98
|
-
await execa(
|
|
99
|
-
cwd: path.join(targetDir,
|
|
103
|
+
await execa('yarn', ['install'], {
|
|
104
|
+
cwd: path.join(targetDir, 'vendor-panel'),
|
|
100
105
|
});
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
spinner.succeed(
|
|
108
|
+
spinner.succeed('Download complete!');
|
|
104
109
|
}
|
package/index.js
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import chalk from
|
|
4
|
-
import { program } from
|
|
5
|
-
import { fullInstall } from
|
|
6
|
-
import { startAll } from
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { program } from 'commander';
|
|
5
|
+
import { fullInstall } from './cli/full-install.js';
|
|
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(`
|
|
10
11
|
╔═══════════════════════════════════════════════╗
|
|
11
12
|
║ ║
|
|
12
|
-
║ ${chalk.bold(
|
|
13
|
+
║ ${chalk.bold('Mercur - Open Source Marketplace Platform')} ║
|
|
13
14
|
║ ║
|
|
15
|
+
║ ${chalk.bold('CLI Version:')} 0.1.9 ║
|
|
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
|
-
.command(
|
|
25
|
-
.version(
|
|
26
|
-
.description(
|
|
21
|
+
.command('install')
|
|
22
|
+
.version('1.1.0')
|
|
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
|
|
30
|
-
.command(
|
|
31
|
-
.version(
|
|
32
|
-
.description(
|
|
28
|
+
.command('dev')
|
|
29
|
+
.version('1.0.0')
|
|
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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mercur-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "CLI for Mercur - Open Source Marketplace Platform",
|
|
5
5
|
"author": "MercurJS <hello@mercurjs.com> (https://mercurjs.com)",
|
|
6
6
|
"repository": {
|
|
@@ -21,19 +21,12 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"scripts": {},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"chalk": "^
|
|
25
|
-
"commander": "^
|
|
24
|
+
"chalk": "^5.6.2",
|
|
25
|
+
"commander": "^14.0.3",
|
|
26
26
|
"execa": "^9.5.2",
|
|
27
27
|
"fs-extra": "^11.2.0",
|
|
28
|
-
"inquirer": "^
|
|
29
|
-
"ora": "^
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/fs-extra": "^11.0.4",
|
|
33
|
-
"@types/inquirer": "^8.2.10",
|
|
34
|
-
"@types/node": "^20.11.0",
|
|
35
|
-
"tsup": "^8.0.2",
|
|
36
|
-
"typescript": "^5.3.3"
|
|
28
|
+
"inquirer": "^13.2.2",
|
|
29
|
+
"ora": "^9.1.0"
|
|
37
30
|
},
|
|
38
31
|
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
|
|
39
32
|
}
|