shopnex 0.0.0-edge.init → 0.0.0-stage

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 CHANGED
@@ -1,52 +1,3 @@
1
- # shopnex
1
+ # Temporary Holding Version
2
2
 
3
- Look after a ShopNex shop that you started with [`create-shopnex`](../create-shopnex). One command today:
4
- `migrate-db`, which moves the shop's data from the embedded database to PostgreSQL.
5
-
6
- ```sh
7
- cd my-shop # the folder create-shopnex made (it has the .env)
8
- # stop the shop (Ctrl+C where it runs), then:
9
- npx shopnex@latest migrate-db --to postgres://user:password@host:5432/shopnex
10
- ```
11
-
12
- The new database must exist and be empty. To keep the password out of your shell history, put the address in an
13
- environment variable and give its name: `--to-env SHOPNEX_TARGET`.
14
-
15
- ## What it does
16
-
17
- 1. Checks that the shop is stopped (nothing answers on the admin's port, 3000; use `--port` if you started it on
18
- another) and that its database is at the schema of this version.
19
- 2. Keeps a copy of `.pglite/` next to it (`.pglite.bak-<date>`).
20
- 3. Runs `admin/migrate-db.mjs` from the packaged build of the same version: it creates the tables in PostgreSQL,
21
- copies every table in foreign-key order inside **one transaction**, and checks every table's row count before it
22
- commits.
23
- 4. Only then changes `DATABASE_URL` in the `.env`. The old line stays above it as a comment, and `.pglite/` stays
24
- where it is: going back is one edit.
25
-
26
- If anything fails, PostgreSQL is left as empty as it was found, the `.env` is not touched, and the extra copy is
27
- removed. The old data is only ever read.
28
-
29
- ## What it does not do
30
-
31
- - **The optional apps' data** (`apps/<name>/.pglite`: Stripe, CJ Dropshipping, Shippo) is not moved. They start empty
32
- on PostgreSQL, and the command names the ones that had data.
33
- - It never merges into a database that already has tables.
34
- - It does not move data back, or between two PostgreSQL servers (use `pg_dump` for that).
35
-
36
- ## The version rule
37
-
38
- Like `create-shopnex`, this CLI runs the packaged build of **its own version** (downloaded once into
39
- `~/.shopnex/app/<version>`, shared with `create-shopnex`). A shop last started by an older version must be started once
40
- with this one first: it updates the database at start, and `migrate-db` refuses to copy until then. A database from a
41
- newer version is refused too.
42
-
43
- ## Development
44
-
45
- ```sh
46
- pnpm --filter shopnex dev migrate-db --help # runs src/main.ts
47
- pnpm --filter shopnex test # the command, against a stub in place of the build's script
48
- pnpm --filter @shopnex/db test # the copier itself (modules/db/src/move-data.ts) on two PGlite databases
49
- ```
50
-
51
- The code that is not about this command (downloading and unpacking the build, the `.env`, ports) is
52
- [`@shopnex/cli-core`](../cli-core), shared with `create-shopnex`.
3
+ This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
package/package.json CHANGED
@@ -1,46 +1,6 @@
1
1
  {
2
2
  "name": "shopnex",
3
- "version": "0.0.0-edge.init",
4
- "description": "Look after a ShopNex shop made with create-shopnex: npx shopnex migrate-db moves the embedded database to PostgreSQL",
5
- "license": "MIT",
6
- "homepage": "https://shopnex.ai",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/shopnex-ai/shopnex.git",
10
- "directory": "packages/cli"
11
- },
12
- "keywords": [
13
- "shopnex",
14
- "ecommerce",
15
- "cli"
16
- ],
17
- "publishConfig": {
18
- "access": "public"
19
- },
20
- "type": "module",
21
- "bin": {
22
- "shopnex": "./bin/shopnex.mjs"
23
- },
24
- "files": [
25
- "bin",
26
- "dist"
27
- ],
28
- "engines": {
29
- "node": ">=22.22.0"
30
- },
31
- "scripts": {
32
- "build": "node scripts/build.mjs",
33
- "prepack": "node scripts/build.mjs",
34
- "dev": "tsx src/main.ts",
35
- "typecheck": "tsc",
36
- "test": "tsx --test \"tests/**/*.test.ts\""
37
- },
38
- "devDependencies": {
39
- "@clack/prompts": "^0.7.0",
40
- "@shopnex/cli-core": "workspace:*",
41
- "@types/node": "catalog:",
42
- "esbuild": "0.28.2",
43
- "picocolors": "^1.1.1",
44
- "tsx": "^4.23.15"
45
- }
46
- }
3
+ "version": "0.0.0-stage",
4
+ "stub": true,
5
+ "description": "Temporary package placeholder for staged publishing"
6
+ }
package/bin/shopnex.mjs DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- // The compiled CLI (pnpm --filter shopnex build; it is built before the package is packed). From a checkout,
3
- // `pnpm --filter shopnex dev -- <options>` runs the TypeScript directly.
4
- try {
5
- await import('../dist/main.mjs')
6
- } catch (error) {
7
- if (error?.code !== 'ERR_MODULE_NOT_FOUND' || !String(error.message).includes('dist/main.mjs')) throw error
8
- console.error('shopnex is not built. Run: pnpm --filter shopnex build')
9
- process.exitCode = 1
10
- }
package/dist/main.mjs DELETED
@@ -1,803 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res, err) => function __init() {
8
- if (err) throw err[0];
9
- try {
10
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
- } catch (e2) {
12
- throw err = [e2], e2;
13
- }
14
- };
15
- var __commonJS = (cb, mod) => function __require() {
16
- try {
17
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
- } catch (e2) {
19
- throw mod = 0, e2;
20
- }
21
- };
22
- var __copyProps = (to, from, except, desc) => {
23
- if (from && typeof from === "object" || typeof from === "function") {
24
- for (let key of __getOwnPropNames(from))
25
- if (!__hasOwnProp.call(to, key) && key !== except)
26
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
- }
28
- return to;
29
- };
30
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
- // If the importer is in node compatibility mode or this is not an ESM
32
- // file that has been converted to a CommonJS file using a Babel-
33
- // compatible transform (i.e. "__esModule" has not been set), then set
34
- // "default" to the CommonJS "module.exports" for node compatibility.
35
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
- mod
37
- ));
38
-
39
- // <define:__PKG__>
40
- var define_PKG_default;
41
- var init_define_PKG = __esm({
42
- "<define:__PKG__>"() {
43
- define_PKG_default = { version: "0.0.0-edge.init", engines: { node: ">=22.22.0" } };
44
- }
45
- });
46
-
47
- // ../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
48
- var require_src = __commonJS({
49
- "../../node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
50
- "use strict";
51
- init_define_PKG();
52
- var ESC = "\x1B";
53
- var CSI = `${ESC}[`;
54
- var beep = "\x07";
55
- var cursor = {
56
- to(x2, y) {
57
- if (!y) return `${CSI}${x2 + 1}G`;
58
- return `${CSI}${y + 1};${x2 + 1}H`;
59
- },
60
- move(x2, y) {
61
- let ret = "";
62
- if (x2 < 0) ret += `${CSI}${-x2}D`;
63
- else if (x2 > 0) ret += `${CSI}${x2}C`;
64
- if (y < 0) ret += `${CSI}${-y}A`;
65
- else if (y > 0) ret += `${CSI}${y}B`;
66
- return ret;
67
- },
68
- up: (count = 1) => `${CSI}${count}A`,
69
- down: (count = 1) => `${CSI}${count}B`,
70
- forward: (count = 1) => `${CSI}${count}C`,
71
- backward: (count = 1) => `${CSI}${count}D`,
72
- nextLine: (count = 1) => `${CSI}E`.repeat(count),
73
- prevLine: (count = 1) => `${CSI}F`.repeat(count),
74
- left: `${CSI}G`,
75
- hide: `${CSI}?25l`,
76
- show: `${CSI}?25h`,
77
- save: `${ESC}7`,
78
- restore: `${ESC}8`
79
- };
80
- var scroll = {
81
- up: (count = 1) => `${CSI}S`.repeat(count),
82
- down: (count = 1) => `${CSI}T`.repeat(count)
83
- };
84
- var erase = {
85
- screen: `${CSI}2J`,
86
- up: (count = 1) => `${CSI}1J`.repeat(count),
87
- down: (count = 1) => `${CSI}J`.repeat(count),
88
- line: `${CSI}2K`,
89
- lineEnd: `${CSI}K`,
90
- lineStart: `${CSI}1K`,
91
- lines(count) {
92
- let clear = "";
93
- for (let i = 0; i < count; i++)
94
- clear += this.line + (i < count - 1 ? cursor.up() : "");
95
- if (count)
96
- clear += cursor.left;
97
- return clear;
98
- }
99
- };
100
- module.exports = { cursor, scroll, erase, beep };
101
- }
102
- });
103
-
104
- // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
105
- var require_picocolors = __commonJS({
106
- "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
107
- init_define_PKG();
108
- var p = process || {};
109
- var argv = p.argv || [];
110
- var env = p.env || {};
111
- var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
112
- var formatter = (open, close, replace = open) => (input) => {
113
- let string = "" + input, index = string.indexOf(close, open.length);
114
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
115
- };
116
- var replaceClose = (string, close, replace, index) => {
117
- let result = "", cursor = 0;
118
- do {
119
- result += string.substring(cursor, index) + replace;
120
- cursor = index + close.length;
121
- index = string.indexOf(close, cursor);
122
- } while (~index);
123
- return result + string.substring(cursor);
124
- };
125
- var createColors = (enabled = isColorSupported) => {
126
- let f3 = enabled ? formatter : () => String;
127
- return {
128
- isColorSupported: enabled,
129
- reset: f3("\x1B[0m", "\x1B[0m"),
130
- bold: f3("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
131
- dim: f3("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
132
- italic: f3("\x1B[3m", "\x1B[23m"),
133
- underline: f3("\x1B[4m", "\x1B[24m"),
134
- inverse: f3("\x1B[7m", "\x1B[27m"),
135
- hidden: f3("\x1B[8m", "\x1B[28m"),
136
- strikethrough: f3("\x1B[9m", "\x1B[29m"),
137
- black: f3("\x1B[30m", "\x1B[39m"),
138
- red: f3("\x1B[31m", "\x1B[39m"),
139
- green: f3("\x1B[32m", "\x1B[39m"),
140
- yellow: f3("\x1B[33m", "\x1B[39m"),
141
- blue: f3("\x1B[34m", "\x1B[39m"),
142
- magenta: f3("\x1B[35m", "\x1B[39m"),
143
- cyan: f3("\x1B[36m", "\x1B[39m"),
144
- white: f3("\x1B[37m", "\x1B[39m"),
145
- gray: f3("\x1B[90m", "\x1B[39m"),
146
- bgBlack: f3("\x1B[40m", "\x1B[49m"),
147
- bgRed: f3("\x1B[41m", "\x1B[49m"),
148
- bgGreen: f3("\x1B[42m", "\x1B[49m"),
149
- bgYellow: f3("\x1B[43m", "\x1B[49m"),
150
- bgBlue: f3("\x1B[44m", "\x1B[49m"),
151
- bgMagenta: f3("\x1B[45m", "\x1B[49m"),
152
- bgCyan: f3("\x1B[46m", "\x1B[49m"),
153
- bgWhite: f3("\x1B[47m", "\x1B[49m"),
154
- blackBright: f3("\x1B[90m", "\x1B[39m"),
155
- redBright: f3("\x1B[91m", "\x1B[39m"),
156
- greenBright: f3("\x1B[92m", "\x1B[39m"),
157
- yellowBright: f3("\x1B[93m", "\x1B[39m"),
158
- blueBright: f3("\x1B[94m", "\x1B[39m"),
159
- magentaBright: f3("\x1B[95m", "\x1B[39m"),
160
- cyanBright: f3("\x1B[96m", "\x1B[39m"),
161
- whiteBright: f3("\x1B[97m", "\x1B[39m"),
162
- bgBlackBright: f3("\x1B[100m", "\x1B[49m"),
163
- bgRedBright: f3("\x1B[101m", "\x1B[49m"),
164
- bgGreenBright: f3("\x1B[102m", "\x1B[49m"),
165
- bgYellowBright: f3("\x1B[103m", "\x1B[49m"),
166
- bgBlueBright: f3("\x1B[104m", "\x1B[49m"),
167
- bgMagentaBright: f3("\x1B[105m", "\x1B[49m"),
168
- bgCyanBright: f3("\x1B[106m", "\x1B[49m"),
169
- bgWhiteBright: f3("\x1B[107m", "\x1B[49m")
170
- };
171
- };
172
- module.exports = createColors();
173
- module.exports.createColors = createColors;
174
- }
175
- });
176
-
177
- // src/main.ts
178
- init_define_PKG();
179
-
180
- // src/cli.ts
181
- init_define_PKG();
182
- import { readFileSync as readFileSync3 } from "node:fs";
183
-
184
- // ../../node_modules/.pnpm/@clack+prompts@0.7.0/node_modules/@clack/prompts/dist/index.mjs
185
- init_define_PKG();
186
-
187
- // ../../node_modules/.pnpm/@clack+core@0.3.5/node_modules/@clack/core/dist/index.mjs
188
- init_define_PKG();
189
- var import_sisteransi = __toESM(require_src(), 1);
190
- import { stdin as $, stdout as k } from "node:process";
191
- import * as f from "node:readline";
192
- function q({ onlyFirst: e2 = false } = {}) {
193
- const F = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
194
- return new RegExp(F, e2 ? void 0 : "g");
195
- }
196
- var J = q();
197
- function T(e2) {
198
- return e2 && e2.__esModule && Object.prototype.hasOwnProperty.call(e2, "default") ? e2.default : e2;
199
- }
200
- var j = { exports: {} };
201
- (function(e2) {
202
- var u = {};
203
- e2.exports = u, u.eastAsianWidth = function(t) {
204
- var s = t.charCodeAt(0), C2 = t.length == 2 ? t.charCodeAt(1) : 0, D = s;
205
- return 55296 <= s && s <= 56319 && 56320 <= C2 && C2 <= 57343 && (s &= 1023, C2 &= 1023, D = s << 10 | C2, D += 65536), D == 12288 || 65281 <= D && D <= 65376 || 65504 <= D && D <= 65510 ? "F" : D == 8361 || 65377 <= D && D <= 65470 || 65474 <= D && D <= 65479 || 65482 <= D && D <= 65487 || 65490 <= D && D <= 65495 || 65498 <= D && D <= 65500 || 65512 <= D && D <= 65518 ? "H" : 4352 <= D && D <= 4447 || 4515 <= D && D <= 4519 || 4602 <= D && D <= 4607 || 9001 <= D && D <= 9002 || 11904 <= D && D <= 11929 || 11931 <= D && D <= 12019 || 12032 <= D && D <= 12245 || 12272 <= D && D <= 12283 || 12289 <= D && D <= 12350 || 12353 <= D && D <= 12438 || 12441 <= D && D <= 12543 || 12549 <= D && D <= 12589 || 12593 <= D && D <= 12686 || 12688 <= D && D <= 12730 || 12736 <= D && D <= 12771 || 12784 <= D && D <= 12830 || 12832 <= D && D <= 12871 || 12880 <= D && D <= 13054 || 13056 <= D && D <= 19903 || 19968 <= D && D <= 42124 || 42128 <= D && D <= 42182 || 43360 <= D && D <= 43388 || 44032 <= D && D <= 55203 || 55216 <= D && D <= 55238 || 55243 <= D && D <= 55291 || 63744 <= D && D <= 64255 || 65040 <= D && D <= 65049 || 65072 <= D && D <= 65106 || 65108 <= D && D <= 65126 || 65128 <= D && D <= 65131 || 110592 <= D && D <= 110593 || 127488 <= D && D <= 127490 || 127504 <= D && D <= 127546 || 127552 <= D && D <= 127560 || 127568 <= D && D <= 127569 || 131072 <= D && D <= 194367 || 177984 <= D && D <= 196605 || 196608 <= D && D <= 262141 ? "W" : 32 <= D && D <= 126 || 162 <= D && D <= 163 || 165 <= D && D <= 166 || D == 172 || D == 175 || 10214 <= D && D <= 10221 || 10629 <= D && D <= 10630 ? "Na" : D == 161 || D == 164 || 167 <= D && D <= 168 || D == 170 || 173 <= D && D <= 174 || 176 <= D && D <= 180 || 182 <= D && D <= 186 || 188 <= D && D <= 191 || D == 198 || D == 208 || 215 <= D && D <= 216 || 222 <= D && D <= 225 || D == 230 || 232 <= D && D <= 234 || 236 <= D && D <= 237 || D == 240 || 242 <= D && D <= 243 || 247 <= D && D <= 250 || D == 252 || D == 254 || D == 257 || D == 273 || D == 275 || D == 283 || 294 <= D && D <= 295 || D == 299 || 305 <= D && D <= 307 || D == 312 || 319 <= D && D <= 322 || D == 324 || 328 <= D && D <= 331 || D == 333 || 338 <= D && D <= 339 || 358 <= D && D <= 359 || D == 363 || D == 462 || D == 464 || D == 466 || D == 468 || D == 470 || D == 472 || D == 474 || D == 476 || D == 593 || D == 609 || D == 708 || D == 711 || 713 <= D && D <= 715 || D == 717 || D == 720 || 728 <= D && D <= 731 || D == 733 || D == 735 || 768 <= D && D <= 879 || 913 <= D && D <= 929 || 931 <= D && D <= 937 || 945 <= D && D <= 961 || 963 <= D && D <= 969 || D == 1025 || 1040 <= D && D <= 1103 || D == 1105 || D == 8208 || 8211 <= D && D <= 8214 || 8216 <= D && D <= 8217 || 8220 <= D && D <= 8221 || 8224 <= D && D <= 8226 || 8228 <= D && D <= 8231 || D == 8240 || 8242 <= D && D <= 8243 || D == 8245 || D == 8251 || D == 8254 || D == 8308 || D == 8319 || 8321 <= D && D <= 8324 || D == 8364 || D == 8451 || D == 8453 || D == 8457 || D == 8467 || D == 8470 || 8481 <= D && D <= 8482 || D == 8486 || D == 8491 || 8531 <= D && D <= 8532 || 8539 <= D && D <= 8542 || 8544 <= D && D <= 8555 || 8560 <= D && D <= 8569 || D == 8585 || 8592 <= D && D <= 8601 || 8632 <= D && D <= 8633 || D == 8658 || D == 8660 || D == 8679 || D == 8704 || 8706 <= D && D <= 8707 || 8711 <= D && D <= 8712 || D == 8715 || D == 8719 || D == 8721 || D == 8725 || D == 8730 || 8733 <= D && D <= 8736 || D == 8739 || D == 8741 || 8743 <= D && D <= 8748 || D == 8750 || 8756 <= D && D <= 8759 || 8764 <= D && D <= 8765 || D == 8776 || D == 8780 || D == 8786 || 8800 <= D && D <= 8801 || 8804 <= D && D <= 8807 || 8810 <= D && D <= 8811 || 8814 <= D && D <= 8815 || 8834 <= D && D <= 8835 || 8838 <= D && D <= 8839 || D == 8853 || D == 8857 || D == 8869 || D == 8895 || D == 8978 || 9312 <= D && D <= 9449 || 9451 <= D && D <= 9547 || 9552 <= D && D <= 9587 || 9600 <= D && D <= 9615 || 9618 <= D && D <= 9621 || 9632 <= D && D <= 9633 || 9635 <= D && D <= 9641 || 9650 <= D && D <= 9651 || 9654 <= D && D <= 9655 || 9660 <= D && D <= 9661 || 9664 <= D && D <= 9665 || 9670 <= D && D <= 9672 || D == 9675 || 9678 <= D && D <= 9681 || 9698 <= D && D <= 9701 || D == 9711 || 9733 <= D && D <= 9734 || D == 9737 || 9742 <= D && D <= 9743 || 9748 <= D && D <= 9749 || D == 9756 || D == 9758 || D == 9792 || D == 9794 || 9824 <= D && D <= 9825 || 9827 <= D && D <= 9829 || 9831 <= D && D <= 9834 || 9836 <= D && D <= 9837 || D == 9839 || 9886 <= D && D <= 9887 || 9918 <= D && D <= 9919 || 9924 <= D && D <= 9933 || 9935 <= D && D <= 9953 || D == 9955 || 9960 <= D && D <= 9983 || D == 10045 || D == 10071 || 10102 <= D && D <= 10111 || 11093 <= D && D <= 11097 || 12872 <= D && D <= 12879 || 57344 <= D && D <= 63743 || 65024 <= D && D <= 65039 || D == 65533 || 127232 <= D && D <= 127242 || 127248 <= D && D <= 127277 || 127280 <= D && D <= 127337 || 127344 <= D && D <= 127386 || 917760 <= D && D <= 917999 || 983040 <= D && D <= 1048573 || 1048576 <= D && D <= 1114109 ? "A" : "N";
206
- }, u.characterLength = function(t) {
207
- var s = this.eastAsianWidth(t);
208
- return s == "F" || s == "W" || s == "A" ? 2 : 1;
209
- };
210
- function F(t) {
211
- return t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
212
- }
213
- u.length = function(t) {
214
- for (var s = F(t), C2 = 0, D = 0; D < s.length; D++) C2 = C2 + this.characterLength(s[D]);
215
- return C2;
216
- }, u.slice = function(t, s, C2) {
217
- textLen = u.length(t), s = s || 0, C2 = C2 || 1, s < 0 && (s = textLen + s), C2 < 0 && (C2 = textLen + C2);
218
- for (var D = "", i = 0, n = F(t), E2 = 0; E2 < n.length; E2++) {
219
- var h2 = n[E2], o2 = u.length(h2);
220
- if (i >= s - (o2 == 2 ? 1 : 0)) if (i + o2 <= C2) D += h2;
221
- else break;
222
- i += o2;
223
- }
224
- return D;
225
- };
226
- })(j);
227
- var Q = j.exports;
228
- var X = T(Q);
229
- var DD = function() {
230
- return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
231
- };
232
- var uD = T(DD);
233
- var d = 10;
234
- var M = (e2 = 0) => (u) => `\x1B[${u + e2}m`;
235
- var P = (e2 = 0) => (u) => `\x1B[${38 + e2};5;${u}m`;
236
- var W = (e2 = 0) => (u, F, t) => `\x1B[${38 + e2};2;${u};${F};${t}m`;
237
- var r = { modifier: { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], overline: [53, 55], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29] }, color: { black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], blackBright: [90, 39], gray: [90, 39], grey: [90, 39], redBright: [91, 39], greenBright: [92, 39], yellowBright: [93, 39], blueBright: [94, 39], magentaBright: [95, 39], cyanBright: [96, 39], whiteBright: [97, 39] }, bgColor: { bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], bgBlackBright: [100, 49], bgGray: [100, 49], bgGrey: [100, 49], bgRedBright: [101, 49], bgGreenBright: [102, 49], bgYellowBright: [103, 49], bgBlueBright: [104, 49], bgMagentaBright: [105, 49], bgCyanBright: [106, 49], bgWhiteBright: [107, 49] } };
238
- Object.keys(r.modifier);
239
- var FD = Object.keys(r.color);
240
- var eD = Object.keys(r.bgColor);
241
- [...FD, ...eD];
242
- function tD() {
243
- const e2 = /* @__PURE__ */ new Map();
244
- for (const [u, F] of Object.entries(r)) {
245
- for (const [t, s] of Object.entries(F)) r[t] = { open: `\x1B[${s[0]}m`, close: `\x1B[${s[1]}m` }, F[t] = r[t], e2.set(s[0], s[1]);
246
- Object.defineProperty(r, u, { value: F, enumerable: false });
247
- }
248
- return Object.defineProperty(r, "codes", { value: e2, enumerable: false }), r.color.close = "\x1B[39m", r.bgColor.close = "\x1B[49m", r.color.ansi = M(), r.color.ansi256 = P(), r.color.ansi16m = W(), r.bgColor.ansi = M(d), r.bgColor.ansi256 = P(d), r.bgColor.ansi16m = W(d), Object.defineProperties(r, { rgbToAnsi256: { value: (u, F, t) => u === F && F === t ? u < 8 ? 16 : u > 248 ? 231 : Math.round((u - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(u / 255 * 5) + 6 * Math.round(F / 255 * 5) + Math.round(t / 255 * 5), enumerable: false }, hexToRgb: { value: (u) => {
249
- const F = /[a-f\d]{6}|[a-f\d]{3}/i.exec(u.toString(16));
250
- if (!F) return [0, 0, 0];
251
- let [t] = F;
252
- t.length === 3 && (t = [...t].map((C2) => C2 + C2).join(""));
253
- const s = Number.parseInt(t, 16);
254
- return [s >> 16 & 255, s >> 8 & 255, s & 255];
255
- }, enumerable: false }, hexToAnsi256: { value: (u) => r.rgbToAnsi256(...r.hexToRgb(u)), enumerable: false }, ansi256ToAnsi: { value: (u) => {
256
- if (u < 8) return 30 + u;
257
- if (u < 16) return 90 + (u - 8);
258
- let F, t, s;
259
- if (u >= 232) F = ((u - 232) * 10 + 8) / 255, t = F, s = F;
260
- else {
261
- u -= 16;
262
- const i = u % 36;
263
- F = Math.floor(u / 36) / 5, t = Math.floor(i / 6) / 5, s = i % 6 / 5;
264
- }
265
- const C2 = Math.max(F, t, s) * 2;
266
- if (C2 === 0) return 30;
267
- let D = 30 + (Math.round(s) << 2 | Math.round(t) << 1 | Math.round(F));
268
- return C2 === 2 && (D += 60), D;
269
- }, enumerable: false }, rgbToAnsi: { value: (u, F, t) => r.ansi256ToAnsi(r.rgbToAnsi256(u, F, t)), enumerable: false }, hexToAnsi: { value: (u) => r.ansi256ToAnsi(r.hexToAnsi256(u)), enumerable: false } }), r;
270
- }
271
- var sD = tD();
272
- var iD = "]";
273
- var w = `${iD}8;;`;
274
- var WD = globalThis.process.platform.startsWith("win");
275
- function OD({ input: e2 = $, output: u = k, overwrite: F = true, hideCursor: t = true } = {}) {
276
- const s = f.createInterface({ input: e2, output: u, prompt: "", tabSize: 1 });
277
- f.emitKeypressEvents(e2, s), e2.isTTY && e2.setRawMode(true);
278
- const C2 = (D, { name: i }) => {
279
- if (String(D) === "") {
280
- t && u.write(import_sisteransi.cursor.show), process.exit(0);
281
- return;
282
- }
283
- if (!F) return;
284
- let n = i === "return" ? 0 : -1, E2 = i === "return" ? -1 : 0;
285
- f.moveCursor(u, n, E2, () => {
286
- f.clearLine(u, 1, () => {
287
- e2.once("keypress", C2);
288
- });
289
- });
290
- };
291
- return t && u.write(import_sisteransi.cursor.hide), e2.once("keypress", C2), () => {
292
- e2.off("keypress", C2), t && u.write(import_sisteransi.cursor.show), e2.isTTY && !WD && e2.setRawMode(false), s.terminal = false, s.close();
293
- };
294
- }
295
-
296
- // ../../node_modules/.pnpm/@clack+prompts@0.7.0/node_modules/@clack/prompts/dist/index.mjs
297
- var import_picocolors = __toESM(require_picocolors(), 1);
298
- var import_sisteransi2 = __toESM(require_src(), 1);
299
- import h from "node:process";
300
- function q2() {
301
- return h.platform !== "win32" ? h.env.TERM !== "linux" : Boolean(h.env.CI) || Boolean(h.env.WT_SESSION) || Boolean(h.env.TERMINUS_SUBLIME) || h.env.ConEmuTask === "{cmd::Cmder}" || h.env.TERM_PROGRAM === "Terminus-Sublime" || h.env.TERM_PROGRAM === "vscode" || h.env.TERM === "xterm-256color" || h.env.TERM === "alacritty" || h.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
302
- }
303
- var _ = q2();
304
- var o = (r2, n) => _ ? r2 : n;
305
- var H = o("\u25C6", "*");
306
- var I = o("\u25A0", "x");
307
- var x = o("\u25B2", "x");
308
- var S = o("\u25C7", "o");
309
- var K = o("\u250C", "T");
310
- var a = o("\u2502", "|");
311
- var d2 = o("\u2514", "\u2014");
312
- var b = o("\u25CF", ">");
313
- var E = o("\u25CB", " ");
314
- var C = o("\u25FB", "[\u2022]");
315
- var w2 = o("\u25FC", "[+]");
316
- var M2 = o("\u25FB", "[ ]");
317
- var U = o("\u25AA", "\u2022");
318
- var B = o("\u2500", "-");
319
- var Z = o("\u256E", "+");
320
- var z = o("\u251C", "+");
321
- var X2 = o("\u256F", "+");
322
- var J2 = o("\u25CF", "\u2022");
323
- var Y = o("\u25C6", "*");
324
- var Q2 = o("\u25B2", "!");
325
- var ee = o("\u25A0", "x");
326
- var oe = (r2 = "") => {
327
- process.stdout.write(`${import_picocolors.default.gray(K)} ${r2}
328
- `);
329
- };
330
- var $e = (r2 = "") => {
331
- process.stdout.write(`${import_picocolors.default.gray(a)}
332
- ${import_picocolors.default.gray(d2)} ${r2}
333
-
334
- `);
335
- };
336
- var f2 = { message: (r2 = "", { symbol: n = import_picocolors.default.gray(a) } = {}) => {
337
- const i = [`${import_picocolors.default.gray(a)}`];
338
- if (r2) {
339
- const [t, ...s] = r2.split(`
340
- `);
341
- i.push(`${n} ${t}`, ...s.map((c) => `${import_picocolors.default.gray(a)} ${c}`));
342
- }
343
- process.stdout.write(`${i.join(`
344
- `)}
345
- `);
346
- }, info: (r2) => {
347
- f2.message(r2, { symbol: import_picocolors.default.blue(J2) });
348
- }, success: (r2) => {
349
- f2.message(r2, { symbol: import_picocolors.default.green(Y) });
350
- }, step: (r2) => {
351
- f2.message(r2, { symbol: import_picocolors.default.green(S) });
352
- }, warn: (r2) => {
353
- f2.message(r2, { symbol: import_picocolors.default.yellow(Q2) });
354
- }, warning: (r2) => {
355
- f2.warn(r2);
356
- }, error: (r2) => {
357
- f2.message(r2, { symbol: import_picocolors.default.red(ee) });
358
- } };
359
- var de = () => {
360
- const r2 = _ ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"], n = _ ? 80 : 120;
361
- let i, t, s = false, c = "";
362
- const l2 = (v = "") => {
363
- s = true, i = OD(), c = v.replace(/\.+$/, ""), process.stdout.write(`${import_picocolors.default.gray(a)}
364
- `);
365
- let g = 0, p = 0;
366
- t = setInterval(() => {
367
- const O = import_picocolors.default.magenta(r2[g]), P2 = ".".repeat(Math.floor(p)).slice(0, 3);
368
- process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${O} ${c}${P2}`), g = g + 1 < r2.length ? g + 1 : 0, p = p < r2.length ? p + 0.125 : 0;
369
- }, n);
370
- }, u = (v = "", g = 0) => {
371
- c = v ?? c, s = false, clearInterval(t);
372
- const p = g === 0 ? import_picocolors.default.green(S) : g === 1 ? import_picocolors.default.red(I) : import_picocolors.default.red(x);
373
- process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${p} ${c}
374
- `), i();
375
- }, m2 = (v = "") => {
376
- c = v ?? c;
377
- }, $2 = (v) => {
378
- const g = v > 1 ? "Something went wrong" : "Canceled";
379
- s && u(g, v);
380
- };
381
- return process.on("uncaughtExceptionMonitor", () => $2(2)), process.on("unhandledRejection", () => $2(2)), process.on("SIGINT", () => $2(1)), process.on("SIGTERM", () => $2(1)), process.on("exit", $2), { start: l2, stop: u, message: m2 };
382
- };
383
-
384
- // ../cli-core/src/errors.ts
385
- init_define_PKG();
386
- var UsageError = class extends Error {
387
- };
388
- var UnavailableError = class extends Error {
389
- };
390
-
391
- // ../cli-core/src/node-version.ts
392
- init_define_PKG();
393
- var atLeast = (version, minimum) => version.replace(/^v/, "").localeCompare(minimum, void 0, { numeric: true }) >= 0;
394
- function assertNode(version, enginesRange) {
395
- const minimum = enginesRange.replace(/^>=/, "");
396
- if (!atLeast(version, minimum)) {
397
- throw new UsageError(
398
- `ShopNex needs Node ${minimum} or newer, this is ${version}. Install a newer Node (https://nodejs.org) and run it again.`
399
- );
400
- }
401
- }
402
-
403
- // ../cli-core/src/theme.ts
404
- init_define_PKG();
405
- var import_picocolors2 = __toESM(require_picocolors(), 1);
406
- var BRAND = [67, 192, 122];
407
- var ON_BRAND = [6, 21, 12];
408
- var truecolor = import_picocolors2.default.isColorSupported && /^(truecolor|24bit)$/i.test(process.env.COLORTERM ?? "");
409
- var brandBadge = (text) => truecolor ? `\x1B[48;2;${BRAND.join(";")}m\x1B[38;2;${ON_BRAND.join(";")}m${text}\x1B[39m\x1B[49m` : import_picocolors2.default.bgGreen(import_picocolors2.default.black(text));
410
-
411
- // src/args.ts
412
- init_define_PKG();
413
- import { parseArgs } from "node:util";
414
- var DEFAULT_PORT = 3e3;
415
- var COMMANDS = ["migrate-db"];
416
- var options = {
417
- to: { type: "string" },
418
- "to-env": { type: "string" },
419
- dir: { type: "string" },
420
- port: { type: "string" },
421
- help: { type: "boolean", short: "h" },
422
- version: { type: "boolean", short: "v" }
423
- };
424
- function parse(argv) {
425
- let values;
426
- let positionals;
427
- try {
428
- ;
429
- ({ values, positionals } = parseArgs({ args: argv, options, allowPositionals: true }));
430
- } catch (error) {
431
- throw new UsageError(`${error.message}
432
- Run shopnex --help for the options.`);
433
- }
434
- if (positionals.length > 1) throw new UsageError(`Give one command, got: ${positionals.join(" ")}`);
435
- const port = values.port === void 0 ? DEFAULT_PORT : Number(values.port);
436
- if (!Number.isInteger(port) || port < 1 || port > 65535) {
437
- throw new UsageError(`--port must be a port number (1-65535), got "${values.port}"`);
438
- }
439
- return {
440
- command: positionals[0],
441
- to: values.to,
442
- toEnv: values["to-env"],
443
- dir: values.dir ?? ".",
444
- port,
445
- help: Boolean(values.help),
446
- version: Boolean(values.version)
447
- };
448
- }
449
-
450
- // src/migrate-db.ts
451
- init_define_PKG();
452
- import { cpSync, existsSync as existsSync3, readdirSync as readdirSync2, rmSync as rmSync2 } from "node:fs";
453
- import { join as join4, resolve as resolve3 } from "node:path";
454
-
455
- // ../cli-core/src/bundle.ts
456
- init_define_PKG();
457
- import { createHash } from "node:crypto";
458
- import {
459
- createWriteStream,
460
- existsSync,
461
- mkdirSync,
462
- mkdtempSync,
463
- readdirSync,
464
- readFileSync,
465
- renameSync,
466
- rmSync
467
- } from "node:fs";
468
- import { join as join2 } from "node:path";
469
- import { spawnSync } from "node:child_process";
470
- import { Readable, Transform } from "node:stream";
471
- import { pipeline } from "node:stream/promises";
472
-
473
- // ../cli-core/src/paths.ts
474
- init_define_PKG();
475
- import { homedir } from "node:os";
476
- import { join, resolve } from "node:path";
477
- var appCacheDir = () => process.env.SHOPNEX_APP_DIR ?? join(homedir(), ".shopnex", "app");
478
-
479
- // ../cli-core/src/bundle.ts
480
- var isEdge = (version) => /-edge\./.test(version);
481
- var bundleName = (version) => `shopnex-v${version}-node.tgz`;
482
- var bundleUrl = (version) => process.env.SHOPNEX_BUNDLE_URL ?? (isEdge(version) ? "https://github.com/shopnex-ai/shopnex/releases/download/edge/shopnex-edge-node.tgz" : `https://github.com/shopnex-ai/shopnex/releases/download/v${version}/${bundleName(version)}`);
483
- var bundleDir = (key) => join2(appCacheDir(), key);
484
- var isInstalled = (key) => existsSync(join2(bundleDir(key), "manifest.json"));
485
- var installedEdges = () => existsSync(appCacheDir()) ? readdirSync(appCacheDir()).filter((name) => /^edge-[0-9a-f]{12}$/.test(name)) : [];
486
- async function get(url, what, version, cli) {
487
- let response;
488
- try {
489
- response = await fetch(url);
490
- } catch (error) {
491
- const reason = error.cause?.message ?? error.message;
492
- throw new UnavailableError(`Could not download ${what} (${reason}).
493
- Check your connection and try again.`);
494
- }
495
- if (response.status === 404) {
496
- throw new UnavailableError(
497
- `ShopNex ${version} has no packaged build to download (404 for ${url}).
498
- Use a released version of ${cli}.`
499
- );
500
- }
501
- if (!response.ok) {
502
- throw new UnavailableError(`Could not download ${what}: ${url} answered ${response.status}.`);
503
- }
504
- return response;
505
- }
506
- var parseChecksum = (text) => text.trim().split(/\s+/)[0]?.toLowerCase() ?? "";
507
- async function download(response, file, onProgress) {
508
- const hash = createHash("sha256");
509
- let bytes = 0;
510
- const measure = new Transform({
511
- transform(chunk, _encoding, done) {
512
- hash.update(chunk);
513
- bytes += chunk.length;
514
- onProgress(bytes);
515
- done(null, chunk);
516
- }
517
- });
518
- await pipeline(
519
- Readable.fromWeb(response.body),
520
- measure,
521
- createWriteStream(file)
522
- );
523
- return hash.digest("hex");
524
- }
525
- async function resolveBundle({ version, cli = "create-shopnex" }) {
526
- const edge = isEdge(version);
527
- if (!edge && isInstalled(version)) return bundleDir(version);
528
- mkdirSync(appCacheDir(), { recursive: true });
529
- const spinner = de();
530
- const animate = Boolean(process.stdout.isTTY);
531
- const say = (message) => animate ? spinner.message(message) : void 0;
532
- const start = edge ? "Checking for a newer edge build" : `Downloading ShopNex ${version} (once, about 15 MB)`;
533
- if (animate) spinner.start(start);
534
- else f2.step(start);
535
- let work;
536
- try {
537
- const url = bundleUrl(version);
538
- const expected = parseChecksum(await (await get(`${url}.sha256`, "the checksum", version, cli)).text());
539
- if (!/^[0-9a-f]{64}$/.test(expected)) throw new UnavailableError(`${url}.sha256 does not hold a SHA-256 checksum.`);
540
- const key = edge ? `edge-${expected.slice(0, 12)}` : version;
541
- const dir = bundleDir(key);
542
- if (isInstalled(key)) {
543
- if (animate) spinner.stop("ShopNex edge is up to date");
544
- return dir;
545
- }
546
- const label = edge ? "the latest edge build" : `ShopNex ${version}`;
547
- say(`Downloading ${label}`);
548
- work = mkdtempSync(join2(appCacheDir(), `${key}.tmp-`));
549
- const file = join2(work, "bundle.tgz");
550
- const actual = await download(
551
- await get(url, "ShopNex", version, cli),
552
- file,
553
- (bytes) => say(`Downloading ${label}: ${(bytes / 1e6).toFixed(1)} MB`)
554
- );
555
- if (actual !== expected) {
556
- throw new UnavailableError(
557
- `The download is damaged: its SHA-256 is ${actual}, expected ${expected}. Nothing was installed; try again.`
558
- );
559
- }
560
- say("Unpacking");
561
- const unpacked = join2(work, "app");
562
- mkdirSync(unpacked);
563
- const tar = spawnSync("tar", ["-xzf", file, "-C", unpacked], { encoding: "utf8" });
564
- if (tar.error || tar.status !== 0) {
565
- throw new UnavailableError(`Could not unpack the download with tar: ${tar.error?.message ?? tar.stderr.trim()}`);
566
- }
567
- const manifestFile = join2(unpacked, "manifest.json");
568
- const manifest = existsSync(manifestFile) ? JSON.parse(readFileSync(manifestFile, "utf8")) : void 0;
569
- if (edge ? !manifest : manifest?.version !== version) {
570
- throw new UnavailableError(
571
- `The download is not ShopNex ${version} (its manifest says ${manifest?.version ?? "nothing"}).`
572
- );
573
- }
574
- rmSync(dir, { recursive: true, force: true });
575
- renameSync(unpacked, dir);
576
- for (const old of installedEdges()) if (old !== key) rmSync(bundleDir(old), { recursive: true, force: true });
577
- if (animate) spinner.stop(`${label} downloaded`);
578
- else f2.success(`${label} downloaded`);
579
- return dir;
580
- } catch (error) {
581
- if (animate) spinner.stop("Download failed", 1);
582
- throw error;
583
- } finally {
584
- if (work) rmSync(work, { recursive: true, force: true });
585
- }
586
- }
587
-
588
- // ../cli-core/src/env.ts
589
- init_define_PKG();
590
- import { randomBytes } from "node:crypto";
591
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, appendFileSync, writeFileSync } from "node:fs";
592
- import { isAbsolute, join as join3, resolve as resolve2 } from "node:path";
593
- import { parseEnv } from "node:util";
594
- var DEFAULT_DATABASE_URL = "pglite:./.pglite";
595
- var template = (secret) => `# ShopNex: the settings of this shop. Edit, then start it again.
596
- #
597
- # Where the data lives. The default is an embedded database in ./.pglite (PGlite): one process owns it, for trying
598
- # ShopNex out. For a real database use PostgreSQL, for example:
599
- # DATABASE_URL=postgres://user:password@localhost:5432/shopnex
600
- # (docker-compose.yml runs ShopNex and PostgreSQL in Docker)
601
- DATABASE_URL=${DEFAULT_DATABASE_URL}
602
-
603
- # Encrypts the provider keys saved in the admin and signs sessions. Keep it: a new one logs everyone out and makes the
604
- # saved keys unreadable. Do not share this file.
605
- SHOPNEX_SECRET=${secret}
606
- `;
607
- var resolveDatabaseUrl = (url, shopDir) => {
608
- if (!url.startsWith("pglite:")) return url;
609
- const path = url.slice("pglite:".length);
610
- return isAbsolute(path) ? url : `pglite:${resolve2(shopDir, path)}`;
611
- };
612
- var redactUrl = (url) => url.replace(/\/\/([^:@/]+):[^@/]*@/, "//$1:***@");
613
- function loadShopEnv(shopDir, { write }) {
614
- const file = join3(shopDir, ".env");
615
- const exists = existsSync2(file);
616
- const { DATABASE_URL, SHOPNEX_SECRET, ...rest } = exists ? parseEnv(readFileSync2(file, "utf8")) : {};
617
- const secret = SHOPNEX_SECRET?.trim() || (write ? randomBytes(32).toString("hex") : "");
618
- const databaseUrl = DATABASE_URL?.trim() || DEFAULT_DATABASE_URL;
619
- if (write) {
620
- if (!exists) {
621
- mkdirSync2(shopDir, { recursive: true });
622
- writeFileSync(file, template(secret), { mode: 384 });
623
- } else {
624
- const missing = [
625
- DATABASE_URL?.trim() ? "" : `DATABASE_URL=${DEFAULT_DATABASE_URL}`,
626
- SHOPNEX_SECRET?.trim() ? "" : `SHOPNEX_SECRET=${secret}`
627
- ].filter(Boolean);
628
- if (missing.length)
629
- appendFileSync(file, `${readFileSync2(file, "utf8").endsWith("\n") ? "" : "\n"}${missing.join("\n")}
630
- `);
631
- }
632
- }
633
- return { databaseUrl: resolveDatabaseUrl(databaseUrl, shopDir), secret, rest, file };
634
- }
635
- function switchDatabaseUrl(file, url, now = /* @__PURE__ */ new Date()) {
636
- if (/[\s#"'`]/.test(url)) {
637
- throw new UsageError(
638
- "The database address has a space, #, quote or backtick in it: percent-encode those characters."
639
- );
640
- }
641
- const text = readFileSync2(file, "utf8");
642
- const line = /^[ \t]*DATABASE_URL[ \t]*=.*$/m;
643
- const old = line.exec(text)?.[0].trim();
644
- const stamp2 = now.toISOString().slice(0, 10);
645
- const replacement = `${old ? `# ${redactUrl(old)} (before shopnex migrate-db, ${stamp2})
646
- ` : ""}DATABASE_URL=${url}`;
647
- writeFileSync(
648
- file,
649
- old ? text.replace(line, () => replacement) : `${text}${text.endsWith("\n") ? "" : "\n"}${replacement}
650
- `
651
- );
652
- }
653
-
654
- // ../cli-core/src/ports.ts
655
- init_define_PKG();
656
- import { connect } from "node:net";
657
- function portInUse(port) {
658
- const tryHost = (host) => new Promise((resolve4) => {
659
- const socket = connect({ port, host });
660
- socket.setTimeout(500);
661
- socket.once("connect", () => (socket.destroy(), resolve4(true)));
662
- socket.once("timeout", () => (socket.destroy(), resolve4(false)));
663
- socket.once("error", () => resolve4(false));
664
- });
665
- return Promise.all([tryHost("127.0.0.1"), tryHost("::1")]).then((used) => used.some(Boolean));
666
- }
667
-
668
- // src/run-once.ts
669
- init_define_PKG();
670
- import { spawn } from "node:child_process";
671
- function runOnce({ script, cwd, env }) {
672
- return new Promise((resolve4) => {
673
- const child = spawn(process.execPath, [script], { cwd, env: { ...process.env, ...env }, stdio: "inherit" });
674
- child.on("error", (error) => {
675
- console.error(`Could not start ${script}: ${error.message}`);
676
- resolve4(1);
677
- });
678
- child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
679
- });
680
- }
681
-
682
- // src/migrate-db.ts
683
- function targetUrl({ to, toEnv }) {
684
- if (to === void 0 === (toEnv === void 0)) {
685
- throw new UsageError("Give where to move the data: --to postgres://\u2026 or --to-env NAME (a variable that holds it).");
686
- }
687
- const url = to ?? process.env[toEnv]?.trim();
688
- if (!url) throw new UsageError(`${toEnv} is not set.`);
689
- if (!/^postgres(ql)?:\/\/\S+$/.test(url)) {
690
- throw new UsageError(`The new database must be a postgres:// address, got "${redactUrl(url)}".`);
691
- }
692
- return url;
693
- }
694
- var stamp = (now) => now.toISOString().replace(/[-:]/g, "").replace("T", "-").slice(0, 15);
695
- var appsWithData = (shopDir) => {
696
- const apps = join4(shopDir, "apps");
697
- if (!existsSync3(apps)) return [];
698
- return readdirSync2(apps).filter((name) => existsSync3(join4(apps, name, ".pglite")));
699
- };
700
- async function migrateDb(options2) {
701
- const target = targetUrl(options2);
702
- const shopDir = resolve3(process.cwd(), options2.dir);
703
- if (!existsSync3(join4(shopDir, ".env"))) {
704
- throw new UsageError(
705
- `${shopDir} is not a ShopNex shop (there is no .env in it). Go into the shop's folder, or give it with --dir.`
706
- );
707
- }
708
- const env = loadShopEnv(shopDir, { write: false });
709
- if (!env.databaseUrl.startsWith("pglite:")) {
710
- throw new UsageError(`This shop already uses PostgreSQL (${redactUrl(env.databaseUrl)}): nothing to move.`);
711
- }
712
- const data = env.databaseUrl.slice("pglite:".length);
713
- if (data === "memory" || !existsSync3(data)) {
714
- throw new UsageError(`There is no data to move: ${data} does not exist. Start the shop once first.`);
715
- }
716
- if (await portInUse(options2.port)) {
717
- throw new UsageError(
718
- `Something answers on port ${options2.port}: stop the shop first (Ctrl+C where it runs). If it runs on another port, give it with --port.`
719
- );
720
- }
721
- const root = await resolveBundle({ version: options2.version, cli: "shopnex" });
722
- const script = join4(root, "admin", "migrate-db.mjs");
723
- if (!existsSync3(script)) {
724
- throw new UnavailableError(`ShopNex ${options2.version} cannot move a database yet (its build has no migrate-db).`);
725
- }
726
- const backup = `${data}.bak-${stamp(/* @__PURE__ */ new Date())}`;
727
- cpSync(data, backup, { recursive: true });
728
- f2.info(`A copy of the current data is kept in ${backup} until the move has worked`);
729
- const code = await runOnce({
730
- script,
731
- cwd: join4(root, "admin"),
732
- env: {
733
- SOURCE_DATABASE_URL: env.databaseUrl,
734
- TARGET_DATABASE_URL: target,
735
- SHOPNEX_MIGRATIONS_DIR: join4(root, "migrations")
736
- }
737
- });
738
- if (code !== 0) {
739
- rmSync2(backup, { recursive: true, force: true });
740
- throw new UnavailableError(`Nothing was changed: the shop still uses ${data}.`);
741
- }
742
- switchDatabaseUrl(env.file, target);
743
- const left = appsWithData(shopDir);
744
- if (left.length) {
745
- f2.warn(
746
- `The data of ${left.map((name) => `apps/${name}`).join(", ")} was not moved: those apps start empty on PostgreSQL. Their old files stay in apps/.`
747
- );
748
- }
749
- $e(
750
- `The shop now uses ${redactUrl(target)}. Start it again as before; the old data stays in ${data} as a fallback.`
751
- );
752
- }
753
-
754
- // src/cli.ts
755
- var pkg = typeof define_PKG_default !== "undefined" ? define_PKG_default : JSON.parse(readFileSync3(new URL("../package.json", import.meta.url), "utf8"));
756
- var HELP = `shopnex ${pkg.version}: look after a ShopNex shop made with create-shopnex.
757
-
758
- Usage
759
- shopnex <command> [options]
760
-
761
- Commands
762
- migrate-db move the shop's data from the embedded database to PostgreSQL
763
-
764
- Options
765
- --to <url> migrate-db: the PostgreSQL address, an empty database (postgres://user:password@host:5432/shopnex)
766
- --to-env <NAME> migrate-db: read that address from the environment variable NAME, so the password stays out of
767
- the shell history
768
- --dir <folder> the shop's folder (default: the current folder)
769
- --port <n> the admin's port, to check the shop is stopped (default 3000)
770
- -h, --help this text
771
- -v, --version the version
772
-
773
- Run it in the shop's folder, with the shop stopped. A copy of the old data is kept next to it.
774
- `;
775
- async function run(argv) {
776
- const options2 = parse(argv);
777
- if (options2.version) return void console.log(pkg.version);
778
- if (options2.help || !options2.command) return void console.log(HELP);
779
- if (!COMMANDS.includes(options2.command)) {
780
- throw new UsageError(`Unknown command "${options2.command}". Run shopnex --help.`);
781
- }
782
- assertNode(process.versions.node, pkg.engines.node);
783
- oe(brandBadge(` shopnex ${options2.command} ${pkg.version} `));
784
- await migrateDb({ ...options2, version: pkg.version });
785
- }
786
- async function main(argv) {
787
- try {
788
- await run(argv);
789
- } catch (error) {
790
- if (error instanceof UsageError) {
791
- console.error(error.message);
792
- process.exitCode = 2;
793
- } else if (error instanceof UnavailableError) {
794
- console.error(error.message);
795
- process.exitCode = 1;
796
- } else {
797
- throw error;
798
- }
799
- }
800
- }
801
-
802
- // src/main.ts
803
- await main(process.argv.slice(2));