mercur-cli 0.1.2 → 0.1.5
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/cli/backend-setup.js +9 -13
- package/cli/data.js +121 -0
- package/cli/pull-and-install.js +38 -1
- package/cli/start.js +1 -1
- package/index.js +1 -1
- package/mercur/backend/.env.template +8 -0
- package/mercur/backend/.env.test +0 -0
- package/mercur/backend/.github/dependabot.yml +21 -0
- package/mercur/backend/.github/scripts/wait-for-server-live.sh +29 -0
- package/mercur/backend/.github/workflows/test-cli.yml +222 -0
- package/mercur/backend/.github/workflows/update-preview-deps-ci.yml +69 -0
- package/mercur/backend/.github/workflows/update-preview-deps.yml +67 -0
- package/mercur/backend/.vscode/settings.json +2 -0
- package/mercur/backend/.yarnrc.yml +1 -0
- package/mercur/backend/README.md +62 -0
- package/mercur/backend/instrumentation.ts +24 -0
- package/mercur/backend/integration-tests/http/README.md +29 -0
- package/mercur/backend/integration-tests/http/health.spec.ts +15 -0
- package/mercur/backend/integration-tests/setup.js +3 -0
- package/mercur/backend/jest.config.js +27 -0
- package/mercur/backend/medusa-config.ts +88 -0
- package/mercur/backend/package.json +65 -0
- package/mercur/backend/src/admin/README.md +33 -0
- package/mercur/backend/src/admin/tsconfig.json +24 -0
- package/mercur/backend/src/admin/vite-env.d.ts +1 -0
- package/mercur/backend/src/api/README.md +135 -0
- package/mercur/backend/src/api/admin/custom/route.ts +8 -0
- package/mercur/backend/src/api/store/custom/route.ts +8 -0
- package/mercur/backend/src/jobs/README.md +38 -0
- package/mercur/backend/src/links/README.md +26 -0
- package/mercur/backend/src/modules/README.md +117 -0
- package/mercur/backend/src/scripts/README.md +63 -0
- package/mercur/backend/src/scripts/seed/seed-functions.ts +519 -0
- package/mercur/backend/src/scripts/seed/seed-products.ts +601 -0
- package/mercur/backend/src/scripts/seed.ts +75 -0
- package/mercur/backend/src/subscribers/README.md +61 -0
- package/mercur/backend/src/workflows/README.md +81 -0
- package/mercur/backend/tsconfig.json +35 -0
- package/mercur/backend/yarn.lock +11469 -0
- package/package.json +10 -8
package/cli/backend-setup.js
CHANGED
|
@@ -6,17 +6,10 @@ import ora from "ora";
|
|
|
6
6
|
export async function backendSetup(options) {
|
|
7
7
|
const targetDir = options.directory;
|
|
8
8
|
const spinner = ora("Setting up Mercur backend...").start();
|
|
9
|
-
|
|
10
|
-
await execa("yarn", ["generate:oas"], {
|
|
11
|
-
cwd: path.join(targetDir, "backend/apps/backend"),
|
|
12
|
-
});
|
|
13
|
-
await execa("yarn", ["codegen"], {
|
|
14
|
-
cwd: path.join(targetDir, "backend"),
|
|
15
|
-
});
|
|
16
9
|
const DB_URL = `postgres://${options.db_user}:${options.db_pass}@${options.db_url}:${options.db_port}/${options.db_name}`;
|
|
17
10
|
|
|
18
11
|
await fs.writeFile(
|
|
19
|
-
path.join(targetDir, "backend
|
|
12
|
+
path.join(targetDir, "backend/.env"),
|
|
20
13
|
`STORE_CORS=http://localhost:3000
|
|
21
14
|
ADMIN_CORS=http://localhost:9000
|
|
22
15
|
VENDOR_CORS=http://localhost:5173
|
|
@@ -34,17 +27,20 @@ STRIPE_CONNECTED_ACCOUNTS_WEBHOOK_SECRET=supersecret
|
|
|
34
27
|
|
|
35
28
|
RESEND_API_KEY=supersecret
|
|
36
29
|
RESEND_FROM_EMAIL=onboarding@resend.dev
|
|
30
|
+
|
|
31
|
+
VITE_TALK_JS_APP_ID=xxx
|
|
32
|
+
VITE_TALK_JS_SECRET_API_KEY=xxx
|
|
37
33
|
`
|
|
38
34
|
);
|
|
39
35
|
|
|
40
36
|
spinner.text = "Setting up database...";
|
|
41
37
|
await execa("npx", ["medusa", "db:create", "--db", options.db_name], {
|
|
42
|
-
cwd: path.join(targetDir, "backend
|
|
38
|
+
cwd: path.join(targetDir, "backend"),
|
|
43
39
|
});
|
|
44
40
|
|
|
45
41
|
spinner.text = "Running migrations...";
|
|
46
|
-
await execa("
|
|
47
|
-
cwd: path.join(targetDir, "backend
|
|
42
|
+
await execa("npx", ["medusa", "db:migrate"], {
|
|
43
|
+
cwd: path.join(targetDir, "backend"),
|
|
48
44
|
});
|
|
49
45
|
|
|
50
46
|
spinner.text = "Seeding data...";
|
|
@@ -53,12 +49,12 @@ RESEND_FROM_EMAIL=onboarding@resend.dev
|
|
|
53
49
|
"npx",
|
|
54
50
|
["medusa", "user", "--email", "admin@mercurjs.com", "--password", "admin"],
|
|
55
51
|
{
|
|
56
|
-
cwd: path.join(targetDir, "backend
|
|
52
|
+
cwd: path.join(targetDir, "backend"),
|
|
57
53
|
}
|
|
58
54
|
);
|
|
59
55
|
|
|
60
56
|
const result = await execa("yarn", ["seed"], {
|
|
61
|
-
cwd: path.join(targetDir, "backend
|
|
57
|
+
cwd: path.join(targetDir, "backend"),
|
|
62
58
|
});
|
|
63
59
|
|
|
64
60
|
const pkstart = result.stdout.indexOf("pk_");
|
package/cli/data.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export const b2cMedusaConfigTemplate = `
|
|
2
|
+
import { defineConfig, loadEnv } from '@medusajs/framework/utils'
|
|
3
|
+
|
|
4
|
+
loadEnv(process.env.NODE_ENV || 'development', process.cwd())
|
|
5
|
+
|
|
6
|
+
module.exports = defineConfig({
|
|
7
|
+
projectConfig: {
|
|
8
|
+
databaseUrl: process.env.DATABASE_URL,
|
|
9
|
+
http: {
|
|
10
|
+
storeCors: process.env.STORE_CORS!,
|
|
11
|
+
adminCors: process.env.ADMIN_CORS!,
|
|
12
|
+
// @ts-expect-error: vendorCors is not a valid config
|
|
13
|
+
vendorCors: process.env.VENDOR_CORS!,
|
|
14
|
+
authCors: process.env.AUTH_CORS!,
|
|
15
|
+
jwtSecret: process.env.JWT_SECRET || 'supersecret',
|
|
16
|
+
cookieSecret: process.env.COOKIE_SECRET || 'supersecret'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
plugins: [
|
|
20
|
+
{
|
|
21
|
+
resolve: '@mercurjs/b2c-core',
|
|
22
|
+
options: {}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
resolve: '@mercurjs/commission',
|
|
26
|
+
options: {}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
resolve: '@mercurjs/algolia',
|
|
30
|
+
options: {
|
|
31
|
+
apiKey: process.env.ALGOLIA_API_KEY,
|
|
32
|
+
appId: process.env.ALGOLIA_APP_ID
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
resolve: '@mercurjs/reviews',
|
|
37
|
+
options: {}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
resolve: '@mercurjs/requests',
|
|
41
|
+
options: {}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
resolve: '@mercurjs/resend',
|
|
45
|
+
options: {}
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
modules: [
|
|
49
|
+
{
|
|
50
|
+
resolve: '@medusajs/medusa/payment',
|
|
51
|
+
options: {
|
|
52
|
+
providers: [
|
|
53
|
+
{
|
|
54
|
+
resolve:
|
|
55
|
+
'@mercurjs/payment-stripe-connect/providers/stripe-connect',
|
|
56
|
+
id: 'stripe-connect',
|
|
57
|
+
options: {
|
|
58
|
+
apiKey: process.env.STRIPE_SECRET_API_KEY
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
resolve: '@medusajs/medusa/notification',
|
|
66
|
+
options: {
|
|
67
|
+
providers: [
|
|
68
|
+
{
|
|
69
|
+
resolve: '@mercurjs/resend/providers/resend',
|
|
70
|
+
id: 'resend',
|
|
71
|
+
options: {
|
|
72
|
+
channels: ['email'],
|
|
73
|
+
api_key: process.env.RESEND_API_KEY,
|
|
74
|
+
from: process.env.RESEND_FROM_EMAIL
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
resolve: '@medusajs/medusa/notification-local',
|
|
79
|
+
id: 'local',
|
|
80
|
+
options: {
|
|
81
|
+
channels: ['feed', 'seller_feed']
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
export const b2cDependencies = [
|
|
92
|
+
"@mercurjs/b2c-core",
|
|
93
|
+
"@mercurjs/framework",
|
|
94
|
+
"@mercurjs/commission",
|
|
95
|
+
"@mercurjs/payment-stripe-connect",
|
|
96
|
+
"@mercurjs/resend",
|
|
97
|
+
"@mercurjs/requests",
|
|
98
|
+
"@mercurjs/algolia",
|
|
99
|
+
"@mercurjs/reviews",
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
export async function getSeedScript() {
|
|
103
|
+
const seedScript = await fetch(
|
|
104
|
+
"https://raw.githubusercontent.com/mercurjs/mercur/refs/heads/main/apps/backend/src/scripts/seed.ts"
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const seedFunctions = await fetch(
|
|
108
|
+
"https://raw.githubusercontent.com/mercurjs/mercur/refs/heads/main/apps/backend/src/scripts/seed/seed-functions.ts"
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const seedProducts = await fetch(
|
|
112
|
+
"https://raw.githubusercontent.com/mercurjs/mercur/refs/heads/main/apps/backend/src/scripts/seed/seed-products.ts"
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const seeds = {
|
|
116
|
+
seedScript: await seedScript.text(),
|
|
117
|
+
seedFunctions: await seedFunctions.text(),
|
|
118
|
+
seedProducts: await seedProducts.text(),
|
|
119
|
+
};
|
|
120
|
+
return seeds;
|
|
121
|
+
}
|
package/cli/pull-and-install.js
CHANGED
|
@@ -2,6 +2,11 @@ import { execa } from "execa";
|
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import ora from "ora";
|
|
5
|
+
import {
|
|
6
|
+
b2cDependencies,
|
|
7
|
+
b2cMedusaConfigTemplate,
|
|
8
|
+
getSeedScript,
|
|
9
|
+
} from "./data.js";
|
|
5
10
|
|
|
6
11
|
export async function pullAndInstall(options) {
|
|
7
12
|
const targetDir = path.resolve(process.cwd(), options.directory);
|
|
@@ -12,11 +17,43 @@ export async function pullAndInstall(options) {
|
|
|
12
17
|
spinner.text = "Installing Mercur backend...";
|
|
13
18
|
await execa(
|
|
14
19
|
"git",
|
|
15
|
-
["clone", "https://github.com/
|
|
20
|
+
["clone", "https://github.com/medusajs/medusa-starter-default", "backend"],
|
|
16
21
|
{
|
|
17
22
|
cwd: targetDir,
|
|
18
23
|
}
|
|
19
24
|
);
|
|
25
|
+
|
|
26
|
+
for (const dependency of b2cDependencies) {
|
|
27
|
+
await execa("yarn", ["add", dependency], {
|
|
28
|
+
cwd: path.join(targetDir, "backend"),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await fs.remove(path.join(targetDir, "backend/medusa-config.ts"));
|
|
33
|
+
|
|
34
|
+
await fs.writeFile(
|
|
35
|
+
path.join(targetDir, "backend/medusa-config.ts"),
|
|
36
|
+
b2cMedusaConfigTemplate
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const seedScript = await getSeedScript();
|
|
40
|
+
|
|
41
|
+
await fs.writeFile(
|
|
42
|
+
path.join(targetDir, "backend/src/scripts/seed.ts"),
|
|
43
|
+
seedScript.seedScript
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
await fs.mkdir(path.join(targetDir, "backend/src/scripts/seed"));
|
|
47
|
+
await fs.writeFile(
|
|
48
|
+
path.join(targetDir, "backend/src/scripts/seed/seed-functions.ts"),
|
|
49
|
+
seedScript.seedFunctions
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
await fs.writeFile(
|
|
53
|
+
path.join(targetDir, "backend/src/scripts/seed/seed-products.ts"),
|
|
54
|
+
seedScript.seedProducts
|
|
55
|
+
);
|
|
56
|
+
|
|
20
57
|
await execa("yarn", ["install"], { cwd: path.join(targetDir, "backend") });
|
|
21
58
|
|
|
22
59
|
if (options.install_storefront) {
|
package/cli/start.js
CHANGED
|
@@ -20,7 +20,7 @@ export async function startAll() {
|
|
|
20
20
|
|
|
21
21
|
spinner.text = "Starting Mercur backend...";
|
|
22
22
|
const backend = execa("yarn", ["dev"], {
|
|
23
|
-
cwd: path.join(process.cwd(), "backend
|
|
23
|
+
cwd: path.join(process.cwd(), "backend"),
|
|
24
24
|
});
|
|
25
25
|
servicesToRun.push(backend);
|
|
26
26
|
|
package/index.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
STORE_CORS=http://localhost:8000,https://docs.medusajs.com
|
|
2
|
+
ADMIN_CORS=http://localhost:5173,http://localhost:9000,https://docs.medusajs.com
|
|
3
|
+
AUTH_CORS=http://localhost:5173,http://localhost:9000,https://docs.medusajs.com
|
|
4
|
+
REDIS_URL=redis://localhost:6379
|
|
5
|
+
JWT_SECRET=supersecret
|
|
6
|
+
COOKIE_SECRET=supersecret
|
|
7
|
+
DATABASE_URL=
|
|
8
|
+
DB_NAME=merctestcli
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "npm"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "daily"
|
|
7
|
+
allow:
|
|
8
|
+
- dependency-type: production
|
|
9
|
+
groups:
|
|
10
|
+
medusa:
|
|
11
|
+
patterns:
|
|
12
|
+
- "@medusajs*"
|
|
13
|
+
- "medusa*"
|
|
14
|
+
update-types:
|
|
15
|
+
- "minor"
|
|
16
|
+
- "patch"
|
|
17
|
+
ignore:
|
|
18
|
+
- dependency-name: "@medusajs*"
|
|
19
|
+
update-types: ["version-update:semver-major"]
|
|
20
|
+
- dependency-name: "medusa*"
|
|
21
|
+
update-types: ["version-update:semver-major"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
for i in {1..6}
|
|
4
|
+
do
|
|
5
|
+
echo $i
|
|
6
|
+
status_code=$(curl \
|
|
7
|
+
-X GET \
|
|
8
|
+
--write-out %{http_code} \
|
|
9
|
+
--silent\
|
|
10
|
+
--output /dev/null\
|
|
11
|
+
http://localhost:9000/store/products)
|
|
12
|
+
|
|
13
|
+
echo $status_code
|
|
14
|
+
if [[ "$status_code" -ne 000 ]] ; then
|
|
15
|
+
echo "exiting"
|
|
16
|
+
exit 0
|
|
17
|
+
else
|
|
18
|
+
sleep 5
|
|
19
|
+
fi
|
|
20
|
+
done
|
|
21
|
+
|
|
22
|
+
echo $status_code
|
|
23
|
+
|
|
24
|
+
if [[ "$status_code" = 000 ]] ; then
|
|
25
|
+
echo "Site status changed to $status_code"
|
|
26
|
+
exit 1
|
|
27
|
+
else
|
|
28
|
+
exit 0
|
|
29
|
+
fi
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
name: Test CLI
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
branches:
|
|
5
|
+
- 'master'
|
|
6
|
+
- 'ci'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test-cli-yarn:
|
|
10
|
+
name: "Test CLI (Yarn)"
|
|
11
|
+
env:
|
|
12
|
+
NODE_ENV: CI
|
|
13
|
+
REDIS_URL: redis://localhost:6379
|
|
14
|
+
DATABASE_URL: "postgres://postgres:postgres@localhost/cli-test"
|
|
15
|
+
POSTGRES_URL: "postgres://postgres:postgres@localhost/cli-test"
|
|
16
|
+
services:
|
|
17
|
+
redis:
|
|
18
|
+
image: redis
|
|
19
|
+
options: >-
|
|
20
|
+
--health-cmd "redis-cli ping"
|
|
21
|
+
--health-interval 10s
|
|
22
|
+
--health-timeout 5s
|
|
23
|
+
--health-retries 5
|
|
24
|
+
ports:
|
|
25
|
+
- 6379:6379
|
|
26
|
+
|
|
27
|
+
postgres:
|
|
28
|
+
image: postgres
|
|
29
|
+
env:
|
|
30
|
+
POSTGRES_PASSWORD: postgres
|
|
31
|
+
POSTGRES_USER: postgres
|
|
32
|
+
POSTGRES_DB: cli-test
|
|
33
|
+
options: >-
|
|
34
|
+
--health-cmd pg_isready
|
|
35
|
+
--health-interval 10s
|
|
36
|
+
--health-timeout 5s
|
|
37
|
+
--health-retries 5
|
|
38
|
+
ports:
|
|
39
|
+
- 5432:5432
|
|
40
|
+
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- name: Checkout
|
|
44
|
+
uses: actions/checkout@v3
|
|
45
|
+
with:
|
|
46
|
+
fetch-depth: 0
|
|
47
|
+
|
|
48
|
+
- name: Cancel Previous Runs
|
|
49
|
+
uses: styfle/cancel-workflow-action@0.11.0
|
|
50
|
+
with:
|
|
51
|
+
access_token: ${{ github.token }}
|
|
52
|
+
|
|
53
|
+
- name: Setup Node.js environment
|
|
54
|
+
uses: actions/setup-node@v3
|
|
55
|
+
with:
|
|
56
|
+
node-version: 20
|
|
57
|
+
|
|
58
|
+
- name: Install Dependencies
|
|
59
|
+
run: yarn install
|
|
60
|
+
|
|
61
|
+
- name: Check CLI tool is installed
|
|
62
|
+
run: ./node_modules/.bin/medusa -v
|
|
63
|
+
|
|
64
|
+
- name: run build
|
|
65
|
+
run: yarn build
|
|
66
|
+
|
|
67
|
+
- name: Run migrations
|
|
68
|
+
run: npx medusa db:migrate
|
|
69
|
+
|
|
70
|
+
- name: Run seed
|
|
71
|
+
run: yarn seed
|
|
72
|
+
|
|
73
|
+
- name: Run development server
|
|
74
|
+
run: yarn dev &
|
|
75
|
+
|
|
76
|
+
- name: Wait for live server response
|
|
77
|
+
shell: "bash"
|
|
78
|
+
run: ./.github/scripts/wait-for-server-live.sh
|
|
79
|
+
|
|
80
|
+
- name: Kill server
|
|
81
|
+
shell: "bash"
|
|
82
|
+
run: kill -9 $(lsof -t -i :9000)
|
|
83
|
+
|
|
84
|
+
test-cli-npm:
|
|
85
|
+
name: "Test CLI (npm)"
|
|
86
|
+
env:
|
|
87
|
+
NODE_ENV: CI
|
|
88
|
+
REDIS_URL: redis://localhost:6379
|
|
89
|
+
DATABASE_URL: "postgres://postgres:postgres@localhost/cli-test"
|
|
90
|
+
POSTGRES_URL: "postgres://postgres:postgres@localhost/cli-test"
|
|
91
|
+
services:
|
|
92
|
+
postgres:
|
|
93
|
+
image: postgres
|
|
94
|
+
env:
|
|
95
|
+
POSTGRES_PASSWORD: postgres
|
|
96
|
+
POSTGRES_USER: postgres
|
|
97
|
+
POSTGRES_DB: cli-test
|
|
98
|
+
options: >-
|
|
99
|
+
--health-cmd pg_isready
|
|
100
|
+
--health-interval 10s
|
|
101
|
+
--health-timeout 5s
|
|
102
|
+
--health-retries 5
|
|
103
|
+
ports:
|
|
104
|
+
- 5432:5432
|
|
105
|
+
|
|
106
|
+
runs-on: ubuntu-latest
|
|
107
|
+
steps:
|
|
108
|
+
- name: Checkout
|
|
109
|
+
uses: actions/checkout@v3
|
|
110
|
+
with:
|
|
111
|
+
fetch-depth: 0
|
|
112
|
+
|
|
113
|
+
- name: Cancel Previous Runs
|
|
114
|
+
uses: styfle/cancel-workflow-action@0.11.0
|
|
115
|
+
with:
|
|
116
|
+
access_token: ${{ github.token }}
|
|
117
|
+
|
|
118
|
+
- name: Setup Node.js environment
|
|
119
|
+
uses: actions/setup-node@v3
|
|
120
|
+
with:
|
|
121
|
+
node-version: 20
|
|
122
|
+
cache: "npm"
|
|
123
|
+
|
|
124
|
+
- name: Install Dependencies
|
|
125
|
+
run: npm install
|
|
126
|
+
|
|
127
|
+
- name: Check CLI tool is installed
|
|
128
|
+
run: ./node_modules/.bin/medusa -v
|
|
129
|
+
|
|
130
|
+
- name: run medusa build
|
|
131
|
+
run: npm run build
|
|
132
|
+
|
|
133
|
+
- name: Run migrations
|
|
134
|
+
run: npx medusa db:migrate
|
|
135
|
+
|
|
136
|
+
- name: Run seed
|
|
137
|
+
run: npm run seed
|
|
138
|
+
|
|
139
|
+
- name: Run development server
|
|
140
|
+
run: npm run dev -- &
|
|
141
|
+
|
|
142
|
+
- name: Wait for live server response
|
|
143
|
+
shell: "bash"
|
|
144
|
+
run: ./.github/scripts/wait-for-server-live.sh
|
|
145
|
+
|
|
146
|
+
- name: Kill server
|
|
147
|
+
shell: "bash"
|
|
148
|
+
run: kill -9 $(lsof -t -i :9000)
|
|
149
|
+
|
|
150
|
+
test-cli-pnpm:
|
|
151
|
+
name: "Test CLI (pnpm)"
|
|
152
|
+
env:
|
|
153
|
+
NODE_ENV: CI
|
|
154
|
+
REDIS_URL: redis://localhost:6379
|
|
155
|
+
DATABASE_URL: "postgres://postgres:postgres@localhost/cli-test"
|
|
156
|
+
POSTGRES_URL: "postgres://postgres:postgres@localhost/cli-test"
|
|
157
|
+
services:
|
|
158
|
+
postgres:
|
|
159
|
+
image: postgres
|
|
160
|
+
env:
|
|
161
|
+
POSTGRES_PASSWORD: postgres
|
|
162
|
+
POSTGRES_USER: postgres
|
|
163
|
+
POSTGRES_DB: cli-test
|
|
164
|
+
options: >-
|
|
165
|
+
--health-cmd pg_isready
|
|
166
|
+
--health-interval 10s
|
|
167
|
+
--health-timeout 5s
|
|
168
|
+
--health-retries 5
|
|
169
|
+
ports:
|
|
170
|
+
- 5432:5432
|
|
171
|
+
|
|
172
|
+
runs-on: ubuntu-latest
|
|
173
|
+
steps:
|
|
174
|
+
- name: Checkout
|
|
175
|
+
uses: actions/checkout@v3
|
|
176
|
+
with:
|
|
177
|
+
fetch-depth: 0
|
|
178
|
+
|
|
179
|
+
- name: Cancel Previous Runs
|
|
180
|
+
uses: styfle/cancel-workflow-action@0.11.0
|
|
181
|
+
with:
|
|
182
|
+
access_token: ${{ github.token }}
|
|
183
|
+
|
|
184
|
+
- name: Create pnpm-lock.yaml
|
|
185
|
+
run: touch pnpm-lock.yaml
|
|
186
|
+
|
|
187
|
+
- uses: pnpm/action-setup@v2
|
|
188
|
+
with:
|
|
189
|
+
version: 9
|
|
190
|
+
|
|
191
|
+
- name: Setup Node.js environment
|
|
192
|
+
uses: actions/setup-node@v3
|
|
193
|
+
with:
|
|
194
|
+
node-version: 20
|
|
195
|
+
cache: "pnpm"
|
|
196
|
+
|
|
197
|
+
- name: Install Dependencies
|
|
198
|
+
run: pnpm install
|
|
199
|
+
|
|
200
|
+
- name: Check CLI tool is installed
|
|
201
|
+
run: ./node_modules/.bin/medusa -v
|
|
202
|
+
|
|
203
|
+
- name: run medusa build
|
|
204
|
+
run: pnpm run build
|
|
205
|
+
|
|
206
|
+
- name: Run migrations
|
|
207
|
+
run: npx medusa db:migrate
|
|
208
|
+
|
|
209
|
+
- name: Run seed
|
|
210
|
+
run: pnpm run seed
|
|
211
|
+
|
|
212
|
+
- name: Run development server
|
|
213
|
+
run: pnpm run dev -- &
|
|
214
|
+
|
|
215
|
+
- name: Wait for live server response
|
|
216
|
+
shell: "bash"
|
|
217
|
+
run: ./.github/scripts/wait-for-server-live.sh
|
|
218
|
+
|
|
219
|
+
- name: Kill server
|
|
220
|
+
shell: "bash"
|
|
221
|
+
run: kill -9 $(lsof -t -i :9000)
|
|
222
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: "Update Preview Dependencies (feat/ci)"
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
update:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- name: Cancel Previous Runs
|
|
10
|
+
uses: styfle/cancel-workflow-action@0.9.1
|
|
11
|
+
with:
|
|
12
|
+
access_token: ${{ github.token }}
|
|
13
|
+
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v2.3.5
|
|
16
|
+
with:
|
|
17
|
+
ref: 'ci'
|
|
18
|
+
|
|
19
|
+
- name: Setup Node.js 20
|
|
20
|
+
uses: actions/setup-node@v3
|
|
21
|
+
with:
|
|
22
|
+
node-version: 20
|
|
23
|
+
|
|
24
|
+
- name: Remove yarn.lock
|
|
25
|
+
run: rm yarn.lock
|
|
26
|
+
|
|
27
|
+
- name: Install Dependencies
|
|
28
|
+
run: yarn
|
|
29
|
+
|
|
30
|
+
- name: Close Previous PRs
|
|
31
|
+
shell: "bash"
|
|
32
|
+
run: |
|
|
33
|
+
|
|
34
|
+
PR_LIST=$(gh pr list --base ci --json number,headRefName)
|
|
35
|
+
|
|
36
|
+
# Filter out PRs where headRefName starts with 'chore/update-preview'
|
|
37
|
+
FILTERED_PR_LIST=$(echo "$PR_LIST" | jq '[.[] | select(.headRefName | test("^chore/update-preview"))]')
|
|
38
|
+
|
|
39
|
+
echo "$FILTERED_PR_LIST"
|
|
40
|
+
|
|
41
|
+
# Check if any pull requests were found after filtering
|
|
42
|
+
if [ -z "$FILTERED_PR_LIST" ] || [ "$FILTERED_PR_LIST" = "[]" ]; then
|
|
43
|
+
echo "No pull requests found on branch ci after filtering"
|
|
44
|
+
exit 0
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
# Close each filtered pull request
|
|
48
|
+
echo "$FILTERED_PR_LIST" | jq -r '.[].number' | while read -r PR_NUMBER; do
|
|
49
|
+
echo "Closing pull request #$PR_NUMBER"
|
|
50
|
+
gh pr close "$PR_NUMBER" -d
|
|
51
|
+
done
|
|
52
|
+
env:
|
|
53
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
54
|
+
OWNER: ${{ github.repository_owner }}
|
|
55
|
+
REPO: ${{ github.event.repository.name }}
|
|
56
|
+
|
|
57
|
+
- name: Open PR with changes
|
|
58
|
+
uses: peter-evans/create-pull-request@v5
|
|
59
|
+
with:
|
|
60
|
+
title: "chore(ci): updated preview dependencies [automated]"
|
|
61
|
+
commit-message: "chore(ci): updated preview dependencies [automated]"
|
|
62
|
+
body: "This PR updates preview dependencies to the latest versions."
|
|
63
|
+
branch: "chore/update-preview"
|
|
64
|
+
branch-suffix: "timestamp"
|
|
65
|
+
token: ${{ secrets.PAT_TOKEN }}
|
|
66
|
+
base: "ci"
|
|
67
|
+
add-paths: yarn.lock
|
|
68
|
+
committer: "GitHub <noreply@github.com>"
|
|
69
|
+
author: "GitHub <github-actions[bot]@users.noreply.github.com>"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: "Update Preview Dependencies (master)"
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
update:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- name: Cancel Previous Runs
|
|
10
|
+
uses: styfle/cancel-workflow-action@0.9.1
|
|
11
|
+
with:
|
|
12
|
+
access_token: ${{ github.token }}
|
|
13
|
+
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v2.3.5
|
|
16
|
+
|
|
17
|
+
- name: Setup Node.js 20
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: 20
|
|
21
|
+
|
|
22
|
+
- name: Remove yarn.lock
|
|
23
|
+
run: rm yarn.lock
|
|
24
|
+
|
|
25
|
+
- name: Install Dependencies
|
|
26
|
+
run: yarn
|
|
27
|
+
|
|
28
|
+
- name: Close Previous PRs
|
|
29
|
+
shell: "bash"
|
|
30
|
+
run: |
|
|
31
|
+
|
|
32
|
+
PR_LIST=$(gh pr list --base master --json number,headRefName)
|
|
33
|
+
|
|
34
|
+
# Filter out PRs where headRefName starts with 'chore/update-preview'
|
|
35
|
+
FILTERED_PR_LIST=$(echo "$PR_LIST" | jq '[.[] | select(.headRefName | test("^chore/update-preview"))]')
|
|
36
|
+
|
|
37
|
+
echo "$FILTERED_PR_LIST"
|
|
38
|
+
|
|
39
|
+
# Check if any pull requests were found after filtering
|
|
40
|
+
if [ -z "$FILTERED_PR_LIST" ] || [ "$FILTERED_PR_LIST" = "[]" ]; then
|
|
41
|
+
echo "No pull requests found on branch master after filtering"
|
|
42
|
+
exit 0
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# Close each filtered pull request
|
|
46
|
+
echo "$FILTERED_PR_LIST" | jq -r '.[].number' | while read -r PR_NUMBER; do
|
|
47
|
+
echo "Closing pull request #$PR_NUMBER"
|
|
48
|
+
gh pr close "$PR_NUMBER" -d
|
|
49
|
+
done
|
|
50
|
+
env:
|
|
51
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
52
|
+
OWNER: ${{ github.repository_owner }}
|
|
53
|
+
REPO: ${{ github.event.repository.name }}
|
|
54
|
+
|
|
55
|
+
- name: Open PR with changes
|
|
56
|
+
uses: peter-evans/create-pull-request@v5
|
|
57
|
+
with:
|
|
58
|
+
title: "chore(master): updated preview dependencies [automated]"
|
|
59
|
+
body: "This PR updates preview dependencies to the latest versions."
|
|
60
|
+
commit-message: "chore(master): updated preview dependencies [automated]"
|
|
61
|
+
branch: "chore/update-preview"
|
|
62
|
+
branch-suffix: "timestamp"
|
|
63
|
+
token: ${{ secrets.PAT_TOKEN }}
|
|
64
|
+
base: "master"
|
|
65
|
+
add-paths: yarn.lock
|
|
66
|
+
committer: "GitHub <noreply@github.com>"
|
|
67
|
+
author: "GitHub <github-actions[bot]@users.noreply.github.com>"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodeLinker: node-modules
|