@jarwizz/create-jarshop 0.1.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/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/generator.d.ts +16 -0
- package/dist/generator.js +198 -0
- package/dist/generator.js.map +1 -0
- package/dist/template/AGENTS.md +41 -0
- package/dist/template/CONTEXT.md +37 -0
- package/dist/template/MEMORY.md +16 -0
- package/dist/template/README.md +63 -0
- package/dist/template/docker-compose.yml +14 -0
- package/dist/template/env.example.template +14 -0
- package/dist/template/gitignore.template +10 -0
- package/dist/template/package.json +46 -0
- package/dist/template/pnpm-lock.yaml +12852 -0
- package/dist/template/pnpm-workspace.yaml +24 -0
- package/dist/template/src/dev.ts +154 -0
- package/dist/template/src/environment.d.ts +19 -0
- package/dist/template/src/index-worker.ts +9 -0
- package/dist/template/src/index.ts +7 -0
- package/dist/template/src/migrations/1786024108433-initial.ts +2677 -0
- package/dist/template/src/seed.ts +138 -0
- package/dist/template/src/vendure-config.ts +75 -0
- package/dist/template/static/email/templates/email-address-change/body.hbs +20 -0
- package/dist/template/static/email/templates/email-verification/body.hbs +20 -0
- package/dist/template/static/email/templates/order-confirmation/body.hbs +133 -0
- package/dist/template/static/email/templates/partials/footer.hbs +10 -0
- package/dist/template/static/email/templates/partials/header.hbs +18 -0
- package/dist/template/static/email/templates/password-reset/body.hbs +24 -0
- package/dist/template/storefront/README.md +8 -0
- package/dist/template/storefront/app/[locale]/[slug]/page.tsx +52 -0
- package/dist/template/storefront/app/[locale]/page.tsx +35 -0
- package/dist/template/storefront/app/globals.css +16 -0
- package/dist/template/storefront/eslint.config.mjs +9 -0
- package/dist/template/storefront/lib/commerce.ts +35 -0
- package/dist/template/storefront/next-env.d.ts +6 -0
- package/dist/template/storefront/next.config.ts +14 -0
- package/dist/template/storefront/package.json +32 -0
- package/dist/template/storefront/pnpm-lock.yaml +3562 -0
- package/dist/template/storefront/pnpm-workspace.yaml +26 -0
- package/dist/template/storefront/tsconfig.json +30 -0
- package/dist/template/tsconfig.dashboard.json +4 -0
- package/dist/template/tsconfig.json +15 -0
- package/dist/template/turbo.json +8 -0
- package/dist/template/vite.config.mts +26 -0
- package/dist/template-manifest.json +3 -0
- package/dist/template.d.ts +8 -0
- package/dist/template.js +54 -0
- package/dist/template.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
packages: []
|
|
2
|
+
|
|
3
|
+
allowBuilds:
|
|
4
|
+
bcrypt: true
|
|
5
|
+
esbuild: true
|
|
6
|
+
sharp: true
|
|
7
|
+
cpu-features: false
|
|
8
|
+
protobufjs: false
|
|
9
|
+
ssh2: false
|
|
10
|
+
"@apollo/protobufjs": false
|
|
11
|
+
msw: false
|
|
12
|
+
strictDepBuilds: true
|
|
13
|
+
dangerouslyAllowAllBuilds: false
|
|
14
|
+
verifyDepsBeforeRun: warn
|
|
15
|
+
savePrefix: ""
|
|
16
|
+
minimumReleaseAge: 1440
|
|
17
|
+
minimumReleaseAgeStrict: true
|
|
18
|
+
minimumReleaseAgeIgnoreMissingTime: false
|
|
19
|
+
trustPolicy: no-downgrade
|
|
20
|
+
trustPolicyExclude:
|
|
21
|
+
- semver@6.3.1
|
|
22
|
+
- chokidar@4.0.3
|
|
23
|
+
trustLockfile: false
|
|
24
|
+
blockExoticSubdeps: true
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { copyFile, access } from "node:fs/promises";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { createServer } from "node:net";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
6
|
+
import dotenv from "dotenv";
|
|
7
|
+
|
|
8
|
+
const root = resolve(__dirname, "..");
|
|
9
|
+
const envFile = resolve(root, ".env");
|
|
10
|
+
const envExample = resolve(root, ".env.example");
|
|
11
|
+
|
|
12
|
+
function parsePort(value: string, name: string): number {
|
|
13
|
+
const port = Number(value);
|
|
14
|
+
if (!Number.isInteger(port) || port < 1 || port > 65_535) {
|
|
15
|
+
throw new Error(`${name} must be an integer between 1 and 65535.`);
|
|
16
|
+
}
|
|
17
|
+
return port;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function assertRuntime(): void {
|
|
21
|
+
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
22
|
+
if (major !== 24 || (minor ?? 0) < 18) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Unsupported Node.js ${process.versions.node}. Install Node.js >=24.18.0 <25 and run pnpm dev again.`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function assertPortAvailable(
|
|
30
|
+
port: number,
|
|
31
|
+
service: string,
|
|
32
|
+
): Promise<void> {
|
|
33
|
+
await new Promise<void>((resolvePromise, reject) => {
|
|
34
|
+
const server = createServer();
|
|
35
|
+
server.once("error", () =>
|
|
36
|
+
reject(
|
|
37
|
+
new Error(
|
|
38
|
+
`Port ${port} for ${service} is already in use. Stop the conflicting process and run pnpm dev again.`,
|
|
39
|
+
),
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
server.listen(port, "127.0.0.1", () =>
|
|
43
|
+
server.close((error) => (error ? reject(error) : resolvePromise())),
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function ensureEnv() {
|
|
49
|
+
try {
|
|
50
|
+
await access(envFile);
|
|
51
|
+
} catch {
|
|
52
|
+
await copyFile(envExample, envFile);
|
|
53
|
+
console.log("Created local .env from .env.example");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function run(
|
|
58
|
+
command: string,
|
|
59
|
+
args: string[],
|
|
60
|
+
options?: { stdio?: "inherit" | "ignore" },
|
|
61
|
+
) {
|
|
62
|
+
return new Promise<void>((resolvePromise, reject) => {
|
|
63
|
+
const child = spawn(command, args, {
|
|
64
|
+
cwd: root,
|
|
65
|
+
stdio: options?.stdio ?? "inherit",
|
|
66
|
+
});
|
|
67
|
+
child.once("error", reject);
|
|
68
|
+
child.once("exit", (code, signal) => {
|
|
69
|
+
if (code === 0) resolvePromise();
|
|
70
|
+
else reject(new Error(`${command} exited with ${signal ?? code}`));
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function dockerReady() {
|
|
76
|
+
const dbPort = parsePort(
|
|
77
|
+
process.env.JARSHOP_POSTGRES_PORT ?? process.env.DB_PORT ?? "6543",
|
|
78
|
+
"JARSHOP_POSTGRES_PORT",
|
|
79
|
+
);
|
|
80
|
+
try {
|
|
81
|
+
await run("docker", ["info"], { stdio: "ignore" });
|
|
82
|
+
} catch {
|
|
83
|
+
throw new Error(
|
|
84
|
+
"Docker is not available. Start Docker Desktop and run pnpm dev again.",
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
await run("docker", ["compose", "up", "-d", "postgres_db"]);
|
|
90
|
+
} catch {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`PostgreSQL could not start on port ${dbPort}. Stop the conflicting service or choose another JARSHOP_POSTGRES_PORT.`,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
for (let attempt = 1; attempt <= 30; attempt += 1) {
|
|
96
|
+
try {
|
|
97
|
+
await run(
|
|
98
|
+
"docker",
|
|
99
|
+
[
|
|
100
|
+
"compose",
|
|
101
|
+
"exec",
|
|
102
|
+
"-T",
|
|
103
|
+
"postgres_db",
|
|
104
|
+
"pg_isready",
|
|
105
|
+
"-U",
|
|
106
|
+
process.env.DB_USERNAME ?? "vendure",
|
|
107
|
+
"-d",
|
|
108
|
+
process.env.DB_NAME ?? "vendure",
|
|
109
|
+
],
|
|
110
|
+
{ stdio: "ignore" },
|
|
111
|
+
);
|
|
112
|
+
return;
|
|
113
|
+
} catch {
|
|
114
|
+
await delay(1000);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
throw new Error(
|
|
118
|
+
`PostgreSQL did not become ready on port ${dbPort} within 30 seconds.`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function main() {
|
|
123
|
+
await ensureEnv();
|
|
124
|
+
dotenv.config({ path: envFile, quiet: true });
|
|
125
|
+
assertRuntime();
|
|
126
|
+
const serverPort = parsePort(process.env.PORT ?? "3000", "PORT");
|
|
127
|
+
await Promise.all([
|
|
128
|
+
assertPortAvailable(serverPort, "Vendure"),
|
|
129
|
+
assertPortAvailable(3001, "storefront"),
|
|
130
|
+
]);
|
|
131
|
+
const isDev = (process.env.APP_ENV ?? "dev") === "dev";
|
|
132
|
+
if (isDev) {
|
|
133
|
+
await dockerReady();
|
|
134
|
+
await run("pnpm", ["db:migrate"]);
|
|
135
|
+
await run("pnpm", ["db:seed"]);
|
|
136
|
+
}
|
|
137
|
+
const turboUi = process.env.JARSHOP_TURBO_UI === "stream" ? "stream" : "tui";
|
|
138
|
+
const turboArgs = [
|
|
139
|
+
"exec",
|
|
140
|
+
"turbo",
|
|
141
|
+
"run",
|
|
142
|
+
"dev:server",
|
|
143
|
+
"dev:worker",
|
|
144
|
+
"dev:storefront",
|
|
145
|
+
`--ui=${turboUi}`,
|
|
146
|
+
];
|
|
147
|
+
if (turboUi === "stream") turboArgs.push("--log-order=stream");
|
|
148
|
+
await run("pnpm", turboArgs);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
main().catch((error: unknown) => {
|
|
152
|
+
console.error(error instanceof Error ? error.message : error);
|
|
153
|
+
process.exitCode = 1;
|
|
154
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
namespace NodeJS {
|
|
5
|
+
interface ProcessEnv {
|
|
6
|
+
APP_ENV?: string;
|
|
7
|
+
PORT?: string;
|
|
8
|
+
COOKIE_SECRET?: string;
|
|
9
|
+
SUPERADMIN_USERNAME?: string;
|
|
10
|
+
SUPERADMIN_PASSWORD?: string;
|
|
11
|
+
DB_HOST?: string;
|
|
12
|
+
DB_PORT?: string;
|
|
13
|
+
DB_NAME?: string;
|
|
14
|
+
DB_USERNAME?: string;
|
|
15
|
+
DB_PASSWORD?: string;
|
|
16
|
+
DB_SCHEMA?: string;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|