easyorders 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/README.md +4 -7
- package/dist/bin/cli.js +185 -0
- package/dist/server/api.js +22 -0
- package/dist/server/index.js +255 -0
- package/dist/server/token-store.js +24 -0
- package/dist/server/tunnel.js +124 -0
- package/package.json +9 -7
- package/cli/bin/cli.js +0 -17
- package/cli/bin/cli.ts +0 -240
- package/cli/server/api.ts +0 -56
- package/cli/server/index.ts +0 -320
- package/cli/server/token-store.ts +0 -35
- package/cli/server/tunnel.ts +0 -161
- /package/{cli → dist}/template/theme/config.json +0 -0
- /package/{cli → dist}/template/theme/schema.json +0 -0
- /package/{cli → dist}/template/theme/script.js +0 -0
- /package/{cli → dist}/template/theme/sections/breadcrumbs.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/categories.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/fake-counter.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/fake-stock.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/fake-visitor.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/featured-products.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/fixed-buy-button.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/footer.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/gallery.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/header.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/home-products-grid.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/list-products.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/order-invoice.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/product-description.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/product-details.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/products-grid.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/related-products.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/reviews.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/slider.liquid +0 -0
- /package/{cli → dist}/template/theme/sections/thanks.liquid +0 -0
- /package/{cli → dist}/template/theme/style.css +0 -0
- /package/{cli → dist}/template/theme/theme-data.json +0 -0
package/cli/server/tunnel.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
import { Tunnel } from "cloudflared";
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
|
|
6
|
-
const CYAN = "\x1b[36m";
|
|
7
|
-
const GREEN = "\x1b[32m";
|
|
8
|
-
const YELLOW = "\x1b[33m";
|
|
9
|
-
const RED = "\x1b[31m";
|
|
10
|
-
const DIM = "\x1b[2m";
|
|
11
|
-
const BOLD = "\x1b[1m";
|
|
12
|
-
const RESET = "\x1b[0m";
|
|
13
|
-
const UNDERLINE = "\x1b[4m";
|
|
14
|
-
|
|
15
|
-
const STORE_DOMAIN =
|
|
16
|
-
process.env.STORE_DOMAIN || "myeasyorders.com";
|
|
17
|
-
|
|
18
|
-
const port = Number(process.env.PORT) || 4000;
|
|
19
|
-
const URL_FILE = path.resolve(process.cwd(), ".tunnel-url");
|
|
20
|
-
const PID_FILE = path.resolve(process.cwd(), ".tunnel-pid");
|
|
21
|
-
const AUTH_READY_FILE = path.resolve(process.cwd(), ".auth-ready");
|
|
22
|
-
|
|
23
|
-
function isAlive(pid: number): boolean {
|
|
24
|
-
try {
|
|
25
|
-
process.kill(pid, 0);
|
|
26
|
-
return true;
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function alreadyRunning(): boolean {
|
|
33
|
-
try {
|
|
34
|
-
const pid = parseInt(fs.readFileSync(PID_FILE, "utf-8").trim(), 10);
|
|
35
|
-
if (isAlive(pid)) {
|
|
36
|
-
const url = fs.readFileSync(URL_FILE, "utf-8").trim();
|
|
37
|
-
console.log(` ${DIM}Tunnel already running (pid ${pid})${RESET}`);
|
|
38
|
-
console.log(
|
|
39
|
-
` ${DIM}Public URL:${RESET} ${CYAN}${UNDERLINE}${url}${RESET}`
|
|
40
|
-
);
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
} catch {}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function spinner(text: string): NodeJS.Timeout {
|
|
48
|
-
const frames = [" ◐", " ◓", " ◑", " ◒"];
|
|
49
|
-
let i = 0;
|
|
50
|
-
return setInterval(() => {
|
|
51
|
-
process.stdout.write(
|
|
52
|
-
`\r${CYAN}${frames[i++ % frames.length]}${RESET} ${DIM}${text}${RESET}`
|
|
53
|
-
);
|
|
54
|
-
}, 120);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function cleanup() {
|
|
58
|
-
try {
|
|
59
|
-
fs.unlinkSync(URL_FILE);
|
|
60
|
-
} catch {}
|
|
61
|
-
try {
|
|
62
|
-
fs.unlinkSync(PID_FILE);
|
|
63
|
-
} catch {}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface AuthData {
|
|
67
|
-
store_name: string;
|
|
68
|
-
code: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function waitForAuthReady(): Promise<AuthData> {
|
|
72
|
-
return new Promise((resolve) => {
|
|
73
|
-
const tryRead = () => {
|
|
74
|
-
if (fs.existsSync(AUTH_READY_FILE)) {
|
|
75
|
-
const raw = fs.readFileSync(AUTH_READY_FILE, "utf-8").trim();
|
|
76
|
-
try {
|
|
77
|
-
const data = JSON.parse(raw) as AuthData;
|
|
78
|
-
return resolve(data);
|
|
79
|
-
} catch {
|
|
80
|
-
return resolve({ store_name: "your-store", code: "" });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
tryRead();
|
|
85
|
-
const check = setInterval(() => {
|
|
86
|
-
if (fs.existsSync(AUTH_READY_FILE)) {
|
|
87
|
-
clearInterval(check);
|
|
88
|
-
tryRead();
|
|
89
|
-
}
|
|
90
|
-
}, 500);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function main() {
|
|
95
|
-
if (alreadyRunning()) return;
|
|
96
|
-
|
|
97
|
-
const authData = await waitForAuthReady();
|
|
98
|
-
|
|
99
|
-
fs.writeFileSync(PID_FILE, String(process.pid), "utf-8");
|
|
100
|
-
|
|
101
|
-
const spin = spinner("Starting Cloudflare tunnel...");
|
|
102
|
-
const tunnel = Tunnel.quick(`http://127.0.0.1:${port}`);
|
|
103
|
-
|
|
104
|
-
const tunnelUrl = await new Promise<string>((resolve) => {
|
|
105
|
-
tunnel.once("url", (url) => resolve(url));
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
clearInterval(spin);
|
|
109
|
-
process.stdout.write("\r\x1b[K");
|
|
110
|
-
|
|
111
|
-
fs.writeFileSync(URL_FILE, tunnelUrl, "utf-8");
|
|
112
|
-
|
|
113
|
-
const themeUrl = `${tunnelUrl}/theme`;
|
|
114
|
-
const storeUrl = `https://${authData.store_name}.${STORE_DOMAIN}?load_theme=${encodeURIComponent(themeUrl)}&code=${authData.code}`;
|
|
115
|
-
|
|
116
|
-
console.log("");
|
|
117
|
-
console.log(`${GREEN}${BOLD} ✔ Tunnel is live${RESET}`);
|
|
118
|
-
console.log("");
|
|
119
|
-
console.log(
|
|
120
|
-
` ${DIM}Public URL:${RESET} ${CYAN}${UNDERLINE}${tunnelUrl}${RESET}`
|
|
121
|
-
);
|
|
122
|
-
console.log(
|
|
123
|
-
` ${GREEN}${BOLD}✔${RESET} ${DIM}Open your store:${RESET} ${CYAN}${UNDERLINE}${storeUrl}${RESET}`
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
console.log(` ${DIM}Local:${RESET} http://127.0.0.1:${port}`);
|
|
127
|
-
console.log(` ${DIM}─────────────────────────────────────────${RESET}`);
|
|
128
|
-
console.log("");
|
|
129
|
-
|
|
130
|
-
tunnel.once("connected", (conn) => {
|
|
131
|
-
console.log(
|
|
132
|
-
` ${GREEN}●${RESET} ${DIM}Connected via${RESET} ${BOLD}${
|
|
133
|
-
conn.location
|
|
134
|
-
}${RESET} ${DIM}(${conn.id.slice(0, 8)})${RESET}`
|
|
135
|
-
);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
tunnel.on("exit", (code, signal) => {
|
|
139
|
-
if (code !== 0) {
|
|
140
|
-
console.log(
|
|
141
|
-
`\n ${RED}✖ Tunnel exited${RESET} ${DIM}(code ${code}, signal ${signal})${RESET}\n`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
cleanup();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
tunnel.on("error", (err) => {
|
|
148
|
-
console.log(` ${YELLOW}⚠ ${err.message}${RESET}`);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
process.once("SIGINT", () => {
|
|
152
|
-
cleanup();
|
|
153
|
-
tunnel.stop();
|
|
154
|
-
});
|
|
155
|
-
process.once("SIGTERM", () => {
|
|
156
|
-
cleanup();
|
|
157
|
-
tunnel.stop();
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
main();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|